stimulus_plumbers 0.3.3 → 0.4.2
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 +69 -0
- data/README.md +11 -4
- data/app/assets/javascripts/stimulus-plumbers/controllers.manifest.json +386 -0
- data/app/assets/javascripts/stimulus-plumbers/stimulus-plumbers-controllers.es.js +756 -304
- data/app/assets/javascripts/stimulus-plumbers/stimulus-plumbers-controllers.umd.js +1 -1
- data/app/assets/stylesheets/stimulus_plumbers/tokens.css +66 -26
- data/config/locales/en.yml +31 -0
- data/lib/stimulus_plumbers/components/avatar.rb +22 -13
- data/lib/stimulus_plumbers/components/button/group.rb +9 -4
- data/lib/stimulus_plumbers/components/button/slots.rb +11 -0
- data/lib/stimulus_plumbers/components/button.rb +30 -34
- data/lib/stimulus_plumbers/components/calendar/turbo/days_of_month.rb +191 -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 +137 -0
- data/lib/stimulus_plumbers/components/calendar/turbo/years_of_decade.rb +114 -0
- data/lib/stimulus_plumbers/components/calendar/turbo.rb +112 -0
- data/lib/stimulus_plumbers/components/calendar.rb +57 -32
- data/lib/stimulus_plumbers/components/card/slots.rb +26 -0
- data/lib/stimulus_plumbers/components/card.rb +53 -13
- data/lib/stimulus_plumbers/components/combobox/builder.rb +45 -0
- data/lib/stimulus_plumbers/components/combobox/date/navigation.rb +80 -0
- data/lib/stimulus_plumbers/components/combobox/date/navigator.rb +27 -0
- data/lib/stimulus_plumbers/components/combobox/date.rb +55 -28
- data/lib/stimulus_plumbers/components/combobox/dropdown.rb +27 -24
- data/lib/stimulus_plumbers/components/combobox/options/option.rb +1 -1
- data/lib/stimulus_plumbers/components/combobox/options/option_group.rb +1 -1
- data/lib/stimulus_plumbers/components/combobox/time.rb +83 -78
- data/lib/stimulus_plumbers/components/combobox/trigger.rb +17 -12
- data/lib/stimulus_plumbers/components/combobox/typeahead.rb +63 -16
- data/lib/stimulus_plumbers/components/combobox.rb +58 -38
- data/lib/stimulus_plumbers/components/divider.rb +9 -8
- data/lib/stimulus_plumbers/components/icon.rb +5 -1
- data/lib/stimulus_plumbers/components/input_group.rb +2 -2
- 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 -18
- data/lib/stimulus_plumbers/components/timeline/event/slots.rb +18 -0
- data/lib/stimulus_plumbers/components/timeline/event.rb +189 -0
- data/lib/stimulus_plumbers/components/timeline/group.rb +42 -0
- data/lib/stimulus_plumbers/components/timeline.rb +40 -0
- data/lib/stimulus_plumbers/engine.rb +1 -0
- data/lib/stimulus_plumbers/form/base.rb +103 -0
- data/lib/stimulus_plumbers/form/builder.rb +78 -23
- data/lib/stimulus_plumbers/form/field.rb +55 -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 +52 -58
- data/lib/stimulus_plumbers/form/fields/inputs/file.rb +15 -9
- data/lib/stimulus_plumbers/form/fields/inputs/password.rb +46 -28
- data/lib/stimulus_plumbers/form/fields/inputs/radio.rb +72 -0
- data/lib/stimulus_plumbers/form/fields/inputs/search.rb +73 -65
- data/lib/stimulus_plumbers/form/fields/inputs/select/grouped.rb +22 -33
- data/lib/stimulus_plumbers/form/fields/inputs/select/timezone.rb +3 -46
- data/lib/stimulus_plumbers/form/fields/inputs/select/weekday.rb +3 -26
- data/lib/stimulus_plumbers/form/fields/inputs/select.rb +64 -61
- data/lib/stimulus_plumbers/form/fields/inputs/submit.rb +10 -7
- data/lib/stimulus_plumbers/form/fields/inputs/text.rb +34 -22
- data/lib/stimulus_plumbers/form/fields/inputs/text_area.rb +15 -9
- 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/button_helper.rb +1 -1
- data/lib/stimulus_plumbers/helpers/calendar_helper.rb +2 -2
- data/lib/stimulus_plumbers/helpers/calendar_turbo_helper.rb +76 -4
- data/lib/stimulus_plumbers/helpers/card_helper.rb +1 -11
- data/lib/stimulus_plumbers/helpers/combobox_helper.rb +27 -60
- 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/timeline_helper.rb +15 -0
- data/lib/stimulus_plumbers/helpers.rb +8 -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 +6 -7
- 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/floating/ranges.rb +15 -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/link/ranges.rb +14 -0
- data/lib/stimulus_plumbers/themes/schema/ranges.rb +1 -5
- data/lib/stimulus_plumbers/themes/schema.rb +169 -51
- data/lib/stimulus_plumbers/version.rb +1 -1
- data/lib/stimulus_plumbers.rb +24 -16
- metadata +48 -16
- data/lib/stimulus_plumbers/components/action_list/item.rb +0 -30
- data/lib/stimulus_plumbers/components/action_list/section.rb +0 -28
- data/lib/stimulus_plumbers/components/action_list.rb +0 -29
- data/lib/stimulus_plumbers/components/calendar/month/turbo/days_of_month.rb +0 -149
- data/lib/stimulus_plumbers/components/calendar/month/turbo/days_of_week.rb +0 -43
- data/lib/stimulus_plumbers/components/calendar/month/turbo.rb +0 -59
- data/lib/stimulus_plumbers/components/card/section.rb +0 -31
- data/lib/stimulus_plumbers/components/combobox/popover.rb +0 -47
- data/lib/stimulus_plumbers/components/combobox/time/drum.rb +0 -43
- data/lib/stimulus_plumbers/components/date_picker/navigation.rb +0 -41
- data/lib/stimulus_plumbers/components/date_picker/navigator.rb +0 -23
- data/lib/stimulus_plumbers/components/popover/builder.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
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.4.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ryan Chang
|
|
@@ -40,52 +40,67 @@ files:
|
|
|
40
40
|
- CHANGELOG.md
|
|
41
41
|
- README.md
|
|
42
42
|
- app/assets/javascripts/stimulus-plumbers/.keep
|
|
43
|
+
- app/assets/javascripts/stimulus-plumbers/controllers.manifest.json
|
|
43
44
|
- app/assets/javascripts/stimulus-plumbers/stimulus-plumbers-controllers.es.js
|
|
44
45
|
- app/assets/javascripts/stimulus-plumbers/stimulus-plumbers-controllers.umd.js
|
|
45
46
|
- app/assets/stylesheets/stimulus_plumbers/tokens.css
|
|
47
|
+
- config/locales/en.yml
|
|
46
48
|
- lib/stimulus_plumbers.rb
|
|
47
|
-
- lib/stimulus_plumbers/components/action_list.rb
|
|
48
|
-
- lib/stimulus_plumbers/components/action_list/item.rb
|
|
49
|
-
- lib/stimulus_plumbers/components/action_list/section.rb
|
|
50
49
|
- lib/stimulus_plumbers/components/avatar.rb
|
|
51
50
|
- lib/stimulus_plumbers/components/button.rb
|
|
52
51
|
- lib/stimulus_plumbers/components/button/group.rb
|
|
52
|
+
- lib/stimulus_plumbers/components/button/slots.rb
|
|
53
53
|
- lib/stimulus_plumbers/components/calendar.rb
|
|
54
|
-
- lib/stimulus_plumbers/components/calendar/
|
|
55
|
-
- lib/stimulus_plumbers/components/calendar/
|
|
56
|
-
- lib/stimulus_plumbers/components/calendar/
|
|
54
|
+
- lib/stimulus_plumbers/components/calendar/turbo.rb
|
|
55
|
+
- lib/stimulus_plumbers/components/calendar/turbo/days_of_month.rb
|
|
56
|
+
- lib/stimulus_plumbers/components/calendar/turbo/days_of_week.rb
|
|
57
|
+
- lib/stimulus_plumbers/components/calendar/turbo/months_of_year.rb
|
|
58
|
+
- lib/stimulus_plumbers/components/calendar/turbo/years_of_decade.rb
|
|
57
59
|
- lib/stimulus_plumbers/components/card.rb
|
|
58
|
-
- lib/stimulus_plumbers/components/card/
|
|
60
|
+
- lib/stimulus_plumbers/components/card/slots.rb
|
|
59
61
|
- lib/stimulus_plumbers/components/combobox.rb
|
|
62
|
+
- lib/stimulus_plumbers/components/combobox/builder.rb
|
|
60
63
|
- lib/stimulus_plumbers/components/combobox/date.rb
|
|
64
|
+
- lib/stimulus_plumbers/components/combobox/date/navigation.rb
|
|
65
|
+
- lib/stimulus_plumbers/components/combobox/date/navigator.rb
|
|
61
66
|
- lib/stimulus_plumbers/components/combobox/dropdown.rb
|
|
62
67
|
- lib/stimulus_plumbers/components/combobox/options.rb
|
|
63
68
|
- lib/stimulus_plumbers/components/combobox/options/option.rb
|
|
64
69
|
- lib/stimulus_plumbers/components/combobox/options/option_group.rb
|
|
65
|
-
- lib/stimulus_plumbers/components/combobox/popover.rb
|
|
66
70
|
- lib/stimulus_plumbers/components/combobox/time.rb
|
|
67
|
-
- lib/stimulus_plumbers/components/combobox/time/drum.rb
|
|
68
71
|
- lib/stimulus_plumbers/components/combobox/trigger.rb
|
|
69
72
|
- lib/stimulus_plumbers/components/combobox/typeahead.rb
|
|
70
|
-
- lib/stimulus_plumbers/components/date_picker/navigation.rb
|
|
71
|
-
- lib/stimulus_plumbers/components/date_picker/navigator.rb
|
|
72
73
|
- lib/stimulus_plumbers/components/divider.rb
|
|
73
74
|
- lib/stimulus_plumbers/components/icon.rb
|
|
74
75
|
- lib/stimulus_plumbers/components/input_group.rb
|
|
76
|
+
- lib/stimulus_plumbers/components/link.rb
|
|
77
|
+
- lib/stimulus_plumbers/components/link/slots.rb
|
|
78
|
+
- lib/stimulus_plumbers/components/list.rb
|
|
79
|
+
- lib/stimulus_plumbers/components/list/item.rb
|
|
80
|
+
- lib/stimulus_plumbers/components/list/item/slots.rb
|
|
81
|
+
- lib/stimulus_plumbers/components/list/section.rb
|
|
75
82
|
- lib/stimulus_plumbers/components/popover.rb
|
|
76
|
-
- lib/stimulus_plumbers/components/popover/
|
|
83
|
+
- lib/stimulus_plumbers/components/popover/panel.rb
|
|
84
|
+
- lib/stimulus_plumbers/components/popover/trigger.rb
|
|
85
|
+
- lib/stimulus_plumbers/components/timeline.rb
|
|
86
|
+
- lib/stimulus_plumbers/components/timeline/event.rb
|
|
87
|
+
- lib/stimulus_plumbers/components/timeline/event/slots.rb
|
|
88
|
+
- lib/stimulus_plumbers/components/timeline/group.rb
|
|
77
89
|
- lib/stimulus_plumbers/configuration.rb
|
|
78
90
|
- lib/stimulus_plumbers/engine.rb
|
|
91
|
+
- lib/stimulus_plumbers/form/base.rb
|
|
79
92
|
- lib/stimulus_plumbers/form/builder.rb
|
|
80
93
|
- lib/stimulus_plumbers/form/field.rb
|
|
81
94
|
- lib/stimulus_plumbers/form/fields/error.rb
|
|
82
95
|
- lib/stimulus_plumbers/form/fields/fieldset.rb
|
|
83
96
|
- lib/stimulus_plumbers/form/fields/group.rb
|
|
84
97
|
- lib/stimulus_plumbers/form/fields/hint.rb
|
|
85
|
-
- lib/stimulus_plumbers/form/fields/inputs/
|
|
98
|
+
- lib/stimulus_plumbers/form/fields/inputs/checkbox.rb
|
|
99
|
+
- lib/stimulus_plumbers/form/fields/inputs/combobox.rb
|
|
86
100
|
- lib/stimulus_plumbers/form/fields/inputs/datetime.rb
|
|
87
101
|
- lib/stimulus_plumbers/form/fields/inputs/file.rb
|
|
88
102
|
- lib/stimulus_plumbers/form/fields/inputs/password.rb
|
|
103
|
+
- lib/stimulus_plumbers/form/fields/inputs/radio.rb
|
|
89
104
|
- lib/stimulus_plumbers/form/fields/inputs/search.rb
|
|
90
105
|
- lib/stimulus_plumbers/form/fields/inputs/select.rb
|
|
91
106
|
- lib/stimulus_plumbers/form/fields/inputs/select/grouped.rb
|
|
@@ -95,8 +110,9 @@ files:
|
|
|
95
110
|
- lib/stimulus_plumbers/form/fields/inputs/text.rb
|
|
96
111
|
- lib/stimulus_plumbers/form/fields/inputs/text_area.rb
|
|
97
112
|
- lib/stimulus_plumbers/form/fields/label.rb
|
|
113
|
+
- lib/stimulus_plumbers/form/fields/label/floating.rb
|
|
114
|
+
- lib/stimulus_plumbers/form/fields/renderer.rb
|
|
98
115
|
- lib/stimulus_plumbers/helpers.rb
|
|
99
|
-
- lib/stimulus_plumbers/helpers/action_list_helper.rb
|
|
100
116
|
- lib/stimulus_plumbers/helpers/avatar_helper.rb
|
|
101
117
|
- lib/stimulus_plumbers/helpers/button_helper.rb
|
|
102
118
|
- lib/stimulus_plumbers/helpers/calendar_helper.rb
|
|
@@ -104,8 +120,12 @@ files:
|
|
|
104
120
|
- lib/stimulus_plumbers/helpers/card_helper.rb
|
|
105
121
|
- lib/stimulus_plumbers/helpers/combobox_helper.rb
|
|
106
122
|
- lib/stimulus_plumbers/helpers/divider_helper.rb
|
|
123
|
+
- lib/stimulus_plumbers/helpers/icon_helper.rb
|
|
124
|
+
- lib/stimulus_plumbers/helpers/link_helper.rb
|
|
125
|
+
- lib/stimulus_plumbers/helpers/list_helper.rb
|
|
107
126
|
- lib/stimulus_plumbers/helpers/plumber_helper.rb
|
|
108
127
|
- lib/stimulus_plumbers/helpers/popover_helper.rb
|
|
128
|
+
- lib/stimulus_plumbers/helpers/timeline_helper.rb
|
|
109
129
|
- lib/stimulus_plumbers/logger.rb
|
|
110
130
|
- lib/stimulus_plumbers/plumber/base.rb
|
|
111
131
|
- lib/stimulus_plumbers/plumber/dispatcher.rb
|
|
@@ -113,15 +133,27 @@ files:
|
|
|
113
133
|
- lib/stimulus_plumbers/plumber/dispatcher/instance_exec.rb
|
|
114
134
|
- lib/stimulus_plumbers/plumber/dispatcher/klass_proxy.rb
|
|
115
135
|
- lib/stimulus_plumbers/plumber/dispatcher/method_call.rb
|
|
116
|
-
- lib/stimulus_plumbers/plumber/
|
|
136
|
+
- lib/stimulus_plumbers/plumber/options/aria.rb
|
|
137
|
+
- lib/stimulus_plumbers/plumber/options/html.rb
|
|
138
|
+
- lib/stimulus_plumbers/plumber/options/stimulus.rb
|
|
139
|
+
- lib/stimulus_plumbers/plumber/options/theme.rb
|
|
140
|
+
- lib/stimulus_plumbers/plumber/options/token_list.rb
|
|
117
141
|
- lib/stimulus_plumbers/plumber/renderer.rb
|
|
142
|
+
- lib/stimulus_plumbers/plumber/slots.rb
|
|
118
143
|
- lib/stimulus_plumbers/themes/base.rb
|
|
119
144
|
- lib/stimulus_plumbers/themes/configuration.rb
|
|
120
145
|
- lib/stimulus_plumbers/themes/icons/external.rb
|
|
121
146
|
- lib/stimulus_plumbers/themes/icons/registry.rb
|
|
122
147
|
- lib/stimulus_plumbers/themes/schema.rb
|
|
148
|
+
- lib/stimulus_plumbers/themes/schema/avatar/ranges.rb
|
|
149
|
+
- lib/stimulus_plumbers/themes/schema/button/ranges.rb
|
|
150
|
+
- lib/stimulus_plumbers/themes/schema/card/ranges.rb
|
|
151
|
+
- lib/stimulus_plumbers/themes/schema/form/checkbox/ranges.rb
|
|
152
|
+
- lib/stimulus_plumbers/themes/schema/form/floating/ranges.rb
|
|
153
|
+
- lib/stimulus_plumbers/themes/schema/form/radio/ranges.rb
|
|
123
154
|
- lib/stimulus_plumbers/themes/schema/form/ranges.rb
|
|
124
155
|
- lib/stimulus_plumbers/themes/schema/icon.rb
|
|
156
|
+
- lib/stimulus_plumbers/themes/schema/link/ranges.rb
|
|
125
157
|
- lib/stimulus_plumbers/themes/schema/ranges.rb
|
|
126
158
|
- lib/stimulus_plumbers/version.rb
|
|
127
159
|
homepage: https://github.com/ryancyq/stimulus-plumbers
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module StimulusPlumbers
|
|
4
|
-
module Components
|
|
5
|
-
class ActionList
|
|
6
|
-
class Item < Plumber::Base
|
|
7
|
-
def render(content = nil, **kwargs, &block)
|
|
8
|
-
render_item(content, **kwargs, &block)
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
private
|
|
12
|
-
|
|
13
|
-
def render_item(content, url: nil, external: false, active: false, **kwargs, &block)
|
|
14
|
-
html_options = merge_html_options(
|
|
15
|
-
{ classes: theme.resolve(:action_list_item, active: active).fetch(:classes, "") },
|
|
16
|
-
kwargs
|
|
17
|
-
)
|
|
18
|
-
|
|
19
|
-
template.content_tag(:li) do
|
|
20
|
-
render_button(content, url: url, external: external, variant: :outline, **html_options, &block)
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def render_button(content, url: nil, external: false, **kwargs, &block)
|
|
25
|
-
Components::Button.new(template).render(content, url: url, external: external, **kwargs, &block)
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
end
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module StimulusPlumbers
|
|
4
|
-
module Components
|
|
5
|
-
class ActionList
|
|
6
|
-
class Section < Plumber::Base
|
|
7
|
-
def render(...)
|
|
8
|
-
render_section(...)
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
private
|
|
12
|
-
|
|
13
|
-
def render_section(title: nil, **kwargs, &block)
|
|
14
|
-
template.content_tag(:li, **kwargs) do
|
|
15
|
-
ul_opts = {}
|
|
16
|
-
ul_opts[:aria] = { label: title } if title.present?
|
|
17
|
-
template.safe_join(
|
|
18
|
-
[
|
|
19
|
-
(template.content_tag(:span, title, aria: { hidden: "true" }) if title.present?),
|
|
20
|
-
template.content_tag(:ul, template.capture(&block), **ul_opts)
|
|
21
|
-
]
|
|
22
|
-
)
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
end
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module StimulusPlumbers
|
|
4
|
-
module Components
|
|
5
|
-
class ActionList < Plumber::Base
|
|
6
|
-
def render(...)
|
|
7
|
-
render_list(...)
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def section(...)
|
|
11
|
-
ActionList::Section.new(template).render(...)
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def item(content = nil, **kwargs, &block)
|
|
15
|
-
ActionList::Item.new(template).render(content, **kwargs, &block)
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
private
|
|
19
|
-
|
|
20
|
-
def render_list(role: "list", **kwargs, &block)
|
|
21
|
-
html_options = merge_html_options(
|
|
22
|
-
{ role: role, classes: theme.resolve(:action_list).fetch(:classes, "") },
|
|
23
|
-
kwargs
|
|
24
|
-
)
|
|
25
|
-
template.content_tag(:ul, template.capture(&block), **html_options)
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
end
|
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module StimulusPlumbers
|
|
4
|
-
module Components
|
|
5
|
-
class Calendar
|
|
6
|
-
module Month
|
|
7
|
-
class Turbo
|
|
8
|
-
class DaysOfMonth < Plumber::Base
|
|
9
|
-
DAYS_IN_WEEK = 7
|
|
10
|
-
|
|
11
|
-
attr_reader :date, :today, :selectable, :selected_date, :show_other_months
|
|
12
|
-
|
|
13
|
-
def initialize(
|
|
14
|
-
template,
|
|
15
|
-
date: Date.today,
|
|
16
|
-
today: Date.today,
|
|
17
|
-
selectable: false,
|
|
18
|
-
selected_date: nil,
|
|
19
|
-
show_other_months: false
|
|
20
|
-
)
|
|
21
|
-
super(template)
|
|
22
|
-
@date = date
|
|
23
|
-
@today = today
|
|
24
|
-
@selectable = selectable
|
|
25
|
-
@selected_date = selected_date
|
|
26
|
-
@show_other_months = show_other_months
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def render(...)
|
|
30
|
-
render_days_of_month(...)
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
private
|
|
34
|
-
|
|
35
|
-
def render_days_of_month(**html_options)
|
|
36
|
-
html_options = merge_html_options(
|
|
37
|
-
{ classes: theme.resolve(:calendar_days_of_month).fetch(:classes, "") },
|
|
38
|
-
html_options
|
|
39
|
-
)
|
|
40
|
-
template.content_tag(:div, **html_options, role: "rowgroup") { weeks_of_month }
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
def weeks_of_month
|
|
44
|
-
week_options = merge_html_options(
|
|
45
|
-
{ classes: theme.resolve(:calendar_week).fetch(:classes, "") },
|
|
46
|
-
{ role: "row" }
|
|
47
|
-
)
|
|
48
|
-
template.safe_join(
|
|
49
|
-
build_days.each_slice(DAYS_IN_WEEK).map do |days|
|
|
50
|
-
template.content_tag(:div, **week_options) { days_in_week(days) }
|
|
51
|
-
end
|
|
52
|
-
)
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
def focus_day
|
|
56
|
-
@focus_day ||= if selected_date_in_current_month?
|
|
57
|
-
selected_date
|
|
58
|
-
elsif today_in_current_month?
|
|
59
|
-
today
|
|
60
|
-
else
|
|
61
|
-
date.beginning_of_month
|
|
62
|
-
end
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
def build_days
|
|
66
|
-
first = date.beginning_of_month
|
|
67
|
-
last = date.end_of_month
|
|
68
|
-
current_days = first.upto(last).to_a
|
|
69
|
-
prev_filler_days(first) + current_days + next_filler_days(last, current_days.length)
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
def prev_filler_days(first_day_of_month)
|
|
73
|
-
week_start = first_day_of_month - first_day_of_month.wday
|
|
74
|
-
week_start.upto(first_day_of_month - 1).to_a
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
def next_filler_days(last_day_of_month, days_in_month)
|
|
78
|
-
week_start_offset = last_day_of_month.beginning_of_month.wday
|
|
79
|
-
total = week_start_offset + days_in_month
|
|
80
|
-
next_count = (DAYS_IN_WEEK - (total % DAYS_IN_WEEK)) % DAYS_IN_WEEK
|
|
81
|
-
next_count.positive? ? (last_day_of_month + 1).upto(last_day_of_month + next_count).to_a : []
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
def selected_date_in_current_month?
|
|
85
|
-
selected_date&.month == date.month && selected_date&.year == date.year
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
def today_in_current_month?
|
|
89
|
-
today.month == date.month && today.year == date.year
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
def days_in_week(days)
|
|
93
|
-
template.safe_join(
|
|
94
|
-
days.map do |day|
|
|
95
|
-
if day.month == date.month
|
|
96
|
-
current_month_day_cell(day)
|
|
97
|
-
elsif show_other_months
|
|
98
|
-
other_month_day_cell(day)
|
|
99
|
-
else
|
|
100
|
-
hidden_day_cell(day)
|
|
101
|
-
end
|
|
102
|
-
end
|
|
103
|
-
)
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
def hidden_day_cell(date)
|
|
107
|
-
template.content_tag(:span, role: "gridcell", tabindex: -1, aria: { hidden: "true" }) do
|
|
108
|
-
template.content_tag(:time, nil, datetime: date.iso8601)
|
|
109
|
-
end
|
|
110
|
-
end
|
|
111
|
-
|
|
112
|
-
def current_month_day_cell(date)
|
|
113
|
-
tag = selectable ? :button : :span
|
|
114
|
-
template.content_tag(tag, **day_cell_html_options(date, today)) do
|
|
115
|
-
template.content_tag(:time, date.day.to_s, datetime: date.iso8601)
|
|
116
|
-
end
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
def day_cell_html_options(date, today)
|
|
120
|
-
is_today = date == today
|
|
121
|
-
selected = selected_date && date == selected_date
|
|
122
|
-
merge_html_options(
|
|
123
|
-
{ classes: theme.resolve(:calendar_day).fetch(:classes, "") },
|
|
124
|
-
{
|
|
125
|
-
role: "gridcell",
|
|
126
|
-
tabindex: date == focus_day ? 0 : -1,
|
|
127
|
-
aria: {
|
|
128
|
-
current: is_today ? "date" : nil,
|
|
129
|
-
selected: if selectable then selected ? "true" : "false" end
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
)
|
|
133
|
-
end
|
|
134
|
-
|
|
135
|
-
def other_month_day_cell(date)
|
|
136
|
-
options = merge_html_options(
|
|
137
|
-
{ classes: theme.resolve(:calendar_day, outside: true).fetch(:classes, "") },
|
|
138
|
-
{ role: "gridcell", tabindex: -1, aria: { disabled: "true", selected: "false" } }
|
|
139
|
-
)
|
|
140
|
-
template.content_tag(:span, **options) do
|
|
141
|
-
template.content_tag(:time, date.day.to_s, datetime: date.iso8601)
|
|
142
|
-
end
|
|
143
|
-
end
|
|
144
|
-
end
|
|
145
|
-
end
|
|
146
|
-
end
|
|
147
|
-
end
|
|
148
|
-
end
|
|
149
|
-
end
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module StimulusPlumbers
|
|
4
|
-
module Components
|
|
5
|
-
class Calendar
|
|
6
|
-
module Month
|
|
7
|
-
class Turbo
|
|
8
|
-
class DaysOfWeek < Plumber::Base
|
|
9
|
-
def render(...)
|
|
10
|
-
render_days_of_week(...)
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
private
|
|
14
|
-
|
|
15
|
-
def render_days_of_week(**kwargs)
|
|
16
|
-
html_options = merge_html_options(
|
|
17
|
-
{ classes: theme.resolve(:calendar_days_of_week).fetch(:classes, "") },
|
|
18
|
-
kwargs
|
|
19
|
-
)
|
|
20
|
-
template.content_tag(:div, **html_options) { days_of_week }
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def days_of_week
|
|
24
|
-
week_options = merge_html_options(
|
|
25
|
-
{ classes: theme.resolve(:calendar_week).fetch(:classes, "") },
|
|
26
|
-
{ role: "row" }
|
|
27
|
-
)
|
|
28
|
-
template.content_tag(:div, **week_options) do
|
|
29
|
-
template.safe_join(
|
|
30
|
-
day_names.map { |abbr, full| template.content_tag(:span, abbr, role: "columnheader", abbr: full) }
|
|
31
|
-
)
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
def day_names
|
|
36
|
-
I18n.t("date.abbr_day_names").zip(I18n.t("date.day_names"))
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
end
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module StimulusPlumbers
|
|
4
|
-
module Components
|
|
5
|
-
class Calendar
|
|
6
|
-
module Month
|
|
7
|
-
class Turbo < Plumber::Base
|
|
8
|
-
STIMULUS_CONTROLLER = "calendar-month-observer"
|
|
9
|
-
|
|
10
|
-
def render(...)
|
|
11
|
-
render_turbo(...)
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
private
|
|
15
|
-
|
|
16
|
-
def render_turbo(
|
|
17
|
-
date: Date.today,
|
|
18
|
-
today: Date.today,
|
|
19
|
-
selectable: false,
|
|
20
|
-
selected_date: nil,
|
|
21
|
-
show_other_months: false,
|
|
22
|
-
**kwargs
|
|
23
|
-
)
|
|
24
|
-
html_options = merge_html_options(
|
|
25
|
-
{
|
|
26
|
-
classes: theme.resolve(:calendar).fetch(:classes, ""),
|
|
27
|
-
data: { controller: STIMULUS_CONTROLLER, action: "click->#{STIMULUS_CONTROLLER}#select" }
|
|
28
|
-
},
|
|
29
|
-
kwargs
|
|
30
|
-
)
|
|
31
|
-
|
|
32
|
-
template.content_tag(:div, role: "grid", **html_options) do
|
|
33
|
-
template.safe_join(
|
|
34
|
-
[
|
|
35
|
-
days_of_week,
|
|
36
|
-
days_of_month(
|
|
37
|
-
date: date,
|
|
38
|
-
today: today,
|
|
39
|
-
selectable: selectable,
|
|
40
|
-
selected_date: selected_date,
|
|
41
|
-
show_other_months: show_other_months
|
|
42
|
-
)
|
|
43
|
-
]
|
|
44
|
-
)
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
def days_of_week(**kwargs)
|
|
49
|
-
Turbo::DaysOfWeek.new(template).render(**kwargs)
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
def days_of_month(**kwargs)
|
|
53
|
-
Turbo::DaysOfMonth.new(template, **kwargs).render
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
end
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module StimulusPlumbers
|
|
4
|
-
module Components
|
|
5
|
-
class Card
|
|
6
|
-
class Section < Plumber::Base
|
|
7
|
-
def render(...)
|
|
8
|
-
render_section(...)
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
private
|
|
12
|
-
|
|
13
|
-
def render_section(title: nil, title_tag: :h3, **kwargs, &block)
|
|
14
|
-
html_options = merge_html_options(
|
|
15
|
-
{ classes: theme.resolve(:card_section).fetch(:classes, "") },
|
|
16
|
-
kwargs
|
|
17
|
-
)
|
|
18
|
-
|
|
19
|
-
template.content_tag(:div, **html_options) do
|
|
20
|
-
template.safe_join(
|
|
21
|
-
[
|
|
22
|
-
(template.content_tag(title_tag, title) if title.present?),
|
|
23
|
-
template.capture(&block)
|
|
24
|
-
]
|
|
25
|
-
)
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
end
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module StimulusPlumbers
|
|
4
|
-
module Components
|
|
5
|
-
class Combobox
|
|
6
|
-
class Popover < Plumber::Base
|
|
7
|
-
def render(...)
|
|
8
|
-
render_popover(...)
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
private
|
|
12
|
-
|
|
13
|
-
def render_popover(
|
|
14
|
-
stimulus_controller:,
|
|
15
|
-
id:,
|
|
16
|
-
tag: :div,
|
|
17
|
-
role: nil,
|
|
18
|
-
label: nil,
|
|
19
|
-
labelledby: nil,
|
|
20
|
-
content: nil,
|
|
21
|
-
data: {},
|
|
22
|
-
**kwargs,
|
|
23
|
-
&block
|
|
24
|
-
)
|
|
25
|
-
opts = {}
|
|
26
|
-
opts[:role] = role if role
|
|
27
|
-
if labelledby
|
|
28
|
-
opts[:aria] = { labelledby: labelledby }
|
|
29
|
-
elsif label
|
|
30
|
-
opts[:aria] = { label: label }
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
html_options = merge_html_options(
|
|
34
|
-
{ id: id, hidden: "" },
|
|
35
|
-
{ data: { "#{stimulus_controller}_target": "popover" } },
|
|
36
|
-
{ data: data },
|
|
37
|
-
opts,
|
|
38
|
-
kwargs
|
|
39
|
-
)
|
|
40
|
-
|
|
41
|
-
html_content = block_given? ? template.capture(id, &block) : content
|
|
42
|
-
template.content_tag(tag, html_content, **html_options)
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
end
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module StimulusPlumbers
|
|
4
|
-
module Components
|
|
5
|
-
class Combobox
|
|
6
|
-
class Time
|
|
7
|
-
class Drum < Plumber::Base
|
|
8
|
-
def render(...)
|
|
9
|
-
render_drum(...)
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
private
|
|
13
|
-
|
|
14
|
-
def render_drum(stimulus_controller:, target:, label:, items:, selected: nil)
|
|
15
|
-
template.content_tag(
|
|
16
|
-
:ul,
|
|
17
|
-
**merge_html_options(
|
|
18
|
-
{ classes: theme.resolve(:combobox_listbox).fetch(:classes, "") },
|
|
19
|
-
{
|
|
20
|
-
role: "listbox",
|
|
21
|
-
tabindex: "0",
|
|
22
|
-
aria: { label: label },
|
|
23
|
-
data: { "#{stimulus_controller}_target": target }
|
|
24
|
-
},
|
|
25
|
-
{ data: { action: "click->#{stimulus_controller}#select keydown->#{stimulus_controller}#onNavigate" } }
|
|
26
|
-
)
|
|
27
|
-
) do
|
|
28
|
-
template.safe_join(
|
|
29
|
-
items.map do |text, value|
|
|
30
|
-
Options::Option.new(template).render(
|
|
31
|
-
label: text,
|
|
32
|
-
value: value,
|
|
33
|
-
selected: value.to_s == selected.to_s
|
|
34
|
-
)
|
|
35
|
-
end
|
|
36
|
-
)
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
end
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module StimulusPlumbers
|
|
4
|
-
module Components
|
|
5
|
-
module DatePicker
|
|
6
|
-
class Navigation < Plumber::Base
|
|
7
|
-
def render(step:, stimulus_controller:, **kwargs)
|
|
8
|
-
html_options = merge_html_options(
|
|
9
|
-
{ classes: theme.resolve(:calendar_navigation).fetch(:classes, ""), aria: { label: "DatePicker Navigation" } },
|
|
10
|
-
kwargs
|
|
11
|
-
)
|
|
12
|
-
|
|
13
|
-
template.content_tag(:nav, **html_options) do
|
|
14
|
-
template.safe_join(navigators(stimulus_controller, step))
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
private
|
|
19
|
-
|
|
20
|
-
def navigators(stimulus_controller, step)
|
|
21
|
-
[
|
|
22
|
-
navigator(stimulus_controller, target: "previous", icon: "arrow-left", label: ["previous", step].join(" ").titleize),
|
|
23
|
-
navigator(stimulus_controller, target: "day", label: "Day"),
|
|
24
|
-
navigator(stimulus_controller, target: "month", label: "Month"),
|
|
25
|
-
navigator(stimulus_controller, target: "year", label: "Year"),
|
|
26
|
-
navigator(stimulus_controller, target: "next", icon: "arrow-right", label: ["next", step].join(" ").titleize)
|
|
27
|
-
]
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def navigator(stimulus_controller, target:, label:, icon: nil)
|
|
31
|
-
opts = {
|
|
32
|
-
aria: { label: label },
|
|
33
|
-
data: { "#{stimulus_controller}-target" => target }
|
|
34
|
-
}
|
|
35
|
-
opts[:icon] = icon if icon
|
|
36
|
-
Navigator.new(template).render(**opts)
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
end
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module StimulusPlumbers
|
|
4
|
-
module Components
|
|
5
|
-
module DatePicker
|
|
6
|
-
class Navigator < Plumber::Base
|
|
7
|
-
def render(...)
|
|
8
|
-
render_navigator(...)
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
private
|
|
12
|
-
|
|
13
|
-
def render_navigator(icon: nil, **kwargs)
|
|
14
|
-
html_options = merge_html_options(
|
|
15
|
-
{ classes: theme.resolve(:calendar_navigation_navigator).fetch(:classes, "") },
|
|
16
|
-
kwargs
|
|
17
|
-
)
|
|
18
|
-
Components::Button.new(template).render(variant: :ghost, size: nil, icon_leading: icon, **html_options)
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|