├── .editorconfig ├── .gitignore ├── README.md ├── angular.json ├── e2e ├── protractor.conf.js ├── src │ ├── app.e2e-spec.ts │ └── app.po.ts └── tsconfig.e2e.json ├── package.json ├── projects └── material-angular-select │ ├── README.md │ ├── karma.conf.js │ ├── ng-package.json │ ├── package.json │ ├── src │ ├── lib │ │ ├── material-angular-select.component.html │ │ ├── material-angular-select.component.scss │ │ ├── material-angular-select.component.ts │ │ └── material-angular-select.module.ts │ ├── public_api.ts │ └── test.ts │ ├── tsconfig.lib.json │ ├── tsconfig.spec.json │ └── tslint.json ├── src ├── app │ ├── app.component.html │ ├── app.component.scss │ ├── app.component.spec.ts │ ├── app.component.ts │ └── app.module.ts ├── assets │ ├── .gitkeep │ └── life_example.gif ├── browserslist ├── environments │ ├── environment.prod.ts │ └── environment.ts ├── favicon.ico ├── index.html ├── karma.conf.js ├── main.ts ├── polyfills.ts ├── styles.scss ├── test.ts ├── tsconfig.app.json ├── tsconfig.spec.json └── tslint.json ├── tsconfig.json ├── tslint.json └── yarn.lock /.editorconfig: -------------------------------------------------------------------------------- 1 | # Editor configuration, see https://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | indent_style = space 7 | indent_size = 2 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.md] 12 | max_line_length = off 13 | trim_trailing_whitespace = false 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # compiled output 4 | /dist 5 | /tmp 6 | /out-tsc 7 | # Only exists if Bazel was run 8 | /bazel-out 9 | 10 | # dependencies 11 | /node_modules 12 | 13 | # profiling files 14 | chrome-profiler-events.json 15 | speed-measure-plugin.json 16 | 17 | # IDEs and editors 18 | /.idea 19 | .project 20 | .classpath 21 | .c9/ 22 | *.launch 23 | .settings/ 24 | *.sublime-workspace 25 | 26 | # IDE - VSCode 27 | .vscode/* 28 | !.vscode/settings.json 29 | !.vscode/tasks.json 30 | !.vscode/launch.json 31 | !.vscode/extensions.json 32 | .history/* 33 | 34 | # misc 35 | /.sass-cache 36 | /connect.lock 37 | /coverage 38 | /libpeerconnection.log 39 | npm-debug.log 40 | yarn-error.log 41 | testem.log 42 | /typings 43 | 44 | # System Files 45 | .DS_Store 46 | Thumbs.db 47 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # material-angular-select 2 | Angular select for [material-design-lite](https://github.com/google/material-design-lite) 3 | 4 | ## Live example 5 | Live example 6 | 7 | ### JS version 8 | Here you can find JS based version: [getmdl-select](https://github.com/CreativeIT/getmdl-select) 9 | 10 | ## Getting started 11 | ### Step 1: Install `material-angular-select`: 12 | ##### NPM 13 | ```shell 14 | npm install --save material-angular-select 15 | ``` 16 | or 17 | ##### YARN 18 | ```shell 19 | yarn add material-angular-select 20 | ``` 21 | ### Step 2: Import the MaterialAngularSelectModule 22 | ```typescript 23 | import { MaterialAngularSelectModule } from 'material-angular-select'; 24 | 25 | @NgModule({ 26 | declarations: [ 27 | AppComponent, 28 | ], 29 | imports: [ 30 | BrowserModule, 31 | MaterialAngularSelectModule, // add the module in imports 32 | ], 33 | providers: [], 34 | bootstrap: [AppComponent] 35 | }) 36 | export class AppModule { } 37 | ``` 38 | 39 | ### Step 3 (Optional): Include MDL 40 | If you didn't use [material-design-lite](https://github.com/google/material-design-lite) in your project before, don't forget to include necessary sources. 41 | Follow steps from [here](https://getmdl.io/started/index.html) 42 | or 43 | - add dependencies in `angular.json` 44 | ```json 45 | ... 46 | "build": { 47 | "options": { 48 | "styles": [ 49 | "node_modules/material-design-lite/src/material-design-lite.scss" 50 | ], 51 | "scripts": [ 52 | "node_modules/material-design-lite/material.js" 53 | ] 54 | ... 55 | ``` 56 | - and import icons to `index.html` 57 | ```html 58 | 59 | ``` 60 | 61 | 62 | ## Sample implementation 63 | 64 | **```app.module.ts```** 65 | 66 | ```javascript 67 | import { BrowserModule } from '@angular/platform-browser'; 68 | import { NgModule } from '@angular/core'; 69 | 70 | import { AppComponent } from './app.component'; 71 | import { MaterialAngularSelectModule } from 'angular-ratify'; 72 | 73 | @NgModule({ 74 | declarations: [ 75 | AppComponent 76 | ], 77 | imports: [ 78 | BrowserModule, 79 | MaterialAngularSelectModule, 80 | ], 81 | providers: [], 82 | bootstrap: [AppComponent] 83 | }) 84 | export class AppModule { } 85 | 86 | ``` 87 | 88 | **```app.component.html```** 89 | 90 | ```html 91 | 96 | ``` 97 | 98 | **```app.component.ts```** 99 | 100 | ```javascript 101 | import { Component } from '@angular/core'; 102 | 103 | @Component({ 104 | selector: 'app-root', 105 | templateUrl: './app.component.html', 106 | styleUrls: ['./app.component.css'] 107 | }) 108 | export class AppComponent { 109 | 110 | public readonly countries = ['Minsk', 'Berlin', 'Moscow', 'NYC']; 111 | public locationValue = 'Minsk'; 112 | 113 | public changeCountry(country) { 114 | // do something 115 | } 116 | } 117 | 118 | ``` 119 | 120 | ## API 121 | 122 | ### Inputs 123 | | Input | Type | Default | Required | Description | 124 | | ------------- | ------------- | ------------- | ------------- | ------------- | 125 | | [data] | Array [] | [] | yes | Items array | 126 | | name | string | '' | yes | Text for name of input | 127 | | label | string | '' | no | Text for label | 128 | | arrow | boolean | true | no | Allows to hide arrow | 129 | | disabled | boolean | false | no | Allows to disable select | 130 | | fixHeight | boolean | false | no | Allows to fix menu height to 280px | 131 | | isFloatingLabel | boolean | true | no | Allows to fix label | 132 | | [classStyle] | Array | null | no | Added own classes to dropdown element | 133 | | keys | {value: string, title: string} | {value: 'value', title: 'title'} | yes | Required if use array of object with different structure | 134 | | currentValue | string or {title: any, value: any} | {title: '', value: ''} | no | Set default value | 135 | 136 | ### Outputs 137 | | Output | Description | 138 | | ------ | ------ | 139 | | selectedValue | Fired on model change. Outputs whole model | 140 | 141 | 142 | 143 | ## Hire us 144 | We are ready to bring value to your business. Visit our site [creativeit.io](http://creativeit.io/) or drop us a line . We will be happy to help you! 145 | 146 | ## Support the project 147 | * Star the repo 148 | * Create issue report or feature request 149 | * Check our [material-angular-dashboard](https://github.com/CreativeIT/material-angular-dashboard) 150 | * [Tweet about it](https://twitter.com/CreativeITeam) 151 | * Follow us on [Twitter](https://twitter.com/CreativeITeam) 152 | 153 | -------------------------------------------------------------------------------- /angular.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json", 3 | "version": 1, 4 | "newProjectRoot": "projects", 5 | "projects": { 6 | "ng-material-angular-select": { 7 | "root": "", 8 | "sourceRoot": "src", 9 | "projectType": "application", 10 | "prefix": "app", 11 | "schematics": { 12 | "@schematics/angular:component": { 13 | "style": "scss" 14 | } 15 | }, 16 | "architect": { 17 | "build": { 18 | "builder": "@angular-devkit/build-angular:browser", 19 | "options": { 20 | "outputPath": "dist/ng-material-angular-select", 21 | "index": "src/index.html", 22 | "main": "src/main.ts", 23 | "polyfills": "src/polyfills.ts", 24 | "tsConfig": "src/tsconfig.app.json", 25 | "assets": [ 26 | "src/favicon.ico", 27 | "src/assets" 28 | ], 29 | "styles": [ 30 | "src/styles.scss", 31 | "node_modules/material-design-lite/src/material-design-lite.scss" 32 | ], 33 | "scripts": [ 34 | "node_modules/material-design-lite/material.js" 35 | ], 36 | "es5BrowserSupport": true 37 | }, 38 | "configurations": { 39 | "production": { 40 | "fileReplacements": [ 41 | { 42 | "replace": "src/environments/environment.ts", 43 | "with": "src/environments/environment.prod.ts" 44 | } 45 | ], 46 | "optimization": true, 47 | "outputHashing": "all", 48 | "sourceMap": false, 49 | "extractCss": true, 50 | "namedChunks": false, 51 | "aot": true, 52 | "extractLicenses": true, 53 | "vendorChunk": false, 54 | "buildOptimizer": true, 55 | "budgets": [ 56 | { 57 | "type": "initial", 58 | "maximumWarning": "2mb", 59 | "maximumError": "5mb" 60 | } 61 | ] 62 | } 63 | } 64 | }, 65 | "serve": { 66 | "builder": "@angular-devkit/build-angular:dev-server", 67 | "options": { 68 | "browserTarget": "ng-material-angular-select:build" 69 | }, 70 | "configurations": { 71 | "production": { 72 | "browserTarget": "ng-material-angular-select:build:production" 73 | } 74 | } 75 | }, 76 | "extract-i18n": { 77 | "builder": "@angular-devkit/build-angular:extract-i18n", 78 | "options": { 79 | "browserTarget": "ng-material-angular-select:build" 80 | } 81 | }, 82 | "test": { 83 | "builder": "@angular-devkit/build-angular:karma", 84 | "options": { 85 | "main": "src/test.ts", 86 | "polyfills": "src/polyfills.ts", 87 | "tsConfig": "src/tsconfig.spec.json", 88 | "karmaConfig": "src/karma.conf.js", 89 | "styles": [ 90 | "src/styles.scss" 91 | ], 92 | "scripts": [], 93 | "assets": [ 94 | "src/favicon.ico", 95 | "src/assets" 96 | ] 97 | } 98 | }, 99 | "lint": { 100 | "builder": "@angular-devkit/build-angular:tslint", 101 | "options": { 102 | "tsConfig": [ 103 | "src/tsconfig.app.json", 104 | "src/tsconfig.spec.json" 105 | ], 106 | "exclude": [ 107 | "**/node_modules/**" 108 | ] 109 | } 110 | } 111 | } 112 | }, 113 | "ng-material-angular-select-e2e": { 114 | "root": "e2e/", 115 | "projectType": "application", 116 | "prefix": "", 117 | "architect": { 118 | "e2e": { 119 | "builder": "@angular-devkit/build-angular:protractor", 120 | "options": { 121 | "protractorConfig": "e2e/protractor.conf.js", 122 | "devServerTarget": "ng-material-angular-select:serve" 123 | }, 124 | "configurations": { 125 | "production": { 126 | "devServerTarget": "ng-material-angular-select:serve:production" 127 | } 128 | } 129 | }, 130 | "lint": { 131 | "builder": "@angular-devkit/build-angular:tslint", 132 | "options": { 133 | "tsConfig": "e2e/tsconfig.e2e.json", 134 | "exclude": [ 135 | "**/node_modules/**" 136 | ] 137 | } 138 | } 139 | } 140 | }, 141 | "material-angular-select": { 142 | "root": "projects/material-angular-select", 143 | "sourceRoot": "projects/material-angular-select/src", 144 | "projectType": "library", 145 | "prefix": "lib", 146 | "architect": { 147 | "build": { 148 | "builder": "@angular-devkit/build-ng-packagr:build", 149 | "options": { 150 | "tsConfig": "projects/material-angular-select/tsconfig.lib.json", 151 | "project": "projects/material-angular-select/ng-package.json" 152 | } 153 | }, 154 | "test": { 155 | "builder": "@angular-devkit/build-angular:karma", 156 | "options": { 157 | "main": "projects/material-angular-select/src/test.ts", 158 | "tsConfig": "projects/material-angular-select/tsconfig.spec.json", 159 | "karmaConfig": "projects/material-angular-select/karma.conf.js" 160 | } 161 | }, 162 | "lint": { 163 | "builder": "@angular-devkit/build-angular:tslint", 164 | "options": { 165 | "tsConfig": [ 166 | "projects/material-angular-select/tsconfig.lib.json", 167 | "projects/material-angular-select/tsconfig.spec.json" 168 | ], 169 | "exclude": [ 170 | "**/node_modules/**" 171 | ] 172 | } 173 | } 174 | } 175 | } 176 | }, 177 | "defaultProject": "ng-material-angular-select" 178 | } 179 | -------------------------------------------------------------------------------- /e2e/protractor.conf.js: -------------------------------------------------------------------------------- 1 | // Protractor configuration file, see link for more information 2 | // https://github.com/angular/protractor/blob/master/lib/config.ts 3 | 4 | const { SpecReporter } = require('jasmine-spec-reporter'); 5 | 6 | exports.config = { 7 | allScriptsTimeout: 11000, 8 | specs: [ 9 | './src/**/*.e2e-spec.ts' 10 | ], 11 | capabilities: { 12 | 'browserName': 'chrome' 13 | }, 14 | directConnect: true, 15 | baseUrl: 'http://localhost:4200/', 16 | framework: 'jasmine', 17 | jasmineNodeOpts: { 18 | showColors: true, 19 | defaultTimeoutInterval: 30000, 20 | print: function() {} 21 | }, 22 | onPrepare() { 23 | require('ts-node').register({ 24 | project: require('path').join(__dirname, './tsconfig.e2e.json') 25 | }); 26 | jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } })); 27 | } 28 | }; -------------------------------------------------------------------------------- /e2e/src/app.e2e-spec.ts: -------------------------------------------------------------------------------- 1 | import { AppPage } from './app.po'; 2 | import { browser, logging } from 'protractor'; 3 | 4 | describe('workspace-project App', () => { 5 | let page: AppPage; 6 | 7 | beforeEach(() => { 8 | page = new AppPage(); 9 | }); 10 | 11 | it('should display welcome message', () => { 12 | page.navigateTo(); 13 | expect(page.getTitleText()).toEqual('Welcome to ng-material-angular-select!'); 14 | }); 15 | 16 | afterEach(async () => { 17 | // Assert that there are no errors emitted from the browser 18 | const logs = await browser.manage().logs().get(logging.Type.BROWSER); 19 | expect(logs).not.toContain(jasmine.objectContaining({ 20 | level: logging.Level.SEVERE, 21 | } as logging.Entry)); 22 | }); 23 | }); 24 | -------------------------------------------------------------------------------- /e2e/src/app.po.ts: -------------------------------------------------------------------------------- 1 | import { browser, by, element } from 'protractor'; 2 | 3 | export class AppPage { 4 | navigateTo() { 5 | return browser.get(browser.baseUrl) as Promise; 6 | } 7 | 8 | getTitleText() { 9 | return element(by.css('app-root h1')).getText() as Promise; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /e2e/tsconfig.e2e.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/app", 5 | "module": "commonjs", 6 | "target": "es5", 7 | "types": [ 8 | "jasmine", 9 | "jasminewd2", 10 | "node" 11 | ] 12 | } 13 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ng-material-angular-select", 3 | "version": "0.0.0", 4 | "scripts": { 5 | "ng": "ng", 6 | "start": "ng serve", 7 | "build": "ng build", 8 | "test": "ng test", 9 | "lint": "ng lint", 10 | "e2e": "ng e2e", 11 | "build-select": "ng build material-angular-select && cp ./README.md ./dist/material-angular-select", 12 | "npm-pack": "cd dist/material-angular-select && npm pack", 13 | "package": "npm run build-select && npm run npm-pack", 14 | "gh-pages": "ng build --prod ng-material-angular-select && npx angular-cli-ghpages --dir=dist/ng-material-angular-select" 15 | }, 16 | "private": true, 17 | "dependencies": { 18 | "@angular/animations": "~7.2.0", 19 | "@angular/common": "~7.2.0", 20 | "@angular/compiler": "~7.2.0", 21 | "@angular/core": "~7.2.0", 22 | "@angular/forms": "~7.2.0", 23 | "@angular/platform-browser": "~7.2.0", 24 | "@angular/platform-browser-dynamic": "~7.2.0", 25 | "@angular/router": "~7.2.0", 26 | "core-js": "^2.5.4", 27 | "material-design-lite": "^1.3.0", 28 | "rxjs": "~6.3.3", 29 | "tslib": "^1.9.0", 30 | "zone.js": "~0.8.26" 31 | }, 32 | "devDependencies": { 33 | "@angular-devkit/build-angular": "~0.13.0", 34 | "@angular-devkit/build-ng-packagr": "~0.13.0", 35 | "@angular/cli": "~7.3.8", 36 | "@angular/compiler-cli": "~7.2.0", 37 | "@angular/language-service": "~7.2.0", 38 | "@types/jasmine": "~2.8.8", 39 | "@types/jasminewd2": "~2.0.3", 40 | "@types/node": "~8.9.4", 41 | "codelyzer": "~4.5.0", 42 | "jasmine-core": "~2.99.1", 43 | "jasmine-spec-reporter": "~4.2.1", 44 | "karma": "~4.0.0", 45 | "karma-chrome-launcher": "~2.2.0", 46 | "karma-coverage-istanbul-reporter": "~2.0.1", 47 | "karma-jasmine": "~1.1.2", 48 | "karma-jasmine-html-reporter": "^0.2.2", 49 | "ng-packagr": "^4.2.0", 50 | "protractor": "~5.4.0", 51 | "ts-node": "~7.0.0", 52 | "tsickle": ">=0.34.0", 53 | "tslib": "^1.9.0", 54 | "tslint": "~5.11.0", 55 | "typescript": "~3.2.2" 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /projects/material-angular-select/README.md: -------------------------------------------------------------------------------- 1 | # material-angular-select 2 | Angular select for [material-design-lite](https://github.com/google/material-design-lite) 3 | 4 | ## Live example 5 | 6 | ![Live example](https://raw.githubusercontent.com/CreativeIT/material-angular-select/master/src/assets/live_example.gif) 7 | 8 | ### JS version 9 | Here you can find JS based version: [getmdl-select](https://github.com/CreativeIT/getmdl-select) 10 | 11 | ## Getting started 12 | ### Step 1: Install `material-angular-select`: 13 | ##### NPM 14 | ```shell 15 | npm install --save material-angular-select 16 | ``` 17 | or 18 | ##### YARN 19 | ```shell 20 | yarn add material-angular-select 21 | ``` 22 | ### Step 2: Import the MaterialAngularSelectModule 23 | ```typescript 24 | import { MaterialAngularSelectModule } from 'material-angular-select'; 25 | 26 | @NgModule({ 27 | declarations: [ 28 | AppComponent, 29 | ], 30 | imports: [ 31 | BrowserModule, 32 | MaterialAngularSelectModule, // add the module in imports 33 | ], 34 | providers: [], 35 | bootstrap: [AppComponent] 36 | }) 37 | export class AppModule { } 38 | ``` 39 | 40 | ### Step 3 (Optional): Include MDL 41 | If you didn't use [material-design-lite](https://github.com/google/material-design-lite) in your project before, don't forget to include necessary sources. 42 | Follow steps from [here](https://getmdl.io/started/index.html) 43 | or 44 | - add dependencies in `angular.json` 45 | ```json 46 | ... 47 | "build": { 48 | "options": { 49 | "styles": [ 50 | "node_modules/material-design-lite/src/material-design-lite.scss" 51 | ], 52 | "scripts": [ 53 | "node_modules/material-design-lite/material.js" 54 | ] 55 | ... 56 | ``` 57 | - and import icons to `index.html` 58 | ```html 59 | 60 | ``` 61 | 62 | 63 | ## Sample implementation 64 | 65 | **```app.module.ts```** 66 | 67 | ```javascript 68 | import { BrowserModule } from '@angular/platform-browser'; 69 | import { NgModule } from '@angular/core'; 70 | 71 | import { AppComponent } from './app.component'; 72 | import { MaterialAngularSelectModule } from 'angular-ratify'; 73 | 74 | @NgModule({ 75 | declarations: [ 76 | AppComponent 77 | ], 78 | imports: [ 79 | BrowserModule, 80 | MaterialAngularSelectModule, 81 | ], 82 | providers: [], 83 | bootstrap: [AppComponent] 84 | }) 85 | export class AppModule { } 86 | 87 | ``` 88 | 89 | **```app.component.html```** 90 | 91 | ```html 92 | 97 | ``` 98 | 99 | **```app.component.ts```** 100 | 101 | ```javascript 102 | import { Component } from '@angular/core'; 103 | 104 | @Component({ 105 | selector: 'app-root', 106 | templateUrl: './app.component.html', 107 | styleUrls: ['./app.component.css'] 108 | }) 109 | export class AppComponent { 110 | 111 | public readonly countries = ['Minsk', 'Berlin', 'Moscow', 'NYC']; 112 | public locationValue = 'Minsk'; 113 | 114 | public changeCountry(country) { 115 | // do something 116 | } 117 | } 118 | 119 | ``` 120 | 121 | ## API 122 | 123 | ### Inputs 124 | | Input | Type | Default | Required | Description | 125 | | ------------- | ------------- | ------------- | ------------- | ------------- | 126 | | [data] | Array [] | [] | yes | Items array | 127 | | name | string | '' | yes | Text for name of input | 128 | | label | string | '' | no | Text for label | 129 | | arrow | boolean | true | no | Allows to hide arrow | 130 | | disabled | boolean | false | no | Allows to disable select | 131 | | fixHeight | boolean | false | no | Allows to fix menu height to 280px | 132 | | isFloatingLabel | boolean | true | no | Allows to fix label | 133 | | [classStyle] | Array | null | no | Added own classes to dropdown element | 134 | | keys | {value: string, title: string} | {value: 'value', title: 'title'} | yes | Required if use array of object with different structure | 135 | | currentValue | string or {title: any, value: any} | {title: '', value: ''} | no | Set default value | 136 | 137 | ### Outputs 138 | | Output | Description | 139 | | ------ | ------ | 140 | | selectedValue | Fired on model change. Outputs whole model | 141 | 142 | 143 | 144 | ## Hire us 145 | We are ready to bring value to your business. Visit our site [creativeit.io](http://creativeit.io/) or drop us a line . We will be happy to help you! 146 | 147 | ## Support the project 148 | * Star the repo 149 | * Create issue report or feature request 150 | * [Tweet about it](https://twitter.com/CreativeITeam) 151 | * Follow us on [Twitter](https://twitter.com/CreativeITeam) 152 | 153 | -------------------------------------------------------------------------------- /projects/material-angular-select/karma.conf.js: -------------------------------------------------------------------------------- 1 | // Karma configuration file, see link for more information 2 | // https://karma-runner.github.io/1.0/config/configuration-file.html 3 | 4 | module.exports = function (config) { 5 | config.set({ 6 | basePath: '', 7 | frameworks: ['jasmine', '@angular-devkit/build-angular'], 8 | plugins: [ 9 | require('karma-jasmine'), 10 | require('karma-chrome-launcher'), 11 | require('karma-jasmine-html-reporter'), 12 | require('karma-coverage-istanbul-reporter'), 13 | require('@angular-devkit/build-angular/plugins/karma') 14 | ], 15 | client: { 16 | clearContext: false // leave Jasmine Spec Runner output visible in browser 17 | }, 18 | coverageIstanbulReporter: { 19 | dir: require('path').join(__dirname, '../../coverage'), 20 | reports: ['html', 'lcovonly'], 21 | fixWebpackSourcePaths: true 22 | }, 23 | reporters: ['progress', 'kjhtml'], 24 | port: 9876, 25 | colors: true, 26 | logLevel: config.LOG_INFO, 27 | autoWatch: true, 28 | browsers: ['Chrome'], 29 | singleRun: false 30 | }); 31 | }; 32 | -------------------------------------------------------------------------------- /projects/material-angular-select/ng-package.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "../../node_modules/ng-packagr/ng-package.schema.json", 3 | "dest": "../../dist/material-angular-select", 4 | "lib": { 5 | "entryFile": "src/public_api.ts" 6 | }, 7 | "whitelistedNonPeerDependencies": [ 8 | "material-design-lite" 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /projects/material-angular-select/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "material-angular-select", 3 | "version": "1.0.0", 4 | "description": "Angular select for material-design-lite", 5 | "keywords": [ 6 | "material", 7 | "mdl", 8 | "getmdl", 9 | "select", 10 | "getmdl-select", 11 | "dropdown", 12 | "getmdl-dropdown", 13 | "angular", 14 | "ng", 15 | "material-angular-select" 16 | ], 17 | "author": "CreativeIT", 18 | "license": "MIT", 19 | "repository": { 20 | "type": "git", 21 | "url": "https://github.com/CreativeIT/material-angular-select.git" 22 | }, 23 | "bugs": { 24 | "url": "https://github.com/CreativeIT/material-angular-select/issues" 25 | }, 26 | "homepage": "https://github.com/CreativeIT/material-angular-select", 27 | "peerDependencies": { 28 | "@angular/common": "^7.2.0", 29 | "@angular/core": "^7.2.0", 30 | "material-design-lite": "1.3.0" 31 | }, 32 | "dependencies": { 33 | "material-design-lite": "1.3.0" 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /projects/material-angular-select/src/lib/material-angular-select.component.html: -------------------------------------------------------------------------------- 1 |
5 | 14 | 15 | 16 |
    17 |
  • 21 | {{ item[keys.title] }} 22 |
  • 23 |
24 | 27 |
28 | -------------------------------------------------------------------------------- /projects/material-angular-select/src/lib/material-angular-select.component.scss: -------------------------------------------------------------------------------- 1 | @import '~material-design-lite/src/variables'; 2 | 3 | $getmdl-select-bg-color: $default-item-hover-bg-color !default; 4 | $getmdl-select-text-color: $text-color-primary !default; 5 | $getmdl-select-label-color: $input-text-highlight-color !default; 6 | $getmdl-select-height: 288px !default; 7 | 8 | /* scroll */ 9 | $getmdl-select-scrollbar-thumb: #666 !default; 10 | $getmdl-select-scrollbar-track: #999 !default; 11 | 12 | material-angular-select { 13 | display: block; 14 | outline: none; 15 | width: 100%; 16 | 17 | .mdl-textfield__input { 18 | cursor: pointer; 19 | 20 | &:focus { 21 | outline: none; 22 | } 23 | } 24 | 25 | .mdl-textfield__label::after { 26 | bottom: 22px; 27 | } 28 | 29 | label { 30 | display: block; 31 | margin-bottom: 0; 32 | } 33 | 34 | .mdl-icon-toggle__label { 35 | float: right; 36 | margin-top: -30px; 37 | color: $getmdl-select-text-color; 38 | transform: rotate(0); 39 | transition: transform 0.3s; 40 | } 41 | 42 | &.is-focused { 43 | .mdl-icon-toggle__label { 44 | color: $getmdl-select-label-color; 45 | transform: rotate(180deg); 46 | } 47 | } 48 | 49 | .is-item-hover { 50 | background-color: $getmdl-select-bg-color; 51 | } 52 | 53 | .mdl-menu__container { 54 | width: 100% !important; 55 | margin-top: 2px; 56 | 57 | .mdl-menu { 58 | width: 100%; 59 | 60 | .mdl-menu__item { 61 | font-size: 16px; 62 | } 63 | } 64 | } 65 | 66 | &.is-focused, 67 | &.is-dirty, 68 | &.has-placeholder { 69 | .mdl-textfield__label { 70 | color: $getmdl-select-label-color; 71 | } 72 | } 73 | 74 | // custom scroll 75 | ::-webkit-scrollbar { 76 | width: 0.5rem; 77 | height: 0.5rem; 78 | } 79 | 80 | ::-webkit-scrollbar-thumb { 81 | background: $getmdl-select-scrollbar-thumb; 82 | cursor: pointer; 83 | } 84 | 85 | ::-webkit-scrollbar-track { 86 | background: $getmdl-select-scrollbar-track; 87 | } 88 | } 89 | 90 | .material-angular-select__fix-height { 91 | .mdl-menu__container .mdl-menu { 92 | overflow-y: auto; 93 | max-height: $getmdl-select-height !important; 94 | } 95 | 96 | .mdl-menu.mdl-menu--top-left { 97 | bottom: auto; 98 | top: 0; 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /projects/material-angular-select/src/lib/material-angular-select.component.ts: -------------------------------------------------------------------------------- 1 | import 'material-design-lite/material'; 2 | 3 | declare var componentHandler: any; 4 | 5 | import { 6 | AfterViewInit, 7 | ChangeDetectorRef, 8 | Component, 9 | ElementRef, 10 | EventEmitter, 11 | Input, 12 | OnChanges, 13 | OnInit, 14 | Output, 15 | QueryList, 16 | SimpleChanges, 17 | ViewChild, 18 | ViewChildren, 19 | ViewEncapsulation, 20 | } from '@angular/core'; 21 | 22 | @Component({ 23 | selector: 'material-angular-select', // tslint:disable-line 24 | styleUrls: ['./material-angular-select.component.scss'], 25 | templateUrl: './material-angular-select.component.html', 26 | encapsulation: ViewEncapsulation.None, // tslint:disable-line 27 | }) 28 | 29 | export class MaterialAngularSelectComponent implements OnInit, OnChanges, AfterViewInit { 30 | @Input() public data: any[] = []; 31 | @Input() public label = ''; 32 | @Input() public name = ''; 33 | @Input() public fixHeight = false; 34 | @Input() public isFloatingLabel = true; 35 | @Input() public disabled = false; 36 | @Input() public classStyle: string[]; 37 | @Input() public arrow = true; 38 | @Input() public keys = { // required if use array of object with different structure 39 | value: 'value', 40 | title: 'title', 41 | }; 42 | @Input() public currentValue = { 43 | [this.keys.title]: '', 44 | [this.keys.value]: '', 45 | }; 46 | 47 | @Output() public selectedValue = new EventEmitter(); 48 | 49 | public id: string; 50 | 51 | @ViewChild('dropdown') dropdown: ElementRef; 52 | @ViewChild('input') input: ElementRef; 53 | @ViewChild('hiddenInput') hiddenInput: ElementRef; 54 | @ViewChild('menu') menu: ElementRef; 55 | @ViewChildren('li') list: QueryList; 56 | 57 | private opened = false; 58 | public isFocused = false; 59 | public dataArray = []; 60 | private isViewInit = false; 61 | private todoAfterInit = []; 62 | public arrowkeyLocation = 0; 63 | public isKeyNavigation = false; 64 | 65 | public constructor(private changeDetector: ChangeDetectorRef) { 66 | 67 | } 68 | 69 | public ngOnInit() { 70 | this.id = `id-${this.name}-${Math.round(Math.random() * 100 + 100)}`; 71 | this.changeDetector.detach(); 72 | } 73 | 74 | public ngOnChanges(changes: SimpleChanges) { 75 | if (changes.hasOwnProperty('classStyle')) { 76 | changes.classStyle.currentValue.forEach((style) => { 77 | this.dropdown.nativeElement.classList.add(style); 78 | }); 79 | } 80 | 81 | if (changes.hasOwnProperty('data')) { 82 | if (!this.isViewInit) { 83 | this.todoAfterInit.push(this.loadData.bind(this)); 84 | } else { 85 | this.loadData(); 86 | } 87 | } 88 | 89 | if (changes.hasOwnProperty('currentValue')) { 90 | if (!this.isViewInit) { 91 | this.todoAfterInit.push(this.setCurrentValue.bind(this, changes.currentValue.currentValue)); 92 | } else { 93 | this.setCurrentValue(changes.currentValue.currentValue); 94 | this.setSelectedItem(this.currentValue); 95 | } 96 | } 97 | 98 | if (!changes.hasOwnProperty('name')) { 99 | this.name = (this.name === '') ? this.label.replace(/\s/g, '') : this.name; 100 | } 101 | componentHandler.upgradeElements(this.dropdown.nativeElement); 102 | } 103 | 104 | private setCurrentValue(item) { 105 | if (!item) { 106 | return; 107 | } 108 | if (typeof item === 'string') { 109 | this.currentValue = { 110 | [this.keys.value]: item, 111 | [this.keys.title]: item, 112 | }; 113 | } else { 114 | this.currentValue = item; 115 | } 116 | } 117 | 118 | private loadData() { 119 | if (this.data.length > 0) { 120 | if (typeof this.data[0] === 'string') { 121 | this.dataArray = []; 122 | this.data.forEach((item) => { 123 | this.dataArray.push({ 124 | [this.keys.value]: item, 125 | [this.keys.title]: item, 126 | }); 127 | }); 128 | } 129 | if (typeof this.data[0] === 'object') { 130 | this.dataArray = this.data; 131 | } 132 | } 133 | this.disabled = this.dataArray.length < 1 || this.disabled; 134 | } 135 | 136 | public ngAfterViewInit() { 137 | this.isViewInit = true; 138 | this.todoAfterInit.forEach(func => func.call()); 139 | this.todoAfterInit = []; 140 | this.setSelectedItem(this.currentValue); 141 | this.changeDetector.detectChanges(); 142 | this.changeDetector.reattach(); 143 | } 144 | 145 | public menuKeyDown(event: KeyboardEvent) { 146 | event.stopImmediatePropagation(); 147 | event.stopPropagation(); 148 | event.preventDefault(); 149 | 150 | this.isKeyNavigation = true; 151 | const isVisible = this.menu.nativeElement.parentElement.classList.contains('is-visible'); 152 | switch (event.keyCode) { 153 | case 38: // arrow up 154 | this.arrowkeyLocation = this.arrowkeyLocation > 0 ? this.arrowkeyLocation - 1 : this.dataArray.length - 1; 155 | break; 156 | case 40: // arrow down 157 | this.arrowkeyLocation = this.arrowkeyLocation >= (this.dataArray.length - 1) ? 0 : this.arrowkeyLocation + 1; 158 | break; 159 | case 13: // enter 160 | if (isVisible) { 161 | this.setCurrentValue(this.data[this.arrowkeyLocation]); 162 | this.closeMenu(); 163 | } else { 164 | this.openMenu(); 165 | } 166 | break; 167 | case 27: // esc 168 | this.closeMenu(); 169 | break; 170 | } 171 | } 172 | 173 | public keyDownTab(event) { 174 | const isVisible = this.menu.nativeElement.parentElement.classList.contains('is-visible'); 175 | switch (event.keyCode) { 176 | case 9: // tab 177 | if (isVisible) { 178 | this.closeMenu(); 179 | } 180 | break; 181 | } 182 | } 183 | 184 | public onInputClick(e) { 185 | e.stopPropagation(); 186 | if (this.disabled) { 187 | return; 188 | } 189 | 190 | const isVisible = this.menu.nativeElement.parentElement.classList.contains('is-visible'); 191 | this.hideAllMenu(); 192 | if (!isVisible) { 193 | this.openMenu(); 194 | } else { 195 | this.isFocused = false; 196 | this.opened = false; 197 | } 198 | } 199 | 200 | private openMenu() { 201 | this.arrowkeyLocation = this.dataArray.findIndex(item => item[this.keys.value] === this.currentValue[this.keys.value]); 202 | this.menu.nativeElement['MaterialMenu'].show(); 203 | this.isFocused = true; 204 | this.opened = true; 205 | } 206 | 207 | private closeMenu() { 208 | this.hideAllMenu(); 209 | this.isFocused = false; 210 | this.opened = false; 211 | } 212 | 213 | private hideAllMenu() { 214 | const allSelects = document.querySelectorAll('.material-angular-select') as any; 215 | allSelects.forEach((select: HTMLElement) => { 216 | const menu = select.querySelector('.mdl-js-menu'); 217 | menu['MaterialMenu'].hide(); 218 | }); 219 | } 220 | 221 | public setSelectedItem(item) { 222 | if (!item) { 223 | return; 224 | } 225 | this.currentValue = item; 226 | this.selectedValue.emit(item); 227 | this.dropdown.nativeElement.MaterialTextfield.change(this.currentValue[this.keys.title]); // handles css class changes 228 | setTimeout(() => { 229 | this.dropdown.nativeElement.MaterialTextfield.updateClasses_(); // update css class 230 | }, 231 | 250); 232 | 233 | if ('createEvent' in document) { 234 | const evt = document.createEvent('HTMLEvents'); 235 | evt.initEvent('change', false, true); 236 | this.menu.nativeElement['MaterialMenu'].hide(); 237 | this.input.nativeElement.dispatchEvent(evt); 238 | } else { 239 | this.input.nativeElement.fireEvent('onchange'); 240 | } 241 | } 242 | } 243 | -------------------------------------------------------------------------------- /projects/material-angular-select/src/lib/material-angular-select.module.ts: -------------------------------------------------------------------------------- 1 | import { CommonModule } from '@angular/common'; 2 | import { NgModule } from '@angular/core'; 3 | 4 | import { MaterialAngularSelectComponent } from './material-angular-select.component'; 5 | 6 | @NgModule({ 7 | declarations: [MaterialAngularSelectComponent], 8 | imports: [ 9 | CommonModule, 10 | ], 11 | exports: [MaterialAngularSelectComponent], 12 | }) 13 | export class MaterialAngularSelectModule { } 14 | -------------------------------------------------------------------------------- /projects/material-angular-select/src/public_api.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Public API Surface of material-angular-select 3 | */ 4 | 5 | export * from './lib/material-angular-select.component'; 6 | export * from './lib/material-angular-select.module'; 7 | -------------------------------------------------------------------------------- /projects/material-angular-select/src/test.ts: -------------------------------------------------------------------------------- 1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files 2 | 3 | import { getTestBed } from '@angular/core/testing'; 4 | import { 5 | BrowserDynamicTestingModule, 6 | platformBrowserDynamicTesting, 7 | } from '@angular/platform-browser-dynamic/testing'; 8 | import 'core-js/es7/reflect'; 9 | import 'zone.js/dist/zone'; 10 | import 'zone.js/dist/zone-testing'; 11 | 12 | declare const require: any; 13 | 14 | // First, initialize the Angular testing environment. 15 | getTestBed().initTestEnvironment( 16 | BrowserDynamicTestingModule, 17 | platformBrowserDynamicTesting(), 18 | ); 19 | // Then we find all the tests. 20 | const context = require.context('./', true, /\.spec\.ts$/); 21 | // And load the modules. 22 | context.keys().map(context); 23 | -------------------------------------------------------------------------------- /projects/material-angular-select/tsconfig.lib.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../../out-tsc/lib", 5 | "target": "es2015", 6 | "module": "es2015", 7 | "moduleResolution": "node", 8 | "declaration": true, 9 | "sourceMap": true, 10 | "inlineSources": true, 11 | "emitDecoratorMetadata": true, 12 | "experimentalDecorators": true, 13 | "importHelpers": true, 14 | "types": [], 15 | "lib": [ 16 | "dom", 17 | "es2018" 18 | ] 19 | }, 20 | "angularCompilerOptions": { 21 | "annotateForClosureCompiler": true, 22 | "skipTemplateCodegen": true, 23 | "strictMetadataEmit": true, 24 | "fullTemplateTypeCheck": true, 25 | "strictInjectionParameters": true, 26 | "enableResourceInlining": true 27 | }, 28 | "exclude": [ 29 | "src/test.ts", 30 | "**/*.spec.ts" 31 | ] 32 | } 33 | -------------------------------------------------------------------------------- /projects/material-angular-select/tsconfig.spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../../out-tsc/spec", 5 | "types": [ 6 | "jasmine", 7 | "node" 8 | ] 9 | }, 10 | "files": [ 11 | "src/test.ts" 12 | ], 13 | "include": [ 14 | "**/*.spec.ts", 15 | "**/*.d.ts" 16 | ] 17 | } 18 | -------------------------------------------------------------------------------- /projects/material-angular-select/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tslint.json", 3 | "rules": { 4 | "directive-selector": [ 5 | true, 6 | "attribute", 7 | "lib", 8 | "camelCase" 9 | ], 10 | "component-selector": [ 11 | true, 12 | "element", 13 | "lib", 14 | "kebab-case" 15 | ] 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/app/app.component.html: -------------------------------------------------------------------------------- 1 |
2 | Star 4 |
5 | 6 |
7 |
8 |

9 | Welcome to {{ title }}! 10 |

11 |
12 |
13 |
Simple select
14 | 16 |
17 |
18 |
Simple select with arrow
19 | 20 |
21 |
22 |
23 | 24 |
25 |
With floating label
26 | 28 |
29 |
30 |
Floating label with arrow
31 | 32 |
33 |
34 |
35 |
36 |
Fixed height
37 | 39 |
40 |
41 |
Pre-selected value
42 | 45 |
Your selected value is {{currentValue}}
46 |
47 |
48 |
49 |
50 |
Disabled
51 | 52 |
53 |
54 |
Complex value
55 | 59 |
60 | Your selected value name - {{currentComplexValue.name}}, code - {{currentComplexValue.code}} 61 |
62 |
63 |
64 | 65 |
66 |
67 |
Own style classes
68 | 71 |
72 |
73 |
74 |
75 | 76 | -------------------------------------------------------------------------------- /src/app/app.component.scss: -------------------------------------------------------------------------------- 1 | .mdl-grid { 2 | margin-bottom: 1rem; 3 | } 4 | 5 | .my-class { 6 | color: red; 7 | .mdl-textfield__label { 8 | color: green; 9 | font-weight: bold; 10 | } 11 | } 12 | 13 | .star { 14 | float: right; 15 | top: 15px; 16 | right: 15px; 17 | position: absolute; 18 | } 19 | -------------------------------------------------------------------------------- /src/app/app.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed, async } from '@angular/core/testing'; 2 | import { AppComponent } from './app.component'; 3 | 4 | describe('AppComponent', () => { 5 | beforeEach(async(() => { 6 | TestBed.configureTestingModule({ 7 | declarations: [ 8 | AppComponent 9 | ], 10 | }).compileComponents(); 11 | })); 12 | 13 | it('should create the app', () => { 14 | const fixture = TestBed.createComponent(AppComponent); 15 | const app = fixture.debugElement.componentInstance; 16 | expect(app).toBeTruthy(); 17 | }); 18 | 19 | it(`should have as title 'ng-material-angular-select'`, () => { 20 | const fixture = TestBed.createComponent(AppComponent); 21 | const app = fixture.debugElement.componentInstance; 22 | expect(app.title).toEqual('ng-material-angular-select'); 23 | }); 24 | 25 | it('should render title in a h1 tag', () => { 26 | const fixture = TestBed.createComponent(AppComponent); 27 | fixture.detectChanges(); 28 | const compiled = fixture.debugElement.nativeElement; 29 | expect(compiled.querySelector('h1').textContent).toContain('Welcome to ng-material-angular-select!'); 30 | }); 31 | }); 32 | -------------------------------------------------------------------------------- /src/app/app.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, ViewEncapsulation } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-root', 5 | templateUrl: './app.component.html', 6 | styleUrls: ['./app.component.scss'], 7 | encapsulation: ViewEncapsulation.None 8 | }) 9 | export class AppComponent { 10 | title = 'material-angular-select'; 11 | cities = ['Minsk', 'Berlin', 'Moscow', 'NYC']; 12 | currentValue = 'Minsk'; 13 | countries = ['Belarus', 'Poland', 'Italy', 'USA', 'Brazil', 'France', 'Russia', 'Finland', 'Estonia']; 14 | complexCountries = [ 15 | { name: 'Belarus', code: 'BY' }, 16 | { name: 'Poland', code: 'PL' }, 17 | { name: 'Russia', code: 'RUS' }, 18 | { name: 'Finland', code: 'FI' }]; 19 | 20 | currentComplexValue = this.complexCountries[2]; 21 | 22 | selectedValue(data: { title: string, value: string }) { 23 | this.currentValue = data.title; 24 | } 25 | 26 | selectedComplexValue(data) { 27 | this.currentComplexValue = data; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/app/app.module.ts: -------------------------------------------------------------------------------- 1 | import { BrowserModule } from '@angular/platform-browser'; 2 | import { NgModule } from '@angular/core'; 3 | 4 | import { AppComponent } from './app.component'; 5 | import { MaterialAngularSelectModule } from '../../projects/material-angular-select/src/lib/material-angular-select.module'; 6 | 7 | @NgModule({ 8 | declarations: [ 9 | AppComponent 10 | ], 11 | imports: [ 12 | BrowserModule, 13 | MaterialAngularSelectModule, 14 | ], 15 | providers: [], 16 | bootstrap: [AppComponent] 17 | }) 18 | export class AppModule { } 19 | -------------------------------------------------------------------------------- /src/assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CreativeIT/material-angular-select/cdc44f6819327814054c7f481e978d4625b346ff/src/assets/.gitkeep -------------------------------------------------------------------------------- /src/assets/life_example.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CreativeIT/material-angular-select/cdc44f6819327814054c7f481e978d4625b346ff/src/assets/life_example.gif -------------------------------------------------------------------------------- /src/browserslist: -------------------------------------------------------------------------------- 1 | # This file is currently used by autoprefixer to adjust CSS to support the below specified browsers 2 | # For additional information regarding the format and rule options, please see: 3 | # https://github.com/browserslist/browserslist#queries 4 | # 5 | # For IE 9-11 support, please remove 'not' from the last line of the file and adjust as needed 6 | 7 | > 0.5% 8 | last 2 versions 9 | Firefox ESR 10 | not dead 11 | not IE 9-11 -------------------------------------------------------------------------------- /src/environments/environment.prod.ts: -------------------------------------------------------------------------------- 1 | export const environment = { 2 | production: true 3 | }; 4 | -------------------------------------------------------------------------------- /src/environments/environment.ts: -------------------------------------------------------------------------------- 1 | // This file can be replaced during build by using the `fileReplacements` array. 2 | // `ng build --prod` replaces `environment.ts` with `environment.prod.ts`. 3 | // The list of file replacements can be found in `angular.json`. 4 | 5 | export const environment = { 6 | production: false 7 | }; 8 | 9 | /* 10 | * For easier debugging in development mode, you can import the following file 11 | * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`. 12 | * 13 | * This import should be commented out in production mode because it will have a negative impact 14 | * on performance if an error is thrown. 15 | */ 16 | // import 'zone.js/dist/zone-error'; // Included with Angular CLI. 17 | -------------------------------------------------------------------------------- /src/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CreativeIT/material-angular-select/cdc44f6819327814054c7f481e978d4625b346ff/src/favicon.ico -------------------------------------------------------------------------------- /src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | NgMaterialAngularSelect 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/karma.conf.js: -------------------------------------------------------------------------------- 1 | // Karma configuration file, see link for more information 2 | // https://karma-runner.github.io/1.0/config/configuration-file.html 3 | 4 | module.exports = function (config) { 5 | config.set({ 6 | basePath: '', 7 | frameworks: ['jasmine', '@angular-devkit/build-angular'], 8 | plugins: [ 9 | require('karma-jasmine'), 10 | require('karma-chrome-launcher'), 11 | require('karma-jasmine-html-reporter'), 12 | require('karma-coverage-istanbul-reporter'), 13 | require('@angular-devkit/build-angular/plugins/karma') 14 | ], 15 | client: { 16 | clearContext: false // leave Jasmine Spec Runner output visible in browser 17 | }, 18 | coverageIstanbulReporter: { 19 | dir: require('path').join(__dirname, '../coverage/ng-material-angular-select'), 20 | reports: ['html', 'lcovonly', 'text-summary'], 21 | fixWebpackSourcePaths: true 22 | }, 23 | reporters: ['progress', 'kjhtml'], 24 | port: 9876, 25 | colors: true, 26 | logLevel: config.LOG_INFO, 27 | autoWatch: true, 28 | browsers: ['Chrome'], 29 | singleRun: false, 30 | restartOnFileChange: true 31 | }); 32 | }; 33 | -------------------------------------------------------------------------------- /src/main.ts: -------------------------------------------------------------------------------- 1 | import { enableProdMode } from '@angular/core'; 2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 3 | 4 | import { AppModule } from './app/app.module'; 5 | import { environment } from './environments/environment'; 6 | 7 | if (environment.production) { 8 | enableProdMode(); 9 | } 10 | 11 | platformBrowserDynamic().bootstrapModule(AppModule) 12 | .catch(err => console.error(err)); 13 | -------------------------------------------------------------------------------- /src/polyfills.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file includes polyfills needed by Angular and is loaded before the app. 3 | * You can add your own extra polyfills to this file. 4 | * 5 | * This file is divided into 2 sections: 6 | * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers. 7 | * 2. Application imports. Files imported after ZoneJS that should be loaded before your main 8 | * file. 9 | * 10 | * The current setup is for so-called "evergreen" browsers; the last versions of browsers that 11 | * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera), 12 | * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile. 13 | * 14 | * Learn more in https://angular.io/guide/browser-support 15 | */ 16 | 17 | /*************************************************************************************************** 18 | * BROWSER POLYFILLS 19 | */ 20 | 21 | /** IE10 and IE11 requires the following for NgClass support on SVG elements */ 22 | // import 'classlist.js'; // Run `npm install --save classlist.js`. 23 | 24 | /** 25 | * Web Animations `@angular/platform-browser/animations` 26 | * Only required if AnimationBuilder is used within the application and using IE/Edge or Safari. 27 | * Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0). 28 | */ 29 | // import 'web-animations-js'; // Run `npm install --save web-animations-js`. 30 | 31 | /** 32 | * By default, zone.js will patch all possible macroTask and DomEvents 33 | * user can disable parts of macroTask/DomEvents patch by setting following flags 34 | * because those flags need to be set before `zone.js` being loaded, and webpack 35 | * will put import in the top of bundle, so user need to create a separate file 36 | * in this directory (for example: zone-flags.ts), and put the following flags 37 | * into that file, and then add the following code before importing zone.js. 38 | * import './zone-flags.ts'; 39 | * 40 | * The flags allowed in zone-flags.ts are listed here. 41 | * 42 | * The following flags will work for all browsers. 43 | * 44 | * (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame 45 | * (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick 46 | * (window as any).__zone_symbol__BLACK_LISTED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames 47 | * 48 | * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js 49 | * with the following flag, it will bypass `zone.js` patch for IE/Edge 50 | * 51 | * (window as any).__Zone_enable_cross_context_check = true; 52 | * 53 | */ 54 | 55 | /*************************************************************************************************** 56 | * Zone JS is required by default for Angular itself. 57 | */ 58 | import 'zone.js/dist/zone'; // Included with Angular CLI. 59 | 60 | 61 | /*************************************************************************************************** 62 | * APPLICATION IMPORTS 63 | */ 64 | -------------------------------------------------------------------------------- /src/styles.scss: -------------------------------------------------------------------------------- 1 | /* You can add global styles to this file, and also import other style files */ 2 | -------------------------------------------------------------------------------- /src/test.ts: -------------------------------------------------------------------------------- 1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files 2 | 3 | import 'zone.js/dist/zone-testing'; 4 | import { getTestBed } from '@angular/core/testing'; 5 | import { 6 | BrowserDynamicTestingModule, 7 | platformBrowserDynamicTesting 8 | } from '@angular/platform-browser-dynamic/testing'; 9 | 10 | declare const require: any; 11 | 12 | // First, initialize the Angular testing environment. 13 | getTestBed().initTestEnvironment( 14 | BrowserDynamicTestingModule, 15 | platformBrowserDynamicTesting() 16 | ); 17 | // Then we find all the tests. 18 | const context = require.context('./', true, /\.spec\.ts$/); 19 | // And load the modules. 20 | context.keys().map(context); 21 | -------------------------------------------------------------------------------- /src/tsconfig.app.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/app", 5 | "types": [] 6 | }, 7 | "exclude": [ 8 | "test.ts", 9 | "**/*.spec.ts" 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /src/tsconfig.spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/spec", 5 | "types": [ 6 | "jasmine", 7 | "node" 8 | ] 9 | }, 10 | "files": [ 11 | "test.ts", 12 | "polyfills.ts" 13 | ], 14 | "include": [ 15 | "**/*.spec.ts", 16 | "**/*.d.ts" 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /src/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tslint.json", 3 | "rules": { 4 | "directive-selector": [ 5 | true, 6 | "attribute", 7 | "app", 8 | "camelCase" 9 | ], 10 | "component-selector": [ 11 | true, 12 | "element", 13 | "app", 14 | "kebab-case" 15 | ] 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compileOnSave": false, 3 | "compilerOptions": { 4 | "baseUrl": "./", 5 | "outDir": "./dist/out-tsc", 6 | "sourceMap": true, 7 | "declaration": false, 8 | "module": "es2015", 9 | "moduleResolution": "node", 10 | "emitDecoratorMetadata": true, 11 | "experimentalDecorators": true, 12 | "importHelpers": true, 13 | "target": "es5", 14 | "typeRoots": [ 15 | "node_modules/@types" 16 | ], 17 | "lib": [ 18 | "es2018", 19 | "dom" 20 | ], 21 | "paths": { 22 | "material-angular-select": [ 23 | "dist/material-angular-select" 24 | ], 25 | "material-angular-select/*": [ 26 | "dist/material-angular-select/*" 27 | ] 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "tslint:recommended", 3 | "rulesDirectory": [ 4 | "codelyzer" 5 | ], 6 | "rules": { 7 | "array-type": false, 8 | "arrow-parens": false, 9 | "deprecation": { 10 | "severity": "warn" 11 | }, 12 | "import-blacklist": [ 13 | true, 14 | "rxjs/Rx" 15 | ], 16 | "interface-name": false, 17 | "max-classes-per-file": false, 18 | "max-line-length": [ 19 | true, 20 | 140 21 | ], 22 | "member-access": false, 23 | "member-ordering": [ 24 | true, 25 | { 26 | "order": [ 27 | "static-field", 28 | "instance-field", 29 | "static-method", 30 | "instance-method" 31 | ] 32 | } 33 | ], 34 | "no-consecutive-blank-lines": false, 35 | "no-console": [ 36 | true, 37 | "debug", 38 | "info", 39 | "time", 40 | "timeEnd", 41 | "trace" 42 | ], 43 | "no-empty": false, 44 | "no-inferrable-types": [ 45 | true, 46 | "ignore-params" 47 | ], 48 | "no-non-null-assertion": true, 49 | "no-redundant-jsdoc": true, 50 | "no-switch-case-fall-through": true, 51 | "no-use-before-declare": true, 52 | "no-var-requires": false, 53 | "object-literal-key-quotes": [ 54 | true, 55 | "as-needed" 56 | ], 57 | "object-literal-sort-keys": false, 58 | "ordered-imports": false, 59 | "quotemark": [ 60 | true, 61 | "single" 62 | ], 63 | "trailing-comma": false, 64 | "no-output-on-prefix": true, 65 | "use-input-property-decorator": true, 66 | "use-output-property-decorator": true, 67 | "use-host-property-decorator": true, 68 | "no-input-rename": true, 69 | "no-output-rename": true, 70 | "use-life-cycle-interface": true, 71 | "use-pipe-transform-interface": true, 72 | "component-class-suffix": true, 73 | "directive-class-suffix": true 74 | } 75 | } 76 | --------------------------------------------------------------------------------