@dloizides/ui-tables 1.29.1 → 3.0.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 +24 -8
- package/dist/index.d.ts +24 -8
- package/dist/index.js +87 -33
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +88 -34
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -24,6 +24,19 @@ interface StatCardProps {
|
|
|
24
24
|
}
|
|
25
25
|
declare const StatCard: React.MemoExoticComponent<({ label, value, testID, tone }: StatCardProps) => React.ReactElement>;
|
|
26
26
|
|
|
27
|
+
interface RowActionNone {
|
|
28
|
+
none: string;
|
|
29
|
+
}
|
|
30
|
+
interface OpensRows<T> {
|
|
31
|
+
onRowPress: (row: T) => void;
|
|
32
|
+
rowAction?: RowActionNone;
|
|
33
|
+
}
|
|
34
|
+
interface DeclaresNoRowAction<T> {
|
|
35
|
+
onRowPress?: (row: T) => void;
|
|
36
|
+
rowAction: RowActionNone;
|
|
37
|
+
}
|
|
38
|
+
type DataTableRowAction<T> = OpensRows<T> | DeclaresNoRowAction<T>;
|
|
39
|
+
|
|
27
40
|
/**
|
|
28
41
|
* The DataTable contract — a `columns + rows` grid (the shape proven in the POC and
|
|
29
42
|
* carried over unchanged; it is the right API). Every user-facing string is either
|
|
@@ -92,7 +105,7 @@ interface DataTableColumn<T> {
|
|
|
92
105
|
minWidth?: number;
|
|
93
106
|
render: (row: T) => React.ReactNode;
|
|
94
107
|
}
|
|
95
|
-
interface
|
|
108
|
+
interface DataTableBaseProps<T> {
|
|
96
109
|
columns: ReadonlyArray<DataTableColumn<T>>;
|
|
97
110
|
rows: readonly T[];
|
|
98
111
|
keyExtractor: (row: T) => string;
|
|
@@ -102,8 +115,6 @@ interface DataTableProps<T> {
|
|
|
102
115
|
zebra?: boolean;
|
|
103
116
|
/** Keep the header pinned while the body scrolls (web `position: sticky`). */
|
|
104
117
|
stickyHeader?: boolean;
|
|
105
|
-
/** Make rows pressable (GRID.md `is-click`). Enables row accessibilityRole=button. */
|
|
106
|
-
onRowPress?: (row: T) => void;
|
|
107
118
|
/** Per-row accessibility label. Falls back to the kit's `rowLabel` translation. */
|
|
108
119
|
getRowAccessibilityLabel?: (row: T) => string;
|
|
109
120
|
/**
|
|
@@ -213,6 +224,7 @@ interface DataTableProps<T> {
|
|
|
213
224
|
styleOverrides?: DataTableStyleOverrides;
|
|
214
225
|
testID?: string;
|
|
215
226
|
}
|
|
227
|
+
type DataTableProps<T> = DataTableBaseProps<T> & DataTableRowAction<T>;
|
|
216
228
|
|
|
217
229
|
/**
|
|
218
230
|
* DataTable — the shared, tokenized RN-web grid for every dloizides.com surface
|
|
@@ -556,7 +568,7 @@ declare const TABLE_I18N: {
|
|
|
556
568
|
*/
|
|
557
569
|
|
|
558
570
|
/** The kinds of field the declarative bar can render. */
|
|
559
|
-
type FilterFieldKind = 'select' | 'text' | 'number' | 'dateRange' | 'typeahead' | 'boolean';
|
|
571
|
+
type FilterFieldKind = 'select' | 'text' | 'number' | 'date' | 'dateRange' | 'typeahead' | 'boolean';
|
|
560
572
|
/**
|
|
561
573
|
* A single choice for a `select` / `typeahead` field. Label is pre-localized.
|
|
562
574
|
*
|
|
@@ -604,6 +616,10 @@ interface NumberFilterField extends FilterFieldBase {
|
|
|
604
616
|
kind: 'number';
|
|
605
617
|
placeholder?: string;
|
|
606
618
|
}
|
|
619
|
+
/** A single calendar date (`YYYY-MM-DD`, ''=unset), rendered by `ui-forms`' `DateField`. */
|
|
620
|
+
interface DateFilterField extends FilterFieldBase {
|
|
621
|
+
kind: 'date';
|
|
622
|
+
}
|
|
607
623
|
/** An inclusive from/to date range (two `YYYY-MM-DD` inputs). */
|
|
608
624
|
interface DateRangeFilterField extends FilterFieldBase {
|
|
609
625
|
kind: 'dateRange';
|
|
@@ -631,7 +647,7 @@ interface BooleanFilterField extends FilterFieldBase {
|
|
|
631
647
|
kind: 'boolean';
|
|
632
648
|
}
|
|
633
649
|
/** The discriminated union of every declarative filter field. */
|
|
634
|
-
type FilterField = SelectFilterField | TextFilterField | NumberFilterField | DateRangeFilterField | TypeaheadFilterField | BooleanFilterField;
|
|
650
|
+
type FilterField = SelectFilterField | TextFilterField | NumberFilterField | DateFilterField | DateRangeFilterField | TypeaheadFilterField | BooleanFilterField;
|
|
635
651
|
|
|
636
652
|
/**
|
|
637
653
|
* FilterFieldView — dispatches one {@link FilterField} to its renderer, wired to the value map.
|
|
@@ -858,7 +874,7 @@ interface StatusLedgerLabels {
|
|
|
858
874
|
actions: string;
|
|
859
875
|
}
|
|
860
876
|
type ToneColors = Partial<Record<StatusTone, string>>;
|
|
861
|
-
interface
|
|
877
|
+
interface StatusLedgerBaseProps<T> {
|
|
862
878
|
rows: readonly T[];
|
|
863
879
|
columns: ReadonlyArray<StatusLedgerColumn<T>>;
|
|
864
880
|
keyExtractor: (row: T) => string;
|
|
@@ -871,7 +887,6 @@ interface StatusLedgerProps<T> {
|
|
|
871
887
|
getSearchText?: (row: T) => string;
|
|
872
888
|
needsLook?: (row: T) => boolean;
|
|
873
889
|
getRowAccessibilityLabel?: (row: T) => string;
|
|
874
|
-
onRowPress?: (row: T) => void;
|
|
875
890
|
renderActions?: (row: T) => React.ReactNode;
|
|
876
891
|
/** Renders a detail region directly under the expanded row (table and card layouts); labelled by `getRowAccessibilityLabel`. */
|
|
877
892
|
renderRowDetail?: (row: T) => React.ReactNode;
|
|
@@ -883,6 +898,7 @@ interface StatusLedgerProps<T> {
|
|
|
883
898
|
loading?: boolean;
|
|
884
899
|
testID?: string;
|
|
885
900
|
}
|
|
901
|
+
type StatusLedgerProps<T> = StatusLedgerBaseProps<T> & DataTableRowAction<T>;
|
|
886
902
|
interface LedgerFilter {
|
|
887
903
|
status: string;
|
|
888
904
|
group: string;
|
|
@@ -989,4 +1005,4 @@ declare const MonthStatusGrid: ({ cells, onSelect, selectedId, columns, accessib
|
|
|
989
1005
|
/** The widest allowed column count, up to `requested`, whose cells stay at least 44 px wide. */
|
|
990
1006
|
declare function fitMonthGridColumns(requested: MonthGridColumns, width: number, gap: number): MonthGridColumns;
|
|
991
1007
|
|
|
992
|
-
export { type BooleanFilterField, CARD_STACK_BREAKPOINT, DEFAULT_PAGE_SIZE, DEFAULT_PAGE_SIZE_OPTIONS, DataTable, type DataTableColumn, type DataTableProps, type DataTableStyleOverrides, type DateRangeFilterField, FIELD_MIN_WIDTH, FILTERS_I18N, FILTERS_TEST_ID, type FieldStrings, FilterBar, type FilterBarProps, type FilterBarStyleOverrides, type FilterDraft, type FilterField, type FilterFieldKind, type FilterOption, type FilterValue, type FilterValues, Filters, type FiltersProps, type LedgerFilter, LedgerLayout, MONTH_STATUS_GRID_TEST_ID, MonthGridColumns, type MonthStatusCell, MonthStatusGrid, type MonthStatusGridProps, type NumberFilterField, type PagedRows, PagedTableLayout, PagedTableLayoutKind, type PagedTableLayoutProps, Pager, type PagerProps, type PagerStyleOverrides, RelativeTime, type RelativeTimeProps, type RelativeTimeStrings, type RelativeUnitStrings, type RenderSelectArgs, STATUS_LEDGER_TEST_ID, type SelectFilterField, SortDirection, type SortValue, StatCard, type StatCardProps, StatTone, StatusLedger, type StatusLedgerColumn, type StatusLedgerLabels, type StatusLedgerProps, StatusPill, type StatusPillProps, StatusTone, TABLE_I18N, TABLE_TEST_IDS, type TextFilterField, type TimeInput, type ToneColors, type TypeaheadFilterField, type UseFilterDraftOptions, type UsePagedRowsOptions, applyTestID, clearTestID, distinctValues, fieldTestID, filterLedgerRows, fitMonthGridColumns, formatRelativeTime, isAttentionTone, ledgerSectionTestID, ledgerSortDirectionTestID, monthCellTestID, resolveStatToneColor, rowDetailTestID, rowFadeTestID, rowSelectTestID, rowTestID, selectAllTestID, sortLedgerRows, splitNeedsLook, toEpochMs, useFilterDraft, usePagedRows };
|
|
1008
|
+
export { type BooleanFilterField, CARD_STACK_BREAKPOINT, DEFAULT_PAGE_SIZE, DEFAULT_PAGE_SIZE_OPTIONS, DataTable, type DataTableBaseProps, type DataTableColumn, type DataTableProps, type DataTableRowAction, type DataTableStyleOverrides, type DateFilterField, type DateRangeFilterField, FIELD_MIN_WIDTH, FILTERS_I18N, FILTERS_TEST_ID, type FieldStrings, FilterBar, type FilterBarProps, type FilterBarStyleOverrides, type FilterDraft, type FilterField, type FilterFieldKind, type FilterOption, type FilterValue, type FilterValues, Filters, type FiltersProps, type LedgerFilter, LedgerLayout, MONTH_STATUS_GRID_TEST_ID, MonthGridColumns, type MonthStatusCell, MonthStatusGrid, type MonthStatusGridProps, type NumberFilterField, type PagedRows, PagedTableLayout, PagedTableLayoutKind, type PagedTableLayoutProps, Pager, type PagerProps, type PagerStyleOverrides, RelativeTime, type RelativeTimeProps, type RelativeTimeStrings, type RelativeUnitStrings, type RenderSelectArgs, type RowActionNone, STATUS_LEDGER_TEST_ID, type SelectFilterField, SortDirection, type SortValue, StatCard, type StatCardProps, StatTone, StatusLedger, type StatusLedgerColumn, type StatusLedgerLabels, type StatusLedgerProps, StatusPill, type StatusPillProps, StatusTone, TABLE_I18N, TABLE_TEST_IDS, type TextFilterField, type TimeInput, type ToneColors, type TypeaheadFilterField, type UseFilterDraftOptions, type UsePagedRowsOptions, applyTestID, clearTestID, distinctValues, fieldTestID, filterLedgerRows, fitMonthGridColumns, formatRelativeTime, isAttentionTone, ledgerSectionTestID, ledgerSortDirectionTestID, monthCellTestID, resolveStatToneColor, rowDetailTestID, rowFadeTestID, rowSelectTestID, rowTestID, selectAllTestID, sortLedgerRows, splitNeedsLook, toEpochMs, useFilterDraft, usePagedRows };
|
package/dist/index.d.ts
CHANGED
|
@@ -24,6 +24,19 @@ interface StatCardProps {
|
|
|
24
24
|
}
|
|
25
25
|
declare const StatCard: React.MemoExoticComponent<({ label, value, testID, tone }: StatCardProps) => React.ReactElement>;
|
|
26
26
|
|
|
27
|
+
interface RowActionNone {
|
|
28
|
+
none: string;
|
|
29
|
+
}
|
|
30
|
+
interface OpensRows<T> {
|
|
31
|
+
onRowPress: (row: T) => void;
|
|
32
|
+
rowAction?: RowActionNone;
|
|
33
|
+
}
|
|
34
|
+
interface DeclaresNoRowAction<T> {
|
|
35
|
+
onRowPress?: (row: T) => void;
|
|
36
|
+
rowAction: RowActionNone;
|
|
37
|
+
}
|
|
38
|
+
type DataTableRowAction<T> = OpensRows<T> | DeclaresNoRowAction<T>;
|
|
39
|
+
|
|
27
40
|
/**
|
|
28
41
|
* The DataTable contract — a `columns + rows` grid (the shape proven in the POC and
|
|
29
42
|
* carried over unchanged; it is the right API). Every user-facing string is either
|
|
@@ -92,7 +105,7 @@ interface DataTableColumn<T> {
|
|
|
92
105
|
minWidth?: number;
|
|
93
106
|
render: (row: T) => React.ReactNode;
|
|
94
107
|
}
|
|
95
|
-
interface
|
|
108
|
+
interface DataTableBaseProps<T> {
|
|
96
109
|
columns: ReadonlyArray<DataTableColumn<T>>;
|
|
97
110
|
rows: readonly T[];
|
|
98
111
|
keyExtractor: (row: T) => string;
|
|
@@ -102,8 +115,6 @@ interface DataTableProps<T> {
|
|
|
102
115
|
zebra?: boolean;
|
|
103
116
|
/** Keep the header pinned while the body scrolls (web `position: sticky`). */
|
|
104
117
|
stickyHeader?: boolean;
|
|
105
|
-
/** Make rows pressable (GRID.md `is-click`). Enables row accessibilityRole=button. */
|
|
106
|
-
onRowPress?: (row: T) => void;
|
|
107
118
|
/** Per-row accessibility label. Falls back to the kit's `rowLabel` translation. */
|
|
108
119
|
getRowAccessibilityLabel?: (row: T) => string;
|
|
109
120
|
/**
|
|
@@ -213,6 +224,7 @@ interface DataTableProps<T> {
|
|
|
213
224
|
styleOverrides?: DataTableStyleOverrides;
|
|
214
225
|
testID?: string;
|
|
215
226
|
}
|
|
227
|
+
type DataTableProps<T> = DataTableBaseProps<T> & DataTableRowAction<T>;
|
|
216
228
|
|
|
217
229
|
/**
|
|
218
230
|
* DataTable — the shared, tokenized RN-web grid for every dloizides.com surface
|
|
@@ -556,7 +568,7 @@ declare const TABLE_I18N: {
|
|
|
556
568
|
*/
|
|
557
569
|
|
|
558
570
|
/** The kinds of field the declarative bar can render. */
|
|
559
|
-
type FilterFieldKind = 'select' | 'text' | 'number' | 'dateRange' | 'typeahead' | 'boolean';
|
|
571
|
+
type FilterFieldKind = 'select' | 'text' | 'number' | 'date' | 'dateRange' | 'typeahead' | 'boolean';
|
|
560
572
|
/**
|
|
561
573
|
* A single choice for a `select` / `typeahead` field. Label is pre-localized.
|
|
562
574
|
*
|
|
@@ -604,6 +616,10 @@ interface NumberFilterField extends FilterFieldBase {
|
|
|
604
616
|
kind: 'number';
|
|
605
617
|
placeholder?: string;
|
|
606
618
|
}
|
|
619
|
+
/** A single calendar date (`YYYY-MM-DD`, ''=unset), rendered by `ui-forms`' `DateField`. */
|
|
620
|
+
interface DateFilterField extends FilterFieldBase {
|
|
621
|
+
kind: 'date';
|
|
622
|
+
}
|
|
607
623
|
/** An inclusive from/to date range (two `YYYY-MM-DD` inputs). */
|
|
608
624
|
interface DateRangeFilterField extends FilterFieldBase {
|
|
609
625
|
kind: 'dateRange';
|
|
@@ -631,7 +647,7 @@ interface BooleanFilterField extends FilterFieldBase {
|
|
|
631
647
|
kind: 'boolean';
|
|
632
648
|
}
|
|
633
649
|
/** The discriminated union of every declarative filter field. */
|
|
634
|
-
type FilterField = SelectFilterField | TextFilterField | NumberFilterField | DateRangeFilterField | TypeaheadFilterField | BooleanFilterField;
|
|
650
|
+
type FilterField = SelectFilterField | TextFilterField | NumberFilterField | DateFilterField | DateRangeFilterField | TypeaheadFilterField | BooleanFilterField;
|
|
635
651
|
|
|
636
652
|
/**
|
|
637
653
|
* FilterFieldView — dispatches one {@link FilterField} to its renderer, wired to the value map.
|
|
@@ -858,7 +874,7 @@ interface StatusLedgerLabels {
|
|
|
858
874
|
actions: string;
|
|
859
875
|
}
|
|
860
876
|
type ToneColors = Partial<Record<StatusTone, string>>;
|
|
861
|
-
interface
|
|
877
|
+
interface StatusLedgerBaseProps<T> {
|
|
862
878
|
rows: readonly T[];
|
|
863
879
|
columns: ReadonlyArray<StatusLedgerColumn<T>>;
|
|
864
880
|
keyExtractor: (row: T) => string;
|
|
@@ -871,7 +887,6 @@ interface StatusLedgerProps<T> {
|
|
|
871
887
|
getSearchText?: (row: T) => string;
|
|
872
888
|
needsLook?: (row: T) => boolean;
|
|
873
889
|
getRowAccessibilityLabel?: (row: T) => string;
|
|
874
|
-
onRowPress?: (row: T) => void;
|
|
875
890
|
renderActions?: (row: T) => React.ReactNode;
|
|
876
891
|
/** Renders a detail region directly under the expanded row (table and card layouts); labelled by `getRowAccessibilityLabel`. */
|
|
877
892
|
renderRowDetail?: (row: T) => React.ReactNode;
|
|
@@ -883,6 +898,7 @@ interface StatusLedgerProps<T> {
|
|
|
883
898
|
loading?: boolean;
|
|
884
899
|
testID?: string;
|
|
885
900
|
}
|
|
901
|
+
type StatusLedgerProps<T> = StatusLedgerBaseProps<T> & DataTableRowAction<T>;
|
|
886
902
|
interface LedgerFilter {
|
|
887
903
|
status: string;
|
|
888
904
|
group: string;
|
|
@@ -989,4 +1005,4 @@ declare const MonthStatusGrid: ({ cells, onSelect, selectedId, columns, accessib
|
|
|
989
1005
|
/** The widest allowed column count, up to `requested`, whose cells stay at least 44 px wide. */
|
|
990
1006
|
declare function fitMonthGridColumns(requested: MonthGridColumns, width: number, gap: number): MonthGridColumns;
|
|
991
1007
|
|
|
992
|
-
export { type BooleanFilterField, CARD_STACK_BREAKPOINT, DEFAULT_PAGE_SIZE, DEFAULT_PAGE_SIZE_OPTIONS, DataTable, type DataTableColumn, type DataTableProps, type DataTableStyleOverrides, type DateRangeFilterField, FIELD_MIN_WIDTH, FILTERS_I18N, FILTERS_TEST_ID, type FieldStrings, FilterBar, type FilterBarProps, type FilterBarStyleOverrides, type FilterDraft, type FilterField, type FilterFieldKind, type FilterOption, type FilterValue, type FilterValues, Filters, type FiltersProps, type LedgerFilter, LedgerLayout, MONTH_STATUS_GRID_TEST_ID, MonthGridColumns, type MonthStatusCell, MonthStatusGrid, type MonthStatusGridProps, type NumberFilterField, type PagedRows, PagedTableLayout, PagedTableLayoutKind, type PagedTableLayoutProps, Pager, type PagerProps, type PagerStyleOverrides, RelativeTime, type RelativeTimeProps, type RelativeTimeStrings, type RelativeUnitStrings, type RenderSelectArgs, STATUS_LEDGER_TEST_ID, type SelectFilterField, SortDirection, type SortValue, StatCard, type StatCardProps, StatTone, StatusLedger, type StatusLedgerColumn, type StatusLedgerLabels, type StatusLedgerProps, StatusPill, type StatusPillProps, StatusTone, TABLE_I18N, TABLE_TEST_IDS, type TextFilterField, type TimeInput, type ToneColors, type TypeaheadFilterField, type UseFilterDraftOptions, type UsePagedRowsOptions, applyTestID, clearTestID, distinctValues, fieldTestID, filterLedgerRows, fitMonthGridColumns, formatRelativeTime, isAttentionTone, ledgerSectionTestID, ledgerSortDirectionTestID, monthCellTestID, resolveStatToneColor, rowDetailTestID, rowFadeTestID, rowSelectTestID, rowTestID, selectAllTestID, sortLedgerRows, splitNeedsLook, toEpochMs, useFilterDraft, usePagedRows };
|
|
1008
|
+
export { type BooleanFilterField, CARD_STACK_BREAKPOINT, DEFAULT_PAGE_SIZE, DEFAULT_PAGE_SIZE_OPTIONS, DataTable, type DataTableBaseProps, type DataTableColumn, type DataTableProps, type DataTableRowAction, type DataTableStyleOverrides, type DateFilterField, type DateRangeFilterField, FIELD_MIN_WIDTH, FILTERS_I18N, FILTERS_TEST_ID, type FieldStrings, FilterBar, type FilterBarProps, type FilterBarStyleOverrides, type FilterDraft, type FilterField, type FilterFieldKind, type FilterOption, type FilterValue, type FilterValues, Filters, type FiltersProps, type LedgerFilter, LedgerLayout, MONTH_STATUS_GRID_TEST_ID, MonthGridColumns, type MonthStatusCell, MonthStatusGrid, type MonthStatusGridProps, type NumberFilterField, type PagedRows, PagedTableLayout, PagedTableLayoutKind, type PagedTableLayoutProps, Pager, type PagerProps, type PagerStyleOverrides, RelativeTime, type RelativeTimeProps, type RelativeTimeStrings, type RelativeUnitStrings, type RenderSelectArgs, type RowActionNone, STATUS_LEDGER_TEST_ID, type SelectFilterField, SortDirection, type SortValue, StatCard, type StatCardProps, StatTone, StatusLedger, type StatusLedgerColumn, type StatusLedgerLabels, type StatusLedgerProps, StatusPill, type StatusPillProps, StatusTone, TABLE_I18N, TABLE_TEST_IDS, type TextFilterField, type TimeInput, type ToneColors, type TypeaheadFilterField, type UseFilterDraftOptions, type UsePagedRowsOptions, applyTestID, clearTestID, distinctValues, fieldTestID, filterLedgerRows, fitMonthGridColumns, formatRelativeTime, isAttentionTone, ledgerSectionTestID, ledgerSortDirectionTestID, monthCellTestID, resolveStatToneColor, rowDetailTestID, rowFadeTestID, rowSelectTestID, rowTestID, selectAllTestID, sortLedgerRows, splitNeedsLook, toEpochMs, useFilterDraft, usePagedRows };
|
package/dist/index.js
CHANGED
|
@@ -451,15 +451,40 @@ function SelectionCheckbox({
|
|
|
451
451
|
}
|
|
452
452
|
);
|
|
453
453
|
}
|
|
454
|
+
|
|
455
|
+
// src/DataTable/rowInteraction.ts
|
|
456
|
+
var PRESSED_TINT_ALPHA = "33";
|
|
457
|
+
var HEX_RGB2 = /^#[0-9a-f]{6}$/i;
|
|
458
|
+
var FOCUS_RING_WIDTH = 2;
|
|
459
|
+
var FOCUS_RING_OFFSET = -2;
|
|
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
|
+
}
|
|
464
|
+
function rowInteractionStyle(state, tokens) {
|
|
465
|
+
const pressedTint = HEX_RGB2.test(tokens.brand) ? `${tokens.brand}${PRESSED_TINT_ALPHA}` : tokens.fallbackTint;
|
|
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 };
|
|
473
|
+
}
|
|
454
474
|
var TAB_INDEX_INACTIVE = -1;
|
|
455
475
|
function webKeyProps(onKeyDown) {
|
|
456
476
|
return onKeyDown === void 0 ? {} : { onKeyDown };
|
|
457
477
|
}
|
|
458
|
-
function focusProps(keyboard) {
|
|
478
|
+
function focusProps(keyboard, frame) {
|
|
459
479
|
if (keyboard === void 0) return {};
|
|
480
|
+
const onFocus = frame === void 0 ? keyboard.onFocus : (event) => {
|
|
481
|
+
keyboard.onFocus();
|
|
482
|
+
frame.onFocus(event);
|
|
483
|
+
};
|
|
460
484
|
return {
|
|
461
485
|
tabIndex: keyboard.tabIndex,
|
|
462
|
-
onFocus
|
|
486
|
+
onFocus,
|
|
487
|
+
onBlur: frame?.onBlur,
|
|
463
488
|
ref: (node) => keyboard.registerNode(node),
|
|
464
489
|
...webKeyProps(keyboard.onKeyDown)
|
|
465
490
|
};
|
|
@@ -474,25 +499,28 @@ function TableRow({
|
|
|
474
499
|
onHoverOut,
|
|
475
500
|
selectionSlot,
|
|
476
501
|
stacked,
|
|
477
|
-
keyboard
|
|
502
|
+
keyboard,
|
|
503
|
+
interaction
|
|
478
504
|
}) {
|
|
479
505
|
const interactive = onPress !== void 0;
|
|
480
506
|
const hover = interactive ? { onHoverIn, onHoverOut } : null;
|
|
507
|
+
const frame = useFrameFocus();
|
|
508
|
+
const frameStyle = [style, focusRingStyle(frame.focused, interaction)];
|
|
481
509
|
if (selectionSlot === void 0) {
|
|
482
|
-
return interactive ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Pressable, { style, 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 });
|
|
483
511
|
}
|
|
484
512
|
const contentStyle = stacked ? selectionStyles.cardContent : selectionStyles.rowContent;
|
|
485
513
|
const content = interactive ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
486
514
|
reactNative.Pressable,
|
|
487
515
|
{
|
|
488
|
-
style: contentStyle,
|
|
516
|
+
style: (state) => [contentStyle, rowInteractionStyle(keyboard === void 0 ? state : { pressed: state.pressed }, interaction)],
|
|
489
517
|
tabIndex: keyboard === void 0 ? void 0 : TAB_INDEX_INACTIVE,
|
|
490
518
|
onPress,
|
|
491
519
|
...hover,
|
|
492
520
|
children
|
|
493
521
|
}
|
|
494
522
|
) : /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: contentStyle, children });
|
|
495
|
-
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: [
|
|
496
524
|
/* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: selectionStyles.selectCell, children: selectionSlot }),
|
|
497
525
|
content
|
|
498
526
|
] });
|
|
@@ -562,6 +590,7 @@ function DataTableRow({
|
|
|
562
590
|
testID: rowID,
|
|
563
591
|
onHoverIn,
|
|
564
592
|
onHoverOut,
|
|
593
|
+
interaction: { brand: theme.palette.primary["500"], fallbackTint: colors.border },
|
|
565
594
|
onPress: pressRow,
|
|
566
595
|
children: /* @__PURE__ */ jsxRuntime.jsx(RowPressProvider, { value: pressRow, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
567
596
|
RowCells,
|
|
@@ -1558,6 +1587,7 @@ var FIELD_MIN_WIDTH = {
|
|
|
1558
1587
|
select: 150,
|
|
1559
1588
|
text: 200,
|
|
1560
1589
|
number: 130,
|
|
1590
|
+
date: 160,
|
|
1561
1591
|
dateRange: 260,
|
|
1562
1592
|
typeahead: 200,
|
|
1563
1593
|
boolean: 150
|
|
@@ -1616,22 +1646,6 @@ function BooleanField({ field, barTestID, value, onChange }) {
|
|
|
1616
1646
|
)
|
|
1617
1647
|
] });
|
|
1618
1648
|
}
|
|
1619
|
-
function DateRangeField({ field, barTestID, value, onChange, onSubmit, fromLabel, toLabel }) {
|
|
1620
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1621
|
-
uiForms.DateRangeControl,
|
|
1622
|
-
{
|
|
1623
|
-
accessibilityHint: field.accessibilityHint,
|
|
1624
|
-
fromLabel: field.fromLabel ?? fromLabel,
|
|
1625
|
-
fromPlaceholder: field.fromPlaceholder,
|
|
1626
|
-
testID: field.testID ?? fieldTestID(barTestID, field.key),
|
|
1627
|
-
toLabel: field.toLabel ?? toLabel,
|
|
1628
|
-
toPlaceholder: field.toPlaceholder,
|
|
1629
|
-
value,
|
|
1630
|
-
onChange,
|
|
1631
|
-
onSubmit
|
|
1632
|
-
}
|
|
1633
|
-
);
|
|
1634
|
-
}
|
|
1635
1649
|
function SelectField({ field, barTestID, value, onChange, placeholder, dropdownHint, optionHint }) {
|
|
1636
1650
|
const { t } = uiFeedback.useUi();
|
|
1637
1651
|
const testID = field.testID ?? fieldTestID(barTestID, field.key);
|
|
@@ -1656,6 +1670,21 @@ function SelectField({ field, barTestID, value, onChange, placeholder, dropdownH
|
|
|
1656
1670
|
}
|
|
1657
1671
|
);
|
|
1658
1672
|
}
|
|
1673
|
+
var NO_HINT = "";
|
|
1674
|
+
function SingleDateField({ field, barTestID, value, onChange, onSubmit, containerStyle }) {
|
|
1675
|
+
const testID = field.testID ?? fieldTestID(barTestID, field.key);
|
|
1676
|
+
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: containerStyle, testID, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1677
|
+
uiForms.DateField,
|
|
1678
|
+
{
|
|
1679
|
+
accessibilityHint: field.accessibilityHint ?? NO_HINT,
|
|
1680
|
+
label: field.label,
|
|
1681
|
+
testID: `${testID}-input`,
|
|
1682
|
+
value,
|
|
1683
|
+
onChange,
|
|
1684
|
+
onSubmit
|
|
1685
|
+
}
|
|
1686
|
+
) });
|
|
1687
|
+
}
|
|
1659
1688
|
function TextField({ field, barTestID, value, onChange, onSubmit }) {
|
|
1660
1689
|
const { theme } = uiFeedback.useUi();
|
|
1661
1690
|
const { colors } = theme;
|
|
@@ -1717,11 +1746,30 @@ function asRange(value) {
|
|
|
1717
1746
|
if (typeof value === "object" && value !== null && "from" in value && "to" in value) return value;
|
|
1718
1747
|
return EMPTY_RANGE;
|
|
1719
1748
|
}
|
|
1749
|
+
function fieldContainerStyle(field) {
|
|
1750
|
+
const minWidth = field.minWidth ?? FIELD_MIN_WIDTH[field.kind];
|
|
1751
|
+
const grow = field.grow === true ? { flexGrow: GROW_FLEX } : null;
|
|
1752
|
+
return [filterStyles.fieldInBar, { minWidth: clampedMinWidth(minWidth), maxWidth: "100%" }, grow, field.style];
|
|
1753
|
+
}
|
|
1720
1754
|
function FilterFieldView({ field, barTestID, values, setField, onSubmit, strings, renderSelect }) {
|
|
1721
1755
|
const raw = values[field.key];
|
|
1722
1756
|
if (field.kind === "boolean") {
|
|
1723
1757
|
return /* @__PURE__ */ jsxRuntime.jsx(BooleanField, { field, barTestID, value: asBool(raw), onChange: (v) => setField(field.key, v) });
|
|
1724
1758
|
}
|
|
1759
|
+
const containerStyle = fieldContainerStyle(field);
|
|
1760
|
+
if (field.kind === "date") {
|
|
1761
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1762
|
+
SingleDateField,
|
|
1763
|
+
{
|
|
1764
|
+
barTestID,
|
|
1765
|
+
containerStyle,
|
|
1766
|
+
field,
|
|
1767
|
+
value: asString(raw),
|
|
1768
|
+
onChange: (v) => setField(field.key, v),
|
|
1769
|
+
onSubmit
|
|
1770
|
+
}
|
|
1771
|
+
);
|
|
1772
|
+
}
|
|
1725
1773
|
const body = (() => {
|
|
1726
1774
|
switch (field.kind) {
|
|
1727
1775
|
case "select":
|
|
@@ -1759,15 +1807,15 @@ function FilterFieldView({ field, barTestID, values, setField, onSubmit, strings
|
|
|
1759
1807
|
);
|
|
1760
1808
|
case "dateRange":
|
|
1761
1809
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1762
|
-
|
|
1810
|
+
uiForms.DateRangeControl,
|
|
1763
1811
|
{
|
|
1764
|
-
field,
|
|
1765
|
-
|
|
1812
|
+
accessibilityHint: field.accessibilityHint,
|
|
1813
|
+
fromLabel: field.fromLabel ?? strings.fromLabel,
|
|
1814
|
+
testID: field.testID ?? fieldTestID(barTestID, field.key),
|
|
1815
|
+
toLabel: field.toLabel ?? strings.toLabel,
|
|
1766
1816
|
value: asRange(raw),
|
|
1767
1817
|
onChange: (v) => setField(field.key, v),
|
|
1768
|
-
onSubmit
|
|
1769
|
-
fromLabel: strings.fromLabel,
|
|
1770
|
-
toLabel: strings.toLabel
|
|
1818
|
+
onSubmit
|
|
1771
1819
|
}
|
|
1772
1820
|
);
|
|
1773
1821
|
default:
|
|
@@ -1783,12 +1831,10 @@ function FilterFieldView({ field, barTestID, values, setField, onSubmit, strings
|
|
|
1783
1831
|
);
|
|
1784
1832
|
}
|
|
1785
1833
|
})();
|
|
1786
|
-
const minWidth = field.minWidth ?? FIELD_MIN_WIDTH[field.kind];
|
|
1787
|
-
const grow = field.grow === true ? { flexGrow: GROW_FLEX } : null;
|
|
1788
1834
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1789
1835
|
uiForms.Field,
|
|
1790
1836
|
{
|
|
1791
|
-
containerStyle
|
|
1837
|
+
containerStyle,
|
|
1792
1838
|
label: field.label,
|
|
1793
1839
|
labelVariant: "control",
|
|
1794
1840
|
testID: field.testID ?? fieldTestID(barTestID, field.key),
|
|
@@ -1938,6 +1984,14 @@ function usePagedRows(rows, options = {}) {
|
|
|
1938
1984
|
};
|
|
1939
1985
|
}
|
|
1940
1986
|
|
|
1987
|
+
// src/DataTable/rowAction.ts
|
|
1988
|
+
function declaresNoRowAction(action) {
|
|
1989
|
+
return action.rowAction !== void 0;
|
|
1990
|
+
}
|
|
1991
|
+
function pickRowAction(action) {
|
|
1992
|
+
return declaresNoRowAction(action) ? { onRowPress: action.onRowPress, rowAction: action.rowAction } : { onRowPress: action.onRowPress };
|
|
1993
|
+
}
|
|
1994
|
+
|
|
1941
1995
|
// src/StatusLedger/StatusTone.ts
|
|
1942
1996
|
var StatusTone = /* @__PURE__ */ ((StatusTone2) => {
|
|
1943
1997
|
StatusTone2["Bad"] = "bad";
|
|
@@ -2138,7 +2192,7 @@ function LedgerSection({ title, rows, columns, emptyLabel, testID, ledger }) {
|
|
|
2138
2192
|
getRowAccessibilityLabel: ledger.getRowAccessibilityLabel,
|
|
2139
2193
|
getRowDetailAccessibilityLabel: ledger.getRowAccessibilityLabel,
|
|
2140
2194
|
keyExtractor: ledger.keyExtractor,
|
|
2141
|
-
|
|
2195
|
+
...pickRowAction(ledger),
|
|
2142
2196
|
renderRowDetail: ledger.renderRowDetail,
|
|
2143
2197
|
rows,
|
|
2144
2198
|
stackBreakpoint: ledger.breakpoint ?? CARD_STACK_BREAKPOINT,
|
|
@@ -2192,7 +2246,7 @@ function StatusLedger(props) {
|
|
|
2192
2246
|
getRowDetailAccessibilityLabel: props.getRowAccessibilityLabel,
|
|
2193
2247
|
keyExtractor: props.keyExtractor,
|
|
2194
2248
|
loading,
|
|
2195
|
-
|
|
2249
|
+
...pickRowAction(props),
|
|
2196
2250
|
renderRowDetail: props.renderRowDetail,
|
|
2197
2251
|
rows: view.visible,
|
|
2198
2252
|
stackBreakpoint: feed ? breakpoint : 0,
|