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
@@ -1,106 +0,0 @@
|
|
1
|
-
class Matestack::Ui::Bootstrap::Components::Modal < Matestack::Ui::VueJsComponent
|
2
|
-
vue_js_component_name 'matestack-ui-bootstrap-modal'
|
3
|
-
|
4
|
-
# header attributes, expects a hash or string
|
5
|
-
# possible keys `:class, :text, :size`
|
6
|
-
optional :header
|
7
|
-
# body attributes, expects a hash or string
|
8
|
-
# possible keys `:class, :text`
|
9
|
-
optional :body
|
10
|
-
# footer is a dismiss button, expects a hash or string for button text
|
11
|
-
# possible keys `:class, :text`
|
12
|
-
optional :footer
|
13
|
-
optional :fade, :size
|
14
|
-
optional :fullscreen # fullscreen attribute, expects boolean or bootstrap breakpoint
|
15
|
-
optional :static, :keyboard, :scrollable, :centered
|
16
|
-
optional :modal_dialog_class, class: { as: :bs_class }, id: { as: :bs_id }
|
17
|
-
# event trigger
|
18
|
-
optional :toggle_on, :show_on, :hide_on, :handle_update_on, :dispose_on
|
19
|
-
|
20
|
-
optional :slots
|
21
|
-
|
22
|
-
def response
|
23
|
-
div modal_attributes do
|
24
|
-
div class: dialog_classes do
|
25
|
-
div class: "modal-content" do
|
26
|
-
header_partial if header || (slots && slots[:header])
|
27
|
-
body_partial if body || slots && slots[:body]
|
28
|
-
footer_partial if footer || (slots && slots[:footer])
|
29
|
-
yield_components
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
protected
|
36
|
-
|
37
|
-
def header_partial
|
38
|
-
header = self.header.is_a?(Hash) ? self.header : { text: self.header }
|
39
|
-
div class: "modal-header" do
|
40
|
-
if slots && slots[:header]
|
41
|
-
slot slots[:header]
|
42
|
-
else
|
43
|
-
heading size: (header[:size] || 5), class: "modal-title #{header[:class]}", text: header[:text] if header[:text].present?
|
44
|
-
bs_close dismiss: 'modal'
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
def body_partial
|
50
|
-
body = self.body.is_a?(Hash) ? self.body : { text: self.body }
|
51
|
-
div class: "modal-body #{body[:class]}".strip do
|
52
|
-
if slots && slots[:body]
|
53
|
-
slot slots[:body]
|
54
|
-
else
|
55
|
-
plain body[:text] if body[:text].present?
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
def footer_partial
|
61
|
-
footer = self.footer.is_a?(Hash) ? self.footer : { text: self.footer }
|
62
|
-
div class: "modal-footer" do
|
63
|
-
slot slots[:footer] if slots && slots[:footer]
|
64
|
-
if footer[:text].present?
|
65
|
-
button class: "btn #{footer[:class].present? ? footer[:class] : 'btn-secondary'}",
|
66
|
-
data: { "bs-dismiss": 'modal' }, attributes: { type: 'button' },
|
67
|
-
text: footer[:text]
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
def modal_attributes
|
73
|
-
attributes = {}.tap do |hash|
|
74
|
-
hash[:class] = modal_classes
|
75
|
-
hash[:attributes] = { 'tabindex': "-1", 'aria-labelledby': "#{bs_id}Label", 'aria-hidden': "true" }
|
76
|
-
hash[:data] = {}.tap do |data|
|
77
|
-
data[:backdrop] = "static" if static
|
78
|
-
data[:keyboard] = "false" if keyboard
|
79
|
-
end
|
80
|
-
end
|
81
|
-
html_attributes.merge(
|
82
|
-
attributes
|
83
|
-
)
|
84
|
-
end
|
85
|
-
|
86
|
-
def modal_classes
|
87
|
-
[].tap do |classes|
|
88
|
-
classes << 'modal'
|
89
|
-
classes << 'fade' if fade || !fade.present?
|
90
|
-
classes << bs_class
|
91
|
-
end.join(' ').strip
|
92
|
-
end
|
93
|
-
|
94
|
-
def dialog_classes
|
95
|
-
[].tap do |classes|
|
96
|
-
classes << 'modal-dialog'
|
97
|
-
classes << 'modal-dialog-centered' if centered
|
98
|
-
classes << 'modal-dialog-scrollable' if scrollable
|
99
|
-
classes << "modal-#{size}" if size
|
100
|
-
if fullscreen.present?
|
101
|
-
classes << (fullscreen == true ? 'modal-fullscreen' : "modal-fullscreen-#{fullscreen}-down")
|
102
|
-
end
|
103
|
-
classes << modal_dialog_class
|
104
|
-
end.join(' ').strip
|
105
|
-
end
|
106
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
import * as bootstrap from 'bootstrap'
|
2
|
-
|
3
|
-
MatestackUiCore.Vue.component('matestack-ui-bootstrap-popover', {
|
4
|
-
|
5
|
-
mixins: [MatestackUiCore.componentMixin],
|
6
|
-
data() {
|
7
|
-
return {
|
8
|
-
popoverInstance: undefined
|
9
|
-
|
10
|
-
};
|
11
|
-
},
|
12
|
-
methods: {
|
13
|
-
|
14
|
-
},
|
15
|
-
mounted: function() {
|
16
|
-
const self = this;
|
17
|
-
var popover = self.$el
|
18
|
-
self.popoverInstance = new bootstrap.Popover(popover, {})
|
19
|
-
},
|
20
|
-
created: function() {
|
21
|
-
},
|
22
|
-
|
23
|
-
beforeDestroy: function() {
|
24
|
-
|
25
|
-
},
|
26
|
-
});
|
@@ -1,48 +0,0 @@
|
|
1
|
-
class Matestack::Ui::Bootstrap::Components::Scrollspy < Matestack::Ui::Component
|
2
|
-
|
3
|
-
requires :height
|
4
|
-
|
5
|
-
optional :offset # pixel to offset from top, by default 10
|
6
|
-
optional method: { as: :bs_method} # find which section, by default auto
|
7
|
-
optional :target # scroll target id
|
8
|
-
optional class: { as: :bs_class} # adding custom class to scrollspy
|
9
|
-
|
10
|
-
def response
|
11
|
-
div scrollspy_attributes do
|
12
|
-
yield_components
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
protected
|
17
|
-
|
18
|
-
def scrollspy_attributes
|
19
|
-
attributes = {}.tap do |hash|
|
20
|
-
hash[:class] = scrollspy_classes
|
21
|
-
hash[:data] = { "bs-spy": "scroll", "bs-target": "#{target}" }
|
22
|
-
hash[:data].merge!("bs-offset": offset) if offset.present?
|
23
|
-
hash[:data].merge!("bs-method": :"#{bs_method}") if bs_method.present?
|
24
|
-
hash[:style] = "overflow-y: scroll; position: relative;"
|
25
|
-
hash[:style] << "height: #{parsed_height};"
|
26
|
-
hash[:tabindex] = 0
|
27
|
-
end
|
28
|
-
html_attributes.merge(
|
29
|
-
attributes
|
30
|
-
)
|
31
|
-
end
|
32
|
-
|
33
|
-
def parsed_height
|
34
|
-
if height.present?
|
35
|
-
if height.to_s.include?("px") || height.to_s.include?("em") || height.to_s.include?("rem")
|
36
|
-
height
|
37
|
-
else
|
38
|
-
"#{height}px"
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
def scrollspy_classes
|
44
|
-
[].tap do |classes|
|
45
|
-
classes << bs_class
|
46
|
-
end.join(' ').strip
|
47
|
-
end
|
48
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
class Matestack::Ui::Bootstrap::Components::SectionCard < Matestack::Ui::Component
|
2
|
-
|
3
|
-
optional :id, :title, :subtitle, :icon, :slots, :content_padding
|
4
|
-
|
5
|
-
def response
|
6
|
-
section id: :id, class: "section-card rounded shadow-sm mb-4 bg-white" do
|
7
|
-
div class: "d-flex flex-row justify-content-between" do
|
8
|
-
if title.present? || subtitle.present?
|
9
|
-
div class: "section-card-heading p-4" do
|
10
|
-
heading size: 5, class: "mb-0" do
|
11
|
-
bs_icon name: icon, size: "35" if icon.present?
|
12
|
-
plain title
|
13
|
-
end
|
14
|
-
small class: "text-muted" do
|
15
|
-
plain subtitle
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
if slots.present? && slots[:actions].present?
|
20
|
-
div class: "section-card-actions p-4" do
|
21
|
-
slot slots[:actions]
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
div class: "section-card-content #{'p-4' unless content_padding == false} #{'pt-1' if title || subtitle}" do
|
26
|
-
yield_components
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
class Matestack::Ui::Bootstrap::Components::Spinner < Matestack::Ui::Component
|
2
|
-
|
3
|
-
optional class: { as: :bs_class }
|
4
|
-
optional :kind, :variant, :size, :sr_only
|
5
|
-
|
6
|
-
def response
|
7
|
-
div spinner_attributes do
|
8
|
-
span class: "visually-hidden", text: sr_only
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
protected
|
13
|
-
|
14
|
-
def spinner_attributes
|
15
|
-
html_attributes.merge(
|
16
|
-
class: spinner_class,
|
17
|
-
attributes: { 'role': "status" }
|
18
|
-
)
|
19
|
-
end
|
20
|
-
|
21
|
-
def spinner_class
|
22
|
-
[].tap do |classes|
|
23
|
-
spinner_kind = kind || :border
|
24
|
-
classes << "spinner-#{spinner_kind}"
|
25
|
-
classes << "text-#{variant || 'primary'}"
|
26
|
-
classes << "spinner-#{spinner_kind}-sm" if size
|
27
|
-
#optional classes
|
28
|
-
classes << bs_class
|
29
|
-
end.join(' ').strip
|
30
|
-
end
|
31
|
-
end
|
@@ -1,83 +0,0 @@
|
|
1
|
-
class Matestack::Ui::Bootstrap::Components::TabNav < Matestack::Ui::Component
|
2
|
-
|
3
|
-
requires :id
|
4
|
-
|
5
|
-
optional :items, :variant, :fill, :justified, :vertical, :vertical_up_to_sm,
|
6
|
-
:vertical_up_to_md, :vertical_up_to_xl, :horizontal,
|
7
|
-
class: { as: :bs_class }, attributes: { as: :bs_attrs}
|
8
|
-
|
9
|
-
def response
|
10
|
-
if items.present?
|
11
|
-
ul nav_attributes do
|
12
|
-
nav_items_partial
|
13
|
-
end
|
14
|
-
end
|
15
|
-
div class: "tab-content", id: "#{id}Content" do
|
16
|
-
yield_components
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
protected
|
21
|
-
|
22
|
-
def nav_items_partial
|
23
|
-
items.each do |item|
|
24
|
-
li class: "nav-item", attributes: { role: "presentation" } do
|
25
|
-
# '<a class="nav-link active" id="pills-home-tab" data-toggle="pill" href="#pills-home" role="tab" aria-controls="pills-home" aria-selected="true">Home</a>'
|
26
|
-
link class: "nav-link #{'active' if item[:active]}",
|
27
|
-
id: "tab-#{item[:id]}",
|
28
|
-
path: "#tab-#{item[:id]}-content",
|
29
|
-
attributes: {
|
30
|
-
role: "tab",
|
31
|
-
"aria-controls": "tab-#{item[:id]}",
|
32
|
-
"aria-selected": "#{'true' if item[:active]}",
|
33
|
-
"data-bs-toggle": "tab"
|
34
|
-
} do
|
35
|
-
bs_icon name: item[:icon], size: 20 if item[:icon]
|
36
|
-
span class: "#{'ps-3' if item[:icon]}", text: item[:text] if item[:text]
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def link_attrs path, active, disabled, delay=nil
|
43
|
-
{}.tap do |hash|
|
44
|
-
hash[:class] = "nav-link #{'active' if path == request.fullpath } #{'disabled' if disabled}"
|
45
|
-
|
46
|
-
hash[:attributes] = {}.tap do |hash|
|
47
|
-
hash[:'aria-selected'] = path == request.fullpath ? 'true' : 'false'
|
48
|
-
hash[:'aria-current'] = 'page' if active == true
|
49
|
-
hash[:'aria-disabled'] = 'true' if disabled
|
50
|
-
hash[:role] = "tab" if toggle.present?
|
51
|
-
hash[:'aria-controls'] = "#{path.gsub('#','')}" if toggle.present?
|
52
|
-
end
|
53
|
-
|
54
|
-
hash[:data] = { "bs-toggle": "pill" } if pills
|
55
|
-
hash[:data] = { "bs-toggle": "tab" } if tabs
|
56
|
-
hash[:path] = path
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
def nav_attributes
|
61
|
-
html_attributes.merge(
|
62
|
-
id: id,
|
63
|
-
class: nav_classes,
|
64
|
-
attributes: { role: "tablist"}
|
65
|
-
)
|
66
|
-
end
|
67
|
-
|
68
|
-
def nav_classes
|
69
|
-
[].tap do |classes|
|
70
|
-
classes << 'nav'
|
71
|
-
classes << 'nav-tabs' if variant == :tabs || variant.nil?
|
72
|
-
classes << 'nav-pills' if variant == :pills
|
73
|
-
classes << 'nav-fill' if fill
|
74
|
-
classes << 'nav-justified' if justified
|
75
|
-
classes << 'flex-column' if vertical
|
76
|
-
classes << 'flex-column flex-sm-column flex-md-row' if vertical_up_to_sm
|
77
|
-
classes << 'flex-column flex-sm-column flex-md-column flex-lg-row' if vertical_up_to_md
|
78
|
-
classes << 'flex-column flex-sm-column flex-md-column flex-lg-column flex-xl-row' if vertical_up_to_xl
|
79
|
-
classes << "justify-content-#{horizontal}" if horizontal.present?
|
80
|
-
classes << bs_class
|
81
|
-
end.join(' ').strip
|
82
|
-
end
|
83
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
class Matestack::Ui::Bootstrap::Components::TabNavContent < Matestack::Ui::Component
|
2
|
-
|
3
|
-
requires :id
|
4
|
-
|
5
|
-
optional :tabs, :pills, :active, class: { as: :bs_class }, attributes: { as: :bs_attrs}
|
6
|
-
|
7
|
-
def response
|
8
|
-
div tab_content_attributes do
|
9
|
-
yield_components
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
protected
|
14
|
-
|
15
|
-
def tab_content_attributes
|
16
|
-
html_attributes.merge(
|
17
|
-
id: "tab-#{id}-content",
|
18
|
-
class: tab_content_classes,
|
19
|
-
attributes: { role: "tabpanel", "aria-labelledby": "tab-#{id}" }
|
20
|
-
)
|
21
|
-
end
|
22
|
-
|
23
|
-
def tab_content_classes
|
24
|
-
[].tap do |classes|
|
25
|
-
classes << 'tab-pane'
|
26
|
-
classes << 'fade'
|
27
|
-
classes << 'show ' if active
|
28
|
-
classes << 'active' if active
|
29
|
-
classes << bs_class
|
30
|
-
end.join(' ').strip
|
31
|
-
end
|
32
|
-
end
|
@@ -1,85 +0,0 @@
|
|
1
|
-
import * as bootstrap from 'bootstrap'
|
2
|
-
|
3
|
-
MatestackUiCore.Vue.component('matestack-ui-bootstrap-toast', {
|
4
|
-
|
5
|
-
mixins: [MatestackUiCore.componentMixin],
|
6
|
-
data() {
|
7
|
-
return {
|
8
|
-
toastsInstance: undefined,
|
9
|
-
eventData: {},
|
10
|
-
showing: false,
|
11
|
-
};
|
12
|
-
},
|
13
|
-
methods: {
|
14
|
-
show: function(event){
|
15
|
-
const self = this;
|
16
|
-
if(this.componentConfig["autohide"]){
|
17
|
-
setTimeout(function () {
|
18
|
-
self.showing = false;
|
19
|
-
}, 5000);
|
20
|
-
}
|
21
|
-
if(this.componentConfig["delay"]){
|
22
|
-
setTimeout(function () {
|
23
|
-
self.showing = true;
|
24
|
-
}, parseInt(self.componentConfig["delay"]));
|
25
|
-
} else {
|
26
|
-
self.showing = true
|
27
|
-
}
|
28
|
-
this.eventData = event
|
29
|
-
},
|
30
|
-
hide: function(event){
|
31
|
-
const self = this;
|
32
|
-
this.showing = false
|
33
|
-
setTimeout(function () {
|
34
|
-
self.eventData = false;
|
35
|
-
}, 500);
|
36
|
-
},
|
37
|
-
dispose: function(){
|
38
|
-
const self = this;
|
39
|
-
self.toastsInstance.dispose()
|
40
|
-
self.toastsInstance = new bootstrap.Toast(self.$el)
|
41
|
-
}
|
42
|
-
},
|
43
|
-
mounted: function() {
|
44
|
-
const self = this;
|
45
|
-
var myToasts = self.$el
|
46
|
-
self.toastsInstance = new bootstrap.Toast(myToasts)
|
47
|
-
},
|
48
|
-
created: function() {
|
49
|
-
const self = this
|
50
|
-
|
51
|
-
if(this.componentConfig["show_on"] != undefined){
|
52
|
-
var show_events = this.componentConfig["show_on"].split(",")
|
53
|
-
show_events.forEach(show_event => MatestackUiCore.matestackEventHub.$on(show_event.trim(), self.show));
|
54
|
-
}
|
55
|
-
|
56
|
-
if(this.componentConfig["hide_on"] != undefined){
|
57
|
-
var show_events = this.componentConfig["hide_on"].split(",")
|
58
|
-
show_events.forEach(show_event => MatestackUiCore.matestackEventHub.$on(show_event.trim(), self.hide));
|
59
|
-
}
|
60
|
-
|
61
|
-
if(this.componentConfig["dispose_on"] != undefined){
|
62
|
-
var show_events = this.componentConfig["dispose_on"].split(",")
|
63
|
-
show_events.forEach(show_event => MatestackUiCore.matestackEventHub.$on(show_event.trim(), self.dispose));
|
64
|
-
}
|
65
|
-
},
|
66
|
-
|
67
|
-
beforeDestroy: function() {
|
68
|
-
const self = this
|
69
|
-
MatestackUiCore.matestackEventHub.$off(this.componentConfig["show_on"], self.show);
|
70
|
-
MatestackUiCore.matestackEventHub.$off(this.componentConfig["hide_on"], self.hide);
|
71
|
-
MatestackUiCore.matestackEventHub.$off(this.componentConfig["dispose_on"], self.hide);
|
72
|
-
if(this.componentConfig["show_on"] != undefined){
|
73
|
-
var shown_events = this.componentConfig["show_on"].split(",")
|
74
|
-
shown_events.forEach(show_event => MatestackUiCore.matestackEventHub.$off(show_event.trim(), self.show));
|
75
|
-
}
|
76
|
-
if(this.componentConfig["hide_on"] != undefined){
|
77
|
-
var hiden_events = this.componentConfig["hide_on"].split(",")
|
78
|
-
hiden_events.forEach(hide_event => MatestackUiCore.matestackEventHub.$off(hide_event.trim(), self.hide));
|
79
|
-
}
|
80
|
-
if(this.componentConfig["dispose_on"] != undefined){
|
81
|
-
var hiden_events = this.componentConfig["dispose_on"].split(",")
|
82
|
-
hiden_events.forEach(hide_event => MatestackUiCore.matestackEventHub.$off(hide_event.trim(), self.dispose));
|
83
|
-
}
|
84
|
-
},
|
85
|
-
});
|
@@ -1,99 +0,0 @@
|
|
1
|
-
class Matestack::Ui::Bootstrap::Components::Toast < Matestack::Ui::VueJsComponent
|
2
|
-
vue_js_component_name "matestack-ui-bootstrap-toast"
|
3
|
-
|
4
|
-
# header attributes, expects a hash or string
|
5
|
-
# possible keys `:icon_class, :icon, :title, :subtitle`
|
6
|
-
optional :header
|
7
|
-
# body expects a string as message inside toast
|
8
|
-
optional :body
|
9
|
-
# placement attributes, expects a hash wiht possible keys: position, min-height
|
10
|
-
optional :placement # for adding custom css style
|
11
|
-
optional :important, :delay, :autohide, :animation
|
12
|
-
optional class: { as: :bs_class }, attributes: { as: :bs_attrs }, data: { as: :bs_data }
|
13
|
-
optional :slots
|
14
|
-
|
15
|
-
def response
|
16
|
-
standard_placement_partial
|
17
|
-
# standard_placement_partial unless placement.present?
|
18
|
-
# custom_placement_partial if placement.present?
|
19
|
-
end
|
20
|
-
|
21
|
-
protected
|
22
|
-
|
23
|
-
def custom_placement_partial
|
24
|
-
div attributes: placement_attrs do
|
25
|
-
standard_placement_partial
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def standard_placement_partial
|
30
|
-
div toast_attributes do
|
31
|
-
header_partial if header || slots && slots[:header]
|
32
|
-
body_partial
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def header_partial
|
37
|
-
header = self.header.is_a?(Hash) ? self.header : { title: self.header }
|
38
|
-
div class: "toast-header" do
|
39
|
-
img class: "#{'rounded me-2' || header[:icon_class]}", path: header[:icon] if header[:icon].present?
|
40
|
-
strong class: "me-auto", text: header[:title] if header[:title].present?
|
41
|
-
small text: header[:subtitle] if header[:subtitle].present?
|
42
|
-
|
43
|
-
slot slots[:header] if slots && slots[:header]
|
44
|
-
bs_close dismiss: 'toast', class: "ms-2 mb-1", attributes: { "@click": "hide()"}
|
45
|
-
end
|
46
|
-
|
47
|
-
end
|
48
|
-
|
49
|
-
def body_partial
|
50
|
-
div class: "toast-body" do
|
51
|
-
plain body if body
|
52
|
-
end
|
53
|
-
unless header || slots && slots[:header]
|
54
|
-
bs_close dismiss: 'toast', class: "ms-auto me-2 btn-close-white", attributes: { "@click": "hide()"}
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
def toast_attributes
|
59
|
-
html_attributes.merge(
|
60
|
-
class: toast_classes,
|
61
|
-
attributes: toast_attrs,
|
62
|
-
data: toast_data
|
63
|
-
)
|
64
|
-
end
|
65
|
-
|
66
|
-
def toast_data
|
67
|
-
(bs_data || {}).tap do |hash|
|
68
|
-
hash["bs-delay"] = delay.nil? ? 5000 : delay
|
69
|
-
hash["bs-autohide"] = autohide.nil? ? "true" : "#{autohide}"
|
70
|
-
hash["bs-animation"] = animation.nil? ? "true" : "#{animation}"
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
def toast_attrs
|
75
|
-
(bs_attrs || {}).tap do |hash|
|
76
|
-
hash[:role] = (important == false ? 'status' : 'alert')
|
77
|
-
hash[:'aria-live'] = (important ? 'assertive' : 'polite') if important.present? && !placement.present?
|
78
|
-
hash[:'aria-live'] = 'assertive' unless important.present?
|
79
|
-
hash[:'aria-atomic'] = 'true' unless placement.present?
|
80
|
-
hash[:style] = "z-index: 10000; position: fixed; #{placement[:position] || 'top: 0; right: 0;' }" if placement.present?
|
81
|
-
hash["v-bind:class"] = "{'show' : showing }"
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
def toast_classes
|
86
|
-
[].tap do |classes|
|
87
|
-
classes << 'toast p-0 fade d-flex align-items-center border-0'
|
88
|
-
classes << bs_class
|
89
|
-
end.join(' ').strip
|
90
|
-
end
|
91
|
-
|
92
|
-
def placement_attrs
|
93
|
-
{}.tap do |hash|
|
94
|
-
hash[:'aria-live'] = (important ? 'assertive' : 'polite') if important.present?
|
95
|
-
hash[:'aria-atomic'] = 'true'
|
96
|
-
hash[:style] = "position: relative; min-height: #{placement[:height]};"
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
@@ -1,99 +0,0 @@
|
|
1
|
-
class Matestack::Ui::Bootstrap::Form::Checkbox < Matestack::Ui::Core::Form::Checkbox::Base
|
2
|
-
|
3
|
-
vue_js_component_name "matestack-ui-core-form-checkbox"
|
4
|
-
|
5
|
-
optional :form_text
|
6
|
-
optional :disabled
|
7
|
-
optional :variant
|
8
|
-
|
9
|
-
def response
|
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
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
private
|
19
|
-
|
20
|
-
def multiple?
|
21
|
-
options[:options].present?
|
22
|
-
end
|
23
|
-
|
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'
|
48
|
-
)
|
49
|
-
|
50
|
-
input html_attributes.merge(
|
51
|
-
attributes: vue_attributes_for_single_input,
|
52
|
-
type: :checkbox,
|
53
|
-
id: id_for_item(value),
|
54
|
-
value: checked_value,
|
55
|
-
class: 'form-check-input'
|
56
|
-
)
|
57
|
-
|
58
|
-
bootstrap_label text: input_label, for_input: id_for_item(value)
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
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
|
-
|
73
|
-
def render_errors
|
74
|
-
unless @included_config[:errors] == false && (errors == false || errors.nil?) || errors == false
|
75
|
-
div class: 'invalid-feedback', attributes: { 'v-for': "error in #{error_key}", style: "display: block;" } do
|
76
|
-
plain '{{ error }}'
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
def input_error_class
|
82
|
-
'is-invalid'
|
83
|
-
end
|
84
|
-
|
85
|
-
def checkbox_options
|
86
|
-
super || {}
|
87
|
-
end
|
88
|
-
|
89
|
-
def render_form_text
|
90
|
-
div id: "form_text_for_#{attr_key}", class: "form-text" do
|
91
|
-
plain form_text
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
def id_for_item(value)
|
96
|
-
"#{html_attributes[:id]}_#{value}_#{attr_key}"
|
97
|
-
end
|
98
|
-
|
99
|
-
end
|