@xeplr/ui-table 1.1.0 → 1.1.2

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 CHANGED
@@ -48,10 +48,11 @@ 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
+ | `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. |
55
56
  | `minDetectionRows` | `10` | non-empty samples a column needs before its detected type is final |
56
57
  | `sorting`, `onSortingChange` | — | controlled sort (`[{ id, desc }]`) — see Sorting |
57
58
  | `onHeaderClick` | — | `(columnKey, isGroupHeader)` — **replaces** sort-on-click |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xeplr/ui-table",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "description": "Controlled TanStack Table wrapper with auto-detected column types and smart filters",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -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 = {
@@ -49,6 +50,10 @@ var CHILD_DISPLAY = { POPUP: 'popup', INNER: 'inner' };
49
50
  * @param {Function} [props.onSortingChange] - Called with the next sort state.
50
51
  * @param {boolean} [props.enableFiltering] - Default: true
51
52
  * @param {boolean} [props.enablePagination] - Default: true
53
+ * @param {boolean} [props.showToolbar] - Default: true. False
54
+ * leaves the toolbar row out entirely — for a small table on a dashboard
55
+ * that offers no filtering or sorting, where an empty bar with a Clear Sort
56
+ * button is clutter. Editing (Add/Delete/Commit) keeps it whatever this says.
52
57
  * @param {Function} [props.rowClassName] - (row) => string|falsy. Extra
53
58
  * CSS class per row, so a host can mark rows that mean something to IT.
54
59
  * @param {Function} [props.toolbarActions] - (ctx) => ReactNode.
@@ -363,6 +368,7 @@ export default function XeplrTable(props) {
363
368
 
364
369
  return (
365
370
  <div className={'xeplr-table-container' + (props.className ? ' ' + props.className : '')}>
371
+ {(props.showToolbar !== false || actions.hasSave || actions.hasDelete || actions.hasPending) && (
366
372
  <div className="xeplr-table-toolbar">
367
373
  {actions.hasSave && (
368
374
  <button type="button" className="xeplr-table-toolbar-btn xeplr-table-toolbar-btn-add" onClick={actions.openAdd}>
@@ -422,6 +428,7 @@ export default function XeplrTable(props) {
422
428
  </>
423
429
  )}
424
430
  </div>
431
+ )}
425
432
 
426
433
  <div className="xeplr-table-scroll" ref={widths.scrollRef}>
427
434
  {/* When sized to content the table stops at the width it needs; the
@@ -701,7 +708,7 @@ export default function XeplrTable(props) {
701
708
  <button type="button" onClick={function() { table.setPageIndex(table.getPageCount() - 1); }} disabled={!table.getCanNextPage()}>»»</button>
702
709
  <select className="xeplr-table-page-size" value={table.getState().pagination.pageSize}
703
710
  onChange={function(e) { table.setPageSize(Number(e.target.value)); }}>
704
- {[100, 200, 500, 1000].map(function(size) { return <option key={size} value={size}>{size} rows</option>; })}
711
+ {pageSizeOptions(table.getState().pagination.pageSize).map(function(size) { return <option key={size} value={size}>{size} rows</option>; })}
705
712
  </select>
706
713
  <span className="xeplr-table-row-count">({table.getFilteredRowModel().rows.length} total)</span>
707
714
  </div>
@@ -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
+ }
@@ -687,7 +687,7 @@
687
687
 
688
688
  .xeplr-table-actions-cell {
689
689
  display: flex;
690
- gap: 4px;
690
+ gap: 6px;
691
691
  align-items: center;
692
692
  }
693
693
 
@@ -720,22 +720,36 @@
720
720
  cursor: not-allowed;
721
721
  }
722
722
 
723
- /* ── Custom row actions (props.rowActions) — text-label buttons, e.g. Rollback/Delete ── */
723
+ /* ── Custom row actions (props.rowActions) — text-label buttons, e.g. Rollback/Delete ──
724
+ ONE LOOK FOR ALL OF THEM: the same outlined button, differing only in
725
+ colour. (A plain label was grey borderless text beside a red outlined
726
+ Delete, so Edit read as disabled.) A danger action is red; every other one
727
+ takes the accent on hover. All of them visibly give under a press. */
724
728
  .xeplr-table-action-label {
725
729
  width: auto;
726
730
  height: auto;
727
- padding: 4px 10px;
731
+ padding: 4px 12px;
728
732
  font-size: 12px;
729
733
  font-weight: 600;
730
734
  white-space: nowrap;
735
+ border-color: var(--xeplr-input-border, #3a3a5a);
736
+ color: var(--xeplr-text-primary, #e0e0e0);
737
+ transition: background 0.12s, color 0.12s, border-color 0.12s, transform 0.08s;
731
738
  }
739
+ .xeplr-table-action-label:hover:not(:disabled) {
740
+ border-color: var(--xeplr-accent, #7c7cff);
741
+ color: var(--xeplr-accent, #7c7cff);
742
+ background: var(--xeplr-bg-hover, #2a2a4a);
743
+ }
744
+ .xeplr-table-action-btn:active:not(:disabled) { transform: scale(0.95); }
732
745
 
733
746
  .xeplr-table-action-danger {
734
- border-color: var(--xeplr-danger, #ff6b6b);
747
+ border-color: color-mix(in srgb, var(--xeplr-danger, #ff6b6b) 55%, transparent);
735
748
  color: var(--xeplr-danger, #ff6b6b);
736
749
  }
737
750
 
738
- .xeplr-table-action-danger:hover:not(:disabled) {
751
+ .xeplr-table-action-label.xeplr-table-action-danger:hover:not(:disabled) {
752
+ border-color: var(--xeplr-danger, #ff6b6b);
739
753
  background: var(--xeplr-danger-bg, #3a1a1a);
740
754
  color: var(--xeplr-danger, #ff8a8a);
741
755
  }