ariadne_view_components 0.0.66 → 0.0.68
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/app/components/ariadne/base_component.rb +1 -5
- data/app/components/ariadne/form/form_control/component.rb +1 -1
- data/app/components/ariadne/form/form_reference/component.rb +1 -1
- data/app/components/ariadne/form/group/component.rb +14 -16
- data/app/components/ariadne/form/separator/component.rb +1 -1
- data/app/components/ariadne/form/spacing_wrapper/component.rb +1 -1
- data/app/components/ariadne/form/validation_message/component.rb +1 -1
- data/app/lib/ariadne/view_component/html_attrs.rb +66 -0
- data/app/lib/ariadne/view_component/style_variants.rb +16 -0
- data/lib/ariadne/view_components/engine.rb +1 -1
- data/lib/ariadne/view_components/version.rb +1 -1
- metadata +3 -3
- data/app/lib/view_components_contrib/html_attrs.rb +0 -64
- data/app/lib/view_components_contrib/style_variants.rb +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2c1c6ce26063b99def7c171185947bcadfc6ab4a01217570bd70ead0ac48fced
|
4
|
+
data.tar.gz: 2c77caa134f149e3b32d9c1e9e767177e00aeb9c9cd51924ad955fa81f974f2b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1a362bbcf743922eec8195d821f17b68d94d78d493f988b12f18994d3fa24efc4328451ff9a03e5f7ec17fe4e21754f322ac42756ca9f85de583dd3b351acd67
|
7
|
+
data.tar.gz: fe2e8da4c9af0221e781a2f11ea920a7a96971c6f0be2326c4e4f9065ed45f49c4b5f2a9086989cc85339a8b3af259c516e223cc3c89a188f001d685c232351a
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
## [v0.0.67] - 05-04-2024
|
2
|
+
**Full Changelog**: https://github.com/yettoapp/ariadne/compare/v0.0.66...v0.0.67
|
3
|
+
## [v0.0.66] - 05-04-2024
|
4
|
+
**Full Changelog**: https://github.com/yettoapp/ariadne/compare/v0.0.65...v0.0.66
|
1
5
|
## [v0.0.65] - 05-04-2024
|
2
6
|
**Full Changelog**: https://github.com/yettoapp/ariadne/compare/v0.0.64...v0.0.65
|
3
7
|
## [v0.0.64] - 05-04-2024
|
@@ -1,17 +1,13 @@
|
|
1
1
|
# typed: false
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
require_relative "../../lib/view_components_contrib/html_attrs"
|
5
4
|
require "dry-initializer"
|
6
5
|
|
7
6
|
module Ariadne
|
8
7
|
# :nodoc:
|
9
8
|
class BaseComponent < ViewComponentContrib::Base
|
9
|
+
include Ariadne::ViewComponent::HTMLAttrs
|
10
10
|
include ViewComponentContrib::StyleVariants
|
11
|
-
require_relative "../../lib/view_components_contrib/style_variants"
|
12
|
-
|
13
|
-
include ViewComponentContrib::HTMLAttrs
|
14
|
-
include ViewComponentContrib::TranslationHelper
|
15
11
|
|
16
12
|
include Ariadne::AttributesHelper
|
17
13
|
|
@@ -4,24 +4,22 @@ module Ariadne
|
|
4
4
|
module Form
|
5
5
|
# :nodoc:
|
6
6
|
module Group
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
LAYOUTS = [VERTICAL, HORIZONTAL].freeze
|
7
|
+
class Component < Ariadne::Form::BaseComponent
|
8
|
+
VERTICAL = :vertical
|
9
|
+
HORIZONTAL = :horizontal
|
10
|
+
DEFAULT_LAYOUT = VERTICAL
|
11
|
+
LAYOUTS = [VERTICAL, HORIZONTAL].freeze
|
13
12
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
13
|
+
def initialize(inputs:, builder:, form:, layout: DEFAULT_LAYOUT, **system_arguments)
|
14
|
+
@inputs = inputs
|
15
|
+
@builder = builder
|
16
|
+
@form = form
|
17
|
+
@layout = layout
|
18
|
+
@system_arguments = system_arguments
|
19
|
+
end
|
21
20
|
|
22
|
-
|
23
|
-
|
24
|
-
end
|
21
|
+
def horizontal?
|
22
|
+
@layout == HORIZONTAL
|
25
23
|
end
|
26
24
|
end
|
27
25
|
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# typed: false
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "action_view/helpers/tag_helper"
|
5
|
+
|
6
|
+
module Ariadne
|
7
|
+
module ViewComponent
|
8
|
+
module HTMLAttrs
|
9
|
+
class AttributesHash < ::Hash
|
10
|
+
TAG_BUILDER = ActionView::Helpers::TagHelper::TagBuilder.new(nil)
|
11
|
+
TAG_OPTIONS = ActionView::Helpers::TagHelper::TagBuilder.instance_method(:tag_options)
|
12
|
+
|
13
|
+
def to_html(nested: false)
|
14
|
+
# TODO: implement + change usage by @tag nested-attributes
|
15
|
+
tag_options(self)&.html_safe # rubocop:disable Rails/OutputSafety
|
16
|
+
end
|
17
|
+
private def tag_options(...) = TAG_OPTIONS.bind_call(TAG_BUILDER, ...)
|
18
|
+
end
|
19
|
+
|
20
|
+
extend ActiveSupport::Concern
|
21
|
+
|
22
|
+
class_methods do
|
23
|
+
def accepts_html_attributes_for(name, **defaults, &block)
|
24
|
+
html_attribute_accessors[name] = defaults
|
25
|
+
|
26
|
+
name = name.to_sym
|
27
|
+
method_name = :"#{name}_attrs"
|
28
|
+
ivar_name = :"@#{method_name}"
|
29
|
+
|
30
|
+
attr_reader(method_name)
|
31
|
+
|
32
|
+
mod = Module.new do
|
33
|
+
define_method(:initialize) do |**options|
|
34
|
+
value = self.class.default_html_attributes_for(name).deep_merge!(options.delete(method_name).to_h)
|
35
|
+
super(**options)
|
36
|
+
instance_exec(value, &block) if block
|
37
|
+
instance_variable_set(ivar_name, value)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
prepend(mod)
|
42
|
+
end
|
43
|
+
|
44
|
+
def accepts_html_attributes(**defaults, &block)
|
45
|
+
accepts_html_attributes_for(:html, **defaults, &block)
|
46
|
+
end
|
47
|
+
|
48
|
+
def html_attribute_accessors
|
49
|
+
@html_attribute_accessors ||=
|
50
|
+
if superclass.respond_to?(:html_attribute_accessors)
|
51
|
+
superclass.html_attribute_accessors.deep_dup
|
52
|
+
else
|
53
|
+
{}
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def default_html_attributes_for(name)
|
58
|
+
html_attribute_accessors.fetch(name).each_with_object(AttributesHash.new) do |(k, v), acc|
|
59
|
+
acc[k] = v.is_a?(Proc) ? v.call : v
|
60
|
+
acc
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Ariadne
|
4
|
+
module ViewComponent
|
5
|
+
module StyleVariants
|
6
|
+
module ClassMethods
|
7
|
+
# Returns the name of the default style set based on the class name:
|
8
|
+
# MyComponent::Component => my_component
|
9
|
+
# Namespaced::MyComponent => my_component
|
10
|
+
def default_style_name
|
11
|
+
@default_style_name ||= name.split("::")[-2].underscore.presence || "component"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ariadne_view_components
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.68
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Garen J. Torikian
|
@@ -193,9 +193,9 @@ files:
|
|
193
193
|
- app/lib/ariadne/form.rb
|
194
194
|
- app/lib/ariadne/icon_helper.rb
|
195
195
|
- app/lib/ariadne/logger_helper.rb
|
196
|
+
- app/lib/ariadne/view_component/html_attrs.rb
|
197
|
+
- app/lib/ariadne/view_component/style_variants.rb
|
196
198
|
- app/lib/ariadne/view_helper.rb
|
197
|
-
- app/lib/view_components_contrib/html_attrs.rb
|
198
|
-
- app/lib/view_components_contrib/style_variants.rb
|
199
199
|
- lib/ariadne/forms/acts_as_component.rb
|
200
200
|
- lib/ariadne/forms/base.html.erb
|
201
201
|
- lib/ariadne/forms/base.rb
|
@@ -1,64 +0,0 @@
|
|
1
|
-
# typed: false
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require "action_view/helpers/tag_helper"
|
5
|
-
|
6
|
-
module ViewComponentContrib
|
7
|
-
module HTMLAttrs
|
8
|
-
class AttributesHash < ::Hash
|
9
|
-
TAG_BUILDER = ActionView::Helpers::TagHelper::TagBuilder.new(nil)
|
10
|
-
TAG_OPTIONS = ActionView::Helpers::TagHelper::TagBuilder.instance_method(:tag_options)
|
11
|
-
|
12
|
-
def to_html(nested: false)
|
13
|
-
# TODO: implement + change usage by @tag nested-attributes
|
14
|
-
tag_options(self)&.html_safe # rubocop:disable Rails/OutputSafety
|
15
|
-
end
|
16
|
-
private def tag_options(...) = TAG_OPTIONS.bind_call(TAG_BUILDER, ...)
|
17
|
-
end
|
18
|
-
|
19
|
-
extend ActiveSupport::Concern
|
20
|
-
|
21
|
-
class_methods do
|
22
|
-
def accepts_html_attributes_for(name, **defaults, &block)
|
23
|
-
html_attribute_accessors[name] = defaults
|
24
|
-
|
25
|
-
name = name.to_sym
|
26
|
-
method_name = :"#{name}_attrs"
|
27
|
-
ivar_name = :"@#{method_name}"
|
28
|
-
|
29
|
-
attr_reader(method_name)
|
30
|
-
|
31
|
-
mod = Module.new do
|
32
|
-
define_method(:initialize) do |**options|
|
33
|
-
value = self.class.default_html_attributes_for(name).deep_merge!(options.delete(method_name).to_h)
|
34
|
-
super(**options)
|
35
|
-
instance_exec(value, &block) if block
|
36
|
-
instance_variable_set(ivar_name, value)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
prepend(mod)
|
41
|
-
end
|
42
|
-
|
43
|
-
def accepts_html_attributes(**defaults, &block)
|
44
|
-
accepts_html_attributes_for(:html, **defaults, &block)
|
45
|
-
end
|
46
|
-
|
47
|
-
def html_attribute_accessors
|
48
|
-
@html_attribute_accessors ||=
|
49
|
-
if superclass.respond_to?(:html_attribute_accessors)
|
50
|
-
superclass.html_attribute_accessors.deep_dup
|
51
|
-
else
|
52
|
-
{}
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
def default_html_attributes_for(name)
|
57
|
-
html_attribute_accessors.fetch(name).each_with_object(AttributesHash.new) do |(k, v), acc|
|
58
|
-
acc[k] = v.is_a?(Proc) ? v.call : v
|
59
|
-
acc
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module ViewComponentContrib
|
4
|
-
module StyleVariants
|
5
|
-
module ClassMethods
|
6
|
-
# Returns the name of the default style set based on the class name:
|
7
|
-
# MyComponent::Component => my_component
|
8
|
-
# Namespaced::MyComponent => my_component
|
9
|
-
def default_style_name
|
10
|
-
@default_style_name ||= name.split("::")[-2].underscore.presence || "component"
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|