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.
- checksums.yaml +4 -4
- data/LICENSE +17 -5
- data/lib/matestack/ui/bootstrap.rb +96 -17
- data/{app/concepts → lib}/matestack/ui/bootstrap/apps/admin_template.rb +14 -7
- data/lib/matestack/ui/bootstrap/base_component.rb +13 -0
- data/lib/matestack/ui/bootstrap/base_vue_js_component.rb +13 -0
- data/{app/concepts → lib}/matestack/ui/bootstrap/components/accordion.rb +18 -16
- data/{app/concepts → lib}/matestack/ui/bootstrap/components/alert.js +12 -9
- data/lib/matestack/ui/bootstrap/components/alert.rb +43 -0
- data/lib/matestack/ui/bootstrap/components/avatar.rb +27 -0
- data/lib/matestack/ui/bootstrap/components/badge.rb +32 -0
- data/{app/concepts → lib}/matestack/ui/bootstrap/components/breadcrumb.rb +12 -10
- data/lib/matestack/ui/bootstrap/components/button.rb +71 -0
- data/lib/matestack/ui/bootstrap/components/button_group.rb +36 -0
- data/lib/matestack/ui/bootstrap/components/card.rb +105 -0
- data/{app/concepts → lib}/matestack/ui/bootstrap/components/carousel.js +21 -18
- data/lib/matestack/ui/bootstrap/components/carousel.rb +103 -0
- data/{app/concepts → lib}/matestack/ui/bootstrap/components/close.rb +10 -9
- data/{app/concepts → lib}/matestack/ui/bootstrap/components/collapse.js +20 -17
- data/lib/matestack/ui/bootstrap/components/collapse.rb +54 -0
- data/{app/concepts → lib}/matestack/ui/bootstrap/components/dropdown.js +5 -2
- data/{app/concepts → lib}/matestack/ui/bootstrap/components/dropdown.rb +29 -25
- data/lib/matestack/ui/bootstrap/components/icon.rb +21 -0
- data/{app/concepts → lib}/matestack/ui/bootstrap/components/list_group.rb +32 -29
- data/{app/concepts → lib}/matestack/ui/bootstrap/components/modal.js +24 -21
- data/lib/matestack/ui/bootstrap/components/modal.rb +121 -0
- data/{app/concepts → lib}/matestack/ui/bootstrap/components/navbar.rb +37 -28
- data/{app/concepts → lib}/matestack/ui/bootstrap/components/page_heading.rb +7 -5
- data/{app/concepts → lib}/matestack/ui/bootstrap/components/pagination.rb +11 -9
- data/{app/concepts → lib}/matestack/ui/bootstrap/components/popover.js +4 -1
- data/{app/concepts → lib}/matestack/ui/bootstrap/components/popover.rb +25 -21
- data/{app/concepts → lib}/matestack/ui/bootstrap/components/progress.rb +19 -19
- data/lib/matestack/ui/bootstrap/components/scrollspy.rb +50 -0
- data/lib/matestack/ui/bootstrap/components/section_card.rb +33 -0
- data/lib/matestack/ui/bootstrap/components/spinner.rb +35 -0
- data/lib/matestack/ui/bootstrap/components/tab_nav.rb +79 -0
- data/lib/matestack/ui/bootstrap/components/tab_nav_content.rb +35 -0
- data/{app/concepts → lib}/matestack/ui/bootstrap/components/toast.js +22 -19
- data/lib/matestack/ui/bootstrap/components/toast.rb +113 -0
- data/{app/concepts → lib}/matestack/ui/bootstrap/components/tooltip.js +4 -1
- data/{app/concepts → lib}/matestack/ui/bootstrap/components/tooltip.rb +20 -18
- data/{app/concepts → lib}/matestack/ui/bootstrap/content/figure.rb +4 -2
- data/{app/concepts → lib}/matestack/ui/bootstrap/content/smart_collection/collection.rb +22 -16
- data/{app/concepts → lib}/matestack/ui/bootstrap/content/smart_collection/collection.scss +0 -0
- data/{app/concepts → lib}/matestack/ui/bootstrap/content/smart_collection/content.rb +23 -19
- data/{app/concepts → lib}/matestack/ui/bootstrap/content/smart_collection/filter.rb +6 -2
- data/{app/concepts → lib}/matestack/ui/bootstrap/content/smart_collection/paginate.rb +16 -11
- data/lib/matestack/ui/bootstrap/form/checkbox.rb +81 -0
- data/lib/matestack/ui/bootstrap/form/input.rb +116 -0
- data/lib/matestack/ui/bootstrap/form/radio.rb +55 -0
- data/lib/matestack/ui/bootstrap/form/select.rb +63 -0
- data/lib/matestack/ui/bootstrap/form/submit.rb +20 -0
- data/lib/matestack/ui/bootstrap/form/switch.rb +32 -0
- data/lib/matestack/ui/bootstrap/index.js +24 -0
- data/lib/matestack/ui/bootstrap/layout/column.rb +49 -0
- data/{app/concepts → lib}/matestack/ui/bootstrap/layout/container.rb +12 -9
- data/lib/matestack/ui/bootstrap/layout/row.rb +25 -0
- data/{app/concepts → lib}/matestack/ui/bootstrap/layout/sidebar.js +5 -2
- data/{app/concepts → lib}/matestack/ui/bootstrap/layout/sidebar.rb +10 -10
- data/{app/concepts → lib}/matestack/ui/bootstrap/layout/sidebar.scss +0 -0
- data/lib/matestack/ui/bootstrap/registry.rb +169 -0
- data/{app/javascript/matestack-ui-bootstrap → lib/matestack/ui/bootstrap}/stylesheets/matestack-ui-bootstrap.scss +0 -0
- data/lib/matestack/ui/bootstrap/version.rb +1 -1
- metadata +67 -72
- data/app/assets/images/avatar-placeholder.png +0 -0
- data/app/assets/images/icons/bootstrap-icons.svg +0 -1
- data/app/concepts/matestack/ui/bootstrap/components/alert.rb +0 -34
- data/app/concepts/matestack/ui/bootstrap/components/avatar.rb +0 -27
- data/app/concepts/matestack/ui/bootstrap/components/badge.rb +0 -30
- data/app/concepts/matestack/ui/bootstrap/components/button.rb +0 -69
- data/app/concepts/matestack/ui/bootstrap/components/button_group.rb +0 -36
- data/app/concepts/matestack/ui/bootstrap/components/card.rb +0 -100
- data/app/concepts/matestack/ui/bootstrap/components/carousel.rb +0 -86
- data/app/concepts/matestack/ui/bootstrap/components/collapse.rb +0 -43
- data/app/concepts/matestack/ui/bootstrap/components/icon.rb +0 -19
- data/app/concepts/matestack/ui/bootstrap/components/modal.rb +0 -106
- data/app/concepts/matestack/ui/bootstrap/components/scrollspy.rb +0 -48
- data/app/concepts/matestack/ui/bootstrap/components/section_card.rb +0 -31
- data/app/concepts/matestack/ui/bootstrap/components/spinner.rb +0 -31
- data/app/concepts/matestack/ui/bootstrap/components/tab_nav.rb +0 -83
- data/app/concepts/matestack/ui/bootstrap/components/tab_nav_content.rb +0 -32
- data/app/concepts/matestack/ui/bootstrap/components/toast.rb +0 -99
- data/app/concepts/matestack/ui/bootstrap/form/checkbox.rb +0 -99
- data/app/concepts/matestack/ui/bootstrap/form/input.rb +0 -112
- data/app/concepts/matestack/ui/bootstrap/form/radio.rb +0 -57
- data/app/concepts/matestack/ui/bootstrap/form/select.rb +0 -53
- data/app/concepts/matestack/ui/bootstrap/form/submit.rb +0 -21
- data/app/concepts/matestack/ui/bootstrap/form/switch.rb +0 -99
- data/app/concepts/matestack/ui/bootstrap/layout/column.rb +0 -47
- data/app/concepts/matestack/ui/bootstrap/layout/row.rb +0 -15
- data/app/concepts/matestack/ui/bootstrap/pages/devise/sign_in.rb +0 -40
- data/app/concepts/matestack/ui/bootstrap/registry.rb +0 -61
- data/app/helpers/matestack/ui/bootstrap/application_helper.rb +0 -17
- data/app/javascript/matestack-ui-bootstrap/index.js +0 -24
- data/app/javascript/packs/matestack-ui-bootstrap.js +0 -2
- data/app/matestack/bootstrap/form/submit.rb +0 -20
- data/config/routes.rb +0 -2
- data/lib/matestack/ui/bootstrap/engine.rb +0 -26
@@ -1,29 +1,30 @@
|
|
1
|
-
|
1
|
+
require_relative "../base_component"
|
2
2
|
|
3
|
-
|
3
|
+
class Matestack::Ui::Bootstrap::Components::Close < Matestack::Ui::Bootstrap::BaseComponent
|
4
|
+
|
5
|
+
optional :dismiss, class: { as: :bs_class }
|
4
6
|
optional :attributes
|
5
7
|
|
6
8
|
def response
|
7
9
|
button close_attributes do
|
8
|
-
span
|
10
|
+
span 'aria-hidden': 'true' do
|
9
11
|
# plain "×".html_safe
|
10
12
|
end
|
11
13
|
end
|
12
14
|
end
|
13
15
|
|
14
16
|
def close_attributes
|
15
|
-
|
17
|
+
options.merge(
|
16
18
|
class: close_classes,
|
17
|
-
data: { "bs-dismiss": "#{dismiss}" },
|
18
|
-
type: 'button'
|
19
|
-
|
20
|
-
)
|
19
|
+
data: { "bs-dismiss": "#{context.dismiss}" },
|
20
|
+
type: 'button'
|
21
|
+
).merge((context.attributes || {}).merge({ 'aria-label': 'Close' }))
|
21
22
|
end
|
22
23
|
|
23
24
|
def close_classes
|
24
25
|
[].tap do |classes|
|
25
26
|
classes << 'btn-close'
|
26
|
-
classes << bs_class
|
27
|
+
classes << context.bs_class
|
27
28
|
end.join(' ').strip
|
28
29
|
end
|
29
30
|
|
@@ -1,6 +1,9 @@
|
|
1
1
|
import * as bootstrap from 'bootstrap'
|
2
|
+
import Vue from 'vue/dist/vue.esm'
|
2
3
|
|
3
|
-
MatestackUiCore
|
4
|
+
import MatestackUiCore from 'matestack-ui-core'
|
5
|
+
|
6
|
+
Vue.component('matestack-ui-bootstrap-collapse', {
|
4
7
|
mixins: [MatestackUiCore.componentMixin],
|
5
8
|
data() {
|
6
9
|
return {
|
@@ -41,43 +44,43 @@ MatestackUiCore.Vue.component('matestack-ui-bootstrap-collapse', {
|
|
41
44
|
const self = this
|
42
45
|
|
43
46
|
// toggle_on event registration
|
44
|
-
if(self.
|
45
|
-
var toggle_events = self.
|
47
|
+
if(self.props["toggle_on"] != undefined){
|
48
|
+
var toggle_events = self.props["toggle_on"].split(",")
|
46
49
|
toggle_events.forEach(toggle_event => MatestackUiCore.matestackEventHub.$on(toggle_event.trim(), self.toggle));
|
47
50
|
}
|
48
51
|
// show_on event registration
|
49
|
-
if(self.
|
50
|
-
var show_events = self.
|
52
|
+
if(self.props["show_on"] != undefined){
|
53
|
+
var show_events = self.props["show_on"].split(",")
|
51
54
|
show_events.forEach(show_event => MatestackUiCore.matestackEventHub.$on(show_event.trim(), self.show));
|
52
55
|
}
|
53
56
|
// hide_on event registration
|
54
|
-
if(self.
|
55
|
-
var hide_events = self.
|
57
|
+
if(self.props["hide_on"] != undefined){
|
58
|
+
var hide_events = self.props["hide_on"].split(",")
|
56
59
|
hide_events.forEach(hide_event => MatestackUiCore.matestackEventHub.$on(hide_event.trim(), self.hide));
|
57
60
|
}
|
58
61
|
// dispose_on event registration
|
59
|
-
if(self.
|
60
|
-
var dispose_events = self.
|
62
|
+
if(self.props["dispose_on"] != undefined){
|
63
|
+
var dispose_events = self.props["dispose_on"].split(",")
|
61
64
|
dispose_events.forEach(dispose_event => MatestackUiCore.matestackEventHub.$on(dispose_event.trim(), self.dispose));
|
62
65
|
}
|
63
66
|
},
|
64
67
|
|
65
68
|
beforeDestroy: function(){
|
66
69
|
const self = this
|
67
|
-
if(self.
|
68
|
-
var show_events = self.
|
70
|
+
if(self.props["toggle_on"] != undefined){
|
71
|
+
var show_events = self.props["toggle_on"].split(",")
|
69
72
|
show_events.forEach(show_event => MatestackUiCore.matestackEventHub.$off(show_event.trim(), self.show));
|
70
73
|
}
|
71
|
-
if(self.
|
72
|
-
var show_events = self.
|
74
|
+
if(self.props["show_on"] != undefined){
|
75
|
+
var show_events = self.props["show_on"].split(",")
|
73
76
|
show_events.forEach(show_event => MatestackUiCore.matestackEventHub.$off(show_event.trim(), self.show));
|
74
77
|
}
|
75
|
-
if(self.
|
76
|
-
var hide_events = self.
|
78
|
+
if(self.props["hide_on"] != undefined){
|
79
|
+
var hide_events = self.props["hide_on"].split(",")
|
77
80
|
hide_events.forEach(hide_event => MatestackUiCore.matestackEventHub.$off(hide_event.trim(), self.hide));
|
78
81
|
}
|
79
|
-
if(self.
|
80
|
-
var dispose_events = self.
|
82
|
+
if(self.props["dispose_on"] != undefined){
|
83
|
+
var dispose_events = self.props["dispose_on"].split(",")
|
81
84
|
dispose_events.forEach(dispose_event => MatestackUiCore.matestackEventHub.$off(dispose_event.trim(), self.dispose));
|
82
85
|
}
|
83
86
|
}
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require_relative "../base_vue_js_component"
|
2
|
+
|
3
|
+
class Matestack::Ui::Bootstrap::Components::Collapse < Matestack::Ui::Bootstrap::BaseVueJsComponent
|
4
|
+
vue_name "matestack-ui-bootstrap-collapse"
|
5
|
+
|
6
|
+
optional :multi, :labelledby, :parent, class: { as: :bs_class }
|
7
|
+
optional :card # possible keys: class, text
|
8
|
+
# event trigger
|
9
|
+
optional :toggle_on, :show_on, :hide_on, :dispose_on
|
10
|
+
|
11
|
+
def response
|
12
|
+
div collapse_attributes do
|
13
|
+
card_partial if context.card
|
14
|
+
yield if block_given?
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
protected
|
19
|
+
|
20
|
+
def vue_props
|
21
|
+
{}.tap do |props|
|
22
|
+
props[:toggle_on] = context.toggle_on
|
23
|
+
props[:show_on] = context.show_on
|
24
|
+
props[:hide_on] = context.hide_on
|
25
|
+
props[:dispose_on] = context.dispose_on
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def card_partial
|
30
|
+
tmp_card = context.card.is_a?(Hash) ? context.card : { text: context.card }
|
31
|
+
div class: "card card-body #{tmp_card[:class]}".strip do
|
32
|
+
plain tmp_card[:text]
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def collapse_attributes
|
37
|
+
options.merge(
|
38
|
+
class: collapse_classes,
|
39
|
+
data: { "bs-parent": context.parent },
|
40
|
+
'aria-labelledby': "#{context.labelledby}"
|
41
|
+
)
|
42
|
+
end
|
43
|
+
|
44
|
+
def collapse_classes
|
45
|
+
[].tap do |classes|
|
46
|
+
classes << 'collapse'
|
47
|
+
# mulit target
|
48
|
+
classes << 'multi-collapse' if context.multi
|
49
|
+
#custom classes
|
50
|
+
classes << context.bs_class
|
51
|
+
end.join(' ').strip
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
@@ -1,6 +1,9 @@
|
|
1
1
|
import * as bootstrap from 'bootstrap'
|
2
|
+
import Vue from 'vue/dist/vue.esm'
|
2
3
|
|
3
|
-
MatestackUiCore
|
4
|
+
import MatestackUiCore from 'matestack-ui-core'
|
5
|
+
|
6
|
+
Vue.component('matestack-ui-bootstrap-dropdown', {
|
4
7
|
mixins: [MatestackUiCore.componentMixin],
|
5
8
|
data() {
|
6
9
|
return {
|
@@ -8,7 +11,7 @@ MatestackUiCore.Vue.component('matestack-ui-bootstrap-dropdown', {
|
|
8
11
|
};
|
9
12
|
},
|
10
13
|
mounted() {
|
11
|
-
// var mydropdown = document.getElementById(this.
|
14
|
+
// var mydropdown = document.getElementById(this.props["dropdown-id"])
|
12
15
|
// this.dropdownInstance = new bootstrap.Dropdown(mydropdown)
|
13
16
|
}
|
14
17
|
});
|
@@ -1,18 +1,22 @@
|
|
1
|
-
|
2
|
-
vue_js_component_name "matestack-ui-bootstrap-dropdown"
|
1
|
+
require_relative "../base_vue_js_component"
|
3
2
|
|
4
|
-
|
3
|
+
class Matestack::Ui::Bootstrap::Components::Dropdown < Matestack::Ui::Bootstrap::BaseVueJsComponent
|
4
|
+
vue_name "matestack-ui-bootstrap-dropdown"
|
5
|
+
|
6
|
+
optional :variant, :btn_class # button attributes
|
5
7
|
optional :direction, :align, :offset, :reference
|
6
8
|
# dropdown menu attributes, expects an array of items with possible keys: type, path, text
|
7
9
|
# or hash with possible keys: items, class
|
8
10
|
optional :menu
|
9
|
-
optional class: { as:
|
10
|
-
optional :
|
11
|
+
optional class: { as: :bs_class }
|
12
|
+
optional :id, :data
|
13
|
+
|
11
14
|
optional :size
|
12
15
|
|
13
16
|
def prepare
|
14
|
-
@bs_menu =
|
17
|
+
@bs_menu = context.menu.is_a?(Hash) ? context.menu : { items: context.menu }
|
15
18
|
end
|
19
|
+
|
16
20
|
def response
|
17
21
|
div dropdown_attributes do
|
18
22
|
split_btn_partial if slots && slots[:split_btn]
|
@@ -20,7 +24,7 @@ class Matestack::Ui::Bootstrap::Components::Dropdown < Matestack::Ui::VueJsCompo
|
|
20
24
|
|
21
25
|
ul menu_attributes do
|
22
26
|
menu_partial unless @bs_menu[:items].blank?
|
23
|
-
|
27
|
+
yield if block_given?
|
24
28
|
end
|
25
29
|
end
|
26
30
|
end
|
@@ -28,7 +32,7 @@ class Matestack::Ui::Bootstrap::Components::Dropdown < Matestack::Ui::VueJsCompo
|
|
28
32
|
protected
|
29
33
|
|
30
34
|
def split_btn_partial
|
31
|
-
slot
|
35
|
+
slot :split_btn
|
32
36
|
bs_btn btn_attributes do
|
33
37
|
span class:"visually-hidden" do plain "Toggle Dropdown" end
|
34
38
|
end
|
@@ -42,13 +46,13 @@ class Matestack::Ui::Bootstrap::Components::Dropdown < Matestack::Ui::VueJsCompo
|
|
42
46
|
when :divider
|
43
47
|
li do hr class: "dropdown-divider" end
|
44
48
|
when :link
|
45
|
-
li do
|
49
|
+
li do a item.merge(class: "dropdown-item #{item[:class]}") end
|
46
50
|
when :transition
|
47
51
|
li do transition item.merge(class: "dropdown-item #{item[:class]}") end
|
48
52
|
when :action
|
49
53
|
li do action item.merge(class: "dropdown-item #{item[:class]}") do plain item[:text] end end
|
50
54
|
when :onclick
|
51
|
-
li do onclick item.merge(class: "dropdown-item #{item[:class]}",
|
55
|
+
li do onclick item.merge(class: "dropdown-item #{item[:class]}", style: "cursor: pointer;" ) do plain item[:text] end end
|
52
56
|
else
|
53
57
|
span class: "dropdown-item-text" do plain item[:text] end
|
54
58
|
end
|
@@ -56,7 +60,7 @@ class Matestack::Ui::Bootstrap::Components::Dropdown < Matestack::Ui::VueJsCompo
|
|
56
60
|
end
|
57
61
|
|
58
62
|
def dropdown_attributes
|
59
|
-
|
63
|
+
options.merge(
|
60
64
|
class: dropdown_classes
|
61
65
|
)
|
62
66
|
end
|
@@ -64,28 +68,28 @@ class Matestack::Ui::Bootstrap::Components::Dropdown < Matestack::Ui::VueJsCompo
|
|
64
68
|
def dropdown_classes
|
65
69
|
[].tap do |classes|
|
66
70
|
classes << ((slots && slots[:split_btn]) ? 'btn-group' : 'dropdown')
|
67
|
-
classes << "drop#{direction}" if direction.present?
|
68
|
-
classes << bs_class
|
71
|
+
classes << "drop#{context.direction}" if context.direction.present?
|
72
|
+
classes << context.bs_class
|
69
73
|
end.join(' ').strip
|
70
74
|
end
|
71
75
|
|
72
76
|
def btn_attributes
|
73
77
|
{
|
74
|
-
id:
|
75
|
-
text: "#{text unless (slots && slots[:split_btn])}",
|
76
|
-
variant: (variant || :primary),
|
78
|
+
id: context.id,
|
79
|
+
text: "#{context.text unless (slots && slots[:split_btn])}",
|
80
|
+
variant: (context.variant || :primary),
|
77
81
|
class: btn_classes,
|
78
82
|
data: btn_data,
|
79
|
-
size: size,
|
80
|
-
|
83
|
+
size: context.size,
|
84
|
+
'aria-expanded': "false"
|
81
85
|
}
|
82
86
|
end
|
83
87
|
|
84
88
|
def btn_data
|
85
|
-
(
|
89
|
+
(context.data || {}).tap do |hash|
|
86
90
|
hash["bs-toggle"] = 'dropdown'
|
87
|
-
hash[:offset] = offset if offset.present?
|
88
|
-
hash[:reference] = reference if reference.present?
|
91
|
+
hash[:offset] = context.offset if context.offset.present?
|
92
|
+
hash[:reference] = context.reference if context.reference.present?
|
89
93
|
end
|
90
94
|
end
|
91
95
|
|
@@ -94,23 +98,23 @@ class Matestack::Ui::Bootstrap::Components::Dropdown < Matestack::Ui::VueJsCompo
|
|
94
98
|
classes << 'dropdown-toggle'
|
95
99
|
classes << 'dropdown-toggle-split' if slots && slots[:split_btn]
|
96
100
|
#custom classes
|
97
|
-
classes << btn_class
|
101
|
+
classes << context.btn_class
|
98
102
|
end.join(' ').strip
|
99
103
|
end
|
100
104
|
|
101
105
|
def menu_attributes
|
102
106
|
{
|
103
107
|
class: menu_classes,
|
104
|
-
|
108
|
+
'aria-labelledby': context.id
|
105
109
|
}
|
106
110
|
end
|
107
111
|
|
108
112
|
def menu_classes
|
109
113
|
[].tap do |classes|
|
110
114
|
classes << 'dropdown-menu'
|
111
|
-
classes << "dropdown-menu-#{align}" if align.present?
|
115
|
+
classes << "dropdown-menu-#{context.align}" if context.align.present?
|
112
116
|
#custom classes
|
113
|
-
classes << @bs_menu[:class] if menu.is_a?(Hash)
|
117
|
+
classes << @bs_menu[:class] if context.menu.is_a?(Hash)
|
114
118
|
end.join(' ').strip
|
115
119
|
end
|
116
120
|
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require_relative "../base_component"
|
2
|
+
|
3
|
+
class Matestack::Ui::Bootstrap::Components::Icon < Matestack::Ui::Bootstrap::BaseComponent
|
4
|
+
|
5
|
+
required :name
|
6
|
+
optional :size
|
7
|
+
optional class: { as: :bs_class }
|
8
|
+
|
9
|
+
def response
|
10
|
+
svg class: "bi #{context.bs_class}", width: get_size, height: get_size, fill: 'currentColor' do
|
11
|
+
unescape("<use xlink:href='#{asset_path("icons/bootstrap-icons.svg")}##{context.name}'/>")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def get_size
|
16
|
+
context.size || 20
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
end
|
@@ -1,21 +1,23 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
require_relative "../base_component"
|
2
|
+
|
3
|
+
class Matestack::Ui::Bootstrap::Components::ListGroup < Matestack::Ui::Bootstrap::BaseComponent
|
4
|
+
optional :role
|
3
5
|
|
4
6
|
optional :items
|
5
7
|
optional :horizontal, :horizontal_size, :checkbox
|
6
|
-
optional :variant, class: { as:
|
8
|
+
optional :variant, class: { as: :bs_class }
|
7
9
|
|
8
10
|
|
9
11
|
def response
|
10
12
|
if actionable_items?
|
11
13
|
div list_group_attributes do
|
12
|
-
|
13
|
-
list_partial if items
|
14
|
+
yield if block_given? unless context.items
|
15
|
+
list_partial if context.items
|
14
16
|
end
|
15
17
|
else
|
16
18
|
ul list_group_attributes do
|
17
|
-
|
18
|
-
list_partial if items
|
19
|
+
yield if block_given? unless context.items
|
20
|
+
list_partial if context.items
|
19
21
|
end
|
20
22
|
end
|
21
23
|
end
|
@@ -23,49 +25,49 @@ class Matestack::Ui::Bootstrap::Components::ListGroup < Matestack::Ui::Component
|
|
23
25
|
protected
|
24
26
|
|
25
27
|
def actionable_items?
|
26
|
-
if items.present?
|
27
|
-
items.any? { |item| [:tab, :transition, :action, :link].include?(item[:type]) }
|
28
|
+
if context.items.present?
|
29
|
+
context.items.any? { |item| [:tab, :transition, :action, :link].include?(item[:type]) }
|
28
30
|
else
|
29
31
|
false
|
30
32
|
end
|
31
33
|
end
|
32
34
|
|
33
35
|
def tab_nav?
|
34
|
-
if items.present?
|
35
|
-
items.any? { |item| item[:type] == :tab }
|
36
|
+
if context.items.present?
|
37
|
+
context.items.any? { |item| item[:type] == :tab }
|
36
38
|
else
|
37
39
|
false
|
38
40
|
end
|
39
41
|
end
|
40
42
|
|
41
43
|
def list_partial
|
42
|
-
items.each do |item|
|
44
|
+
context.items.each do |item|
|
43
45
|
case item[:type]
|
44
46
|
when :link
|
45
|
-
|
47
|
+
a link_attrs(item) do
|
46
48
|
text_rendering(item)
|
47
49
|
end
|
48
50
|
when :tab
|
49
|
-
|
51
|
+
a tab_attrs(item) do
|
50
52
|
text_rendering(item)
|
51
53
|
end
|
52
54
|
when :transition
|
53
|
-
transition transition_attrs(item)
|
55
|
+
transition transition_attrs(item) do
|
54
56
|
text_rendering(item)
|
55
57
|
end
|
56
58
|
when :action
|
57
|
-
action action_attrs(item)
|
59
|
+
action action_attrs(item) do
|
58
60
|
text_rendering(item)
|
59
61
|
end
|
60
62
|
when :label
|
61
63
|
label id: item[:id], class: "#{list_classes item, false}" do
|
62
|
-
input class: "form-check-input me-1",
|
64
|
+
input class: "form-check-input me-1", 'type': "checkbox", 'value': "" if context.checkbox
|
63
65
|
text_rendering(item)
|
64
66
|
end
|
65
67
|
else
|
66
|
-
li id: item[:id], class: "#{list_classes item, false}",
|
68
|
+
li id: item[:id], class: "#{list_classes item, false}", "aria-disabled": "#{true if item[:disabled]}" do
|
67
69
|
# this implementation is useless, would need to be connected to a form through bs_form_checkbox
|
68
|
-
# input class: "form-check-input me-1",
|
70
|
+
# input class: "form-check-input me-1", 'type': "checkbox", 'value': "", 'aria-label': "#{item[:text]}" if checkbox
|
69
71
|
text_rendering(item)
|
70
72
|
bs_badge variant: :primary, rounded: true, text: item[:badge] if item[:badge]
|
71
73
|
end
|
@@ -81,9 +83,9 @@ class Matestack::Ui::Bootstrap::Components::ListGroup < Matestack::Ui::Component
|
|
81
83
|
def list_group_attributes
|
82
84
|
attributes = {}.tap do |hash|
|
83
85
|
hash[:class] = list_group_classes
|
84
|
-
hash[:
|
86
|
+
hash[:role] = "tablist" if tab_nav?
|
85
87
|
end
|
86
|
-
|
88
|
+
options.merge(
|
87
89
|
attributes
|
88
90
|
)
|
89
91
|
end
|
@@ -91,16 +93,16 @@ class Matestack::Ui::Bootstrap::Components::ListGroup < Matestack::Ui::Component
|
|
91
93
|
def list_group_classes
|
92
94
|
[].tap do |classes|
|
93
95
|
classes << 'list-group'
|
94
|
-
classes << (horizontal_size.present? ? "list-group-horizontal-#{horizontal_size}": "list-group-horizontal") if horizontal
|
95
|
-
classes << 'list-group-flush' if variant == :flush
|
96
|
-
classes << bs_class
|
96
|
+
classes << (context.horizontal_size.present? ? "list-group-horizontal-#{context.horizontal_size}": "list-group-horizontal") if context.horizontal
|
97
|
+
classes << 'list-group-flush' if context.variant == :flush
|
98
|
+
classes << context.bs_class
|
97
99
|
end.join(' ').strip
|
98
100
|
end
|
99
101
|
|
100
102
|
def link_attrs(item)
|
101
103
|
attrs = item
|
102
104
|
attrs[:class] = "#{list_classes item, true}"
|
103
|
-
attrs[
|
105
|
+
attrs["aria-disabled"] = "#{true if item[:disabled]}" if item[:disabled]
|
104
106
|
attrs
|
105
107
|
end
|
106
108
|
|
@@ -109,8 +111,9 @@ class Matestack::Ui::Bootstrap::Components::ListGroup < Matestack::Ui::Component
|
|
109
111
|
hash[:id] = "tab-#{item[:id]}" if tab_nav?
|
110
112
|
hash[:class] = "#{list_classes item, true}"
|
111
113
|
hash[:data] = { "bs-toggle": "list" }
|
112
|
-
hash[
|
113
|
-
hash[
|
114
|
+
hash["aria-disabled"] = "#{true if item[:disabled]}" if item[:disabled]
|
115
|
+
hash['aria-controls'] = "#tab-#{item[:id]}-content"
|
116
|
+
hash[:role] = "tab"
|
114
117
|
hash[:path] = "#tab-#{item[:id]}-content"
|
115
118
|
hash[:target] = item[:target]
|
116
119
|
end
|
@@ -119,14 +122,14 @@ class Matestack::Ui::Bootstrap::Components::ListGroup < Matestack::Ui::Component
|
|
119
122
|
def transition_attrs(item)
|
120
123
|
attrs = item
|
121
124
|
attrs[:class] = "#{list_classes item, true}"
|
122
|
-
attrs[
|
125
|
+
attrs["aria-disabled"] = "#{true if item[:disabled]}" if item[:disabled]
|
123
126
|
attrs
|
124
127
|
end
|
125
128
|
|
126
129
|
def action_attrs(item)
|
127
130
|
attrs = item
|
128
131
|
attrs[:class] = "#{list_classes item, true}"
|
129
|
-
attrs[
|
132
|
+
attrs["aria-disabled"] = "#{true if item[:disabled]}" if item[:disabled]
|
130
133
|
attrs
|
131
134
|
end
|
132
135
|
|