@dloizides/ui-tables 1.23.0 → 1.25.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 +16 -0
- package/dist/index.d.mts +34 -1
- package/dist/index.d.ts +34 -1
- package/dist/index.js +118 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +114 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -333,7 +333,7 @@ function DesktopCell({ column, row, textColor, testID, styleOverrides, inGrid })
|
|
|
333
333
|
View,
|
|
334
334
|
{
|
|
335
335
|
style: [
|
|
336
|
-
{ flex: column.weight ?? 1, alignItems: column.numeric ? "flex-end" : "flex-start" },
|
|
336
|
+
{ flex: column.weight ?? 1, minWidth: column.minWidth, alignItems: column.numeric ? "flex-end" : "flex-start" },
|
|
337
337
|
styleOverrides?.cellWrap
|
|
338
338
|
],
|
|
339
339
|
testID,
|
|
@@ -635,7 +635,7 @@ function TableHeader({ columns, stickyHeader, selection, inGrid, styleOverrides:
|
|
|
635
635
|
columns.map((col) => /* @__PURE__ */ jsx(
|
|
636
636
|
Text,
|
|
637
637
|
{
|
|
638
|
-
style: [tableStyles.headCell, { color: colors.textSecondary, flex: col.weight ?? 1, textAlign: col.numeric ? "right" : "left" }, o?.headCell],
|
|
638
|
+
style: [tableStyles.headCell, { color: colors.textSecondary, flex: col.weight ?? 1, minWidth: col.minWidth, textAlign: col.numeric ? "right" : "left" }, o?.headCell],
|
|
639
639
|
...inGrid ? { role: "columnheader" } : null,
|
|
640
640
|
children: col.header
|
|
641
641
|
},
|
|
@@ -1853,6 +1853,8 @@ var STATUS_LEDGER_TEST_ID = "ui-status-ledger";
|
|
|
1853
1853
|
var STATUS_COLUMN_KEY = "status";
|
|
1854
1854
|
var ACTIONS_COLUMN_KEY = "actions";
|
|
1855
1855
|
var ALL_VALUE = "";
|
|
1856
|
+
var STATUS_MIN_WIDTH = 120;
|
|
1857
|
+
var ACTIONS_MIN_WIDTH = 136;
|
|
1856
1858
|
var TONE_RANK = {
|
|
1857
1859
|
["bad" /* Bad */]: 0,
|
|
1858
1860
|
["warn" /* Warn */]: 1,
|
|
@@ -1975,10 +1977,11 @@ function useLedgerView(props) {
|
|
|
1975
1977
|
const status = {
|
|
1976
1978
|
key: STATUS_COLUMN_KEY,
|
|
1977
1979
|
header: labels.status,
|
|
1980
|
+
minWidth: STATUS_MIN_WIDTH,
|
|
1978
1981
|
sortValue: (row) => toneRank(toneOf(row)),
|
|
1979
1982
|
render: (row) => /* @__PURE__ */ jsx(StatusPill, { color: toneColor(toneOf(row)), label: statusLabel(getStatus(row)), tone: toneOf(row) })
|
|
1980
1983
|
};
|
|
1981
|
-
const actions = renderActions === void 0 ? [] : [{ key: ACTIONS_COLUMN_KEY, header: labels.actions, render: renderActions }];
|
|
1984
|
+
const actions = renderActions === void 0 ? [] : [{ key: ACTIONS_COLUMN_KEY, header: labels.actions, minWidth: ACTIONS_MIN_WIDTH, render: renderActions }];
|
|
1982
1985
|
return [columns[0], status, ...columns.slice(1), ...actions].filter((c) => c !== void 0);
|
|
1983
1986
|
}, [columns, labels, toneOf, toneColor, statusLabel, getStatus, renderActions]);
|
|
1984
1987
|
const fields = useMemo(() => {
|
|
@@ -2154,6 +2157,113 @@ function RelativeTime({ value, nowMs, strings, hint, formatAbsolute = defaultAbs
|
|
|
2154
2157
|
);
|
|
2155
2158
|
}
|
|
2156
2159
|
|
|
2157
|
-
|
|
2160
|
+
// src/MonthStatusGrid/MonthGridColumns.ts
|
|
2161
|
+
var MonthGridColumns = /* @__PURE__ */ ((MonthGridColumns2) => {
|
|
2162
|
+
MonthGridColumns2[MonthGridColumns2["Twelve"] = 12] = "Twelve";
|
|
2163
|
+
MonthGridColumns2[MonthGridColumns2["Six"] = 6] = "Six";
|
|
2164
|
+
MonthGridColumns2[MonthGridColumns2["Four"] = 4] = "Four";
|
|
2165
|
+
return MonthGridColumns2;
|
|
2166
|
+
})(MonthGridColumns || {});
|
|
2167
|
+
|
|
2168
|
+
// src/MonthStatusGrid/monthGridLayout.ts
|
|
2169
|
+
var COLUMN_OPTIONS = [12 /* Twelve */, 6 /* Six */, 4 /* Four */];
|
|
2170
|
+
function fitMonthGridColumns(requested, width, gap) {
|
|
2171
|
+
const fits = (columns) => (width - gap * (columns - 1)) / columns >= MIN_TARGET_PX;
|
|
2172
|
+
return COLUMN_OPTIONS.find((columns) => columns <= requested && fits(columns)) ?? 4 /* Four */;
|
|
2173
|
+
}
|
|
2174
|
+
function chunkIntoRows(cells, columns) {
|
|
2175
|
+
const rows = [];
|
|
2176
|
+
for (let start = 0; start < cells.length; start += columns) rows.push(cells.slice(start, start + columns));
|
|
2177
|
+
return rows;
|
|
2178
|
+
}
|
|
2179
|
+
var MONTH_STATUS_GRID_TEST_ID = "month-status-grid";
|
|
2180
|
+
function monthCellTestID(gridTestID, cellId) {
|
|
2181
|
+
return `${gridTestID}-cell-${cellId}`;
|
|
2182
|
+
}
|
|
2183
|
+
var GRID_GAP = 6;
|
|
2184
|
+
var CELL_MIN_HEIGHT = 56;
|
|
2185
|
+
var CELL_RADIUS = 8;
|
|
2186
|
+
var CELL_PADDING_V = 6;
|
|
2187
|
+
var CELL_INNER_GAP = 4;
|
|
2188
|
+
var LABEL_SIZE = 14;
|
|
2189
|
+
var SELECTED_BORDER = 2;
|
|
2190
|
+
var COLOR_STEP = "500";
|
|
2191
|
+
var styles5 = StyleSheet.create({
|
|
2192
|
+
grid: { gap: GRID_GAP },
|
|
2193
|
+
row: { flexDirection: "row", gap: GRID_GAP },
|
|
2194
|
+
filler: { flex: 1 },
|
|
2195
|
+
cell: {
|
|
2196
|
+
flex: 1,
|
|
2197
|
+
minWidth: MIN_TARGET_PX,
|
|
2198
|
+
minHeight: CELL_MIN_HEIGHT,
|
|
2199
|
+
borderRadius: CELL_RADIUS,
|
|
2200
|
+
borderWidth: 1,
|
|
2201
|
+
paddingVertical: CELL_PADDING_V,
|
|
2202
|
+
alignItems: "center",
|
|
2203
|
+
justifyContent: "center",
|
|
2204
|
+
gap: CELL_INNER_GAP
|
|
2205
|
+
},
|
|
2206
|
+
dashed: { borderStyle: "dashed" },
|
|
2207
|
+
selected: { borderWidth: SELECTED_BORDER },
|
|
2208
|
+
label: { fontSize: LABEL_SIZE, fontWeight: "600", textAlign: "center" }
|
|
2209
|
+
});
|
|
2210
|
+
var GridCell = ({ cell, isSelected, onSelect, hint, testID }) => {
|
|
2211
|
+
const { theme } = useUi();
|
|
2212
|
+
const { colors } = theme;
|
|
2213
|
+
const hasStatus = cell.statusLabel !== void 0 && cell.statusLabel !== "";
|
|
2214
|
+
return /* @__PURE__ */ jsxs(
|
|
2215
|
+
Pressable,
|
|
2216
|
+
{
|
|
2217
|
+
accessibilityHint: hint,
|
|
2218
|
+
accessibilityLabel: hasStatus ? `${cell.label}, ${String(cell.statusLabel)}` : cell.label,
|
|
2219
|
+
accessibilityRole: "button",
|
|
2220
|
+
"aria-pressed": isSelected,
|
|
2221
|
+
onPress: () => onSelect(cell.id),
|
|
2222
|
+
style: [
|
|
2223
|
+
styles5.cell,
|
|
2224
|
+
{ backgroundColor: isSelected ? colors.background : colors.surface, borderColor: colors.border },
|
|
2225
|
+
cell.dashed === true && styles5.dashed,
|
|
2226
|
+
isSelected && styles5.selected,
|
|
2227
|
+
isSelected && { borderColor: theme.palette.primary[COLOR_STEP] }
|
|
2228
|
+
],
|
|
2229
|
+
testID,
|
|
2230
|
+
children: [
|
|
2231
|
+
cell.icon !== void 0 && cell.icon !== null ? /* @__PURE__ */ jsx(View, { "aria-hidden": true, children: cell.icon }) : null,
|
|
2232
|
+
/* @__PURE__ */ jsx(Text, { style: [styles5.label, { color: colors.text }], children: cell.label })
|
|
2233
|
+
]
|
|
2234
|
+
}
|
|
2235
|
+
);
|
|
2236
|
+
};
|
|
2237
|
+
var MonthStatusGrid = ({
|
|
2238
|
+
cells,
|
|
2239
|
+
onSelect,
|
|
2240
|
+
selectedId = null,
|
|
2241
|
+
columns = 12 /* Twelve */,
|
|
2242
|
+
accessibilityLabel,
|
|
2243
|
+
cellHint,
|
|
2244
|
+
testID = MONTH_STATUS_GRID_TEST_ID
|
|
2245
|
+
}) => {
|
|
2246
|
+
const { width: windowWidth } = useWindowDimensions();
|
|
2247
|
+
const [measuredWidth, setMeasuredWidth] = useState(null);
|
|
2248
|
+
const fitted = fitMonthGridColumns(columns, measuredWidth ?? windowWidth, GRID_GAP);
|
|
2249
|
+
const rows = useMemo(() => chunkIntoRows(cells, fitted), [cells, fitted]);
|
|
2250
|
+
const onLayout = (event) => setMeasuredWidth(event.nativeEvent.layout.width);
|
|
2251
|
+
return /* @__PURE__ */ jsx(View, { accessibilityLabel, onLayout, role: "group", style: styles5.grid, testID, children: rows.map((row) => /* @__PURE__ */ jsxs(View, { style: styles5.row, testID: `${testID}-row`, children: [
|
|
2252
|
+
row.map((cell) => /* @__PURE__ */ jsx(
|
|
2253
|
+
GridCell,
|
|
2254
|
+
{
|
|
2255
|
+
cell,
|
|
2256
|
+
hint: cellHint,
|
|
2257
|
+
isSelected: cell.id === selectedId,
|
|
2258
|
+
onSelect,
|
|
2259
|
+
testID: monthCellTestID(testID, cell.id)
|
|
2260
|
+
},
|
|
2261
|
+
cell.id
|
|
2262
|
+
)),
|
|
2263
|
+
Array.from({ length: fitted - row.length }, (_, index) => /* @__PURE__ */ jsx(View, { style: styles5.filler }, index))
|
|
2264
|
+
] }, row[0]?.id)) });
|
|
2265
|
+
};
|
|
2266
|
+
|
|
2267
|
+
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, StatusLedger, StatusPill, StatusTone, TABLE_I18N, TABLE_TEST_IDS, applyTestID, clearTestID, distinctValues, fieldTestID, filterLedgerRows, fitMonthGridColumns, formatRelativeTime, isAttentionTone, ledgerSectionTestID, ledgerSortDirectionTestID, monthCellTestID, rowDetailTestID, rowFadeTestID, rowSelectTestID, rowTestID, selectAllTestID, sortLedgerRows, splitNeedsLook, toEpochMs, useFilterDraft, usePagedRows };
|
|
2158
2268
|
//# sourceMappingURL=index.mjs.map
|
|
2159
2269
|
//# sourceMappingURL=index.mjs.map
|