nfg_ui 5.15.3 → 5.15.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bc2e41b096acf0984f462d1c7b2058dbf4f7c14d183ced10061b70cad2c263fb
4
- data.tar.gz: 044aba97d396b80d60ab7dde7b6ed598f5f70c1c4c46366ac2db3a1ed9e27b81
3
+ metadata.gz: 44a92bdd16747ddbe83d9bc5bf872094e7344d6205391b356d8c5e01cc2209cb
4
+ data.tar.gz: 2dc7bdf3bfcad4046d0ea6162d36d3b1e6a3a023e83f0813f88d6e393ca16da6
5
5
  SHA512:
6
- metadata.gz: 172b725c9ee35587851e1883b2f06c349c8cf6c438db6afe2c5b450dbd434f1bf3de610e6f64fd18e737c286beb0abe775f7a4522cc5259f4d15486c0035a93d
7
- data.tar.gz: a687c3edd6dd070bf6e4d511050019d4c302ab334e40da37d20c58cd9c6bdc3333cabd7991145491247ab81a28a90b036d88d19537f88def6e2bd2c920137d53
6
+ metadata.gz: a2557d3579278fd434faa9d0c1e246f95d3fc4ba4eaf7d320b1c9f7e284f4eb74800147e6c06ad9946ae70969db4d3f52d17b4539ae320c92cc533257158428b
7
+ data.tar.gz: beca0a9fcebd58ab9cf36bbe2d4f6f598a3a7d5698092b0a90e6554ab4b632cf0f1cccf1314220b0f1f52f83832dd20d65050272cacc3eebbd9de3a77698cfb7
@@ -15,16 +15,42 @@ module NfgUi
15
15
 
16
16
  include NfgUi::Components::Traits::Collapse
17
17
 
18
+ # Because it is common to forget to add the required :id
19
+ # to the component options when doing a "speed built"
20
+ # collapse, example:
21
+ # = ui.nfg :collapse, :collapsed, body: 'Collapse body content', heading: 'My Link'
22
+ #
23
+ # Send in a random string that is carried through
24
+ # from the speed built heading / button AND
25
+ # to the collapse component.
26
+ def component_initialize
27
+ # Only create and supply a random ID this when a :heading is present
28
+ return unless heading
29
+ new_id = options[:id].nil? ? random_id : options[:id]
30
+ options[:id] = new_id
31
+ end
32
+
18
33
  def render
19
34
  capture do
20
35
  if heading
21
- opts = { collapse: "##{id}", body: heading, icon: 'caret-down', class: 'pl-0 text-left' }
36
+ icon = options.fetch(:icon, 'caret-down')
37
+ opts = { collapse: "##{html_options[:id]}", body: heading, icon: icon, class: 'pl-0 text-left' }
22
38
  opts.merge!(traits: [:link, :block])
23
39
  concat(NfgUi::Components::Elements::Button.new(opts, view_context).render)
24
40
  end
25
41
  concat(super)
26
42
  end
27
43
  end
44
+
45
+ private
46
+
47
+ # Generate a string of random letters
48
+ # We must insert a random letter before SecureRandom because
49
+ # if a css ID starts with a number, it seems to break
50
+ # the collapse JS functionality.
51
+ def random_id
52
+ "#{('a'..'z').to_a.sample}-#{SecureRandom.alphanumeric(6)}"
53
+ end
28
54
  end
29
55
  end
30
56
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module NfgUi
4
- VERSION = '5.15.3'
4
+ VERSION = '5.15.4'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nfg_ui
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.15.3
4
+ version: 5.15.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Roehm
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-11-01 00:00:00.000000000 Z
12
+ date: 2022-11-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bootstrap