ui_bibz 4.0.0.beta3 → 4.0.0.beta4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +110 -79
- data/app/assets/config/ui_bibz.js +2 -0
- data/app/assets/javascripts/controllers/combobox_controller.js +37 -0
- data/app/assets/stylesheets/sass/_forms.sass +1 -0
- data/app/assets/stylesheets/sass/forms/_combobox.sass +32 -0
- data/config/importmap.rb +2 -0
- data/config/initializers/assets.rb +1 -1
- data/lib/ui_bibz/helpers/ui/core/forms_helper.rb +8 -0
- data/lib/ui_bibz/infos.rb +1 -1
- data/lib/ui_bibz/inputs/ui_bibz_inputs/ui_combobox_field_input.rb +15 -0
- data/lib/ui_bibz/ui/core/forms/texts/combobox_field.rb +96 -0
- data/lib/ui_bibz.rb +1 -0
- data/test/ui/core/forms/texts/combobox_field_test.rb +19 -0
- data/vendor/assets/javascripts/debounce.js +51 -0
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 700d531ae188bd2c4a87404667a960cdeb73ecdb278a60e66ed216822f899bdc
|
4
|
+
data.tar.gz: 6612425d1076b9aed91259c733d5560c7a8d80d6a5d155281441874d52e1bed0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 97cc99d6e3d772d40c6be7091e6c5a2a68e9de849952b2b016f57b42eb3801df26247103c29ddd22f5ad75b59344bf067dd328b2ec6f0de30b607bd67ef41f5b
|
7
|
+
data.tar.gz: 0e3e98b1d96c9eb7ab56eec9d1f128c261b99f3787244e6deeda56d50620956b145abc2f39f916263c38587e7547db6ea9a77ece08b9aa06695d36a56ea12399
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
ui_bibz (4.0.0.
|
4
|
+
ui_bibz (4.0.0.beta4)
|
5
5
|
bootstrap (~> 5.3.0)
|
6
6
|
rails (>= 7.0.6)
|
7
7
|
will-paginate-i18n
|
@@ -11,76 +11,85 @@ PATH
|
|
11
11
|
GEM
|
12
12
|
remote: https://rubygems.org/
|
13
13
|
specs:
|
14
|
-
actioncable (7.
|
15
|
-
actionpack (= 7.
|
16
|
-
activesupport (= 7.
|
14
|
+
actioncable (7.1.1)
|
15
|
+
actionpack (= 7.1.1)
|
16
|
+
activesupport (= 7.1.1)
|
17
17
|
nio4r (~> 2.0)
|
18
18
|
websocket-driver (>= 0.6.1)
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
19
|
+
zeitwerk (~> 2.6)
|
20
|
+
actionmailbox (7.1.1)
|
21
|
+
actionpack (= 7.1.1)
|
22
|
+
activejob (= 7.1.1)
|
23
|
+
activerecord (= 7.1.1)
|
24
|
+
activestorage (= 7.1.1)
|
25
|
+
activesupport (= 7.1.1)
|
25
26
|
mail (>= 2.7.1)
|
26
27
|
net-imap
|
27
28
|
net-pop
|
28
29
|
net-smtp
|
29
|
-
actionmailer (7.
|
30
|
-
actionpack (= 7.
|
31
|
-
actionview (= 7.
|
32
|
-
activejob (= 7.
|
33
|
-
activesupport (= 7.
|
30
|
+
actionmailer (7.1.1)
|
31
|
+
actionpack (= 7.1.1)
|
32
|
+
actionview (= 7.1.1)
|
33
|
+
activejob (= 7.1.1)
|
34
|
+
activesupport (= 7.1.1)
|
34
35
|
mail (~> 2.5, >= 2.5.4)
|
35
36
|
net-imap
|
36
37
|
net-pop
|
37
38
|
net-smtp
|
38
|
-
rails-dom-testing (~> 2.
|
39
|
-
actionpack (7.
|
40
|
-
actionview (= 7.
|
41
|
-
activesupport (= 7.
|
42
|
-
|
39
|
+
rails-dom-testing (~> 2.2)
|
40
|
+
actionpack (7.1.1)
|
41
|
+
actionview (= 7.1.1)
|
42
|
+
activesupport (= 7.1.1)
|
43
|
+
nokogiri (>= 1.8.5)
|
44
|
+
rack (>= 2.2.4)
|
45
|
+
rack-session (>= 1.0.1)
|
43
46
|
rack-test (>= 0.6.3)
|
44
|
-
rails-dom-testing (~> 2.
|
45
|
-
rails-html-sanitizer (~> 1.
|
46
|
-
actiontext (7.
|
47
|
-
actionpack (= 7.
|
48
|
-
activerecord (= 7.
|
49
|
-
activestorage (= 7.
|
50
|
-
activesupport (= 7.
|
47
|
+
rails-dom-testing (~> 2.2)
|
48
|
+
rails-html-sanitizer (~> 1.6)
|
49
|
+
actiontext (7.1.1)
|
50
|
+
actionpack (= 7.1.1)
|
51
|
+
activerecord (= 7.1.1)
|
52
|
+
activestorage (= 7.1.1)
|
53
|
+
activesupport (= 7.1.1)
|
51
54
|
globalid (>= 0.6.0)
|
52
55
|
nokogiri (>= 1.8.5)
|
53
|
-
actionview (7.
|
54
|
-
activesupport (= 7.
|
56
|
+
actionview (7.1.1)
|
57
|
+
activesupport (= 7.1.1)
|
55
58
|
builder (~> 3.1)
|
56
|
-
erubi (~> 1.
|
57
|
-
rails-dom-testing (~> 2.
|
58
|
-
rails-html-sanitizer (~> 1.
|
59
|
-
activejob (7.
|
60
|
-
activesupport (= 7.
|
59
|
+
erubi (~> 1.11)
|
60
|
+
rails-dom-testing (~> 2.2)
|
61
|
+
rails-html-sanitizer (~> 1.6)
|
62
|
+
activejob (7.1.1)
|
63
|
+
activesupport (= 7.1.1)
|
61
64
|
globalid (>= 0.3.6)
|
62
|
-
activemodel (7.
|
63
|
-
activesupport (= 7.
|
64
|
-
activerecord (7.
|
65
|
-
activemodel (= 7.
|
66
|
-
activesupport (= 7.
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
65
|
+
activemodel (7.1.1)
|
66
|
+
activesupport (= 7.1.1)
|
67
|
+
activerecord (7.1.1)
|
68
|
+
activemodel (= 7.1.1)
|
69
|
+
activesupport (= 7.1.1)
|
70
|
+
timeout (>= 0.4.0)
|
71
|
+
activestorage (7.1.1)
|
72
|
+
actionpack (= 7.1.1)
|
73
|
+
activejob (= 7.1.1)
|
74
|
+
activerecord (= 7.1.1)
|
75
|
+
activesupport (= 7.1.1)
|
72
76
|
marcel (~> 1.0)
|
73
|
-
|
74
|
-
|
77
|
+
activesupport (7.1.1)
|
78
|
+
base64
|
79
|
+
bigdecimal
|
75
80
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
81
|
+
connection_pool (>= 2.2.5)
|
82
|
+
drb
|
76
83
|
i18n (>= 1.6, < 2)
|
77
84
|
minitest (>= 5.1)
|
85
|
+
mutex_m
|
78
86
|
tzinfo (~> 2.0)
|
79
87
|
ast (2.4.2)
|
80
88
|
autoprefixer-rails (10.4.15.0)
|
81
89
|
execjs (~> 2)
|
82
90
|
awesome_print (1.9.2)
|
83
91
|
base64 (0.1.1)
|
92
|
+
bigdecimal (3.1.4)
|
84
93
|
bootstrap (5.3.1)
|
85
94
|
autoprefixer-rails (>= 9.1.0)
|
86
95
|
popper_js (>= 2.11.8, < 3)
|
@@ -89,9 +98,12 @@ GEM
|
|
89
98
|
byebug (11.1.3)
|
90
99
|
childprocess (4.1.0)
|
91
100
|
concurrent-ruby (1.2.2)
|
101
|
+
connection_pool (2.4.1)
|
92
102
|
crass (1.0.6)
|
93
103
|
date (3.3.3)
|
94
104
|
docile (1.4.0)
|
105
|
+
drb (2.1.1)
|
106
|
+
ruby2_keywords
|
95
107
|
erubi (1.12.0)
|
96
108
|
execjs (2.9.1)
|
97
109
|
factory_bot (4.11.1)
|
@@ -99,10 +111,10 @@ GEM
|
|
99
111
|
factory_bot_rails (4.11.1)
|
100
112
|
factory_bot (~> 4.11.1)
|
101
113
|
railties (>= 3.0.0)
|
102
|
-
ffi (1.16.
|
114
|
+
ffi (1.16.3)
|
103
115
|
globalid (1.2.1)
|
104
116
|
activesupport (>= 6.1)
|
105
|
-
haml (6.2.
|
117
|
+
haml (6.2.3)
|
106
118
|
temple (>= 0.8.2)
|
107
119
|
thor
|
108
120
|
tilt
|
@@ -117,9 +129,13 @@ GEM
|
|
117
129
|
actionpack (>= 6.0.0)
|
118
130
|
railties (>= 6.0.0)
|
119
131
|
iniparse (1.5.0)
|
132
|
+
io-console (0.6.0)
|
133
|
+
irb (1.8.3)
|
134
|
+
rdoc
|
135
|
+
reline (>= 0.3.8)
|
120
136
|
json (2.6.3)
|
121
137
|
language_server-protocol (3.17.0.3)
|
122
|
-
loofah (2.21.
|
138
|
+
loofah (2.21.4)
|
123
139
|
crass (~> 1.0.2)
|
124
140
|
nokogiri (>= 1.12.0)
|
125
141
|
mail (2.8.1)
|
@@ -128,10 +144,10 @@ GEM
|
|
128
144
|
net-pop
|
129
145
|
net-smtp
|
130
146
|
marcel (1.0.2)
|
131
|
-
method_source (1.0.0)
|
132
147
|
mini_mime (1.1.5)
|
133
148
|
minitest (5.20.0)
|
134
|
-
|
149
|
+
mutex_m (0.1.2)
|
150
|
+
net-imap (0.4.1)
|
135
151
|
date
|
136
152
|
net-protocol
|
137
153
|
net-pop (0.1.2)
|
@@ -150,30 +166,37 @@ GEM
|
|
150
166
|
iniparse (~> 1.4)
|
151
167
|
rexml (~> 3.2)
|
152
168
|
parallel (1.23.0)
|
153
|
-
parser (3.2.2.
|
169
|
+
parser (3.2.2.4)
|
154
170
|
ast (~> 2.4.1)
|
155
171
|
racc
|
156
172
|
popper_js (2.11.8)
|
173
|
+
psych (5.1.1.1)
|
174
|
+
stringio
|
157
175
|
puma (6.4.0)
|
158
176
|
nio4r (~> 2.0)
|
159
177
|
racc (1.7.1)
|
160
|
-
rack (
|
178
|
+
rack (3.0.8)
|
179
|
+
rack-session (2.0.0)
|
180
|
+
rack (>= 3.0.0)
|
161
181
|
rack-test (2.1.0)
|
162
182
|
rack (>= 1.3)
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
183
|
+
rackup (2.1.0)
|
184
|
+
rack (>= 3)
|
185
|
+
webrick (~> 1.8)
|
186
|
+
rails (7.1.1)
|
187
|
+
actioncable (= 7.1.1)
|
188
|
+
actionmailbox (= 7.1.1)
|
189
|
+
actionmailer (= 7.1.1)
|
190
|
+
actionpack (= 7.1.1)
|
191
|
+
actiontext (= 7.1.1)
|
192
|
+
actionview (= 7.1.1)
|
193
|
+
activejob (= 7.1.1)
|
194
|
+
activemodel (= 7.1.1)
|
195
|
+
activerecord (= 7.1.1)
|
196
|
+
activestorage (= 7.1.1)
|
197
|
+
activesupport (= 7.1.1)
|
175
198
|
bundler (>= 1.15.0)
|
176
|
-
railties (= 7.
|
199
|
+
railties (= 7.1.1)
|
177
200
|
rails-dom-testing (2.2.0)
|
178
201
|
activesupport (>= 5.0.0)
|
179
202
|
minitest
|
@@ -181,23 +204,28 @@ GEM
|
|
181
204
|
rails-html-sanitizer (1.6.0)
|
182
205
|
loofah (~> 2.21)
|
183
206
|
nokogiri (~> 1.14)
|
184
|
-
railties (7.
|
185
|
-
actionpack (= 7.
|
186
|
-
activesupport (= 7.
|
187
|
-
|
207
|
+
railties (7.1.1)
|
208
|
+
actionpack (= 7.1.1)
|
209
|
+
activesupport (= 7.1.1)
|
210
|
+
irb
|
211
|
+
rackup (>= 1.0.0)
|
188
212
|
rake (>= 12.2)
|
189
|
-
thor (~> 1.0)
|
190
|
-
zeitwerk (~> 2.
|
213
|
+
thor (~> 1.0, >= 1.2.2)
|
214
|
+
zeitwerk (~> 2.6)
|
191
215
|
rainbow (3.1.1)
|
192
216
|
rake (13.0.6)
|
193
|
-
|
217
|
+
rdoc (6.5.0)
|
218
|
+
psych (>= 4.0.0)
|
219
|
+
regexp_parser (2.8.2)
|
220
|
+
reline (0.3.9)
|
221
|
+
io-console (~> 0.5)
|
194
222
|
rexml (3.2.6)
|
195
|
-
rubocop (1.
|
223
|
+
rubocop (1.57.1)
|
196
224
|
base64 (~> 0.1.1)
|
197
225
|
json (~> 2.3)
|
198
226
|
language_server-protocol (>= 3.17.0)
|
199
227
|
parallel (~> 1.10)
|
200
|
-
parser (>= 3.2.2.
|
228
|
+
parser (>= 3.2.2.4)
|
201
229
|
rainbow (>= 2.2.2, < 4.0)
|
202
230
|
regexp_parser (>= 1.8, < 3.0)
|
203
231
|
rexml (>= 3.2.5, < 4.0)
|
@@ -216,6 +244,7 @@ GEM
|
|
216
244
|
rack (>= 1.1)
|
217
245
|
rubocop (>= 1.33.0, < 2.0)
|
218
246
|
ruby-progressbar (1.13.0)
|
247
|
+
ruby2_keywords (0.0.5)
|
219
248
|
sassc (2.4.0)
|
220
249
|
ffi (~> 1.9)
|
221
250
|
sassc-rails (2.1.2)
|
@@ -224,7 +253,7 @@ GEM
|
|
224
253
|
sprockets (> 3.0)
|
225
254
|
sprockets-rails
|
226
255
|
tilt
|
227
|
-
simple_form (5.
|
256
|
+
simple_form (5.3.0)
|
228
257
|
actionpack (>= 5.2)
|
229
258
|
activemodel (>= 5.2)
|
230
259
|
simplecov (0.22.0)
|
@@ -240,15 +269,17 @@ GEM
|
|
240
269
|
actionpack (>= 5.2)
|
241
270
|
activesupport (>= 5.2)
|
242
271
|
sprockets (>= 3.0.0)
|
243
|
-
sqlite3 (1.6.
|
244
|
-
sqlite3 (1.6.
|
245
|
-
|
272
|
+
sqlite3 (1.6.7-x86_64-darwin)
|
273
|
+
sqlite3 (1.6.7-x86_64-linux)
|
274
|
+
stringio (3.0.8)
|
275
|
+
temple (0.10.3)
|
246
276
|
thor (1.2.2)
|
247
277
|
tilt (2.3.0)
|
248
278
|
timeout (0.4.0)
|
249
279
|
tzinfo (2.0.6)
|
250
280
|
concurrent-ruby (~> 1.0)
|
251
281
|
unicode-display_width (2.5.0)
|
282
|
+
webrick (1.8.1)
|
252
283
|
websocket-driver (0.7.6)
|
253
284
|
websocket-extensions (>= 0.1.0)
|
254
285
|
websocket-extensions (0.1.5)
|
@@ -0,0 +1,37 @@
|
|
1
|
+
import { Controller } from "@hotwired/stimulus"
|
2
|
+
import debounce from "debounce"
|
3
|
+
|
4
|
+
export default class ComboboxController extends Controller {
|
5
|
+
static values = { url: String, debounce: Number };
|
6
|
+
|
7
|
+
connect(){
|
8
|
+
this.searchValue = this.searchValue.bind(this);
|
9
|
+
this.debounceValue = this.element.getAttribute("data-combobox-debounce-value")
|
10
|
+
this.debouncedSearchValue = debounce(this.searchValue, this.debounceValue)
|
11
|
+
}
|
12
|
+
|
13
|
+
search(e) {
|
14
|
+
if (this.debounceValue && Number(this.debounceValue) > 0){
|
15
|
+
this.debouncedSearchValue(e);
|
16
|
+
}else {
|
17
|
+
this.searchValue(e);
|
18
|
+
}
|
19
|
+
}
|
20
|
+
|
21
|
+
insertValue(e){
|
22
|
+
this.element.querySelector('input').value = e.target.innerText
|
23
|
+
this.element.querySelector("turbo-frame").innerHTML = ''
|
24
|
+
}
|
25
|
+
|
26
|
+
searchValue(){
|
27
|
+
let input = this.element.querySelector('input')
|
28
|
+
let query = input.value
|
29
|
+
if (query.length < 2) {
|
30
|
+
return
|
31
|
+
}
|
32
|
+
|
33
|
+
const url = this.element.getAttribute("data-combobox-url-value") + '?query=' + query;
|
34
|
+
|
35
|
+
input.nextSibling.querySelector("turbo-frame").src = url;
|
36
|
+
}
|
37
|
+
}
|
@@ -0,0 +1,32 @@
|
|
1
|
+
.combobox
|
2
|
+
width: 100%
|
3
|
+
position: relative
|
4
|
+
|
5
|
+
.combobox-list
|
6
|
+
position: absolute
|
7
|
+
z-index: 99
|
8
|
+
top: 100%
|
9
|
+
left: 0
|
10
|
+
right: 0
|
11
|
+
|
12
|
+
.combobox .turbo-frame-error
|
13
|
+
position: absolute
|
14
|
+
z-index: 99
|
15
|
+
top: 100%
|
16
|
+
left: 0
|
17
|
+
right: 0
|
18
|
+
padding: 10px
|
19
|
+
cursor: pointer
|
20
|
+
background-color: #fff
|
21
|
+
border-bottom: 1px solid #d4d4d4
|
22
|
+
border-left: 1px solid #d4d4d4
|
23
|
+
border-right: 1px solid #d4d4d4
|
24
|
+
|
25
|
+
.input-group > .combobox:not(:first-child):not(.dropdown-menu):not(.valid-tooltip):not(.valid-feedback):not(.invalid-tooltip):not(.invalid-feedback)
|
26
|
+
input
|
27
|
+
border-top-left-radius: 0
|
28
|
+
border-bottom-left-radius: 0
|
29
|
+
|
30
|
+
.input-group:not(.has-validation) > .combobox:not(:last-child):not(.dropdown-toggle):not(.dropdown-menu):not(.form-floating)
|
31
|
+
input
|
32
|
+
border-radius: 0px
|
data/config/importmap.rb
CHANGED
@@ -17,3 +17,5 @@ pin 'tables', to: 'tables.js', preload: true
|
|
17
17
|
pin 'formula', to: 'forms/formula.js', preload: true
|
18
18
|
pin 'input-connected', to: 'forms/input-connected.js', preload: true
|
19
19
|
pin 'jquery.multi-select-extend', to: 'forms/jquery.multi-select-extend.js', preload: true
|
20
|
+
pin 'debounce', to: 'debounce.js', preload: true
|
21
|
+
pin 'controllers/combobox_controller', to: 'controllers/combobox_controller.js', preload: true
|
@@ -2,4 +2,4 @@
|
|
2
2
|
|
3
3
|
Rails.application.config.assets.precompile += %w[bootstrap.min.js popper.js
|
4
4
|
jquery-3.7.0.min.js bootstrap-multiselect.min.js jquery.multi-select.min.js
|
5
|
-
forms.js interfaces.js tables.js forms/formula.js forms/input-connected.js forms/jquery.multi-select-extend.js"]
|
5
|
+
forms.js interfaces.js tables.js forms/formula.js forms/input-connected.js forms/jquery.multi-select-extend.js controllers/combobox_controller.js debounce.js"]
|
@@ -208,4 +208,12 @@ module UiBibz::Helpers::Ui::Core::FormsHelper
|
|
208
208
|
def ui_file_field(name, options = nil, html_options = nil, &)
|
209
209
|
UiBibz::Ui::Core::Forms::Files::FileField.new(name, options, html_options, &).render
|
210
210
|
end
|
211
|
+
|
212
|
+
# Combobox Field Component
|
213
|
+
#
|
214
|
+
# +options+ (Hash)
|
215
|
+
# +html_options+ (Hash)
|
216
|
+
def ui_combobox_field(content = nil, options = nil, html_options = nil, &)
|
217
|
+
UiBibz::Ui::Core::Forms::Texts::ComboboxField.new(content, options, html_options, &).render
|
218
|
+
end
|
211
219
|
end
|
data/lib/ui_bibz/infos.rb
CHANGED
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module UiBibzInputs
|
4
|
+
class UiComboboxFieldInput < CollectionInput
|
5
|
+
include UiBibz::Ui::Core::Forms::Texts
|
6
|
+
|
7
|
+
def input(_wrapper_options)
|
8
|
+
UiBibz::Ui::Core::Forms::Texts::ComboboxField.new(input_attribute_name, new_options, input_html_options).render
|
9
|
+
end
|
10
|
+
|
11
|
+
def new_options
|
12
|
+
super.merge({ value: @builder.object.send(attribute_name) })
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,96 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'ui_bibz/ui/extensions/core/forms/surround_extension'
|
4
|
+
module UiBibz::Ui::Core::Forms::Texts
|
5
|
+
# Create a ComboboxField
|
6
|
+
#
|
7
|
+
# This element is an extend of UiBibz::Ui::Core::Component.
|
8
|
+
#
|
9
|
+
# ==== Attributes
|
10
|
+
#
|
11
|
+
# * +content+ - Content of element
|
12
|
+
# * +options+ - Options of element
|
13
|
+
# * +html_options+ - Html Options of element
|
14
|
+
#
|
15
|
+
# ==== Options
|
16
|
+
#
|
17
|
+
# You can add HTML attributes using the +html_options+.
|
18
|
+
# You can pass arguments in options attribute:
|
19
|
+
# * +url+ - String [required]
|
20
|
+
# * +append+ - String, Html
|
21
|
+
# * +prepend+ - String, Html
|
22
|
+
#
|
23
|
+
# ==== Signatures
|
24
|
+
#
|
25
|
+
# UiBibz::Ui::Core::Forms::Texts::ComboboxField.new(content, options = {}, html_options = {}).render
|
26
|
+
#
|
27
|
+
# UiBibz::Ui::Core::Forms::Texts::ComboboxField.new(options = {}, html_options = {}) do
|
28
|
+
# content
|
29
|
+
# end.render
|
30
|
+
#
|
31
|
+
# ==== Examples
|
32
|
+
#
|
33
|
+
# UiBibz::Ui::Core::Forms::Texts::ComboboxField.new('company', { debounce: 200, url: 'http://exemple.com/list' }, { class: 'test' })
|
34
|
+
#
|
35
|
+
# UiBibz::Ui::Core::Forms::Texts::ComboboxField.new(url: 'http://exemple.com/list') do
|
36
|
+
# #content
|
37
|
+
# end
|
38
|
+
#
|
39
|
+
# ==== Helper
|
40
|
+
#
|
41
|
+
# combobox_field(options = {}, html_options = {}) do
|
42
|
+
# # content
|
43
|
+
# end
|
44
|
+
#
|
45
|
+
class ComboboxField < UiBibz::Ui::Core::Forms::Texts::TextField
|
46
|
+
# See UiBibz::Ui::Core::Component.initialize
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def text_field_input_tag
|
51
|
+
content_tag :div, data: data_controller_attributes, class: 'combobox' do
|
52
|
+
text_field_tag(content, options[:value] || html_options[:value], html_options) + combobox_list_render
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def combobox_list_render
|
57
|
+
content_tag :div, class: 'combobox-list' do
|
58
|
+
content_tag 'turbo-frame', '', id: combobox_list_name, src: ''
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def component_html_options
|
63
|
+
{ autocomplete: false, disabled: options[:state] }
|
64
|
+
end
|
65
|
+
|
66
|
+
def component_html_classes
|
67
|
+
super << 'combobox-field'
|
68
|
+
end
|
69
|
+
|
70
|
+
def combobox_list_name
|
71
|
+
@combobox_list_name ||= "#{html_options[:id] || content.to_s.parameterize.underscore}-combobox-list"
|
72
|
+
end
|
73
|
+
|
74
|
+
def component_html_data
|
75
|
+
@data_html_options_builder.add('action', value: data_actions)
|
76
|
+
end
|
77
|
+
|
78
|
+
def data_controller_attributes
|
79
|
+
{
|
80
|
+
controller: data_controllers,
|
81
|
+
'combobox-url-value': options[:url],
|
82
|
+
'combobox-debounce-value': options[:debounce]
|
83
|
+
}
|
84
|
+
end
|
85
|
+
|
86
|
+
def data_actions
|
87
|
+
actions = [options[:action], html_options.dig(:data, :action)].compact
|
88
|
+
actions.blank? ? 'keyup->combobox#search' : actions.join(' ')
|
89
|
+
end
|
90
|
+
|
91
|
+
def data_controllers
|
92
|
+
controllers = [options.delete(:controller), html_options.try(:[], :data).try(:delete, :controller), @data_html_options_builder.html_options.try(:[], :data).try(:delete, :controller)].compact
|
93
|
+
controllers.blank? ? 'combobox' : controllers.join(' ')
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
data/lib/ui_bibz.rb
CHANGED
@@ -169,6 +169,7 @@ module UiBibz
|
|
169
169
|
|
170
170
|
module Texts
|
171
171
|
autoload :AutoCompleteField, 'ui_bibz/ui/core/forms/texts/auto_complete_field'
|
172
|
+
autoload :ComboboxField, 'ui_bibz/ui/core/forms/texts/combobox_field'
|
172
173
|
autoload :TextField, 'ui_bibz/ui/core/forms/texts/text_field'
|
173
174
|
end
|
174
175
|
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'test_helper'
|
4
|
+
|
5
|
+
class ComboboxFieldTest < ActionView::TestCase
|
6
|
+
test 'comobobox_field' do
|
7
|
+
actual = UiBibz::Ui::Core::Forms::Texts::ComboboxField.new('test', { url: root_url, debounce: 200 }, { id: 'test' }).render
|
8
|
+
expected = "<div data-controller=\"combobox\" data-combobox-url-value=\"http://test.host/\" data-combobox-debounce-value=\"200\" class=\"combobox\"><input type=\"text\" name=\"test\" id=\"test\" data-action=\"keyup->combobox#search\" class=\"form-control combobox-field\" autocomplete=\"false\" /><div class=\"combobox-list\"><turbo-frame id=\"test-combobox-list\" src=\"\"></turbo-frame></div></div>"
|
9
|
+
|
10
|
+
assert_equal expected, actual
|
11
|
+
end
|
12
|
+
|
13
|
+
test 'comobobox_field with prepend content' do
|
14
|
+
actual = UiBibz::Ui::Core::Forms::Texts::ComboboxField.new('test', { prepend: 'Append content' }, { id: 'test' }).render
|
15
|
+
expected = "<div class=\"input-group ui_surround_field\"><div data-controller=\"combobox\" class=\"combobox\"><input type=\"text\" name=\"test\" id=\"test\" data-action=\"keyup->combobox#search\" class=\"form-control combobox-field\" autocomplete=\"false\" /><div class=\"combobox-list\"><turbo-frame id=\"test-combobox-list\" src=\"\"></turbo-frame></div></div><span class=\"input-group-text\">Append content</span></div>"
|
16
|
+
|
17
|
+
assert_equal expected, actual
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
export default function debounce(func, wait, immediate){
|
2
|
+
var timeout, args, context, timestamp, result;
|
3
|
+
if (null == wait) wait = 100;
|
4
|
+
|
5
|
+
function later() {
|
6
|
+
var last = Date.now() - timestamp;
|
7
|
+
|
8
|
+
if (last < wait && last >= 0) {
|
9
|
+
timeout = setTimeout(later, wait - last);
|
10
|
+
} else {
|
11
|
+
timeout = null;
|
12
|
+
if (!immediate) {
|
13
|
+
result = func.apply(context, args);
|
14
|
+
context = args = null;
|
15
|
+
}
|
16
|
+
}
|
17
|
+
};
|
18
|
+
|
19
|
+
var debounced = function(){
|
20
|
+
context = this;
|
21
|
+
args = arguments;
|
22
|
+
timestamp = Date.now();
|
23
|
+
var callNow = immediate && !timeout;
|
24
|
+
if (!timeout) timeout = setTimeout(later, wait);
|
25
|
+
if (callNow) {
|
26
|
+
result = func.apply(context, args);
|
27
|
+
context = args = null;
|
28
|
+
}
|
29
|
+
|
30
|
+
return result;
|
31
|
+
};
|
32
|
+
|
33
|
+
debounced.clear = function() {
|
34
|
+
if (timeout) {
|
35
|
+
clearTimeout(timeout);
|
36
|
+
timeout = null;
|
37
|
+
}
|
38
|
+
};
|
39
|
+
|
40
|
+
debounced.flush = function() {
|
41
|
+
if (timeout) {
|
42
|
+
result = func.apply(context, args);
|
43
|
+
context = args = null;
|
44
|
+
|
45
|
+
clearTimeout(timeout);
|
46
|
+
timeout = null;
|
47
|
+
}
|
48
|
+
};
|
49
|
+
|
50
|
+
return debounced;
|
51
|
+
};
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ui_bibz
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.0.
|
4
|
+
version: 4.0.0.beta4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thooams [Thomas HUMMEL]
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-10-
|
11
|
+
date: 2023-10-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -117,6 +117,7 @@ files:
|
|
117
117
|
- README.md
|
118
118
|
- Rakefile
|
119
119
|
- app/assets/config/ui_bibz.js
|
120
|
+
- app/assets/javascripts/controllers/combobox_controller.js
|
120
121
|
- app/assets/javascripts/forms.js
|
121
122
|
- app/assets/javascripts/forms/formula.js
|
122
123
|
- app/assets/javascripts/forms/input-connected.js
|
@@ -140,6 +141,7 @@ files:
|
|
140
141
|
- app/assets/stylesheets/sass/containers/_panel.scss
|
141
142
|
- app/assets/stylesheets/sass/forms/_bootstrap_select.sass
|
142
143
|
- app/assets/stylesheets/sass/forms/_button.sass
|
144
|
+
- app/assets/stylesheets/sass/forms/_combobox.sass
|
143
145
|
- app/assets/stylesheets/sass/forms/_date_picker.sass
|
144
146
|
- app/assets/stylesheets/sass/forms/_dropdown.sass
|
145
147
|
- app/assets/stylesheets/sass/forms/_form_check.sass
|
@@ -191,6 +193,7 @@ files:
|
|
191
193
|
- lib/ui_bibz/inputs/ui_bibz_inputs/ui_checkbox_field_input.rb
|
192
194
|
- lib/ui_bibz/inputs/ui_bibz_inputs/ui_choice_field_input.rb
|
193
195
|
- lib/ui_bibz/inputs/ui_bibz_inputs/ui_choice_group_input.rb
|
196
|
+
- lib/ui_bibz/inputs/ui_bibz_inputs/ui_combobox_field_input.rb
|
194
197
|
- lib/ui_bibz/inputs/ui_bibz_inputs/ui_date_picker_field_input.rb
|
195
198
|
- lib/ui_bibz/inputs/ui_bibz_inputs/ui_dropdown_select_field_input.rb
|
196
199
|
- lib/ui_bibz/inputs/ui_bibz_inputs/ui_file_field_input.rb
|
@@ -276,6 +279,7 @@ files:
|
|
276
279
|
- lib/ui_bibz/ui/core/forms/surrounds/surround_field.rb
|
277
280
|
- lib/ui_bibz/ui/core/forms/textareas/markdown_editor_field.rb
|
278
281
|
- lib/ui_bibz/ui/core/forms/texts/auto_complete_field.rb
|
282
|
+
- lib/ui_bibz/ui/core/forms/texts/combobox_field.rb
|
279
283
|
- lib/ui_bibz/ui/core/forms/texts/text_field.rb
|
280
284
|
- lib/ui_bibz/ui/core/icons/components/glyph_counter.rb
|
281
285
|
- lib/ui_bibz/ui/core/icons/components/glyph_text.rb
|
@@ -451,6 +455,7 @@ files:
|
|
451
455
|
- test/ui/core/forms/surrounds/surround_field_test.rb
|
452
456
|
- test/ui/core/forms/textareas/markdown_editor_field_test.rb
|
453
457
|
- test/ui/core/forms/texts/auto_complete_field_test.rb
|
458
|
+
- test/ui/core/forms/texts/combobox_field_test.rb
|
454
459
|
- test/ui/core/forms/texts/text_field_test.rb
|
455
460
|
- test/ui/core/icons/glyph_test.rb
|
456
461
|
- test/ui/core/icons/star_test.rb
|
@@ -497,6 +502,7 @@ files:
|
|
497
502
|
- vendor/assets/javascripts/bootstrap-select.min.js
|
498
503
|
- vendor/assets/javascripts/bootstrap-switch.min.js
|
499
504
|
- vendor/assets/javascripts/bs-custom-file-input.min.js
|
505
|
+
- vendor/assets/javascripts/debounce.js
|
500
506
|
- vendor/assets/javascripts/fontawesome/all.js
|
501
507
|
- vendor/assets/javascripts/fontawesome/all.min.js
|
502
508
|
- vendor/assets/javascripts/fontawesome/brands.js
|