stimulus_plumbers 0.3.0 → 0.3.1
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/CHANGELOG.md +7 -0
- data/lib/stimulus_plumbers/components/action_list/section.rb +6 -5
- data/lib/stimulus_plumbers/components/action_list.rb +3 -3
- data/lib/stimulus_plumbers/components/calendar/month/turbo/days_of_month.rb +10 -8
- data/lib/stimulus_plumbers/components/card/section.rb +3 -3
- data/lib/stimulus_plumbers/components/card.rb +3 -3
- data/lib/stimulus_plumbers/components/combobox/autocomplete.rb +8 -14
- data/lib/stimulus_plumbers/components/combobox/date.rb +6 -2
- data/lib/stimulus_plumbers/components/combobox/dropdown.rb +6 -2
- data/lib/stimulus_plumbers/components/combobox/popover.rb +9 -5
- data/lib/stimulus_plumbers/components/combobox/time.rb +1 -1
- data/lib/stimulus_plumbers/components/combobox/trigger.rb +20 -11
- data/lib/stimulus_plumbers/components/combobox.rb +33 -23
- data/lib/stimulus_plumbers/components/divider.rb +16 -0
- data/lib/stimulus_plumbers/components/popover/builder.rb +2 -2
- data/lib/stimulus_plumbers/form/builder.rb +39 -43
- data/lib/stimulus_plumbers/form/field.rb +96 -45
- data/lib/stimulus_plumbers/form/fields/error.rb +2 -2
- data/lib/stimulus_plumbers/form/fields/fieldset.rb +54 -0
- data/lib/stimulus_plumbers/form/fields/group.rb +2 -2
- data/lib/stimulus_plumbers/form/fields/hint.rb +2 -2
- data/lib/stimulus_plumbers/form/fields/input_group.rb +25 -0
- data/lib/stimulus_plumbers/form/fields/inputs/choice.rb +69 -0
- data/lib/stimulus_plumbers/form/fields/inputs/datetime.rb +81 -0
- data/lib/stimulus_plumbers/form/fields/inputs/file.rb +22 -0
- data/lib/stimulus_plumbers/form/fields/inputs/password.rb +59 -0
- data/lib/stimulus_plumbers/form/fields/inputs/search.rb +102 -0
- data/lib/stimulus_plumbers/form/fields/inputs/select/grouped.rb +56 -0
- data/lib/stimulus_plumbers/form/fields/inputs/select/timezone.rb +59 -0
- data/lib/stimulus_plumbers/form/fields/inputs/select/weekday.rb +45 -0
- data/lib/stimulus_plumbers/form/fields/inputs/select.rb +91 -0
- data/lib/stimulus_plumbers/form/fields/inputs/submit.rb +25 -0
- data/lib/stimulus_plumbers/form/fields/inputs/text.rb +37 -0
- data/lib/stimulus_plumbers/form/fields/inputs/text_area.rb +22 -0
- data/lib/stimulus_plumbers/form/fields/label.rb +13 -9
- data/lib/stimulus_plumbers/helpers/calendar_helper.rb +1 -1
- data/lib/stimulus_plumbers/helpers/combobox_helper.rb +29 -36
- data/lib/stimulus_plumbers/helpers/divider_helper.rb +11 -0
- data/lib/stimulus_plumbers/helpers.rb +2 -0
- data/lib/stimulus_plumbers/themes/base.rb +1 -0
- data/lib/stimulus_plumbers/themes/schema.rb +7 -1
- data/lib/stimulus_plumbers/version.rb +1 -1
- data/lib/stimulus_plumbers.rb +4 -2
- metadata +17 -11
- data/lib/stimulus_plumbers/form/fields/choice.rb +0 -25
- data/lib/stimulus_plumbers/form/fields/combobox.rb +0 -44
- data/lib/stimulus_plumbers/form/fields/file.rb +0 -16
- data/lib/stimulus_plumbers/form/fields/password.rb +0 -55
- data/lib/stimulus_plumbers/form/fields/renderer.rb +0 -55
- data/lib/stimulus_plumbers/form/fields/search.rb +0 -54
- data/lib/stimulus_plumbers/form/fields/select.rb +0 -33
- data/lib/stimulus_plumbers/form/fields/submit.rb +0 -23
- data/lib/stimulus_plumbers/form/fields/text.rb +0 -33
- data/lib/stimulus_plumbers/form/fields/text_area.rb +0 -16
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module StimulusPlumbers
|
|
4
|
-
module Form
|
|
5
|
-
module Fields
|
|
6
|
-
module Password
|
|
7
|
-
def password_field(attribute, options = {})
|
|
8
|
-
rails_opts, form_field_opts = extract_options(options)
|
|
9
|
-
reveal = form_field_opts.delete(:reveal) { false }
|
|
10
|
-
field = build_field(attribute, form_field_opts)
|
|
11
|
-
|
|
12
|
-
input_html = if reveal
|
|
13
|
-
input_opts = merge_html_options(
|
|
14
|
-
rails_opts,
|
|
15
|
-
field_theme(:form_input_reveal),
|
|
16
|
-
field.html_opts,
|
|
17
|
-
{ "data-input-format-target": "input" }
|
|
18
|
-
)
|
|
19
|
-
build_input_group(
|
|
20
|
-
super(attribute, input_opts),
|
|
21
|
-
field,
|
|
22
|
-
trailing: reveal_button,
|
|
23
|
-
"data-controller": "input-format",
|
|
24
|
-
"data-input-format-type-value": "password"
|
|
25
|
-
)
|
|
26
|
-
else
|
|
27
|
-
html_opts = merge_html_options(
|
|
28
|
-
rails_opts,
|
|
29
|
-
field_theme(:form_input, error: field.error?),
|
|
30
|
-
field.html_opts
|
|
31
|
-
)
|
|
32
|
-
super(attribute, html_opts)
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
render_field(field, input_html)
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
private
|
|
39
|
-
|
|
40
|
-
def reveal_button
|
|
41
|
-
@template.content_tag(
|
|
42
|
-
:button,
|
|
43
|
-
"",
|
|
44
|
-
type: "button",
|
|
45
|
-
class: field_theme(:form_button_reveal)[:class],
|
|
46
|
-
"aria-label": "Show password",
|
|
47
|
-
"aria-pressed": "false",
|
|
48
|
-
"data-input-format-target": "toggle",
|
|
49
|
-
"data-action": "click->input-format#toggle"
|
|
50
|
-
)
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
end
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module StimulusPlumbers
|
|
4
|
-
module Form
|
|
5
|
-
module Fields
|
|
6
|
-
class Renderer
|
|
7
|
-
attr_reader :template, :theme, :field
|
|
8
|
-
|
|
9
|
-
def initialize(template, theme, field)
|
|
10
|
-
@template = template
|
|
11
|
-
@theme = theme
|
|
12
|
-
@field = field
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def call(input_html)
|
|
16
|
-
Group.new(template).render(layout: field.layout, error: field.error?) do
|
|
17
|
-
(field_label + input_html.html_safe + field_hint + field_errors).html_safe
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
private
|
|
22
|
-
|
|
23
|
-
def field_label
|
|
24
|
-
Label.new(template).render(
|
|
25
|
-
text: field.label_text,
|
|
26
|
-
for_id: field.input_id,
|
|
27
|
-
required: field.required,
|
|
28
|
-
hidden: field.label_hidden?
|
|
29
|
-
)
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def field_hint
|
|
33
|
-
return "".html_safe unless field.details.present?
|
|
34
|
-
|
|
35
|
-
Hint.new(template).render(
|
|
36
|
-
text: field.details,
|
|
37
|
-
id: field.hint_id
|
|
38
|
-
)
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
def field_errors
|
|
42
|
-
return "".html_safe if field.errors.none?
|
|
43
|
-
|
|
44
|
-
field.errors.map.with_index(1) do |message, i|
|
|
45
|
-
Error.new(template).render(message: message, id: error_id_for(i))
|
|
46
|
-
end.join.html_safe
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
def error_id_for(index)
|
|
50
|
-
field.errors.one? ? field.error_id : "#{field.error_id}_#{index}"
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
end
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module StimulusPlumbers
|
|
4
|
-
module Form
|
|
5
|
-
module Fields
|
|
6
|
-
module Search
|
|
7
|
-
def search_field(attribute, options = {})
|
|
8
|
-
rails_opts, form_field_opts = extract_options(options)
|
|
9
|
-
clearable = form_field_opts.delete(:clearable) { false }
|
|
10
|
-
field = build_field(attribute, form_field_opts)
|
|
11
|
-
|
|
12
|
-
input_html = if clearable
|
|
13
|
-
input_opts = merge_html_options(
|
|
14
|
-
rails_opts,
|
|
15
|
-
field_theme(:form_input, error: field.error?),
|
|
16
|
-
field.html_opts,
|
|
17
|
-
{ "data-input-search-target": "input", inputmode: "search" }
|
|
18
|
-
)
|
|
19
|
-
build_input_group(
|
|
20
|
-
super(attribute, input_opts),
|
|
21
|
-
field,
|
|
22
|
-
trailing: clear_button,
|
|
23
|
-
"data-controller": "input-search",
|
|
24
|
-
role: "search"
|
|
25
|
-
)
|
|
26
|
-
else
|
|
27
|
-
html_opts = merge_html_options(
|
|
28
|
-
rails_opts,
|
|
29
|
-
field_theme(:form_input, error: field.error?),
|
|
30
|
-
field.html_opts
|
|
31
|
-
)
|
|
32
|
-
super(attribute, html_opts)
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
render_field(field, input_html)
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
private
|
|
39
|
-
|
|
40
|
-
def clear_button
|
|
41
|
-
@template.content_tag(
|
|
42
|
-
:button,
|
|
43
|
-
"",
|
|
44
|
-
type: "button",
|
|
45
|
-
class: field_theme(:form_button_reveal)[:class],
|
|
46
|
-
"aria-label": "Clear search",
|
|
47
|
-
"data-input-search-target": "clear",
|
|
48
|
-
"data-action": "click->input-search#clear"
|
|
49
|
-
)
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
end
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module StimulusPlumbers
|
|
4
|
-
module Form
|
|
5
|
-
module Fields
|
|
6
|
-
module Select
|
|
7
|
-
def select(attribute, choices = nil, options = {}, html_options = {})
|
|
8
|
-
rails_opts, form_field_opts = extract_options(options)
|
|
9
|
-
field = build_field(attribute, form_field_opts)
|
|
10
|
-
html_opts = merge_html_options(html_options, field_theme(:form_select, error: field.error?), field.html_opts)
|
|
11
|
-
render_field(field, super(attribute, choices, rails_opts, html_opts))
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def collection_select(
|
|
15
|
-
attribute,
|
|
16
|
-
collection,
|
|
17
|
-
value_method,
|
|
18
|
-
text_method,
|
|
19
|
-
options = {},
|
|
20
|
-
html_options = {}
|
|
21
|
-
)
|
|
22
|
-
rails_opts, form_field_opts = extract_options(options)
|
|
23
|
-
field = build_field(attribute, form_field_opts)
|
|
24
|
-
html_opts = merge_html_options(html_options, field_theme(:form_select, error: field.error?), field.html_opts)
|
|
25
|
-
render_field(
|
|
26
|
-
field,
|
|
27
|
-
super(attribute, collection, value_method, text_method, rails_opts, html_opts)
|
|
28
|
-
)
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
end
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module StimulusPlumbers
|
|
4
|
-
module Form
|
|
5
|
-
module Fields
|
|
6
|
-
module Submit
|
|
7
|
-
def submit(value = nil, options = {})
|
|
8
|
-
if value.is_a?(Hash)
|
|
9
|
-
options = value
|
|
10
|
-
value = nil
|
|
11
|
-
end
|
|
12
|
-
value ||= submit_default_value
|
|
13
|
-
variant = options.delete(:variant) { :default }
|
|
14
|
-
@template.tag.input(
|
|
15
|
-
type: "submit",
|
|
16
|
-
value: value,
|
|
17
|
-
**merge_html_options(field_theme(:form_submit, variant: variant), options)
|
|
18
|
-
)
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module StimulusPlumbers
|
|
4
|
-
module Form
|
|
5
|
-
module Fields
|
|
6
|
-
module Text
|
|
7
|
-
FIELD_TYPES = %i[
|
|
8
|
-
color_field
|
|
9
|
-
date_field
|
|
10
|
-
datetime_local_field
|
|
11
|
-
email_field
|
|
12
|
-
month_field
|
|
13
|
-
number_field
|
|
14
|
-
range_field
|
|
15
|
-
telephone_field
|
|
16
|
-
text_field
|
|
17
|
-
time_field
|
|
18
|
-
url_field
|
|
19
|
-
week_field
|
|
20
|
-
].freeze
|
|
21
|
-
|
|
22
|
-
FIELD_TYPES.each do |method_name|
|
|
23
|
-
define_method(method_name) do |attribute, options = {}|
|
|
24
|
-
rails_opts, form_field_opts = extract_options(options)
|
|
25
|
-
field = build_field(attribute, form_field_opts)
|
|
26
|
-
html_opts = merge_html_options(rails_opts, field_theme(:form_input, error: field.error?), field.html_opts)
|
|
27
|
-
render_field(field, super(attribute, html_opts))
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
end
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module StimulusPlumbers
|
|
4
|
-
module Form
|
|
5
|
-
module Fields
|
|
6
|
-
module TextArea
|
|
7
|
-
def text_area(attribute, options = {})
|
|
8
|
-
rails_opts, form_field_opts = extract_options(options)
|
|
9
|
-
field = build_field(attribute, form_field_opts)
|
|
10
|
-
html_opts = merge_html_options(rails_opts, field_theme(:form_textarea, error: field.error?), field.html_opts)
|
|
11
|
-
render_field(field, super(attribute, html_opts))
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
end
|