playbook_ui 14.15.0.pre.rc.2 → 14.15.0.pre.rc.4

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 (45) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_overlay/_overlay.scss +13 -0
  3. data/app/pb_kits/playbook/pb_overlay/_overlay.tsx +7 -1
  4. data/app/pb_kits/playbook/pb_overlay/docs/_overlay_hide_scroll_bar.html.erb +11 -0
  5. data/app/pb_kits/playbook/pb_overlay/docs/_overlay_hide_scroll_bar.jsx +37 -0
  6. data/app/pb_kits/playbook/pb_overlay/docs/_overlay_hide_scroll_bar_rails.md +1 -0
  7. data/app/pb_kits/playbook/pb_overlay/docs/_overlay_hide_scroll_bar_react.md +1 -0
  8. data/app/pb_kits/playbook/pb_overlay/docs/_overlay_vertical_dynamic_multi_directional.html.erb +11 -0
  9. data/app/pb_kits/playbook/pb_overlay/docs/_overlay_vertical_dynamic_multi_directional.md +1 -0
  10. data/app/pb_kits/playbook/pb_overlay/docs/example.yml +3 -0
  11. data/app/pb_kits/playbook/pb_overlay/docs/index.js +1 -0
  12. data/app/pb_kits/playbook/pb_overlay/index.js +61 -0
  13. data/app/pb_kits/playbook/pb_overlay/overlay.html.erb +5 -3
  14. data/app/pb_kits/playbook/pb_overlay/overlay.rb +16 -1
  15. data/app/pb_kits/playbook/pb_overlay/overlay.test.jsx +12 -0
  16. data/app/pb_kits/playbook/pb_title/_title.scss +0 -35
  17. data/app/pb_kits/playbook/pb_title/_title.tsx +1 -10
  18. data/app/pb_kits/playbook/pb_title/docs/_title_default.html.erb +2 -1
  19. data/app/pb_kits/playbook/pb_title/docs/_title_default.jsx +1 -1
  20. data/app/pb_kits/playbook/pb_title/docs/example.yml +0 -2
  21. data/app/pb_kits/playbook/pb_title/docs/index.js +0 -1
  22. data/app/pb_kits/playbook/pb_title/title.rb +1 -10
  23. data/app/pb_kits/playbook/pb_typeahead/_typeahead.tsx +34 -1
  24. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_dynamic_options.html.erb +45 -0
  25. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_dynamic_options.md +5 -0
  26. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_dynamic_options_pure_rails.html.erb +33 -0
  27. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_dynamic_options_pure_rails.md +3 -0
  28. data/app/pb_kits/playbook/pb_typeahead/docs/example.yml +2 -0
  29. data/app/pb_kits/playbook/pb_typeahead/index.ts +61 -8
  30. data/app/pb_kits/playbook/pb_typeahead/typeahead.rb +13 -1
  31. data/dist/chunks/{_typeahead-_d2af7Id.js → _typeahead-NXKDTf__.js} +3 -3
  32. data/dist/chunks/{_weekday_stacked-BZe1DgW-.js → _weekday_stacked-DtCYkCXM.js} +2 -2
  33. data/dist/chunks/{lib-Fr78pbpF.js → lib-Dmay5Z6U.js} +1 -1
  34. data/dist/chunks/{pb_form_validation-CN51bfsD.js → pb_form_validation-DdP7BnVX.js} +1 -1
  35. data/dist/chunks/vendor.js +1 -1
  36. data/dist/menu.yml +2 -2
  37. data/dist/playbook-doc.js +1 -1
  38. data/dist/playbook-rails-react-bindings.js +1 -1
  39. data/dist/playbook-rails.js +1 -1
  40. data/dist/playbook.css +1 -1
  41. data/lib/playbook/version.rb +1 -1
  42. metadata +17 -9
  43. data/app/pb_kits/playbook/pb_title/docs/_title_display_size.html.erb +0 -7
  44. data/app/pb_kits/playbook/pb_title/docs/_title_display_size.jsx +0 -54
  45. data/app/pb_kits/playbook/pb_title/docs/_title_display_size.md +0 -1
@@ -20,6 +20,34 @@ 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
+
24
+ if (this.clearOnContextChange && this.searchContextElement) {
25
+ this.searchContextElement.addEventListener('change', () => {
26
+ this.searchInputClear()
27
+ this.resultsCacheClear()
28
+ this.clearResults()
29
+ })
30
+ }
31
+ }
32
+
33
+ get optionsByContext() {
34
+ return (this.element as HTMLElement).dataset.pbTypeaheadKitOptionsByContext
35
+ ? JSON.parse((this.element as HTMLElement).dataset.pbTypeaheadKitOptionsByContext)
36
+ : null
37
+ }
38
+
39
+ get searchContextElement() {
40
+ const selector = (this.element as HTMLElement).dataset.pbTypeaheadKitSearchContextSelector
41
+ if (!selector) return null
42
+
43
+ const found = this.element.parentNode?.querySelector(`#${selector}`)
44
+ || this.element.closest(selector)
45
+
46
+ return found || null
47
+ }
48
+
49
+ get clearOnContextChange() {
50
+ return (this.element as HTMLElement).dataset.pbTypeaheadKitClearOnContextChange === 'true'
23
51
  }
24
52
 
25
53
  handleKeydown(event: KeyboardEvent) {
@@ -40,14 +68,32 @@ export default class PbTypeahead extends PbEnhancedElement {
40
68
 
41
69
  const searchTerm = this.searchTerm
42
70
  const searchContext = this.searchContext
43
- const search = {
44
- searchingFor: searchTerm,
45
- searchingContext: searchContext,
46
- setResults: (results: Array<DocumentFragment>) => {
47
- this.resultsCacheUpdate(searchTerm, searchContext, results)
48
- },
71
+
72
+ if (this.optionsByContext && Object.keys(this.optionsByContext).length > 0) {
73
+ const contextArray = this.optionsByContext[searchContext] || []
74
+
75
+ const filteredResults = contextArray.filter((obj: { label: string, value: string }) => {
76
+ return obj.label
77
+ && obj.label.toLowerCase().includes(searchTerm.toLowerCase())
78
+ })
79
+
80
+ const optionFragments = filteredResults.map((obj: { label: string, value: string }) => {
81
+ const singleOption = document.createDocumentFragment()
82
+ singleOption.appendChild(document.createTextNode(obj.label))
83
+ return singleOption
84
+ })
85
+
86
+ this.resultsCacheUpdate(searchTerm, searchContext, optionFragments)
87
+ } else {
88
+ const search = {
89
+ searchingFor: searchTerm,
90
+ searchingContext: searchContext,
91
+ setResults: (results: Array<DocumentFragment>) => {
92
+ this.resultsCacheUpdate(searchTerm, searchContext, results)
93
+ },
94
+ }
95
+ this.element.dispatchEvent(new CustomEvent('pb-typeahead-kit-search', { bubbles: true, detail: search }))
49
96
  }
50
- this.element.dispatchEvent(new CustomEvent('pb-typeahead-kit-search', { bubbles: true, detail: search }))
51
97
  }
52
98
 
53
99
  resultsCacheUpdate(searchTerm: string, searchContext: string, results: Array<DocumentFragment>) {
@@ -87,11 +133,15 @@ export default class PbTypeahead extends PbEnhancedElement {
87
133
  const resultOption = (event.target as Element).closest('[data-result-option-item]')
88
134
  if (!resultOption) return
89
135
 
136
+ const selectedText = resultOption.textContent.trim()
137
+
90
138
  this._validSelection = true
91
139
  this.removeValidationError()
92
140
 
141
+ if (this.searchContextElement) this.searchInput.value = selectedText
142
+
93
143
  this.resultsCacheClear()
94
- this.searchInputClear()
144
+ if (!this.searchContextElement) this.searchInputClear()
95
145
  this.clearResults()
96
146
 
97
147
  this.element.dispatchEvent(new CustomEvent('pb-typeahead-kit-result-option-selected', { bubbles: true, detail: { selected: resultOption, typeahead: this } }))
@@ -173,6 +223,9 @@ export default class PbTypeahead extends PbEnhancedElement {
173
223
  this.element.parentNode.querySelector(selector) ||
174
224
  this.element.closest(selector)
175
225
  ) as HTMLInputElement).value
226
+ else if (this.searchContextElement) {
227
+ return (this.searchContextElement as HTMLInputElement).value
228
+ }
176
229
 
177
230
  return null
178
231
  }
@@ -44,6 +44,12 @@ module Playbook
44
44
  default: false
45
45
  prop :validation, type: Playbook::Props::HashProp,
46
46
  default: {}
47
+ prop :clear_on_context_change, type: Playbook::Props::Boolean,
48
+ default: true
49
+ prop :options_by_context, type: Playbook::Props::HashProp,
50
+ default: {}
51
+ prop :search_context_selector, type: Playbook::Props::String,
52
+ default: nil
47
53
 
48
54
  def classname
49
55
  default_margin_bottom = margin_bottom.present? ? "" : " mb_sm"
@@ -58,7 +64,10 @@ module Playbook
58
64
  Hash(values[:data]).merge(
59
65
  pb_typeahead_kit: true,
60
66
  pb_typeahead_kit_search_term_minimum_length: search_term_minimum_length,
61
- pb_typeahead_kit_search_debounce_timeout: search_debounce_timeout
67
+ pb_typeahead_kit_search_debounce_timeout: search_debounce_timeout,
68
+ pb_typeahead_kit_clear_on_context_change: clear_on_context_change,
69
+ pb_typeahead_kit_search_context_selector: search_context_selector,
70
+ pb_typeahead_kit_options_by_context: options_by_context.to_json
62
71
  )
63
72
  end
64
73
 
@@ -85,6 +94,9 @@ module Playbook
85
94
  placeholder: placeholder,
86
95
  plusIcon: plus_icon,
87
96
  truncate: truncate,
97
+ searchContextSelector: search_context_selector,
98
+ optionsByContext: options_by_context,
99
+ clearOnContextChange: clear_on_context_change,
88
100
  }
89
101
 
90
102
  base_options[:getOptionLabel] = get_option_label if get_option_label.present?