stimulus_plumbers 0.4.8 → 0.4.9
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 +16 -0
- data/README.md +7 -9
- data/app/assets/javascripts/stimulus-plumbers/controllers.manifest.json +331 -20
- data/app/assets/javascripts/stimulus-plumbers/index.es.js +493 -226
- data/app/assets/javascripts/stimulus-plumbers/index.es.js.map +1 -1
- data/app/assets/javascripts/stimulus-plumbers/index.umd.js +1 -1
- data/app/assets/javascripts/stimulus-plumbers/index.umd.js.map +1 -1
- data/app/assets/stylesheets/stimulus_plumbers/tokens.css +58 -53
- data/docs/architecture.md +0 -2
- data/docs/component/avatar.md +1 -0
- data/docs/component/button.md +1 -0
- data/docs/component/calendar.md +7 -16
- data/docs/component/checklist.md +153 -0
- data/docs/component/icon.md +7 -5
- data/docs/component/indicator.md +55 -0
- data/docs/component/list.md +2 -3
- data/docs/component/ordered_list.md +118 -0
- data/docs/component/plumber.md +21 -0
- data/docs/component/popover.md +1 -2
- data/docs/component/progress.md +65 -0
- data/docs/component/timeline.md +47 -12
- data/docs/guide.md +12 -0
- data/lib/generators/stimulus_plumbers/install/install_generator.rb +16 -12
- data/lib/stimulus_plumbers/components/button.rb +1 -0
- data/lib/stimulus_plumbers/components/checklist/item/slots.rb +13 -0
- data/lib/stimulus_plumbers/components/checklist/item.rb +64 -0
- data/lib/stimulus_plumbers/components/checklist.rb +50 -0
- data/lib/stimulus_plumbers/components/combobox/typeahead.rb +1 -0
- data/lib/stimulus_plumbers/components/icon.rb +2 -2
- data/lib/stimulus_plumbers/components/indicator.rb +30 -0
- data/lib/stimulus_plumbers/components/link.rb +1 -0
- data/lib/stimulus_plumbers/components/ordered_list/item/slots.rb +13 -0
- data/lib/stimulus_plumbers/components/ordered_list/item.rb +129 -0
- data/lib/stimulus_plumbers/components/ordered_list.rb +24 -0
- data/lib/stimulus_plumbers/components/progress_bar.rb +48 -0
- data/lib/stimulus_plumbers/components/progress_meter.rb +37 -0
- data/lib/stimulus_plumbers/components/progress_ring.rb +40 -0
- data/lib/stimulus_plumbers/components/timeline/event.rb +2 -1
- data/lib/stimulus_plumbers/components/timeline/group.rb +5 -3
- data/lib/stimulus_plumbers/form/fields/inputs/password.rb +1 -0
- data/lib/stimulus_plumbers/form/fields/inputs/search.rb +1 -0
- data/lib/stimulus_plumbers/generators/css_entrypoint.rb +15 -9
- data/lib/stimulus_plumbers/generators/tokens_directive.rb +6 -2
- data/lib/stimulus_plumbers/helpers/avatar_helper.rb +1 -7
- data/lib/stimulus_plumbers/helpers/button_helper.rb +1 -7
- data/lib/stimulus_plumbers/helpers/calendar_helper.rb +2 -9
- data/lib/stimulus_plumbers/helpers/calendar_turbo_helper.rb +3 -6
- data/lib/stimulus_plumbers/helpers/checklist_helper.rb +11 -0
- data/lib/stimulus_plumbers/helpers/indicator_helper.rb +11 -0
- data/lib/stimulus_plumbers/helpers/ordered_list_helper.rb +11 -0
- data/lib/stimulus_plumbers/helpers/popover_helper.rb +1 -7
- data/lib/stimulus_plumbers/helpers/progress_helper.rb +21 -0
- data/lib/stimulus_plumbers/helpers.rb +8 -0
- data/lib/stimulus_plumbers/themes/base.rb +4 -0
- data/lib/stimulus_plumbers/themes/schema/icon.rb +21 -4
- data/lib/stimulus_plumbers/themes/schema/indicator/ranges.rb +14 -0
- data/lib/stimulus_plumbers/themes/schema.rb +39 -3
- data/lib/stimulus_plumbers/version.rb +1 -1
- data/lib/stimulus_plumbers.rb +10 -0
- data/vendor/ARIA.md +22 -2
- data/vendor/component/manifest.json +212 -0
- data/vendor/controller/docs/calendar.md +4 -7
- data/vendor/controller/docs/checklist.md +45 -0
- data/vendor/controller/docs/combobox.md +1 -31
- data/vendor/controller/docs/input-clearable.md +1 -4
- data/vendor/controller/docs/input-formatter.md +1 -2
- data/vendor/controller/docs/modal.md +1 -4
- data/vendor/controller/docs/popover.md +1 -3
- data/vendor/controller/docs/progress.md +82 -0
- data/vendor/controller/docs/reorderable.md +82 -0
- data/vendor/controller/docs/visibility.md +31 -0
- data/vendor/controller/manifest.json +331 -20
- metadata +25 -1
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module StimulusPlumbers
|
|
4
|
+
module Components
|
|
5
|
+
class ProgressRing < Plumber::Base
|
|
6
|
+
def render(...) = render_ring(...)
|
|
7
|
+
|
|
8
|
+
private
|
|
9
|
+
|
|
10
|
+
def render_ring(value:, max: 100, min: 0, indeterminate: false, **kwargs)
|
|
11
|
+
icon_options = merge_html_options(
|
|
12
|
+
theme.resolve(:progress_ring),
|
|
13
|
+
kwargs,
|
|
14
|
+
stimulus_data(value: value, min: min, max: max, indeterminate: indeterminate),
|
|
15
|
+
{ role: "progressbar", aria: progress_aria(value: value, min: min, max: max, indeterminate: indeterminate) }
|
|
16
|
+
)
|
|
17
|
+
Components::Icon.new(template).render(name: "progress-ring", **icon_options)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def progress_aria(value:, min:, max:, indeterminate:)
|
|
21
|
+
aria = { valuemin: min, valuemax: max }
|
|
22
|
+
aria[:valuenow] = value unless indeterminate
|
|
23
|
+
aria
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def stimulus_data(value:, min:, max:, indeterminate:)
|
|
27
|
+
{
|
|
28
|
+
data: {
|
|
29
|
+
controller: "progress",
|
|
30
|
+
"progress-variant-value": "ring",
|
|
31
|
+
"progress-current-value": value,
|
|
32
|
+
"progress-min-value": min,
|
|
33
|
+
"progress-max-value": max,
|
|
34
|
+
"progress-indeterminate-value": indeterminate
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -107,11 +107,12 @@ module StimulusPlumbers
|
|
|
107
107
|
if type == :icon && icon_name
|
|
108
108
|
Components::Icon.new(template).render(
|
|
109
109
|
name: icon_name,
|
|
110
|
+
size: :sm,
|
|
110
111
|
classes: theme.resolve(:timeline_item_indicator_icon_slot).fetch(:classes, ""),
|
|
111
112
|
aria: { hidden: "true" }
|
|
112
113
|
)
|
|
113
114
|
else
|
|
114
|
-
template.
|
|
115
|
+
Components::Indicator.new(template).render(type: :dot, variant: :primary)
|
|
115
116
|
end
|
|
116
117
|
end
|
|
117
118
|
|
|
@@ -4,7 +4,8 @@ module StimulusPlumbers
|
|
|
4
4
|
module Components
|
|
5
5
|
class Timeline
|
|
6
6
|
class Group < Plumber::Base
|
|
7
|
-
def render(**kwargs, &block)
|
|
7
|
+
def render(orientation: :vertical, **kwargs, &block)
|
|
8
|
+
@orientation = orientation
|
|
8
9
|
content = template.capture(self, &block)
|
|
9
10
|
html_options = merge_html_options(theme.resolve(:timeline_group), kwargs)
|
|
10
11
|
template.content_tag(:div, content, **html_options)
|
|
@@ -12,7 +13,7 @@ module StimulusPlumbers
|
|
|
12
13
|
|
|
13
14
|
def section(date:, datetime: nil, **kwargs, &block)
|
|
14
15
|
inner_tl = Timeline.new(template)
|
|
15
|
-
inner_tl.instance_variable_set(:@orientation,
|
|
16
|
+
inner_tl.instance_variable_set(:@orientation, @orientation)
|
|
16
17
|
inner_tl.instance_variable_set(:@interactive, false)
|
|
17
18
|
|
|
18
19
|
events_html = template.capture(inner_tl, &block)
|
|
@@ -29,10 +30,11 @@ module StimulusPlumbers
|
|
|
29
30
|
theme.resolve(:timeline_group_section_date),
|
|
30
31
|
datetime ? { datetime: datetime } : {}
|
|
31
32
|
)
|
|
33
|
+
list_attrs = merge_html_options(theme.resolve(:timeline_group_section_list, orientation: @orientation))
|
|
32
34
|
template.safe_join(
|
|
33
35
|
[
|
|
34
36
|
template.content_tag(:time, date, **date_attrs),
|
|
35
|
-
template.content_tag(:ol, events_html, **
|
|
37
|
+
template.content_tag(:ol, events_html, **list_attrs)
|
|
36
38
|
]
|
|
37
39
|
)
|
|
38
40
|
end
|
|
@@ -3,13 +3,21 @@
|
|
|
3
3
|
module StimulusPlumbers
|
|
4
4
|
module Generators
|
|
5
5
|
module CssEntrypoint
|
|
6
|
-
|
|
6
|
+
STIMULUS_PLUMBERS_CSS_ENTRY = "STIMULUS_PLUMBERS_CSS_ENTRY"
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
# Shared with stimulus_plumbers_tailwind's InstallGenerator — checked in order,
|
|
9
|
+
# each path is another gem/tool's own default entry file. Detection is theme-
|
|
10
|
+
# agnostic: any of these may be the CSS entry regardless of which theme is active.
|
|
11
|
+
ENTRY_CANDIDATES = [
|
|
12
|
+
"app/assets/stylesheets/application.tailwind.css", # tailwindcss-rails 2.x default
|
|
13
|
+
"app/assets/tailwind/application.css", # tailwindcss-rails 3.x+ default
|
|
14
|
+
"app/assets/stylesheets/application.css", # Rails/Propshaft default manifest
|
|
15
|
+
"app/javascript/entrypoints/application.css" # jsbundling-rails (esbuild/webpack) default
|
|
16
|
+
].freeze
|
|
11
17
|
|
|
12
|
-
|
|
18
|
+
def entry_css_file(candidates:, env_var:)
|
|
19
|
+
if ENV[env_var]
|
|
20
|
+
path = File.expand_path(ENV.fetch(env_var, nil))
|
|
13
21
|
return path if File.exist?(path)
|
|
14
22
|
end
|
|
15
23
|
|
|
@@ -18,11 +26,9 @@ module StimulusPlumbers
|
|
|
18
26
|
.find { |f| File.exist?(f) }
|
|
19
27
|
end
|
|
20
28
|
|
|
21
|
-
def warn_entry_css_not_found(candidates:, env_var:, label
|
|
29
|
+
def warn_entry_css_not_found(candidates:, env_var:, label:)
|
|
22
30
|
tried = candidates.map { |c| File.join(destination_root, c) }
|
|
23
|
-
[env_var
|
|
24
|
-
tried.unshift(File.expand_path(ENV[var])) if ENV[var]
|
|
25
|
-
end
|
|
31
|
+
tried.unshift(File.expand_path(ENV[env_var])) if ENV[env_var]
|
|
26
32
|
say "Could not find a #{label} entry file. Tried: #{tried.join(", ")}. " \
|
|
27
33
|
"Set #{env_var}=/path/to/entry.css and re-run.",
|
|
28
34
|
:red
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require "pathname"
|
|
4
|
+
|
|
3
5
|
module StimulusPlumbers
|
|
4
6
|
module Generators
|
|
5
7
|
module TokensDirective
|
|
@@ -8,8 +10,10 @@ module StimulusPlumbers
|
|
|
8
10
|
|
|
9
11
|
module_function
|
|
10
12
|
|
|
11
|
-
def directive
|
|
12
|
-
|
|
13
|
+
def directive(from:)
|
|
14
|
+
path = Pathname.new(GEM_ROOT).join(TOKENS_CSS_REL_PATH)
|
|
15
|
+
rel = path.relative_path_from(Pathname.new(from))
|
|
16
|
+
%(@import "#{rel}";)
|
|
13
17
|
end
|
|
14
18
|
|
|
15
19
|
def stale_pattern
|
|
@@ -4,13 +4,7 @@ module StimulusPlumbers
|
|
|
4
4
|
module Helpers
|
|
5
5
|
module AvatarHelper
|
|
6
6
|
def sp_avatar(...)
|
|
7
|
-
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
private
|
|
11
|
-
|
|
12
|
-
def avatar_renderer
|
|
13
|
-
Components::Avatar.new(self)
|
|
7
|
+
Components::Avatar.new(self).render(...)
|
|
14
8
|
end
|
|
15
9
|
end
|
|
16
10
|
end
|
|
@@ -4,18 +4,12 @@ module StimulusPlumbers
|
|
|
4
4
|
module Helpers
|
|
5
5
|
module ButtonHelper
|
|
6
6
|
def sp_button(content = nil, **kwargs, &block)
|
|
7
|
-
|
|
7
|
+
Components::Button.new(self).render(content, **kwargs, &block)
|
|
8
8
|
end
|
|
9
9
|
|
|
10
10
|
def sp_button_group(...)
|
|
11
11
|
Components::Button::Group.new(self).render(...)
|
|
12
12
|
end
|
|
13
|
-
|
|
14
|
-
private
|
|
15
|
-
|
|
16
|
-
def button_renderer
|
|
17
|
-
Components::Button.new(self)
|
|
18
|
-
end
|
|
19
13
|
end
|
|
20
14
|
end
|
|
21
15
|
end
|
|
@@ -9,20 +9,13 @@ module StimulusPlumbers
|
|
|
9
9
|
kwargs.deep_merge(
|
|
10
10
|
data: {
|
|
11
11
|
"calendar-month-year-value": date.year,
|
|
12
|
-
"calendar-month-month-value": date.month - 1
|
|
13
|
-
"calendar-month-day-value": date.day
|
|
12
|
+
"calendar-month-month-value": date.month - 1
|
|
14
13
|
}
|
|
15
14
|
)
|
|
16
15
|
else
|
|
17
16
|
kwargs
|
|
18
17
|
end
|
|
19
|
-
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
private
|
|
23
|
-
|
|
24
|
-
def calendar_renderer
|
|
25
|
-
Components::Calendar.new(self)
|
|
18
|
+
Components::Calendar.new(self).month(**html_options)
|
|
26
19
|
end
|
|
27
20
|
end
|
|
28
21
|
end
|
|
@@ -31,8 +31,7 @@ module StimulusPlumbers
|
|
|
31
31
|
[
|
|
32
32
|
content_tag(
|
|
33
33
|
:turbo_frame,
|
|
34
|
-
id:
|
|
35
|
-
data: { "combobox-date-target": "monthView" }
|
|
34
|
+
id: "calendar-month-frame"
|
|
36
35
|
) do
|
|
37
36
|
calendar_turbo_renderer.month(
|
|
38
37
|
date: date,
|
|
@@ -48,8 +47,7 @@ module StimulusPlumbers
|
|
|
48
47
|
content_tag(
|
|
49
48
|
:turbo_frame,
|
|
50
49
|
id: "calendar-year-frame",
|
|
51
|
-
hidden: true
|
|
52
|
-
data: { "combobox-date-target": "yearView" }
|
|
50
|
+
hidden: true
|
|
53
51
|
) do
|
|
54
52
|
calendar_turbo_renderer.year(
|
|
55
53
|
date: date,
|
|
@@ -63,8 +61,7 @@ module StimulusPlumbers
|
|
|
63
61
|
content_tag(
|
|
64
62
|
:turbo_frame,
|
|
65
63
|
id: "calendar-decade-frame",
|
|
66
|
-
hidden: true
|
|
67
|
-
data: { "combobox-date-target": "decadeView" }
|
|
64
|
+
hidden: true
|
|
68
65
|
) do
|
|
69
66
|
calendar_turbo_renderer.decade(
|
|
70
67
|
date: date,
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module StimulusPlumbers
|
|
4
|
+
module Helpers
|
|
5
|
+
module IndicatorHelper
|
|
6
|
+
def sp_indicator(variant: :primary, type: :dot, pulse: false, **kwargs, &block)
|
|
7
|
+
Components::Indicator.new(self).render(type: type, variant: variant, pulse: pulse, **kwargs, &block)
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
@@ -4,13 +4,7 @@ module StimulusPlumbers
|
|
|
4
4
|
module Helpers
|
|
5
5
|
module PopoverHelper
|
|
6
6
|
def sp_popover(...)
|
|
7
|
-
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
private
|
|
11
|
-
|
|
12
|
-
def popover_renderer
|
|
13
|
-
Components::Popover.new(self)
|
|
7
|
+
Components::Popover.new(self).render(...)
|
|
14
8
|
end
|
|
15
9
|
end
|
|
16
10
|
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module StimulusPlumbers
|
|
4
|
+
module Helpers
|
|
5
|
+
module ProgressHelper
|
|
6
|
+
def sp_progress_bar(value:, min: 0, max: 100, indeterminate: false, **kwargs)
|
|
7
|
+
Components::ProgressBar.new(self).render(value: value, min: min, max: max, indeterminate: indeterminate, **kwargs)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def sp_progress_ring(value:, min: 0, max: 100, indeterminate: false, **kwargs)
|
|
11
|
+
Components::ProgressRing.new(self).render(value: value, min: min, max: max, indeterminate: indeterminate, **kwargs)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def sp_progress_meter(value:, min: 0, max: 100, low: nil, high: nil, optimum: nil, **kwargs)
|
|
15
|
+
Components::ProgressMeter.new(self).render(
|
|
16
|
+
value: value, min: min, max: max, low: low, high: high, optimum: optimum, **kwargs
|
|
17
|
+
)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
require_relative "helpers/plumber_helper"
|
|
4
4
|
require_relative "helpers/icon_helper"
|
|
5
|
+
require_relative "helpers/indicator_helper"
|
|
5
6
|
require_relative "helpers/list_helper"
|
|
7
|
+
require_relative "helpers/checklist_helper"
|
|
8
|
+
require_relative "helpers/ordered_list_helper"
|
|
6
9
|
require_relative "helpers/avatar_helper"
|
|
7
10
|
require_relative "helpers/button_helper"
|
|
8
11
|
require_relative "helpers/calendar_helper"
|
|
@@ -12,13 +15,17 @@ require_relative "helpers/combobox_helper"
|
|
|
12
15
|
require_relative "helpers/divider_helper"
|
|
13
16
|
require_relative "helpers/link_helper"
|
|
14
17
|
require_relative "helpers/popover_helper"
|
|
18
|
+
require_relative "helpers/progress_helper"
|
|
15
19
|
require_relative "helpers/timeline_helper"
|
|
16
20
|
|
|
17
21
|
module StimulusPlumbers
|
|
18
22
|
module Helpers
|
|
19
23
|
include PlumberHelper
|
|
20
24
|
include IconHelper
|
|
25
|
+
include IndicatorHelper
|
|
21
26
|
include ListHelper
|
|
27
|
+
include ChecklistHelper
|
|
28
|
+
include OrderedListHelper
|
|
22
29
|
include AvatarHelper
|
|
23
30
|
include ButtonHelper
|
|
24
31
|
include CalendarHelper
|
|
@@ -28,6 +35,7 @@ module StimulusPlumbers
|
|
|
28
35
|
include DividerHelper
|
|
29
36
|
include LinkHelper
|
|
30
37
|
include PopoverHelper
|
|
38
|
+
include ProgressHelper
|
|
31
39
|
include TimelineHelper
|
|
32
40
|
end
|
|
33
41
|
end
|
|
@@ -8,6 +8,8 @@ module StimulusPlumbers
|
|
|
8
8
|
class Base
|
|
9
9
|
SCHEMA = {
|
|
10
10
|
**Schema::LIST,
|
|
11
|
+
**Schema::CHECKLIST,
|
|
12
|
+
**Schema::ORDERED_LIST,
|
|
11
13
|
**Schema::AVATAR,
|
|
12
14
|
**Schema::BUTTON,
|
|
13
15
|
**Schema::CALENDAR,
|
|
@@ -15,9 +17,11 @@ module StimulusPlumbers
|
|
|
15
17
|
**Schema::COMBOBOX,
|
|
16
18
|
**Schema::FORM,
|
|
17
19
|
**Schema::ICON,
|
|
20
|
+
**Schema::INDICATOR,
|
|
18
21
|
**Schema::INPUT_GROUP,
|
|
19
22
|
**Schema::LAYOUT,
|
|
20
23
|
**Schema::LINK,
|
|
24
|
+
**Schema::PROGRESS,
|
|
21
25
|
**Schema::TIMELINE
|
|
22
26
|
}.freeze
|
|
23
27
|
|
|
@@ -23,7 +23,7 @@ module StimulusPlumbers
|
|
|
23
23
|
|
|
24
24
|
ELEMENT_ATTRS = {
|
|
25
25
|
path: %i[d fill fill_rule clip_rule stroke_linecap stroke_linejoin opacity].freeze,
|
|
26
|
-
circle: %i[cx cy r].freeze,
|
|
26
|
+
circle: %i[cx cy r class stroke stroke_width stroke_linecap].freeze,
|
|
27
27
|
ellipse: %i[cx cy rx ry].freeze,
|
|
28
28
|
rect: %i[x y width height rx ry].freeze,
|
|
29
29
|
line: %i[x1 y1 x2 y2].freeze,
|
|
@@ -64,9 +64,26 @@ module StimulusPlumbers
|
|
|
64
64
|
end
|
|
65
65
|
|
|
66
66
|
def resolve_element_attrs(element_data)
|
|
67
|
-
element_data.
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
element_data.filter_map do |key, value|
|
|
68
|
+
next if key == :tag
|
|
69
|
+
next unless element_attr_allowed?(element_data[:tag], key)
|
|
70
|
+
|
|
71
|
+
[element_attr_name(key), value.to_s]
|
|
72
|
+
end.to_h
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def element_attr_allowed?(tag, key)
|
|
76
|
+
ELEMENT_ATTRS.fetch(tag, []).include?(key) || data_or_aria_attr?(key)
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def element_attr_name(key)
|
|
80
|
+
return key.to_s.tr("_", "-") if data_or_aria_attr?(key)
|
|
81
|
+
|
|
82
|
+
ELEMENT_ATTR_NAMES.fetch(key, key.to_s)
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def data_or_aria_attr?(key)
|
|
86
|
+
key.to_s.start_with?("data_", "aria_")
|
|
70
87
|
end
|
|
71
88
|
end
|
|
72
89
|
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module StimulusPlumbers
|
|
4
|
+
module Themes
|
|
5
|
+
module Schema
|
|
6
|
+
module Indicator
|
|
7
|
+
module Ranges
|
|
8
|
+
TYPE = %i[dot pulse badge].freeze
|
|
9
|
+
VARIANT = %i[primary secondary tertiary success destructive warning info].freeze
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -5,6 +5,7 @@ require_relative "schema/ranges"
|
|
|
5
5
|
require_relative "schema/avatar/ranges"
|
|
6
6
|
require_relative "schema/button/ranges"
|
|
7
7
|
require_relative "schema/card/ranges"
|
|
8
|
+
require_relative "schema/indicator/ranges"
|
|
8
9
|
require_relative "schema/link/ranges"
|
|
9
10
|
require_relative "schema/form/ranges"
|
|
10
11
|
require_relative "schema/form/checkbox/ranges"
|
|
@@ -27,6 +28,24 @@ module StimulusPlumbers
|
|
|
27
28
|
list_item_description: {}.freeze
|
|
28
29
|
}.freeze
|
|
29
30
|
|
|
31
|
+
CHECKLIST = {
|
|
32
|
+
checklist: {}.freeze,
|
|
33
|
+
checklist_item: {}.freeze,
|
|
34
|
+
checklist_item_input: {}.freeze,
|
|
35
|
+
checklist_item_content: {}.freeze,
|
|
36
|
+
checklist_item_title: {}.freeze,
|
|
37
|
+
checklist_item_description: {}.freeze
|
|
38
|
+
}.freeze
|
|
39
|
+
|
|
40
|
+
ORDERED_LIST = {
|
|
41
|
+
ordered_list: {}.freeze,
|
|
42
|
+
ordered_list_item: {}.freeze,
|
|
43
|
+
ordered_list_item_handle: {}.freeze,
|
|
44
|
+
ordered_list_item_content: {}.freeze,
|
|
45
|
+
ordered_list_item_title: {}.freeze,
|
|
46
|
+
ordered_list_item_description: {}.freeze
|
|
47
|
+
}.freeze
|
|
48
|
+
|
|
30
49
|
AVATAR = {
|
|
31
50
|
avatar: {
|
|
32
51
|
size: { default: :md, validate: Avatar::Ranges::SIZE },
|
|
@@ -169,7 +188,16 @@ module StimulusPlumbers
|
|
|
169
188
|
}.freeze
|
|
170
189
|
|
|
171
190
|
ICON = {
|
|
172
|
-
icon: {}.freeze
|
|
191
|
+
icon: { size: { default: :lg, validate: %i[sm md lg] } }.freeze
|
|
192
|
+
}.freeze
|
|
193
|
+
|
|
194
|
+
INDICATOR = {
|
|
195
|
+
indicator: {
|
|
196
|
+
type: { default: :dot, validate: Indicator::Ranges::TYPE },
|
|
197
|
+
variant: { default: :primary, validate: Indicator::Ranges::VARIANT }
|
|
198
|
+
}.freeze,
|
|
199
|
+
indicator_wrapper: {}.freeze,
|
|
200
|
+
indicator_pulse: {}.freeze
|
|
173
201
|
}.freeze
|
|
174
202
|
|
|
175
203
|
INPUT_GROUP = {
|
|
@@ -196,6 +224,13 @@ module StimulusPlumbers
|
|
|
196
224
|
popover: {}.freeze
|
|
197
225
|
}.freeze
|
|
198
226
|
|
|
227
|
+
PROGRESS = {
|
|
228
|
+
progress_bar: {}.freeze,
|
|
229
|
+
progress_bar_fill: {}.freeze,
|
|
230
|
+
progress_ring: {}.freeze,
|
|
231
|
+
progress_meter: {}.freeze
|
|
232
|
+
}.freeze
|
|
233
|
+
|
|
199
234
|
TIMELINE = {
|
|
200
235
|
timeline: {
|
|
201
236
|
orientation: { default: :vertical, validate: %i[vertical horizontal] }
|
|
@@ -216,7 +251,6 @@ module StimulusPlumbers
|
|
|
216
251
|
timeline_item_description: {}.freeze,
|
|
217
252
|
timeline_item_detail: {}.freeze,
|
|
218
253
|
timeline_item_actions: {}.freeze,
|
|
219
|
-
timeline_item_indicator_dot: {}.freeze,
|
|
220
254
|
timeline_item_connector: {}.freeze,
|
|
221
255
|
timeline_item_content: {}.freeze,
|
|
222
256
|
timeline_track_line: {}.freeze,
|
|
@@ -224,7 +258,9 @@ module StimulusPlumbers
|
|
|
224
258
|
timeline_group: {}.freeze,
|
|
225
259
|
timeline_group_section: {}.freeze,
|
|
226
260
|
timeline_group_section_date: {}.freeze,
|
|
227
|
-
timeline_group_section_list: {
|
|
261
|
+
timeline_group_section_list: {
|
|
262
|
+
orientation: { default: :vertical, validate: %i[vertical horizontal] }
|
|
263
|
+
}.freeze
|
|
228
264
|
}.freeze
|
|
229
265
|
end
|
|
230
266
|
end
|
data/lib/stimulus_plumbers.rb
CHANGED
|
@@ -17,6 +17,7 @@ require_relative "stimulus_plumbers/plumber/base"
|
|
|
17
17
|
|
|
18
18
|
# -- UI components --
|
|
19
19
|
require_relative "stimulus_plumbers/components/icon"
|
|
20
|
+
require_relative "stimulus_plumbers/components/indicator"
|
|
20
21
|
require_relative "stimulus_plumbers/components/avatar"
|
|
21
22
|
require_relative "stimulus_plumbers/components/button"
|
|
22
23
|
require_relative "stimulus_plumbers/components/button/slots"
|
|
@@ -25,10 +26,16 @@ require_relative "stimulus_plumbers/components/link"
|
|
|
25
26
|
require_relative "stimulus_plumbers/components/link/slots"
|
|
26
27
|
require_relative "stimulus_plumbers/components/card"
|
|
27
28
|
require_relative "stimulus_plumbers/components/card/slots"
|
|
29
|
+
require_relative "stimulus_plumbers/components/checklist"
|
|
30
|
+
require_relative "stimulus_plumbers/components/checklist/item"
|
|
31
|
+
require_relative "stimulus_plumbers/components/checklist/item/slots"
|
|
28
32
|
require_relative "stimulus_plumbers/components/list"
|
|
29
33
|
require_relative "stimulus_plumbers/components/list/section"
|
|
30
34
|
require_relative "stimulus_plumbers/components/list/item"
|
|
31
35
|
require_relative "stimulus_plumbers/components/list/item/slots"
|
|
36
|
+
require_relative "stimulus_plumbers/components/ordered_list"
|
|
37
|
+
require_relative "stimulus_plumbers/components/ordered_list/item"
|
|
38
|
+
require_relative "stimulus_plumbers/components/ordered_list/item/slots"
|
|
32
39
|
require_relative "stimulus_plumbers/components/timeline"
|
|
33
40
|
require_relative "stimulus_plumbers/components/timeline/event"
|
|
34
41
|
require_relative "stimulus_plumbers/components/timeline/event/slots"
|
|
@@ -38,6 +45,9 @@ require_relative "stimulus_plumbers/components/input_group"
|
|
|
38
45
|
require_relative "stimulus_plumbers/components/popover"
|
|
39
46
|
require_relative "stimulus_plumbers/components/popover/trigger"
|
|
40
47
|
require_relative "stimulus_plumbers/components/popover/panel"
|
|
48
|
+
require_relative "stimulus_plumbers/components/progress_bar"
|
|
49
|
+
require_relative "stimulus_plumbers/components/progress_ring"
|
|
50
|
+
require_relative "stimulus_plumbers/components/progress_meter"
|
|
41
51
|
|
|
42
52
|
# -- Calendar --
|
|
43
53
|
require_relative "stimulus_plumbers/components/calendar"
|
data/vendor/ARIA.md
CHANGED
|
@@ -30,6 +30,7 @@ Two helper classes handle keyboard navigation in controllers — see [`stimulus-
|
|
|
30
30
|
- `role="dialog"`, `aria-modal="true"`, `aria-labelledby` pointing to heading
|
|
31
31
|
- Focus moves into dialog on open; returns to trigger on close
|
|
32
32
|
- Focus trapped inside — Tab/Shift+Tab cycle within; Escape closes
|
|
33
|
+
- Status announcements ("Modal opened"/"Modal closed") via `aria-live` on open/close (WCAG 4.1.3)
|
|
33
34
|
|
|
34
35
|
#### Popover (`popover_controller`)
|
|
35
36
|
- `role="dialog"` or `role="tooltip"` depending on interactivity
|
|
@@ -57,9 +58,15 @@ Two helper classes handle keyboard navigation in controllers — see [`stimulus-
|
|
|
57
58
|
- Invalid fields: `aria-invalid="true"` + `aria-describedby` pointing to error message
|
|
58
59
|
- Error message element: `role="alert"` or `aria-live="polite"` so it's announced
|
|
59
60
|
|
|
60
|
-
#### Password Reveal (`
|
|
61
|
+
#### Password Reveal (`input-formatter_controller`, `"password"` formatter)
|
|
61
62
|
- Toggle button: `aria-label` describes action ("Show password" / "Hide password")
|
|
62
|
-
-
|
|
63
|
+
- `aria-pressed` managed on toggle button, reflecting revealed state
|
|
64
|
+
|
|
65
|
+
#### Input Clearable (`input_clearable_controller`)
|
|
66
|
+
- Clear button: `hidden` attribute while the input is empty, removing it from the keyboard/AT tab order until there's something to clear
|
|
67
|
+
- Escape inside the input clears it (keyboard equivalent to clicking the clear button, WCAG 2.1.1); default is prevented so it doesn't also close a parent overlay
|
|
68
|
+
- Focus returns to the input after clearing (WCAG 2.4.3 Focus Order)
|
|
69
|
+
- No `aria-live` announcement — clearing is user-initiated and the button's disappearance is self-explanatory
|
|
63
70
|
|
|
64
71
|
#### Flipper / Visibility / Dismisser
|
|
65
72
|
- Trigger: `aria-expanded="true/false"` when toggling a region
|
|
@@ -75,6 +82,13 @@ Two helper classes handle keyboard navigation in controllers — see [`stimulus-
|
|
|
75
82
|
- Static list: `role="list"` + `role="listitem"` (explicitly set to preserve semantics when CSS resets strip list role)
|
|
76
83
|
- Active item: `aria-current="page"` on `<a>` links; `aria-current="true"` on `<button>` items — the value differs by element type per the ARIA spec
|
|
77
84
|
|
|
85
|
+
#### Checklist (`checklist_controller`, `sp_checklist`)
|
|
86
|
+
- Each item: native `<input type="checkbox">` inside a `<label>` — role, keyboard activation (Space), focus, and checked-state announcement are all handled by the browser. The component sets no ARIA attributes on items.
|
|
87
|
+
- Read-only item (`readonly: true`): native `disabled` attribute — removes the control from the tab order and announces it as unavailable to assistive tech. No `aria-readonly`/`tabindex` hack.
|
|
88
|
+
- Master "select all" toggle (`select_all:`): same `<input type="checkbox">` shape as an item. Its `indeterminate` property (JS-only, no HTML attribute) is set client-side by the `checklist` controller when some but not all enabled items are checked — modern browsers map `indeterminate` to the accessibility tree's `mixed` checked state automatically, satisfying WCAG 4.1.2 with no manual ARIA.
|
|
89
|
+
- Accepted tradeoff: because `indeterminate` has no HTML attribute, the server can only render the master's initial `checked` state for the all-true case; every other case (including mixed) renders unchecked and is corrected to `indeterminate` once the `checklist` controller connects — a brief, accepted flash for the mixed case only.
|
|
90
|
+
- Disabled (readonly) items are excluded from the master's aggregate and from bulk toggling — the `checklist` controller filters them out via their own `.disabled` property, mirroring their exclusion from tab order and AT interaction.
|
|
91
|
+
|
|
78
92
|
#### Avatar / Card / Icon
|
|
79
93
|
- Decorative images/icons: `aria-hidden="true"` or `alt=""`
|
|
80
94
|
- Meaningful images: descriptive `alt` text
|
|
@@ -86,3 +100,9 @@ Two helper classes handle keyboard navigation in controllers — see [`stimulus-
|
|
|
86
100
|
- Expandable items: trigger `<button>` with `aria-expanded="false/true"` + `aria-controls` → detail element id; detail has `hidden` attribute toggled by controller
|
|
87
101
|
- Trigger lives inside `<h3>` (`<h3><button aria-expanded>Title</button></h3>`) — WAI-ARIA Accordion pattern
|
|
88
102
|
- Keyboard (interactive): Up/Down arrows move focus between item triggers; Home/End jump to first/last trigger; Enter/Space toggle expansion (native button behaviour)
|
|
103
|
+
|
|
104
|
+
#### Reorderable (`reorderable_controller`)
|
|
105
|
+
- Roving tabindex on `item` targets (`RovingTabIndex`) — plain Arrow/Home/End move focus only, unaffected by editing state
|
|
106
|
+
- Keyboard move (`Alt+Arrow` on the axis matching `orientation`, default `ArrowUp`/`ArrowDown`; configurable modifier via `moveKey`; horizontal move-key meaning flips under `dir="rtl"`): moves the focused item, keeps focus on it, announces the new position via `role="status"`/`aria-live` (WCAG 4.1.3) — satisfies the keyboard-equivalent requirement (WCAG 2.1.1) for pointer drag
|
|
107
|
+
- Pointer drag: does not move focus or announce — avoids stealing focus from a mouse user who never asked for it
|
|
108
|
+
- `editingValue` gates both drag and keyboard-move; while `true`, every `trigger` target (`<a>`/`<button>` inside an item) gets `aria-disabled="true"` + `tabindex="-1"` — removes it from keyboard/AT activation and tab order without touching pointer clicks (apps/themes add their own `pointer-events: none` CSS rule for that half)
|