keystone_ui 0.55.0 → 0.57.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/assets/javascripts/keystone_ui/action_menu_controller.js +7 -1
- data/app/components/keystone/ui/action_menu_component.html.erb +2 -2
- data/app/components/keystone/ui/form_field_component.html.erb +3 -3
- data/app/components/keystone/ui/form_field_component.rb +17 -2
- data/app/components/keystone/ui/input_component.rb +11 -1
- data/app/components/keystone/ui/mobile_actions_component.html.erb +4 -3
- data/app/components/keystone/ui/mobile_actions_component.rb +1 -1
- data/lib/keystone_ui/version.rb +1 -1
- data/the_local/agents/keystone_ui-develop.md +23 -3
- 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: 2fb26a12c2b20d1b8102650320a2e5e6f2dfefaf2b304237f757338dacd2e1ae
|
|
4
|
+
data.tar.gz: 858ac42699c78a23a79942f18202db43f698a99a252f5d1fca6d098f2ec8d318
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5033f7611a6beb90d84c9ff39cfd49abac83ca61f881dae585f1effc838e485bbfd9a3f6087c00f2e090bb5dcfeabdef8ff7ed7f6c125a6f8b3e0bb546d66d3c
|
|
7
|
+
data.tar.gz: 41a9d9300720e1bfab2c8b46b2ac065922d2e2331a8f17ba0d2c178e11356f2c0953fe1695408ee0c5e904bca83134873c50bff3e74f1354d509bee39896d589
|
|
@@ -19,11 +19,17 @@ export default class extends Controller {
|
|
|
19
19
|
this.menuTarget.classList.add("hidden")
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
+
follow() {
|
|
23
|
+
if (!this.menuTarget.classList.contains("hidden")) this.place()
|
|
24
|
+
}
|
|
25
|
+
|
|
22
26
|
place() {
|
|
23
27
|
const button = this.buttonTarget.getBoundingClientRect()
|
|
28
|
+
const screenHeight = this.element.ownerDocument.documentElement.clientHeight
|
|
29
|
+
const roomBelow = button.bottom + this.menuTarget.offsetHeight <= screenHeight
|
|
24
30
|
Object.assign(this.menuTarget.style, {
|
|
25
31
|
position: "fixed",
|
|
26
|
-
top: `${button.bottom}px`,
|
|
32
|
+
top: `${roomBelow ? button.bottom : Math.max(0, button.top - this.menuTarget.offsetHeight)}px`,
|
|
27
33
|
left: `${button.right - this.menuTarget.offsetWidth}px`,
|
|
28
34
|
right: "auto"
|
|
29
35
|
})
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
<div class="<%= WRAPPER_CLASSES %>" data-controller="action-menu" data-action="scroll@window->action-menu#
|
|
1
|
+
<div class="<%= WRAPPER_CLASSES %>" data-controller="action-menu" data-action="scroll@window->action-menu#follow resize@window->action-menu#close">
|
|
2
2
|
<button type="button"
|
|
3
|
-
data-action="click->action-menu#toggle
|
|
3
|
+
data-action="click->action-menu#toggle pointerup@window->action-menu#hide"
|
|
4
4
|
data-action-menu-target="button"
|
|
5
5
|
class="<%= BUTTON_CLASSES %>"
|
|
6
6
|
aria-label="Actions">
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<div class="<%= WRAPPER_CLASSES %>">
|
|
2
2
|
<% unless checkbox? %>
|
|
3
|
-
<label class="<%= LABEL_CLASSES %>">
|
|
3
|
+
<label for="<%= field_id %>" class="<%= LABEL_CLASSES %>">
|
|
4
4
|
<%= label_text %><% if required? %><span class="<%= REQUIRED_CLASSES %>">*</span><% end %>
|
|
5
5
|
</label>
|
|
6
6
|
<% end %>
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
<span class="text-sm text-gray-700 dark:text-gray-300"><%= label_text %></span>
|
|
13
13
|
</div>
|
|
14
14
|
<% elsif textarea? %>
|
|
15
|
-
<textarea name="<%= @attribute %>" rows="3" class="<%= Keystone::Ui::TextareaComponent::BASE_CLASSES %>"<% if @placeholder %> placeholder="<%= @placeholder %>"<% end %>><%= @value %></textarea>
|
|
15
|
+
<textarea name="<%= @attribute %>" id="<%= field_id %>" rows="3" class="<%= Keystone::Ui::TextareaComponent::BASE_CLASSES %>"<% if @placeholder %> placeholder="<%= @placeholder %>"<% end %>><%= @value %></textarea>
|
|
16
16
|
<% elsif select? %>
|
|
17
|
-
<select name="<%= @attribute %>" class="<%= Keystone::Ui::SelectComponent::BASE_CLASSES %>">
|
|
17
|
+
<select name="<%= @attribute %>" id="<%= field_id %>" class="<%= Keystone::Ui::SelectComponent::BASE_CLASSES %>">
|
|
18
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>
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require "active_support/core_ext/string/inflections"
|
|
4
|
+
|
|
3
5
|
module Keystone
|
|
4
6
|
module Ui
|
|
5
7
|
class FormFieldComponent < ViewComponent::Base
|
|
@@ -11,7 +13,7 @@ module Keystone
|
|
|
11
13
|
CHECKBOX_CLASSES = "ks-checkbox"
|
|
12
14
|
CHECKBOX_WRAPPER_CLASSES = "ks-form-field-checkbox flex items-center"
|
|
13
15
|
|
|
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, disabled: false, suggestions: [])
|
|
16
|
+
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, disabled: false, suggestions: [], autofocus: false, autocomplete: nil, autocapitalize: nil, inputmode: nil)
|
|
15
17
|
@attribute = attribute
|
|
16
18
|
@label = label
|
|
17
19
|
@type = type
|
|
@@ -27,6 +29,10 @@ module Keystone
|
|
|
27
29
|
@include_blank = include_blank.to_s
|
|
28
30
|
@disabled = disabled
|
|
29
31
|
@suggestions = Array(suggestions)
|
|
32
|
+
@autofocus = autofocus
|
|
33
|
+
@autocomplete = autocomplete
|
|
34
|
+
@autocapitalize = autocapitalize
|
|
35
|
+
@inputmode = inputmode
|
|
30
36
|
end
|
|
31
37
|
|
|
32
38
|
def label_text
|
|
@@ -74,7 +80,7 @@ module Keystone
|
|
|
74
80
|
end
|
|
75
81
|
|
|
76
82
|
def input_options
|
|
77
|
-
options = { name: @attribute.to_s, class: Keystone::Ui::InputComponent::BASE_CLASSES }
|
|
83
|
+
options = { name: @attribute.to_s, id: field_id, class: Keystone::Ui::InputComponent::BASE_CLASSES }
|
|
78
84
|
unless textarea?
|
|
79
85
|
options[:type] = Keystone::Ui::InputComponent::TYPE_MAP.fetch(@type)
|
|
80
86
|
end
|
|
@@ -84,6 +90,11 @@ module Keystone
|
|
|
84
90
|
options[:max] = @max unless @max.nil?
|
|
85
91
|
options[:step] = @step unless @step.nil?
|
|
86
92
|
options[:disabled] = true if @disabled
|
|
93
|
+
options[:required] = true if required?
|
|
94
|
+
options[:autofocus] = true if @autofocus
|
|
95
|
+
options[:autocomplete] = @autocomplete unless @autocomplete.nil?
|
|
96
|
+
options[:autocapitalize] = @autocapitalize unless @autocapitalize.nil?
|
|
97
|
+
options[:inputmode] = @inputmode unless @inputmode.nil?
|
|
87
98
|
options[:list] = suggestions_id if suggestions?
|
|
88
99
|
options
|
|
89
100
|
end
|
|
@@ -96,6 +107,10 @@ module Keystone
|
|
|
96
107
|
@suggestions
|
|
97
108
|
end
|
|
98
109
|
|
|
110
|
+
def field_id
|
|
111
|
+
@attribute.to_s.parameterize
|
|
112
|
+
end
|
|
113
|
+
|
|
99
114
|
def suggestions_id
|
|
100
115
|
"#{@attribute.to_s.parameterize}-suggestions"
|
|
101
116
|
end
|
|
@@ -24,7 +24,7 @@ module Keystone
|
|
|
24
24
|
value.strftime(DATETIME_FORMAT)
|
|
25
25
|
end
|
|
26
26
|
|
|
27
|
-
def initialize(name:, type: :text, value: nil, placeholder: nil, disabled: false, min: nil, max: nil, step: nil)
|
|
27
|
+
def initialize(name:, type: :text, value: nil, placeholder: nil, disabled: false, min: nil, max: nil, step: nil, autofocus: false, autocomplete: nil, autocapitalize: nil, inputmode: nil, required: false)
|
|
28
28
|
@name = name
|
|
29
29
|
@type = type
|
|
30
30
|
@value = value
|
|
@@ -33,6 +33,11 @@ module Keystone
|
|
|
33
33
|
@min = min
|
|
34
34
|
@max = max
|
|
35
35
|
@step = step
|
|
36
|
+
@autofocus = autofocus
|
|
37
|
+
@autocomplete = autocomplete
|
|
38
|
+
@autocapitalize = autocapitalize
|
|
39
|
+
@inputmode = inputmode
|
|
40
|
+
@required = required
|
|
36
41
|
end
|
|
37
42
|
|
|
38
43
|
def classes
|
|
@@ -57,6 +62,11 @@ module Keystone
|
|
|
57
62
|
options[:min] = @min unless @min.nil?
|
|
58
63
|
options[:max] = @max unless @max.nil?
|
|
59
64
|
options[:step] = @step unless @step.nil?
|
|
65
|
+
options[:autofocus] = true if @autofocus
|
|
66
|
+
options[:autocomplete] = @autocomplete unless @autocomplete.nil?
|
|
67
|
+
options[:autocapitalize] = @autocapitalize unless @autocapitalize.nil?
|
|
68
|
+
options[:inputmode] = @inputmode unless @inputmode.nil?
|
|
69
|
+
options[:required] = true if @required
|
|
60
70
|
options
|
|
61
71
|
end
|
|
62
72
|
end
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
<div class="<%= WRAPPER_CLASSES %>" data-controller="
|
|
1
|
+
<div class="<%= WRAPPER_CLASSES %>" data-controller="action-menu" data-action="scroll@window->action-menu#follow resize@window->action-menu#close">
|
|
2
2
|
<button type="button"
|
|
3
|
-
data-action="click->
|
|
3
|
+
data-action="click->action-menu#toggle pointerup@window->action-menu#hide"
|
|
4
|
+
data-action-menu-target="button"
|
|
4
5
|
class="<%= BUTTON_CLASSES %>"
|
|
5
6
|
aria-label="Actions">
|
|
6
7
|
<%= ELLIPSIS_ICON.html_safe %>
|
|
7
8
|
</button>
|
|
8
|
-
<div data-
|
|
9
|
+
<div data-action-menu-target="menu" class="<%= DROPDOWN_CLASSES %>">
|
|
9
10
|
<%= content %>
|
|
10
11
|
</div>
|
|
11
12
|
</div>
|
data/lib/keystone_ui/version.rb
CHANGED
|
@@ -268,7 +268,7 @@ two exceptions: `ui_page`'s `padding:` treats any value other than `:none` as
|
|
|
268
268
|
- `ui_form(action:, method: :post, multipart: false, data: nil)` takes a
|
|
269
269
|
block. `method:` may be `:patch`, `:put` or `:delete`, sent as Rails
|
|
270
270
|
expects. Set `multipart: true` when the form holds a file upload.
|
|
271
|
-
- `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, disabled: false, suggestions: [])`
|
|
271
|
+
- `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, disabled: false, suggestions: [], autofocus: false, autocomplete: nil, autocapitalize: nil, inputmode: nil)`
|
|
272
272
|
is the default way to render a field. `type:` is `:text` `:number`
|
|
273
273
|
`:email` `:password` `:date` `:datetime` `:textarea` `:checkbox` `:select`.
|
|
274
274
|
- A `:datetime` field is a `datetime-local` input for a date and a time of
|
|
@@ -290,11 +290,31 @@ two exceptions: `ui_page`'s `padding:` treats any value other than `:none` as
|
|
|
290
290
|
`:email` `:password` `:date` `:datetime` and is ignored by the other types. Its list
|
|
291
291
|
is identified by `attribute:`, so two fields with suggestions on one
|
|
292
292
|
screen need different `attribute:` values.
|
|
293
|
+
- The field's label is tied to its input, textarea or select through an
|
|
294
|
+
`id` built from `attribute:`, so tapping the label focuses the input and
|
|
295
|
+
a screen reader reads the label. `"player[email]"` gets the id
|
|
296
|
+
`player-email`, so two fields on one screen need different `attribute:`
|
|
297
|
+
values.
|
|
298
|
+
- `required: true` marks the label with an asterisk and, on a `:text`
|
|
299
|
+
`:number` `:email` `:password` `:date` `:datetime` field, sets the
|
|
300
|
+
input's `required` attribute so the browser will not send the form with
|
|
301
|
+
it empty.
|
|
302
|
+
- `autofocus: true` puts the cursor in the input when the page opens. Give
|
|
303
|
+
it to one field per page at most.
|
|
304
|
+
- `autocomplete:`, `autocapitalize:` and `inputmode:` are written onto the
|
|
305
|
+
input as given, such as `autocomplete: "email"`, `autocapitalize: "none"`
|
|
306
|
+
and `inputmode: "numeric"`. They let a phone suggest a saved value, stop
|
|
307
|
+
capitalizing the first letter, and open the right keyboard.
|
|
308
|
+
- `autofocus:`, `autocomplete:`, `autocapitalize:` and `inputmode:` apply to
|
|
309
|
+
the same types as `suggestions:` and are ignored by `:textarea`
|
|
310
|
+
`:checkbox` and `:select`.
|
|
293
311
|
- A value that must be one of a fixed list is a `:select`, and a free value
|
|
294
312
|
with common choices is a text field with `suggestions:`. Ask the developer
|
|
295
313
|
which a field is and which values it offers.
|
|
296
|
-
- `ui_input(name:, type: :text, value: nil, placeholder: nil, disabled: false, min: nil, max: nil, step: nil)`
|
|
297
|
-
takes `:text` `:number` `:email` `:password` `:date` `:datetime`.
|
|
314
|
+
- `ui_input(name:, type: :text, value: nil, placeholder: nil, disabled: false, min: nil, max: nil, step: nil, autofocus: false, autocomplete: nil, autocapitalize: nil, inputmode: nil, required: false)`
|
|
315
|
+
takes `:text` `:number` `:email` `:password` `:date` `:datetime`. Its
|
|
316
|
+
`autofocus:` `autocomplete:` `autocapitalize:` and `inputmode:` work as on
|
|
317
|
+
`ui_form_field`, and `required: true` sets the `required` attribute.
|
|
298
318
|
`ui_textarea(name:, value: nil, rows: 3, placeholder: nil, disabled: false)`
|
|
299
319
|
and `ui_select(name:, options: [], selected: nil, include_blank: nil, disabled: false)`
|
|
300
320
|
are the bare forms of the other two. Use them only where a label does not
|