katalyst-tables 3.12.1 → 3.13.1
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/CHANGELOG.md +7 -0
- data/app/assets/images/katalyst/tables/icons/sort-asc.svg +1 -3
- data/app/assets/images/katalyst/tables/icons/sort-desc.svg +1 -3
- data/app/assets/stylesheets/katalyst/tables/summary.css +31 -6
- data/app/assets/stylesheets/katalyst/tables/table.css +17 -16
- data/app/components/concerns/katalyst/tables/has_table_content.rb +3 -3
- data/app/components/concerns/katalyst/tables/selectable.rb +2 -2
- data/app/components/concerns/katalyst/tables/sortable.rb +7 -7
- data/app/components/katalyst/table_component.rb +3 -3
- data/app/components/katalyst/tables/cell_component.rb +4 -4
- data/app/components/katalyst/tables/cells/date_time_component.rb +1 -1
- data/app/components/katalyst/tables/cells/number_component.rb +1 -1
- data/app/components/katalyst/tables/cells/select_component.rb +1 -1
- data/app/components/katalyst/tables/label.rb +2 -2
- data/app/components/katalyst/tables/query_component.rb +1 -1
- data/app/helpers/katalyst/tables/frontend.rb +2 -2
- data/app/models/concerns/katalyst/tables/collection/has_params.rb +1 -2
- data/app/models/concerns/katalyst/tables/collection/pagination.rb +1 -1
- data/app/models/concerns/katalyst/tables/collection/query/parser.rb +2 -2
- data/app/models/concerns/katalyst/tables/collection/query/untagged_literal.rb +1 -1
- data/app/models/concerns/katalyst/tables/collection/query/value_parser.rb +1 -1
- data/app/models/katalyst/tables/suggestions/constant_value.rb +1 -1
- data/app/models/katalyst/tables/suggestions/custom_value.rb +1 -1
- data/app/models/katalyst/tables/suggestions/database_value.rb +1 -1
- data/lib/katalyst/tables/collection/type/enum.rb +2 -2
- data/lib/katalyst/tables/collection/type/helpers/range.rb +1 -1
- data/lib/katalyst/tables/collection/type/search.rb +1 -2
- data/lib/katalyst/tables/collection/type/string.rb +1 -1
- data/lib/katalyst/tables/collection/type/value.rb +3 -3
- data/lib/katalyst/tables/config.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 23a8a8a1807a0f6355a6c8b8dfd8a79b8654b42f49f4e04ddffa95a152658ec5
|
|
4
|
+
data.tar.gz: b4b62f128a45aac4bd9fbb32218288ce861951a673c420075e91acff9f2243a9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 428907f63918d7f3497729b1ebb7605028bd4e8d467ce2681941ce629532b9cab778e2f6d3420305fff6b0683deefa9197b69321f782b4ea9b442727643a4039
|
|
7
|
+
data.tar.gz: 5a484636e22f700bf9721c123855998dbfaa7b732939ad60f0e3af4bfde70292f156785c61acc63a39e6eb859845a03c68d329373875cd9985d395795f3ce0b2
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [3.13.0]
|
|
2
|
+
|
|
3
|
+
Default style overhaul for .katalyst--summary-table (BREAKING CHANGE)
|
|
4
|
+
* Use grid instead of table layout to support more complex alignment
|
|
5
|
+
* Respond to stacked layout on mobile
|
|
6
|
+
* Users will likely want to make spacing and layout tweaks depending on table style
|
|
7
|
+
|
|
1
8
|
## [3.12.0]
|
|
2
9
|
|
|
3
10
|
* Support for ordering variable height rows
|
|
@@ -1,3 +1 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"
|
|
2
|
-
<path d="M8 1V15M8 15L15 8M8 15L1 8" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
3
|
-
</svg>
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 16 16"><path stroke="#000" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 1v14m0 0 7-7m-7 7L1 8"/></svg>
|
|
@@ -1,3 +1 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"
|
|
2
|
-
<path d="M8 15V1M8 1L15 8M8 1L1 8" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
3
|
-
</svg>
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 16 16"><path stroke="#000" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 15V1m0 0 7 7M8 1 1 8"/></svg>
|
|
@@ -1,17 +1,42 @@
|
|
|
1
1
|
.katalyst--summary-table {
|
|
2
|
-
width:
|
|
3
|
-
|
|
2
|
+
--table-min-width: min(60ch, 100cqi);
|
|
3
|
+
--table-max-width: 100%;
|
|
4
|
+
--label-min-width: min(20ch, 33cqi);
|
|
5
|
+
--label-width: clamp(12ch, 33cqi, 30ch);
|
|
4
6
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
+
display: grid;
|
|
8
|
+
grid-template-columns: fit-content(var(--label-width)) 1fr;
|
|
9
|
+
align-items: stretch;
|
|
10
|
+
|
|
11
|
+
width: fit-content;
|
|
12
|
+
min-width: var(--table-min-width);
|
|
13
|
+
max-width: var(--table-max-width);
|
|
14
|
+
|
|
15
|
+
tbody,
|
|
16
|
+
tr {
|
|
17
|
+
display: contents;
|
|
7
18
|
}
|
|
8
19
|
|
|
9
20
|
th,
|
|
10
21
|
td {
|
|
11
|
-
|
|
12
|
-
|
|
22
|
+
overflow-wrap: anywhere;
|
|
23
|
+
hyphens: auto;
|
|
13
24
|
}
|
|
14
25
|
|
|
26
|
+
th {
|
|
27
|
+
min-width: var(--label-min-width);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@container (width < 60ch) {
|
|
32
|
+
.katalyst--summary-table {
|
|
33
|
+
grid-template-columns: 1fr;
|
|
34
|
+
min-width: unset;
|
|
35
|
+
width: 100%;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.katalyst--summary-table {
|
|
15
40
|
:where([data-cell-type="enum"]) {
|
|
16
41
|
[data-enum] {
|
|
17
42
|
background: var(--tag-background-color, var(--color-tint, #f0ecf3));
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
/* Select */
|
|
79
79
|
|
|
80
80
|
:where([data-cell-type="selection"]) {
|
|
81
|
-
|
|
81
|
+
width: 2rem;
|
|
82
82
|
|
|
83
83
|
label {
|
|
84
84
|
display: block;
|
|
@@ -98,28 +98,29 @@
|
|
|
98
98
|
aspect-ratio: 1;
|
|
99
99
|
height: 1.5ex;
|
|
100
100
|
line-height: 1;
|
|
101
|
-
background:
|
|
102
|
-
background-size: contain;
|
|
101
|
+
background: currentColor;
|
|
103
102
|
transform: translateY(0.1ex);
|
|
104
103
|
margin-inline-start: var(--space-2xs, 0.5rem);
|
|
104
|
+
opacity: 0;
|
|
105
|
+
-webkit-mask: url("icons/sort-asc.svg") no-repeat center;
|
|
106
|
+
mask: url("icons/sort-asc.svg") no-repeat center;
|
|
107
|
+
transition: opacity var(--animation-duration, 125ms);
|
|
105
108
|
}
|
|
106
109
|
|
|
110
|
+
/* Unsorted + hover/focus: ghost arrow */
|
|
107
111
|
a:is(.sortable):hover::after,
|
|
108
|
-
a:is(.sortable):focus-visible::after
|
|
109
|
-
|
|
110
|
-
[data-sort="desc"] a:is(.sortable):hover::after,
|
|
111
|
-
[data-sort="desc"] a:is(.sortable):focus-visible::after {
|
|
112
|
-
background: currentColor;
|
|
113
|
-
-webkit-mask: url("/katalyst/tables/icons/sort-asc.svg") no-repeat center;
|
|
114
|
-
mask: url("/katalyst/tables/icons/sort-asc.svg") no-repeat center;
|
|
112
|
+
a:is(.sortable):focus-visible::after {
|
|
113
|
+
opacity: 0.3;
|
|
115
114
|
}
|
|
116
115
|
|
|
117
|
-
|
|
118
|
-
[data-sort
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
116
|
+
/* Sorted: solid state arrow */
|
|
117
|
+
[data-sort] a:is(.sortable)::after {
|
|
118
|
+
opacity: 1;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
[data-sort="desc"] a:is(.sortable)::after {
|
|
122
|
+
-webkit-mask: url("icons/sort-desc.svg") no-repeat center;
|
|
123
|
+
mask: url("icons/sort-desc.svg") no-repeat center;
|
|
123
124
|
}
|
|
124
125
|
|
|
125
126
|
/* Width and wrapping */
|
|
@@ -15,7 +15,7 @@ module Katalyst
|
|
|
15
15
|
|
|
16
16
|
def before_render
|
|
17
17
|
# move @__vc_render_in_block to @row_proc to avoid slot lookup attempting to call it
|
|
18
|
-
@row_proc
|
|
18
|
+
@row_proc = @__vc_render_in_block
|
|
19
19
|
@__vc_render_in_block = nil
|
|
20
20
|
end
|
|
21
21
|
|
|
@@ -26,11 +26,11 @@ module Katalyst
|
|
|
26
26
|
private
|
|
27
27
|
|
|
28
28
|
def row_content(row, record)
|
|
29
|
-
@current_row
|
|
29
|
+
@current_row = row
|
|
30
30
|
@current_record = record
|
|
31
31
|
row_proc.call(self, record)
|
|
32
32
|
ensure
|
|
33
|
-
@current_row
|
|
33
|
+
@current_row = nil
|
|
34
34
|
@current_record = nil
|
|
35
35
|
end
|
|
36
36
|
|
|
@@ -7,9 +7,9 @@ module Katalyst
|
|
|
7
7
|
module Selectable
|
|
8
8
|
extend ActiveSupport::Concern
|
|
9
9
|
|
|
10
|
-
FORM_CONTROLLER
|
|
10
|
+
FORM_CONTROLLER = "tables--selection--form"
|
|
11
11
|
TABLE_CONTROLLER = "tables--selection--table"
|
|
12
|
-
ITEM_CONTROLLER
|
|
12
|
+
ITEM_CONTROLLER = "tables--selection--item"
|
|
13
13
|
|
|
14
14
|
# Returns the default dom id for the selection form, uses the table's
|
|
15
15
|
# default id with '_selection' appended.
|
|
@@ -33,7 +33,7 @@ module Katalyst
|
|
|
33
33
|
super(**)
|
|
34
34
|
|
|
35
35
|
@collection = collection
|
|
36
|
-
@cell
|
|
36
|
+
@cell = cell
|
|
37
37
|
end
|
|
38
38
|
|
|
39
39
|
def call
|
|
@@ -46,12 +46,12 @@ module Katalyst
|
|
|
46
46
|
# Implementation inspired by pagy's `pagy_url_for` helper.
|
|
47
47
|
# Preserve any existing GET parameters
|
|
48
48
|
# CAUTION: these parameters are not sanitised
|
|
49
|
-
sort
|
|
50
|
-
params
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
49
|
+
sort = column && collection.toggle_sort(column)
|
|
50
|
+
params = if sort && !sort.eql?(collection.default_sort)
|
|
51
|
+
request.GET.merge("sort" => sort).except("page")
|
|
52
|
+
else
|
|
53
|
+
request.GET.except("page", "sort")
|
|
54
|
+
end
|
|
55
55
|
query_string = params.empty? ? "" : "?#{Rack::Utils.build_nested_query(params)}"
|
|
56
56
|
|
|
57
57
|
"#{request.path}#{query_string}"
|
|
@@ -61,10 +61,10 @@ module Katalyst
|
|
|
61
61
|
# caption: true means render the caption, caption: false means no caption, if a hash, passes as options
|
|
62
62
|
@caption_options = caption
|
|
63
63
|
|
|
64
|
-
@header_row_callbacks
|
|
65
|
-
@body_row_callbacks
|
|
64
|
+
@header_row_callbacks = []
|
|
65
|
+
@body_row_callbacks = []
|
|
66
66
|
@header_row_cell_callbacks = []
|
|
67
|
-
@body_row_cell_callbacks
|
|
67
|
+
@body_row_cell_callbacks = []
|
|
68
68
|
|
|
69
69
|
super(generate_ids:, object_name:, partial:, as:, **)
|
|
70
70
|
end
|
|
@@ -11,10 +11,10 @@ module Katalyst
|
|
|
11
11
|
super(**)
|
|
12
12
|
|
|
13
13
|
@collection = collection
|
|
14
|
-
@row
|
|
15
|
-
@column
|
|
16
|
-
@record
|
|
17
|
-
@heading
|
|
14
|
+
@row = row
|
|
15
|
+
@column = column
|
|
16
|
+
@record = record
|
|
17
|
+
@heading = heading
|
|
18
18
|
|
|
19
19
|
if @row.header?
|
|
20
20
|
@label = Label.new(collection:, column:, label:)
|
|
@@ -63,7 +63,7 @@ module Katalyst
|
|
|
63
63
|
# Caution: requires config.view_component.capture_compatibility_patch_enabled to be set
|
|
64
64
|
def with_form(model: collection, url: @url, method: :get, **options, &block)
|
|
65
65
|
@form_options = { model:, url:, method:, **options }
|
|
66
|
-
@form_block
|
|
66
|
+
@form_block = block
|
|
67
67
|
end
|
|
68
68
|
|
|
69
69
|
def with_modal(collection: self.collection, **, &)
|
|
@@ -35,7 +35,7 @@ module Katalyst
|
|
|
35
35
|
**,
|
|
36
36
|
&)
|
|
37
37
|
component ||= default_table_component_class
|
|
38
|
-
component
|
|
38
|
+
component = component.new(collection:, header:, caption:, generate_ids:, object_name:, partial:, as:, **)
|
|
39
39
|
|
|
40
40
|
render(component, &)
|
|
41
41
|
end
|
|
@@ -81,7 +81,7 @@ module Katalyst
|
|
|
81
81
|
# @yieldparam [nil, Object] nil for the header column, or the given model for the value column
|
|
82
82
|
def summary_table_with(model:, **, &)
|
|
83
83
|
component ||= default_summary_table_component_class
|
|
84
|
-
component
|
|
84
|
+
component = component.new(model:, **)
|
|
85
85
|
|
|
86
86
|
render(component, &)
|
|
87
87
|
end
|
|
@@ -32,11 +32,10 @@ module Katalyst
|
|
|
32
32
|
|
|
33
33
|
# Returns a hash of the current attributes that have changed from defaults.
|
|
34
34
|
# This uses Refinements internally so it needs to be exposed publicly with this super call.
|
|
35
|
-
# rubocop:disable Lint/UselessMethodDefinition
|
|
35
|
+
# rubocop:disable-next Lint/UselessMethodDefinition
|
|
36
36
|
def to_params
|
|
37
37
|
super
|
|
38
38
|
end
|
|
39
|
-
# rubocop:enable Lint/UselessMethodDefinition
|
|
40
39
|
end
|
|
41
40
|
end
|
|
42
41
|
end
|
|
@@ -46,7 +46,7 @@ module Katalyst
|
|
|
46
46
|
class Paginate # :nodoc:
|
|
47
47
|
# Pagy is not a required gem unless you're using pagination
|
|
48
48
|
# Expect to see NoMethodError failures if pagy is not available
|
|
49
|
-
if (pagy_method
|
|
49
|
+
if (pagy_method = "Pagy::Method".safe_constantize)
|
|
50
50
|
include(pagy_method)
|
|
51
51
|
elsif (pagy_backend = "Pagy::Backend".safe_constantize)
|
|
52
52
|
include(pagy_backend)
|
|
@@ -16,12 +16,12 @@ module Katalyst
|
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
def suggestions(scope, attribute)
|
|
19
|
-
model
|
|
19
|
+
model = scope.model
|
|
20
20
|
column = attribute.name
|
|
21
21
|
|
|
22
22
|
if attribute.name.include?(".")
|
|
23
23
|
table_name, column = attribute.name.split(".")
|
|
24
|
-
model
|
|
24
|
+
model = scope.model.reflections[table_name].klass
|
|
25
25
|
|
|
26
26
|
raise(ArgumentError, "Unknown association '#{table_name}' for #{scope.model}") unless model
|
|
27
27
|
end
|
|
@@ -86,7 +86,7 @@ module Katalyst
|
|
|
86
86
|
# when a value that accepts multiple is given a range, it double-packs the value so we get ..[0]
|
|
87
87
|
# unpack the array value
|
|
88
88
|
from = from.first if from.is_a?(::Array) && from.length == 1
|
|
89
|
-
to
|
|
89
|
+
to = to.first if to.is_a?(::Array) && to.length == 1
|
|
90
90
|
(from..to)
|
|
91
91
|
end
|
|
92
92
|
end
|
|
@@ -6,11 +6,10 @@ module Katalyst
|
|
|
6
6
|
module Type
|
|
7
7
|
class Search < Value
|
|
8
8
|
# @overwrite Value.initialize() to require scope
|
|
9
|
-
# rubocop:disable Lint/UselessMethodDefinition
|
|
9
|
+
# rubocop:disable-next Lint/UselessMethodDefinition
|
|
10
10
|
def initialize(scope:, **)
|
|
11
11
|
super
|
|
12
12
|
end
|
|
13
|
-
# rubocop:enable Lint/UselessMethodDefinition
|
|
14
13
|
|
|
15
14
|
def type
|
|
16
15
|
:search
|
|
@@ -12,7 +12,7 @@ module Katalyst
|
|
|
12
12
|
def initialize(scope: nil, filter: true)
|
|
13
13
|
super()
|
|
14
14
|
|
|
15
|
-
@scope
|
|
15
|
+
@scope = scope
|
|
16
16
|
@filterable = filter
|
|
17
17
|
end
|
|
18
18
|
|
|
@@ -52,12 +52,12 @@ module Katalyst
|
|
|
52
52
|
end
|
|
53
53
|
|
|
54
54
|
def suggestions(scope, attribute, limit: 10, order: :asc)
|
|
55
|
-
model
|
|
55
|
+
model = scope.model
|
|
56
56
|
column = attribute.name
|
|
57
57
|
|
|
58
58
|
if attribute.name.include?(".")
|
|
59
59
|
table_name, column = attribute.name.split(".")
|
|
60
|
-
model
|
|
60
|
+
model = scope.model.reflections[table_name].klass
|
|
61
61
|
|
|
62
62
|
raise(ArgumentError, "Unknown association '#{table_name}' for #{scope.model}") unless model
|
|
63
63
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: katalyst-tables
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.
|
|
4
|
+
version: 3.13.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Katalyst Interactive
|
|
@@ -37,8 +37,10 @@ dependencies:
|
|
|
37
37
|
- - ">="
|
|
38
38
|
- !ruby/object:Gem::Version
|
|
39
39
|
version: 4.0.0
|
|
40
|
-
description: HTML table generator for building tabular index views with filtering,
|
|
40
|
+
description: 'HTML table generator for building tabular index views with filtering,
|
|
41
41
|
sorting, and pagination.
|
|
42
|
+
|
|
43
|
+
'
|
|
42
44
|
email:
|
|
43
45
|
- devs@katalyst.com.au
|
|
44
46
|
executables: []
|
|
@@ -182,7 +184,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
182
184
|
- !ruby/object:Gem::Version
|
|
183
185
|
version: '0'
|
|
184
186
|
requirements: []
|
|
185
|
-
rubygems_version: 4.0.
|
|
187
|
+
rubygems_version: 4.0.16
|
|
186
188
|
specification_version: 4
|
|
187
189
|
summary: HTML table generator for Rails views
|
|
188
190
|
test_files: []
|