keystone_ui 0.58.0 → 0.60.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 +4 -4
- data/app/assets/javascripts/keystone_ui/index.js +3 -1
- data/app/assets/javascripts/keystone_ui/sortable_list_controller.js +61 -0
- data/app/components/keystone/ui/mobile_header_component.rb +3 -3
- data/app/components/keystone/ui/navbar_component.rb +3 -3
- data/app/components/keystone/ui/sortable_list_component.html.erb +26 -0
- data/app/components/keystone/ui/sortable_list_component.rb +20 -0
- data/app/helpers/keystone_ui_helper.rb +4 -0
- data/config/importmap.rb +1 -0
- data/lib/keystone_ui/safelist.rb +1 -0
- data/lib/keystone_ui/version.rb +1 -1
- data/the_local/agents/keystone_ui-develop.md +17 -2
- data/the_local/interface.yml +3 -0
- metadata +4 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cd5a112008a22c8c4a2c46f10929571f013deef9df4d4926d3d17a06d47e09f3
|
|
4
|
+
data.tar.gz: cab1f062cc0f9f68f3a577e82c7a406895e5b50005af4b671fd0e48f4fbbe81c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bb84cb09936b8fd5d1695142591e4502fd76ce307b91b692c10d09d516de165b0277d935097aa9c786c62a9bfc14b3531ab14b74cf9ad8dd35d811d7f1d70f83
|
|
7
|
+
data.tar.gz: f4a070003e5b23465001b048265b3abe0d4c5870221bf31e85eb67eeceeb0fc7f4d28d14e89200524010bf17297d11d6c2570075fd16eb636494946f4f0606ff
|
|
@@ -2,6 +2,7 @@ import ColorPickerController from "keystone_ui/color_picker_controller"
|
|
|
2
2
|
import MultiSelectController from "keystone_ui/multi_select_controller"
|
|
3
3
|
import SearchSelectController from "keystone_ui/search_select_controller"
|
|
4
4
|
import SwipeDeckController from "keystone_ui/swipe_deck_controller"
|
|
5
|
+
import SortableListController from "keystone_ui/sortable_list_controller"
|
|
5
6
|
import ColumnPickerController from "keystone_ui/column_picker_controller"
|
|
6
7
|
import FileUploadController from "keystone_ui/file_upload_controller"
|
|
7
8
|
import DropdownController from "keystone_ui/dropdown_controller"
|
|
@@ -23,6 +24,7 @@ export function registerControllers(application) {
|
|
|
23
24
|
application.register("multi-select", MultiSelectController)
|
|
24
25
|
application.register("search-select", SearchSelectController)
|
|
25
26
|
application.register("swipe-deck", SwipeDeckController)
|
|
27
|
+
application.register("sortable-list", SortableListController)
|
|
26
28
|
application.register("column-picker", ColumnPickerController)
|
|
27
29
|
application.register("file-upload", FileUploadController)
|
|
28
30
|
application.register("dropdown", DropdownController)
|
|
@@ -40,4 +42,4 @@ export function registerControllers(application) {
|
|
|
40
42
|
keepPageThemeInStep()
|
|
41
43
|
}
|
|
42
44
|
|
|
43
|
-
export { ColorPickerController, MultiSelectController, SwipeDeckController, ColumnPickerController, FileUploadController, DropdownController, DismissController, ModalController, ClipboardController, TabSwitcherController, AccordionController, StatCardInfoController, InfoController, AutoSubmitController, LineChartController }
|
|
45
|
+
export { ColorPickerController, MultiSelectController, SwipeDeckController, SortableListController, ColumnPickerController, FileUploadController, DropdownController, DismissController, ModalController, ClipboardController, TabSwitcherController, AccordionController, StatCardInfoController, InfoController, AutoSubmitController, LineChartController }
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { Controller } from "@hotwired/stimulus"
|
|
2
|
+
|
|
3
|
+
export default class extends Controller {
|
|
4
|
+
static targets = ["row", "control", "status"]
|
|
5
|
+
|
|
6
|
+
connect() {
|
|
7
|
+
this.controlTargets.forEach((control) => { control.hidden = false })
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
moveUp({ currentTarget }) {
|
|
11
|
+
const row = this.rowHolding(currentTarget)
|
|
12
|
+
const previous = row.previousElementSibling
|
|
13
|
+
if (previous) row.after(previous)
|
|
14
|
+
this.announce(row)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
moveDown({ currentTarget }) {
|
|
18
|
+
const row = this.rowHolding(currentTarget)
|
|
19
|
+
const next = row.nextElementSibling
|
|
20
|
+
if (next) row.before(next)
|
|
21
|
+
this.announce(row)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
grab({ currentTarget, pointerId, button }) {
|
|
25
|
+
if (button !== 0 || this.dragged) return
|
|
26
|
+
|
|
27
|
+
currentTarget.setPointerCapture(pointerId)
|
|
28
|
+
this.draggingPointer = pointerId
|
|
29
|
+
this.dragged = this.rowHolding(currentTarget)
|
|
30
|
+
this.startingIndex = this.rowTargets.indexOf(this.dragged)
|
|
31
|
+
this.dragged.dataset.dragging = "true"
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
drag({ clientY, pointerId }) {
|
|
35
|
+
const row = this.dragged
|
|
36
|
+
if (!row || pointerId !== this.draggingPointer) return
|
|
37
|
+
while (row.nextElementSibling && clientY > this.middleOf(row.nextElementSibling)) row.before(row.nextElementSibling)
|
|
38
|
+
while (row.previousElementSibling && clientY < this.middleOf(row.previousElementSibling)) row.after(row.previousElementSibling)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
drop({ pointerId }) {
|
|
42
|
+
if (!this.dragged || pointerId !== this.draggingPointer) return
|
|
43
|
+
if (this.rowTargets.indexOf(this.dragged) !== this.startingIndex) this.announce(this.dragged)
|
|
44
|
+
delete this.dragged.dataset.dragging
|
|
45
|
+
this.dragged = null
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
middleOf(row) {
|
|
49
|
+
const { top, height } = row.getBoundingClientRect()
|
|
50
|
+
return top + height / 2
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
announce(row) {
|
|
54
|
+
const rows = this.rowTargets
|
|
55
|
+
this.statusTarget.textContent = `${row.dataset.label} is number ${rows.indexOf(row) + 1} of ${rows.length}.`
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
rowHolding(element) {
|
|
59
|
+
return element.closest('[data-sortable-list-target="row"]')
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -15,10 +15,10 @@ module Keystone
|
|
|
15
15
|
</svg>
|
|
16
16
|
SVG
|
|
17
17
|
|
|
18
|
-
WRAPPER_CLASSES = "lg:hidden print:hidden"
|
|
18
|
+
WRAPPER_CLASSES = "flex items-center lg:hidden print:hidden"
|
|
19
19
|
BACK_LINK_CLASSES = "ks-mobile-header-back"
|
|
20
|
-
TITLE_CLASSES = "ks-mobile-header-title
|
|
21
|
-
SUBTITLE_CLASSES = "ks-mobile-header-subtitle block text-xs truncate
|
|
20
|
+
TITLE_CLASSES = "ks-mobile-header-title flex-[1_1_6rem] min-w-0 self-center lg:hidden truncate"
|
|
21
|
+
SUBTITLE_CLASSES = "ks-mobile-header-subtitle block text-xs truncate"
|
|
22
22
|
DROPDOWN_CLASSES = "ks-action-menu hidden absolute right-0 z-50 w-48 origin-top-right"
|
|
23
23
|
|
|
24
24
|
# Renders the left-side and title of the mobile header.
|
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
module Keystone
|
|
4
4
|
module Ui
|
|
5
5
|
class NavbarComponent < ViewComponent::Base
|
|
6
|
-
NAV_BASE = "top-nav print:hidden"
|
|
6
|
+
NAV_BASE = "top-nav print:hidden max-lg:has-[.ks-mobile-header-title]:flex-wrap"
|
|
7
7
|
NAV_STICKY = "sticky top-0 z-40"
|
|
8
|
-
MOBILE_LEFT_CLASSES = "lg:hidden flex items-center"
|
|
8
|
+
MOBILE_LEFT_CLASSES = "lg:hidden flex items-center max-lg:has-[.ks-mobile-header-title]:contents"
|
|
9
9
|
LOGO_CLASSES = "logo"
|
|
10
10
|
LOGO_MOBILE_HIDDEN_CLASSES = "hidden lg:flex"
|
|
11
11
|
MOBILE_CENTER_CLASSES = "ks-navbar-title absolute left-1/2 -translate-x-1/2 lg:hidden truncate max-w-[60%]"
|
|
12
12
|
DESKTOP_LINKS_CLASSES = "nav-container hidden lg:flex"
|
|
13
|
-
MOBILE_RIGHT_CLASSES = "nav-user-controls ml-auto"
|
|
13
|
+
MOBILE_RIGHT_CLASSES = "nav-user-controls ml-auto max-lg:in-[.top-nav:has(.ks-mobile-header-title)]:flex-wrap max-lg:in-[.top-nav:has(.ks-mobile-header-title)]:justify-end"
|
|
14
14
|
|
|
15
15
|
renders_one :logo
|
|
16
16
|
renders_one :desktop_links
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<div data-controller="sortable-list">
|
|
2
|
+
<ul aria-label="<%= @label %>">
|
|
3
|
+
<% @rows.each do |row| %>
|
|
4
|
+
<li class="<%= ROW_CLASSES %>" data-sortable-list-target="row" data-label="<%= row[:label] %>">
|
|
5
|
+
<input type="hidden" name="<%= @name %>" value="<%= row[:id] %>">
|
|
6
|
+
<span hidden data-sortable-list-target="control" class="<%= HANDLE_CLASSES %>" data-action="pointerdown->sortable-list#grab pointermove->sortable-list#drag pointerup->sortable-list#drop pointercancel->sortable-list#drop">
|
|
7
|
+
<svg class="<%= ICON_CLASSES %>" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" aria-hidden="true">
|
|
8
|
+
<path stroke-linecap="round" d="M4 8h16M4 16h16" />
|
|
9
|
+
</svg>
|
|
10
|
+
</span>
|
|
11
|
+
<span class="<%= LABEL_CLASSES %>"><%= row[:label] %></span>
|
|
12
|
+
<button hidden data-sortable-list-target="control" type="button" class="<%= MOVE_BUTTON_CLASSES %>" aria-label="Move <%= row[:label] %> up" data-action="sortable-list#moveUp">
|
|
13
|
+
<svg class="<%= ICON_CLASSES %>" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" aria-hidden="true">
|
|
14
|
+
<path stroke-linecap="round" stroke-linejoin="round" d="m4.5 15.75 7.5-7.5 7.5 7.5" />
|
|
15
|
+
</svg>
|
|
16
|
+
</button>
|
|
17
|
+
<button hidden data-sortable-list-target="control" type="button" class="<%= MOVE_BUTTON_CLASSES %>" aria-label="Move <%= row[:label] %> down" data-action="sortable-list#moveDown">
|
|
18
|
+
<svg class="<%= ICON_CLASSES %>" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" aria-hidden="true">
|
|
19
|
+
<path stroke-linecap="round" stroke-linejoin="round" d="m19.5 8.25-7.5 7.5-7.5-7.5" />
|
|
20
|
+
</svg>
|
|
21
|
+
</button>
|
|
22
|
+
</li>
|
|
23
|
+
<% end %>
|
|
24
|
+
</ul>
|
|
25
|
+
<div role="status" class="<%= STATUS_CLASSES %>" data-sortable-list-target="status"></div>
|
|
26
|
+
</div>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Keystone
|
|
4
|
+
module Ui
|
|
5
|
+
class SortableListComponent < ViewComponent::Base
|
|
6
|
+
ROW_CLASSES = "ks-value-list-row items-center data-dragging:opacity-50"
|
|
7
|
+
LABEL_CLASSES = "ks-paragraph min-w-0 flex-1"
|
|
8
|
+
HANDLE_CLASSES = "ks-tone-muted flex size-11 shrink-0 cursor-grab touch-none select-none items-center justify-center"
|
|
9
|
+
MOVE_BUTTON_CLASSES = "ks-button ks-button-secondary ks-button-sm size-11 shrink-0"
|
|
10
|
+
ICON_CLASSES = "size-5"
|
|
11
|
+
STATUS_CLASSES = "sr-only"
|
|
12
|
+
|
|
13
|
+
def initialize(name:, label:, rows:)
|
|
14
|
+
@name = name
|
|
15
|
+
@label = label
|
|
16
|
+
@rows = rows
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -205,6 +205,10 @@ module KeystoneUiHelper
|
|
|
205
205
|
render Keystone::Ui::SwipeDeckComponent.new(**args), &block
|
|
206
206
|
end
|
|
207
207
|
|
|
208
|
+
def ui_sortable_list(**args)
|
|
209
|
+
render Keystone::Ui::SortableListComponent.new(**args)
|
|
210
|
+
end
|
|
211
|
+
|
|
208
212
|
def ui_column_picker(**args)
|
|
209
213
|
render Keystone::Ui::ColumnPickerComponent.new(**args)
|
|
210
214
|
end
|
data/config/importmap.rb
CHANGED
|
@@ -3,6 +3,7 @@ pin "keystone_ui/color_picker_controller", to: "keystone_ui/color_picker_control
|
|
|
3
3
|
pin "keystone_ui/multi_select_controller", to: "keystone_ui/multi_select_controller.js"
|
|
4
4
|
pin "keystone_ui/search_select_controller", to: "keystone_ui/search_select_controller.js"
|
|
5
5
|
pin "keystone_ui/swipe_deck_controller", to: "keystone_ui/swipe_deck_controller.js"
|
|
6
|
+
pin "keystone_ui/sortable_list_controller", to: "keystone_ui/sortable_list_controller.js"
|
|
6
7
|
pin "keystone_ui/column_picker_controller", to: "keystone_ui/column_picker_controller.js"
|
|
7
8
|
pin "keystone_ui/file_upload_controller", to: "keystone_ui/file_upload_controller.js"
|
|
8
9
|
pin "keystone_ui/dropdown_controller", to: "keystone_ui/dropdown_controller.js"
|
data/lib/keystone_ui/safelist.rb
CHANGED
|
@@ -58,6 +58,7 @@ module Keystone
|
|
|
58
58
|
Keystone::Ui::ColorPickerComponent,
|
|
59
59
|
Keystone::Ui::MultiSelectComponent,
|
|
60
60
|
Keystone::Ui::SwipeDeckComponent,
|
|
61
|
+
Keystone::Ui::SortableListComponent,
|
|
61
62
|
Keystone::Ui::ColumnPickerComponent,
|
|
62
63
|
Keystone::Ui::FormComponent,
|
|
63
64
|
Keystone::Ui::FileUploadComponent,
|
data/lib/keystone_ui/version.rb
CHANGED
|
@@ -40,7 +40,7 @@ not available in the app yet, that is `keystone_ui-install`'s job.
|
|
|
40
40
|
- `ui_nav_dropdown` — a navbar dropdown menu.
|
|
41
41
|
- `ui_bottom_nav` — the mobile bottom tab bar.
|
|
42
42
|
- `ui_bottom_nav_item` — one tab in the bottom tab bar.
|
|
43
|
-
- `ui_mobile_header` — a mobile back arrow and
|
|
43
|
+
- `ui_mobile_header` — a mobile back arrow and a title beside it.
|
|
44
44
|
- `ui_mobile_actions` — an ellipsis menu of actions shown only below `lg:`.
|
|
45
45
|
- `ui_mobile_action` — a plus icon link to the action a screen's page header publishes, for the phone top bar.
|
|
46
46
|
- `ui_action_menu` — an ellipsis menu of actions shown at every screen size.
|
|
@@ -58,6 +58,7 @@ not available in the app yet, that is `keystone_ui-install`'s job.
|
|
|
58
58
|
- `ui_color_picker` — a colour swatch that writes a hex value into a hidden input.
|
|
59
59
|
- `ui_radio_card` — a selectable card backed by a radio input.
|
|
60
60
|
- `ui_checkbox_row` — a checkbox with its label and hint, toggled by a tap anywhere on the row.
|
|
61
|
+
- `ui_sortable_list` — a list of rows dragged into a new order, submitted with the form it sits in.
|
|
61
62
|
- `ui_option_card` — a radio whose visible body is whatever its block renders.
|
|
62
63
|
- `ui_data_table` — a table of records with links, row actions, sorting, hideable columns and the viewer's own row marked.
|
|
63
64
|
- `Keystone::Ui::Column` — a table column with options a `{ key: "Label" }` hash cannot carry.
|
|
@@ -257,7 +258,13 @@ two exceptions: `ui_page`'s `padding:` treats any value other than `:none` as
|
|
|
257
258
|
Hotwire Native web view.
|
|
258
259
|
- `ui_mobile_header(title:, back_url:, subtitle: nil)` is hidden from `lg:`
|
|
259
260
|
up and goes in the navbar's `mobile_left` slot. `back_url:` must be
|
|
260
|
-
passed, and `nil` renders the title with no back arrow.
|
|
261
|
+
passed, and `nil` renders the title with no back arrow. The title and
|
|
262
|
+
subtitle sit between the arrow and the right-side controls, start at the
|
|
263
|
+
left, and end in an ellipsis when too long. In `ui_navbar`, controls that
|
|
264
|
+
leave less than 6rem for the title move to a second row under it. In a
|
|
265
|
+
hand-written top bar, make the header a direct child of the bar's flex
|
|
266
|
+
row, and add `max-lg:has-[.ks-mobile-header-title]:flex-wrap` to the bar if
|
|
267
|
+
its controls can fill its width.
|
|
261
268
|
- `ui_mobile_action` takes no keywords and no block, and goes in the top
|
|
262
269
|
bar's right side, such as the navbar's `mobile_right` slot. It draws a plus
|
|
263
270
|
icon linking to the `action_url:` a screen gives `ui_page_header`, named
|
|
@@ -379,6 +386,14 @@ two exceptions: `ui_page`'s `padding:` treats any value other than `:none` as
|
|
|
379
386
|
- A checked `ui_checkbox_row` submits `value` under `name`, an unchecked one
|
|
380
387
|
submits nothing, and rows sharing an array name such as `"shown[]"`
|
|
381
388
|
submit the checked values as a list.
|
|
389
|
+
- `ui_sortable_list(name:, label:, rows:)` is one field inside a `ui_form`,
|
|
390
|
+
for putting a short list in order. `rows:` is an array of
|
|
391
|
+
`{ id:, label: }` hashes, `label:` names the list for screen readers, and
|
|
392
|
+
`name:` names a hidden field in each row, so pass an array name such as
|
|
393
|
+
`"order[]"` and a different one for each list on a page. The form submits
|
|
394
|
+
the ids in the order shown, and the list makes no request of its own. A
|
|
395
|
+
row is dragged by its handle, or moved with its Move up and Move down
|
|
396
|
+
buttons. Without JavaScript the form submits the starting order.
|
|
382
397
|
- `ui_option_card(name:, value:, selected: false, input_data: {}, label_data: {})`
|
|
383
398
|
takes a block rendering the card's body. `input_data:` and `label_data:`
|
|
384
399
|
become `data-*` attributes on the input and the label.
|
data/the_local/interface.yml
CHANGED
|
@@ -55,6 +55,7 @@ develop:
|
|
|
55
55
|
- ui_multi_select
|
|
56
56
|
- ui_search_select
|
|
57
57
|
- ui_swipe_deck
|
|
58
|
+
- ui_sortable_list
|
|
58
59
|
- ui_column_picker
|
|
59
60
|
- ui_form
|
|
60
61
|
- ui_file_upload
|
|
@@ -165,6 +166,8 @@ sources:
|
|
|
165
166
|
- app/components/keystone/ui/settings_link_component.rb
|
|
166
167
|
- app/components/keystone/ui/show_page_component.rb
|
|
167
168
|
- app/components/keystone/ui/show_page_component.html.erb
|
|
169
|
+
- app/components/keystone/ui/sortable_list_component.rb
|
|
170
|
+
- app/components/keystone/ui/sortable_list_component.html.erb
|
|
168
171
|
- app/components/keystone/ui/stat_card_component.rb
|
|
169
172
|
- app/components/keystone/ui/stat_card_component.html.erb
|
|
170
173
|
- app/components/keystone/ui/swipe_deck_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.
|
|
4
|
+
version: 0.60.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Tyler Schneider
|
|
@@ -68,6 +68,7 @@ files:
|
|
|
68
68
|
- app/assets/javascripts/keystone_ui/multi_select_controller.js
|
|
69
69
|
- app/assets/javascripts/keystone_ui/page_theme.js
|
|
70
70
|
- app/assets/javascripts/keystone_ui/search_select_controller.js
|
|
71
|
+
- app/assets/javascripts/keystone_ui/sortable_list_controller.js
|
|
71
72
|
- app/assets/javascripts/keystone_ui/stat_card_info_controller.js
|
|
72
73
|
- app/assets/javascripts/keystone_ui/swipe_deck_controller.js
|
|
73
74
|
- app/assets/javascripts/keystone_ui/tab_switcher_controller.js
|
|
@@ -198,6 +199,8 @@ files:
|
|
|
198
199
|
- app/components/keystone/ui/settings_link_component.rb
|
|
199
200
|
- app/components/keystone/ui/show_page_component.html.erb
|
|
200
201
|
- app/components/keystone/ui/show_page_component.rb
|
|
202
|
+
- app/components/keystone/ui/sortable_list_component.html.erb
|
|
203
|
+
- app/components/keystone/ui/sortable_list_component.rb
|
|
201
204
|
- app/components/keystone/ui/stat_card_component.html.erb
|
|
202
205
|
- app/components/keystone/ui/stat_card_component.rb
|
|
203
206
|
- app/components/keystone/ui/swipe_deck_component.html.erb
|