@xeplr/ui-table 1.1.2 → 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 +11 -0
- package/package.json +1 -1
- package/src/XeplrTable.jsx +17 -0
- package/src/xeplr-table.css +42 -0
package/README.md
CHANGED
|
@@ -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
|
@@ -32,6 +32,14 @@ var filterComponentMap = {
|
|
|
32
32
|
*/
|
|
33
33
|
var CHILD_DISPLAY = { POPUP: 'popup', INNER: 'inner' };
|
|
34
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
|
+
|
|
35
43
|
/**
|
|
36
44
|
* Main table component.
|
|
37
45
|
*
|
|
@@ -356,6 +364,14 @@ export default function XeplrTable(props) {
|
|
|
356
364
|
}
|
|
357
365
|
}
|
|
358
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
|
+
|
|
359
375
|
// Resolved fresh each render: if the row has paged, sorted or filtered away,
|
|
360
376
|
// there is nothing to find and the box simply isn't rendered.
|
|
361
377
|
var zoomCell = null;
|
|
@@ -595,6 +611,7 @@ export default function XeplrTable(props) {
|
|
|
595
611
|
|
|
596
612
|
rowElements.push(
|
|
597
613
|
<tr key={row.id} className={rowClass}
|
|
614
|
+
onClick={function(e) { handleRowTap(e, original); }}
|
|
598
615
|
onDoubleClick={function() { handleRowDoubleClick(original); }}>
|
|
599
616
|
{showExpandCol && (
|
|
600
617
|
<td className="xeplr-table-td xeplr-table-td-expand">
|
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 ── */
|
|
@@ -1082,3 +1088,39 @@
|
|
|
1082
1088
|
border-left: none;
|
|
1083
1089
|
border-right: none;
|
|
1084
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
|
+
}
|