keystone_ui 0.34.0 → 0.35.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: ac460729f806dac1343306018aab4560b2c75f39ad05ec5a775886c24f5084fb
4
- data.tar.gz: 89e7107f63d2d0b6f4b2b27907c464b09cc44375d12fc59e7958bae8e99efbb7
3
+ metadata.gz: c2f3f4d0784444fc8cf7acde02c493fa2829dbcca367d1af4a852338b6f42212
4
+ data.tar.gz: 366951b7d1e19d053229c9c509db6555a8de379442e7bf0d11dfb9637992e012
5
5
  SHA512:
6
- metadata.gz: '097bdb96a57af1b3b1f886b522fa4bd3a5be40f89b433be36df0c5c74ae895ba4c5dda568a6bbea8c5e32743ee6d072cd61ba553ee9d381fc90c8917399b768f'
7
- data.tar.gz: e0b238491fc14b93e2cb32e67871290bb8a5a0d606f3663c3c839a62964ce2c8a954d1f6242a158da01713eb7e1b3565f2b3371b46c7e54607cc9e4aae77967a
6
+ metadata.gz: 8f8064c88fc4ce2937ec84bff38ee5a60eab0fe03380995af9204fc2ccc58d82ec7c5cf89203ceb991088b0e0e06c6aa1b9d4106b251b099ea86e8303a686d85
7
+ data.tar.gz: d9453549349d298e249bab69ee78ea54d70a09c1cbf989c9aaba21c307c8525b985708f4645e3374bb99e72457954cf9c5d39c4a5f71ab7ecbe6c0e4f490f17b
@@ -15,33 +15,62 @@ export default class extends Controller {
15
15
 
16
16
  toggle(event) {
17
17
  event.stopPropagation()
18
- this.menuTarget.classList.toggle("hidden")
18
+ if (this.menuTarget.classList.contains("hidden")) {
19
+ this.menuTarget.classList.remove("hidden")
20
+ } else {
21
+ this.hideMenu()
22
+ }
19
23
  }
20
24
 
21
25
  close(event) {
22
26
  if (!this.element.contains(event.target)) {
23
- this.menuTarget.classList.add("hidden")
27
+ this.hideMenu()
24
28
  }
25
29
  }
26
30
 
27
- save() {
28
- this.send(this.columnOrder())
31
+ hideMenu() {
32
+ this.menuTarget.classList.add("hidden")
33
+ if (!this.changed) return
34
+
35
+ this.changed = false
36
+ this.send()
37
+ }
38
+
39
+ mark(event) {
40
+ const option = this.optionFor(event)
41
+ option.querySelector("label").classList.toggle("ks-menu-option-hidden", !this.checkboxIn(option).checked)
42
+ this.changed = true
43
+ }
44
+
45
+ optionFor(event) {
46
+ return event.currentTarget.closest('[data-column-picker-target="option"]')
29
47
  }
30
48
 
31
49
  moveUp(event) {
32
- this.move(event, -1)
50
+ const option = this.optionFor(event)
51
+ const previous = option.previousElementSibling
52
+ if (!previous) return
53
+
54
+ option.parentNode.insertBefore(option, previous)
55
+ this.moved()
33
56
  }
34
57
 
35
58
  moveDown(event) {
36
- this.move(event, 1)
59
+ const option = this.optionFor(event)
60
+ const next = option.nextElementSibling
61
+ if (!next) return
62
+
63
+ option.parentNode.insertBefore(next, option)
64
+ this.moved()
37
65
  }
38
66
 
39
- move(event, step) {
40
- const order = this.columnOrder()
41
- const index = this.optionTargets.indexOf(event.currentTarget.closest('[data-column-picker-target="option"]'))
42
- const [key] = order.splice(index, 1)
43
- order.splice(index + step, 0, key)
44
- this.send(order)
67
+ moved() {
68
+ this.changed = true
69
+ const options = this.optionTargets
70
+ options.forEach((option, index) => {
71
+ option.querySelector('[data-action="click->column-picker#moveUp"]').disabled = index === 0
72
+ option.querySelector('[data-action="click->column-picker#moveDown"]').disabled = index === options.length - 1
73
+ })
45
74
  }
46
75
 
47
76
  columnOrder() {
@@ -59,7 +88,7 @@ export default class extends Controller {
59
88
  return option.querySelector("input[type=checkbox]")
60
89
  }
61
90
 
62
- send(columnOrder) {
91
+ send() {
63
92
  if (!this.hasSaveUrlValue) return
64
93
 
65
94
  const token = document.querySelector('meta[name="csrf-token"]')?.content
@@ -69,7 +98,7 @@ export default class extends Controller {
69
98
  "Content-Type": "application/json",
70
99
  "X-CSRF-Token": token
71
100
  },
72
- body: JSON.stringify({ hidden_columns: this.hiddenColumns(), column_order: columnOrder })
101
+ body: JSON.stringify({ hidden_columns: this.hiddenColumns(), column_order: this.columnOrder() })
73
102
  }).then(() => {
74
103
  Turbo.visit(window.location.href, { action: "replace" })
75
104
  })
@@ -3,7 +3,7 @@
3
3
  module Keystone
4
4
  module Ui
5
5
  class BreadcrumbsComponent < ViewComponent::Base
6
- CLASSES = "ks-mobile-header-back hidden lg:block text-sm"
6
+ CLASSES = "ks-mobile-header-back ks-breadcrumbs hidden lg:block text-sm"
7
7
  SEPARATOR = "›"
8
8
 
9
9
  def initialize(trail:, current: nil)
@@ -8,11 +8,11 @@
8
8
  <div data-column-picker-target="menu" class="<%= MENU_CLASSES %>">
9
9
  <% hideable_columns.each_with_index do |col, index| %>
10
10
  <div class="<%= OPTION_ROW_CLASSES %>" data-column-picker-target="option">
11
- <label class="<%= OPTION_CLASSES %>">
11
+ <label class="<%= option_classes(col.key) %>">
12
12
  <input type="checkbox"
13
13
  value="<%= col.key %>"
14
14
  <%= "checked" unless hidden?(col.key) %>
15
- data-action="change->column-picker#save"
15
+ data-action="change->column-picker#mark"
16
16
  class="<%= CHECKBOX_CLASSES %>">
17
17
  <%= col.header_text %>
18
18
  </label>
@@ -8,6 +8,7 @@ module Keystone
8
8
  MENU_CLASSES = "ks-menu absolute right-0 z-10 w-56 hidden"
9
9
  OPTION_CLASSES = "ks-menu-option flex items-center text-sm cursor-pointer"
10
10
  CHECKBOX_CLASSES = "ks-menu-checkbox"
11
+ OPTION_HIDDEN_CLASSES = "ks-menu-option-hidden"
11
12
  OPTION_ROW_CLASSES = "flex items-center"
12
13
  MOVE_BUTTON_CLASSES = "ks-menu-move text-sm"
13
14
 
@@ -32,6 +33,10 @@ module Keystone
32
33
  def hidden?(key)
33
34
  @hidden_keys.include?(key.to_sym)
34
35
  end
36
+
37
+ def option_classes(key)
38
+ hidden?(key) ? "#{OPTION_CLASSES} #{OPTION_HIDDEN_CLASSES}" : OPTION_CLASSES
39
+ end
35
40
  end
36
41
  end
37
42
  end
@@ -1,5 +1,7 @@
1
1
  <% if column_picker %>
2
- <%= render column_picker %>
2
+ <div class="<%= Keystone::Ui::DataTableComponent::TOOLBAR_CLASSES %>">
3
+ <%= render column_picker %>
4
+ </div>
3
5
  <% end %>
4
6
  <div class="<%= Keystone::Ui::DataTableComponent::WRAPPER_CLASSES %>">
5
7
  <table class="relative min-w-full divide-y divide-gray-300 dark:divide-white/15">
@@ -7,6 +7,7 @@ module Keystone
7
7
  BODY_CLASSES = "ks-table-body"
8
8
  HEAD_CLASSES = "ks-table-head"
9
9
  WRAPPER_CLASSES = "ks-table overflow-x-auto"
10
+ TOOLBAR_CLASSES = "ks-table-toolbar flex justify-end"
10
11
  HEADER_CLASSES_FIRST = "ks-table-header ks-table-header-first text-left text-sm"
11
12
  HEADER_CLASSES_MIDDLE = "ks-table-header ks-table-header-middle text-left text-sm"
12
13
  HEADER_CLASSES_LAST = "ks-table-header ks-table-header-last text-right text-sm"
@@ -3,7 +3,7 @@
3
3
  module Keystone
4
4
  module Ui
5
5
  class DesktopBackLinkComponent < ViewComponent::Base
6
- CLASSES = "ks-mobile-header-back hidden lg:inline-flex items-center"
6
+ CLASSES = "ks-mobile-header-back ks-page-back hidden lg:inline-flex items-center"
7
7
  LABEL = "Back"
8
8
 
9
9
  def initialize(url:)
@@ -2,11 +2,12 @@
2
2
  <% content_for :form_page_title, @title %>
3
3
  <% content_for :form_page_back_url, @back_url %>
4
4
 
5
- <% if @trail %>
6
- <% content_for :keystone_page_header, render(Keystone::Ui::BreadcrumbsComponent.new(trail: @trail, current: @title)) %>
7
- <% else %>
5
+ <% unless top_level? %>
8
6
  <% content_for :keystone_page_header, render(Keystone::Ui::DesktopBackLinkComponent.new(url: @back_url)) %>
9
7
  <% end %>
8
+ <% if @trail&.any? %>
9
+ <% content_for :keystone_page_header, render(Keystone::Ui::BreadcrumbsComponent.new(trail: @trail, current: @title)) %>
10
+ <% end %>
10
11
 
11
12
  <% content_for :keystone_page_header do %>
12
13
  <div class="<%= DESKTOP_WRAPPER_CLASSES %>">
@@ -17,10 +17,14 @@ module Keystone
17
17
  def before_render
18
18
  @trail ||= KeystoneUi.configuration.supplied_trail(helpers)
19
19
  @back_url ||= @trail&.last&.last
20
- raise KeystoneUi::MissingBackLink, @title unless @back_url
20
+ raise KeystoneUi::MissingBackLink, @title unless @back_url || top_level?
21
21
  raise KeystoneUi::IncompleteTrail, @title if @trail&.any? { |label, href| label.blank? || href.blank? }
22
22
  end
23
23
 
24
+ def top_level?
25
+ @trail == []
26
+ end
27
+
24
28
  def subtitle?
25
29
  !@subtitle.nil?
26
30
  end
@@ -1,6 +1,8 @@
1
1
  <div class="<%= WRAPPER_CLASSES %>">
2
- <%= link_to @back_url, class: BACK_LINK_CLASSES, aria: { label: "Back" } do %>
3
- <%= BACK_ICON.html_safe %>
2
+ <% if @back_url %>
3
+ <%= link_to @back_url, class: BACK_LINK_CLASSES, aria: { label: "Back" } do %>
4
+ <%= BACK_ICON.html_safe %>
5
+ <% end %>
4
6
  <% end %>
5
7
  </div>
6
8
  <span class="<%= TITLE_CLASSES %>">
@@ -3,8 +3,9 @@
3
3
  <% content_for :show_page_back_url, @back_url %>
4
4
  <% content_for :show_page_subtitle, @subtitle if @subtitle.present? %>
5
5
 
6
- <% if @trail %>
7
- <% content_for :keystone_page_header, render(Keystone::Ui::BreadcrumbsComponent.new(trail: @trail, current: @title)) %>
8
- <% else %>
6
+ <% unless top_level? %>
9
7
  <% content_for :keystone_page_header, render(Keystone::Ui::DesktopBackLinkComponent.new(url: @back_url)) %>
10
8
  <% end %>
9
+ <% if @trail&.any? %>
10
+ <% content_for :keystone_page_header, render(Keystone::Ui::BreadcrumbsComponent.new(trail: @trail, current: @title)) %>
11
+ <% end %>
@@ -17,10 +17,14 @@ module Keystone
17
17
  def before_render
18
18
  @trail ||= KeystoneUi.configuration.supplied_trail(helpers)
19
19
  @back_url ||= @trail&.last&.last
20
- raise KeystoneUi::MissingBackLink, @title unless @back_url
20
+ raise KeystoneUi::MissingBackLink, @title unless @back_url || top_level?
21
21
  raise KeystoneUi::IncompleteTrail, @title if @trail&.any? { |label, href| label.blank? || href.blank? }
22
22
  end
23
23
 
24
+ def top_level?
25
+ @trail == []
26
+ end
27
+
24
28
  def subtitle?
25
29
  !@subtitle.nil?
26
30
  end
@@ -3,7 +3,7 @@
3
3
  module KeystoneUi
4
4
  class MissingBackLink < StandardError
5
5
  def initialize(title)
6
- super(%(The page "#{title}" has no Back link. Pass back_url: or trail:, or supply a trail for it through config.trail_supplier.))
6
+ super(%(The page "#{title}" has no Back link. Pass back_url: or trail:, or supply a trail for it through config.trail_supplier. A nav tab's own page passes trail: [].))
7
7
  end
8
8
  end
9
9
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module KeystoneUi
4
- VERSION = "0.34.0"
4
+ VERSION = "0.35.0"
5
5
  end
@@ -43,8 +43,9 @@ outer element. See Conventions before using it.
43
43
  takes a block. The outer wrapper for a screen. `max_width:` `:sm` `:md` `:lg`
44
44
  `:xl` `:full`; `padding:` `:standard` or `:none`; `top_offset:` `:sm` `:md`
45
45
  `:lg` `:xl` to clear a fixed navbar. When `ui_form_page` or `ui_show_page` was
46
- called earlier on the same screen, `ui_page` renders their back link or
47
- breadcrumbs, and the form page's title, at its top, above the block.
46
+ called earlier on the same screen, `ui_page` renders their "Back" link, their
47
+ breadcrumbs, and the form page's title, in that order, at its top, above the
48
+ block.
48
49
  - `ui_section(title: nil, subtitle: nil, action: nil, menu: [], spacing: :md, class: nil)`
49
50
  — takes a block. A titled block of content with an optional right-aligned
50
51
  link. `action:` is `{ label:, href: }`; `spacing:` `:sm` `:md` `:lg`.
@@ -73,25 +74,29 @@ outer element. See Conventions before using it.
73
74
  the title and back URL so the navbar can render mobile header context, and
74
75
  hands `ui_page` a "Back" link to `back_url` shown from `lg:` up, then the
75
76
  title and subtitle shown from `md:` up. Call it before `ui_page`, outside
76
- `ui_page`'s block, or none of that appears. Passing `trail:` replaces the
77
- "Back" link with breadcrumbs: the trail's links followed by `title` unlinked,
78
- as `ui_breadcrumbs` renders them. With no `trail:`, it uses the trail the app
79
- supplies for the current request, if the app supplies one. With no
80
- `back_url:`, the back URL is the `href` of the trail's last link. A `trail:`
81
- or `back_url:` passed here always wins over the supplied ones. With no
82
- `back_url:` and no trail from either place, or a trail that is empty or whose
83
- last link has no `href`, rendering raises `KeystoneUi::MissingBackLink`, naming
84
- the page's title. A trail with any link whose label or `href` is `nil` or
85
- blank raises `KeystoneUi::IncompleteTrail`, naming the page's title, even when
86
- `back_url:` is passed.
77
+ `ui_page`'s block, or none of that appears. Passing a non-empty `trail:` adds
78
+ breadcrumbs under the "Back" link: the trail's links followed by `title`
79
+ unlinked, as `ui_breadcrumbs` renders them, shown from `lg:` up. With no
80
+ `trail:`, it uses the trail the app supplies for the current request, if the
81
+ app supplies one. With no `back_url:`, the back URL is the `href` of the
82
+ trail's last link. A `trail:` or `back_url:` passed here always wins over the
83
+ supplied ones. `trail: []` marks the page a navigation tab opens directly: it
84
+ shows no "Back" link and no breadcrumbs, publishes no back URL when no
85
+ `back_url:` is passed, so the mobile header shows no back arrow, and raises
86
+ nothing. With no `back_url:` and no trail from either place, or a trail whose
87
+ last link has no `href`, rendering raises `KeystoneUi::MissingBackLink`,
88
+ naming the page's title. A trail with any link whose label or `href` is `nil`
89
+ or blank raises `KeystoneUi::IncompleteTrail`, naming the page's title, even
90
+ when `back_url:` is passed.
87
91
  - `ui_show_page(title:, back_url: nil, subtitle: nil, trail: nil)` — the shell
88
92
  marker for a detail screen. It renders nothing where it is called. It
89
93
  publishes the title, subtitle, and back URL for the navbar, and hands
90
94
  `ui_page` a "Back" link to `back_url` shown from `lg:` up. Call it before
91
95
  `ui_page`, outside `ui_page`'s block. It shows no title, so put
92
96
  `ui_page_header` inside the `ui_page` block for the desktop title. `trail:`
93
- and `back_url:` work as they do on `ui_form_page`, including the supplied
94
- trail, the fallback to the trail's last link, and the
97
+ and `back_url:` work as they do on `ui_form_page`, including the breadcrumbs
98
+ under the "Back" link, the supplied trail, the fallback to the trail's last
99
+ link, `trail: []` for a navigation tab's own page, and the
95
100
  `KeystoneUi::MissingBackLink` and `KeystoneUi::IncompleteTrail` errors, and
96
101
  the breadcrumbs end with `title` unlinked.
97
102
  - `ui_breadcrumbs(trail:, current: nil)` — a line of links shown only from `lg:`
@@ -116,7 +121,8 @@ outer element. See Conventions before using it.
116
121
  `icon:` is a raw SVG string.
117
122
  - `ui_mobile_header(title:, back_url:, subtitle: nil)` — a back chevron plus
118
123
  centered title for mobile; hidden above `lg:`. Place it in the navbar's
119
- `mobile_left` slot.
124
+ `mobile_left` slot. `back_url:` must be passed, and `nil` renders the title
125
+ with no back chevron.
120
126
  - `ui_action_menu` — no keywords, takes a block. An ellipsis (⋯) button that
121
127
  opens a dropdown of actions, shown at every screen size. Fill the block with
122
128
  `ui_action_menu_item` calls.
@@ -233,8 +239,9 @@ outer element. See Conventions before using it.
233
239
  they were declared. Columns that are not hideable keep their declared place,
234
240
  and the hideable ones fill the remaining places. With no `"column_order"` the
235
241
  columns keep their declared order. Whenever the supplier
236
- returns a save address, the table renders a "Columns" menu above itself that
237
- saves to it, including for a person with nothing saved yet. When the
242
+ returns a save address, the table renders a "Columns" menu in a row above
243
+ itself, aligned right, that saves to it as `ui_column_picker` does, including
244
+ for a person with nothing saved yet. When the
238
245
  supplier returns nothing, when no supplier is set, or when no `key:` is
239
246
  passed, the table renders from `hidden_columns:` with no Columns menu. In
240
247
  every case `hidden_columns:` is the table's default layout.
@@ -247,13 +254,16 @@ outer element. See Conventions before using it.
247
254
  dropdown with one row per `hideable` column, in the order `columns:` lists
248
255
  them. Each row has a checkbox and an up and a down button that move the
249
256
  column one place; the first row's up button and the last row's down button
250
- are disabled. Pass it the same columns, in the order the table shows them,
251
- and the same hidden keys as the table. On a checkbox change or a move it
252
- sends `PATCH save_url` with JSON
253
- `{ "hidden_columns": ["key", ...], "column_order": ["key", ...] }` and a
254
- `X-CSRF-Token` header, then reloads the page. `column_order` lists every
255
- hideable column's key in the menu's order after the move. With no
256
- `save_url:` it sends nothing. The app must provide that endpoint and persist
257
+ are disabled, and after a move the disabled buttons follow the new first and
258
+ last rows. A hidden column's name renders greyed, and unticking a box greys
259
+ its name at once. Pass it the same columns, in the order the table shows
260
+ them, and the same hidden keys as the table. Ticking, unticking and moving
261
+ change only the open menu and send nothing. When the menu closes, by its
262
+ Columns button or by a click outside it, it sends one `PATCH save_url` with
263
+ JSON `{ "hidden_columns": ["key", ...], "column_order": ["key", ...] }` and a
264
+ `X-CSRF-Token` header, then reloads the page. A menu closed with nothing
265
+ changed sends nothing. `column_order` lists every hideable column's key in
266
+ the menu's order when it closes. With no `save_url:` it sends nothing. The app must provide that endpoint and persist
257
267
  both lists. The picker does not reorder the table: beside a table without
258
268
  `key:`, the app must pass the table and the picker its columns in the saved
259
269
  order itself. A table
@@ -454,8 +464,11 @@ outer element. See Conventions before using it.
454
464
  detail screen without `ui_page` shows no desktop "Back" link or form title.
455
465
  Those shells supply the desktop "Back" link themselves, so never add a
456
466
  second back link or button to those screens. Whether a screen
457
- shows that "Back" link or breadcrumbs, and which parent screens the trail
458
- names, is the developer's choice, so ask before passing `trail:`. Check
467
+ shows breadcrumbs under its "Back" link, and which parent screens the trail
468
+ names, is the developer's choice, so ask before passing `trail:`. A screen
469
+ a navigation tab opens directly, such as a bottom tab's own page, passes
470
+ `trail: []` and no `back_url:`, so it shows no "Back" link and no back
471
+ arrow; which screens those are is the developer's choice, so ask. Check
459
472
  first whether the app's Keystone UI initializer sets a `trail_supplier`,
460
473
  which supplies a trail for every request: if it
461
474
  does, a screen whose supplied trail is right passes neither `trail:` nor
@@ -539,7 +552,10 @@ outer element. See Conventions before using it.
539
552
  names the table, which columns are hideable, and which it hides by default
540
553
  are the developer's choice, so ask rather than pick. If the app sets no supplier, either use `ui_column_picker`
541
554
  with an endpoint the app owns, as in step 7, or hand setting up a supplier to
542
- `keystone_ui-install`, and ask the developer which.
555
+ `keystone_ui-install`, and ask the developer which. If a Columns menu shows
556
+ no greyed name for a hidden column, the app's keystone_ui-styles version is
557
+ older than 0.11.0, so stop and hand that part to `keystone_ui-install`, and
558
+ add no classes to fix it.
543
559
 
544
560
  7. Wire up anything that posts back. Several helpers render controls whose
545
561
  endpoints the app must own — the column picker's save URL, the pipeline's box
@@ -26,21 +26,24 @@ component updates every page that uses it. It is mobile-first — components shi
26
26
  separate mobile and desktop treatments (a bottom tab bar and mobile header on
27
27
  small screens, a full navigation bar from the `lg:` breakpoint up), because
28
28
  these apps are often viewed in a native webview. The form and show page shells
29
- follow the same split for going back: the mobile header carries the back link on
29
+ follow the same split for going back: the mobile header carries the back arrow on
30
30
  small screens, and from `lg:` up the shell shows a "Back" link. Given a trail of
31
- earlier pages instead, the shell shows breadcrumbs in place of that link, ending
32
- with the page's own title. A page that passes no trail gets the one the app or
31
+ earlier pages, the shell shows breadcrumbs under that "Back" link, ending with
32
+ the page's own title. A page that passes no trail gets the one the app or
33
33
  another gem supplies for the request, if any, and a page that passes no back
34
34
  link goes back to that trail's last link. A trail or back link the page passes
35
35
  itself always wins. Supplying a trail is set up through the install local.
36
36
 
37
- Every form and show page must end up with a Back link. A page with no back
38
- link, no trail and no supplied trail raises `KeystoneUi::MissingBackLink` when it
39
- renders, and the message names the page's title. A trail with a link missing
40
- its label or its address raises `KeystoneUi::IncompleteTrail`, also naming the
41
- page. That link or those breadcrumbs, and the form page's title, appear at the
42
- top of the page container, inside its width and padding, so a page using either
43
- shell also uses the page container.
37
+ A nav tab's own page has nowhere to go back to, and it says so by passing an
38
+ empty trail. Such a page shows no "Back" link and no breadcrumbs, and its mobile
39
+ header shows no back arrow. Every other form and show page must end up with a
40
+ Back link. A page with no back link, no trail and no supplied trail raises
41
+ `KeystoneUi::MissingBackLink` when it renders, and the message names the page's
42
+ title and says an empty trail marks a nav tab's page. A trail with a link
43
+ missing its label or its address raises `KeystoneUi::IncompleteTrail`, also
44
+ naming the page. The "Back" link, the breadcrumbs and the form page's title
45
+ appear at the top of the page container, inside its width and padding, so a
46
+ page using either shell also uses the page container.
44
47
 
45
48
  ## Interface
46
49
 
@@ -137,11 +140,14 @@ holds the catalog.
137
140
  out follow the ones it names. Every other column keeps its place, and a
138
141
  layout with no order keeps the order the columns were declared in. When the
139
142
  supplier gives an address to save to, a "Columns" menu appears above the
140
- table and saves the user's choice there, even before anything has been
141
- saved. The menu lists the hideable columns in the order the table shows
142
- them, each with a box to show or hide it and buttons to move it up or down.
143
- Ticking a box or moving a column saves the hidden columns and the order
144
- together, then reloads the page.
143
+ table, at its right, and saves the user's choice there, even before anything
144
+ has been saved. The menu lists the hideable columns in the order the table
145
+ shows them, each with a box to show or hide it and buttons to move it up or
146
+ down. An unticked column's name is greyed at once. Ticking boxes and moving
147
+ columns sends nothing while the menu is open. Closing the menu, with its
148
+ Columns button or by clicking anywhere outside it, saves the hidden columns
149
+ and the order together once, then reloads the page. Closing it with nothing
150
+ changed saves nothing.
145
151
  A table with no key, or an app with no supplier, renders from its own call
146
152
  alone. Setting up the supplier belongs to the install local.
147
153
  - **Suggestions.** A form field can carry a list of suggested values. The
@@ -43,7 +43,7 @@ built on ViewComponent; hook it in before building any screen with those helpers
43
43
  ## How to use it
44
44
 
45
45
  1. Confirm the prerequisites: Ruby >= 3.2 and **tailwindcss-rails v4+** in the
46
- host app. The gem brings ViewComponent and keystone_ui-styles 0.10.0 or later with it.
46
+ host app. The gem brings ViewComponent and keystone_ui-styles 0.11.0 or later with it.
47
47
  Tailwind does not have to be initialized first, because the generator creates
48
48
  the stylesheet if it is missing.
49
49
 
@@ -213,26 +213,31 @@ built on ViewComponent; hook it in before building any screen with those helpers
213
213
  name for the request. A name that is not registered, or `nil`, leaves the
214
214
  page on the default look.
215
215
  - `trail_supplier` — a callable that receives the view and returns the
216
- breadcrumb trail as an array of `[label, href]` pairs, or `nil`. A form or
217
- show page that passes no trail of its own shows the supplied one on `lg:`
218
- screens, ending with the page's title, in place of the desktop "Back" link.
219
- A page that passes no Back link goes back to the trail's last link. A page
220
- that passes its own trail or Back link keeps it. With no supplier, or a
221
- `nil` return, the page shows its Back link. Return `nil`, not an empty
222
- array, for a page with no trail. An empty array replaces the page's Back
223
- link with breadcrumbs holding only its title, and on a page that passes
224
- no Back link it raises `KeystoneUi::MissingBackLink`.
225
- - Every form and show page must end up with a Back link. A page that passes
226
- no Back link and no trail, and gets no trail from the supplier, raises
227
- `KeystoneUi::MissingBackLink` naming the page's title when it renders.
228
- So does a page whose trail's last link has no address.
229
- - Every link the supplier returns needs both a label and an address. A trail
230
- with a blank label or address raises `KeystoneUi::IncompleteTrail` naming
231
- the page's title.
232
- - Ask the developer which code in the app knows each page's trail before
233
- writing the callable. If some form or show pages pass no `back_url:`, ask
234
- where their Back link should come from before enabling the supplier or
235
- leaving it out.
216
+ breadcrumb trail as an array of `[label, href]` pairs, an empty array, or
217
+ `nil`. It is asked only by a form or show page that passes no `trail:`.
218
+ A page that passes its own trail, including an empty one, keeps it.
219
+ - On `lg:` screens a form or show page shows a "Back" link, and under it the
220
+ breadcrumbs ending with the page's title when the trail has any links. A
221
+ page that passes no `back_url:` goes back to the trail's last link. With
222
+ no supplier, or a `nil` return, the page shows only its Back link.
223
+ - An empty trail marks a nav tab's own page, which has nowhere to go back
224
+ to. The page shows no Back link and no breadcrumbs, and raises nothing.
225
+ Return `[]` from the supplier for those
226
+ pages, and `nil` for a page whose Back link comes from its own
227
+ `back_url:`.
228
+ - Every other form and show page must end up with a Back link. A page that
229
+ passes no `back_url:`, and has no trail or a trail whose last link has no
230
+ address, raises `KeystoneUi::MissingBackLink` naming the page's title when
231
+ it renders. The message tells the developer to pass `back_url:` or
232
+ `trail:`, to supply a trail through `trail_supplier`, or to pass
233
+ `trail: []` on a nav tab's own page.
234
+ - Every link in a trail needs both a label and an address. A trail with a
235
+ blank label or address raises `KeystoneUi::IncompleteTrail` naming the
236
+ page's title.
237
+ - Ask the developer which code in the app knows each page's trail, and which
238
+ pages are nav tabs' own pages, before writing the callable. If some form
239
+ or show pages pass no `back_url:`, ask where their Back link should come
240
+ from before enabling the supplier or leaving it out.
236
241
  - `preference_supplier` — a callable that receives the view and a data
237
242
  table's key and returns `{ value:, save_url: }`, or `nil` when the person
238
243
  can neither see nor save a layout for that key. It is asked only for
@@ -257,13 +262,18 @@ built on ViewComponent; hook it in before building any screen with those helpers
257
262
  - When nothing is saved yet for a person who may save a layout, return
258
263
  `{ value: nil, save_url: }`. The table then shows its own default layout
259
264
  with the Columns menu, so the person can save a first layout.
260
- - When `save_url` is present, the table shows a Columns menu above itself.
261
- It lists the hideable columns in the order the table shows them, with the
262
- currently hidden columns unchecked, and gives each column an up and a down
263
- button. Ticking or unticking a column, or moving one, sends a `PATCH` to
264
- `save_url` with the page's CSRF token and the JSON body
265
- `{"hidden_columns": [...], "column_order": [...]}`, then reloads the page.
266
- `column_order` lists every hideable column's name in the menu's order.
265
+ - When `save_url` is present, the table shows a Columns button above its
266
+ right edge. The button opens a menu listing the hideable columns in the
267
+ order the table shows them, with the currently hidden columns unchecked,
268
+ and gives each column an up and a down button.
269
+ - Ticking, unticking and moving columns change only the menu while it is
270
+ open. When the menu is closed, by its Columns button or by a click
271
+ outside it, it sends one `PATCH` to `save_url` if anything was changed
272
+ while it was open, then reloads the page. A menu closed with no change
273
+ sends nothing.
274
+ - The `PATCH` carries the page's CSRF token and the JSON body
275
+ `{"hidden_columns": [...], "column_order": [...]}`. `column_order` lists
276
+ every hideable column's name in the menu's order.
267
277
  - The host must have a route and action at `save_url` that store both lists
268
278
  for that key. The supplier must return them in `value` under the same
269
279
  string keys, `"hidden_columns"` and `"column_order"`, or the saved order
@@ -125,6 +125,7 @@ sources:
125
125
  - app/components/keystone/ui/action_menu_component.rb
126
126
  - app/components/keystone/ui/action_menu_item_component.rb
127
127
  - app/components/keystone/ui/mobile_header_component.rb
128
+ - app/components/keystone/ui/mobile_header_component.html.erb
128
129
  - app/components/keystone/ui/modal_component.rb
129
130
  - app/components/keystone/ui/multi_select_component.rb
130
131
  - app/components/keystone/ui/nav_dropdown_component.rb
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.34.0
4
+ version: 0.35.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.10.0
18
+ version: 0.12.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.10.0
25
+ version: 0.12.0
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: view_component
28
28
  requirement: !ruby/object:Gem::Requirement