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,24 +1,26 @@
1
- class Matestack::Ui::Bootstrap::Components::Progress < Matestack::Ui::Component
1
+ require_relative "../base_component"
2
2
 
3
- optional class: { as: :bs_class }
4
- optional :text, :valuemin, :valuemax
3
+ class Matestack::Ui::Bootstrap::Components::Progress < Matestack::Ui::Bootstrap::BaseComponent
4
+
5
+ optional class: { as: :bs_class }
6
+ optional :valuemin, :valuemax
5
7
  # progress expects a number or a list containing hashes with at least a :value
6
- # other options are :text, :class, :variant, :striped, :animated, :aria_valuenow
8
+ # other options are :text, class: { as: :bs_class }, :variant, :striped, :animated, :aria_valuenow
7
9
  optional :progress
8
10
  optional :value
9
11
  optional :variant, :striped, :animated, :height
10
12
 
11
13
  def response
12
14
  div progress_attributes do
13
- progress = self.progress.is_a?(Array) ? self.progress : [{ value: self.progress || value, text: self.text }]
15
+ progress = context.progress.is_a?(Array) ? context.progress : [{ value: context.progress || context.value, text: context.text }]
14
16
  progress.each do |prog|
15
- progress_bar(prog[:value], valuemin, valuemax,
16
- text: prog[:text], klass: prog[:class], variant: prog[:variant] || variant,
17
- striped: prog[:striped] || striped, animated: prog[:animated] || animated,
17
+ progress_bar(prog[:value], context.valuemin, context.valuemax,
18
+ text: prog[:text], klass: prog[:class], variant: prog[:variant] || context.variant,
19
+ striped: prog[:striped] || context.striped, animated: prog[:animated] || context.animated,
18
20
  aria_valuenow: prog[:aria_valuenow]
19
21
  )
20
22
  end
21
- yield_components
23
+ yield if block_given?
22
24
  end
23
25
  end
24
26
 
@@ -26,10 +28,10 @@ class Matestack::Ui::Bootstrap::Components::Progress < Matestack::Ui::Component
26
28
 
27
29
  def progress_attributes
28
30
  attributes = {}.tap do |hash|
29
- hash[:class] = "progress #{bs_class}".strip
30
- hash[:attributes] = { style: "height: #{height}px;" } if height
31
+ hash[:class] = "progress #{context.bs_class}".strip
32
+ hash[:style] = "height: #{context.height}px;" if context.height
31
33
  end
32
- html_attributes.merge(
34
+ options.merge(
33
35
  attributes
34
36
  )
35
37
  end
@@ -43,13 +45,11 @@ class Matestack::Ui::Bootstrap::Components::Progress < Matestack::Ui::Component
43
45
  def progress_bar_attributes(value, klass, variant, striped, animated, aria_valuenow)
44
46
  {
45
47
  class: progress_bar_classes(klass, variant, striped, animated),
46
- attributes: {
47
- role: :progressbar,
48
- style: "width: #{value.to_i > 0 ? value : 0}%;",
49
- 'aria-valuenow': aria_valuenow || value || 0,
50
- 'aria-valuemin': valuemin || 0,
51
- 'aria-valuemax': valuemax || 100
52
- }
48
+ role: :progressbar,
49
+ style: "width: #{value.to_i > 0 ? value : 0}%;",
50
+ 'aria-valuenow': aria_valuenow || value || 0,
51
+ 'aria-valuemin': context.valuemin || 0,
52
+ 'aria-valuemax': context.valuemax || 100
53
53
  }
54
54
  end
55
55
 
@@ -0,0 +1,50 @@
1
+ require_relative "../base_component"
2
+
3
+ class Matestack::Ui::Bootstrap::Components::Scrollspy < Matestack::Ui::Bootstrap::BaseComponent
4
+
5
+ required :height
6
+
7
+ optional :offset # pixel to offset from top, by default 10
8
+ optional method: { as: :bs_method } # find which section, by default auto
9
+ optional :target # scroll target id
10
+ optional class: { as: :bs_class } # adding custom class to scrollspy
11
+
12
+ def response
13
+ div scrollspy_attributes do
14
+ yield if block_given?
15
+ end
16
+ end
17
+
18
+ protected
19
+
20
+ def scrollspy_attributes
21
+ attributes = {}.tap do |hash|
22
+ hash[:class] = scrollspy_classes
23
+ hash[:data] = { "bs-spy": "scroll", "bs-target": "#{context.target}" }
24
+ hash[:data].merge!("bs-offset": context.offset) if context.offset.present?
25
+ hash[:data].merge!("bs-method": :"#{context.bs_method}") if context.bs_method.present?
26
+ hash[:style] = "overflow-y: scroll; position: relative;"
27
+ hash[:style] << "height: #{parsed_height};"
28
+ hash[:tabindex] = 0
29
+ end
30
+ options.merge(
31
+ attributes
32
+ )
33
+ end
34
+
35
+ def parsed_height
36
+ if context.height.present?
37
+ if context.height.to_s.include?("px") || context.height.to_s.include?("em") || context.height.to_s.include?("rem")
38
+ context.height
39
+ else
40
+ "#{context.height}px"
41
+ end
42
+ end
43
+ end
44
+
45
+ def scrollspy_classes
46
+ [].tap do |classes|
47
+ classes << context.bs_class
48
+ end.join(' ').strip
49
+ end
50
+ end
@@ -0,0 +1,33 @@
1
+ require_relative "../base_component"
2
+
3
+ class Matestack::Ui::Bootstrap::Components::SectionCard < Matestack::Ui::Bootstrap::BaseComponent
4
+
5
+ optional :id, :title, :subtitle, :icon, :slots, :content_padding
6
+
7
+ def response
8
+ section id: context.id, class: "section-card rounded shadow-sm mb-4 bg-white #{options[:class]}" do
9
+ div class: "d-flex flex-row justify-content-between" do
10
+ if context.title.present? || context.subtitle.present?
11
+ div class: "section-card-heading p-4" do
12
+ heading size: 5, class: "mb-0" do
13
+ bs_icon name: context.icon, size: "35" if context.icon.present?
14
+ plain context.title
15
+ end
16
+ small class: "text-muted" do
17
+ plain context.subtitle
18
+ end
19
+ end
20
+ end
21
+ if slots.present? && slots[:actions].present?
22
+ div class: "section-card-actions p-4" do
23
+ slot :actions
24
+ end
25
+ end
26
+ end
27
+ div class: "section-card-content #{'p-4' unless context.content_padding == false} #{'pt-1' if context.title || context.subtitle}" do
28
+ yield if block_given?
29
+ end
30
+ end
31
+ end
32
+
33
+ end
@@ -0,0 +1,35 @@
1
+ require_relative "../base_component"
2
+
3
+ class Matestack::Ui::Bootstrap::Components::Spinner < Matestack::Ui::Bootstrap::BaseComponent
4
+
5
+ optional class: { as: :bs_class }
6
+ optional :kind, :variant, :size, :sr_only
7
+
8
+ def response
9
+ div spinner_attributes do
10
+ span class: "visually-hidden" do
11
+ plain context.sr_only
12
+ end
13
+ end
14
+ end
15
+
16
+ protected
17
+
18
+ def spinner_attributes
19
+ options.merge(
20
+ class: spinner_class,
21
+ 'role': "status"
22
+ )
23
+ end
24
+
25
+ def spinner_class
26
+ [].tap do |classes|
27
+ spinner_kind = context.kind || :border
28
+ classes << "spinner-#{spinner_kind}"
29
+ classes << "text-#{context.variant || 'primary'}"
30
+ classes << "spinner-#{spinner_kind}-sm" if context.size
31
+ #optional classes
32
+ classes << context.bs_class
33
+ end.join(' ').strip
34
+ end
35
+ end
@@ -0,0 +1,79 @@
1
+ require_relative "../base_component"
2
+
3
+ class Matestack::Ui::Bootstrap::Components::TabNav < Matestack::Ui::Bootstrap::BaseComponent
4
+
5
+ required :id
6
+
7
+ optional :items, :variant, :fill, :justified, :vertical, :vertical_up_to_sm,
8
+ :vertical_up_to_md, :vertical_up_to_xl, :horizontal,
9
+ class: { as: :bs_class }
10
+
11
+ def response
12
+ if context.items.present?
13
+ ul nav_attributes do
14
+ nav_items_partial
15
+ end
16
+ end
17
+ div class: "tab-content", id: "#{context.id}Content" do
18
+ yield if block_given?
19
+ end
20
+ end
21
+
22
+ protected
23
+
24
+ def nav_items_partial
25
+ context.items.each do |item|
26
+ li class: "nav-item", role: "presentation" do
27
+ a class: "nav-link #{'active' if item[:active]}",
28
+ id: "tab-#{item[:id]}",
29
+ path: "#tab-#{item[:id]}-content",
30
+ role: "tab",
31
+ "aria-controls": "tab-#{item[:id]}",
32
+ "aria-selected": "#{'true' if item[:active]}",
33
+ "data-bs-toggle": "tab" do
34
+ bs_icon name: item[:icon], size: 20 if item[:icon]
35
+ span item[:text], class: "#{'ps-3' if item[:icon]}" if item[:text]
36
+ end
37
+ end
38
+ end
39
+ end
40
+
41
+ def link_attrs path, active, disabled, delay=nil
42
+ {}.tap do |hash|
43
+ hash[:class] = "nav-link #{'active' if path == request.fullpath } #{'disabled' if disabled}"
44
+ hash[:'aria-selected'] = path == request.fullpath ? 'true' : 'false'
45
+ hash[:'aria-current'] = 'page' if active == true
46
+ hash[:'aria-disabled'] = 'true' if disabled
47
+ hash[:role] = "tab" if toggle.present?
48
+ hash[:'aria-controls'] = "#{path.gsub('#','')}" if context.toggle.present?
49
+
50
+ hash[:data] = { "bs-toggle": "pill" } if context.pills
51
+ hash[:data] = { "bs-toggle": "tab" } if context.tabs
52
+ hash[:path] = path
53
+ end
54
+ end
55
+
56
+ def nav_attributes
57
+ options.merge(
58
+ id: context.id,
59
+ class: nav_classes,
60
+ role: "tablist"
61
+ )
62
+ end
63
+
64
+ def nav_classes
65
+ [].tap do |classes|
66
+ classes << 'nav'
67
+ classes << 'nav-tabs' if context.variant == :tabs || context.variant.nil?
68
+ classes << 'nav-pills' if context.variant == :pills
69
+ classes << 'nav-fill' if context.fill
70
+ classes << 'nav-justified' if context.justified
71
+ classes << 'flex-column' if context.vertical
72
+ classes << 'flex-column flex-sm-column flex-md-row' if context.vertical_up_to_sm
73
+ classes << 'flex-column flex-sm-column flex-md-column flex-lg-row' if context.vertical_up_to_md
74
+ classes << 'flex-column flex-sm-column flex-md-column flex-lg-column flex-xl-row' if context.vertical_up_to_xl
75
+ classes << "justify-content-#{context.horizontal}" if context.horizontal.present?
76
+ classes << context.bs_class
77
+ end.join(' ').strip
78
+ end
79
+ end
@@ -0,0 +1,35 @@
1
+ require_relative "../base_component"
2
+
3
+ class Matestack::Ui::Bootstrap::Components::TabNavContent < Matestack::Ui::Bootstrap::BaseComponent
4
+
5
+ required :id
6
+
7
+ optional :active, class: { as: :bs_class }
8
+
9
+ def response
10
+ div tab_content_attributes do
11
+ yield if block_given?
12
+ end
13
+ end
14
+
15
+ protected
16
+
17
+ def tab_content_attributes
18
+ options.merge(
19
+ id: "tab-#{context.id}-content",
20
+ class: tab_content_classes,
21
+ role: "tabpanel",
22
+ "aria-labelledby": "tab-#{context.id}"
23
+ )
24
+ end
25
+
26
+ def tab_content_classes
27
+ [].tap do |classes|
28
+ classes << 'tab-pane'
29
+ classes << 'fade'
30
+ classes << 'show ' if context.active
31
+ classes << 'active' if context.active
32
+ classes << context.bs_class
33
+ end.join(' ').strip
34
+ end
35
+ end
@@ -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-toast', {
4
+ import MatestackUiCore from 'matestack-ui-core'
5
+
6
+ Vue.component('matestack-ui-bootstrap-toast', {
4
7
 
5
8
  mixins: [MatestackUiCore.componentMixin],
6
9
  data() {
@@ -13,15 +16,15 @@ MatestackUiCore.Vue.component('matestack-ui-bootstrap-toast', {
13
16
  methods: {
14
17
  show: function(event){
15
18
  const self = this;
16
- if(this.componentConfig["autohide"]){
19
+ if(this.props["autohide"]){
17
20
  setTimeout(function () {
18
21
  self.showing = false;
19
22
  }, 5000);
20
23
  }
21
- if(this.componentConfig["delay"]){
24
+ if(this.props["delay"]){
22
25
  setTimeout(function () {
23
26
  self.showing = true;
24
- }, parseInt(self.componentConfig["delay"]));
27
+ }, parseInt(self.props["delay"]));
25
28
  } else {
26
29
  self.showing = true
27
30
  }
@@ -48,37 +51,37 @@ MatestackUiCore.Vue.component('matestack-ui-bootstrap-toast', {
48
51
  created: function() {
49
52
  const self = this
50
53
 
51
- if(this.componentConfig["show_on"] != undefined){
52
- var show_events = this.componentConfig["show_on"].split(",")
54
+ if(this.props["show_on"] != undefined){
55
+ var show_events = this.props["show_on"].split(",")
53
56
  show_events.forEach(show_event => MatestackUiCore.matestackEventHub.$on(show_event.trim(), self.show));
54
57
  }
55
58
 
56
- if(this.componentConfig["hide_on"] != undefined){
57
- var show_events = this.componentConfig["hide_on"].split(",")
59
+ if(this.props["hide_on"] != undefined){
60
+ var show_events = this.props["hide_on"].split(",")
58
61
  show_events.forEach(show_event => MatestackUiCore.matestackEventHub.$on(show_event.trim(), self.hide));
59
62
  }
60
63
 
61
- if(this.componentConfig["dispose_on"] != undefined){
62
- var show_events = this.componentConfig["dispose_on"].split(",")
64
+ if(this.props["dispose_on"] != undefined){
65
+ var show_events = this.props["dispose_on"].split(",")
63
66
  show_events.forEach(show_event => MatestackUiCore.matestackEventHub.$on(show_event.trim(), self.dispose));
64
67
  }
65
68
  },
66
69
 
67
70
  beforeDestroy: function() {
68
71
  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(",")
72
+ MatestackUiCore.matestackEventHub.$off(this.props["show_on"], self.show);
73
+ MatestackUiCore.matestackEventHub.$off(this.props["hide_on"], self.hide);
74
+ MatestackUiCore.matestackEventHub.$off(this.props["dispose_on"], self.hide);
75
+ if(this.props["show_on"] != undefined){
76
+ var shown_events = this.props["show_on"].split(",")
74
77
  shown_events.forEach(show_event => MatestackUiCore.matestackEventHub.$off(show_event.trim(), self.show));
75
78
  }
76
- if(this.componentConfig["hide_on"] != undefined){
77
- var hiden_events = this.componentConfig["hide_on"].split(",")
79
+ if(this.props["hide_on"] != undefined){
80
+ var hiden_events = this.props["hide_on"].split(",")
78
81
  hiden_events.forEach(hide_event => MatestackUiCore.matestackEventHub.$off(hide_event.trim(), self.hide));
79
82
  }
80
- if(this.componentConfig["dispose_on"] != undefined){
81
- var hiden_events = this.componentConfig["dispose_on"].split(",")
83
+ if(this.props["dispose_on"] != undefined){
84
+ var hiden_events = this.props["dispose_on"].split(",")
82
85
  hiden_events.forEach(hide_event => MatestackUiCore.matestackEventHub.$off(hide_event.trim(), self.dispose));
83
86
  }
84
87
  },
@@ -0,0 +1,113 @@
1
+ require_relative "../base_vue_js_component"
2
+
3
+ class Matestack::Ui::Bootstrap::Components::Toast < Matestack::Ui::Bootstrap::BaseVueJsComponent
4
+ vue_name "matestack-ui-bootstrap-toast"
5
+
6
+ # header attributes, expects a hash or string
7
+ # possible keys `:icon_class, :icon, :title, :subtitle`
8
+ optional :header
9
+ # body expects a string as message inside toast
10
+ optional :body
11
+ # placement attributes, expects a hash wiht possible keys: position, min-height
12
+ optional :placement # for adding custom css style
13
+ optional :important, :delay, :autohide, :animation
14
+ optional class: { as: :bs_class }
15
+ optional :attributes, :data
16
+
17
+
18
+ optional :show_on, :hide_on, :dispose_on
19
+
20
+ def response
21
+ standard_placement_partial
22
+ # standard_placement_partial unless placement.present?
23
+ # custom_placement_partial if placement.present?
24
+ end
25
+
26
+ protected
27
+
28
+ def vue_props
29
+ {}.tap do |props|
30
+ props[:delay] = context.delay
31
+ props[:autohide] = context.autohide
32
+ props[:show_on] = context.show_on
33
+ props[:hide_on] = context.hide_on
34
+ props[:dispose_on] = context.dispose_on
35
+ end
36
+ end
37
+
38
+ def custom_placement_partial
39
+ div placement_attrs do
40
+ standard_placement_partial
41
+ end
42
+ end
43
+
44
+ def standard_placement_partial
45
+ div toast_attributes do
46
+ header_partial if context.header || slots && slots[:header]
47
+ body_partial
48
+ end
49
+ end
50
+
51
+ def header_partial
52
+ header = context.header.is_a?(Hash) ? context.header : { title: context.header }
53
+ div class: "toast-header" do
54
+ img class: "#{'rounded me-2' || header[:icon_class]}", path: header[:icon] if header[:icon].present?
55
+ strong header[:title], class: "me-auto" if header[:title].present?
56
+ small header[:subtitle] if header[:subtitle].present?
57
+
58
+ slot :header if slots && slots[:header]
59
+ bs_close dismiss: 'toast', class: "ms-2 mb-1", "@click": "hide()"
60
+ end
61
+
62
+ end
63
+
64
+ def body_partial
65
+ div class: "toast-body" do
66
+ plain context.body if context.body
67
+ end
68
+ unless context.header || slots && slots[:header]
69
+ bs_close dismiss: 'toast', class: "ms-auto me-2 btn-close-white", "@click": "hide()"
70
+ end
71
+ end
72
+
73
+ def toast_attributes
74
+ options.merge(
75
+ class: toast_classes,
76
+ data: toast_data
77
+ ).merge(toast_attrs)
78
+ end
79
+
80
+ def toast_data
81
+ (context.data || {}).tap do |hash|
82
+ hash["bs-delay"] = context.delay.nil? ? 5000 : context.delay
83
+ hash["bs-autohide"] = context.autohide.nil? ? "true" : "#{context.autohide}"
84
+ hash["bs-animation"] = context.animation.nil? ? "true" : "#{context.animation}"
85
+ end
86
+ end
87
+
88
+ def toast_attrs
89
+ (context.attributes || {}).tap do |hash|
90
+ hash[:role] = (context.important == false ? 'status' : 'alert')
91
+ hash[:'aria-live'] = (context.important ? 'assertive' : 'polite') if context.important.present? && !context.placement.present?
92
+ hash[:'aria-live'] = 'assertive' unless context.important.present?
93
+ hash[:'aria-atomic'] = 'true' unless context.placement.present?
94
+ hash[:style] = "z-index: 10000; position: fixed; #{context.placement[:position] || 'top: 0; right: 0;' }" if context.placement.present?
95
+ hash[:"v-bind:class"] = "{'show' : showing }"
96
+ end
97
+ end
98
+
99
+ def toast_classes
100
+ [].tap do |classes|
101
+ classes << 'toast p-0 fade d-flex align-items-center border-0'
102
+ classes << context.bs_class
103
+ end.join(' ').strip
104
+ end
105
+
106
+ def placement_attrs
107
+ {}.tap do |hash|
108
+ hash[:'aria-live'] = (context.important ? 'assertive' : 'polite') if context.important.present?
109
+ hash[:'aria-atomic'] = 'true'
110
+ hash[:style] = "position: relative; min-height: #{context.placement[:height]};"
111
+ end
112
+ end
113
+ end