katalyst-tables 3.7.0 → 3.8.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 (40) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +14 -0
  3. data/app/assets/builds/katalyst/tables.min.js.map +1 -1
  4. data/app/assets/images/katalyst/tables/icons/sort-asc.svg +3 -0
  5. data/app/assets/images/katalyst/tables/icons/sort-desc.svg +3 -0
  6. data/app/assets/stylesheets/katalyst/_tables.scss +3 -0
  7. data/app/assets/stylesheets/katalyst/tables/query.css +142 -0
  8. data/app/assets/stylesheets/katalyst/tables/{_summary.scss → summary.css} +1 -1
  9. data/app/assets/stylesheets/katalyst/tables/table.css +164 -0
  10. data/app/assets/stylesheets/katalyst/tables.css +3 -0
  11. data/app/components/concerns/katalyst/tables/orderable.rb +1 -1
  12. data/app/components/concerns/katalyst/tables/sortable.rb +1 -1
  13. data/app/components/katalyst/summary_table_component.rb +4 -2
  14. data/app/components/katalyst/table_component.rb +5 -1
  15. data/app/components/katalyst/tables/cells/boolean_component.rb +1 -1
  16. data/app/components/katalyst/tables/cells/currency_component.rb +1 -1
  17. data/app/components/katalyst/tables/cells/date_component.rb +1 -1
  18. data/app/components/katalyst/tables/cells/date_time_component.rb +1 -1
  19. data/app/components/katalyst/tables/cells/enum_component.rb +1 -1
  20. data/app/components/katalyst/tables/cells/number_component.rb +1 -1
  21. data/app/components/katalyst/tables/cells/ordinal_component.rb +3 -3
  22. data/app/components/katalyst/tables/cells/rich_text_component.rb +1 -1
  23. data/app/components/katalyst/tables/cells/select_component.rb +4 -4
  24. data/app/components/katalyst/tables/query/input_component.html.erb +1 -1
  25. data/app/components/katalyst/tables/query/modal_component.html.erb +1 -1
  26. data/app/components/katalyst/tables/query_component.rb +2 -1
  27. data/lib/katalyst/tables/collection/type/date.rb +2 -2
  28. metadata +9 -15
  29. data/app/assets/stylesheets/katalyst/tables/_index.scss +0 -3
  30. data/app/assets/stylesheets/katalyst/tables/_ordinal.scss +0 -38
  31. data/app/assets/stylesheets/katalyst/tables/_query.scss +0 -142
  32. data/app/assets/stylesheets/katalyst/tables/_select.scss +0 -7
  33. data/app/assets/stylesheets/katalyst/tables/_table.scss +0 -128
  34. data/app/assets/stylesheets/katalyst/tables/typed-columns/_boolean.scss +0 -4
  35. data/app/assets/stylesheets/katalyst/tables/typed-columns/_currency.scss +0 -8
  36. data/app/assets/stylesheets/katalyst/tables/typed-columns/_date.scss +0 -4
  37. data/app/assets/stylesheets/katalyst/tables/typed-columns/_datetime.scss +0 -4
  38. data/app/assets/stylesheets/katalyst/tables/typed-columns/_enum.scss +0 -19
  39. data/app/assets/stylesheets/katalyst/tables/typed-columns/_index.scss +0 -6
  40. data/app/assets/stylesheets/katalyst/tables/typed-columns/_number.scss +0 -8
@@ -58,7 +58,7 @@ module Katalyst
58
58
  end
59
59
 
60
60
  def default_html_attributes
61
- { data: { turbo_action: "replace" } }
61
+ { class: "sortable", data: { turbo_action: "replace" } }
62
62
  end
63
63
  end
64
64
  end
@@ -21,8 +21,6 @@ module Katalyst
21
21
  super(collection: [model], **)
22
22
 
23
23
  @summary_rows = []
24
-
25
- update_html_attributes(class: "summary-table")
26
24
  end
27
25
 
28
26
  def with_cell(cell, &)
@@ -40,5 +38,9 @@ module Katalyst
40
38
  @index += 1
41
39
  end
42
40
  end
41
+
42
+ def default_html_attributes
43
+ { class: "katalyst--summary-table" }
44
+ end
43
45
  end
44
46
  end
@@ -230,7 +230,7 @@ module Katalyst
230
230
  # @example Render a generic text column for any value that supports `to_s`
231
231
  # <% row.enum :status %>
232
232
  # <%# label => <th>Status</th> %>
233
- # <%# data => <td class="type-enum"><span data-enum="status" data-value="published">Published</span></td> %>
233
+ # <%# data => <td data-cell-type="enum"><span data-enum="status" data-value="published">Published</span></td> %>
234
234
  def enum(column, label: nil, heading: false, **, &)
235
235
  with_cell(Tables::Cells::EnumComponent.new(
236
236
  collection:, row:, column:, record:, label:, heading:, **,
@@ -317,6 +317,10 @@ module Katalyst
317
317
 
318
318
  private
319
319
 
320
+ def default_html_attributes
321
+ { class: "katalyst--table" }
322
+ end
323
+
320
324
  # Extension point for subclasses and extensions to customize header row rendering.
321
325
  def add_header_row_callback(&block)
322
326
  @header_row_callbacks << block
@@ -12,7 +12,7 @@ module Katalyst
12
12
  private
13
13
 
14
14
  def default_html_attributes
15
- { class: "type-boolean" }
15
+ { data: { cell_type: "boolean" } }
16
16
  end
17
17
  end
18
18
  end
@@ -40,7 +40,7 @@ module Katalyst
40
40
  private
41
41
 
42
42
  def default_html_attributes
43
- { class: "type-currency" }
43
+ { data: { cell_type: "currency" } }
44
44
  end
45
45
  end
46
46
  end
@@ -26,7 +26,7 @@ module Katalyst
26
26
 
27
27
  def default_html_attributes
28
28
  {
29
- class: "type-date",
29
+ data: { cell_type: "date" },
30
30
  title: (absolute_time if row.body? && @relative && value.present? && days_ago_in_words(value).present?),
31
31
  }
32
32
  end
@@ -28,7 +28,7 @@ module Katalyst
28
28
 
29
29
  def default_html_attributes
30
30
  {
31
- class: "type-datetime",
31
+ data: { cell_type: "datetime" },
32
32
  title: (absolute_time if row.body? && @relative && today?),
33
33
  }
34
34
  end
@@ -15,7 +15,7 @@ module Katalyst
15
15
  private
16
16
 
17
17
  def default_html_attributes
18
- { class: "type-enum" }
18
+ { data: { cell_type: "enum" } }
19
19
  end
20
20
  end
21
21
  end
@@ -44,7 +44,7 @@ module Katalyst
44
44
  private
45
45
 
46
46
  def default_html_attributes
47
- { class: "type-number" }
47
+ { data: { cell_type: "number" } }
48
48
  end
49
49
  end
50
50
  end
@@ -18,11 +18,11 @@ module Katalyst
18
18
 
19
19
  def default_html_attributes
20
20
  if @row.header?
21
- { class: "ordinal" }
21
+ { data: { cell_type: "ordinal" } }
22
22
  else
23
23
  {
24
- class: "ordinal",
25
- data: {
24
+ data: {
25
+ cell_type: "ordinal",
26
26
  controller: Orderable::ITEM_CONTROLLER,
27
27
  "#{Orderable::ITEM_CONTROLLER}-params-value": params.to_json,
28
28
  },
@@ -11,7 +11,7 @@ module Katalyst
11
11
 
12
12
  def default_html_attributes
13
13
  {
14
- class: "type-rich-text",
14
+ data: { cell_type: "rich-text" },
15
15
  title: (value.to_plain_text unless row.header?),
16
16
  }
17
17
  end
@@ -24,16 +24,16 @@ module Katalyst
24
24
  def default_html_attributes
25
25
  if @row.header?
26
26
  {
27
- class: "selection",
28
- data: {
27
+ data: {
28
+ cell_type: "selection",
29
29
  "#{Selectable::TABLE_CONTROLLER}-target" => "header",
30
30
  action: "change->#{Selectable::TABLE_CONTROLLER}#toggleHeader",
31
31
  },
32
32
  }
33
33
  else
34
34
  {
35
- class: "selection",
36
- data: {
35
+ data: {
36
+ cell_type: "selection",
37
37
  controller: Selectable::ITEM_CONTROLLER,
38
38
  action: "change->#{Selectable::ITEM_CONTROLLER}#change",
39
39
  "#{Selectable::ITEM_CONTROLLER}-params-value" => @params.to_json,
@@ -15,5 +15,5 @@
15
15
  ) %>
16
16
  <div aria-hidden="true" class="highlight" data-tables--query-input-target="highlight"><%= form.object.query %></div>
17
17
  <%= form.hidden_field(:p) %>
18
- <%= form.button("Apply", type: :submit, name: nil, tabindex: -1) %>
18
+ <%= form.button("Apply", type: :submit, name: nil, tabindex: -1, class: "button") %>
19
19
  <% end %>
@@ -9,7 +9,7 @@
9
9
  <div class="content">
10
10
  <% if suggestions? %>
11
11
  <h4 id="suggestions-title"><%= t(".suggestions_title") %></h4>
12
- <ul id="suggestions" role="listbox" aria-labelledby="suggestions-title">
12
+ <ul id="suggestions" class="suggestions" role="listbox" aria-labelledby="suggestions-title">
13
13
  <% suggestions.each do |suggestion| %>
14
14
  <%= render suggestion %>
15
15
  <% end %>
@@ -80,7 +80,8 @@ module Katalyst
80
80
 
81
81
  def default_html_attributes
82
82
  {
83
- data: {
83
+ class: "katalyst--tables--query",
84
+ data: {
84
85
  controller: "tables--query",
85
86
  turbo_action: :replace,
86
87
  action: %w[
@@ -7,6 +7,8 @@ module Katalyst
7
7
  class Date < Value
8
8
  include Helpers::Range
9
9
 
10
+ ISO_DATE = /\A(?<year>\d{4})-(?<month>\d\d)-(?<day>\d\d)\z/
11
+
10
12
  define_range_patterns /\d{4}-\d\d-\d\d/
11
13
 
12
14
  def type
@@ -34,8 +36,6 @@ module Katalyst
34
36
 
35
37
  private
36
38
 
37
- ISO_DATE = /\A(?<year>\d{4})-(?<month>\d\d)-(?<day>\d\d)\z/
38
-
39
39
  def cast_value(value)
40
40
  return value unless value.is_a?(::String)
41
41
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: katalyst-tables
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.7.0
4
+ version: 3.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Katalyst Interactive
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-01-13 00:00:00.000000000 Z
10
+ date: 2025-03-12 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: katalyst-html-attributes
@@ -53,19 +53,13 @@ files:
53
53
  - app/assets/builds/katalyst/tables.min.js
54
54
  - app/assets/builds/katalyst/tables.min.js.map
55
55
  - app/assets/config/katalyst-tables.js
56
- - app/assets/stylesheets/katalyst/tables/_index.scss
57
- - app/assets/stylesheets/katalyst/tables/_ordinal.scss
58
- - app/assets/stylesheets/katalyst/tables/_query.scss
59
- - app/assets/stylesheets/katalyst/tables/_select.scss
60
- - app/assets/stylesheets/katalyst/tables/_summary.scss
61
- - app/assets/stylesheets/katalyst/tables/_table.scss
62
- - app/assets/stylesheets/katalyst/tables/typed-columns/_boolean.scss
63
- - app/assets/stylesheets/katalyst/tables/typed-columns/_currency.scss
64
- - app/assets/stylesheets/katalyst/tables/typed-columns/_date.scss
65
- - app/assets/stylesheets/katalyst/tables/typed-columns/_datetime.scss
66
- - app/assets/stylesheets/katalyst/tables/typed-columns/_enum.scss
67
- - app/assets/stylesheets/katalyst/tables/typed-columns/_index.scss
68
- - app/assets/stylesheets/katalyst/tables/typed-columns/_number.scss
56
+ - app/assets/images/katalyst/tables/icons/sort-asc.svg
57
+ - app/assets/images/katalyst/tables/icons/sort-desc.svg
58
+ - app/assets/stylesheets/katalyst/_tables.scss
59
+ - app/assets/stylesheets/katalyst/tables.css
60
+ - app/assets/stylesheets/katalyst/tables/query.css
61
+ - app/assets/stylesheets/katalyst/tables/summary.css
62
+ - app/assets/stylesheets/katalyst/tables/table.css
69
63
  - app/components/concerns/katalyst/tables/has_table_content.rb
70
64
  - app/components/concerns/katalyst/tables/identifiable.rb
71
65
  - app/components/concerns/katalyst/tables/orderable.rb
@@ -1,3 +0,0 @@
1
- @use "query";
2
- @use "table";
3
- @use "summary";
@@ -1,38 +0,0 @@
1
- $width: 2rem !default;
2
- $time: 125ms !default;
3
-
4
- table {
5
- tr {
6
- transition:
7
- top $time ease-in-out,
8
- transform $time ease-in-out;
9
- }
10
-
11
- tr[dragging] {
12
- transition: transform $time ease-in-out;
13
- filter: drop-shadow(0 0 0.5rem var(--row-border-color));
14
- transform: scale(1.01);
15
- td {
16
- box-shadow: none;
17
- }
18
- }
19
-
20
- th.ordinal {
21
- width: $width;
22
- padding-left: 0;
23
- a {
24
- width: $width;
25
- height: 3rem;
26
- }
27
- a::after {
28
- margin-left: 0.4rem;
29
- }
30
- }
31
-
32
- td.ordinal {
33
- width: $width;
34
- padding-left: 0;
35
- cursor: grab;
36
- text-align: center;
37
- }
38
- }
@@ -1,142 +0,0 @@
1
- [data-controller="tables--query"] {
2
- position: relative;
3
-
4
- .query-input {
5
- position: relative;
6
- display: grid;
7
- grid-template-areas: "input button";
8
- grid-template-columns: 1fr auto;
9
-
10
- [role="combobox"] {
11
- grid-area: input;
12
- background: transparent;
13
- caret-color: black;
14
- resize: none;
15
- }
16
-
17
- &[data-connected] [role="combobox"] {
18
- color: transparent;
19
- }
20
-
21
- button {
22
- grid-area: button;
23
- flex: 0;
24
- }
25
-
26
- .highlight {
27
- grid-area: input;
28
- visibility: hidden;
29
- border: 1px solid transparent;
30
- color: black;
31
- z-index: -1;
32
- font-size: 1rem;
33
- padding: 2px;
34
-
35
- overflow-wrap: break-word;
36
- white-space: pre-wrap;
37
-
38
- .value {
39
- color: #666666;
40
- }
41
- }
42
-
43
- &[data-connected] .highlight {
44
- visibility: visible;
45
- }
46
- }
47
- }
48
-
49
- .query-modal {
50
- --suggestion-hover: rgba(0, 0, 0, 0.1);
51
- --suggestion-selected: #888;
52
-
53
- position: absolute;
54
- top: 100%;
55
- left: 0;
56
- right: 0;
57
- border: 1px solid rgba(0, 0, 0, 0.16);
58
- box-shadow:
59
- 0 3px 6px rgba(0, 0, 0, 0.16),
60
- 0 3px 6px rgba(0, 0, 0, 0.23);
61
- background: white;
62
- border-radius: 4px;
63
- z-index: 1;
64
- opacity: 0;
65
- transition: opacity 0.125s;
66
- pointer-events: none;
67
- display: grid;
68
- grid-template-areas: "header" "content" "footer";
69
- grid-template-rows: auto 1fr auto;
70
-
71
- &[data-open] {
72
- opacity: 1;
73
- pointer-events: unset;
74
- }
75
-
76
- header {
77
- grid-area: header;
78
- }
79
-
80
- .content {
81
- grid-area: content;
82
- padding-top: 0.5rem;
83
- }
84
-
85
- h4 {
86
- padding-inline: 1rem;
87
- }
88
-
89
- ul {
90
- margin-block: 0;
91
- padding-inline-start: 0;
92
- list-style: none;
93
-
94
- li {
95
- position: relative;
96
- display: flex;
97
- align-items: baseline;
98
- padding-inline: 1rem;
99
- padding-block: 0.125rem;
100
-
101
- &[aria-selected="true"],
102
- &:hover {
103
- outline: none;
104
- background: var(--suggestion-hover);
105
- }
106
-
107
- &[aria-selected="true"]::after {
108
- content: "";
109
- position: absolute;
110
- left: 0;
111
- top: 0;
112
- bottom: 0;
113
- width: 4px;
114
- background: var(--suggestion-selected);
115
- }
116
-
117
- &:hover {
118
- cursor: pointer;
119
- }
120
- }
121
- }
122
-
123
- .error {
124
- background: #fff2f2;
125
- border-bottom: 1px solid #fdd3d3;
126
- padding: 0.5rem 1rem;
127
-
128
- code {
129
- font-weight: bold;
130
- }
131
- }
132
-
133
- footer {
134
- grid-area: footer;
135
- display: flex;
136
- justify-content: flex-start;
137
- padding-inline: 1rem;
138
- padding-block: 0.5rem;
139
- border-top: 1px solid #d3d3d3;
140
- font-size: small;
141
- }
142
- }
@@ -1,7 +0,0 @@
1
- :where(th.selection, td.selection) {
2
- width: 2rem;
3
-
4
- label {
5
- display: block;
6
- }
7
- }
@@ -1,128 +0,0 @@
1
- @use "ordinal" as *;
2
- @use "select" as *;
3
- @use "typed-columns";
4
-
5
- $grey: #f0ecf3 !default;
6
-
7
- $table-header-color: transparent !default;
8
- $row-border-color: $grey !default;
9
- $row-height: 48px !default;
10
- $cell-spacing: 0.5rem !default;
11
- $tag-color: $grey !default;
12
- $on-tag-color: black !default;
13
-
14
- $width-small: 6rem !default;
15
- $width-medium: 12rem !default;
16
- $width-large: 16rem !default;
17
-
18
- table {
19
- --row-height: #{$row-height};
20
- --cell-spacing: #{$cell-spacing};
21
- --table-header-color: #{$table-header-color};
22
- --row-border-color: #{$row-border-color};
23
- --tag-color: #{$tag-color};
24
- --on-tag-color: #{$on-tag-color};
25
-
26
- --width-small: #{$width-small};
27
- --width-medium: #{$width-medium};
28
- --width-large: #{$width-large};
29
- }
30
-
31
- table {
32
- border: none;
33
- table-layout: fixed;
34
- border-collapse: collapse;
35
- text-align: left;
36
- width: 100%;
37
-
38
- thead {
39
- background: var(--table-header-color);
40
- }
41
-
42
- tr {
43
- height: var(--row-height);
44
- line-height: var(--row-height);
45
- }
46
-
47
- th,
48
- td {
49
- border: none;
50
- box-shadow: inset 0px -1px 0px var(--row-border-color);
51
- overflow: hidden;
52
- text-overflow: ellipsis;
53
- vertical-align: top;
54
- white-space: nowrap;
55
- background-color: white;
56
- padding-right: var(--cell-spacing);
57
-
58
- &:last-child {
59
- padding-right: 0;
60
- }
61
-
62
- > a {
63
- display: block;
64
- overflow: hidden;
65
- white-space: nowrap;
66
- text-overflow: ellipsis;
67
- text-decoration: none;
68
- }
69
-
70
- > img,
71
- > a > img {
72
- max-height: 3rem;
73
- padding: 0;
74
- }
75
-
76
- > .trix-content {
77
- overflow: hidden;
78
- text-overflow: ellipsis;
79
- }
80
- }
81
-
82
- th {
83
- font-weight: bold;
84
-
85
- :where(&.width-s) {
86
- width: var(--width-small);
87
- }
88
-
89
- :where(&.width-m) {
90
- width: var(--width-medium);
91
- }
92
-
93
- :where(&.width-l) {
94
- width: var(--width-large);
95
- }
96
- }
97
-
98
- thead a.ascending:after,
99
- [data-sort="asc"] a::after {
100
- display: inline-block;
101
- content: " ";
102
- position: relative;
103
- margin-left: 1rem;
104
- background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 13'%3E%3Cpath d='M.541 0l11.125 12.573a.5.5 0 00.749 0L23.541 0h-23z' fill='%23000' fill-rule='evenodd'/%3E%3C/svg%3E");
105
- background-size: 14px 14px;
106
- height: 14px;
107
- width: 14px;
108
- top: 0;
109
- transform: rotate(180deg);
110
- }
111
-
112
- thead a.descending:after,
113
- [data-sort="desc"] a::after {
114
- display: inline-block;
115
- content: " ";
116
- position: relative;
117
- margin-left: 1rem;
118
- background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 13'%3E%3Cpath d='M.541 0l11.125 12.573a.5.5 0 00.749 0L23.541 0h-23z' fill='%23000' fill-rule='evenodd'/%3E%3C/svg%3E");
119
- background-size: 14px 14px;
120
- height: 14px;
121
- width: 14px;
122
- top: 4px;
123
- }
124
-
125
- caption {
126
- margin: 2rem 0;
127
- }
128
- }
@@ -1,4 +0,0 @@
1
- // where psuedo selector has a specificity of 0 so it can be easily overwritten with simple selectors
2
- :where(th.type-boolean, td.type-boolean) {
3
- width: var(--width-small);
4
- }
@@ -1,8 +0,0 @@
1
- // where psuedo selector has a specificity of 0 so it can be easily overwritten with simple selectors
2
- :where(th.type-currency, td.type-currency) {
3
- width: var(--width-small);
4
- }
5
-
6
- :where(thead th.type-currency, td.type-currency) {
7
- text-align: right;
8
- }
@@ -1,4 +0,0 @@
1
- // where psuedo selector has a specificity of 0 so it can be easily overwritten with simple selectors
2
- :where(th.type-date, td.type-date) {
3
- width: var(--width-small);
4
- }
@@ -1,4 +0,0 @@
1
- // where psuedo selector has a specificity of 0 so it can be easily overwritten with simple selectors
2
- :where(th.type-datetime, td.type-datetime) {
3
- width: var(--width-medium);
4
- }
@@ -1,19 +0,0 @@
1
- :where(th.type-enum, td.type-enum) {
2
- width: var(--width-small);
3
- }
4
-
5
- :where(td.type-enum) {
6
- // ensure ellipsis is the correct color
7
- color: var(--on-tag-color);
8
-
9
- small {
10
- background: var(--tag-color);
11
- border-radius: 0.25rem;
12
- padding: 0.25rem;
13
- font-size: small;
14
- }
15
- }
16
-
17
- table td.type-enum {
18
- text-overflow: unset;
19
- }
@@ -1,6 +0,0 @@
1
- @use "boolean";
2
- @use "currency";
3
- @use "date";
4
- @use "datetime";
5
- @use "enum";
6
- @use "number";
@@ -1,8 +0,0 @@
1
- // where psuedo selector has a specificity of 0 so it can be easily overwritten with simple selectors
2
- :where(th.type-number, td.type-number) {
3
- width: var(--width-small);
4
- }
5
-
6
- :where(thead th.type-number, td.type-number) {
7
- text-align: right;
8
- }