keystone_ui 0.117.0 → 0.118.0
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/app/components/keystone/ui/form_field_component.html.erb +9 -1
- data/app/components/keystone/ui/form_field_component.rb +8 -0
- data/app/components/keystone/ui/select_component.html.erb +9 -1
- data/app/components/keystone/ui/select_component.rb +8 -0
- data/lib/keystone_ui/version.rb +1 -1
- data/the_local/agents/keystone_ui-develop.md +10 -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: 4fbd38bd59f910a8e2ae0b3745aac0641de08cf45e5b634d34d4521899441f0a
|
|
4
|
+
data.tar.gz: 6c25792dbd5b8937c6b455d37d34d5e16b9cde903a3967f5ab3523322756df91
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 948f30d946badde94f0b844a3cb08da9860fb90976f4ca172acd677e4db4e9daa2607138835883d354ac7b3d8c1e8251c18acadad339bf13f3c43efc48cdf3ba
|
|
7
|
+
data.tar.gz: 79eb302a343164bef3866e674be410a5c41219decdb7558cc6169e05a2192360acdd66b7e2f18fac4207977ef2c742ac49860fd80f64dfbfe89a1226000cf79b
|
|
@@ -17,7 +17,15 @@
|
|
|
17
17
|
<select name="<%= @attribute %>" id="<%= field_id %>" class="<%= Keystone::Ui::SelectComponent::BASE_CLASSES %>">
|
|
18
18
|
<% if blank_option? %><option value=""><%= blank_option_text %></option><% end %>
|
|
19
19
|
<% select_options.each do |label, value, attributes| %>
|
|
20
|
-
|
|
20
|
+
<% if option_group?(value) %>
|
|
21
|
+
<%= tag.optgroup(label: label) do %>
|
|
22
|
+
<% value.each do |choice| %>
|
|
23
|
+
<%= option_tag(*choice) %>
|
|
24
|
+
<% end %>
|
|
25
|
+
<% end %>
|
|
26
|
+
<% else %>
|
|
27
|
+
<%= option_tag(label, value, attributes) %>
|
|
28
|
+
<% end %>
|
|
21
29
|
<% end %>
|
|
22
30
|
</select>
|
|
23
31
|
<% else %>
|
|
@@ -83,6 +83,14 @@ module Keystone
|
|
|
83
83
|
@options
|
|
84
84
|
end
|
|
85
85
|
|
|
86
|
+
def option_group?(value)
|
|
87
|
+
value.is_a?(Array)
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def option_tag(label, value, attributes = nil)
|
|
91
|
+
tag.option(label, value: value, selected: @value.to_s == value.to_s, disabled: attributes&.dig(:disabled))
|
|
92
|
+
end
|
|
93
|
+
|
|
86
94
|
def blank_option?
|
|
87
95
|
!required? && @include_blank != false
|
|
88
96
|
end
|
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
<option value=""><%= include_blank %></option>
|
|
4
4
|
<% end %>
|
|
5
5
|
<% options.each do |label, value, attributes| %>
|
|
6
|
-
|
|
6
|
+
<% if option_group?(value) %>
|
|
7
|
+
<%= tag.optgroup(label: label) do %>
|
|
8
|
+
<% value.each do |choice| %>
|
|
9
|
+
<%= option_tag(*choice) %>
|
|
10
|
+
<% end %>
|
|
11
|
+
<% end %>
|
|
12
|
+
<% else %>
|
|
13
|
+
<%= option_tag(label, value, attributes) %>
|
|
14
|
+
<% end %>
|
|
7
15
|
<% end %>
|
|
8
16
|
<% end %>
|
|
@@ -23,6 +23,14 @@ module Keystone
|
|
|
23
23
|
tokens.join(" ")
|
|
24
24
|
end
|
|
25
25
|
|
|
26
|
+
def option_group?(value)
|
|
27
|
+
value.is_a?(Array)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def option_tag(label, value, attributes = nil)
|
|
31
|
+
tag.option(label, value: value, selected: selected.to_s == value.to_s, disabled: attributes&.dig(:disabled))
|
|
32
|
+
end
|
|
33
|
+
|
|
26
34
|
def tag_options
|
|
27
35
|
opts = {
|
|
28
36
|
name: @name,
|
data/lib/keystone_ui/version.rb
CHANGED
|
@@ -56,7 +56,7 @@ not available in the app yet, that is `keystone_ui-install`'s job.
|
|
|
56
56
|
- `ui_form_field` — a labelled input, textarea, checkbox or select with hint and error text, and short text such as `$` or `hours` inside a text or number input's border.
|
|
57
57
|
- `ui_input` — a bare styled input with no label, optionally with short text inside its border before or after it.
|
|
58
58
|
- `ui_textarea` — a bare styled textarea with no label.
|
|
59
|
-
- `ui_select` — a bare styled select with no label, any of whose choices can be greyed out so it cannot be chosen.
|
|
59
|
+
- `ui_select` — a bare styled select with no label, any of whose choices can be greyed out so it cannot be chosen, and whose choices can sit under group headings.
|
|
60
60
|
- `ui_multi_select` — a dropdown of checkboxes posting every checked value.
|
|
61
61
|
- `ui_search_select` — a form field that searches the app as a person types and submits the id of the record they pick.
|
|
62
62
|
- `ui_file_upload` — a file drop zone with selected-file feedback.
|
|
@@ -547,6 +547,15 @@ two exceptions: `ui_page`'s `padding:` treats any value other than `:none` as
|
|
|
547
547
|
out and cannot be chosen, on `ui_form_field` and on `ui_select`. Use it
|
|
548
548
|
for a choice that is shown but not available, and ask the developer what
|
|
549
549
|
makes a choice unavailable.
|
|
550
|
+
- An entry of `options:` given as `[group_label, [[label, value], ...]]`
|
|
551
|
+
draws its choices under a heading reading `group_label`, on
|
|
552
|
+
`ui_form_field` and on `ui_select`, the shape Rails'
|
|
553
|
+
`grouped_options_for_select` takes. `value:` (or `selected:` on
|
|
554
|
+
`ui_select`) and `{ disabled: true }` work on a choice inside a group, and
|
|
555
|
+
the empty first choice stays above every group. Use groups when choices
|
|
556
|
+
come from different sources, such as `[["Census data", [["Income",
|
|
557
|
+
"income"]]], ["Your estimate", [["Interested", "interested"]]]]`, rather
|
|
558
|
+
than writing the source into each choice's label.
|
|
550
559
|
- A `:checkbox` renders its label beside the box, submits `"0"` unchecked
|
|
551
560
|
and `"1"` checked, and is checked when `value:` is `"1"`. With
|
|
552
561
|
`required: true` the browser will not submit the form while it is
|