katalyst-tables 3.12.1 → 3.13.0

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.
Files changed (27) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +7 -0
  3. data/app/assets/stylesheets/katalyst/tables/summary.css +31 -6
  4. data/app/components/concerns/katalyst/tables/has_table_content.rb +3 -3
  5. data/app/components/concerns/katalyst/tables/selectable.rb +2 -2
  6. data/app/components/concerns/katalyst/tables/sortable.rb +7 -7
  7. data/app/components/katalyst/table_component.rb +3 -3
  8. data/app/components/katalyst/tables/cell_component.rb +4 -4
  9. data/app/components/katalyst/tables/cells/date_time_component.rb +1 -1
  10. data/app/components/katalyst/tables/cells/number_component.rb +1 -1
  11. data/app/components/katalyst/tables/cells/select_component.rb +1 -1
  12. data/app/components/katalyst/tables/label.rb +2 -2
  13. data/app/components/katalyst/tables/query_component.rb +1 -1
  14. data/app/helpers/katalyst/tables/frontend.rb +2 -2
  15. data/app/models/concerns/katalyst/tables/collection/pagination.rb +1 -1
  16. data/app/models/concerns/katalyst/tables/collection/query/parser.rb +2 -2
  17. data/app/models/concerns/katalyst/tables/collection/query/untagged_literal.rb +1 -1
  18. data/app/models/concerns/katalyst/tables/collection/query/value_parser.rb +1 -1
  19. data/app/models/katalyst/tables/suggestions/constant_value.rb +1 -1
  20. data/app/models/katalyst/tables/suggestions/custom_value.rb +1 -1
  21. data/app/models/katalyst/tables/suggestions/database_value.rb +1 -1
  22. data/lib/katalyst/tables/collection/type/enum.rb +2 -2
  23. data/lib/katalyst/tables/collection/type/helpers/range.rb +1 -1
  24. data/lib/katalyst/tables/collection/type/string.rb +1 -1
  25. data/lib/katalyst/tables/collection/type/value.rb +3 -3
  26. data/lib/katalyst/tables/config.rb +1 -1
  27. metadata +5 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 007b144646f8dc19c4c446a46725b662b014d5aea88accddc30e7b92426b3d2a
4
- data.tar.gz: e28722af27d28e8c5fd6bb190b356d4f6da73d3247b02de20c4519802e6e30a0
3
+ metadata.gz: 9a139afe818b1985bc81203a5370dd737fb2df832f83bbb3966407ca299a953b
4
+ data.tar.gz: cb3c47dbcb78cde5243686b8787aa37ee549d2ec1c9eb5b655c7d4cc00319358
5
5
  SHA512:
6
- metadata.gz: '09c6645880695698dcc6f4478b2ca30e550ff48d937ffb49ecad6b482a55d5d0e56f9b2d9a5821df545ac263fe3759af177d4f043c37e17b077cf1c9f8da6fab'
7
- data.tar.gz: 83318a4e3a4069708866d6037ecad1759b83dabc8204e3e301686e1bbbc61ae01b180c787ef7c90d1f6e2513fe15fd38237ce9b82d60734beaf94566c94e305c
6
+ metadata.gz: ee72cb55d174f7510f68ed3c8b6eaaedbcdaf8f3167de81a2d22234dc6fabc5e9e2d769c1d5ad5bdaae7f976643667001e37b8c406ba1edae480c347bb8d3cb1
7
+ data.tar.gz: 137584392a2357aa056b4c45124b1bc11f1d7585b4eaa1ad1901b05d42ecfe479677543351bf30da45c32efd23a1983214c99b21d77e1dfa00d3e1f371bfea14
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,17 +1,42 @@
1
1
  .katalyst--summary-table {
2
- width: unset;
3
- border-top: 1px solid var(--row-border-color);
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
- th {
6
- min-width: 12rem;
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
- vertical-align: baseline;
12
- text-align: left;
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));
@@ -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 = @__vc_render_in_block
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 = row
29
+ @current_row = row
30
30
  @current_record = record
31
31
  row_proc.call(self, record)
32
32
  ensure
33
- @current_row = nil
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 = "tables--selection--form"
10
+ FORM_CONTROLLER = "tables--selection--form"
11
11
  TABLE_CONTROLLER = "tables--selection--table"
12
- ITEM_CONTROLLER = "tables--selection--item"
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 = 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 = 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
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 = row
15
- @column = column
16
- @record = record
17
- @heading = 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:)
@@ -12,7 +12,7 @@ module Katalyst
12
12
  def initialize(format:, relative:, **)
13
13
  super(**)
14
14
 
15
- @format = format
15
+ @format = format
16
16
  @relative = relative
17
17
  end
18
18
 
@@ -12,7 +12,7 @@ module Katalyst
12
12
  def initialize(format:, options:, **)
13
13
  super(**)
14
14
 
15
- @format = format
15
+ @format = format
16
16
  @options = options
17
17
  end
18
18
 
@@ -7,7 +7,7 @@ module Katalyst
7
7
  def initialize(params:, form_id:, **)
8
8
  super(**)
9
9
 
10
- @params = params
10
+ @params = params
11
11
  @form_id = form_id
12
12
  end
13
13
 
@@ -5,8 +5,8 @@ module Katalyst
5
5
  class Label
6
6
  def initialize(collection:, column:, label: nil)
7
7
  @collection = collection
8
- @column = column
9
- @label = label
8
+ @column = column
9
+ @label = label
10
10
  end
11
11
 
12
12
  def value
@@ -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 = 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 = component.new(collection:, header:, caption:, generate_ids:, object_name:, partial:, as:, **)
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 = component.new(model:, **)
84
+ component = component.new(model:, **)
85
85
 
86
86
  render(component, &)
87
87
  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 = "Pagy::Method".safe_constantize)
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)
@@ -11,8 +11,8 @@ module Katalyst
11
11
 
12
12
  def initialize(collection)
13
13
  @collection = collection
14
- @tagged = {}
15
- @untagged = []
14
+ @tagged = {}
15
+ @untagged = []
16
16
  end
17
17
 
18
18
  # @param query [String]
@@ -10,7 +10,7 @@ module Katalyst
10
10
  def initialize(value:, start:)
11
11
  @value = value
12
12
  @start = start
13
- @end = start + value.length
13
+ @end = start + value.length
14
14
  end
15
15
 
16
16
  def literal?
@@ -8,7 +8,7 @@ module Katalyst
8
8
  attr_accessor :query, :key
9
9
 
10
10
  def initialize(key:, start:)
11
- @key = key
11
+ @key = key
12
12
  @start = start
13
13
  end
14
14
 
@@ -10,7 +10,7 @@ module Katalyst
10
10
  super(value)
11
11
 
12
12
  @attribute_type = type
13
- @name = name
13
+ @name = name
14
14
  end
15
15
 
16
16
  def type
@@ -9,7 +9,7 @@ module Katalyst
9
9
  def initialize(value, name:, type:)
10
10
  super(value)
11
11
 
12
- @name = name
12
+ @name = name
13
13
  @attribute_type = type
14
14
  end
15
15
 
@@ -10,7 +10,7 @@ module Katalyst
10
10
  super(value)
11
11
 
12
12
  @attribute_type = type
13
- @name = name
13
+ @name = name
14
14
  end
15
15
 
16
16
  def type
@@ -16,12 +16,12 @@ module Katalyst
16
16
  end
17
17
 
18
18
  def suggestions(scope, attribute)
19
- model = scope.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 = scope.model.reflections[table_name].klass
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 = to.first if to.is_a?(::Array) && to.length == 1
89
+ to = to.first if to.is_a?(::Array) && to.length == 1
90
90
  (from..to)
91
91
  end
92
92
  end
@@ -13,7 +13,7 @@ module Katalyst
13
13
  def initialize(exact: false, **)
14
14
  super(**)
15
15
 
16
- @exact = exact
16
+ @exact = exact
17
17
  @delegate = ActiveModel::Type::String.new
18
18
  end
19
19
 
@@ -12,7 +12,7 @@ module Katalyst
12
12
  def initialize(scope: nil, filter: true)
13
13
  super()
14
14
 
15
- @scope = 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 = scope.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 = scope.model.reflections[table_name].klass
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
 
@@ -27,7 +27,7 @@ module Katalyst
27
27
  Katalyst::Tables::Sortable
28
28
  ]
29
29
 
30
- self.date_format = :default
30
+ self.date_format = :default
31
31
  self.datetime_format = :default
32
32
  end
33
33
  end
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.12.1
4
+ version: 3.13.0
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.6
187
+ rubygems_version: 4.0.16
186
188
  specification_version: 4
187
189
  summary: HTML table generator for Rails views
188
190
  test_files: []