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

Commit 373945c

Browse files
authored
Add Material Select (#65)
* Add Dynamic Component. * Add Material Select. * Material Chip: Add option for icon on the left. * Material Expansionpanel: Add option to always display expansion icon. * Material Input: * Add an optional errorRenderer that will allow clients to override/specify their own error messages. * Add percent input directive. * Material Multiline Input: Fix 'hint' typo in inputs list. * Material Radio Group: Support deselecting all radio buttons for unmatched value. * Material Tooltip: Reduce delay. * i18l improvements.
1 parent 6cd04a4 commit 373945c

File tree

70 files changed

+2814
-82
lines changed

Some content is hidden

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

70 files changed

+2814
-82
lines changed

CHANGELOG.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,21 @@ This code is considered production quality, but depends on angular2:
44
3.0.0-alpha+1. The alpha tag represents the evolving nature of the AngularDart
55
api, not code quality (3.0.0-alpha+1 is used in production Google apps).
66

7-
* Add code Material Design .scss files as a reference. Currently not used
7+
* Add Dynamic Component.
8+
* Add Material Select.
9+
* Add core Material Design .scss files as a reference. Currently not used
810
during build.
11+
* Material Chip: Add option for icon on the left.
12+
* Material Expansionpanel: Add option to always display expansion icon.
13+
* Material Input:
14+
* Add an optional errorRenderer that will allow clients to override/specify
15+
their own error messages.
16+
* Add percent input directive.
17+
* Material Multiline Input: Fix 'hint' typo in inputs list.
18+
* Material Radio Group: Support deselecting all radio buttons for unmatched
19+
value.
20+
* Material Tooltip: Reduce delay.
21+
* i18l improvements.
922

1023
## 0.4.0-alpha
1124

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ possible.
3232
*`<material-popup>`
3333
*`<material-tooltip>`
3434
*`<material-list>`
35-
* `<material-select>`
35+
* `<material-select>`
3636
*`<material-tree>`
3737
*`<material-auto-suggest-input>`
3838
*`<material-date-range-picker>`

lib/angular2_components.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const List<Type> materialDirectives = const [
1616
ClickableTooltipTargetDirective,
1717
DarkThemeDirective,
1818
DeferredContentDirective,
19+
DisplayNameRendererDirective,
1920
FixedMaterialTabStripComponent,
2021
FocusActivableItemDirective,
2122
FocusItemDirective,
@@ -28,6 +29,7 @@ const List<Type> materialDirectives = const [
2829
MaterialChipComponent,
2930
MaterialChipsComponent,
3031
MaterialDialogComponent,
32+
MaterialDropdownSelectComponent,
3133
MaterialExpansionPanel,
3234
MaterialExpansionPanelSet,
3335
MaterialFabComponent,
@@ -44,6 +46,8 @@ const List<Type> materialDirectives = const [
4446
MaterialRadioComponent,
4547
MaterialRadioGroupComponent,
4648
MaterialRippleComponent,
49+
MaterialSelectComponent,
50+
MaterialSelectItemComponent,
4751
MaterialSpinnerComponent,
4852
MaterialTabComponent,
4953
MaterialTabPanelComponent,

lib/src/all_components.dart

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export 'components/auto_dismiss/auto_dismiss.dart';
99
export 'components/button_decorator/button_decorator.dart';
1010
export 'components/content/deferred_content.dart';
1111
export 'components/content/deferred_content_aware.dart';
12+
export 'components/dynamic_component/dynamic_component.dart';
1213
export 'components/focus/focus.dart';
1314
export 'components/focus/focus_activable_item.dart';
1415
export 'components/focus/focus_item.dart';
@@ -32,9 +33,11 @@ export 'components/material_input/input_wrapper.dart';
3233
export 'components/material_input/material_input.dart'
3334
hide materialInputErrorKey;
3435
export 'components/material_input/material_input_default_value_accessor.dart';
36+
export 'components/material_input/material_input_error_keys.dart';
3537
export 'components/material_input/material_input_multiline.dart';
3638
export 'components/material_input/material_number_accessor.dart';
3739
export 'components/material_input/material_number_validators.dart';
40+
export 'components/material_input/material_percent_directive.dart';
3841
export 'components/material_list/material_list.dart';
3942
export 'components/material_list/material_list_item.dart';
4043
export 'components/material_list/material_list_size.dart';
@@ -43,6 +46,15 @@ export 'components/material_progress/material_progress.dart';
4346
export 'components/material_radio/material_radio.dart';
4447
export 'components/material_radio/material_radio_group.dart';
4548
export 'components/material_ripple/material_ripple.dart';
49+
export 'components/material_select/activation_handler.dart';
50+
export 'components/material_select/display_name.dart';
51+
export 'components/material_select/dropdown_button.dart';
52+
export 'components/material_select/material_dropdown_select.dart';
53+
export 'components/material_select/material_select.dart';
54+
export 'components/material_select/material_select_base.dart';
55+
export 'components/material_select/material_select_dropdown_item.dart';
56+
export 'components/material_select/material_select_item.dart';
57+
export 'components/material_select/shift_click_selection.dart';
4658
export 'components/material_spinner/material_spinner.dart';
4759
export 'components/material_tab/fixed_material_tab_strip.dart';
4860
export 'components/material_tab/material_tab.dart';
@@ -52,16 +64,24 @@ export 'components/material_toggle/material_toggle.dart';
5264
export 'components/material_tooltip/material_tooltip.dart';
5365
export 'components/material_tooltip/module.dart';
5466
export 'components/material_yes_no_buttons/material_yes_no_buttons.dart';
67+
export 'components/mixins/button_wrapper.dart';
5568
export 'components/mixins/focusable_mixin.dart';
5669
export 'components/mixins/has_tab_index.dart';
5770
export 'components/mixins/material_dropdown_base.dart';
71+
export 'components/mixins/track_layout_changes.dart';
5872
export 'components/reorder_list/reorder_list.dart';
5973
export 'components/scorecard/scoreboard.dart';
6074
export 'components/scorecard/scorecard.dart';
6175
export 'components/theme/dark_theme.dart';
6276
export 'components/theme/module.dart';
6377
export 'laminate/components/modal/modal.dart';
78+
export 'laminate/enums/alignment.dart';
6479
export 'laminate/overlay/module.dart';
6580
export 'laminate/popup/module.dart';
6681
export 'laminate/popup/popup.dart';
6782
export 'model/selection/selection_model.dart';
83+
export 'model/selection/selection_options.dart';
84+
export 'model/selection/src/interfaces/selectable.dart';
85+
export 'model/selection/string_selection_options.dart';
86+
export 'model/ui/display_name.dart';
87+
export 'model/ui/has_renderer.dart';

lib/src/components/button_decorator/button_decorator.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ class ButtonDirective extends RootFocusable with HasTabIndex {
7070
_hostTabIndex = value;
7171
}
7272

73-
7473
/// Triggers if not disabled.
7574
void handleClick(MouseEvent mouseEvent) {
7675
if (_disabled) return;
@@ -87,5 +86,4 @@ class ButtonDirective extends RootFocusable with HasTabIndex {
8786
keyboardEvent.preventDefault();
8887
}
8988
}
90-
9189
}
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
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+
import 'dart:async';
6+
7+
import '../../model/ui/has_renderer.dart';
8+
import '../../utils/async/async.dart';
9+
import 'package:angular2/angular2.dart';
10+
11+
/// Dynamically renders another component, setting the [value] field on the
12+
/// dynamic component if it implements [RendersValue] (and not if the component
13+
/// does not implement the interface).
14+
///
15+
/// A host component can load child components in a loop and set their values:
16+
///
17+
/// ... *ngFor="item in items">
18+
/// <dynamic-component
19+
/// [componentType]="aTypeThatMayNotRenderValue"
20+
/// [value]="item">
21+
/// </dynamic-component>
22+
///
23+
@Component(
24+
selector: 'dynamic-component',
25+
// #marker variable is used to refer to the <div> tag later when calling
26+
// DynamicComponentLoader.loadNextToLocation. The tag does not have to be
27+
// <span>. It can be anything. In this case, we simply needed something
28+
// that's not visible, and <span> does the job perfectly.
29+
template: '''<span #marker></span>''')
30+
class DynamicComponent implements OnDestroy {
31+
final DynamicComponentLoader _componentLoader;
32+
final ChangeDetectorRef _changeDetectorRef;
33+
final _onLoadController = new LazyStreamController<ComponentRef>();
34+
35+
ViewContainerRef _viewContainerRef;
36+
bool _loadDeferred = false;
37+
38+
@ViewChild('marker', read: ViewContainerRef)
39+
set viewContainerRef(ViewContainerRef value) {
40+
_viewContainerRef = value;
41+
if (_loadDeferred) {
42+
_initialize();
43+
_loadDeferred = false;
44+
}
45+
}
46+
47+
ComponentRef _childComponent;
48+
Type _componentType;
49+
Object _value;
50+
51+
/// Fired when component is loaded allowing clients to get a handle on the
52+
/// component loaded.
53+
@Output()
54+
Stream<ComponentRef> get onLoad => _onLoadController.stream;
55+
56+
DynamicComponent(this._componentLoader, this._changeDetectorRef);
57+
58+
/// Returns the loaded dynamic component reference.
59+
ComponentRef get childComponent => _childComponent;
60+
61+
@override
62+
void ngOnDestroy() {
63+
_disposeChildComponent();
64+
_viewContainerRef = null;
65+
}
66+
67+
void _disposeChildComponent() {
68+
_childComponent?.destroy();
69+
_childComponent = null;
70+
}
71+
72+
/// The type of component to dynamically render.
73+
@Input()
74+
set componentType(Type dartType) {
75+
_disposeChildComponent();
76+
_componentType = dartType;
77+
if (dartType == null) {
78+
return;
79+
}
80+
if (_viewContainerRef != null) {
81+
_initialize();
82+
} else {
83+
_loadDeferred = true;
84+
}
85+
}
86+
87+
void _initialize() {
88+
Type loadType = _componentType;
89+
_componentLoader
90+
.loadNextToLocation(loadType, _viewContainerRef)
91+
.then((ComponentRef componentRef) {
92+
if (loadType != _componentType) {
93+
// During the load time, the component type has changed,
94+
// and the type we just loaded is no longer valid.
95+
componentRef.destroy();
96+
return;
97+
}
98+
if (_childComponent != null) {
99+
throw 'Attempting to overwrite a dynamic component';
100+
}
101+
_childComponent = componentRef;
102+
_onLoadController.add(componentRef);
103+
_updateChildComponent();
104+
});
105+
}
106+
107+
/// The value to set on the component if the component implements
108+
/// [RendersValue]. Optional.
109+
@Input()
110+
set value(dynamic s) {
111+
_value = s;
112+
_updateChildComponent();
113+
}
114+
115+
void _updateChildComponent() {
116+
_changeDetectorRef.markForCheck();
117+
118+
if (_childComponent != null) {
119+
if (_childComponent.instance is RendersValue) {
120+
_childComponent.instance.value = _value;
121+
}
122+
}
123+
}
124+
}

lib/src/components/glyph/glyph.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ const List<String> _flippedIcons = const [
1616
'chevron_right',
1717
'navigate_before',
1818
'navigate_next',
19+
'last_page',
20+
'first_page',
21+
'open_in_new',
22+
'exit_to_app',
1923
];
2024

2125
/// A component that creates a material style icon. Currently only font icons

lib/src/components/glyph/glyph.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
for details. All rights reserved. Use of this source code is governed by a
44
BSD-style license that can be found in the LICENSE file.
55
-->
6-
<i [class.material-icons]="useMaterialIconsExtended"
6+
<i class="glyph-i"
7+
[class.material-icons]="useMaterialIconsExtended"
78
aria-hidden="true">
89
{{iconName}}
910
</i>

lib/src/components/glyph/glyph.scss.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
* for details. All rights reserved. Use of this source code is governed by a
44
* BSD-style license that can be found in the LICENSE file.
55
*/
6-
:host{display:-webkit-inline-flex;display:inline-flex}:host[light]{opacity:0.54}:host[size="x-small"] /deep/ i{font-size:12px;height:1em;line-height:1em;width:1em}:host[size="small"] /deep/ i{font-size:13px;height:1em;line-height:1em;width:1em}:host[size="medium"] /deep/ i{font-size:16px;height:1em;line-height:1em;width:1em}:host[size="large"] /deep/ i{font-size:18px;height:1em;line-height:1em;width:1em}:host[size="x-large"] /deep/ i{font-size:20px;height:1em;line-height:1em;width:1em}:host-context([dir="rtl"])[flip]{transform:scaleX(-1)}
6+
:host{display:-webkit-inline-flex;display:inline-flex}:host[light]{opacity:0.54}:host[size="x-small"] /deep/ i{font-size:12px;height:1em;line-height:1em;width:1em}:host[size="small"] /deep/ i{font-size:13px;height:1em;line-height:1em;width:1em}:host[size="medium"] /deep/ i{font-size:16px;height:1em;line-height:1em;width:1em}:host[size="large"] /deep/ i{font-size:18px;height:1em;line-height:1em;width:1em}:host[size="x-large"] /deep/ i{font-size:20px;height:1em;line-height:1em;width:1em}:host-context([dir="rtl"])[flip] .glyph-i{transform:scaleX(-1)}

0 commit comments

Comments
 (0)