keystone_ui 0.14.0 → 0.15.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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cdb61774853355f3b66ae9c1a7d6f4930005216827486777c19b582b3ac775f2
|
|
4
|
+
data.tar.gz: a815979ea629c273e43b8b7d39a20a1310908dedee967aec21b326e027784333
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: '0975326ab4b00a0f6ce7f28ae8642e2bee4704e13509046a1c2ad820e50880ace96f0b0d0e66dfd95e29b3d7d56cff68f7e4aef1264c507b2480eb72d3b14c5d'
|
|
7
|
+
data.tar.gz: e06fedfeebf535bf2c17ae2dc30938878a05f3cfb918f29df694886538f2c88f97d83d5eb51e9210e4dcdc8bfdbf3b16c8daef006d0bc51f6f93815752c4268c
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
<textarea name="<%= @attribute %>" rows="3" class="<%= Keystone::Ui::TextareaComponent::BASE_CLASSES %>"<% if @placeholder %> placeholder="<%= @placeholder %>"<% end %>><%= @value %></textarea>
|
|
16
16
|
<% elsif select? %>
|
|
17
17
|
<select name="<%= @attribute %>" class="<%= Keystone::Ui::SelectComponent::BASE_CLASSES %>">
|
|
18
|
-
<% unless required? %><option value=""
|
|
18
|
+
<% unless required? %><option value=""><%= blank_option_text %></option><% end %>
|
|
19
19
|
<% select_options.each do |label, value| %>
|
|
20
20
|
<option value="<%= value %>" <%= "selected" if @value.to_s == value.to_s %>><%= label %></option>
|
|
21
21
|
<% end %>
|
|
@@ -11,7 +11,7 @@ module Keystone
|
|
|
11
11
|
CHECKBOX_CLASSES = "ks-checkbox"
|
|
12
12
|
CHECKBOX_WRAPPER_CLASSES = "flex items-center gap-2"
|
|
13
13
|
|
|
14
|
-
def initialize(attribute:, label: nil, type: :text, required: false, hint: nil, placeholder: nil, min: nil, max: nil, step: nil, value: nil, options: [], errors: [])
|
|
14
|
+
def initialize(attribute:, label: nil, type: :text, required: false, hint: nil, placeholder: nil, min: nil, max: nil, step: nil, value: nil, options: [], errors: [], include_blank: nil)
|
|
15
15
|
@attribute = attribute
|
|
16
16
|
@label = label
|
|
17
17
|
@type = type
|
|
@@ -24,6 +24,7 @@ module Keystone
|
|
|
24
24
|
@value = value
|
|
25
25
|
@options = options
|
|
26
26
|
@errors = Array(errors)
|
|
27
|
+
@include_blank = include_blank.to_s
|
|
27
28
|
end
|
|
28
29
|
|
|
29
30
|
def label_text
|
|
@@ -66,6 +67,10 @@ module Keystone
|
|
|
66
67
|
@options
|
|
67
68
|
end
|
|
68
69
|
|
|
70
|
+
def blank_option_text
|
|
71
|
+
@include_blank
|
|
72
|
+
end
|
|
73
|
+
|
|
69
74
|
def input_options
|
|
70
75
|
options = { name: @attribute.to_s, class: Keystone::Ui::InputComponent::BASE_CLASSES }
|
|
71
76
|
unless textarea?
|
data/lib/keystone_ui/version.rb
CHANGED
|
@@ -96,7 +96,7 @@ outer element. See Conventions before using it.
|
|
|
96
96
|
The `<form>` wrapper. `method:` may be `:patch`/`:put`/`:delete` and is
|
|
97
97
|
translated for Rails. Set `multipart: true` when the form contains a file
|
|
98
98
|
upload.
|
|
99
|
-
- `ui_form_field(attribute:, label: nil, type: :text, required: false, hint: nil, placeholder: nil, min: nil, max: nil, step: nil, value: nil, options: [], errors: [])`
|
|
99
|
+
- `ui_form_field(attribute:, label: nil, type: :text, required: false, hint: nil, placeholder: nil, min: nil, max: nil, step: nil, value: nil, options: [], errors: [], include_blank: nil)`
|
|
100
100
|
— a labeled field with hint and error text. This is the default way to render
|
|
101
101
|
an input. `type:` `:text` `:number` `:email` `:password` `:date` `:textarea`
|
|
102
102
|
`:checkbox` `:select`. `attribute:` is used verbatim as the input's `name`, so
|
|
@@ -104,7 +104,9 @@ outer element. See Conventions before using it.
|
|
|
104
104
|
pass `label:` whenever the attribute is a nested name. `label:` defaults to the
|
|
105
105
|
attribute with underscores turned to spaces and the first letter capitalized.
|
|
106
106
|
`options:` is for `:select` and takes `[[label, value], ...]`; `value:` picks
|
|
107
|
-
the selected option, and a non-required select gets a leading
|
|
107
|
+
the selected option, and a non-required select gets a leading empty option,
|
|
108
|
+
worded by `include_blank:` (for example `"Not set yet"`) or left blank without
|
|
109
|
+
it. Never add your own empty choice to `options:` as well. A
|
|
108
110
|
`:checkbox` renders its label beside the box, submits `"0"` when unchecked and
|
|
109
111
|
`"1"` when checked, and pre-checks when `value:` is `"1"`. `errors:` is an
|
|
110
112
|
array of message strings.
|