keystone_ui 0.54.0 → 0.55.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 43359bd6e64474a6d13c8d40ce91b0d92883f73f941db147f88ba5a51a7f83e2
4
- data.tar.gz: e204d14c0526bc5ffae69c2fdaa58e094b879a39e035553c09b9ca125a52d270
3
+ metadata.gz: f5b386ab0f7c078b363565555aba8cd927ace939f39ed67b908c4d1b2978f7d2
4
+ data.tar.gz: 52b8ae3921a2f695ede0d7fc2e4d799727c2512aae8aff6291b242ded37ef251
5
5
  SHA512:
6
- metadata.gz: 16845938b705f24c366616906e2d5ae19530143e59e1e411f167bc8c39bf41380975653fc4f10e4e2bee1ea521db1988dff5a71b8f36c954ccac43328f7e31c7
7
- data.tar.gz: 1fa972e398b10bc3c74eaa5b241b46cdf5581139a23f2d2f7044317568aefa72c5d92e7b61e6cb1f0f263e8c32b8e5b977e776b0769ae73645f808281254665d
6
+ metadata.gz: 3f961b433f998ead9d4e13f7e9cdc4e923efeb732c8b77f14987ce64e26423df7fef1307285893ffe89f68706572a179b3196e33dafc53bb7b7852a5b9b879f8
7
+ data.tar.gz: 28cf2cff0b421d1e84bb83edeff44a50c249349ceabb80d4f2216b19751804fdab85caa6c04e3814db3ae005accad2d5116bf648b0ce8d7bb14d019844de7cb1
@@ -44,7 +44,7 @@
44
44
  <% if actions? %><th></th><% end %>
45
45
  </tr>
46
46
  <% end %>
47
- <tr>
47
+ <tr<% if current_row?(idx) %> class="<%= Keystone::Ui::DataTableComponent::CURRENT_ROW_CLASSES %>" aria-current="true"<% end %>>
48
48
  <% row_cells[idx].each do |cell| %>
49
49
  <td class="<%= cell[:classes] %>">
50
50
  <% if cell[:href] %>
@@ -5,6 +5,7 @@ module Keystone
5
5
  class DataTableComponent < ViewComponent::Base
6
6
  EMPTY_CELL_CLASSES = "ks-table-cell-middle text-sm"
7
7
  BODY_CLASSES = "ks-table-body"
8
+ CURRENT_ROW_CLASSES = "ks-table-row-current"
8
9
  HEAD_CLASSES = "ks-table-head"
9
10
  WRAPPER_CLASSES = "ks-table overflow-x-auto"
10
11
  TOOLBAR_CLASSES = "ks-table-toolbar flex justify-end"
@@ -30,8 +31,9 @@ module Keystone
30
31
  SORT_DESC_ICON = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor"><path fill-rule="evenodd" d="M10 3a.75.75 0 0 1 .75.75v10.638l3.96-4.158a.75.75 0 1 1 1.08 1.04l-5.25 5.5a.75.75 0 0 1-1.08 0l-5.25-5.5a.75.75 0 0 1 1.08-1.04l3.96 4.158V3.75A.75.75 0 0 1 10 3Z" clip-rule="evenodd" /></svg>'
31
32
  SORT_NEUTRAL_ICON = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor"><path fill-rule="evenodd" d="M10 3a.75.75 0 0 1 .55.24l3.25 3.5a.75.75 0 1 1-1.1 1.02L10 4.852 7.3 7.76a.75.75 0 0 1-1.1-1.02l3.25-3.5A.75.75 0 0 1 10 3Zm-3.76 9.2a.75.75 0 0 1 1.06.04l2.7 2.908 2.7-2.908a.75.75 0 1 1 1.1 1.02l-3.25 3.5a.75.75 0 0 1-1.1 0l-3.25-3.5a.75.75 0 0 1 .04-1.06Z" clip-rule="evenodd" /></svg>'
32
33
 
33
- def initialize(items:, columns:, empty_message: nil, sort: nil, sort_direction: nil, sort_url: nil, hidden_columns: [], key: nil, group_by: nil, group_totals: {}, total: nil)
34
+ def initialize(items:, columns:, empty_message: nil, sort: nil, sort_direction: nil, sort_url: nil, hidden_columns: [], key: nil, group_by: nil, group_totals: {}, total: nil, current_row: nil)
34
35
  @items = items.to_a
36
+ @current_index = @items.index(current_row) unless current_row.nil?
35
37
  @group_by = group_by
36
38
  @group_totals = group_totals.to_h.transform_keys(&:to_s)
37
39
  @total = total&.to_h&.transform_keys(&:to_s)
@@ -142,6 +144,10 @@ module Keystone
142
144
  end
143
145
  end
144
146
 
147
+ def current_row?(index)
148
+ index == @current_index
149
+ end
150
+
145
151
  def empty?
146
152
  @items.empty?
147
153
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module KeystoneUi
4
- VERSION = "0.54.0"
4
+ VERSION = "0.55.0"
5
5
  end
@@ -58,7 +58,7 @@ not available in the app yet, that is `keystone_ui-install`'s job.
58
58
  - `ui_radio_card` — a selectable card backed by a radio input.
59
59
  - `ui_checkbox_row` — a checkbox with its label and hint, toggled by a tap anywhere on the row.
60
60
  - `ui_option_card` — a radio whose visible body is whatever its block renders.
61
- - `ui_data_table` — a table of records with links, row actions, sorting and hideable columns.
61
+ - `ui_data_table` — a table of records with links, row actions, sorting, hideable columns and the viewer's own row marked.
62
62
  - `Keystone::Ui::Column` — a table column with options a `{ key: "Label" }` hash cannot carry.
63
63
  - `ui_column_picker` — a Columns menu that saves which columns are hidden and their order to an app endpoint.
64
64
  - `ui_button` — a link or a button styled as a button, or a button sending a POST, PATCH or DELETE request.
@@ -367,7 +367,7 @@ two exceptions: `ui_page`'s `padding:` treats any value other than `:none` as
367
367
 
368
368
  8. Build tables.
369
369
 
370
- - `ui_data_table(items:, columns:, empty_message: nil, sort: nil, sort_direction: nil, sort_url: nil, hidden_columns: [], key: nil, group_by: nil, group_totals: {}, total: nil)`
370
+ - `ui_data_table(items:, columns:, empty_message: nil, sort: nil, sort_direction: nil, sort_url: nil, hidden_columns: [], key: nil, group_by: nil, group_totals: {}, total: nil, current_row: nil)`
371
371
  takes a block yielding the table. `items:` are records or hashes, and a
372
372
  cell's value is the column key called on the item, or `item[key]`.
373
373
  `group_by:` lists rows under heading rows named by that key's value,
@@ -394,6 +394,12 @@ two exceptions: `ui_page`'s `padding:` treats any value other than `:none` as
394
394
  `sort_direction:` (`:asc` or `:desc`) and `sort_url:` (a lambda taking
395
395
  `(column_key, direction)` and returning a URL). Headers then render as
396
396
  links that flip direction.
397
+ - `current_row:` takes the item whose row is the viewer's own, such as
398
+ their entry on a scoreboard or leaderboard. That row carries the
399
+ `ks-table-row-current` class, which keystone_ui-styles colours, and
400
+ `aria-current="true"`, so a screen reader announces it. The item
401
+ is compared with `==` and only the first equal row is marked, so pass the
402
+ same record or an equal hash. Use it instead of a "You" badge in a cell.
397
403
  - `hidden_columns:` is the table's default layout and drops only hideable
398
404
  columns. The declared order is the default order.
399
405
  - For a table whose columns a user chooses and keeps, check whether the
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: keystone_ui
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.54.0
4
+ version: 0.55.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyler Schneider
@@ -15,14 +15,14 @@ dependencies:
15
15
  requirements:
16
16
  - - ">="
17
17
  - !ruby/object:Gem::Version
18
- version: 0.27.0
18
+ version: 0.28.0
19
19
  type: :runtime
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - ">="
24
24
  - !ruby/object:Gem::Version
25
- version: 0.27.0
25
+ version: 0.28.0
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: view_component
28
28
  requirement: !ruby/object:Gem::Requirement