ui_bibz 4.0.0.beta3 → 4.0.0.beta6

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 56911e4917a97e61edb91f19c9f81e66026f52c67c26b905647eed1f9bb64c31
4
- data.tar.gz: 23779f1d51631b260c26363c77c649d70464a6a696348c6ad8e11fe271ecccc1
3
+ metadata.gz: 9f528f47695918dfaa5213da8ccec52eb09351947a09df77b6c9e755986bd624
4
+ data.tar.gz: c454a9bad6b5cf32c67860844fa5a0583df88b6be74aa35acba92aec4b37d291
5
5
  SHA512:
6
- metadata.gz: 59e8545e2fa75e4da93212209b4a0b2f2e36062211acd2e4fb73ae0a7dd8c173dbb0209bf1174bda050f92af25266be0d51ba8ee495bd4ebe62619e8ed77ee5f
7
- data.tar.gz: 2c8a2f443857a453054ac0ddf21f680d41b5f615284fa27d6ea4c94d1e677f14f79368a0bb2479d729ee3803fe6e6904163ba87761b96e90202f812868d56491
6
+ metadata.gz: b06b6004730cfd177e929dd8a464e5e3a655264a87bb2935f8c434fbd3e53b523a0e02a1a3c3986c77a6efa92dcd2407204b3eae6ce023ea031823f6f8ac10f8
7
+ data.tar.gz: 3d1eea98cb27518f825499f0b14f61acd7bf88cf3265406394f6f0460cf63766ba2c1aa72b769c073ad2a7775f84e7de483052962c45c86374299bdcdf019bf0
data/Gemfile.lock CHANGED
@@ -1,9 +1,10 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ui_bibz (4.0.0.beta3)
4
+ ui_bibz (4.0.0.beta6)
5
5
  bootstrap (~> 5.3.0)
6
- rails (>= 7.0.6)
6
+ dartsass-sprockets (~> 3.0.0)
7
+ rails (>= 7.1.0)
7
8
  will-paginate-i18n
8
9
  will_paginate (~> 3.3.0)
9
10
  will_paginate-bootstrap4
@@ -11,87 +12,107 @@ PATH
11
12
  GEM
12
13
  remote: https://rubygems.org/
13
14
  specs:
14
- actioncable (7.0.8)
15
- actionpack (= 7.0.8)
16
- activesupport (= 7.0.8)
15
+ actioncable (7.1.2)
16
+ actionpack (= 7.1.2)
17
+ activesupport (= 7.1.2)
17
18
  nio4r (~> 2.0)
18
19
  websocket-driver (>= 0.6.1)
19
- actionmailbox (7.0.8)
20
- actionpack (= 7.0.8)
21
- activejob (= 7.0.8)
22
- activerecord (= 7.0.8)
23
- activestorage (= 7.0.8)
24
- activesupport (= 7.0.8)
20
+ zeitwerk (~> 2.6)
21
+ actionmailbox (7.1.2)
22
+ actionpack (= 7.1.2)
23
+ activejob (= 7.1.2)
24
+ activerecord (= 7.1.2)
25
+ activestorage (= 7.1.2)
26
+ activesupport (= 7.1.2)
25
27
  mail (>= 2.7.1)
26
28
  net-imap
27
29
  net-pop
28
30
  net-smtp
29
- actionmailer (7.0.8)
30
- actionpack (= 7.0.8)
31
- actionview (= 7.0.8)
32
- activejob (= 7.0.8)
33
- activesupport (= 7.0.8)
31
+ actionmailer (7.1.2)
32
+ actionpack (= 7.1.2)
33
+ actionview (= 7.1.2)
34
+ activejob (= 7.1.2)
35
+ activesupport (= 7.1.2)
34
36
  mail (~> 2.5, >= 2.5.4)
35
37
  net-imap
36
38
  net-pop
37
39
  net-smtp
38
- rails-dom-testing (~> 2.0)
39
- actionpack (7.0.8)
40
- actionview (= 7.0.8)
41
- activesupport (= 7.0.8)
42
- rack (~> 2.0, >= 2.2.4)
40
+ rails-dom-testing (~> 2.2)
41
+ actionpack (7.1.2)
42
+ actionview (= 7.1.2)
43
+ activesupport (= 7.1.2)
44
+ nokogiri (>= 1.8.5)
45
+ racc
46
+ rack (>= 2.2.4)
47
+ rack-session (>= 1.0.1)
43
48
  rack-test (>= 0.6.3)
44
- rails-dom-testing (~> 2.0)
45
- rails-html-sanitizer (~> 1.0, >= 1.2.0)
46
- actiontext (7.0.8)
47
- actionpack (= 7.0.8)
48
- activerecord (= 7.0.8)
49
- activestorage (= 7.0.8)
50
- activesupport (= 7.0.8)
49
+ rails-dom-testing (~> 2.2)
50
+ rails-html-sanitizer (~> 1.6)
51
+ actiontext (7.1.2)
52
+ actionpack (= 7.1.2)
53
+ activerecord (= 7.1.2)
54
+ activestorage (= 7.1.2)
55
+ activesupport (= 7.1.2)
51
56
  globalid (>= 0.6.0)
52
57
  nokogiri (>= 1.8.5)
53
- actionview (7.0.8)
54
- activesupport (= 7.0.8)
58
+ actionview (7.1.2)
59
+ activesupport (= 7.1.2)
55
60
  builder (~> 3.1)
56
- erubi (~> 1.4)
57
- rails-dom-testing (~> 2.0)
58
- rails-html-sanitizer (~> 1.1, >= 1.2.0)
59
- activejob (7.0.8)
60
- activesupport (= 7.0.8)
61
+ erubi (~> 1.11)
62
+ rails-dom-testing (~> 2.2)
63
+ rails-html-sanitizer (~> 1.6)
64
+ activejob (7.1.2)
65
+ activesupport (= 7.1.2)
61
66
  globalid (>= 0.3.6)
62
- activemodel (7.0.8)
63
- activesupport (= 7.0.8)
64
- activerecord (7.0.8)
65
- activemodel (= 7.0.8)
66
- activesupport (= 7.0.8)
67
- activestorage (7.0.8)
68
- actionpack (= 7.0.8)
69
- activejob (= 7.0.8)
70
- activerecord (= 7.0.8)
71
- activesupport (= 7.0.8)
67
+ activemodel (7.1.2)
68
+ activesupport (= 7.1.2)
69
+ activerecord (7.1.2)
70
+ activemodel (= 7.1.2)
71
+ activesupport (= 7.1.2)
72
+ timeout (>= 0.4.0)
73
+ activestorage (7.1.2)
74
+ actionpack (= 7.1.2)
75
+ activejob (= 7.1.2)
76
+ activerecord (= 7.1.2)
77
+ activesupport (= 7.1.2)
72
78
  marcel (~> 1.0)
73
- mini_mime (>= 1.1.0)
74
- activesupport (7.0.8)
79
+ activesupport (7.1.2)
80
+ base64
81
+ bigdecimal
75
82
  concurrent-ruby (~> 1.0, >= 1.0.2)
83
+ connection_pool (>= 2.2.5)
84
+ drb
76
85
  i18n (>= 1.6, < 2)
77
86
  minitest (>= 5.1)
87
+ mutex_m
78
88
  tzinfo (~> 2.0)
79
89
  ast (2.4.2)
80
90
  autoprefixer-rails (10.4.15.0)
81
91
  execjs (~> 2)
82
92
  awesome_print (1.9.2)
83
- base64 (0.1.1)
84
- bootstrap (5.3.1)
93
+ base64 (0.2.0)
94
+ bigdecimal (3.1.4)
95
+ bootstrap (5.3.2)
85
96
  autoprefixer-rails (>= 9.1.0)
86
97
  popper_js (>= 2.11.8, < 3)
87
- sassc-rails (>= 2.0.0)
88
98
  builder (3.2.4)
89
99
  byebug (11.1.3)
90
100
  childprocess (4.1.0)
91
101
  concurrent-ruby (1.2.2)
102
+ connection_pool (2.4.1)
92
103
  crass (1.0.6)
93
- date (3.3.3)
104
+ dartsass-ruby (3.0.2)
105
+ sass-embedded (~> 1.54, < 1.67)
106
+ dartsass-sprockets (3.0.0)
107
+ dartsass-ruby (~> 3.0)
108
+ railties (>= 4.0.0)
109
+ sprockets (> 3.0)
110
+ sprockets-rails
111
+ tilt
112
+ date (3.3.4)
94
113
  docile (1.4.0)
114
+ drb (2.2.0)
115
+ ruby2_keywords
95
116
  erubi (1.12.0)
96
117
  execjs (2.9.1)
97
118
  factory_bot (4.11.1)
@@ -99,10 +120,11 @@ GEM
99
120
  factory_bot_rails (4.11.1)
100
121
  factory_bot (~> 4.11.1)
101
122
  railties (>= 3.0.0)
102
- ffi (1.16.2)
103
123
  globalid (1.2.1)
104
124
  activesupport (>= 6.1)
105
- haml (6.2.0)
125
+ google-protobuf (3.25.1-x86_64-darwin)
126
+ google-protobuf (3.25.1-x86_64-linux)
127
+ haml (6.2.3)
106
128
  temple (>= 0.8.2)
107
129
  thor
108
130
  tilt
@@ -113,13 +135,18 @@ GEM
113
135
  railties (>= 5.1)
114
136
  i18n (1.14.1)
115
137
  concurrent-ruby (~> 1.0)
116
- importmap-rails (1.2.1)
138
+ importmap-rails (1.2.3)
117
139
  actionpack (>= 6.0.0)
140
+ activesupport (>= 6.0.0)
118
141
  railties (>= 6.0.0)
119
142
  iniparse (1.5.0)
143
+ io-console (0.6.0)
144
+ irb (1.9.0)
145
+ rdoc
146
+ reline (>= 0.3.8)
120
147
  json (2.6.3)
121
148
  language_server-protocol (3.17.0.3)
122
- loofah (2.21.3)
149
+ loofah (2.22.0)
123
150
  crass (~> 1.0.2)
124
151
  nokogiri (>= 1.12.0)
125
152
  mail (2.8.1)
@@ -128,19 +155,19 @@ GEM
128
155
  net-pop
129
156
  net-smtp
130
157
  marcel (1.0.2)
131
- method_source (1.0.0)
132
158
  mini_mime (1.1.5)
133
159
  minitest (5.20.0)
134
- net-imap (0.3.7)
160
+ mutex_m (0.2.0)
161
+ net-imap (0.4.5)
135
162
  date
136
163
  net-protocol
137
164
  net-pop (0.1.2)
138
165
  net-protocol
139
- net-protocol (0.2.1)
166
+ net-protocol (0.2.2)
140
167
  timeout
141
168
  net-smtp (0.4.0)
142
169
  net-protocol
143
- nio4r (2.5.9)
170
+ nio4r (2.6.0)
144
171
  nokogiri (1.15.4-x86_64-darwin)
145
172
  racc (~> 1.4)
146
173
  nokogiri (1.15.4-x86_64-linux)
@@ -150,30 +177,37 @@ GEM
150
177
  iniparse (~> 1.4)
151
178
  rexml (~> 3.2)
152
179
  parallel (1.23.0)
153
- parser (3.2.2.3)
180
+ parser (3.2.2.4)
154
181
  ast (~> 2.4.1)
155
182
  racc
156
183
  popper_js (2.11.8)
184
+ psych (5.1.1.1)
185
+ stringio
157
186
  puma (6.4.0)
158
187
  nio4r (~> 2.0)
159
- racc (1.7.1)
160
- rack (2.2.8)
188
+ racc (1.7.3)
189
+ rack (3.0.8)
190
+ rack-session (2.0.0)
191
+ rack (>= 3.0.0)
161
192
  rack-test (2.1.0)
162
193
  rack (>= 1.3)
163
- rails (7.0.8)
164
- actioncable (= 7.0.8)
165
- actionmailbox (= 7.0.8)
166
- actionmailer (= 7.0.8)
167
- actionpack (= 7.0.8)
168
- actiontext (= 7.0.8)
169
- actionview (= 7.0.8)
170
- activejob (= 7.0.8)
171
- activemodel (= 7.0.8)
172
- activerecord (= 7.0.8)
173
- activestorage (= 7.0.8)
174
- activesupport (= 7.0.8)
194
+ rackup (2.1.0)
195
+ rack (>= 3)
196
+ webrick (~> 1.8)
197
+ rails (7.1.2)
198
+ actioncable (= 7.1.2)
199
+ actionmailbox (= 7.1.2)
200
+ actionmailer (= 7.1.2)
201
+ actionpack (= 7.1.2)
202
+ actiontext (= 7.1.2)
203
+ actionview (= 7.1.2)
204
+ activejob (= 7.1.2)
205
+ activemodel (= 7.1.2)
206
+ activerecord (= 7.1.2)
207
+ activestorage (= 7.1.2)
208
+ activesupport (= 7.1.2)
175
209
  bundler (>= 1.15.0)
176
- railties (= 7.0.8)
210
+ railties (= 7.1.2)
177
211
  rails-dom-testing (2.2.0)
178
212
  activesupport (>= 5.0.0)
179
213
  minitest
@@ -181,50 +215,51 @@ GEM
181
215
  rails-html-sanitizer (1.6.0)
182
216
  loofah (~> 2.21)
183
217
  nokogiri (~> 1.14)
184
- railties (7.0.8)
185
- actionpack (= 7.0.8)
186
- activesupport (= 7.0.8)
187
- method_source
218
+ railties (7.1.2)
219
+ actionpack (= 7.1.2)
220
+ activesupport (= 7.1.2)
221
+ irb
222
+ rackup (>= 1.0.0)
188
223
  rake (>= 12.2)
189
- thor (~> 1.0)
190
- zeitwerk (~> 2.5)
224
+ thor (~> 1.0, >= 1.2.2)
225
+ zeitwerk (~> 2.6)
191
226
  rainbow (3.1.1)
192
- rake (13.0.6)
193
- regexp_parser (2.8.1)
227
+ rake (13.1.0)
228
+ rdoc (6.6.0)
229
+ psych (>= 4.0.0)
230
+ regexp_parser (2.8.2)
231
+ reline (0.4.0)
232
+ io-console (~> 0.5)
194
233
  rexml (3.2.6)
195
- rubocop (1.56.4)
196
- base64 (~> 0.1.1)
234
+ rubocop (1.57.2)
197
235
  json (~> 2.3)
198
236
  language_server-protocol (>= 3.17.0)
199
237
  parallel (~> 1.10)
200
- parser (>= 3.2.2.3)
238
+ parser (>= 3.2.2.4)
201
239
  rainbow (>= 2.2.2, < 4.0)
202
240
  regexp_parser (>= 1.8, < 3.0)
203
241
  rexml (>= 3.2.5, < 4.0)
204
242
  rubocop-ast (>= 1.28.1, < 2.0)
205
243
  ruby-progressbar (~> 1.7)
206
244
  unicode-display_width (>= 2.4.0, < 3.0)
207
- rubocop-ast (1.29.0)
245
+ rubocop-ast (1.30.0)
208
246
  parser (>= 3.2.1.0)
209
- rubocop-minitest (0.32.2)
247
+ rubocop-minitest (0.33.0)
210
248
  rubocop (>= 1.39, < 2.0)
211
249
  rubocop-performance (1.19.1)
212
250
  rubocop (>= 1.7.0, < 2.0)
213
251
  rubocop-ast (>= 0.4.0)
214
- rubocop-rails (2.21.2)
252
+ rubocop-rails (2.22.1)
215
253
  activesupport (>= 4.2.0)
216
254
  rack (>= 1.1)
217
255
  rubocop (>= 1.33.0, < 2.0)
218
256
  ruby-progressbar (1.13.0)
219
- sassc (2.4.0)
220
- ffi (~> 1.9)
221
- sassc-rails (2.1.2)
222
- railties (>= 4.0.0)
223
- sassc (>= 2.0)
224
- sprockets (> 3.0)
225
- sprockets-rails
226
- tilt
227
- simple_form (5.2.0)
257
+ ruby2_keywords (0.0.5)
258
+ sass-embedded (1.66.1-x86_64-darwin)
259
+ google-protobuf (~> 3.23)
260
+ sass-embedded (1.66.1-x86_64-linux-gnu)
261
+ google-protobuf (~> 3.23)
262
+ simple_form (5.3.0)
228
263
  actionpack (>= 5.2)
229
264
  activemodel (>= 5.2)
230
265
  simplecov (0.22.0)
@@ -240,15 +275,17 @@ GEM
240
275
  actionpack (>= 5.2)
241
276
  activesupport (>= 5.2)
242
277
  sprockets (>= 3.0.0)
243
- sqlite3 (1.6.6-x86_64-darwin)
244
- sqlite3 (1.6.6-x86_64-linux)
245
- temple (0.10.2)
246
- thor (1.2.2)
278
+ sqlite3 (1.6.8-x86_64-darwin)
279
+ sqlite3 (1.6.8-x86_64-linux)
280
+ stringio (3.0.9)
281
+ temple (0.10.3)
282
+ thor (1.3.0)
247
283
  tilt (2.3.0)
248
- timeout (0.4.0)
284
+ timeout (0.4.1)
249
285
  tzinfo (2.0.6)
250
286
  concurrent-ruby (~> 1.0)
251
287
  unicode-display_width (2.5.0)
288
+ webrick (1.8.1)
252
289
  websocket-driver (0.7.6)
253
290
  websocket-extensions (>= 0.1.0)
254
291
  websocket-extensions (0.1.5)
@@ -10,3 +10,5 @@
10
10
  //= link forms/jquery.multi-select-extend.js
11
11
  //= link forms/input-connected.js
12
12
  //= link forms/formula.js
13
+ //= link debounce.js
14
+ //= link controllers/combobox_controller.js
@@ -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
+ }
@@ -6,3 +6,4 @@
6
6
  @import forms/_formula_field
7
7
  @import forms/_surround_field
8
8
  @import forms/_form_check
9
+ @import forms/combobox
@@ -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
@@ -12,6 +12,6 @@ module UiBibz
12
12
  REPO = 'git+https://github.com/thooams/ui_bibz.git'
13
13
  EMAIL = 'thomas@hummel.link'
14
14
  AUTHOR = 'Thooams [Thomas HUMMEL]'
15
- VERSION = '4.0.0.beta3'
15
+ VERSION = '4.0.0.beta6'
16
16
  AUTHORS = ['Thooams'].freeze
17
17
  end
@@ -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
@@ -24,6 +24,8 @@ module UiBibz
24
24
  private
25
25
 
26
26
  def read_cache
27
+ return if @options.try(:[], :cache).blank?
28
+
27
29
  ::Rails.cache.read(@options.try(:[], :cache))
28
30
  end
29
31
  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-&gt;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-&gt;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
data/ui_bibz.gemspec CHANGED
@@ -26,10 +26,11 @@ Gem::Specification.new do |s|
26
26
  s.require_paths = %w[lib vendor]
27
27
 
28
28
  # Rails gems
29
- s.add_dependency 'rails', '>= 7.0.6'
29
+ s.add_dependency 'rails', '>= 7.1.0'
30
30
 
31
31
  # Remove these dependencies after
32
32
  s.add_dependency 'bootstrap', '~> 5.3.0'
33
+ s.add_dependency 'dartsass-sprockets', '~> 3.0.0'
33
34
  s.add_dependency 'will_paginate', '~> 3.3.0'
34
35
  s.add_dependency 'will_paginate-bootstrap4'
35
36
  s.add_dependency 'will-paginate-i18n'
@@ -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.beta3
4
+ version: 4.0.0.beta6
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-03 00:00:00.000000000 Z
11
+ date: 2023-11-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 7.0.6
19
+ version: 7.1.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 7.0.6
26
+ version: 7.1.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bootstrap
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: 5.3.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: dartsass-sprockets
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 3.0.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 3.0.0
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: will_paginate
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -117,6 +131,7 @@ files:
117
131
  - README.md
118
132
  - Rakefile
119
133
  - app/assets/config/ui_bibz.js
134
+ - app/assets/javascripts/controllers/combobox_controller.js
120
135
  - app/assets/javascripts/forms.js
121
136
  - app/assets/javascripts/forms/formula.js
122
137
  - app/assets/javascripts/forms/input-connected.js
@@ -140,6 +155,7 @@ files:
140
155
  - app/assets/stylesheets/sass/containers/_panel.scss
141
156
  - app/assets/stylesheets/sass/forms/_bootstrap_select.sass
142
157
  - app/assets/stylesheets/sass/forms/_button.sass
158
+ - app/assets/stylesheets/sass/forms/_combobox.sass
143
159
  - app/assets/stylesheets/sass/forms/_date_picker.sass
144
160
  - app/assets/stylesheets/sass/forms/_dropdown.sass
145
161
  - app/assets/stylesheets/sass/forms/_form_check.sass
@@ -191,6 +207,7 @@ files:
191
207
  - lib/ui_bibz/inputs/ui_bibz_inputs/ui_checkbox_field_input.rb
192
208
  - lib/ui_bibz/inputs/ui_bibz_inputs/ui_choice_field_input.rb
193
209
  - lib/ui_bibz/inputs/ui_bibz_inputs/ui_choice_group_input.rb
210
+ - lib/ui_bibz/inputs/ui_bibz_inputs/ui_combobox_field_input.rb
194
211
  - lib/ui_bibz/inputs/ui_bibz_inputs/ui_date_picker_field_input.rb
195
212
  - lib/ui_bibz/inputs/ui_bibz_inputs/ui_dropdown_select_field_input.rb
196
213
  - lib/ui_bibz/inputs/ui_bibz_inputs/ui_file_field_input.rb
@@ -276,6 +293,7 @@ files:
276
293
  - lib/ui_bibz/ui/core/forms/surrounds/surround_field.rb
277
294
  - lib/ui_bibz/ui/core/forms/textareas/markdown_editor_field.rb
278
295
  - lib/ui_bibz/ui/core/forms/texts/auto_complete_field.rb
296
+ - lib/ui_bibz/ui/core/forms/texts/combobox_field.rb
279
297
  - lib/ui_bibz/ui/core/forms/texts/text_field.rb
280
298
  - lib/ui_bibz/ui/core/icons/components/glyph_counter.rb
281
299
  - lib/ui_bibz/ui/core/icons/components/glyph_text.rb
@@ -451,6 +469,7 @@ files:
451
469
  - test/ui/core/forms/surrounds/surround_field_test.rb
452
470
  - test/ui/core/forms/textareas/markdown_editor_field_test.rb
453
471
  - test/ui/core/forms/texts/auto_complete_field_test.rb
472
+ - test/ui/core/forms/texts/combobox_field_test.rb
454
473
  - test/ui/core/forms/texts/text_field_test.rb
455
474
  - test/ui/core/icons/glyph_test.rb
456
475
  - test/ui/core/icons/star_test.rb
@@ -497,6 +516,7 @@ files:
497
516
  - vendor/assets/javascripts/bootstrap-select.min.js
498
517
  - vendor/assets/javascripts/bootstrap-switch.min.js
499
518
  - vendor/assets/javascripts/bs-custom-file-input.min.js
519
+ - vendor/assets/javascripts/debounce.js
500
520
  - vendor/assets/javascripts/fontawesome/all.js
501
521
  - vendor/assets/javascripts/fontawesome/all.min.js
502
522
  - vendor/assets/javascripts/fontawesome/brands.js