0.1.4 • Published 1 year ago

@bjorkdev/ngx-autocomplete v0.1.4

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

@bjorkdev/ngx-autocomplete

This package is in pre-release, features are still being added and tested.

Demo

Overview

This library provides a directive that can turn any input field into an autocomplete field.

Pre-release limitations

  • Only supports string arrays as input. Objects will be supported in the future.
  • Styling is limited to light and dark themes.
  • Only returns strings. Key accessor to be added.
  • Placement of the window is not configurable.

Contents

Getting Started

Import NxgAutoCompleteDirective to your component:

@Component({
  selector: 'whatever',
  standalone: true,
  imports: [NxgAutoCompleteDirective]
...

Apply the directive to the input element and provide the data:

const sampleData = ['apple', 'banana', 'cherry', 'date'];
<input [ngxAutoComplete]="sampleData" />

API Reference

Inputs

InputTypeDescriptionDefault
ngxAutoCompletestring[]The data to render.[]
ngxAutoCompleteMaxResultsnumberMax amount of results to display in the window. Default will display everything.0
multiplebooleanConfigures the window to allow multiple selections.false
showWindowOnFocusbooleanSets whether the window should popup on input focus.false
style'light' or 'dark'Sets the color of the window.light
checkboxColorstringThe accent-color of the checkbox if multiple is selected.#a8a8a8
maxHeightstringMax height of the window.400px

Outputs

InputTypeDescription
ngxAutoCompleteItemSelectedEventEmitter<string>Emitted when an item is selected.
ngxAutoCompleteItemRemovedEventEmitter<string>Emitted when an item is unselected.
ngxAutCompleteWindowChangedEventEmitter<NgxAutoCompleteWindowEvent>Emitted when the window is opened or closed.

Navigation

KeyMeaning
arrow up / arrow downNavigate through the options.
enterSelects / adds the current active option from the dropdown.
escapeHides the dropdown.
BackspaceRemoves the last item selected from the input or the last character if partial query.

Full Example

https://github.com/bjork-dev/ngx-autocomplete/blob/master/projects/sample/src/app/app.component.ts

License

This project is licensed under the MIT License.

0.1.4

1 year ago

0.1.3

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago