From 0bd51c5ecd071feb7df4c4462496ef13b289b893 Mon Sep 17 00:00:00 2001 From: Steve Date: Sat, 9 Mar 2024 12:24:32 +0100 Subject: [PATCH] chore: 1st refactoring and options management --- README.md | 24 ++- src/index.html | 183 ++++------------- src/js/vanilla/kompleter.js | 380 +++++++++++++----------------------- src/sass/_mixins.scss | 16 ++ src/sass/_variables.scss | 2 +- src/sass/kompleter.scss | 136 ++++++++----- 6 files changed, 304 insertions(+), 437 deletions(-) diff --git a/README.md b/README.md index e4a4dfa..842c180 100644 --- a/README.md +++ b/README.md @@ -70,4 +70,26 @@ Following options are available: * **beforeFocus**: function(e, element), function, callback fired before focus on result item * **afterFocus**: function(e, element), callback fired after focus on result item * **beforeComplete**: function(e, dataset, element), callback fired before insertion of result -* **afterComplete**: function(e, dataset, element), callback fired after insertion of result \ No newline at end of file +* **afterComplete**: function(e, dataset, element), callback fired after insertion of result + +### Analyze and refactoring to Vanilla version + +Two ways of usage: static, dynamic local, dynamic api + +#### Static + +Consumer give the full dataset when kompltr is initialized + +-> No lazy loading +-> async onKeyup callback optional +-> Cache available +-> Filtering is made at kompletr side + +#### Dynamic + +Consumer give nothing when kompltr is initialized + +-> Lazy loading +-> async onKeyup callback required +-> Cache available +-> Filtering is made at client side diff --git a/src/index.html b/src/index.html index 2ae1fa4..bae6eab 100644 --- a/src/index.html +++ b/src/index.html @@ -48,10 +48,7 @@

Kømpletr

class="input--search" autocomplete="off" placeholder="Enter a city name ..." - value="" - data-url="files/kompleter.json" - data-filter-on="Name" - data-fields="Name,CountryCode,Population" /> + value="" />