bullet_train-fields 1.2.9 → 1.2.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f8de5c52084981df640d57028b48fc0c3fd49297659f35f0ca648d2aa044cfbc
4
- data.tar.gz: 6add341ece96a606d1b0cd50a3da5a44105ac424ff3e1ce76200b41fb1dd0f8a
3
+ metadata.gz: 5f86b53caeffd0b50842d1c0b08c321c0cd6de630c97802efcb391307860f88e
4
+ data.tar.gz: d3e892eef0c61bf88841ef8c63f9cee097390f40fd3e3efca021718761a1a688
5
5
  SHA512:
6
- metadata.gz: e0aa3bf87ee7b47eee7d13ecf46956cb86da6db22e613603a00fa69bce5317f359854952e2ddcff443e4cf394ccd5bdcc30a58c21184db9ddb099a451b2a8d86
7
- data.tar.gz: e2274e7467624e4727126512eaf3d54493068280ac1613097426ae1349cf8a57e862bdf95d495df669835b9263edc183d669806c54ea88d578c30d685b5b2a8a
6
+ metadata.gz: 5e5dbc68552e9c12f9597f2b73b885e11bc444ca14da9a5655cc49706d78e24aac6780a2e24716cf16f4c153369fe4b06fdc8db97840cd7d87a766b47a86beb0
7
+ data.tar.gz: eef23851200aab7b419a9c661f2f2442f0d20dc669d12ec73627ec1eadbaf05c33de1f972d6d3414cc03124600aca96844ee18e3b0cfef110defd403ffc33ab1
@@ -1,6 +1,6 @@
1
1
  module FieldsHelper
2
2
  def current_fields_form
3
- @_fields_helper_forms ? @_fields_helper_forms.last : nil
3
+ @_fields_helper_forms&.last
4
4
  end
5
5
 
6
6
  def with_field_settings(options)
@@ -2,6 +2,9 @@ import { Controller } from "@hotwired/stimulus"
2
2
  require("select2/dist/css/select2.min.css");
3
3
  import select2 from "select2";
4
4
 
5
+ const select2SelectedPreviewSelector = ".select2-selection--single"
6
+ const select2SearchInputFieldSelector = ".select2-search__field"
7
+
5
8
  export default class extends Controller {
6
9
  static targets = [ "select" ]
7
10
  static values = {
@@ -86,6 +89,32 @@ export default class extends Controller {
86
89
  // revert to original markup, remove any event listeners
87
90
  $(this.pluginMainEl).select2('destroy');
88
91
  }
92
+
93
+ open() {
94
+ $(this.pluginMainEl).select2('open')
95
+ }
96
+
97
+ focusOnTextField(event) {
98
+ this.element.querySelector(select2SearchInputFieldSelector)?.focus()
99
+ }
100
+
101
+ injectKeystrokeIntoTextField(event) {
102
+ if (!event?.srcElement.matches(select2SelectedPreviewSelector)) { return }
103
+
104
+ if (["Shift", "Alt", "Control", "Meta", "Tab", "Backspace", "Escape"].includes(event.key)) { return }
105
+
106
+ this.open()
107
+
108
+ const searchInputField = this.element.querySelector(select2SearchInputFieldSelector)
109
+
110
+ if (!searchInputField) { return }
111
+
112
+ if (event.type !== "keydown") {
113
+ // since keydown precedes keyup, and since keyup is what sends the key to an input field, this next line isn't necessary if keydown is the event captured. We'll just focus on the input field, and the keyup will caught by the input field naturally.
114
+ searchInputField.value = searchInputField.value + event.key
115
+ }
116
+ searchInputField.focus()
117
+ }
89
118
 
90
119
  initReissuePluginEventsAsNativeEvents() {
91
120
  this.constructor.jQueryEventsToReissue.forEach((eventName) => {
@@ -1,5 +1,5 @@
1
1
  module BulletTrain
2
2
  module Fields
3
- VERSION = "1.2.9"
3
+ VERSION = "1.2.11"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bullet_train-fields
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.9
4
+ version: 1.2.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Culver
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-12-28 00:00:00.000000000 Z
11
+ date: 2023-02-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: standard
@@ -143,7 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
143
143
  - !ruby/object:Gem::Version
144
144
  version: '0'
145
145
  requirements: []
146
- rubygems_version: 3.3.7
146
+ rubygems_version: 3.4.1
147
147
  signing_key:
148
148
  specification_version: 4
149
149
  summary: Bullet Train Fields