ui_bibz 4.0.0.beta3 → 4.0.0.beta4

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: 700d531ae188bd2c4a87404667a960cdeb73ecdb278a60e66ed216822f899bdc
4
+ data.tar.gz: 6612425d1076b9aed91259c733d5560c7a8d80d6a5d155281441874d52e1bed0
5
5
  SHA512:
6
- metadata.gz: 59e8545e2fa75e4da93212209b4a0b2f2e36062211acd2e4fb73ae0a7dd8c173dbb0209bf1174bda050f92af25266be0d51ba8ee495bd4ebe62619e8ed77ee5f
7
- data.tar.gz: 2c8a2f443857a453054ac0ddf21f680d41b5f615284fa27d6ea4c94d1e677f14f79368a0bb2479d729ee3803fe6e6904163ba87761b96e90202f812868d56491
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.beta3)
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.0.8)
15
- actionpack (= 7.0.8)
16
- activesupport (= 7.0.8)
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
- 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)
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.0.8)
30
- actionpack (= 7.0.8)
31
- actionview (= 7.0.8)
32
- activejob (= 7.0.8)
33
- activesupport (= 7.0.8)
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.0)
39
- actionpack (7.0.8)
40
- actionview (= 7.0.8)
41
- activesupport (= 7.0.8)
42
- rack (~> 2.0, >= 2.2.4)
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.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)
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.0.8)
54
- activesupport (= 7.0.8)
56
+ actionview (7.1.1)
57
+ activesupport (= 7.1.1)
55
58
  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)
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.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)
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
- mini_mime (>= 1.1.0)
74
- activesupport (7.0.8)
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.2)
114
+ ffi (1.16.3)
103
115
  globalid (1.2.1)
104
116
  activesupport (>= 6.1)
105
- haml (6.2.0)
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.3)
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
- net-imap (0.3.7)
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.3)
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 (2.2.8)
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
- 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)
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.0.8)
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.0.8)
185
- actionpack (= 7.0.8)
186
- activesupport (= 7.0.8)
187
- method_source
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.5)
213
+ thor (~> 1.0, >= 1.2.2)
214
+ zeitwerk (~> 2.6)
191
215
  rainbow (3.1.1)
192
216
  rake (13.0.6)
193
- regexp_parser (2.8.1)
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.56.4)
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.3)
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.2.0)
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.6-x86_64-darwin)
244
- sqlite3 (1.6.6-x86_64-linux)
245
- temple (0.10.2)
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)
@@ -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.beta4'
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
@@ -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
@@ -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.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-03 00:00:00.000000000 Z
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