bullet_train-fields 1.2.10 → 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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5f86b53caeffd0b50842d1c0b08c321c0cd6de630c97802efcb391307860f88e
|
4
|
+
data.tar.gz: d3e892eef0c61bf88841ef8c63f9cee097390f40fd3e3efca021718761a1a688
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e5dbc68552e9c12f9597f2b73b885e11bc444ca14da9a5655cc49706d78e24aac6780a2e24716cf16f4c153369fe4b06fdc8db97840cd7d87a766b47a86beb0
|
7
|
+
data.tar.gz: eef23851200aab7b419a9c661f2f2442f0d20dc669d12ec73627ec1eadbaf05c33de1f972d6d3414cc03124600aca96844ee18e3b0cfef110defd403ffc33ab1
|
@@ -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) => {
|
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.
|
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:
|
11
|
+
date: 2023-02-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: standard
|