reflex_behaviors 0.0.2 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +13 -8
- data/README.md +1 -1
- data/app/assets/builds/reflex_behaviors.js +133 -3
- data/app/assets/builds/reflex_behaviors.js.map +4 -4
- data/app/helpers/reflex_behaviors/application_helper.rb +13 -6
- data/app/javascript/devtools/dom.js +34 -0
- data/app/javascript/devtools/elements/devtool_element.js +62 -0
- data/app/javascript/devtools/elements/supervisor_element.js +113 -0
- data/app/javascript/devtools/elements/tooltip_element.js +102 -0
- data/app/javascript/devtools/index.js +5 -0
- data/app/javascript/devtools/supervisor.js +83 -0
- data/app/javascript/devtools/toggle.js +150 -0
- data/app/javascript/elements/reflex_element.js +27 -0
- data/app/javascript/elements/toggle_trigger_element.js +50 -2
- data/app/javascript/index.js +3 -0
- data/lib/reflex_behaviors/tag_builders/base_tag_builder.rb +8 -0
- data/lib/reflex_behaviors/tag_builders/toggle_tags_builder.rb +24 -33
- data/lib/reflex_behaviors/version.rb +1 -1
- data/package.json +1 -1
- data/tags +1069 -853
- data/yarn.lock +141 -141
- metadata +9 -2
data/app/javascript/index.js
CHANGED
@@ -9,6 +9,14 @@ module ReflexBehaviors
|
|
9
9
|
def initialize(view_context)
|
10
10
|
@view_context = view_context
|
11
11
|
end
|
12
|
+
|
13
|
+
def view_stack
|
14
|
+
prefix = "app/views/"
|
15
|
+
locations = caller_locations.select { |location| location.path.include?(prefix) }
|
16
|
+
locations.each_with_object(Set.new) do |location, memo|
|
17
|
+
memo << location.path[(location.path.index(prefix) + prefix.length)..]
|
18
|
+
end
|
19
|
+
end
|
12
20
|
end
|
13
21
|
end
|
14
22
|
end
|
@@ -5,22 +5,39 @@ require_relative "base_tag_builder"
|
|
5
5
|
module ReflexBehaviors::TagBuilders
|
6
6
|
class ToggleTagsBuilder < BaseTagBuilder
|
7
7
|
def target_tag(id, expanded: false, **kwargs, &block)
|
8
|
-
return unless expanded || target_expanded?(id)
|
9
|
-
|
10
8
|
kwargs = kwargs.with_indifferent_access
|
11
9
|
kwargs[:id] = id
|
12
10
|
kwargs[:role] = "region"
|
11
|
+
|
13
12
|
kwargs[:aria] ||= {}
|
14
|
-
kwargs[:aria]
|
13
|
+
kwargs[:aria][:label] ||= "Dynamic Content Region"
|
14
|
+
kwargs[:aria][:live] ||= "polite"
|
15
15
|
|
16
|
-
|
16
|
+
kwargs[:data] ||= {}
|
17
|
+
kwargs[:data][:view_stack] = view_stack.to_json if Rails.env.development?
|
18
|
+
|
19
|
+
if expanded || target_expanded?(id)
|
20
|
+
content_tag("toggle-target", nil, kwargs, &block)
|
21
|
+
else
|
22
|
+
content_tag("toggle-target", nil, kwargs)
|
23
|
+
end
|
17
24
|
end
|
18
25
|
|
19
|
-
def trigger_tag(target:, render:,
|
26
|
+
def trigger_tag(target:, render:, action: :toggle, disabled: false, **kwargs, &block)
|
20
27
|
kwargs = kwargs.with_indifferent_access
|
21
28
|
kwargs[:id] ||= "#{target}-toggle-trigger"
|
22
|
-
|
23
|
-
kwargs[:
|
29
|
+
|
30
|
+
kwargs[:aria] ||= {}
|
31
|
+
kwargs[:aria][:atomic] ||= true
|
32
|
+
kwargs[:aria][:relevant] ||= "all"
|
33
|
+
kwargs[:aria].merge!(controls: target, expanded: target_expanded?(target))
|
34
|
+
|
35
|
+
kwargs[:data] ||= {}
|
36
|
+
kwargs[:data][:auto_collapse] = !!kwargs[:data][:auto_collapse]
|
37
|
+
kwargs[:data][:view_stack] = view_stack.to_json if Rails.env.development?
|
38
|
+
kwargs[:data][:remember] = !!kwargs[:data][:remember]
|
39
|
+
kwargs[:data][:render] = render
|
40
|
+
kwargs[:data][:turbo_reflex] = "ReflexBehaviors::ToggleReflex##{action}" unless disabled
|
24
41
|
|
25
42
|
content_tag("toggle-trigger", nil, kwargs, &block)
|
26
43
|
end
|
@@ -32,31 +49,5 @@ module ReflexBehaviors::TagBuilders
|
|
32
49
|
def target_collapsed?(target)
|
33
50
|
!target_expanded?(target)
|
34
51
|
end
|
35
|
-
|
36
|
-
private
|
37
|
-
|
38
|
-
def trigger_aria(controls:, expanded:, **kwargs)
|
39
|
-
kwargs = kwargs.with_indifferent_access
|
40
|
-
kwargs[:atomic] ||= true
|
41
|
-
kwargs[:relevant] ||= "all"
|
42
|
-
kwargs.merge(controls: controls, expanded: !!expanded)
|
43
|
-
end
|
44
|
-
|
45
|
-
def trigger_data(render:, disabled: false, remember: false, auto_collapse: false, **kwargs)
|
46
|
-
kwargs = kwargs.with_indifferent_access
|
47
|
-
kwargs.merge(
|
48
|
-
turbo_reflex: disabled ? nil : "ReflexBehaviors::ToggleReflex#toggle",
|
49
|
-
render: render,
|
50
|
-
remember: !!remember,
|
51
|
-
auto_collapse: !!auto_collapse
|
52
|
-
)
|
53
|
-
end
|
54
|
-
|
55
|
-
def target_aria(**kwargs)
|
56
|
-
kwargs = kwargs.with_indifferent_access
|
57
|
-
kwargs[:label] ||= "Dynamic Content Region"
|
58
|
-
kwargs[:live] ||= "polite"
|
59
|
-
kwargs
|
60
|
-
end
|
61
52
|
end
|
62
53
|
end
|
data/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "reflex_behaviors",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.3",
|
4
4
|
"description": "Pre-built easy to use reactive TurboReflex behaviors for Rails/Hotwire apps.",
|
5
5
|
"main": "app/javascript/index.js",
|
6
6
|
"repository": "https://github.com/hopsoft/reflex_behaviors",
|