stimulus_plumbers 0.3.2 → 0.4.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/CHANGELOG.md +72 -0
- data/README.md +3 -1
- data/app/assets/javascripts/stimulus-plumbers/controllers.manifest.json +273 -0
- data/app/assets/javascripts/stimulus-plumbers/stimulus-plumbers-controllers.es.js +269 -160
- data/app/assets/javascripts/stimulus-plumbers/stimulus-plumbers-controllers.umd.js +1 -1
- data/app/assets/stylesheets/stimulus_plumbers/tokens.css +56 -13
- data/config/locales/en.yml +10 -0
- data/lib/stimulus_plumbers/components/avatar.rb +24 -17
- data/lib/stimulus_plumbers/components/button/group.rb +15 -4
- data/lib/stimulus_plumbers/components/button/slots.rb +11 -0
- data/lib/stimulus_plumbers/components/button.rb +45 -11
- data/lib/stimulus_plumbers/components/calendar/turbo/days_of_month.rb +151 -0
- data/lib/stimulus_plumbers/components/calendar/turbo/days_of_week.rb +62 -0
- data/lib/stimulus_plumbers/components/calendar/turbo/months_of_year.rb +99 -0
- data/lib/stimulus_plumbers/components/calendar/turbo/years_of_decade.rb +86 -0
- data/lib/stimulus_plumbers/components/calendar/turbo.rb +65 -0
- data/lib/stimulus_plumbers/components/calendar.rb +70 -26
- data/lib/stimulus_plumbers/components/card/slots.rb +26 -0
- data/lib/stimulus_plumbers/components/card.rb +56 -10
- data/lib/stimulus_plumbers/components/combobox/builder.rb +45 -0
- data/lib/stimulus_plumbers/components/combobox/date/navigation.rb +72 -0
- data/lib/stimulus_plumbers/components/combobox/date/navigator.rb +25 -0
- data/lib/stimulus_plumbers/components/combobox/date.rb +37 -23
- data/lib/stimulus_plumbers/components/combobox/dropdown.rb +30 -21
- data/lib/stimulus_plumbers/components/combobox/options/option.rb +8 -2
- data/lib/stimulus_plumbers/components/combobox/options/option_group.rb +8 -2
- data/lib/stimulus_plumbers/components/combobox/options.rb +9 -5
- data/lib/stimulus_plumbers/components/combobox/time/drum.rb +8 -2
- data/lib/stimulus_plumbers/components/combobox/time.rb +50 -47
- data/lib/stimulus_plumbers/components/combobox/trigger.rb +62 -14
- data/lib/stimulus_plumbers/components/combobox/typeahead.rb +96 -0
- data/lib/stimulus_plumbers/components/combobox.rb +62 -38
- data/lib/stimulus_plumbers/components/divider.rb +25 -4
- data/lib/stimulus_plumbers/components/icon.rb +11 -17
- data/lib/stimulus_plumbers/components/input_group.rb +29 -0
- data/lib/stimulus_plumbers/components/link/slots.rb +11 -0
- data/lib/stimulus_plumbers/components/link.rb +63 -0
- data/lib/stimulus_plumbers/components/list/item/slots.rb +13 -0
- data/lib/stimulus_plumbers/components/list/item.rb +83 -0
- data/lib/stimulus_plumbers/components/list/section.rb +73 -0
- data/lib/stimulus_plumbers/components/list.rb +31 -0
- data/lib/stimulus_plumbers/components/popover/panel.rb +32 -0
- data/lib/stimulus_plumbers/components/popover/trigger.rb +27 -0
- data/lib/stimulus_plumbers/components/popover.rb +44 -14
- data/lib/stimulus_plumbers/engine.rb +1 -0
- data/lib/stimulus_plumbers/form/base.rb +103 -0
- data/lib/stimulus_plumbers/form/builder.rb +71 -24
- data/lib/stimulus_plumbers/form/field.rb +56 -88
- data/lib/stimulus_plumbers/form/fields/error.rb +1 -1
- data/lib/stimulus_plumbers/form/fields/fieldset.rb +11 -8
- data/lib/stimulus_plumbers/form/fields/hint.rb +1 -1
- data/lib/stimulus_plumbers/form/fields/inputs/checkbox.rb +115 -0
- data/lib/stimulus_plumbers/form/fields/inputs/combobox.rb +24 -0
- data/lib/stimulus_plumbers/form/fields/inputs/datetime.rb +42 -48
- data/lib/stimulus_plumbers/form/fields/inputs/file.rb +9 -8
- data/lib/stimulus_plumbers/form/fields/inputs/password.rb +32 -25
- data/lib/stimulus_plumbers/form/fields/inputs/radio.rb +60 -0
- data/lib/stimulus_plumbers/form/fields/inputs/search.rb +34 -57
- data/lib/stimulus_plumbers/form/fields/inputs/select/grouped.rb +22 -29
- data/lib/stimulus_plumbers/form/fields/inputs/select/timezone.rb +3 -44
- data/lib/stimulus_plumbers/form/fields/inputs/select/weekday.rb +3 -28
- data/lib/stimulus_plumbers/form/fields/inputs/select.rb +62 -49
- data/lib/stimulus_plumbers/form/fields/inputs/submit.rb +10 -7
- data/lib/stimulus_plumbers/form/fields/inputs/text.rb +29 -22
- data/lib/stimulus_plumbers/form/fields/inputs/text_area.rb +9 -8
- data/lib/stimulus_plumbers/form/fields/label/floating.rb +41 -0
- data/lib/stimulus_plumbers/form/fields/label.rb +9 -3
- data/lib/stimulus_plumbers/form/fields/renderer.rb +39 -0
- data/lib/stimulus_plumbers/helpers/avatar_helper.rb +2 -2
- data/lib/stimulus_plumbers/helpers/button_helper.rb +4 -8
- data/lib/stimulus_plumbers/helpers/calendar_helper.rb +14 -11
- data/lib/stimulus_plumbers/helpers/calendar_turbo_helper.rb +49 -11
- data/lib/stimulus_plumbers/helpers/card_helper.rb +2 -12
- data/lib/stimulus_plumbers/helpers/combobox_helper.rb +27 -47
- data/lib/stimulus_plumbers/helpers/divider_helper.rb +2 -2
- data/lib/stimulus_plumbers/helpers/icon_helper.rb +11 -0
- data/lib/stimulus_plumbers/helpers/link_helper.rb +11 -0
- data/lib/stimulus_plumbers/helpers/list_helper.rb +11 -0
- data/lib/stimulus_plumbers/helpers/plumber_helper.rb +3 -6
- data/lib/stimulus_plumbers/helpers/popover_helper.rb +2 -2
- data/lib/stimulus_plumbers/helpers.rb +6 -2
- data/lib/stimulus_plumbers/logger.rb +4 -3
- data/lib/stimulus_plumbers/plumber/base.rb +6 -1
- data/lib/stimulus_plumbers/plumber/dispatcher/klass_proxy.rb +4 -3
- data/lib/stimulus_plumbers/plumber/dispatcher/method_call.rb +4 -3
- data/lib/stimulus_plumbers/plumber/dispatcher.rb +4 -4
- data/lib/stimulus_plumbers/plumber/options/aria.rb +17 -0
- data/lib/stimulus_plumbers/plumber/options/html.rb +29 -0
- data/lib/stimulus_plumbers/plumber/options/stimulus.rb +29 -0
- data/lib/stimulus_plumbers/plumber/options/theme.rb +19 -0
- data/lib/stimulus_plumbers/plumber/options/token_list.rb +29 -0
- data/lib/stimulus_plumbers/plumber/renderer.rb +136 -41
- data/lib/stimulus_plumbers/plumber/slots.rb +74 -0
- data/lib/stimulus_plumbers/themes/base.rb +20 -23
- data/lib/stimulus_plumbers/themes/icons/external.rb +60 -0
- data/lib/stimulus_plumbers/themes/icons/registry.rb +36 -0
- data/lib/stimulus_plumbers/themes/schema/avatar/ranges.rb +13 -0
- data/lib/stimulus_plumbers/themes/schema/button/ranges.rb +16 -0
- data/lib/stimulus_plumbers/themes/schema/card/ranges.rb +13 -0
- data/lib/stimulus_plumbers/themes/schema/form/checkbox/ranges.rb +16 -0
- data/lib/stimulus_plumbers/themes/schema/form/radio/ranges.rb +16 -0
- data/lib/stimulus_plumbers/themes/schema/form/ranges.rb +1 -2
- data/lib/stimulus_plumbers/themes/schema/icon.rb +57 -15
- data/lib/stimulus_plumbers/themes/schema/link/ranges.rb +14 -0
- data/lib/stimulus_plumbers/themes/schema/ranges.rb +1 -5
- data/lib/stimulus_plumbers/themes/schema.rb +142 -67
- data/lib/stimulus_plumbers/version.rb +1 -1
- data/lib/stimulus_plumbers.rb +22 -17
- metadata +46 -17
- data/lib/stimulus_plumbers/components/action_list/item.rb +0 -27
- data/lib/stimulus_plumbers/components/action_list/section.rb +0 -22
- data/lib/stimulus_plumbers/components/action_list.rb +0 -23
- data/lib/stimulus_plumbers/components/calendar/month/turbo/days_of_month.rb +0 -145
- data/lib/stimulus_plumbers/components/calendar/month/turbo/days_of_week.rb +0 -39
- data/lib/stimulus_plumbers/components/calendar/month/turbo.rb +0 -55
- data/lib/stimulus_plumbers/components/card/section.rb +0 -25
- data/lib/stimulus_plumbers/components/combobox/autocomplete.rb +0 -47
- data/lib/stimulus_plumbers/components/combobox/popover.rb +0 -24
- data/lib/stimulus_plumbers/components/date_picker/navigation.rb +0 -41
- data/lib/stimulus_plumbers/components/date_picker/navigator.rb +0 -31
- data/lib/stimulus_plumbers/components/popover/builder.rb +0 -25
- data/lib/stimulus_plumbers/form/fields/input_group.rb +0 -25
- data/lib/stimulus_plumbers/form/fields/inputs/choice.rb +0 -69
- data/lib/stimulus_plumbers/helpers/action_list_helper.rb +0 -25
- data/lib/stimulus_plumbers/plumber/html_options.rb +0 -52
|
@@ -6,50 +6,9 @@ module StimulusPlumbers
|
|
|
6
6
|
module Inputs
|
|
7
7
|
module Select
|
|
8
8
|
module Timezone
|
|
9
|
-
def time_zone_select(attribute, priority_zones = nil, options = {},
|
|
10
|
-
|
|
11
|
-
|
|
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] }
|
|
9
|
+
def time_zone_select(attribute, priority_zones = nil, options = {}, html_opts = {})
|
|
10
|
+
html_options = merge_html_options(theme.resolve(:form_select), html_opts)
|
|
11
|
+
super(attribute, priority_zones, options, html_options)
|
|
53
12
|
end
|
|
54
13
|
end
|
|
55
14
|
end
|
|
@@ -7,36 +7,11 @@ module StimulusPlumbers
|
|
|
7
7
|
module Select
|
|
8
8
|
module Weekday
|
|
9
9
|
if ActionView.version >= Gem::Version.new("7.1")
|
|
10
|
-
def weekday_select(attribute, options = {},
|
|
11
|
-
|
|
12
|
-
|
|
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
|
|
10
|
+
def weekday_select(attribute, options = {}, html_opts = {})
|
|
11
|
+
html_options = merge_html_options(theme.resolve(:form_select), html_opts)
|
|
12
|
+
super(attribute, options, html_options)
|
|
26
13
|
end
|
|
27
14
|
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
15
|
end
|
|
41
16
|
end
|
|
42
17
|
end
|
|
@@ -1,74 +1,87 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require_relative "combobox"
|
|
4
|
+
|
|
3
5
|
module StimulusPlumbers
|
|
4
6
|
module Form
|
|
5
7
|
module Fields
|
|
6
8
|
module Inputs
|
|
7
9
|
module Select
|
|
10
|
+
include Combobox
|
|
11
|
+
|
|
8
12
|
def select(attribute, choices = nil, options = {}, html_options = {})
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
13
|
+
merged = merge_html_options(theme.resolve(:form_field_input_select), html_options)
|
|
14
|
+
super(attribute, choices, options, merged)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def collection_select(attribute, collection, value_method, text_method, options = {}, html_options = {})
|
|
18
|
+
merged = merge_html_options(theme.resolve(:form_field_input_select), html_options)
|
|
19
|
+
super(attribute, collection, value_method, text_method, options, merged)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
private
|
|
23
|
+
|
|
24
|
+
def render_combobox_dropdown(
|
|
25
|
+
attribute,
|
|
26
|
+
html_opts,
|
|
27
|
+
opts,
|
|
28
|
+
error,
|
|
29
|
+
icon_leading: nil,
|
|
30
|
+
icon_trailing: nil,
|
|
31
|
+
choices: [],
|
|
32
|
+
include_blank: nil,
|
|
33
|
+
prompt: nil,
|
|
34
|
+
selected: nil,
|
|
35
|
+
**kwargs
|
|
36
|
+
)
|
|
37
|
+
current_value = selected || (object.respond_to?(attribute) ? object.public_send(attribute) : nil)
|
|
38
|
+
all_choices = build_select_dropdown_choices(Array(choices), include_blank: include_blank, prompt: prompt)
|
|
39
|
+
labelledby = Field.label_id(html_opts[:id])
|
|
40
|
+
combobox_opts = build_select_dropdown_opts(
|
|
41
|
+
html_opts, current_value, opts: opts, icon_leading: icon_leading, icon_trailing: icon_trailing
|
|
42
|
+
)
|
|
43
|
+
render_combobox(
|
|
12
44
|
attribute,
|
|
13
|
-
input_id:
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
else
|
|
19
|
-
render_select_dropdown(attribute, opts, merged_html_opts, err: error) { Array(choices) }
|
|
20
|
-
end
|
|
45
|
+
input_id: html_opts[:id],
|
|
46
|
+
opts: combobox_opts,
|
|
47
|
+
error: error
|
|
48
|
+
) do |c|
|
|
49
|
+
c.dropdown(options: all_choices, value: current_value, labelledby: labelledby, **kwargs)
|
|
21
50
|
end
|
|
22
51
|
end
|
|
23
52
|
|
|
24
|
-
def
|
|
53
|
+
def render_collection_combobox_dropdown(
|
|
25
54
|
attribute,
|
|
26
55
|
collection,
|
|
27
56
|
value_method,
|
|
28
57
|
text_method,
|
|
29
|
-
|
|
30
|
-
|
|
58
|
+
field_opts,
|
|
59
|
+
**kwargs
|
|
31
60
|
)
|
|
32
|
-
|
|
33
|
-
|
|
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
|
|
61
|
+
choices = collection.map { |item| [item.public_send(text_method), item.public_send(value_method)] }
|
|
62
|
+
render_field(:select, attribute, field_opts, { choices: choices, **kwargs })
|
|
47
63
|
end
|
|
48
64
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
value: current_value,
|
|
62
|
-
labelledby: Field.label_id(html_opts[:id])
|
|
63
|
-
)
|
|
64
|
-
end
|
|
65
|
+
def render_grouped_collection_combobox_dropdown(
|
|
66
|
+
attribute,
|
|
67
|
+
collection,
|
|
68
|
+
value_method,
|
|
69
|
+
text_method,
|
|
70
|
+
field_opts,
|
|
71
|
+
group_method:,
|
|
72
|
+
group_label_method:,
|
|
73
|
+
**kwargs
|
|
74
|
+
)
|
|
75
|
+
choices = build_grouped_choices(collection, group_label_method, group_method, value_method, text_method)
|
|
76
|
+
render_field(:select, attribute, field_opts, { choices: choices, **kwargs })
|
|
65
77
|
end
|
|
66
78
|
|
|
67
|
-
def build_select_dropdown_opts(html_opts, current_value)
|
|
68
|
-
|
|
79
|
+
def build_select_dropdown_opts(html_opts, current_value, opts:, icon_leading:, icon_trailing:)
|
|
80
|
+
{
|
|
69
81
|
input: { value: current_value },
|
|
70
|
-
trigger: html_opts
|
|
71
|
-
|
|
82
|
+
trigger: { aria: html_opts[:aria], icon_leading: icon_leading, icon_trailing: icon_trailing }.compact,
|
|
83
|
+
**opts
|
|
84
|
+
}
|
|
72
85
|
end
|
|
73
86
|
|
|
74
87
|
def build_select_dropdown_choices(choices, include_blank:, prompt:)
|
|
@@ -10,13 +10,16 @@ module StimulusPlumbers
|
|
|
10
10
|
options = value
|
|
11
11
|
value = nil
|
|
12
12
|
end
|
|
13
|
-
value
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
13
|
+
value ||= submit_default_value
|
|
14
|
+
type = options.delete(:type) { :default }
|
|
15
|
+
variant = options.delete(:variant) { :primary }
|
|
16
|
+
|
|
17
|
+
Components::Button.new(@template).build(type: type, variant: variant) do |attrs|
|
|
18
|
+
@template.tag.button(
|
|
19
|
+
type: "submit",
|
|
20
|
+
**merge_html_options(attrs, options)
|
|
21
|
+
) { value }
|
|
22
|
+
end
|
|
20
23
|
end
|
|
21
24
|
end
|
|
22
25
|
end
|
|
@@ -5,31 +5,38 @@ module StimulusPlumbers
|
|
|
5
5
|
module Fields
|
|
6
6
|
module Inputs
|
|
7
7
|
module Text
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
8
|
+
TEXT_FIELD_METHODS = {
|
|
9
|
+
text: :text_field,
|
|
10
|
+
email: :email_field,
|
|
11
|
+
number: :number_field,
|
|
12
|
+
url: :url_field,
|
|
13
|
+
tel: :telephone_field,
|
|
14
|
+
color: :color_field,
|
|
15
|
+
month: :month_field,
|
|
16
|
+
week: :week_field,
|
|
17
|
+
range: :range_field,
|
|
18
|
+
datetime_local: :datetime_local_field
|
|
19
|
+
}.freeze
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
define_method(
|
|
23
|
-
|
|
24
|
-
|
|
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
|
|
21
|
+
TEXT_FIELD_METHODS.each_value do |template_method|
|
|
22
|
+
define_method(template_method) do |attribute, options = {}|
|
|
23
|
+
html_options = merge_html_options(theme.resolve(:form_field_input), options)
|
|
24
|
+
super(attribute, html_options)
|
|
31
25
|
end
|
|
32
26
|
end
|
|
27
|
+
|
|
28
|
+
private
|
|
29
|
+
|
|
30
|
+
TEXT_FIELD_METHODS.each do |as_key, template_method|
|
|
31
|
+
define_method(:"render_#{as_key}_input") do |attribute, html_opts, opts, error, **kwargs|
|
|
32
|
+
render_text(attribute, html_opts, opts, error, template_method, **kwargs)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def render_text(attribute, html_opts, opts, error, template_method, **kwargs)
|
|
37
|
+
html_options = merge_html_options(theme.resolve(:form_field_input, error: error), opts, html_opts, kwargs)
|
|
38
|
+
@template.public_send(template_method, @object_name, attribute, objectify_options(html_options))
|
|
39
|
+
end
|
|
33
40
|
end
|
|
34
41
|
end
|
|
35
42
|
end
|
|
@@ -6,14 +6,15 @@ module StimulusPlumbers
|
|
|
6
6
|
module Inputs
|
|
7
7
|
module TextArea
|
|
8
8
|
def text_area(attribute, options = {})
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
9
|
+
html_options = merge_html_options(theme.resolve(:form_field_input_textarea), options)
|
|
10
|
+
super(attribute, html_options)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
private
|
|
14
|
+
|
|
15
|
+
def render_text_area_input(attribute, html_opts, opts, error, **kwargs)
|
|
16
|
+
html_options = merge_html_options(theme.resolve(:form_field_input_textarea, error: error), opts, html_opts, kwargs)
|
|
17
|
+
@template.text_area(@object_name, attribute, objectify_options(html_options))
|
|
17
18
|
end
|
|
18
19
|
end
|
|
19
20
|
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module StimulusPlumbers
|
|
4
|
+
module Form
|
|
5
|
+
module Fields
|
|
6
|
+
class Label
|
|
7
|
+
class Floating < Plumber::Base
|
|
8
|
+
def render(text:, for_id:, id:, type:, required:, error:, &block)
|
|
9
|
+
html_options = merge_html_options(theme.resolve(:form_field_floating_group, type: type))
|
|
10
|
+
label_options = merge_html_options(theme.resolve(:form_field_floating_label, type: type, error: error))
|
|
11
|
+
mark_options = required && merge_html_options(
|
|
12
|
+
{ aria: { hidden: true } },
|
|
13
|
+
theme.resolve(:form_field_required_mark)
|
|
14
|
+
)
|
|
15
|
+
template.content_tag(:div, **html_options) do
|
|
16
|
+
template.safe_join(
|
|
17
|
+
[
|
|
18
|
+
template.capture(&block),
|
|
19
|
+
render_label(text, mark_options, for: for_id, id: id, **label_options)
|
|
20
|
+
]
|
|
21
|
+
)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
private
|
|
26
|
+
|
|
27
|
+
def render_label(text, mark_options, **html_options)
|
|
28
|
+
template.content_tag(:label, **html_options) do
|
|
29
|
+
template.safe_join(
|
|
30
|
+
[
|
|
31
|
+
text,
|
|
32
|
+
mark_options ? template.content_tag(:span, "*", **mark_options) : nil
|
|
33
|
+
]
|
|
34
|
+
)
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -7,10 +7,16 @@ module StimulusPlumbers
|
|
|
7
7
|
def render(text:, for_id: nil, id: nil, required: false, hidden: false, tag: :label)
|
|
8
8
|
mark_options = required && merge_html_options(
|
|
9
9
|
{ aria: { hidden: true } },
|
|
10
|
-
theme.resolve(:
|
|
10
|
+
theme.resolve(:form_field_required_mark)
|
|
11
11
|
)
|
|
12
|
-
html_options = merge_html_options(theme.resolve(:
|
|
13
|
-
|
|
12
|
+
html_options = merge_html_options(theme.resolve(:form_field_label, required: required, hidden: hidden))
|
|
13
|
+
render_label(text, mark_options, tag, for: for_id, id: id, **html_options)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
private
|
|
17
|
+
|
|
18
|
+
def render_label(text, mark_options, tag, **html_options)
|
|
19
|
+
template.content_tag(tag, **html_options) do
|
|
14
20
|
template.safe_join(
|
|
15
21
|
[
|
|
16
22
|
text,
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module StimulusPlumbers
|
|
4
|
+
module Form
|
|
5
|
+
module Fields
|
|
6
|
+
module Renderer
|
|
7
|
+
FIELD = {
|
|
8
|
+
text: :render_text_input,
|
|
9
|
+
email: :render_email_input,
|
|
10
|
+
number: :render_number_input,
|
|
11
|
+
url: :render_url_input,
|
|
12
|
+
tel: :render_tel_input,
|
|
13
|
+
color: :render_color_input,
|
|
14
|
+
month: :render_month_input,
|
|
15
|
+
week: :render_week_input,
|
|
16
|
+
range: :render_range_input,
|
|
17
|
+
datetime_local: :render_datetime_local_input,
|
|
18
|
+
text_area: :render_text_area_input,
|
|
19
|
+
file: :render_file_input,
|
|
20
|
+
password: :render_password_input,
|
|
21
|
+
date: :render_combobox_date,
|
|
22
|
+
time: :render_combobox_time,
|
|
23
|
+
select: :render_combobox_dropdown,
|
|
24
|
+
search: :render_combobox_typeahead
|
|
25
|
+
}.freeze
|
|
26
|
+
|
|
27
|
+
COLLECTION = {
|
|
28
|
+
collection_select: :render_collection_combobox_dropdown,
|
|
29
|
+
grouped_collection_select: :render_grouped_collection_combobox_dropdown
|
|
30
|
+
}.freeze
|
|
31
|
+
|
|
32
|
+
CHOICE = {
|
|
33
|
+
radio: :render_collection_radio_button,
|
|
34
|
+
check_box: :render_check_box
|
|
35
|
+
}.freeze
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
module StimulusPlumbers
|
|
4
4
|
module Helpers
|
|
5
5
|
module AvatarHelper
|
|
6
|
-
def sp_avatar(
|
|
7
|
-
avatar_renderer.render(
|
|
6
|
+
def sp_avatar(...)
|
|
7
|
+
avatar_renderer.render(...)
|
|
8
8
|
end
|
|
9
9
|
|
|
10
10
|
private
|
|
@@ -3,16 +3,12 @@
|
|
|
3
3
|
module StimulusPlumbers
|
|
4
4
|
module Helpers
|
|
5
5
|
module ButtonHelper
|
|
6
|
-
def sp_button(content = nil,
|
|
7
|
-
button_renderer.render(
|
|
8
|
-
content,
|
|
9
|
-
url: url, external: external, variant: variant, size: size, **html_options,
|
|
10
|
-
&block
|
|
11
|
-
)
|
|
6
|
+
def sp_button(content = nil, **kwargs, &block)
|
|
7
|
+
button_renderer.render(content, **kwargs, &block)
|
|
12
8
|
end
|
|
13
9
|
|
|
14
|
-
def sp_button_group(
|
|
15
|
-
|
|
10
|
+
def sp_button_group(...)
|
|
11
|
+
Components::Button::Group.new(self).render(...)
|
|
16
12
|
end
|
|
17
13
|
|
|
18
14
|
private
|
|
@@ -3,17 +3,20 @@
|
|
|
3
3
|
module StimulusPlumbers
|
|
4
4
|
module Helpers
|
|
5
5
|
module CalendarHelper
|
|
6
|
-
def sp_calendar_month(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
6
|
+
def sp_calendar_month(**kwargs)
|
|
7
|
+
date = kwargs.delete(:date)
|
|
8
|
+
html_options = if date
|
|
9
|
+
kwargs.deep_merge(
|
|
10
|
+
data: {
|
|
11
|
+
"calendar-month-year-value": date.year,
|
|
12
|
+
"calendar-month-month-value": date.month - 1,
|
|
13
|
+
"calendar-month-day-value": date.day
|
|
14
|
+
}
|
|
15
|
+
)
|
|
16
|
+
else
|
|
17
|
+
kwargs
|
|
18
|
+
end
|
|
19
|
+
calendar_renderer.render(**html_options)
|
|
17
20
|
end
|
|
18
21
|
|
|
19
22
|
private
|
|
@@ -3,28 +3,66 @@
|
|
|
3
3
|
module StimulusPlumbers
|
|
4
4
|
module Helpers
|
|
5
5
|
module CalendarTurboHelper
|
|
6
|
-
def
|
|
6
|
+
def sp_calendar_turbo_month(**kwargs)
|
|
7
|
+
calendar_turbo_renderer.month(**kwargs)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def sp_calendar_turbo_year(**kwargs)
|
|
11
|
+
calendar_turbo_renderer.year(**kwargs)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def sp_calendar_turbo_decade(**kwargs)
|
|
15
|
+
calendar_turbo_renderer.decade(**kwargs)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def sp_calendar_turbo(
|
|
7
19
|
date: Date.today,
|
|
8
20
|
today: Date.today,
|
|
9
21
|
selectable: false,
|
|
10
22
|
selected_date: nil,
|
|
11
23
|
show_other_months: false,
|
|
12
|
-
**
|
|
24
|
+
**kwargs
|
|
13
25
|
)
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
26
|
+
safe_join(
|
|
27
|
+
[
|
|
28
|
+
content_tag(
|
|
29
|
+
:turbo_frame,
|
|
30
|
+
id: "calendar-month-frame",
|
|
31
|
+
data: { "combobox-date-target": "monthView" }
|
|
32
|
+
) do
|
|
33
|
+
calendar_turbo_renderer.month(
|
|
34
|
+
date: date,
|
|
35
|
+
today: today,
|
|
36
|
+
selectable: selectable,
|
|
37
|
+
selected_date: selected_date,
|
|
38
|
+
show_other_months: show_other_months,
|
|
39
|
+
**kwargs
|
|
40
|
+
)
|
|
41
|
+
end,
|
|
42
|
+
content_tag(
|
|
43
|
+
:turbo_frame,
|
|
44
|
+
id: "calendar-year-frame",
|
|
45
|
+
hidden: true,
|
|
46
|
+
data: { "combobox-date-target": "yearView" }
|
|
47
|
+
) do
|
|
48
|
+
calendar_turbo_renderer.year(date: date, today: today, selected_date: selected_date)
|
|
49
|
+
end,
|
|
50
|
+
content_tag(
|
|
51
|
+
:turbo_frame,
|
|
52
|
+
id: "calendar-decade-frame",
|
|
53
|
+
hidden: true,
|
|
54
|
+
data: { "combobox-date-target": "decadeView" }
|
|
55
|
+
) do
|
|
56
|
+
calendar_turbo_renderer.decade(date: date, today: today, selected_date: selected_date)
|
|
57
|
+
end
|
|
58
|
+
]
|
|
21
59
|
)
|
|
22
60
|
end
|
|
23
61
|
|
|
24
62
|
private
|
|
25
63
|
|
|
26
|
-
def
|
|
27
|
-
Components::Calendar::
|
|
64
|
+
def calendar_turbo_renderer
|
|
65
|
+
@calendar_turbo_renderer ||= Components::Calendar::Turbo.new(self)
|
|
28
66
|
end
|
|
29
67
|
end
|
|
30
68
|
end
|
|
@@ -3,18 +3,8 @@
|
|
|
3
3
|
module StimulusPlumbers
|
|
4
4
|
module Helpers
|
|
5
5
|
module CardHelper
|
|
6
|
-
def sp_card(
|
|
7
|
-
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def sp_card_section(title: nil, **html_options, &block)
|
|
11
|
-
card_renderer.section(title: title, **html_options, &block)
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
private
|
|
15
|
-
|
|
16
|
-
def card_renderer
|
|
17
|
-
Components::Card.new(self)
|
|
6
|
+
def sp_card(...)
|
|
7
|
+
Components::Card.new(self).render(...)
|
|
18
8
|
end
|
|
19
9
|
end
|
|
20
10
|
end
|