stimulus_plumbers 0.2.9 → 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 +38 -0
- data/README.md +5 -4
- data/app/assets/javascripts/stimulus-plumbers/stimulus-plumbers-controllers.es.js +246 -269
- data/app/assets/javascripts/stimulus-plumbers/stimulus-plumbers-controllers.umd.js +1 -1
- 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/avatar.rb +4 -3
- data/lib/stimulus_plumbers/components/calendar/month/turbo/days_of_month.rb +62 -41
- data/lib/stimulus_plumbers/components/calendar/month/turbo/days_of_week.rb +13 -10
- data/lib/stimulus_plumbers/components/calendar.rb +36 -13
- 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 +19 -10
- data/lib/stimulus_plumbers/components/combobox.rb +33 -23
- data/lib/stimulus_plumbers/components/date_picker/navigation.rb +14 -22
- data/lib/stimulus_plumbers/components/divider.rb +16 -0
- data/lib/stimulus_plumbers/components/icon.rb +14 -20
- data/lib/stimulus_plumbers/components/popover/builder.rb +2 -2
- data/lib/stimulus_plumbers/components/popover.rb +11 -6
- data/lib/stimulus_plumbers/configuration.rb +3 -18
- data/lib/stimulus_plumbers/engine.rb +2 -2
- data/lib/stimulus_plumbers/form/builder.rb +40 -44
- 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/plumber/base.rb +1 -1
- data/lib/stimulus_plumbers/plumber/dispatcher/callable_inspector.rb +19 -0
- data/lib/stimulus_plumbers/plumber/dispatcher/instance_exec.rb +35 -0
- data/lib/stimulus_plumbers/plumber/dispatcher/klass_proxy.rb +34 -0
- data/lib/stimulus_plumbers/plumber/dispatcher/method_call.rb +36 -0
- data/lib/stimulus_plumbers/plumber/dispatcher.rb +4 -87
- data/lib/stimulus_plumbers/plumber/html_options.rb +6 -5
- data/lib/stimulus_plumbers/plumber/renderer.rb +2 -2
- data/lib/stimulus_plumbers/themes/base.rb +26 -5
- data/lib/stimulus_plumbers/themes/configuration.rb +38 -0
- data/lib/stimulus_plumbers/themes/schema/form/ranges.rb +14 -0
- data/lib/stimulus_plumbers/themes/schema/icon.rb +32 -0
- data/lib/stimulus_plumbers/themes/schema/ranges.rb +1 -1
- data/lib/stimulus_plumbers/themes/schema.rb +17 -5
- data/lib/stimulus_plumbers/version.rb +1 -1
- data/lib/stimulus_plumbers.rb +4 -2
- metadata +25 -21
- data/lib/stimulus_plumbers/form/fields/choice.rb +0 -25
- data/lib/stimulus_plumbers/form/fields/combobox.rb +0 -41
- 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 -52
- 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
- data/lib/stimulus_plumbers/themes/tailwind/action_list.rb +0 -33
- data/lib/stimulus_plumbers/themes/tailwind/avatar.rb +0 -52
- data/lib/stimulus_plumbers/themes/tailwind/button.rb +0 -89
- data/lib/stimulus_plumbers/themes/tailwind/calendar.rb +0 -80
- data/lib/stimulus_plumbers/themes/tailwind/card.rb +0 -24
- data/lib/stimulus_plumbers/themes/tailwind/combobox.rb +0 -75
- data/lib/stimulus_plumbers/themes/tailwind/form.rb +0 -108
- data/lib/stimulus_plumbers/themes/tailwind/layout.rb +0 -25
- data/lib/stimulus_plumbers/themes/tailwind_theme.rb +0 -31
|
@@ -13,6 +13,7 @@ module StimulusPlumbers
|
|
|
13
13
|
**Schema::CARD,
|
|
14
14
|
**Schema::COMBOBOX,
|
|
15
15
|
**Schema::FORM,
|
|
16
|
+
**Schema::ICON,
|
|
16
17
|
**Schema::LAYOUT
|
|
17
18
|
}.freeze
|
|
18
19
|
|
|
@@ -20,6 +21,22 @@ module StimulusPlumbers
|
|
|
20
21
|
@name ||= self.class.name.demodulize.delete_suffix("Theme")
|
|
21
22
|
end
|
|
22
23
|
|
|
24
|
+
def avatar_colors
|
|
25
|
+
{}
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def avatar_color_range
|
|
29
|
+
[]
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def icons
|
|
33
|
+
{}
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def icon_range
|
|
37
|
+
icons.keys
|
|
38
|
+
end
|
|
39
|
+
|
|
23
40
|
def attribute_names(component)
|
|
24
41
|
SCHEMA.fetch(component, {}).keys
|
|
25
42
|
end
|
|
@@ -49,11 +66,7 @@ module StimulusPlumbers
|
|
|
49
66
|
def coerce_arg(component, key, value, schema)
|
|
50
67
|
return value unless schema
|
|
51
68
|
|
|
52
|
-
range =
|
|
53
|
-
respond_to?(schema[:range], true) ? send(schema[:range]) : []
|
|
54
|
-
else
|
|
55
|
-
schema[:range]
|
|
56
|
-
end
|
|
69
|
+
range = range_for(schema)
|
|
57
70
|
return value if range.empty? || range.include?(value)
|
|
58
71
|
|
|
59
72
|
StimulusPlumbers::Logger.warn(
|
|
@@ -62,6 +75,14 @@ module StimulusPlumbers
|
|
|
62
75
|
)
|
|
63
76
|
schema[:default]
|
|
64
77
|
end
|
|
78
|
+
|
|
79
|
+
def range_for(schema)
|
|
80
|
+
if schema[:range].is_a?(Symbol)
|
|
81
|
+
respond_to?(schema[:range], true) ? send(schema[:range]) : []
|
|
82
|
+
else
|
|
83
|
+
schema[:range]
|
|
84
|
+
end
|
|
85
|
+
end
|
|
65
86
|
end
|
|
66
87
|
end
|
|
67
88
|
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module StimulusPlumbers
|
|
4
|
+
module Themes
|
|
5
|
+
class Configuration
|
|
6
|
+
def register(name, klass)
|
|
7
|
+
raise ArgumentError, "#{klass} must be a subclass of Themes::Base" unless klass <= Base
|
|
8
|
+
|
|
9
|
+
registry[name.to_sym] = klass
|
|
10
|
+
self
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def use(name_or_instance)
|
|
14
|
+
@current = resolve(name_or_instance)
|
|
15
|
+
self
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def current
|
|
19
|
+
@current ||= Base.new
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def registry
|
|
23
|
+
@registry ||= {}
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
private
|
|
27
|
+
|
|
28
|
+
def resolve(value)
|
|
29
|
+
return value if value.is_a?(Base)
|
|
30
|
+
|
|
31
|
+
klass = registry[value.to_sym]
|
|
32
|
+
raise ArgumentError, "Unknown theme #{value.inspect}. Registered: #{registry.keys.inspect}" unless klass
|
|
33
|
+
|
|
34
|
+
klass.new
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module StimulusPlumbers
|
|
4
|
+
module Themes
|
|
5
|
+
module Schema
|
|
6
|
+
module Icon
|
|
7
|
+
DEFAULTS = {
|
|
8
|
+
fill: "none",
|
|
9
|
+
view_box: "0 0 24 24",
|
|
10
|
+
width: "24",
|
|
11
|
+
height: "24",
|
|
12
|
+
stroke: "currentColor",
|
|
13
|
+
stroke_width: 1.5,
|
|
14
|
+
stroke_linecap: :round,
|
|
15
|
+
stroke_linejoin: :round
|
|
16
|
+
}.freeze
|
|
17
|
+
|
|
18
|
+
ATTRS = ([:d] + DEFAULTS.keys).freeze
|
|
19
|
+
|
|
20
|
+
def self.resolve(icon_data)
|
|
21
|
+
return unless icon_data.is_a?(Hash)
|
|
22
|
+
|
|
23
|
+
merged = DEFAULTS.merge(icon_data.slice(*ATTRS)).transform_values(&:to_s)
|
|
24
|
+
return merged if merged[:d].present?
|
|
25
|
+
|
|
26
|
+
StimulusPlumbers::Logger.warn("Icon missing required :d attribute")
|
|
27
|
+
nil
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -8,7 +8,7 @@ module StimulusPlumbers
|
|
|
8
8
|
SIZE = %i[sm md lg].freeze
|
|
9
9
|
FLEX_ALIGN = %i[left center right top bottom].freeze
|
|
10
10
|
FLEX_DIRECTION = %i[row col].freeze
|
|
11
|
-
|
|
11
|
+
BUTTON_VARIANT = %i[primary secondary outline destructive ghost link].freeze
|
|
12
12
|
end
|
|
13
13
|
end
|
|
14
14
|
end
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require_relative "schema/ranges"
|
|
4
|
+
require_relative "schema/form/ranges"
|
|
5
|
+
require_relative "schema/icon"
|
|
4
6
|
|
|
5
7
|
module StimulusPlumbers
|
|
6
8
|
module Themes
|
|
@@ -21,7 +23,7 @@ module StimulusPlumbers
|
|
|
21
23
|
|
|
22
24
|
BUTTON = {
|
|
23
25
|
button: {
|
|
24
|
-
variant: { default: :primary, range:
|
|
26
|
+
variant: { default: :primary, range: Ranges::BUTTON_VARIANT },
|
|
25
27
|
size: { default: :md, range: Ranges::SIZE }
|
|
26
28
|
}.freeze,
|
|
27
29
|
button_group: {
|
|
@@ -33,6 +35,7 @@ module StimulusPlumbers
|
|
|
33
35
|
CALENDAR = {
|
|
34
36
|
calendar: {}.freeze,
|
|
35
37
|
calendar_days_of_week: {}.freeze,
|
|
38
|
+
calendar_week: {}.freeze,
|
|
36
39
|
calendar_days_of_month: {}.freeze,
|
|
37
40
|
calendar_day: {
|
|
38
41
|
today: { default: false, range: Ranges::BOOL },
|
|
@@ -41,7 +44,9 @@ module StimulusPlumbers
|
|
|
41
44
|
}.freeze,
|
|
42
45
|
calendar_navigation: {}.freeze,
|
|
43
46
|
calendar_navigation_navigator: {}.freeze,
|
|
44
|
-
calendar_navigation_navigator_icon: {
|
|
47
|
+
calendar_navigation_navigator_icon: {
|
|
48
|
+
name: { default: "arrow-left", range: :icon_range }
|
|
49
|
+
}.freeze
|
|
45
50
|
}.freeze
|
|
46
51
|
|
|
47
52
|
CARD = {
|
|
@@ -50,6 +55,7 @@ module StimulusPlumbers
|
|
|
50
55
|
}.freeze
|
|
51
56
|
|
|
52
57
|
COMBOBOX = {
|
|
58
|
+
combobox_trigger: {}.freeze,
|
|
53
59
|
combobox_option: {
|
|
54
60
|
selected: { default: false, range: Ranges::BOOL },
|
|
55
61
|
disabled: { default: false, range: Ranges::BOOL }
|
|
@@ -63,7 +69,7 @@ module StimulusPlumbers
|
|
|
63
69
|
|
|
64
70
|
FORM = {
|
|
65
71
|
form_group: {
|
|
66
|
-
layout: { default: :stacked, range: Ranges::
|
|
72
|
+
layout: { default: :stacked, range: Form::Ranges::LAYOUT },
|
|
67
73
|
error: { default: false, range: Ranges::BOOL }
|
|
68
74
|
}.freeze,
|
|
69
75
|
form_label: {
|
|
@@ -81,13 +87,19 @@ module StimulusPlumbers
|
|
|
81
87
|
form_radio: { error: { default: false, range: Ranges::BOOL } }.freeze,
|
|
82
88
|
form_input_group: { error: { default: false, range: Ranges::BOOL } }.freeze,
|
|
83
89
|
form_combobox: { error: { default: false, range: Ranges::BOOL } }.freeze,
|
|
84
|
-
form_input_reveal: {}.freeze,
|
|
90
|
+
form_input_reveal: { error: { default: false, range: Ranges::BOOL } }.freeze,
|
|
91
|
+
form_input_search: {}.freeze,
|
|
85
92
|
form_button_reveal: {}.freeze,
|
|
93
|
+
form_button_clear: {}.freeze,
|
|
86
94
|
form_submit: {
|
|
87
|
-
variant: { default: :default, range:
|
|
95
|
+
variant: { default: :default, range: Form::Ranges::SUBMIT_VARIANT }
|
|
88
96
|
}.freeze
|
|
89
97
|
}.freeze
|
|
90
98
|
|
|
99
|
+
ICON = {
|
|
100
|
+
icon: {}.freeze
|
|
101
|
+
}.freeze
|
|
102
|
+
|
|
91
103
|
LAYOUT = {
|
|
92
104
|
divider: {}.freeze,
|
|
93
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.
|
|
4
|
+
version: 0.3.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ryan Chang
|
|
@@ -10,7 +10,7 @@ cert_chain: []
|
|
|
10
10
|
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
|
-
name:
|
|
13
|
+
name: actionview
|
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
|
15
15
|
requirements:
|
|
16
16
|
- - ">="
|
|
@@ -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,25 +103,24 @@ 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
|
|
104
110
|
- lib/stimulus_plumbers/plumber/base.rb
|
|
105
111
|
- lib/stimulus_plumbers/plumber/dispatcher.rb
|
|
112
|
+
- lib/stimulus_plumbers/plumber/dispatcher/callable_inspector.rb
|
|
113
|
+
- lib/stimulus_plumbers/plumber/dispatcher/instance_exec.rb
|
|
114
|
+
- lib/stimulus_plumbers/plumber/dispatcher/klass_proxy.rb
|
|
115
|
+
- lib/stimulus_plumbers/plumber/dispatcher/method_call.rb
|
|
106
116
|
- lib/stimulus_plumbers/plumber/html_options.rb
|
|
107
117
|
- lib/stimulus_plumbers/plumber/renderer.rb
|
|
108
118
|
- lib/stimulus_plumbers/themes/base.rb
|
|
119
|
+
- lib/stimulus_plumbers/themes/configuration.rb
|
|
109
120
|
- lib/stimulus_plumbers/themes/schema.rb
|
|
121
|
+
- lib/stimulus_plumbers/themes/schema/form/ranges.rb
|
|
122
|
+
- lib/stimulus_plumbers/themes/schema/icon.rb
|
|
110
123
|
- lib/stimulus_plumbers/themes/schema/ranges.rb
|
|
111
|
-
- lib/stimulus_plumbers/themes/tailwind/action_list.rb
|
|
112
|
-
- lib/stimulus_plumbers/themes/tailwind/avatar.rb
|
|
113
|
-
- lib/stimulus_plumbers/themes/tailwind/button.rb
|
|
114
|
-
- lib/stimulus_plumbers/themes/tailwind/calendar.rb
|
|
115
|
-
- lib/stimulus_plumbers/themes/tailwind/card.rb
|
|
116
|
-
- lib/stimulus_plumbers/themes/tailwind/combobox.rb
|
|
117
|
-
- lib/stimulus_plumbers/themes/tailwind/form.rb
|
|
118
|
-
- lib/stimulus_plumbers/themes/tailwind/layout.rb
|
|
119
|
-
- lib/stimulus_plumbers/themes/tailwind_theme.rb
|
|
120
124
|
- lib/stimulus_plumbers/version.rb
|
|
121
125
|
homepage: https://github.com/ryancyq/stimulus-plumbers
|
|
122
126
|
licenses:
|
|
@@ -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,41 +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
|
-
base_id = field_id(attribute)
|
|
23
|
-
current_value = object&.public_send(attribute)
|
|
24
|
-
|
|
25
|
-
popover = klass.new(@template).render(options: options, value: current_value, **rails_opts)
|
|
26
|
-
opts = klass.default_opts.deep_merge(
|
|
27
|
-
input: { name: field_name(attribute), value: current_value },
|
|
28
|
-
popover: { content: popover }
|
|
29
|
-
)
|
|
30
|
-
wrapper = Components::Combobox.new(@template).render(
|
|
31
|
-
base_id: base_id,
|
|
32
|
-
options: opts,
|
|
33
|
-
**field_theme(:form_combobox, error: field.error?),
|
|
34
|
-
**field.html_opts
|
|
35
|
-
)
|
|
36
|
-
render_field(field, wrapper)
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
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
|
|
@@ -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,52 +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
|
-
id = field.errors.one? ? field.error_id : "#{field.error_id}_#{i}"
|
|
46
|
-
Error.new(template).render(message: message, id: id)
|
|
47
|
-
end.join.html_safe
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
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
|