@angular/cdk 11.0.0-rc.4 → 11.0.3

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.
Files changed (82) hide show
  1. package/a11y/focus-trap/focus-trap.d.ts +8 -8
  2. package/a11y/index.metadata.json +1 -1
  3. package/bundles/cdk-a11y.umd.js +18 -13
  4. package/bundles/cdk-a11y.umd.js.map +1 -1
  5. package/bundles/cdk-a11y.umd.min.js +7 -7
  6. package/bundles/cdk-a11y.umd.min.js.map +1 -1
  7. package/bundles/cdk-coercion.umd.js +5 -5
  8. package/bundles/cdk-coercion.umd.js.map +1 -1
  9. package/bundles/cdk-coercion.umd.min.js.map +1 -1
  10. package/bundles/cdk-collections.umd.js +5 -5
  11. package/bundles/cdk-collections.umd.js.map +1 -1
  12. package/bundles/cdk-collections.umd.min.js +1 -1
  13. package/bundles/cdk-collections.umd.min.js.map +1 -1
  14. package/bundles/cdk-drag-drop.umd.js +43 -11
  15. package/bundles/cdk-drag-drop.umd.js.map +1 -1
  16. package/bundles/cdk-drag-drop.umd.min.js +8 -8
  17. package/bundles/cdk-drag-drop.umd.min.js.map +1 -1
  18. package/bundles/cdk-observers.umd.js +3 -4
  19. package/bundles/cdk-observers.umd.js.map +1 -1
  20. package/bundles/cdk-observers.umd.min.js +1 -1
  21. package/bundles/cdk-observers.umd.min.js.map +1 -1
  22. package/bundles/cdk-overlay.umd.js +5 -5
  23. package/bundles/cdk-overlay.umd.js.map +1 -1
  24. package/bundles/cdk-overlay.umd.min.js +1 -1
  25. package/bundles/cdk-overlay.umd.min.js.map +1 -1
  26. package/bundles/cdk-portal.umd.js +5 -5
  27. package/bundles/cdk-portal.umd.js.map +1 -1
  28. package/bundles/cdk-portal.umd.min.js +1 -1
  29. package/bundles/cdk-portal.umd.min.js.map +1 -1
  30. package/bundles/cdk-scrolling.umd.js +5 -5
  31. package/bundles/cdk-scrolling.umd.js.map +1 -1
  32. package/bundles/cdk-scrolling.umd.min.js +2 -2
  33. package/bundles/cdk-scrolling.umd.min.js.map +1 -1
  34. package/bundles/cdk-table.umd.js +5 -5
  35. package/bundles/cdk-table.umd.js.map +1 -1
  36. package/bundles/cdk-table.umd.min.js +1 -1
  37. package/bundles/cdk-table.umd.min.js.map +1 -1
  38. package/bundles/cdk-testing-protractor.umd.js +5 -5
  39. package/bundles/cdk-testing-protractor.umd.js.map +1 -1
  40. package/bundles/cdk-testing-protractor.umd.min.js +1 -1
  41. package/bundles/cdk-testing-protractor.umd.min.js.map +1 -1
  42. package/bundles/cdk-testing-testbed.umd.js +5 -5
  43. package/bundles/cdk-testing-testbed.umd.js.map +1 -1
  44. package/bundles/cdk-testing-testbed.umd.min.js +1 -1
  45. package/bundles/cdk-testing-testbed.umd.min.js.map +1 -1
  46. package/bundles/cdk-testing.umd.js +5 -5
  47. package/bundles/cdk-testing.umd.js.map +1 -1
  48. package/bundles/cdk-testing.umd.min.js +1 -1
  49. package/bundles/cdk-testing.umd.min.js.map +1 -1
  50. package/bundles/cdk-tree.umd.js +5 -5
  51. package/bundles/cdk-tree.umd.js.map +1 -1
  52. package/bundles/cdk-tree.umd.min.js +2 -2
  53. package/bundles/cdk-tree.umd.min.js.map +1 -1
  54. package/bundles/cdk.umd.js +1 -1
  55. package/bundles/cdk.umd.js.map +1 -1
  56. package/bundles/cdk.umd.min.js +1 -1
  57. package/bundles/cdk.umd.min.js.map +1 -1
  58. package/drag-drop/drag-ref.d.ts +13 -0
  59. package/drag-drop/index.metadata.json +1 -1
  60. package/esm2015/a11y/focus-trap/focus-trap.js +14 -9
  61. package/esm2015/drag-drop/drag-ref.js +39 -8
  62. package/esm2015/observers/observe-content.js +3 -4
  63. package/esm2015/version.js +1 -1
  64. package/fesm2015/a11y.js +13 -8
  65. package/fesm2015/a11y.js.map +1 -1
  66. package/fesm2015/cdk.js +1 -1
  67. package/fesm2015/cdk.js.map +1 -1
  68. package/fesm2015/drag-drop.js +37 -6
  69. package/fesm2015/drag-drop.js.map +1 -1
  70. package/fesm2015/observers.js +2 -3
  71. package/fesm2015/observers.js.map +1 -1
  72. package/observers/index.metadata.json +1 -1
  73. package/observers/observe-content.d.ts +2 -2
  74. package/package.json +3 -3
  75. package/schematics/migration.json +5 -0
  76. package/schematics/ng-add/index.js +1 -1
  77. package/schematics/ng-update/devkit-file-system.d.ts +1 -0
  78. package/schematics/ng-update/devkit-file-system.js +20 -13
  79. package/schematics/ng-update/index.d.ts +2 -0
  80. package/schematics/ng-update/index.js +7 -2
  81. package/schematics/update-tool/target-version.d.ts +2 -1
  82. package/schematics/update-tool/target-version.js +2 -1
@@ -479,6 +479,7 @@
479
479
  if (newValue !== this._disabled) {
480
480
  this._disabled = newValue;
481
481
  this._toggleNativeDragInteractions();
482
+ this._handles.forEach(function (handle) { return toggleNativeDragInteractions(handle, newValue); });
482
483
  }
483
484
  },
484
485
  enumerable: false,
@@ -504,9 +505,21 @@
504
505
  };
505
506
  /** Registers the handles that can be used to drag the element. */
506
507
  DragRef.prototype.withHandles = function (handles) {
508
+ var _this = this;
507
509
  this._handles = handles.map(function (handle) { return coercion.coerceElement(handle); });
508
- this._handles.forEach(function (handle) { return toggleNativeDragInteractions(handle, false); });
510
+ this._handles.forEach(function (handle) { return toggleNativeDragInteractions(handle, _this.disabled); });
509
511
  this._toggleNativeDragInteractions();
512
+ // Delete any lingering disabled handles that may have been destroyed. Note that we re-create
513
+ // the set, rather than iterate over it and filter out the destroyed handles, because while
514
+ // the ES spec allows for sets to be modified while they're being iterated over, some polyfills
515
+ // use an array internally which may throw an error.
516
+ var disabledHandles = new Set();
517
+ this._disabledHandles.forEach(function (handle) {
518
+ if (_this._handles.indexOf(handle) > -1) {
519
+ disabledHandles.add(handle);
520
+ }
521
+ });
522
+ this._disabledHandles = disabledHandles;
510
523
  return this;
511
524
  };
512
525
  /**
@@ -609,8 +622,9 @@
609
622
  * @param handle Handle element that should be disabled.
610
623
  */
611
624
  DragRef.prototype.disableHandle = function (handle) {
612
- if (this._handles.indexOf(handle) > -1) {
625
+ if (!this._disabledHandles.has(handle) && this._handles.indexOf(handle) > -1) {
613
626
  this._disabledHandles.add(handle);
627
+ toggleNativeDragInteractions(handle, true);
614
628
  }
615
629
  };
616
630
  /**
@@ -618,7 +632,10 @@
618
632
  * @param handle Handle element to be enabled.
619
633
  */
620
634
  DragRef.prototype.enableHandle = function (handle) {
621
- this._disabledHandles.delete(handle);
635
+ if (this._disabledHandles.has(handle)) {
636
+ this._disabledHandles.delete(handle);
637
+ toggleNativeDragInteractions(handle, this.disabled);
638
+ }
622
639
  };
623
640
  /** Sets the layout direction of the draggable item. */
624
641
  DragRef.prototype.withDirection = function (direction) {
@@ -743,6 +760,8 @@
743
760
  var preview = this._preview = this._createPreviewElement();
744
761
  var placeholder = this._placeholder = this._createPlaceholderElement();
745
762
  var anchor = this._anchor = this._anchor || this._document.createComment('');
763
+ // Needs to happen before the root element is moved.
764
+ var shadowRoot = this._getShadowRoot();
746
765
  // Insert an anchor node so that we can restore the element's position in the DOM.
747
766
  parent.insertBefore(anchor, element);
748
767
  // We move the element out at the end of the body and we make it hidden, because keeping it in
@@ -750,7 +769,7 @@
750
769
  // from the DOM completely, because iOS will stop firing all subsequent events in the chain.
751
770
  toggleVisibility(element, false);
752
771
  this._document.body.appendChild(parent.replaceChild(placeholder, element));
753
- getPreviewInsertionPoint(this._document).appendChild(preview);
772
+ getPreviewInsertionPoint(this._document, shadowRoot).appendChild(preview);
754
773
  this.started.next({ source: this }); // Emit before notifying the container.
755
774
  dropContainer.start();
756
775
  this._initialContainer = dropContainer;
@@ -1243,6 +1262,18 @@
1243
1262
  return cachedPosition ? cachedPosition.scrollPosition :
1244
1263
  this._viewportRuler.getViewportScrollPosition();
1245
1264
  };
1265
+ /**
1266
+ * Lazily resolves and returns the shadow root of the element. We do this in a function, rather
1267
+ * than saving it in property directly on init, because we want to resolve it as late as possible
1268
+ * in order to ensure that the element has been moved into the shadow DOM. Doing it inside the
1269
+ * constructor might be too early if the element is inside of something like `ngFor` or `ngIf`.
1270
+ */
1271
+ DragRef.prototype._getShadowRoot = function () {
1272
+ if (this._cachedShadowRoot === undefined) {
1273
+ this._cachedShadowRoot = platform._getShadowRoot(this._rootElement);
1274
+ }
1275
+ return this._cachedShadowRoot;
1276
+ };
1246
1277
  return DragRef;
1247
1278
  }());
1248
1279
  /**
@@ -1276,11 +1307,12 @@
1276
1307
  return event.type[0] === 't';
1277
1308
  }
1278
1309
  /** Gets the element into which the drag preview should be inserted. */
1279
- function getPreviewInsertionPoint(documentRef) {
1310
+ function getPreviewInsertionPoint(documentRef, shadowRoot) {
1280
1311
  // We can't use the body if the user is in fullscreen mode,
1281
1312
  // because the preview will render under the fullscreen element.
1282
1313
  // TODO(crisbeto): dedupe this with the `FullscreenOverlayContainer` eventually.
1283
- return documentRef.fullscreenElement ||
1314
+ return shadowRoot ||
1315
+ documentRef.fullscreenElement ||
1284
1316
  documentRef.webkitFullscreenElement ||
1285
1317
  documentRef.mozFullScreenElement ||
1286
1318
  documentRef.msFullscreenElement ||
@@ -1329,7 +1361,7 @@
1329
1361
  extendStatics = Object.setPrototypeOf ||
1330
1362
  ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
1331
1363
  function (d, b) { for (var p in b)
1332
- if (b.hasOwnProperty(p))
1364
+ if (Object.prototype.hasOwnProperty.call(b, p))
1333
1365
  d[p] = b[p]; };
1334
1366
  return extendStatics(d, b);
1335
1367
  };
@@ -1476,10 +1508,10 @@
1476
1508
  k2 = k;
1477
1509
  o[k2] = m[k];
1478
1510
  });
1479
- function __exportStar(m, exports) {
1511
+ function __exportStar(m, o) {
1480
1512
  for (var p in m)
1481
- if (p !== "default" && !exports.hasOwnProperty(p))
1482
- __createBinding(exports, m, p);
1513
+ if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
1514
+ __createBinding(o, m, p);
1483
1515
  }
1484
1516
  function __values(o) {
1485
1517
  var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
@@ -1589,7 +1621,7 @@
1589
1621
  var result = {};
1590
1622
  if (mod != null)
1591
1623
  for (var k in mod)
1592
- if (Object.hasOwnProperty.call(mod, k))
1624
+ if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
1593
1625
  __createBinding(result, mod, k);
1594
1626
  __setModuleDefault(result, mod);
1595
1627
  return result;