keystone_ui 0.35.0 → 0.36.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/components/keystone/ui/column.rb +4 -2
- data/app/components/keystone/ui/data_table_component.rb +4 -0
- data/lib/keystone_ui/version.rb +1 -1
- data/the_local/agents/keystone_ui-develop.md +17 -4
- data/the_local/agents/keystone_ui-info.md +7 -0
- data/the_local/agents/keystone_ui-install.md +4 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d7a0b5685fe1dc1107e8e75d274e80401826ed52616ae95c20d6a288fdc5c647
|
|
4
|
+
data.tar.gz: 8220957d8d617f0c32c71b264c84c5bf8b992a3cc2e3bb512f3f4e0a1cbf8bb0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 58889e18335df436f8b13caad57648caf6ed3e13e17b50dc5d6011ae0f8fa85ceb98a9e9fd682f90cd10729ed3d3f20603ed34e438afb09a33090ec4d7493c95
|
|
7
|
+
data.tar.gz: c79c624b0a0a09e83b1f6fcee1566df17c7adf96f8141a20c8ee3ed20b361ab7faa1135be33bcf41f780e68e663e78d9ba833d27af09e72c782d4763a09463da
|
|
@@ -5,17 +5,19 @@ module Keystone
|
|
|
5
5
|
class Column
|
|
6
6
|
attr_reader :key, :header_text
|
|
7
7
|
|
|
8
|
-
def initialize(key, header_text, mobile_hidden: false, sortable: false, hideable: false)
|
|
8
|
+
def initialize(key, header_text, mobile_hidden: false, sortable: false, hideable: false, locked: false)
|
|
9
9
|
@key = key
|
|
10
10
|
@header_text = header_text
|
|
11
11
|
@mobile_hidden = mobile_hidden
|
|
12
12
|
@sortable = sortable
|
|
13
13
|
@hideable = hideable
|
|
14
|
+
@locked = locked
|
|
14
15
|
end
|
|
15
16
|
|
|
16
17
|
def mobile_hidden? = @mobile_hidden
|
|
17
18
|
def sortable? = @sortable
|
|
18
|
-
def hideable? = @hideable
|
|
19
|
+
def hideable? = @hideable && !@locked
|
|
20
|
+
def locked? = @locked
|
|
19
21
|
end
|
|
20
22
|
end
|
|
21
23
|
end
|
|
@@ -17,6 +17,8 @@ module Keystone
|
|
|
17
17
|
ROW_CLASSES_LAST = "ks-table-cell-last text-right text-sm whitespace-nowrap"
|
|
18
18
|
|
|
19
19
|
MOBILE_HIDDEN_CLASSES = "hidden sm:table-cell"
|
|
20
|
+
HEADER_LOCKED_CLASSES = "ks-table-header-locked sticky left-0"
|
|
21
|
+
CELL_LOCKED_CLASSES = "ks-table-cell-locked sticky left-0"
|
|
20
22
|
|
|
21
23
|
SORT_LINK_CLASSES = "ks-table-sort-link group inline-flex items-center"
|
|
22
24
|
SORT_ICON_CLASSES = "h-4 w-4 flex-shrink-0"
|
|
@@ -76,6 +78,7 @@ module Keystone
|
|
|
76
78
|
cells = @columns.map.with_index do |column, index|
|
|
77
79
|
tokens = [ header_classes_for(index) ]
|
|
78
80
|
tokens << MOBILE_HIDDEN_CLASSES if column.mobile_hidden?
|
|
81
|
+
tokens << HEADER_LOCKED_CLASSES if index.zero? && column.locked?
|
|
79
82
|
|
|
80
83
|
cell = {
|
|
81
84
|
label: column.header_text,
|
|
@@ -119,6 +122,7 @@ module Keystone
|
|
|
119
122
|
@columns.map.with_index do |column, index|
|
|
120
123
|
tokens = [ row_classes_for(index) ]
|
|
121
124
|
tokens << MOBILE_HIDDEN_CLASSES if column.mobile_hidden?
|
|
125
|
+
tokens << CELL_LOCKED_CLASSES if index.zero? && column.locked?
|
|
122
126
|
|
|
123
127
|
cell = {
|
|
124
128
|
value: resolve_value(item, column.key),
|
data/lib/keystone_ui/version.rb
CHANGED
|
@@ -245,11 +245,16 @@ outer element. See Conventions before using it.
|
|
|
245
245
|
supplier returns nothing, when no supplier is set, or when no `key:` is
|
|
246
246
|
passed, the table renders from `hidden_columns:` with no Columns menu. In
|
|
247
247
|
every case `hidden_columns:` is the table's default layout.
|
|
248
|
-
- `Keystone::Ui::Column.new(key, header_text, mobile_hidden: false, sortable: false, hideable: false)`
|
|
248
|
+
- `Keystone::Ui::Column.new(key, header_text, mobile_hidden: false, sortable: false, hideable: false, locked: false)`
|
|
249
249
|
— a column with per-column options, for when a `{ key: "Label" }` hash is not
|
|
250
250
|
enough. `mobile_hidden:` hides the column below `sm:`; `sortable:` opts it into
|
|
251
251
|
sort headers; `hideable:` lets the Columns menu hide it and move it, and a
|
|
252
|
-
saved `"column_order"` place it.
|
|
252
|
+
saved `"column_order"` place it. `locked: true` on the table's first column
|
|
253
|
+
keeps its header and cells in view while the rest of the table scrolls
|
|
254
|
+
sideways. A locked column that is not first renders as an ordinary column. A
|
|
255
|
+
locked column is never hideable, even with `hideable: true`: it is left out of
|
|
256
|
+
the Columns menu, `hidden_columns:` and a saved layout cannot hide it, and a
|
|
257
|
+
saved `"column_order"` cannot move it.
|
|
253
258
|
- `ui_column_picker(columns:, hidden_columns: [], save_url: nil)` — a "Columns"
|
|
254
259
|
dropdown with one row per `hideable` column, in the order `columns:` lists
|
|
255
260
|
them. Each row has a checkbox and an up and a down button that move the
|
|
@@ -540,8 +545,16 @@ outer element. See Conventions before using it.
|
|
|
540
545
|
|
|
541
546
|
6. For a table, decide how columns are declared. Use `{ key: "Label" }` hashes
|
|
542
547
|
when every column is plain. Switch the whole set to `Keystone::Ui::Column`
|
|
543
|
-
objects as soon as one column needs `mobile_hidden:`, `sortable:`,
|
|
544
|
-
`hideable:`.
|
|
548
|
+
objects as soon as one column needs `mobile_hidden:`, `sortable:`,
|
|
549
|
+
`hideable:`, or `locked:`.
|
|
550
|
+
|
|
551
|
+
To keep a wide table's first column, such as a name, in view while the rest
|
|
552
|
+
scrolls sideways, declare it first with `locked: true`. Whether a table locks
|
|
553
|
+
its first column is the developer's choice, so ask rather than pick. If the
|
|
554
|
+
locked column stays in place but the scrolled columns show through its
|
|
555
|
+
cells, the app's keystone_ui-styles version does not define the
|
|
556
|
+
`ks-table-header-locked` and `ks-table-cell-locked` classes, so stop and hand
|
|
557
|
+
that part to `keystone_ui-install`, and add no classes to fix it.
|
|
545
558
|
|
|
546
559
|
For a table whose hideable columns a user should be able to choose and keep,
|
|
547
560
|
check whether the app's Keystone UI initializer sets a
|
|
@@ -127,6 +127,13 @@ holds the catalog.
|
|
|
127
127
|
- **The last table column is right-aligned.** In a data table with no actions
|
|
128
128
|
column, the last column's header is right-aligned like the cells beneath it,
|
|
129
129
|
so a figure or total placed in that header lines up with the figures below.
|
|
130
|
+
- **A locked first column.** A table column can be marked locked. When it is
|
|
131
|
+
the table's first column, its header and cells stay in view while the rest
|
|
132
|
+
of the table scrolls sideways, styled by keystone_ui-styles' locked header
|
|
133
|
+
and cell classes. A locked column anywhere else renders as an ordinary
|
|
134
|
+
column. A locked column cannot be hidden or moved, so it never appears in the
|
|
135
|
+
"Columns" menu and a saved layout leaves it where it is, even when it is also
|
|
136
|
+
marked hideable.
|
|
130
137
|
- **Saved table layouts.** A data table can be given a key naming it. A table
|
|
131
138
|
with a key asks the app, or another gem such as keystone_ui-preferences, for
|
|
132
139
|
the layout saved under that key for the request. A saved layout lists 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.
|
|
46
|
+
host app. The gem brings ViewComponent and keystone_ui-styles 0.12.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
|
|
|
@@ -248,6 +248,9 @@ built on ViewComponent; hook it in before building any screen with those helpers
|
|
|
248
248
|
`"hidden_columns"`, such as `{ "hidden_columns" => ["sku"] }`. That list
|
|
249
249
|
replaces the hidden columns the table's own call passes, and an empty list
|
|
250
250
|
shows every column. Only columns marked hideable are hidden.
|
|
251
|
+
- A column marked locked is never hideable, even when it is also marked
|
|
252
|
+
hideable. A saved layout cannot hide it or move it, and the Columns menu
|
|
253
|
+
does not list it.
|
|
251
254
|
- When `value` is `nil`, or has no `"hidden_columns"` string key, the table
|
|
252
255
|
keeps the hidden columns its own call passes. A symbol key is not read, so
|
|
253
256
|
`{ hidden_columns: [...] }` also keeps them.
|