@dloizides/ui-tables 2.0.0 → 3.0.1
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 +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +52 -44
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +53 -45
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -874,7 +874,7 @@ interface StatusLedgerLabels {
|
|
|
874
874
|
actions: string;
|
|
875
875
|
}
|
|
876
876
|
type ToneColors = Partial<Record<StatusTone, string>>;
|
|
877
|
-
interface
|
|
877
|
+
interface StatusLedgerBaseProps<T> {
|
|
878
878
|
rows: readonly T[];
|
|
879
879
|
columns: ReadonlyArray<StatusLedgerColumn<T>>;
|
|
880
880
|
keyExtractor: (row: T) => string;
|
|
@@ -887,7 +887,6 @@ interface StatusLedgerProps<T> {
|
|
|
887
887
|
getSearchText?: (row: T) => string;
|
|
888
888
|
needsLook?: (row: T) => boolean;
|
|
889
889
|
getRowAccessibilityLabel?: (row: T) => string;
|
|
890
|
-
onRowPress?: (row: T) => void;
|
|
891
890
|
renderActions?: (row: T) => React.ReactNode;
|
|
892
891
|
/** Renders a detail region directly under the expanded row (table and card layouts); labelled by `getRowAccessibilityLabel`. */
|
|
893
892
|
renderRowDetail?: (row: T) => React.ReactNode;
|
|
@@ -899,6 +898,7 @@ interface StatusLedgerProps<T> {
|
|
|
899
898
|
loading?: boolean;
|
|
900
899
|
testID?: string;
|
|
901
900
|
}
|
|
901
|
+
type StatusLedgerProps<T> = StatusLedgerBaseProps<T> & DataTableRowAction<T>;
|
|
902
902
|
interface LedgerFilter {
|
|
903
903
|
status: string;
|
|
904
904
|
group: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -874,7 +874,7 @@ interface StatusLedgerLabels {
|
|
|
874
874
|
actions: string;
|
|
875
875
|
}
|
|
876
876
|
type ToneColors = Partial<Record<StatusTone, string>>;
|
|
877
|
-
interface
|
|
877
|
+
interface StatusLedgerBaseProps<T> {
|
|
878
878
|
rows: readonly T[];
|
|
879
879
|
columns: ReadonlyArray<StatusLedgerColumn<T>>;
|
|
880
880
|
keyExtractor: (row: T) => string;
|
|
@@ -887,7 +887,6 @@ interface StatusLedgerProps<T> {
|
|
|
887
887
|
getSearchText?: (row: T) => string;
|
|
888
888
|
needsLook?: (row: T) => boolean;
|
|
889
889
|
getRowAccessibilityLabel?: (row: T) => string;
|
|
890
|
-
onRowPress?: (row: T) => void;
|
|
891
890
|
renderActions?: (row: T) => React.ReactNode;
|
|
892
891
|
/** Renders a detail region directly under the expanded row (table and card layouts); labelled by `getRowAccessibilityLabel`. */
|
|
893
892
|
renderRowDetail?: (row: T) => React.ReactNode;
|
|
@@ -899,6 +898,7 @@ interface StatusLedgerProps<T> {
|
|
|
899
898
|
loading?: boolean;
|
|
900
899
|
testID?: string;
|
|
901
900
|
}
|
|
901
|
+
type StatusLedgerProps<T> = StatusLedgerBaseProps<T> & DataTableRowAction<T>;
|
|
902
902
|
interface LedgerFilter {
|
|
903
903
|
status: string;
|
|
904
904
|
group: string;
|
package/dist/index.js
CHANGED
|
@@ -458,23 +458,33 @@ var HEX_RGB2 = /^#[0-9a-f]{6}$/i;
|
|
|
458
458
|
var FOCUS_RING_WIDTH = 2;
|
|
459
459
|
var FOCUS_RING_OFFSET = -2;
|
|
460
460
|
var POINTER = { cursor: "pointer" };
|
|
461
|
+
function focusRingStyle(focused, tokens) {
|
|
462
|
+
return focused === true ? { outlineStyle: "solid", outlineWidth: FOCUS_RING_WIDTH, outlineColor: tokens.brand, outlineOffset: FOCUS_RING_OFFSET } : null;
|
|
463
|
+
}
|
|
461
464
|
function rowInteractionStyle(state, tokens) {
|
|
462
465
|
const pressedTint = HEX_RGB2.test(tokens.brand) ? `${tokens.brand}${PRESSED_TINT_ALPHA}` : tokens.fallbackTint;
|
|
463
|
-
return [
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
];
|
|
466
|
+
return [POINTER, state.pressed ? { backgroundColor: pressedTint } : null, focusRingStyle(state.focused, tokens)];
|
|
467
|
+
}
|
|
468
|
+
function useFrameFocus() {
|
|
469
|
+
const [focused, setFocused] = React2.useState(false);
|
|
470
|
+
const onFocus = React2.useCallback((event) => setFocused(event.target === event.currentTarget), []);
|
|
471
|
+
const onBlur = React2.useCallback(() => setFocused(false), []);
|
|
472
|
+
return { focused, onFocus, onBlur };
|
|
468
473
|
}
|
|
469
474
|
var TAB_INDEX_INACTIVE = -1;
|
|
470
475
|
function webKeyProps(onKeyDown) {
|
|
471
476
|
return onKeyDown === void 0 ? {} : { onKeyDown };
|
|
472
477
|
}
|
|
473
|
-
function focusProps(keyboard) {
|
|
478
|
+
function focusProps(keyboard, frame) {
|
|
474
479
|
if (keyboard === void 0) return {};
|
|
480
|
+
const onFocus = frame === void 0 ? keyboard.onFocus : (event) => {
|
|
481
|
+
keyboard.onFocus();
|
|
482
|
+
frame.onFocus(event);
|
|
483
|
+
};
|
|
475
484
|
return {
|
|
476
485
|
tabIndex: keyboard.tabIndex,
|
|
477
|
-
onFocus
|
|
486
|
+
onFocus,
|
|
487
|
+
onBlur: frame?.onBlur,
|
|
478
488
|
ref: (node) => keyboard.registerNode(node),
|
|
479
489
|
...webKeyProps(keyboard.onKeyDown)
|
|
480
490
|
};
|
|
@@ -494,21 +504,23 @@ function TableRow({
|
|
|
494
504
|
}) {
|
|
495
505
|
const interactive = onPress !== void 0;
|
|
496
506
|
const hover = interactive ? { onHoverIn, onHoverOut } : null;
|
|
507
|
+
const frame = useFrameFocus();
|
|
508
|
+
const frameStyle = [style, focusRingStyle(frame.focused, interaction)];
|
|
497
509
|
if (selectionSlot === void 0) {
|
|
498
|
-
return interactive ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Pressable, { style: (state) => [style, rowInteractionStyle(state, interaction)], testID, onPress, ...hover, ...a11y, ...focusProps(keyboard), children }) : /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style, testID, ...a11y, ...focusProps(keyboard), children });
|
|
510
|
+
return interactive ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Pressable, { style: (state) => [style, rowInteractionStyle(state, interaction)], testID, onPress, ...hover, ...a11y, ...focusProps(keyboard), children }) : /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: frameStyle, testID, ...a11y, ...focusProps(keyboard, frame), children });
|
|
499
511
|
}
|
|
500
512
|
const contentStyle = stacked ? selectionStyles.cardContent : selectionStyles.rowContent;
|
|
501
513
|
const content = interactive ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
502
514
|
reactNative.Pressable,
|
|
503
515
|
{
|
|
504
|
-
style: (state) => [contentStyle, rowInteractionStyle(state, interaction)],
|
|
516
|
+
style: (state) => [contentStyle, rowInteractionStyle(keyboard === void 0 ? state : { pressed: state.pressed }, interaction)],
|
|
505
517
|
tabIndex: keyboard === void 0 ? void 0 : TAB_INDEX_INACTIVE,
|
|
506
518
|
onPress,
|
|
507
519
|
...hover,
|
|
508
520
|
children
|
|
509
521
|
}
|
|
510
522
|
) : /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: contentStyle, children });
|
|
511
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style, testID, ...a11y, ...focusProps(keyboard), children: [
|
|
523
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: frameStyle, testID, ...a11y, ...focusProps(keyboard, frame), children: [
|
|
512
524
|
/* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: selectionStyles.selectCell, children: selectionSlot }),
|
|
513
525
|
content
|
|
514
526
|
] });
|
|
@@ -1658,21 +1670,6 @@ function SelectField({ field, barTestID, value, onChange, placeholder, dropdownH
|
|
|
1658
1670
|
}
|
|
1659
1671
|
);
|
|
1660
1672
|
}
|
|
1661
|
-
var NO_HINT = "";
|
|
1662
|
-
function SingleDateField({ field, barTestID, value, onChange, onSubmit, containerStyle }) {
|
|
1663
|
-
const testID = field.testID ?? fieldTestID(barTestID, field.key);
|
|
1664
|
-
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: containerStyle, testID, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1665
|
-
uiForms.DateField,
|
|
1666
|
-
{
|
|
1667
|
-
accessibilityHint: field.accessibilityHint ?? NO_HINT,
|
|
1668
|
-
label: field.label,
|
|
1669
|
-
testID: `${testID}-input`,
|
|
1670
|
-
value,
|
|
1671
|
-
onChange,
|
|
1672
|
-
onSubmit
|
|
1673
|
-
}
|
|
1674
|
-
) });
|
|
1675
|
-
}
|
|
1676
1673
|
function TextField({ field, barTestID, value, onChange, onSubmit }) {
|
|
1677
1674
|
const { theme } = uiFeedback.useUi();
|
|
1678
1675
|
const { colors } = theme;
|
|
@@ -1724,6 +1721,7 @@ function clampedMinWidth(minWidth) {
|
|
|
1724
1721
|
}
|
|
1725
1722
|
var EMPTY_RANGE = { from: "", to: "" };
|
|
1726
1723
|
var GROW_FLEX = 1;
|
|
1724
|
+
var NO_HINT = "";
|
|
1727
1725
|
function asString(value) {
|
|
1728
1726
|
return typeof value === "string" ? value : "";
|
|
1729
1727
|
}
|
|
@@ -1745,21 +1743,26 @@ function FilterFieldView({ field, barTestID, values, setField, onSubmit, strings
|
|
|
1745
1743
|
return /* @__PURE__ */ jsxRuntime.jsx(BooleanField, { field, barTestID, value: asBool(raw), onChange: (v) => setField(field.key, v) });
|
|
1746
1744
|
}
|
|
1747
1745
|
const containerStyle = fieldContainerStyle(field);
|
|
1748
|
-
|
|
1749
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1750
|
-
SingleDateField,
|
|
1751
|
-
{
|
|
1752
|
-
barTestID,
|
|
1753
|
-
containerStyle,
|
|
1754
|
-
field,
|
|
1755
|
-
value: asString(raw),
|
|
1756
|
-
onChange: (v) => setField(field.key, v),
|
|
1757
|
-
onSubmit
|
|
1758
|
-
}
|
|
1759
|
-
);
|
|
1760
|
-
}
|
|
1746
|
+
const testID = field.testID ?? fieldTestID(barTestID, field.key);
|
|
1761
1747
|
const body = (() => {
|
|
1762
1748
|
switch (field.kind) {
|
|
1749
|
+
case "date":
|
|
1750
|
+
return function renderDateInput(context) {
|
|
1751
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1752
|
+
uiForms.DateInput,
|
|
1753
|
+
{
|
|
1754
|
+
context,
|
|
1755
|
+
fieldProps: {
|
|
1756
|
+
accessibilityHint: field.accessibilityHint ?? NO_HINT,
|
|
1757
|
+
label: field.label,
|
|
1758
|
+
testID: `${testID}-input`,
|
|
1759
|
+
value: asString(raw),
|
|
1760
|
+
onChange: (v) => setField(field.key, v),
|
|
1761
|
+
onSubmit
|
|
1762
|
+
}
|
|
1763
|
+
}
|
|
1764
|
+
);
|
|
1765
|
+
};
|
|
1763
1766
|
case "select":
|
|
1764
1767
|
if (renderSelect !== void 0) {
|
|
1765
1768
|
return renderSelect({
|
|
@@ -1825,7 +1828,7 @@ function FilterFieldView({ field, barTestID, values, setField, onSubmit, strings
|
|
|
1825
1828
|
containerStyle,
|
|
1826
1829
|
label: field.label,
|
|
1827
1830
|
labelVariant: "control",
|
|
1828
|
-
testID
|
|
1831
|
+
testID,
|
|
1829
1832
|
children: body
|
|
1830
1833
|
}
|
|
1831
1834
|
);
|
|
@@ -1972,6 +1975,14 @@ function usePagedRows(rows, options = {}) {
|
|
|
1972
1975
|
};
|
|
1973
1976
|
}
|
|
1974
1977
|
|
|
1978
|
+
// src/DataTable/rowAction.ts
|
|
1979
|
+
function declaresNoRowAction(action) {
|
|
1980
|
+
return action.rowAction !== void 0;
|
|
1981
|
+
}
|
|
1982
|
+
function pickRowAction(action) {
|
|
1983
|
+
return declaresNoRowAction(action) ? { onRowPress: action.onRowPress, rowAction: action.rowAction } : { onRowPress: action.onRowPress };
|
|
1984
|
+
}
|
|
1985
|
+
|
|
1975
1986
|
// src/StatusLedger/StatusTone.ts
|
|
1976
1987
|
var StatusTone = /* @__PURE__ */ ((StatusTone2) => {
|
|
1977
1988
|
StatusTone2["Bad"] = "bad";
|
|
@@ -2151,7 +2162,6 @@ var LedgerLayout = /* @__PURE__ */ ((LedgerLayout2) => {
|
|
|
2151
2162
|
LedgerLayout2["Feed"] = "feed";
|
|
2152
2163
|
return LedgerLayout2;
|
|
2153
2164
|
})(LedgerLayout || {});
|
|
2154
|
-
var LEDGER_ROW_ACTION_FALLBACK = { none: "status ledger caller passed no onRowPress" };
|
|
2155
2165
|
var GAP = 12;
|
|
2156
2166
|
var HEADING_FONT = 15;
|
|
2157
2167
|
var HEADING_WEIGHT = "700";
|
|
@@ -2173,8 +2183,7 @@ function LedgerSection({ title, rows, columns, emptyLabel, testID, ledger }) {
|
|
|
2173
2183
|
getRowAccessibilityLabel: ledger.getRowAccessibilityLabel,
|
|
2174
2184
|
getRowDetailAccessibilityLabel: ledger.getRowAccessibilityLabel,
|
|
2175
2185
|
keyExtractor: ledger.keyExtractor,
|
|
2176
|
-
|
|
2177
|
-
rowAction: LEDGER_ROW_ACTION_FALLBACK,
|
|
2186
|
+
...pickRowAction(ledger),
|
|
2178
2187
|
renderRowDetail: ledger.renderRowDetail,
|
|
2179
2188
|
rows,
|
|
2180
2189
|
stackBreakpoint: ledger.breakpoint ?? CARD_STACK_BREAKPOINT,
|
|
@@ -2228,8 +2237,7 @@ function StatusLedger(props) {
|
|
|
2228
2237
|
getRowDetailAccessibilityLabel: props.getRowAccessibilityLabel,
|
|
2229
2238
|
keyExtractor: props.keyExtractor,
|
|
2230
2239
|
loading,
|
|
2231
|
-
|
|
2232
|
-
rowAction: LEDGER_ROW_ACTION_FALLBACK,
|
|
2240
|
+
...pickRowAction(props),
|
|
2233
2241
|
renderRowDetail: props.renderRowDetail,
|
|
2234
2242
|
rows: view.visible,
|
|
2235
2243
|
stackBreakpoint: feed ? breakpoint : 0,
|