@dloizides/ui-tables 1.16.0 → 1.18.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/CHANGELOG.md +30 -0
- package/dist/index.d.mts +25 -1
- package/dist/index.d.ts +25 -1
- package/dist/index.js +89 -67
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +44 -27
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.18.0
|
|
4
|
+
|
|
5
|
+
**`DataTable` rows now fade in on load — the Ant-design-like list entrance — via `@dloizides/ui-motion`.**
|
|
6
|
+
|
|
7
|
+
When a `DataTable` mounts its rows (first load, and whenever the row set changes — sort / filter /
|
|
8
|
+
page), each row now fades in with a small upward translate, staggered across the first few rows. It
|
|
9
|
+
is a subtle polish layer, gated hard so it never becomes jank on a large page, and **entirely
|
|
10
|
+
opt-outable** — omit nothing and the table behaves exactly as before minus the fade.
|
|
11
|
+
|
|
12
|
+
### What changed
|
|
13
|
+
|
|
14
|
+
| Area | Detail |
|
|
15
|
+
|---|---|
|
|
16
|
+
| **New optional prop** | `animateRows?: boolean` (default **`true`**). Each row (and its expanded detail panel, if any) is wrapped in `@dloizides/ui-motion`'s `<FadeIn>`, keyed by the row key. |
|
|
17
|
+
| **Capped stagger** | Only the first `ROW_ENTRANCE_STAGGER_CAP` (10) rows stagger, `ROW_ENTRANCE_STAGGER_STEP_MS` (30 ms) apart; every row past the cap shares the capped delay. A 100- or 5,000-row page settles in a fixed ~300 ms, **never** row-by-row. |
|
|
18
|
+
| **Reduced-motion** | Honoured: rows render instantly, with **no wrapper node and no delay** (`FadeIn` gates too, but the wrapper is skipped entirely so the reduced-motion DOM is identical to the un-animated table). |
|
|
19
|
+
| **No re-fade on re-render** | Each row's `<FadeIn>` is keyed by its row key, so React keeps its identity across unrelated re-renders (hover, a re-fetch that resolves to the SAME keys) — the entrance plays once per key, not on every render. A genuine row-set change (new keys) re-fades, as intended. |
|
|
20
|
+
| **New test id** | `rowFadeTestID(tableTestID, key)` → `${tableTestID}-fade-${key}` (present only while animating), exported alongside the other row test-id helpers. |
|
|
21
|
+
|
|
22
|
+
### Backward compatibility
|
|
23
|
+
|
|
24
|
+
- **MINOR, additive.** The public API gains one optional prop and one test-id helper; nothing is
|
|
25
|
+
renamed or removed.
|
|
26
|
+
- All existing behaviour is preserved: zebra, sticky header, mobile card-stack, row/per-cell/head/
|
|
27
|
+
detail-panel/select-checkbox test ids, `onRowPress`, bulk-select, keyboard navigation, the pager,
|
|
28
|
+
and the refetch-does-not-blank-the-grid guard.
|
|
29
|
+
- Pass `animateRows={false}` (or run under `prefers-reduced-motion`) and rows render with no
|
|
30
|
+
wrapper node — DOM identical to before this release.
|
|
31
|
+
- New peer of the kit: `@dloizides/ui-motion` (`^1.0.1`) is added as a dependency.
|
|
32
|
+
|
|
3
33
|
## 1.16.0
|
|
4
34
|
|
|
5
35
|
**The responsive card-stack now reads as a proper mobile layout — and keeps every E2E hook.**
|
package/dist/index.d.mts
CHANGED
|
@@ -161,6 +161,22 @@ interface DataTableProps<T> {
|
|
|
161
161
|
* Web-only in effect (focus movement and key events are DOM concerns); inert on native.
|
|
162
162
|
*/
|
|
163
163
|
keyboardNavigation?: boolean;
|
|
164
|
+
/**
|
|
165
|
+
* Fade each row in (with a small upward translate) as the row SET mounts — the
|
|
166
|
+
* Ant-design-like list entrance, via `@dloizides/ui-motion`'s `<FadeIn>`. The first
|
|
167
|
+
* few rows stagger; every row past the cap shares one capped delay, so a full page
|
|
168
|
+
* never animates row-by-row (see `ROW_ENTRANCE_STAGGER_CAP`).
|
|
169
|
+
*
|
|
170
|
+
* The entrance plays when a row's key first appears — i.e. on first load and whenever
|
|
171
|
+
* the row set changes (sort / filter / page) — and **NOT** on unrelated re-renders
|
|
172
|
+
* (hover, a re-fetch that resolves to the same keys), because each row's `<FadeIn>` is
|
|
173
|
+
* keyed by its row key and so keeps its identity across those renders.
|
|
174
|
+
*
|
|
175
|
+
* Honours reduced-motion: the rows render instantly, with no wrapper and no delay.
|
|
176
|
+
* Default **on**; pass `animateRows={false}` to opt out — rows then render exactly as
|
|
177
|
+
* they did before this prop existed (no wrapper node, unchanged DOM).
|
|
178
|
+
*/
|
|
179
|
+
animateRows?: boolean;
|
|
164
180
|
loading?: boolean;
|
|
165
181
|
/** Loading text (already translated). Falls back to the kit's `loading` translation. */
|
|
166
182
|
loadingLabel?: string;
|
|
@@ -387,6 +403,8 @@ declare const TABLE_TEST_IDS: {
|
|
|
387
403
|
readonly rowDetailInfix: "row-detail";
|
|
388
404
|
/** Infix of a row's select checkbox: `${tableTestID}-select-${key}`. */
|
|
389
405
|
readonly rowSelectInfix: "select";
|
|
406
|
+
/** Infix of a row's entrance-fade wrapper: `${tableTestID}-fade-${key}`. */
|
|
407
|
+
readonly rowFadeInfix: "fade";
|
|
390
408
|
/** Suffix of the header (select-all-on-page) checkbox: `${tableTestID}-select-all`. */
|
|
391
409
|
readonly selectAllSuffix: "select-all";
|
|
392
410
|
/** Suffix of the select-all-matching banner: `${tableTestID}-select-banner`. */
|
|
@@ -418,6 +436,12 @@ declare const rowDetailTestID: (tableTestID: string, key: string) => string;
|
|
|
418
436
|
declare const rowSelectTestID: (tableTestID: string, key: string) => string;
|
|
419
437
|
/** The test id of the header (select-all-on-page) checkbox: `${tableTestID}-select-all`. */
|
|
420
438
|
declare const selectAllTestID: (tableTestID: string) => string;
|
|
439
|
+
/**
|
|
440
|
+
* The test id of a row's entrance-fade wrapper: `${tableTestID}-fade-${key}` (key from
|
|
441
|
+
* `keyExtractor`). Only present while `animateRows` is on and reduced-motion is off.
|
|
442
|
+
* Exported so consumers/e2e can target (or assert the absence of) the animation wrapper.
|
|
443
|
+
*/
|
|
444
|
+
declare const rowFadeTestID: (tableTestID: string, key: string) => string;
|
|
421
445
|
/**
|
|
422
446
|
* Translation keys for every component-authored, user-facing string. Apps map
|
|
423
447
|
* these in their UiProvider `t` (FM); the neutral default `t` returns the key, so
|
|
@@ -759,4 +783,4 @@ interface PagedRows<T> {
|
|
|
759
783
|
*/
|
|
760
784
|
declare function usePagedRows<T>(rows: readonly T[], options?: UsePagedRowsOptions): PagedRows<T>;
|
|
761
785
|
|
|
762
|
-
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 NumberFilterField, type PagedRows, Pager, type PagerProps, type PagerStyleOverrides, type RenderSelectArgs, type SelectFilterField, StatCard, type StatCardProps, TABLE_I18N, TABLE_TEST_IDS, type TextFilterField, type TypeaheadFilterField, type UseFilterDraftOptions, type UsePagedRowsOptions, applyTestID, clearTestID, fieldTestID, rowDetailTestID, rowSelectTestID, rowTestID, selectAllTestID, useFilterDraft, usePagedRows };
|
|
786
|
+
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 NumberFilterField, type PagedRows, Pager, type PagerProps, type PagerStyleOverrides, type RenderSelectArgs, type SelectFilterField, StatCard, type StatCardProps, TABLE_I18N, TABLE_TEST_IDS, type TextFilterField, type TypeaheadFilterField, type UseFilterDraftOptions, type UsePagedRowsOptions, applyTestID, clearTestID, fieldTestID, rowDetailTestID, rowFadeTestID, rowSelectTestID, rowTestID, selectAllTestID, useFilterDraft, usePagedRows };
|
package/dist/index.d.ts
CHANGED
|
@@ -161,6 +161,22 @@ interface DataTableProps<T> {
|
|
|
161
161
|
* Web-only in effect (focus movement and key events are DOM concerns); inert on native.
|
|
162
162
|
*/
|
|
163
163
|
keyboardNavigation?: boolean;
|
|
164
|
+
/**
|
|
165
|
+
* Fade each row in (with a small upward translate) as the row SET mounts — the
|
|
166
|
+
* Ant-design-like list entrance, via `@dloizides/ui-motion`'s `<FadeIn>`. The first
|
|
167
|
+
* few rows stagger; every row past the cap shares one capped delay, so a full page
|
|
168
|
+
* never animates row-by-row (see `ROW_ENTRANCE_STAGGER_CAP`).
|
|
169
|
+
*
|
|
170
|
+
* The entrance plays when a row's key first appears — i.e. on first load and whenever
|
|
171
|
+
* the row set changes (sort / filter / page) — and **NOT** on unrelated re-renders
|
|
172
|
+
* (hover, a re-fetch that resolves to the same keys), because each row's `<FadeIn>` is
|
|
173
|
+
* keyed by its row key and so keeps its identity across those renders.
|
|
174
|
+
*
|
|
175
|
+
* Honours reduced-motion: the rows render instantly, with no wrapper and no delay.
|
|
176
|
+
* Default **on**; pass `animateRows={false}` to opt out — rows then render exactly as
|
|
177
|
+
* they did before this prop existed (no wrapper node, unchanged DOM).
|
|
178
|
+
*/
|
|
179
|
+
animateRows?: boolean;
|
|
164
180
|
loading?: boolean;
|
|
165
181
|
/** Loading text (already translated). Falls back to the kit's `loading` translation. */
|
|
166
182
|
loadingLabel?: string;
|
|
@@ -387,6 +403,8 @@ declare const TABLE_TEST_IDS: {
|
|
|
387
403
|
readonly rowDetailInfix: "row-detail";
|
|
388
404
|
/** Infix of a row's select checkbox: `${tableTestID}-select-${key}`. */
|
|
389
405
|
readonly rowSelectInfix: "select";
|
|
406
|
+
/** Infix of a row's entrance-fade wrapper: `${tableTestID}-fade-${key}`. */
|
|
407
|
+
readonly rowFadeInfix: "fade";
|
|
390
408
|
/** Suffix of the header (select-all-on-page) checkbox: `${tableTestID}-select-all`. */
|
|
391
409
|
readonly selectAllSuffix: "select-all";
|
|
392
410
|
/** Suffix of the select-all-matching banner: `${tableTestID}-select-banner`. */
|
|
@@ -418,6 +436,12 @@ declare const rowDetailTestID: (tableTestID: string, key: string) => string;
|
|
|
418
436
|
declare const rowSelectTestID: (tableTestID: string, key: string) => string;
|
|
419
437
|
/** The test id of the header (select-all-on-page) checkbox: `${tableTestID}-select-all`. */
|
|
420
438
|
declare const selectAllTestID: (tableTestID: string) => string;
|
|
439
|
+
/**
|
|
440
|
+
* The test id of a row's entrance-fade wrapper: `${tableTestID}-fade-${key}` (key from
|
|
441
|
+
* `keyExtractor`). Only present while `animateRows` is on and reduced-motion is off.
|
|
442
|
+
* Exported so consumers/e2e can target (or assert the absence of) the animation wrapper.
|
|
443
|
+
*/
|
|
444
|
+
declare const rowFadeTestID: (tableTestID: string, key: string) => string;
|
|
421
445
|
/**
|
|
422
446
|
* Translation keys for every component-authored, user-facing string. Apps map
|
|
423
447
|
* these in their UiProvider `t` (FM); the neutral default `t` returns the key, so
|
|
@@ -759,4 +783,4 @@ interface PagedRows<T> {
|
|
|
759
783
|
*/
|
|
760
784
|
declare function usePagedRows<T>(rows: readonly T[], options?: UsePagedRowsOptions): PagedRows<T>;
|
|
761
785
|
|
|
762
|
-
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 NumberFilterField, type PagedRows, Pager, type PagerProps, type PagerStyleOverrides, type RenderSelectArgs, type SelectFilterField, StatCard, type StatCardProps, TABLE_I18N, TABLE_TEST_IDS, type TextFilterField, type TypeaheadFilterField, type UseFilterDraftOptions, type UsePagedRowsOptions, applyTestID, clearTestID, fieldTestID, rowDetailTestID, rowSelectTestID, rowTestID, selectAllTestID, useFilterDraft, usePagedRows };
|
|
786
|
+
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 NumberFilterField, type PagedRows, Pager, type PagerProps, type PagerStyleOverrides, type RenderSelectArgs, type SelectFilterField, StatCard, type StatCardProps, TABLE_I18N, TABLE_TEST_IDS, type TextFilterField, type TypeaheadFilterField, type UseFilterDraftOptions, type UsePagedRowsOptions, applyTestID, clearTestID, fieldTestID, rowDetailTestID, rowFadeTestID, rowSelectTestID, rowTestID, selectAllTestID, useFilterDraft, usePagedRows };
|
package/dist/index.js
CHANGED
|
@@ -1,17 +1,25 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var React2 = require('react');
|
|
4
4
|
var reactNative = require('react-native');
|
|
5
5
|
var uiFeedback = require('@dloizides/ui-feedback');
|
|
6
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
7
|
+
var uiMotion = require('@dloizides/ui-motion');
|
|
7
8
|
var reactDom = require('react-dom');
|
|
8
9
|
var uiForms = require('@dloizides/ui-forms');
|
|
9
10
|
|
|
11
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
+
|
|
13
|
+
var React2__default = /*#__PURE__*/_interopDefault(React2);
|
|
14
|
+
|
|
10
15
|
// src/StatCard/StatCard.tsx
|
|
11
16
|
|
|
12
17
|
// src/DataTable/constants.ts
|
|
13
18
|
var CARD_STACK_BREAKPOINT = 768;
|
|
14
19
|
var DEFAULT_PAGE_SIZE_OPTIONS = [25, 50, 100, 200];
|
|
20
|
+
var ROW_ENTRANCE_STAGGER_CAP = 10;
|
|
21
|
+
var ROW_ENTRANCE_STAGGER_STEP_MS = 30;
|
|
22
|
+
var rowEntranceDelayMs = (index) => Math.min(index, ROW_ENTRANCE_STAGGER_CAP) * ROW_ENTRANCE_STAGGER_STEP_MS;
|
|
15
23
|
var TABLE_TEST_IDS = {
|
|
16
24
|
root: "ui-data-table",
|
|
17
25
|
head: "ui-data-table-head",
|
|
@@ -21,6 +29,8 @@ var TABLE_TEST_IDS = {
|
|
|
21
29
|
rowDetailInfix: "row-detail",
|
|
22
30
|
/** Infix of a row's select checkbox: `${tableTestID}-select-${key}`. */
|
|
23
31
|
rowSelectInfix: "select",
|
|
32
|
+
/** Infix of a row's entrance-fade wrapper: `${tableTestID}-fade-${key}`. */
|
|
33
|
+
rowFadeInfix: "fade",
|
|
24
34
|
/** Suffix of the header (select-all-on-page) checkbox: `${tableTestID}-select-all`. */
|
|
25
35
|
selectAllSuffix: "select-all",
|
|
26
36
|
/** Suffix of the select-all-matching banner: `${tableTestID}-select-banner`. */
|
|
@@ -40,6 +50,7 @@ var rowTestID = (tableTestID, key) => `${tableTestID}-${TABLE_TEST_IDS.rowInfix}
|
|
|
40
50
|
var rowDetailTestID = (tableTestID, key) => `${tableTestID}-${TABLE_TEST_IDS.rowDetailInfix}-${key}`;
|
|
41
51
|
var rowSelectTestID = (tableTestID, key) => `${tableTestID}-${TABLE_TEST_IDS.rowSelectInfix}-${key}`;
|
|
42
52
|
var selectAllTestID = (tableTestID) => `${tableTestID}-${TABLE_TEST_IDS.selectAllSuffix}`;
|
|
53
|
+
var rowFadeTestID = (tableTestID, key) => `${tableTestID}-${TABLE_TEST_IDS.rowFadeInfix}-${key}`;
|
|
43
54
|
var TABLE_I18N = {
|
|
44
55
|
loading: "uiTables.loading",
|
|
45
56
|
empty: "uiTables.empty",
|
|
@@ -120,7 +131,7 @@ var styles = reactNative.StyleSheet.create({
|
|
|
120
131
|
lineHeight: VALUE_LINE_HEIGHT
|
|
121
132
|
}
|
|
122
133
|
});
|
|
123
|
-
var StatCard =
|
|
134
|
+
var StatCard = React2.memo(({ label, value, testID }) => {
|
|
124
135
|
const { theme, t } = uiFeedback.useUi();
|
|
125
136
|
const { colors } = theme;
|
|
126
137
|
const formattedValue = value.toLocaleString();
|
|
@@ -670,21 +681,21 @@ var TAB_INDEX_ACTIVE = 0;
|
|
|
670
681
|
var TAB_INDEX_INACTIVE2 = -1;
|
|
671
682
|
var IS_WEB = reactNative.Platform.OS === "web";
|
|
672
683
|
function useRovingFocus({ rowKeys, enabled, onToggleKey, onActivateKey }) {
|
|
673
|
-
const [focusedKey, setFocusedKey] =
|
|
674
|
-
const nodes =
|
|
684
|
+
const [focusedKey, setFocusedKey] = React2.useState(void 0);
|
|
685
|
+
const nodes = React2.useRef(/* @__PURE__ */ new Map());
|
|
675
686
|
const tabbableKey = enabled ? resolveTabbableKey(rowKeys, focusedKey) : void 0;
|
|
676
|
-
const registerRow =
|
|
687
|
+
const registerRow = React2.useCallback((key, node) => {
|
|
677
688
|
if (node === null || node === void 0) {
|
|
678
689
|
nodes.current.delete(key);
|
|
679
690
|
return;
|
|
680
691
|
}
|
|
681
692
|
nodes.current.set(key, node);
|
|
682
693
|
}, []);
|
|
683
|
-
const focusRow =
|
|
694
|
+
const focusRow = React2.useCallback((key) => {
|
|
684
695
|
setFocusedKey(key);
|
|
685
696
|
nodes.current.get(key)?.focus?.();
|
|
686
697
|
}, []);
|
|
687
|
-
const handleKey =
|
|
698
|
+
const handleKey = React2.useCallback(
|
|
688
699
|
(event, key) => {
|
|
689
700
|
const action = toRowNavAction(event.key);
|
|
690
701
|
if (action === void 0) return;
|
|
@@ -709,18 +720,18 @@ function useRovingFocus({ rowKeys, enabled, onToggleKey, onActivateKey }) {
|
|
|
709
720
|
},
|
|
710
721
|
[rowKeys, onToggleKey, onActivateKey, focusRow]
|
|
711
722
|
);
|
|
712
|
-
const keyDownFor =
|
|
723
|
+
const keyDownFor = React2.useCallback(
|
|
713
724
|
(key) => {
|
|
714
725
|
if (!enabled || !IS_WEB) return void 0;
|
|
715
726
|
return (event) => handleKey(event, key);
|
|
716
727
|
},
|
|
717
728
|
[enabled, handleKey]
|
|
718
729
|
);
|
|
719
|
-
const tabIndexFor =
|
|
730
|
+
const tabIndexFor = React2.useCallback(
|
|
720
731
|
(key) => key === tabbableKey ? TAB_INDEX_ACTIVE : TAB_INDEX_INACTIVE2,
|
|
721
732
|
[tabbableKey]
|
|
722
733
|
);
|
|
723
|
-
const onRowFocus =
|
|
734
|
+
const onRowFocus = React2.useCallback((key) => setFocusedKey(key), []);
|
|
724
735
|
return { tabIndexFor, registerRow, onRowFocus, keyDownFor };
|
|
725
736
|
}
|
|
726
737
|
|
|
@@ -772,20 +783,20 @@ function useTableSelection({
|
|
|
772
783
|
const selected = selectedRowKeys ?? NO_KEYS;
|
|
773
784
|
const allMatching = allMatchingSelected ?? false;
|
|
774
785
|
const matching = matchingCount ?? NO_MATCHES;
|
|
775
|
-
const pageHeaderState =
|
|
786
|
+
const pageHeaderState = React2.useMemo(
|
|
776
787
|
() => resolveHeaderCheckboxState(selected, pageKeys),
|
|
777
788
|
[selected, pageKeys]
|
|
778
789
|
);
|
|
779
790
|
const headerState = allMatching ? "all" /* All */ : pageHeaderState;
|
|
780
|
-
const bannerMode =
|
|
791
|
+
const bannerMode = React2.useMemo(
|
|
781
792
|
() => onSelectAllMatchingChange === void 0 ? "hidden" /* Hidden */ : resolveSelectAllBannerMode(pageHeaderState, allMatching, pageKeys.length, matching),
|
|
782
793
|
[onSelectAllMatchingChange, pageHeaderState, allMatching, pageKeys.length, matching]
|
|
783
794
|
);
|
|
784
|
-
const isSelected =
|
|
795
|
+
const isSelected = React2.useCallback(
|
|
785
796
|
(key) => isRowSelected(selected, key, allMatching),
|
|
786
797
|
[selected, allMatching]
|
|
787
798
|
);
|
|
788
|
-
const toggleRow =
|
|
799
|
+
const toggleRow = React2.useCallback(
|
|
789
800
|
(key) => {
|
|
790
801
|
if (allMatching) {
|
|
791
802
|
onSelectAllMatchingChange?.(false);
|
|
@@ -796,7 +807,7 @@ function useTableSelection({
|
|
|
796
807
|
},
|
|
797
808
|
[allMatching, onSelectAllMatchingChange, onSelectionChange, pageKeys, selected]
|
|
798
809
|
);
|
|
799
|
-
const toggleAll =
|
|
810
|
+
const toggleAll = React2.useCallback(() => {
|
|
800
811
|
if (allMatching) {
|
|
801
812
|
onSelectAllMatchingChange?.(false);
|
|
802
813
|
onSelectionChange?.(NO_KEYS);
|
|
@@ -804,7 +815,7 @@ function useTableSelection({
|
|
|
804
815
|
}
|
|
805
816
|
onSelectionChange?.(toggleAllOnPage(selected, pageKeys));
|
|
806
817
|
}, [allMatching, onSelectAllMatchingChange, onSelectionChange, selected, pageKeys]);
|
|
807
|
-
const toggleAllMatching =
|
|
818
|
+
const toggleAllMatching = React2.useCallback(() => {
|
|
808
819
|
const next = !allMatching;
|
|
809
820
|
onSelectAllMatchingChange?.(next);
|
|
810
821
|
if (!next) onSelectionChange?.(NO_KEYS);
|
|
@@ -836,18 +847,21 @@ function DataTable(props) {
|
|
|
836
847
|
allMatchingSelected,
|
|
837
848
|
onSelectAllMatchingChange,
|
|
838
849
|
keyboardNavigation = false,
|
|
850
|
+
animateRows = true,
|
|
839
851
|
stackBreakpoint = CARD_STACK_BREAKPOINT,
|
|
840
852
|
testID = TABLE_TEST_IDS.root
|
|
841
853
|
} = props;
|
|
842
854
|
const { theme, t } = uiFeedback.useUi();
|
|
855
|
+
const reducedMotion = uiMotion.useReducedMotion();
|
|
856
|
+
const animateRowEntrance = animateRows && !reducedMotion;
|
|
843
857
|
const { colors } = theme;
|
|
844
858
|
const { width } = reactNative.useWindowDimensions();
|
|
845
859
|
const stacked = width < stackBreakpoint;
|
|
846
860
|
const frame = { backgroundColor: colors.surface, borderColor: colors.border };
|
|
847
861
|
const interactive = onRowPress !== void 0;
|
|
848
|
-
const [hoveredKey, setHoveredKey] =
|
|
862
|
+
const [hoveredKey, setHoveredKey] = React2.useState(void 0);
|
|
849
863
|
const hoverTint = softBrandTint(theme.palette.primary["500"]) ?? colors.background;
|
|
850
|
-
const rowKeys =
|
|
864
|
+
const rowKeys = React2.useMemo(() => rows.map(keyExtractor), [rows, keyExtractor]);
|
|
851
865
|
const selection = useTableSelection({
|
|
852
866
|
pageKeys: rowKeys,
|
|
853
867
|
selectedRowKeys,
|
|
@@ -856,7 +870,7 @@ function DataTable(props) {
|
|
|
856
870
|
allMatchingSelected,
|
|
857
871
|
onSelectAllMatchingChange
|
|
858
872
|
});
|
|
859
|
-
const activateKey =
|
|
873
|
+
const activateKey = React2.useCallback(
|
|
860
874
|
(key) => {
|
|
861
875
|
const row = rows[rowKeys.indexOf(key)];
|
|
862
876
|
if (row !== void 0) onRowPress?.(row);
|
|
@@ -869,7 +883,7 @@ function DataTable(props) {
|
|
|
869
883
|
onToggleKey: selection.selectable ? selection.toggleRow : void 0,
|
|
870
884
|
onActivateKey: interactive ? activateKey : void 0
|
|
871
885
|
});
|
|
872
|
-
const rowBackground =
|
|
886
|
+
const rowBackground = React2.useCallback(
|
|
873
887
|
(row, index) => {
|
|
874
888
|
const tint = rowTint?.(row);
|
|
875
889
|
if (tint) return tint;
|
|
@@ -882,28 +896,31 @@ function DataTable(props) {
|
|
|
882
896
|
if (rows.length === 0) {
|
|
883
897
|
return stateView(loading ? loadingLabel ?? t(TABLE_I18N.loading) : emptyLabel ?? t(TABLE_I18N.empty));
|
|
884
898
|
}
|
|
885
|
-
const renderRow = (row, key, style) =>
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
899
|
+
const renderRow = (row, key, index, style) => {
|
|
900
|
+
const node = /* @__PURE__ */ jsxRuntime.jsx(
|
|
901
|
+
DataTableRow,
|
|
902
|
+
{
|
|
903
|
+
columns,
|
|
904
|
+
expanded: expandedRowKeys?.includes(key) ?? false,
|
|
905
|
+
getRowAccessibilityLabel,
|
|
906
|
+
keyboardNavigation,
|
|
907
|
+
renderRowDetail,
|
|
908
|
+
roving,
|
|
909
|
+
row,
|
|
910
|
+
rowKey: key,
|
|
911
|
+
selection,
|
|
912
|
+
stacked,
|
|
913
|
+
style,
|
|
914
|
+
styleOverrides: o,
|
|
915
|
+
tableTestID: testID,
|
|
916
|
+
onHoverIn: () => setHoveredKey(key),
|
|
917
|
+
onHoverOut: () => setHoveredKey((current) => current === key ? void 0 : current),
|
|
918
|
+
onRowPress
|
|
919
|
+
}
|
|
920
|
+
);
|
|
921
|
+
if (!animateRowEntrance) return /* @__PURE__ */ jsxRuntime.jsx(React2__default.default.Fragment, { children: node }, key);
|
|
922
|
+
return /* @__PURE__ */ jsxRuntime.jsx(uiMotion.FadeIn, { delay: rowEntranceDelayMs(index), testID: rowFadeTestID(testID, key), children: node }, key);
|
|
923
|
+
};
|
|
907
924
|
const banner = /* @__PURE__ */ jsxRuntime.jsx(
|
|
908
925
|
SelectAllBanner,
|
|
909
926
|
{
|
|
@@ -923,7 +940,7 @@ function DataTable(props) {
|
|
|
923
940
|
rows.map((row, i) => {
|
|
924
941
|
const key = rowKeys[i] ?? keyExtractor(row);
|
|
925
942
|
const bg = rowBg(row, i, key);
|
|
926
|
-
return renderRow(row, key, [
|
|
943
|
+
return renderRow(row, key, i, [
|
|
927
944
|
tableStyles.card,
|
|
928
945
|
{ borderTopColor: colors.border },
|
|
929
946
|
i === FIRST_ROW_INDEX ? { borderTopWidth: 0 } : null,
|
|
@@ -957,7 +974,7 @@ function DataTable(props) {
|
|
|
957
974
|
rows.map((row, i) => {
|
|
958
975
|
const key = rowKeys[i] ?? keyExtractor(row);
|
|
959
976
|
const bg = rowBg(row, i, key);
|
|
960
|
-
return renderRow(row, key, [tableStyles.row, { borderTopColor: colors.border }, bg ? { backgroundColor: bg } : null, o?.row]);
|
|
977
|
+
return renderRow(row, key, i, [tableStyles.row, { borderTopColor: colors.border }, bg ? { backgroundColor: bg } : null, o?.row]);
|
|
961
978
|
})
|
|
962
979
|
]
|
|
963
980
|
}
|
|
@@ -1023,8 +1040,8 @@ function buildWebFixedStyle(rect, viewportWidth) {
|
|
|
1023
1040
|
};
|
|
1024
1041
|
}
|
|
1025
1042
|
function useTriggerRect(anchorRef, isOpen) {
|
|
1026
|
-
const [rect, setRect] =
|
|
1027
|
-
|
|
1043
|
+
const [rect, setRect] = React2.useState(null);
|
|
1044
|
+
React2.useLayoutEffect(() => {
|
|
1028
1045
|
if (!IS_WEB2 || !isOpen) return void 0;
|
|
1029
1046
|
const measure = () => {
|
|
1030
1047
|
setRect(readTriggerRect(anchorRef));
|
|
@@ -1040,7 +1057,7 @@ function useTriggerRect(anchorRef, isOpen) {
|
|
|
1040
1057
|
return rect;
|
|
1041
1058
|
}
|
|
1042
1059
|
function useDismissOnOutside(anchorRef, menuRef, isOpen, onClose) {
|
|
1043
|
-
|
|
1060
|
+
React2.useEffect(() => {
|
|
1044
1061
|
if (!IS_WEB2 || !isOpen) return void 0;
|
|
1045
1062
|
const onMouseDown = (event) => {
|
|
1046
1063
|
const anchorNode = anchorRef.current;
|
|
@@ -1078,16 +1095,16 @@ function SizeDropdown({
|
|
|
1078
1095
|
triggerStyle,
|
|
1079
1096
|
triggerTextStyle
|
|
1080
1097
|
}) {
|
|
1081
|
-
const anchorRef =
|
|
1082
|
-
const menuRef =
|
|
1083
|
-
const [isOpen, setIsOpen] =
|
|
1084
|
-
const close =
|
|
1098
|
+
const anchorRef = React2.useRef(null);
|
|
1099
|
+
const menuRef = React2.useRef(null);
|
|
1100
|
+
const [isOpen, setIsOpen] = React2.useState(false);
|
|
1101
|
+
const close = React2.useCallback(() => {
|
|
1085
1102
|
setIsOpen(false);
|
|
1086
1103
|
}, []);
|
|
1087
|
-
const toggle =
|
|
1104
|
+
const toggle = React2.useCallback(() => {
|
|
1088
1105
|
setIsOpen((prev) => !prev);
|
|
1089
1106
|
}, []);
|
|
1090
|
-
const select =
|
|
1107
|
+
const select = React2.useCallback(
|
|
1091
1108
|
(size) => {
|
|
1092
1109
|
onPageSizeChange(size);
|
|
1093
1110
|
setIsOpen(false);
|
|
@@ -1553,6 +1570,10 @@ function TypeaheadField({ field, barTestID, value, onChange, onSubmit, optionHin
|
|
|
1553
1570
|
}
|
|
1554
1571
|
);
|
|
1555
1572
|
}
|
|
1573
|
+
function clampedMinWidth(minWidth) {
|
|
1574
|
+
if (reactNative.Platform.OS !== "web") return minWidth;
|
|
1575
|
+
return `min(${minWidth}px, 100%)`;
|
|
1576
|
+
}
|
|
1556
1577
|
var EMPTY_RANGE = { from: "", to: "" };
|
|
1557
1578
|
var GROW_FLEX = 1;
|
|
1558
1579
|
function asString(value) {
|
|
@@ -1636,7 +1657,7 @@ function FilterFieldView({ field, barTestID, values, setField, onSubmit, strings
|
|
|
1636
1657
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1637
1658
|
uiForms.Field,
|
|
1638
1659
|
{
|
|
1639
|
-
containerStyle: [filterStyles.fieldInBar, { minWidth }, grow, field.style],
|
|
1660
|
+
containerStyle: [filterStyles.fieldInBar, { minWidth: clampedMinWidth(minWidth), maxWidth: "100%" }, grow, field.style],
|
|
1640
1661
|
label: field.label,
|
|
1641
1662
|
labelVariant: "control",
|
|
1642
1663
|
testID: field.testID ?? fieldTestID(barTestID, field.key),
|
|
@@ -1666,16 +1687,16 @@ function Filters({
|
|
|
1666
1687
|
testID = FILTERS_TEST_ID
|
|
1667
1688
|
}) {
|
|
1668
1689
|
const { t } = uiFeedback.useUi();
|
|
1669
|
-
const setField =
|
|
1690
|
+
const setField = React2.useCallback(
|
|
1670
1691
|
(key, value) => {
|
|
1671
1692
|
onChange({ ...values, [key]: value });
|
|
1672
1693
|
},
|
|
1673
1694
|
[onChange, values]
|
|
1674
1695
|
);
|
|
1675
|
-
const onSubmit =
|
|
1696
|
+
const onSubmit = React2.useCallback(() => {
|
|
1676
1697
|
if (onApply !== void 0 && !applyDisabled) onApply();
|
|
1677
1698
|
}, [onApply, applyDisabled]);
|
|
1678
|
-
const strings =
|
|
1699
|
+
const strings = React2.useMemo(
|
|
1679
1700
|
() => ({
|
|
1680
1701
|
selectPlaceholder: selectPlaceholder ?? t(FILTERS_I18N.selectPlaceholder),
|
|
1681
1702
|
dropdownHint: t(FILTERS_I18N.dropdownHint),
|
|
@@ -1738,37 +1759,37 @@ function shallowEqual(a, b) {
|
|
|
1738
1759
|
return JSON.stringify(a) === JSON.stringify(b);
|
|
1739
1760
|
}
|
|
1740
1761
|
function useFilterDraft({ initial, onApply, onReset }) {
|
|
1741
|
-
const [draft, setDraft] =
|
|
1742
|
-
const [committed, setCommitted] =
|
|
1743
|
-
const setField =
|
|
1762
|
+
const [draft, setDraft] = React2.useState(initial);
|
|
1763
|
+
const [committed, setCommitted] = React2.useState(initial);
|
|
1764
|
+
const setField = React2.useCallback((key, value) => {
|
|
1744
1765
|
setDraft((prev) => ({ ...prev, [key]: value }));
|
|
1745
1766
|
}, []);
|
|
1746
|
-
const apply =
|
|
1767
|
+
const apply = React2.useCallback(() => {
|
|
1747
1768
|
setCommitted(draft);
|
|
1748
1769
|
onApply?.(draft);
|
|
1749
1770
|
}, [draft, onApply]);
|
|
1750
|
-
const reset =
|
|
1771
|
+
const reset = React2.useCallback(() => {
|
|
1751
1772
|
setDraft(initial);
|
|
1752
1773
|
setCommitted(initial);
|
|
1753
1774
|
onReset?.();
|
|
1754
1775
|
}, [initial, onReset]);
|
|
1755
|
-
const dirty =
|
|
1776
|
+
const dirty = React2.useMemo(() => !shallowEqual(draft, committed), [draft, committed]);
|
|
1756
1777
|
return { draft, committed, setField, setDraft, apply, reset, dirty };
|
|
1757
1778
|
}
|
|
1758
1779
|
var DEFAULT_PAGE_SIZE = 10;
|
|
1759
1780
|
function usePagedRows(rows, options = {}) {
|
|
1760
1781
|
const pageSize = Math.max(1, options.pageSize ?? DEFAULT_PAGE_SIZE);
|
|
1761
|
-
const [currentPage, setCurrentPage] =
|
|
1782
|
+
const [currentPage, setCurrentPage] = React2.useState(0);
|
|
1762
1783
|
const totalPages = Math.ceil(rows.length / pageSize);
|
|
1763
|
-
|
|
1784
|
+
React2.useEffect(() => {
|
|
1764
1785
|
const lastValidPage = totalPages > 0 ? totalPages - 1 : 0;
|
|
1765
1786
|
if (currentPage > lastValidPage) setCurrentPage(lastValidPage);
|
|
1766
1787
|
}, [currentPage, totalPages]);
|
|
1767
|
-
const pageRows =
|
|
1788
|
+
const pageRows = React2.useMemo(() => {
|
|
1768
1789
|
const start = currentPage * pageSize;
|
|
1769
1790
|
return rows.slice(start, start + pageSize);
|
|
1770
1791
|
}, [rows, currentPage, pageSize]);
|
|
1771
|
-
const setPage =
|
|
1792
|
+
const setPage = React2.useCallback(
|
|
1772
1793
|
(page) => {
|
|
1773
1794
|
const lastValidPage = totalPages > 0 ? totalPages - 1 : 0;
|
|
1774
1795
|
const clamped = Math.min(Math.max(0, page), lastValidPage);
|
|
@@ -1819,6 +1840,7 @@ exports.applyTestID = applyTestID;
|
|
|
1819
1840
|
exports.clearTestID = clearTestID;
|
|
1820
1841
|
exports.fieldTestID = fieldTestID;
|
|
1821
1842
|
exports.rowDetailTestID = rowDetailTestID;
|
|
1843
|
+
exports.rowFadeTestID = rowFadeTestID;
|
|
1822
1844
|
exports.rowSelectTestID = rowSelectTestID;
|
|
1823
1845
|
exports.rowTestID = rowTestID;
|
|
1824
1846
|
exports.selectAllTestID = selectAllTestID;
|