katalyst-tables 2.2.10 → 2.2.11
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/app/components/concerns/katalyst/tables/orderable.rb +1 -1
- data/app/components/katalyst/table_component.rb +4 -1
- data/app/components/katalyst/tables/body_cell_component.rb +4 -1
- data/app/components/katalyst/tables/body_row_component.rb +4 -1
- data/app/components/katalyst/tables/empty_caption_component.rb +1 -1
- data/app/components/katalyst/tables/header_cell_component.rb +4 -1
- data/app/components/katalyst/tables/header_row_component.rb +4 -1
- data/lib/katalyst/tables.rb +1 -1
- metadata +3 -5
- data/app/components/concerns/katalyst/tables/has_html_attributes.rb +0 -83
- data/lib/katalyst/tables/version.rb +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 93183f42b6a85c9ec376968ac1afd2c4481c16dc69d36bc0c42fc533ff73cb23
|
4
|
+
data.tar.gz: db5e89db2a8b56280a64c9183c51c984905d364e141d410e1f3718fad1353cc2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
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
|
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
|
@@ -4,7 +4,7 @@ module Katalyst
|
|
4
4
|
module Tables
|
5
5
|
class HeaderCellComponent < ViewComponent::Base # :nodoc:
|
6
6
|
include Frontend::Helper
|
7
|
-
include
|
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
|
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
|
data/lib/katalyst/tables.rb
CHANGED
@@ -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.
|
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
|
+
date: 2023-12-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name: html-attributes
|
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
|