@dloizides/ui-tables 1.16.0 → 1.18.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 +30 -0
- package/dist/index.d.mts +25 -1
- package/dist/index.d.ts +25 -1
- package/dist/index.js +84 -66
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +39 -26
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -3
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { memo, useState, useMemo, useCallback, useEffect, useRef, useLayoutEffect } from 'react';
|
|
1
|
+
import React2, { memo, useState, useMemo, useCallback, useEffect, useRef, 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';
|
|
5
|
+
import { useReducedMotion, FadeIn } from '@dloizides/ui-motion';
|
|
5
6
|
import { createPortal } from 'react-dom';
|
|
6
7
|
import { Field, controlStyles, DateRangeControl, TypeaheadControl, DEFAULT_TYPEAHEAD_MIN_CHARS, DEFAULT_TYPEAHEAD_MAX_SUGGESTIONS, SelectControl } from '@dloizides/ui-forms';
|
|
7
8
|
export { DEFAULT_TYPEAHEAD_MAX_SUGGESTIONS, DEFAULT_TYPEAHEAD_MIN_CHARS, isUnmatched, suggestOptions } from '@dloizides/ui-forms';
|
|
@@ -11,6 +12,9 @@ export { DEFAULT_TYPEAHEAD_MAX_SUGGESTIONS, DEFAULT_TYPEAHEAD_MIN_CHARS, isUnmat
|
|
|
11
12
|
// src/DataTable/constants.ts
|
|
12
13
|
var CARD_STACK_BREAKPOINT = 768;
|
|
13
14
|
var DEFAULT_PAGE_SIZE_OPTIONS = [25, 50, 100, 200];
|
|
15
|
+
var ROW_ENTRANCE_STAGGER_CAP = 10;
|
|
16
|
+
var ROW_ENTRANCE_STAGGER_STEP_MS = 30;
|
|
17
|
+
var rowEntranceDelayMs = (index) => Math.min(index, ROW_ENTRANCE_STAGGER_CAP) * ROW_ENTRANCE_STAGGER_STEP_MS;
|
|
14
18
|
var TABLE_TEST_IDS = {
|
|
15
19
|
root: "ui-data-table",
|
|
16
20
|
head: "ui-data-table-head",
|
|
@@ -20,6 +24,8 @@ var TABLE_TEST_IDS = {
|
|
|
20
24
|
rowDetailInfix: "row-detail",
|
|
21
25
|
/** Infix of a row's select checkbox: `${tableTestID}-select-${key}`. */
|
|
22
26
|
rowSelectInfix: "select",
|
|
27
|
+
/** Infix of a row's entrance-fade wrapper: `${tableTestID}-fade-${key}`. */
|
|
28
|
+
rowFadeInfix: "fade",
|
|
23
29
|
/** Suffix of the header (select-all-on-page) checkbox: `${tableTestID}-select-all`. */
|
|
24
30
|
selectAllSuffix: "select-all",
|
|
25
31
|
/** Suffix of the select-all-matching banner: `${tableTestID}-select-banner`. */
|
|
@@ -39,6 +45,7 @@ var rowTestID = (tableTestID, key) => `${tableTestID}-${TABLE_TEST_IDS.rowInfix}
|
|
|
39
45
|
var rowDetailTestID = (tableTestID, key) => `${tableTestID}-${TABLE_TEST_IDS.rowDetailInfix}-${key}`;
|
|
40
46
|
var rowSelectTestID = (tableTestID, key) => `${tableTestID}-${TABLE_TEST_IDS.rowSelectInfix}-${key}`;
|
|
41
47
|
var selectAllTestID = (tableTestID) => `${tableTestID}-${TABLE_TEST_IDS.selectAllSuffix}`;
|
|
48
|
+
var rowFadeTestID = (tableTestID, key) => `${tableTestID}-${TABLE_TEST_IDS.rowFadeInfix}-${key}`;
|
|
42
49
|
var TABLE_I18N = {
|
|
43
50
|
loading: "uiTables.loading",
|
|
44
51
|
empty: "uiTables.empty",
|
|
@@ -835,10 +842,13 @@ function DataTable(props) {
|
|
|
835
842
|
allMatchingSelected,
|
|
836
843
|
onSelectAllMatchingChange,
|
|
837
844
|
keyboardNavigation = false,
|
|
845
|
+
animateRows = true,
|
|
838
846
|
stackBreakpoint = CARD_STACK_BREAKPOINT,
|
|
839
847
|
testID = TABLE_TEST_IDS.root
|
|
840
848
|
} = props;
|
|
841
849
|
const { theme, t } = useUi();
|
|
850
|
+
const reducedMotion = useReducedMotion();
|
|
851
|
+
const animateRowEntrance = animateRows && !reducedMotion;
|
|
842
852
|
const { colors } = theme;
|
|
843
853
|
const { width } = useWindowDimensions();
|
|
844
854
|
const stacked = width < stackBreakpoint;
|
|
@@ -881,28 +891,31 @@ function DataTable(props) {
|
|
|
881
891
|
if (rows.length === 0) {
|
|
882
892
|
return stateView(loading ? loadingLabel ?? t(TABLE_I18N.loading) : emptyLabel ?? t(TABLE_I18N.empty));
|
|
883
893
|
}
|
|
884
|
-
const renderRow = (row, key, style) =>
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
894
|
+
const renderRow = (row, key, index, style) => {
|
|
895
|
+
const node = /* @__PURE__ */ jsx(
|
|
896
|
+
DataTableRow,
|
|
897
|
+
{
|
|
898
|
+
columns,
|
|
899
|
+
expanded: expandedRowKeys?.includes(key) ?? false,
|
|
900
|
+
getRowAccessibilityLabel,
|
|
901
|
+
keyboardNavigation,
|
|
902
|
+
renderRowDetail,
|
|
903
|
+
roving,
|
|
904
|
+
row,
|
|
905
|
+
rowKey: key,
|
|
906
|
+
selection,
|
|
907
|
+
stacked,
|
|
908
|
+
style,
|
|
909
|
+
styleOverrides: o,
|
|
910
|
+
tableTestID: testID,
|
|
911
|
+
onHoverIn: () => setHoveredKey(key),
|
|
912
|
+
onHoverOut: () => setHoveredKey((current) => current === key ? void 0 : current),
|
|
913
|
+
onRowPress
|
|
914
|
+
}
|
|
915
|
+
);
|
|
916
|
+
if (!animateRowEntrance) return /* @__PURE__ */ jsx(React2.Fragment, { children: node }, key);
|
|
917
|
+
return /* @__PURE__ */ jsx(FadeIn, { delay: rowEntranceDelayMs(index), testID: rowFadeTestID(testID, key), children: node }, key);
|
|
918
|
+
};
|
|
906
919
|
const banner = /* @__PURE__ */ jsx(
|
|
907
920
|
SelectAllBanner,
|
|
908
921
|
{
|
|
@@ -922,7 +935,7 @@ function DataTable(props) {
|
|
|
922
935
|
rows.map((row, i) => {
|
|
923
936
|
const key = rowKeys[i] ?? keyExtractor(row);
|
|
924
937
|
const bg = rowBg(row, i, key);
|
|
925
|
-
return renderRow(row, key, [
|
|
938
|
+
return renderRow(row, key, i, [
|
|
926
939
|
tableStyles.card,
|
|
927
940
|
{ borderTopColor: colors.border },
|
|
928
941
|
i === FIRST_ROW_INDEX ? { borderTopWidth: 0 } : null,
|
|
@@ -956,7 +969,7 @@ function DataTable(props) {
|
|
|
956
969
|
rows.map((row, i) => {
|
|
957
970
|
const key = rowKeys[i] ?? keyExtractor(row);
|
|
958
971
|
const bg = rowBg(row, i, key);
|
|
959
|
-
return renderRow(row, key, [tableStyles.row, { borderTopColor: colors.border }, bg ? { backgroundColor: bg } : null, o?.row]);
|
|
972
|
+
return renderRow(row, key, i, [tableStyles.row, { borderTopColor: colors.border }, bg ? { backgroundColor: bg } : null, o?.row]);
|
|
960
973
|
})
|
|
961
974
|
]
|
|
962
975
|
}
|
|
@@ -1785,6 +1798,6 @@ function usePagedRows(rows, options = {}) {
|
|
|
1785
1798
|
};
|
|
1786
1799
|
}
|
|
1787
1800
|
|
|
1788
|
-
export { CARD_STACK_BREAKPOINT, DEFAULT_PAGE_SIZE, DEFAULT_PAGE_SIZE_OPTIONS, DataTable, FIELD_MIN_WIDTH, FILTERS_I18N, FILTERS_TEST_ID, FilterBar, Filters, Pager, StatCard, TABLE_I18N, TABLE_TEST_IDS, applyTestID, clearTestID, fieldTestID, rowDetailTestID, rowSelectTestID, rowTestID, selectAllTestID, useFilterDraft, usePagedRows };
|
|
1801
|
+
export { CARD_STACK_BREAKPOINT, DEFAULT_PAGE_SIZE, DEFAULT_PAGE_SIZE_OPTIONS, DataTable, FIELD_MIN_WIDTH, FILTERS_I18N, FILTERS_TEST_ID, FilterBar, Filters, Pager, StatCard, TABLE_I18N, TABLE_TEST_IDS, applyTestID, clearTestID, fieldTestID, rowDetailTestID, rowFadeTestID, rowSelectTestID, rowTestID, selectAllTestID, useFilterDraft, usePagedRows };
|
|
1789
1802
|
//# sourceMappingURL=index.mjs.map
|
|
1790
1803
|
//# sourceMappingURL=index.mjs.map
|