@xeplr/ui-table 1.1.1 → 1.1.3
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.
- package/README.md +13 -2
- package/package.json +1 -1
- package/src/XeplrTable.jsx +19 -1
- package/src/pageSizes.js +9 -0
- package/src/xeplr-table.css +61 -5
package/README.md
CHANGED
|
@@ -48,9 +48,9 @@ The package ships its `src/` as ES modules with JSX and imports its own styleshe
|
|
|
48
48
|
| `data` | — | row array. Rows need an `id` for editing, selection and the changeset |
|
|
49
49
|
| `schema` | — | `{ 0: { key, columns }, 1: { key, columns, header? }, … }` — see below |
|
|
50
50
|
| `onCommit` | — | `async (changeSet) => …`. **Omit it and the table is read-only** |
|
|
51
|
-
| `rowActions` | — | custom per-row buttons, replacing the built-in set |
|
|
51
|
+
| `rowActions` | — | custom per-row buttons, replacing the built-in set. Labelled ones share one outlined look; `variant: 'danger'` turns one red |
|
|
52
52
|
| `childDisplay` | `'popup'` | `'popup'` or `'inner'` — how level-1 children show |
|
|
53
|
-
| `pageSize` | `20` | initial page size (the page-size menu offers 100, 200, 500, 1000) |
|
|
53
|
+
| `pageSize` | `20` | initial page size (the page-size menu offers 100, 200, 500, 1000, plus this size when it is not one of them) |
|
|
54
54
|
| `enableSorting`, `enableFiltering`, `enablePagination` | `true` | |
|
|
55
55
|
| `showToolbar` | `true` | `false` leaves the toolbar row out (a small table that offers no filtering or sorting). Editing tables keep it for Add/Delete/Commit. |
|
|
56
56
|
| `minDetectionRows` | `10` | non-empty samples a column needs before its detected type is final |
|
|
@@ -263,6 +263,17 @@ CSS classes are namespaced `xeplr-table-*` (chrome) and `xeplr-r-*` (renderers).
|
|
|
263
263
|
|
|
264
264
|
The `gold` / `blue` tag variants and `link` use fixed colours. The header is not sticky by default; add `position: sticky; top: 0` to `.xeplr-table-th` and the table offsets each grouped header row by the real height of the rows above it.
|
|
265
265
|
|
|
266
|
+
### Touch screens and phones
|
|
267
|
+
|
|
268
|
+
- **Rows keep scrolling sideways** on a phone, inside the table's own box — a table of ten columns does not fit 360px, and turning rows into cards loses the grid. The page itself never widens.
|
|
269
|
+
- **The actions column is pinned to the right edge** below 640px, so a row's Edit or Delete is on screen without scrolling the table.
|
|
270
|
+
- **One tap opens a row** on a touch screen where a mouse needs a double-click (`childDisplay="popup"`). A tap on the row's own button or tick box does only that.
|
|
271
|
+
- **Thumb-sized targets** on any touch screen (`pointer: coarse`) and below 640px: row buttons 40px, filter and expand buttons 36px, tick boxes 22px, toolbar and paging buttons 36–40px.
|
|
272
|
+
- **The toolbar and the paging bar wrap** instead of clipping their last buttons; "Page 1 of 3" and the row count never break mid-phrase.
|
|
273
|
+
- **Popups fill the screen** below 640px, and the detail popup's fields go to one column.
|
|
274
|
+
|
|
275
|
+
Nothing above changes on a desktop with a mouse.
|
|
276
|
+
|
|
266
277
|
### Style layers for a host panel
|
|
267
278
|
|
|
268
279
|
`tableStyles.js` is the vocabulary a host builds a style editor from — no React:
|
package/package.json
CHANGED
package/src/XeplrTable.jsx
CHANGED
|
@@ -15,6 +15,7 @@ import ChildTable from './actions/ChildTable.jsx';
|
|
|
15
15
|
import RecordModal from './actions/RecordModal.jsx';
|
|
16
16
|
import RecordDetail from './actions/RecordDetail.jsx';
|
|
17
17
|
import { resolveCellStyle } from './resolveCellStyle.js';
|
|
18
|
+
import { pageSizeOptions } from './pageSizes.js';
|
|
18
19
|
import './xeplr-table.css';
|
|
19
20
|
|
|
20
21
|
var filterComponentMap = {
|
|
@@ -31,6 +32,14 @@ var filterComponentMap = {
|
|
|
31
32
|
*/
|
|
32
33
|
var CHILD_DISPLAY = { POPUP: 'popup', INNER: 'inner' };
|
|
33
34
|
|
|
35
|
+
// Was this click a finger? A click is a PointerEvent that says so; where the
|
|
36
|
+
// browser does not say, a screen with no hover is a touch screen.
|
|
37
|
+
function isTouch(e) {
|
|
38
|
+
var type = e.nativeEvent && e.nativeEvent.pointerType;
|
|
39
|
+
if (type) return type === 'touch' || type === 'pen';
|
|
40
|
+
return typeof window !== 'undefined' && !!window.matchMedia && window.matchMedia('(hover: none)').matches;
|
|
41
|
+
}
|
|
42
|
+
|
|
34
43
|
/**
|
|
35
44
|
* Main table component.
|
|
36
45
|
*
|
|
@@ -355,6 +364,14 @@ export default function XeplrTable(props) {
|
|
|
355
364
|
}
|
|
356
365
|
}
|
|
357
366
|
|
|
367
|
+
// A finger has no double-click: on a touch screen one tap opens the row.
|
|
368
|
+
// Not when the tap was on something of the row's own (a button, a tick box).
|
|
369
|
+
function handleRowTap(e, original) {
|
|
370
|
+
if (!usePopup || !isTouch(e)) return;
|
|
371
|
+
if (e.target.closest && e.target.closest('button, input, select, textarea, a, label')) return;
|
|
372
|
+
actions.openDetail(original);
|
|
373
|
+
}
|
|
374
|
+
|
|
358
375
|
// Resolved fresh each render: if the row has paged, sorted or filtered away,
|
|
359
376
|
// there is nothing to find and the box simply isn't rendered.
|
|
360
377
|
var zoomCell = null;
|
|
@@ -594,6 +611,7 @@ export default function XeplrTable(props) {
|
|
|
594
611
|
|
|
595
612
|
rowElements.push(
|
|
596
613
|
<tr key={row.id} className={rowClass}
|
|
614
|
+
onClick={function(e) { handleRowTap(e, original); }}
|
|
597
615
|
onDoubleClick={function() { handleRowDoubleClick(original); }}>
|
|
598
616
|
{showExpandCol && (
|
|
599
617
|
<td className="xeplr-table-td xeplr-table-td-expand">
|
|
@@ -707,7 +725,7 @@ export default function XeplrTable(props) {
|
|
|
707
725
|
<button type="button" onClick={function() { table.setPageIndex(table.getPageCount() - 1); }} disabled={!table.getCanNextPage()}>»»</button>
|
|
708
726
|
<select className="xeplr-table-page-size" value={table.getState().pagination.pageSize}
|
|
709
727
|
onChange={function(e) { table.setPageSize(Number(e.target.value)); }}>
|
|
710
|
-
{
|
|
728
|
+
{pageSizeOptions(table.getState().pagination.pageSize).map(function(size) { return <option key={size} value={size}>{size} rows</option>; })}
|
|
711
729
|
</select>
|
|
712
730
|
<span className="xeplr-table-row-count">({table.getFilteredRowModel().rows.length} total)</span>
|
|
713
731
|
</div>
|
package/src/pageSizes.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// The rows-per-page choices ALWAYS include the size in use. The list was a
|
|
2
|
+
// fixed 100/200/500/1000, so a table given pageSize 10 showed 10 rows while
|
|
3
|
+
// its dropdown claimed "100 rows" — the one control on the bar that was lying.
|
|
4
|
+
var PAGE_SIZES = [100, 200, 500, 1000];
|
|
5
|
+
|
|
6
|
+
export function pageSizeOptions(current) {
|
|
7
|
+
if (!current || PAGE_SIZES.indexOf(current) !== -1) return PAGE_SIZES;
|
|
8
|
+
return [current].concat(PAGE_SIZES).sort(function(a, b) { return a - b; });
|
|
9
|
+
}
|
package/src/xeplr-table.css
CHANGED
|
@@ -24,6 +24,9 @@
|
|
|
24
24
|
/* Centred so arbitrary host content in the leading slot sits on the same
|
|
25
25
|
line as the buttons instead of stretching to the row's full height. */
|
|
26
26
|
align-items: center;
|
|
27
|
+
/* Wraps rather than clipping: the container is overflow:hidden, so on a
|
|
28
|
+
narrow screen a toolbar that cannot wrap loses its last buttons. */
|
|
29
|
+
flex-wrap: wrap;
|
|
27
30
|
gap: 8px;
|
|
28
31
|
padding: 8px 12px;
|
|
29
32
|
border-bottom: 1px solid var(--xeplr-border-primary, #2a2a4a);
|
|
@@ -448,6 +451,7 @@
|
|
|
448
451
|
.xeplr-table-pagination {
|
|
449
452
|
display: flex;
|
|
450
453
|
align-items: center;
|
|
454
|
+
flex-wrap: wrap;
|
|
451
455
|
gap: 8px;
|
|
452
456
|
padding: 8px 12px;
|
|
453
457
|
border-top: 1px solid var(--xeplr-border-primary, #2a2a4a);
|
|
@@ -476,6 +480,7 @@
|
|
|
476
480
|
|
|
477
481
|
.xeplr-table-page-info {
|
|
478
482
|
color: var(--xeplr-text-secondary, #a0a0c0);
|
|
483
|
+
white-space: nowrap;
|
|
479
484
|
}
|
|
480
485
|
|
|
481
486
|
.xeplr-table-page-size {
|
|
@@ -490,6 +495,7 @@
|
|
|
490
495
|
.xeplr-table-row-count {
|
|
491
496
|
color: var(--xeplr-text-muted, #666);
|
|
492
497
|
margin-left: auto;
|
|
498
|
+
white-space: nowrap;
|
|
493
499
|
}
|
|
494
500
|
|
|
495
501
|
/* ── Scrollbar ── */
|
|
@@ -687,7 +693,7 @@
|
|
|
687
693
|
|
|
688
694
|
.xeplr-table-actions-cell {
|
|
689
695
|
display: flex;
|
|
690
|
-
gap:
|
|
696
|
+
gap: 6px;
|
|
691
697
|
align-items: center;
|
|
692
698
|
}
|
|
693
699
|
|
|
@@ -720,22 +726,36 @@
|
|
|
720
726
|
cursor: not-allowed;
|
|
721
727
|
}
|
|
722
728
|
|
|
723
|
-
/* ── Custom row actions (props.rowActions) — text-label buttons, e.g. Rollback/Delete ──
|
|
729
|
+
/* ── Custom row actions (props.rowActions) — text-label buttons, e.g. Rollback/Delete ──
|
|
730
|
+
ONE LOOK FOR ALL OF THEM: the same outlined button, differing only in
|
|
731
|
+
colour. (A plain label was grey borderless text beside a red outlined
|
|
732
|
+
Delete, so Edit read as disabled.) A danger action is red; every other one
|
|
733
|
+
takes the accent on hover. All of them visibly give under a press. */
|
|
724
734
|
.xeplr-table-action-label {
|
|
725
735
|
width: auto;
|
|
726
736
|
height: auto;
|
|
727
|
-
padding: 4px
|
|
737
|
+
padding: 4px 12px;
|
|
728
738
|
font-size: 12px;
|
|
729
739
|
font-weight: 600;
|
|
730
740
|
white-space: nowrap;
|
|
741
|
+
border-color: var(--xeplr-input-border, #3a3a5a);
|
|
742
|
+
color: var(--xeplr-text-primary, #e0e0e0);
|
|
743
|
+
transition: background 0.12s, color 0.12s, border-color 0.12s, transform 0.08s;
|
|
731
744
|
}
|
|
745
|
+
.xeplr-table-action-label:hover:not(:disabled) {
|
|
746
|
+
border-color: var(--xeplr-accent, #7c7cff);
|
|
747
|
+
color: var(--xeplr-accent, #7c7cff);
|
|
748
|
+
background: var(--xeplr-bg-hover, #2a2a4a);
|
|
749
|
+
}
|
|
750
|
+
.xeplr-table-action-btn:active:not(:disabled) { transform: scale(0.95); }
|
|
732
751
|
|
|
733
752
|
.xeplr-table-action-danger {
|
|
734
|
-
border-color: var(--xeplr-danger, #ff6b6b);
|
|
753
|
+
border-color: color-mix(in srgb, var(--xeplr-danger, #ff6b6b) 55%, transparent);
|
|
735
754
|
color: var(--xeplr-danger, #ff6b6b);
|
|
736
755
|
}
|
|
737
756
|
|
|
738
|
-
.xeplr-table-action-danger:hover:not(:disabled) {
|
|
757
|
+
.xeplr-table-action-label.xeplr-table-action-danger:hover:not(:disabled) {
|
|
758
|
+
border-color: var(--xeplr-danger, #ff6b6b);
|
|
739
759
|
background: var(--xeplr-danger-bg, #3a1a1a);
|
|
740
760
|
color: var(--xeplr-danger, #ff8a8a);
|
|
741
761
|
}
|
|
@@ -1068,3 +1088,39 @@
|
|
|
1068
1088
|
border-left: none;
|
|
1069
1089
|
border-right: none;
|
|
1070
1090
|
}
|
|
1091
|
+
|
|
1092
|
+
/* ── Touch ──
|
|
1093
|
+
A finger is not a mouse pointer: every control a row or the toolbar offers
|
|
1094
|
+
gets a target a thumb can hit (about 40px), on any touch screen and on
|
|
1095
|
+
any phone-width one. */
|
|
1096
|
+
@media (pointer: coarse), (max-width: 640px) {
|
|
1097
|
+
.xeplr-table-action-btn { width: 40px; height: 40px; }
|
|
1098
|
+
.xeplr-table-action-label { width: auto; height: auto; min-height: 40px; padding: 8px 14px; font-size: 13px; }
|
|
1099
|
+
.xeplr-table-filter-trigger, .xeplr-table-expand-btn { width: 36px; height: 36px; }
|
|
1100
|
+
.xeplr-table-checkbox { width: 22px; height: 22px; }
|
|
1101
|
+
.xeplr-table-toolbar-btn { min-height: 36px; padding: 6px 14px; font-size: 13px; }
|
|
1102
|
+
.xeplr-table-pagination button { min-width: 40px; min-height: 40px; }
|
|
1103
|
+
.xeplr-table-page-size { min-height: 40px; font-size: 14px; }
|
|
1104
|
+
.xeplr-table-modal-close { min-width: 40px; min-height: 40px; }
|
|
1105
|
+
}
|
|
1106
|
+
|
|
1107
|
+
/* ── Phones ──
|
|
1108
|
+
The table keeps scrolling sideways — ten columns do not fit a phone and
|
|
1109
|
+
turning rows into cards loses the grid — but the row's own buttons stay
|
|
1110
|
+
pinned at the right edge, so Edit is never a scroll away. Popups fill the
|
|
1111
|
+
screen and their fields stack. */
|
|
1112
|
+
@media (max-width: 640px) {
|
|
1113
|
+
.xeplr-table-th-actions,
|
|
1114
|
+
.xeplr-table-td-actions {
|
|
1115
|
+
position: sticky;
|
|
1116
|
+
right: 0;
|
|
1117
|
+
z-index: 1;
|
|
1118
|
+
background: var(--xeplr-bg-tertiary, #1a1a2e);
|
|
1119
|
+
box-shadow: -6px 0 8px -6px rgba(0, 0, 0, 0.25);
|
|
1120
|
+
}
|
|
1121
|
+
.xeplr-table-th-actions { background: var(--xeplr-bg-secondary, #16162a); }
|
|
1122
|
+
.xeplr-table-modal,
|
|
1123
|
+
.xeplr-table-detail { width: 100%; max-width: none; height: 100%; max-height: none; border-radius: 0; }
|
|
1124
|
+
.xeplr-table-detail-fields { grid-template-columns: 1fr; }
|
|
1125
|
+
.xeplr-table-detail-body { padding: 16px; }
|
|
1126
|
+
}
|