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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ced29e9d5d3ea81b63053dafceebaff0a5faa5912341adc06e5561ffde74f4be
4
- data.tar.gz: d1edeaa13348008834ea70e582393cb760de8fdb0257720cf18607e312e5f5d4
3
+ metadata.gz: 2c1c6ce26063b99def7c171185947bcadfc6ab4a01217570bd70ead0ac48fced
4
+ data.tar.gz: 2c77caa134f149e3b32d9c1e9e767177e00aeb9c9cd51924ad955fa81f974f2b
5
5
  SHA512:
6
- metadata.gz: abd39c12342494f01b486c4fe679a1d235d5c6ef3218b08ab59079bc6aa5ef462e78e37b779a04c7c3d8e154c0a21a3b4a65d09c3905619d418ef9c690887f3e
7
- data.tar.gz: 490bc1b70b1225d84988fffd9f7c6c09332c2c49424cc9f35547f8932147ff6790822f63ea6cf6745a9a3370f730a23e75d962ef05e8db3c23e7d46da8334c48
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,7 +4,7 @@ module Ariadne
4
4
  module Form
5
5
  # :nodoc:
6
6
  module FormControl
7
- class Component < Ariadne::Form::BaseInputComponent
7
+ class Component < Ariadne::Form::BaseComponent
8
8
  delegate :builder, :form, to: :@input
9
9
 
10
10
  def initialize(input:, tag: :div, **system_arguments)
@@ -4,7 +4,7 @@ module Ariadne
4
4
  module Form
5
5
  # :nodoc:
6
6
  module FormReference
7
- class Component < Ariadne::Form::BaseInputComponent
7
+ class Component < Ariadne::Form::BaseComponent
8
8
  delegate :builder, :form, to: :@input
9
9
 
10
10
  def initialize(input:)
@@ -4,24 +4,22 @@ module Ariadne
4
4
  module Form
5
5
  # :nodoc:
6
6
  module Group
7
- module Component
8
- class Component < Ariadne::Form::BaseInputComponent
9
- VERTICAL = :vertical
10
- HORIZONTAL = :horizontal
11
- DEFAULT_LAYOUT = VERTICAL
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
- def initialize(inputs:, builder:, form:, layout: DEFAULT_LAYOUT, **system_arguments)
15
- @inputs = inputs
16
- @builder = builder
17
- @form = form
18
- @layout = layout
19
- @system_arguments = system_arguments
20
- end
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
- def horizontal?
23
- @layout == HORIZONTAL
24
- end
21
+ def horizontal?
22
+ @layout == HORIZONTAL
25
23
  end
26
24
  end
27
25
  end
@@ -3,7 +3,7 @@
3
3
  module Ariadne
4
4
  module Form
5
5
  module Separator
6
- class Component < Ariadne::Form::BaseInputComponent
6
+ class Component < Ariadne::Form::BaseComponent
7
7
  end
8
8
  end
9
9
  end
@@ -3,7 +3,7 @@
3
3
  module Ariadne
4
4
  module Form
5
5
  module SpacingWrapper
6
- class Component < Ariadne::Form::BaseInputComponent
6
+ class Component < Ariadne::Form::BaseComponent
7
7
  end
8
8
  end
9
9
  end
@@ -4,7 +4,7 @@ module Ariadne
4
4
  module Form
5
5
  # :nodoc:
6
6
  module ValidationMessage
7
- class Component < Ariadne::Form::BaseInputComponent
7
+ class Component < Ariadne::Form::BaseComponent
8
8
  attr_reader :input
9
9
 
10
10
  def initialize(input:)
@@ -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
@@ -50,7 +50,7 @@ module Ariadne
50
50
  helper Ariadne::FormHelper
51
51
 
52
52
  # make ariadne_form_with available to view components also
53
- ViewComponent::Base.prepend(Ariadne::FormHelper)
53
+ ::ViewComponent::Base.prepend(Ariadne::FormHelper)
54
54
  end
55
55
  end
56
56
 
@@ -3,6 +3,6 @@
3
3
  # :nocov:
4
4
  module Ariadne
5
5
  module ViewComponents
6
- VERSION = "0.0.66"
6
+ VERSION = "0.0.68"
7
7
  end
8
8
  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.66
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