vident 0.12.0 → 0.13.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 +80 -0
- data/LICENSE.txt +1 -1
- data/README.md +720 -164
- data/lib/vident/base.rb +44 -10
- data/lib/vident/component.rb +1 -1
- data/lib/vident/root_component.rb +25 -12
- data/lib/vident/version.rb +6 -1
- data/lib/vident.rb +10 -4
- metadata +12 -22
- data/.ruby-version +0 -1
- data/.standard.yml +0 -3
- data/CODE_OF_CONDUCT.md +0 -84
- data/Rakefile +0 -3
- data/lib/tasks/vident_tasks.rake +0 -4
- data/sig/vident.rbs +0 -4
- data/vident.gemspec +0 -30
data/lib/vident/base.rb
CHANGED
@@ -92,8 +92,7 @@ module Vident
|
|
92
92
|
|
93
93
|
# HTML and attribute definition and creation
|
94
94
|
|
95
|
-
#
|
96
|
-
# The separation between component and root element is a bit messy. Might need rethinking.
|
95
|
+
# Generate action/target/etc Stimulus attribute string that can be used externally to this component
|
97
96
|
delegate :action, :target, :named_classes, to: :root
|
98
97
|
|
99
98
|
# This can be overridden to return an array of extra class names
|
@@ -133,14 +132,49 @@ module Vident
|
|
133
132
|
|
134
133
|
private
|
135
134
|
|
136
|
-
def
|
137
|
-
|
138
|
-
|
139
|
-
|
135
|
+
def root_element_attributes
|
136
|
+
{}
|
137
|
+
end
|
138
|
+
|
139
|
+
def merge_element_attributes!(element_attributes, attributes)
|
140
|
+
attributes.each_with_object(element_attributes) do |(k, v), h|
|
141
|
+
if h[k].is_a?(Hash)
|
142
|
+
h[k].merge!(v)
|
143
|
+
elsif h[k].is_a?(Array)
|
144
|
+
h[k] << v
|
145
|
+
else
|
146
|
+
h[k] = v
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
def root_component_attributes(**attributes)
|
152
|
+
@root_component_attributes ||= {}
|
153
|
+
merge_element_attributes!(@root_component_attributes, attributes)
|
154
|
+
end
|
155
|
+
|
156
|
+
def stimulus_options_for_root_component
|
157
|
+
attributes = root_element_attributes
|
158
|
+
merge_element_attributes!(attributes, @root_component_attributes) if @root_component_attributes.present?
|
159
|
+
stimulus_options_for_component(attributes)
|
140
160
|
end
|
141
161
|
|
142
162
|
# Prepare the stimulus attributes for a StimulusComponent
|
143
163
|
def stimulus_options_for_component(options)
|
164
|
+
# Add pending actions
|
165
|
+
all_actions = attribute(:actions) + Array.wrap(options[:actions])
|
166
|
+
all_actions += @pending_actions if @pending_actions&.any?
|
167
|
+
|
168
|
+
# Add pending targets
|
169
|
+
all_targets = attribute(:targets) + Array.wrap(options[:targets])
|
170
|
+
all_targets += @pending_targets if @pending_targets&.any?
|
171
|
+
|
172
|
+
# Merge pending named classes
|
173
|
+
named_classes_option = merge_stimulus_option(options, :named_classes)
|
174
|
+
if @pending_named_classes&.any?
|
175
|
+
named_classes_option = named_classes_option.merge(@pending_named_classes)
|
176
|
+
end
|
177
|
+
|
144
178
|
{
|
145
179
|
id: respond_to?(:id) ? id : (attribute(:id) || options[:id]),
|
146
180
|
element_tag: attribute(:element_tag) || options[:element_tag] || :div,
|
@@ -148,12 +182,12 @@ module Vident
|
|
148
182
|
controllers: (
|
149
183
|
self.class.stimulus_controller? ? [default_controller_path] : []
|
150
184
|
) + Array.wrap(options[:controllers]) + attribute(:controllers),
|
151
|
-
actions:
|
152
|
-
targets:
|
185
|
+
actions: all_actions,
|
186
|
+
targets: all_targets,
|
153
187
|
outlets: attribute(:outlets) + Array.wrap(options[:outlets]),
|
154
188
|
outlet_host: attribute(:outlet_host),
|
155
|
-
named_classes:
|
156
|
-
|
189
|
+
named_classes: named_classes_option,
|
190
|
+
values: prepare_stimulus_option(options, :values)
|
157
191
|
}
|
158
192
|
end
|
159
193
|
|
data/lib/vident/component.rb
CHANGED
@@ -18,7 +18,7 @@ module Vident
|
|
18
18
|
attribute :targets, default: [], delegates: false
|
19
19
|
attribute :outlets, default: [], delegates: false
|
20
20
|
attribute :outlet_host, delegates: false
|
21
|
-
attribute :
|
21
|
+
attribute :values, default: [], delegates: false
|
22
22
|
attribute :named_classes, delegates: false
|
23
23
|
end
|
24
24
|
|
@@ -9,7 +9,7 @@ module Vident
|
|
9
9
|
outlets: nil,
|
10
10
|
outlet_host: nil,
|
11
11
|
named_classes: nil, # https://stimulus.hotwired.dev/reference/css-classes
|
12
|
-
|
12
|
+
values: nil,
|
13
13
|
element_tag: nil,
|
14
14
|
id: nil,
|
15
15
|
html_options: nil
|
@@ -22,8 +22,7 @@ module Vident
|
|
22
22
|
@targets = targets
|
23
23
|
@outlets = outlets
|
24
24
|
@named_classes = named_classes
|
25
|
-
@
|
26
|
-
@data_maps = data_maps
|
25
|
+
@values = values
|
27
26
|
|
28
27
|
outlet_host.connect_outlet(self) if outlet_host.respond_to?(:connect_outlet)
|
29
28
|
end
|
@@ -150,13 +149,18 @@ module Vident
|
|
150
149
|
build_named_classes_data_attributes(@named_classes)
|
151
150
|
end
|
152
151
|
|
152
|
+
def values_list
|
153
|
+
return {} unless @values&.size&.positive?
|
154
|
+
build_values_attributes
|
155
|
+
end
|
156
|
+
|
153
157
|
# stimulus "data-*" attributes map for this component
|
154
158
|
def tag_data_attributes
|
155
159
|
{controller: controller_list(@controllers), action: action_list(@actions)}
|
156
160
|
.merge!(target_list)
|
157
161
|
.merge!(outlet_list)
|
158
162
|
.merge!(named_classes_list)
|
159
|
-
.merge!(
|
163
|
+
.merge!(values_list)
|
160
164
|
.compact_blank!
|
161
165
|
end
|
162
166
|
|
@@ -229,7 +233,11 @@ module Vident
|
|
229
233
|
|
230
234
|
def parse_target(raw_target)
|
231
235
|
return raw_target if raw_target.is_a?(String)
|
232
|
-
|
236
|
+
if raw_target.is_a?(Hash)
|
237
|
+
raw_target[:name] = js_name(raw_target[:name]) if raw_target[:name].is_a?(Symbol)
|
238
|
+
return raw_target
|
239
|
+
end
|
240
|
+
return target(*raw_target) if raw_target.is_a?(Array)
|
233
241
|
target(raw_target)
|
234
242
|
end
|
235
243
|
|
@@ -241,23 +249,28 @@ module Vident
|
|
241
249
|
actions.map! { |a| a.is_a?(String) ? a : action(*a) }
|
242
250
|
end
|
243
251
|
|
244
|
-
def
|
245
|
-
attrs.transform_keys
|
252
|
+
def parse_value_attributes(attrs, controller: nil)
|
253
|
+
attrs.transform_keys do |value_name|
|
254
|
+
:"#{controller || implied_controller_name}-#{value_name.to_s.dasherize}-value"
|
255
|
+
end
|
246
256
|
end
|
247
257
|
|
248
|
-
def
|
249
|
-
|
250
|
-
@data_maps.each_with_object({}) do |m, obj|
|
258
|
+
def build_values_attributes
|
259
|
+
@values.each_with_object({}) do |m, obj|
|
251
260
|
if m.is_a?(Hash)
|
252
|
-
obj.merge!(
|
261
|
+
obj.merge!(parse_value_attributes(m))
|
253
262
|
elsif m.is_a?(Array)
|
254
263
|
controller_path = m.first
|
255
264
|
data = m.last
|
256
|
-
obj.merge!(
|
265
|
+
obj.merge!(parse_value_attributes(data, controller: stimulize_path(controller_path)))
|
257
266
|
end
|
258
267
|
end
|
259
268
|
end
|
260
269
|
|
270
|
+
def build_values_data_attributes(values)
|
271
|
+
values.map { |name, value| [:"#{name}-value", value] }.to_h
|
272
|
+
end
|
273
|
+
|
261
274
|
def parse_named_classes_hash(named_classes)
|
262
275
|
named_classes.map do |name, classes|
|
263
276
|
logical_name = name.to_s.dasherize
|
data/lib/vident/version.rb
CHANGED
data/lib/vident.rb
CHANGED
@@ -1,8 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "active_support"
|
4
|
+
require "active_support/concern"
|
3
5
|
require "vident/version"
|
4
|
-
require "vident/
|
6
|
+
require "vident/base"
|
7
|
+
require "vident/stable_id"
|
8
|
+
require "vident/attributes/not_typed"
|
9
|
+
require "vident/root_component"
|
10
|
+
require "vident/component"
|
5
11
|
|
6
|
-
|
7
|
-
|
8
|
-
end
|
12
|
+
require "vident/engine" if defined?(Rails)
|
13
|
+
|
14
|
+
module Vident; end
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vident
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.13.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stephen Ierodiaconou
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-04-07 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: railties
|
@@ -16,40 +15,40 @@ dependencies:
|
|
16
15
|
requirements:
|
17
16
|
- - ">="
|
18
17
|
- !ruby/object:Gem::Version
|
19
|
-
version: '7'
|
18
|
+
version: '7.2'
|
20
19
|
- - "<"
|
21
20
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
21
|
+
version: '9'
|
23
22
|
type: :runtime
|
24
23
|
prerelease: false
|
25
24
|
version_requirements: !ruby/object:Gem::Requirement
|
26
25
|
requirements:
|
27
26
|
- - ">="
|
28
27
|
- !ruby/object:Gem::Version
|
29
|
-
version: '7'
|
28
|
+
version: '7.2'
|
30
29
|
- - "<"
|
31
30
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
31
|
+
version: '9'
|
33
32
|
- !ruby/object:Gem::Dependency
|
34
33
|
name: activesupport
|
35
34
|
requirement: !ruby/object:Gem::Requirement
|
36
35
|
requirements:
|
37
36
|
- - ">="
|
38
37
|
- !ruby/object:Gem::Version
|
39
|
-
version: '7'
|
38
|
+
version: '7.2'
|
40
39
|
- - "<"
|
41
40
|
- !ruby/object:Gem::Version
|
42
|
-
version: '
|
41
|
+
version: '9'
|
43
42
|
type: :runtime
|
44
43
|
prerelease: false
|
45
44
|
version_requirements: !ruby/object:Gem::Requirement
|
46
45
|
requirements:
|
47
46
|
- - ">="
|
48
47
|
- !ruby/object:Gem::Version
|
49
|
-
version: '7'
|
48
|
+
version: '7.2'
|
50
49
|
- - "<"
|
51
50
|
- !ruby/object:Gem::Version
|
52
|
-
version: '
|
51
|
+
version: '9'
|
53
52
|
description: Vident makes using Stimulus with your `ViewComponent` or `Phlex` view
|
54
53
|
components as easy as writing Ruby. Vident is the base of your design system implementation,
|
55
54
|
which provides helpers for working with Stimulus. For component libraries with ViewComponent
|
@@ -60,14 +59,9 @@ executables: []
|
|
60
59
|
extensions: []
|
61
60
|
extra_rdoc_files: []
|
62
61
|
files:
|
63
|
-
- ".ruby-version"
|
64
|
-
- ".standard.yml"
|
65
62
|
- CHANGELOG.md
|
66
|
-
- CODE_OF_CONDUCT.md
|
67
63
|
- LICENSE.txt
|
68
64
|
- README.md
|
69
|
-
- Rakefile
|
70
|
-
- lib/tasks/vident_tasks.rake
|
71
65
|
- lib/vident.rb
|
72
66
|
- lib/vident/attributes/not_typed.rb
|
73
67
|
- lib/vident/base.rb
|
@@ -77,8 +71,6 @@ files:
|
|
77
71
|
- lib/vident/root_component.rb
|
78
72
|
- lib/vident/stable_id.rb
|
79
73
|
- lib/vident/version.rb
|
80
|
-
- sig/vident.rbs
|
81
|
-
- vident.gemspec
|
82
74
|
homepage: https://github.com/stevegeek/vident
|
83
75
|
licenses:
|
84
76
|
- MIT
|
@@ -86,7 +78,6 @@ metadata:
|
|
86
78
|
homepage_uri: https://github.com/stevegeek/vident
|
87
79
|
source_code_uri: https://github.com/stevegeek/vident
|
88
80
|
changelog_uri: https://github.com/stevegeek/vident/blob/main/CHANGELOG.md
|
89
|
-
post_install_message:
|
90
81
|
rdoc_options: []
|
91
82
|
require_paths:
|
92
83
|
- lib
|
@@ -94,15 +85,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
94
85
|
requirements:
|
95
86
|
- - ">="
|
96
87
|
- !ruby/object:Gem::Version
|
97
|
-
version: 3.
|
88
|
+
version: 3.1.0
|
98
89
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
90
|
requirements:
|
100
91
|
- - ">="
|
101
92
|
- !ruby/object:Gem::Version
|
102
93
|
version: '0'
|
103
94
|
requirements: []
|
104
|
-
rubygems_version: 3.
|
105
|
-
signing_key:
|
95
|
+
rubygems_version: 3.6.2
|
106
96
|
specification_version: 4
|
107
97
|
summary: Vident is the base of your design system implementation, which provides helpers
|
108
98
|
for working with Stimulus. For component libraries with ViewComponent or Phlex.
|
data/.ruby-version
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
3.3.0
|
data/.standard.yml
DELETED
data/CODE_OF_CONDUCT.md
DELETED
@@ -1,84 +0,0 @@
|
|
1
|
-
# Contributor Covenant Code of Conduct
|
2
|
-
|
3
|
-
## Our Pledge
|
4
|
-
|
5
|
-
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
6
|
-
|
7
|
-
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
|
8
|
-
|
9
|
-
## Our Standards
|
10
|
-
|
11
|
-
Examples of behavior that contributes to a positive environment for our community include:
|
12
|
-
|
13
|
-
* Demonstrating empathy and kindness toward other people
|
14
|
-
* Being respectful of differing opinions, viewpoints, and experiences
|
15
|
-
* Giving and gracefully accepting constructive feedback
|
16
|
-
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
|
17
|
-
* Focusing on what is best not just for us as individuals, but for the overall community
|
18
|
-
|
19
|
-
Examples of unacceptable behavior include:
|
20
|
-
|
21
|
-
* The use of sexualized language or imagery, and sexual attention or
|
22
|
-
advances of any kind
|
23
|
-
* Trolling, insulting or derogatory comments, and personal or political attacks
|
24
|
-
* Public or private harassment
|
25
|
-
* Publishing others' private information, such as a physical or email
|
26
|
-
address, without their explicit permission
|
27
|
-
* Other conduct which could reasonably be considered inappropriate in a
|
28
|
-
professional setting
|
29
|
-
|
30
|
-
## Enforcement Responsibilities
|
31
|
-
|
32
|
-
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
|
33
|
-
|
34
|
-
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
|
35
|
-
|
36
|
-
## Scope
|
37
|
-
|
38
|
-
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
|
39
|
-
|
40
|
-
## Enforcement
|
41
|
-
|
42
|
-
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at stevegeek@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
|
43
|
-
|
44
|
-
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
|
45
|
-
|
46
|
-
## Enforcement Guidelines
|
47
|
-
|
48
|
-
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
|
49
|
-
|
50
|
-
### 1. Correction
|
51
|
-
|
52
|
-
**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
|
53
|
-
|
54
|
-
**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
|
55
|
-
|
56
|
-
### 2. Warning
|
57
|
-
|
58
|
-
**Community Impact**: A violation through a single incident or series of actions.
|
59
|
-
|
60
|
-
**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
|
61
|
-
|
62
|
-
### 3. Temporary Ban
|
63
|
-
|
64
|
-
**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
|
65
|
-
|
66
|
-
**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
|
67
|
-
|
68
|
-
### 4. Permanent Ban
|
69
|
-
|
70
|
-
**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
|
71
|
-
|
72
|
-
**Consequence**: A permanent ban from any sort of public interaction within the community.
|
73
|
-
|
74
|
-
## Attribution
|
75
|
-
|
76
|
-
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
|
77
|
-
available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
78
|
-
|
79
|
-
Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
|
80
|
-
|
81
|
-
[homepage]: https://www.contributor-covenant.org
|
82
|
-
|
83
|
-
For answers to common questions about this code of conduct, see the FAQ at
|
84
|
-
https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
|
data/Rakefile
DELETED
data/lib/tasks/vident_tasks.rake
DELETED
data/sig/vident.rbs
DELETED
data/vident.gemspec
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative "lib/vident/version"
|
4
|
-
|
5
|
-
Gem::Specification.new do |spec|
|
6
|
-
spec.name = "vident"
|
7
|
-
spec.version = Vident::VERSION
|
8
|
-
spec.authors = ["Stephen Ierodiaconou"]
|
9
|
-
spec.email = ["stevegeek@gmail.com"]
|
10
|
-
|
11
|
-
spec.summary = "Vident is the base of your design system implementation, which provides helpers for working with Stimulus. For component libraries with ViewComponent or Phlex."
|
12
|
-
spec.description = "Vident makes using Stimulus with your `ViewComponent` or `Phlex` view components as easy as writing Ruby. Vident is the base of your design system implementation, which provides helpers for working with Stimulus. For component libraries with ViewComponent or Phlex."
|
13
|
-
spec.homepage = "https://github.com/stevegeek/vident"
|
14
|
-
spec.license = "MIT"
|
15
|
-
spec.required_ruby_version = ">= 3.0.0"
|
16
|
-
|
17
|
-
spec.metadata["homepage_uri"] = spec.homepage
|
18
|
-
spec.metadata["source_code_uri"] = spec.homepage
|
19
|
-
spec.metadata["changelog_uri"] = spec.homepage + "/blob/main/CHANGELOG.md"
|
20
|
-
|
21
|
-
spec.files = Dir.chdir(__dir__) do
|
22
|
-
`git ls-files -z`.split("\x0").reject do |f|
|
23
|
-
(File.expand_path(f) == __FILE__) ||
|
24
|
-
f.start_with?(*%w[bin/ test/ spec/ features/ examples/ docs/ .git .github appveyor Gemfile])
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
spec.add_dependency "railties", ">= 7", "< 8.0"
|
29
|
-
spec.add_dependency "activesupport", ">= 7", "< 8.0"
|
30
|
-
end
|