ui_bibz 3.0.0.beta7 → 3.0.0.beta12

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: fcf81ce4807a05b926ca746d1bf59c6247fcd15f1570b92375f31965e9e2b77c
4
- data.tar.gz: c194e18025bdaa41f2d89550f55b84cf96eaa76ce3c7d24802ec0a42c65ce80a
3
+ metadata.gz: 50692a30f39e9110cec4b66aca482aac06b5954f6785350c66e0e3f5b34fb79f
4
+ data.tar.gz: 1dcf3b39d353062f5ba6e5265339a98474f78e0fa74b7822f1269db13a036c52
5
5
  SHA512:
6
- metadata.gz: 809d8c0a5adc0a12aace155c5e9d94dd3c99e495922c0b5c55e1ed837ee3c1a98c6e09ef35a5de3b631e99cb21c4b6a4b59cda912168df6dfd4c5f8192eaa4e7
7
- data.tar.gz: 6cb6392d902b2750a16c2d4bb17a8a2515294b0c9de8d4a81f1311ae86dc70ab77d8ae8efd987d7dc8ed66ddf9af28daab48152e4e26a6ea3e67c8eb6296f1ab
6
+ metadata.gz: 5ea403acad7678809350b802ebaab7f3c96b13daa26c3637b46c3b40da038930b2a0a921b96efb7f044bc562d4604ab57c0826781d88bb73b0b2b458f3f76b52
7
+ data.tar.gz: 1b22114c6aaf66f7de20b8dfd80e8e790eea1a07e1695a3ba31f7c26a95fd30d404babc9981332731605c2015733fa03dd570bb719c4689ba7430102efa6f791
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ui_bibz (3.0.0.beta7)
4
+ ui_bibz (3.0.0.beta12)
5
5
  will-paginate-i18n
6
6
  will_paginate (~> 3.3.0)
7
7
  will_paginate-bootstrap4
@@ -9,56 +9,56 @@ PATH
9
9
  GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
- actioncable (6.0.3.4)
13
- actionpack (= 6.0.3.4)
12
+ actioncable (6.0.3.5)
13
+ actionpack (= 6.0.3.5)
14
14
  nio4r (~> 2.0)
15
15
  websocket-driver (>= 0.6.1)
16
- actionmailbox (6.0.3.4)
17
- actionpack (= 6.0.3.4)
18
- activejob (= 6.0.3.4)
19
- activerecord (= 6.0.3.4)
20
- activestorage (= 6.0.3.4)
21
- activesupport (= 6.0.3.4)
16
+ actionmailbox (6.0.3.5)
17
+ actionpack (= 6.0.3.5)
18
+ activejob (= 6.0.3.5)
19
+ activerecord (= 6.0.3.5)
20
+ activestorage (= 6.0.3.5)
21
+ activesupport (= 6.0.3.5)
22
22
  mail (>= 2.7.1)
23
- actionmailer (6.0.3.4)
24
- actionpack (= 6.0.3.4)
25
- actionview (= 6.0.3.4)
26
- activejob (= 6.0.3.4)
23
+ actionmailer (6.0.3.5)
24
+ actionpack (= 6.0.3.5)
25
+ actionview (= 6.0.3.5)
26
+ activejob (= 6.0.3.5)
27
27
  mail (~> 2.5, >= 2.5.4)
28
28
  rails-dom-testing (~> 2.0)
29
- actionpack (6.0.3.4)
30
- actionview (= 6.0.3.4)
31
- activesupport (= 6.0.3.4)
29
+ actionpack (6.0.3.5)
30
+ actionview (= 6.0.3.5)
31
+ activesupport (= 6.0.3.5)
32
32
  rack (~> 2.0, >= 2.0.8)
33
33
  rack-test (>= 0.6.3)
34
34
  rails-dom-testing (~> 2.0)
35
35
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
36
- actiontext (6.0.3.4)
37
- actionpack (= 6.0.3.4)
38
- activerecord (= 6.0.3.4)
39
- activestorage (= 6.0.3.4)
40
- activesupport (= 6.0.3.4)
36
+ actiontext (6.0.3.5)
37
+ actionpack (= 6.0.3.5)
38
+ activerecord (= 6.0.3.5)
39
+ activestorage (= 6.0.3.5)
40
+ activesupport (= 6.0.3.5)
41
41
  nokogiri (>= 1.8.5)
42
- actionview (6.0.3.4)
43
- activesupport (= 6.0.3.4)
42
+ actionview (6.0.3.5)
43
+ activesupport (= 6.0.3.5)
44
44
  builder (~> 3.1)
45
45
  erubi (~> 1.4)
46
46
  rails-dom-testing (~> 2.0)
47
47
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
48
- activejob (6.0.3.4)
49
- activesupport (= 6.0.3.4)
48
+ activejob (6.0.3.5)
49
+ activesupport (= 6.0.3.5)
50
50
  globalid (>= 0.3.6)
51
- activemodel (6.0.3.4)
52
- activesupport (= 6.0.3.4)
53
- activerecord (6.0.3.4)
54
- activemodel (= 6.0.3.4)
55
- activesupport (= 6.0.3.4)
56
- activestorage (6.0.3.4)
57
- actionpack (= 6.0.3.4)
58
- activejob (= 6.0.3.4)
59
- activerecord (= 6.0.3.4)
51
+ activemodel (6.0.3.5)
52
+ activesupport (= 6.0.3.5)
53
+ activerecord (6.0.3.5)
54
+ activemodel (= 6.0.3.5)
55
+ activesupport (= 6.0.3.5)
56
+ activestorage (6.0.3.5)
57
+ actionpack (= 6.0.3.5)
58
+ activejob (= 6.0.3.5)
59
+ activerecord (= 6.0.3.5)
60
60
  marcel (~> 0.3.1)
61
- activesupport (6.0.3.4)
61
+ activesupport (6.0.3.5)
62
62
  concurrent-ruby (~> 1.0, >= 1.0.2)
63
63
  i18n (>= 0.7, < 2)
64
64
  minitest (~> 5.1)
@@ -95,7 +95,7 @@ GEM
95
95
  haml (>= 4.0, < 6)
96
96
  nokogiri (>= 1.6.0)
97
97
  ruby_parser (~> 3.5)
98
- i18n (1.8.7)
98
+ i18n (1.8.8)
99
99
  concurrent-ruby (~> 1.0)
100
100
  iniparse (1.5.0)
101
101
  jquery-rails (4.4.0)
@@ -114,7 +114,7 @@ GEM
114
114
  mini_mime (1.0.2)
115
115
  mini_portile2 (2.5.0)
116
116
  minitest (5.14.3)
117
- nio4r (2.5.4)
117
+ nio4r (2.5.5)
118
118
  nokogiri (1.11.1)
119
119
  mini_portile2 (~> 2.5.0)
120
120
  racc (~> 1.4)
@@ -128,29 +128,29 @@ GEM
128
128
  rack (2.2.3)
129
129
  rack-test (1.1.0)
130
130
  rack (>= 1.0, < 3)
131
- rails (6.0.3.4)
132
- actioncable (= 6.0.3.4)
133
- actionmailbox (= 6.0.3.4)
134
- actionmailer (= 6.0.3.4)
135
- actionpack (= 6.0.3.4)
136
- actiontext (= 6.0.3.4)
137
- actionview (= 6.0.3.4)
138
- activejob (= 6.0.3.4)
139
- activemodel (= 6.0.3.4)
140
- activerecord (= 6.0.3.4)
141
- activestorage (= 6.0.3.4)
142
- activesupport (= 6.0.3.4)
131
+ rails (6.0.3.5)
132
+ actioncable (= 6.0.3.5)
133
+ actionmailbox (= 6.0.3.5)
134
+ actionmailer (= 6.0.3.5)
135
+ actionpack (= 6.0.3.5)
136
+ actiontext (= 6.0.3.5)
137
+ actionview (= 6.0.3.5)
138
+ activejob (= 6.0.3.5)
139
+ activemodel (= 6.0.3.5)
140
+ activerecord (= 6.0.3.5)
141
+ activestorage (= 6.0.3.5)
142
+ activesupport (= 6.0.3.5)
143
143
  bundler (>= 1.3.0)
144
- railties (= 6.0.3.4)
144
+ railties (= 6.0.3.5)
145
145
  sprockets-rails (>= 2.0.0)
146
146
  rails-dom-testing (2.0.3)
147
147
  activesupport (>= 4.2.0)
148
148
  nokogiri (>= 1.6)
149
149
  rails-html-sanitizer (1.3.0)
150
150
  loofah (~> 2.3)
151
- railties (6.0.3.4)
152
- actionpack (= 6.0.3.4)
153
- activesupport (= 6.0.3.4)
151
+ railties (6.0.3.5)
152
+ actionpack (= 6.0.3.5)
153
+ activesupport (= 6.0.3.5)
154
154
  method_source
155
155
  rake (>= 0.8.7)
156
156
  thor (>= 0.20.3, < 2.0)
@@ -158,7 +158,7 @@ GEM
158
158
  rake (13.0.3)
159
159
  regexp_parser (2.0.3)
160
160
  rexml (3.2.4)
161
- rubocop (1.9.0)
161
+ rubocop (1.9.1)
162
162
  parallel (~> 1.10)
163
163
  parser (>= 3.0.0.0)
164
164
  rainbow (>= 2.2.2, < 4.0)
@@ -182,9 +182,9 @@ GEM
182
182
  ruby_parser (3.15.1)
183
183
  sexp_processor (~> 4.9)
184
184
  sexp_processor (4.15.2)
185
- simple_form (5.0.3)
186
- actionpack (>= 5.0)
187
- activemodel (>= 5.0)
185
+ simple_form (5.1.0)
186
+ actionpack (>= 5.2)
187
+ activemodel (>= 5.2)
188
188
  simplecov (0.21.2)
189
189
  docile (~> 1.1)
190
190
  simplecov-html (~> 0.11)
data/lib/ui_bibz.rb CHANGED
@@ -180,9 +180,11 @@ module UiBibz
180
180
  module Notifications
181
181
  autoload :Alert, 'ui_bibz/ui/core/notifications/alert'
182
182
  autoload :Badge, 'ui_bibz/ui/core/notifications/badge'
183
+ autoload :Popover, 'ui_bibz/ui/core/notifications/popover'
183
184
  autoload :ProgressBar, 'ui_bibz/ui/core/notifications/progress_bar'
184
185
  autoload :Spinner, 'ui_bibz/ui/core/notifications/spinner'
185
186
  autoload :Toast, 'ui_bibz/ui/core/notifications/toast'
187
+ autoload :Tooltip, 'ui_bibz/ui/core/notifications/tooltip'
186
188
  end
187
189
 
188
190
  module Windows
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 = '3.0.0.beta7'
15
+ VERSION = '3.0.0.beta12'
16
16
  AUTHORS = ['Thooams'].freeze
17
17
  end
@@ -22,6 +22,8 @@ module UiBibz::Ui::Core::Forms::Choices
22
22
  # * +action+ - String Stimulus Option
23
23
  # * +label+ - [String/Boolean]
24
24
  # * +boolean+ - Boolean Add an hidden field for rails
25
+ # * +wrapper_html+: - Hash html_options for the wrapper
26
+ # * +label_html+: - Hash html_options for the label
25
27
  #
26
28
  # ==== Signatures
27
29
  #
@@ -52,30 +54,35 @@ module UiBibz::Ui::Core::Forms::Choices
52
54
 
53
55
  # Render html tag
54
56
  def pre_render
55
- checkbox_field_html_tag
57
+ content_tag :div, wrapper_html_options do
58
+ concat hidden_field_tag(content, '0', id: "#{content}-hidden") if options[:boolean]
59
+ concat check_box_tag(content, options[:value] || '1', options[:checked] || html_options[:checked], checkbox_html_options)
60
+ concat label_tag(label_name, label_content, label_html_options) if options[:label] != false
61
+ end
56
62
  end
57
63
 
58
64
  private
59
65
 
60
- def checkbox_field_html_tag
61
- content_tag(:div, html_options.except(:id, 'data-action')) do
62
- concat hidden_field_tag content, '0', id: "#{content}-hidden" if options[:boolean]
63
- concat check_box_tag content, options[:value] || '1', options[:checked] || html_options[:checked], checkbox_html_options
64
- concat label_tag(label_name, label_content, class: 'form-check-label') if options[:label] != false
66
+ def wrapper_html_options
67
+ (options[:wrapper_html] || {}).tap do |option|
68
+ option[:class] = UiBibz::Utils::Screwdriver.join_classes('form-check', inline, options[:wrapper_html].try(:[], :class))
65
69
  end
66
70
  end
67
71
 
68
- def checkbox_html_options
69
- {
70
- disabled: disabled?,
71
- indeterminate: options[:indeterminate],
72
- "data-action": options[:action],
73
- class: UiBibz::Utils::Screwdriver.join_classes('form-check-input', input_status)
74
- }.tap do |html|
75
- html[:id] = html_options[:id] if html_options[:id]
72
+ def label_html_options
73
+ (options[:label_html] || {}).tap do |option|
74
+ option[:class] = UiBibz::Utils::Screwdriver.join_classes('form-check-label', options[:label_html].try(:[], :class))
76
75
  end
77
76
  end
78
77
 
78
+ def checkbox_html_options
79
+ html_options.merge({
80
+ disabled: disabled?,
81
+ checked: html_options[:checked] || options[:state] == :active,
82
+ indeterminate: options[:indeterminate]
83
+ })
84
+ end
85
+
79
86
  def label_name
80
87
  html_options[:id] || content
81
88
  end
@@ -92,7 +99,7 @@ module UiBibz::Ui::Core::Forms::Choices
92
99
  end
93
100
 
94
101
  def component_html_classes
95
- super << component_wrapper_html_classes
102
+ super << ['form-check-input', input_status]
96
103
  end
97
104
 
98
105
  def input_status
@@ -104,9 +111,5 @@ module UiBibz::Ui::Core::Forms::Choices
104
111
  def inline
105
112
  'form-check-inline' if options[:inline]
106
113
  end
107
-
108
- def component_wrapper_html_classes
109
- ['form-check', inline]
110
- end
111
114
  end
112
115
  end
@@ -116,5 +116,7 @@ module UiBibz::Ui::Core::Forms::Choices
116
116
  def input_id
117
117
  @input_id ||= @options[:id] || generate_id('choice')
118
118
  end
119
+
120
+ def state; end
119
121
  end
120
122
  end
@@ -21,6 +21,8 @@ module UiBibz::Ui::Core::Forms::Choices
21
21
  # * +inline+ - Boolean
22
22
  # * +action+ - String Stimulus Option
23
23
  # * +label+ - String
24
+ # * +wrapper_html+: - Hash html_options for the wrapper
25
+ # * +label_html+: - Hash html_options for the label
24
26
  #
25
27
  # ==== Signatures
26
28
  #
@@ -51,11 +53,26 @@ module UiBibz::Ui::Core::Forms::Choices
51
53
 
52
54
  # Render html tag
53
55
  def pre_render
54
- radio_field_html_tag
56
+ content_tag :div, wrapper_html_options do
57
+ concat radio_button_tag content, options[:value], options[:checked] || false, checkbox_html_options
58
+ concat label_tag(label_name, label_content, class: 'form-check-label') if options[:label] != false
59
+ end
55
60
  end
56
61
 
57
62
  private
58
63
 
64
+ def wrapper_html_options
65
+ (options[:wrapper_html] || {}).tap do |option|
66
+ option[:class] = UiBibz::Utils::Screwdriver.join_classes('form-check', inline, options[:wrapper_html].try(:[], :class))
67
+ end
68
+ end
69
+
70
+ def label_html_options
71
+ (options[:label_html] || {}).tap do |option|
72
+ option[:class] = UiBibz::Utils::Screwdriver.join_classes('form-check-label', options[:label_html].try(:[], :class))
73
+ end
74
+ end
75
+
59
76
  def radio_field_html_tag
60
77
  content_tag :div, html_options.except(:id) do
61
78
  concat radio_button_tag content, options[:value], options[:checked] || false, checkbox_html_options
@@ -63,34 +80,8 @@ module UiBibz::Ui::Core::Forms::Choices
63
80
  end
64
81
  end
65
82
 
66
- def checkbox_html_options
67
- {
68
- disabled: options[:state] == :disabled,
69
- "data-action": options[:action],
70
- class: UiBibz::Utils::Screwdriver.join_classes('form-check-input', input_status)
71
- }
72
- end
73
-
74
83
  def label_name
75
84
  "#{content}_#{options[:value]}"
76
85
  end
77
-
78
- def component_html_classes
79
- super << component_wrapper_html_classes
80
- end
81
-
82
- def status; end
83
-
84
- def input_status
85
- "form-check-input-#{options[:status]}" if options[:status]
86
- end
87
-
88
- def inline
89
- 'form-check-inline' if options[:inline]
90
- end
91
-
92
- def component_wrapper_html_classes
93
- ['form-check', inline]
94
- end
95
86
  end
96
87
  end
@@ -73,12 +73,12 @@ module UiBibz::Ui::Core::Forms::Dropdowns
73
73
  end
74
74
 
75
75
  def button_html
76
- content_tag :button, button_content, class: join_classes('btn', button_status, size)
76
+ content_tag :button, button_content, (options[:html_button] || {}).merge(class: join_classes('btn', button_status, size, options[:html_button].try(:[], :class)))
77
77
  end
78
78
 
79
79
  def split_html
80
- content_tag :button, split_content, class: split_classes, type: 'button',
81
- 'data-bs-toggle' => 'dropdown', 'aria-haspopup' => true, 'aria-expanded' => false
80
+ content_tag :button, split_content, (options[:html_split] || {}).merge(class: split_classes, type: 'button',
81
+ 'data-bs-toggle' => 'dropdown', 'aria-haspopup' => true, 'aria-expanded' => false)
82
82
  end
83
83
 
84
84
  def split_content
@@ -86,7 +86,7 @@ module UiBibz::Ui::Core::Forms::Dropdowns
86
86
  end
87
87
 
88
88
  def split_classes
89
- join_classes('btn', button_status, size, 'dropdown-toggle', 'dropdown-toggle-split')
89
+ join_classes('btn', button_status, size, 'dropdown-toggle', 'dropdown-toggle-split', options[:split_html].try(:[], :class))
90
90
  end
91
91
 
92
92
  def src_only
@@ -0,0 +1,89 @@
1
+ # frozen_string_literal: true
2
+
3
+ module UiBibz::Ui::Core::Notifications
4
+ # Create a popover
5
+ #
6
+ # This element is an extend of UiBibz::Ui::Core::Component.
7
+ #
8
+ # ==== Attributes
9
+ #
10
+ # * +content+ - Content of element
11
+ # * +options+ - Options of element
12
+ # * +html_options+ - Html Options of element
13
+ #
14
+ # ==== Options
15
+ #
16
+ # You can add HTML attributes using the +html_options+.
17
+ # You can pass arguments in options attribute:
18
+ #
19
+ # ==== Signatures
20
+ #
21
+ # UiBibz::Ui::Core::Notifications::Popover.new(content, options = nil, html_options = nil)
22
+ #
23
+ # UiBibz::Ui::Core::Notifications::Popover.new(options = nil, html_options = nil) do
24
+ # content
25
+ # end
26
+ #
27
+ # ==== Examples
28
+ #
29
+ # UiBibz::Ui::Core::Notifications::Popover.new(class: 'my-toast').tap |t|
30
+ # t.header "My header toast", glyph: 'eye', time: 'now'
31
+ # t.body "My body toast"
32
+ # end
33
+ #
34
+ # ==== Helper
35
+ #
36
+ # popover = UiBibz::Ui::Core::Notifications::Popover.new(position: :left) do
37
+ # My content
38
+ # end
39
+ # ui_glyph("diamond", popover: popover)
40
+ #
41
+ # # or
42
+ #
43
+ # ui_glyph("diamond", {popover: true}, { title: "My content" })
44
+ #
45
+ # # or
46
+ #
47
+ # ui_glyph("diamond", popover: { title: "My content", position: :right})
48
+ #
49
+ class Popover < UiBibz::Ui::Core::Component
50
+ # Note that for security reasons the sanitize, sanitizeFn, and allowList
51
+ # options cannot be supplied using data attributes.
52
+ # https://getbootstrap.com/docs/5.0/components/popovers/#options
53
+ DATA_ATTRIBUTES = %i[animation container delay html selector
54
+ template title trigger offset fallbackPlacement
55
+ boundary customClass popperConfig].freeze
56
+
57
+ # See UiBibz::Ui::Core::Component.initialize
58
+ def initialize(content = nil, options = nil, html_options = nil, &block)
59
+ super
60
+ @content = @options[:content] if content.is_a?(Hash) && block.nil?
61
+ end
62
+
63
+ # Render html tag
64
+ def render
65
+ base_attributes.merge(data_attributes)
66
+ end
67
+
68
+ private
69
+
70
+ def base_attributes
71
+ {
72
+ 'data-bs-toggle' => 'popover',
73
+ 'data-bs-content' => @content.html_safe
74
+ }.tap do |h|
75
+ h['data-bs-placement'] = options[:position] || options[:placement] if (options[:position] || options[:placement]).present?
76
+ end
77
+ end
78
+
79
+ def data_attributes
80
+ DATA_ATTRIBUTES.map do |data_attribute|
81
+ options[data_attribute].to_s.blank? ? nil : { "data-bs-#{data_attribute}" => data_attribute_value(data_attribute) }
82
+ end.compact.reduce(&:merge) || {}
83
+ end
84
+
85
+ def data_attribute_value(data_attribute)
86
+ options[data_attribute].is_a?(String) ? options[data_attribute].html_safe : options[data_attribute]
87
+ end
88
+ end
89
+ end
@@ -25,20 +25,20 @@ module UiBibz::Ui::Core::Notifications
25
25
  #
26
26
  # ==== Signatures
27
27
  #
28
- # UiBibz::Ui::Core::Toast.new(content, options = nil, html_options = nil)
28
+ # UiBibz::Ui::Core::Notifications::Toast.new(content, options = nil, html_options = nil)
29
29
  #
30
- # UiBibz::Ui::Core::Toast.new(options = nil, html_options = nil) do
30
+ # UiBibz::Ui::Core::Notifications::Toast.new(options = nil, html_options = nil) do
31
31
  # content
32
32
  # end
33
33
  #
34
34
  # ==== Examples
35
35
  #
36
- # UiBibz::Ui::Core::Toast.new(class: 'my-toast').tap |t|
36
+ # UiBibz::Ui::Core::Notifications::Toast.new(class: 'my-toast').tap |t|
37
37
  # t.header "My header toast", glyph: 'eye', time: 'now'
38
38
  # t.body "My body toast"
39
39
  # end
40
40
  #
41
- # UiBibz::Ui::Core::Toast.new(class: 'my-toast').tap |t|
41
+ # UiBibz::Ui::Core::Notifications::Toast.new(class: 'my-toast').tap |t|
42
42
  # t.header glyph: 'eye', time: 'now' do
43
43
  # My header toast
44
44
  # end
@@ -0,0 +1,89 @@
1
+ # frozen_string_literal: true
2
+
3
+ module UiBibz::Ui::Core::Notifications
4
+ # Create a tooltip
5
+ #
6
+ # This element is an extend of UiBibz::Ui::Core::Component.
7
+ #
8
+ # ==== Attributes
9
+ #
10
+ # * +content+ - Content of element
11
+ # * +options+ - Options of element
12
+ # * +html_options+ - Html Options of element
13
+ #
14
+ # ==== Options
15
+ #
16
+ # You can add HTML attributes using the +html_options+.
17
+ # You can pass arguments in options attribute:
18
+ #
19
+ # ==== Signatures
20
+ #
21
+ # UiBibz::Ui::Core::Notifications::Tooltip.new(content, options = nil, html_options = nil)
22
+ #
23
+ # UiBibz::Ui::Core::Notifications::Tooltip.new(options = nil, html_options = nil) do
24
+ # content
25
+ # end
26
+ #
27
+ # ==== Examples
28
+ #
29
+ # UiBibz::Ui::Core::Notifications::Tooltip.new("My content")
30
+ #
31
+ # # or
32
+ #
33
+ # UiBibz::Ui::Core::Notifications::Tooltip.new(position: :right) do
34
+ # content
35
+ # end
36
+ #
37
+ # ==== Helper
38
+ #
39
+ # tooltip = UiBibz::Ui::Core::Notifications::Tooltip.new("My content", position: :left)
40
+ # ui_glyph("diamond", tooltip: tooltip)
41
+ #
42
+ # # or
43
+ #
44
+ # ui_glyph("diamond", {tooltip: true}, { title: "My content" })
45
+ #
46
+ # # or
47
+ #
48
+ # ui_glyph("diamond", tooltip: { title: "My content", position: :right})
49
+ #
50
+ class Tooltip < UiBibz::Ui::Core::Component
51
+ # Note that for security reasons the sanitize, sanitizeFn, and allowList
52
+ # options cannot be supplied using data attributes.
53
+ # https://getbootstrap.com/docs/5.0/components/tooltips/#options
54
+ DATA_ATTRIBUTES = %i[animation container delay html selector template trigger
55
+ fallbackPlacement boundary].freeze
56
+
57
+ # See UiBibz::Ui::Core::Component.initialize
58
+ def initialize(content = nil, options = nil, html_options = nil, &block)
59
+ super
60
+ @content = @options[:title] if content.is_a?(Hash) && block.nil?
61
+ end
62
+
63
+ # Render html tag
64
+ def render
65
+ base_attributes.merge(data_attributes)
66
+ end
67
+
68
+ private
69
+
70
+ def base_attributes
71
+ {
72
+ 'data-bs-toggle' => 'tooltip',
73
+ 'data-bs-title' => @content.html_safe
74
+ }.tap do |h|
75
+ h['data-bs-placement'] = options[:position] || options[:placement] if (options[:position] || options[:placement]).present?
76
+ end
77
+ end
78
+
79
+ def data_attributes
80
+ DATA_ATTRIBUTES.map do |data_attribute|
81
+ options[data_attribute].to_s.blank? ? nil : { "data-bs-#{data_attribute}" => data_attribute_value(data_attribute) }
82
+ end.compact.reduce(&:merge) || {}
83
+ end
84
+
85
+ def data_attribute_value(data_attribute)
86
+ options[data_attribute].is_a?(String) ? options[data_attribute].html_safe : options[data_attribute]
87
+ end
88
+ end
89
+ end
@@ -1,34 +1,70 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PopoverExtension
4
- TOOLTIP_METHODS = %i[animation container delay html placement selector template title trigger
5
- offset fallback_placement boundary sanitize white_list santitize_fn].freeze
6
-
7
- POPOVER_METHODS = %i[animation container delay html placement selector template title
8
- trigger offset fallback_placement boundary sanitize white_list sanitize_fn].freeze
9
-
4
+ # Add popover to a component
5
+ #
6
+ # By tooltip object
7
+ #
8
+ # popover = UiBibz::Ui::Core::Notifications::Popover.new("My Popover")
9
+ # UiBibz::Ui::Core::Component.new("My content", popover: popover)
10
+ #
11
+ # By Hash
12
+ #
13
+ # UiBibz::Ui::Core::Component.new("My content", popover: { content: "My Popover" })
14
+ #
15
+ # By String
16
+ #
17
+ # UiBibz::Ui::Core::Component.new("My content", popover: "My Popover")
18
+ #
10
19
  def popover_data_html
11
- if options[:popover].present?
12
- add_html_data 'bs-toggle', value: 'popover'
13
- add_html_data 'bs-content', value: (options[:popover].is_a?(String) ? options[:popover] : options[:popover][:content])
14
- end
20
+ return if options[:popover].nil?
15
21
 
16
- return unless options[:popover].is_a?(Hash)
17
-
18
- POPOVER_METHODS.each { |mth| add_html_data("bs-#{mth}", value: options[:popover].try(:[], mth)) unless options[:popover].try(:[], mth).nil? }
19
- add_html_data 'bs-placement', value: options[:popover].try(:[], :position) unless options[:popover].try(:[], :position).nil?
22
+ html_options.update(generate_popover.render)
20
23
  end
21
24
 
25
+ # Add tooltip to a component
26
+ #
27
+ # By tooltip object
28
+ #
29
+ # tooltip = UiBibz::Ui::Core::Notifications::Tooltip.new("My tooltip")
30
+ # UiBibz::Ui::Core::Component.new("My content", tooltip: tooltip)
31
+ #
32
+ # By Boolean
33
+ #
34
+ # UiBibz::Ui::Core::Component.new("My content", tooltip: true)
35
+ # # or
36
+ # UiBibz::Ui::Core::Component.new("My content", {tooltip: true}, { title: 'My tooltip' })
37
+ #
38
+ # By Hash
39
+ #
40
+ # UiBibz::Ui::Core::Component.new("My content", tooltip: { title: 'My tooltip' })
41
+ #
22
42
  def tooltip_data_html
23
43
  return if options[:tooltip].nil?
24
44
 
25
- add_html_data 'bs-toggle', value: 'tooltip'
45
+ html_options.update(generate_tooltip.render)
46
+ end
47
+
48
+ private
49
+
50
+ def generate_tooltip
51
+ case options[:tooltip].class.name
52
+ when 'UiBibz::Ui::Core::Notifications::Tooltip'
53
+ options[:tooltip]
54
+ when 'TrueClass'
55
+ tooltip_content = html_options.delete(:title) || (sanitize_text(content) if options[:text] == false)
56
+ UiBibz::Ui::Core::Notifications::Tooltip.new(tooltip_content)
57
+ else
58
+ UiBibz::Ui::Core::Notifications::Tooltip.new(options[:tooltip])
59
+ end
60
+ end
26
61
 
27
- if options[:tooltip].is_a?(Hash)
28
- TOOLTIP_METHODS.each { |mth| add_html_data("bs-#{mth}", value: options[:tooltip].try(:[], mth)) unless options[:tooltip].try(:[], mth).nil? }
29
- add_html_data 'bs-placement', value: options[:tooltip].try(:[], :position) unless options[:tooltip].try(:[], :position).nil?
62
+ def generate_popover
63
+ case options[:popover].class.name
64
+ when 'UiBibz::Ui::Core::Notifications::Popover'
65
+ options[:popover]
30
66
  else
31
- add_html_data :title, value: options[:tooltip] == true ? sanitize_text(content) : options[:tooltip]
67
+ UiBibz::Ui::Core::Notifications::Popover.new(options[:popover])
32
68
  end
33
69
  end
34
70
  end
@@ -35,7 +35,7 @@ module UiBibz::Ui::Ux::Tables
35
35
 
36
36
  return if default_actions? != true && @actions.raw_list.empty?
37
37
 
38
- UiBibz::Ui::Core::Forms::Dropdowns::Dropdown.new(dropdown_action_name, { position: :right, size: :sm, glyph: actions_glyph }, { class: 'dropdown-action' }).tap do |d|
38
+ UiBibz::Ui::Core::Forms::Dropdowns::Dropdown.new(dropdown_action_name, { size: :sm, glyph: actions_glyph }, { class: 'dropdown-action' }).tap do |d|
39
39
  actions_links(record).each do |l|
40
40
  d.html l.to_s.html_safe
41
41
  end
@@ -42,7 +42,8 @@ module UiBibz::Ui::Ux::Tables
42
42
  # * +size+
43
43
  # (+:sm+)
44
44
  # * +responsive+ - Boolean
45
- # * +reflow+ - Boolean
45
+ # * +breakpoint+
46
+ # (+:sm+, +:md+, +:lg+, +:xl+, +:xxl+)
46
47
  #
47
48
  # ==== Signatures
48
49
  #
@@ -118,7 +119,7 @@ module UiBibz::Ui::Ux::Tables
118
119
 
119
120
  # Render html tag
120
121
  def pre_render
121
- table_html
122
+ options[:responsive] ? content_tag(:div, table_html, class: responsive) : table_html
122
123
  end
123
124
 
124
125
  # Store must be generated by *table_search_pagination* method
@@ -184,7 +185,7 @@ module UiBibz::Ui::Ux::Tables
184
185
  private
185
186
 
186
187
  def component_html_classes
187
- ['table', striped, bordered, hoverable, size, responsive, reflow]
188
+ ['table', striped, bordered, hoverable, size]
188
189
  end
189
190
 
190
191
  def status
@@ -208,11 +209,7 @@ module UiBibz::Ui::Ux::Tables
208
209
  end
209
210
 
210
211
  def responsive
211
- 'table-responsive' unless @options[:responsive].nil?
212
- end
213
-
214
- def reflow
215
- 'table-reflow' unless @options[:reflow].nil?
212
+ ['table-responsive', @options[:breakpoint]].compact.join('-') unless @options[:responsive].nil?
216
213
  end
217
214
  end
218
215
  end
@@ -32,7 +32,8 @@ module UiBibz::Ui::Ux::Tables
32
32
  # * +size+
33
33
  # (+sm+)
34
34
  # * +responsive+ - Boolean
35
- # * +reflow+ - Boolean
35
+ # * +breakpoint+
36
+ # (+:sm+, +:md+, +:lg+, +:xl+, +:xxl+)
36
37
  #
37
38
  #
38
39
  # ==== Signatures
@@ -21,6 +21,16 @@ class SimpleFormTest < ActionView::TestCase
21
21
  @user = @users.first
22
22
  end
23
23
 
24
+ test 'simple form input' do
25
+ actual = simple_form_for @user do |f|
26
+ f.input :name_fr
27
+ end
28
+
29
+ expected = "<form class=\"simple_form edit_user\" id=\"edit_user_1\" action=\"/users/1\" accept-charset=\"UTF-8\" method=\"post\"><input type=\"hidden\" name=\"_method\" value=\"patch\" /><div class=\"form-group string optional user_name_fr\"><label class=\"control-label string optional\" for=\"user_name_fr\">Name fr</label><input class=\"form-control string optional\" type=\"text\" value=\"test1\" name=\"user[name_fr]\" id=\"user_name_fr\" /></div></form>"
30
+
31
+ assert_equal expected, actual
32
+ end
33
+
24
34
  test 'auto complete field input in simple form' do
25
35
  actual = simple_form_for @user do |f|
26
36
  f.input :name_fr, as: :ui_auto_complete_field, collection: @users, label_method: :name_fr
@@ -125,7 +135,7 @@ test1</textarea></div></form>"
125
135
  f.input :name_fr, as: :ui_radio_field, collection: @users, label_method: :name_fr
126
136
  end
127
137
 
128
- expected = "<form class=\"simple_form edit_user\" id=\"edit_user_1\" action=\"/users/1\" accept-charset=\"UTF-8\" method=\"post\"><input type=\"hidden\" name=\"_method\" value=\"patch\" /><div class=\"form-group ui_radio_field optional user_name_fr\"><label class=\"control-label ui_radio_field optional\">Name fr</label><input type=\"hidden\" name=\"user[name_fr]\" value=\"\" /><div class=\"radio ui_radio_field optional form-check\"><input class=\"ui_radio_field optional form-check\" type=\"radio\" value=\"1\" name=\"user[name_fr]\" id=\"user_name_fr_1\" /><label class=\"collection_radio_buttons\" for=\"user_name_fr_1\">test1</label></div><div class=\"radio ui_radio_field optional form-check\"><input class=\"ui_radio_field optional form-check\" type=\"radio\" value=\"2\" name=\"user[name_fr]\" id=\"user_name_fr_2\" /><label class=\"collection_radio_buttons\" for=\"user_name_fr_2\">test2</label></div></div></form>"
138
+ expected = "<form class=\"simple_form edit_user\" id=\"edit_user_1\" action=\"/users/1\" accept-charset=\"UTF-8\" method=\"post\"><input type=\"hidden\" name=\"_method\" value=\"patch\" /><div class=\"form-group ui_radio_field optional user_name_fr\"><label class=\"control-label ui_radio_field optional\">Name fr</label><input type=\"hidden\" name=\"user[name_fr]\" value=\"\" /><div class=\"radio ui_radio_field optional form-check-input\"><input class=\"ui_radio_field optional form-check-input\" type=\"radio\" value=\"1\" name=\"user[name_fr]\" id=\"user_name_fr_1\" /><label class=\"collection_radio_buttons\" for=\"user_name_fr_1\">test1</label></div><div class=\"radio ui_radio_field optional form-check-input\"><input class=\"ui_radio_field optional form-check-input\" type=\"radio\" value=\"2\" name=\"user[name_fr]\" id=\"user_name_fr_2\" /><label class=\"collection_radio_buttons\" for=\"user_name_fr_2\">test2</label></div></div></form>"
129
139
 
130
140
  assert_equal expected, actual
131
141
  end
@@ -91,14 +91,14 @@ class ButtonTest < ActionView::TestCase
91
91
 
92
92
  test 'button with complex popover' do
93
93
  actual = ui_button('My Button', popover: { content: 'My popover', position: :left, html: true })
94
- expected = '<button data-bs-toggle="popover" data-bs-content="My popover" data-bs-html="true" data-bs-placement="left" class="btn-secondary btn">My Button</button>'
94
+ expected = "<button data-bs-toggle=\"popover\" data-bs-content=\"My popover\" data-bs-placement=\"left\" data-bs-html=\"true\" class=\"btn-secondary btn\">My Button</button>"
95
95
 
96
96
  assert_equal expected, actual
97
97
  end
98
98
 
99
99
  test 'button with simple tooltip' do
100
100
  actual = ui_button('My Button', { tooltip: 'My Button' }, { title: 'My tooltip' })
101
- expected = '<button title="My tooltip" data-bs-toggle="tooltip" data-title="My Button" class="btn-secondary btn">My Button</button>'
101
+ expected = '<button title="My tooltip" data-bs-toggle="tooltip" data-bs-title="My Button" class="btn-secondary btn">My Button</button>'
102
102
 
103
103
  assert_equal expected, actual
104
104
  end
@@ -16,4 +16,11 @@ class CheckboxFieldTest < ActionView::TestCase
16
16
 
17
17
  assert_equal expected, actual
18
18
  end
19
+
20
+ test 'checkbox_field with options and html_options' do
21
+ actual = UiBibz::Ui::Core::Forms::Choices::CheckboxField.new('John', action: 'click->controller#action', label_html: { class: 'test' }, wrapper_html: { title: "My title" }).render
22
+ expected = "<div title=\"My title\" class=\"form-check\"><input type=\"checkbox\" name=\"John\" id=\"John\" value=\"1\" data-action=\"click-&gt;controller#action\" class=\"form-check-input\" /><label class=\"form-check-label test\" for=\"John\">John</label></div>"
23
+
24
+ assert_equal expected, actual
25
+ end
19
26
  end
@@ -11,7 +11,7 @@ class ChoiceGroupTest < ActionView::TestCase
11
11
  bc.choice 'Checkbox 2', state: :active
12
12
  end
13
13
 
14
- expected = "<div data-toggle=\"buttons\" class=\"btn-group button-choice btn-group-toggle\"><input type=\"checkbox\" autocomplete=\"off\" class=\"btn-check\" id=\"#{actual.items.first.input_options[:id]}\" /><label class=\"btn-secondary btn\" for=\"#{actual.items.first.input_options[:id]}\">Checkbox 1</label><input type=\"checkbox\" autocomplete=\"off\" class=\"btn-check\" checked=\"checked\" id=\"#{actual.items.last.input_options[:id]}\" /><label class=\"active btn-secondary btn\" aria-pressed=\"true\" for=\"#{actual.items.last.input_options[:id]}\">Checkbox 2</label></div>"
14
+ expected = "<div data-toggle=\"buttons\" class=\"btn-group button-choice btn-group-toggle\"><input type=\"checkbox\" autocomplete=\"off\" class=\"btn-check\" id=\"#{actual.items.first.input_options[:id]}\" /><label class=\"btn-secondary btn\" for=\"#{actual.items.first.input_options[:id]}\">Checkbox 1</label><input type=\"checkbox\" autocomplete=\"off\" class=\"btn-check\" checked=\"checked\" id=\"#{actual.items.last.input_options[:id]}\" /><label class=\"btn-secondary btn\" aria-pressed=\"true\" for=\"#{actual.items.last.input_options[:id]}\">Checkbox 2</label></div>"
15
15
 
16
16
  assert_equal expected, actual.render
17
17
  end
@@ -22,7 +22,7 @@ class ChoiceGroupTest < ActionView::TestCase
22
22
  bc.choice 'Radio 2', state: :active
23
23
  end
24
24
 
25
- expected = "<div data-toggle=\"buttons\" class=\"btn-group button-choice btn-group-toggle\"><input type=\"radio\" autocomplete=\"off\" class=\"btn-check\" name=\"#{actual.items.first.input_options[:name]}\" id=\"#{actual.items.first.input_options[:id]}\" /><label class=\"btn-secondary btn\" for=\"#{actual.items.first.input_options[:id]}\">Radio 1</label><input type=\"radio\" autocomplete=\"off\" class=\"btn-check\" checked=\"checked\" name=\"#{actual.items.last.input_options[:name]}\" id=\"#{actual.items.last.input_options[:id]}\" /><label class=\"active btn-secondary btn\" aria-pressed=\"true\" for=\"#{actual.items.last.input_options[:id]}\">Radio 2</label></div>"
25
+ expected = "<div data-toggle=\"buttons\" class=\"btn-group button-choice btn-group-toggle\"><input type=\"radio\" autocomplete=\"off\" class=\"btn-check\" name=\"#{actual.items.first.input_options[:name]}\" id=\"#{actual.items.first.input_options[:id]}\" /><label class=\"btn-secondary btn\" for=\"#{actual.items.first.input_options[:id]}\">Radio 1</label><input type=\"radio\" autocomplete=\"off\" class=\"btn-check\" checked=\"checked\" name=\"#{actual.items.last.input_options[:name]}\" id=\"#{actual.items.last.input_options[:id]}\" /><label class=\"btn-secondary btn\" aria-pressed=\"true\" for=\"#{actual.items.last.input_options[:id]}\">Radio 2</label></div>"
26
26
 
27
27
  assert_equal expected, actual.render
28
28
  end
@@ -32,7 +32,7 @@ class ChoiceGroupTest < ActionView::TestCase
32
32
  bc.choice 'Radio 1', glyph: 'diamond', status: :primary
33
33
  bc.choice 'Radio 2', state: :active
34
34
  end
35
- expected = "<div data-toggle=\"buttons\" class=\"btn-group btn-group-lg button-choice btn-group-toggle\"><input type=\"radio\" autocomplete=\"off\" class=\"btn-check\" name=\"#{actual.items.first.input_options[:name]}\" id=\"#{actual.items.first.input_options[:id]}\" /><label class=\"btn-outline-primary btn btn-lg\" for=\"#{actual.items.first.input_options[:id]}\"><i class=\"glyph fas fa-diamond\"></i> Radio 1</label><input type=\"radio\" autocomplete=\"off\" class=\"btn-check\" checked=\"checked\" name=\"#{actual.items.last.input_options[:name]}\" id=\"#{actual.items.last.input_options[:id]}\" /><label class=\"active btn-outline-secondary btn btn-lg\" aria-pressed=\"true\" for=\"#{actual.items.last.input_options[:id]}\">Radio 2</label></div>"
35
+ expected = "<div data-toggle=\"buttons\" class=\"btn-group btn-group-lg button-choice btn-group-toggle\"><input type=\"radio\" autocomplete=\"off\" class=\"btn-check\" name=\"#{actual.items.first.input_options[:name]}\" id=\"#{actual.items.first.input_options[:id]}\" /><label class=\"btn-outline-primary btn btn-lg\" for=\"#{actual.items.first.input_options[:id]}\"><i class=\"glyph fas fa-diamond\"></i> Radio 1</label><input type=\"radio\" autocomplete=\"off\" class=\"btn-check\" checked=\"checked\" name=\"#{actual.items.last.input_options[:name]}\" id=\"#{actual.items.last.input_options[:id]}\" /><label class=\"btn-outline-secondary btn btn-lg\" aria-pressed=\"true\" for=\"#{actual.items.last.input_options[:id]}\">Radio 2</label></div>"
36
36
 
37
37
  assert_equal expected, actual.render
38
38
  end
@@ -9,4 +9,11 @@ class RadioFieldTest < ActionView::TestCase
9
9
 
10
10
  assert_equal expected, actual
11
11
  end
12
+
13
+ test 'checkbox_field with options and html_options' do
14
+ actual = UiBibz::Ui::Core::Forms::Choices::RadioField.new('John', action: 'click->controller#action', label_html: { class: 'test' }, wrapper_html: { title: "My title" }).render
15
+ expected = "<div title=\"My title\" class=\"form-check\"><input type=\"radio\" name=\"John\" id=\"John_\" data-action=\"click-&gt;controller#action\" class=\"form-check-input\" /><label class=\"form-check-label\" for=\"John_\">John</label></div>"
16
+
17
+ assert_equal expected, actual
18
+ end
12
19
  end
@@ -87,7 +87,7 @@ class SurroundFieldTest < ActionView::TestCase
87
87
  sf.button_refresh
88
88
  end.render
89
89
 
90
- expected = "<div class=\"input-group ui_surround_field\"><span class=\"input-group-text\"><i class=\"glyph fas fa-gem\"></i></span><span class=\"input-group-text\">test</span><button class=\"btn-secondary btn\">button</button><div class=\"input-group-btn\" role=\"group\"><button class=\"btn-secondary btn\">test</button></div><a class=\"btn-secondary btn\" role=\"button\" href=\"#\">link</a><div class=\"input-group-text\" label=\"false\"><input type=\"checkbox\" name=\"check\" id=\"check\" value=\"1\" class=\"form-check-input\" /><label class=\"form-check-label\" for=\"check\">check</label></div><div class=\"input-group-text\" label=\"false\"><input type=\"radio\" name=\"radio\" id=\"radio_\" class=\"form-check-input\" /><label class=\"form-check-label\" for=\"radio_\">radio</label></div><input type=\"text\" name=\"text\" id=\"text\" class=\"form-control\" /><input type=\"text\" name=\"date\" id=\"date\" data-date-locale=\"en\" data-provide=\"datepicker\" data-date-format=\"yyyy-mm-dd\" data-date-today-btn=\"linked\" data-date-toggle-active=\"true\" class=\"date_picker form-control\" /><select name=\"dropdown_select\" id=\"dropdown_select\" data-wrapper-classes=\"input-group-btn\" data-dropdown-classes=\"dropdown\" class=\"btn-secondary multi-select-field\"></select><select name=\"select\" id=\"select\" class=\"select-field form-control form-select\"></select><input type=\"text\" name=\"auto\" id=\"auto\" class=\"form-control auto-complete-field\" autocomplete=\"true\" list=\"auto-datalist\" /><datalist id=\"auto-datalist\"></datalist><span data-connect=\"{&quot;events&quot;:&quot;click&quot;,&quot;mode&quot;:&quot;remote&quot;,&quot;target&quot;:{&quot;selector&quot;:&quot;&quot;,&quot;url&quot;:&quot;&quot;,&quot;data&quot;:[]}}\" class=\"btn-secondary ui-bibz-connect btn input-refresh-button\"><i class=\"glyph fas fa-sync-alt\"></i></span></div>"
90
+ expected = "<div class=\"input-group ui_surround_field\"><span class=\"input-group-text\"><i class=\"glyph fas fa-gem\"></i></span><span class=\"input-group-text\">test</span><button class=\"btn-secondary btn\">button</button><div class=\"input-group-btn\" role=\"group\"><button class=\"btn-secondary btn\">test</button></div><a class=\"btn-secondary btn\" role=\"button\" href=\"#\">link</a><div class=\"form-check\"><input type=\"checkbox\" name=\"check\" id=\"check\" value=\"1\" class=\"form-check-input input-group-text\" label=\"false\" /><label class=\"form-check-label\" for=\"check\">check</label></div><div class=\"form-check\"><input type=\"radio\" name=\"radio\" id=\"radio_\" class=\"form-check-input input-group-text\" label=\"false\" /><label class=\"form-check-label\" for=\"radio_\">radio</label></div><input type=\"text\" name=\"text\" id=\"text\" class=\"form-control\" /><input type=\"text\" name=\"date\" id=\"date\" data-date-locale=\"en\" data-provide=\"datepicker\" data-date-format=\"yyyy-mm-dd\" data-date-today-btn=\"linked\" data-date-toggle-active=\"true\" class=\"date_picker form-control\" /><select name=\"dropdown_select\" id=\"dropdown_select\" data-wrapper-classes=\"input-group-btn\" data-dropdown-classes=\"dropdown\" class=\"btn-secondary multi-select-field\"></select><select name=\"select\" id=\"select\" class=\"select-field form-control form-select\"></select><input type=\"text\" name=\"auto\" id=\"auto\" class=\"form-control auto-complete-field\" autocomplete=\"true\" list=\"auto-datalist\" /><datalist id=\"auto-datalist\"></datalist><span data-connect=\"{&quot;events&quot;:&quot;click&quot;,&quot;mode&quot;:&quot;remote&quot;,&quot;target&quot;:{&quot;selector&quot;:&quot;&quot;,&quot;url&quot;:&quot;&quot;,&quot;data&quot;:[]}}\" class=\"btn-secondary ui-bibz-connect btn input-refresh-button\"><i class=\"glyph fas fa-sync-alt\"></i></span></div>"
91
91
 
92
92
  assert_equal expected, actual
93
93
  end
@@ -0,0 +1,59 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'test_helper'
4
+ class PopoverTest < ActionView::TestCase
5
+ setup do
6
+ @parameters = { animation: true, container: "body", position: :left,
7
+ delay: 10, html: true, selector: false, template: "<b>",
8
+ trigger: "hover focus", fallbackPlacement: %w[top right],
9
+ boundary: 'clippingParents', title: "My title", offset: 2,
10
+ customClass: "test", popperConfig: "Mystring" }
11
+ end
12
+
13
+ test 'popover by hash' do
14
+ actual = UiBibz::Ui::Core::Notifications::Popover.new(@parameters.merge(content: "My Content")).render
15
+ expected = { "data-bs-toggle" => "popover", "data-bs-content" => "My Content", "data-bs-placement" => :left, "data-bs-animation" => true, "data-bs-container" => "body", "data-bs-delay" => 10, "data-bs-html" => true, "data-bs-selector" => false, "data-bs-template" => "<b>", "data-bs-title" => "My title", "data-bs-trigger" => "hover focus", "data-bs-offset" => 2, "data-bs-fallbackPlacement" => %w[top right], "data-bs-boundary" => "clippingParents", "data-bs-customClass" => "test", "data-bs-popperConfig" => "Mystring" }
16
+
17
+ assert_equal expected, actual
18
+ end
19
+
20
+ test 'popover with content and options' do
21
+ actual = UiBibz::Ui::Core::Notifications::Popover.new("My Content", @parameters).render
22
+
23
+ expected = { "data-bs-toggle" => "popover", "data-bs-content" => "My Content", "data-bs-placement" => :left, "data-bs-animation" => true, "data-bs-container" => "body", "data-bs-delay" => 10, "data-bs-html" => true, "data-bs-selector" => false, "data-bs-template" => "<b>", "data-bs-title" => "My title", "data-bs-trigger" => "hover focus", "data-bs-offset" => 2, "data-bs-fallbackPlacement" => %w[top right], "data-bs-boundary" => "clippingParents", "data-bs-customClass" => "test", "data-bs-popperConfig" => "Mystring" }
24
+
25
+ assert_equal expected, actual
26
+ end
27
+
28
+ test 'popover with block and options' do
29
+ actual = UiBibz::Ui::Core::Notifications::Popover.new(@parameters) do
30
+ "My Content"
31
+ end.render
32
+
33
+ expected = { "data-bs-toggle" => "popover", "data-bs-content" => "My Content", "data-bs-placement" => :left, "data-bs-animation" => true, "data-bs-container" => "body", "data-bs-delay" => 10, "data-bs-html" => true, "data-bs-selector" => false, "data-bs-template" => "<b>", "data-bs-title" => "My title", "data-bs-trigger" => "hover focus", "data-bs-offset" => 2, "data-bs-fallbackPlacement" => %w[top right], "data-bs-boundary" => "clippingParents", "data-bs-customClass" => "test", "data-bs-popperConfig" => "Mystring" }
34
+
35
+ assert_equal expected, actual
36
+ end
37
+
38
+ test 'glyph with popover object' do
39
+ popover = UiBibz::Ui::Core::Notifications::Popover.new(@parameters.merge(content: "My Content"))
40
+ actual = UiBibz::Ui::Core::Icons::Glyph.new("diamond", popover: popover).render
41
+ expected = "<i data-bs-toggle=\"popover\" data-bs-content=\"My Content\" data-bs-placement=\"left\" data-bs-animation=\"true\" data-bs-container=\"body\" data-bs-delay=\"10\" data-bs-html=\"true\" data-bs-selector=\"false\" data-bs-template=\"<b>\" data-bs-title=\"My title\" data-bs-trigger=\"hover focus\" data-bs-offset=\"2\" data-bs-fallbackPlacement=\"top right\" data-bs-boundary=\"clippingParents\" data-bs-customClass=\"test\" data-bs-popperConfig=\"Mystring\" class=\"glyph fas fa-diamond\"></i>"
42
+
43
+ assert_equal expected, actual
44
+ end
45
+
46
+ test 'glyph with popover hash' do
47
+ actual = UiBibz::Ui::Core::Icons::Glyph.new("diamond", popover: @parameters.merge(content: "My Content")).render
48
+ expected = "<i data-bs-toggle=\"popover\" data-bs-content=\"My Content\" data-bs-placement=\"left\" data-bs-animation=\"true\" data-bs-container=\"body\" data-bs-delay=\"10\" data-bs-html=\"true\" data-bs-selector=\"false\" data-bs-template=\"<b>\" data-bs-title=\"My title\" data-bs-trigger=\"hover focus\" data-bs-offset=\"2\" data-bs-fallbackPlacement=\"top right\" data-bs-boundary=\"clippingParents\" data-bs-customClass=\"test\" data-bs-popperConfig=\"Mystring\" class=\"glyph fas fa-diamond\"></i>"
49
+
50
+ assert_equal expected, actual
51
+ end
52
+
53
+ test 'glyph with popover String' do
54
+ actual = UiBibz::Ui::Core::Icons::Glyph.new("diamond", popover: "My Content").render
55
+ expected = "<i data-bs-toggle=\"popover\" data-bs-content=\"My Content\" class=\"glyph fas fa-diamond\"></i>"
56
+
57
+ assert_equal expected, actual
58
+ end
59
+ end
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'test_helper'
4
+ class TooltipTest < ActionView::TestCase
5
+ setup do
6
+ @parameters = { animation: true, container: "body", position: :left,
7
+ delay: 10, html: true, selector: false, template: "<b>",
8
+ trigger: "hover focus", fallbackPlacement: %w[top right],
9
+ boundary: 'clippingParents' }
10
+ end
11
+
12
+ test 'tooltip by hash' do
13
+ actual = UiBibz::Ui::Core::Notifications::Tooltip.new(@parameters.merge(title: "My Title")).render
14
+ expected = { "data-bs-toggle" => "tooltip", "data-bs-title" => "My Title", "data-bs-placement" => :left, "data-bs-animation" => true, "data-bs-container" => "body", "data-bs-delay" => 10, "data-bs-html" => true, "data-bs-selector" => false, "data-bs-template" => "<b>", "data-bs-trigger" => "hover focus", "data-bs-fallbackPlacement" => %w[top right], "data-bs-boundary" => "clippingParents" }
15
+
16
+ assert_equal expected, actual
17
+ end
18
+
19
+ test 'tooltip with content and options' do
20
+ actual = UiBibz::Ui::Core::Notifications::Tooltip.new("My Title", @parameters).render
21
+
22
+ expected = { "data-bs-toggle" => "tooltip", "data-bs-title" => "My Title", "data-bs-placement" => :left, "data-bs-animation" => true, "data-bs-container" => "body", "data-bs-delay" => 10, "data-bs-html" => true, "data-bs-selector" => false, "data-bs-template" => "<b>", "data-bs-trigger" => "hover focus", "data-bs-fallbackPlacement" => %w[top right], "data-bs-boundary" => "clippingParents" }
23
+
24
+ assert_equal expected, actual
25
+ end
26
+
27
+ test 'tooltip with block and options' do
28
+ actual = UiBibz::Ui::Core::Notifications::Tooltip.new(@parameters) do
29
+ "My Title"
30
+ end.render
31
+
32
+ expected = { "data-bs-toggle" => "tooltip", "data-bs-title" => "My Title", "data-bs-placement" => :left, "data-bs-animation" => true, "data-bs-container" => "body", "data-bs-delay" => 10, "data-bs-html" => true, "data-bs-selector" => false, "data-bs-template" => "<b>", "data-bs-trigger" => "hover focus", "data-bs-fallbackPlacement" => %w[top right], "data-bs-boundary" => "clippingParents" }
33
+
34
+ assert_equal expected, actual
35
+ end
36
+
37
+ test 'glyph with tooltip object' do
38
+ tooltip = UiBibz::Ui::Core::Notifications::Tooltip.new(@parameters.merge(title: "My Title"))
39
+ actual = UiBibz::Ui::Core::Icons::Glyph.new("diamond", tooltip: tooltip).render
40
+ expected = "<i data-bs-toggle=\"tooltip\" data-bs-title=\"My Title\" data-bs-placement=\"left\" data-bs-animation=\"true\" data-bs-container=\"body\" data-bs-delay=\"10\" data-bs-html=\"true\" data-bs-selector=\"false\" data-bs-template=\"<b>\" data-bs-trigger=\"hover focus\" data-bs-fallbackPlacement=\"top right\" data-bs-boundary=\"clippingParents\" class=\"glyph fas fa-diamond\"></i>"
41
+
42
+ assert_equal expected, actual
43
+ end
44
+
45
+ test 'glyph with tooltip hash' do
46
+ actual = UiBibz::Ui::Core::Icons::Glyph.new("diamond", tooltip: @parameters.merge(title: "My Title")).render
47
+ expected = "<i data-bs-toggle=\"tooltip\" data-bs-title=\"My Title\" data-bs-placement=\"left\" data-bs-animation=\"true\" data-bs-container=\"body\" data-bs-delay=\"10\" data-bs-html=\"true\" data-bs-selector=\"false\" data-bs-template=\"<b>\" data-bs-trigger=\"hover focus\" data-bs-fallbackPlacement=\"top right\" data-bs-boundary=\"clippingParents\" class=\"glyph fas fa-diamond\"></i>"
48
+
49
+ assert_equal expected, actual
50
+ end
51
+
52
+ test 'glyph with tooltip boolean' do
53
+ actual = UiBibz::Ui::Core::Icons::Glyph.new("diamond", { tooltip: true }, { title: "My Title" }).render
54
+ expected = "<i data-bs-toggle=\"tooltip\" data-bs-title=\"My Title\" class=\"glyph fas fa-diamond\"></i>"
55
+
56
+ assert_equal expected, actual
57
+ end
58
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'test_helper'
4
+ require 'ui_bibz/ui/ux/tables/components/store'
5
+ require 'ui_bibz/ui/ux/tables/extensions/paginable'
6
+ require 'ui_bibz/ui/ux/tables/extensions/searchable'
7
+ require 'ui_bibz/ui/ux/tables/extensions/sortable'
8
+ require 'ui_bibz/ui/ux/tables/extensions/actionable'
9
+
10
+ class TableCardTest < ActionView::TestCase
11
+ setup do
12
+ create_list(:user, 25)
13
+ params = ActionController::Parameters.new({
14
+ controller: 'users',
15
+ action: 'index',
16
+ sort: 'users.name_fr',
17
+ direction: 'asc',
18
+ search: 'Name fr',
19
+ per_page: 2,
20
+ page: 1,
21
+ only_path: true
22
+ })
23
+ @users = User.table_search_pagination(params, session)
24
+ @store = UiBibz::Ui::Ux::Tables::Store.new @users
25
+ end
26
+
27
+ test 'table card visual options' do
28
+ table_card = UiBibz::Ui::Ux::Tables::TableCard.new(store: @users, table_options: { striped: true, status: :inverse, responsive: true, bordered: true, size: :sm, hoverable: true, breakpoint: :sm }).render
29
+ actual_table_classes = Nokogiri::HTML(table_card).xpath('//table')[0].attributes['class'].value
30
+ div_classes = Nokogiri::HTML(table_card).xpath('//div').css('.table-responsive-sm')[0].attributes['class'].value
31
+ table_classes = 'table-inverse table table-striped table-bordered table-hoverable table-sm'
32
+ actual_div_classes = 'table-responsive-sm'
33
+
34
+ assert_equal table_classes, actual_table_classes
35
+ assert_equal div_classes, actual_div_classes
36
+ end
37
+ end
@@ -195,11 +195,14 @@ class TableTest < ActionView::TestCase
195
195
  end
196
196
 
197
197
  test 'table visual options' do
198
- table = UiBibz::Ui::Ux::Tables::Table.new(store: @users, striped: true, status: :inverse, responsive: true, bordered: true, size: :sm, hoverable: true, reflow: true).render
199
- actual = Nokogiri::HTML(table).xpath('//table')[0].attributes['class'].value
200
- expected = 'table-inverse table table-striped table-bordered table-hoverable table-sm table-responsive table-reflow'
201
-
202
- assert_equal expected, actual
198
+ table = UiBibz::Ui::Ux::Tables::Table.new(store: @users, striped: true, status: :inverse, responsive: true, bordered: true, size: :sm, hoverable: true, breakpoint: :sm).render
199
+ div_classes = Nokogiri::HTML(table).xpath('//div')[0].attributes['class'].value
200
+ actual_table_classes = Nokogiri::HTML(table).xpath('//table')[0].attributes['class'].value
201
+ table_classes = 'table-inverse table table-striped table-bordered table-hoverable table-sm'
202
+ actual_div_classes = 'table-responsive-sm'
203
+
204
+ assert_equal table_classes, actual_table_classes
205
+ assert_equal div_classes, actual_div_classes
203
206
  end
204
207
 
205
208
  test 'table thead visual options' do
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: 3.0.0.beta7
4
+ version: 3.0.0.beta12
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: 2021-01-29 00:00:00.000000000 Z
11
+ date: 2021-02-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -411,9 +411,11 @@ files:
411
411
  - lib/ui_bibz/ui/core/notifications/components/bar.rb
412
412
  - lib/ui_bibz/ui/core/notifications/components/toast_body.rb
413
413
  - lib/ui_bibz/ui/core/notifications/components/toast_header.rb
414
+ - lib/ui_bibz/ui/core/notifications/popover.rb
414
415
  - lib/ui_bibz/ui/core/notifications/progress_bar.rb
415
416
  - lib/ui_bibz/ui/core/notifications/spinner.rb
416
417
  - lib/ui_bibz/ui/core/notifications/toast.rb
418
+ - lib/ui_bibz/ui/core/notifications/tooltip.rb
417
419
  - lib/ui_bibz/ui/core/windows/components/modal_body.rb
418
420
  - lib/ui_bibz/ui/core/windows/components/modal_footer.rb
419
421
  - lib/ui_bibz/ui/core/windows/components/modal_header.rb
@@ -564,12 +566,15 @@ files:
564
566
  - test/ui/core/navigations/toolbar_test.rb
565
567
  - test/ui/core/notifications/alert_test.rb
566
568
  - test/ui/core/notifications/badge_test.rb
569
+ - test/ui/core/notifications/popover_test.rb
567
570
  - test/ui/core/notifications/progress_bar_test.rb
568
571
  - test/ui/core/notifications/spinner_test.rb
569
572
  - test/ui/core/notifications/toast_test.rb
573
+ - test/ui/core/notifications/tooltip_test.rb
570
574
  - test/ui/core/windows/modal_test.rb
571
575
  - test/ui/utils/breakdown_class_name_generator_test.rb
572
576
  - test/ui/ux/containers/panel_test.rb
577
+ - test/ui/ux/tables/table_card_test.rb
573
578
  - test/ui/ux/tables/table_test.rb
574
579
  - test/ui_bibz_test.rb
575
580
  - ui_bibz.gemspec
@@ -774,11 +779,14 @@ test_files:
774
779
  - test/ui/core/navigations/toolbar_test.rb
775
780
  - test/ui/core/notifications/alert_test.rb
776
781
  - test/ui/core/notifications/badge_test.rb
782
+ - test/ui/core/notifications/popover_test.rb
777
783
  - test/ui/core/notifications/progress_bar_test.rb
778
784
  - test/ui/core/notifications/spinner_test.rb
779
785
  - test/ui/core/notifications/toast_test.rb
786
+ - test/ui/core/notifications/tooltip_test.rb
780
787
  - test/ui/core/windows/modal_test.rb
781
788
  - test/ui/utils/breakdown_class_name_generator_test.rb
782
789
  - test/ui/ux/containers/panel_test.rb
790
+ - test/ui/ux/tables/table_card_test.rb
783
791
  - test/ui/ux/tables/table_test.rb
784
792
  - test/ui_bibz_test.rb