3.4.7 • Published 2 years ago

autocomplete-entry v3.4.7

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

Autocomplete

This Material autocomplete and dropdown combined allowing you to use ether types. There are many options available as to how to display the dropdown or autocomplete behaviours. Data may be an Observable or not.

Now supports closest match!

Intsallation

npm install autocomplete-entry

Inputs

The following Inputs are available

InputTypeDefautDescription
autocompleteBOOLEANFASLEautocomplete entry with listdropdown selection
dataANY[][]data for the autocomplete list or dropdown list
defaultSTRINGNULLdefault selection
keySTRINGNULLproperty to use for list values (object type array)
returnKeySTRINGNULLproperty to use for return values (object type array)
labelSTRINGNULLLabel for input
placeholderSTRINGNULLLabel for placeholder (autocomplete input)
acceptInputBOOLEANFALSEAllow for custom entry and return value
sortAlphaBOOLEANFALSEsort in alphabetical order
requiredBOOLEANFALSEvalidation required
disabledBOOLEANFASLEdiable control
styleSTRINGNULLstyles to apply to formfield/select
minLenNUMBERNULLsets the min length of field
maxLenNUMBERNULLsets the max length of field
prefixSTRINGNULLsets a prefix string for an input field
appearenceSTRINGNULLinput style

FormControl

For a formControl you will need to provide controls for - country, region, city

formControlName="country"

 countrySelection = this.fb.group({
    country: [null],
  })

Options

<div style="margin: 24px;" [formGroup]="selection">

  <app-autocomplete-selection
    [autocomplete]="false"
    [data]="autocompleteList"
    [default]="'Canada'"
    [key]="'name'"
    [returnKey]="'abbr'"
    [displayInput]="'name'"
    [label]="'Country'"
    [acceptInput]="true"
    [placeholder]="'Canada'"
    [sortAlpha]="true"
    [required]="true"
    [disabled]="false"
    [minLength]="3"
    [maxLength]="10"
    formControlName="country"
  >
  </app-autocomplete-selection>

</div>

Data

Provide the data ether as an Observable or Static data as an array of objects

autocompleteList = [
  { name: 'United States', id: 1, abbr: 'US'},
  { name: 'Italy', id: 1, abbr: 'IT'},
  { name: 'Canada', id: 1, abbr: 'CA'},
]

Or you can provide an array of strings

autocompleteList = ['United States', 'Italy', 'Canada']

Sample Implementation

selection: formGroup

constructor(
  private fb: FormBuilder
  ) {}

ngOnInit() {

  selection = this.fb.group({
    country: [null]
  })

  this.selection.patchValue({ country: 'Canada'})
  this.selection.valueChanges.subscribe(data => console.log(data))

  }
3.4.7

2 years ago

3.4.6

2 years ago

3.4.3

2 years ago

3.3.3

2 years ago

3.3.2

2 years ago

3.3.1

2 years ago

3.3.0

2 years ago

3.2.9

2 years ago

3.2.8

2 years ago

3.2.6

2 years ago

3.2.5

2 years ago

3.2.4

2 years ago

3.2.3

2 years ago

3.2.2

2 years ago

3.2.1

2 years ago

3.1.3

2 years ago

3.1.2

2 years ago

3.1.1

2 years ago

3.1.0

2 years ago

3.0.8

2 years ago

3.0.7

2 years ago

3.0.6

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

0.0.1

2 years ago