matestack-ui-bootstrap 1.5.1 → 3.0.0.rc1
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/README.md +36 -60
- data/lib/matestack/ui/bootstrap/base_component.rb +11 -0
- data/lib/matestack/ui/bootstrap/base_vue_js_component.rb +11 -0
- data/{app/concepts → lib}/matestack/ui/bootstrap/components/accordion.rb +18 -16
- data/lib/matestack/ui/bootstrap/components/alert.js +58 -0
- 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/lib/matestack/ui/bootstrap/components/carousel.js +84 -0
- data/lib/matestack/ui/bootstrap/components/carousel.rb +103 -0
- data/{app/concepts → lib}/matestack/ui/bootstrap/components/close.rb +10 -9
- data/lib/matestack/ui/bootstrap/components/collapse.js +89 -0
- data/lib/matestack/ui/bootstrap/components/collapse.rb +54 -0
- data/lib/matestack/ui/bootstrap/components/dropdown.js +19 -0
- 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 +32 -28
- data/lib/matestack/ui/bootstrap/components/modal.rb +121 -0
- data/{app/concepts → lib}/matestack/ui/bootstrap/components/navbar.rb +39 -30
- 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/lib/matestack/ui/bootstrap/components/popover.js +30 -0
- 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/lib/matestack/ui/bootstrap/components/toast.js +89 -0
- data/lib/matestack/ui/bootstrap/components/toast.rb +113 -0
- data/{app/concepts → lib}/matestack/ui/bootstrap/components/tooltip.js +9 -6
- 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 +38 -21
- 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 +88 -0
- data/lib/matestack/ui/bootstrap/form/input.rb +116 -0
- data/lib/matestack/ui/bootstrap/form/radio.rb +55 -0
- data/{app/concepts → lib}/matestack/ui/bootstrap/form/select.rb +18 -10
- data/lib/matestack/ui/bootstrap/form/submit.rb +20 -0
- data/lib/matestack/ui/bootstrap/form/switch.rb +30 -0
- data/lib/matestack/ui/bootstrap/form/textarea.rb +47 -0
- data/lib/matestack/ui/bootstrap/index.js +40 -0
- data/lib/matestack/ui/bootstrap/initialize.rb +3 -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 +10 -6
- data/lib/matestack/ui/bootstrap/layout/sidebar.rb +43 -0
- data/{app/concepts → lib}/matestack/ui/bootstrap/layout/sidebar.scss +0 -0
- data/{app/concepts/matestack/ui/bootstrap/apps → lib/matestack/ui/bootstrap/layouts}/admin_template.rb +18 -13
- data/lib/matestack/ui/bootstrap/registry.rb +173 -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
- data/lib/matestack/ui/bootstrap.rb +99 -17
- metadata +85 -80
- 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.js +0 -53
- 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.js +0 -79
- data/app/concepts/matestack/ui/bootstrap/components/carousel.rb +0 -86
- data/app/concepts/matestack/ui/bootstrap/components/collapse.js +0 -84
- data/app/concepts/matestack/ui/bootstrap/components/collapse.rb +0 -43
- data/app/concepts/matestack/ui/bootstrap/components/dropdown.js +0 -14
- 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/popover.js +0 -26
- 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.js +0 -85
- 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/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/layout/sidebar.rb +0 -45
- 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/config/webpack/development.js +0 -5
- data/config/webpack/environment.js +0 -29
- data/config/webpack/production.js +0 -33
- data/config/webpack/test.js +0 -5
- data/config/webpacker.yml +0 -96
- data/lib/matestack/ui/bootstrap/engine.rb +0 -26
@@ -0,0 +1,105 @@
|
|
1
|
+
require_relative "../base_component"
|
2
|
+
|
3
|
+
class Matestack::Ui::Bootstrap::Components::Card < Matestack::Ui::Bootstrap::BaseComponent
|
4
|
+
|
5
|
+
optional class: { as: :bs_class }
|
6
|
+
|
7
|
+
# header attributes, expects a hash or string
|
8
|
+
# possible keys `:class, :text`
|
9
|
+
optional :header
|
10
|
+
# footer attributes, expects a hash or string
|
11
|
+
# possible keys `:class, :text`
|
12
|
+
optional :footer
|
13
|
+
|
14
|
+
optional :title, :body, :subtitle # body attributes
|
15
|
+
optional :img_path, :img_pos, :alt_text # image attributes
|
16
|
+
|
17
|
+
optional :content_wrapper_class # class for content wrapper -> useful for content padding without affecting top image
|
18
|
+
|
19
|
+
def response
|
20
|
+
div card_attributes do
|
21
|
+
if context.header || slots && slots[:header]
|
22
|
+
header_partial
|
23
|
+
end
|
24
|
+
|
25
|
+
img_partial :top unless context.img_pos == :bottom
|
26
|
+
div class: context.content_wrapper_class do
|
27
|
+
body_partial if context.title || context.body || slots && slots[:body]
|
28
|
+
|
29
|
+
# custom body components
|
30
|
+
# needed a div otherwise it will be displayed below footer
|
31
|
+
div class: "p-3 pt-1" do yield if block_given? end
|
32
|
+
|
33
|
+
img_partial :bottom if context.img_pos == :bottom
|
34
|
+
|
35
|
+
footer_partial if context.footer || slots && slots[:footer]
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
protected
|
41
|
+
|
42
|
+
def header_partial
|
43
|
+
header = self.context.header.is_a?(Hash) ? self.context.header : { text: self.context.header }
|
44
|
+
div class: "card-header #{header[:class]}" do
|
45
|
+
plain header[:text] if header[:text].present?
|
46
|
+
slot :header if slots && slots[:header]
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def body_partial
|
51
|
+
div class: "card-body" do
|
52
|
+
# title
|
53
|
+
card_title(context.title, "card-title")
|
54
|
+
# subtitle
|
55
|
+
card_title(context.subtitle, 6, "card-subtitle text-muted")
|
56
|
+
# body
|
57
|
+
if context.body.is_a? Hash
|
58
|
+
paragraph class: "card-text #{body[:class]}" do
|
59
|
+
plain context.body[:text]
|
60
|
+
end
|
61
|
+
elsif context.body
|
62
|
+
paragraph class: "card-text" do
|
63
|
+
plain context.body
|
64
|
+
end
|
65
|
+
end
|
66
|
+
slot :body if slots && slots[:body]
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def footer_partial
|
71
|
+
footer = self.context.footer.is_a?(Hash) ? self.context.footer : { text: self.context.footer }
|
72
|
+
div class: "card-footer #{footer[:class]}" do
|
73
|
+
plain footer[:text] if footer[:text].present?
|
74
|
+
slot :footer if slots && slots[:footer]
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def img_partial pos
|
79
|
+
img class: "card-img-#{pos}", path: context.img_path, alt: context.alt_text if context.img_path.present?
|
80
|
+
end
|
81
|
+
|
82
|
+
def card_attributes
|
83
|
+
options.merge(
|
84
|
+
class: card_classes
|
85
|
+
)
|
86
|
+
end
|
87
|
+
|
88
|
+
def card_classes
|
89
|
+
[].tap do |classes|
|
90
|
+
classes << 'card'
|
91
|
+
classes << context.bs_class
|
92
|
+
end.join(' ').strip
|
93
|
+
end
|
94
|
+
|
95
|
+
def card_title(options, default_size = 5, title_class)
|
96
|
+
if options.is_a? Hash
|
97
|
+
heading context.text, size: (context.size || default_size), class: "#{context.bs_class} #{title_class}"
|
98
|
+
elsif options
|
99
|
+
heading size: default_size, class: title_class do
|
100
|
+
plain options
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
import * as bootstrap from 'bootstrap'
|
2
|
+
|
3
|
+
import MatestackUiVueJs from 'matestack-ui-vuejs'
|
4
|
+
|
5
|
+
const carouselComponent = {
|
6
|
+
mixins: [MatestackUiVueJs.componentMixin],
|
7
|
+
template: MatestackUiVueJs.componentHelpers.inlineTemplate,
|
8
|
+
data() {
|
9
|
+
return {
|
10
|
+
carouselInstance: undefined
|
11
|
+
};
|
12
|
+
},
|
13
|
+
|
14
|
+
methods: {
|
15
|
+
cycle: function(){
|
16
|
+
const self = this;
|
17
|
+
self.carouselInstance.cycle()
|
18
|
+
},
|
19
|
+
pause: function(){
|
20
|
+
const self = this;
|
21
|
+
self.carouselInstance.pause()
|
22
|
+
},
|
23
|
+
prev: function(){
|
24
|
+
const self = this;
|
25
|
+
self.carouselInstance.prev()
|
26
|
+
},
|
27
|
+
next: function(){
|
28
|
+
const self = this;
|
29
|
+
self.carouselInstance.next()
|
30
|
+
}
|
31
|
+
},
|
32
|
+
|
33
|
+
mounted: function() {
|
34
|
+
const self = this;
|
35
|
+
var myCarousel = self.getElement();
|
36
|
+
self.carouselInstance = new bootstrap.Carousel(myCarousel, {
|
37
|
+
interval: (self.props['interval'] || 5000)
|
38
|
+
})
|
39
|
+
},
|
40
|
+
|
41
|
+
created: function() {
|
42
|
+
const self = this
|
43
|
+
if(self.props["cycle_on"] != undefined){
|
44
|
+
var cycle_events = self.props["cycle_on"].split(",")
|
45
|
+
cycle_events.forEach(cycle_event => MatestackUiVueJs.eventHub.$on(cycle_event.trim(), self.cycle));
|
46
|
+
}
|
47
|
+
if(self.props["pause_on"] != undefined){
|
48
|
+
var pause_events = self.props["pause_on"].split(",")
|
49
|
+
pause_events.forEach(pause_event => MatestackUiVueJs.eventHub.$on(pause_event.trim(), self.pause));
|
50
|
+
}
|
51
|
+
if(self.props["prev_on"] != undefined){
|
52
|
+
var prev_events = self.props["prev_on"].split(",")
|
53
|
+
prev_events.forEach(prev_event => MatestackUiVueJs.eventHub.$on(prev_event.trim(), self.prev));
|
54
|
+
}
|
55
|
+
if(self.props["next_on"] != undefined){
|
56
|
+
var next_events = self.props["next_on"].split(",")
|
57
|
+
next_events.forEach(next_event => MatestackUiVueJs.eventHub.$on(next_event.trim(), self.next));
|
58
|
+
}
|
59
|
+
},
|
60
|
+
|
61
|
+
beforeUnmount: function() {
|
62
|
+
const self = this
|
63
|
+
if(self.props["cycle_on"] != undefined){
|
64
|
+
var cycle_events = self.props["cycle_on"].split(",")
|
65
|
+
cycle_events.forEach(cycle_event => MatestackUiVueJs.eventHub.$off(cycle_event.trim(), self.cycle));
|
66
|
+
}
|
67
|
+
|
68
|
+
if(self.props["pause_on"] != undefined){
|
69
|
+
var pause_events = self.props["pause_on"].split(",")
|
70
|
+
pause_events.forEach(pause_event => MatestackUiVueJs.eventHub.$off(pause_event.trim(), self.pause));
|
71
|
+
}
|
72
|
+
|
73
|
+
if(self.props["prev_on"] != undefined){
|
74
|
+
var prev_events = self.props["prev_on"].split(",")
|
75
|
+
prev_events.forEach(prev_event => MatestackUiVueJs.eventHub.$off(prev_event.trim(), self.prev));
|
76
|
+
}
|
77
|
+
if(self.props["next_on"] != undefined){
|
78
|
+
var next_events = self.props["next_on"].split(",")
|
79
|
+
next_events.forEach(next_event => MatestackUiVueJs.eventHub.$off(next_event.trim(), self.next));
|
80
|
+
}
|
81
|
+
},
|
82
|
+
}
|
83
|
+
|
84
|
+
export default carouselComponent
|
@@ -0,0 +1,103 @@
|
|
1
|
+
require_relative "../base_vue_js_component"
|
2
|
+
|
3
|
+
class Matestack::Ui::Bootstrap::Components::Carousel < Matestack::Ui::Bootstrap::BaseVueJsComponent
|
4
|
+
vue_name "matestack-ui-bootstrap-carousel"
|
5
|
+
|
6
|
+
optional :start, :controls, :indicators, :fade, :interval, :variant
|
7
|
+
optional :items, class: { as: :bs_class }
|
8
|
+
# possible keys for items: path, title, text, interval
|
9
|
+
# event trigger
|
10
|
+
optional :cycle_on, :pause_on, :prev_on, :next_on
|
11
|
+
|
12
|
+
def response
|
13
|
+
div carousel_attributes do
|
14
|
+
# carousel indicator
|
15
|
+
indicator_partial if context.indicators.present?
|
16
|
+
# carousel content
|
17
|
+
div class: "carousel-inner" do
|
18
|
+
yield if block_given?
|
19
|
+
carousel_partial if context.items
|
20
|
+
end
|
21
|
+
controls_partial if context.controls
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
protected
|
26
|
+
|
27
|
+
def vue_props
|
28
|
+
{}.tap do |props|
|
29
|
+
props["carousel-id"] = carousel_id
|
30
|
+
props[:interval] = context.interval
|
31
|
+
props[:cycle_on] = context.cycle_on
|
32
|
+
props[:pause_on] = context.pause_on
|
33
|
+
props[:prev_on] = context.prev_on
|
34
|
+
props[:next_on] = context.next_on
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def indicator_partial
|
39
|
+
ol class: "carousel-indicators" do
|
40
|
+
context.items.size.times do |index|
|
41
|
+
li data: { "bs-target": "##{carousel_id}", 'bs-slide-to': index },
|
42
|
+
class: "#{'active' if index == (context.start || 0) }"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def carousel_partial
|
48
|
+
context.items.each_with_index do |item, index|
|
49
|
+
div class: "carousel-item #{'active' if index == (context.start || 0) } #{item[:class]}".strip,
|
50
|
+
data: { "bs-interval": item[:interval] } do
|
51
|
+
img class: "d-block w-100", path: item[:path]
|
52
|
+
if item[:title] || item[:text]
|
53
|
+
div class: "carousel-caption d-none d-md-block #{item[:title_class]}" do
|
54
|
+
heading size: 5 do
|
55
|
+
plain item[:title]
|
56
|
+
end
|
57
|
+
paragraph do
|
58
|
+
plain item[:text]
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def controls_partial
|
67
|
+
a class: "carousel-control-prev", data: { "bs-target": "##{carousel_id}", "bs-slide": :prev }, 'role': "button" do
|
68
|
+
span class: "carousel-control-prev-icon", 'aria-hidden': "true"
|
69
|
+
span class: "visually-hidden" do
|
70
|
+
plain "Previous"
|
71
|
+
end
|
72
|
+
end
|
73
|
+
a class: "carousel-control-next", data: { "bs-target": "##{carousel_id}", "bs-slide": :next }, 'role': "button" do
|
74
|
+
span class: "carousel-control-next-icon", 'aria-hidden': "true"
|
75
|
+
span class: "visually-hidden" do
|
76
|
+
plain "Next"
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def carousel_attributes
|
82
|
+
options.merge(
|
83
|
+
id: carousel_id,
|
84
|
+
class: carousel_classes,
|
85
|
+
data: { "bs-ride": 'carousel', "bs-interval": (context.interval || 5000) }
|
86
|
+
)
|
87
|
+
end
|
88
|
+
|
89
|
+
def carousel_classes
|
90
|
+
[].tap do |classes|
|
91
|
+
classes << 'carousel slide'
|
92
|
+
classes << 'carousel-fade' if context.fade
|
93
|
+
classes << 'carousel-dark' if context.variant == :dark
|
94
|
+
#custom classes
|
95
|
+
classes << context.bs_class
|
96
|
+
end.join(' ').strip
|
97
|
+
end
|
98
|
+
|
99
|
+
def carousel_id
|
100
|
+
@carousel_id ||= "matestack-carousel-#{SecureRandom.hex}"
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|
@@ -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
|
|
@@ -0,0 +1,89 @@
|
|
1
|
+
import * as bootstrap from 'bootstrap'
|
2
|
+
|
3
|
+
import MatestackUiVueJs from 'matestack-ui-vuejs'
|
4
|
+
|
5
|
+
const collapseComponent = {
|
6
|
+
mixins: [MatestackUiVueJs.componentMixin],
|
7
|
+
template: MatestackUiVueJs.componentHelpers.inlineTemplate,
|
8
|
+
data() {
|
9
|
+
return {
|
10
|
+
collapseInstance: undefined
|
11
|
+
};
|
12
|
+
},
|
13
|
+
|
14
|
+
methods: {
|
15
|
+
toggle: function (){
|
16
|
+
const self = this;
|
17
|
+
self.collapseInstance.toggle();
|
18
|
+
},
|
19
|
+
show: function(){
|
20
|
+
const self = this;
|
21
|
+
self.collapseInstance.show();
|
22
|
+
},
|
23
|
+
hide: function(){
|
24
|
+
const self = this;
|
25
|
+
self.collapseInstance.hide();
|
26
|
+
},
|
27
|
+
dispose: function(){
|
28
|
+
const self = this;
|
29
|
+
self.collapseInstance.hide();
|
30
|
+
self.collapseInstance.dispose();
|
31
|
+
// ToDo: Error occurs after dispose when click on the button again
|
32
|
+
}
|
33
|
+
},
|
34
|
+
|
35
|
+
mounted: function() {
|
36
|
+
const self = this;
|
37
|
+
const collapseElement = self.getElement()
|
38
|
+
self.collapseInstance = new bootstrap.Collapse(collapseElement, {
|
39
|
+
toggle: false
|
40
|
+
})
|
41
|
+
},
|
42
|
+
|
43
|
+
created: function() {
|
44
|
+
const self = this
|
45
|
+
|
46
|
+
// toggle_on event registration
|
47
|
+
if(self.props["toggle_on"] != undefined){
|
48
|
+
var toggle_events = self.props["toggle_on"].split(",")
|
49
|
+
toggle_events.forEach(toggle_event => MatestackUiVueJs.eventHub.$on(toggle_event.trim(), self.toggle));
|
50
|
+
}
|
51
|
+
// show_on event registration
|
52
|
+
if(self.props["show_on"] != undefined){
|
53
|
+
var show_events = self.props["show_on"].split(",")
|
54
|
+
show_events.forEach(show_event => MatestackUiVueJs.eventHub.$on(show_event.trim(), self.show));
|
55
|
+
}
|
56
|
+
// hide_on event registration
|
57
|
+
if(self.props["hide_on"] != undefined){
|
58
|
+
var hide_events = self.props["hide_on"].split(",")
|
59
|
+
hide_events.forEach(hide_event => MatestackUiVueJs.eventHub.$on(hide_event.trim(), self.hide));
|
60
|
+
}
|
61
|
+
// dispose_on event registration
|
62
|
+
if(self.props["dispose_on"] != undefined){
|
63
|
+
var dispose_events = self.props["dispose_on"].split(",")
|
64
|
+
dispose_events.forEach(dispose_event => MatestackUiVueJs.eventHub.$on(dispose_event.trim(), self.dispose));
|
65
|
+
}
|
66
|
+
},
|
67
|
+
|
68
|
+
beforeUnmount: function(){
|
69
|
+
const self = this
|
70
|
+
if(self.props["toggle_on"] != undefined){
|
71
|
+
var show_events = self.props["toggle_on"].split(",")
|
72
|
+
show_events.forEach(show_event => MatestackUiVueJs.eventHub.$off(show_event.trim(), self.show));
|
73
|
+
}
|
74
|
+
if(self.props["show_on"] != undefined){
|
75
|
+
var show_events = self.props["show_on"].split(",")
|
76
|
+
show_events.forEach(show_event => MatestackUiVueJs.eventHub.$off(show_event.trim(), self.show));
|
77
|
+
}
|
78
|
+
if(self.props["hide_on"] != undefined){
|
79
|
+
var hide_events = self.props["hide_on"].split(",")
|
80
|
+
hide_events.forEach(hide_event => MatestackUiVueJs.eventHub.$off(hide_event.trim(), self.hide));
|
81
|
+
}
|
82
|
+
if(self.props["dispose_on"] != undefined){
|
83
|
+
var dispose_events = self.props["dispose_on"].split(",")
|
84
|
+
dispose_events.forEach(dispose_event => MatestackUiVueJs.eventHub.$off(dispose_event.trim(), self.dispose));
|
85
|
+
}
|
86
|
+
}
|
87
|
+
}
|
88
|
+
|
89
|
+
export default collapseComponent
|
@@ -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
|
@@ -0,0 +1,19 @@
|
|
1
|
+
import * as bootstrap from 'bootstrap'
|
2
|
+
|
3
|
+
import MatestackUiVueJs from 'matestack-ui-vuejs'
|
4
|
+
|
5
|
+
const dropdownComponent = {
|
6
|
+
mixins: [MatestackUiVueJs.componentMixin],
|
7
|
+
template: MatestackUiVueJs.componentHelpers.inlineTemplate,
|
8
|
+
data() {
|
9
|
+
return {
|
10
|
+
dropdownInstance: undefined
|
11
|
+
};
|
12
|
+
},
|
13
|
+
mounted() {
|
14
|
+
// var mydropdown = document.getElementById(this.props["dropdown-id"])
|
15
|
+
// this.dropdownInstance = new bootstrap.Dropdown(mydropdown)
|
16
|
+
}
|
17
|
+
}
|
18
|
+
|
19
|
+
export default dropdownComponent
|
@@ -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
|