matestack-ui-bootstrap 1.5.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +17 -5
  3. data/lib/matestack/ui/bootstrap.rb +96 -17
  4. data/{app/concepts → lib}/matestack/ui/bootstrap/apps/admin_template.rb +14 -7
  5. data/lib/matestack/ui/bootstrap/base_component.rb +13 -0
  6. data/lib/matestack/ui/bootstrap/base_vue_js_component.rb +13 -0
  7. data/{app/concepts → lib}/matestack/ui/bootstrap/components/accordion.rb +18 -16
  8. data/{app/concepts → lib}/matestack/ui/bootstrap/components/alert.js +12 -9
  9. data/lib/matestack/ui/bootstrap/components/alert.rb +43 -0
  10. data/lib/matestack/ui/bootstrap/components/avatar.rb +27 -0
  11. data/lib/matestack/ui/bootstrap/components/badge.rb +32 -0
  12. data/{app/concepts → lib}/matestack/ui/bootstrap/components/breadcrumb.rb +12 -10
  13. data/lib/matestack/ui/bootstrap/components/button.rb +71 -0
  14. data/lib/matestack/ui/bootstrap/components/button_group.rb +36 -0
  15. data/lib/matestack/ui/bootstrap/components/card.rb +105 -0
  16. data/{app/concepts → lib}/matestack/ui/bootstrap/components/carousel.js +21 -18
  17. data/lib/matestack/ui/bootstrap/components/carousel.rb +103 -0
  18. data/{app/concepts → lib}/matestack/ui/bootstrap/components/close.rb +10 -9
  19. data/{app/concepts → lib}/matestack/ui/bootstrap/components/collapse.js +20 -17
  20. data/lib/matestack/ui/bootstrap/components/collapse.rb +54 -0
  21. data/{app/concepts → lib}/matestack/ui/bootstrap/components/dropdown.js +5 -2
  22. data/{app/concepts → lib}/matestack/ui/bootstrap/components/dropdown.rb +29 -25
  23. data/lib/matestack/ui/bootstrap/components/icon.rb +21 -0
  24. data/{app/concepts → lib}/matestack/ui/bootstrap/components/list_group.rb +32 -29
  25. data/{app/concepts → lib}/matestack/ui/bootstrap/components/modal.js +24 -21
  26. data/lib/matestack/ui/bootstrap/components/modal.rb +121 -0
  27. data/{app/concepts → lib}/matestack/ui/bootstrap/components/navbar.rb +37 -28
  28. data/{app/concepts → lib}/matestack/ui/bootstrap/components/page_heading.rb +7 -5
  29. data/{app/concepts → lib}/matestack/ui/bootstrap/components/pagination.rb +11 -9
  30. data/{app/concepts → lib}/matestack/ui/bootstrap/components/popover.js +4 -1
  31. data/{app/concepts → lib}/matestack/ui/bootstrap/components/popover.rb +25 -21
  32. data/{app/concepts → lib}/matestack/ui/bootstrap/components/progress.rb +19 -19
  33. data/lib/matestack/ui/bootstrap/components/scrollspy.rb +50 -0
  34. data/lib/matestack/ui/bootstrap/components/section_card.rb +33 -0
  35. data/lib/matestack/ui/bootstrap/components/spinner.rb +35 -0
  36. data/lib/matestack/ui/bootstrap/components/tab_nav.rb +79 -0
  37. data/lib/matestack/ui/bootstrap/components/tab_nav_content.rb +35 -0
  38. data/{app/concepts → lib}/matestack/ui/bootstrap/components/toast.js +22 -19
  39. data/lib/matestack/ui/bootstrap/components/toast.rb +113 -0
  40. data/{app/concepts → lib}/matestack/ui/bootstrap/components/tooltip.js +4 -1
  41. data/{app/concepts → lib}/matestack/ui/bootstrap/components/tooltip.rb +20 -18
  42. data/{app/concepts → lib}/matestack/ui/bootstrap/content/figure.rb +4 -2
  43. data/{app/concepts → lib}/matestack/ui/bootstrap/content/smart_collection/collection.rb +22 -16
  44. data/{app/concepts → lib}/matestack/ui/bootstrap/content/smart_collection/collection.scss +0 -0
  45. data/{app/concepts → lib}/matestack/ui/bootstrap/content/smart_collection/content.rb +23 -19
  46. data/{app/concepts → lib}/matestack/ui/bootstrap/content/smart_collection/filter.rb +6 -2
  47. data/{app/concepts → lib}/matestack/ui/bootstrap/content/smart_collection/paginate.rb +16 -11
  48. data/lib/matestack/ui/bootstrap/form/checkbox.rb +81 -0
  49. data/lib/matestack/ui/bootstrap/form/input.rb +116 -0
  50. data/lib/matestack/ui/bootstrap/form/radio.rb +55 -0
  51. data/lib/matestack/ui/bootstrap/form/select.rb +63 -0
  52. data/lib/matestack/ui/bootstrap/form/submit.rb +20 -0
  53. data/lib/matestack/ui/bootstrap/form/switch.rb +32 -0
  54. data/lib/matestack/ui/bootstrap/index.js +24 -0
  55. data/lib/matestack/ui/bootstrap/layout/column.rb +49 -0
  56. data/{app/concepts → lib}/matestack/ui/bootstrap/layout/container.rb +12 -9
  57. data/lib/matestack/ui/bootstrap/layout/row.rb +25 -0
  58. data/{app/concepts → lib}/matestack/ui/bootstrap/layout/sidebar.js +5 -2
  59. data/{app/concepts → lib}/matestack/ui/bootstrap/layout/sidebar.rb +10 -10
  60. data/{app/concepts → lib}/matestack/ui/bootstrap/layout/sidebar.scss +0 -0
  61. data/lib/matestack/ui/bootstrap/registry.rb +169 -0
  62. data/{app/javascript/matestack-ui-bootstrap → lib/matestack/ui/bootstrap}/stylesheets/matestack-ui-bootstrap.scss +0 -0
  63. data/lib/matestack/ui/bootstrap/version.rb +1 -1
  64. metadata +67 -72
  65. data/app/assets/images/avatar-placeholder.png +0 -0
  66. data/app/assets/images/icons/bootstrap-icons.svg +0 -1
  67. data/app/concepts/matestack/ui/bootstrap/components/alert.rb +0 -34
  68. data/app/concepts/matestack/ui/bootstrap/components/avatar.rb +0 -27
  69. data/app/concepts/matestack/ui/bootstrap/components/badge.rb +0 -30
  70. data/app/concepts/matestack/ui/bootstrap/components/button.rb +0 -69
  71. data/app/concepts/matestack/ui/bootstrap/components/button_group.rb +0 -36
  72. data/app/concepts/matestack/ui/bootstrap/components/card.rb +0 -100
  73. data/app/concepts/matestack/ui/bootstrap/components/carousel.rb +0 -86
  74. data/app/concepts/matestack/ui/bootstrap/components/collapse.rb +0 -43
  75. data/app/concepts/matestack/ui/bootstrap/components/icon.rb +0 -19
  76. data/app/concepts/matestack/ui/bootstrap/components/modal.rb +0 -106
  77. data/app/concepts/matestack/ui/bootstrap/components/scrollspy.rb +0 -48
  78. data/app/concepts/matestack/ui/bootstrap/components/section_card.rb +0 -31
  79. data/app/concepts/matestack/ui/bootstrap/components/spinner.rb +0 -31
  80. data/app/concepts/matestack/ui/bootstrap/components/tab_nav.rb +0 -83
  81. data/app/concepts/matestack/ui/bootstrap/components/tab_nav_content.rb +0 -32
  82. data/app/concepts/matestack/ui/bootstrap/components/toast.rb +0 -99
  83. data/app/concepts/matestack/ui/bootstrap/form/checkbox.rb +0 -99
  84. data/app/concepts/matestack/ui/bootstrap/form/input.rb +0 -112
  85. data/app/concepts/matestack/ui/bootstrap/form/radio.rb +0 -57
  86. data/app/concepts/matestack/ui/bootstrap/form/select.rb +0 -53
  87. data/app/concepts/matestack/ui/bootstrap/form/submit.rb +0 -21
  88. data/app/concepts/matestack/ui/bootstrap/form/switch.rb +0 -99
  89. data/app/concepts/matestack/ui/bootstrap/layout/column.rb +0 -47
  90. data/app/concepts/matestack/ui/bootstrap/layout/row.rb +0 -15
  91. data/app/concepts/matestack/ui/bootstrap/pages/devise/sign_in.rb +0 -40
  92. data/app/concepts/matestack/ui/bootstrap/registry.rb +0 -61
  93. data/app/helpers/matestack/ui/bootstrap/application_helper.rb +0 -17
  94. data/app/javascript/matestack-ui-bootstrap/index.js +0 -24
  95. data/app/javascript/packs/matestack-ui-bootstrap.js +0 -2
  96. data/app/matestack/bootstrap/form/submit.rb +0 -20
  97. data/config/routes.rb +0 -2
  98. data/lib/matestack/ui/bootstrap/engine.rb +0 -26
@@ -1,6 +1,9 @@
1
1
  import * as bootstrap from 'bootstrap'
2
+ import Vue from 'vue/dist/vue.esm'
2
3
 
3
- MatestackUiCore.Vue.component('matestack-ui-bootstrap-modal', {
4
+ import MatestackUiCore from 'matestack-ui-core'
5
+
6
+ Vue.component('matestack-ui-bootstrap-modal', {
4
7
  mixins: [MatestackUiCore.componentMixin],
5
8
 
6
9
  data() {
@@ -37,28 +40,28 @@ MatestackUiCore.Vue.component('matestack-ui-bootstrap-modal', {
37
40
  const self = this
38
41
  var eventHub = MatestackUiCore.matestackEventHub;
39
42
  // toggle_on event registration
40
- if(self.componentConfig["toggle_on"] != undefined){
41
- var toggle_events = self.componentConfig["toggle_on"].split(",")
43
+ if(self.props["toggle_on"] != undefined){
44
+ var toggle_events = self.props["toggle_on"].split(",")
42
45
  toggle_events.forEach(toggle_event => eventHub.$on(toggle_event.trim(), self.toggle));
43
46
  }
44
47
  // show_on event registration
45
- if(self.componentConfig["show_on"] != undefined){
46
- var show_events = self.componentConfig["show_on"].split(",")
48
+ if(self.props["show_on"] != undefined){
49
+ var show_events = self.props["show_on"].split(",")
47
50
  show_events.forEach(show_event => eventHub.$on(show_event.trim(), self.show));
48
51
  }
49
52
  // hide_on event registration
50
- if(self.componentConfig["hide_on"] != undefined){
51
- var hide_events = self.componentConfig["hide_on"].split(",")
53
+ if(self.props["hide_on"] != undefined){
54
+ var hide_events = self.props["hide_on"].split(",")
52
55
  hide_events.forEach(hide_event => eventHub.$on(hide_event.trim(), self.hide));
53
56
  }
54
57
  // handle_update_on event registration
55
- if(self.componentConfig["handle_update_on"] != undefined){
56
- var handle_update_events = self.componentConfig["handle_update_on"].split(",")
58
+ if(self.props["handle_update_on"] != undefined){
59
+ var handle_update_events = self.props["handle_update_on"].split(",")
57
60
  handle_update_events.forEach(handle_update_event => eventHub.$on(handle_update_event.trim(), self.handle_update));
58
61
  }
59
62
  // dispose_on event registration
60
- if(self.componentConfig["dispose_on"] != undefined){
61
- var dispose_events = self.componentConfig["dispose_on"].split(",")
63
+ if(self.props["dispose_on"] != undefined){
64
+ var dispose_events = self.props["dispose_on"].split(",")
62
65
  dispose_events.forEach(dispose_event => eventHub.$on(dispose_event.trim(), self.dispose));
63
66
  }
64
67
  },
@@ -66,24 +69,24 @@ MatestackUiCore.Vue.component('matestack-ui-bootstrap-modal', {
66
69
  beforeDestroy: function() {
67
70
  const self = this
68
71
  var eventHub = MatestackUiCore.matestackEventHub;
69
- if(self.componentConfig["toggle_on"] != undefined){
70
- var toggle_events = self.componentConfig["toggle_on"].split(",")
72
+ if(self.props["toggle_on"] != undefined){
73
+ var toggle_events = self.props["toggle_on"].split(",")
71
74
  toggle_events.forEach(toggle_event => eventHub.$off(toggle_event.trim(), self.toggle));
72
75
  }
73
- if(self.componentConfig["show_on"] != undefined){
74
- var show_events = self.componentConfig["show_on"].split(",")
76
+ if(self.props["show_on"] != undefined){
77
+ var show_events = self.props["show_on"].split(",")
75
78
  show_events.forEach(show_event => eventHub.$off(show_event.trim(), self.show));
76
79
  }
77
- if(self.componentConfig["hide_on"] != undefined){
78
- var hide_events = self.componentConfig["hide_on"].split(",")
80
+ if(self.props["hide_on"] != undefined){
81
+ var hide_events = self.props["hide_on"].split(",")
79
82
  hide_events.forEach(hide_event => eventHub.$off(hide_event.trim(), self.hide));
80
83
  }
81
- if(self.componentConfig["handle_update_on"] != undefined){
82
- var handle_update_events = self.componentConfig["handle_update_on"].split(",")
84
+ if(self.props["handle_update_on"] != undefined){
85
+ var handle_update_events = self.props["handle_update_on"].split(",")
83
86
  handle_update_events.forEach(handle_update_event => eventHub.$off(handle_update_event.trim(), self.handle_update));
84
87
  }
85
- if(self.componentConfig["dispose_on"] != undefined){
86
- var dispose_events = self.componentConfig["dispose_on"].split(",")
88
+ if(self.props["dispose_on"] != undefined){
89
+ var dispose_events = self.props["dispose_on"].split(",")
87
90
  dispose_events.forEach(dispose_event => eventHub.$off(dispose_event.trim(), self.dispose));
88
91
  }
89
92
  },
@@ -0,0 +1,121 @@
1
+ require_relative "../base_vue_js_component"
2
+
3
+ class Matestack::Ui::Bootstrap::Components::Modal < Matestack::Ui::Bootstrap::BaseVueJsComponent
4
+ vue_name 'matestack-ui-bootstrap-modal'
5
+
6
+ # header attributes, expects a hash or string
7
+ # possible keys `:class, :text, :size`
8
+ optional :header
9
+ # body attributes, expects a hash or string
10
+ # possible keys `:class, :text`
11
+ optional :body
12
+ # footer is a dismiss button, expects a hash or string for button text
13
+ # possible keys `:class, :text`
14
+ optional :footer
15
+ optional :fade, :size
16
+ optional :fullscreen # fullscreen attribute, expects boolean or bootstrap breakpoint
17
+ optional :static, :keyboard, :scrollable, :centered
18
+ optional :modal_dialog_class
19
+ optional :id
20
+ # event trigger
21
+ optional :toggle_on, :show_on, :hide_on, :handle_update_on, :dispose_on
22
+
23
+
24
+
25
+ def response
26
+ div modal_attributes do
27
+ div class: dialog_classes do
28
+ div class: "modal-content" do
29
+ header_partial if context.header || (slots && slots[:header])
30
+ body_partial if context.body || slots && slots[:body]
31
+ footer_partial if context.footer || (slots && slots[:footer])
32
+ yield if block_given?
33
+ end
34
+ end
35
+ end
36
+ end
37
+
38
+ protected
39
+
40
+ def vue_props
41
+ {}.tap do |props|
42
+ props[:toggle_on] = context.toggle_on
43
+ props[:show_on] = context.show_on
44
+ props[:hide_on] = context.hide_on
45
+ props[:handle_update_on] = context.handle_update_on
46
+ props[:dispose_on] = context.dispose_on
47
+ end
48
+ end
49
+
50
+ def header_partial
51
+ header = context.header.is_a?(Hash) ? context.header : { text: context.header }
52
+ div class: "modal-header" do
53
+ if slots && slots[:header]
54
+ slot :header
55
+ else
56
+ heading header[:text], size: (header[:size] || 5), class: "modal-title #{header[:class]}" if header[:text].present?
57
+ bs_close dismiss: 'modal'
58
+ end
59
+ end
60
+ end
61
+
62
+ def body_partial
63
+ body = context.body.is_a?(Hash) ? context.body : { text: context.body }
64
+ div class: "modal-body #{body[:class]}".strip do
65
+ if slots && slots[:body]
66
+ slot :body
67
+ else
68
+ plain body[:text] if body[:text].present?
69
+ end
70
+ end
71
+ end
72
+
73
+ def footer_partial
74
+ footer = context.footer.is_a?(Hash) ? context.footer : { text: context.footer }
75
+ div class: "modal-footer" do
76
+ slot :footer if slots && slots[:footer]
77
+ if footer[:text].present?
78
+ button class: "btn #{footer[:class].present? ? footer[:class] : 'btn-secondary'}",
79
+ data: { "bs-dismiss": 'modal' }, type: 'button' do
80
+ plain footer[:text]
81
+ end
82
+ end
83
+ end
84
+ end
85
+
86
+ def modal_attributes
87
+ attributes = {}.tap do |hash|
88
+ hash[:id] = context.id
89
+ hash[:class] = modal_classes
90
+ hash[:attributes] = { 'tabindex': "-1", 'aria-labelledby': "#{context.id}Label", 'aria-hidden': "true" }
91
+ hash[:data] = {}.tap do |data|
92
+ data[:backdrop] = "static" if context.static
93
+ data[:keyboard] = "false" if context.keyboard
94
+ end
95
+ end
96
+ options.merge(
97
+ attributes
98
+ )
99
+ end
100
+
101
+ def modal_classes
102
+ [].tap do |classes|
103
+ classes << 'modal'
104
+ classes << 'fade' if context.fade || !context.fade.present?
105
+ classes << context.bs_class
106
+ end.join(' ').strip
107
+ end
108
+
109
+ def dialog_classes
110
+ [].tap do |classes|
111
+ classes << 'modal-dialog'
112
+ classes << 'modal-dialog-centered' if context.centered
113
+ classes << 'modal-dialog-scrollable' if context.scrollable
114
+ classes << "modal-#{context.size}" if context.size
115
+ if context.fullscreen.present?
116
+ classes << (context.fullscreen == true ? 'modal-fullscreen' : "modal-fullscreen-#{context.fullscreen}-down")
117
+ end
118
+ classes << context.modal_dialog_class
119
+ end.join(' ').strip
120
+ end
121
+ end
@@ -1,9 +1,11 @@
1
- class Matestack::Ui::Bootstrap::Components::Navbar < Matestack::Ui::Component
1
+ require_relative "../base_component"
2
+
3
+ class Matestack::Ui::Bootstrap::Components::Navbar < Matestack::Ui::Bootstrap::BaseComponent
2
4
 
3
5
  POS_ATTRIBUTES = %i[fixed_top fixed_bottom sticky_top]
4
6
  optional *POS_ATTRIBUTES
5
7
 
6
- optional class: { as: :bs_class }
8
+ optional class: { as: :bs_class }
7
9
  optional :items, :items_class, :theme, :expand_at, :color, :container_size
8
10
  optional :collapse_class
9
11
  # brand expect hash or string, possible keys for hash: text, path, img
@@ -12,21 +14,22 @@ class Matestack::Ui::Bootstrap::Components::Navbar < Matestack::Ui::Component
12
14
  # possible keys for hash: position, class
13
15
  optional :toggle
14
16
 
17
+
15
18
  def prepare
16
- @toggle = self.toggle.is_a?(Hash) ? self.toggle : { position: self.toggle }
19
+ @toggle = context.toggle.is_a?(Hash) ? context.toggle : { position: context.toggle }
17
20
  end
18
21
 
19
- def response
22
+ def response(&block)
20
23
  nav navbar_attributes do
21
- bs_container size: "#{container_size.present? ? container_size : "fluid" }" do
24
+ bs_container size: "#{context.container_size.present? ? context.container_size : "fluid" }" do
22
25
  # custom elements for navbar
23
- if options[:slots] && options[:slots][:custom_items]
24
- slot options[:slots][:custom_items]
26
+ if slots && slots[:custom_items]
27
+ slot :custom_items
25
28
  else
26
29
  toggle_button if @toggle[:position] == :left
27
30
  brand_partial
28
31
  toggle_button if !@toggle[:position].present? || @toggle[:position] == :right
29
- navbar_content_partial
32
+ navbar_content_partial(&block)
30
33
  end
31
34
  end
32
35
  end
@@ -35,51 +38,57 @@ class Matestack::Ui::Bootstrap::Components::Navbar < Matestack::Ui::Component
35
38
  protected
36
39
 
37
40
  def brand_partial
38
- brand = self.brand.is_a?(Hash) ? self.brand : { text: self.brand }
41
+ brand = context.brand.is_a?(Hash) ? context.brand : { text: context.brand }
39
42
  path = brand[:path].present? ? brand[:path] : "/"
40
43
  brand[:path] = path
41
44
  case brand[:type]
42
45
  when :link
43
- link brand.except(:text).merge(class: "navbar-brand") do
44
- img height: 40, path: brand[:img], attributes: { loading: "lazy" } if brand[:img].present?
46
+ a brand.except(:text).merge(class: "navbar-brand") do
47
+ img height: 40, path: brand[:img], loading: "lazy" if brand[:img].present?
45
48
  plain brand[:text]
46
49
  end
47
50
  else
48
51
  transition brand.except(:text).merge(class: "navbar-brand") do
49
- img height: 40, path: brand[:img], attributes: { loading: "lazy" } if brand[:img].present?
52
+ img height: 40, path: brand[:img], loading: "lazy" if brand[:img].present?
50
53
  plain brand[:text]
51
54
  end
52
55
  end
53
56
  end
54
57
 
55
- def navbar_content_partial
56
- div class: "collapse navbar-collapse #{collapse_class}", id: 'matestackNavbarContent' do
57
- if items.present?
58
+ def navbar_content_partial(&block)
59
+ div class: "collapse navbar-collapse #{context.collapse_class}", id: 'matestackNavbarContent' do
60
+ if context.items.present?
58
61
  ul class: items_classes do
59
- items.each do |item|
62
+ context.items.each do |item|
60
63
  li class: "nav-item" do
61
64
  case item[:type]
62
65
  when :link
63
- link link_config(item) do
66
+ a link_config(item) do
64
67
  bs_icon name: item[:icon], size: 20 if item[:icon]
65
- span class: "ps-3", text: item[:text] if item[:text]
68
+ span class: "ps-3" do
69
+ plain item[:text] if item[:text]
70
+ end
66
71
  end
67
72
  when :action
68
73
  action action_config(item) do
69
74
  bs_icon name: item[:icon], size: 20 if item[:icon]
70
- span class: "ps-3", text: item[:text] if item[:text]
75
+ span class: "ps-3" do
76
+ plain item[:text] if item[:text]
77
+ end
71
78
  end
72
79
  else
73
80
  transition transition_config(item) do
74
81
  bs_icon name: item[:icon], size: 20 if item[:icon]
75
- span class: "ps-3", text: item[:text] if item[:text]
82
+ span class: "ps-3" do
83
+ plain item[:text] if item[:text]
84
+ end
76
85
  end
77
86
  end
78
87
  end
79
88
  end
80
89
  end
81
90
  end
82
- yield_components
91
+ yield if block_given?
83
92
  end
84
93
  end
85
94
 
@@ -102,7 +111,7 @@ class Matestack::Ui::Bootstrap::Components::Navbar < Matestack::Ui::Component
102
111
  end
103
112
 
104
113
  def navbar_attributes
105
- html_attributes.merge(
114
+ options.merge(
106
115
  class: navbar_classes
107
116
  )
108
117
  end
@@ -111,12 +120,12 @@ class Matestack::Ui::Bootstrap::Components::Navbar < Matestack::Ui::Component
111
120
  [].tap do |classes|
112
121
  classes << "navbar"
113
122
  POS_ATTRIBUTES.each do |pos|
114
- classes << "#{pos}".gsub('_','-') if self.send("#{pos}")
123
+ classes << "#{pos}".gsub('_','-') if context.send("#{pos}")
115
124
  end
116
- classes << "navbar-expand-#{ (expand_at.present? ? expand_at : "lg") }"
117
- classes << "navbar-#{theme}" if theme.present?
118
- classes << (color.present? ? "bg-#{color}" : "bg-#{theme}") if theme || color
119
- classes << bs_class
125
+ classes << "navbar-expand-#{ (context.expand_at.present? ? context.expand_at : "lg") }"
126
+ classes << "navbar-#{context.theme}" if context.theme.present?
127
+ classes << (context.color.present? ? "bg-#{context.color}" : "bg-#{context.theme}") if context.theme || context.color
128
+ classes << context.bs_class
120
129
  end.join(' ').strip
121
130
  end
122
131
 
@@ -147,7 +156,7 @@ class Matestack::Ui::Bootstrap::Components::Navbar < Matestack::Ui::Component
147
156
  def items_classes
148
157
  [].tap do |classes|
149
158
  classes << 'navbar-nav'
150
- classes << (items_class.present? ? items_class : "ms-auto mb-2 mb-lg-0")
159
+ classes << (context.items_class.present? ? context.items_class : "ms-auto mb-2 mb-lg-0")
151
160
  # classes << "ms-auto" unless items_class.present?
152
161
  end.join(' ').strip
153
162
  end
@@ -1,4 +1,6 @@
1
- class Matestack::Ui::Bootstrap::Components::PageHeading < Matestack::Ui::Component
1
+ require_relative "../base_component"
2
+
3
+ class Matestack::Ui::Bootstrap::Components::PageHeading < Matestack::Ui::Bootstrap::BaseComponent
2
4
 
3
5
  optional :title, :subtitle, :icon
4
6
 
@@ -8,17 +10,17 @@ class Matestack::Ui::Bootstrap::Components::PageHeading < Matestack::Ui::Compone
8
10
  bs_col do
9
11
  div class: "page-heading-heading" do
10
12
  heading size: 2 do
11
- bs_icon name: icon, size: "35" if icon.present?
12
- plain title
13
+ bs_icon name: context.icon, size: "35" if context.icon.present?
14
+ plain context.title
13
15
  end
14
16
  heading size: 6, class: "text-muted" do
15
- plain subtitle
17
+ plain context.subtitle
16
18
  end
17
19
  end
18
20
  end
19
21
  bs_col md: 12, xl: 4, class: "text-xl-end mt-3" do
20
22
  div class: "page-heading-actions text-xl-end" do
21
- yield_components
23
+ yield if block_given?
22
24
  end
23
25
  end
24
26
  end
@@ -1,23 +1,25 @@
1
- class Matestack::Ui::Bootstrap::Components::Pagination < Matestack::Ui::Component
1
+ require_relative "../base_component"
2
2
 
3
- optional :aria_label, :size, class: { as: :bs_class }
3
+ class Matestack::Ui::Bootstrap::Components::Pagination < Matestack::Ui::Bootstrap::BaseComponent
4
+
5
+ optional :aria_label, :size
4
6
  optional :items
5
7
 
6
8
  def response
7
9
  nav pagination_attributes do
8
10
  ul class: ul_classes do
9
- if items.present?
10
- items.each do |item|
11
+ if context.items.present?
12
+ context.items.each do |item|
11
13
  li class: "page-item #{ 'active' if item[:active] }" do
12
14
  if item[:type] == :link
13
- link item.merge({ class: 'page-link' })
15
+ a item.merge({ class: 'page-link' })
14
16
  else
15
17
  transition item.merge({ class: 'page-link' })
16
18
  end
17
19
  end
18
20
  end
19
21
  end
20
- yield_components
22
+ yield if block_given?
21
23
  end
22
24
  end
23
25
  end
@@ -25,15 +27,15 @@ class Matestack::Ui::Bootstrap::Components::Pagination < Matestack::Ui::Componen
25
27
  protected
26
28
 
27
29
  def pagination_attributes
28
- html_attributes.merge(
29
- attributes: { 'aria-label': "#{aria_label || 'Page navigation'}" }
30
+ options.merge(
31
+ 'aria-label': "#{context.aria_label || 'Page navigation'}"
30
32
  )
31
33
  end
32
34
 
33
35
  def ul_classes
34
36
  [].tap do |classes|
35
37
  classes << "pagination"
36
- classes << "pagination-#{size}" if size.present?
38
+ classes << "pagination-#{context.size}" if context.size.present?
37
39
  end.join(' ').strip
38
40
  end
39
41
 
@@ -1,6 +1,9 @@
1
1
  import * as bootstrap from 'bootstrap'
2
+ import Vue from 'vue/dist/vue.esm'
2
3
 
3
- MatestackUiCore.Vue.component('matestack-ui-bootstrap-popover', {
4
+ import MatestackUiCore from 'matestack-ui-core'
5
+
6
+ Vue.component('matestack-ui-bootstrap-popover', {
4
7
 
5
8
  mixins: [MatestackUiCore.componentMixin],
6
9
  data() {
@@ -1,5 +1,7 @@
1
- class Matestack::Ui::Bootstrap::Components::Popover < Matestack::Ui::VueJsComponent
2
- vue_js_component_name "matestack-ui-bootstrap-popover"
1
+ require_relative "../base_vue_js_component"
2
+
3
+ class Matestack::Ui::Bootstrap::Components::Popover < Matestack::Ui::Bootstrap::BaseVueJsComponent
4
+ vue_name "matestack-ui-bootstrap-popover"
3
5
 
4
6
  # How i imagine using a popover
5
7
  #
@@ -26,16 +28,16 @@ class Matestack::Ui::Bootstrap::Components::Popover < Matestack::Ui::VueJsCompon
26
28
  DATA_ALIAS_ATTRIBUTES = %i[container delay selector html template fallback_placement]
27
29
 
28
30
  DATA_ALIAS_ATTRIBUTES.each do |attribute|
29
- optional "#{attribute}": { as: :"bs_#{attribute}"}
31
+ optional :"#{attribute}"
30
32
  end
31
33
 
32
34
  # TODO:
33
35
  # for security reasons the sanitize, sanitizeFn and whiteList options cannot be supplied using data attributes.
34
36
  # sanitize sanitize_fn white_list
35
37
 
36
- optional class: { as: :bs_class }
38
+ optional class: { as: :bs_class }
37
39
  optional id: { as: :bs_id }
38
- DATA_ATTRIBUTES = %i[tag content title text variant animation placement tabindex trigger boundary offset popper_config]
40
+ DATA_ATTRIBUTES = %i[tag content title variant animation placement tabindex trigger boundary offset popper_config]
39
41
  optional *DATA_ATTRIBUTES
40
42
  # :tag # different element to apply: div, span, links, button, ...
41
43
  # :content, :title # popover title and content strings
@@ -43,49 +45,51 @@ class Matestack::Ui::Bootstrap::Components::Popover < Matestack::Ui::VueJsCompon
43
45
  # :variant, :text # button styling & text
44
46
  # :placement # placement direction as string
45
47
 
46
- def response
47
- if tag.present?
48
- public_send(tag, popover_attributes) do
49
- content_partial
48
+ def response(&block)
49
+ if context.tag.present?
50
+ public_send(context.tag, popover_attributes) do
51
+ content_partial(&block)
50
52
  end
51
53
  else
52
54
  bs_btn popover_attributes do
53
- content_partial
55
+ content_partial(&block)
54
56
  end
55
57
  end
56
58
  end
57
59
 
58
60
  protected
59
61
 
60
- def content_partial
61
- plain text if text
62
- yield_components unless text
62
+ def content_partial(&block)
63
+ plain context.text if context.text
64
+ yield if block_given? unless context.text
63
65
  end
64
66
 
65
67
  def popover_attributes
66
68
  attributes = {}.tap do |hash|
67
69
  hash[:class] = popover_classes
68
- hash[:attributes] = { role: (text ? 'button': nil), title: "#{title}", tabindex: "#{tabindex}" }
70
+ hash[:role] = (context.text ? 'button': nil)
71
+ hash[:title] = "#{context.title}"
72
+ hash[:tabindex] = "#{context.tabindex}"
69
73
  hash[:data] = {}.tap do |data|
70
74
  DATA_ALIAS_ATTRIBUTES.each do |attribute|
71
- data["bs-#{attribute}"] = self.send(:"bs_#{attribute}") if self.send(:"bs_#{attribute}")
75
+ data["bs-#{attribute}"] = context.send("#{attribute}") if context.send("#{attribute}")
72
76
  end
73
77
  (DATA_ATTRIBUTES - [:tag, :text, :variant]).each do |attribute|
74
- data["bs-#{attribute}"] = self.send(:"#{attribute}") if self.send(:"#{attribute}")
78
+ data["bs-#{attribute}"] = context.send("#{attribute}") if context.send("#{attribute}")
75
79
  end
76
80
  data["bs-toggle"] = "popover"
77
81
  end
78
82
  end
79
- html_attributes.merge(
80
- attributes
83
+ options.merge(
84
+ attributes || {}
81
85
  )
82
86
  end
83
87
 
84
88
  def popover_classes
85
89
  [].tap do |classes|
86
- classes << "d-inline-block" unless text
87
- classes << "btn btn-#{variant}" if variant
88
- classes << bs_class
90
+ classes << "d-inline-block" unless context.text
91
+ classes << "btn btn-#{context.variant}" if context.variant
92
+ classes << context.bs_class
89
93
  end.join(' ').strip
90
94
  end
91
95