matestack-ui-bootstrap 1.4.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (112) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +17 -5
  3. data/README.md +53 -19
  4. data/lib/matestack/ui/bootstrap.rb +97 -17
  5. data/{app/concepts → lib}/matestack/ui/bootstrap/apps/admin_template.rb +14 -7
  6. data/lib/matestack/ui/bootstrap/base_component.rb +13 -0
  7. data/lib/matestack/ui/bootstrap/base_vue_js_component.rb +13 -0
  8. data/lib/matestack/ui/bootstrap/components/accordion.rb +58 -0
  9. data/{app/concepts → lib}/matestack/ui/bootstrap/components/alert.js +12 -9
  10. data/lib/matestack/ui/bootstrap/components/alert.rb +43 -0
  11. data/lib/matestack/ui/bootstrap/components/avatar.rb +27 -0
  12. data/lib/matestack/ui/bootstrap/components/badge.rb +32 -0
  13. data/lib/matestack/ui/bootstrap/components/breadcrumb.rb +50 -0
  14. data/lib/matestack/ui/bootstrap/components/button.rb +71 -0
  15. data/lib/matestack/ui/bootstrap/components/button_group.rb +36 -0
  16. data/lib/matestack/ui/bootstrap/components/card.rb +105 -0
  17. data/{app/concepts → lib}/matestack/ui/bootstrap/components/carousel.js +21 -18
  18. data/lib/matestack/ui/bootstrap/components/carousel.rb +103 -0
  19. data/{app/concepts → lib}/matestack/ui/bootstrap/components/close.rb +10 -9
  20. data/{app/concepts → lib}/matestack/ui/bootstrap/components/collapse.js +20 -17
  21. data/lib/matestack/ui/bootstrap/components/collapse.rb +54 -0
  22. data/{app/concepts → lib}/matestack/ui/bootstrap/components/dropdown.js +5 -2
  23. data/{app/concepts → lib}/matestack/ui/bootstrap/components/dropdown.rb +31 -26
  24. data/lib/matestack/ui/bootstrap/components/icon.rb +21 -0
  25. data/lib/matestack/ui/bootstrap/components/list_group.rb +148 -0
  26. data/{app/concepts → lib}/matestack/ui/bootstrap/components/modal.js +24 -21
  27. data/lib/matestack/ui/bootstrap/components/modal.rb +121 -0
  28. data/lib/matestack/ui/bootstrap/components/navbar.rb +163 -0
  29. data/{app/concepts → lib}/matestack/ui/bootstrap/components/page_heading.rb +7 -5
  30. data/{app/concepts → lib}/matestack/ui/bootstrap/components/pagination.rb +15 -13
  31. data/{app/concepts → lib}/matestack/ui/bootstrap/components/popover.js +4 -1
  32. data/{app/concepts → lib}/matestack/ui/bootstrap/components/popover.rb +26 -22
  33. data/{app/concepts → lib}/matestack/ui/bootstrap/components/progress.rb +24 -24
  34. data/lib/matestack/ui/bootstrap/components/scrollspy.rb +50 -0
  35. data/lib/matestack/ui/bootstrap/components/section_card.rb +33 -0
  36. data/lib/matestack/ui/bootstrap/components/spinner.rb +35 -0
  37. data/lib/matestack/ui/bootstrap/components/tab_nav.rb +79 -0
  38. data/lib/matestack/ui/bootstrap/components/tab_nav_content.rb +35 -0
  39. data/{app/concepts → lib}/matestack/ui/bootstrap/components/toast.js +27 -18
  40. data/lib/matestack/ui/bootstrap/components/toast.rb +113 -0
  41. data/{app/concepts → lib}/matestack/ui/bootstrap/components/tooltip.js +4 -1
  42. data/lib/matestack/ui/bootstrap/components/tooltip.rb +66 -0
  43. data/{app/concepts → lib}/matestack/ui/bootstrap/content/figure.rb +4 -2
  44. data/lib/matestack/ui/bootstrap/content/smart_collection/collection.rb +120 -0
  45. data/{app/concepts/matestack/ui/bootstrap/content/collection → lib/matestack/ui/bootstrap/content/smart_collection}/collection.scss +0 -0
  46. data/lib/matestack/ui/bootstrap/content/smart_collection/content.rb +118 -0
  47. data/{app/concepts/matestack/ui/bootstrap/content/collection → lib/matestack/ui/bootstrap/content/smart_collection}/filter.rb +7 -3
  48. data/{app/concepts/matestack/ui/bootstrap/content/collection → lib/matestack/ui/bootstrap/content/smart_collection}/paginate.rb +19 -14
  49. data/lib/matestack/ui/bootstrap/form/checkbox.rb +90 -0
  50. data/lib/matestack/ui/bootstrap/form/input.rb +118 -0
  51. data/lib/matestack/ui/bootstrap/form/radio.rb +57 -0
  52. data/lib/matestack/ui/bootstrap/form/select.rb +63 -0
  53. data/lib/matestack/ui/bootstrap/form/submit.rb +20 -0
  54. data/lib/matestack/ui/bootstrap/form/switch.rb +32 -0
  55. data/lib/matestack/ui/bootstrap/form/textarea.rb +49 -0
  56. data/lib/matestack/ui/bootstrap/index.js +24 -0
  57. data/lib/matestack/ui/bootstrap/layout/column.rb +49 -0
  58. data/{app/concepts → lib}/matestack/ui/bootstrap/layout/container.rb +12 -9
  59. data/lib/matestack/ui/bootstrap/layout/row.rb +25 -0
  60. data/{app/concepts → lib}/matestack/ui/bootstrap/layout/sidebar.js +5 -2
  61. data/{app/concepts → lib}/matestack/ui/bootstrap/layout/sidebar.rb +10 -10
  62. data/{app/concepts → lib}/matestack/ui/bootstrap/layout/sidebar.scss +0 -0
  63. data/lib/matestack/ui/bootstrap/registry.rb +173 -0
  64. data/{app/javascript/matestack-ui-bootstrap → lib/matestack/ui/bootstrap}/stylesheets/matestack-ui-bootstrap.scss +0 -0
  65. data/lib/matestack/ui/bootstrap/version.rb +1 -1
  66. data/lib/tasks/matestack/ui/bootstrap_tasks.rake +25 -25
  67. metadata +68 -76
  68. data/app/assets/images/avatar-placeholder.png +0 -0
  69. data/app/assets/images/icons/bootstrap-icons.svg +0 -1
  70. data/app/concepts/matestack/ui/bootstrap/components/accordion.rb +0 -53
  71. data/app/concepts/matestack/ui/bootstrap/components/alert.rb +0 -34
  72. data/app/concepts/matestack/ui/bootstrap/components/avatar.rb +0 -27
  73. data/app/concepts/matestack/ui/bootstrap/components/badge.rb +0 -30
  74. data/app/concepts/matestack/ui/bootstrap/components/breadcrumb.rb +0 -46
  75. data/app/concepts/matestack/ui/bootstrap/components/button.rb +0 -54
  76. data/app/concepts/matestack/ui/bootstrap/components/button_group.rb +0 -36
  77. data/app/concepts/matestack/ui/bootstrap/components/card.rb +0 -100
  78. data/app/concepts/matestack/ui/bootstrap/components/carousel.rb +0 -85
  79. data/app/concepts/matestack/ui/bootstrap/components/chart.js +0 -232
  80. data/app/concepts/matestack/ui/bootstrap/components/chart.rb +0 -71
  81. data/app/concepts/matestack/ui/bootstrap/components/collapse.rb +0 -43
  82. data/app/concepts/matestack/ui/bootstrap/components/icon.rb +0 -19
  83. data/app/concepts/matestack/ui/bootstrap/components/list_group.rb +0 -83
  84. data/app/concepts/matestack/ui/bootstrap/components/modal.rb +0 -106
  85. data/app/concepts/matestack/ui/bootstrap/components/navbar.rb +0 -120
  86. data/app/concepts/matestack/ui/bootstrap/components/scrollspy.rb +0 -33
  87. data/app/concepts/matestack/ui/bootstrap/components/section_card.rb +0 -31
  88. data/app/concepts/matestack/ui/bootstrap/components/spinner.rb +0 -31
  89. data/app/concepts/matestack/ui/bootstrap/components/tab_nav.rb +0 -81
  90. data/app/concepts/matestack/ui/bootstrap/components/tab_nav_content.rb +0 -32
  91. data/app/concepts/matestack/ui/bootstrap/components/toast.rb +0 -99
  92. data/app/concepts/matestack/ui/bootstrap/components/tooltip.rb +0 -82
  93. data/app/concepts/matestack/ui/bootstrap/content/collection/collection.rb +0 -112
  94. data/app/concepts/matestack/ui/bootstrap/content/collection/content.rb +0 -101
  95. data/app/concepts/matestack/ui/bootstrap/form/checkbox.rb +0 -90
  96. data/app/concepts/matestack/ui/bootstrap/form/date.js +0 -38
  97. data/app/concepts/matestack/ui/bootstrap/form/date.rb +0 -98
  98. data/app/concepts/matestack/ui/bootstrap/form/input.rb +0 -123
  99. data/app/concepts/matestack/ui/bootstrap/form/radio.rb +0 -65
  100. data/app/concepts/matestack/ui/bootstrap/form/select.haml +0 -11
  101. data/app/concepts/matestack/ui/bootstrap/form/select.rb +0 -74
  102. data/app/concepts/matestack/ui/bootstrap/form/submit.rb +0 -20
  103. data/app/concepts/matestack/ui/bootstrap/form/switch.rb +0 -90
  104. data/app/concepts/matestack/ui/bootstrap/layout/column.rb +0 -47
  105. data/app/concepts/matestack/ui/bootstrap/layout/row.rb +0 -15
  106. data/app/concepts/matestack/ui/bootstrap/pages/devise/sign_in.rb +0 -40
  107. data/app/concepts/matestack/ui/bootstrap/registry.rb +0 -63
  108. data/app/helpers/matestack/ui/bootstrap/application_helper.rb +0 -13
  109. data/app/javascript/matestack-ui-bootstrap/index.js +0 -26
  110. data/app/javascript/packs/matestack-ui-bootstrap.js +0 -2
  111. data/config/routes.rb +0 -2
  112. data/lib/matestack/ui/bootstrap/engine.rb +0 -26
@@ -1,101 +0,0 @@
1
- module Matestack::Ui::Bootstrap::Content::Collection::Content
2
-
3
- def content
4
- bs_row id: 'content' do
5
- bs_col do
6
- async id: collection_id, rerender_on: "#{collection_id}-update, #{rerender_on} " do
7
- collection_content collection.config do
8
- div class: responsive_class do
9
- if slots && slots[:collection_rendering]
10
- slot slots[:collection_rendering].call(collection.paginated_data)
11
- elsif columns
12
- div class: "table-responsive" do
13
- table table_attributes do
14
- table_head
15
- table_body
16
- table_footer
17
- end
18
- end
19
- end
20
- end
21
- paginate_partial if paginate.present?
22
- end
23
- end
24
- end
25
- end
26
- end
27
-
28
- def table_head
29
- thead do
30
- tr do
31
- columns&.each do |key, value|
32
- th text: value.is_a?(Hash) ? value[:heading] : value, class: cell_class(value), attributes: { scope: :col }
33
- end
34
- th if slots && slots[:table_item_actions]
35
- end
36
- end
37
- end
38
-
39
- def table_body
40
- tbody do
41
- collection.paginated_data.each_with_index do |data, index|
42
- tr class: 'align-middle' do
43
- columns.each do |key, value|
44
- cell(data, key, value)
45
- end
46
- if slots && slots[:table_item_actions]
47
- td class: 'text-end' do
48
- slot slots[:table_item_actions].call(data)
49
- end
50
- end
51
- end
52
- end
53
- end
54
- end
55
-
56
- def table_footer
57
- tfoot do
58
- tr do
59
- footer&.each do |value|
60
- td text: value
61
- end
62
- end
63
- end if footer
64
- end
65
-
66
- private
67
-
68
- def cell(data, key, value)
69
- td text: cell_text(data, key, value), class: cell_class(value)
70
- end
71
-
72
- def cell_class(value)
73
- [].tap do |classes|
74
- classes << "text-#{value[:text]}" if value[:text]
75
- classes << "align-#{value[:align]}" if value[:align]
76
- end.join(' ') if value.is_a? Hash
77
- end
78
-
79
- def cell_text(data, key, value)
80
- text = data.instance_eval(key.to_s)
81
- text = value[:format].call(text) if value.is_a?(Hash) && value[:format]
82
- text
83
- end
84
-
85
- def table_attributes
86
- klass = ['table'].tap do |classes|
87
- classes << "table-#{variant}" if variant
88
- classes << "table-striped" if striped
89
- classes << "table-hover" if hoverable
90
- classes << "table-bordered border-#{border_variant}" if border_variant
91
- classes << "table-borderless" if borderless
92
- end.join(' ').strip
93
- { id: collection_id, class: klass }
94
- end
95
-
96
- def responsive_class
97
- return unless responsive
98
- responsive === true ? 'table-responsive' : "table-responsive-#{responsive}"
99
- end
100
-
101
- end
@@ -1,90 +0,0 @@
1
- class Matestack::Ui::Bootstrap::Form::Checkbox < Matestack::Ui::Core::Form::Checkbox::Checkbox
2
-
3
- optional :form_text
4
- optional :disabled
5
- optional :variant
6
-
7
- def response
8
- if !checkbox_options.empty?
9
- label for: attr_key, class: "form-label", text: input_label if input_label
10
- end
11
- if !checkbox_options.empty?
12
- multiple_checkboxes
13
- else
14
- true_false_checkbox
15
- end
16
- render_form_text
17
- end
18
-
19
- private
20
-
21
- def checkbox_wrapper(options = {}, &block)
22
- div class: "form-check #{'form-check-inline' if variant == :inline}", attributes: options[:attributes] do
23
- yield
24
- end
25
- end
26
-
27
- def bootstrap_label(text:, for_input:)
28
- label text: text, for: for_input, class: 'form-check-label'
29
- end
30
-
31
- def true_false_checkbox
32
- checkbox_wrapper do
33
- form_input type: :hidden, key: key, value: (false_value || 0), errors: false
34
- input html_attributes.merge(
35
- type: :checkbox,
36
- id: "#{id_for_item(value)}",
37
- name: item_name(key),
38
- value: checked_value,
39
- class: 'form-check-input',
40
- disabled: disabled,
41
- attributes: vue_attributes.merge(
42
- ref: "input.#{attr_key}",
43
- )
44
- )
45
- bootstrap_label text: input_label, for_input: id_for_item(value)
46
- render_errors
47
- end
48
- end
49
-
50
- def multiple_checkboxes
51
- checkbox_options.to_a.each do |item|
52
- checkbox_wrapper do
53
- input html_attributes.merge(
54
- type: :checkbox,
55
- id: "#{id_for_item(item_value(item))}",
56
- name: item_name(item),
57
- value: item_value(item),
58
- class: 'form-check-input',
59
- disabled: disabled,
60
- attributes: vue_attributes
61
- )
62
- bootstrap_label text: item_name(item), for_input: id_for_item(item_value(item))
63
- render_errors if checkbox_options.to_a.last == item
64
- end
65
- end
66
- end
67
-
68
- def render_errors
69
- unless @included_config[:errors] == false && (errors == false || errors.nil?) || errors == false
70
- div class: 'invalid-feedback', attributes: { 'v-for': "error in #{error_key}" } do
71
- plain '{{ error }}'
72
- end
73
- end
74
- end
75
-
76
- def input_error_class
77
- 'is-invalid'
78
- end
79
-
80
- def checkbox_options
81
- super || {}
82
- end
83
-
84
- def render_form_text
85
- div id: "form_text_for_#{attr_key}", class: "form-text" do
86
- plain form_text
87
- end
88
- end
89
-
90
- end
@@ -1,38 +0,0 @@
1
- const bootstrap = require('bootstrap')
2
- import flatpickr from "flatpickr";
3
-
4
- MatestackUiCore.Vue.component('matestack-ui-bootstrap-date', {
5
- mixins: [MatestackUiCore.componentMixin],
6
-
7
- data() {
8
- return {};
9
- },
10
-
11
- methods: {
12
-
13
- },
14
-
15
- mounted: function() {
16
- const self = this
17
- let data = this.$parent.data;
18
- flatpickr(this.$el.querySelector('.flatpickr'), {
19
- defaultDate: this.componentConfig["init_value"],
20
- enableTime: (this.componentConfig["enable_time"] == true)
21
- });
22
- for (let key in this.$refs) {
23
- let initValue = this.$refs[key]["attributes"]["init-value"];
24
-
25
- if (initValue) {
26
- data[key.replace("input.", "")] = initValue["value"];
27
- } else {
28
- data[key.replace("input.", "")] = null;
29
- }
30
- }
31
- this.$parent.data = data
32
-
33
- //without the timeout it's somehow not working
34
- setTimeout(function () {
35
- self.$parent.data = data
36
- }, 100);
37
- }
38
- });
@@ -1,98 +0,0 @@
1
- class Matestack::Ui::Bootstrap::Form::Date < Matestack::Ui::Core::Component::Dynamic
2
-
3
- include Matestack::Ui::Core::Form::Utils
4
- include Matestack::Ui::Core::Form::HasInputHtmlAttributes
5
- include Matestack::Ui::Core::Form::HasErrors
6
-
7
- requires :key
8
- optional :multiple, :init, for: { as: :input_for }, label: { as: :input_label }
9
-
10
- optional :form_text
11
- optional :disabled
12
- optional :placeholder
13
-
14
- optional :with_time
15
-
16
- vue_js_component_name "matestack-ui-bootstrap-date"
17
-
18
- def input_key
19
- "$parent.data[\"#{key}\"]"
20
- end
21
-
22
- def error_key
23
- "$parent.errors[\"#{key}\"]"
24
- end
25
-
26
- def setup
27
- @component_config[:init_value] = init_value
28
- @component_config[:with_time] = with_time
29
- end
30
-
31
- def response
32
- div do
33
- label for: attr_key, class: "form-label", text: input_label if input_label
34
- input html_attributes.merge(attributes: vue_attributes).merge(bootstrap_input_attributes)
35
- render_errors
36
- render_form_text if form_text
37
- end
38
- end
39
-
40
- def vue_attributes
41
- (options[:attributes] || {}).merge({
42
- id: attr_key,
43
- "@change": change_event,
44
- ref: "input.#{attr_key}",
45
- 'init-value': init_value,
46
- 'v-bind:class': "{ '#{input_error_class}': #{error_key} }",
47
- "aria-describedby": attr_key
48
- }).merge({ "v-model": input_key })
49
- end
50
-
51
- def change_event
52
- "$parent.inputChanged('#{attr_key}');".strip
53
- end
54
-
55
- def custom_options_validation
56
- raise "included form config is missing, please add ':include' to parent form component" if @included_config.nil?
57
- end
58
-
59
- def attr_key
60
- super
61
- end
62
-
63
- private
64
-
65
- def parse_value(value)
66
- if [true, false].include? value
67
- value ? 1 : 0
68
- else
69
- return value
70
- end
71
- end
72
-
73
- def bootstrap_input_attributes
74
- {
75
- class: (options[:class] || "") << (" form-control flatpickr"),
76
- disabled: disabled
77
- }
78
- end
79
-
80
- def render_errors
81
- unless @included_config[:errors] == false && (errors == false || errors.nil?) || errors == false
82
- div class: 'invalid-feedback', attributes: { 'v-for': "error in #{error_key}" } do
83
- plain '{{ error }}'
84
- end
85
- end
86
- end
87
-
88
- def input_error_class
89
- 'is-invalid'
90
- end
91
-
92
- def render_form_text
93
- div id: "form_text_for_#{attr_key}", class: "form-text" do
94
- plain form_text
95
- end
96
- end
97
-
98
- end
@@ -1,123 +0,0 @@
1
- class Matestack::Ui::Bootstrap::Form::Input < Matestack::Ui::Core::Form::Input::Input
2
-
3
- optional :form_text
4
- optional :disabled
5
- optional :browse_button_text
6
- optional :placeholder
7
- optional :variant
8
- optional :min
9
- optional :max
10
- optional :step
11
- optional :show_value
12
-
13
- def response
14
- div do
15
- label for: attr_key, class: "form-label", text: input_label if input_label
16
- case type
17
- when :range
18
- input html_attributes.merge(attributes: vue_attributes).merge(bootstrap_range_attributes)
19
- if show_value
20
- div id: attr_key, class: "form-text" do
21
- plain "{{ data['#{attr_key}'] }}"
22
- end
23
- end
24
- when :file
25
- file_input
26
- else
27
- input html_attributes.merge(attributes: vue_attributes).merge(bootstrap_input_attributes)
28
- render_errors
29
- end
30
- render_form_text if form_text
31
- end
32
- end
33
-
34
- def vue_attributes
35
- (options[:attributes] || {}).merge({
36
- id: attr_key,
37
- "@change": change_event,
38
- ref: "input.#{attr_key}",
39
- 'init-value': init_value,
40
- 'v-bind:class': "{ '#{input_error_class}': #{error_key} }",
41
- "aria-describedby": attr_key,
42
- "step": "any"
43
- }).merge(
44
- type != :file ? { "#{v_model_type}": input_key } : {}
45
- ) # file inputs are readonly, no v-model possible
46
- end
47
-
48
- def bootstrap_input_attributes
49
- {
50
- class: (options[:class] || "") << (" form-control"),
51
- disabled: disabled
52
- }
53
- end
54
-
55
- def bootstrap_range_attributes
56
- {
57
- class: (options[:class] || "") << (" form-range"),
58
- disabled: disabled,
59
- min: min,
60
- max: max,
61
- steps: step
62
- }
63
- end
64
-
65
- def bootstrap_file_input_attributes
66
- {
67
- class: (options[:class] || "") << (" form-file-input"),
68
- disabled: disabled
69
- }
70
- end
71
-
72
- def form_file_wrapper_class
73
- case variant
74
- when :lg
75
- (options[:class] || "") << (" form-file form-file-lg")
76
- when :sm
77
- (options[:class] || "") << (" form-file form-file-sm")
78
- else
79
- (options[:class] || "") << (" form-file")
80
- end
81
- end
82
-
83
- def file_input
84
- div class: form_file_wrapper_class do
85
- input html_attributes.merge(attributes: vue_attributes).merge(bootstrap_file_input_attributes)
86
- label class: "form-file-label", for: attr_key do
87
- span class: "form-file-text", attributes: { "v-if": "data['#{attr_key}']" } do
88
- if multiple
89
- span attributes: { "v-for": "file in data['#{attr_key}']" } do
90
- plain "{{ file['name'] }}"
91
- end
92
- else
93
- plain "{{ data['#{attr_key}']['name'] }}"
94
- end
95
- end
96
- span class: "form-file-text", attributes: { "v-if": "!data['#{attr_key}']" } do
97
- plain placeholder || "Choose file"
98
- end
99
- span class: "form-file-button", text: browse_button_text || "Browse"
100
- end
101
- render_errors
102
- end
103
- end
104
-
105
- def render_errors
106
- unless @included_config[:errors] == false && (errors == false || errors.nil?) || errors == false
107
- div class: 'invalid-feedback', attributes: { 'v-for': "error in #{error_key}" } do
108
- plain '{{ error }}'
109
- end
110
- end
111
- end
112
-
113
- def input_error_class
114
- 'is-invalid'
115
- end
116
-
117
- def render_form_text
118
- div id: "form_text_for_#{attr_key}", class: "form-text" do
119
- plain form_text
120
- end
121
- end
122
-
123
- end