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
@@ -0,0 +1,116 @@
1
+ class Matestack::Ui::Bootstrap::Form::Input < Matestack::Ui::VueJs::Components::Form::Input
2
+
3
+ include Matestack::Ui::Bootstrap::Registry
4
+
5
+ vue_name "matestack-ui-core-form-input"
6
+
7
+ optional :form_text
8
+ optional :disabled
9
+ optional :browse_button_text
10
+ optional :placeholder
11
+ optional :variant
12
+ optional :min
13
+ optional :max
14
+ optional :step
15
+ optional :show_value
16
+
17
+ def response
18
+ div class: "matestack-ui-bootstrap-input" do
19
+ label input_label, for: attribute_key, class: "form-label" if input_label
20
+ case context.type
21
+ when :range
22
+ input options.merge(input_attributes).merge(bootstrap_range_attributes)
23
+ if context.show_value
24
+ div id: attribute_key, class: "form-text" do
25
+ plain "{{ data['#{attribute_key}'] }}"
26
+ end
27
+ end
28
+ when :file
29
+ file_input
30
+ else
31
+ input options.merge(input_attributes).merge(bootstrap_input_attributes)
32
+ render_errors
33
+ end
34
+ render_form_text if context.form_text
35
+ end
36
+ end
37
+
38
+ def bootstrap_input_attributes
39
+ {
40
+ id: (options[:id] || attribute_key),
41
+ class: (options[:class] || "") << (" form-control"),
42
+ disabled: context.disabled
43
+ }
44
+ end
45
+
46
+ def bootstrap_range_attributes
47
+ {
48
+ class: (options[:class] || "") << (" form-range"),
49
+ disabled: context.disabled,
50
+ min: context.min,
51
+ max: context.max,
52
+ step: context.step
53
+ }
54
+ end
55
+
56
+ def bootstrap_file_input_attributes
57
+ {
58
+ class: (options[:class] || "") << (" form-file-input"),
59
+ disabled: context.disabled
60
+ }
61
+ end
62
+
63
+ def form_file_wrapper_class
64
+ case context.variant
65
+ when :lg
66
+ (options[:class] || "") << (" form-file form-file-lg")
67
+ when :sm
68
+ (options[:class] || "") << (" form-file form-file-sm")
69
+ else
70
+ (options[:class] || "") << (" form-file")
71
+ end
72
+ end
73
+
74
+ def file_input
75
+ div class: form_file_wrapper_class do
76
+ input options.merge(input_attributes).merge(bootstrap_file_input_attributes)
77
+ label class: "form-file-label", for: attribute_key do
78
+ span class: "form-file-text", "v-if": "data['#{attribute_key}']" do
79
+ if context.multiple
80
+ span "v-for": "file in data['#{attribute_key}']" do
81
+ plain "{{ file['name'] }}"
82
+ end
83
+ else
84
+ plain "{{ data['#{attribute_key}']['name'] }}"
85
+ end
86
+ end
87
+ span class: "form-file-text", "v-if": "!data['#{attribute_key}']" do
88
+ plain context.placeholder || "Choose file"
89
+ end
90
+ span class: "form-file-button" do
91
+ plain context.browse_button_text || "Browse"
92
+ end
93
+ end
94
+ render_errors
95
+ end
96
+ end
97
+
98
+ def render_errors
99
+ if display_errors?
100
+ div class: 'invalid-feedback', 'v-for': "error in #{error_key}" do
101
+ plain '{{ error }}'
102
+ end
103
+ end
104
+ end
105
+
106
+ def input_error_class
107
+ 'is-invalid'
108
+ end
109
+
110
+ def render_form_text
111
+ div id: "form_text_for_#{attribute_key}", class: "form-text" do
112
+ plain context.form_text
113
+ end
114
+ end
115
+
116
+ end
@@ -0,0 +1,55 @@
1
+ class Matestack::Ui::Bootstrap::Form::Radio < Matestack::Ui::VueJs::Components::Form::Radio
2
+
3
+ include Matestack::Ui::Bootstrap::Registry
4
+
5
+ vue_name "matestack-ui-core-form-radio"
6
+
7
+ optional :form_text
8
+ optional :disabled
9
+ optional :variant
10
+
11
+ def response
12
+ div class: "matestack-ui-bootstrap-radio" do
13
+ label input_label, class: "form-label" if input_label
14
+
15
+ radio_options.to_a.each_with_index do |item, index|
16
+ div class: "form-check #{'form-check-inline' if context.variant == :inline}" do
17
+ input options.merge(radio_attributes(item)).merge(bootstrap_radio_attributes)
18
+ label item_label(item), class: "form-check-label", for: item_id(item_value(item))
19
+ if index == radio_options.to_a.size - 1
20
+ render_errors
21
+ end
22
+ end
23
+ end
24
+ render_form_text if context.form_text
25
+ end
26
+
27
+ end
28
+
29
+
30
+ def bootstrap_radio_attributes
31
+ {
32
+ class: (options[:class] || "") << (" form-check-input"),
33
+ disabled: context.disabled
34
+ }
35
+ end
36
+
37
+ def render_form_text
38
+ div id: "form_text_for_#{attribute_key}", class: "form-text" do
39
+ plain context.form_text
40
+ end
41
+ end
42
+
43
+ def render_errors
44
+ if display_errors?
45
+ div class: 'invalid-feedback', 'v-for': "error in #{error_key}", style: "display: block;" do
46
+ plain '{{ error }}'
47
+ end
48
+ end
49
+ end
50
+
51
+ def input_error_class
52
+ 'is-invalid'
53
+ end
54
+
55
+ end
@@ -0,0 +1,63 @@
1
+ class Matestack::Ui::Bootstrap::Form::Select < Matestack::Ui::VueJs::Components::Form::Select
2
+
3
+ include Matestack::Ui::Bootstrap::Registry
4
+
5
+ vue_name "matestack-ui-core-form-select"
6
+
7
+ optional :variant
8
+ optional :size
9
+ optional :form_text
10
+
11
+ def response
12
+ div class: "matestack-ui-bootstrap-form-select" do
13
+ label input_label, for: attribute_key, class: "form-label" if input_label
14
+ select select_attributes.merge(bootstrap_select_attributes) do
15
+ render_options
16
+ end
17
+ render_errors
18
+ render_form_text
19
+ end
20
+ end
21
+
22
+ def bootstrap_select_attributes
23
+ {
24
+ class: form_select_class,
25
+ size: size_class,
26
+ disabled: context.disabled
27
+ }
28
+ end
29
+
30
+ def form_select_class
31
+ case context.variant
32
+ when :lg
33
+ (options[:class] || "") << (" form-select form-select-lg")
34
+ when :sm
35
+ (options[:class] || "") << (" form-select form-select-sm")
36
+ else
37
+ (options[:class] || "") << (" form-select")
38
+ end
39
+ end
40
+
41
+ def size_class
42
+ context.size
43
+ end
44
+
45
+ def render_errors
46
+ if display_errors?
47
+ div class: 'invalid-feedback', 'v-for': "error in #{error_key}" do
48
+ plain '{{ error }}'
49
+ end
50
+ end
51
+ end
52
+
53
+ def input_error_class
54
+ 'is-invalid'
55
+ end
56
+
57
+ def render_form_text
58
+ div id: "form_text_for_#{attribute_key}", class: "form-text" do
59
+ plain context.form_text
60
+ end
61
+ end
62
+
63
+ end
@@ -0,0 +1,20 @@
1
+ class Matestack::Ui::Bootstrap::Form::Submit < Matestack::Ui::Bootstrap::BaseComponent
2
+
3
+ optional :button_variant
4
+ optional :spinner_variant
5
+ optional :loading_text
6
+ optional :loading_class
7
+ optional :size
8
+ optional class: { as: :bs_class }
9
+
10
+ def response
11
+ bs_btn type: "submit", size:context.size, class: "#{context.bs_class}", variant: context.button_variant || :primary, "v-if": "!loading" do
12
+ plain context.text || "Submit"
13
+ end
14
+ bs_btn type: "submit", size: context.size, class: "#{context.bs_class} #{context.loading_class}", variant: context.button_variant || :primary, disabled: true, "v-if": "loading" do
15
+ bs_spinner variant: context.spinner_variant || :light, size: :sm
16
+ plain context.loading_text || "Loading..."
17
+ end
18
+ end
19
+
20
+ end
@@ -0,0 +1,32 @@
1
+ class Matestack::Ui::Bootstrap::Form::Switch < Matestack::Ui::Bootstrap::Form::Checkbox
2
+
3
+ include Matestack::Ui::Bootstrap::Registry
4
+
5
+ vue_name "matestack-ui-core-form-checkbox"
6
+
7
+ optional :form_text
8
+ optional :disabled
9
+ optional :variant
10
+
11
+ def response
12
+ div class: "matestack-ui-bootstrap-switch" do
13
+ label input_label, class: "form-label", for: attribute_key if input_label && multiple?
14
+ render_options
15
+ render_errors
16
+ plain context.form_text
17
+ render_form_text if context.form_text
18
+ end
19
+ end
20
+
21
+ private
22
+
23
+ def checkbox_wrapper(options = {}, &block)
24
+ wrapper_attributes = (options[:attributes] || {}).merge({
25
+ class: "form-check form-switch #{'form-check-inline' if context.variant == :inline}"
26
+ })
27
+ div wrapper_attributes do
28
+ yield if block_given?
29
+ end
30
+ end
31
+
32
+ end
@@ -0,0 +1,24 @@
1
+ // This file is automatically compiled by Webpack, along with any other files
2
+ // present in this directory. You're encouraged to place your actual application logic in
3
+ // a relevant structure within javascript and only use these pack files to reference
4
+ // that code so it'll be compiled.
5
+
6
+ import "./stylesheets/matestack-ui-bootstrap.scss";
7
+
8
+ import './components/alert'
9
+ import './components/carousel'
10
+ import './components/collapse'
11
+ import './components/dropdown'
12
+ import './components/modal'
13
+ import './components/toast'
14
+ import './components/popover'
15
+ import './components/tooltip'
16
+ import './layout/sidebar'
17
+ import './layout/sidebar.scss'
18
+ import './content/smart_collection/collection.scss'
19
+
20
+ const MatestackUiBootstrap = {}
21
+
22
+ window.MatestackUiBootstrap = MatestackUiBootstrap
23
+
24
+ export default MatestackUiBootstrap
@@ -0,0 +1,49 @@
1
+ require_relative "../base_component"
2
+
3
+ class Matestack::Ui::Bootstrap::Layout::Column < Matestack::Ui::Bootstrap::BaseComponent
4
+
5
+ COL_ATTRIBUTES = %i[default sm md lg xl xxl]
6
+ optional *COL_ATTRIBUTES
7
+
8
+ ORDER_ATTRIBUTES = %i[order order_sm order_md order_lg order_xl order_xxl]
9
+ optional *ORDER_ATTRIBUTES
10
+
11
+ OFFSET_ATTRIBUTES = %i[offset offset_sm offset_md offset_lg offset_xl offset_xxl]
12
+ optional *OFFSET_ATTRIBUTES
13
+
14
+ optional class: { as: :bs_class }
15
+ optional :align_self
16
+
17
+ def response
18
+ div col_attributes do
19
+ yield if block_given?
20
+ end
21
+ end
22
+
23
+ protected
24
+
25
+ def col_attributes
26
+ options.merge(
27
+ class: col_classes
28
+ )
29
+ end
30
+
31
+ def col_classes
32
+ classes = []
33
+ COL_ATTRIBUTES.each do |attrs|
34
+ classes << "col-#{ context.send("#{attrs}") }" if attrs == :default and context.send("#{attrs}")
35
+ classes << "col-#{attrs}-#{ context.send("#{attrs}") }" if attrs != :default and context.send("#{attrs}")
36
+ end
37
+ ORDER_ATTRIBUTES.each do |attrs|
38
+ classes << "#{attrs}-#{ context.send("#{attrs}") }".gsub('_', '-') if context.send("#{attrs}")
39
+ end
40
+ OFFSET_ATTRIBUTES.each do |attrs|
41
+ classes << "#{attrs}-#{ context.send("#{attrs}") }".gsub('_', '-') if context.send("#{attrs}")
42
+ end
43
+ classes << "align-self-#{context.align_self}" if context.align_self.present?
44
+ classes << "col" if classes.blank?
45
+ classes << context.bs_class
46
+ classes.join(' ').strip
47
+ end
48
+
49
+ end
@@ -1,25 +1,28 @@
1
- class Matestack::Ui::Bootstrap::Layout::Container < Matestack::Ui::Component
1
+ require_relative "../base_component"
2
2
 
3
- optional :size, class: { as: :bs_class }
3
+ class Matestack::Ui::Bootstrap::Layout::Container < Matestack::Ui::Bootstrap::BaseComponent
4
4
 
5
- def response
5
+ optional :size
6
+
7
+ def response
6
8
  div container_attributes do
7
- yield_components
9
+ yield
8
10
  end
9
11
  end
10
12
 
11
13
  protected
12
-
14
+
13
15
  def container_attributes
14
- html_attributes.merge(
16
+ options.merge(
15
17
  class: container_classes
16
18
  )
17
19
  end
18
20
 
19
21
  def container_classes
20
22
  [].tap do |classes|
21
- classes << (size.present? ? "container-#{size}" : "container")
22
- classes << bs_class
23
+ classes << (context.size.present? ? "container-#{context.size}" : "container")
24
+ classes << options[:class]
23
25
  end.join(' ').strip
24
26
  end
25
- end
27
+
28
+ end
@@ -0,0 +1,25 @@
1
+ require_relative "../base_component"
2
+
3
+ class Matestack::Ui::Bootstrap::Layout::Row < Matestack::Ui::Bootstrap::BaseComponent
4
+
5
+ optional :vertical
6
+ optional :horizontal
7
+ optional class: { as: :bs_class }
8
+
9
+ def response
10
+ div options.merge(class: row_classes) do
11
+ yield if block_given?
12
+ end
13
+ end
14
+
15
+ def row_classes
16
+ classes = ["row"]
17
+
18
+ classes << "align-items-#{context.vertical}" if context.vertical.present?
19
+ classes << "justify-content-#{context.horizontal}" if context.horizontal.present?
20
+ classes << "#{context.bs_class}" if context.bs_class.present?
21
+
22
+ classes.join(' ')
23
+ end
24
+
25
+ end
@@ -1,6 +1,9 @@
1
- const bootstrap = require('bootstrap')
1
+ import * as bootstrap from 'bootstrap'
2
+ import Vue from 'vue/dist/vue.esm'
2
3
 
3
- MatestackUiCore.Vue.component('matestack-ui-bootstrap-sidebar', {
4
+ import MatestackUiCore from 'matestack-ui-core'
5
+
6
+ Vue.component('matestack-ui-bootstrap-sidebar', {
4
7
  mixins: [MatestackUiCore.componentMixin],
5
8
 
6
9
  data() {