matestack-ui-bootstrap 1.4.0 → 1.5.0

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.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +65 -7
  3. data/app/concepts/matestack/ui/bootstrap/components/accordion.rb +17 -14
  4. data/app/concepts/matestack/ui/bootstrap/components/alert.rb +1 -1
  5. data/app/concepts/matestack/ui/bootstrap/components/badge.rb +4 -4
  6. data/app/concepts/matestack/ui/bootstrap/components/breadcrumb.rb +8 -6
  7. data/app/concepts/matestack/ui/bootstrap/components/button.rb +18 -3
  8. data/app/concepts/matestack/ui/bootstrap/components/carousel.rb +15 -14
  9. data/app/concepts/matestack/ui/bootstrap/components/close.rb +1 -1
  10. data/app/concepts/matestack/ui/bootstrap/components/collapse.rb +6 -6
  11. data/app/concepts/matestack/ui/bootstrap/components/dropdown.rb +3 -2
  12. data/app/concepts/matestack/ui/bootstrap/components/list_group.rb +87 -25
  13. data/app/concepts/matestack/ui/bootstrap/components/modal.rb +1 -1
  14. data/app/concepts/matestack/ui/bootstrap/components/navbar.rb +54 -20
  15. data/app/concepts/matestack/ui/bootstrap/components/pagination.rb +5 -5
  16. data/app/concepts/matestack/ui/bootstrap/components/popover.rb +1 -1
  17. data/app/concepts/matestack/ui/bootstrap/components/progress.rb +7 -7
  18. data/app/concepts/matestack/ui/bootstrap/components/scrollspy.rb +15 -0
  19. data/app/concepts/matestack/ui/bootstrap/components/spinner.rb +1 -1
  20. data/app/concepts/matestack/ui/bootstrap/components/tab_nav.rb +4 -2
  21. data/app/concepts/matestack/ui/bootstrap/components/toast.js +7 -1
  22. data/app/concepts/matestack/ui/bootstrap/components/tooltip.rb +8 -26
  23. data/app/concepts/matestack/ui/bootstrap/content/{collection → smart_collection}/collection.rb +18 -16
  24. data/app/concepts/matestack/ui/bootstrap/content/{collection → smart_collection}/collection.scss +0 -0
  25. data/app/concepts/matestack/ui/bootstrap/content/{collection → smart_collection}/content.rb +3 -3
  26. data/app/concepts/matestack/ui/bootstrap/content/{collection → smart_collection}/filter.rb +3 -3
  27. data/app/concepts/matestack/ui/bootstrap/content/{collection → smart_collection}/paginate.rb +3 -3
  28. data/app/concepts/matestack/ui/bootstrap/form/checkbox.rb +55 -46
  29. data/app/concepts/matestack/ui/bootstrap/form/input.rb +5 -16
  30. data/app/concepts/matestack/ui/bootstrap/form/radio.rb +22 -30
  31. data/app/concepts/matestack/ui/bootstrap/form/select.rb +12 -33
  32. data/app/concepts/matestack/ui/bootstrap/form/submit.rb +3 -2
  33. data/app/concepts/matestack/ui/bootstrap/form/switch.rb +80 -71
  34. data/app/concepts/matestack/ui/bootstrap/registry.rb +2 -4
  35. data/app/helpers/matestack/ui/bootstrap/application_helper.rb +9 -5
  36. data/app/javascript/matestack-ui-bootstrap/index.js +1 -3
  37. data/app/matestack/bootstrap/form/submit.rb +20 -0
  38. data/lib/matestack/ui/bootstrap/engine.rb +2 -2
  39. data/lib/matestack/ui/bootstrap/version.rb +1 -1
  40. data/lib/tasks/matestack/ui/bootstrap_tasks.rake +25 -25
  41. metadata +8 -12
  42. data/app/concepts/matestack/ui/bootstrap/components/chart.js +0 -232
  43. data/app/concepts/matestack/ui/bootstrap/components/chart.rb +0 -71
  44. data/app/concepts/matestack/ui/bootstrap/form/date.js +0 -38
  45. data/app/concepts/matestack/ui/bootstrap/form/date.rb +0 -98
  46. data/app/concepts/matestack/ui/bootstrap/form/select.haml +0 -11
@@ -1,4 +1,4 @@
1
- module Matestack::Ui::Bootstrap::Content::Collection::Paginate
1
+ module Matestack::Ui::Bootstrap::Content::SmartCollection::Paginate
2
2
 
3
3
  def paginate_partial
4
4
  div class: "current-pagination-state ps-2" do
@@ -17,7 +17,7 @@ module Matestack::Ui::Bootstrap::Content::Collection::Paginate
17
17
  def pagination_nav_partial
18
18
  nav class: "table-responsive", attributes: { style: "display: -webkit-box;" } do
19
19
  ul class: ul_classes do
20
- li class: "page-item #{ 'disabled' if current_page == 1 }" do
20
+ li class: "page-item previous #{ 'disabled' if current_page == 1 }" do
21
21
  collection_content_previous class: 'page-link' do
22
22
  bs_icon name: "chevron-left", size: 10
23
23
  end
@@ -59,7 +59,7 @@ module Matestack::Ui::Bootstrap::Content::Collection::Paginate
59
59
  end
60
60
  end
61
61
  end
62
- li class: "page-item #{ 'disabled' if current_page == last_page }" do
62
+ li class: "page-item next #{ 'disabled' if current_page == last_page }" do
63
63
  collection_content_next class: 'page-link' do
64
64
  bs_icon name: "chevron-right", size: 10
65
65
  end
@@ -1,73 +1,78 @@
1
- class Matestack::Ui::Bootstrap::Form::Checkbox < Matestack::Ui::Core::Form::Checkbox::Checkbox
1
+ class Matestack::Ui::Bootstrap::Form::Checkbox < Matestack::Ui::Core::Form::Checkbox::Base
2
+
3
+ vue_js_component_name "matestack-ui-core-form-checkbox"
2
4
 
3
5
  optional :form_text
4
6
  optional :disabled
5
7
  optional :variant
6
8
 
7
9
  def response
8
- if !checkbox_options.empty?
9
- label for: attr_key, class: "form-label", text: input_label if input_label
10
- end
11
- if !checkbox_options.empty?
12
- multiple_checkboxes
13
- else
14
- true_false_checkbox
10
+ div class: "matestack-ui-bootstrap-form-checkbox" do
11
+ label class: "form-label", text: input_label, for: attr_key if input_label && multiple?
12
+ render_options
13
+ render_errors
14
+ render_form_text unless form_text.nil? # otherwise renders empty div
15
15
  end
16
- render_form_text
17
16
  end
18
17
 
19
18
  private
20
19
 
21
- def checkbox_wrapper(options = {}, &block)
22
- div class: "form-check #{'form-check-inline' if variant == :inline}", attributes: options[:attributes] do
23
- yield
24
- end
20
+ def multiple?
21
+ options[:options].present?
25
22
  end
26
23
 
27
- def bootstrap_label(text:, for_input:)
28
- label text: text, for: for_input, class: 'form-check-label'
29
- end
30
-
31
- def true_false_checkbox
32
- checkbox_wrapper do
33
- form_input type: :hidden, key: key, value: (false_value || 0), errors: false
34
- input html_attributes.merge(
35
- type: :checkbox,
36
- id: "#{id_for_item(value)}",
37
- name: item_name(key),
38
- value: checked_value,
39
- class: 'form-check-input',
40
- disabled: disabled,
41
- attributes: vue_attributes.merge(
42
- ref: "input.#{attr_key}",
24
+ def render_options
25
+ # multiple
26
+ if multiple?
27
+ options[:options].to_a.each do |item|
28
+ checkbox_wrapper do
29
+ input html_attributes.merge(
30
+ attributes: vue_attributes,
31
+ type: :checkbox,
32
+ id: "#{id_for_item(item_value(item))}",
33
+ name: item_name(item),
34
+ value: item_value(item),
35
+ class: 'form-check-input'
36
+ )
37
+ bootstrap_label text: item_name(item), for_input: id_for_item(item_value(item))
38
+ end
39
+ end
40
+ # checked/unchecked checkbox (true/false checkbox)
41
+ else
42
+ checkbox_wrapper do
43
+ input html_attributes.merge(
44
+ attributes: vue_attributes_for_single_input,
45
+ type: :hidden,
46
+ value: (false_value || 0),
47
+ class: 'form-check-input'
43
48
  )
44
- )
45
- bootstrap_label text: input_label, for_input: id_for_item(value)
46
- render_errors
47
- end
48
- end
49
49
 
50
- def multiple_checkboxes
51
- checkbox_options.to_a.each do |item|
52
- checkbox_wrapper do
53
50
  input html_attributes.merge(
51
+ attributes: vue_attributes_for_single_input,
54
52
  type: :checkbox,
55
- id: "#{id_for_item(item_value(item))}",
56
- name: item_name(item),
57
- value: item_value(item),
58
- class: 'form-check-input',
59
- disabled: disabled,
60
- attributes: vue_attributes
53
+ id: id_for_item(value),
54
+ value: checked_value,
55
+ class: 'form-check-input'
61
56
  )
62
- bootstrap_label text: item_name(item), for_input: id_for_item(item_value(item))
63
- render_errors if checkbox_options.to_a.last == item
57
+
58
+ bootstrap_label text: input_label, for_input: id_for_item(value)
64
59
  end
65
60
  end
66
61
  end
67
62
 
63
+ def checkbox_wrapper(options = {}, &block)
64
+ div class: "form-check #{'form-check-inline' if variant == :inline}", attributes: options[:attributes] do
65
+ yield
66
+ end
67
+ end
68
+
69
+ def bootstrap_label(text:, for_input:)
70
+ label text: text, for: for_input, class: 'form-check-label'
71
+ end
72
+
68
73
  def render_errors
69
74
  unless @included_config[:errors] == false && (errors == false || errors.nil?) || errors == false
70
- div class: 'invalid-feedback', attributes: { 'v-for': "error in #{error_key}" } do
75
+ div class: 'invalid-feedback', attributes: { 'v-for': "error in #{error_key}", style: "display: block;" } do
71
76
  plain '{{ error }}'
72
77
  end
73
78
  end
@@ -87,4 +92,8 @@ class Matestack::Ui::Bootstrap::Form::Checkbox < Matestack::Ui::Core::Form::Chec
87
92
  end
88
93
  end
89
94
 
95
+ def id_for_item(value)
96
+ "#{html_attributes[:id]}_#{value}_#{attr_key}"
97
+ end
98
+
90
99
  end
@@ -1,4 +1,6 @@
1
- class Matestack::Ui::Bootstrap::Form::Input < Matestack::Ui::Core::Form::Input::Input
1
+ class Matestack::Ui::Bootstrap::Form::Input < Matestack::Ui::Core::Form::Input::Base
2
+
3
+ vue_js_component_name "matestack-ui-core-form-input"
2
4
 
3
5
  optional :form_text
4
6
  optional :disabled
@@ -11,7 +13,7 @@ class Matestack::Ui::Bootstrap::Form::Input < Matestack::Ui::Core::Form::Input::
11
13
  optional :show_value
12
14
 
13
15
  def response
14
- div do
16
+ div class: "matestack-ui-bootstrap-input" do
15
17
  label for: attr_key, class: "form-label", text: input_label if input_label
16
18
  case type
17
19
  when :range
@@ -31,22 +33,9 @@ class Matestack::Ui::Bootstrap::Form::Input < Matestack::Ui::Core::Form::Input::
31
33
  end
32
34
  end
33
35
 
34
- def vue_attributes
35
- (options[:attributes] || {}).merge({
36
- id: attr_key,
37
- "@change": change_event,
38
- ref: "input.#{attr_key}",
39
- 'init-value': init_value,
40
- 'v-bind:class': "{ '#{input_error_class}': #{error_key} }",
41
- "aria-describedby": attr_key,
42
- "step": "any"
43
- }).merge(
44
- type != :file ? { "#{v_model_type}": input_key } : {}
45
- ) # file inputs are readonly, no v-model possible
46
- end
47
-
48
36
  def bootstrap_input_attributes
49
37
  {
38
+ id: (options[:id] || attr_key),
50
39
  class: (options[:class] || "") << (" form-control"),
51
40
  disabled: disabled
52
41
  }
@@ -1,30 +1,34 @@
1
- class Matestack::Ui::Bootstrap::Form::Radio < Matestack::Ui::Core::Form::Radio::Radio
1
+ class Matestack::Ui::Bootstrap::Form::Radio < Matestack::Ui::Core::Form::Radio::Base
2
+
3
+ vue_js_component_name "matestack-ui-core-form-radio"
2
4
 
3
5
  optional :form_text
4
6
  optional :disabled
5
7
  optional :variant
6
8
 
7
9
  def response
8
- label class: "form-label", text: input_label if input_label
9
-
10
- radio_options.to_a.each_with_index do |item, index|
11
- div class: "form-check #{'form-check-inline' if variant == :inline}" do
12
- input html_attributes.merge(
13
- attributes: vue_attributes,
14
- type: :radio,
15
- id: "#{id_for_item(item_value(item))}",
16
- name: item_name(item),
17
- value: item_value(item),
18
- class: radio_class,
19
- disabled: disabled
20
- )
21
- label class: "form-check-label", text: item_label(item), for: id_for_item(item_value(item))
22
- if index == radio_options.to_a.size - 1
23
- render_errors
10
+ div class: "matestack-ui-bootstrap-radio" do
11
+ label class: "form-label", text: input_label if input_label
12
+
13
+ radio_options.to_a.each_with_index do |item, index|
14
+ div class: "form-check #{'form-check-inline' if variant == :inline}" do
15
+ input html_attributes.merge(
16
+ attributes: vue_attributes,
17
+ type: :radio,
18
+ id: "#{id_for_item(item_value(item))}",
19
+ name: item_name(item),
20
+ value: item_value(item),
21
+ class: radio_class,
22
+ disabled: disabled
23
+ )
24
+ label class: "form-check-label", text: item_label(item), for: id_for_item(item_value(item))
25
+ if index == radio_options.to_a.size - 1
26
+ render_errors
27
+ end
24
28
  end
25
29
  end
30
+ render_form_text if form_text
26
31
  end
27
- render_form_text if form_text
28
32
 
29
33
  end
30
34
 
@@ -32,17 +36,6 @@ class Matestack::Ui::Bootstrap::Form::Radio < Matestack::Ui::Core::Form::Radio::
32
36
  (options[:class] || "") << (" form-check-input")
33
37
  end
34
38
 
35
- def vue_attributes
36
- (options[:attributes] || {}).merge({
37
- "@change": change_event,
38
- ref: "select.#{attr_key}",
39
- 'init-value': init_value,
40
- 'v-bind:class': "{ '#{input_error_class}': #{error_key} }",
41
- 'value-type': value_type,
42
- "#{v_model_type}": input_key,
43
- })
44
- end
45
-
46
39
  def render_form_text
47
40
  div id: "form_text_for_#{attr_key}", class: "form-text" do
48
41
  plain form_text
@@ -61,5 +54,4 @@ class Matestack::Ui::Bootstrap::Form::Radio < Matestack::Ui::Core::Form::Radio::
61
54
  'is-invalid'
62
55
  end
63
56
 
64
-
65
57
  end
@@ -1,21 +1,20 @@
1
- class Matestack::Ui::Bootstrap::Form::Select < Matestack::Ui::Core::Form::Select::Select
1
+ class Matestack::Ui::Bootstrap::Form::Select < Matestack::Ui::Core::Form::Select::Base
2
+
3
+ vue_js_component_name "matestack-ui-core-form-select"
2
4
 
3
5
  optional :variant
4
6
  optional :size
5
7
  optional :form_text
6
8
 
7
- def vue_attributes
8
- (options[:attributes] || {}).merge({
9
- "@change": change_event,
10
- ref: vue_ref,
11
- 'init-value': determine_init_value,
12
- 'v-bind:class': "{ '#{input_error_class}': #{error_key} }",
13
- 'value-type': value_type,
14
- 'class': form_select_class,
15
- 'size': size_class,
16
- 'id': attr_key,
17
- "#{v_model_type}": input_key,
18
- })
9
+ def response
10
+ div class: "matestack-ui-bootstrap-form-select" do
11
+ label for: attr_key, class: "form-label", text: input_label if input_label
12
+ select select_attributes.merge({ id: (options[:id] || attr_key), class: form_select_class, size: size_class }) do
13
+ render_options
14
+ end
15
+ render_errors
16
+ render_form_text
17
+ end
19
18
  end
20
19
 
21
20
  def form_select_class
@@ -33,26 +32,6 @@ class Matestack::Ui::Bootstrap::Form::Select < Matestack::Ui::Core::Form::Select
33
32
  size
34
33
  end
35
34
 
36
- def determine_init_value
37
- if init_value
38
- init_value
39
- else
40
- if multiple
41
- []
42
- else
43
- nil
44
- end
45
- end
46
- end
47
-
48
- def placeholder_value
49
- if multiple
50
- '[]'
51
- else
52
- 'null'
53
- end
54
- end
55
-
56
35
  def render_errors
57
36
  unless @included_config[:errors] == false && (errors == false || errors.nil?) || errors == false
58
37
  div class: 'invalid-feedback', attributes: { 'v-for': "error in #{error_key}" } do
@@ -4,13 +4,14 @@ class Matestack::Ui::Bootstrap::Form::Submit < Matestack::Ui::Component
4
4
  optional :spinner_variant
5
5
  optional :text
6
6
  optional :loading_text
7
+ optional :loading_class
7
8
 
8
9
  def response
9
10
  form_submit do
10
- bs_btn type: "submit", variant: button_variant || :primary, attributes: { "v-if": "!loading()" } do
11
+ bs_btn type: "submit", size: options[:size], class: "#{options[:class]}", variant: button_variant || :primary, attributes: { "v-if": "!loading()" } do
11
12
  plain text || "Submit"
12
13
  end
13
- bs_btn type: "submit", variant: button_variant || :primary, attributes: { disabled: true, "v-if": "loading()" } do
14
+ bs_btn type: "submit", size: options[:size], class: "#{options[:class]} #{loading_class}", variant: button_variant || :primary, attributes: { disabled: true, "v-if": "loading()" } do
14
15
  bs_spinner variant: spinner_variant || :light, size: :sm
15
16
  plain loading_text || "Loading..."
16
17
  end
@@ -1,19 +1,27 @@
1
- class Matestack::Ui::Bootstrap::Form::Switch < Matestack::Ui::Core::Form::Checkbox::Checkbox
1
+ class Matestack::Ui::Bootstrap::Form::Switch < Matestack::Ui::Bootstrap::Form::Checkbox
2
+
3
+ vue_js_component_name "matestack-ui-core-form-checkbox"
2
4
 
3
5
  optional :form_text
4
6
  optional :disabled
5
7
  optional :variant
6
8
 
7
9
  def response
8
- if !checkbox_options.empty?
9
- label for: attr_key, class: "form-label", text: input_label if input_label
10
- end
11
- if !checkbox_options.empty?
12
- multiple_switches
13
- else
14
- true_false_switch
10
+ div class: "matestack-ui-bootstrap-switch" do
11
+ label class: "form-label", text: input_label, for: attr_key if input_label && multiple?
12
+ render_options
13
+ render_errors
14
+ render_form_text unless form_text.nil? # otherwise renders empty div
15
+ # if !checkbox_options.empty?
16
+ # label for: attr_key, class: "form-label", text: input_label if input_label
17
+ # end
18
+ # if !checkbox_options.empty?
19
+ # multiple_switches
20
+ # else
21
+ # true_false_switch
22
+ # end
23
+ # render_form_text unless form_text.nil? # otherwise renders empty div
15
24
  end
16
- render_form_text
17
25
  end
18
26
 
19
27
  private
@@ -24,67 +32,68 @@ class Matestack::Ui::Bootstrap::Form::Switch < Matestack::Ui::Core::Form::Checkb
24
32
  end
25
33
  end
26
34
 
27
- def bs_label(text:, for_input:)
28
- label text: text, for: for_input, class: 'form-check-label'
29
- end
30
-
31
- def true_false_switch
32
- checkbox_wrapper do
33
- form_input type: :hidden, key: key, value: (false_value || 0), errors: false
34
- input html_attributes.merge(
35
- type: :checkbox,
36
- id: "#{id_for_item(value)}",
37
- name: item_name(key),
38
- value: checked_value,
39
- class: 'form-check-input',
40
- disabled: disabled,
41
- attributes: vue_attributes.merge(
42
- ref: "input.#{attr_key}",
43
- )
44
- )
45
- bs_label text: input_label, for_input: id_for_item(value)
46
- render_errors
47
- end
48
- end
49
-
50
- def multiple_switches
51
- checkbox_options.to_a.each do |item|
52
- checkbox_wrapper do
53
- input html_attributes.merge(
54
- type: :checkbox,
55
- id: "#{id_for_item(item_value(item))}",
56
- name: item_name(item),
57
- value: item_value(item),
58
- class: 'form-check-input',
59
- disabled: disabled,
60
- attributes: vue_attributes
61
- )
62
- bs_label text: item_name(item), for_input: id_for_item(item_value(item))
63
- render_errors if checkbox_options.to_a.last == item
64
- end
65
- end
66
- end
67
-
68
- def render_errors
69
- unless @included_config[:errors] == false && (errors == false || errors.nil?) || errors == false
70
- div class: 'invalid-feedback', attributes: { 'v-for': "error in #{error_key}" } do
71
- plain '{{ error }}'
72
- end
73
- end
74
- end
75
-
76
- def input_error_class
77
- 'is-invalid'
78
- end
79
-
80
- def checkbox_options
81
- super || {}
82
- end
83
-
84
- def render_form_text
85
- div id: "form_text_for_#{attr_key}", class: "form-text" do
86
- plain form_text
87
- end
88
- end
35
+ # def bs_label(text:, for_input:)
36
+ # label text: text, for: for_input, class: 'form-check-label'
37
+ # end
38
+ #
39
+ # def true_false_switch
40
+ # checkbox_wrapper do
41
+ # form_input type: :hidden, key: key, value: (false_value || 0), errors: false
42
+ # input html_attributes.merge(
43
+ # type: :checkbox,
44
+ # id: "#{id_for_item(value)}",
45
+ # # id: "#{key}", alternative to address the visible input field better?
46
+ # name: item_name(key),
47
+ # value: checked_value,
48
+ # class: 'form-check-input',
49
+ # disabled: disabled,
50
+ # attributes: vue_attributes.merge(
51
+ # ref: "input.#{attr_key}",
52
+ # )
53
+ # )
54
+ # bs_label text: input_label, for_input: id_for_item(value)
55
+ # render_errors
56
+ # end
57
+ # end
58
+ #
59
+ # def multiple_switches
60
+ # checkbox_options.to_a.each do |item|
61
+ # checkbox_wrapper do
62
+ # input html_attributes.merge(
63
+ # type: :checkbox,
64
+ # id: "#{id_for_item(item_value(item))}",
65
+ # name: item_name(item),
66
+ # value: item_value(item),
67
+ # class: 'form-check-input',
68
+ # disabled: disabled,
69
+ # attributes: vue_attributes
70
+ # )
71
+ # bs_label text: item_name(item), for_input: id_for_item(item_value(item))
72
+ # render_errors if checkbox_options.to_a.last == item
73
+ # end
74
+ # end
75
+ # end
76
+ #
77
+ # def render_errors
78
+ # unless @included_config[:errors] == false && (errors == false || errors.nil?) || errors == false
79
+ # div class: 'invalid-feedback', attributes: { 'v-for': "error in #{error_key}" } do
80
+ # plain '{{ error }}'
81
+ # end
82
+ # end
83
+ # end
84
+ #
85
+ # def input_error_class
86
+ # 'is-invalid'
87
+ # end
88
+ #
89
+ # def checkbox_options
90
+ # super || {}
91
+ # end
92
+ #
93
+ # def render_form_text
94
+ # div id: "form_text_for_#{attr_key}", class: "form-text" do
95
+ # plain form_text
96
+ # end
97
+ # end
89
98
 
90
99
  end