@lukso/web-components 1.42.0 → 1.43.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/dist/components/index.cjs +3 -3
  2. package/dist/components/index.js +3 -3
  3. package/dist/components/lukso-button/index.cjs +1 -1
  4. package/dist/components/lukso-button/index.js +1 -1
  5. package/dist/components/lukso-card/index.cjs +35 -42
  6. package/dist/components/lukso-card/index.d.ts.map +1 -1
  7. package/dist/components/lukso-card/index.js +35 -42
  8. package/dist/components/lukso-checkbox/index.cjs +1 -1
  9. package/dist/components/lukso-checkbox/index.js +1 -1
  10. package/dist/components/lukso-footer/index.cjs +1 -1
  11. package/dist/components/lukso-footer/index.js +1 -1
  12. package/dist/components/lukso-icon/index.cjs +2 -2
  13. package/dist/components/lukso-icon/index.js +2 -2
  14. package/dist/components/lukso-input/index.cjs +1 -1
  15. package/dist/components/lukso-input/index.js +1 -1
  16. package/dist/components/lukso-modal/index.cjs +1 -1
  17. package/dist/components/lukso-modal/index.js +1 -1
  18. package/dist/components/lukso-navbar/index.cjs +2 -2
  19. package/dist/components/lukso-navbar/index.js +2 -2
  20. package/dist/components/lukso-profile/index.cjs +2 -2
  21. package/dist/components/lukso-profile/index.js +2 -2
  22. package/dist/components/lukso-progress/index.cjs +2 -2
  23. package/dist/components/lukso-progress/index.js +2 -2
  24. package/dist/components/lukso-sanitize/index.cjs +1 -1
  25. package/dist/components/lukso-sanitize/index.js +1 -1
  26. package/dist/components/lukso-search/index.cjs +81 -32
  27. package/dist/components/lukso-search/index.d.ts +17 -12
  28. package/dist/components/lukso-search/index.d.ts.map +1 -1
  29. package/dist/components/lukso-search/index.js +81 -32
  30. package/dist/components/lukso-search/lukso-search.stories.d.ts.map +1 -1
  31. package/dist/components/lukso-share/index.cjs +1 -1
  32. package/dist/components/lukso-share/index.js +1 -1
  33. package/dist/components/lukso-switch/index.cjs +2 -2
  34. package/dist/components/lukso-switch/index.js +2 -2
  35. package/dist/components/lukso-tag/index.cjs +2 -2
  36. package/dist/components/lukso-tag/index.js +2 -2
  37. package/dist/components/lukso-terms/index.cjs +2 -2
  38. package/dist/components/lukso-terms/index.js +2 -2
  39. package/dist/components/lukso-test/index.cjs +2 -2
  40. package/dist/components/lukso-test/index.js +2 -2
  41. package/dist/components/lukso-username/index.cjs +2 -2
  42. package/dist/components/lukso-username/index.js +2 -2
  43. package/dist/components/lukso-wizard/index.cjs +2 -2
  44. package/dist/components/lukso-wizard/index.js +2 -2
  45. package/dist/{directive-helpers-8f79cbe5.js → directive-helpers-422da386.js} +1 -1
  46. package/dist/{directive-helpers-01f1c3b1.cjs → directive-helpers-b2851157.cjs} +1 -1
  47. package/dist/index-5b6b1166.js +59 -0
  48. package/dist/index-7ef6f8a1.cjs +67 -0
  49. package/dist/index.cjs +3 -3
  50. package/dist/index.js +3 -3
  51. package/dist/shared/tailwind-element/index.cjs +1 -1
  52. package/dist/shared/tailwind-element/index.js +1 -1
  53. package/dist/{style-map-5daca6c4.js → style-map-6cdbbb8b.js} +1 -1
  54. package/dist/{style-map-3b9af808.cjs → style-map-c00f9dd9.cjs} +1 -1
  55. package/package.json +1 -1
  56. package/tailwind.config.cjs +1 -0
  57. package/dist/index-930f6cf2.cjs +0 -67
  58. package/dist/index-ed87f41b.js +0 -59
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const shared_tailwindElement_index = require('../../index-930f6cf2.cjs');
5
+ const shared_tailwindElement_index = require('../../index-7ef6f8a1.cjs');
6
6
  const queryAssignedElements = require('../../query-assigned-elements-5200f974.cjs');
7
7
  const state = require('../../state-51b50a6b.cjs');
8
8
  const index = require('../../index-e9668573.cjs');
@@ -10,7 +10,7 @@ require('../lukso-icon/index.cjs');
10
10
  require('../lukso-profile/index.cjs');
11
11
  require('../lukso-username/index.cjs');
12
12
  require('../../directive-8278ab14.cjs');
13
- require('../../style-map-3b9af808.cjs');
13
+ require('../../style-map-c00f9dd9.cjs');
14
14
 
15
15
  const style = ":host {\n\n display: inline-flex\n}\n\n:host([is-full-width]) {\n\n display: flex;\n\n width: 100%\n}";
16
16
 
@@ -30,7 +30,6 @@ exports.LuksoSearch = class LuksoSearch extends shared_tailwindElement_index.Tai
30
30
  super(...arguments);
31
31
  this.value = "";
32
32
  this.name = "";
33
- this.type = "text";
34
33
  this.placeholder = "";
35
34
  this.label = "";
36
35
  this.autocomplete = "off";
@@ -51,6 +50,8 @@ exports.LuksoSearch = class LuksoSearch extends shared_tailwindElement_index.Tai
51
50
  this.hasFocus = false;
52
51
  this.hasHighlight = false;
53
52
  this.isDebouncing = false;
53
+ this.resultsParsed = [];
54
+ this.searchTerm = "";
54
55
  this.defaultInputStyles = `bg-neutral-100 paragraph-inter-14-regular px-4 py-3 pr-10
55
56
  border-solid h-[48px] placeholder:text-neutral-70
56
57
  outline-none transition transition-all duration-150 appearance-none rounded-12`;
@@ -59,7 +60,7 @@ exports.LuksoSearch = class LuksoSearch extends shared_tailwindElement_index.Tai
59
60
  return shared_tailwindElement_index.x`
60
61
  <input
61
62
  name=${this.name}
62
- type=${this.type}
63
+ type="text"
63
64
  .value=${this.value}
64
65
  placeholder=${this.placeholder}
65
66
  ?autofocus=${this.autofocus}
@@ -111,32 +112,61 @@ exports.LuksoSearch = class LuksoSearch extends shared_tailwindElement_index.Tai
111
112
  }
112
113
  resultsTemplate() {
113
114
  const resultTemplates = [];
114
- if (this.results === "" && !this.showNoResults || this.showNoResults && !this.noResultsText) {
115
- return shared_tailwindElement_index.x``;
115
+ this.resultsParsed = JSON.parse(this.results);
116
+ for (const result of Object.entries(this.resultsParsed)) {
117
+ if ("value" in result[1]) {
118
+ resultTemplates.push(this.resultStringTemplate(result[1]));
119
+ } else if ("address" in result[1]) {
120
+ resultTemplates.push(this.resultProfileTemplate(result[1]));
121
+ } else {
122
+ console.error("Unknown result type", result);
123
+ }
116
124
  }
125
+ return shared_tailwindElement_index.x`${this.dropdownWrapperTemplate(resultTemplates)}`;
126
+ }
127
+ noResultsTemplate() {
128
+ return shared_tailwindElement_index.x`${this.dropdownWrapperTemplate(
129
+ shared_tailwindElement_index.x`<div class="paragraph-inter-14-semi-bold text-neutral-20 pl-1">
130
+ ${this.noResultsText}
131
+ </div>`
132
+ )}`;
133
+ }
134
+ loadingTemplate() {
117
135
  if (this.showNoResults) {
118
- resultTemplates.push(this.resultEmptyTemplate());
119
- } else {
120
- const results = JSON.parse(this.results);
121
- for (const result of Object.entries(results)) {
122
- if ("value" in result[1]) {
123
- resultTemplates.push(this.resultStringTemplate(result[1]));
124
- } else if ("address" in result[1]) {
125
- resultTemplates.push(this.resultProfileTemplate(result[1]));
126
- } else {
127
- console.error("Unknown result type", result);
128
- }
129
- }
136
+ return shared_tailwindElement_index.x`${this.dropdownWrapperTemplate(shared_tailwindElement_index.x`
137
+ <div role="status" class="flex flex-col gap-1">
138
+ <div
139
+ class="h-10 bg-neutral-95 w-full rounded-8 animate-pulse animation-delay-none"
140
+ ></div>
141
+ </div>
142
+ `)}`;
143
+ }
144
+ if (this.resultsParsed.length === 0 || this.resultsParsed.length > 5) {
145
+ return shared_tailwindElement_index.x`${this.dropdownWrapperTemplate(shared_tailwindElement_index.x`
146
+ <div role="status" class="flex flex-col gap-1">
147
+ ${[...Array(5)].map(
148
+ () => shared_tailwindElement_index.x`<div
149
+ class="h-10 bg-neutral-95 w-full rounded-8 animate-pulse animation-delay-none"
150
+ ></div>`
151
+ )}
152
+ </div>
153
+ `)}`;
130
154
  }
155
+ return shared_tailwindElement_index.x`${this.dropdownWrapperTemplate(shared_tailwindElement_index.x`
156
+ <div role="status" class="flex flex-col gap-1">
157
+ ${this.resultsParsed.map(
158
+ () => shared_tailwindElement_index.x`<div
159
+ class="h-10 bg-neutral-95 w-full rounded-8 animate-pulse animation-delay-none"
160
+ ></div>`
161
+ )}
162
+ </div>
163
+ `)}`;
164
+ }
165
+ dropdownWrapperTemplate(innerTemplate) {
131
166
  return shared_tailwindElement_index.x`<div
132
167
  class="bg-neutral-100 border border-neutral-90 shadow-1xl rounded-12 p-3 mt-2 z-50 flex absolute w-full flex-col gap-1 overflow-y-auto max-h-64"
133
168
  >
134
- ${resultTemplates}
135
- </div>`;
136
- }
137
- resultEmptyTemplate() {
138
- return shared_tailwindElement_index.x`<div class="paragraph-inter-14-semi-bold text-neutral-20 pl-1">
139
- ${this.noResultsText}
169
+ ${innerTemplate}
140
170
  </div>`;
141
171
  }
142
172
  resultStringTemplate(result) {
@@ -185,11 +215,22 @@ exports.LuksoSearch = class LuksoSearch extends shared_tailwindElement_index.Tai
185
215
  this.hasHighlight = true;
186
216
  }
187
217
  }
188
- handleBlur() {
218
+ handleBlur(event) {
189
219
  this.hasFocus = false;
190
220
  this.hasHighlight = false;
221
+ const target = event.target;
222
+ const blurEvent = new CustomEvent("on-blur", {
223
+ detail: {
224
+ value: target.value,
225
+ event
226
+ },
227
+ bubbles: false,
228
+ composed: true
229
+ });
230
+ this.dispatchEvent(blurEvent);
191
231
  }
192
232
  searchDebounce(searchTerm) {
233
+ this.value = searchTerm;
193
234
  this.debounceTimer = setTimeout(() => {
194
235
  const changeEvent = new CustomEvent("on-search", {
195
236
  detail: {
@@ -228,16 +269,21 @@ exports.LuksoSearch = class LuksoSearch extends shared_tailwindElement_index.Tai
228
269
  <div class="flex relative items-center">
229
270
  ${this.inputTemplate()}
230
271
  <lukso-icon
231
- name="${this.isSearching || this.isDebouncing ? "spinner" : "search"}"
272
+ name="search"
232
273
  class="absolute right-0 mr-3 ${index.customClassMap({
233
274
  ["opacity-60 cursor-not-allowed"]: this.isDisabled,
234
- ["cursor-not-allowed"]: this.isReadonly,
235
- ["animate-spin"]: this.isSearching || this.isDebouncing
275
+ ["cursor-not-allowed"]: this.isReadonly
236
276
  })}"
237
277
  @mouseenter=${this.handleMouseOver}
238
278
  ></lukso-icon>
239
279
  </div>
240
- ${this.results || this.showNoResults && this.hasFocus ? this.resultsTemplate() : shared_tailwindElement_index.A}
280
+ <!-- results dropdown -->
281
+ ${this.results && !(this.isSearching || this.isDebouncing) ? this.resultsTemplate() : shared_tailwindElement_index.A}
282
+ <!-- no results dropdown -->
283
+ ${this.showNoResults && !(this.isSearching || this.isDebouncing) ? this.noResultsTemplate() : shared_tailwindElement_index.A}
284
+ <!-- loading dropdown -->
285
+ ${this.value && (this.isSearching || this.isDebouncing) ? this.loadingTemplate() : shared_tailwindElement_index.A}
286
+ <!-- error -->
241
287
  ${this.error ? this.errorTemplate() : shared_tailwindElement_index.A}
242
288
  </div>
243
289
  `;
@@ -249,9 +295,6 @@ __decorateClass([
249
295
  __decorateClass([
250
296
  queryAssignedElements.e({ type: String })
251
297
  ], exports.LuksoSearch.prototype, "name", 2);
252
- __decorateClass([
253
- queryAssignedElements.e({ type: String })
254
- ], exports.LuksoSearch.prototype, "type", 2);
255
298
  __decorateClass([
256
299
  queryAssignedElements.e({ type: String })
257
300
  ], exports.LuksoSearch.prototype, "placeholder", 2);
@@ -315,6 +358,12 @@ __decorateClass([
315
358
  __decorateClass([
316
359
  state.t()
317
360
  ], exports.LuksoSearch.prototype, "debounceTimer", 2);
361
+ __decorateClass([
362
+ state.t()
363
+ ], exports.LuksoSearch.prototype, "resultsParsed", 2);
364
+ __decorateClass([
365
+ state.t()
366
+ ], exports.LuksoSearch.prototype, "searchTerm", 2);
318
367
  exports.LuksoSearch = __decorateClass([
319
368
  queryAssignedElements.e$1("lukso-search")
320
369
  ], exports.LuksoSearch);
@@ -1,18 +1,19 @@
1
+ import { TemplateResult } from 'lit';
1
2
  import { Address } from '../../shared/types';
2
- export type StringResult = {
3
+ export type SearchStringResult = {
3
4
  id?: string;
4
5
  value: string;
5
6
  };
6
- export type ProfileResult = {
7
+ export type SearchProfileResult = {
7
8
  address: Address;
8
9
  image?: string;
9
10
  name?: string;
10
11
  };
12
+ export type SearchResult = SearchStringResult | SearchProfileResult;
11
13
  declare const LuksoSearch_base: typeof import("lit").LitElement;
12
14
  export declare class LuksoSearch extends LuksoSearch_base {
13
15
  value: string;
14
16
  name: string;
15
- type: string;
16
17
  placeholder: string;
17
18
  label: string;
18
19
  autocomplete: string;
@@ -34,15 +35,19 @@ export declare class LuksoSearch extends LuksoSearch_base {
34
35
  private hasHighlight;
35
36
  private isDebouncing;
36
37
  private debounceTimer;
38
+ private resultsParsed;
39
+ private searchTerm;
37
40
  private defaultInputStyles;
38
- inputTemplate(): import("lit").TemplateResult<1>;
39
- labelTemplate(): import("lit").TemplateResult<1>;
40
- descriptionTemplate(): import("lit").TemplateResult<1>;
41
- errorTemplate(): import("lit").TemplateResult<1>;
42
- resultsTemplate(): import("lit").TemplateResult<1>;
43
- resultEmptyTemplate(): import("lit").TemplateResult<1>;
44
- resultStringTemplate(result: StringResult): import("lit").TemplateResult<1>;
45
- resultProfileTemplate(result: ProfileResult): import("lit").TemplateResult<1>;
41
+ inputTemplate(): TemplateResult<1>;
42
+ labelTemplate(): TemplateResult<1>;
43
+ descriptionTemplate(): TemplateResult<1>;
44
+ errorTemplate(): TemplateResult<1>;
45
+ resultsTemplate(): TemplateResult<1>;
46
+ noResultsTemplate(): TemplateResult<1>;
47
+ loadingTemplate(): TemplateResult<1>;
48
+ dropdownWrapperTemplate(innerTemplate: TemplateResult<1> | TemplateResult<1>[]): TemplateResult<1>;
49
+ resultStringTemplate(result: SearchStringResult): TemplateResult<1>;
50
+ resultProfileTemplate(result: SearchProfileResult): TemplateResult<1>;
46
51
  private handleSelect;
47
52
  private handleFocus;
48
53
  private handleBlur;
@@ -50,7 +55,7 @@ export declare class LuksoSearch extends LuksoSearch_base {
50
55
  private handleSearch;
51
56
  private handleMouseOver;
52
57
  private handleMouseOut;
53
- render(): import("lit").TemplateResult<1>;
58
+ render(): TemplateResult<1>;
54
59
  }
55
60
  declare global {
56
61
  interface HTMLElementTagNameMap {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/lukso-search/index.ts"],"names":[],"mappings":"AAMA,OAAO,yBAA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Y,CAAQ;IAG5B,OAAO,CAAC,aAAa,CAAgB;IAGrC,OAAO,CAAC,aAAa,CAAqB;IAG1C,OAAO,CAAC,UAAU,CAAK;IAEvB,OAAO,CAAC,kBAAkB,CAEuD;IAEjF,aAAa;IAoCb,aAAa;IAUb,mBAAmB;IAQnB,aAAa;IAMb,eAAe;IAmBf,iBAAiB;IAQjB,eAAe;IAuCf,uBAAuB,CACrB,aAAa,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,EAAE;IASxD,oBAAoB,CAAC,MAAM,EAAE,kBAAkB;IAU/C,qBAAqB,CAAC,MAAM,EAAE,mBAAmB;IAsBjD,OAAO,CAAC,YAAY;IAWpB,OAAO,CAAC,WAAW;IAOnB,OAAO,CAAC,UAAU;IAelB,OAAO,CAAC,cAAc;IAgBtB,OAAO,CAAC,YAAY;IAUpB,OAAO,CAAC,eAAe;IAMvB,OAAO,CAAC,cAAc;IAMtB,MAAM;CAiCP;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,cAAc,EAAE,WAAW,CAAA;KAC5B;CACF"}
@@ -1,4 +1,4 @@
1
- import { T as TailwindStyledElement, x, A } from '../../index-ed87f41b.js';
1
+ import { T as TailwindStyledElement, x, A } from '../../index-5b6b1166.js';
2
2
  import { e, a as e$1 } from '../../query-assigned-elements-e36df787.js';
3
3
  import { t } from '../../state-02a92ffa.js';
4
4
  import { c as customClassMap } from '../../index-5e194caf.js';
@@ -6,7 +6,7 @@ import '../lukso-icon/index.js';
6
6
  import '../lukso-profile/index.js';
7
7
  import '../lukso-username/index.js';
8
8
  import '../../directive-2bb7789e.js';
9
- import '../../style-map-5daca6c4.js';
9
+ import '../../style-map-6cdbbb8b.js';
10
10
 
11
11
  const style = ":host {\n\n display: inline-flex\n}\n\n:host([is-full-width]) {\n\n display: flex;\n\n width: 100%\n}";
12
12
 
@@ -26,7 +26,6 @@ let LuksoSearch = class extends TailwindStyledElement(style) {
26
26
  super(...arguments);
27
27
  this.value = "";
28
28
  this.name = "";
29
- this.type = "text";
30
29
  this.placeholder = "";
31
30
  this.label = "";
32
31
  this.autocomplete = "off";
@@ -47,6 +46,8 @@ let LuksoSearch = class extends TailwindStyledElement(style) {
47
46
  this.hasFocus = false;
48
47
  this.hasHighlight = false;
49
48
  this.isDebouncing = false;
49
+ this.resultsParsed = [];
50
+ this.searchTerm = "";
50
51
  this.defaultInputStyles = `bg-neutral-100 paragraph-inter-14-regular px-4 py-3 pr-10
51
52
  border-solid h-[48px] placeholder:text-neutral-70
52
53
  outline-none transition transition-all duration-150 appearance-none rounded-12`;
@@ -55,7 +56,7 @@ let LuksoSearch = class extends TailwindStyledElement(style) {
55
56
  return x`
56
57
  <input
57
58
  name=${this.name}
58
- type=${this.type}
59
+ type="text"
59
60
  .value=${this.value}
60
61
  placeholder=${this.placeholder}
61
62
  ?autofocus=${this.autofocus}
@@ -107,32 +108,61 @@ let LuksoSearch = class extends TailwindStyledElement(style) {
107
108
  }
108
109
  resultsTemplate() {
109
110
  const resultTemplates = [];
110
- if (this.results === "" && !this.showNoResults || this.showNoResults && !this.noResultsText) {
111
- return x``;
111
+ this.resultsParsed = JSON.parse(this.results);
112
+ for (const result of Object.entries(this.resultsParsed)) {
113
+ if ("value" in result[1]) {
114
+ resultTemplates.push(this.resultStringTemplate(result[1]));
115
+ } else if ("address" in result[1]) {
116
+ resultTemplates.push(this.resultProfileTemplate(result[1]));
117
+ } else {
118
+ console.error("Unknown result type", result);
119
+ }
112
120
  }
121
+ return x`${this.dropdownWrapperTemplate(resultTemplates)}`;
122
+ }
123
+ noResultsTemplate() {
124
+ return x`${this.dropdownWrapperTemplate(
125
+ x`<div class="paragraph-inter-14-semi-bold text-neutral-20 pl-1">
126
+ ${this.noResultsText}
127
+ </div>`
128
+ )}`;
129
+ }
130
+ loadingTemplate() {
113
131
  if (this.showNoResults) {
114
- resultTemplates.push(this.resultEmptyTemplate());
115
- } else {
116
- const results = JSON.parse(this.results);
117
- for (const result of Object.entries(results)) {
118
- if ("value" in result[1]) {
119
- resultTemplates.push(this.resultStringTemplate(result[1]));
120
- } else if ("address" in result[1]) {
121
- resultTemplates.push(this.resultProfileTemplate(result[1]));
122
- } else {
123
- console.error("Unknown result type", result);
124
- }
125
- }
132
+ return x`${this.dropdownWrapperTemplate(x`
133
+ <div role="status" class="flex flex-col gap-1">
134
+ <div
135
+ class="h-10 bg-neutral-95 w-full rounded-8 animate-pulse animation-delay-none"
136
+ ></div>
137
+ </div>
138
+ `)}`;
139
+ }
140
+ if (this.resultsParsed.length === 0 || this.resultsParsed.length > 5) {
141
+ return x`${this.dropdownWrapperTemplate(x`
142
+ <div role="status" class="flex flex-col gap-1">
143
+ ${[...Array(5)].map(
144
+ () => x`<div
145
+ class="h-10 bg-neutral-95 w-full rounded-8 animate-pulse animation-delay-none"
146
+ ></div>`
147
+ )}
148
+ </div>
149
+ `)}`;
126
150
  }
151
+ return x`${this.dropdownWrapperTemplate(x`
152
+ <div role="status" class="flex flex-col gap-1">
153
+ ${this.resultsParsed.map(
154
+ () => x`<div
155
+ class="h-10 bg-neutral-95 w-full rounded-8 animate-pulse animation-delay-none"
156
+ ></div>`
157
+ )}
158
+ </div>
159
+ `)}`;
160
+ }
161
+ dropdownWrapperTemplate(innerTemplate) {
127
162
  return x`<div
128
163
  class="bg-neutral-100 border border-neutral-90 shadow-1xl rounded-12 p-3 mt-2 z-50 flex absolute w-full flex-col gap-1 overflow-y-auto max-h-64"
129
164
  >
130
- ${resultTemplates}
131
- </div>`;
132
- }
133
- resultEmptyTemplate() {
134
- return x`<div class="paragraph-inter-14-semi-bold text-neutral-20 pl-1">
135
- ${this.noResultsText}
165
+ ${innerTemplate}
136
166
  </div>`;
137
167
  }
138
168
  resultStringTemplate(result) {
@@ -181,11 +211,22 @@ let LuksoSearch = class extends TailwindStyledElement(style) {
181
211
  this.hasHighlight = true;
182
212
  }
183
213
  }
184
- handleBlur() {
214
+ handleBlur(event) {
185
215
  this.hasFocus = false;
186
216
  this.hasHighlight = false;
217
+ const target = event.target;
218
+ const blurEvent = new CustomEvent("on-blur", {
219
+ detail: {
220
+ value: target.value,
221
+ event
222
+ },
223
+ bubbles: false,
224
+ composed: true
225
+ });
226
+ this.dispatchEvent(blurEvent);
187
227
  }
188
228
  searchDebounce(searchTerm) {
229
+ this.value = searchTerm;
189
230
  this.debounceTimer = setTimeout(() => {
190
231
  const changeEvent = new CustomEvent("on-search", {
191
232
  detail: {
@@ -224,16 +265,21 @@ let LuksoSearch = class extends TailwindStyledElement(style) {
224
265
  <div class="flex relative items-center">
225
266
  ${this.inputTemplate()}
226
267
  <lukso-icon
227
- name="${this.isSearching || this.isDebouncing ? "spinner" : "search"}"
268
+ name="search"
228
269
  class="absolute right-0 mr-3 ${customClassMap({
229
270
  ["opacity-60 cursor-not-allowed"]: this.isDisabled,
230
- ["cursor-not-allowed"]: this.isReadonly,
231
- ["animate-spin"]: this.isSearching || this.isDebouncing
271
+ ["cursor-not-allowed"]: this.isReadonly
232
272
  })}"
233
273
  @mouseenter=${this.handleMouseOver}
234
274
  ></lukso-icon>
235
275
  </div>
236
- ${this.results || this.showNoResults && this.hasFocus ? this.resultsTemplate() : A}
276
+ <!-- results dropdown -->
277
+ ${this.results && !(this.isSearching || this.isDebouncing) ? this.resultsTemplate() : A}
278
+ <!-- no results dropdown -->
279
+ ${this.showNoResults && !(this.isSearching || this.isDebouncing) ? this.noResultsTemplate() : A}
280
+ <!-- loading dropdown -->
281
+ ${this.value && (this.isSearching || this.isDebouncing) ? this.loadingTemplate() : A}
282
+ <!-- error -->
237
283
  ${this.error ? this.errorTemplate() : A}
238
284
  </div>
239
285
  `;
@@ -245,9 +291,6 @@ __decorateClass([
245
291
  __decorateClass([
246
292
  e({ type: String })
247
293
  ], LuksoSearch.prototype, "name", 2);
248
- __decorateClass([
249
- e({ type: String })
250
- ], LuksoSearch.prototype, "type", 2);
251
294
  __decorateClass([
252
295
  e({ type: String })
253
296
  ], LuksoSearch.prototype, "placeholder", 2);
@@ -311,6 +354,12 @@ __decorateClass([
311
354
  __decorateClass([
312
355
  t()
313
356
  ], LuksoSearch.prototype, "debounceTimer", 2);
357
+ __decorateClass([
358
+ t()
359
+ ], LuksoSearch.prototype, "resultsParsed", 2);
360
+ __decorateClass([
361
+ t()
362
+ ], LuksoSearch.prototype, "searchTerm", 2);
314
363
  LuksoSearch = __decorateClass([
315
364
  e$1("lukso-search")
316
365
  ], LuksoSearch);
@@ -1 +1 @@
1
- {"version":3,"file":"lukso-search.stories.d.ts","sourceRoot":"","sources":["../../../../../src/components/lukso-search/lukso-search.stories.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,2BAA2B,CAAA;AAGhD,OAAO,SAAS,CAAA;AAEhB,mHAAmH;AACnH,QAAA,MAAM,IAAI,EAAE,IA6NX,CAAA;AAED,eAAe,IAAI,CAAA;AAyEnB,+CAA+C;AAC/C,eAAO,MAAM,aAAa,KAAoB,CAAA;AAK9C,gDAAgD;AAChD,eAAO,MAAM,aAAa,KAAoB,CAAA;AAqB9C,0FAA0F;AAC1F,eAAO,MAAM,cAAc,KAAoB,CAAA;AAM/C,mJAAmJ;AACnJ,eAAO,MAAM,SAAS,KAAoB,CAAA"}
1
+ {"version":3,"file":"lukso-search.stories.d.ts","sourceRoot":"","sources":["../../../../../src/components/lukso-search/lukso-search.stories.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,2BAA2B,CAAA;AAGhD,OAAO,SAAS,CAAA;AAEhB,mHAAmH;AACnH,QAAA,MAAM,IAAI,EAAE,IAsOX,CAAA;AAED,eAAe,IAAI,CAAA;AA4EnB,+CAA+C;AAC/C,eAAO,MAAM,aAAa,KAAoB,CAAA;AAM9C,gDAAgD;AAChD,eAAO,MAAM,aAAa,KAAoB,CAAA;AAsB9C,0FAA0F;AAC1F,eAAO,MAAM,cAAc,KAAoB,CAAA;AAQ/C,mJAAmJ;AACnJ,eAAO,MAAM,SAAS,KAAoB,CAAA"}
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const shared_tailwindElement_index = require('../../index-930f6cf2.cjs');
5
+ const shared_tailwindElement_index = require('../../index-7ef6f8a1.cjs');
6
6
  const queryAssignedElements = require('../../query-assigned-elements-5200f974.cjs');
7
7
 
8
8
  const style = ":host {\n display: inline-flex\n}";
@@ -1,4 +1,4 @@
1
- import { T as TailwindStyledElement, x } from '../../index-ed87f41b.js';
1
+ import { T as TailwindStyledElement, x } from '../../index-5b6b1166.js';
2
2
  import { e, a as e$1 } from '../../query-assigned-elements-e36df787.js';
3
3
 
4
4
  const style = ":host {\n display: inline-flex\n}";
@@ -2,9 +2,9 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const shared_tailwindElement_index = require('../../index-930f6cf2.cjs');
5
+ const shared_tailwindElement_index = require('../../index-7ef6f8a1.cjs');
6
6
  const queryAssignedElements = require('../../query-assigned-elements-5200f974.cjs');
7
- const styleMap = require('../../style-map-3b9af808.cjs');
7
+ const styleMap = require('../../style-map-c00f9dd9.cjs');
8
8
  const index = require('../../index-e9668573.cjs');
9
9
  require('../../directive-8278ab14.cjs');
10
10
 
@@ -1,6 +1,6 @@
1
- import { a as TailwindElement, x } from '../../index-ed87f41b.js';
1
+ import { a as TailwindElement, x } from '../../index-5b6b1166.js';
2
2
  import { e, a as e$1 } from '../../query-assigned-elements-e36df787.js';
3
- import { o } from '../../style-map-5daca6c4.js';
3
+ import { o } from '../../style-map-6cdbbb8b.js';
4
4
  import { c as customClassMap } from '../../index-5e194caf.js';
5
5
  import '../../directive-2bb7789e.js';
6
6
 
@@ -2,9 +2,9 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const shared_tailwindElement_index = require('../../index-930f6cf2.cjs');
5
+ const shared_tailwindElement_index = require('../../index-7ef6f8a1.cjs');
6
6
  const queryAssignedElements = require('../../query-assigned-elements-5200f974.cjs');
7
- const styleMap = require('../../style-map-3b9af808.cjs');
7
+ const styleMap = require('../../style-map-c00f9dd9.cjs');
8
8
  const index = require('../../index-e9668573.cjs');
9
9
  require('../../directive-8278ab14.cjs');
10
10
 
@@ -1,6 +1,6 @@
1
- import { T as TailwindStyledElement, x } from '../../index-ed87f41b.js';
1
+ import { T as TailwindStyledElement, x } from '../../index-5b6b1166.js';
2
2
  import { e, a as e$1 } from '../../query-assigned-elements-e36df787.js';
3
- import { o } from '../../style-map-5daca6c4.js';
3
+ import { o } from '../../style-map-6cdbbb8b.js';
4
4
  import { c as customClassMap } from '../../index-5e194caf.js';
5
5
  import '../../directive-2bb7789e.js';
6
6
 
@@ -2,14 +2,14 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const shared_tailwindElement_index = require('../../index-930f6cf2.cjs');
5
+ const shared_tailwindElement_index = require('../../index-7ef6f8a1.cjs');
6
6
  const queryAssignedElements = require('../../query-assigned-elements-5200f974.cjs');
7
7
  const state = require('../../state-51b50a6b.cjs');
8
8
  const index = require('../../index-e9668573.cjs');
9
9
  require('../lukso-icon/index.cjs');
10
10
  require('../lukso-sanitize/index.cjs');
11
11
  require('../../directive-8278ab14.cjs');
12
- require('../../style-map-3b9af808.cjs');
12
+ require('../../style-map-c00f9dd9.cjs');
13
13
 
14
14
  const style = ":host {\n display: flex;\n height: 100%\n}";
15
15
 
@@ -1,11 +1,11 @@
1
- import { T as TailwindStyledElement, x } from '../../index-ed87f41b.js';
1
+ import { T as TailwindStyledElement, x } from '../../index-5b6b1166.js';
2
2
  import { e, a as e$1 } from '../../query-assigned-elements-e36df787.js';
3
3
  import { t } from '../../state-02a92ffa.js';
4
4
  import { c as customClassMap } from '../../index-5e194caf.js';
5
5
  import '../lukso-icon/index.js';
6
6
  import '../lukso-sanitize/index.js';
7
7
  import '../../directive-2bb7789e.js';
8
- import '../../style-map-5daca6c4.js';
8
+ import '../../style-map-6cdbbb8b.js';
9
9
 
10
10
  const style = ":host {\n display: flex;\n height: 100%\n}";
11
11
 
@@ -2,10 +2,10 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const shared_tailwindElement_index = require('../../index-930f6cf2.cjs');
5
+ const shared_tailwindElement_index = require('../../index-7ef6f8a1.cjs');
6
6
  const queryAssignedElements = require('../../query-assigned-elements-5200f974.cjs');
7
7
  const directive = require('../../directive-8278ab14.cjs');
8
- const directiveHelpers = require('../../directive-helpers-01f1c3b1.cjs');
8
+ const directiveHelpers = require('../../directive-helpers-b2851157.cjs');
9
9
 
10
10
  /**
11
11
  * @license
@@ -1,7 +1,7 @@
1
- import { c as A$1, b as T, T as TailwindStyledElement, x as x$1 } from '../../index-ed87f41b.js';
1
+ import { c as A$1, b as T, T as TailwindStyledElement, x as x$1 } from '../../index-5b6b1166.js';
2
2
  import { e as e$2, a as e$3 } from '../../query-assigned-elements-e36df787.js';
3
3
  import { i as i$1, t as t$1, e as e$1 } from '../../directive-2bb7789e.js';
4
- import { e } from '../../directive-helpers-8f79cbe5.js';
4
+ import { e } from '../../directive-helpers-422da386.js';
5
5
 
6
6
  /**
7
7
  * @license
@@ -2,9 +2,9 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const shared_tailwindElement_index = require('../../index-930f6cf2.cjs');
5
+ const shared_tailwindElement_index = require('../../index-7ef6f8a1.cjs');
6
6
  const queryAssignedElements = require('../../query-assigned-elements-5200f974.cjs');
7
- const styleMap = require('../../style-map-3b9af808.cjs');
7
+ const styleMap = require('../../style-map-c00f9dd9.cjs');
8
8
  const index = require('../../index-e9668573.cjs');
9
9
  require('../../directive-8278ab14.cjs');
10
10
 
@@ -1,6 +1,6 @@
1
- import { T as TailwindStyledElement, x, c as A } from '../../index-ed87f41b.js';
1
+ import { T as TailwindStyledElement, x, c as A } from '../../index-5b6b1166.js';
2
2
  import { e, a as e$1 } from '../../query-assigned-elements-e36df787.js';
3
- import { o } from '../../style-map-5daca6c4.js';
3
+ import { o } from '../../style-map-6cdbbb8b.js';
4
4
  import { c as customClassMap } from '../../index-5e194caf.js';
5
5
  import '../../directive-2bb7789e.js';
6
6
 
@@ -2,10 +2,10 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const shared_tailwindElement_index = require('../../index-930f6cf2.cjs');
5
+ const shared_tailwindElement_index = require('../../index-7ef6f8a1.cjs');
6
6
  const queryAssignedElements = require('../../query-assigned-elements-5200f974.cjs');
7
7
  const directive = require('../../directive-8278ab14.cjs');
8
- const directiveHelpers = require('../../directive-helpers-01f1c3b1.cjs');
8
+ const directiveHelpers = require('../../directive-helpers-b2851157.cjs');
9
9
  const index = require('../../index-e9668573.cjs');
10
10
 
11
11
  /**
@@ -1,7 +1,7 @@
1
- import { b as T, T as TailwindStyledElement, x } from '../../index-ed87f41b.js';
1
+ import { b as T, T as TailwindStyledElement, x } from '../../index-5b6b1166.js';
2
2
  import { e as e$1, a as e$2 } from '../../query-assigned-elements-e36df787.js';
3
3
  import { e, i, t } from '../../directive-2bb7789e.js';
4
- import { m, f, c as c$1, p, a } from '../../directive-helpers-8f79cbe5.js';
4
+ import { m, f, c as c$1, p, a } from '../../directive-helpers-422da386.js';
5
5
  import { c as customClassMap } from '../../index-5e194caf.js';
6
6
 
7
7
  /**
@@ -1,4 +1,4 @@
1
- import { j } from './index-ed87f41b.js';
1
+ import { j } from './index-5b6b1166.js';
2
2
 
3
3
  /**
4
4
  * @license