@dloizides/ui-tables 1.22.0 → 1.24.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.
package/dist/index.d.mts CHANGED
@@ -78,6 +78,8 @@ interface DataTableColumn<T> {
78
78
  numeric?: boolean;
79
79
  /** Flex weight on desktop. Default 1. */
80
80
  weight?: number;
81
+ /** Desktop width floor (px): the column never shrinks below it, so a button or pill in it is not clipped. */
82
+ minWidth?: number;
81
83
  render: (row: T) => React.ReactNode;
82
84
  }
83
85
  interface DataTableProps<T> {
package/dist/index.d.ts CHANGED
@@ -78,6 +78,8 @@ interface DataTableColumn<T> {
78
78
  numeric?: boolean;
79
79
  /** Flex weight on desktop. Default 1. */
80
80
  weight?: number;
81
+ /** Desktop width floor (px): the column never shrinks below it, so a button or pill in it is not clipped. */
82
+ minWidth?: number;
81
83
  render: (row: T) => React.ReactNode;
82
84
  }
83
85
  interface DataTableProps<T> {
package/dist/index.js CHANGED
@@ -338,7 +338,7 @@ function DesktopCell({ column, row, textColor, testID, styleOverrides, inGrid })
338
338
  reactNative.View,
339
339
  {
340
340
  style: [
341
- { flex: column.weight ?? 1, alignItems: column.numeric ? "flex-end" : "flex-start" },
341
+ { flex: column.weight ?? 1, minWidth: column.minWidth, alignItems: column.numeric ? "flex-end" : "flex-start" },
342
342
  styleOverrides?.cellWrap
343
343
  ],
344
344
  testID,
@@ -381,6 +381,9 @@ function RowCells({
381
381
  col.key
382
382
  )) });
383
383
  }
384
+ var RowPressContext = React2.createContext(void 0);
385
+ var RowPressProvider = RowPressContext.Provider;
386
+ var useRowPress = () => React2.useContext(RowPressContext);
384
387
  var CHECK_GLYPH = "\u2713";
385
388
  var MIXED_GLYPH = "\u2013";
386
389
  var TRANSPARENT = "transparent";
@@ -500,6 +503,7 @@ function DataTableRow({
500
503
  const isExpandable = renderRowDetail !== void 0;
501
504
  const { selectable } = selection;
502
505
  const isSelected = selectable && selection.isSelected(rowKey);
506
+ const pressRow = onRowPress === void 0 ? void 0 : () => onRowPress(row);
503
507
  const a11y = {
504
508
  accessibilityLabel: getRowAccessibilityLabel?.(row) ?? t(TABLE_I18N.rowLabel),
505
509
  accessibilityHint: t(TABLE_I18N.rowHint),
@@ -539,8 +543,8 @@ function DataTableRow({
539
543
  testID: rowID,
540
544
  onHoverIn,
541
545
  onHoverOut,
542
- onPress: onRowPress === void 0 ? void 0 : () => onRowPress(row),
543
- children: /* @__PURE__ */ jsxRuntime.jsx(
546
+ onPress: pressRow,
547
+ children: /* @__PURE__ */ jsxRuntime.jsx(RowPressProvider, { value: pressRow, children: /* @__PURE__ */ jsxRuntime.jsx(
544
548
  RowCells,
545
549
  {
546
550
  columns,
@@ -552,7 +556,7 @@ function DataTableRow({
552
556
  styleOverrides: o,
553
557
  textColor: colors.text
554
558
  }
555
- )
559
+ ) })
556
560
  }
557
561
  );
558
562
  if (!isExpandable || !expanded) return rowNode;
@@ -636,7 +640,7 @@ function TableHeader({ columns, stickyHeader, selection, inGrid, styleOverrides:
636
640
  columns.map((col) => /* @__PURE__ */ jsxRuntime.jsx(
637
641
  reactNative.Text,
638
642
  {
639
- style: [tableStyles.headCell, { color: colors.textSecondary, flex: col.weight ?? 1, textAlign: col.numeric ? "right" : "left" }, o?.headCell],
643
+ style: [tableStyles.headCell, { color: colors.textSecondary, flex: col.weight ?? 1, minWidth: col.minWidth, textAlign: col.numeric ? "right" : "left" }, o?.headCell],
640
644
  ...inGrid ? { role: "columnheader" } : null,
641
645
  children: col.header
642
646
  },
@@ -1854,6 +1858,8 @@ var STATUS_LEDGER_TEST_ID = "ui-status-ledger";
1854
1858
  var STATUS_COLUMN_KEY = "status";
1855
1859
  var ACTIONS_COLUMN_KEY = "actions";
1856
1860
  var ALL_VALUE = "";
1861
+ var STATUS_MIN_WIDTH = 120;
1862
+ var ACTIONS_MIN_WIDTH = 136;
1857
1863
  var TONE_RANK = {
1858
1864
  ["bad" /* Bad */]: 0,
1859
1865
  ["warn" /* Warn */]: 1,
@@ -1976,10 +1982,11 @@ function useLedgerView(props) {
1976
1982
  const status = {
1977
1983
  key: STATUS_COLUMN_KEY,
1978
1984
  header: labels.status,
1985
+ minWidth: STATUS_MIN_WIDTH,
1979
1986
  sortValue: (row) => toneRank(toneOf(row)),
1980
1987
  render: (row) => /* @__PURE__ */ jsxRuntime.jsx(StatusPill, { color: toneColor(toneOf(row)), label: statusLabel(getStatus(row)), tone: toneOf(row) })
1981
1988
  };
1982
- const actions = renderActions === void 0 ? [] : [{ key: ACTIONS_COLUMN_KEY, header: labels.actions, render: renderActions }];
1989
+ const actions = renderActions === void 0 ? [] : [{ key: ACTIONS_COLUMN_KEY, header: labels.actions, minWidth: ACTIONS_MIN_WIDTH, render: renderActions }];
1983
1990
  return [columns[0], status, ...columns.slice(1), ...actions].filter((c) => c !== void 0);
1984
1991
  }, [columns, labels, toneOf, toneColor, statusLabel, getStatus, renderActions]);
1985
1992
  const fields = React2.useMemo(() => {
@@ -2133,6 +2140,7 @@ var defaultAbsolute = (ms) => new Date(ms).toLocaleString();
2133
2140
  function RelativeTime({ value, nowMs, strings, hint, formatAbsolute = defaultAbsolute, testID }) {
2134
2141
  const { theme } = uiFeedback.useUi();
2135
2142
  const [showAbsolute, setShowAbsolute] = React2.useState(false);
2143
+ const pressRow = useRowPress();
2136
2144
  const ms = toEpochMs(value);
2137
2145
  const relative = formatRelativeTime(value, nowMs, strings);
2138
2146
  const absolute = ms === null ? relative : formatAbsolute(ms);
@@ -2143,7 +2151,10 @@ function RelativeTime({ value, nowMs, strings, hint, formatAbsolute = defaultAbs
2143
2151
  accessibilityLabel: absolute,
2144
2152
  accessibilityRole: "button",
2145
2153
  disabled: ms === null,
2146
- onPress: () => setShowAbsolute((current) => !current),
2154
+ onPress: () => {
2155
+ setShowAbsolute((current) => !current);
2156
+ pressRow?.();
2157
+ },
2147
2158
  style: styles4.target,
2148
2159
  testID,
2149
2160
  children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: { color: theme.colors.text }, children: showAbsolute ? absolute : relative })