We've found that, with the current state of tree-shaking in the world,
that using an aggregate NgModule like `MaterialModule` leads to tools
not being able to eliminate code for components that aren't used.
In order to ensure that users end up with the smallest code size
possible, we're deprecating MaterialModule, to be removed in the a
subsequent release.
To replace `MaterialModule`, users can create their own "Material"
modul within their application (e.g., `GmailMaterialModule`) that
imports only the set of components actually used in the application.
* test(select): various test inconsistencies
* Fixes a select test that occasionally fails to capture the error inside the expect, causing it to get logged without actually being thrown. This seems to be a Zone-related issue since wrapping a few calls in `async` makes it behave correctly.
* Fixes an RTL test that fails if it is made async. This incorporates the changes from #3866 and #3163 and fixes the underlying issue. It appears that the test was failing, because IE does a slight twitch on the select panel since it goes from a pixel-based `min-width` to one with `calc` and percentages to just percentages. I've set the default width to 100% which is the same as the pixel-based one, which appears to make IE happy.
* chore: verify that changing the min-width causes failures
* chore: revert min-width change
* chore: remove a few unnecessary expressions
* fix: aot runtime issues
Currently when using the `MdSnackBar` in AOT, there will be runtime exceptions from the NgFactory. Those are caused by the re-exports of DI tokens.
The Angular compiler will then look for the first export e.g `MdLiveAnnouncer` and the normal `LiveAnnouncer` export wont be included in the factory.
This is breaking at runtime now, because the NgFactory searches for `LiveAnnouncer` but there is only the `LiveAnnouncer` (DI exception)
Since this deprecation is pretty old we can safely remove it anyways. Although this is probably an Angular that should be reported separately.
Also this commit fixes the output directory of the `aot` gulp task. Currently it outputs the factories in a wrong directory. (This allows us to serve the aot demo-app in the future)
* Remove MdUniqueSelectionDispatcher
Fixes the slide-toggle required demo, where the component will be compared with the native required state.
Basically in the demo, the form should be validated native and should show the browsers popup if the slide-toggle is required.
* No longer prints the whole SASS file-tree when running the `build:release` task.
* Added a new options that allows disabling STDOUT messages. STDERR is important for error messages.
* Renames the `unmonitor` function to `stopMonitoring`.
* Removes unnecessary code that keeps track of the `FocusOriginMonitor` subscription. After calling `stopMonitoring` the observable will complete.
* feat(dialog): allow for the dialog dimensions to be updated
Adds an `updateDimensions` method to the `MdDialogRef` which allows the user to update a dialog's dimensions after it has been created.
Fixes#2930.
* refactor: split dimensions method into two
* refactor: rename updateDimensions to updateSize
* refactor: add back _getOverlayState method
* chore: fix aot issue
* Due to the TSConfig file renaming in #3791 and the fact that they were merged at the same time, the path in the closure-compiler script is now invalid.
Fixes an error that is thrown if something attempts to access the `selected` value of `md-select` too early. The issue comes from the fact that the underlying `SelectionModel` gets initialized too late in `ngAfterContentInit`.
Fixes#3750.
* feat(theming): log a warning if core theme isn't loaded
* Checks the user's loaded stylesheets and logs a warning if the Material core theme isn't loaded.
* Fixes a wrong `typeof` check when determining the doctype.
Fixes#2828.
Note: I originally went with looping through the `document.styleSheets` to check whether the selector is defined, however I had to switch back to `getComputedStyle`, because browsers don't expose the `document.styleSheets`, if the CSS file is being loaded from another domain. This would've caused the warning to be logged if the user loads over a CDN.
* refactor: address feedback
* fix(autocomplete): do not trigger submit on ENTER
When an option is selected with the ENTER key, it should not submit the form and prevent the default input behavior
Fixes#3159
* test(autocomplete): removing extra detectChanges
* fix(dialog): leaking MdDialogContainer references
Fixes an issue that caused the `MdDialogContainer` references to not be cleaned up, and as a result, any of the `MdDialogRef` and `MdDialogConfig` instances as well. The issue seems to come from the fact that a couple of blocks that look like:
```
this._ngZone.onMicrotaskEmpty.first().subscribe(() => {
this._elementFocusedBeforeDialogWasOpened = document.activeElement;
this._focusTrap.focusFirstTabbableElement();
});
```
End up being transpiled to:
```
var _this = this;
this._ngZone.onMicrotaskEmpty.first().subscribe(function () {
_this._elementFocusedBeforeDialogWasOpened = document.activeElement;
_this._focusTrap.focusFirstTabbableElement();
});
```
This seems to cause the browser to retain the `_this` reference after the dialog has been destroyed.
Fixes#2876.
* chore: add comment about `this` usage in zone
* build: fix serve task
* Currently when serving the dev-app or e2e-app and chanages are recognized, the library task will run. This task clears the whole `dist/` and rebuilds then.
* This is problematic because sometimes only the library will be rebuilt and for example the `dev-app` won't be rebuilt. After the task ran, the `dev-app` is removed and the serve task will crash.
* Rename to library:clean-build
* build: tsconfig for editor warnings
Currently when using a code editor that uses the TypeScript language service (Webstorm / VS Code / Atom / Sublime) there will be TypeScript errors in the `.spec` files.
This is because the editor finds the `tsconfig.json` file that doesn't match the spec files. Therefore it complains about the `experimentalDecorators`.
In `angular/angular` there is a global `tsconfig` file that matches everything and is therefore fixing the editor warnings. This file is also used to compile all `.spec` files for the whole project.
We can add such a `tsconfig.json` file as well, and in the future we can use it for compiling the specs as well.
* Add docs for tsconfig files
* build: run closure-compiler
* Adds a script that runs the closure-compiler against the devapp / demo-app.
* The script will run on the CI as a new mode. Ensuring that all our components are closure-compatible.
Fixes#1206.
* Address feedback
Delays focusing the first tabbable element in a dialog until animation is done. This prevents issues where other components (e.g. autocomplete) may have a wrong position on load, because they measured dialog while it was animating.
Note on lack of tests: This is kind of hard to test, because we don't have much control over how the animations runs.
Fixes#3722.
* bug(autocomplete): deselect the other options when the user select one from the autocomplete
Fixes#3689
* bug(autocomplete): only call deselect on the previous selected option. Unit tests.
* Fixes the progress spinner not redrawing when the mode is changed dynamically from `indeterminate` to `determinate`.
* Some minor cleanup in the progress spinner.
Fixes#3648.
* fix(select): allow custom aria-label
* Adds support for custom `aria-label` attributes on the select host element.
* Also fixes that the `aria-labelledby` attribute is overwritten by the placeholder `aria-label`.
Fixes#3762.
* Fix typos
* Currently when developers call the `focus` method on the checkbox, the checkbox focuses via keyboard. This makes the focus-classes of the `FocusOriginMonitor` invalid.
* To be consistent with native input controls, the focus indicator should also show for programmatic focus.
Fixes a case where the order of overlays can be invalid if one overlay is detached, while another is destroyed. Next time both of them are open, the one that was disposed will end up beneath the freshly-created one, no matter the order of attachment. This PR adds some logic that will ensure that all each newly-opened overlay will be at the top of the stacking order.
Fixes#3574.
* feat(input): add directive for displayed error messages
Adds the `md-error` directive that can be utilised to display validation errors to the user. Example:
```
<md-input-container>
<input mdInput placeholder="email" [formControl]="emailFormControl">
<md-error *ngIf="emailFormControl.errors.required">This field is required</md-error>
<md-error *ngIf="emailFormControl.errors.pattern">
Please enter a valid email address
</md-error>
</md-input-container>
```
The `md-input-container` behavior is as follows:
* If there is an error and the user interacted with the input, the errors will be shown.
* If there is an error and the user submitted the a form that wraps the input, the errors will be shown.
* If there are errors to be shown on an input container that has `md-hint`-s, the hints will be hidden.
* If an input with hints and errors becomes valid, the hint won't be displayed anymore.
**Note:** At the moment, all hints will be hidden when an error is shown. This might not be intended for some cases (e.g. with a character counter). It might make sense to only hide the one in the `start` slot, but this could be addressed separately.
* chore: lint and aot errors
* fix: address feedback
* fix: address more feedback
* chore: use FormGroup properly
* refactor: switch back to showing hints when valid
* errror
* Avoids triggering change detection when listening to global scroll events in the `ScrollDispatcher`.
* Avoids triggering change detection when scrolling inside of `Scrollable` instances.
* Switches a `ScrollDispatcher` test to use spies, instead of toggling booleans.
Fixes a case where the first time an autocomplete is focused by clicking within its input container (note not directly on the input), the panel is invisible, because its `showPanel` flag hasn't been set yet.
Relates to #3722.