bootstrap_concerns 0.3.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 78d040af08e9dacd88c1349639729cf0b6bda36c21d533f5cb26604e01b31b9e
4
- data.tar.gz: 706dc441311c59bfa3e8d96b32b3a9e1b5a8ccb901db3ee4df5a6490f50d1c18
3
+ metadata.gz: a6d66204774585ab5856791f11c3fd72caa2f15e4ef9a9e203057713853f20ee
4
+ data.tar.gz: aa498bd064e817cc3eeb7cad582e4f691bcd564adf1b2901c72b328a9c2ab866
5
5
  SHA512:
6
- metadata.gz: 4504d96f03b9a87ef3948b32ee4fc1b452f64695e82edb64660353487da4b0e207db40fe4e879075f363a6460a289cda6e17541303f2c3118ed4faa7d55f8154
7
- data.tar.gz: bd6fdfc3ea4cb8779342652091c1f2857003d4eb97b170549cf008077fbd4059dfd4d804c8ac45473dd9dd96748e1b8d9b4ae1f4385ca6bc092a083490d04080
6
+ metadata.gz: a663c46f524584544fa709a0f503e540dd5f8183d45150fe7674b24a5e12dc5ebd4fbf4b5d8d5fcaee440a00b09651a269857a9e196e9467b7dd4e4f70453cf8
7
+ data.tar.gz: 75f5f5599cbf4779d5cb65fb26613d880a5aba225c58540b596cb79fbc1184d8f865c27e422ef0c1ee36c3eb4453725c7a570472b501553c5be9800007ce51f3
@@ -1,6 +1,6 @@
1
1
  module BootstrapConcerns
2
2
  module ComponentsHelper
3
- SEARCH_COL_MARGIN = "mb-3".freeze
3
+ MARGIN = "mb-3".freeze
4
4
 
5
5
  def assign_icon
6
6
  icon("box-arrow-in-left", "Assign")
@@ -14,6 +14,19 @@ module BootstrapConcerns
14
14
  content_tag(:i, "", class: "bi bi-check-circle-fill")
15
15
  end
16
16
 
17
+ def bs_button_tag(content_or_options = nil, options = nil, &)
18
+ normalized_options =
19
+ if content_or_options.is_a?(Hash)
20
+ content_or_options
21
+ else
22
+ options ||= {}
23
+ end
24
+
25
+ normalized_options.merge!(Option.options_with_button_class(normalized_options))
26
+
27
+ button_tag(content_or_options, options, &)
28
+ end
29
+
17
30
  def bs_button_to(name = nil, options = nil, html_options = nil, &)
18
31
  bs_link_or_button_to(:button_to, name, options, html_options, &)
19
32
  end
@@ -21,7 +34,7 @@ module BootstrapConcerns
21
34
  def bs_errors(record)
22
35
  return if record.errors.empty?
23
36
 
24
- content_tag(:div, class: "alert alert-danger alert-dismissible fade show mt-3") do
37
+ content_tag(:div, class: "alert alert-danger alert-dismissible fade show #{MARGIN}") do
25
38
  concat content_tag(:h5, "Errors")
26
39
  concat(
27
40
  content_tag(:ul, class: "mb-0") do
@@ -34,6 +47,19 @@ module BootstrapConcerns
34
47
  end
35
48
  end
36
49
 
50
+ def bs_form_with(model: false, **options, &)
51
+ form_with(model: model, **options) do |form|
52
+ concat(bs_errors(model)) if model
53
+ concat(
54
+ content_tag(:div, class: "row") do
55
+ content_tag(:div, class: "col-md-6") do
56
+ yield(form)
57
+ end
58
+ end
59
+ )
60
+ end
61
+ end
62
+
37
63
  def bs_link_or_button_to(method_name, name, options, html_options, &)
38
64
  normalized_html_options =
39
65
  if block_given?
@@ -58,11 +84,11 @@ module BootstrapConcerns
58
84
  end
59
85
 
60
86
  def bs_search_col(&)
61
- content_tag(:div, class: "col-12 col-sm #{SEARCH_COL_MARGIN}", &)
87
+ content_tag(:div, class: "col-12 col-sm #{MARGIN}", &)
62
88
  end
63
89
 
64
90
  def bs_search_submit_col
65
- content_tag(:div, class: "col-auto #{SEARCH_COL_MARGIN}") do
91
+ content_tag(:div, class: "col-auto #{MARGIN}") do
66
92
  content_tag(:button, BootstrapConcerns::Option.options_with_button_class) do
67
93
  search_icon
68
94
  end
@@ -52,6 +52,15 @@ module BootstrapConcerns
52
52
  email_field(method, options_with_form_control_class(options))
53
53
  end
54
54
 
55
+ def bs_form_group(method, type, *args)
56
+ options = args.find { it.is_a?(Hash) }.to_h
57
+
58
+ @template.content_tag(:div, class: ComponentsHelper::MARGIN) do
59
+ @template.concat bs_label(method, options.slice(:required))
60
+ @template.concat public_send("bs_#{type}", method, *args)
61
+ end
62
+ end
63
+
55
64
  def bs_grouped_collection_select(
56
65
  method,
57
66
  collection,
@@ -81,6 +90,25 @@ module BootstrapConcerns
81
90
  label(method, text, options, &)
82
91
  end
83
92
 
93
+ def bs_file_field(method, options = {})
94
+ file_field(
95
+ method,
96
+ {
97
+ class: FORM_CONTROL_BASE_CLASS,
98
+ direct_upload: true,
99
+ data: {
100
+ controller: "direct-upload-field",
101
+ action: <<~ACTION.squish
102
+ direct-upload:initialize->direct-upload-field#setup
103
+ direct-upload:progress->direct-upload-field#progress
104
+ direct-upload:error->direct-upload-field#error
105
+ direct-upload:end->direct-upload-field#end
106
+ ACTION
107
+ }
108
+ }.merge(options)
109
+ )
110
+ end
111
+
84
112
  def bs_number_field(method, options = {})
85
113
  number_field(method, options_with_form_control_class(options))
86
114
  end
@@ -11,7 +11,7 @@ module BootstrapConcerns
11
11
  end
12
12
 
13
13
  def prefixed_option(options, key:, prefix:, default: nil)
14
- (options.delete(key) || default)&.then { "#{prefix}-#{_1}" }
14
+ (options.delete(key) || default)&.then { "#{prefix}-#{it}" }
15
15
  end
16
16
 
17
17
  def options_with_base_class(options, *base_class)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bootstrap_concerns
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evan Brooks
8
8
  - Robert Keresnyei
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-03-05 00:00:00.000000000 Z
11
+ date: 2025-04-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionview