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

Commit 4ffdf09

Browse files
authored
Add Material Tree component (#104)
* Material Dialog: Add `shouldShowScrollStrokes` option for displaying stroke lines when the content is scrollable. * Material Dropdown Select: Avoid checking isSelected with deselectLabel. * Material Input: UpperBoundsValidator, and LowerBoundsValidator now use `Comparable` instead of `num`. * Material Popup: Use the real viewport (aka window) size. * Scorecard: Add `ng-content` area for a description. * Adjust positioning algorithm to account for scrolling within elements. * Migrate use of LazyEventController to StreamController.
1 parent 3180459 commit 4ffdf09

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1399
-54
lines changed

CHANGELOG.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
## 0.5.3
2+
3+
* Add Material Tree component.
4+
* Material Dialog: Add `shouldShowScrollStrokes` option for displaying
5+
stroke lines when the content is scrollable.
6+
* Material Dropdown Select: Avoid checking isSelected with deselectLabel.
7+
* Material Input: UpperBoundsValidator, and LowerBoundsValidator now use
8+
`Comparable` instead of `num`.
9+
* Material Popup: Use the real viewport (aka window) size.
10+
* Scorecard: Add `ng-content` area for a description.
11+
* Adjust positioning algorithm to account for scrolling within elements.
12+
* Migrate use of LazyEventController to StreamController.
13+
114
## 0.5.2
215

316
* Material Progress: Cleanup animations on destroy to prevent memory leaks.
@@ -15,7 +28,7 @@
1528
* Add string selection sanitizing options.
1629
* Remove `NoopStream` in favor of `Stream.empty()` as provided by the SDK.
1730
* Migrate use of LazyEventController to StreamController.
18-
* Fix bug in lazy group creation that would cause multiple groups to be
31+
* Fix bug in lazy group creation that would cause multiple groups to be
1932
created.
2033
* Strong mode fixes.
2134

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ developers to be able to use the package as soon as possible.
3131
*`<material-tooltip>`
3232
*`<material-list>`
3333
*`<material-select>`
34-
* `<material-tree>`
34+
* `<material-tree>`
3535
*`<material-auto-suggest-input>`
3636
*`<material-date-range-picker>`
3737
*`<material-menu>`

lib/src/all_components.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ export 'components/material_tab/tab_mixin.dart';
6666
export 'components/material_toggle/material_toggle.dart';
6767
export 'components/material_tooltip/material_tooltip.dart';
6868
export 'components/material_tooltip/module.dart';
69+
export 'components/material_tree/material_tree.dart';
6970
export 'components/material_yes_no_buttons/material_yes_no_buttons.dart';
7071
export 'components/mixins/button_wrapper.dart';
7172
export 'components/mixins/focusable_mixin.dart';
@@ -83,9 +84,11 @@ export 'laminate/enums/alignment.dart';
8384
export 'laminate/overlay/module.dart';
8485
export 'laminate/popup/module.dart';
8586
export 'laminate/popup/popup.dart';
87+
export 'model/selection/select.dart';
8688
export 'model/selection/selection_model.dart';
8789
export 'model/selection/selection_options.dart';
8890
export 'model/selection/src/interfaces/selectable.dart';
8991
export 'model/selection/string_selection_options.dart';
9092
export 'model/ui/display_name.dart';
9193
export 'model/ui/has_renderer.dart';
94+
export 'utils/async/async.dart';

lib/src/components/material_checkbox/material_checkbox.scss.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/src/components/material_dialog/material_dialog.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ class MaterialDialogComponent implements AfterContentChecked, OnDestroy {
112112
HtmlElement _mainElement;
113113
bool _shouldShowHeader = true;
114114
bool _shouldShowFooter = true;
115+
bool _shouldShowScrollStrokes = true;
115116
bool shouldShowTopScrollStroke = false;
116117
bool shouldShowBottomScrollStroke = false;
117118

@@ -142,9 +143,14 @@ class MaterialDialogComponent implements AfterContentChecked, OnDestroy {
142143

143144
bool get shouldShowFooter => _shouldShowFooter;
144145

146+
@Input()
147+
set shouldShowScrollStrokes(shouldShowScrollStrokes) =>
148+
_shouldShowScrollStrokes = getBool(shouldShowScrollStrokes);
149+
145150
void onScroll() => _setHeaderFooterScrollBorder();
146151

147152
void _setHeaderFooterScrollBorder() {
153+
if (!_shouldShowScrollStrokes) return;
148154
_disposer.addDisposable(_domService.scheduleRead(() {
149155
var shouldShowTopScrollStroke =
150156
_mainElement.scrollTop > 0 && error == null;

lib/src/components/material_input/material_number_validators.dart

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,8 @@ class LowerBoundValidator implements Validator {
6868
@override
6969
Map<String, dynamic> validate(AbstractControl control) {
7070
if (control.value == null || lowerBound == null) return null;
71-
assert(control.value is num); // Should be using number accessor
72-
final value = control.value as num;
73-
if (value < lowerBound) {
71+
assert(control.value is Comparable, 'Value needs to be Comparable');
72+
if (control.value < lowerBound) {
7473
return {numberBelowLowerBoundErrorKey: numberIsTooSmallMsg(lowerBound)};
7574
}
7675
return null;
@@ -95,9 +94,8 @@ class UpperBoundValidator implements Validator {
9594
@override
9695
Map<String, dynamic> validate(AbstractControl control) {
9796
if (control.value == null) return null; // Handled by accessor validator
98-
assert(control.value is num); // Should be using number accessor
99-
final value = control.value as num;
100-
if (value > upperBound) {
97+
assert(control.value is Comparable, 'Value needs to be Comparable');
98+
if (control.value > upperBound) {
10199
return {numberAboveUpperBoundErrorKey: numberIsTooLargeMsg(upperBound)};
102100
}
103101
return null;

lib/src/components/material_popup/material_popup.dart

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// BSD-style license that can be found in the LICENSE file.
44

55
import 'dart:async';
6+
import 'dart:html';
67
import 'dart:math';
78

89
import 'package:angular2/angular2.dart';
@@ -13,7 +14,6 @@ import '../../laminate/overlay/overlay.dart';
1314
import '../../laminate/popup/popup.dart'
1415
show PopupEvent, PopupRef, PopupService, PopupSizeProvider;
1516
import '../../utils/angular/properties/properties.dart';
16-
import '../../utils/async/async.dart';
1717
import '../../utils/browser/dom_service/dom_service.dart';
1818
import '../content/deferred_content_aware.dart';
1919
import '../mixins/material_dropdown_base.dart';
@@ -97,12 +97,8 @@ export '../../laminate/popup/popup.dart' show PopupSourceDirective;
9797
'z'
9898
],
9999
outputs: const [
100-
'onAnimationComplete: animationComplete',
101100
'onOpen: open',
102-
// TODO(google): See if we can refactor this out (from old component).
103-
'onOpened: opened',
104101
'onClose: close',
105-
'visibleChange',
106102
],
107103
providers: const [
108104
const Provider(PopupComponent, useExisting: MaterialPopupComponent),
@@ -125,10 +121,15 @@ class MaterialPopupComponent extends PopupComponent
125121
// Visible for testing.
126122
static const Duration SLIDE_DELAY = const Duration(milliseconds: 218);
127123

128-
final LazyEventEmitter onAnimationComplete = new LazyEventEmitter();
129-
final LazyEventEmitter onOpened = new LazyEventEmitter();
130-
final LazyEventEmitter<bool> _onContentVisible =
131-
new LazyEventEmitter<bool>.broadcast();
124+
@Output('animationComplete')
125+
Stream get onAnimationComplete => _onAnimationComplete.stream;
126+
final StreamController _onAnimationComplete =
127+
new StreamController.broadcast(sync: true);
128+
@Output('opened')
129+
Stream get onOpened => _onOpened.stream;
130+
final StreamController _onOpened = new StreamController.broadcast(sync: true);
131+
final StreamController<bool> _onContentVisible =
132+
new StreamController<bool>.broadcast(sync: true);
132133
final ChangeDetectorRef _changeDetector;
133134

134135
// Used to have a maximum of one timer to wait for CSS animations.
@@ -169,6 +170,7 @@ class MaterialPopupComponent extends PopupComponent
169170
int z = 2;
170171

171172
/// Output stream that supports [(visible)] syntax.
173+
@Output()
172174
Stream<bool> get visibleChange => onVisible;
173175

174176
/// The CSS transform origin based on configuration.
@@ -250,7 +252,7 @@ class MaterialPopupComponent extends PopupComponent
250252
changeDetector, elementRef);
251253

252254
@override
253-
Stream<bool> get contentVisible => _onContentVisible.distinct();
255+
Stream<bool> get contentVisible => _onContentVisible.stream.distinct();
254256

255257
// Returns a future that completes after a short duration that an animation
256258
// may occur (in this case, via CSS). If a pending animation is already in
@@ -270,7 +272,7 @@ class MaterialPopupComponent extends PopupComponent
270272
_animationTimer = null;
271273
_onAnimationCompleter = null;
272274
completer.complete();
273-
onAnimationComplete.add(null);
275+
_onAnimationComplete.add(null);
274276
_changeDetector.markForCheck();
275277
});
276278
}
@@ -344,15 +346,15 @@ class MaterialPopupComponent extends PopupComponent
344346
_animateContentSize();
345347
_afterAnimationDelay().then((_) {
346348
_resetContentSize();
347-
onOpened.add(null);
349+
_onOpened.add(null);
348350
});
349351
});
350352
}
351353

352354
void _noAnimationPopupOpen() {
353355
showPopup = true;
354356
_resetContentSize();
355-
onOpened.add(null);
357+
_onOpened.add(null);
356358
}
357359

358360
void _nextFrame(void fn()) {
@@ -373,7 +375,8 @@ class MaterialPopupComponent extends PopupComponent
373375
// Initializes the maximum size and content size based on the viewport size
374376
// before popup position is populated.
375377
if (_popupSizeProvider != null) {
376-
_viewportSize = await _overlayService.measureContainer();
378+
_viewportSize =
379+
new Rectangle(0, 0, window.innerWidth, window.innerHeight);
377380
contentHeight =
378381
maxHeight = _popupSizeProvider.getMaxHeight(0, _viewportSize.height);
379382
contentWidth =

lib/src/components/material_select/material_dropdown_select.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ class MaterialDropdownSelectComponent extends MaterialSelectBase
249249
if (selection == null || selection.selectedValues.isEmpty) {
250250
activeModel.activate(null);
251251
} else if (activeModel.activeItem == null ||
252+
(showDeselectItem && activeModel.activeItem == deselectLabel) ||
252253
!selection.isSelected(activeModel.activeItem)) {
253254
// If the current active item is not selected, activate the first selected
254255
// item.

lib/src/components/material_tab/tab_change_event.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ class TabChangeEvent {
2727
defaultPrevented = true;
2828
}
2929

30+
/// Returns whether the event is to or from a de-emphasized tab.
31+
bool get isDeEmphasizedTabChange =>
32+
oldSubIndex != noSelectionIndex || newSubIndex != noSelectionIndex;
33+
3034
@override
3135
String toString() =>
3236
'TabChangeEvent: [$oldIndex:$oldSubIndex] => [$newIndex:$newSubIndex]';
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
export 'src/group/material_tree_group.dart' show materialTreeLeftPaddingToken;
6+
export 'src/material_tree_dropdown.dart';
7+
export 'src/material_tree_impl.dart';

0 commit comments

Comments
 (0)