@dloizides/ui-tables 1.28.1 → 1.29.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 +16 -0
- package/dist/index.d.mts +21 -1
- package/dist/index.d.ts +21 -1
- package/dist/index.js +79 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +79 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React2, { memo, createContext, useState, useMemo, useCallback, useEffect, useRef,
|
|
1
|
+
import React2, { memo, createContext, useContext, 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';
|
|
@@ -35,6 +35,7 @@ var TABLE_TEST_IDS = {
|
|
|
35
35
|
/** Suffix of the banner's action: `${tableTestID}-select-banner-action`. */
|
|
36
36
|
selectBannerActionSuffix: "select-banner-action",
|
|
37
37
|
filterBar: "ui-filters",
|
|
38
|
+
pagedLayout: "ui-paged-table-layout",
|
|
38
39
|
results: "ui-results",
|
|
39
40
|
pager: "ui-pager",
|
|
40
41
|
pagerInfo: "ui-pager-info",
|
|
@@ -587,6 +588,32 @@ function DataTableRow({
|
|
|
587
588
|
)
|
|
588
589
|
] });
|
|
589
590
|
}
|
|
591
|
+
|
|
592
|
+
// src/DataTable/PagedTableLayoutKind.ts
|
|
593
|
+
var PagedTableLayoutKind = /* @__PURE__ */ ((PagedTableLayoutKind2) => {
|
|
594
|
+
PagedTableLayoutKind2["Toolbar"] = "toolbar";
|
|
595
|
+
PagedTableLayoutKind2["Spaced"] = "spaced";
|
|
596
|
+
PagedTableLayoutKind2["Footer"] = "footer";
|
|
597
|
+
PagedTableLayoutKind2["Panel"] = "panel";
|
|
598
|
+
return PagedTableLayoutKind2;
|
|
599
|
+
})(PagedTableLayoutKind || {});
|
|
600
|
+
|
|
601
|
+
// src/DataTable/joinedFrameContext.ts
|
|
602
|
+
var SQUARE = 0;
|
|
603
|
+
var INNER_RADIUS = BORDER_RADIUS - BORDER_WIDTH;
|
|
604
|
+
var NO_OUTER_BORDER = { borderTopWidth: 0, borderRightWidth: 0, borderBottomWidth: 0, borderLeftWidth: 0 };
|
|
605
|
+
function cornerRadii(top, bottom) {
|
|
606
|
+
return { borderTopLeftRadius: top, borderTopRightRadius: top, borderBottomLeftRadius: bottom, borderBottomRightRadius: bottom };
|
|
607
|
+
}
|
|
608
|
+
var AT_FRAME_TOP = { ...NO_OUTER_BORDER, ...cornerRadii(INNER_RADIUS, SQUARE) };
|
|
609
|
+
var AT_FRAME_BOTTOM = { ...NO_OUTER_BORDER, ...cornerRadii(SQUARE, INNER_RADIUS) };
|
|
610
|
+
var JOINED_FRAME_STYLES = {
|
|
611
|
+
["toolbar" /* Toolbar */]: { wrap: AT_FRAME_BOTTOM },
|
|
612
|
+
["spaced" /* Spaced */]: null,
|
|
613
|
+
["footer" /* Footer */]: { wrap: AT_FRAME_TOP },
|
|
614
|
+
["panel" /* Panel */]: { wrap: AT_FRAME_BOTTOM, filters: AT_FRAME_TOP }
|
|
615
|
+
};
|
|
616
|
+
var JoinedFrameContext = createContext(null);
|
|
590
617
|
function SelectAllBanner({
|
|
591
618
|
mode,
|
|
592
619
|
pageCount,
|
|
@@ -896,6 +923,7 @@ function DataTable(props) {
|
|
|
896
923
|
const { width } = useWindowDimensions();
|
|
897
924
|
const stacked = width < stackBreakpoint;
|
|
898
925
|
const frame = { backgroundColor: colors.surface, borderColor: colors.border };
|
|
926
|
+
const joined = useContext(JoinedFrameContext);
|
|
899
927
|
const interactive = onRowPress !== void 0;
|
|
900
928
|
const [hoveredKey, setHoveredKey] = useState(void 0);
|
|
901
929
|
const hoverTint = softBrandTint(theme.palette.primary["500"]) ?? colors.background;
|
|
@@ -930,7 +958,7 @@ function DataTable(props) {
|
|
|
930
958
|
[rowTint, zebra, colors.background]
|
|
931
959
|
);
|
|
932
960
|
const rowBg = (row, index, key) => interactive && hoveredKey === key ? hoverTint : rowBackground(row, index);
|
|
933
|
-
const stateView = (label) => /* @__PURE__ */ jsx(View, { style: [tableStyles.wrap, frame, o?.wrap], testID, children: /* @__PURE__ */ jsx(View, { style: [tableStyles.state, o?.state], children: /* @__PURE__ */ jsx(Text, { style: [tableStyles.stateText, { color: colors.textSecondary }, o?.stateText], children: label }) }) });
|
|
961
|
+
const stateView = (label) => /* @__PURE__ */ jsx(View, { style: [tableStyles.wrap, frame, joined?.wrap, o?.wrap], testID, children: /* @__PURE__ */ jsx(View, { style: [tableStyles.state, o?.state], children: /* @__PURE__ */ jsx(Text, { style: [tableStyles.stateText, { color: colors.textSecondary }, o?.stateText], children: label }) }) });
|
|
934
962
|
if (rows.length === 0) {
|
|
935
963
|
return stateView(loading ? loadingLabel ?? t(TABLE_I18N.loading) : emptyLabel ?? t(TABLE_I18N.empty));
|
|
936
964
|
}
|
|
@@ -957,8 +985,9 @@ function DataTable(props) {
|
|
|
957
985
|
onRowPress
|
|
958
986
|
}
|
|
959
987
|
);
|
|
960
|
-
|
|
961
|
-
return /* @__PURE__ */ jsx(
|
|
988
|
+
const detachedFromFrame = /* @__PURE__ */ jsx(JoinedFrameContext.Provider, { value: null, children: node });
|
|
989
|
+
if (!animateRowEntrance) return /* @__PURE__ */ jsx(React2.Fragment, { children: detachedFromFrame }, key);
|
|
990
|
+
return /* @__PURE__ */ jsx(FadeIn, { delay: rowEntranceDelayMs(index), testID: rowFadeTestID(testID, key), children: detachedFromFrame }, key);
|
|
962
991
|
};
|
|
963
992
|
const banner = /* @__PURE__ */ jsx(
|
|
964
993
|
SelectAllBanner,
|
|
@@ -973,7 +1002,7 @@ function DataTable(props) {
|
|
|
973
1002
|
}
|
|
974
1003
|
);
|
|
975
1004
|
if (stacked) {
|
|
976
|
-
return /* @__PURE__ */ jsxs(View, { style: [tableStyles.wrap, frame, o?.wrap], testID, "aria-busy": loading, children: [
|
|
1005
|
+
return /* @__PURE__ */ jsxs(View, { style: [tableStyles.wrap, frame, joined?.wrap, o?.wrap], testID, "aria-busy": loading, children: [
|
|
977
1006
|
banner,
|
|
978
1007
|
/* @__PURE__ */ jsx(View, { style: tableStyles.headSentinel, testID: TABLE_TEST_IDS.head, "aria-hidden": true }),
|
|
979
1008
|
rows.map((row, i) => {
|
|
@@ -994,7 +1023,7 @@ function DataTable(props) {
|
|
|
994
1023
|
return /* @__PURE__ */ jsxs(
|
|
995
1024
|
View,
|
|
996
1025
|
{
|
|
997
|
-
style: [tableStyles.wrap, frame, o?.wrap],
|
|
1026
|
+
style: [tableStyles.wrap, frame, joined?.wrap, o?.wrap],
|
|
998
1027
|
testID,
|
|
999
1028
|
"aria-busy": loading,
|
|
1000
1029
|
...keyboardNavigation ? { role: "grid" } : null,
|
|
@@ -1030,8 +1059,9 @@ function FilterBar({
|
|
|
1030
1059
|
}) {
|
|
1031
1060
|
const { theme, t } = useUi();
|
|
1032
1061
|
const { colors } = theme;
|
|
1062
|
+
const joined = useContext(JoinedFrameContext);
|
|
1033
1063
|
const word = resultsLabel ?? t(TABLE_I18N.results);
|
|
1034
|
-
return /* @__PURE__ */ jsxs(View, { style: [chromeStyles.filters, { backgroundColor: colors.surface, borderColor: colors.border }, o?.filters], testID, children: [
|
|
1064
|
+
return /* @__PURE__ */ jsxs(View, { style: [chromeStyles.filters, { backgroundColor: colors.surface, borderColor: colors.border }, joined?.filters, o?.filters], testID, children: [
|
|
1035
1065
|
children,
|
|
1036
1066
|
/* @__PURE__ */ jsx(View, { style: [chromeStyles.filtersSpacer, o?.filtersSpacer] }),
|
|
1037
1067
|
typeof resultsCount === "number" && // Live region: announce the new count when filters change the result set (WCAG 4.1.3).
|
|
@@ -1423,6 +1453,47 @@ function Pager({
|
|
|
1423
1453
|
)
|
|
1424
1454
|
] });
|
|
1425
1455
|
}
|
|
1456
|
+
var LAYOUT_GAP = 12;
|
|
1457
|
+
var PAGER_SLOT_PAD_V = 8;
|
|
1458
|
+
var PAGER_IN_FRAME = { paddingHorizontal: ROW_PAD_H, paddingVertical: PAGER_SLOT_PAD_V };
|
|
1459
|
+
var FRAME = { borderWidth: BORDER_WIDTH, borderRadius: BORDER_RADIUS };
|
|
1460
|
+
var SLOT_STYLES = {
|
|
1461
|
+
["toolbar" /* Toolbar */]: { filters: { marginBottom: LAYOUT_GAP }, pager: { ...PAGER_IN_FRAME, borderBottomWidth: BORDER_WIDTH } },
|
|
1462
|
+
["spaced" /* Spaced */]: { filters: {}, pager: { marginTop: LAYOUT_GAP, marginBottom: LAYOUT_GAP } },
|
|
1463
|
+
["footer" /* Footer */]: { filters: { marginBottom: LAYOUT_GAP }, pager: { ...PAGER_IN_FRAME, borderTopWidth: BORDER_WIDTH } },
|
|
1464
|
+
["panel" /* Panel */]: { filters: { borderBottomWidth: BORDER_WIDTH }, pager: { ...PAGER_IN_FRAME, borderBottomWidth: BORDER_WIDTH } }
|
|
1465
|
+
};
|
|
1466
|
+
function PagedTableLayout({
|
|
1467
|
+
filters,
|
|
1468
|
+
pager,
|
|
1469
|
+
table,
|
|
1470
|
+
layout = "toolbar" /* Toolbar */,
|
|
1471
|
+
testID = TABLE_TEST_IDS.pagedLayout
|
|
1472
|
+
}) {
|
|
1473
|
+
const { colors } = useUi().theme;
|
|
1474
|
+
const slots = SLOT_STYLES[layout];
|
|
1475
|
+
const line = { borderColor: colors.border };
|
|
1476
|
+
const hasFilters = filters !== void 0 && filters !== null && filters !== false;
|
|
1477
|
+
const filtersInFrame = layout === "panel" /* Panel */;
|
|
1478
|
+
const isJoined = layout !== "spaced" /* Spaced */;
|
|
1479
|
+
const filtersSlot = hasFilters ? /* @__PURE__ */ jsx(View, { style: [slots.filters, line], testID: `${testID}-filters`, children: filters }) : null;
|
|
1480
|
+
const pagerSlot = /* @__PURE__ */ jsx(View, { style: [slots.pager, line], testID: `${testID}-pager`, children: pager });
|
|
1481
|
+
const tableSlot = /* @__PURE__ */ jsx(View, { testID: `${testID}-table`, children: table });
|
|
1482
|
+
const pagerAndTable = layout === "footer" /* Footer */ ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1483
|
+
tableSlot,
|
|
1484
|
+
pagerSlot
|
|
1485
|
+
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1486
|
+
pagerSlot,
|
|
1487
|
+
tableSlot
|
|
1488
|
+
] });
|
|
1489
|
+
return /* @__PURE__ */ jsx(JoinedFrameContext.Provider, { value: JOINED_FRAME_STYLES[layout], children: /* @__PURE__ */ jsxs(View, { testID, children: [
|
|
1490
|
+
filtersInFrame ? null : filtersSlot,
|
|
1491
|
+
isJoined ? /* @__PURE__ */ jsxs(View, { style: [FRAME, line, { backgroundColor: colors.surface }], testID: `${testID}-frame`, children: [
|
|
1492
|
+
filtersInFrame ? filtersSlot : null,
|
|
1493
|
+
pagerAndTable
|
|
1494
|
+
] }) : pagerAndTable
|
|
1495
|
+
] }) });
|
|
1496
|
+
}
|
|
1426
1497
|
var FIELD_GAP = 4;
|
|
1427
1498
|
var SWITCH_ROW_GAP = 8;
|
|
1428
1499
|
var ACTION_PAD_H = 14;
|
|
@@ -2289,6 +2360,6 @@ var MonthStatusGrid = ({
|
|
|
2289
2360
|
] }, row[0]?.id)) });
|
|
2290
2361
|
};
|
|
2291
2362
|
|
|
2292
|
-
export { CARD_STACK_BREAKPOINT, DEFAULT_PAGE_SIZE, DEFAULT_PAGE_SIZE_OPTIONS, DataTable, FIELD_MIN_WIDTH, FILTERS_I18N, FILTERS_TEST_ID, FilterBar, Filters, LedgerLayout, MONTH_STATUS_GRID_TEST_ID, MonthGridColumns, MonthStatusGrid, Pager, RelativeTime, STATUS_LEDGER_TEST_ID, SortDirection, StatCard, StatTone, StatusLedger, StatusPill, StatusTone, TABLE_I18N, TABLE_TEST_IDS, applyTestID, clearTestID, distinctValues, fieldTestID, filterLedgerRows, fitMonthGridColumns, formatRelativeTime, isAttentionTone, ledgerSectionTestID, ledgerSortDirectionTestID, monthCellTestID, resolveStatToneColor, rowDetailTestID, rowFadeTestID, rowSelectTestID, rowTestID, selectAllTestID, sortLedgerRows, splitNeedsLook, toEpochMs, useFilterDraft, usePagedRows };
|
|
2363
|
+
export { CARD_STACK_BREAKPOINT, DEFAULT_PAGE_SIZE, DEFAULT_PAGE_SIZE_OPTIONS, DataTable, FIELD_MIN_WIDTH, FILTERS_I18N, FILTERS_TEST_ID, FilterBar, Filters, LedgerLayout, MONTH_STATUS_GRID_TEST_ID, MonthGridColumns, MonthStatusGrid, PagedTableLayout, PagedTableLayoutKind, Pager, RelativeTime, STATUS_LEDGER_TEST_ID, SortDirection, StatCard, StatTone, StatusLedger, StatusPill, StatusTone, TABLE_I18N, TABLE_TEST_IDS, applyTestID, clearTestID, distinctValues, fieldTestID, filterLedgerRows, fitMonthGridColumns, formatRelativeTime, isAttentionTone, ledgerSectionTestID, ledgerSortDirectionTestID, monthCellTestID, resolveStatToneColor, rowDetailTestID, rowFadeTestID, rowSelectTestID, rowTestID, selectAllTestID, sortLedgerRows, splitNeedsLook, toEpochMs, useFilterDraft, usePagedRows };
|
|
2293
2364
|
//# sourceMappingURL=index.mjs.map
|
|
2294
2365
|
//# sourceMappingURL=index.mjs.map
|