Skip to content
This repository was archived by the owner on May 20, 2023. It is now read-only.

Commit a0eff87

Browse files
committed
Updates and fix for Angular breaking change
1 parent adbdfb2 commit a0eff87

File tree

10 files changed

+76
-52
lines changed

10 files changed

+76
-52
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 0.2.1
2+
3+
* Rollup of recent changes
4+
* Includes fix for breaking change in Angular 2.2.0
5+
16
## 0.2.0
27

38
* Add a modal dialog window called material_dialog.

lib/src/components/material_expansionpanel/material_expansionpanel_set.dart

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ class MaterialExpansionPanelSet implements OnDestroy {
1818
MaterialExpansionPanel _openPanel;
1919
QueryList<MaterialExpansionPanel> _panels;
2020

21-
MaterialExpansionPanelSet(
22-
@ContentChildren(MaterialExpansionPanel) this._panels) {
21+
@ContentChildren(MaterialExpansionPanel)
22+
set panels(QueryList<MaterialExpansionPanel> value) {
23+
_panels = value;
2324
_tearDownDisposer.addStreamSubscription(
2425
_panels.changes.listen((_) => _onPanelsChange()));
2526
_onPanelsChange();
@@ -47,6 +48,10 @@ class MaterialExpansionPanelSet implements OnDestroy {
4748
panel.close.listen((event) => _onPanelClose(panel, event)));
4849
_panelDisposer.addDisposable(
4950
panel.cancel.listen((event) => _onPanelClose(panel, event)));
51+
if (panel.closeOnSave) {
52+
_panelDisposer.addDisposable(
53+
panel.save.listen((event) => _onPanelClose(panel, event)));
54+
}
5055
});
5156
}
5257

@@ -79,9 +84,9 @@ class MaterialExpansionPanelSet implements OnDestroy {
7984
}
8085

8186
void _setOpenPanel(MaterialExpansionPanel panel) {
82-
_panels.forEach((p) {
87+
for (MaterialExpansionPanel p in _panels) {
8388
if (p != panel) p.anotherExpanded = (panel != null);
84-
});
89+
}
8590
_openPanel = panel;
8691
}
8792
}

lib/src/components/material_input/material_input.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,4 +251,3 @@ class MaterialInputComponent extends BaseMaterialInput
251251
popupSourceEl = null;
252252
}
253253
}
254-

lib/src/components/material_radio/material_radio_group.dart

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -64,34 +64,10 @@ import '../../utils/disposer/disposer.dart';
6464
class MaterialRadioGroupComponent implements ControlValueAccessor, OnDestroy {
6565
final _disposer = new Disposer.oneShot();
6666
final ManagedZone _managedZone;
67+
final NgControl cd;
6768
List<MaterialRadioComponent> _children;
6869

69-
MaterialRadioGroupComponent(
70-
this._managedZone,
71-
@ContentChildren(MaterialRadioComponent) QueryList components,
72-
@Self() @Optional() NgControl cd) {
73-
_disposer.addStreamSubscription(components.changes.listen((_) {
74-
_children = new List.from(components);
75-
for (var child in _children) {
76-
_disposer
77-
..addStreamSubscription(child.focusmove.listen(_moveFocus))
78-
..addStreamSubscription(child.selectionmove.listen(_moveSelection));
79-
}
80-
if (_preselectedValue != null) {
81-
// Since this is updating children that were already dirty-checked,
82-
// need to delay this change until next angular cycle.
83-
_managedZone.onTurnDone.first.then((_) {
84-
// Initialize preselect now, this will trigger tabIndex reset.
85-
selected = _preselectedValue;
86-
// The preselected value should be used only once.
87-
_preselectedValue = null;
88-
});
89-
} else {
90-
// Initialize tabIndex.
91-
_resetTabIndex();
92-
}
93-
}));
94-
70+
MaterialRadioGroupComponent(this._managedZone, @Self() @Optional() this.cd) {
9571
_disposer.addStreamSubscription(componentSelection.selectionChanges
9672
.listen((List<SelectionChangeRecord<MaterialRadioComponent>> changes) {
9773
// Need to uncheck if selection change was made via user action.
@@ -121,9 +97,32 @@ class MaterialRadioGroupComponent implements ControlValueAccessor, OnDestroy {
12197

12298
// When NgControl is present on the host element, the component
12399
// participates in the Forms API.
124-
if (cd != null) {
125-
cd.valueAccessor = this;
126-
}
100+
cd?.valueAccessor = this;
101+
}
102+
103+
@ContentChildren(MaterialRadioComponent)
104+
set list(QueryList components) {
105+
_disposer.addStreamSubscription(components.changes.listen((_) {
106+
_children = new List.from(components);
107+
for (var child in _children) {
108+
_disposer
109+
..addStreamSubscription(child.focusmove.listen(_moveFocus))
110+
..addStreamSubscription(child.selectionmove.listen(_moveSelection));
111+
}
112+
if (_preselectedValue != null) {
113+
// Since this is updating children that were already dirty-checked,
114+
// need to delay this change until next angular cycle.
115+
_managedZone.onTurnDone.first.then((_) {
116+
// Initialize preselect now, this will trigger tabIndex reset.
117+
selected = _preselectedValue;
118+
// The preselected value should be used only once.
119+
_preselectedValue = null;
120+
});
121+
} else {
122+
// Initialize tabIndex.
123+
_resetTabIndex();
124+
}
125+
}));
127126
}
128127

129128
@override

lib/src/components/reorder_list/reorder_list.dart

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,14 @@ class ReorderListComponent implements OnDestroy {
9999
@ViewChild('placeholder', read: ElementRef)
100100
ElementRef placeholder;
101101

102-
ReorderListComponent(
103-
this._managedZone, @ContentChildren(ReorderItemDirective) this._items) {
102+
ReorderListComponent(this._managedZone) {
104103
_subscriptions = new Map<HtmlElement, List<StreamSubscription>>();
105104
_dragSubscriptions = new Map<HtmlElement, StreamSubscription>();
105+
}
106+
107+
@ContentChildren(ReorderItemDirective)
108+
set items(QueryList<ReorderItemDirective> value) {
109+
_items = value;
106110
_disposer
107111
.addStreamSubscription(_items.changes.listen((_) => _refreshItems()));
108112
_refreshItems();

lib/src/components/scorecard/scoreboard.dart

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5+
import 'dart:async';
56
import 'dart:html';
67

78
import '../glyph/glyph.dart';
@@ -70,14 +71,18 @@ class ScoreboardComponent implements OnInit, OnDestroy {
7071
bool get atScorecardBarEnd => _atScorecardBarEnd;
7172

7273
ScoreboardComponent(
73-
@ContentChildren(ScorecardComponent) this._scorecards,
7474
@Attribute('enableUniformWidths') String enableUniformWidths,
7575
this._domService,
7676
this._changeDetector) {
7777
_enableUniformWidths = enableUniformWidths != 'false'; // Defaults to true
78+
}
79+
80+
@ContentChildren(ScorecardComponent)
81+
set scoreCards(QueryList<ScorecardComponent> value) {
82+
_scorecards = value;
7883
_disposer.addStreamSubscription(
79-
_scorecards.changes.listen((_) => _onScorecardsChange()));
80-
_onScorecardsChange();
84+
_scorecards.changes.listen((_) => _onScorecardsChange));
85+
scheduleMicrotask(_onScorecardsChange);
8186
}
8287

8388
@override

lib/src/components/scorecard/scorecard.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ class ScorecardComponent extends KeyboardOnlyFocusIndicatorDirective {
182182
/// Whether the selection state of the scorecard can be changed by clicking.
183183
@HostBinding('class.selectable')
184184
bool get selectable => _selectable;
185+
185186
@Input()
186187
set selectable(selectable) {
187188
_selectable = getBool(selectable);

lib/src/laminate/popup/src/popup_source_directive.dart

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -78,17 +78,14 @@ class PopupSourceDirective
7878

7979
@override
8080
Stream<Rectangle<num>> onDimensionsChanged({bool track: false}) {
81-
StreamController<Rectangle> buffer;
82-
return (buffer = new StreamController(
83-
sync: true,
84-
onListen: () {
85-
buffer.addStream(_popupSource.onDimensionsChanged(track: track));
86-
}))
87-
.stream;
81+
return _popupSource.onDimensionsChanged(track: track).distinct();
8882
}
8983

9084
void _updateSource() {
91-
_popupSource = _domPopupSourceFactory.create(_elementRef.nativeElement,
92-
alignOriginX: _alignOriginX, alignOriginY: _alignOriginY);
85+
_popupSource = _domPopupSourceFactory.create(
86+
_elementRef.nativeElement,
87+
alignOriginX: _alignOriginX,
88+
alignOriginY: _alignOriginY,
89+
);
9390
}
9491
}

lib/src/utils/browser/dom_service/dom_service.dart

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ import '../../disposer/disposable_callback.dart';
1414

1515
import '../../disposer/disposer.dart';
1616

17-
// TODO(google): Consolidate this with RenderSync /Angular.
18-
1917
/// A callback from [DomService.scheduleRead] or [DomService.scheduleWrite].
2018
typedef void DomReadWriteFn();
2119

@@ -406,6 +404,17 @@ class DomService {
406404
StreamSubscription addLayoutObserver(void domReadCallback()) =>
407405
onLayoutChanged.listen((_) => domReadCallback());
408406

407+
String describeStability() {
408+
return {
409+
'_insideDigest': _insideDigest,
410+
'_scheduledProcessQueue': _scheduledProcessQueue,
411+
'_layoutObserveRead': _layoutObserveRead != null,
412+
'_nextFrameFuture': _nextFrameFuture != null,
413+
'_domReadQueue': _domReadQueue.length,
414+
'_domWriteQueue': _domWriteQueue.length,
415+
}.toString();
416+
}
417+
409418
/// Whether there is any pending update.
410419
bool get hasPendingUpdate =>
411420
_insideDigest ||

pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: angular2_components
2-
version: 0.2.0
2+
version: 0.2.1
33
description: >
44
The official Material Design components for AngularDart. Used at Google
55
in production apps.
@@ -8,7 +8,7 @@ author: Dart Team <[email protected]>
88
environment:
99
sdk: '>=1.20.0 <2.0.0'
1010
dependencies:
11-
angular2: ^2.1.0
11+
angular2: '>=2.2.0 <2.3.0'
1212
intl: ^0.14.0
1313
js: ^0.6.1
1414
observable: ^0.14.0+1

0 commit comments

Comments
 (0)