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
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module StimulusPlumbers
|
|
4
|
+
module Form
|
|
5
|
+
module Fields
|
|
6
|
+
module Inputs
|
|
7
|
+
module Select
|
|
8
|
+
module Timezone
|
|
9
|
+
def time_zone_select(attribute, priority_zones = nil, options = {}, html_options = {})
|
|
10
|
+
html_native = options.delete(:html_native) { false }
|
|
11
|
+
Field.new(@template, **options).render(object, attribute, input_id: field_id(attribute)) do |html_opts, opts, error|
|
|
12
|
+
merged_html_opts = merge_html_options(html_options, html_opts, field_theme(:form_select, error: error))
|
|
13
|
+
if html_native
|
|
14
|
+
super(attribute, priority_zones, opts, merged_html_opts)
|
|
15
|
+
else
|
|
16
|
+
render_select_dropdown(attribute, opts, merged_html_opts, err: error) do
|
|
17
|
+
model = opts.delete(:model) { ActiveSupport::TimeZone }
|
|
18
|
+
build_zone_choices(priority_zones, model.all)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
private
|
|
25
|
+
|
|
26
|
+
def build_zone_choices(priority_zones, all_zones)
|
|
27
|
+
return zone_options(all_zones) unless priority_zones
|
|
28
|
+
|
|
29
|
+
priority = filter_priority_zones(priority_zones, all_zones)
|
|
30
|
+
priority_names = priority.to_set(&:name)
|
|
31
|
+
remaining = all_zones.reject { |z| priority_names.include?(z.name) }
|
|
32
|
+
[
|
|
33
|
+
{
|
|
34
|
+
label: I18n.t("helpers.time_zone_select.priority_zones", default: "Suggested"),
|
|
35
|
+
options: zone_options(priority)
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
label: I18n.t("helpers.time_zone_select.other_zones", default: "Other"),
|
|
39
|
+
options: zone_options(remaining)
|
|
40
|
+
}
|
|
41
|
+
]
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def filter_priority_zones(priority_zones, all_zones)
|
|
45
|
+
case priority_zones
|
|
46
|
+
when Regexp then all_zones.select { |z| z.name.match?(priority_zones) }
|
|
47
|
+
else Array(priority_zones)
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def zone_options(zones)
|
|
52
|
+
zones.map { |z| [z.to_s, z.name] }
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module StimulusPlumbers
|
|
4
|
+
module Form
|
|
5
|
+
module Fields
|
|
6
|
+
module Inputs
|
|
7
|
+
module Select
|
|
8
|
+
module Weekday
|
|
9
|
+
if ActionView.version >= Gem::Version.new("7.1")
|
|
10
|
+
def weekday_select(attribute, options = {}, html_options = {})
|
|
11
|
+
html_native = options.delete(:html_native) { false }
|
|
12
|
+
Field.new(@template, **options).render(
|
|
13
|
+
object,
|
|
14
|
+
attribute,
|
|
15
|
+
input_id: field_id(attribute)
|
|
16
|
+
) do |html_opts, opts, error|
|
|
17
|
+
merged_html_opts = merge_html_options(html_options, html_opts, field_theme(:form_select, error: error))
|
|
18
|
+
if html_native
|
|
19
|
+
super(attribute, opts, merged_html_opts)
|
|
20
|
+
else
|
|
21
|
+
render_select_dropdown(attribute, opts, merged_html_opts, err: error) do
|
|
22
|
+
build_weekday_choices(opts)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
private
|
|
30
|
+
|
|
31
|
+
def build_weekday_choices(opts)
|
|
32
|
+
index_as_value = opts.delete(:index_as_value) { false }
|
|
33
|
+
day_format = opts.delete(:day_format) { :day_names }
|
|
34
|
+
beginning_of_week = opts.delete(:beginning_of_week) { Date.beginning_of_week }
|
|
35
|
+
|
|
36
|
+
day_names = I18n.t("date.#{day_format}")
|
|
37
|
+
choices = day_names.each_with_index.map { |name, i| index_as_value ? [name, i] : [name, name] }
|
|
38
|
+
choices.rotate(Date::DAYS_INTO_WEEK.fetch(beginning_of_week))
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module StimulusPlumbers
|
|
4
|
+
module Form
|
|
5
|
+
module Fields
|
|
6
|
+
module Inputs
|
|
7
|
+
module Select
|
|
8
|
+
def select(attribute, choices = nil, options = {}, html_options = {})
|
|
9
|
+
html_native = options.delete(:html_native) { false }
|
|
10
|
+
Field.new(@template, **options).render(
|
|
11
|
+
object,
|
|
12
|
+
attribute,
|
|
13
|
+
input_id: field_id(attribute)
|
|
14
|
+
) do |html_opts, opts, error|
|
|
15
|
+
merged_html_opts = merge_html_options(html_options, html_opts, field_theme(:form_select, error: error))
|
|
16
|
+
if html_native
|
|
17
|
+
super(attribute, choices, opts, merged_html_opts)
|
|
18
|
+
else
|
|
19
|
+
render_select_dropdown(attribute, opts, merged_html_opts, err: error) { Array(choices) }
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def collection_select(
|
|
25
|
+
attribute,
|
|
26
|
+
collection,
|
|
27
|
+
value_method,
|
|
28
|
+
text_method,
|
|
29
|
+
options = {},
|
|
30
|
+
html_options = {}
|
|
31
|
+
)
|
|
32
|
+
html_native = options.delete(:html_native) { false }
|
|
33
|
+
Field.new(@template, **options).render(
|
|
34
|
+
object,
|
|
35
|
+
attribute,
|
|
36
|
+
input_id: field_id(attribute)
|
|
37
|
+
) do |html_opts, opts, error|
|
|
38
|
+
merged_html_opts = merge_html_options(html_options, html_opts, field_theme(:form_select, error: error))
|
|
39
|
+
if html_native
|
|
40
|
+
super(attribute, collection, value_method, text_method, opts, merged_html_opts)
|
|
41
|
+
else
|
|
42
|
+
render_select_dropdown(attribute, opts, merged_html_opts, err: error) do
|
|
43
|
+
collection.map { |item| [item.public_send(text_method), item.public_send(value_method)] }
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
private
|
|
50
|
+
|
|
51
|
+
def render_select_dropdown(attribute, opts, html_opts, err:)
|
|
52
|
+
include_blank = opts.delete(:include_blank)
|
|
53
|
+
prompt = opts.delete(:prompt)
|
|
54
|
+
current_value = opts.delete(:selected) { object.respond_to?(attribute) ? object.public_send(attribute) : nil }
|
|
55
|
+
choices = build_select_dropdown_choices(yield(current_value), include_blank: include_blank, prompt: prompt)
|
|
56
|
+
|
|
57
|
+
combobox_opts = build_select_dropdown_opts(html_opts, current_value)
|
|
58
|
+
render_combobox(attribute, input_id: html_opts[:id], opts: combobox_opts, err: err) do
|
|
59
|
+
Components::Combobox::Dropdown.new(@template).render(
|
|
60
|
+
options: choices,
|
|
61
|
+
value: current_value,
|
|
62
|
+
labelledby: Field.label_id(html_opts[:id])
|
|
63
|
+
)
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def build_select_dropdown_opts(html_opts, current_value)
|
|
68
|
+
Components::Combobox::Dropdown.default_opts.deep_merge(
|
|
69
|
+
input: { value: current_value },
|
|
70
|
+
trigger: html_opts
|
|
71
|
+
)
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def build_select_dropdown_choices(choices, include_blank:, prompt:)
|
|
75
|
+
return choices unless include_blank || prompt
|
|
76
|
+
|
|
77
|
+
choices = choices.dup
|
|
78
|
+
choices.unshift([include_blank.is_a?(String) ? include_blank : "", ""]) if include_blank
|
|
79
|
+
choices.unshift(build_select_dropdown_choice_prompt(prompt)) if prompt
|
|
80
|
+
choices
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def build_select_dropdown_choice_prompt(prompt)
|
|
84
|
+
label = prompt.is_a?(String) ? prompt : I18n.t("helpers.select.prompt", default: "Please select")
|
|
85
|
+
[label, "", { disabled: true }]
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module StimulusPlumbers
|
|
4
|
+
module Form
|
|
5
|
+
module Fields
|
|
6
|
+
module Inputs
|
|
7
|
+
module Submit
|
|
8
|
+
def submit(value = nil, options = {})
|
|
9
|
+
if value.is_a?(Hash)
|
|
10
|
+
options = value
|
|
11
|
+
value = nil
|
|
12
|
+
end
|
|
13
|
+
value ||= submit_default_value
|
|
14
|
+
variant = options.delete(:variant) { :default }
|
|
15
|
+
@template.tag.input(
|
|
16
|
+
type: "submit",
|
|
17
|
+
value: value,
|
|
18
|
+
**merge_html_options(field_theme(:form_submit, variant: variant), options)
|
|
19
|
+
)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module StimulusPlumbers
|
|
4
|
+
module Form
|
|
5
|
+
module Fields
|
|
6
|
+
module Inputs
|
|
7
|
+
module Text
|
|
8
|
+
FIELD_TYPES = %i[
|
|
9
|
+
color_field
|
|
10
|
+
datetime_local_field
|
|
11
|
+
email_field
|
|
12
|
+
month_field
|
|
13
|
+
number_field
|
|
14
|
+
range_field
|
|
15
|
+
telephone_field
|
|
16
|
+
text_field
|
|
17
|
+
url_field
|
|
18
|
+
week_field
|
|
19
|
+
].freeze
|
|
20
|
+
|
|
21
|
+
FIELD_TYPES.each do |method_name|
|
|
22
|
+
define_method(method_name) do |attribute, options = {}|
|
|
23
|
+
Field.new(@template, **options).render(
|
|
24
|
+
object,
|
|
25
|
+
attribute,
|
|
26
|
+
input_id: field_id(attribute)
|
|
27
|
+
) do |html_opts, opts, error|
|
|
28
|
+
html_options = merge_html_options(opts, html_opts, field_theme(:form_input, error: error))
|
|
29
|
+
super(attribute, html_options)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module StimulusPlumbers
|
|
4
|
+
module Form
|
|
5
|
+
module Fields
|
|
6
|
+
module Inputs
|
|
7
|
+
module TextArea
|
|
8
|
+
def text_area(attribute, options = {})
|
|
9
|
+
Field.new(@template, **options).render(
|
|
10
|
+
object,
|
|
11
|
+
attribute,
|
|
12
|
+
input_id: field_id(attribute)
|
|
13
|
+
) do |html_opts, opts, error|
|
|
14
|
+
html_options = merge_html_options(opts, html_opts, field_theme(:form_textarea, error: error))
|
|
15
|
+
super(attribute, html_options)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -4,16 +4,20 @@ module StimulusPlumbers
|
|
|
4
4
|
module Form
|
|
5
5
|
module Fields
|
|
6
6
|
class Label < Plumber::Base
|
|
7
|
-
def render(text:, for_id
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
def render(text:, for_id: nil, id: nil, required: false, hidden: false, tag: :label)
|
|
8
|
+
mark_options = required && merge_html_options(
|
|
9
|
+
{ aria: { hidden: true } },
|
|
10
|
+
theme.resolve(:form_required_mark)
|
|
11
|
+
)
|
|
12
|
+
html_options = merge_html_options(theme.resolve(:form_label, required: required, hidden: hidden))
|
|
13
|
+
template.content_tag(tag, for: for_id, id: id, **html_options) do
|
|
14
|
+
template.safe_join(
|
|
15
|
+
[
|
|
16
|
+
text,
|
|
17
|
+
mark_options ? template.content_tag(:span, "*", **mark_options) : nil
|
|
18
|
+
]
|
|
19
|
+
)
|
|
14
20
|
end
|
|
15
|
-
|
|
16
|
-
template.content_tag(:label, inner, for: for_id, class: klass.presence)
|
|
17
21
|
end
|
|
18
22
|
end
|
|
19
23
|
end
|
|
@@ -5,7 +5,7 @@ module StimulusPlumbers
|
|
|
5
5
|
module CalendarHelper
|
|
6
6
|
def sp_calendar_month(date: nil, **html_options, &block)
|
|
7
7
|
if date
|
|
8
|
-
html_options.deep_merge
|
|
8
|
+
html_options = html_options.deep_merge(
|
|
9
9
|
data: {
|
|
10
10
|
"calendar-month-year-value": date.year,
|
|
11
11
|
"calendar-month-month-value": date.month - 1,
|
|
@@ -4,70 +4,63 @@ module StimulusPlumbers
|
|
|
4
4
|
module Helpers
|
|
5
5
|
module ComboboxHelper
|
|
6
6
|
def sp_combobox_date(label: nil, value: nil, **html_options)
|
|
7
|
+
id = sp_dom_id
|
|
7
8
|
opts = Components::Combobox::Date.default_opts.deep_merge(
|
|
8
9
|
input: { value: value },
|
|
9
|
-
|
|
10
|
+
trigger: { id: id, aria_label: label }.compact
|
|
10
11
|
)
|
|
11
|
-
opts = opts.deep_merge(trigger: { aria_label: label }) if label
|
|
12
12
|
Components::Combobox.new(self).render(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
data: { input_format_type_value: "date" },
|
|
13
|
+
**opts,
|
|
14
|
+
data: { input_format_type_value: "date" },
|
|
16
15
|
**html_options
|
|
17
|
-
)
|
|
16
|
+
) do |popover_id|
|
|
17
|
+
Components::Combobox::Date.new(self).render(value: value, popover_id: popover_id)
|
|
18
|
+
end
|
|
18
19
|
end
|
|
19
20
|
|
|
20
21
|
def sp_combobox_dropdown(label: nil, options: [], value: nil, **html_options)
|
|
22
|
+
id = sp_dom_id
|
|
21
23
|
opts = Components::Combobox::Dropdown.default_opts.deep_merge(
|
|
22
24
|
input: { value: value },
|
|
23
|
-
|
|
24
|
-
)
|
|
25
|
-
opts = opts.deep_merge(trigger: { aria_label: label }) if label
|
|
26
|
-
Components::Combobox.new(self).render(
|
|
27
|
-
base_id: sp_dom_id,
|
|
28
|
-
options: opts,
|
|
29
|
-
**html_options
|
|
25
|
+
trigger: { id: id, aria_label: label }.compact
|
|
30
26
|
)
|
|
27
|
+
Components::Combobox.new(self).render(**opts, **html_options) do
|
|
28
|
+
Components::Combobox::Dropdown.new(self).render(options: options, value: value, label: label)
|
|
29
|
+
end
|
|
31
30
|
end
|
|
32
31
|
|
|
33
32
|
def sp_combobox_autocomplete(label: nil, options: [], value: nil, url: nil, **html_options)
|
|
34
|
-
id
|
|
35
|
-
|
|
36
|
-
opts = Components::Combobox::Autocomplete.default_opts.deep_merge(
|
|
33
|
+
id = sp_dom_id
|
|
34
|
+
opts = Components::Combobox::Autocomplete.default_opts.deep_merge(
|
|
37
35
|
input: { value: value },
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
options: options,
|
|
41
|
-
value: value,
|
|
42
|
-
label: label
|
|
43
|
-
),
|
|
44
|
-
data: url ? { combobox_dropdown_url_value: url } : {}
|
|
45
|
-
}
|
|
36
|
+
trigger: { id: id, aria_label: label }.compact,
|
|
37
|
+
popover: { data: url ? { combobox_dropdown_url_value: url } : {} }
|
|
46
38
|
)
|
|
47
|
-
opts = opts.deep_merge(trigger: { aria_label: label }) if label
|
|
48
39
|
Components::Combobox.new(self).render(
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
input_combobox_combobox_dropdown_outlet: "##{popover_id}",
|
|
40
|
+
**opts,
|
|
41
|
+
data: {
|
|
42
|
+
input_combobox_combobox_dropdown_outlet: "##{Components::Combobox.popover_id_for(id)}",
|
|
53
43
|
action: "input->input-combobox#onInput"
|
|
54
44
|
},
|
|
55
45
|
**html_options
|
|
56
|
-
)
|
|
46
|
+
) do
|
|
47
|
+
Components::Combobox::Autocomplete.new(self).render(options: options, value: value, label: label)
|
|
48
|
+
end
|
|
57
49
|
end
|
|
58
50
|
|
|
59
51
|
def sp_combobox_time(format: :h12, label: nil, step: 1, value: nil, **html_options)
|
|
52
|
+
id = sp_dom_id
|
|
60
53
|
opts = Components::Combobox::Time.default_opts.deep_merge(
|
|
61
54
|
input: { value: value },
|
|
62
|
-
|
|
55
|
+
trigger: { id: id, aria_label: label }.compact
|
|
63
56
|
)
|
|
64
|
-
opts = opts.deep_merge(trigger: { aria_label: label }) if label
|
|
65
57
|
Components::Combobox.new(self).render(
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
data: { input_format_type_value: "time", input_format_options_value: { format: format }.to_json },
|
|
58
|
+
**opts,
|
|
59
|
+
data: { input_format_type_value: "time", input_format_options_value: { format: format }.to_json },
|
|
69
60
|
**html_options
|
|
70
|
-
)
|
|
61
|
+
) do
|
|
62
|
+
Components::Combobox::Time.new(self).render(format: format, step: step, value: value)
|
|
63
|
+
end
|
|
71
64
|
end
|
|
72
65
|
end
|
|
73
66
|
end
|
|
@@ -8,6 +8,7 @@ require_relative "helpers/calendar_helper"
|
|
|
8
8
|
require_relative "helpers/calendar_turbo_helper"
|
|
9
9
|
require_relative "helpers/card_helper"
|
|
10
10
|
require_relative "helpers/combobox_helper"
|
|
11
|
+
require_relative "helpers/divider_helper"
|
|
11
12
|
require_relative "helpers/popover_helper"
|
|
12
13
|
|
|
13
14
|
module StimulusPlumbers
|
|
@@ -20,6 +21,7 @@ module StimulusPlumbers
|
|
|
20
21
|
include CalendarTurboHelper
|
|
21
22
|
include CardHelper
|
|
22
23
|
include ComboboxHelper
|
|
24
|
+
include DividerHelper
|
|
23
25
|
include PopoverHelper
|
|
24
26
|
end
|
|
25
27
|
end
|
|
@@ -87,13 +87,19 @@ module StimulusPlumbers
|
|
|
87
87
|
form_radio: { error: { default: false, range: Ranges::BOOL } }.freeze,
|
|
88
88
|
form_input_group: { error: { default: false, range: Ranges::BOOL } }.freeze,
|
|
89
89
|
form_combobox: { error: { default: false, range: Ranges::BOOL } }.freeze,
|
|
90
|
-
form_input_reveal: {}.freeze,
|
|
90
|
+
form_input_reveal: { error: { default: false, range: Ranges::BOOL } }.freeze,
|
|
91
|
+
form_input_search: {}.freeze,
|
|
91
92
|
form_button_reveal: {}.freeze,
|
|
93
|
+
form_button_clear: {}.freeze,
|
|
92
94
|
form_submit: {
|
|
93
95
|
variant: { default: :default, range: Form::Ranges::SUBMIT_VARIANT }
|
|
94
96
|
}.freeze
|
|
95
97
|
}.freeze
|
|
96
98
|
|
|
99
|
+
ICON = {
|
|
100
|
+
icon: {}.freeze
|
|
101
|
+
}.freeze
|
|
102
|
+
|
|
97
103
|
LAYOUT = {
|
|
98
104
|
divider: {}.freeze,
|
|
99
105
|
popover: {}.freeze
|
data/lib/stimulus_plumbers.rb
CHANGED
|
@@ -26,6 +26,7 @@ require_relative "stimulus_plumbers/components/card/section"
|
|
|
26
26
|
require_relative "stimulus_plumbers/components/action_list"
|
|
27
27
|
require_relative "stimulus_plumbers/components/action_list/section"
|
|
28
28
|
require_relative "stimulus_plumbers/components/action_list/item"
|
|
29
|
+
require_relative "stimulus_plumbers/components/divider"
|
|
29
30
|
require_relative "stimulus_plumbers/components/popover"
|
|
30
31
|
require_relative "stimulus_plumbers/components/popover/builder"
|
|
31
32
|
|
|
@@ -54,10 +55,11 @@ require_relative "stimulus_plumbers/components/combobox/time/drum"
|
|
|
54
55
|
|
|
55
56
|
# -- Form --
|
|
56
57
|
require_relative "stimulus_plumbers/form/field"
|
|
58
|
+
require_relative "stimulus_plumbers/form/fields/error"
|
|
57
59
|
require_relative "stimulus_plumbers/form/fields/group"
|
|
58
|
-
require_relative "stimulus_plumbers/form/fields/label"
|
|
59
60
|
require_relative "stimulus_plumbers/form/fields/hint"
|
|
60
|
-
require_relative "stimulus_plumbers/form/fields/
|
|
61
|
+
require_relative "stimulus_plumbers/form/fields/input_group"
|
|
62
|
+
require_relative "stimulus_plumbers/form/fields/label"
|
|
61
63
|
require_relative "stimulus_plumbers/form/builder"
|
|
62
64
|
|
|
63
65
|
module StimulusPlumbers
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: stimulus_plumbers
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.3.
|
|
4
|
+
version: 0.3.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ryan Chang
|
|
@@ -69,6 +69,7 @@ files:
|
|
|
69
69
|
- lib/stimulus_plumbers/components/combobox/trigger.rb
|
|
70
70
|
- lib/stimulus_plumbers/components/date_picker/navigation.rb
|
|
71
71
|
- lib/stimulus_plumbers/components/date_picker/navigator.rb
|
|
72
|
+
- lib/stimulus_plumbers/components/divider.rb
|
|
72
73
|
- lib/stimulus_plumbers/components/icon.rb
|
|
73
74
|
- lib/stimulus_plumbers/components/popover.rb
|
|
74
75
|
- lib/stimulus_plumbers/components/popover/builder.rb
|
|
@@ -76,20 +77,24 @@ files:
|
|
|
76
77
|
- lib/stimulus_plumbers/engine.rb
|
|
77
78
|
- lib/stimulus_plumbers/form/builder.rb
|
|
78
79
|
- lib/stimulus_plumbers/form/field.rb
|
|
79
|
-
- lib/stimulus_plumbers/form/fields/choice.rb
|
|
80
|
-
- lib/stimulus_plumbers/form/fields/combobox.rb
|
|
81
80
|
- lib/stimulus_plumbers/form/fields/error.rb
|
|
82
|
-
- lib/stimulus_plumbers/form/fields/
|
|
81
|
+
- lib/stimulus_plumbers/form/fields/fieldset.rb
|
|
83
82
|
- lib/stimulus_plumbers/form/fields/group.rb
|
|
84
83
|
- lib/stimulus_plumbers/form/fields/hint.rb
|
|
84
|
+
- lib/stimulus_plumbers/form/fields/input_group.rb
|
|
85
|
+
- lib/stimulus_plumbers/form/fields/inputs/choice.rb
|
|
86
|
+
- lib/stimulus_plumbers/form/fields/inputs/datetime.rb
|
|
87
|
+
- lib/stimulus_plumbers/form/fields/inputs/file.rb
|
|
88
|
+
- lib/stimulus_plumbers/form/fields/inputs/password.rb
|
|
89
|
+
- lib/stimulus_plumbers/form/fields/inputs/search.rb
|
|
90
|
+
- lib/stimulus_plumbers/form/fields/inputs/select.rb
|
|
91
|
+
- lib/stimulus_plumbers/form/fields/inputs/select/grouped.rb
|
|
92
|
+
- lib/stimulus_plumbers/form/fields/inputs/select/timezone.rb
|
|
93
|
+
- lib/stimulus_plumbers/form/fields/inputs/select/weekday.rb
|
|
94
|
+
- lib/stimulus_plumbers/form/fields/inputs/submit.rb
|
|
95
|
+
- lib/stimulus_plumbers/form/fields/inputs/text.rb
|
|
96
|
+
- lib/stimulus_plumbers/form/fields/inputs/text_area.rb
|
|
85
97
|
- lib/stimulus_plumbers/form/fields/label.rb
|
|
86
|
-
- lib/stimulus_plumbers/form/fields/password.rb
|
|
87
|
-
- lib/stimulus_plumbers/form/fields/renderer.rb
|
|
88
|
-
- lib/stimulus_plumbers/form/fields/search.rb
|
|
89
|
-
- lib/stimulus_plumbers/form/fields/select.rb
|
|
90
|
-
- lib/stimulus_plumbers/form/fields/submit.rb
|
|
91
|
-
- lib/stimulus_plumbers/form/fields/text.rb
|
|
92
|
-
- lib/stimulus_plumbers/form/fields/text_area.rb
|
|
93
98
|
- lib/stimulus_plumbers/helpers.rb
|
|
94
99
|
- lib/stimulus_plumbers/helpers/action_list_helper.rb
|
|
95
100
|
- lib/stimulus_plumbers/helpers/avatar_helper.rb
|
|
@@ -98,6 +103,7 @@ files:
|
|
|
98
103
|
- lib/stimulus_plumbers/helpers/calendar_turbo_helper.rb
|
|
99
104
|
- lib/stimulus_plumbers/helpers/card_helper.rb
|
|
100
105
|
- lib/stimulus_plumbers/helpers/combobox_helper.rb
|
|
106
|
+
- lib/stimulus_plumbers/helpers/divider_helper.rb
|
|
101
107
|
- lib/stimulus_plumbers/helpers/plumber_helper.rb
|
|
102
108
|
- lib/stimulus_plumbers/helpers/popover_helper.rb
|
|
103
109
|
- lib/stimulus_plumbers/logger.rb
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module StimulusPlumbers
|
|
4
|
-
module Form
|
|
5
|
-
module Fields
|
|
6
|
-
module Choice
|
|
7
|
-
def check_box(attribute, options = {}, checked_value = "1", unchecked_value = "0")
|
|
8
|
-
rails_opts, form_field_opts = extract_options(options)
|
|
9
|
-
form_field_opts[:layout] ||= :inline
|
|
10
|
-
field = build_field(attribute, form_field_opts)
|
|
11
|
-
html_opts = merge_html_options(rails_opts, field_theme(:form_checkbox, error: field.error?), field.html_opts)
|
|
12
|
-
render_field(field, super(attribute, html_opts, checked_value, unchecked_value))
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def radio_button(attribute, tag_value, options = {})
|
|
16
|
-
rails_opts, form_field_opts = extract_options(options)
|
|
17
|
-
form_field_opts[:layout] ||= :inline
|
|
18
|
-
field = build_field(attribute, form_field_opts, input_id: field_id(attribute, tag_value))
|
|
19
|
-
html_opts = merge_html_options(rails_opts, field_theme(:form_radio, error: field.error?), field.html_opts)
|
|
20
|
-
render_field(field, super(attribute, tag_value, html_opts))
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module StimulusPlumbers
|
|
4
|
-
module Form
|
|
5
|
-
module Fields
|
|
6
|
-
module Combobox
|
|
7
|
-
COMPONENT_CLASS = {
|
|
8
|
-
autocomplete: Components::Combobox::Autocomplete,
|
|
9
|
-
date: Components::Combobox::Date,
|
|
10
|
-
dropdown: Components::Combobox::Dropdown,
|
|
11
|
-
time: Components::Combobox::Time
|
|
12
|
-
}.freeze
|
|
13
|
-
|
|
14
|
-
def combobox_field(attribute, type:, options: [], **html_options)
|
|
15
|
-
klass = COMPONENT_CLASS.fetch(type) do
|
|
16
|
-
raise ArgumentError,
|
|
17
|
-
"unsupported combobox type #{type.inspect}. Must be one of: #{COMPONENT_CLASS.keys.join(", ")}"
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
rails_opts, field_opts = extract_options(html_options)
|
|
21
|
-
field = build_field(attribute, field_opts)
|
|
22
|
-
current_value = object&.public_send(attribute)
|
|
23
|
-
|
|
24
|
-
wrapper = build_combobox_wrapper(klass, attribute, field, current_value, options, rails_opts)
|
|
25
|
-
render_field(field, wrapper)
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def build_combobox_wrapper(klass, attribute, field, current_value, options, rails_opts)
|
|
29
|
-
popover = klass.new(@template).render(options: options, value: current_value, **rails_opts)
|
|
30
|
-
opts = klass.default_opts.deep_merge(
|
|
31
|
-
input: { name: field_name(attribute), value: current_value },
|
|
32
|
-
popover: { content: popover }
|
|
33
|
-
)
|
|
34
|
-
Components::Combobox.new(@template).render(
|
|
35
|
-
base_id: field_id(attribute),
|
|
36
|
-
options: opts,
|
|
37
|
-
**field_theme(:form_combobox, error: field.error?),
|
|
38
|
-
**field.html_opts
|
|
39
|
-
)
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
end
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module StimulusPlumbers
|
|
4
|
-
module Form
|
|
5
|
-
module Fields
|
|
6
|
-
module File
|
|
7
|
-
def file_field(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_file, error: field.error?), field.html_opts)
|
|
11
|
-
render_field(field, super(attribute, html_opts))
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
end
|