phlex-forms 0.2.6 → 0.2.7
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 +4 -4
- data/lib/forms/live.rb +7 -1
- data/lib/forms/tag_field.rb +25 -18
- data/lib/phlex_forms/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d963c5c0eb08c6027d236da0489af8e2b7fd5ef258092c91cc280c8fe4711c5e
|
|
4
|
+
data.tar.gz: d1a686ce5b6b249c3860584c8b7a9447e4198efe7d0b6c9aed86441a3d7ee915
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4563f81fac25d23e76303ee2c96f2734add870c5b5707b8d45683a62479fccc30d0cd36464492627bb7bbabba209f41df8d657514d37a7fd748715d1af3150ab
|
|
7
|
+
data.tar.gz: 39961525f504962d9345cb6e9ab6215c624717d710db5e801b6fad872a8b60dc792233f66f653711c17aa694aa961263d720a8c75084e54d6832c55315c57f65
|
data/lib/forms/live.rb
CHANGED
|
@@ -168,10 +168,16 @@ module Forms
|
|
|
168
168
|
# widget (rendered in the block) is driven by this root, which then DOM-owns
|
|
169
169
|
# its hidden field. Name/id derived through field_name/field_id — the same
|
|
170
170
|
# path the rootless render uses, so the [name=…]/#…_query selectors match.
|
|
171
|
+
# This form IS a reactive component, so it has reactive_tags/reactive_filter
|
|
172
|
+
# itself — the same 0.12.2 escape-hatch sugar Forms::TagField uses, emitting
|
|
173
|
+
# both filter selectors the client needs (issue #6 Caveats 1 & 2).
|
|
171
174
|
tag = self.class.live_tags_declaration
|
|
172
175
|
return attrs unless tag
|
|
173
176
|
|
|
174
|
-
|
|
177
|
+
query_id = Forms::TagField.query_id(field_id(tag[:name]))
|
|
178
|
+
mix(attrs,
|
|
179
|
+
reactive_tags(name: field_name(tag[:name])),
|
|
180
|
+
reactive_filter(input: "##{query_id}"))
|
|
175
181
|
end
|
|
176
182
|
|
|
177
183
|
# Untouched fields get no error set, so nothing flashes before the user
|
data/lib/forms/tag_field.rb
CHANGED
|
@@ -18,11 +18,13 @@ module Forms
|
|
|
18
18
|
# The reactive_tags_* client helpers require phlex-reactive >= 0.11.4.
|
|
19
19
|
#
|
|
20
20
|
# It uses the reactive_tags_add/option/remove helpers for the chip/query/option
|
|
21
|
-
# behavior,
|
|
22
|
-
# reactive_tags(:
|
|
23
|
-
#
|
|
24
|
-
#
|
|
25
|
-
#
|
|
21
|
+
# behavior, and the ROOT's wire attrs come from the 0.12.2 escape-hatch sugar:
|
|
22
|
+
# reactive_tags(name: @name) takes the per-instance wire name verbatim ("user[tags]")
|
|
23
|
+
# — the class-level reactive_scope compile can't express it — validated at render;
|
|
24
|
+
# reactive_filter(input: "#…_query") targets the query input by id so it never
|
|
25
|
+
# submits, and (unlike the old raw -input-only attr) also emits
|
|
26
|
+
# data-reactive-filter-option so the 0.12.x client type-ahead actually runs
|
|
27
|
+
# (issue #6 Caveats 1 & 2).
|
|
26
28
|
class TagField < Phlex::HTML
|
|
27
29
|
include Phlex::Reactive::ClientBindings
|
|
28
30
|
|
|
@@ -48,21 +50,26 @@ module Forms
|
|
|
48
50
|
end
|
|
49
51
|
end
|
|
50
52
|
|
|
51
|
-
# The
|
|
52
|
-
#
|
|
53
|
-
#
|
|
54
|
-
|
|
55
|
-
# is lifted rootless.
|
|
56
|
-
def self.root_tag_attributes(name:, id:)
|
|
57
|
-
{ data: {
|
|
58
|
-
reactive_tags_field: %([name="#{name}"]),
|
|
59
|
-
reactive_filter_input: "##{id}_query"
|
|
60
|
-
} }
|
|
61
|
-
end
|
|
53
|
+
# The query input's id — the reactive_filter(input:) target and the id the
|
|
54
|
+
# search input itself carries. Public so Forms::Live can derive the same id
|
|
55
|
+
# when it hoists the tag wire attrs onto the <form> root (rootless widget).
|
|
56
|
+
def self.query_id(id) = "#{id}_query"
|
|
62
57
|
|
|
63
58
|
private
|
|
64
59
|
|
|
65
|
-
|
|
60
|
+
# The root's tag wire attrs, via the 0.12.2 escape-hatch sugar (Caveats 1 & 2):
|
|
61
|
+
# reactive_tags(name:) takes the instance-dynamic wire name verbatim and
|
|
62
|
+
# validates it at render; reactive_filter(input:) targets the query input by
|
|
63
|
+
# #id (so it never submits a stray param) and emits both filter selectors the
|
|
64
|
+
# 0.12.x client needs to run the type-ahead. Both are private helpers from
|
|
65
|
+
# ClientBindings — Forms::Live has its own copies (it's a reactive component)
|
|
66
|
+
# and calls them directly when hoisting these onto the <form> root.
|
|
67
|
+
def root_tag_attributes
|
|
68
|
+
mix(
|
|
69
|
+
reactive_tags(name: @name),
|
|
70
|
+
reactive_filter(input: "##{self.class.query_id(@id)}")
|
|
71
|
+
)
|
|
72
|
+
end
|
|
66
73
|
|
|
67
74
|
# The widget body WITHOUT its root wrapper — shared with the rootless variant
|
|
68
75
|
# so chip/template/suggestion markup never drifts between the two.
|
|
@@ -93,7 +100,7 @@ module Forms
|
|
|
93
100
|
|
|
94
101
|
def query_attributes
|
|
95
102
|
{
|
|
96
|
-
id:
|
|
103
|
+
id: self.class.query_id(@id), type: "search", autocomplete: "off",
|
|
97
104
|
placeholder: @placeholder, class: input_classes,
|
|
98
105
|
"aria-invalid": @error || nil
|
|
99
106
|
}.compact
|
data/lib/phlex_forms/version.rb
CHANGED