@kato-lee/cdk 14.2.7
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/LICENSE +21 -0
- package/README.md +8 -0
- package/_index.scss +8 -0
- package/a11y/_index.import.scss +2 -0
- package/a11y/_index.scss +102 -0
- package/a11y/index.d.ts +1212 -0
- package/a11y-prebuilt.css +1 -0
- package/accordion/index.d.ts +140 -0
- package/bidi/index.d.ts +80 -0
- package/clipboard/index.d.ts +115 -0
- package/coercion/index.d.ts +67 -0
- package/collections/index.d.ts +374 -0
- package/dialog/index.d.ts +469 -0
- package/drag-drop/index.d.ts +1614 -0
- package/esm2020/a11y/a11y-module.mjs +32 -0
- package/esm2020/a11y/a11y_public_index.mjs +5 -0
- package/esm2020/a11y/aria-describer/aria-describer.mjs +232 -0
- package/esm2020/a11y/aria-describer/aria-reference.mjs +44 -0
- package/esm2020/a11y/fake-event-detection.mjs +31 -0
- package/esm2020/a11y/focus-monitor/focus-monitor.mjs +451 -0
- package/esm2020/a11y/focus-trap/configurable-focus-trap-config.mjs +9 -0
- package/esm2020/a11y/focus-trap/configurable-focus-trap-factory.mjs +53 -0
- package/esm2020/a11y/focus-trap/configurable-focus-trap.mjs +51 -0
- package/esm2020/a11y/focus-trap/event-listener-inert-strategy.mjs +61 -0
- package/esm2020/a11y/focus-trap/focus-trap-inert-strategy.mjs +11 -0
- package/esm2020/a11y/focus-trap/focus-trap-manager.mjs +53 -0
- package/esm2020/a11y/focus-trap/focus-trap.mjs +402 -0
- package/esm2020/a11y/high-contrast-mode/high-contrast-mode-detector.mjs +109 -0
- package/esm2020/a11y/index.mjs +9 -0
- package/esm2020/a11y/input-modality/input-modality-detector.mjs +176 -0
- package/esm2020/a11y/interactivity-checker/interactivity-checker.mjs +238 -0
- package/esm2020/a11y/key-manager/activedescendant-key-manager.mjs +20 -0
- package/esm2020/a11y/key-manager/focus-key-manager.mjs +29 -0
- package/esm2020/a11y/key-manager/list-key-manager.mjs +321 -0
- package/esm2020/a11y/live-announcer/live-announcer-tokens.mjs +19 -0
- package/esm2020/a11y/live-announcer/live-announcer.mjs +178 -0
- package/esm2020/a11y/public-api.mjs +26 -0
- package/esm2020/accordion/accordion-item.mjs +167 -0
- package/esm2020/accordion/accordion-module.mjs +24 -0
- package/esm2020/accordion/accordion.mjs +70 -0
- package/esm2020/accordion/accordion_public_index.mjs +5 -0
- package/esm2020/accordion/index.mjs +9 -0
- package/esm2020/accordion/public-api.mjs +11 -0
- package/esm2020/bidi/bidi-module.mjs +23 -0
- package/esm2020/bidi/bidi_public_index.mjs +5 -0
- package/esm2020/bidi/dir-document-token.mjs +33 -0
- package/esm2020/bidi/dir.mjs +69 -0
- package/esm2020/bidi/directionality.mjs +52 -0
- package/esm2020/bidi/index.mjs +9 -0
- package/esm2020/bidi/public-api.mjs +12 -0
- package/esm2020/clipboard/clipboard-module.mjs +23 -0
- package/esm2020/clipboard/clipboard.mjs +53 -0
- package/esm2020/clipboard/clipboard_public_index.mjs +5 -0
- package/esm2020/clipboard/copy-to-clipboard.mjs +99 -0
- package/esm2020/clipboard/index.mjs +9 -0
- package/esm2020/clipboard/pending-copy.mjs +69 -0
- package/esm2020/clipboard/public-api.mjs +12 -0
- package/esm2020/coercion/array.mjs +11 -0
- package/esm2020/coercion/boolean-property.mjs +12 -0
- package/esm2020/coercion/css-pixel-value.mjs +15 -0
- package/esm2020/coercion/element.mjs +16 -0
- package/esm2020/coercion/index.mjs +9 -0
- package/esm2020/coercion/number-property.mjs +21 -0
- package/esm2020/coercion/public-api.mjs +14 -0
- package/esm2020/coercion/string-array.mjs +38 -0
- package/esm2020/collections/array-data-source.mjs +21 -0
- package/esm2020/collections/collection-viewer.mjs +9 -0
- package/esm2020/collections/collections_public_index.mjs +5 -0
- package/esm2020/collections/data-source.mjs +19 -0
- package/esm2020/collections/dispose-view-repeater-strategy.mjs +47 -0
- package/esm2020/collections/index.mjs +9 -0
- package/esm2020/collections/public-api.mjs +17 -0
- package/esm2020/collections/recycle-view-repeater-strategy.mjs +128 -0
- package/esm2020/collections/selection-model.mjs +216 -0
- package/esm2020/collections/tree-adapter.mjs +9 -0
- package/esm2020/collections/unique-selection-dispatcher.mjs +55 -0
- package/esm2020/collections/view-repeater.mjs +14 -0
- package/esm2020/dialog/dialog-config.mjs +63 -0
- package/esm2020/dialog/dialog-container.mjs +278 -0
- package/esm2020/dialog/dialog-injectors.mjs +26 -0
- package/esm2020/dialog/dialog-module.mjs +42 -0
- package/esm2020/dialog/dialog-ref.mjs +76 -0
- package/esm2020/dialog/dialog.mjs +301 -0
- package/esm2020/dialog/dialog_public_index.mjs +5 -0
- package/esm2020/dialog/index.mjs +9 -0
- package/esm2020/dialog/public-api.mjs +14 -0
- package/esm2020/drag-drop/directives/assertions.mjs +18 -0
- package/esm2020/drag-drop/directives/config.mjs +14 -0
- package/esm2020/drag-drop/directives/drag-handle.mjs +66 -0
- package/esm2020/drag-drop/directives/drag-placeholder.mjs +36 -0
- package/esm2020/drag-drop/directives/drag-preview.mjs +47 -0
- package/esm2020/drag-drop/directives/drag.mjs +487 -0
- package/esm2020/drag-drop/directives/drop-list-group.mjs +53 -0
- package/esm2020/drag-drop/directives/drop-list.mjs +345 -0
- package/esm2020/drag-drop/dom/client-rect.mjs +64 -0
- package/esm2020/drag-drop/dom/clone-node.mjs +65 -0
- package/esm2020/drag-drop/dom/parent-position-tracker.mjs +76 -0
- package/esm2020/drag-drop/dom/styling.mjs +69 -0
- package/esm2020/drag-drop/dom/transition-duration.mjs +36 -0
- package/esm2020/drag-drop/drag-drop-module.mjs +57 -0
- package/esm2020/drag-drop/drag-drop-registry.mjs +231 -0
- package/esm2020/drag-drop/drag-drop.mjs +57 -0
- package/esm2020/drag-drop/drag-drop_public_index.mjs +5 -0
- package/esm2020/drag-drop/drag-events.mjs +9 -0
- package/esm2020/drag-drop/drag-parent.mjs +16 -0
- package/esm2020/drag-drop/drag-ref.mjs +1146 -0
- package/esm2020/drag-drop/drag-utils.mjs +60 -0
- package/esm2020/drag-drop/drop-list-ref.mjs +577 -0
- package/esm2020/drag-drop/index.mjs +9 -0
- package/esm2020/drag-drop/public-api.mjs +23 -0
- package/esm2020/drag-drop/sorting/drop-list-sort-strategy.mjs +9 -0
- package/esm2020/drag-drop/sorting/single-axis-sort-strategy.mjs +341 -0
- package/esm2020/index.mjs +9 -0
- package/esm2020/keycodes/index.mjs +9 -0
- package/esm2020/keycodes/keycodes.mjs +127 -0
- package/esm2020/keycodes/keycodes_public_index.mjs +5 -0
- package/esm2020/keycodes/modifiers.mjs +18 -0
- package/esm2020/keycodes/public-api.mjs +10 -0
- package/esm2020/layout/breakpoints-observer.mjs +105 -0
- package/esm2020/layout/breakpoints.mjs +29 -0
- package/esm2020/layout/index.mjs +9 -0
- package/esm2020/layout/layout-module.mjs +19 -0
- package/esm2020/layout/layout_public_index.mjs +5 -0
- package/esm2020/layout/media-matcher.mjs +85 -0
- package/esm2020/layout/public-api.mjs +12 -0
- package/esm2020/listbox/index.mjs +9 -0
- package/esm2020/listbox/listbox-module.mjs +24 -0
- package/esm2020/listbox/listbox.mjs +872 -0
- package/esm2020/listbox/listbox_public_index.mjs +5 -0
- package/esm2020/listbox/public-api.mjs +10 -0
- package/esm2020/menu/context-menu-trigger.mjs +212 -0
- package/esm2020/menu/index.mjs +9 -0
- package/esm2020/menu/menu-aim.mjs +203 -0
- package/esm2020/menu/menu-bar.mjs +133 -0
- package/esm2020/menu/menu-base.mjs +187 -0
- package/esm2020/menu/menu-errors.mjs +22 -0
- package/esm2020/menu/menu-group.mjs +30 -0
- package/esm2020/menu/menu-interface.mjs +11 -0
- package/esm2020/menu/menu-item-checkbox.mjs +49 -0
- package/esm2020/menu/menu-item-radio.mjs +71 -0
- package/esm2020/menu/menu-item-selectable.mjs +42 -0
- package/esm2020/menu/menu-item.mjs +267 -0
- package/esm2020/menu/menu-module.mjs +62 -0
- package/esm2020/menu/menu-stack.mjs +156 -0
- package/esm2020/menu/menu-trigger-base.mjs +107 -0
- package/esm2020/menu/menu-trigger.mjs +291 -0
- package/esm2020/menu/menu.mjs +134 -0
- package/esm2020/menu/menu_public_index.mjs +5 -0
- package/esm2020/menu/pointer-focus-tracker.mjs +51 -0
- package/esm2020/menu/public-api.mjs +24 -0
- package/esm2020/observers/index.mjs +9 -0
- package/esm2020/observers/observe-content.mjs +187 -0
- package/esm2020/observers/observers_public_index.mjs +5 -0
- package/esm2020/observers/public-api.mjs +9 -0
- package/esm2020/overlay/dispatchers/base-overlay-dispatcher.mjs +52 -0
- package/esm2020/overlay/dispatchers/index.mjs +10 -0
- package/esm2020/overlay/dispatchers/overlay-keyboard-dispatcher.mjs +81 -0
- package/esm2020/overlay/dispatchers/overlay-outside-click-dispatcher.mjs +138 -0
- package/esm2020/overlay/fullscreen-overlay-container.mjs +94 -0
- package/esm2020/overlay/index.mjs +9 -0
- package/esm2020/overlay/overlay-config.mjs +45 -0
- package/esm2020/overlay/overlay-container.mjs +81 -0
- package/esm2020/overlay/overlay-directives.mjs +427 -0
- package/esm2020/overlay/overlay-module.mjs +29 -0
- package/esm2020/overlay/overlay-ref.mjs +427 -0
- package/esm2020/overlay/overlay-reference.mjs +9 -0
- package/esm2020/overlay/overlay.mjs +125 -0
- package/esm2020/overlay/overlay_public_index.mjs +5 -0
- package/esm2020/overlay/position/connected-position.mjs +88 -0
- package/esm2020/overlay/position/flexible-connected-position-strategy.mjs +985 -0
- package/esm2020/overlay/position/global-position-strategy.mjs +237 -0
- package/esm2020/overlay/position/overlay-position-builder.mjs +50 -0
- package/esm2020/overlay/position/position-strategy.mjs +9 -0
- package/esm2020/overlay/position/scroll-clip.mjs +40 -0
- package/esm2020/overlay/public-api.mjs +22 -0
- package/esm2020/overlay/scroll/block-scroll-strategy.mjs +80 -0
- package/esm2020/overlay/scroll/close-scroll-strategy.mjs +61 -0
- package/esm2020/overlay/scroll/index.mjs +14 -0
- package/esm2020/overlay/scroll/noop-scroll-strategy.mjs +17 -0
- package/esm2020/overlay/scroll/reposition-scroll-strategy.mjs +61 -0
- package/esm2020/overlay/scroll/scroll-strategy-options.mjs +55 -0
- package/esm2020/overlay/scroll/scroll-strategy.mjs +14 -0
- package/esm2020/platform/features/input-types.mjs +59 -0
- package/esm2020/platform/features/passive-listeners.mjs +36 -0
- package/esm2020/platform/features/scrolling.mjs +85 -0
- package/esm2020/platform/features/shadow-dom.mjs +54 -0
- package/esm2020/platform/features/test-environment.mjs +24 -0
- package/esm2020/platform/index.mjs +9 -0
- package/esm2020/platform/platform-module.mjs +19 -0
- package/esm2020/platform/platform.mjs +85 -0
- package/esm2020/platform/platform_public_index.mjs +5 -0
- package/esm2020/platform/public-api.mjs +15 -0
- package/esm2020/portal/dom-portal-outlet.mjs +158 -0
- package/esm2020/portal/index.mjs +9 -0
- package/esm2020/portal/portal-directives.mjs +246 -0
- package/esm2020/portal/portal-errors.mjs +51 -0
- package/esm2020/portal/portal-injector.mjs +28 -0
- package/esm2020/portal/portal.mjs +188 -0
- package/esm2020/portal/portal_public_index.mjs +5 -0
- package/esm2020/portal/public-api.mjs +12 -0
- package/esm2020/public-api.mjs +9 -0
- package/esm2020/scrolling/fixed-size-virtual-scroll.mjs +217 -0
- package/esm2020/scrolling/index.mjs +9 -0
- package/esm2020/scrolling/public-api.mjs +20 -0
- package/esm2020/scrolling/scroll-dispatcher.mjs +163 -0
- package/esm2020/scrolling/scrollable.mjs +176 -0
- package/esm2020/scrolling/scrolling-module.mjs +67 -0
- package/esm2020/scrolling/scrolling_public_index.mjs +5 -0
- package/esm2020/scrolling/viewport-ruler.mjs +146 -0
- package/esm2020/scrolling/virtual-for-of.mjs +298 -0
- package/esm2020/scrolling/virtual-scroll-repeater.mjs +9 -0
- package/esm2020/scrolling/virtual-scroll-strategy.mjs +11 -0
- package/esm2020/scrolling/virtual-scroll-viewport.mjs +437 -0
- package/esm2020/scrolling/virtual-scrollable-element.mjs +41 -0
- package/esm2020/scrolling/virtual-scrollable-window.mjs +40 -0
- package/esm2020/scrolling/virtual-scrollable.mjs +40 -0
- package/esm2020/stepper/index.mjs +9 -0
- package/esm2020/stepper/public-api.mjs +13 -0
- package/esm2020/stepper/step-header.mjs +30 -0
- package/esm2020/stepper/step-label.mjs +23 -0
- package/esm2020/stepper/stepper-button.mjs +56 -0
- package/esm2020/stepper/stepper-module.mjs +40 -0
- package/esm2020/stepper/stepper.mjs +458 -0
- package/esm2020/stepper/stepper_public_index.mjs +5 -0
- package/esm2020/table/can-stick.mjs +44 -0
- package/esm2020/table/cell.mjs +217 -0
- package/esm2020/table/coalesced-style-scheduler.mjs +91 -0
- package/esm2020/table/index.mjs +9 -0
- package/esm2020/table/public-api.mjs +20 -0
- package/esm2020/table/row.mjs +262 -0
- package/esm2020/table/sticky-position-listener.mjs +11 -0
- package/esm2020/table/sticky-styler.mjs +345 -0
- package/esm2020/table/table-errors.mjs +67 -0
- package/esm2020/table/table-module.mjs +94 -0
- package/esm2020/table/table.mjs +1065 -0
- package/esm2020/table/table_public_index.mjs +5 -0
- package/esm2020/table/text-column.mjs +153 -0
- package/esm2020/table/tokens.mjs +16 -0
- package/esm2020/text-field/autofill.mjs +113 -0
- package/esm2020/text-field/autosize.mjs +309 -0
- package/esm2020/text-field/index.mjs +9 -0
- package/esm2020/text-field/public-api.mjs +11 -0
- package/esm2020/text-field/text-field-module.mjs +24 -0
- package/esm2020/text-field/text-field_public_index.mjs +5 -0
- package/esm2020/tree/control/base-tree-control.mjs +57 -0
- package/esm2020/tree/control/flat-tree-control.mjs +51 -0
- package/esm2020/tree/control/nested-tree-control.mjs +58 -0
- package/esm2020/tree/control/tree-control.mjs +2 -0
- package/esm2020/tree/index.mjs +9 -0
- package/esm2020/tree/nested-node.mjs +112 -0
- package/esm2020/tree/node.mjs +35 -0
- package/esm2020/tree/outlet.mjs +39 -0
- package/esm2020/tree/padding.mjs +131 -0
- package/esm2020/tree/public-api.mjs +20 -0
- package/esm2020/tree/toggle.mjs +50 -0
- package/esm2020/tree/tree-errors.mjs +43 -0
- package/esm2020/tree/tree-module.mjs +49 -0
- package/esm2020/tree/tree.mjs +347 -0
- package/esm2020/tree/tree_public_index.mjs +5 -0
- package/esm2020/version.mjs +11 -0
- package/fesm2015/a11y.mjs +2473 -0
- package/fesm2015/a11y.mjs.map +1 -0
- package/fesm2015/accordion.mjs +414 -0
- package/fesm2015/accordion.mjs.map +1 -0
- package/fesm2015/bidi.mjs +194 -0
- package/fesm2015/bidi.mjs.map +1 -0
- package/fesm2015/cdk.mjs +30 -0
- package/fesm2015/cdk.mjs.map +1 -0
- package/fesm2015/clipboard.mjs +263 -0
- package/fesm2015/clipboard.mjs.map +1 -0
- package/fesm2015/coercion.mjs +132 -0
- package/fesm2015/coercion.mjs.map +1 -0
- package/fesm2015/collections.mjs +519 -0
- package/fesm2015/collections.mjs.map +1 -0
- package/fesm2015/dialog.mjs +1050 -0
- package/fesm2015/dialog.mjs.map +1 -0
- package/fesm2015/drag-drop.mjs +3812 -0
- package/fesm2015/drag-drop.mjs.map +1 -0
- package/fesm2015/keycodes.mjs +167 -0
- package/fesm2015/keycodes.mjs.map +1 -0
- package/fesm2015/layout.mjs +337 -0
- package/fesm2015/layout.mjs.map +1 -0
- package/fesm2015/listbox.mjs +1200 -0
- package/fesm2015/listbox.mjs.map +1 -0
- package/fesm2015/menu.mjs +2719 -0
- package/fesm2015/menu.mjs.map +1 -0
- package/fesm2015/observers.mjs +326 -0
- package/fesm2015/observers.mjs.map +1 -0
- package/fesm2015/overlay.mjs +3137 -0
- package/fesm2015/overlay.mjs.map +1 -0
- package/fesm2015/platform.mjs +385 -0
- package/fesm2015/platform.mjs.map +1 -0
- package/fesm2015/portal.mjs +691 -0
- package/fesm2015/portal.mjs.map +1 -0
- package/fesm2015/scrolling.mjs +1558 -0
- package/fesm2015/scrolling.mjs.map +1 -0
- package/fesm2015/stepper.mjs +989 -0
- package/fesm2015/stepper.mjs.map +1 -0
- package/fesm2015/table.mjs +2356 -0
- package/fesm2015/table.mjs.map +1 -0
- package/fesm2015/testing.mjs +833 -0
- package/fesm2015/testing.mjs.map +1 -0
- package/fesm2015/text-field.mjs +461 -0
- package/fesm2015/text-field.mjs.map +1 -0
- package/fesm2015/tree.mjs +1303 -0
- package/fesm2015/tree.mjs.map +1 -0
- package/fesm2020/a11y.mjs +2476 -0
- package/fesm2020/a11y.mjs.map +1 -0
- package/fesm2020/accordion.mjs +414 -0
- package/fesm2020/accordion.mjs.map +1 -0
- package/fesm2020/bidi.mjs +192 -0
- package/fesm2020/bidi.mjs.map +1 -0
- package/fesm2020/cdk.mjs +30 -0
- package/fesm2020/cdk.mjs.map +1 -0
- package/fesm2020/clipboard.mjs +259 -0
- package/fesm2020/clipboard.mjs.map +1 -0
- package/fesm2020/coercion.mjs +132 -0
- package/fesm2020/coercion.mjs.map +1 -0
- package/fesm2020/collections.mjs +535 -0
- package/fesm2020/collections.mjs.map +1 -0
- package/fesm2020/dialog.mjs +787 -0
- package/fesm2020/dialog.mjs.map +1 -0
- package/fesm2020/drag-drop.mjs +3808 -0
- package/fesm2020/drag-drop.mjs.map +1 -0
- package/fesm2020/keycodes.mjs +167 -0
- package/fesm2020/keycodes.mjs.map +1 -0
- package/fesm2020/layout.mjs +337 -0
- package/fesm2020/layout.mjs.map +1 -0
- package/fesm2020/listbox.mjs +1164 -0
- package/fesm2020/listbox.mjs.map +1 -0
- package/fesm2020/menu.mjs +2615 -0
- package/fesm2020/menu.mjs.map +1 -0
- package/fesm2020/observers.mjs +325 -0
- package/fesm2020/observers.mjs.map +1 -0
- package/fesm2020/overlay.mjs +3145 -0
- package/fesm2020/overlay.mjs.map +1 -0
- package/fesm2020/platform.mjs +383 -0
- package/fesm2020/platform.mjs.map +1 -0
- package/fesm2020/portal.mjs +689 -0
- package/fesm2020/portal.mjs.map +1 -0
- package/fesm2020/scrolling.mjs +1591 -0
- package/fesm2020/scrolling.mjs.map +1 -0
- package/fesm2020/stepper.mjs +985 -0
- package/fesm2020/stepper.mjs.map +1 -0
- package/fesm2020/table.mjs +2348 -0
- package/fesm2020/table.mjs.map +1 -0
- package/fesm2020/testing.mjs +797 -0
- package/fesm2020/testing.mjs.map +1 -0
- package/fesm2020/text-field.mjs +459 -0
- package/fesm2020/text-field.mjs.map +1 -0
- package/fesm2020/tree.mjs +1305 -0
- package/fesm2020/tree.mjs.map +1 -0
- package/index.d.ts +6 -0
- package/keycodes/index.d.ts +249 -0
- package/layout/index.d.ts +90 -0
- package/listbox/index.d.ts +419 -0
- package/menu/index.d.ts +1013 -0
- package/observers/index.d.ts +109 -0
- package/overlay/_index-deprecated.scss +13 -0
- package/overlay/_index.import.scss +13 -0
- package/overlay/_index.scss +152 -0
- package/overlay/index.d.ts +1343 -0
- package/overlay-prebuilt.css +1 -0
- package/package.json +232 -0
- package/platform/index.d.ts +106 -0
- package/portal/index.d.ts +328 -0
- package/scrolling/index.d.ts +849 -0
- package/stepper/index.d.ts +419 -0
- package/table/index.d.ts +1483 -0
- package/text-field/_index.import.scss +2 -0
- package/text-field/_index.scss +89 -0
- package/text-field/index.d.ts +203 -0
- package/text-field-prebuilt.css +1 -0
- package/tree/index.d.ts +593 -0
|
@@ -0,0 +1,1303 @@
|
|
|
1
|
+
import { SelectionModel, isDataSource } from '@kato-lee/cdk/collections';
|
|
2
|
+
import { isObservable, Subject, BehaviorSubject, of } from 'rxjs';
|
|
3
|
+
import { take, filter, takeUntil } from 'rxjs/operators';
|
|
4
|
+
import * as i0 from '@angular/core';
|
|
5
|
+
import {
|
|
6
|
+
InjectionToken,
|
|
7
|
+
Directive,
|
|
8
|
+
Inject,
|
|
9
|
+
Optional,
|
|
10
|
+
Component,
|
|
11
|
+
ViewEncapsulation,
|
|
12
|
+
ChangeDetectionStrategy,
|
|
13
|
+
Input,
|
|
14
|
+
ViewChild,
|
|
15
|
+
ContentChildren,
|
|
16
|
+
NgModule,
|
|
17
|
+
} from '@angular/core';
|
|
18
|
+
import { coerceNumberProperty, coerceBooleanProperty } from '@kato-lee/cdk/coercion';
|
|
19
|
+
import * as i2 from '@kato-lee/cdk/bidi';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @license
|
|
23
|
+
* Copyright Google LLC All Rights Reserved.
|
|
24
|
+
*
|
|
25
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
26
|
+
* found in the LICENSE file at https://angular.io/license
|
|
27
|
+
*/
|
|
28
|
+
/** Base tree control. It has basic toggle/expand/collapse operations on a single data node. */
|
|
29
|
+
class BaseTreeControl {
|
|
30
|
+
constructor() {
|
|
31
|
+
/** A selection model with multi-selection to track expansion status. */
|
|
32
|
+
this.expansionModel = new SelectionModel(true);
|
|
33
|
+
}
|
|
34
|
+
/** Toggles one single data node's expanded/collapsed state. */
|
|
35
|
+
toggle(dataNode) {
|
|
36
|
+
this.expansionModel.toggle(this._trackByValue(dataNode));
|
|
37
|
+
}
|
|
38
|
+
/** Expands one single data node. */
|
|
39
|
+
expand(dataNode) {
|
|
40
|
+
this.expansionModel.select(this._trackByValue(dataNode));
|
|
41
|
+
}
|
|
42
|
+
/** Collapses one single data node. */
|
|
43
|
+
collapse(dataNode) {
|
|
44
|
+
this.expansionModel.deselect(this._trackByValue(dataNode));
|
|
45
|
+
}
|
|
46
|
+
/** Whether a given data node is expanded or not. Returns true if the data node is expanded. */
|
|
47
|
+
isExpanded(dataNode) {
|
|
48
|
+
return this.expansionModel.isSelected(this._trackByValue(dataNode));
|
|
49
|
+
}
|
|
50
|
+
/** Toggles a subtree rooted at `node` recursively. */
|
|
51
|
+
toggleDescendants(dataNode) {
|
|
52
|
+
this.expansionModel.isSelected(this._trackByValue(dataNode))
|
|
53
|
+
? this.collapseDescendants(dataNode)
|
|
54
|
+
: this.expandDescendants(dataNode);
|
|
55
|
+
}
|
|
56
|
+
/** Collapse all dataNodes in the tree. */
|
|
57
|
+
collapseAll() {
|
|
58
|
+
this.expansionModel.clear();
|
|
59
|
+
}
|
|
60
|
+
/** Expands a subtree rooted at given data node recursively. */
|
|
61
|
+
expandDescendants(dataNode) {
|
|
62
|
+
let toBeProcessed = [dataNode];
|
|
63
|
+
toBeProcessed.push(...this.getDescendants(dataNode));
|
|
64
|
+
this.expansionModel.select(...toBeProcessed.map(value => this._trackByValue(value)));
|
|
65
|
+
}
|
|
66
|
+
/** Collapses a subtree rooted at given data node recursively. */
|
|
67
|
+
collapseDescendants(dataNode) {
|
|
68
|
+
let toBeProcessed = [dataNode];
|
|
69
|
+
toBeProcessed.push(...this.getDescendants(dataNode));
|
|
70
|
+
this.expansionModel.deselect(...toBeProcessed.map(value => this._trackByValue(value)));
|
|
71
|
+
}
|
|
72
|
+
_trackByValue(value) {
|
|
73
|
+
return this.trackBy ? this.trackBy(value) : value;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* @license
|
|
79
|
+
* Copyright Google LLC All Rights Reserved.
|
|
80
|
+
*
|
|
81
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
82
|
+
* found in the LICENSE file at https://angular.io/license
|
|
83
|
+
*/
|
|
84
|
+
/** Flat tree control. Able to expand/collapse a subtree recursively for flattened tree. */
|
|
85
|
+
class FlatTreeControl extends BaseTreeControl {
|
|
86
|
+
/** Construct with flat tree data node functions getLevel and isExpandable. */
|
|
87
|
+
constructor(getLevel, isExpandable, options) {
|
|
88
|
+
super();
|
|
89
|
+
this.getLevel = getLevel;
|
|
90
|
+
this.isExpandable = isExpandable;
|
|
91
|
+
this.options = options;
|
|
92
|
+
if (this.options) {
|
|
93
|
+
this.trackBy = this.options.trackBy;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Gets a list of the data node's subtree of descendent data nodes.
|
|
98
|
+
*
|
|
99
|
+
* To make this working, the `dataNodes` of the TreeControl must be flattened tree nodes
|
|
100
|
+
* with correct levels.
|
|
101
|
+
*/
|
|
102
|
+
getDescendants(dataNode) {
|
|
103
|
+
const startIndex = this.dataNodes.indexOf(dataNode);
|
|
104
|
+
const results = [];
|
|
105
|
+
// Goes through flattened tree nodes in the `dataNodes` array, and get all descendants.
|
|
106
|
+
// The level of descendants of a tree node must be greater than the level of the given
|
|
107
|
+
// tree node.
|
|
108
|
+
// If we reach a node whose level is equal to the level of the tree node, we hit a sibling.
|
|
109
|
+
// If we reach a node whose level is greater than the level of the tree node, we hit a
|
|
110
|
+
// sibling of an ancestor.
|
|
111
|
+
for (
|
|
112
|
+
let i = startIndex + 1;
|
|
113
|
+
i < this.dataNodes.length && this.getLevel(dataNode) < this.getLevel(this.dataNodes[i]);
|
|
114
|
+
i++
|
|
115
|
+
) {
|
|
116
|
+
results.push(this.dataNodes[i]);
|
|
117
|
+
}
|
|
118
|
+
return results;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Expands all data nodes in the tree.
|
|
122
|
+
*
|
|
123
|
+
* To make this working, the `dataNodes` variable of the TreeControl must be set to all flattened
|
|
124
|
+
* data nodes of the tree.
|
|
125
|
+
*/
|
|
126
|
+
expandAll() {
|
|
127
|
+
this.expansionModel.select(...this.dataNodes.map(node => this._trackByValue(node)));
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* @license
|
|
133
|
+
* Copyright Google LLC All Rights Reserved.
|
|
134
|
+
*
|
|
135
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
136
|
+
* found in the LICENSE file at https://angular.io/license
|
|
137
|
+
*/
|
|
138
|
+
/** Nested tree control. Able to expand/collapse a subtree recursively for NestedNode type. */
|
|
139
|
+
class NestedTreeControl extends BaseTreeControl {
|
|
140
|
+
/** Construct with nested tree function getChildren. */
|
|
141
|
+
constructor(getChildren, options) {
|
|
142
|
+
super();
|
|
143
|
+
this.getChildren = getChildren;
|
|
144
|
+
this.options = options;
|
|
145
|
+
if (this.options) {
|
|
146
|
+
this.trackBy = this.options.trackBy;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Expands all dataNodes in the tree.
|
|
151
|
+
*
|
|
152
|
+
* To make this working, the `dataNodes` variable of the TreeControl must be set to all root level
|
|
153
|
+
* data nodes of the tree.
|
|
154
|
+
*/
|
|
155
|
+
expandAll() {
|
|
156
|
+
this.expansionModel.clear();
|
|
157
|
+
const allNodes = this.dataNodes.reduce(
|
|
158
|
+
(accumulator, dataNode) => [...accumulator, ...this.getDescendants(dataNode), dataNode],
|
|
159
|
+
[]
|
|
160
|
+
);
|
|
161
|
+
this.expansionModel.select(...allNodes.map(node => this._trackByValue(node)));
|
|
162
|
+
}
|
|
163
|
+
/** Gets a list of descendant dataNodes of a subtree rooted at given data node recursively. */
|
|
164
|
+
getDescendants(dataNode) {
|
|
165
|
+
const descendants = [];
|
|
166
|
+
this._getDescendants(descendants, dataNode);
|
|
167
|
+
// Remove the node itself
|
|
168
|
+
return descendants.splice(1);
|
|
169
|
+
}
|
|
170
|
+
/** A helper function to get descendants recursively. */
|
|
171
|
+
_getDescendants(descendants, dataNode) {
|
|
172
|
+
descendants.push(dataNode);
|
|
173
|
+
const childrenNodes = this.getChildren(dataNode);
|
|
174
|
+
if (Array.isArray(childrenNodes)) {
|
|
175
|
+
childrenNodes.forEach(child => this._getDescendants(descendants, child));
|
|
176
|
+
} else if (isObservable(childrenNodes)) {
|
|
177
|
+
// TypeScript as of version 3.5 doesn't seem to treat `Boolean` like a function that
|
|
178
|
+
// returns a `boolean` specifically in the context of `filter`, so we manually clarify that.
|
|
179
|
+
childrenNodes.pipe(take(1), filter(Boolean)).subscribe(children => {
|
|
180
|
+
for (const child of children) {
|
|
181
|
+
this._getDescendants(descendants, child);
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* @license
|
|
190
|
+
* Copyright Google LLC All Rights Reserved.
|
|
191
|
+
*
|
|
192
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
193
|
+
* found in the LICENSE file at https://angular.io/license
|
|
194
|
+
*/
|
|
195
|
+
/**
|
|
196
|
+
* Injection token used to provide a `CdkTreeNode` to its outlet.
|
|
197
|
+
* Used primarily to avoid circular imports.
|
|
198
|
+
* @docs-private
|
|
199
|
+
*/
|
|
200
|
+
const CDK_TREE_NODE_OUTLET_NODE = new InjectionToken('CDK_TREE_NODE_OUTLET_NODE');
|
|
201
|
+
/**
|
|
202
|
+
* Outlet for nested CdkNode. Put `[cdkTreeNodeOutlet]` on a tag to place children dataNodes
|
|
203
|
+
* inside the outlet.
|
|
204
|
+
*/
|
|
205
|
+
class CdkTreeNodeOutlet {
|
|
206
|
+
constructor(viewContainer, _node) {
|
|
207
|
+
this.viewContainer = viewContainer;
|
|
208
|
+
this._node = _node;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
CdkTreeNodeOutlet.ɵfac = i0.ɵɵngDeclareFactory({
|
|
212
|
+
minVersion: '12.0.0',
|
|
213
|
+
version: '14.2.0',
|
|
214
|
+
ngImport: i0,
|
|
215
|
+
type: CdkTreeNodeOutlet,
|
|
216
|
+
deps: [{ token: i0.ViewContainerRef }, { token: CDK_TREE_NODE_OUTLET_NODE, optional: true }],
|
|
217
|
+
target: i0.ɵɵFactoryTarget.Directive,
|
|
218
|
+
});
|
|
219
|
+
CdkTreeNodeOutlet.ɵdir = i0.ɵɵngDeclareDirective({
|
|
220
|
+
minVersion: '14.0.0',
|
|
221
|
+
version: '14.2.0',
|
|
222
|
+
type: CdkTreeNodeOutlet,
|
|
223
|
+
selector: '[cdkTreeNodeOutlet]',
|
|
224
|
+
ngImport: i0,
|
|
225
|
+
});
|
|
226
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
227
|
+
minVersion: '12.0.0',
|
|
228
|
+
version: '14.2.0',
|
|
229
|
+
ngImport: i0,
|
|
230
|
+
type: CdkTreeNodeOutlet,
|
|
231
|
+
decorators: [
|
|
232
|
+
{
|
|
233
|
+
type: Directive,
|
|
234
|
+
args: [
|
|
235
|
+
{
|
|
236
|
+
selector: '[cdkTreeNodeOutlet]',
|
|
237
|
+
},
|
|
238
|
+
],
|
|
239
|
+
},
|
|
240
|
+
],
|
|
241
|
+
ctorParameters: function () {
|
|
242
|
+
return [
|
|
243
|
+
{ type: i0.ViewContainerRef },
|
|
244
|
+
{
|
|
245
|
+
type: undefined,
|
|
246
|
+
decorators: [
|
|
247
|
+
{
|
|
248
|
+
type: Inject,
|
|
249
|
+
args: [CDK_TREE_NODE_OUTLET_NODE],
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
type: Optional,
|
|
253
|
+
},
|
|
254
|
+
],
|
|
255
|
+
},
|
|
256
|
+
];
|
|
257
|
+
},
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* @license
|
|
262
|
+
* Copyright Google LLC All Rights Reserved.
|
|
263
|
+
*
|
|
264
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
265
|
+
* found in the LICENSE file at https://angular.io/license
|
|
266
|
+
*/
|
|
267
|
+
/** Context provided to the tree node component. */
|
|
268
|
+
class CdkTreeNodeOutletContext {
|
|
269
|
+
constructor(data) {
|
|
270
|
+
this.$implicit = data;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Data node definition for the CdkTree.
|
|
275
|
+
* Captures the node's template and a when predicate that describes when this node should be used.
|
|
276
|
+
*/
|
|
277
|
+
class CdkTreeNodeDef {
|
|
278
|
+
/** @docs-private */
|
|
279
|
+
constructor(template) {
|
|
280
|
+
this.template = template;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
CdkTreeNodeDef.ɵfac = i0.ɵɵngDeclareFactory({
|
|
284
|
+
minVersion: '12.0.0',
|
|
285
|
+
version: '14.2.0',
|
|
286
|
+
ngImport: i0,
|
|
287
|
+
type: CdkTreeNodeDef,
|
|
288
|
+
deps: [{ token: i0.TemplateRef }],
|
|
289
|
+
target: i0.ɵɵFactoryTarget.Directive,
|
|
290
|
+
});
|
|
291
|
+
CdkTreeNodeDef.ɵdir = i0.ɵɵngDeclareDirective({
|
|
292
|
+
minVersion: '14.0.0',
|
|
293
|
+
version: '14.2.0',
|
|
294
|
+
type: CdkTreeNodeDef,
|
|
295
|
+
selector: '[cdkTreeNodeDef]',
|
|
296
|
+
inputs: { when: ['cdkTreeNodeDefWhen', 'when'] },
|
|
297
|
+
ngImport: i0,
|
|
298
|
+
});
|
|
299
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
300
|
+
minVersion: '12.0.0',
|
|
301
|
+
version: '14.2.0',
|
|
302
|
+
ngImport: i0,
|
|
303
|
+
type: CdkTreeNodeDef,
|
|
304
|
+
decorators: [
|
|
305
|
+
{
|
|
306
|
+
type: Directive,
|
|
307
|
+
args: [
|
|
308
|
+
{
|
|
309
|
+
selector: '[cdkTreeNodeDef]',
|
|
310
|
+
inputs: ['when: cdkTreeNodeDefWhen'],
|
|
311
|
+
},
|
|
312
|
+
],
|
|
313
|
+
},
|
|
314
|
+
],
|
|
315
|
+
ctorParameters: function () {
|
|
316
|
+
return [{ type: i0.TemplateRef }];
|
|
317
|
+
},
|
|
318
|
+
});
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* @license
|
|
322
|
+
* Copyright Google LLC All Rights Reserved.
|
|
323
|
+
*
|
|
324
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
325
|
+
* found in the LICENSE file at https://angular.io/license
|
|
326
|
+
*/
|
|
327
|
+
/**
|
|
328
|
+
* Returns an error to be thrown when there is no usable data.
|
|
329
|
+
* @docs-private
|
|
330
|
+
*/
|
|
331
|
+
function getTreeNoValidDataSourceError() {
|
|
332
|
+
return Error(`A valid data source must be provided.`);
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* Returns an error to be thrown when there are multiple nodes that are missing a when function.
|
|
336
|
+
* @docs-private
|
|
337
|
+
*/
|
|
338
|
+
function getTreeMultipleDefaultNodeDefsError() {
|
|
339
|
+
return Error(`There can only be one default row without a when predicate function.`);
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* Returns an error to be thrown when there are no matching node defs for a particular set of data.
|
|
343
|
+
* @docs-private
|
|
344
|
+
*/
|
|
345
|
+
function getTreeMissingMatchingNodeDefError() {
|
|
346
|
+
return Error(`Could not find a matching node definition for the provided node data.`);
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* Returns an error to be thrown when there are tree control.
|
|
350
|
+
* @docs-private
|
|
351
|
+
*/
|
|
352
|
+
function getTreeControlMissingError() {
|
|
353
|
+
return Error(`Could not find a tree control for the tree.`);
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* Returns an error to be thrown when tree control did not implement functions for flat/nested node.
|
|
357
|
+
* @docs-private
|
|
358
|
+
*/
|
|
359
|
+
function getTreeControlFunctionsMissingError() {
|
|
360
|
+
return Error(`Could not find functions for nested/flat tree in tree control.`);
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
* CDK tree component that connects with a data source to retrieve data of type `T` and renders
|
|
365
|
+
* dataNodes with hierarchy. Updates the dataNodes when new data is provided by the data source.
|
|
366
|
+
*/
|
|
367
|
+
class CdkTree {
|
|
368
|
+
constructor(_differs, _changeDetectorRef) {
|
|
369
|
+
this._differs = _differs;
|
|
370
|
+
this._changeDetectorRef = _changeDetectorRef;
|
|
371
|
+
/** Subject that emits when the component has been destroyed. */
|
|
372
|
+
this._onDestroy = new Subject();
|
|
373
|
+
/** Level of nodes */
|
|
374
|
+
this._levels = new Map();
|
|
375
|
+
// TODO(tinayuangao): Setup a listener for scrolling, emit the calculated view to viewChange.
|
|
376
|
+
// Remove the MAX_VALUE in viewChange
|
|
377
|
+
/**
|
|
378
|
+
* Stream containing the latest information on what rows are being displayed on screen.
|
|
379
|
+
* Can be used by the data source to as a heuristic of what data should be provided.
|
|
380
|
+
*/
|
|
381
|
+
this.viewChange = new BehaviorSubject({
|
|
382
|
+
start: 0,
|
|
383
|
+
end: Number.MAX_VALUE,
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* Provides a stream containing the latest data array to render. Influenced by the tree's
|
|
388
|
+
* stream of view window (what dataNodes are currently on screen).
|
|
389
|
+
* Data source can be an observable of data array, or a data array to render.
|
|
390
|
+
*/
|
|
391
|
+
get dataSource() {
|
|
392
|
+
return this._dataSource;
|
|
393
|
+
}
|
|
394
|
+
set dataSource(dataSource) {
|
|
395
|
+
if (this._dataSource !== dataSource) {
|
|
396
|
+
this._switchDataSource(dataSource);
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
ngOnInit() {
|
|
400
|
+
this._dataDiffer = this._differs.find([]).create(this.trackBy);
|
|
401
|
+
if (!this.treeControl && (typeof ngDevMode === 'undefined' || ngDevMode)) {
|
|
402
|
+
throw getTreeControlMissingError();
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
ngOnDestroy() {
|
|
406
|
+
this._nodeOutlet.viewContainer.clear();
|
|
407
|
+
this.viewChange.complete();
|
|
408
|
+
this._onDestroy.next();
|
|
409
|
+
this._onDestroy.complete();
|
|
410
|
+
if (this._dataSource && typeof this._dataSource.disconnect === 'function') {
|
|
411
|
+
this.dataSource.disconnect(this);
|
|
412
|
+
}
|
|
413
|
+
if (this._dataSubscription) {
|
|
414
|
+
this._dataSubscription.unsubscribe();
|
|
415
|
+
this._dataSubscription = null;
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
ngAfterContentChecked() {
|
|
419
|
+
const defaultNodeDefs = this._nodeDefs.filter(def => !def.when);
|
|
420
|
+
if (defaultNodeDefs.length > 1 && (typeof ngDevMode === 'undefined' || ngDevMode)) {
|
|
421
|
+
throw getTreeMultipleDefaultNodeDefsError();
|
|
422
|
+
}
|
|
423
|
+
this._defaultNodeDef = defaultNodeDefs[0];
|
|
424
|
+
if (this.dataSource && this._nodeDefs && !this._dataSubscription) {
|
|
425
|
+
this._observeRenderChanges();
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
// TODO(tinayuangao): Work on keyboard traversal and actions, make sure it's working for RTL
|
|
429
|
+
// and nested trees.
|
|
430
|
+
/**
|
|
431
|
+
* Switch to the provided data source by resetting the data and unsubscribing from the current
|
|
432
|
+
* render change subscription if one exists. If the data source is null, interpret this by
|
|
433
|
+
* clearing the node outlet. Otherwise start listening for new data.
|
|
434
|
+
*/
|
|
435
|
+
_switchDataSource(dataSource) {
|
|
436
|
+
if (this._dataSource && typeof this._dataSource.disconnect === 'function') {
|
|
437
|
+
this.dataSource.disconnect(this);
|
|
438
|
+
}
|
|
439
|
+
if (this._dataSubscription) {
|
|
440
|
+
this._dataSubscription.unsubscribe();
|
|
441
|
+
this._dataSubscription = null;
|
|
442
|
+
}
|
|
443
|
+
// Remove the all dataNodes if there is now no data source
|
|
444
|
+
if (!dataSource) {
|
|
445
|
+
this._nodeOutlet.viewContainer.clear();
|
|
446
|
+
}
|
|
447
|
+
this._dataSource = dataSource;
|
|
448
|
+
if (this._nodeDefs) {
|
|
449
|
+
this._observeRenderChanges();
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
/** Set up a subscription for the data provided by the data source. */
|
|
453
|
+
_observeRenderChanges() {
|
|
454
|
+
let dataStream;
|
|
455
|
+
if (isDataSource(this._dataSource)) {
|
|
456
|
+
dataStream = this._dataSource.connect(this);
|
|
457
|
+
} else if (isObservable(this._dataSource)) {
|
|
458
|
+
dataStream = this._dataSource;
|
|
459
|
+
} else if (Array.isArray(this._dataSource)) {
|
|
460
|
+
dataStream = of(this._dataSource);
|
|
461
|
+
}
|
|
462
|
+
if (dataStream) {
|
|
463
|
+
this._dataSubscription = dataStream
|
|
464
|
+
.pipe(takeUntil(this._onDestroy))
|
|
465
|
+
.subscribe(data => this.renderNodeChanges(data));
|
|
466
|
+
} else if (typeof ngDevMode === 'undefined' || ngDevMode) {
|
|
467
|
+
throw getTreeNoValidDataSourceError();
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
/** Check for changes made in the data and render each change (node added/removed/moved). */
|
|
471
|
+
renderNodeChanges(
|
|
472
|
+
data,
|
|
473
|
+
dataDiffer = this._dataDiffer,
|
|
474
|
+
viewContainer = this._nodeOutlet.viewContainer,
|
|
475
|
+
parentData
|
|
476
|
+
) {
|
|
477
|
+
const changes = dataDiffer.diff(data);
|
|
478
|
+
if (!changes) {
|
|
479
|
+
return;
|
|
480
|
+
}
|
|
481
|
+
changes.forEachOperation((item, adjustedPreviousIndex, currentIndex) => {
|
|
482
|
+
if (item.previousIndex == null) {
|
|
483
|
+
this.insertNode(data[currentIndex], currentIndex, viewContainer, parentData);
|
|
484
|
+
} else if (currentIndex == null) {
|
|
485
|
+
viewContainer.remove(adjustedPreviousIndex);
|
|
486
|
+
this._levels.delete(item.item);
|
|
487
|
+
} else {
|
|
488
|
+
const view = viewContainer.get(adjustedPreviousIndex);
|
|
489
|
+
viewContainer.move(view, currentIndex);
|
|
490
|
+
}
|
|
491
|
+
});
|
|
492
|
+
this._changeDetectorRef.detectChanges();
|
|
493
|
+
}
|
|
494
|
+
/**
|
|
495
|
+
* Finds the matching node definition that should be used for this node data. If there is only
|
|
496
|
+
* one node definition, it is returned. Otherwise, find the node definition that has a when
|
|
497
|
+
* predicate that returns true with the data. If none return true, return the default node
|
|
498
|
+
* definition.
|
|
499
|
+
*/
|
|
500
|
+
_getNodeDef(data, i) {
|
|
501
|
+
if (this._nodeDefs.length === 1) {
|
|
502
|
+
return this._nodeDefs.first;
|
|
503
|
+
}
|
|
504
|
+
const nodeDef =
|
|
505
|
+
this._nodeDefs.find(def => def.when && def.when(i, data)) || this._defaultNodeDef;
|
|
506
|
+
if (!nodeDef && (typeof ngDevMode === 'undefined' || ngDevMode)) {
|
|
507
|
+
throw getTreeMissingMatchingNodeDefError();
|
|
508
|
+
}
|
|
509
|
+
return nodeDef;
|
|
510
|
+
}
|
|
511
|
+
/**
|
|
512
|
+
* Create the embedded view for the data node template and place it in the correct index location
|
|
513
|
+
* within the data node view container.
|
|
514
|
+
*/
|
|
515
|
+
insertNode(nodeData, index, viewContainer, parentData) {
|
|
516
|
+
const node = this._getNodeDef(nodeData, index);
|
|
517
|
+
// Node context that will be provided to created embedded view
|
|
518
|
+
const context = new CdkTreeNodeOutletContext(nodeData);
|
|
519
|
+
// If the tree is flat tree, then use the `getLevel` function in flat tree control
|
|
520
|
+
// Otherwise, use the level of parent node.
|
|
521
|
+
if (this.treeControl.getLevel) {
|
|
522
|
+
context.level = this.treeControl.getLevel(nodeData);
|
|
523
|
+
} else if (typeof parentData !== 'undefined' && this._levels.has(parentData)) {
|
|
524
|
+
context.level = this._levels.get(parentData) + 1;
|
|
525
|
+
} else {
|
|
526
|
+
context.level = 0;
|
|
527
|
+
}
|
|
528
|
+
this._levels.set(nodeData, context.level);
|
|
529
|
+
// Use default tree nodeOutlet, or nested node's nodeOutlet
|
|
530
|
+
const container = viewContainer ? viewContainer : this._nodeOutlet.viewContainer;
|
|
531
|
+
container.createEmbeddedView(node.template, context, index);
|
|
532
|
+
// Set the data to just created `CdkTreeNode`.
|
|
533
|
+
// The `CdkTreeNode` created from `createEmbeddedView` will be saved in static variable
|
|
534
|
+
// `mostRecentTreeNode`. We get it from static variable and pass the node data to it.
|
|
535
|
+
if (CdkTreeNode.mostRecentTreeNode) {
|
|
536
|
+
CdkTreeNode.mostRecentTreeNode.data = nodeData;
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
CdkTree.ɵfac = i0.ɵɵngDeclareFactory({
|
|
541
|
+
minVersion: '12.0.0',
|
|
542
|
+
version: '14.2.0',
|
|
543
|
+
ngImport: i0,
|
|
544
|
+
type: CdkTree,
|
|
545
|
+
deps: [{ token: i0.IterableDiffers }, { token: i0.ChangeDetectorRef }],
|
|
546
|
+
target: i0.ɵɵFactoryTarget.Component,
|
|
547
|
+
});
|
|
548
|
+
CdkTree.ɵcmp = i0.ɵɵngDeclareComponent({
|
|
549
|
+
minVersion: '14.0.0',
|
|
550
|
+
version: '14.2.0',
|
|
551
|
+
type: CdkTree,
|
|
552
|
+
selector: 'cdk-tree',
|
|
553
|
+
inputs: { dataSource: 'dataSource', treeControl: 'treeControl', trackBy: 'trackBy' },
|
|
554
|
+
host: { attributes: { role: 'tree' }, classAttribute: 'cdk-tree' },
|
|
555
|
+
queries: [{ propertyName: '_nodeDefs', predicate: CdkTreeNodeDef, descendants: true }],
|
|
556
|
+
viewQueries: [
|
|
557
|
+
{
|
|
558
|
+
propertyName: '_nodeOutlet',
|
|
559
|
+
first: true,
|
|
560
|
+
predicate: CdkTreeNodeOutlet,
|
|
561
|
+
descendants: true,
|
|
562
|
+
static: true,
|
|
563
|
+
},
|
|
564
|
+
],
|
|
565
|
+
exportAs: ['cdkTree'],
|
|
566
|
+
ngImport: i0,
|
|
567
|
+
template: `<ng-container cdkTreeNodeOutlet></ng-container>`,
|
|
568
|
+
isInline: true,
|
|
569
|
+
dependencies: [{ kind: 'directive', type: CdkTreeNodeOutlet, selector: '[cdkTreeNodeOutlet]' }],
|
|
570
|
+
changeDetection: i0.ChangeDetectionStrategy.Default,
|
|
571
|
+
encapsulation: i0.ViewEncapsulation.None,
|
|
572
|
+
});
|
|
573
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
574
|
+
minVersion: '12.0.0',
|
|
575
|
+
version: '14.2.0',
|
|
576
|
+
ngImport: i0,
|
|
577
|
+
type: CdkTree,
|
|
578
|
+
decorators: [
|
|
579
|
+
{
|
|
580
|
+
type: Component,
|
|
581
|
+
args: [
|
|
582
|
+
{
|
|
583
|
+
selector: 'cdk-tree',
|
|
584
|
+
exportAs: 'cdkTree',
|
|
585
|
+
template: `<ng-container cdkTreeNodeOutlet></ng-container>`,
|
|
586
|
+
host: {
|
|
587
|
+
class: 'cdk-tree',
|
|
588
|
+
role: 'tree',
|
|
589
|
+
},
|
|
590
|
+
encapsulation: ViewEncapsulation.None,
|
|
591
|
+
// The "OnPush" status for the `CdkTree` component is effectively a noop, so we are removing it.
|
|
592
|
+
// The view for `CdkTree` consists entirely of templates declared in other views. As they are
|
|
593
|
+
// declared elsewhere, they are checked when their declaration points are checked.
|
|
594
|
+
// tslint:disable-next-line:validate-decorators
|
|
595
|
+
changeDetection: ChangeDetectionStrategy.Default,
|
|
596
|
+
},
|
|
597
|
+
],
|
|
598
|
+
},
|
|
599
|
+
],
|
|
600
|
+
ctorParameters: function () {
|
|
601
|
+
return [{ type: i0.IterableDiffers }, { type: i0.ChangeDetectorRef }];
|
|
602
|
+
},
|
|
603
|
+
propDecorators: {
|
|
604
|
+
dataSource: [
|
|
605
|
+
{
|
|
606
|
+
type: Input,
|
|
607
|
+
},
|
|
608
|
+
],
|
|
609
|
+
treeControl: [
|
|
610
|
+
{
|
|
611
|
+
type: Input,
|
|
612
|
+
},
|
|
613
|
+
],
|
|
614
|
+
trackBy: [
|
|
615
|
+
{
|
|
616
|
+
type: Input,
|
|
617
|
+
},
|
|
618
|
+
],
|
|
619
|
+
_nodeOutlet: [
|
|
620
|
+
{
|
|
621
|
+
type: ViewChild,
|
|
622
|
+
args: [CdkTreeNodeOutlet, { static: true }],
|
|
623
|
+
},
|
|
624
|
+
],
|
|
625
|
+
_nodeDefs: [
|
|
626
|
+
{
|
|
627
|
+
type: ContentChildren,
|
|
628
|
+
args: [
|
|
629
|
+
CdkTreeNodeDef,
|
|
630
|
+
{
|
|
631
|
+
// We need to use `descendants: true`, because Ivy will no longer match
|
|
632
|
+
// indirect descendants if it's left as false.
|
|
633
|
+
descendants: true,
|
|
634
|
+
},
|
|
635
|
+
],
|
|
636
|
+
},
|
|
637
|
+
],
|
|
638
|
+
},
|
|
639
|
+
});
|
|
640
|
+
/**
|
|
641
|
+
* Tree node for CdkTree. It contains the data in the tree node.
|
|
642
|
+
*/
|
|
643
|
+
class CdkTreeNode {
|
|
644
|
+
constructor(_elementRef, _tree) {
|
|
645
|
+
this._elementRef = _elementRef;
|
|
646
|
+
this._tree = _tree;
|
|
647
|
+
/** Subject that emits when the component has been destroyed. */
|
|
648
|
+
this._destroyed = new Subject();
|
|
649
|
+
/** Emits when the node's data has changed. */
|
|
650
|
+
this._dataChanges = new Subject();
|
|
651
|
+
CdkTreeNode.mostRecentTreeNode = this;
|
|
652
|
+
this.role = 'treeitem';
|
|
653
|
+
}
|
|
654
|
+
/**
|
|
655
|
+
* The role of the tree node.
|
|
656
|
+
* @deprecated The correct role is 'treeitem', 'group' should not be used. This input will be
|
|
657
|
+
* removed in a future version.
|
|
658
|
+
* @breaking-change 12.0.0 Remove this input
|
|
659
|
+
*/
|
|
660
|
+
get role() {
|
|
661
|
+
return 'treeitem';
|
|
662
|
+
}
|
|
663
|
+
set role(_role) {
|
|
664
|
+
// TODO: move to host after View Engine deprecation
|
|
665
|
+
this._elementRef.nativeElement.setAttribute('role', _role);
|
|
666
|
+
}
|
|
667
|
+
/** The tree node's data. */
|
|
668
|
+
get data() {
|
|
669
|
+
return this._data;
|
|
670
|
+
}
|
|
671
|
+
set data(value) {
|
|
672
|
+
if (value !== this._data) {
|
|
673
|
+
this._data = value;
|
|
674
|
+
this._setRoleFromData();
|
|
675
|
+
this._dataChanges.next();
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
get isExpanded() {
|
|
679
|
+
return this._tree.treeControl.isExpanded(this._data);
|
|
680
|
+
}
|
|
681
|
+
get level() {
|
|
682
|
+
// If the treeControl has a getLevel method, use it to get the level. Otherwise read the
|
|
683
|
+
// aria-level off the parent node and use it as the level for this node (note aria-level is
|
|
684
|
+
// 1-indexed, while this property is 0-indexed, so we don't need to increment).
|
|
685
|
+
return this._tree.treeControl.getLevel
|
|
686
|
+
? this._tree.treeControl.getLevel(this._data)
|
|
687
|
+
: this._parentNodeAriaLevel;
|
|
688
|
+
}
|
|
689
|
+
ngOnInit() {
|
|
690
|
+
this._parentNodeAriaLevel = getParentNodeAriaLevel(this._elementRef.nativeElement);
|
|
691
|
+
this._elementRef.nativeElement.setAttribute('aria-level', `${this.level + 1}`);
|
|
692
|
+
}
|
|
693
|
+
ngOnDestroy() {
|
|
694
|
+
// If this is the last tree node being destroyed,
|
|
695
|
+
// clear out the reference to avoid leaking memory.
|
|
696
|
+
if (CdkTreeNode.mostRecentTreeNode === this) {
|
|
697
|
+
CdkTreeNode.mostRecentTreeNode = null;
|
|
698
|
+
}
|
|
699
|
+
this._dataChanges.complete();
|
|
700
|
+
this._destroyed.next();
|
|
701
|
+
this._destroyed.complete();
|
|
702
|
+
}
|
|
703
|
+
/** Focuses the menu item. Implements for FocusableOption. */
|
|
704
|
+
focus() {
|
|
705
|
+
this._elementRef.nativeElement.focus();
|
|
706
|
+
}
|
|
707
|
+
// TODO: role should eventually just be set in the component host
|
|
708
|
+
_setRoleFromData() {
|
|
709
|
+
if (
|
|
710
|
+
!this._tree.treeControl.isExpandable &&
|
|
711
|
+
!this._tree.treeControl.getChildren &&
|
|
712
|
+
(typeof ngDevMode === 'undefined' || ngDevMode)
|
|
713
|
+
) {
|
|
714
|
+
throw getTreeControlFunctionsMissingError();
|
|
715
|
+
}
|
|
716
|
+
this.role = 'treeitem';
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
/**
|
|
720
|
+
* The most recently created `CdkTreeNode`. We save it in static variable so we can retrieve it
|
|
721
|
+
* in `CdkTree` and set the data to it.
|
|
722
|
+
*/
|
|
723
|
+
CdkTreeNode.mostRecentTreeNode = null;
|
|
724
|
+
CdkTreeNode.ɵfac = i0.ɵɵngDeclareFactory({
|
|
725
|
+
minVersion: '12.0.0',
|
|
726
|
+
version: '14.2.0',
|
|
727
|
+
ngImport: i0,
|
|
728
|
+
type: CdkTreeNode,
|
|
729
|
+
deps: [{ token: i0.ElementRef }, { token: CdkTree }],
|
|
730
|
+
target: i0.ɵɵFactoryTarget.Directive,
|
|
731
|
+
});
|
|
732
|
+
CdkTreeNode.ɵdir = i0.ɵɵngDeclareDirective({
|
|
733
|
+
minVersion: '14.0.0',
|
|
734
|
+
version: '14.2.0',
|
|
735
|
+
type: CdkTreeNode,
|
|
736
|
+
selector: 'cdk-tree-node',
|
|
737
|
+
inputs: { role: 'role' },
|
|
738
|
+
host: { properties: { 'attr.aria-expanded': 'isExpanded' }, classAttribute: 'cdk-tree-node' },
|
|
739
|
+
exportAs: ['cdkTreeNode'],
|
|
740
|
+
ngImport: i0,
|
|
741
|
+
});
|
|
742
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
743
|
+
minVersion: '12.0.0',
|
|
744
|
+
version: '14.2.0',
|
|
745
|
+
ngImport: i0,
|
|
746
|
+
type: CdkTreeNode,
|
|
747
|
+
decorators: [
|
|
748
|
+
{
|
|
749
|
+
type: Directive,
|
|
750
|
+
args: [
|
|
751
|
+
{
|
|
752
|
+
selector: 'cdk-tree-node',
|
|
753
|
+
exportAs: 'cdkTreeNode',
|
|
754
|
+
host: {
|
|
755
|
+
class: 'cdk-tree-node',
|
|
756
|
+
'[attr.aria-expanded]': 'isExpanded',
|
|
757
|
+
},
|
|
758
|
+
},
|
|
759
|
+
],
|
|
760
|
+
},
|
|
761
|
+
],
|
|
762
|
+
ctorParameters: function () {
|
|
763
|
+
return [{ type: i0.ElementRef }, { type: CdkTree }];
|
|
764
|
+
},
|
|
765
|
+
propDecorators: {
|
|
766
|
+
role: [
|
|
767
|
+
{
|
|
768
|
+
type: Input,
|
|
769
|
+
},
|
|
770
|
+
],
|
|
771
|
+
},
|
|
772
|
+
});
|
|
773
|
+
function getParentNodeAriaLevel(nodeElement) {
|
|
774
|
+
let parent = nodeElement.parentElement;
|
|
775
|
+
while (parent && !isNodeElement(parent)) {
|
|
776
|
+
parent = parent.parentElement;
|
|
777
|
+
}
|
|
778
|
+
if (!parent) {
|
|
779
|
+
if (typeof ngDevMode === 'undefined' || ngDevMode) {
|
|
780
|
+
throw Error('Incorrect tree structure containing detached node.');
|
|
781
|
+
} else {
|
|
782
|
+
return -1;
|
|
783
|
+
}
|
|
784
|
+
} else if (parent.classList.contains('cdk-nested-tree-node')) {
|
|
785
|
+
return coerceNumberProperty(parent.getAttribute('aria-level'));
|
|
786
|
+
} else {
|
|
787
|
+
// The ancestor element is the cdk-tree itself
|
|
788
|
+
return 0;
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
function isNodeElement(element) {
|
|
792
|
+
const classList = element.classList;
|
|
793
|
+
return !!(
|
|
794
|
+
(classList === null || classList === void 0
|
|
795
|
+
? void 0
|
|
796
|
+
: classList.contains('cdk-nested-tree-node')) ||
|
|
797
|
+
(classList === null || classList === void 0 ? void 0 : classList.contains('cdk-tree'))
|
|
798
|
+
);
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
/**
|
|
802
|
+
* @license
|
|
803
|
+
* Copyright Google LLC All Rights Reserved.
|
|
804
|
+
*
|
|
805
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
806
|
+
* found in the LICENSE file at https://angular.io/license
|
|
807
|
+
*/
|
|
808
|
+
/**
|
|
809
|
+
* Nested node is a child of `<cdk-tree>`. It works with nested tree.
|
|
810
|
+
* By using `cdk-nested-tree-node` component in tree node template, children of the parent node will
|
|
811
|
+
* be added in the `cdkTreeNodeOutlet` in tree node template.
|
|
812
|
+
* The children of node will be automatically added to `cdkTreeNodeOutlet`.
|
|
813
|
+
*/
|
|
814
|
+
class CdkNestedTreeNode extends CdkTreeNode {
|
|
815
|
+
constructor(elementRef, tree, _differs) {
|
|
816
|
+
super(elementRef, tree);
|
|
817
|
+
this._differs = _differs;
|
|
818
|
+
}
|
|
819
|
+
ngAfterContentInit() {
|
|
820
|
+
this._dataDiffer = this._differs.find([]).create(this._tree.trackBy);
|
|
821
|
+
if (!this._tree.treeControl.getChildren && (typeof ngDevMode === 'undefined' || ngDevMode)) {
|
|
822
|
+
throw getTreeControlFunctionsMissingError();
|
|
823
|
+
}
|
|
824
|
+
const childrenNodes = this._tree.treeControl.getChildren(this.data);
|
|
825
|
+
if (Array.isArray(childrenNodes)) {
|
|
826
|
+
this.updateChildrenNodes(childrenNodes);
|
|
827
|
+
} else if (isObservable(childrenNodes)) {
|
|
828
|
+
childrenNodes
|
|
829
|
+
.pipe(takeUntil(this._destroyed))
|
|
830
|
+
.subscribe(result => this.updateChildrenNodes(result));
|
|
831
|
+
}
|
|
832
|
+
this.nodeOutlet.changes
|
|
833
|
+
.pipe(takeUntil(this._destroyed))
|
|
834
|
+
.subscribe(() => this.updateChildrenNodes());
|
|
835
|
+
}
|
|
836
|
+
// This is a workaround for https://github.com/angular/angular/issues/23091
|
|
837
|
+
// In aot mode, the lifecycle hooks from parent class are not called.
|
|
838
|
+
ngOnInit() {
|
|
839
|
+
super.ngOnInit();
|
|
840
|
+
}
|
|
841
|
+
ngOnDestroy() {
|
|
842
|
+
this._clear();
|
|
843
|
+
super.ngOnDestroy();
|
|
844
|
+
}
|
|
845
|
+
/** Add children dataNodes to the NodeOutlet */
|
|
846
|
+
updateChildrenNodes(children) {
|
|
847
|
+
const outlet = this._getNodeOutlet();
|
|
848
|
+
if (children) {
|
|
849
|
+
this._children = children;
|
|
850
|
+
}
|
|
851
|
+
if (outlet && this._children) {
|
|
852
|
+
const viewContainer = outlet.viewContainer;
|
|
853
|
+
this._tree.renderNodeChanges(this._children, this._dataDiffer, viewContainer, this._data);
|
|
854
|
+
} else {
|
|
855
|
+
// Reset the data differ if there's no children nodes displayed
|
|
856
|
+
this._dataDiffer.diff([]);
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
/** Clear the children dataNodes. */
|
|
860
|
+
_clear() {
|
|
861
|
+
const outlet = this._getNodeOutlet();
|
|
862
|
+
if (outlet) {
|
|
863
|
+
outlet.viewContainer.clear();
|
|
864
|
+
this._dataDiffer.diff([]);
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
/** Gets the outlet for the current node. */
|
|
868
|
+
_getNodeOutlet() {
|
|
869
|
+
const outlets = this.nodeOutlet;
|
|
870
|
+
// Note that since we use `descendants: true` on the query, we have to ensure
|
|
871
|
+
// that we don't pick up the outlet of a child node by accident.
|
|
872
|
+
return outlets && outlets.find(outlet => !outlet._node || outlet._node === this);
|
|
873
|
+
}
|
|
874
|
+
}
|
|
875
|
+
CdkNestedTreeNode.ɵfac = i0.ɵɵngDeclareFactory({
|
|
876
|
+
minVersion: '12.0.0',
|
|
877
|
+
version: '14.2.0',
|
|
878
|
+
ngImport: i0,
|
|
879
|
+
type: CdkNestedTreeNode,
|
|
880
|
+
deps: [{ token: i0.ElementRef }, { token: CdkTree }, { token: i0.IterableDiffers }],
|
|
881
|
+
target: i0.ɵɵFactoryTarget.Directive,
|
|
882
|
+
});
|
|
883
|
+
CdkNestedTreeNode.ɵdir = i0.ɵɵngDeclareDirective({
|
|
884
|
+
minVersion: '14.0.0',
|
|
885
|
+
version: '14.2.0',
|
|
886
|
+
type: CdkNestedTreeNode,
|
|
887
|
+
selector: 'cdk-nested-tree-node',
|
|
888
|
+
inputs: { role: 'role', disabled: 'disabled', tabIndex: 'tabIndex' },
|
|
889
|
+
host: { classAttribute: 'cdk-nested-tree-node' },
|
|
890
|
+
providers: [
|
|
891
|
+
{ provide: CdkTreeNode, useExisting: CdkNestedTreeNode },
|
|
892
|
+
{ provide: CDK_TREE_NODE_OUTLET_NODE, useExisting: CdkNestedTreeNode },
|
|
893
|
+
],
|
|
894
|
+
queries: [{ propertyName: 'nodeOutlet', predicate: CdkTreeNodeOutlet, descendants: true }],
|
|
895
|
+
exportAs: ['cdkNestedTreeNode'],
|
|
896
|
+
usesInheritance: true,
|
|
897
|
+
ngImport: i0,
|
|
898
|
+
});
|
|
899
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
900
|
+
minVersion: '12.0.0',
|
|
901
|
+
version: '14.2.0',
|
|
902
|
+
ngImport: i0,
|
|
903
|
+
type: CdkNestedTreeNode,
|
|
904
|
+
decorators: [
|
|
905
|
+
{
|
|
906
|
+
type: Directive,
|
|
907
|
+
args: [
|
|
908
|
+
{
|
|
909
|
+
selector: 'cdk-nested-tree-node',
|
|
910
|
+
exportAs: 'cdkNestedTreeNode',
|
|
911
|
+
inputs: ['role', 'disabled', 'tabIndex'],
|
|
912
|
+
providers: [
|
|
913
|
+
{ provide: CdkTreeNode, useExisting: CdkNestedTreeNode },
|
|
914
|
+
{ provide: CDK_TREE_NODE_OUTLET_NODE, useExisting: CdkNestedTreeNode },
|
|
915
|
+
],
|
|
916
|
+
host: {
|
|
917
|
+
class: 'cdk-nested-tree-node',
|
|
918
|
+
},
|
|
919
|
+
},
|
|
920
|
+
],
|
|
921
|
+
},
|
|
922
|
+
],
|
|
923
|
+
ctorParameters: function () {
|
|
924
|
+
return [{ type: i0.ElementRef }, { type: CdkTree }, { type: i0.IterableDiffers }];
|
|
925
|
+
},
|
|
926
|
+
propDecorators: {
|
|
927
|
+
nodeOutlet: [
|
|
928
|
+
{
|
|
929
|
+
type: ContentChildren,
|
|
930
|
+
args: [
|
|
931
|
+
CdkTreeNodeOutlet,
|
|
932
|
+
{
|
|
933
|
+
// We need to use `descendants: true`, because Ivy will no longer match
|
|
934
|
+
// indirect descendants if it's left as false.
|
|
935
|
+
descendants: true,
|
|
936
|
+
},
|
|
937
|
+
],
|
|
938
|
+
},
|
|
939
|
+
],
|
|
940
|
+
},
|
|
941
|
+
});
|
|
942
|
+
|
|
943
|
+
/** Regex used to split a string on its CSS units. */
|
|
944
|
+
const cssUnitPattern = /([A-Za-z%]+)$/;
|
|
945
|
+
/**
|
|
946
|
+
* Indent for the children tree dataNodes.
|
|
947
|
+
* This directive will add left-padding to the node to show hierarchy.
|
|
948
|
+
*/
|
|
949
|
+
class CdkTreeNodePadding {
|
|
950
|
+
constructor(_treeNode, _tree, _element, _dir) {
|
|
951
|
+
this._treeNode = _treeNode;
|
|
952
|
+
this._tree = _tree;
|
|
953
|
+
this._element = _element;
|
|
954
|
+
this._dir = _dir;
|
|
955
|
+
/** Subject that emits when the component has been destroyed. */
|
|
956
|
+
this._destroyed = new Subject();
|
|
957
|
+
/** CSS units used for the indentation value. */
|
|
958
|
+
this.indentUnits = 'px';
|
|
959
|
+
this._indent = 40;
|
|
960
|
+
this._setPadding();
|
|
961
|
+
if (_dir) {
|
|
962
|
+
_dir.change.pipe(takeUntil(this._destroyed)).subscribe(() => this._setPadding(true));
|
|
963
|
+
}
|
|
964
|
+
// In Ivy the indentation binding might be set before the tree node's data has been added,
|
|
965
|
+
// which means that we'll miss the first render. We have to subscribe to changes in the
|
|
966
|
+
// data to ensure that everything is up to date.
|
|
967
|
+
_treeNode._dataChanges.subscribe(() => this._setPadding());
|
|
968
|
+
}
|
|
969
|
+
/** The level of depth of the tree node. The padding will be `level * indent` pixels. */
|
|
970
|
+
get level() {
|
|
971
|
+
return this._level;
|
|
972
|
+
}
|
|
973
|
+
set level(value) {
|
|
974
|
+
this._setLevelInput(value);
|
|
975
|
+
}
|
|
976
|
+
/**
|
|
977
|
+
* The indent for each level. Can be a number or a CSS string.
|
|
978
|
+
* Default number 40px from material design menu sub-menu spec.
|
|
979
|
+
*/
|
|
980
|
+
get indent() {
|
|
981
|
+
return this._indent;
|
|
982
|
+
}
|
|
983
|
+
set indent(indent) {
|
|
984
|
+
this._setIndentInput(indent);
|
|
985
|
+
}
|
|
986
|
+
ngOnDestroy() {
|
|
987
|
+
this._destroyed.next();
|
|
988
|
+
this._destroyed.complete();
|
|
989
|
+
}
|
|
990
|
+
/** The padding indent value for the tree node. Returns a string with px numbers if not null. */
|
|
991
|
+
_paddingIndent() {
|
|
992
|
+
const nodeLevel =
|
|
993
|
+
this._treeNode.data && this._tree.treeControl.getLevel
|
|
994
|
+
? this._tree.treeControl.getLevel(this._treeNode.data)
|
|
995
|
+
: null;
|
|
996
|
+
const level = this._level == null ? nodeLevel : this._level;
|
|
997
|
+
return typeof level === 'number' ? `${level * this._indent}${this.indentUnits}` : null;
|
|
998
|
+
}
|
|
999
|
+
_setPadding(forceChange = false) {
|
|
1000
|
+
const padding = this._paddingIndent();
|
|
1001
|
+
if (padding !== this._currentPadding || forceChange) {
|
|
1002
|
+
const element = this._element.nativeElement;
|
|
1003
|
+
const paddingProp = this._dir && this._dir.value === 'rtl' ? 'paddingRight' : 'paddingLeft';
|
|
1004
|
+
const resetProp = paddingProp === 'paddingLeft' ? 'paddingRight' : 'paddingLeft';
|
|
1005
|
+
element.style[paddingProp] = padding || '';
|
|
1006
|
+
element.style[resetProp] = '';
|
|
1007
|
+
this._currentPadding = padding;
|
|
1008
|
+
}
|
|
1009
|
+
}
|
|
1010
|
+
/**
|
|
1011
|
+
* This has been extracted to a util because of TS 4 and VE.
|
|
1012
|
+
* View Engine doesn't support property rename inheritance.
|
|
1013
|
+
* TS 4.0 doesn't allow properties to override accessors or vice-versa.
|
|
1014
|
+
* @docs-private
|
|
1015
|
+
*/
|
|
1016
|
+
_setLevelInput(value) {
|
|
1017
|
+
// Set to null as the fallback value so that _setPadding can fall back to the node level if the
|
|
1018
|
+
// consumer set the directive as `cdkTreeNodePadding=""`. We still want to take this value if
|
|
1019
|
+
// they set 0 explicitly.
|
|
1020
|
+
this._level = coerceNumberProperty(value, null);
|
|
1021
|
+
this._setPadding();
|
|
1022
|
+
}
|
|
1023
|
+
/**
|
|
1024
|
+
* This has been extracted to a util because of TS 4 and VE.
|
|
1025
|
+
* View Engine doesn't support property rename inheritance.
|
|
1026
|
+
* TS 4.0 doesn't allow properties to override accessors or vice-versa.
|
|
1027
|
+
* @docs-private
|
|
1028
|
+
*/
|
|
1029
|
+
_setIndentInput(indent) {
|
|
1030
|
+
let value = indent;
|
|
1031
|
+
let units = 'px';
|
|
1032
|
+
if (typeof indent === 'string') {
|
|
1033
|
+
const parts = indent.split(cssUnitPattern);
|
|
1034
|
+
value = parts[0];
|
|
1035
|
+
units = parts[1] || units;
|
|
1036
|
+
}
|
|
1037
|
+
this.indentUnits = units;
|
|
1038
|
+
this._indent = coerceNumberProperty(value);
|
|
1039
|
+
this._setPadding();
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
1042
|
+
CdkTreeNodePadding.ɵfac = i0.ɵɵngDeclareFactory({
|
|
1043
|
+
minVersion: '12.0.0',
|
|
1044
|
+
version: '14.2.0',
|
|
1045
|
+
ngImport: i0,
|
|
1046
|
+
type: CdkTreeNodePadding,
|
|
1047
|
+
deps: [
|
|
1048
|
+
{ token: CdkTreeNode },
|
|
1049
|
+
{ token: CdkTree },
|
|
1050
|
+
{ token: i0.ElementRef },
|
|
1051
|
+
{ token: i2.Directionality, optional: true },
|
|
1052
|
+
],
|
|
1053
|
+
target: i0.ɵɵFactoryTarget.Directive,
|
|
1054
|
+
});
|
|
1055
|
+
CdkTreeNodePadding.ɵdir = i0.ɵɵngDeclareDirective({
|
|
1056
|
+
minVersion: '14.0.0',
|
|
1057
|
+
version: '14.2.0',
|
|
1058
|
+
type: CdkTreeNodePadding,
|
|
1059
|
+
selector: '[cdkTreeNodePadding]',
|
|
1060
|
+
inputs: {
|
|
1061
|
+
level: ['cdkTreeNodePadding', 'level'],
|
|
1062
|
+
indent: ['cdkTreeNodePaddingIndent', 'indent'],
|
|
1063
|
+
},
|
|
1064
|
+
ngImport: i0,
|
|
1065
|
+
});
|
|
1066
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
1067
|
+
minVersion: '12.0.0',
|
|
1068
|
+
version: '14.2.0',
|
|
1069
|
+
ngImport: i0,
|
|
1070
|
+
type: CdkTreeNodePadding,
|
|
1071
|
+
decorators: [
|
|
1072
|
+
{
|
|
1073
|
+
type: Directive,
|
|
1074
|
+
args: [
|
|
1075
|
+
{
|
|
1076
|
+
selector: '[cdkTreeNodePadding]',
|
|
1077
|
+
},
|
|
1078
|
+
],
|
|
1079
|
+
},
|
|
1080
|
+
],
|
|
1081
|
+
ctorParameters: function () {
|
|
1082
|
+
return [
|
|
1083
|
+
{ type: CdkTreeNode },
|
|
1084
|
+
{ type: CdkTree },
|
|
1085
|
+
{ type: i0.ElementRef },
|
|
1086
|
+
{
|
|
1087
|
+
type: i2.Directionality,
|
|
1088
|
+
decorators: [
|
|
1089
|
+
{
|
|
1090
|
+
type: Optional,
|
|
1091
|
+
},
|
|
1092
|
+
],
|
|
1093
|
+
},
|
|
1094
|
+
];
|
|
1095
|
+
},
|
|
1096
|
+
propDecorators: {
|
|
1097
|
+
level: [
|
|
1098
|
+
{
|
|
1099
|
+
type: Input,
|
|
1100
|
+
args: ['cdkTreeNodePadding'],
|
|
1101
|
+
},
|
|
1102
|
+
],
|
|
1103
|
+
indent: [
|
|
1104
|
+
{
|
|
1105
|
+
type: Input,
|
|
1106
|
+
args: ['cdkTreeNodePaddingIndent'],
|
|
1107
|
+
},
|
|
1108
|
+
],
|
|
1109
|
+
},
|
|
1110
|
+
});
|
|
1111
|
+
|
|
1112
|
+
/**
|
|
1113
|
+
* @license
|
|
1114
|
+
* Copyright Google LLC All Rights Reserved.
|
|
1115
|
+
*
|
|
1116
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
1117
|
+
* found in the LICENSE file at https://angular.io/license
|
|
1118
|
+
*/
|
|
1119
|
+
/**
|
|
1120
|
+
* Node toggle to expand/collapse the node.
|
|
1121
|
+
*/
|
|
1122
|
+
class CdkTreeNodeToggle {
|
|
1123
|
+
constructor(_tree, _treeNode) {
|
|
1124
|
+
this._tree = _tree;
|
|
1125
|
+
this._treeNode = _treeNode;
|
|
1126
|
+
this._recursive = false;
|
|
1127
|
+
}
|
|
1128
|
+
/** Whether expand/collapse the node recursively. */
|
|
1129
|
+
get recursive() {
|
|
1130
|
+
return this._recursive;
|
|
1131
|
+
}
|
|
1132
|
+
set recursive(value) {
|
|
1133
|
+
this._recursive = coerceBooleanProperty(value);
|
|
1134
|
+
}
|
|
1135
|
+
_toggle(event) {
|
|
1136
|
+
this.recursive
|
|
1137
|
+
? this._tree.treeControl.toggleDescendants(this._treeNode.data)
|
|
1138
|
+
: this._tree.treeControl.toggle(this._treeNode.data);
|
|
1139
|
+
event.stopPropagation();
|
|
1140
|
+
}
|
|
1141
|
+
}
|
|
1142
|
+
CdkTreeNodeToggle.ɵfac = i0.ɵɵngDeclareFactory({
|
|
1143
|
+
minVersion: '12.0.0',
|
|
1144
|
+
version: '14.2.0',
|
|
1145
|
+
ngImport: i0,
|
|
1146
|
+
type: CdkTreeNodeToggle,
|
|
1147
|
+
deps: [{ token: CdkTree }, { token: CdkTreeNode }],
|
|
1148
|
+
target: i0.ɵɵFactoryTarget.Directive,
|
|
1149
|
+
});
|
|
1150
|
+
CdkTreeNodeToggle.ɵdir = i0.ɵɵngDeclareDirective({
|
|
1151
|
+
minVersion: '14.0.0',
|
|
1152
|
+
version: '14.2.0',
|
|
1153
|
+
type: CdkTreeNodeToggle,
|
|
1154
|
+
selector: '[cdkTreeNodeToggle]',
|
|
1155
|
+
inputs: { recursive: ['cdkTreeNodeToggleRecursive', 'recursive'] },
|
|
1156
|
+
host: { listeners: { click: '_toggle($event)' } },
|
|
1157
|
+
ngImport: i0,
|
|
1158
|
+
});
|
|
1159
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
1160
|
+
minVersion: '12.0.0',
|
|
1161
|
+
version: '14.2.0',
|
|
1162
|
+
ngImport: i0,
|
|
1163
|
+
type: CdkTreeNodeToggle,
|
|
1164
|
+
decorators: [
|
|
1165
|
+
{
|
|
1166
|
+
type: Directive,
|
|
1167
|
+
args: [
|
|
1168
|
+
{
|
|
1169
|
+
selector: '[cdkTreeNodeToggle]',
|
|
1170
|
+
host: {
|
|
1171
|
+
'(click)': '_toggle($event)',
|
|
1172
|
+
},
|
|
1173
|
+
},
|
|
1174
|
+
],
|
|
1175
|
+
},
|
|
1176
|
+
],
|
|
1177
|
+
ctorParameters: function () {
|
|
1178
|
+
return [{ type: CdkTree }, { type: CdkTreeNode }];
|
|
1179
|
+
},
|
|
1180
|
+
propDecorators: {
|
|
1181
|
+
recursive: [
|
|
1182
|
+
{
|
|
1183
|
+
type: Input,
|
|
1184
|
+
args: ['cdkTreeNodeToggleRecursive'],
|
|
1185
|
+
},
|
|
1186
|
+
],
|
|
1187
|
+
},
|
|
1188
|
+
});
|
|
1189
|
+
|
|
1190
|
+
/**
|
|
1191
|
+
* @license
|
|
1192
|
+
* Copyright Google LLC All Rights Reserved.
|
|
1193
|
+
*
|
|
1194
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
1195
|
+
* found in the LICENSE file at https://angular.io/license
|
|
1196
|
+
*/
|
|
1197
|
+
const EXPORTED_DECLARATIONS = [
|
|
1198
|
+
CdkNestedTreeNode,
|
|
1199
|
+
CdkTreeNodeDef,
|
|
1200
|
+
CdkTreeNodePadding,
|
|
1201
|
+
CdkTreeNodeToggle,
|
|
1202
|
+
CdkTree,
|
|
1203
|
+
CdkTreeNode,
|
|
1204
|
+
CdkTreeNodeOutlet,
|
|
1205
|
+
];
|
|
1206
|
+
class CdkTreeModule {}
|
|
1207
|
+
CdkTreeModule.ɵfac = i0.ɵɵngDeclareFactory({
|
|
1208
|
+
minVersion: '12.0.0',
|
|
1209
|
+
version: '14.2.0',
|
|
1210
|
+
ngImport: i0,
|
|
1211
|
+
type: CdkTreeModule,
|
|
1212
|
+
deps: [],
|
|
1213
|
+
target: i0.ɵɵFactoryTarget.NgModule,
|
|
1214
|
+
});
|
|
1215
|
+
CdkTreeModule.ɵmod = i0.ɵɵngDeclareNgModule({
|
|
1216
|
+
minVersion: '14.0.0',
|
|
1217
|
+
version: '14.2.0',
|
|
1218
|
+
ngImport: i0,
|
|
1219
|
+
type: CdkTreeModule,
|
|
1220
|
+
declarations: [
|
|
1221
|
+
CdkNestedTreeNode,
|
|
1222
|
+
CdkTreeNodeDef,
|
|
1223
|
+
CdkTreeNodePadding,
|
|
1224
|
+
CdkTreeNodeToggle,
|
|
1225
|
+
CdkTree,
|
|
1226
|
+
CdkTreeNode,
|
|
1227
|
+
CdkTreeNodeOutlet,
|
|
1228
|
+
],
|
|
1229
|
+
exports: [
|
|
1230
|
+
CdkNestedTreeNode,
|
|
1231
|
+
CdkTreeNodeDef,
|
|
1232
|
+
CdkTreeNodePadding,
|
|
1233
|
+
CdkTreeNodeToggle,
|
|
1234
|
+
CdkTree,
|
|
1235
|
+
CdkTreeNode,
|
|
1236
|
+
CdkTreeNodeOutlet,
|
|
1237
|
+
],
|
|
1238
|
+
});
|
|
1239
|
+
CdkTreeModule.ɵinj = i0.ɵɵngDeclareInjector({
|
|
1240
|
+
minVersion: '12.0.0',
|
|
1241
|
+
version: '14.2.0',
|
|
1242
|
+
ngImport: i0,
|
|
1243
|
+
type: CdkTreeModule,
|
|
1244
|
+
});
|
|
1245
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
1246
|
+
minVersion: '12.0.0',
|
|
1247
|
+
version: '14.2.0',
|
|
1248
|
+
ngImport: i0,
|
|
1249
|
+
type: CdkTreeModule,
|
|
1250
|
+
decorators: [
|
|
1251
|
+
{
|
|
1252
|
+
type: NgModule,
|
|
1253
|
+
args: [
|
|
1254
|
+
{
|
|
1255
|
+
exports: EXPORTED_DECLARATIONS,
|
|
1256
|
+
declarations: EXPORTED_DECLARATIONS,
|
|
1257
|
+
},
|
|
1258
|
+
],
|
|
1259
|
+
},
|
|
1260
|
+
],
|
|
1261
|
+
});
|
|
1262
|
+
|
|
1263
|
+
/**
|
|
1264
|
+
* @license
|
|
1265
|
+
* Copyright Google LLC All Rights Reserved.
|
|
1266
|
+
*
|
|
1267
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
1268
|
+
* found in the LICENSE file at https://angular.io/license
|
|
1269
|
+
*/
|
|
1270
|
+
|
|
1271
|
+
/**
|
|
1272
|
+
* @license
|
|
1273
|
+
* Copyright Google LLC All Rights Reserved.
|
|
1274
|
+
*
|
|
1275
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
1276
|
+
* found in the LICENSE file at https://angular.io/license
|
|
1277
|
+
*/
|
|
1278
|
+
|
|
1279
|
+
/**
|
|
1280
|
+
* Generated bundle index. Do not edit.
|
|
1281
|
+
*/
|
|
1282
|
+
|
|
1283
|
+
export {
|
|
1284
|
+
BaseTreeControl,
|
|
1285
|
+
CDK_TREE_NODE_OUTLET_NODE,
|
|
1286
|
+
CdkNestedTreeNode,
|
|
1287
|
+
CdkTree,
|
|
1288
|
+
CdkTreeModule,
|
|
1289
|
+
CdkTreeNode,
|
|
1290
|
+
CdkTreeNodeDef,
|
|
1291
|
+
CdkTreeNodeOutlet,
|
|
1292
|
+
CdkTreeNodeOutletContext,
|
|
1293
|
+
CdkTreeNodePadding,
|
|
1294
|
+
CdkTreeNodeToggle,
|
|
1295
|
+
FlatTreeControl,
|
|
1296
|
+
NestedTreeControl,
|
|
1297
|
+
getTreeControlFunctionsMissingError,
|
|
1298
|
+
getTreeControlMissingError,
|
|
1299
|
+
getTreeMissingMatchingNodeDefError,
|
|
1300
|
+
getTreeMultipleDefaultNodeDefsError,
|
|
1301
|
+
getTreeNoValidDataSourceError,
|
|
1302
|
+
};
|
|
1303
|
+
//# sourceMappingURL=tree.mjs.map
|