@dloizides/ui-tables 1.21.1 → 1.23.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 +547 -528
- package/dist/index.d.mts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +23 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +24 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -102,6 +102,8 @@ interface DataTableProps<T> {
|
|
|
102
102
|
* Omit for a plain table (nothing about the row rendering changes).
|
|
103
103
|
*/
|
|
104
104
|
renderRowDetail?: (row: T) => React.ReactNode;
|
|
105
|
+
/** Accessible name of a row's detail panel; defaults to the generic `uiTables.rowDetail`. */
|
|
106
|
+
getRowDetailAccessibilityLabel?: (row: T) => string;
|
|
105
107
|
/**
|
|
106
108
|
* Keys (as produced by `keyExtractor`) of the rows currently expanded. Expansion
|
|
107
109
|
* is CONTROLLED by the caller: own the state, toggle it from `onRowPress`. The
|
|
@@ -839,6 +841,10 @@ interface StatusLedgerProps<T> {
|
|
|
839
841
|
getRowAccessibilityLabel?: (row: T) => string;
|
|
840
842
|
onRowPress?: (row: T) => void;
|
|
841
843
|
renderActions?: (row: T) => React.ReactNode;
|
|
844
|
+
/** Renders a detail region directly under the expanded row (table and card layouts); labelled by `getRowAccessibilityLabel`. */
|
|
845
|
+
renderRowDetail?: (row: T) => React.ReactNode;
|
|
846
|
+
/** Key of the expanded row (CONTROLLED: toggle it from `onRowPress`); `null`/omitted = none. */
|
|
847
|
+
expandedRowKey?: string | null;
|
|
842
848
|
toneColors?: ToneColors;
|
|
843
849
|
layout?: LedgerLayout;
|
|
844
850
|
breakpoint?: number;
|
package/dist/index.d.ts
CHANGED
|
@@ -102,6 +102,8 @@ interface DataTableProps<T> {
|
|
|
102
102
|
* Omit for a plain table (nothing about the row rendering changes).
|
|
103
103
|
*/
|
|
104
104
|
renderRowDetail?: (row: T) => React.ReactNode;
|
|
105
|
+
/** Accessible name of a row's detail panel; defaults to the generic `uiTables.rowDetail`. */
|
|
106
|
+
getRowDetailAccessibilityLabel?: (row: T) => string;
|
|
105
107
|
/**
|
|
106
108
|
* Keys (as produced by `keyExtractor`) of the rows currently expanded. Expansion
|
|
107
109
|
* is CONTROLLED by the caller: own the state, toggle it from `onRowPress`. The
|
|
@@ -839,6 +841,10 @@ interface StatusLedgerProps<T> {
|
|
|
839
841
|
getRowAccessibilityLabel?: (row: T) => string;
|
|
840
842
|
onRowPress?: (row: T) => void;
|
|
841
843
|
renderActions?: (row: T) => React.ReactNode;
|
|
844
|
+
/** Renders a detail region directly under the expanded row (table and card layouts); labelled by `getRowAccessibilityLabel`. */
|
|
845
|
+
renderRowDetail?: (row: T) => React.ReactNode;
|
|
846
|
+
/** Key of the expanded row (CONTROLLED: toggle it from `onRowPress`); `null`/omitted = none. */
|
|
847
|
+
expandedRowKey?: string | null;
|
|
842
848
|
toneColors?: ToneColors;
|
|
843
849
|
layout?: LedgerLayout;
|
|
844
850
|
breakpoint?: number;
|
package/dist/index.js
CHANGED
|
@@ -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";
|
|
@@ -488,6 +491,7 @@ function DataTableRow({
|
|
|
488
491
|
onRowPress,
|
|
489
492
|
getRowAccessibilityLabel,
|
|
490
493
|
renderRowDetail,
|
|
494
|
+
getRowDetailAccessibilityLabel,
|
|
491
495
|
expanded,
|
|
492
496
|
onHoverIn,
|
|
493
497
|
onHoverOut,
|
|
@@ -499,6 +503,7 @@ function DataTableRow({
|
|
|
499
503
|
const isExpandable = renderRowDetail !== void 0;
|
|
500
504
|
const { selectable } = selection;
|
|
501
505
|
const isSelected = selectable && selection.isSelected(rowKey);
|
|
506
|
+
const pressRow = onRowPress === void 0 ? void 0 : () => onRowPress(row);
|
|
502
507
|
const a11y = {
|
|
503
508
|
accessibilityLabel: getRowAccessibilityLabel?.(row) ?? t(TABLE_I18N.rowLabel),
|
|
504
509
|
accessibilityHint: t(TABLE_I18N.rowHint),
|
|
@@ -538,8 +543,8 @@ function DataTableRow({
|
|
|
538
543
|
testID: rowID,
|
|
539
544
|
onHoverIn,
|
|
540
545
|
onHoverOut,
|
|
541
|
-
onPress:
|
|
542
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
546
|
+
onPress: pressRow,
|
|
547
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(RowPressProvider, { value: pressRow, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
543
548
|
RowCells,
|
|
544
549
|
{
|
|
545
550
|
columns,
|
|
@@ -551,7 +556,7 @@ function DataTableRow({
|
|
|
551
556
|
styleOverrides: o,
|
|
552
557
|
textColor: colors.text
|
|
553
558
|
}
|
|
554
|
-
)
|
|
559
|
+
) })
|
|
555
560
|
}
|
|
556
561
|
);
|
|
557
562
|
if (!isExpandable || !expanded) return rowNode;
|
|
@@ -560,7 +565,7 @@ function DataTableRow({
|
|
|
560
565
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
561
566
|
reactNative.View,
|
|
562
567
|
{
|
|
563
|
-
accessibilityLabel: t(TABLE_I18N.rowDetail),
|
|
568
|
+
accessibilityLabel: getRowDetailAccessibilityLabel?.(row) ?? t(TABLE_I18N.rowDetail),
|
|
564
569
|
accessibilityRole: "summary",
|
|
565
570
|
style: [tableStyles.rowDetail, { borderTopColor: colors.border, backgroundColor: colors.background }, o?.rowDetail],
|
|
566
571
|
testID: rowDetailTestID(tableTestID, rowKey),
|
|
@@ -858,6 +863,7 @@ function DataTable(props) {
|
|
|
858
863
|
loadingLabel,
|
|
859
864
|
emptyLabel,
|
|
860
865
|
renderRowDetail,
|
|
866
|
+
getRowDetailAccessibilityLabel,
|
|
861
867
|
expandedRowKeys,
|
|
862
868
|
styleOverrides: o,
|
|
863
869
|
selectedRowKeys,
|
|
@@ -922,6 +928,7 @@ function DataTable(props) {
|
|
|
922
928
|
columns,
|
|
923
929
|
expanded: expandedRowKeys?.includes(key) ?? false,
|
|
924
930
|
getRowAccessibilityLabel,
|
|
931
|
+
getRowDetailAccessibilityLabel,
|
|
925
932
|
keyboardNavigation,
|
|
926
933
|
renderRowDetail,
|
|
927
934
|
roving,
|
|
@@ -2015,6 +2022,7 @@ var LedgerLayout = /* @__PURE__ */ ((LedgerLayout2) => {
|
|
|
2015
2022
|
var GAP = 12;
|
|
2016
2023
|
var HEADING_FONT = 15;
|
|
2017
2024
|
var HEADING_WEIGHT = "700";
|
|
2025
|
+
var expandedKeys = (key) => key === null || key === void 0 ? void 0 : [key];
|
|
2018
2026
|
var styles3 = reactNative.StyleSheet.create({
|
|
2019
2027
|
root: { gap: GAP },
|
|
2020
2028
|
heading: { fontSize: HEADING_FONT, fontWeight: HEADING_WEIGHT },
|
|
@@ -2028,9 +2036,12 @@ function LedgerSection({ title, rows, columns, emptyLabel, testID, ledger }) {
|
|
|
2028
2036
|
DataTable,
|
|
2029
2037
|
{
|
|
2030
2038
|
columns,
|
|
2039
|
+
expandedRowKeys: expandedKeys(ledger.expandedRowKey),
|
|
2031
2040
|
getRowAccessibilityLabel: ledger.getRowAccessibilityLabel,
|
|
2041
|
+
getRowDetailAccessibilityLabel: ledger.getRowAccessibilityLabel,
|
|
2032
2042
|
keyExtractor: ledger.keyExtractor,
|
|
2033
2043
|
onRowPress: ledger.onRowPress,
|
|
2044
|
+
renderRowDetail: ledger.renderRowDetail,
|
|
2034
2045
|
rows,
|
|
2035
2046
|
stackBreakpoint: ledger.breakpoint ?? CARD_STACK_BREAKPOINT,
|
|
2036
2047
|
testID: `${testID}-table`
|
|
@@ -2078,10 +2089,13 @@ function StatusLedger(props) {
|
|
|
2078
2089
|
{
|
|
2079
2090
|
columns: view.tableColumns,
|
|
2080
2091
|
emptyLabel: labels.empty,
|
|
2092
|
+
expandedRowKeys: expandedKeys(props.expandedRowKey),
|
|
2081
2093
|
getRowAccessibilityLabel: props.getRowAccessibilityLabel,
|
|
2094
|
+
getRowDetailAccessibilityLabel: props.getRowAccessibilityLabel,
|
|
2082
2095
|
keyExtractor: props.keyExtractor,
|
|
2083
2096
|
loading,
|
|
2084
2097
|
onRowPress: props.onRowPress,
|
|
2098
|
+
renderRowDetail: props.renderRowDetail,
|
|
2085
2099
|
rows: view.visible,
|
|
2086
2100
|
stackBreakpoint: feed ? breakpoint : 0,
|
|
2087
2101
|
testID: `${testID}-table`
|
|
@@ -2123,6 +2137,7 @@ var defaultAbsolute = (ms) => new Date(ms).toLocaleString();
|
|
|
2123
2137
|
function RelativeTime({ value, nowMs, strings, hint, formatAbsolute = defaultAbsolute, testID }) {
|
|
2124
2138
|
const { theme } = uiFeedback.useUi();
|
|
2125
2139
|
const [showAbsolute, setShowAbsolute] = React2.useState(false);
|
|
2140
|
+
const pressRow = useRowPress();
|
|
2126
2141
|
const ms = toEpochMs(value);
|
|
2127
2142
|
const relative = formatRelativeTime(value, nowMs, strings);
|
|
2128
2143
|
const absolute = ms === null ? relative : formatAbsolute(ms);
|
|
@@ -2133,7 +2148,10 @@ function RelativeTime({ value, nowMs, strings, hint, formatAbsolute = defaultAbs
|
|
|
2133
2148
|
accessibilityLabel: absolute,
|
|
2134
2149
|
accessibilityRole: "button",
|
|
2135
2150
|
disabled: ms === null,
|
|
2136
|
-
onPress: () =>
|
|
2151
|
+
onPress: () => {
|
|
2152
|
+
setShowAbsolute((current) => !current);
|
|
2153
|
+
pressRow?.();
|
|
2154
|
+
},
|
|
2137
2155
|
style: styles4.target,
|
|
2138
2156
|
testID,
|
|
2139
2157
|
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: { color: theme.colors.text }, children: showAbsolute ? absolute : relative })
|