tramway 2.1.2 → 2.1.2.1

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: 59b04db0703fc68b1a6377dc00723c2767ecc3417eb9b8f6cf2b73e522ea3a71
4
- data.tar.gz: 20580dcdc78622ce7b20404c0b957bd152b741403c5783d00814ad7412b6f177
3
+ metadata.gz: 65ec93e5a4973beff68cd58f7c0bd06929d9f9063aab326ec16c974c164b319a
4
+ data.tar.gz: 19f708dfefa7c8c744cfd6ca6f97f7620a1580160039baf962b72a73b649009b
5
5
  SHA512:
6
- metadata.gz: d266d0adc904060a2c8d376b48cc88be31c8c3b0d1670d0477bd71f07cba7fdbbcf19712b3639395e63e3a3555b401bdc56c43fb5dc841406c7e0e9d1f097670
7
- data.tar.gz: 40ec0e1c9668b429155c1ac725f818ffed2eef2074ee67b41c57ef4b7bded03d654bdcc969d400e5d28dc8c135a2af083c94af9d5e082b76216dad843907b426
6
+ metadata.gz: 1f5760b7f15c842d445dbf788ef0de27b40a43cdf829ea8dce4f3adc22dd68eafeed9820d0794f60a9f8e06d19dcda99189382aff52860b7543ae16401b94ce7
7
+ data.tar.gz: 39043e6cca5363ce179ad6322e7766cc3e9eaf521cddf77b047d577dd9d5b797a7166618152d7fc7a0d3b3963b4b1b8feb2a56dbc882c9cbe092f41787430816
@@ -1,20 +1,20 @@
1
1
  - if text.present?
2
2
  - if render_a_tag?
3
- = link_to text, path, class: classes, **options.except(:class)
3
+ = link_to text, path, class: classes, **render_options
4
4
  - else
5
5
  - if type&.to_sym == :submit
6
- %button{ type: :submit, name: :commit, class: classes, **options.except(:class) }
6
+ %button{ type: :submit, name: :commit, class: classes, **render_options }
7
7
  = text
8
8
  - else
9
- = button_to text, path, method:, form: form_options, class: classes, **options.except(:class)
9
+ = button_to text, path, method:, form: form_options, class: classes, **render_options
10
10
  - else
11
11
  - if render_a_tag?
12
- = link_to path, class: classes, **options.except(:class) do
12
+ = link_to path, class: classes, **render_options do
13
13
  = content
14
14
  - else
15
15
  - if type&.to_sym == :submit
16
- %button{ type: :submit, name: :commit, class: classes, **options.except(:class) }
16
+ %button{ type: :submit, name: :commit, class: classes, **render_options }
17
17
  = content
18
18
  - else
19
- = button_to path, method:, class: classes, form: form_options, **options.except(:class) do
19
+ = button_to path, method:, class: classes, form: form_options, **render_options do
20
20
  = content
@@ -61,8 +61,25 @@ module Tailwinds
61
61
  false
62
62
  end
63
63
 
64
+ def render_options
65
+ base_options = options.except(:class)
66
+ return base_options unless stop_cell_propagation?
67
+
68
+ base_options.merge(onclick: merged_onclick(base_options[:onclick]))
69
+ end
70
+
64
71
  private
65
72
 
73
+ def stop_cell_propagation?
74
+ view_context.respond_to?(:tramway_inside_cell) && view_context.tramway_inside_cell
75
+ end
76
+
77
+ def merged_onclick(existing_onclick)
78
+ return 'event.stopPropagation();' if existing_onclick.blank?
79
+
80
+ "#{existing_onclick}; event.stopPropagation();"
81
+ end
82
+
66
83
  def cursor_class
67
84
  if !render_a_tag? && !disabled?
68
85
  'cursor-pointer'
@@ -4,6 +4,22 @@ module Tailwinds
4
4
  module Table
5
5
  # Component for rendering a cell in a table
6
6
  class CellComponent < Tramway::BaseComponent
7
+ def around_render
8
+ ensure_view_context_accessor
9
+ previous_flag = view_context.tramway_inside_cell
10
+ view_context.tramway_inside_cell = true
11
+ yield
12
+ ensure
13
+ view_context.tramway_inside_cell = previous_flag
14
+ end
15
+
16
+ private
17
+
18
+ def ensure_view_context_accessor
19
+ return if view_context.respond_to?(:tramway_inside_cell=)
20
+
21
+ view_context.singleton_class.attr_accessor :tramway_inside_cell
22
+ end
7
23
  end
8
24
  end
9
25
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Tramway
4
- VERSION = '2.1.2'
4
+ VERSION = '2.1.2.1'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tramway
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.2
4
+ version: 2.1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - kalashnikovisme