@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/CHANGELOG.md +557 -538
- package/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +18 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +19 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React2, { memo, useState, useMemo, useCallback, useEffect, useRef, useLayoutEffect } from 'react';
|
|
1
|
+
import React2, { memo, createContext, useState, useMemo, useCallback, useEffect, useRef, useContext, useLayoutEffect } from 'react';
|
|
2
2
|
import { StyleSheet, View, Text, Platform, useWindowDimensions, Pressable, Switch, TextInput } from 'react-native';
|
|
3
3
|
import { useUi } from '@dloizides/ui-feedback';
|
|
4
4
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
@@ -333,7 +333,7 @@ function DesktopCell({ column, row, textColor, testID, styleOverrides, inGrid })
|
|
|
333
333
|
View,
|
|
334
334
|
{
|
|
335
335
|
style: [
|
|
336
|
-
{ flex: column.weight ?? 1, alignItems: column.numeric ? "flex-end" : "flex-start" },
|
|
336
|
+
{ flex: column.weight ?? 1, minWidth: column.minWidth, alignItems: column.numeric ? "flex-end" : "flex-start" },
|
|
337
337
|
styleOverrides?.cellWrap
|
|
338
338
|
],
|
|
339
339
|
testID,
|
|
@@ -376,6 +376,9 @@ function RowCells({
|
|
|
376
376
|
col.key
|
|
377
377
|
)) });
|
|
378
378
|
}
|
|
379
|
+
var RowPressContext = createContext(void 0);
|
|
380
|
+
var RowPressProvider = RowPressContext.Provider;
|
|
381
|
+
var useRowPress = () => useContext(RowPressContext);
|
|
379
382
|
var CHECK_GLYPH = "\u2713";
|
|
380
383
|
var MIXED_GLYPH = "\u2013";
|
|
381
384
|
var TRANSPARENT = "transparent";
|
|
@@ -495,6 +498,7 @@ function DataTableRow({
|
|
|
495
498
|
const isExpandable = renderRowDetail !== void 0;
|
|
496
499
|
const { selectable } = selection;
|
|
497
500
|
const isSelected = selectable && selection.isSelected(rowKey);
|
|
501
|
+
const pressRow = onRowPress === void 0 ? void 0 : () => onRowPress(row);
|
|
498
502
|
const a11y = {
|
|
499
503
|
accessibilityLabel: getRowAccessibilityLabel?.(row) ?? t(TABLE_I18N.rowLabel),
|
|
500
504
|
accessibilityHint: t(TABLE_I18N.rowHint),
|
|
@@ -534,8 +538,8 @@ function DataTableRow({
|
|
|
534
538
|
testID: rowID,
|
|
535
539
|
onHoverIn,
|
|
536
540
|
onHoverOut,
|
|
537
|
-
onPress:
|
|
538
|
-
children: /* @__PURE__ */ jsx(
|
|
541
|
+
onPress: pressRow,
|
|
542
|
+
children: /* @__PURE__ */ jsx(RowPressProvider, { value: pressRow, children: /* @__PURE__ */ jsx(
|
|
539
543
|
RowCells,
|
|
540
544
|
{
|
|
541
545
|
columns,
|
|
@@ -547,7 +551,7 @@ function DataTableRow({
|
|
|
547
551
|
styleOverrides: o,
|
|
548
552
|
textColor: colors.text
|
|
549
553
|
}
|
|
550
|
-
)
|
|
554
|
+
) })
|
|
551
555
|
}
|
|
552
556
|
);
|
|
553
557
|
if (!isExpandable || !expanded) return rowNode;
|
|
@@ -631,7 +635,7 @@ function TableHeader({ columns, stickyHeader, selection, inGrid, styleOverrides:
|
|
|
631
635
|
columns.map((col) => /* @__PURE__ */ jsx(
|
|
632
636
|
Text,
|
|
633
637
|
{
|
|
634
|
-
style: [tableStyles.headCell, { color: colors.textSecondary, flex: col.weight ?? 1, textAlign: col.numeric ? "right" : "left" }, o?.headCell],
|
|
638
|
+
style: [tableStyles.headCell, { color: colors.textSecondary, flex: col.weight ?? 1, minWidth: col.minWidth, textAlign: col.numeric ? "right" : "left" }, o?.headCell],
|
|
635
639
|
...inGrid ? { role: "columnheader" } : null,
|
|
636
640
|
children: col.header
|
|
637
641
|
},
|
|
@@ -1849,6 +1853,8 @@ var STATUS_LEDGER_TEST_ID = "ui-status-ledger";
|
|
|
1849
1853
|
var STATUS_COLUMN_KEY = "status";
|
|
1850
1854
|
var ACTIONS_COLUMN_KEY = "actions";
|
|
1851
1855
|
var ALL_VALUE = "";
|
|
1856
|
+
var STATUS_MIN_WIDTH = 120;
|
|
1857
|
+
var ACTIONS_MIN_WIDTH = 136;
|
|
1852
1858
|
var TONE_RANK = {
|
|
1853
1859
|
["bad" /* Bad */]: 0,
|
|
1854
1860
|
["warn" /* Warn */]: 1,
|
|
@@ -1971,10 +1977,11 @@ function useLedgerView(props) {
|
|
|
1971
1977
|
const status = {
|
|
1972
1978
|
key: STATUS_COLUMN_KEY,
|
|
1973
1979
|
header: labels.status,
|
|
1980
|
+
minWidth: STATUS_MIN_WIDTH,
|
|
1974
1981
|
sortValue: (row) => toneRank(toneOf(row)),
|
|
1975
1982
|
render: (row) => /* @__PURE__ */ jsx(StatusPill, { color: toneColor(toneOf(row)), label: statusLabel(getStatus(row)), tone: toneOf(row) })
|
|
1976
1983
|
};
|
|
1977
|
-
const actions = renderActions === void 0 ? [] : [{ key: ACTIONS_COLUMN_KEY, header: labels.actions, render: renderActions }];
|
|
1984
|
+
const actions = renderActions === void 0 ? [] : [{ key: ACTIONS_COLUMN_KEY, header: labels.actions, minWidth: ACTIONS_MIN_WIDTH, render: renderActions }];
|
|
1978
1985
|
return [columns[0], status, ...columns.slice(1), ...actions].filter((c) => c !== void 0);
|
|
1979
1986
|
}, [columns, labels, toneOf, toneColor, statusLabel, getStatus, renderActions]);
|
|
1980
1987
|
const fields = useMemo(() => {
|
|
@@ -2128,6 +2135,7 @@ var defaultAbsolute = (ms) => new Date(ms).toLocaleString();
|
|
|
2128
2135
|
function RelativeTime({ value, nowMs, strings, hint, formatAbsolute = defaultAbsolute, testID }) {
|
|
2129
2136
|
const { theme } = useUi();
|
|
2130
2137
|
const [showAbsolute, setShowAbsolute] = useState(false);
|
|
2138
|
+
const pressRow = useRowPress();
|
|
2131
2139
|
const ms = toEpochMs(value);
|
|
2132
2140
|
const relative = formatRelativeTime(value, nowMs, strings);
|
|
2133
2141
|
const absolute = ms === null ? relative : formatAbsolute(ms);
|
|
@@ -2138,7 +2146,10 @@ function RelativeTime({ value, nowMs, strings, hint, formatAbsolute = defaultAbs
|
|
|
2138
2146
|
accessibilityLabel: absolute,
|
|
2139
2147
|
accessibilityRole: "button",
|
|
2140
2148
|
disabled: ms === null,
|
|
2141
|
-
onPress: () =>
|
|
2149
|
+
onPress: () => {
|
|
2150
|
+
setShowAbsolute((current) => !current);
|
|
2151
|
+
pressRow?.();
|
|
2152
|
+
},
|
|
2142
2153
|
style: styles4.target,
|
|
2143
2154
|
testID,
|
|
2144
2155
|
children: /* @__PURE__ */ jsx(Text, { style: { color: theme.colors.text }, children: showAbsolute ? absolute : relative })
|