stimulus_plumbers 0.2.8 → 0.3.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 +52 -0
- data/README.md +8 -4
- data/app/assets/javascripts/stimulus-plumbers/stimulus-plumbers-controllers.es.js +450 -436
- data/app/assets/javascripts/stimulus-plumbers/stimulus-plumbers-controllers.umd.js +1 -1
- data/lib/stimulus_plumbers/components/action_list/item.rb +27 -0
- data/lib/stimulus_plumbers/components/action_list/section.rb +21 -0
- data/lib/stimulus_plumbers/components/action_list.rb +23 -0
- data/lib/stimulus_plumbers/components/avatar.rb +73 -0
- data/lib/stimulus_plumbers/components/button/group.rb +17 -0
- data/lib/stimulus_plumbers/components/button.rb +27 -0
- data/lib/stimulus_plumbers/components/calendar/month/turbo/days_of_month.rb +60 -41
- data/lib/stimulus_plumbers/components/calendar/month/turbo/days_of_week.rb +15 -12
- data/lib/stimulus_plumbers/components/calendar/month/turbo.rb +55 -0
- data/lib/stimulus_plumbers/components/calendar.rb +56 -0
- data/lib/stimulus_plumbers/components/card/section.rb +25 -0
- data/lib/stimulus_plumbers/components/card.rb +27 -0
- data/lib/stimulus_plumbers/components/combobox/autocomplete.rb +30 -34
- data/lib/stimulus_plumbers/components/combobox/date.rb +16 -18
- data/lib/stimulus_plumbers/components/combobox/dropdown.rb +13 -16
- data/lib/stimulus_plumbers/components/combobox/options/option.rb +34 -0
- data/lib/stimulus_plumbers/components/combobox/options/option_group.rb +29 -0
- data/lib/stimulus_plumbers/components/combobox/options.rb +59 -0
- data/lib/stimulus_plumbers/components/combobox/popover.rb +20 -0
- data/lib/stimulus_plumbers/components/combobox/time/drum.rb +37 -0
- data/lib/stimulus_plumbers/components/combobox/time.rb +32 -15
- data/lib/stimulus_plumbers/components/combobox/trigger.rb +38 -0
- data/lib/stimulus_plumbers/components/combobox.rb +59 -0
- data/lib/stimulus_plumbers/components/date_picker/navigation.rb +14 -22
- data/lib/stimulus_plumbers/components/date_picker/navigator.rb +1 -1
- data/lib/stimulus_plumbers/components/icon.rb +43 -0
- data/lib/stimulus_plumbers/components/popover/builder.rb +25 -0
- data/lib/stimulus_plumbers/components/popover.rb +31 -0
- data/lib/stimulus_plumbers/configuration.rb +3 -18
- data/lib/stimulus_plumbers/engine.rb +2 -2
- data/lib/stimulus_plumbers/form/builder.rb +8 -6
- data/lib/stimulus_plumbers/form/{field_component.rb → field.rb} +1 -1
- data/lib/stimulus_plumbers/form/fields/combobox.rb +7 -4
- data/lib/stimulus_plumbers/form/fields/error.rb +14 -0
- data/lib/stimulus_plumbers/form/fields/group.rb +14 -0
- data/lib/stimulus_plumbers/form/fields/hint.rb +14 -0
- data/lib/stimulus_plumbers/form/fields/label.rb +21 -0
- data/lib/stimulus_plumbers/form/fields/renderer.rb +20 -21
- data/lib/stimulus_plumbers/form/fields/search.rb +23 -9
- data/lib/stimulus_plumbers/form/fields/submit.rb +23 -0
- data/lib/stimulus_plumbers/helpers/action_list_helper.rb +2 -2
- data/lib/stimulus_plumbers/helpers/avatar_helper.rb +2 -2
- data/lib/stimulus_plumbers/helpers/button_helper.rb +2 -2
- data/lib/stimulus_plumbers/helpers/calendar_helper.rb +1 -1
- data/lib/stimulus_plumbers/helpers/calendar_turbo_helper.rb +1 -1
- data/lib/stimulus_plumbers/helpers/card_helper.rb +2 -2
- data/lib/stimulus_plumbers/helpers/combobox_helper.rb +5 -5
- data/lib/stimulus_plumbers/helpers/popover_helper.rb +2 -2
- data/lib/stimulus_plumbers/plumber/base.rb +20 -0
- 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 +28 -0
- data/lib/stimulus_plumbers/plumber/html_options.rb +52 -0
- data/lib/stimulus_plumbers/plumber/renderer.rb +89 -0
- data/lib/stimulus_plumbers/themes/base.rb +34 -20
- 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 +5 -5
- data/lib/stimulus_plumbers/themes/schema.rb +103 -0
- data/lib/stimulus_plumbers/version.rb +1 -1
- data/lib/stimulus_plumbers.rb +29 -19
- metadata +40 -34
- data/lib/stimulus_plumbers/components/action_list/renderer.rb +0 -47
- data/lib/stimulus_plumbers/components/avatar/renderer.rb +0 -74
- data/lib/stimulus_plumbers/components/button/renderer.rb +0 -33
- data/lib/stimulus_plumbers/components/calendar/month/turbo/renderer.rb +0 -57
- data/lib/stimulus_plumbers/components/calendar/renderer.rb +0 -35
- data/lib/stimulus_plumbers/components/card/renderer.rb +0 -41
- data/lib/stimulus_plumbers/components/combobox/option.rb +0 -27
- data/lib/stimulus_plumbers/components/combobox/option_group.rb +0 -52
- data/lib/stimulus_plumbers/components/combobox/renderer.rb +0 -78
- data/lib/stimulus_plumbers/components/icon/renderer.rb +0 -51
- data/lib/stimulus_plumbers/components/plumber/base.rb +0 -22
- data/lib/stimulus_plumbers/components/plumber/dispatcher.rb +0 -113
- data/lib/stimulus_plumbers/components/plumber/html_options.rb +0 -53
- data/lib/stimulus_plumbers/components/plumber/renderer.rb +0 -91
- data/lib/stimulus_plumbers/components/popover/renderer.rb +0 -46
- data/lib/stimulus_plumbers/components/time_picker/renderer.rb +0 -38
- data/lib/stimulus_plumbers/themes/base/action_list.rb +0 -14
- data/lib/stimulus_plumbers/themes/base/avatar.rb +0 -14
- data/lib/stimulus_plumbers/themes/base/button.rb +0 -18
- data/lib/stimulus_plumbers/themes/base/calendar.rb +0 -15
- data/lib/stimulus_plumbers/themes/base/card.rb +0 -12
- data/lib/stimulus_plumbers/themes/base/form.rb +0 -34
- data/lib/stimulus_plumbers/themes/base/layout.rb +0 -12
- 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 -34
- data/lib/stimulus_plumbers/themes/tailwind/card.rb +0 -24
- 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 -29
data/lib/stimulus_plumbers.rb
CHANGED
|
@@ -11,43 +11,53 @@ require_relative "stimulus_plumbers/helpers"
|
|
|
11
11
|
require_relative "stimulus_plumbers/logger"
|
|
12
12
|
|
|
13
13
|
# -- Plumber base --
|
|
14
|
-
require_relative "stimulus_plumbers/
|
|
15
|
-
require_relative "stimulus_plumbers/
|
|
16
|
-
require_relative "stimulus_plumbers/
|
|
17
|
-
require_relative "stimulus_plumbers/
|
|
14
|
+
require_relative "stimulus_plumbers/plumber/html_options"
|
|
15
|
+
require_relative "stimulus_plumbers/plumber/dispatcher"
|
|
16
|
+
require_relative "stimulus_plumbers/plumber/renderer"
|
|
17
|
+
require_relative "stimulus_plumbers/plumber/base"
|
|
18
18
|
|
|
19
19
|
# -- UI components --
|
|
20
|
-
require_relative "stimulus_plumbers/components/icon
|
|
21
|
-
require_relative "stimulus_plumbers/components/avatar
|
|
22
|
-
require_relative "stimulus_plumbers/components/button
|
|
23
|
-
require_relative "stimulus_plumbers/components/
|
|
24
|
-
require_relative "stimulus_plumbers/components/
|
|
25
|
-
require_relative "stimulus_plumbers/components/
|
|
20
|
+
require_relative "stimulus_plumbers/components/icon"
|
|
21
|
+
require_relative "stimulus_plumbers/components/avatar"
|
|
22
|
+
require_relative "stimulus_plumbers/components/button"
|
|
23
|
+
require_relative "stimulus_plumbers/components/button/group"
|
|
24
|
+
require_relative "stimulus_plumbers/components/card"
|
|
25
|
+
require_relative "stimulus_plumbers/components/card/section"
|
|
26
|
+
require_relative "stimulus_plumbers/components/action_list"
|
|
27
|
+
require_relative "stimulus_plumbers/components/action_list/section"
|
|
28
|
+
require_relative "stimulus_plumbers/components/action_list/item"
|
|
29
|
+
require_relative "stimulus_plumbers/components/popover"
|
|
30
|
+
require_relative "stimulus_plumbers/components/popover/builder"
|
|
26
31
|
|
|
27
32
|
# -- Calendar --
|
|
28
|
-
require_relative "stimulus_plumbers/components/calendar
|
|
33
|
+
require_relative "stimulus_plumbers/components/calendar"
|
|
34
|
+
require_relative "stimulus_plumbers/components/calendar/month/turbo"
|
|
29
35
|
require_relative "stimulus_plumbers/components/calendar/month/turbo/days_of_week"
|
|
30
36
|
require_relative "stimulus_plumbers/components/calendar/month/turbo/days_of_month"
|
|
31
|
-
require_relative "stimulus_plumbers/components/calendar/month/turbo/renderer"
|
|
32
37
|
|
|
33
38
|
# -- Date picker --
|
|
34
39
|
require_relative "stimulus_plumbers/components/date_picker/navigator"
|
|
35
40
|
require_relative "stimulus_plumbers/components/date_picker/navigation"
|
|
36
41
|
|
|
37
|
-
# -- Time picker --
|
|
38
|
-
require_relative "stimulus_plumbers/components/time_picker/renderer"
|
|
39
|
-
|
|
40
42
|
# -- Combobox --
|
|
41
|
-
require_relative "stimulus_plumbers/components/combobox
|
|
42
|
-
require_relative "stimulus_plumbers/components/combobox/
|
|
43
|
-
require_relative "stimulus_plumbers/components/combobox/
|
|
43
|
+
require_relative "stimulus_plumbers/components/combobox"
|
|
44
|
+
require_relative "stimulus_plumbers/components/combobox/trigger"
|
|
45
|
+
require_relative "stimulus_plumbers/components/combobox/popover"
|
|
46
|
+
require_relative "stimulus_plumbers/components/combobox/options"
|
|
47
|
+
require_relative "stimulus_plumbers/components/combobox/options/option"
|
|
48
|
+
require_relative "stimulus_plumbers/components/combobox/options/option_group"
|
|
44
49
|
require_relative "stimulus_plumbers/components/combobox/date"
|
|
45
50
|
require_relative "stimulus_plumbers/components/combobox/dropdown"
|
|
46
51
|
require_relative "stimulus_plumbers/components/combobox/autocomplete"
|
|
47
52
|
require_relative "stimulus_plumbers/components/combobox/time"
|
|
53
|
+
require_relative "stimulus_plumbers/components/combobox/time/drum"
|
|
48
54
|
|
|
49
55
|
# -- Form --
|
|
50
|
-
require_relative "stimulus_plumbers/form/
|
|
56
|
+
require_relative "stimulus_plumbers/form/field"
|
|
57
|
+
require_relative "stimulus_plumbers/form/fields/group"
|
|
58
|
+
require_relative "stimulus_plumbers/form/fields/label"
|
|
59
|
+
require_relative "stimulus_plumbers/form/fields/hint"
|
|
60
|
+
require_relative "stimulus_plumbers/form/fields/error"
|
|
51
61
|
require_relative "stimulus_plumbers/form/builder"
|
|
52
62
|
|
|
53
63
|
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.0
|
|
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
|
- - ">="
|
|
@@ -44,41 +44,50 @@ files:
|
|
|
44
44
|
- app/assets/javascripts/stimulus-plumbers/stimulus-plumbers-controllers.umd.js
|
|
45
45
|
- app/assets/stylesheets/stimulus_plumbers/tokens.css
|
|
46
46
|
- lib/stimulus_plumbers.rb
|
|
47
|
-
- lib/stimulus_plumbers/components/action_list
|
|
48
|
-
- lib/stimulus_plumbers/components/
|
|
49
|
-
- lib/stimulus_plumbers/components/
|
|
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
|
+
- lib/stimulus_plumbers/components/avatar.rb
|
|
51
|
+
- lib/stimulus_plumbers/components/button.rb
|
|
52
|
+
- lib/stimulus_plumbers/components/button/group.rb
|
|
53
|
+
- lib/stimulus_plumbers/components/calendar.rb
|
|
54
|
+
- lib/stimulus_plumbers/components/calendar/month/turbo.rb
|
|
50
55
|
- lib/stimulus_plumbers/components/calendar/month/turbo/days_of_month.rb
|
|
51
56
|
- lib/stimulus_plumbers/components/calendar/month/turbo/days_of_week.rb
|
|
52
|
-
- lib/stimulus_plumbers/components/
|
|
53
|
-
- lib/stimulus_plumbers/components/
|
|
54
|
-
- lib/stimulus_plumbers/components/
|
|
57
|
+
- lib/stimulus_plumbers/components/card.rb
|
|
58
|
+
- lib/stimulus_plumbers/components/card/section.rb
|
|
59
|
+
- lib/stimulus_plumbers/components/combobox.rb
|
|
55
60
|
- lib/stimulus_plumbers/components/combobox/autocomplete.rb
|
|
56
61
|
- lib/stimulus_plumbers/components/combobox/date.rb
|
|
57
62
|
- lib/stimulus_plumbers/components/combobox/dropdown.rb
|
|
58
|
-
- lib/stimulus_plumbers/components/combobox/
|
|
59
|
-
- lib/stimulus_plumbers/components/combobox/
|
|
60
|
-
- lib/stimulus_plumbers/components/combobox/
|
|
63
|
+
- lib/stimulus_plumbers/components/combobox/options.rb
|
|
64
|
+
- lib/stimulus_plumbers/components/combobox/options/option.rb
|
|
65
|
+
- lib/stimulus_plumbers/components/combobox/options/option_group.rb
|
|
66
|
+
- lib/stimulus_plumbers/components/combobox/popover.rb
|
|
61
67
|
- lib/stimulus_plumbers/components/combobox/time.rb
|
|
68
|
+
- lib/stimulus_plumbers/components/combobox/time/drum.rb
|
|
69
|
+
- lib/stimulus_plumbers/components/combobox/trigger.rb
|
|
62
70
|
- lib/stimulus_plumbers/components/date_picker/navigation.rb
|
|
63
71
|
- lib/stimulus_plumbers/components/date_picker/navigator.rb
|
|
64
|
-
- lib/stimulus_plumbers/components/icon
|
|
65
|
-
- lib/stimulus_plumbers/components/
|
|
66
|
-
- lib/stimulus_plumbers/components/
|
|
67
|
-
- lib/stimulus_plumbers/components/plumber/html_options.rb
|
|
68
|
-
- lib/stimulus_plumbers/components/plumber/renderer.rb
|
|
69
|
-
- lib/stimulus_plumbers/components/popover/renderer.rb
|
|
70
|
-
- lib/stimulus_plumbers/components/time_picker/renderer.rb
|
|
72
|
+
- lib/stimulus_plumbers/components/icon.rb
|
|
73
|
+
- lib/stimulus_plumbers/components/popover.rb
|
|
74
|
+
- lib/stimulus_plumbers/components/popover/builder.rb
|
|
71
75
|
- lib/stimulus_plumbers/configuration.rb
|
|
72
76
|
- lib/stimulus_plumbers/engine.rb
|
|
73
77
|
- lib/stimulus_plumbers/form/builder.rb
|
|
74
|
-
- lib/stimulus_plumbers/form/
|
|
78
|
+
- lib/stimulus_plumbers/form/field.rb
|
|
75
79
|
- lib/stimulus_plumbers/form/fields/choice.rb
|
|
76
80
|
- lib/stimulus_plumbers/form/fields/combobox.rb
|
|
81
|
+
- lib/stimulus_plumbers/form/fields/error.rb
|
|
77
82
|
- lib/stimulus_plumbers/form/fields/file.rb
|
|
83
|
+
- lib/stimulus_plumbers/form/fields/group.rb
|
|
84
|
+
- lib/stimulus_plumbers/form/fields/hint.rb
|
|
85
|
+
- lib/stimulus_plumbers/form/fields/label.rb
|
|
78
86
|
- lib/stimulus_plumbers/form/fields/password.rb
|
|
79
87
|
- lib/stimulus_plumbers/form/fields/renderer.rb
|
|
80
88
|
- lib/stimulus_plumbers/form/fields/search.rb
|
|
81
89
|
- lib/stimulus_plumbers/form/fields/select.rb
|
|
90
|
+
- lib/stimulus_plumbers/form/fields/submit.rb
|
|
82
91
|
- lib/stimulus_plumbers/form/fields/text.rb
|
|
83
92
|
- lib/stimulus_plumbers/form/fields/text_area.rb
|
|
84
93
|
- lib/stimulus_plumbers/helpers.rb
|
|
@@ -92,23 +101,20 @@ files:
|
|
|
92
101
|
- lib/stimulus_plumbers/helpers/plumber_helper.rb
|
|
93
102
|
- lib/stimulus_plumbers/helpers/popover_helper.rb
|
|
94
103
|
- lib/stimulus_plumbers/logger.rb
|
|
104
|
+
- lib/stimulus_plumbers/plumber/base.rb
|
|
105
|
+
- lib/stimulus_plumbers/plumber/dispatcher.rb
|
|
106
|
+
- lib/stimulus_plumbers/plumber/dispatcher/callable_inspector.rb
|
|
107
|
+
- lib/stimulus_plumbers/plumber/dispatcher/instance_exec.rb
|
|
108
|
+
- lib/stimulus_plumbers/plumber/dispatcher/klass_proxy.rb
|
|
109
|
+
- lib/stimulus_plumbers/plumber/dispatcher/method_call.rb
|
|
110
|
+
- lib/stimulus_plumbers/plumber/html_options.rb
|
|
111
|
+
- lib/stimulus_plumbers/plumber/renderer.rb
|
|
95
112
|
- lib/stimulus_plumbers/themes/base.rb
|
|
96
|
-
- lib/stimulus_plumbers/themes/
|
|
97
|
-
- lib/stimulus_plumbers/themes/
|
|
98
|
-
- lib/stimulus_plumbers/themes/
|
|
99
|
-
- lib/stimulus_plumbers/themes/
|
|
100
|
-
- lib/stimulus_plumbers/themes/base/card.rb
|
|
101
|
-
- lib/stimulus_plumbers/themes/base/form.rb
|
|
102
|
-
- lib/stimulus_plumbers/themes/base/layout.rb
|
|
113
|
+
- lib/stimulus_plumbers/themes/configuration.rb
|
|
114
|
+
- lib/stimulus_plumbers/themes/schema.rb
|
|
115
|
+
- lib/stimulus_plumbers/themes/schema/form/ranges.rb
|
|
116
|
+
- lib/stimulus_plumbers/themes/schema/icon.rb
|
|
103
117
|
- lib/stimulus_plumbers/themes/schema/ranges.rb
|
|
104
|
-
- lib/stimulus_plumbers/themes/tailwind/action_list.rb
|
|
105
|
-
- lib/stimulus_plumbers/themes/tailwind/avatar.rb
|
|
106
|
-
- lib/stimulus_plumbers/themes/tailwind/button.rb
|
|
107
|
-
- lib/stimulus_plumbers/themes/tailwind/calendar.rb
|
|
108
|
-
- lib/stimulus_plumbers/themes/tailwind/card.rb
|
|
109
|
-
- lib/stimulus_plumbers/themes/tailwind/form.rb
|
|
110
|
-
- lib/stimulus_plumbers/themes/tailwind/layout.rb
|
|
111
|
-
- lib/stimulus_plumbers/themes/tailwind_theme.rb
|
|
112
118
|
- lib/stimulus_plumbers/version.rb
|
|
113
119
|
homepage: https://github.com/ryancyq/stimulus-plumbers
|
|
114
120
|
licenses:
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module StimulusPlumbers
|
|
4
|
-
module Components
|
|
5
|
-
module ActionList
|
|
6
|
-
class Renderer < Plumber::Base
|
|
7
|
-
def list(**kwargs, &block)
|
|
8
|
-
html_options = merge_html_options(
|
|
9
|
-
{ classes: theme.resolve(:action_list).fetch(:classes, "") },
|
|
10
|
-
kwargs
|
|
11
|
-
)
|
|
12
|
-
template.content_tag(:div, template.capture(&block), **html_options)
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def section(title: nil, **kwargs, &block)
|
|
16
|
-
html_options = merge_html_options(kwargs)
|
|
17
|
-
template.content_tag(:div, **html_options) do
|
|
18
|
-
template.safe_join(
|
|
19
|
-
[
|
|
20
|
-
(template.content_tag(:p, title) if title.present?),
|
|
21
|
-
template.content_tag(:ul, template.capture(&block))
|
|
22
|
-
].compact
|
|
23
|
-
)
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def item(content = nil, url: nil, external: false, active: false, **kwargs, &block)
|
|
28
|
-
content = template.capture(&block) if block_given?
|
|
29
|
-
html_options = merge_html_options(
|
|
30
|
-
{ classes: theme.resolve(:action_list_item, active: active).fetch(:classes, "") },
|
|
31
|
-
kwargs
|
|
32
|
-
)
|
|
33
|
-
|
|
34
|
-
inner = if url
|
|
35
|
-
html_options[:target] = "_blank" if external
|
|
36
|
-
template.content_tag(:a, content, href: url, **html_options)
|
|
37
|
-
else
|
|
38
|
-
html_options[:type] ||= "button"
|
|
39
|
-
template.content_tag(:button, content, **html_options)
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
template.content_tag(:li, inner)
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
end
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module StimulusPlumbers
|
|
4
|
-
module Components
|
|
5
|
-
module Avatar
|
|
6
|
-
class Renderer < Plumber::Base
|
|
7
|
-
def avatar(name: nil, initials: nil, url: nil, color: nil, size: :md, **kwargs, &block)
|
|
8
|
-
color_css = resolve_color(color, name, initials) unless url || block_given?
|
|
9
|
-
|
|
10
|
-
html_options = merge_html_options(
|
|
11
|
-
{
|
|
12
|
-
classes: [theme.resolve(:avatar, size: size).fetch(:classes, ""), color_css],
|
|
13
|
-
"aria-label": name,
|
|
14
|
-
role: "img"
|
|
15
|
-
},
|
|
16
|
-
kwargs
|
|
17
|
-
)
|
|
18
|
-
|
|
19
|
-
template.content_tag(:span, inner(name, initials, url, &block), **html_options)
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
private
|
|
23
|
-
|
|
24
|
-
def inner(name, initials, url, &block)
|
|
25
|
-
if block_given?
|
|
26
|
-
template.capture(&block)
|
|
27
|
-
elsif url
|
|
28
|
-
template.tag.img(src: url, alt: name.present? ? "#{name}'s avatar" : "", onerror: "this.src=''")
|
|
29
|
-
elsif initials
|
|
30
|
-
initials_svg(initials)
|
|
31
|
-
else
|
|
32
|
-
fallback_svg
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
def resolve_color(color, name, initials)
|
|
37
|
-
if color
|
|
38
|
-
theme.avatar_colors.fetch(color, nil)
|
|
39
|
-
elsif (seed = name || initials)
|
|
40
|
-
theme.avatar_color_range[seed.bytes.reduce(:^) % theme.avatar_color_range.length]
|
|
41
|
-
else
|
|
42
|
-
theme.avatar_color_range.first
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
def initials_svg(initials)
|
|
47
|
-
template.content_tag(:svg, viewBox: "0 0 40 40") do
|
|
48
|
-
template.content_tag(
|
|
49
|
-
:text,
|
|
50
|
-
initials.upcase,
|
|
51
|
-
x: "50%",
|
|
52
|
-
y: "50%",
|
|
53
|
-
dy: "0.35em",
|
|
54
|
-
fill: "currentColor",
|
|
55
|
-
"font-size": "20",
|
|
56
|
-
"text-anchor": "middle"
|
|
57
|
-
)
|
|
58
|
-
end
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
def fallback_svg
|
|
62
|
-
template.content_tag(:svg, viewBox: "0 0 40 40") do
|
|
63
|
-
template.tag.path(
|
|
64
|
-
fill: "currentColor",
|
|
65
|
-
d: "M8.28 27.5A14.95 14.95 0 0120 21.8c4.76 0 8.97 2.24 11.72 5.7a14.02 " \
|
|
66
|
-
"14.02 0 01-8.25 5.91 14.82 14.82 0 01-6.94 0 14.02 14.02 0 01-8.25-5.9z" \
|
|
67
|
-
"M13.99 12.78a6.02 6.02 0 1112.03 0 6.02 6.02 0 01-12.03 0z"
|
|
68
|
-
)
|
|
69
|
-
end
|
|
70
|
-
end
|
|
71
|
-
end
|
|
72
|
-
end
|
|
73
|
-
end
|
|
74
|
-
end
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module StimulusPlumbers
|
|
4
|
-
module Components
|
|
5
|
-
module Button
|
|
6
|
-
class Renderer < Plumber::Base
|
|
7
|
-
def button(content = nil, url: nil, external: false, variant: :primary, size: :md, **kwargs, &block)
|
|
8
|
-
content = template.capture(&block) if block_given?
|
|
9
|
-
html_options = merge_html_options(
|
|
10
|
-
{ classes: theme.resolve(:button, variant: variant, size: size).fetch(:classes, "") },
|
|
11
|
-
kwargs
|
|
12
|
-
)
|
|
13
|
-
|
|
14
|
-
if url
|
|
15
|
-
html_options[:target] = "_blank" if external
|
|
16
|
-
template.content_tag(:a, content, href: url, **html_options)
|
|
17
|
-
else
|
|
18
|
-
html_options[:type] ||= "button"
|
|
19
|
-
template.content_tag(:button, content, **html_options)
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def group(alignment: :left, direction: :row, **kwargs, &block)
|
|
24
|
-
html_options = merge_html_options(
|
|
25
|
-
{ classes: theme.resolve(:button_group, alignment: alignment, direction: direction).fetch(:classes, "") },
|
|
26
|
-
kwargs
|
|
27
|
-
)
|
|
28
|
-
template.content_tag(:div, template.capture(&block), **html_options)
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
end
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module StimulusPlumbers
|
|
4
|
-
module Components
|
|
5
|
-
module Calendar
|
|
6
|
-
module Month
|
|
7
|
-
module Turbo
|
|
8
|
-
class Renderer < Plumber::Base
|
|
9
|
-
STIMULUS_CONTROLLER = "calendar-month-observer"
|
|
10
|
-
|
|
11
|
-
def render(
|
|
12
|
-
date: Date.today,
|
|
13
|
-
today: Date.today,
|
|
14
|
-
selectable: false,
|
|
15
|
-
selected_date: nil,
|
|
16
|
-
show_other_months: false,
|
|
17
|
-
**kwargs
|
|
18
|
-
)
|
|
19
|
-
html_options = merge_html_options(
|
|
20
|
-
{
|
|
21
|
-
classes: theme.resolve(:calendar).fetch(:classes, ""),
|
|
22
|
-
data: { controller: STIMULUS_CONTROLLER, action: "click->#{STIMULUS_CONTROLLER}#select" }
|
|
23
|
-
},
|
|
24
|
-
kwargs
|
|
25
|
-
)
|
|
26
|
-
|
|
27
|
-
template.content_tag(:div, role: "grid", **html_options) do
|
|
28
|
-
template.safe_join(
|
|
29
|
-
[
|
|
30
|
-
days_of_week,
|
|
31
|
-
days_of_month(
|
|
32
|
-
date: date,
|
|
33
|
-
today: today,
|
|
34
|
-
selectable: selectable,
|
|
35
|
-
selected_date: selected_date,
|
|
36
|
-
show_other_months: show_other_months
|
|
37
|
-
)
|
|
38
|
-
]
|
|
39
|
-
)
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
private
|
|
44
|
-
|
|
45
|
-
def days_of_week(**kwargs)
|
|
46
|
-
DaysOfWeek.new(template).render(**kwargs)
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
def days_of_month(**kwargs)
|
|
50
|
-
DaysOfMonth.new(template, **kwargs).render
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
end
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module StimulusPlumbers
|
|
4
|
-
module Components
|
|
5
|
-
module Calendar
|
|
6
|
-
class Renderer < Plumber::Base
|
|
7
|
-
STIMULUS_CONTROLLER = "calendar-month"
|
|
8
|
-
OBSERVER_STIMULUS_CONTROLLER = "calendar-month-observer"
|
|
9
|
-
STIMULUS_DATA = {
|
|
10
|
-
controller: "#{STIMULUS_CONTROLLER} #{OBSERVER_STIMULUS_CONTROLLER}",
|
|
11
|
-
action: "click->#{OBSERVER_STIMULUS_CONTROLLER}#select"
|
|
12
|
-
}.freeze
|
|
13
|
-
|
|
14
|
-
def month(**kwargs)
|
|
15
|
-
html_options = merge_html_options(
|
|
16
|
-
{ classes: theme.resolve(:calendar).fetch(:classes, ""), data: STIMULUS_DATA },
|
|
17
|
-
kwargs
|
|
18
|
-
)
|
|
19
|
-
|
|
20
|
-
template.content_tag(:div, role: "grid", **html_options) do
|
|
21
|
-
template.safe_join(
|
|
22
|
-
[
|
|
23
|
-
template.tag.div(data: { "#{STIMULUS_CONTROLLER}-target" => "daysOfWeek" }),
|
|
24
|
-
template.tag.div(
|
|
25
|
-
role: "rowgroup",
|
|
26
|
-
data: { "#{STIMULUS_CONTROLLER}-target" => "daysOfMonth" }
|
|
27
|
-
)
|
|
28
|
-
]
|
|
29
|
-
)
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
end
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module StimulusPlumbers
|
|
4
|
-
module Components
|
|
5
|
-
module Card
|
|
6
|
-
class Renderer < Plumber::Base
|
|
7
|
-
def card(title: nil, **kwargs, &block)
|
|
8
|
-
html_options = merge_html_options(
|
|
9
|
-
{ classes: theme.resolve(:card).fetch(:classes, "") },
|
|
10
|
-
kwargs
|
|
11
|
-
)
|
|
12
|
-
|
|
13
|
-
template.content_tag(:div, **html_options) do
|
|
14
|
-
template.safe_join(
|
|
15
|
-
[
|
|
16
|
-
(template.content_tag(:h2, title) if title.present?),
|
|
17
|
-
template.capture(&block)
|
|
18
|
-
].compact
|
|
19
|
-
)
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def section(title: nil, **kwargs, &block)
|
|
24
|
-
html_options = merge_html_options(
|
|
25
|
-
{ classes: theme.resolve(:card_section).fetch(:classes, "") },
|
|
26
|
-
kwargs
|
|
27
|
-
)
|
|
28
|
-
|
|
29
|
-
template.content_tag(:div, **html_options) do
|
|
30
|
-
template.safe_join(
|
|
31
|
-
[
|
|
32
|
-
(template.content_tag(:h3, title) if title.present?),
|
|
33
|
-
template.capture(&block)
|
|
34
|
-
].compact
|
|
35
|
-
)
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
end
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module StimulusPlumbers
|
|
4
|
-
module Components
|
|
5
|
-
module Combobox
|
|
6
|
-
class Option < Plumber::Base
|
|
7
|
-
def render(label:, value:, description: nil, disabled: false, selected: false)
|
|
8
|
-
aria = { selected: selected ? "true" : "false" }
|
|
9
|
-
aria[:disabled] = "true" if disabled
|
|
10
|
-
|
|
11
|
-
template.content_tag(:li, role: "option", aria: aria, data: { value: value }) do
|
|
12
|
-
if description
|
|
13
|
-
template.safe_join(
|
|
14
|
-
[
|
|
15
|
-
template.content_tag(:span, label),
|
|
16
|
-
template.content_tag(:span, description)
|
|
17
|
-
]
|
|
18
|
-
)
|
|
19
|
-
else
|
|
20
|
-
label
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
end
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module StimulusPlumbers
|
|
4
|
-
module Components
|
|
5
|
-
module Combobox
|
|
6
|
-
module OptionGroup
|
|
7
|
-
private
|
|
8
|
-
|
|
9
|
-
def render_items(items, value: nil)
|
|
10
|
-
@selected_value = value.to_s
|
|
11
|
-
template.safe_join(items.map { |item| render_item(item) })
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def render_item(item)
|
|
15
|
-
case item
|
|
16
|
-
when Hash
|
|
17
|
-
item.key?(:options) ? render_group(item[:label], item[:options]) : render_option_hash(item)
|
|
18
|
-
else
|
|
19
|
-
render_option(item[0], item[1].to_s, item[2] || {})
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def render_option_hash(item)
|
|
24
|
-
render_option(item[:label], item[:value].to_s, item.except(:label, :value))
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def render_option(label, value, attrs = {})
|
|
28
|
-
Option.new(template).render(
|
|
29
|
-
label: label,
|
|
30
|
-
value: value,
|
|
31
|
-
selected: @selected_value == value,
|
|
32
|
-
disabled: attrs[:disabled] || false,
|
|
33
|
-
description: attrs[:description]
|
|
34
|
-
)
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def render_group(label, options)
|
|
38
|
-
template.content_tag(:li, role: "group", aria: { label: label }) do
|
|
39
|
-
template.safe_join(
|
|
40
|
-
[
|
|
41
|
-
template.content_tag(:span, label, aria: { hidden: "true" }),
|
|
42
|
-
template.content_tag(:ul) do
|
|
43
|
-
template.safe_join(options.map { |opt| render_item(opt) })
|
|
44
|
-
end
|
|
45
|
-
]
|
|
46
|
-
)
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
end
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module StimulusPlumbers
|
|
4
|
-
module Components
|
|
5
|
-
module Combobox
|
|
6
|
-
class Renderer < Plumber::Base
|
|
7
|
-
STIMULUS_CONTROLLER = "input-combobox"
|
|
8
|
-
FORMAT_CONTROLLER = "input-format"
|
|
9
|
-
FORMAT_ACTION = "input-combobox:changed->input-format#format"
|
|
10
|
-
|
|
11
|
-
def render(base_id:, options: {}, **kwargs)
|
|
12
|
-
popover_id = "#{base_id}_popover"
|
|
13
|
-
initial_value = options.dig(:input, :value)
|
|
14
|
-
|
|
15
|
-
base_data = {
|
|
16
|
-
controller: "#{STIMULUS_CONTROLLER} #{FORMAT_CONTROLLER}",
|
|
17
|
-
action: FORMAT_ACTION
|
|
18
|
-
}
|
|
19
|
-
base_data[:input_combobox_value_value] = initial_value if initial_value.present?
|
|
20
|
-
|
|
21
|
-
html_options = merge_html_options({ data: base_data }, kwargs)
|
|
22
|
-
|
|
23
|
-
template.content_tag(:div, **html_options) do
|
|
24
|
-
template.safe_join(
|
|
25
|
-
[
|
|
26
|
-
trigger_input(
|
|
27
|
-
popover_id,
|
|
28
|
-
options.dig(:popover, :haspopup) || options.dig(:popover, :role) || "dialog",
|
|
29
|
-
options.fetch(:trigger, {})
|
|
30
|
-
),
|
|
31
|
-
hidden_input(options.fetch(:input, {})),
|
|
32
|
-
popover_element(popover_id, options.fetch(:popover, {}))
|
|
33
|
-
]
|
|
34
|
-
)
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
private
|
|
39
|
-
|
|
40
|
-
def trigger_input(popover_id, haspopup, opts)
|
|
41
|
-
base_data = {
|
|
42
|
-
"#{STIMULUS_CONTROLLER}_target": "trigger",
|
|
43
|
-
input_format_target: "input",
|
|
44
|
-
action: "focus->#{STIMULUS_CONTROLLER}#open keydown.esc->#{STIMULUS_CONTROLLER}#close"
|
|
45
|
-
}
|
|
46
|
-
data = merge_data_options(base_data, opts.fetch(:data, {}).symbolize_keys)
|
|
47
|
-
|
|
48
|
-
aria = { haspopup: haspopup, expanded: "false", controls: popover_id }
|
|
49
|
-
aria[:autocomplete] = opts[:aria_autocomplete] if opts[:aria_autocomplete]
|
|
50
|
-
aria[:label] = opts[:aria_label] if opts[:aria_label]
|
|
51
|
-
|
|
52
|
-
template.tag.input(
|
|
53
|
-
type: "text",
|
|
54
|
-
readonly: (opts.fetch(:readonly, true) ? true : nil),
|
|
55
|
-
role: "combobox",
|
|
56
|
-
aria: aria,
|
|
57
|
-
data: data
|
|
58
|
-
)
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
def hidden_input(opts)
|
|
62
|
-
data = { "#{STIMULUS_CONTROLLER}_target": "value" }.merge(opts.fetch(:data, {}))
|
|
63
|
-
template.tag.input(type: "hidden", name: opts[:name], value: opts[:value], data: data)
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
def popover_element(popover_id, opts)
|
|
67
|
-
base_data = { "#{STIMULUS_CONTROLLER}_target": "popover" }
|
|
68
|
-
data = merge_data_options(base_data, (opts[:data] || {}).symbolize_keys)
|
|
69
|
-
|
|
70
|
-
attrs = { id: popover_id, hidden: "", data: data }
|
|
71
|
-
attrs[:role] = opts[:role] if opts[:role]
|
|
72
|
-
attrs[:aria] = { label: opts[:label] } if opts[:label]
|
|
73
|
-
template.content_tag(opts.fetch(:tag, :div), **attrs) { opts[:content] }
|
|
74
|
-
end
|
|
75
|
-
end
|
|
76
|
-
end
|
|
77
|
-
end
|
|
78
|
-
end
|