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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 65ec93e5a4973beff68cd58f7c0bd06929d9f9063aab326ec16c974c164b319a
|
|
4
|
+
data.tar.gz: 19f708dfefa7c8c744cfd6ca6f97f7620a1580160039baf962b72a73b649009b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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, **
|
|
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, **
|
|
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, **
|
|
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, **
|
|
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, **
|
|
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, **
|
|
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
|
data/lib/tramway/version.rb
CHANGED