Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(chips): chip templates + object list support + async loading support. (closes #252) (closes #359) (closes #601) #626

Merged
merged 34 commits into from
May 30, 2017

Conversation

emoralesb05
Copy link
Contributor

@emoralesb05 emoralesb05 commented May 26, 2017

Description

Addresses:
#359
#601
#252

Part of OnPush epic: #325

What's included?

  • fix(chips): keep focused state as long as you keep clicking inside the chips context.

  • fix(chips): make underline animate the same way as material

  • feat(chips): ability to use object lists and set templates for both autocomplete and chips
    this will be the base to support contact chips.

Usage

<td-chips [items]="objects"
          [(ngModel)]="objectsModel"
          placeholder="Enter autocomplete strings"
          requireMatch>
  <ng-template td-basic-chip let-chip="chip">
    {{chip.city}}, (Pop: {{chip.population}})
  </ng-template>
  <ng-template td-autocomplete-option let-option="option">
    <md-icon>location_city</md-icon> {{option.city}}
  </ng-template>
</td-chips>
  • BREAKING CHANGE feat(chips): abstract the autocomplete filtering and add [debounce] input and (inputChange) output to implement filtering locally or server side.

it makes more sense to have the filtering done outside of chips and we also provide examples on how to achieve it since this way chips are agnostic of local vs server side filtering + string vs object filtering

Usage

<td-chips [items]="filteredStrings"
          [(ngModel)]="stringsModel"
          placeholder="Enter autocomplete strings"
          (inputChange)="filterStrings($event)"
          requireMatch>
</td-chips>
strings: string[] = [
    'stepper',
    'expansion-panel',
    'markdown',
    'highlight',
    'loading',
    'media',
    'chips',
    'http',
    'json-formatter',
    'pipes',
    'need more?',
  ];

  filteredStrings: string[];

  stringsModel: string[] = this.strings.slice(0, 6);

  ngOnInit(): void {
    this.filterStrings('');
  }

  filterStrings(value: string): void {
    this.filteredStrings = this.strings.filter((item: any) => {
      return item.toLowerCase().indexOf(value.toLowerCase()) > -1;
    }).filter((filteredItem: any) => {
      return this.stringsModel ? this.stringsModel.indexOf(filteredItem) < 0 : true;
    });
  }
  • perf(chips): support OnPush change detection
  • docs(chips): update docs with more examples on how to use all this.

Test Steps

General Tests for Every PR

  • ng serve --aot still works.
  • npm run lint passes.
  • npm test passes and code coverage is not lower.
  • npm run build still works.

emoralesb05 and others added 18 commits May 25, 2017 08:25
…utocomplete and chips

this will be the base to support contact chips. First we need to make sure it works fine with objects and strings, and add good a11y around this.
…d add debounce input

it makes more sense to have the filtering done outside of chips and provide examples on how to achieve it since this way chips are agnostic of local vs server side filtering + string vs object filtering
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant