Giter Club home page Giter Club logo

promact / md2 Goto Github PK

View Code? Open in Web Editor NEW
379.0 31.0 116.0 32.16 MB

Angular2 based Material Design components, directives and services are Accordion, Autocomplete, Collapse, Colorpicker, Datepicker, Dialog(Modal), Menu, Multiselect, Select, Tabs, Tags(Chips), Toast and Tooltip.

Home Page: http://code.promactinfo.com/md2/

License: MIT License

TypeScript 69.21% HTML 8.89% CSS 15.81% JavaScript 4.72% Shell 1.37%
material angular2 chip material-design color-picker accordion datepicker autocomplete

md2's Introduction

MD2

Angular2 based Material Design components, directives and services are Accordion, Autocomplete, Chips(Tags), Collapse, Colorpicker, Data Table, Datepicker, Dialog(Modal), Menu, Multiselect, Select, Tabs, Tags(Chips), Toast and Tooltip.

npm version Build Status

Installation

The latest release of MD2 can be installed from npm

npm install --save md2

Playing with the latest changes from master is also possible

npm install --save https://github.com/Promact/md2.git

Getting started

Setup MD2 in your project

// system.config.js
// ================
{
  map: {
    'md2': 'node_modules/md2/bundles/md2.umd.js'
  }
}


// app.module.ts
// =============

import { Md2Module }  from 'md2';
@NgModule({
  imports: [
    ...,
    Md2Module,
  ],
  ...
})
export class AppModule { }

Demo

demo and demo sources.

Components:

The goal of MD2

Our goal is to build a set of high-quality UI components built with Angular and TypeScript, following the Material Design spec. These components will serve as an example of how to write Angular code following best practices.

What do we mean by "high-quality"?

  • Internationalized and accessible so that all users can use them.
  • Straightforward APIs that don't confuse developers.
  • Behave as expected across a wide variety of use-cases without bugs.
  • Behavior is well-tested with both unit and integration tests.
  • Customizable within the bounds of the Material Design specification.
  • Performance cost is minimized.
  • Code is clean and well-documented to serve as an example for Angular devs.

Browser and screen reader support

MD2 supports the most recent two versions of all major browsers: Chrome (including Android), Firefox, Safari (including iOS), and IE11 / Edge

We also aim for great user experience with the following screen readers:

  • NVDA and JAWS with IE / FF / Chrome (on Windows).
  • VoiceOver with Safari on iOS and Safari / Chrome on OSX.
  • TalkBack with Chrome on Android.

md2's People

Contributors

asherbarak avatar bjoernkw avatar chintans avatar danribbens avatar dharmeshpipariya avatar dharmeshpipariya-zz avatar igorivaniuk avatar jefersonestevo avatar krupa310 avatar leocaseiro avatar mi9rom avatar mmrath avatar naspinski avatar orokon avatar rolfsskiv avatar rushi216 avatar sergeioff avatar shalugin avatar shreel2015 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

md2's Issues

[email protected] md2-select not work in Firefox and IE11

The issue is that when I select an option , the selected value will not update.
<md2-select [(ngModel)]="selectedCategory" placeholder="category">
<option *ngFor="let i of categories" [value]="i">{{i}}

even I use:
<md2-select [(ngModel)]="selectedCategory" (change)="onChange($event)" placeholder="category">
<option *ngFor="let i of categories" [value]="i">{{i}}

onChange(newValue) {
  this.selectedCategory= newValue;
}

I ran the demo on Chrome, Firefox, IE11 and the result is only work on chrome.

Demo Confirm Dialog not working

The demo of Confirm Dialog does not work. Show a dialog, but with not buttons to either confirm or cancel, as I guess it suppose to work.

screen

Accordion should accept multiple a template string

I don't think there is a way to define a boolean in html template, so if I want to set the multiple property in the accordion, it should accept 'false' or 'true' as string in the template.

Right now it only accepts boolean values, and boolean values only can be passed if they are bound.

<!-- How it is right now -->
<md2-accordion [multiple]="multiple"> <!-- where multiple have to be bound in the component -->
<!-- How should be permited -->
<md2-accordion multiple="false">
<!-- or -->
<md2-accordion multiple="true">

Format of datepicker not being used on render.

The passed format to the datepicker only is being used when a new date is selected, when it first loads it uses the default format.

    dateFormat = 'MM/DD/YYYY';

Template:

    <md2-datepicker
       [formControlName]="question.key"
       [id]="question.id"
       [type]="question.type"
       [format]="dateFormat"
   ></md2-datepicker>

Tooltip bug on firefox browser

Tooltip not disappear when appear and change the other view page. Tooltip continue showing in the appear position when leave the view page and not disappear.

appear

When leave the view the tooltip continue showing

continue appear when leave the view

Congratulations for md2 project!!!

Support for theming

Your component look great, especially the datepicker. Is custom theming already supported? If no, when can we expect it?

Datepicker should position itself to always be visible within viewport

Hi,

Currently, the datepicker always opens to the bottom.

Ideally there would either be:

  • An option to control how the datepicker opens (@Input() position) with either top or bottom
  • The ability for the datepicker to detect if it is near the edge of the viewport, and open in the opposite direction if it is

Unable to load transpiler to transpile http://localhost:5555/node_modules/md2/index.js

I am trying to integrate md2 with angular seed .But i'm getting these following errors.
Seed info :https://github.com/mgechev/angular-seed

My project.config.ts file

import { join } from 'path';

import { SeedConfig } from './seed.config';

/**
 * This class extends the basic seed configuration, allowing for project specific overrides. A few examples can be found
 * below.
 */
export class ProjectConfig extends SeedConfig {

  PROJECT_TASKS_DIR = join(process.cwd(), this.TOOLS_DIR, 'tasks', 'project');

  constructor() {
    super();
    //this.APP_TITLE = 'Put name of your app here';


    /* Enable typeless compiler runs (faster) between typed compiler runs. */
    // this.TYPED_COMPILE_INTERVAL = 5;

    // Add `NPM` third-party libraries to be injected/bundled.
    this.NPM_DEPENDENCIES = [
      ...this.NPM_DEPENDENCIES,
      /* Select a pre-built Material theme */
     {src: '@angular/material/core/theming/prebuilt/indigo-pink.css', inject: true},
      // {src: 'jquery/dist/jquery.min.js', inject: 'libs'},
      // {src: 'lodash/lodash.min.js', inject: 'libs'},
    ];

    // Add `local` third-party libraries to be injected/bundled.
    this.APP_ASSETS = [
      ...this.APP_ASSETS,
      // {src: `${this.APP_SRC}/your-path-to-lib/libs/jquery-ui.js`, inject: true, vendor: false}
      // {src: `${this.CSS_SRC}/path-to-lib/test-lib.css`, inject: true, vendor: false},
    ];

    /* Add to or override NPM module configurations: */
    // this.mergeObject(this.PLUGIN_CONFIGS['browser-sync'], { ghostMode: false });
    // add Material configuration to SystemJS.
   this.addPackageBundles({
     name:'@angular/material',
     path:'node_modules/@angular/material/material.umd.js',
     packageMeta:{
       main: 'index.js',
       defaultExtension: 'js'
     }
   });

   // add Material configuration to SystemJS.
  this.addPackageBundles({
    name:'md2',
    path:'node_modules/md2/index.js',
    packageMeta:{
      main: 'md2.umd.js',
      format:'cjs'
    }
  });

  }

}

image

[email protected] and 0.0.6 dont't work on @angular 2.1.0 with meteor 1.4

When run the meteor app run well, but in the browser the error appear:

Uncaught SyntaxError: Unexpected token import

The error is in this line:

import { ApplicationRef, ComponentFactoryResolver, Injectable, ReflectiveInjector, NgModule } from '@angular/core';

this is the fragment of code when the error appear:

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//                                                                                                                     //
// node_modules/md2/toast/toast.js                                                                                     //
//                                                                                                                     //
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                                                                                                                       //
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {                               // 1
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;                                                     // 5
};                                                                                                                     // 6
var __metadata = (this && this.__metadata) || function (k, v) {                                                        // 7
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);          // 8
};                                                                                                                     // 9
import { ApplicationRef, ComponentFactoryResolver, Injectable, ReflectiveInjector, NgModule } from '@angular/core';    // 10
import { CommonModule } from '@angular/common';                                                                        // 11
import { Md2ToastComponent } from './toast.component';                                                                 // 12
export var Toast = (function () {                                                                                      // 13
    function Toast(message) {

Use hash in demo page

Github Pages does not recognize the routes, and the app does not load if the route if different from root. So you should consider using hash to handle the root. Using this will improve user history navigation and page reloading behavior.
use:
RouterModule.forRoot(ROUTES, { useHash: true }),
result:
http://code.promactinfo.com/md2/#/accordion
instead try to go to:
http://code.promactinfo.com/md2/accordion

The hashed url redirects to root, cause it does not know any route with hash, but if it did it would redirect to that route. Instead, the unhashed url throws a 404 error page.

Unexpected token export

Hey guys I'm getting this error when trying to run it:

index.js:1 Uncaught SyntaxError: Unexpected token export

This is just happening by adding Md2Module.forRoot() in my module.

Using: Angular 2.2.4 with Webpack

Can't import Md2Module into project created and built with angular-cli beta 15

When trying to import the library into a project built using beta 15 of the angular cli and webpack I follow the same steps as other libraries and add

import { Md2Module } from 'md2/all';

and add Md2Module.forRoot() to the NgModule imports

in app.module.ts

It builds fine but on running it gives the error

Uncaught Error: Cannot find module "."

This happens even with or without .forRoot and also for importing individual modules such as Md2DatePicker

Can you update the documentation with the correct configuration to get everything running with the angular cli.

Thanks

Angular CLI Issue

I had this library working fine using systemjs . I had to move to web pack and I get the following error

webpack: bundle is now VALID
/Users/ar/Programs/angCLI/CashPanda/node_modules/md2/index.js:1
(function (exports, require, module, __filename, __dirname) { export * from './core';
^^^^^^
SyntaxError: Unexpected token export
at Object.exports.runInThisContext (vm.js:76:16)
at Module._compile (module.js:542:28)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object. (/Users/ar/Programs/angCLI/CashPanda/dist/server/server.bundle.js:2212:18)
at webpack_require (/Users/ar/Programs/angCLI/CashPanda/dist/server/server.bundle.js:21:30)

The module definition is

import { Md2Module } from 'md2';
import { MdCardModule } from '@angular/material';

@NgModule({
imports: [
CommonModule, Md2Module.forRoot(), MdCardModule.forRoot()
],
declarations: [FaqsComponent],
exports: [FaqsComponent]
})
export class FaqsModule { }

Everything has been installed with npm install md2 --save

Can you create an example with the Angular 2 CLI?

Thanks in advance for your help.

Bug: Datepicker Safari

Safari is not working for time and datetime, only date.

It might be something with the format.
I'll investigate deeply later. But, you can run the demo app and see Nan:

screen shot 2016-10-04 at 1 40 53 pm

md2-accordion-tab is ignoring hidden property

md2-accordion-tab is ignoring the hidden property in the html template and it's being showed anyway.

I expect the md2-accordion-tab to be hidden if the property is set to true, and be showed again if the property is set to false.

Datepicker: set min/max date check current date

It is strange that date not in range can be selected if:

  1. Select a date (ex. 2016-11-15)
  2. Change max input to date before selected (ex. 2016-10-15)
  3. Selected date is out of new range

I think expected behaviour should be moving selected date to closest one in range (ex. 2016-10-15)

AoT compiler failing with [email protected]

AOT compilation failed for my app with the following errors.

dist/tmp/node_modules/md2/autocomplete/autocomplete.ngfactory.ts(235,44): error TS2339: Property '_control' does not exist on type 'Md2Autocomplete'.
dist/tmp/node_modules/md2/autocomplete/autocomplete.ngfactory.ts(235,91): error TS2339: Property '_control' does not exist on type 'Md2Autocomplete'.
dist/tmp/node_modules/md2/autocomplete/autocomplete.ngfactory.ts(253,48): error TS2339: Property '_onBlur' does not exist on type 'Md2Autocomplete'.

I guess the following lines are the rootcause
https://github.com/Promact/md2/blob/master/src/lib/autocomplete/autocomplete.ts#L66
https://github.com/Promact/md2/blob/master/src/lib/autocomplete/autocomplete.ts#L69

md2datepicker not responsive

I tried to use md2datepicker in my application but like other material components md2datepicker is not responsive.
please correct me if i am wrong

Datepicker: unable to clear

Hello! Thanks for the nice component.
But it doesn't have a possibility to clear date.

Steps:

  1. select date
  2. set model to null or undefined

Actual result: view contains old date
Expected result: datepicker should be empty

PS: select and autocomplete work correctly

Thanks

select and datepicker not working in IE11

I am using these two components in my angular 2 app and they seem to work fine in Chrome, FireFox and Safari. However they seem to be broken in IE11. When I click in the component it displays the selectable items but when I click on an item to select it then nothing appears to have been selected. I tried loading your demo site in IE11 and even with that I get the same broken behaviour under IE11.

I am using [email protected] and [email protected]

Update
I have discovered that if I use the keyboard and press enter to select items then that seems to work. So its only mouse selection that seems to have an issue.

Access to Autocomplete Input text

Hello,

is there a way to access the input text value of the auto complete control? If not, this would be very convenient to have.

Cheers
Marco

Upgrade to use new forms api

Components are using old value accessor from common, I think it use the value from the forms api

Old:
import { NG_VALUE_ACCESSOR, ControlValueAccessor } from '@angular/common'

New:
import { NG_VALUE_ACCESSOR, ControlValueAccessor } from '@angular/forms'

Angular rc6 compability

I get following errors when installing md2 with angilar2 rc6:

ERROR in /Users/tb/project/frontend/node_modules/md2/md-dialog/portal/portal.d.ts
(25,16): error TS2314: Generic type 'Type<T>' requires 1 type argument(s).

ERROR in /Users/tb/project/frontend/node_modules/md2/md-dialog/portal/portal.d.ts
(32,28): error TS2314: Generic type 'Type<T>' requires 1 type argument(s).

ERROR in /Users/tb/project/frontend/node_modules/md2/md-dialog/overlay/overlay.d.ts
(1,10): error TS2305: Module '"/Users/tb/project/frontend/node_modules/@angular/core/index"' has no exported member 'ComponentResolver'.

md2DataTable doesn't work

Hello, i love all the extra's this project has to offer and used several plugins in my app. Only the data table doesn't work.

Not close custom dialog When I have click on submit button(Submit form).

I have submit form on submit button click. but I have use custom function like saveArea(areaForm.value,areaForm.valid). and In typescript file in function has if..else condition.if form submitted successfully submit and else doesn't want to close dialog and error message display..

I want to close dialog In IF. so please help. I have through MD2 documents but I cant found that.

I know about some methods of dialog
In .ts file
show(dialog: any) { dialog.show(); }
close(dialog: any) { dialog.close(); }

but it's not working it. I thought some custom methods.

======== HTML code =======

<md2-dialog #newArea title="Create a new area">
   <form [formGroup]="areaForm" novalidate (ngSubmit)="saveArea(areaForm.value,areaForm.valid)">
        <div class="col-md-12">
           <md-input formControlName="name" class="form-control" type="text" placeholder="Enter area name"></md-input>
        </div>
        <div class="clearfix"></div>
        <md2-dialog-footer>
            <button button type="button" (click)="newArea.close()" [ngClass]="'modal-cancel-btn'">Cancel</button>
           <button button [ngClass]="'modal-save-btn'">Create</button>
        </md2-dialog-footer>
    </form>
</md2-dialog>

======= typescript code ========

saveArea(value: any, isFormValid: boolean) {`
    console.log(value);
    this.isFormSubmitted = true;
    this.isFormInvalid = isFormValid;
    if (isFormValid) {
      if (this.selectedArea == null) {
        this.donationAreaManagementService.addArea(value).subscribe(result => {
          this.initialize()
        })
      } else {
        let body = {
          "name": value.name,

        }
        this.donationAreaManagementService.editArea(this.selectedArea.areaId, body).subscribe(result => {
          this.initialize()
        })
      }
    }
  }

dialog png 1366x768

accordion By default Open All accordion if [multiple]="false" also

<md2-accordion [multiple]="false">
<md2-accordion-tab *ngFor="let tab of accordions"
[header]="tab.title"
[active]="tab.active"
[disabled]="tab.disabled">

                <p *ngFor="let t of tab.content" style="margin-top:0px;cursor: pointer;color: red;}">
                    <span (click)="AccordianClick(t)">{{t.name}}</span>
                </p>

let content = [{"id":1,"name":"aaaaa","link":"1111"},
{"id":2,"name":"bbbbb","link":"2222"},
{"id":3,"name":"cccc","link":"3333"}
];

let tt1 = {"title":"first","active":true,"disabled":false,"content":content};
let tt2 = {"title":"second","active":true,"disabled":false,"content":content};

this.accordions.push(tt1);
this.accordions.push(tt2);
this.accordions.push(tt1);

If i will give [multiple]="false" but when page load that time all accordion are open.
And when click once all accordion then work fine.

When page load then default all accordion should be close or might be some configuration based.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.