playbook_ui 14.8.0.pre.alpha.revert3916revert3893PBNTR667railstypeaheadformintegration4565 → 14.8.0.pre.alpha.revert3916revert3893PBNTR667railstypeaheadformintegration4567
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/pb_kits/playbook/pb_typeahead/index.ts +8 -271
- data/lib/playbook/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ab3091b250c9adb5894b9b3e5a3c7abc8d8bffbe5c150aec1c8e604276aada12
|
4
|
+
data.tar.gz: 9c91c2f685a8ceb56496ec4d8e433a887e6656af1bd90b09dff999a2cc22dc85
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 14654ce385ecebb0507c9b12e46ea562d135c6a9775d39e16bb7bc3aa4c81367ee54931f88219aae03513e3e79f14df0c3ba100f5576aac744625afa710f6475
|
7
|
+
data.tar.gz: cef726720b79b6a97302ee8d8dbe8332d0dc176c2242bcb37258a094fb5e65465f2d9019f29a98d38e348d22b70ed859c2243f8c64d80820b567a8c178a6e7a1
|
@@ -4,12 +4,12 @@ import { debounce } from 'lodash'
|
|
4
4
|
export default class PbTypeahead extends PbEnhancedElement {
|
5
5
|
_searchInput: HTMLInputElement
|
6
6
|
_resultsElement: HTMLElement
|
7
|
-
_debouncedSearch: () => void
|
7
|
+
_debouncedSearch: () => void
|
8
8
|
_resultsLoadingIndicator: HTMLElement
|
9
9
|
_resultOptionTemplate: HTMLElement
|
10
10
|
_resultsOptionCache: Map<string, Array<DocumentFragment>>
|
11
11
|
_searchContext: string
|
12
|
-
_validSelection: boolean
|
12
|
+
_validSelection: boolean
|
13
13
|
|
14
14
|
static get selector() {
|
15
15
|
return '[data-pb-typeahead-kit]'
|
@@ -20,7 +20,6 @@ export default class PbTypeahead extends PbEnhancedElement {
|
|
20
20
|
this.searchInput.addEventListener('focus', () => this.debouncedSearch())
|
21
21
|
this.searchInput.addEventListener('input', () => this.debouncedSearch())
|
22
22
|
this.resultsElement.addEventListener('click', (event: MouseEvent) => this.optionSelected(event))
|
23
|
-
// this.element.closest('form')?.addEventListener('submit', (event) => this.handleFormSubmission(event)) // changed - new
|
24
23
|
}
|
25
24
|
|
26
25
|
handleKeydown(event: KeyboardEvent) {
|
@@ -88,8 +87,8 @@ export default class PbTypeahead extends PbEnhancedElement {
|
|
88
87
|
const resultOption = (event.target as Element).closest('[data-result-option-item]')
|
89
88
|
if (!resultOption) return
|
90
89
|
|
91
|
-
this._validSelection = true
|
92
|
-
this.removeValidationError()
|
90
|
+
this._validSelection = true
|
91
|
+
this.removeValidationError()
|
93
92
|
|
94
93
|
this.resultsCacheClear()
|
95
94
|
this.searchInputClear()
|
@@ -97,7 +96,7 @@ export default class PbTypeahead extends PbEnhancedElement {
|
|
97
96
|
|
98
97
|
this.element.dispatchEvent(new CustomEvent('pb-typeahead-kit-result-option-selected', { bubbles: true, detail: { selected: resultOption, typeahead: this } }))
|
99
98
|
}
|
100
|
-
|
99
|
+
|
101
100
|
removeValidationError() {
|
102
101
|
const inputWrapper = this.searchInput.closest('.text_input_wrapper')
|
103
102
|
if (inputWrapper) {
|
@@ -108,7 +107,7 @@ export default class PbTypeahead extends PbEnhancedElement {
|
|
108
107
|
this.searchInput.classList.remove('error')
|
109
108
|
}
|
110
109
|
}
|
111
|
-
|
110
|
+
|
112
111
|
showValidationError() {
|
113
112
|
const inputWrapper = this.searchInput.closest('.text_input_wrapper')
|
114
113
|
if (inputWrapper) {
|
@@ -119,13 +118,6 @@ export default class PbTypeahead extends PbEnhancedElement {
|
|
119
118
|
this.searchInput.classList.add('error')
|
120
119
|
}
|
121
120
|
}
|
122
|
-
// changed - new
|
123
|
-
// handleFormSubmission(event: Event) {
|
124
|
-
// if (!this._validSelection) {
|
125
|
-
// this.showValidationError()
|
126
|
-
// event.preventDefault()
|
127
|
-
// }
|
128
|
-
// }
|
129
121
|
|
130
122
|
clearResults() {
|
131
123
|
this.resultsElement.innerHTML = ''
|
@@ -235,263 +227,8 @@ export default class PbTypeahead extends PbEnhancedElement {
|
|
235
227
|
}
|
236
228
|
|
237
229
|
toggleResultsLoadingIndicator(visible: boolean) {
|
238
|
-
let visibilityProperty = '0'
|
230
|
+
let visibilityProperty = '0'
|
239
231
|
if (visible) visibilityProperty = '1'
|
240
232
|
this.resultsLoadingIndicator.style.opacity = visibilityProperty
|
241
233
|
}
|
242
|
-
}
|
243
|
-
|
244
|
-
// import PbEnhancedElement from '../pb_enhanced_element';
|
245
|
-
// import { debounce } from 'lodash';
|
246
|
-
|
247
|
-
// export default class PbTypeahead extends PbEnhancedElement {
|
248
|
-
// _searchInput: HTMLInputElement;
|
249
|
-
// _resultsElement: HTMLElement;
|
250
|
-
// _debouncedSearch: () => void;
|
251
|
-
// _resultsLoadingIndicator: HTMLElement;
|
252
|
-
// _resultOptionTemplate: HTMLElement;
|
253
|
-
// _resultsOptionCache: Map<string, Array<DocumentFragment>>;
|
254
|
-
// _searchContext: string;
|
255
|
-
// _validSelection: boolean;
|
256
|
-
|
257
|
-
// static get selector() {
|
258
|
-
// return '[data-pb-typeahead-kit]';
|
259
|
-
// }
|
260
|
-
|
261
|
-
// connect() {
|
262
|
-
// this.element.addEventListener('keydown', (event: KeyboardEvent) => this.handleKeydown(event));
|
263
|
-
// this.searchInput.addEventListener('focus', () => this.debouncedSearch());
|
264
|
-
// this.searchInput.addEventListener('input', () => this.debouncedSearch());
|
265
|
-
// this.resultsElement.addEventListener('click', (event: MouseEvent) => this.optionSelected(event));
|
266
|
-
// // this.attachFormSubmissionHandler();
|
267
|
-
// }
|
268
|
-
|
269
|
-
// // attachFormSubmissionHandler() {
|
270
|
-
// // const formElement = this.element.closest('form');
|
271
|
-
// // if (formElement) {
|
272
|
-
// // formElement.addEventListener('submit', (event: Event) => {
|
273
|
-
// // if (!this._validSelection) {
|
274
|
-
// // this.showValidationError();
|
275
|
-
// // event.preventDefault();
|
276
|
-
// // }
|
277
|
-
// // });
|
278
|
-
// // }
|
279
|
-
// // }
|
280
|
-
|
281
|
-
// handleKeydown(event: KeyboardEvent) {
|
282
|
-
// if (event.key === 'ArrowUp') {
|
283
|
-
// event.preventDefault();
|
284
|
-
// this.focusPreviousOption();
|
285
|
-
// } else if (event.key === 'ArrowDown') {
|
286
|
-
// event.preventDefault();
|
287
|
-
// this.focusNextOption();
|
288
|
-
// }
|
289
|
-
// }
|
290
|
-
|
291
|
-
// search() {
|
292
|
-
// if (this.searchTerm.length < parseInt(this.searchTermMinimumLength)) {
|
293
|
-
// return this.clearResults();
|
294
|
-
// }
|
295
|
-
|
296
|
-
// this.toggleResultsLoadingIndicator(true);
|
297
|
-
// this.showResults();
|
298
|
-
|
299
|
-
// const searchTerm = this.searchTerm;
|
300
|
-
// const searchContext = this.searchContext;
|
301
|
-
// const search = {
|
302
|
-
// searchingFor: searchTerm,
|
303
|
-
// searchingContext: searchContext,
|
304
|
-
// setResults: (results: Array<DocumentFragment>) => {
|
305
|
-
// this.resultsCacheUpdate(searchTerm, searchContext, results);
|
306
|
-
// },
|
307
|
-
// };
|
308
|
-
// this.element.dispatchEvent(new CustomEvent('pb-typeahead-kit-search', { bubbles: true, detail: search }));
|
309
|
-
// }
|
310
|
-
|
311
|
-
// resultsCacheUpdate(searchTerm: string, searchContext: string, results: Array<DocumentFragment>) {
|
312
|
-
// const searchTermAndContext = this.cacheKeyFor(searchTerm, searchContext);
|
313
|
-
// if (this.resultsOptionCache.has(searchTermAndContext)) {
|
314
|
-
// this.resultsOptionCache.delete(searchTermAndContext);
|
315
|
-
// }
|
316
|
-
// if (this.resultsOptionCache.size > 32) {
|
317
|
-
// this.resultsOptionCache.delete(this.resultsOptionCache.keys().next().value);
|
318
|
-
// }
|
319
|
-
|
320
|
-
// this.resultsOptionCache.set(searchTermAndContext, results);
|
321
|
-
// this.showResults();
|
322
|
-
// }
|
323
|
-
|
324
|
-
// resultsCacheClear() {
|
325
|
-
// this.resultsOptionCache.clear();
|
326
|
-
// }
|
327
|
-
|
328
|
-
// get debouncedSearch() {
|
329
|
-
// return this._debouncedSearch = (
|
330
|
-
// this._debouncedSearch ||
|
331
|
-
// debounce(this.search, parseInt(this.searchDebounceTimeout)).bind(this)
|
332
|
-
// );
|
333
|
-
// }
|
334
|
-
|
335
|
-
// showResults() {
|
336
|
-
// if (!this.resultsOptionCache.has(this.searchTermAndContext)) return;
|
337
|
-
|
338
|
-
// this.toggleResultsLoadingIndicator(false);
|
339
|
-
// this.clearResults();
|
340
|
-
// for (const result of this.resultsOptionCache.get(this.searchTermAndContext)) {
|
341
|
-
// this.resultsElement.appendChild(this.newResultOption(result.cloneNode(true)));
|
342
|
-
// }
|
343
|
-
// for (const result of this.resultsElement.querySelectorAll('[data-result-option-item]')) {
|
344
|
-
// result.addEventListener('mousedown', (event: MouseEvent) => this.optionSelected(event));
|
345
|
-
// }
|
346
|
-
// }
|
347
|
-
|
348
|
-
// optionSelected(event: MouseEvent) {
|
349
|
-
// const resultOption = (event.target as Element).closest('[data-result-option-item]');
|
350
|
-
// if (!resultOption) return;
|
351
|
-
|
352
|
-
// this._validSelection = true;
|
353
|
-
// this.removeValidationError();
|
354
|
-
|
355
|
-
// this.resultsCacheClear();
|
356
|
-
// this.searchInputClear();
|
357
|
-
// this.clearResults();
|
358
|
-
|
359
|
-
// this.element.dispatchEvent(new CustomEvent('pb-typeahead-kit-result-option-selected', {
|
360
|
-
// bubbles: true,
|
361
|
-
// detail: { selected: resultOption, typeahead: this },
|
362
|
-
// }));
|
363
|
-
// }
|
364
|
-
|
365
|
-
// removeValidationError() {
|
366
|
-
// const inputWrapper = this.searchInput.closest('.text_input_wrapper');
|
367
|
-
// if (inputWrapper) {
|
368
|
-
// const errorMessage = inputWrapper.querySelector('.pb_body_kit_negative') as HTMLElement;
|
369
|
-
// if (errorMessage) {
|
370
|
-
// errorMessage.style.display = 'none';
|
371
|
-
// }
|
372
|
-
// this.searchInput.classList.remove('error');
|
373
|
-
// }
|
374
|
-
// }
|
375
|
-
|
376
|
-
// showValidationError() {
|
377
|
-
// const inputWrapper = this.searchInput.closest('.text_input_wrapper');
|
378
|
-
// if (inputWrapper) {
|
379
|
-
// const errorMessage = inputWrapper.querySelector('.pb_body_kit_negative') as HTMLElement;
|
380
|
-
// if (errorMessage) {
|
381
|
-
// errorMessage.style.display = 'block';
|
382
|
-
// }
|
383
|
-
// this.searchInput.classList.add('error');
|
384
|
-
// }
|
385
|
-
// }
|
386
|
-
|
387
|
-
// clearResults() {
|
388
|
-
// this.resultsElement.innerHTML = '';
|
389
|
-
// }
|
390
|
-
|
391
|
-
// newResultOption(content: DocumentFragment) {
|
392
|
-
// const resultOption = (this.resultOptionTemplate as HTMLTemplateElement).content.cloneNode(true) as Element;
|
393
|
-
// resultOption.querySelector('slot[name="content"]').replaceWith(content);
|
394
|
-
// return resultOption;
|
395
|
-
// }
|
396
|
-
|
397
|
-
// focusPreviousOption() {
|
398
|
-
// const currentIndex = this.resultOptionItems.indexOf(this.currentSelectedResultOptionItem);
|
399
|
-
// const previousIndex = currentIndex - 1;
|
400
|
-
// const previousOptionItem = (
|
401
|
-
// this.resultOptionItems[previousIndex] ||
|
402
|
-
// this.resultOptionItems[this.resultOptionItems.length - 1]
|
403
|
-
// );
|
404
|
-
// (previousOptionItem as HTMLElement).focus();
|
405
|
-
// }
|
406
|
-
|
407
|
-
// focusNextOption() {
|
408
|
-
// const currentIndex = this.resultOptionItems.indexOf(this.currentSelectedResultOptionItem);
|
409
|
-
// const nextIndex = currentIndex + 1;
|
410
|
-
// const nextOptionItem = (
|
411
|
-
// this.resultOptionItems[nextIndex] ||
|
412
|
-
// this.resultOptionItems[0]
|
413
|
-
// );
|
414
|
-
// (nextOptionItem as HTMLElement).focus();
|
415
|
-
// }
|
416
|
-
|
417
|
-
// get resultOptionItems() {
|
418
|
-
// return Array.from(this.resultsElement.querySelectorAll('[data-result-option-item]'));
|
419
|
-
// }
|
420
|
-
|
421
|
-
// get currentSelectedResultOptionItem() {
|
422
|
-
// return document.activeElement.closest('[data-result-option-item]');
|
423
|
-
// }
|
424
|
-
|
425
|
-
// get searchInput() {
|
426
|
-
// return this._searchInput = (this._searchInput || this.element.querySelector('input[type="search"]'));
|
427
|
-
// }
|
428
|
-
|
429
|
-
// get searchTerm() {
|
430
|
-
// return this.searchInput.value;
|
431
|
-
// }
|
432
|
-
|
433
|
-
// get searchContext() {
|
434
|
-
// if (this._searchContext) return this._searchContext;
|
435
|
-
|
436
|
-
// const selector = (this.element as HTMLElement).dataset.searchContextValueSelector;
|
437
|
-
// if (selector) return ((
|
438
|
-
// this.element.parentNode.querySelector(selector) ||
|
439
|
-
// this.element.closest(selector)
|
440
|
-
// ) as HTMLInputElement).value;
|
441
|
-
|
442
|
-
// return null;
|
443
|
-
// }
|
444
|
-
|
445
|
-
// set searchContext(value) {
|
446
|
-
// this._searchContext = value;
|
447
|
-
// }
|
448
|
-
|
449
|
-
// get searchTermAndContext() {
|
450
|
-
// return this.cacheKeyFor(this.searchTerm, this.searchContext);
|
451
|
-
// }
|
452
|
-
|
453
|
-
// cacheKeyFor(searchTerm: string, searchContext: string) {
|
454
|
-
// return [searchTerm, JSON.stringify(searchContext)].join();
|
455
|
-
// }
|
456
|
-
|
457
|
-
// searchInputClear() {
|
458
|
-
// this.searchInput.value = '';
|
459
|
-
// }
|
460
|
-
|
461
|
-
// get searchTermMinimumLength() {
|
462
|
-
// return (this.element as HTMLElement).dataset.pbTypeaheadKitSearchTermMinimumLength;
|
463
|
-
// }
|
464
|
-
|
465
|
-
// get searchDebounceTimeout() {
|
466
|
-
// return (this.element as HTMLElement).dataset.pbTypeaheadKitSearchDebounceTimeout;
|
467
|
-
// }
|
468
|
-
|
469
|
-
// get resultsElement() {
|
470
|
-
// return this._resultsElement = (this._resultsElement || this.element.querySelector('[data-pb-typeahead-kit-results]'));
|
471
|
-
// }
|
472
|
-
|
473
|
-
// get resultOptionTemplate() {
|
474
|
-
// return this._resultOptionTemplate = (
|
475
|
-
// this._resultOptionTemplate ||
|
476
|
-
// this.element.querySelector('template[data-pb-typeahead-kit-result-option]')
|
477
|
-
// );
|
478
|
-
// }
|
479
|
-
|
480
|
-
// get resultsOptionCache() {
|
481
|
-
// return this._resultsOptionCache = (
|
482
|
-
// this._resultsOptionCache ||
|
483
|
-
// new Map
|
484
|
-
// );
|
485
|
-
// }
|
486
|
-
|
487
|
-
// get resultsLoadingIndicator() {
|
488
|
-
// return this._resultsLoadingIndicator = (
|
489
|
-
// this._resultsLoadingIndicator ||
|
490
|
-
// this.element.querySelector('[data-pb-typeahead-kit-loading-indicator]')
|
491
|
-
// );
|
492
|
-
// }
|
493
|
-
|
494
|
-
// toggleResultsLoadingIndicator(visible: boolean) {
|
495
|
-
// this.resultsLoadingIndicator.style.opacity = visible ? '1' : '0';
|
496
|
-
// }
|
497
|
-
// }
|
234
|
+
}
|
data/lib/playbook/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: playbook_ui
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 14.8.0.pre.alpha.
|
4
|
+
version: 14.8.0.pre.alpha.revert3916revert3893PBNTR667railstypeaheadformintegration4567
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Power UX
|