@dloizides/ui-tables 1.22.0 → 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/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';
@@ -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: onRowPress === void 0 ? void 0 : () => onRowPress(row),
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;
@@ -2128,6 +2132,7 @@ var defaultAbsolute = (ms) => new Date(ms).toLocaleString();
2128
2132
  function RelativeTime({ value, nowMs, strings, hint, formatAbsolute = defaultAbsolute, testID }) {
2129
2133
  const { theme } = useUi();
2130
2134
  const [showAbsolute, setShowAbsolute] = useState(false);
2135
+ const pressRow = useRowPress();
2131
2136
  const ms = toEpochMs(value);
2132
2137
  const relative = formatRelativeTime(value, nowMs, strings);
2133
2138
  const absolute = ms === null ? relative : formatAbsolute(ms);
@@ -2138,7 +2143,10 @@ function RelativeTime({ value, nowMs, strings, hint, formatAbsolute = defaultAbs
2138
2143
  accessibilityLabel: absolute,
2139
2144
  accessibilityRole: "button",
2140
2145
  disabled: ms === null,
2141
- onPress: () => setShowAbsolute((current) => !current),
2146
+ onPress: () => {
2147
+ setShowAbsolute((current) => !current);
2148
+ pressRow?.();
2149
+ },
2142
2150
  style: styles4.target,
2143
2151
  testID,
2144
2152
  children: /* @__PURE__ */ jsx(Text, { style: { color: theme.colors.text }, children: showAbsolute ? absolute : relative })