ariadne_view_components 0.0.67 → 0.0.69

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: bd5283c6a467784134844ba0e33b4e057751409ab319edd1290d50187548d00f
4
- data.tar.gz: 71955ed5ec0978b6dd4134e06e04ac75ab8431dcf1a773fa8ba44de714580a02
3
+ metadata.gz: 6ea95398dc37c037489d83c7df796efa07358b63e5ad265db31ff497c7f3fab7
4
+ data.tar.gz: 268aba20f7c246554ded76254471c4496a659bbf4364e469138413d27138bf59
5
5
  SHA512:
6
- metadata.gz: fdf4d46026299a7aacc15ce2a404f214fc44f9995295970ef2108ae6b8ae9491dc8434d576087f56dbe93c2cf477cf4b57a4a62c67bacf15a7841ec657b13b4e
7
- data.tar.gz: d7a08dbe0d5307bf83b75daaa8c9d8d788a6078ef4877aecab4aa4f54698e3b10cc1dd078d335292b5f538014ac01a3f94ad9624aeb1ba8870f7bbfffb826f93
6
+ metadata.gz: cc4cbf3d71140d80c85a1dd9cd9e8c0046df890fb9c06404da089aea6850dc7325c2fb4812986cbe8d60234bcc3eb0a4ab7b5d1e2079825b7403175061d62571
7
+ data.tar.gz: f8308ec755858f998dfc30c79f52082fd3ab56c16c059d8295669e446db62464ffcf33c03c34e5172efb9a25a3a7edfd8afe4fc2ab32043bcea1529b0e4c9af0
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## [v0.0.68] - 05-04-2024
2
+ **Full Changelog**: https://github.com/yettoapp/ariadne/compare/v0.0.67...v0.0.68
3
+ ## [v0.0.67] - 05-04-2024
4
+ **Full Changelog**: https://github.com/yettoapp/ariadne/compare/v0.0.66...v0.0.67
1
5
  ## [v0.0.66] - 05-04-2024
2
6
  **Full Changelog**: https://github.com/yettoapp/ariadne/compare/v0.0.65...v0.0.66
3
7
  ## [v0.0.65] - 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:)
@@ -29,81 +29,6 @@ module Ariadne
29
29
  include IconHelper
30
30
  include HeroiconsHelper
31
31
 
32
- PRELOADED_ICONS = [
33
- {
34
- name: "bell",
35
- variant: HeroiconsHelper::Icon::VARIANT_OUTLINE,
36
- },
37
- {
38
- name: "check",
39
- variant: HeroiconsHelper::Icon::VARIANT_OUTLINE,
40
- },
41
- {
42
- name: "chevron-down",
43
- variant: HeroiconsHelper::Icon::VARIANT_OUTLINE,
44
- },
45
- {
46
- name: "clipboard",
47
- variant: HeroiconsHelper::Icon::VARIANT_OUTLINE,
48
- },
49
- {
50
- name: "clock",
51
- variant: HeroiconsHelper::Icon::VARIANT_OUTLINE,
52
- },
53
- {
54
- name: "information-circle",
55
- variant: HeroiconsHelper::Icon::VARIANT_OUTLINE,
56
- },
57
- {
58
- name: "dots-horizontal",
59
- variant: HeroiconsHelper::Icon::VARIANT_OUTLINE,
60
- },
61
- {
62
- name: "link",
63
- variant: HeroiconsHelper::Icon::VARIANT_OUTLINE,
64
- },
65
- {
66
- name: "lock-closed",
67
- variant: HeroiconsHelper::Icon::VARIANT_OUTLINE,
68
- },
69
- {
70
- name: "mail",
71
- variant: HeroiconsHelper::Icon::VARIANT_OUTLINE,
72
- },
73
- {
74
- name: "menu",
75
- variant: HeroiconsHelper::Icon::VARIANT_OUTLINE,
76
- },
77
- {
78
- name: "pencil",
79
- variant: HeroiconsHelper::Icon::VARIANT_OUTLINE,
80
- },
81
- {
82
- name: "plus-sm",
83
- variant: HeroiconsHelper::Icon::VARIANT_OUTLINE,
84
- },
85
- {
86
- name: "question-mark-circle",
87
- variant: HeroiconsHelper::Icon::VARIANT_OUTLINE,
88
- },
89
- {
90
- name: "search",
91
- variant: HeroiconsHelper::Icon::VARIANT_OUTLINE,
92
- },
93
- {
94
- name: "search",
95
- variant: HeroiconsHelper::Icon::VARIANT_OUTLINE,
96
- },
97
- {
98
- name: "trash",
99
- variant: HeroiconsHelper::Icon::VARIANT_OUTLINE,
100
- },
101
- {
102
- name: "x-mark",
103
- variant: HeroiconsHelper::Icon::VARIANT_OUTLINE,
104
- },
105
- ].freeze
106
-
107
32
  accepts_html_attributes do |html_attrs|
108
33
  html_attrs[:class] = Ariadne::ViewComponents.tailwind_merger.merge([@heroicon.attributes["class"], style(size: @size), html_attrs[:class]].join(" "))
109
34
  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
@@ -34,8 +34,7 @@ module Ariadne
34
34
  if Rails.application.config.eager_load
35
35
  Ariadne::Forms::Base.compile!
36
36
  Ariadne::Forms::Base.descendants.each(&:compile!)
37
- Ariadne::Forms::BaseComponent.descendants.each(&:compile!)
38
- Ariadne::Heroicon::Cache.preload!
37
+ Ariadne::Form::BaseComponent.descendants.each(&:compile!)
39
38
  end
40
39
  end
41
40
  end
@@ -50,7 +49,7 @@ module Ariadne
50
49
  helper Ariadne::FormHelper
51
50
 
52
51
  # make ariadne_form_with available to view components also
53
- ViewComponent::Base.prepend(Ariadne::FormHelper)
52
+ ::ViewComponent::Base.prepend(Ariadne::FormHelper)
54
53
  end
55
54
  end
56
55
 
@@ -3,6 +3,6 @@
3
3
  # :nocov:
4
4
  module Ariadne
5
5
  module ViewComponents
6
- VERSION = "0.0.67"
6
+ VERSION = "0.0.69"
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.67
4
+ version: 0.0.69
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_component_contrib/html_attrs.rb
198
- - app/lib/view_component_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