keystone_ui 0.70.0 → 0.72.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: d96059f073f00b06481b723fb6e180de135d958e0e3a3fcc3413e2d34597ebe8
4
- data.tar.gz: d8a8aa05e26e90910ab1764ec0b0b2f5336c4f790984de40230937402ec89dfb
3
+ metadata.gz: b5c864218e3c08539be733309f9a8a3b04773b9bfa659a0b7d19bc4431346bf8
4
+ data.tar.gz: 2d362eca45eb1624c8ef3a617d0801efea167abfc1887c63885fd2b627cc902d
5
5
  SHA512:
6
- metadata.gz: a41678266c550174986fa9c04a01bde5cdfa0d5a4b66f7bd7b862376e1a8c654bd03878be4d10e1bcfc80d3092c7f0df5eb2b307dce0ffa86d131731d374dde7
7
- data.tar.gz: 7d73b0660e745189ceacd0c1b3c047c246e3325d4de08217a94909c40a833bdfef2d9b5f055037bf35ed745bf728bae244f0aa04ffa5773b2001f01b16a5d27b
6
+ metadata.gz: 0371ee2dfec124385cdc27cbf079cc5fa08b52bfe8540291f631397352b176d13e7c536f608e76462cc31519f05f1aace40fbc0ed83a4cfc9464236a20cde607
7
+ data.tar.gz: 153f5013bdd548512cb20da11d95d215edf837dc57341e198fdbd319598ff2aa9a48b0aac4a254f3b4546b63e065a9024d48fdf96aff54eda0fab6625d94f088
@@ -4,28 +4,30 @@
4
4
  </div>
5
5
  <% end %>
6
6
  <div class="<%= Keystone::Ui::DataTableComponent::WRAPPER_CLASSES %>">
7
- <table class="relative min-w-full divide-y divide-gray-300 dark:divide-white/15">
8
- <thead class="<%= Keystone::Ui::DataTableComponent::HEAD_CLASSES %>">
9
- <tr>
10
- <% header_cells.each do |cell| %>
11
- <th scope="<%= cell[:scope] %>" class="<%= cell[:classes] %>">
12
- <% if cell[:sort_href] %>
13
- <a href="<%= cell[:sort_href] %>" class="<%= Keystone::Ui::DataTableComponent::SORT_LINK_CLASSES %>" data-turbo-action="replace">
7
+ <table class="<%= table_classes %> divide-y divide-gray-300 dark:divide-white/15">
8
+ <% if header? %>
9
+ <thead class="<%= head_classes %>">
10
+ <tr>
11
+ <% header_cells.each do |cell| %>
12
+ <th scope="<%= cell[:scope] %>" class="<%= cell[:classes] %>">
13
+ <% if cell[:sort_href] %>
14
+ <a href="<%= cell[:sort_href] %>" class="<%= Keystone::Ui::DataTableComponent::SORT_LINK_CLASSES %>" data-turbo-action="replace">
15
+ <%= cell[:label] %>
16
+ <% if cell[:sort_active] %>
17
+ <span class="<%= Keystone::Ui::DataTableComponent::SORT_ICON_CLASSES %> <%= Keystone::Ui::DataTableComponent::SORT_ICON_ACTIVE %>"><%= (cell[:sort_direction] == :asc ? Keystone::Ui::DataTableComponent::SORT_ASC_ICON : Keystone::Ui::DataTableComponent::SORT_DESC_ICON).html_safe %></span>
18
+ <% else %>
19
+ <span class="<%= Keystone::Ui::DataTableComponent::SORT_ICON_CLASSES %> <%= Keystone::Ui::DataTableComponent::SORT_ICON_INACTIVE %>"><%= Keystone::Ui::DataTableComponent::SORT_NEUTRAL_ICON.html_safe %></span>
20
+ <% end %>
21
+ </a>
22
+ <% else %>
14
23
  <%= cell[:label] %>
15
- <% if cell[:sort_active] %>
16
- <span class="<%= Keystone::Ui::DataTableComponent::SORT_ICON_CLASSES %> <%= Keystone::Ui::DataTableComponent::SORT_ICON_ACTIVE %>"><%= (cell[:sort_direction] == :asc ? Keystone::Ui::DataTableComponent::SORT_ASC_ICON : Keystone::Ui::DataTableComponent::SORT_DESC_ICON).html_safe %></span>
17
- <% else %>
18
- <span class="<%= Keystone::Ui::DataTableComponent::SORT_ICON_CLASSES %> <%= Keystone::Ui::DataTableComponent::SORT_ICON_INACTIVE %>"><%= Keystone::Ui::DataTableComponent::SORT_NEUTRAL_ICON.html_safe %></span>
19
- <% end %>
20
- </a>
21
- <% else %>
22
- <%= cell[:label] %>
23
- <% end %>
24
- </th>
25
- <% end %>
26
- </tr>
27
- </thead>
28
- <tbody class="<%= Keystone::Ui::DataTableComponent::BODY_CLASSES %>"<% if row_detail? %> data-controller="row-detail" data-action="turbo:before-morph-attribute->row-detail#keep"<% end %>>
24
+ <% end %>
25
+ </th>
26
+ <% end %>
27
+ </tr>
28
+ </thead>
29
+ <% end %>
30
+ <tbody class="<%= body_classes %>"<% if row_detail? %> data-controller="row-detail" data-action="turbo:before-morph-attribute->row-detail#keep"<% end %>>
29
31
  <% if empty? %>
30
32
  <% if @empty_message %>
31
33
  <tr>
@@ -37,9 +39,9 @@
37
39
  <% else %>
38
40
  <% @items.each_with_index do |item, idx| %>
39
41
  <% if (group = group_starting_at(idx)) %>
40
- <tr class="<%= Keystone::Ui::DataTableComponent::HEAD_CLASSES %>" data-table-group>
42
+ <tr class="<%= summary_row_classes %>" data-table-group>
41
43
  <% group_cells(group).each do |cell| %>
42
- <th scope="colgroup" class="<%= cell[:classes] %>"><%= cell[:value] %></th>
44
+ <th scope="colgroup" class="<%= cell[:classes] %>"><% if cell[:label] %><span class="<%= Keystone::Ui::DataTableComponent::CELL_LABEL_CLASSES %>"><%= cell[:label] %></span><% end %><%= cell[:value] %></th>
43
45
  <% end %>
44
46
  <% if actions? %><th></th><% end %>
45
47
  </tr>
@@ -48,6 +50,9 @@
48
50
  <tr<% if (classes = row_classes(idx)) %> class="<%= classes %>"<% end %><% if current_row?(idx) %> aria-current="true"<% end %><% if detail.present? %> data-action="click->row-detail#toggle"<% end %>>
49
51
  <% row_cells[idx].each_with_index do |cell, cell_index| %>
50
52
  <td class="<%= cell[:classes] %>">
53
+ <% if cell[:label] %>
54
+ <span class="<%= Keystone::Ui::DataTableComponent::CELL_LABEL_CLASSES %>"><%= cell[:label] %></span>
55
+ <% end %>
51
56
  <% if detail.present? && cell_index.zero? %>
52
57
  <button type="button" class="<%= Keystone::Ui::DataTableComponent::DETAIL_BUTTON_CLASSES %>" aria-label="Show detail" aria-expanded="false" aria-controls="<%= row_detail_id(idx) %>" data-row-detail-target="toggle"><%= Keystone::Ui::DisclosureComponent::CARET_ICON.html_safe %></button>
53
58
  <% end %>
@@ -59,29 +64,28 @@
59
64
  </td>
60
65
  <% end %>
61
66
  <% if actions? %>
62
- <td class="<%= Keystone::Ui::DataTableComponent::ROW_CLASSES_LAST %>">
63
- <% row_actions = capture(item, &@actions_block) %>
64
- <% if row_actions.present? %>
67
+ <td class="<%= actions_cell_classes %>">
68
+ <% if row_actions[idx].present? %>
65
69
  <%= render Keystone::Ui::ActionMenuComponent.new do %>
66
- <%= row_actions %>
70
+ <%= row_actions[idx] %>
67
71
  <% end %>
68
72
  <% end %>
69
73
  </td>
70
74
  <% end %>
71
75
  </tr>
72
76
  <% if detail.present? %>
73
- <tr id="<%= row_detail_id(idx) %>" hidden data-row-detail-target="detail">
74
- <td colspan="<%= column_count %>"><%= detail %></td>
77
+ <tr id="<%= row_detail_id(idx) %>"<% if phone_list_block_classes %> class="<%= phone_list_block_classes %>"<% end %> hidden data-row-detail-target="detail">
78
+ <td<% if phone_list_block_classes %> class="<%= phone_list_block_classes %>"<% end %> colspan="<%= column_count %>"><%= detail %></td>
75
79
  </tr>
76
80
  <% end %>
77
81
  <% end %>
78
82
  <% end %>
79
83
  </tbody>
80
84
  <% if total_cells.any? %>
81
- <tfoot class="<%= Keystone::Ui::DataTableComponent::HEAD_CLASSES %>">
82
- <tr>
85
+ <tfoot class="<%= summary_row_classes %>">
86
+ <tr<% if phone_list_block_classes %> class="<%= phone_list_block_classes %>"<% end %>>
83
87
  <% total_cells.each do |cell| %>
84
- <th scope="row" class="<%= cell[:classes] %>"><%= cell[:value] %></th>
88
+ <th scope="row" class="<%= cell[:classes] %>"><% if cell[:label] %><span class="<%= Keystone::Ui::DataTableComponent::CELL_LABEL_CLASSES %>"><%= cell[:label] %></span><% end %><%= cell[:value] %></th>
85
89
  <% end %>
86
90
  <% if actions? %><th></th><% end %>
87
91
  </tr>
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "active_support/core_ext/object/blank"
4
+
3
5
  module Keystone
4
6
  module Ui
5
7
  class DataTableComponent < ViewComponent::Base
@@ -14,6 +16,7 @@ module Keystone
14
16
  }.freeze
15
17
  DETAIL_BUTTON_CLASSES = "ks-disclosure-icon inline-flex align-middle transition-transform aria-expanded:rotate-180"
16
18
  HEAD_CLASSES = "ks-table-head"
19
+ TABLE_CLASSES = "relative min-w-full"
17
20
  WRAPPER_CLASSES = "ks-table overflow-x-auto"
18
21
  TOOLBAR_CLASSES = "ks-table-toolbar flex justify-end"
19
22
  HEADER_CLASSES_FIRST = "ks-table-header ks-table-header-first text-left text-sm"
@@ -29,6 +32,11 @@ module Keystone
29
32
  HEADER_LOCKED_CLASSES = "ks-table-header-locked sticky left-0"
30
33
  CELL_LOCKED_CLASSES = "ks-table-cell-locked sticky left-0"
31
34
 
35
+ PHONE_LIST_HEAD_CLASSES = "max-sm:hidden"
36
+ PHONE_LIST_BLOCK_CLASSES = "max-sm:block"
37
+ PHONE_LIST_CELL_CLASSES = "ks-table-phone-list-cell max-sm:block max-sm:text-left max-sm:whitespace-normal"
38
+ CELL_LABEL_CLASSES = "ks-caption block sm:hidden"
39
+
32
40
  SORT_LINK_CLASSES = "ks-table-sort-link group inline-flex items-center"
33
41
  SORT_ICON_CLASSES = "h-4 w-4 flex-shrink-0"
34
42
  SORT_ICON_ACTIVE = "ks-table-sort-icon-active"
@@ -38,7 +46,7 @@ module Keystone
38
46
  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>'
39
47
  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>'
40
48
 
41
- 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)
49
+ 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, phone_list: false, header: true)
42
50
  @items = items.to_a
43
51
  @current_index = @items.index(current_row) unless current_row.nil?
44
52
  @group_by = group_by
@@ -55,6 +63,8 @@ module Keystone
55
63
  @sort_url = sort_url
56
64
  @actions_block = nil
57
65
  @link_blocks = {}
66
+ @phone_list = phone_list
67
+ @header = header
58
68
  end
59
69
 
60
70
  def before_render
@@ -87,13 +97,47 @@ module Keystone
87
97
  end
88
98
 
89
99
  def row_classes(index)
90
- classes = [ (CURRENT_ROW_CLASSES if current_row?(index)), row_colour_class(@items[index]) ].compact
100
+ classes = [ (CURRENT_ROW_CLASSES if current_row?(index)), row_colour_class(@items[index]), (PHONE_LIST_BLOCK_CLASSES if @phone_list) ].compact
91
101
 
92
102
  classes.join(" ") unless classes.empty?
93
103
  end
94
104
 
105
+ def table_classes
106
+ phone_list_classes(TABLE_CLASSES, PHONE_LIST_BLOCK_CLASSES)
107
+ end
108
+
109
+ def body_classes
110
+ phone_list_classes(BODY_CLASSES, PHONE_LIST_BLOCK_CLASSES)
111
+ end
112
+
113
+ def summary_row_classes
114
+ phone_list_classes(HEAD_CLASSES, PHONE_LIST_BLOCK_CLASSES)
115
+ end
116
+
117
+ def phone_list_block_classes
118
+ PHONE_LIST_BLOCK_CLASSES if @phone_list
119
+ end
120
+
121
+ def actions_cell_classes
122
+ phone_list_classes(ROW_CLASSES_LAST, PHONE_LIST_BLOCK_CLASSES)
123
+ end
124
+
125
+ def head_classes
126
+ phone_list_classes(HEAD_CLASSES, PHONE_LIST_HEAD_CLASSES)
127
+ end
128
+
129
+ def header?
130
+ @header
131
+ end
132
+
95
133
  def actions?
96
- !!@actions_block
134
+ row_actions.any?(&:present?)
135
+ end
136
+
137
+ def row_actions
138
+ return [] unless @actions_block
139
+
140
+ @row_actions ||= @items.map { |item| capture(item, &@actions_block) }
97
141
  end
98
142
 
99
143
  def column_picker
@@ -159,11 +203,13 @@ module Keystone
159
203
  tokens = [ row_classes_for(index) ]
160
204
  tokens << MOBILE_HIDDEN_CLASSES if column.mobile_hidden?
161
205
  tokens << CELL_LOCKED_CLASSES if index.zero? && column.locked?
206
+ tokens << PHONE_LIST_CELL_CLASSES if @phone_list && !column.mobile_hidden?
162
207
 
163
208
  cell = {
164
209
  value: resolve_value(item, column.key),
165
210
  classes: wrapped(aligned(tokens.join(" "), column), column)
166
211
  }
212
+ cell[:label] = column.header_text if phone_labels?
167
213
 
168
214
  link_block = @link_blocks[column.key]
169
215
  cell[:href] = link_block.call(item) if link_block
@@ -196,19 +242,31 @@ module Keystone
196
242
  return [] unless @total
197
243
 
198
244
  @columns.map.with_index do |column, index|
199
- { value: @total[column.key.to_s], classes: aligned(header_classes_for(index), column) }
245
+ { value: @total[column.key.to_s], classes: phone_list_classes(aligned(header_classes_for(index), column), PHONE_LIST_CELL_CLASSES), label: summary_label(index, column) }
200
246
  end
201
247
  end
202
248
 
203
249
  def group_cells(name)
204
250
  subtotals = @group_totals.fetch(name.to_s, {}).to_h.transform_keys(&:to_s)
205
251
  @columns.map.with_index do |column, index|
206
- { value: index.zero? ? name : subtotals[column.key.to_s], classes: aligned(header_classes_for(index), column) }
252
+ { value: index.zero? ? name : subtotals[column.key.to_s], classes: phone_list_classes(aligned(header_classes_for(index), column), PHONE_LIST_CELL_CLASSES), label: summary_label(index, column) }
207
253
  end
208
254
  end
209
255
 
210
256
  private
211
257
 
258
+ def summary_label(index, column)
259
+ column.header_text if phone_labels? && !index.zero?
260
+ end
261
+
262
+ def phone_labels?
263
+ @phone_list && @header
264
+ end
265
+
266
+ def phone_list_classes(classes, phone_list_classes)
267
+ @phone_list ? "#{classes} #{phone_list_classes}" : classes
268
+ end
269
+
212
270
  def apply_saved_layout
213
271
  saved = KeystoneUi.configuration.supplied_preference(helpers, @key)
214
272
  return unless saved
@@ -1,15 +1,17 @@
1
1
  <div class="ks-value-list">
2
2
  <% rows.each do |row| %>
3
3
  <%= link_to row.fetch(:href), class: ROW_CLASSES do %>
4
- <span class="<%= TEXT_CLASSES %>">
5
- <span class="<%= LABEL_CLASSES %>"><%= row.fetch(:label) %></span>
6
- <% if row[:subtitle] %>
7
- <span class="<%= SUBTITLE_CLASSES %>"><%= row[:subtitle] %></span>
4
+ <span class="<%= STACK_CLASSES %>">
5
+ <span class="<%= TEXT_CLASSES %>">
6
+ <span class="<%= LABEL_CLASSES %>"><%= row.fetch(:label) %></span>
7
+ <% if row[:subtitle] %>
8
+ <span class="<%= SUBTITLE_CLASSES %>"><%= row[:subtitle] %></span>
9
+ <% end %>
10
+ </span>
11
+ <% if row[:badge] %>
12
+ <%= render badge(row) %>
8
13
  <% end %>
9
14
  </span>
10
- <% if row[:badge] %>
11
- <%= render badge(row) %>
12
- <% end %>
13
15
  <% if row[:value] %>
14
16
  <span class="<%= VALUE_CLASSES %>"><%= row[:value] %></span>
15
17
  <% end %>
@@ -4,6 +4,8 @@ module Keystone
4
4
  module Ui
5
5
  class LinkListComponent < ViewComponent::Base
6
6
  ROW_CLASSES = "ks-value-list-row items-center no-underline"
7
+ STACK_CLASSES = "flex min-w-0 flex-1 flex-col-reverse ks-grid-gap-sm sm:contents"
8
+ BADGE_CLASSES = "max-sm:self-start"
7
9
  TEXT_CLASSES = "min-w-0 flex-1"
8
10
  LABEL_CLASSES = "ks-paragraph ks-settings-link-label block"
9
11
  SUBTITLE_CLASSES = "ks-value-list-note"
@@ -16,7 +18,7 @@ module Keystone
16
18
  end
17
19
 
18
20
  def badge(row)
19
- BadgeComponent.new(**row[:badge])
21
+ BadgeComponent.new(**row[:badge], class: BADGE_CLASSES)
20
22
  end
21
23
  end
22
24
  end
@@ -1,13 +1,15 @@
1
- <div class="<%= WRAPPER_CLASSES %>">
2
- <% if @back_url %>
3
- <%= link_to @back_url, class: BACK_LINK_CLASSES, aria: { label: "Back" } do %>
4
- <%= BACK_ICON.html_safe %>
1
+ <div class="<%= ROW_CLASSES %>">
2
+ <div class="<%= WRAPPER_CLASSES %>">
3
+ <% if @back_url %>
4
+ <%= link_to @back_url, class: BACK_LINK_CLASSES, aria: { label: "Back" } do %>
5
+ <%= BACK_ICON.html_safe %>
6
+ <% end %>
5
7
  <% end %>
6
- <% end %>
8
+ </div>
9
+ <span class="<%= TITLE_CLASSES %>">
10
+ <%= @title %>
11
+ <% if @subtitle.present? %>
12
+ <span class="<%= SUBTITLE_CLASSES %>"><%= @subtitle %></span>
13
+ <% end %>
14
+ </span>
7
15
  </div>
8
- <span class="<%= TITLE_CLASSES %>">
9
- <%= @title %>
10
- <% if @subtitle.present? %>
11
- <span class="<%= SUBTITLE_CLASSES %>"><%= @subtitle %></span>
12
- <% end %>
13
- </span>
@@ -15,6 +15,7 @@ module Keystone
15
15
  </svg>
16
16
  SVG
17
17
 
18
+ ROW_CLASSES = "ks-page flex items-center ks-grid-gap-sm lg:hidden print:hidden max-lg:in-[.top-nav]:contents"
18
19
  WRAPPER_CLASSES = "flex items-center lg:hidden print:hidden"
19
20
  BACK_LINK_CLASSES = "ks-mobile-header-back"
20
21
  TITLE_CLASSES = "ks-mobile-header-title flex-[1_1_6rem] min-w-0 self-center lg:hidden truncate"
@@ -9,8 +9,8 @@ module Keystone
9
9
  ACTIONS_CLASSES = "page-header-actions ks-page-header-actions"
10
10
  PHONE_TITLE_CLASSES = "ks-page-header-title max-sm:[body:has(.ks-mobile-header-title)_&]:hidden"
11
11
  PHONE_WRAPPER_CLASSES = "max-sm:flex max-sm:flex-wrap max-sm:items-center max-sm:justify-between"
12
- PHONE_ACTIONS_CLASSES = "max-sm:block"
13
- MENU_ROW_CLASSES = "flex items-center ks-grid-gap-sm"
12
+ PHONE_ACTIONS_CLASSES = "max-sm:flex max-sm:items-center max-sm:basis-full"
13
+ ROW_CLASSES = "sm:flex sm:items-center flex-wrap max-w-full ks-grid-gap-sm"
14
14
  TITLE_ROW_CLASSES = "flex flex-wrap items-center ks-grid-gap-sm"
15
15
 
16
16
  attr_reader :title, :action_url, :action_label, :action_method
@@ -44,7 +44,7 @@ module Keystone
44
44
  end
45
45
 
46
46
  def actions_classes
47
- [ ACTIONS_CLASSES, (menu? ? MENU_ROW_CLASSES : PHONE_ACTIONS_CLASSES if phone?) ].compact.join(" ")
47
+ [ ACTIONS_CLASSES, ROW_CLASSES, (PHONE_ACTIONS_CLASSES if phone?) ].compact.join(" ")
48
48
  end
49
49
 
50
50
  def title_classes
@@ -7,17 +7,21 @@
7
7
  <p class="<%= SUBTITLE_CLASSES %>"><%= @subtitle %></p>
8
8
  <% end %>
9
9
  </div>
10
- <% if @action %>
11
- <a href="<%= @action[:href] %>" class="<%= action_classes %>">
12
- <%= @action[:label] %>
13
- </a>
14
- <% end %>
15
- <% if @menu.any? %>
16
- <%= render Keystone::Ui::ActionMenuComponent.new do %>
17
- <% @menu.each do |item| %>
18
- <%= render Keystone::Ui::ActionMenuItemComponent.new(**item) %>
10
+ <% if @action || @menu.any? %>
11
+ <div class="<%= ACTIONS_CLASSES %>">
12
+ <% if @action %>
13
+ <a href="<%= @action[:href] %>" class="<%= action_classes %>">
14
+ <%= @action[:label] %>
15
+ </a>
19
16
  <% end %>
20
- <% end %>
17
+ <% if @menu.any? %>
18
+ <%= render Keystone::Ui::ActionMenuComponent.new do %>
19
+ <% @menu.each do |item| %>
20
+ <%= render Keystone::Ui::ActionMenuItemComponent.new(**item) %>
21
+ <% end %>
22
+ <% end %>
23
+ <% end %>
24
+ </div>
21
25
  <% end %>
22
26
  </div>
23
27
  <% end %>
@@ -8,6 +8,7 @@ module Keystone
8
8
  TITLE_CLASSES = "ks-section-title"
9
9
  SUBTITLE_CLASSES = "ks-section-subtitle"
10
10
  ACTION_CLASSES = "ks-section-action"
11
+ ACTIONS_CLASSES = "flex items-center shrink-0 ks-grid-gap-sm"
11
12
 
12
13
  def initialize(title: nil, subtitle: nil, action: nil, menu: [], spacing: :md, class: nil)
13
14
  @title = title
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module KeystoneUi
4
- VERSION = "0.70.0"
4
+ VERSION = "0.72.0"
5
5
  end
@@ -187,7 +187,11 @@ two exceptions: `ui_page`'s `padding:` treats any value other than `:none` as
187
187
  actions and menu, and hides its title when the page holds
188
188
  `ui_mobile_header`'s title. Its action then shows below `sm:` beside
189
189
  `ui_mobile_action`'s plus icon, so ask the developer whether a screen
190
- with both keeps both.
190
+ with both keeps both. Below `sm:` the actions and menu sit side by side
191
+ on their own full-width row under the title and badges, and from `sm:` up
192
+ they sit side by side on the right, with or without a menu. At every
193
+ width buttons that do not fit wrap onto another line, so the header never
194
+ makes the page wider than the screen.
191
195
  - `ui_breadcrumbs(trail:, current: nil)` renders `trail:` as links separated
192
196
  by `›`, then `current:` unlinked and marked as the current page, shown
193
197
  only from `lg:` up. On a form or detail screen pass `trail:` to the shell
@@ -200,10 +204,11 @@ two exceptions: `ui_page`'s `padding:` treats any value other than `:none` as
200
204
  4. Lay out the body. Each of these takes a block and they nest.
201
205
 
202
206
  - `ui_section(title: nil, subtitle: nil, action: nil, menu: [], spacing: :md, class: nil)`
203
- — `action:` is `{ label:, href: }` and renders a right-aligned link.
207
+ — `action:` is `{ label:, href: }` and renders a link.
204
208
  `menu:` is `[{ label:, href:, method: }, ...]`, each hash taking the
205
- keywords of `ui_action_menu_item`, and renders an action menu at the right
206
- of the header. `spacing:` is `:sm` `:md` `:lg`. The header, with its
209
+ keywords of `ui_action_menu_item`, and renders an action menu. The link
210
+ and the menu sit side by side at the right edge of the header, the link
211
+ first, at every width. `spacing:` is `:sm` `:md` `:lg`. The header, with its
207
212
  `action:` and `menu:`, renders only when `title:` is given.
208
213
  - `ui_grid(cols: { default: 1 }, gap: :md, gap_x: nil, gap_y: nil)` —
209
214
  `cols:` maps `:default` `:sm` `:md` `:lg` to a count from 1 to 12, such as
@@ -274,14 +279,19 @@ two exceptions: `ui_page`'s `padding:` treats any value other than `:none` as
274
279
  over the icon. The bar is hidden from `lg:` up and inside a
275
280
  Hotwire Native web view.
276
281
  - `ui_mobile_header(title:, back_url:, subtitle: nil)` is hidden from `lg:`
277
- up and goes in the navbar's `mobile_left` slot. `back_url:` must be
278
- passed, and `nil` renders the title with no back arrow. The title and
279
- subtitle sit between the arrow and the right-side controls, start at the
280
- left, and end in an ellipsis when too long. In `ui_navbar`, controls that
281
- leave less than 6rem for the title move to a second row under it. In a
282
- hand-written top bar, make the header a direct child of the bar's flex
283
- row, and add `max-lg:has-[.ks-mobile-header-title]:flex-wrap` to the bar if
284
- its controls can fill its width.
282
+ up and goes in the navbar's `mobile_left` slot or directly in the
283
+ layout's `<header>`. `back_url:` must be passed, and `nil` renders the
284
+ title with no back arrow. Outside a top bar it draws the arrow, title and
285
+ subtitle in one row with `ui_page`'s side margin, ending the text in an
286
+ ellipsis when too long. Inside an element with the `top-nav` class, such
287
+ as `ui_navbar`, the arrow and title are laid out by the bar instead: the
288
+ title and subtitle sit between the arrow and the right-side controls,
289
+ start at the left, and end in an ellipsis when too long. In `ui_navbar`,
290
+ controls that leave less than 6rem for the title move to a second row
291
+ under it. In a hand-written top bar, give the bar the `top-nav` class,
292
+ make the header a direct child of the bar's flex row, and add
293
+ `max-lg:has-[.ks-mobile-header-title]:flex-wrap` to the bar if its
294
+ controls can fill its width.
285
295
  - `ui_mobile_action` takes no keywords and no block, and goes in the top
286
296
  bar's right side, such as the navbar's `mobile_right` slot. It draws a plus
287
297
  icon linking to the `action_url:` a screen gives `ui_page_header`, named
@@ -435,7 +445,7 @@ two exceptions: `ui_page`'s `padding:` treats any value other than `:none` as
435
445
 
436
446
  8. Build tables.
437
447
 
438
- - `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)`
448
+ - `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, phone_list: false, header: true)`
439
449
  takes a block yielding the table. `items:` are records or hashes, and a
440
450
  cell's value is the column key called on the item, or `item[key]`.
441
451
  `group_by:` lists rows under heading rows named by that key's value,
@@ -443,6 +453,19 @@ two exceptions: `ui_page`'s `padding:` treats any value other than `:none` as
443
453
  subtotals in each heading row, and `total:` (`{ column_key => value }`)
444
454
  ends the table with a total row. Pass every subtotal and total already
445
455
  calculated. `align: :start` or `:end` on a `Column` aligns it left or right.
456
+ - `phone_list: true` shows the table as a list below `sm:`. The heading
457
+ row is hidden there, each row is one item, and each cell sits on its own
458
+ line under its column's heading, starting at the left and wrapping. A
459
+ row's links, badges, detail button and action menu stay in its item, and
460
+ group subtotals and totals after the first carry their headings. Sorting
461
+ is not reachable below `sm:`, since the sort links are in the heading row.
462
+ From `sm:` up the table is unchanged, and a table without it is unchanged
463
+ at every width. It is chosen table by table, so ask the developer which
464
+ tables show as a list on a phone.
465
+ - `header: false` draws no heading row, for a table of labels and their
466
+ values such as a record's details. With `phone_list: true` it also drops
467
+ the column heading label from every cell, subtotal and total below `sm:`,
468
+ so each row shows only its label and its value.
446
469
  - `columns:` takes `{ key: "Label" }` hashes when every column is plain.
447
470
  Switch the whole set to `Keystone::Ui::Column` objects once one column
448
471
  needs an option.
@@ -458,9 +481,10 @@ two exceptions: `ui_page`'s `padding:` treats any value other than `:none` as
458
481
  table locks its first column.
459
482
  - In the block, `table.link(:column_key) { |item| url }` turns a column's
460
483
  cells into links, and `table.actions { |item| ... }` adds a right-aligned
461
- actions column whose block holds only `ui_action_menu_item` calls. With no
462
- actions column, the last column is right-aligned, so put a column of
463
- amounts last.
484
+ actions column whose block holds only `ui_action_menu_item` calls. When
485
+ the block renders nothing for every row, the table draws no actions
486
+ column. With no actions column, the last column is right-aligned, so put
487
+ a column of amounts last.
464
488
  - `table.row_colour { |item| ... }` tints a whole row. The block returns
465
489
  `:danger`, `:warning`, `:success`, `:info` or `nil` for each item. A named
466
490
  colour tints every cell of that row in the same colour as the badge of
@@ -544,6 +568,7 @@ two exceptions: `ui_page`'s `padding:` treats any value other than `:none` as
544
568
  adds a close button.
545
569
  - `ui_link_list(rows:)` — each row is `{ label:, href:, subtitle: nil,
546
570
  badge: nil, value: nil }`, and `badge:` takes `ui_badge`'s `{ label:, variant: }`.
571
+ A row's badge sits above its label below `sm` and beside it from `sm` up.
547
572
  Use it for a list of records that each open their own page, in place of a
548
573
  hand-written `<ul>` of links.
549
574
  - `ui_empty_state(title:, message: nil, action: nil)` — `action:` is
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.70.0
4
+ version: 0.72.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.29.0
18
+ version: 0.32.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.29.0
25
+ version: 0.32.0
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: view_component
28
28
  requirement: !ruby/object:Gem::Requirement