@angular/cdk-experimental 13.0.0-next.7 → 13.0.0-rc.2
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/column-resize/column-resize-directives/column-resize-flex.d.ts +3 -0
- package/column-resize/column-resize-directives/column-resize.d.ts +3 -0
- package/column-resize/column-resize-directives/default-enabled-column-resize-flex.d.ts +3 -0
- package/column-resize/column-resize-directives/default-enabled-column-resize.d.ts +3 -0
- package/column-resize/column-resize-module.d.ts +11 -7
- package/column-resize/column-resize-notifier.d.ts +5 -7
- package/column-resize/column-resize.d.ts +3 -0
- package/column-resize/column-resize_public_index.d.ts +4 -0
- package/column-resize/column-size-store.d.ts +3 -7
- package/column-resize/event-dispatcher.d.ts +3 -0
- package/column-resize/index.d.ts +5 -2
- package/column-resize/overlay-handle.d.ts +3 -0
- package/column-resize/package.json +6 -6
- package/column-resize/resizable.d.ts +3 -0
- package/column-resize/resize-strategy.d.ts +7 -0
- package/combobox/combobox-module.d.ts +8 -7
- package/combobox/combobox-panel.d.ts +5 -2
- package/combobox/combobox-popup.d.ts +3 -0
- package/combobox/combobox.d.ts +8 -5
- package/combobox/combobox_public_index.d.ts +4 -0
- package/combobox/index.d.ts +5 -1
- package/combobox/package.json +6 -6
- package/dialog/dialog-container.d.ts +4 -1
- package/dialog/dialog-module.d.ts +8 -7
- package/dialog/dialog.d.ts +3 -0
- package/dialog/dialog_public_index.d.ts +4 -0
- package/dialog/index.d.ts +5 -1
- package/dialog/package.json +6 -6
- package/esm2020/column-resize/column-resize-directives/column-resize-flex.mjs +42 -0
- package/esm2020/column-resize/column-resize-directives/column-resize.mjs +42 -0
- package/{esm2015/column-resize/column-resize-directives/constants.js → esm2020/column-resize/column-resize-directives/constants.mjs} +0 -0
- package/esm2020/column-resize/column-resize-directives/default-enabled-column-resize-flex.mjs +48 -0
- package/esm2020/column-resize/column-resize-directives/default-enabled-column-resize.mjs +48 -0
- package/esm2020/column-resize/column-resize-module.mjs +46 -0
- package/esm2020/column-resize/column-resize-notifier.mjs +52 -0
- package/esm2020/column-resize/column-resize.mjs +82 -0
- package/esm2020/column-resize/column-resize_public_index.mjs +5 -0
- package/esm2020/column-resize/column-size-store.mjs +20 -0
- package/esm2020/column-resize/event-dispatcher.mjs +70 -0
- package/esm2020/column-resize/index.mjs +9 -0
- package/esm2020/column-resize/overlay-handle.mjs +146 -0
- package/{esm2015/column-resize/public-api.js → esm2020/column-resize/public-api.mjs} +0 -0
- package/esm2020/column-resize/resizable.mjs +195 -0
- package/{esm2015/column-resize/resize-ref.js → esm2020/column-resize/resize-ref.mjs} +1 -1
- package/esm2020/column-resize/resize-strategy.mjs +230 -0
- package/{esm2015/column-resize/selectors.js → esm2020/column-resize/selectors.mjs} +0 -0
- package/esm2020/combobox/combobox-module.mjs +28 -0
- package/esm2020/combobox/combobox-panel.mjs +48 -0
- package/esm2020/combobox/combobox-popup.mjs +83 -0
- package/esm2020/combobox/combobox.mjs +261 -0
- package/esm2020/combobox/combobox_public_index.mjs +5 -0
- package/esm2020/combobox/index.mjs +9 -0
- package/{esm2015/combobox/public-api.js → esm2020/combobox/public-api.mjs} +0 -0
- package/{esm2015/dialog/dialog-config.js → esm2020/dialog/dialog-config.mjs} +0 -0
- package/esm2020/dialog/dialog-container.mjs +310 -0
- package/esm2020/dialog/dialog-injectors.mjs +30 -0
- package/esm2020/dialog/dialog-module.mjs +57 -0
- package/esm2020/dialog/dialog-ref.mjs +116 -0
- package/esm2020/dialog/dialog.mjs +252 -0
- package/esm2020/dialog/dialog_public_index.mjs +5 -0
- package/esm2020/dialog/index.mjs +9 -0
- package/{esm2015/dialog/public-api.js → esm2020/dialog/public-api.mjs} +0 -0
- package/{esm2015/index.js → esm2020/index.mjs} +0 -0
- package/esm2020/listbox/index.mjs +9 -0
- package/esm2020/listbox/listbox-module.mjs +24 -0
- package/esm2020/listbox/listbox.mjs +499 -0
- package/esm2020/listbox/listbox_public_index.mjs +5 -0
- package/{esm2015/listbox/public-api.js → esm2020/listbox/public-api.mjs} +0 -0
- package/esm2020/menu/context-menu.mjs +287 -0
- package/esm2020/menu/index.mjs +9 -0
- package/esm2020/menu/menu-aim.mjs +199 -0
- package/esm2020/menu/menu-bar.mjs +272 -0
- package/{esm2015/menu/menu-errors.js → esm2020/menu/menu-errors.mjs} +1 -1
- package/esm2020/menu/menu-group.mjs +68 -0
- package/{esm2015/menu/menu-interface.js → esm2020/menu/menu-interface.mjs} +0 -0
- package/esm2020/menu/menu-item-checkbox.mjs +48 -0
- package/esm2020/menu/menu-item-radio.mjs +90 -0
- package/esm2020/menu/menu-item-selectable.mjs +57 -0
- package/esm2020/menu/menu-item-trigger.mjs +361 -0
- package/esm2020/menu/menu-item.mjs +291 -0
- package/esm2020/menu/menu-module.mjs +64 -0
- package/esm2020/menu/menu-panel.mjs +37 -0
- package/{esm2015/menu/menu-stack.js → esm2020/menu/menu-stack.mjs} +0 -0
- package/esm2020/menu/menu.mjs +316 -0
- package/esm2020/menu/menu_public_index.mjs +5 -0
- package/{esm2015/menu/pointer-focus-tracker.js → esm2020/menu/pointer-focus-tracker.mjs} +1 -1
- package/{esm2015/menu/public-api.js → esm2020/menu/public-api.mjs} +0 -0
- package/{esm2015/popover-edit/constants.js → esm2020/popover-edit/constants.mjs} +0 -0
- package/esm2020/popover-edit/edit-event-dispatcher.mjs +215 -0
- package/esm2020/popover-edit/edit-ref.mjs +84 -0
- package/esm2020/popover-edit/edit-services.mjs +48 -0
- package/esm2020/popover-edit/focus-dispatcher.mjs +82 -0
- package/esm2020/popover-edit/focus-escape-notifier.mjs +63 -0
- package/{esm2015/popover-edit/form-value-container.js → esm2020/popover-edit/form-value-container.mjs} +0 -0
- package/esm2020/popover-edit/index.mjs +9 -0
- package/esm2020/popover-edit/lens-directives.mjs +210 -0
- package/esm2020/popover-edit/polyfill.mjs +37 -0
- package/esm2020/popover-edit/popover-edit-module.mjs +62 -0
- package/esm2020/popover-edit/popover-edit-position-strategy-factory.mjs +76 -0
- package/esm2020/popover-edit/popover-edit_public_index.mjs +5 -0
- package/{esm2015/popover-edit/public-api.js → esm2020/popover-edit/public-api.mjs} +0 -0
- package/esm2020/popover-edit/table-directives.mjs +400 -0
- package/{esm2015/public-api.js → esm2020/public-api.mjs} +0 -0
- package/esm2020/scrolling/auto-size-virtual-scroll.mjs +421 -0
- package/esm2020/scrolling/index.mjs +9 -0
- package/{esm2015/scrolling/public-api.js → esm2020/scrolling/public-api.mjs} +0 -0
- package/esm2020/scrolling/scrolling-module.mjs +23 -0
- package/esm2020/scrolling/scrolling_public_index.mjs +5 -0
- package/esm2020/selection/index.mjs +9 -0
- package/{esm2015/selection/public-api.js → esm2020/selection/public-api.mjs} +0 -0
- package/esm2020/selection/row-selection.mjs +49 -0
- package/esm2020/selection/select-all.mjs +109 -0
- package/esm2020/selection/selection-column.mjs +134 -0
- package/esm2020/selection/selection-module.mjs +40 -0
- package/{esm2015/selection/selection-set.js → esm2020/selection/selection-set.mjs} +1 -1
- package/esm2020/selection/selection-toggle.mjs +101 -0
- package/esm2020/selection/selection.mjs +186 -0
- package/esm2020/selection/selection_public_index.mjs +5 -0
- package/esm2020/table-scroll-container/index.mjs +9 -0
- package/{esm2015/table-scroll-container/public-api.js → esm2020/table-scroll-container/public-api.mjs} +0 -0
- package/esm2020/table-scroll-container/table-scroll-container-module.mjs +23 -0
- package/esm2020/table-scroll-container/table-scroll-container.mjs +131 -0
- package/esm2020/table-scroll-container/table-scroll-container_public_index.mjs +5 -0
- package/{esm2015/version.js → esm2020/version.mjs} +1 -1
- package/fesm2015/{cdk-experimental.js → cdk-experimental.mjs} +2 -2
- package/fesm2015/cdk-experimental.mjs.map +1 -0
- package/fesm2015/{column-resize.js → column-resize.mjs} +213 -175
- package/fesm2015/column-resize.mjs.map +1 -0
- package/fesm2015/{combobox.js → combobox.mjs} +134 -102
- package/fesm2015/combobox.mjs.map +1 -0
- package/fesm2015/dialog.mjs +813 -0
- package/fesm2015/dialog.mjs.map +1 -0
- package/fesm2015/{listbox.js → listbox.mjs} +128 -91
- package/fesm2015/listbox.mjs.map +1 -0
- package/fesm2015/{menu.js → menu.mjs} +576 -397
- package/fesm2015/menu.mjs.map +1 -0
- package/fesm2015/{popover-edit.js → popover-edit.mjs} +257 -230
- package/fesm2015/popover-edit.mjs.map +1 -0
- package/fesm2015/{scrolling.js → scrolling.mjs} +66 -36
- package/fesm2015/scrolling.mjs.map +1 -0
- package/fesm2015/selection.mjs +693 -0
- package/fesm2015/selection.mjs.map +1 -0
- package/fesm2015/{table-scroll-container.js → table-scroll-container.mjs} +43 -30
- package/fesm2015/table-scroll-container.mjs.map +1 -0
- package/fesm2020/cdk-experimental.mjs +30 -0
- package/fesm2020/cdk-experimental.mjs.map +1 -0
- package/fesm2020/column-resize.mjs +1016 -0
- package/fesm2020/column-resize.mjs.map +1 -0
- package/fesm2020/combobox.mjs +430 -0
- package/fesm2020/combobox.mjs.map +1 -0
- package/{fesm2015/dialog.js → fesm2020/dialog.mjs} +156 -104
- package/fesm2020/dialog.mjs.map +1 -0
- package/fesm2020/listbox.mjs +541 -0
- package/fesm2020/listbox.mjs.map +1 -0
- package/fesm2020/menu.mjs +2202 -0
- package/fesm2020/menu.mjs.map +1 -0
- package/fesm2020/popover-edit.mjs +1289 -0
- package/fesm2020/popover-edit.mjs.map +1 -0
- package/fesm2020/scrolling.mjs +464 -0
- package/fesm2020/scrolling.mjs.map +1 -0
- package/{fesm2015/selection.js → fesm2020/selection.mjs} +195 -107
- package/fesm2020/selection.mjs.map +1 -0
- package/fesm2020/table-scroll-container.mjs +173 -0
- package/fesm2020/table-scroll-container.mjs.map +1 -0
- package/listbox/index.d.ts +5 -1
- package/listbox/listbox-module.d.ts +5 -7
- package/listbox/listbox.d.ts +5 -0
- package/listbox/listbox_public_index.d.ts +4 -0
- package/listbox/package.json +6 -6
- package/menu/context-menu.d.ts +5 -0
- package/menu/index.d.ts +5 -3
- package/menu/menu-aim.d.ts +5 -0
- package/menu/menu-bar.d.ts +3 -0
- package/menu/menu-group.d.ts +3 -0
- package/menu/menu-item-checkbox.d.ts +3 -7
- package/menu/menu-item-radio.d.ts +3 -0
- package/menu/menu-item-selectable.d.ts +3 -0
- package/menu/menu-item-trigger.d.ts +3 -0
- package/menu/menu-item.d.ts +3 -0
- package/menu/menu-module.d.ts +15 -7
- package/menu/menu-panel.d.ts +3 -0
- package/menu/menu.d.ts +3 -0
- package/menu/menu_public_index.d.ts +4 -0
- package/menu/package.json +6 -6
- package/package.json +94 -8
- package/popover-edit/edit-event-dispatcher.d.ts +3 -0
- package/popover-edit/edit-ref.d.ts +3 -0
- package/popover-edit/edit-services.d.ts +3 -0
- package/popover-edit/focus-dispatcher.d.ts +3 -0
- package/popover-edit/focus-escape-notifier.d.ts +3 -0
- package/popover-edit/index.d.ts +5 -3
- package/popover-edit/lens-directives.d.ts +7 -0
- package/popover-edit/package.json +6 -6
- package/popover-edit/popover-edit-module.d.ts +7 -7
- package/popover-edit/popover-edit-position-strategy-factory.d.ts +5 -0
- package/popover-edit/popover-edit_public_index.d.ts +4 -0
- package/popover-edit/table-directives.d.ts +11 -0
- package/scrolling/auto-size-virtual-scroll.d.ts +3 -0
- package/scrolling/index.d.ts +5 -1
- package/scrolling/package.json +6 -6
- package/scrolling/scrolling-module.d.ts +5 -7
- package/scrolling/scrolling_public_index.d.ts +4 -0
- package/selection/index.d.ts +5 -1
- package/selection/package.json +6 -6
- package/selection/row-selection.d.ts +3 -0
- package/selection/select-all.d.ts +3 -0
- package/selection/selection-column.d.ts +3 -0
- package/selection/selection-module.d.ts +11 -7
- package/selection/selection-toggle.d.ts +3 -0
- package/selection/selection.d.ts +3 -0
- package/selection/selection_public_index.d.ts +4 -0
- package/table-scroll-container/index.d.ts +5 -1
- package/table-scroll-container/package.json +6 -6
- package/table-scroll-container/table-scroll-container-module.d.ts +5 -7
- package/table-scroll-container/table-scroll-container.d.ts +3 -0
- package/table-scroll-container/table-scroll-container_public_index.d.ts +4 -0
- package/bundles/cdk-experimental-column-resize.umd.js +0 -1324
- package/bundles/cdk-experimental-column-resize.umd.js.map +0 -1
- package/bundles/cdk-experimental-combobox.umd.js +0 -443
- package/bundles/cdk-experimental-combobox.umd.js.map +0 -1
- package/bundles/cdk-experimental-dialog.umd.js +0 -1113
- package/bundles/cdk-experimental-dialog.umd.js.map +0 -1
- package/bundles/cdk-experimental-listbox.umd.js +0 -935
- package/bundles/cdk-experimental-listbox.umd.js.map +0 -1
- package/bundles/cdk-experimental-menu.umd.js +0 -2461
- package/bundles/cdk-experimental-menu.umd.js.map +0 -1
- package/bundles/cdk-experimental-popover-edit.umd.js +0 -1679
- package/bundles/cdk-experimental-popover-edit.umd.js.map +0 -1
- package/bundles/cdk-experimental-scrolling.umd.js +0 -459
- package/bundles/cdk-experimental-scrolling.umd.js.map +0 -1
- package/bundles/cdk-experimental-selection.umd.js +0 -961
- package/bundles/cdk-experimental-selection.umd.js.map +0 -1
- package/bundles/cdk-experimental-table-scroll-container.umd.js +0 -499
- package/bundles/cdk-experimental-table-scroll-container.umd.js.map +0 -1
- package/bundles/cdk-experimental.umd.js +0 -38
- package/bundles/cdk-experimental.umd.js.map +0 -1
- package/column-resize/index.metadata.json +0 -1
- package/combobox/index.metadata.json +0 -1
- package/dialog/index.metadata.json +0 -1
- package/esm2015/cdk-experimental.externs.js +0 -0
- package/esm2015/column-resize/column-resize-directives/column-resize-flex.js +0 -46
- package/esm2015/column-resize/column-resize-directives/column-resize.js +0 -46
- package/esm2015/column-resize/column-resize-directives/default-enabled-column-resize-flex.js +0 -46
- package/esm2015/column-resize/column-resize-directives/default-enabled-column-resize.js +0 -46
- package/esm2015/column-resize/column-resize-module.js +0 -37
- package/esm2015/column-resize/column-resize-notifier.js +0 -45
- package/esm2015/column-resize/column-resize.externs.js +0 -6
- package/esm2015/column-resize/column-resize.js +0 -71
- package/esm2015/column-resize/column-size-store.js +0 -17
- package/esm2015/column-resize/event-dispatcher.js +0 -70
- package/esm2015/column-resize/index.js +0 -6
- package/esm2015/column-resize/overlay-handle.js +0 -139
- package/esm2015/column-resize/resizable.js +0 -185
- package/esm2015/column-resize/resize-strategy.js +0 -227
- package/esm2015/combobox/combobox-module.js +0 -23
- package/esm2015/combobox/combobox-panel.js +0 -55
- package/esm2015/combobox/combobox-popup.js +0 -74
- package/esm2015/combobox/combobox.externs.js +0 -6
- package/esm2015/combobox/combobox.js +0 -248
- package/esm2015/combobox/index.js +0 -5
- package/esm2015/dialog/dialog-container.js +0 -289
- package/esm2015/dialog/dialog-injectors.js +0 -30
- package/esm2015/dialog/dialog-module.js +0 -47
- package/esm2015/dialog/dialog-ref.js +0 -115
- package/esm2015/dialog/dialog.externs.js +0 -6
- package/esm2015/dialog/dialog.js +0 -238
- package/esm2015/dialog/index.js +0 -5
- package/esm2015/listbox/index.js +0 -5
- package/esm2015/listbox/listbox-module.js +0 -19
- package/esm2015/listbox/listbox.externs.js +0 -6
- package/esm2015/listbox/listbox.js +0 -481
- package/esm2015/menu/context-menu.js +0 -280
- package/esm2015/menu/index.js +0 -6
- package/esm2015/menu/menu-aim.js +0 -195
- package/esm2015/menu/menu-bar.js +0 -252
- package/esm2015/menu/menu-group.js +0 -63
- package/esm2015/menu/menu-item-checkbox.js +0 -41
- package/esm2015/menu/menu-item-radio.js +0 -73
- package/esm2015/menu/menu-item-selectable.js +0 -51
- package/esm2015/menu/menu-item-trigger.js +0 -354
- package/esm2015/menu/menu-item.js +0 -253
- package/esm2015/menu/menu-module.js +0 -41
- package/esm2015/menu/menu-panel.js +0 -37
- package/esm2015/menu/menu.externs.js +0 -6
- package/esm2015/menu/menu.js +0 -293
- package/esm2015/popover-edit/edit-event-dispatcher.js +0 -215
- package/esm2015/popover-edit/edit-ref.js +0 -82
- package/esm2015/popover-edit/edit-services.js +0 -49
- package/esm2015/popover-edit/focus-dispatcher.js +0 -83
- package/esm2015/popover-edit/focus-escape-notifier.js +0 -64
- package/esm2015/popover-edit/index.js +0 -7
- package/esm2015/popover-edit/lens-directives.js +0 -199
- package/esm2015/popover-edit/polyfill.js +0 -35
- package/esm2015/popover-edit/popover-edit-module.js +0 -38
- package/esm2015/popover-edit/popover-edit-position-strategy-factory.js +0 -70
- package/esm2015/popover-edit/popover-edit.externs.js +0 -6
- package/esm2015/popover-edit/table-directives.js +0 -390
- package/esm2015/scrolling/auto-size-virtual-scroll.js +0 -403
- package/esm2015/scrolling/index.js +0 -5
- package/esm2015/scrolling/scrolling-module.js +0 -18
- package/esm2015/scrolling/scrolling.externs.js +0 -6
- package/esm2015/selection/index.js +0 -5
- package/esm2015/selection/row-selection.js +0 -41
- package/esm2015/selection/select-all.js +0 -96
- package/esm2015/selection/selection-column.js +0 -93
- package/esm2015/selection/selection-module.js +0 -40
- package/esm2015/selection/selection-toggle.js +0 -82
- package/esm2015/selection/selection.externs.js +0 -6
- package/esm2015/selection/selection.js +0 -176
- package/esm2015/table-scroll-container/index.js +0 -5
- package/esm2015/table-scroll-container/table-scroll-container-module.js +0 -18
- package/esm2015/table-scroll-container/table-scroll-container.externs.js +0 -6
- package/esm2015/table-scroll-container/table-scroll-container.js +0 -133
- package/fesm2015/cdk-experimental.js.map +0 -1
- package/fesm2015/column-resize.js.map +0 -1
- package/fesm2015/combobox.js.map +0 -1
- package/fesm2015/dialog.js.map +0 -1
- package/fesm2015/listbox.js.map +0 -1
- package/fesm2015/menu.js.map +0 -1
- package/fesm2015/popover-edit.js.map +0 -1
- package/fesm2015/scrolling.js.map +0 -1
- package/fesm2015/selection.js.map +0 -1
- package/fesm2015/table-scroll-container.js.map +0 -1
- package/listbox/index.metadata.json +0 -1
- package/menu/index.metadata.json +0 -1
- package/popover-edit/index.metadata.json +0 -1
- package/scrolling/index.metadata.json +0 -1
- package/selection/index.metadata.json +0 -1
- package/table-scroll-container/index.metadata.json +0 -1
|
@@ -0,0 +1,1289 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { Injectable, Self, EventEmitter, Directive, HostListener, Input, Inject, NgModule } from '@angular/core';
|
|
3
|
+
import { Subject, pipe, combineLatest, Observable, fromEvent, fromEventPattern, merge } from 'rxjs';
|
|
4
|
+
import { distinctUntilChanged, startWith, shareReplay, filter, map, auditTime, audit, debounceTime, skip, take, takeUntil, mapTo, throttleTime, share, withLatestFrom } from 'rxjs/operators';
|
|
5
|
+
import * as i1 from '@angular/forms';
|
|
6
|
+
import * as i1$1 from '@angular/cdk/bidi';
|
|
7
|
+
import { RIGHT_ARROW, LEFT_ARROW, DOWN_ARROW, UP_ARROW, hasModifierKey } from '@angular/cdk/keycodes';
|
|
8
|
+
import * as i2 from '@angular/cdk/overlay';
|
|
9
|
+
import { OverlayModule } from '@angular/cdk/overlay';
|
|
10
|
+
import { TemplatePortal } from '@angular/cdk/portal';
|
|
11
|
+
import * as i4 from '@angular/cdk/a11y';
|
|
12
|
+
import { FocusTrap } from '@angular/cdk/a11y';
|
|
13
|
+
import * as i7 from '@angular/cdk/scrolling';
|
|
14
|
+
import { DOCUMENT } from '@angular/common';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @license
|
|
18
|
+
* Copyright Google LLC All Rights Reserved.
|
|
19
|
+
*
|
|
20
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
21
|
+
* found in the LICENSE file at https://angular.io/license
|
|
22
|
+
*/
|
|
23
|
+
/** Selector for finding table cells. */
|
|
24
|
+
const CELL_SELECTOR = '.cdk-cell, .mat-cell, td';
|
|
25
|
+
/** Selector for finding editable table cells. */
|
|
26
|
+
const EDITABLE_CELL_SELECTOR = '.cdk-popover-edit-cell, .mat-popover-edit-cell';
|
|
27
|
+
/** Selector for finding table rows. */
|
|
28
|
+
const ROW_SELECTOR = '.cdk-row, .mat-row, tr';
|
|
29
|
+
/** Selector for finding the table element. */
|
|
30
|
+
const TABLE_SELECTOR = 'table, cdk-table, mat-table';
|
|
31
|
+
/** CSS class added to the edit lens pane. */
|
|
32
|
+
const EDIT_PANE_CLASS = 'cdk-edit-pane';
|
|
33
|
+
/** Selector for finding the edit lens pane. */
|
|
34
|
+
const EDIT_PANE_SELECTOR = `.${EDIT_PANE_CLASS}, .mat-edit-pane`;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* @license
|
|
38
|
+
* Copyright Google LLC All Rights Reserved.
|
|
39
|
+
*
|
|
40
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
41
|
+
* found in the LICENSE file at https://angular.io/license
|
|
42
|
+
*/
|
|
43
|
+
/** IE 11 compatible matches implementation. */
|
|
44
|
+
function matches(element, selector) {
|
|
45
|
+
return element.matches
|
|
46
|
+
? element.matches(selector)
|
|
47
|
+
: element['msMatchesSelector'](selector);
|
|
48
|
+
}
|
|
49
|
+
/** IE 11 compatible closest implementation that is able to start from non-Element Nodes. */
|
|
50
|
+
function closest(element, selector) {
|
|
51
|
+
if (!(element instanceof Node)) {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
let curr = element;
|
|
55
|
+
while (curr != null && !(curr instanceof Element)) {
|
|
56
|
+
curr = curr.parentNode;
|
|
57
|
+
}
|
|
58
|
+
return (curr &&
|
|
59
|
+
(hasNativeClosest
|
|
60
|
+
? curr.closest(selector)
|
|
61
|
+
: polyfillClosest(curr, selector)));
|
|
62
|
+
}
|
|
63
|
+
/** Polyfill for browsers without Element.closest. */
|
|
64
|
+
function polyfillClosest(element, selector) {
|
|
65
|
+
let curr = element;
|
|
66
|
+
while (curr != null && !(curr instanceof Element && matches(curr, selector))) {
|
|
67
|
+
curr = curr.parentNode;
|
|
68
|
+
}
|
|
69
|
+
return (curr || null);
|
|
70
|
+
}
|
|
71
|
+
const hasNativeClosest = !!Element.prototype.closest;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* @license
|
|
75
|
+
* Copyright Google LLC All Rights Reserved.
|
|
76
|
+
*
|
|
77
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
78
|
+
* found in the LICENSE file at https://angular.io/license
|
|
79
|
+
*/
|
|
80
|
+
/** The delay applied to mouse events before hiding or showing hover content. */
|
|
81
|
+
const MOUSE_EVENT_DELAY_MS = 40;
|
|
82
|
+
/** The delay for reacting to focus/blur changes. */
|
|
83
|
+
const FOCUS_DELAY = 0;
|
|
84
|
+
// Note: this class is generic, rather than referencing EditRef directly, in order to avoid
|
|
85
|
+
// circular imports. If we were to reference it here, importing the registry into the
|
|
86
|
+
// class that is registering itself will introduce a circular import.
|
|
87
|
+
/**
|
|
88
|
+
* Service for sharing delegated events and state for triggering table edits.
|
|
89
|
+
*/
|
|
90
|
+
class EditEventDispatcher {
|
|
91
|
+
constructor(_ngZone) {
|
|
92
|
+
this._ngZone = _ngZone;
|
|
93
|
+
/** A subject that indicates which table cell is currently editing (unless it is disabled). */
|
|
94
|
+
this.editing = new Subject();
|
|
95
|
+
/** A subject that indicates which table row is currently hovered. */
|
|
96
|
+
this.hovering = new Subject();
|
|
97
|
+
/** A subject that indicates which table row currently contains focus. */
|
|
98
|
+
this.focused = new Subject();
|
|
99
|
+
/** A subject that indicates all elements in the table matching ROW_SELECTOR. */
|
|
100
|
+
this.allRows = new Subject();
|
|
101
|
+
/** A subject that emits mouse move events from the table indicating the targeted row. */
|
|
102
|
+
this.mouseMove = new Subject();
|
|
103
|
+
// TODO: Use WeakSet once IE11 support is dropped.
|
|
104
|
+
/**
|
|
105
|
+
* Tracks the currently disabled editable cells - edit calls will be ignored
|
|
106
|
+
* for these cells.
|
|
107
|
+
*/
|
|
108
|
+
this.disabledCells = new WeakMap();
|
|
109
|
+
this._editRef = null;
|
|
110
|
+
// Optimization: Precompute common pipeable operators used per row/cell.
|
|
111
|
+
this._distinctUntilChanged = distinctUntilChanged();
|
|
112
|
+
this._startWithNull = startWith(null);
|
|
113
|
+
this._distinctShare = pipe(this._distinctUntilChanged, shareReplay(1));
|
|
114
|
+
this._startWithNullDistinct = pipe(this._startWithNull, this._distinctUntilChanged);
|
|
115
|
+
this.editingAndEnabled = this.editing.pipe(filter(cell => cell == null || !this.disabledCells.has(cell)), shareReplay(1));
|
|
116
|
+
/** An observable that emits the row containing focus or an active edit. */
|
|
117
|
+
this.editingOrFocused = combineLatest([
|
|
118
|
+
this.editingAndEnabled.pipe(map(cell => closest(cell, ROW_SELECTOR)), this._startWithNull),
|
|
119
|
+
this.focused.pipe(this._startWithNull),
|
|
120
|
+
]).pipe(map(([editingRow, focusedRow]) => focusedRow || editingRow), this._distinctUntilChanged, auditTime(FOCUS_DELAY), // Use audit to skip over blur events to the next focused element.
|
|
121
|
+
this._distinctUntilChanged, shareReplay(1));
|
|
122
|
+
/** Tracks rows that contain hover content with a reference count. */
|
|
123
|
+
this._rowsWithHoverContent = new WeakMap();
|
|
124
|
+
/** The table cell that has an active edit lens (or null). */
|
|
125
|
+
this._currentlyEditing = null;
|
|
126
|
+
/** The combined set of row hover content states organized by row. */
|
|
127
|
+
this._hoveredContentStateDistinct = combineLatest([
|
|
128
|
+
this._getFirstRowWithHoverContent(),
|
|
129
|
+
this._getLastRowWithHoverContent(),
|
|
130
|
+
this.editingOrFocused,
|
|
131
|
+
this.hovering.pipe(distinctUntilChanged(), audit(row => this.mouseMove.pipe(filter(mouseMoveRow => row === mouseMoveRow), this._startWithNull, debounceTime(MOUSE_EVENT_DELAY_MS))), this._startWithNullDistinct),
|
|
132
|
+
]).pipe(skip(1), // Skip the initial emission of [null, null, null, null].
|
|
133
|
+
map(computeHoverContentState), distinctUntilChanged(areMapEntriesEqual),
|
|
134
|
+
// Optimization: Enter the zone before shareReplay so that we trigger a single
|
|
135
|
+
// ApplicationRef.tick for all row updates.
|
|
136
|
+
this._enterZone(), shareReplay(1));
|
|
137
|
+
this._editingAndEnabledDistinct = this.editingAndEnabled.pipe(distinctUntilChanged(), this._enterZone(), shareReplay(1));
|
|
138
|
+
// Optimization: Share row events observable with subsequent callers.
|
|
139
|
+
// At startup, calls will be sequential by row.
|
|
140
|
+
this._lastSeenRow = null;
|
|
141
|
+
this._lastSeenRowHoverOrFocus = null;
|
|
142
|
+
this._editingAndEnabledDistinct.subscribe(cell => {
|
|
143
|
+
this._currentlyEditing = cell;
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
/** The EditRef for the currently active edit lens (if any). */
|
|
147
|
+
get editRef() {
|
|
148
|
+
return this._editRef;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Gets an Observable that emits true when the specified element's cell
|
|
152
|
+
* is editing and false when not.
|
|
153
|
+
*/
|
|
154
|
+
editingCell(element) {
|
|
155
|
+
let cell = null;
|
|
156
|
+
return this._editingAndEnabledDistinct.pipe(map(editCell => editCell === (cell || (cell = closest(element, CELL_SELECTOR)))), this._distinctUntilChanged);
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Stops editing for the specified cell. If the specified cell is not the current
|
|
160
|
+
* edit cell, does nothing.
|
|
161
|
+
*/
|
|
162
|
+
doneEditingCell(element) {
|
|
163
|
+
const cell = closest(element, CELL_SELECTOR);
|
|
164
|
+
if (this._currentlyEditing === cell) {
|
|
165
|
+
this.editing.next(null);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
/** Sets the currently active EditRef. */
|
|
169
|
+
setActiveEditRef(ref) {
|
|
170
|
+
this._editRef = ref;
|
|
171
|
+
}
|
|
172
|
+
/** Unsets the currently active EditRef, if the specified editRef is active. */
|
|
173
|
+
unsetActiveEditRef(ref) {
|
|
174
|
+
if (this._editRef !== ref) {
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
this._editRef = null;
|
|
178
|
+
}
|
|
179
|
+
/** Adds the specified table row to be tracked for first/last row comparisons. */
|
|
180
|
+
registerRowWithHoverContent(row) {
|
|
181
|
+
this._rowsWithHoverContent.set(row, (this._rowsWithHoverContent.get(row) || 0) + 1);
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Reference decrements and ultimately removes the specified table row from first/last row
|
|
185
|
+
* comparisons.
|
|
186
|
+
*/
|
|
187
|
+
deregisterRowWithHoverContent(row) {
|
|
188
|
+
const refCount = this._rowsWithHoverContent.get(row) || 0;
|
|
189
|
+
if (refCount <= 1) {
|
|
190
|
+
this._rowsWithHoverContent.delete(row);
|
|
191
|
+
}
|
|
192
|
+
else {
|
|
193
|
+
this._rowsWithHoverContent.set(row, refCount - 1);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Gets an Observable that emits true when the specified element's row
|
|
198
|
+
* contains the focused element or is being hovered over and false when not.
|
|
199
|
+
* Hovering is defined as when the mouse has momentarily stopped moving over the cell.
|
|
200
|
+
*/
|
|
201
|
+
hoverOrFocusOnRow(row) {
|
|
202
|
+
if (row !== this._lastSeenRow) {
|
|
203
|
+
this._lastSeenRow = row;
|
|
204
|
+
this._lastSeenRowHoverOrFocus = this._hoveredContentStateDistinct.pipe(map(state => state.get(row) || 0 /* OFF */), this._distinctShare);
|
|
205
|
+
}
|
|
206
|
+
return this._lastSeenRowHoverOrFocus;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* RxJS operator that enters the Angular zone, used to reduce boilerplate in
|
|
210
|
+
* re-entering the zone for stream pipelines.
|
|
211
|
+
*/
|
|
212
|
+
_enterZone() {
|
|
213
|
+
return (source) => new Observable(observer => source.subscribe({
|
|
214
|
+
next: value => this._ngZone.run(() => observer.next(value)),
|
|
215
|
+
error: err => observer.error(err),
|
|
216
|
+
complete: () => observer.complete(),
|
|
217
|
+
}));
|
|
218
|
+
}
|
|
219
|
+
_getFirstRowWithHoverContent() {
|
|
220
|
+
return this._mapAllRowsToSingleRow(rows => {
|
|
221
|
+
for (let i = 0, row; (row = rows[i]); i++) {
|
|
222
|
+
if (this._rowsWithHoverContent.has(row)) {
|
|
223
|
+
return row;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
return null;
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
_getLastRowWithHoverContent() {
|
|
230
|
+
return this._mapAllRowsToSingleRow(rows => {
|
|
231
|
+
for (let i = rows.length - 1, row; (row = rows[i]); i--) {
|
|
232
|
+
if (this._rowsWithHoverContent.has(row)) {
|
|
233
|
+
return row;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
return null;
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
_mapAllRowsToSingleRow(mapper) {
|
|
240
|
+
return this.allRows.pipe(map(mapper), this._startWithNullDistinct);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
EditEventDispatcher.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: EditEventDispatcher, deps: [{ token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
244
|
+
EditEventDispatcher.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: EditEventDispatcher });
|
|
245
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: EditEventDispatcher, decorators: [{
|
|
246
|
+
type: Injectable
|
|
247
|
+
}], ctorParameters: function () { return [{ type: i0.NgZone }]; } });
|
|
248
|
+
function computeHoverContentState([firstRow, lastRow, activeRow, hoverRow,]) {
|
|
249
|
+
const hoverContentState = new Map();
|
|
250
|
+
// Add focusable rows.
|
|
251
|
+
for (const focussableRow of [
|
|
252
|
+
firstRow,
|
|
253
|
+
lastRow,
|
|
254
|
+
activeRow && activeRow.previousElementSibling,
|
|
255
|
+
activeRow && activeRow.nextElementSibling,
|
|
256
|
+
]) {
|
|
257
|
+
if (focussableRow) {
|
|
258
|
+
hoverContentState.set(focussableRow, 1 /* FOCUSABLE */);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
// Add/overwrite with fully visible rows.
|
|
262
|
+
for (const onRow of [activeRow, hoverRow]) {
|
|
263
|
+
if (onRow) {
|
|
264
|
+
hoverContentState.set(onRow, 2 /* ON */);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
return hoverContentState;
|
|
268
|
+
}
|
|
269
|
+
function areMapEntriesEqual(a, b) {
|
|
270
|
+
if (a.size !== b.size) {
|
|
271
|
+
return false;
|
|
272
|
+
}
|
|
273
|
+
// TODO: use Map.prototype.entries once we're off IE11.
|
|
274
|
+
for (const aKey of Array.from(a.keys())) {
|
|
275
|
+
if (b.get(aKey) !== a.get(aKey)) {
|
|
276
|
+
return false;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
return true;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* @license
|
|
284
|
+
* Copyright Google LLC All Rights Reserved.
|
|
285
|
+
*
|
|
286
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
287
|
+
* found in the LICENSE file at https://angular.io/license
|
|
288
|
+
*/
|
|
289
|
+
/**
|
|
290
|
+
* Used for communication between the form within the edit lens and the
|
|
291
|
+
* table that launched it. Provided by CdkEditControl within the lens.
|
|
292
|
+
*/
|
|
293
|
+
class EditRef {
|
|
294
|
+
constructor(_form, _editEventDispatcher, _ngZone) {
|
|
295
|
+
this._form = _form;
|
|
296
|
+
this._editEventDispatcher = _editEventDispatcher;
|
|
297
|
+
this._ngZone = _ngZone;
|
|
298
|
+
/** Emits the final value of this edit instance before closing. */
|
|
299
|
+
this._finalValueSubject = new Subject();
|
|
300
|
+
this.finalValue = this._finalValueSubject;
|
|
301
|
+
/** Emits when the user tabs out of this edit lens before closing. */
|
|
302
|
+
this._blurredSubject = new Subject();
|
|
303
|
+
this.blurred = this._blurredSubject;
|
|
304
|
+
this._editEventDispatcher.setActiveEditRef(this);
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Called by the host directive's OnInit hook. Reads the initial state of the
|
|
308
|
+
* form and overrides it with persisted state from previous openings, if
|
|
309
|
+
* applicable.
|
|
310
|
+
*/
|
|
311
|
+
init(previousFormValue) {
|
|
312
|
+
// Wait for the zone to stabilize before caching the initial value.
|
|
313
|
+
// This ensures that all form controls have been initialized.
|
|
314
|
+
this._ngZone.onStable.pipe(take(1)).subscribe(() => {
|
|
315
|
+
this.updateRevertValue();
|
|
316
|
+
if (previousFormValue) {
|
|
317
|
+
this.reset(previousFormValue);
|
|
318
|
+
}
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
ngOnDestroy() {
|
|
322
|
+
this._editEventDispatcher.unsetActiveEditRef(this);
|
|
323
|
+
this._finalValueSubject.next(this._form.value);
|
|
324
|
+
this._finalValueSubject.complete();
|
|
325
|
+
}
|
|
326
|
+
/** Whether the attached form is in a valid state. */
|
|
327
|
+
isValid() {
|
|
328
|
+
return this._form.valid;
|
|
329
|
+
}
|
|
330
|
+
/** Set the form's current value as what it will be set to on revert/reset. */
|
|
331
|
+
updateRevertValue() {
|
|
332
|
+
this._revertFormValue = this._form.value;
|
|
333
|
+
}
|
|
334
|
+
/** Tells the table to close the edit popup. */
|
|
335
|
+
close() {
|
|
336
|
+
this._editEventDispatcher.editing.next(null);
|
|
337
|
+
}
|
|
338
|
+
/** Notifies the active edit that the user has moved focus out of the lens. */
|
|
339
|
+
blur() {
|
|
340
|
+
this._blurredSubject.next();
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Resets the form value to the specified value or the previously set
|
|
344
|
+
* revert value.
|
|
345
|
+
*/
|
|
346
|
+
reset(value) {
|
|
347
|
+
this._form.reset(value || this._revertFormValue);
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
EditRef.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: EditRef, deps: [{ token: i1.ControlContainer, self: true }, { token: EditEventDispatcher }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
351
|
+
EditRef.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: EditRef });
|
|
352
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: EditRef, decorators: [{
|
|
353
|
+
type: Injectable
|
|
354
|
+
}], ctorParameters: function () { return [{ type: i1.ControlContainer, decorators: [{
|
|
355
|
+
type: Self
|
|
356
|
+
}] }, { type: EditEventDispatcher }, { type: i0.NgZone }]; } });
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* @license
|
|
360
|
+
* Copyright Google LLC All Rights Reserved.
|
|
361
|
+
*
|
|
362
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
363
|
+
* found in the LICENSE file at https://angular.io/license
|
|
364
|
+
*/
|
|
365
|
+
/**
|
|
366
|
+
* Service responsible for moving cell focus around in response to keyboard events.
|
|
367
|
+
* May be overridden to customize the keyboard behavior of popover edit.
|
|
368
|
+
*/
|
|
369
|
+
class FocusDispatcher {
|
|
370
|
+
constructor(directionality) {
|
|
371
|
+
this.directionality = directionality;
|
|
372
|
+
this.keyObserver = { next: event => this.handleKeyboardEvent(event) };
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* Moves focus to earlier or later cells (in dom order) by offset cells relative to
|
|
376
|
+
* currentCell.
|
|
377
|
+
*/
|
|
378
|
+
moveFocusHorizontally(currentCell, offset) {
|
|
379
|
+
const cells = Array.from(closest(currentCell, TABLE_SELECTOR).querySelectorAll(EDITABLE_CELL_SELECTOR));
|
|
380
|
+
const currentIndex = cells.indexOf(currentCell);
|
|
381
|
+
const newIndex = currentIndex + offset;
|
|
382
|
+
if (cells[newIndex]) {
|
|
383
|
+
cells[newIndex].focus();
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
/** Moves focus to up or down by row by offset cells relative to currentCell. */
|
|
387
|
+
moveFocusVertically(currentCell, offset) {
|
|
388
|
+
const currentRow = closest(currentCell, ROW_SELECTOR);
|
|
389
|
+
const rows = Array.from(closest(currentRow, TABLE_SELECTOR).querySelectorAll(ROW_SELECTOR));
|
|
390
|
+
const currentRowIndex = rows.indexOf(currentRow);
|
|
391
|
+
const currentIndexWithinRow = Array.from(currentRow.querySelectorAll(EDITABLE_CELL_SELECTOR)).indexOf(currentCell);
|
|
392
|
+
const newRowIndex = currentRowIndex + offset;
|
|
393
|
+
if (rows[newRowIndex]) {
|
|
394
|
+
const rowToFocus = Array.from(rows[newRowIndex].querySelectorAll(EDITABLE_CELL_SELECTOR));
|
|
395
|
+
if (rowToFocus[currentIndexWithinRow]) {
|
|
396
|
+
rowToFocus[currentIndexWithinRow].focus();
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
/** Translates arrow keydown events into focus move operations. */
|
|
401
|
+
handleKeyboardEvent(event) {
|
|
402
|
+
const cell = closest(event.target, EDITABLE_CELL_SELECTOR);
|
|
403
|
+
if (!cell) {
|
|
404
|
+
return;
|
|
405
|
+
}
|
|
406
|
+
switch (event.keyCode) {
|
|
407
|
+
case UP_ARROW:
|
|
408
|
+
this.moveFocusVertically(cell, -1);
|
|
409
|
+
break;
|
|
410
|
+
case DOWN_ARROW:
|
|
411
|
+
this.moveFocusVertically(cell, 1);
|
|
412
|
+
break;
|
|
413
|
+
case LEFT_ARROW:
|
|
414
|
+
this.moveFocusHorizontally(cell, this.directionality.value === 'ltr' ? -1 : 1);
|
|
415
|
+
break;
|
|
416
|
+
case RIGHT_ARROW:
|
|
417
|
+
this.moveFocusHorizontally(cell, this.directionality.value === 'ltr' ? 1 : -1);
|
|
418
|
+
break;
|
|
419
|
+
default:
|
|
420
|
+
// If the keyboard event is not handled, return now so that we don't `preventDefault`.
|
|
421
|
+
return;
|
|
422
|
+
}
|
|
423
|
+
event.preventDefault();
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
FocusDispatcher.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: FocusDispatcher, deps: [{ token: i1$1.Directionality }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
427
|
+
FocusDispatcher.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: FocusDispatcher, providedIn: 'root' });
|
|
428
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: FocusDispatcher, decorators: [{
|
|
429
|
+
type: Injectable,
|
|
430
|
+
args: [{ providedIn: 'root' }]
|
|
431
|
+
}], ctorParameters: function () { return [{ type: i1$1.Directionality }]; } });
|
|
432
|
+
|
|
433
|
+
/**
|
|
434
|
+
* @license
|
|
435
|
+
* Copyright Google LLC All Rights Reserved.
|
|
436
|
+
*
|
|
437
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
438
|
+
* found in the LICENSE file at https://angular.io/license
|
|
439
|
+
*/
|
|
440
|
+
/**
|
|
441
|
+
* A convenience class for preserving unsaved form state while an edit lens is closed.
|
|
442
|
+
*
|
|
443
|
+
* Example usage:
|
|
444
|
+
* class MyComponent {
|
|
445
|
+
* readonly nameEditValues = new FormValueContainer<Item, {name: string}>();
|
|
446
|
+
* }
|
|
447
|
+
*
|
|
448
|
+
* <form cdkEditControl [(cdkEditControlPreservedFormValue)]="nameEditValues.for(item).value">
|
|
449
|
+
*/
|
|
450
|
+
class FormValueContainer {
|
|
451
|
+
constructor() {
|
|
452
|
+
this._formValues = new WeakMap();
|
|
453
|
+
}
|
|
454
|
+
for(key) {
|
|
455
|
+
const _formValues = this._formValues;
|
|
456
|
+
let entry = _formValues.get(key);
|
|
457
|
+
if (!entry) {
|
|
458
|
+
// Expose entry as an object so that we can [(two-way)] bind to its value member
|
|
459
|
+
entry = {};
|
|
460
|
+
_formValues.set(key, entry);
|
|
461
|
+
}
|
|
462
|
+
return entry;
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
/**
|
|
467
|
+
* @license
|
|
468
|
+
* Copyright Google LLC All Rights Reserved.
|
|
469
|
+
*
|
|
470
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
471
|
+
* found in the LICENSE file at https://angular.io/license
|
|
472
|
+
*/
|
|
473
|
+
/**
|
|
474
|
+
* A directive that attaches to a form within the edit lens.
|
|
475
|
+
* It coordinates the form state with the table-wide edit system and handles
|
|
476
|
+
* closing the edit lens when the form is submitted or the user clicks
|
|
477
|
+
* out.
|
|
478
|
+
*/
|
|
479
|
+
class CdkEditControl {
|
|
480
|
+
constructor(elementRef, editRef) {
|
|
481
|
+
this.elementRef = elementRef;
|
|
482
|
+
this.editRef = editRef;
|
|
483
|
+
this.destroyed = new Subject();
|
|
484
|
+
/**
|
|
485
|
+
* Specifies what should happen when the user clicks outside of the edit lens.
|
|
486
|
+
* The default behavior is to close the lens without submitting the form.
|
|
487
|
+
*/
|
|
488
|
+
this.clickOutBehavior = 'close';
|
|
489
|
+
this.preservedFormValueChange = new EventEmitter();
|
|
490
|
+
/**
|
|
491
|
+
* Determines whether the lens will close on form submit if the form is not in a valid
|
|
492
|
+
* state. By default the lens will remain open.
|
|
493
|
+
*/
|
|
494
|
+
this.ignoreSubmitUnlessValid = true;
|
|
495
|
+
}
|
|
496
|
+
ngOnInit() {
|
|
497
|
+
this.editRef.init(this.preservedFormValue);
|
|
498
|
+
this.editRef.finalValue.subscribe(this.preservedFormValueChange);
|
|
499
|
+
this.editRef.blurred.subscribe(() => this._handleBlur());
|
|
500
|
+
}
|
|
501
|
+
ngOnDestroy() {
|
|
502
|
+
this.destroyed.next();
|
|
503
|
+
this.destroyed.complete();
|
|
504
|
+
}
|
|
505
|
+
/**
|
|
506
|
+
* Called when the form submits. If ignoreSubmitUnlessValid is true, checks
|
|
507
|
+
* the form for validity before proceeding.
|
|
508
|
+
* Updates the revert state with the latest submitted value then closes the edit.
|
|
509
|
+
*/
|
|
510
|
+
// In Ivy the `host` metadata will be merged, whereas in ViewEngine it is overridden. In order
|
|
511
|
+
// to avoid double event listeners, we need to use `HostListener`. Once Ivy is the default, we
|
|
512
|
+
// can move this back into `host`.
|
|
513
|
+
// tslint:disable-next-line:no-host-decorator-in-concrete
|
|
514
|
+
handleFormSubmit() {
|
|
515
|
+
if (this.ignoreSubmitUnlessValid && !this.editRef.isValid()) {
|
|
516
|
+
return;
|
|
517
|
+
}
|
|
518
|
+
this.editRef.updateRevertValue();
|
|
519
|
+
this.editRef.close();
|
|
520
|
+
}
|
|
521
|
+
/** Called on Escape keyup. Closes the edit. */
|
|
522
|
+
close() {
|
|
523
|
+
// todo - allow this behavior to be customized as well, such as calling
|
|
524
|
+
// reset before close
|
|
525
|
+
this.editRef.close();
|
|
526
|
+
}
|
|
527
|
+
/**
|
|
528
|
+
* Called on click anywhere in the document.
|
|
529
|
+
* If the click was outside of the lens, trigger the specified click out behavior.
|
|
530
|
+
*/
|
|
531
|
+
// In Ivy the `host` metadata will be merged, whereas in ViewEngine it is overridden. In order
|
|
532
|
+
// to avoid double event listeners, we need to use `HostListener`. Once Ivy is the default, we
|
|
533
|
+
// can move this back into `host`.
|
|
534
|
+
// tslint:disable-next-line:no-host-decorator-in-concrete
|
|
535
|
+
handlePossibleClickOut(evt) {
|
|
536
|
+
if (closest(evt.target, EDIT_PANE_SELECTOR)) {
|
|
537
|
+
return;
|
|
538
|
+
}
|
|
539
|
+
switch (this.clickOutBehavior) {
|
|
540
|
+
case 'submit':
|
|
541
|
+
// Manually cause the form to submit before closing.
|
|
542
|
+
this._triggerFormSubmit();
|
|
543
|
+
this.editRef.close();
|
|
544
|
+
break;
|
|
545
|
+
case 'close':
|
|
546
|
+
this.editRef.close();
|
|
547
|
+
break;
|
|
548
|
+
default:
|
|
549
|
+
break;
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
// In Ivy the `host` metadata will be merged, whereas in ViewEngine it is overridden. In order
|
|
553
|
+
// to avoid double event listeners, we need to use `HostListener`. Once Ivy is the default, we
|
|
554
|
+
// can move this back into `host`.
|
|
555
|
+
// tslint:disable-next-line:no-host-decorator-in-concrete
|
|
556
|
+
_handleKeydown(event) {
|
|
557
|
+
if (event.key === 'Escape' && !hasModifierKey(event)) {
|
|
558
|
+
this.close();
|
|
559
|
+
event.preventDefault();
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
/** Triggers submit on tab out if clickOutBehavior is 'submit'. */
|
|
563
|
+
_handleBlur() {
|
|
564
|
+
if (this.clickOutBehavior === 'submit') {
|
|
565
|
+
// Manually cause the form to submit before closing.
|
|
566
|
+
this._triggerFormSubmit();
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
_triggerFormSubmit() {
|
|
570
|
+
this.elementRef.nativeElement.dispatchEvent(new Event('submit'));
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
CdkEditControl.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: CdkEditControl, deps: [{ token: i0.ElementRef }, { token: EditRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
574
|
+
CdkEditControl.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.0.0-next.15", type: CdkEditControl, selector: "form[cdkEditControl]", inputs: { clickOutBehavior: ["cdkEditControlClickOutBehavior", "clickOutBehavior"], preservedFormValue: ["cdkEditControlPreservedFormValue", "preservedFormValue"], ignoreSubmitUnlessValid: ["cdkEditControlIgnoreSubmitUnlessValid", "ignoreSubmitUnlessValid"] }, outputs: { preservedFormValueChange: "cdkEditControlPreservedFormValueChange" }, host: { listeners: { "ngSubmit": "handleFormSubmit()", "document:click": "handlePossibleClickOut($event)", "keydown": "_handleKeydown($event)" } }, providers: [EditRef], ngImport: i0 });
|
|
575
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: CdkEditControl, decorators: [{
|
|
576
|
+
type: Directive,
|
|
577
|
+
args: [{
|
|
578
|
+
selector: 'form[cdkEditControl]',
|
|
579
|
+
inputs: [
|
|
580
|
+
'clickOutBehavior: cdkEditControlClickOutBehavior',
|
|
581
|
+
'preservedFormValue: cdkEditControlPreservedFormValue',
|
|
582
|
+
'ignoreSubmitUnlessValid: cdkEditControlIgnoreSubmitUnlessValid',
|
|
583
|
+
],
|
|
584
|
+
outputs: ['preservedFormValueChange: cdkEditControlPreservedFormValueChange'],
|
|
585
|
+
providers: [EditRef],
|
|
586
|
+
}]
|
|
587
|
+
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: EditRef }]; }, propDecorators: { handleFormSubmit: [{
|
|
588
|
+
type: HostListener,
|
|
589
|
+
args: ['ngSubmit']
|
|
590
|
+
}], handlePossibleClickOut: [{
|
|
591
|
+
type: HostListener,
|
|
592
|
+
args: ['document:click', ['$event']]
|
|
593
|
+
}], _handleKeydown: [{
|
|
594
|
+
type: HostListener,
|
|
595
|
+
args: ['keydown', ['$event']]
|
|
596
|
+
}] } });
|
|
597
|
+
/** Reverts the form to its initial or previously submitted state on click. */
|
|
598
|
+
class CdkEditRevert {
|
|
599
|
+
constructor(editRef) {
|
|
600
|
+
this.editRef = editRef;
|
|
601
|
+
/** Type of the button. Defaults to `button` to avoid accident form submits. */
|
|
602
|
+
this.type = 'button';
|
|
603
|
+
}
|
|
604
|
+
// In Ivy the `host` metadata will be merged, whereas in ViewEngine it is overridden. In order
|
|
605
|
+
// to avoid double event listeners, we need to use `HostListener`. Once Ivy is the default, we
|
|
606
|
+
// can move this back into `host`.
|
|
607
|
+
// tslint:disable-next-line:no-host-decorator-in-concrete
|
|
608
|
+
revertEdit() {
|
|
609
|
+
this.editRef.reset();
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
CdkEditRevert.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: CdkEditRevert, deps: [{ token: EditRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
613
|
+
CdkEditRevert.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.0.0-next.15", type: CdkEditRevert, selector: "button[cdkEditRevert]", inputs: { type: "type" }, host: { attributes: { "type": "button" }, listeners: { "click": "revertEdit()" } }, ngImport: i0 });
|
|
614
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: CdkEditRevert, decorators: [{
|
|
615
|
+
type: Directive,
|
|
616
|
+
args: [{
|
|
617
|
+
selector: 'button[cdkEditRevert]',
|
|
618
|
+
host: {
|
|
619
|
+
'type': 'button', // Prevents accidental form submits.
|
|
620
|
+
},
|
|
621
|
+
}]
|
|
622
|
+
}], ctorParameters: function () { return [{ type: EditRef }]; }, propDecorators: { type: [{
|
|
623
|
+
type: Input
|
|
624
|
+
}], revertEdit: [{
|
|
625
|
+
type: HostListener,
|
|
626
|
+
args: ['click']
|
|
627
|
+
}] } });
|
|
628
|
+
/** Closes the lens on click. */
|
|
629
|
+
class CdkEditClose {
|
|
630
|
+
constructor(elementRef, editRef) {
|
|
631
|
+
this.elementRef = elementRef;
|
|
632
|
+
this.editRef = editRef;
|
|
633
|
+
const nativeElement = elementRef.nativeElement;
|
|
634
|
+
// Prevent accidental form submits.
|
|
635
|
+
if (nativeElement.nodeName === 'BUTTON' && !nativeElement.getAttribute('type')) {
|
|
636
|
+
nativeElement.setAttribute('type', 'button');
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
// In Ivy the `host` metadata will be merged, whereas in ViewEngine it is overridden. In order
|
|
640
|
+
// to avoid double event listeners, we need to use `HostListener`. Once Ivy is the default, we
|
|
641
|
+
// can move this back into `host`.
|
|
642
|
+
// tslint:disable-next-line:no-host-decorator-in-concrete
|
|
643
|
+
closeEdit() {
|
|
644
|
+
// Note that we use `click` here, rather than a keyboard event, because some screen readers
|
|
645
|
+
// will emit a fake click event instead of an enter keyboard event on buttons. For the keyboard
|
|
646
|
+
// events we use `keydown`, rather than `keyup`, because we use `keydown` to open the overlay
|
|
647
|
+
// as well. If we were to use `keyup`, the user could end up opening and closing within
|
|
648
|
+
// the same event sequence if focus was moved quickly.
|
|
649
|
+
this.editRef.close();
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
CdkEditClose.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: CdkEditClose, deps: [{ token: i0.ElementRef }, { token: EditRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
653
|
+
CdkEditClose.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.0.0-next.15", type: CdkEditClose, selector: "[cdkEditClose]", host: { listeners: { "click": "closeEdit()", "keydown.enter": "closeEdit()", "keydown.space": "closeEdit()" } }, ngImport: i0 });
|
|
654
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: CdkEditClose, decorators: [{
|
|
655
|
+
type: Directive,
|
|
656
|
+
args: [{ selector: '[cdkEditClose]' }]
|
|
657
|
+
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: EditRef }]; }, propDecorators: { closeEdit: [{
|
|
658
|
+
type: HostListener,
|
|
659
|
+
args: ['click']
|
|
660
|
+
}, {
|
|
661
|
+
type: HostListener,
|
|
662
|
+
args: ['keydown.enter']
|
|
663
|
+
}, {
|
|
664
|
+
type: HostListener,
|
|
665
|
+
args: ['keydown.space']
|
|
666
|
+
}] } });
|
|
667
|
+
|
|
668
|
+
/**
|
|
669
|
+
* @license
|
|
670
|
+
* Copyright Google LLC All Rights Reserved.
|
|
671
|
+
*
|
|
672
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
673
|
+
* found in the LICENSE file at https://angular.io/license
|
|
674
|
+
*/
|
|
675
|
+
/**
|
|
676
|
+
* Overridable factory responsible for configuring how cdkPopoverEdit popovers are positioned
|
|
677
|
+
* and sized.
|
|
678
|
+
*/
|
|
679
|
+
class PopoverEditPositionStrategyFactory {
|
|
680
|
+
}
|
|
681
|
+
PopoverEditPositionStrategyFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: PopoverEditPositionStrategyFactory, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
682
|
+
PopoverEditPositionStrategyFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: PopoverEditPositionStrategyFactory });
|
|
683
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: PopoverEditPositionStrategyFactory, decorators: [{
|
|
684
|
+
type: Injectable
|
|
685
|
+
}] });
|
|
686
|
+
/**
|
|
687
|
+
* Default implementation of PopoverEditPositionStrategyFactory.
|
|
688
|
+
* Uses a FlexibleConnectedPositionStrategy anchored to the start + top of the cell.
|
|
689
|
+
* Note: This will change to CoverPositionStrategy once it implemented.
|
|
690
|
+
*/
|
|
691
|
+
class DefaultPopoverEditPositionStrategyFactory extends PopoverEditPositionStrategyFactory {
|
|
692
|
+
constructor(direction, overlay) {
|
|
693
|
+
super();
|
|
694
|
+
this.direction = direction;
|
|
695
|
+
this.overlay = overlay;
|
|
696
|
+
}
|
|
697
|
+
positionStrategyForCells(cells) {
|
|
698
|
+
return this.overlay
|
|
699
|
+
.position()
|
|
700
|
+
.flexibleConnectedTo(cells[0])
|
|
701
|
+
.withGrowAfterOpen()
|
|
702
|
+
.withPush()
|
|
703
|
+
.withViewportMargin(16)
|
|
704
|
+
.withPositions([
|
|
705
|
+
{
|
|
706
|
+
originX: 'start',
|
|
707
|
+
originY: 'top',
|
|
708
|
+
overlayX: 'start',
|
|
709
|
+
overlayY: 'top',
|
|
710
|
+
},
|
|
711
|
+
]);
|
|
712
|
+
}
|
|
713
|
+
sizeConfigForCells(cells) {
|
|
714
|
+
if (cells.length === 0) {
|
|
715
|
+
return {};
|
|
716
|
+
}
|
|
717
|
+
if (cells.length === 1) {
|
|
718
|
+
return { width: cells[0].getBoundingClientRect().width };
|
|
719
|
+
}
|
|
720
|
+
let firstCell, lastCell;
|
|
721
|
+
if (this.direction.value === 'ltr') {
|
|
722
|
+
firstCell = cells[0];
|
|
723
|
+
lastCell = cells[cells.length - 1];
|
|
724
|
+
}
|
|
725
|
+
else {
|
|
726
|
+
lastCell = cells[0];
|
|
727
|
+
firstCell = cells[cells.length - 1];
|
|
728
|
+
}
|
|
729
|
+
return { width: lastCell.getBoundingClientRect().right - firstCell.getBoundingClientRect().left };
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
DefaultPopoverEditPositionStrategyFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: DefaultPopoverEditPositionStrategyFactory, deps: [{ token: i1$1.Directionality }, { token: i2.Overlay }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
733
|
+
DefaultPopoverEditPositionStrategyFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: DefaultPopoverEditPositionStrategyFactory });
|
|
734
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: DefaultPopoverEditPositionStrategyFactory, decorators: [{
|
|
735
|
+
type: Injectable
|
|
736
|
+
}], ctorParameters: function () { return [{ type: i1$1.Directionality }, { type: i2.Overlay }]; } });
|
|
737
|
+
|
|
738
|
+
/**
|
|
739
|
+
* @license
|
|
740
|
+
* Copyright Google LLC All Rights Reserved.
|
|
741
|
+
*
|
|
742
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
743
|
+
* found in the LICENSE file at https://angular.io/license
|
|
744
|
+
*/
|
|
745
|
+
/**
|
|
746
|
+
* Optimization
|
|
747
|
+
* Collects multiple Injectables into a singleton shared across the table. By reducing the
|
|
748
|
+
* number of services injected into each CdkPopoverEdit, this saves about 0.023ms of cpu time
|
|
749
|
+
* and 56 bytes of memory per instance.
|
|
750
|
+
*/
|
|
751
|
+
class EditServices {
|
|
752
|
+
constructor(directionality, editEventDispatcher, focusDispatcher, focusTrapFactory, ngZone, overlay, positionFactory, scrollDispatcher, viewportRuler) {
|
|
753
|
+
this.directionality = directionality;
|
|
754
|
+
this.editEventDispatcher = editEventDispatcher;
|
|
755
|
+
this.focusDispatcher = focusDispatcher;
|
|
756
|
+
this.focusTrapFactory = focusTrapFactory;
|
|
757
|
+
this.ngZone = ngZone;
|
|
758
|
+
this.overlay = overlay;
|
|
759
|
+
this.positionFactory = positionFactory;
|
|
760
|
+
this.scrollDispatcher = scrollDispatcher;
|
|
761
|
+
this.viewportRuler = viewportRuler;
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
EditServices.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: EditServices, deps: [{ token: i1$1.Directionality }, { token: EditEventDispatcher }, { token: FocusDispatcher }, { token: i4.FocusTrapFactory }, { token: i0.NgZone }, { token: i2.Overlay }, { token: PopoverEditPositionStrategyFactory }, { token: i7.ScrollDispatcher }, { token: i7.ViewportRuler }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
765
|
+
EditServices.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: EditServices });
|
|
766
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: EditServices, decorators: [{
|
|
767
|
+
type: Injectable
|
|
768
|
+
}], ctorParameters: function () { return [{ type: i1$1.Directionality }, { type: EditEventDispatcher }, { type: FocusDispatcher }, { type: i4.FocusTrapFactory }, { type: i0.NgZone }, { type: i2.Overlay }, { type: PopoverEditPositionStrategyFactory }, { type: i7.ScrollDispatcher }, { type: i7.ViewportRuler }]; } });
|
|
769
|
+
|
|
770
|
+
/**
|
|
771
|
+
* @license
|
|
772
|
+
* Copyright Google LLC All Rights Reserved.
|
|
773
|
+
*
|
|
774
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
775
|
+
* found in the LICENSE file at https://angular.io/license
|
|
776
|
+
*/
|
|
777
|
+
/**
|
|
778
|
+
* Like FocusTrap, but rather than trapping focus within a dom region, notifies subscribers when
|
|
779
|
+
* focus leaves the region.
|
|
780
|
+
*/
|
|
781
|
+
class FocusEscapeNotifier extends FocusTrap {
|
|
782
|
+
constructor(element, checker, ngZone, document) {
|
|
783
|
+
super(element, checker, ngZone, document, true /* deferAnchors */);
|
|
784
|
+
this._escapeSubject = new Subject();
|
|
785
|
+
// The focus trap adds "anchors" at the beginning and end of a trapped region that redirect
|
|
786
|
+
// focus. We override that redirect behavior here with simply emitting on a stream.
|
|
787
|
+
this.startAnchorListener = () => {
|
|
788
|
+
this._escapeSubject.next(0 /* START */);
|
|
789
|
+
return true;
|
|
790
|
+
};
|
|
791
|
+
this.endAnchorListener = () => {
|
|
792
|
+
this._escapeSubject.next(1 /* END */);
|
|
793
|
+
return true;
|
|
794
|
+
};
|
|
795
|
+
this.attachAnchors();
|
|
796
|
+
}
|
|
797
|
+
escapes() {
|
|
798
|
+
return this._escapeSubject;
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
/** Factory that allows easy instantiation of focus escape notifiers. */
|
|
802
|
+
class FocusEscapeNotifierFactory {
|
|
803
|
+
constructor(_checker, _ngZone, _document) {
|
|
804
|
+
this._checker = _checker;
|
|
805
|
+
this._ngZone = _ngZone;
|
|
806
|
+
this._document = _document;
|
|
807
|
+
}
|
|
808
|
+
/**
|
|
809
|
+
* Creates a focus escape notifier region around the given element.
|
|
810
|
+
* @param element The element around which focus will be monitored.
|
|
811
|
+
* @returns The created focus escape notifier instance.
|
|
812
|
+
*/
|
|
813
|
+
create(element) {
|
|
814
|
+
return new FocusEscapeNotifier(element, this._checker, this._ngZone, this._document);
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
FocusEscapeNotifierFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: FocusEscapeNotifierFactory, deps: [{ token: i4.InteractivityChecker }, { token: i0.NgZone }, { token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
818
|
+
FocusEscapeNotifierFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: FocusEscapeNotifierFactory, providedIn: 'root' });
|
|
819
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: FocusEscapeNotifierFactory, decorators: [{
|
|
820
|
+
type: Injectable,
|
|
821
|
+
args: [{ providedIn: 'root' }]
|
|
822
|
+
}], ctorParameters: function () { return [{ type: i4.InteractivityChecker }, { type: i0.NgZone }, { type: undefined, decorators: [{
|
|
823
|
+
type: Inject,
|
|
824
|
+
args: [DOCUMENT]
|
|
825
|
+
}] }]; } });
|
|
826
|
+
|
|
827
|
+
/** Used for rate-limiting mousemove events. */
|
|
828
|
+
const MOUSE_MOVE_THROTTLE_TIME_MS = 10;
|
|
829
|
+
/**
|
|
830
|
+
* A directive that must be attached to enable editability on a table.
|
|
831
|
+
* It is responsible for setting up delegated event handlers and providing the
|
|
832
|
+
* EditEventDispatcher service for use by the other edit directives.
|
|
833
|
+
*/
|
|
834
|
+
class CdkEditable {
|
|
835
|
+
constructor(elementRef, editEventDispatcher, focusDispatcher, ngZone) {
|
|
836
|
+
this.elementRef = elementRef;
|
|
837
|
+
this.editEventDispatcher = editEventDispatcher;
|
|
838
|
+
this.focusDispatcher = focusDispatcher;
|
|
839
|
+
this.ngZone = ngZone;
|
|
840
|
+
this.destroyed = new Subject();
|
|
841
|
+
}
|
|
842
|
+
ngAfterViewInit() {
|
|
843
|
+
this._listenForTableEvents();
|
|
844
|
+
}
|
|
845
|
+
ngOnDestroy() {
|
|
846
|
+
this.destroyed.next();
|
|
847
|
+
this.destroyed.complete();
|
|
848
|
+
}
|
|
849
|
+
_listenForTableEvents() {
|
|
850
|
+
const element = this.elementRef.nativeElement;
|
|
851
|
+
const toClosest = (selector) => map((event) => closest(event.target, selector));
|
|
852
|
+
this.ngZone.runOutsideAngular(() => {
|
|
853
|
+
// Track mouse movement over the table to hide/show hover content.
|
|
854
|
+
fromEvent(element, 'mouseover')
|
|
855
|
+
.pipe(toClosest(ROW_SELECTOR), takeUntil(this.destroyed))
|
|
856
|
+
.subscribe(this.editEventDispatcher.hovering);
|
|
857
|
+
fromEvent(element, 'mouseleave')
|
|
858
|
+
.pipe(mapTo(null), takeUntil(this.destroyed))
|
|
859
|
+
.subscribe(this.editEventDispatcher.hovering);
|
|
860
|
+
fromEvent(element, 'mousemove')
|
|
861
|
+
.pipe(throttleTime(MOUSE_MOVE_THROTTLE_TIME_MS), toClosest(ROW_SELECTOR), takeUntil(this.destroyed))
|
|
862
|
+
.subscribe(this.editEventDispatcher.mouseMove);
|
|
863
|
+
// Track focus within the table to hide/show/make focusable hover content.
|
|
864
|
+
fromEventPattern(handler => element.addEventListener('focus', handler, true), handler => element.removeEventListener('focus', handler, true))
|
|
865
|
+
.pipe(toClosest(ROW_SELECTOR), share(), takeUntil(this.destroyed))
|
|
866
|
+
.subscribe(this.editEventDispatcher.focused);
|
|
867
|
+
merge(fromEventPattern(handler => element.addEventListener('blur', handler, true), handler => element.removeEventListener('blur', handler, true)), fromEvent(element, 'keydown').pipe(filter(event => event.key === 'Escape')))
|
|
868
|
+
.pipe(mapTo(null), share(), takeUntil(this.destroyed))
|
|
869
|
+
.subscribe(this.editEventDispatcher.focused);
|
|
870
|
+
// Keep track of rows within the table. This is used to know which rows with hover content
|
|
871
|
+
// are first or last in the table. They are kept focusable in case focus enters from above
|
|
872
|
+
// or below the table.
|
|
873
|
+
this.ngZone.onStable
|
|
874
|
+
.pipe(
|
|
875
|
+
// Optimization: ignore dom changes while focus is within the table as we already
|
|
876
|
+
// ensure that rows above and below the focused/active row are tabbable.
|
|
877
|
+
withLatestFrom(this.editEventDispatcher.editingOrFocused), filter(([_, activeRow]) => activeRow == null), map(() => element.querySelectorAll(ROW_SELECTOR)), share(), takeUntil(this.destroyed))
|
|
878
|
+
.subscribe(this.editEventDispatcher.allRows);
|
|
879
|
+
fromEvent(element, 'keydown')
|
|
880
|
+
.pipe(filter(event => event.key === 'Enter'), toClosest(CELL_SELECTOR), takeUntil(this.destroyed))
|
|
881
|
+
.subscribe(this.editEventDispatcher.editing);
|
|
882
|
+
// Keydown must be used here or else key autorepeat does not work properly on some platforms.
|
|
883
|
+
fromEvent(element, 'keydown')
|
|
884
|
+
.pipe(takeUntil(this.destroyed))
|
|
885
|
+
.subscribe(this.focusDispatcher.keyObserver);
|
|
886
|
+
});
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
CdkEditable.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: CdkEditable, deps: [{ token: i0.ElementRef }, { token: EditEventDispatcher }, { token: FocusDispatcher }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive });
|
|
890
|
+
CdkEditable.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.0.0-next.15", type: CdkEditable, selector: "table[editable], cdk-table[editable], mat-table[editable]", providers: [EditEventDispatcher, EditServices], ngImport: i0 });
|
|
891
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: CdkEditable, decorators: [{
|
|
892
|
+
type: Directive,
|
|
893
|
+
args: [{
|
|
894
|
+
selector: 'table[editable], cdk-table[editable], mat-table[editable]',
|
|
895
|
+
providers: [EditEventDispatcher, EditServices],
|
|
896
|
+
}]
|
|
897
|
+
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: EditEventDispatcher }, { type: FocusDispatcher }, { type: i0.NgZone }]; } });
|
|
898
|
+
const POPOVER_EDIT_HOST_BINDINGS = {
|
|
899
|
+
'[attr.tabindex]': 'disabled ? null : 0',
|
|
900
|
+
'class': 'cdk-popover-edit-cell',
|
|
901
|
+
'[attr.aria-haspopup]': '!disabled',
|
|
902
|
+
};
|
|
903
|
+
const POPOVER_EDIT_INPUTS = [
|
|
904
|
+
'template: cdkPopoverEdit',
|
|
905
|
+
'context: cdkPopoverEditContext',
|
|
906
|
+
'colspan: cdkPopoverEditColspan',
|
|
907
|
+
'disabled: cdkPopoverEditDisabled',
|
|
908
|
+
];
|
|
909
|
+
/**
|
|
910
|
+
* Attaches an ng-template to a cell and shows it when instructed to by the
|
|
911
|
+
* EditEventDispatcher service.
|
|
912
|
+
* Makes the cell focusable.
|
|
913
|
+
*/
|
|
914
|
+
class CdkPopoverEdit {
|
|
915
|
+
constructor(services, elementRef, viewContainerRef) {
|
|
916
|
+
this.services = services;
|
|
917
|
+
this.elementRef = elementRef;
|
|
918
|
+
this.viewContainerRef = viewContainerRef;
|
|
919
|
+
/** The edit lens template shown over the cell on edit. */
|
|
920
|
+
this.template = null;
|
|
921
|
+
this._colspan = {};
|
|
922
|
+
this._disabled = false;
|
|
923
|
+
this.destroyed = new Subject();
|
|
924
|
+
}
|
|
925
|
+
/**
|
|
926
|
+
* Specifies that the popup should cover additional table cells before and/or after
|
|
927
|
+
* this one.
|
|
928
|
+
*/
|
|
929
|
+
get colspan() {
|
|
930
|
+
return this._colspan;
|
|
931
|
+
}
|
|
932
|
+
set colspan(value) {
|
|
933
|
+
this._colspan = value;
|
|
934
|
+
// Recompute positioning when the colspan changes.
|
|
935
|
+
if (this.overlayRef) {
|
|
936
|
+
this.overlayRef.updatePositionStrategy(this._getPositionStrategy());
|
|
937
|
+
if (this.overlayRef.hasAttached()) {
|
|
938
|
+
this._updateOverlaySize();
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
/** Whether popover edit is disabled for this cell. */
|
|
943
|
+
get disabled() {
|
|
944
|
+
return this._disabled;
|
|
945
|
+
}
|
|
946
|
+
set disabled(value) {
|
|
947
|
+
this._disabled = value;
|
|
948
|
+
if (value) {
|
|
949
|
+
this.services.editEventDispatcher.doneEditingCell(this.elementRef.nativeElement);
|
|
950
|
+
this.services.editEventDispatcher.disabledCells.set(this.elementRef.nativeElement, true);
|
|
951
|
+
}
|
|
952
|
+
else {
|
|
953
|
+
this.services.editEventDispatcher.disabledCells.delete(this.elementRef.nativeElement);
|
|
954
|
+
}
|
|
955
|
+
}
|
|
956
|
+
ngAfterViewInit() {
|
|
957
|
+
this._startListeningToEditEvents();
|
|
958
|
+
}
|
|
959
|
+
ngOnDestroy() {
|
|
960
|
+
this.destroyed.next();
|
|
961
|
+
this.destroyed.complete();
|
|
962
|
+
if (this.focusTrap) {
|
|
963
|
+
this.focusTrap.destroy();
|
|
964
|
+
this.focusTrap = undefined;
|
|
965
|
+
}
|
|
966
|
+
if (this.overlayRef) {
|
|
967
|
+
this.overlayRef.dispose();
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
initFocusTrap() {
|
|
971
|
+
this.focusTrap = this.services.focusTrapFactory.create(this.overlayRef.overlayElement);
|
|
972
|
+
}
|
|
973
|
+
closeEditOverlay() {
|
|
974
|
+
this.services.editEventDispatcher.doneEditingCell(this.elementRef.nativeElement);
|
|
975
|
+
}
|
|
976
|
+
panelClass() {
|
|
977
|
+
return EDIT_PANE_CLASS;
|
|
978
|
+
}
|
|
979
|
+
_startListeningToEditEvents() {
|
|
980
|
+
this.services.editEventDispatcher
|
|
981
|
+
.editingCell(this.elementRef.nativeElement)
|
|
982
|
+
.pipe(takeUntil(this.destroyed))
|
|
983
|
+
.subscribe(open => {
|
|
984
|
+
if (open && this.template) {
|
|
985
|
+
if (!this.overlayRef) {
|
|
986
|
+
this._createEditOverlay();
|
|
987
|
+
}
|
|
988
|
+
this._showEditOverlay();
|
|
989
|
+
}
|
|
990
|
+
else if (this.overlayRef) {
|
|
991
|
+
this._maybeReturnFocusToCell();
|
|
992
|
+
this.overlayRef.detach();
|
|
993
|
+
}
|
|
994
|
+
});
|
|
995
|
+
}
|
|
996
|
+
_createEditOverlay() {
|
|
997
|
+
this.overlayRef = this.services.overlay.create({
|
|
998
|
+
disposeOnNavigation: true,
|
|
999
|
+
panelClass: this.panelClass(),
|
|
1000
|
+
positionStrategy: this._getPositionStrategy(),
|
|
1001
|
+
scrollStrategy: this.services.overlay.scrollStrategies.reposition(),
|
|
1002
|
+
direction: this.services.directionality,
|
|
1003
|
+
});
|
|
1004
|
+
this.initFocusTrap();
|
|
1005
|
+
this.overlayRef.overlayElement.setAttribute('aria-role', 'dialog');
|
|
1006
|
+
this.overlayRef.detachments().subscribe(() => this.closeEditOverlay());
|
|
1007
|
+
}
|
|
1008
|
+
_showEditOverlay() {
|
|
1009
|
+
this.overlayRef.attach(new TemplatePortal(this.template, this.viewContainerRef, { $implicit: this.context }));
|
|
1010
|
+
// We have to defer trapping focus, because doing so too early can cause the form inside
|
|
1011
|
+
// the overlay to be submitted immediately if it was opened on an Enter keydown event.
|
|
1012
|
+
this.services.ngZone.runOutsideAngular(() => {
|
|
1013
|
+
setTimeout(() => {
|
|
1014
|
+
this.focusTrap.focusInitialElement();
|
|
1015
|
+
});
|
|
1016
|
+
});
|
|
1017
|
+
// Update the size of the popup initially and on subsequent changes to
|
|
1018
|
+
// scroll position and viewport size.
|
|
1019
|
+
merge(this.services.scrollDispatcher.scrolled(), this.services.viewportRuler.change())
|
|
1020
|
+
.pipe(startWith(null), takeUntil(merge(this.overlayRef.detachments(), this.destroyed)))
|
|
1021
|
+
.subscribe(() => {
|
|
1022
|
+
this._updateOverlaySize();
|
|
1023
|
+
});
|
|
1024
|
+
}
|
|
1025
|
+
_getOverlayCells() {
|
|
1026
|
+
const cell = closest(this.elementRef.nativeElement, CELL_SELECTOR);
|
|
1027
|
+
if (!this._colspan.before && !this._colspan.after) {
|
|
1028
|
+
return [cell];
|
|
1029
|
+
}
|
|
1030
|
+
const row = closest(this.elementRef.nativeElement, ROW_SELECTOR);
|
|
1031
|
+
const rowCells = Array.from(row.querySelectorAll(CELL_SELECTOR));
|
|
1032
|
+
const ownIndex = rowCells.indexOf(cell);
|
|
1033
|
+
return rowCells.slice(ownIndex - (this._colspan.before || 0), ownIndex + (this._colspan.after || 0) + 1);
|
|
1034
|
+
}
|
|
1035
|
+
_getPositionStrategy() {
|
|
1036
|
+
return this.services.positionFactory.positionStrategyForCells(this._getOverlayCells());
|
|
1037
|
+
}
|
|
1038
|
+
_updateOverlaySize() {
|
|
1039
|
+
this.overlayRef.updateSize(this.services.positionFactory.sizeConfigForCells(this._getOverlayCells()));
|
|
1040
|
+
}
|
|
1041
|
+
_maybeReturnFocusToCell() {
|
|
1042
|
+
if (closest(document.activeElement, EDIT_PANE_SELECTOR) === this.overlayRef.overlayElement) {
|
|
1043
|
+
this.elementRef.nativeElement.focus();
|
|
1044
|
+
}
|
|
1045
|
+
}
|
|
1046
|
+
}
|
|
1047
|
+
CdkPopoverEdit.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: CdkPopoverEdit, deps: [{ token: EditServices }, { token: i0.ElementRef }, { token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
1048
|
+
CdkPopoverEdit.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.0.0-next.15", type: CdkPopoverEdit, selector: "[cdkPopoverEdit]:not([cdkPopoverEditTabOut])", inputs: { template: ["cdkPopoverEdit", "template"], context: ["cdkPopoverEditContext", "context"], colspan: ["cdkPopoverEditColspan", "colspan"], disabled: ["cdkPopoverEditDisabled", "disabled"] }, host: { properties: { "attr.tabindex": "disabled ? null : 0", "attr.aria-haspopup": "!disabled" }, classAttribute: "cdk-popover-edit-cell" }, ngImport: i0 });
|
|
1049
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: CdkPopoverEdit, decorators: [{
|
|
1050
|
+
type: Directive,
|
|
1051
|
+
args: [{
|
|
1052
|
+
selector: '[cdkPopoverEdit]:not([cdkPopoverEditTabOut])',
|
|
1053
|
+
host: POPOVER_EDIT_HOST_BINDINGS,
|
|
1054
|
+
inputs: POPOVER_EDIT_INPUTS,
|
|
1055
|
+
}]
|
|
1056
|
+
}], ctorParameters: function () { return [{ type: EditServices }, { type: i0.ElementRef }, { type: i0.ViewContainerRef }]; } });
|
|
1057
|
+
/**
|
|
1058
|
+
* Attaches an ng-template to a cell and shows it when instructed to by the
|
|
1059
|
+
* EditEventDispatcher service.
|
|
1060
|
+
* Makes the cell focusable.
|
|
1061
|
+
*/
|
|
1062
|
+
class CdkPopoverEditTabOut extends CdkPopoverEdit {
|
|
1063
|
+
constructor(elementRef, viewContainerRef, services, focusEscapeNotifierFactory) {
|
|
1064
|
+
super(services, elementRef, viewContainerRef);
|
|
1065
|
+
this.focusEscapeNotifierFactory = focusEscapeNotifierFactory;
|
|
1066
|
+
}
|
|
1067
|
+
initFocusTrap() {
|
|
1068
|
+
this.focusTrap = this.focusEscapeNotifierFactory.create(this.overlayRef.overlayElement);
|
|
1069
|
+
this.focusTrap
|
|
1070
|
+
.escapes()
|
|
1071
|
+
.pipe(takeUntil(this.destroyed))
|
|
1072
|
+
.subscribe(direction => {
|
|
1073
|
+
if (this.services.editEventDispatcher.editRef) {
|
|
1074
|
+
this.services.editEventDispatcher.editRef.blur();
|
|
1075
|
+
}
|
|
1076
|
+
this.services.focusDispatcher.moveFocusHorizontally(closest(this.elementRef.nativeElement, CELL_SELECTOR), direction === 0 /* START */ ? -1 : 1);
|
|
1077
|
+
this.closeEditOverlay();
|
|
1078
|
+
});
|
|
1079
|
+
}
|
|
1080
|
+
}
|
|
1081
|
+
CdkPopoverEditTabOut.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: CdkPopoverEditTabOut, deps: [{ token: i0.ElementRef }, { token: i0.ViewContainerRef }, { token: EditServices }, { token: FocusEscapeNotifierFactory }], target: i0.ɵɵFactoryTarget.Directive });
|
|
1082
|
+
CdkPopoverEditTabOut.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.0.0-next.15", type: CdkPopoverEditTabOut, selector: "[cdkPopoverEdit][cdkPopoverEditTabOut]", inputs: { template: ["cdkPopoverEdit", "template"], context: ["cdkPopoverEditContext", "context"], colspan: ["cdkPopoverEditColspan", "colspan"], disabled: ["cdkPopoverEditDisabled", "disabled"] }, host: { properties: { "attr.tabindex": "disabled ? null : 0", "attr.aria-haspopup": "!disabled" }, classAttribute: "cdk-popover-edit-cell" }, usesInheritance: true, ngImport: i0 });
|
|
1083
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: CdkPopoverEditTabOut, decorators: [{
|
|
1084
|
+
type: Directive,
|
|
1085
|
+
args: [{
|
|
1086
|
+
selector: '[cdkPopoverEdit][cdkPopoverEditTabOut]',
|
|
1087
|
+
host: POPOVER_EDIT_HOST_BINDINGS,
|
|
1088
|
+
inputs: POPOVER_EDIT_INPUTS,
|
|
1089
|
+
}]
|
|
1090
|
+
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.ViewContainerRef }, { type: EditServices }, { type: FocusEscapeNotifierFactory }]; } });
|
|
1091
|
+
/**
|
|
1092
|
+
* A structural directive that shows its contents when the table row containing
|
|
1093
|
+
* it is hovered or when an element in the row has focus.
|
|
1094
|
+
*/
|
|
1095
|
+
class CdkRowHoverContent {
|
|
1096
|
+
constructor(services, elementRef, templateRef, viewContainerRef) {
|
|
1097
|
+
this.services = services;
|
|
1098
|
+
this.elementRef = elementRef;
|
|
1099
|
+
this.templateRef = templateRef;
|
|
1100
|
+
this.viewContainerRef = viewContainerRef;
|
|
1101
|
+
this.destroyed = new Subject();
|
|
1102
|
+
this.viewRef = null;
|
|
1103
|
+
}
|
|
1104
|
+
ngAfterViewInit() {
|
|
1105
|
+
this._row = closest(this.elementRef.nativeElement, ROW_SELECTOR);
|
|
1106
|
+
this.services.editEventDispatcher.registerRowWithHoverContent(this._row);
|
|
1107
|
+
this._listenForHoverAndFocusEvents();
|
|
1108
|
+
}
|
|
1109
|
+
ngOnDestroy() {
|
|
1110
|
+
this.destroyed.next();
|
|
1111
|
+
this.destroyed.complete();
|
|
1112
|
+
if (this.viewRef) {
|
|
1113
|
+
this.viewRef.destroy();
|
|
1114
|
+
}
|
|
1115
|
+
if (this._row) {
|
|
1116
|
+
this.services.editEventDispatcher.deregisterRowWithHoverContent(this._row);
|
|
1117
|
+
}
|
|
1118
|
+
}
|
|
1119
|
+
/**
|
|
1120
|
+
* Called immediately after the hover content is created and added to the dom.
|
|
1121
|
+
* In the CDK version, this is a noop but subclasses such as MatRowHoverContent use this
|
|
1122
|
+
* to prepare/style the inserted element.
|
|
1123
|
+
*/
|
|
1124
|
+
initElement(_) { }
|
|
1125
|
+
/**
|
|
1126
|
+
* Called when the hover content needs to be focusable to preserve a reasonable tab ordering
|
|
1127
|
+
* but should not yet be shown.
|
|
1128
|
+
*/
|
|
1129
|
+
makeElementHiddenButFocusable(element) {
|
|
1130
|
+
element.style.opacity = '0';
|
|
1131
|
+
}
|
|
1132
|
+
/**
|
|
1133
|
+
* Called when the hover content needs to be focusable to preserve a reasonable tab ordering
|
|
1134
|
+
* but should not yet be shown.
|
|
1135
|
+
*/
|
|
1136
|
+
makeElementVisible(element) {
|
|
1137
|
+
element.style.opacity = '';
|
|
1138
|
+
}
|
|
1139
|
+
_listenForHoverAndFocusEvents() {
|
|
1140
|
+
this.services.editEventDispatcher
|
|
1141
|
+
.hoverOrFocusOnRow(this._row)
|
|
1142
|
+
.pipe(takeUntil(this.destroyed))
|
|
1143
|
+
.subscribe(eventState => {
|
|
1144
|
+
// When in FOCUSABLE state, add the hover content to the dom but make it transparent so
|
|
1145
|
+
// that it is in the tab order relative to the currently focused row.
|
|
1146
|
+
if (eventState === 2 /* ON */ || eventState === 1 /* FOCUSABLE */) {
|
|
1147
|
+
if (!this.viewRef) {
|
|
1148
|
+
this.viewRef = this.viewContainerRef.createEmbeddedView(this.templateRef, {});
|
|
1149
|
+
this.initElement(this.viewRef.rootNodes[0]);
|
|
1150
|
+
this.viewRef.markForCheck();
|
|
1151
|
+
}
|
|
1152
|
+
else if (this.viewContainerRef.indexOf(this.viewRef) === -1) {
|
|
1153
|
+
this.viewContainerRef.insert(this.viewRef);
|
|
1154
|
+
this.viewRef.markForCheck();
|
|
1155
|
+
}
|
|
1156
|
+
if (eventState === 2 /* ON */) {
|
|
1157
|
+
this.makeElementVisible(this.viewRef.rootNodes[0]);
|
|
1158
|
+
}
|
|
1159
|
+
else {
|
|
1160
|
+
this.makeElementHiddenButFocusable(this.viewRef.rootNodes[0]);
|
|
1161
|
+
}
|
|
1162
|
+
}
|
|
1163
|
+
else if (this.viewRef) {
|
|
1164
|
+
this.viewContainerRef.detach(this.viewContainerRef.indexOf(this.viewRef));
|
|
1165
|
+
}
|
|
1166
|
+
});
|
|
1167
|
+
}
|
|
1168
|
+
}
|
|
1169
|
+
CdkRowHoverContent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: CdkRowHoverContent, deps: [{ token: EditServices }, { token: i0.ElementRef }, { token: i0.TemplateRef }, { token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
1170
|
+
CdkRowHoverContent.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.0.0-next.15", type: CdkRowHoverContent, selector: "[cdkRowHoverContent]", ngImport: i0 });
|
|
1171
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: CdkRowHoverContent, decorators: [{
|
|
1172
|
+
type: Directive,
|
|
1173
|
+
args: [{
|
|
1174
|
+
selector: '[cdkRowHoverContent]',
|
|
1175
|
+
}]
|
|
1176
|
+
}], ctorParameters: function () { return [{ type: EditServices }, { type: i0.ElementRef }, { type: i0.TemplateRef }, { type: i0.ViewContainerRef }]; } });
|
|
1177
|
+
/**
|
|
1178
|
+
* Opens the closest edit popover to this element, whether it's associated with this exact
|
|
1179
|
+
* element or an ancestor element.
|
|
1180
|
+
*/
|
|
1181
|
+
class CdkEditOpen {
|
|
1182
|
+
constructor(elementRef, editEventDispatcher) {
|
|
1183
|
+
this.elementRef = elementRef;
|
|
1184
|
+
this.editEventDispatcher = editEventDispatcher;
|
|
1185
|
+
const nativeElement = elementRef.nativeElement;
|
|
1186
|
+
// Prevent accidental form submits.
|
|
1187
|
+
if (nativeElement.nodeName === 'BUTTON' && !nativeElement.getAttribute('type')) {
|
|
1188
|
+
nativeElement.setAttribute('type', 'button');
|
|
1189
|
+
}
|
|
1190
|
+
}
|
|
1191
|
+
// In Ivy the `host` metadata will be merged, whereas in ViewEngine it is overridden. In order
|
|
1192
|
+
// to avoid double event listeners, we need to use `HostListener`. Once Ivy is the default, we
|
|
1193
|
+
// can move this back into `host`.
|
|
1194
|
+
// tslint:disable-next-line:no-host-decorator-in-concrete
|
|
1195
|
+
openEdit(evt) {
|
|
1196
|
+
this.editEventDispatcher.editing.next(closest(this.elementRef.nativeElement, CELL_SELECTOR));
|
|
1197
|
+
evt.stopPropagation();
|
|
1198
|
+
}
|
|
1199
|
+
}
|
|
1200
|
+
CdkEditOpen.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: CdkEditOpen, deps: [{ token: i0.ElementRef }, { token: EditEventDispatcher }], target: i0.ɵɵFactoryTarget.Directive });
|
|
1201
|
+
CdkEditOpen.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.0.0-next.15", type: CdkEditOpen, selector: "[cdkEditOpen]", host: { listeners: { "click": "openEdit($event)" } }, ngImport: i0 });
|
|
1202
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: CdkEditOpen, decorators: [{
|
|
1203
|
+
type: Directive,
|
|
1204
|
+
args: [{
|
|
1205
|
+
selector: '[cdkEditOpen]',
|
|
1206
|
+
}]
|
|
1207
|
+
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: EditEventDispatcher }]; }, propDecorators: { openEdit: [{
|
|
1208
|
+
type: HostListener,
|
|
1209
|
+
args: ['click', ['$event']]
|
|
1210
|
+
}] } });
|
|
1211
|
+
|
|
1212
|
+
/**
|
|
1213
|
+
* @license
|
|
1214
|
+
* Copyright Google LLC All Rights Reserved.
|
|
1215
|
+
*
|
|
1216
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
1217
|
+
* found in the LICENSE file at https://angular.io/license
|
|
1218
|
+
*/
|
|
1219
|
+
const EXPORTED_DECLARATIONS = [
|
|
1220
|
+
CdkPopoverEdit,
|
|
1221
|
+
CdkPopoverEditTabOut,
|
|
1222
|
+
CdkRowHoverContent,
|
|
1223
|
+
CdkEditControl,
|
|
1224
|
+
CdkEditRevert,
|
|
1225
|
+
CdkEditClose,
|
|
1226
|
+
CdkEditable,
|
|
1227
|
+
CdkEditOpen,
|
|
1228
|
+
];
|
|
1229
|
+
class CdkPopoverEditModule {
|
|
1230
|
+
}
|
|
1231
|
+
CdkPopoverEditModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: CdkPopoverEditModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
1232
|
+
CdkPopoverEditModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: CdkPopoverEditModule, declarations: [CdkPopoverEdit,
|
|
1233
|
+
CdkPopoverEditTabOut,
|
|
1234
|
+
CdkRowHoverContent,
|
|
1235
|
+
CdkEditControl,
|
|
1236
|
+
CdkEditRevert,
|
|
1237
|
+
CdkEditClose,
|
|
1238
|
+
CdkEditable,
|
|
1239
|
+
CdkEditOpen], imports: [OverlayModule], exports: [CdkPopoverEdit,
|
|
1240
|
+
CdkPopoverEditTabOut,
|
|
1241
|
+
CdkRowHoverContent,
|
|
1242
|
+
CdkEditControl,
|
|
1243
|
+
CdkEditRevert,
|
|
1244
|
+
CdkEditClose,
|
|
1245
|
+
CdkEditable,
|
|
1246
|
+
CdkEditOpen] });
|
|
1247
|
+
CdkPopoverEditModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: CdkPopoverEditModule, providers: [
|
|
1248
|
+
{
|
|
1249
|
+
provide: PopoverEditPositionStrategyFactory,
|
|
1250
|
+
useClass: DefaultPopoverEditPositionStrategyFactory,
|
|
1251
|
+
},
|
|
1252
|
+
], imports: [[OverlayModule]] });
|
|
1253
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: CdkPopoverEditModule, decorators: [{
|
|
1254
|
+
type: NgModule,
|
|
1255
|
+
args: [{
|
|
1256
|
+
imports: [OverlayModule],
|
|
1257
|
+
exports: EXPORTED_DECLARATIONS,
|
|
1258
|
+
declarations: EXPORTED_DECLARATIONS,
|
|
1259
|
+
providers: [
|
|
1260
|
+
{
|
|
1261
|
+
provide: PopoverEditPositionStrategyFactory,
|
|
1262
|
+
useClass: DefaultPopoverEditPositionStrategyFactory,
|
|
1263
|
+
},
|
|
1264
|
+
],
|
|
1265
|
+
}]
|
|
1266
|
+
}] });
|
|
1267
|
+
|
|
1268
|
+
/**
|
|
1269
|
+
* @license
|
|
1270
|
+
* Copyright Google LLC All Rights Reserved.
|
|
1271
|
+
*
|
|
1272
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
1273
|
+
* found in the LICENSE file at https://angular.io/license
|
|
1274
|
+
*/
|
|
1275
|
+
|
|
1276
|
+
/**
|
|
1277
|
+
* @license
|
|
1278
|
+
* Copyright Google LLC All Rights Reserved.
|
|
1279
|
+
*
|
|
1280
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
1281
|
+
* found in the LICENSE file at https://angular.io/license
|
|
1282
|
+
*/
|
|
1283
|
+
|
|
1284
|
+
/**
|
|
1285
|
+
* Generated bundle index. Do not edit.
|
|
1286
|
+
*/
|
|
1287
|
+
|
|
1288
|
+
export { CdkEditClose, CdkEditControl, CdkEditOpen, CdkEditRevert, CdkEditable, CdkPopoverEdit, CdkPopoverEditModule, CdkPopoverEditTabOut, CdkRowHoverContent, DefaultPopoverEditPositionStrategyFactory, EditEventDispatcher, EditRef, FocusDispatcher, FormValueContainer, PopoverEditPositionStrategyFactory, CELL_SELECTOR as _CELL_SELECTOR, closest as _closest, matches as _matches };
|
|
1289
|
+
//# sourceMappingURL=popover-edit.mjs.map
|