katalyst-tables 2.2.10 → 2.2.11

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: d3e58b95b2dc1f01bdd97fd36a31b2f340d93928d939a7501b58e7fd96150571
4
- data.tar.gz: a72ece66c7770865d2b5892b83d114a9fa90afc5d1f81751ea37be6c34406077
3
+ metadata.gz: 93183f42b6a85c9ec376968ac1afd2c4481c16dc69d36bc0c42fc533ff73cb23
4
+ data.tar.gz: db5e89db2a8b56280a64c9183c51c984905d364e141d410e1f3718fad1353cc2
5
5
  SHA512:
6
- metadata.gz: e353837d14ec65ca9391a5190615c8696d39a0b46a4099f5c4563b28963b0cd338eaf70d48187a485fbf2a747ed64d11d296da8805f3c4008ae4e02bbeacc768
7
- data.tar.gz: 0d3837526230b4f95f9a1c235d6377c112b5d2edb820b0b56ca9f621c72a0019b735d206f9d39002340b1ce93c7efd3674013dbb1c96073d306c785562b4ad7c
6
+ metadata.gz: 0b6354580e9abae55ab47491d4ac201a8f282c3fb13fc51bf8747e421eaa6aee7ff736cfcf2012ef4561f88f71a3f1acc66842e77a944cd3b582f17ee553c9cb
7
+ data.tar.gz: b87903d4dc31840d8c69fb7f9176bd597da008e297c18e045e2243bb85059281f818e275b8b2e874a56916035c729b04497afd309a6e82512cc21612376c5bee
@@ -11,7 +11,7 @@ module Katalyst
11
11
  ITEM_CONTROLLER = "tables--orderable--item"
12
12
  LIST_CONTROLLER = "tables--orderable--list"
13
13
 
14
- using HasHtmlAttributes
14
+ using Katalyst::HtmlAttributes
15
15
 
16
16
  # Support for inclusion in a table component class
17
17
  # Adds an `orderable` slot and component configuration
@@ -11,8 +11,8 @@ module Katalyst
11
11
  # <% end %>
12
12
  # ```
13
13
  class TableComponent < ViewComponent::Base
14
+ include Katalyst::HtmlAttributes
14
15
  include Tables::ConfigurableComponent
15
- include Tables::HasHtmlAttributes
16
16
  include Tables::HasTableContent
17
17
 
18
18
  attr_reader :collection, :object_name
@@ -86,5 +86,8 @@ module Katalyst
86
86
 
87
87
  define_html_attribute_methods(:thead_attributes)
88
88
  define_html_attribute_methods(:tbody_attributes)
89
+
90
+ # Backwards compatibility with tables 1.0
91
+ alias_method :options, :html_attributes=
89
92
  end
90
93
  end
@@ -3,7 +3,7 @@
3
3
  module Katalyst
4
4
  module Tables
5
5
  class BodyCellComponent < ViewComponent::Base # :nodoc:
6
- include HasHtmlAttributes
6
+ include Katalyst::HtmlAttributes
7
7
 
8
8
  attr_reader :record
9
9
 
@@ -39,6 +39,9 @@ module Katalyst
39
39
  def inspect
40
40
  "#<#{self.class.name} attribute: #{@attribute.inspect}, value: #{value.inspect}>"
41
41
  end
42
+
43
+ # Backwards compatibility with tables 1.0
44
+ alias_method :options, :html_attributes=
42
45
  end
43
46
  end
44
47
  end
@@ -3,7 +3,7 @@
3
3
  module Katalyst
4
4
  module Tables
5
5
  class BodyRowComponent < ViewComponent::Base # :nodoc:
6
- include HasHtmlAttributes
6
+ include Katalyst::HtmlAttributes
7
7
 
8
8
  renders_many :columns, ->(component) { component }
9
9
 
@@ -39,6 +39,9 @@ module Katalyst
39
39
  def inspect
40
40
  "#<#{self.class.name} record: #{record.inspect}>"
41
41
  end
42
+
43
+ # Backwards compatibility with tables 1.0
44
+ alias_method :options, :html_attributes=
42
45
  end
43
46
  end
44
47
  end
@@ -3,7 +3,7 @@
3
3
  module Katalyst
4
4
  module Tables
5
5
  class EmptyCaptionComponent < ViewComponent::Base # :nodoc:
6
- include HasHtmlAttributes
6
+ include Katalyst::HtmlAttributes
7
7
 
8
8
  def initialize(table, **html_attributes)
9
9
  super(**html_attributes)
@@ -4,7 +4,7 @@ module Katalyst
4
4
  module Tables
5
5
  class HeaderCellComponent < ViewComponent::Base # :nodoc:
6
6
  include Frontend::Helper
7
- include HasHtmlAttributes
7
+ include Katalyst::HtmlAttributes
8
8
  include Sortable
9
9
 
10
10
  delegate :object_name, :collection, :sorting, to: :@table
@@ -50,6 +50,9 @@ module Katalyst
50
50
  "#<#{self.class.name} attribute: #{@attribute.inspect}, value: #{value.inspect}>"
51
51
  end
52
52
 
53
+ # Backwards compatibility with tables 1.0
54
+ alias_method :options, :html_attributes=
55
+
53
56
  private
54
57
 
55
58
  def default_html_attributes
@@ -3,7 +3,7 @@
3
3
  module Katalyst
4
4
  module Tables
5
5
  class HeaderRowComponent < ViewComponent::Base # :nodoc:
6
- include HasHtmlAttributes
6
+ include Katalyst::HtmlAttributes
7
7
 
8
8
  renders_many :columns, ->(component) { component }
9
9
 
@@ -39,6 +39,9 @@ module Katalyst
39
39
  def inspect
40
40
  "#<#{self.class.name} link_attributes: #{@link_attributes.inspect}>"
41
41
  end
42
+
43
+ # Backwards compatibility with tables 1.0
44
+ alias_method :options, :html_attributes=
42
45
  end
43
46
  end
44
47
  end
@@ -1,11 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "view_component"
4
+ require "katalyst/html_attributes"
4
5
 
5
6
  require_relative "tables/backend"
6
7
  require_relative "tables/engine"
7
8
  require_relative "tables/frontend"
8
- require_relative "tables/version"
9
9
 
10
10
  require_relative "tables/engine" if Object.const_defined?(:Rails)
11
11
 
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: katalyst-tables
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.10
4
+ version: 2.2.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Katalyst Interactive
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-11-09 00:00:00.000000000 Z
11
+ date: 2023-12-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: html-attributes-utils
14
+ name: katalyst-html-attributes
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
@@ -55,7 +55,6 @@ files:
55
55
  - app/assets/javascripts/controllers/tables/orderable/list_controller.js
56
56
  - app/assets/javascripts/controllers/tables/turbo_collection_controller.js
57
57
  - app/components/concerns/katalyst/tables/configurable_component.rb
58
- - app/components/concerns/katalyst/tables/has_html_attributes.rb
59
58
  - app/components/concerns/katalyst/tables/has_table_content.rb
60
59
  - app/components/concerns/katalyst/tables/orderable.rb
61
60
  - app/components/concerns/katalyst/tables/sortable.rb
@@ -84,7 +83,6 @@ files:
84
83
  - lib/katalyst/tables/engine.rb
85
84
  - lib/katalyst/tables/frontend.rb
86
85
  - lib/katalyst/tables/frontend/helper.rb
87
- - lib/katalyst/tables/version.rb
88
86
  homepage: https://github.com/katalyst/katalyst-tables
89
87
  licenses:
90
88
  - MIT
@@ -1,83 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "html_attributes_utils"
4
-
5
- module Katalyst
6
- module Tables
7
- # Adds HTML attributes to a component.
8
- # Accepts HTML attributes from the constructor or via `html_attributes=`.
9
- # These are merged with the default attributes defined in the component.
10
- # Adds support for custom html attributes for other tags, e.g.:
11
- # define_html_attribute_methods :table_attributes, default: {}
12
- # tag.table(**table_attributes)
13
- module HasHtmlAttributes
14
- extend ActiveSupport::Concern
15
-
16
- using HTMLAttributesUtils
17
-
18
- MERGEABLE_ATTRIBUTES = [
19
- *HTMLAttributesUtils::DEFAULT_MERGEABLE_ATTRIBUTES,
20
- %i[data controller],
21
- %i[data action],
22
- ].freeze
23
-
24
- FLATTENABLE_ATTRIBUTES = [
25
- %i[data controller],
26
- %i[data action],
27
- ].freeze
28
-
29
- refine NilClass do
30
- def flatten_html(*)
31
- self
32
- end
33
- end
34
-
35
- refine Hash do
36
- def merge_html(attributes)
37
- result = deep_merge_html_attributes(attributes, mergeable_attributes: MERGEABLE_ATTRIBUTES)
38
- FLATTENABLE_ATTRIBUTES.each_with_object(result) do |path, flattened|
39
- flattened.flatten_html(*path)
40
- end
41
- end
42
-
43
- def flatten_html(key, *path)
44
- if path.empty?
45
- self[key] = self[key].join(" ") if self[key].is_a?(Array)
46
- else
47
- self[key].flatten_html(*path)
48
- end
49
- end
50
- end
51
-
52
- class_methods do
53
- using HasHtmlAttributes
54
-
55
- def define_html_attribute_methods(name, default: {})
56
- define_method("default_#{name}") { default }
57
- private("default_#{name}")
58
-
59
- define_method(name) do
60
- send("default_#{name}").merge_html(instance_variable_get("@#{name}") || {})
61
- end
62
-
63
- define_method("#{name}=") do |options|
64
- instance_variable_set("@#{name}", options.slice(:id, :aria, :class, :data).merge(options.fetch(:html, {})))
65
- end
66
- end
67
- end
68
-
69
- included do
70
- define_html_attribute_methods :html_attributes, default: {}
71
-
72
- # Backwards compatibility with tables 1.0
73
- alias_method :options, :html_attributes=
74
- end
75
-
76
- def initialize(**options)
77
- super(**options.except(:id, :aria, :class, :data, :html))
78
-
79
- self.html_attributes = options
80
- end
81
- end
82
- end
83
- end
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Katalyst
4
- module Tables
5
- VERSION = "2.2.10"
6
- end
7
- end