@dloizides/ui-tables 1.24.0 → 1.26.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 +6 -0
- package/dist/index.d.mts +33 -1
- package/dist/index.d.ts +33 -1
- package/dist/index.js +113 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +109 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.25.0
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- `MonthStatusGrid`: one selectable status cell per period in 12, 6 or 4 columns, narrowing when a cell would drop below 44 px. INVOICE-3 "Invoice interface over a user-chosen folder".
|
|
8
|
+
|
|
3
9
|
## 1.24.0
|
|
4
10
|
|
|
5
11
|
**`StatusLedger` floors its status and actions columns, so a row's button and status pill are never clipped (JOBS-POLISH-1 "Jobs page visual fixes").**
|
package/dist/index.d.mts
CHANGED
|
@@ -927,4 +927,36 @@ declare function splitNeedsLook<T>(rows: readonly T[], needsLook: (row: T) => bo
|
|
|
927
927
|
/** Distinct non-empty values in first-seen order. */
|
|
928
928
|
declare function distinctValues<T>(rows: readonly T[], pick: (row: T) => string | undefined): string[];
|
|
929
929
|
|
|
930
|
-
|
|
930
|
+
declare const enum MonthGridColumns {
|
|
931
|
+
Twelve = 12,
|
|
932
|
+
Six = 6,
|
|
933
|
+
Four = 4
|
|
934
|
+
}
|
|
935
|
+
|
|
936
|
+
declare const MONTH_STATUS_GRID_TEST_ID = "month-status-grid";
|
|
937
|
+
/** The testID of one cell. */
|
|
938
|
+
declare function monthCellTestID(gridTestID: string, cellId: string): string;
|
|
939
|
+
interface MonthStatusCell {
|
|
940
|
+
id: string;
|
|
941
|
+
label: string;
|
|
942
|
+
icon?: React.ReactNode;
|
|
943
|
+
statusLabel?: string;
|
|
944
|
+
dashed?: boolean;
|
|
945
|
+
}
|
|
946
|
+
interface MonthStatusGridProps {
|
|
947
|
+
cells: readonly MonthStatusCell[];
|
|
948
|
+
onSelect: (id: string) => void;
|
|
949
|
+
selectedId?: string | null;
|
|
950
|
+
columns?: MonthGridColumns;
|
|
951
|
+
accessibilityLabel: string;
|
|
952
|
+
accessibilityHint?: string;
|
|
953
|
+
cellHint: string;
|
|
954
|
+
testID?: string;
|
|
955
|
+
}
|
|
956
|
+
/** One selectable status cell per period, in 12, 6 or 4 columns, narrowing when a cell would drop below 44 px. */
|
|
957
|
+
declare const MonthStatusGrid: ({ cells, onSelect, selectedId, columns, accessibilityLabel, accessibilityHint, cellHint, testID, }: MonthStatusGridProps) => React.ReactElement;
|
|
958
|
+
|
|
959
|
+
/** The widest allowed column count, up to `requested`, whose cells stay at least 44 px wide. */
|
|
960
|
+
declare function fitMonthGridColumns(requested: MonthGridColumns, width: number, gap: number): MonthGridColumns;
|
|
961
|
+
|
|
962
|
+
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, 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, 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, rowDetailTestID, rowFadeTestID, rowSelectTestID, rowTestID, selectAllTestID, sortLedgerRows, splitNeedsLook, toEpochMs, useFilterDraft, usePagedRows };
|
package/dist/index.d.ts
CHANGED
|
@@ -927,4 +927,36 @@ declare function splitNeedsLook<T>(rows: readonly T[], needsLook: (row: T) => bo
|
|
|
927
927
|
/** Distinct non-empty values in first-seen order. */
|
|
928
928
|
declare function distinctValues<T>(rows: readonly T[], pick: (row: T) => string | undefined): string[];
|
|
929
929
|
|
|
930
|
-
|
|
930
|
+
declare const enum MonthGridColumns {
|
|
931
|
+
Twelve = 12,
|
|
932
|
+
Six = 6,
|
|
933
|
+
Four = 4
|
|
934
|
+
}
|
|
935
|
+
|
|
936
|
+
declare const MONTH_STATUS_GRID_TEST_ID = "month-status-grid";
|
|
937
|
+
/** The testID of one cell. */
|
|
938
|
+
declare function monthCellTestID(gridTestID: string, cellId: string): string;
|
|
939
|
+
interface MonthStatusCell {
|
|
940
|
+
id: string;
|
|
941
|
+
label: string;
|
|
942
|
+
icon?: React.ReactNode;
|
|
943
|
+
statusLabel?: string;
|
|
944
|
+
dashed?: boolean;
|
|
945
|
+
}
|
|
946
|
+
interface MonthStatusGridProps {
|
|
947
|
+
cells: readonly MonthStatusCell[];
|
|
948
|
+
onSelect: (id: string) => void;
|
|
949
|
+
selectedId?: string | null;
|
|
950
|
+
columns?: MonthGridColumns;
|
|
951
|
+
accessibilityLabel: string;
|
|
952
|
+
accessibilityHint?: string;
|
|
953
|
+
cellHint: string;
|
|
954
|
+
testID?: string;
|
|
955
|
+
}
|
|
956
|
+
/** One selectable status cell per period, in 12, 6 or 4 columns, narrowing when a cell would drop below 44 px. */
|
|
957
|
+
declare const MonthStatusGrid: ({ cells, onSelect, selectedId, columns, accessibilityLabel, accessibilityHint, cellHint, testID, }: MonthStatusGridProps) => React.ReactElement;
|
|
958
|
+
|
|
959
|
+
/** The widest allowed column count, up to `requested`, whose cells stay at least 44 px wide. */
|
|
960
|
+
declare function fitMonthGridColumns(requested: MonthGridColumns, width: number, gap: number): MonthGridColumns;
|
|
961
|
+
|
|
962
|
+
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, 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, 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, rowDetailTestID, rowFadeTestID, rowSelectTestID, rowTestID, selectAllTestID, sortLedgerRows, splitNeedsLook, toEpochMs, useFilterDraft, usePagedRows };
|
package/dist/index.js
CHANGED
|
@@ -2162,6 +2162,114 @@ function RelativeTime({ value, nowMs, strings, hint, formatAbsolute = defaultAbs
|
|
|
2162
2162
|
);
|
|
2163
2163
|
}
|
|
2164
2164
|
|
|
2165
|
+
// src/MonthStatusGrid/MonthGridColumns.ts
|
|
2166
|
+
var MonthGridColumns = /* @__PURE__ */ ((MonthGridColumns2) => {
|
|
2167
|
+
MonthGridColumns2[MonthGridColumns2["Twelve"] = 12] = "Twelve";
|
|
2168
|
+
MonthGridColumns2[MonthGridColumns2["Six"] = 6] = "Six";
|
|
2169
|
+
MonthGridColumns2[MonthGridColumns2["Four"] = 4] = "Four";
|
|
2170
|
+
return MonthGridColumns2;
|
|
2171
|
+
})(MonthGridColumns || {});
|
|
2172
|
+
|
|
2173
|
+
// src/MonthStatusGrid/monthGridLayout.ts
|
|
2174
|
+
var COLUMN_OPTIONS = [12 /* Twelve */, 6 /* Six */, 4 /* Four */];
|
|
2175
|
+
function fitMonthGridColumns(requested, width, gap) {
|
|
2176
|
+
const fits = (columns) => (width - gap * (columns - 1)) / columns >= MIN_TARGET_PX;
|
|
2177
|
+
return COLUMN_OPTIONS.find((columns) => columns <= requested && fits(columns)) ?? 4 /* Four */;
|
|
2178
|
+
}
|
|
2179
|
+
function chunkIntoRows(cells, columns) {
|
|
2180
|
+
const rows = [];
|
|
2181
|
+
for (let start = 0; start < cells.length; start += columns) rows.push(cells.slice(start, start + columns));
|
|
2182
|
+
return rows;
|
|
2183
|
+
}
|
|
2184
|
+
var MONTH_STATUS_GRID_TEST_ID = "month-status-grid";
|
|
2185
|
+
function monthCellTestID(gridTestID, cellId) {
|
|
2186
|
+
return `${gridTestID}-cell-${cellId}`;
|
|
2187
|
+
}
|
|
2188
|
+
var GRID_GAP = 6;
|
|
2189
|
+
var CELL_MIN_HEIGHT = 56;
|
|
2190
|
+
var CELL_RADIUS = 8;
|
|
2191
|
+
var CELL_PADDING_V = 6;
|
|
2192
|
+
var CELL_INNER_GAP = 4;
|
|
2193
|
+
var LABEL_SIZE = 14;
|
|
2194
|
+
var SELECTED_BORDER = 2;
|
|
2195
|
+
var COLOR_STEP = "500";
|
|
2196
|
+
var styles5 = reactNative.StyleSheet.create({
|
|
2197
|
+
grid: { gap: GRID_GAP },
|
|
2198
|
+
row: { flexDirection: "row", gap: GRID_GAP },
|
|
2199
|
+
filler: { flex: 1 },
|
|
2200
|
+
cell: {
|
|
2201
|
+
flex: 1,
|
|
2202
|
+
minWidth: MIN_TARGET_PX,
|
|
2203
|
+
minHeight: CELL_MIN_HEIGHT,
|
|
2204
|
+
borderRadius: CELL_RADIUS,
|
|
2205
|
+
borderWidth: 1,
|
|
2206
|
+
paddingVertical: CELL_PADDING_V,
|
|
2207
|
+
alignItems: "center",
|
|
2208
|
+
justifyContent: "center",
|
|
2209
|
+
gap: CELL_INNER_GAP
|
|
2210
|
+
},
|
|
2211
|
+
dashed: { borderStyle: "dashed" },
|
|
2212
|
+
selected: { borderWidth: SELECTED_BORDER },
|
|
2213
|
+
label: { fontSize: LABEL_SIZE, fontWeight: "600", textAlign: "center" }
|
|
2214
|
+
});
|
|
2215
|
+
var GridCell = ({ cell, isSelected, onSelect, hint, testID }) => {
|
|
2216
|
+
const { theme } = uiFeedback.useUi();
|
|
2217
|
+
const { colors } = theme;
|
|
2218
|
+
const hasStatus = cell.statusLabel !== void 0 && cell.statusLabel !== "";
|
|
2219
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2220
|
+
reactNative.Pressable,
|
|
2221
|
+
{
|
|
2222
|
+
accessibilityHint: hint,
|
|
2223
|
+
accessibilityLabel: hasStatus ? `${cell.label}, ${String(cell.statusLabel)}` : cell.label,
|
|
2224
|
+
accessibilityRole: "button",
|
|
2225
|
+
"aria-pressed": isSelected,
|
|
2226
|
+
onPress: () => onSelect(cell.id),
|
|
2227
|
+
style: [
|
|
2228
|
+
styles5.cell,
|
|
2229
|
+
{ backgroundColor: isSelected ? colors.background : colors.surface, borderColor: colors.border },
|
|
2230
|
+
cell.dashed === true && styles5.dashed,
|
|
2231
|
+
isSelected && styles5.selected,
|
|
2232
|
+
isSelected && { borderColor: theme.palette.primary[COLOR_STEP] }
|
|
2233
|
+
],
|
|
2234
|
+
testID,
|
|
2235
|
+
children: [
|
|
2236
|
+
cell.icon !== void 0 && cell.icon !== null ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { "aria-hidden": true, children: cell.icon }) : null,
|
|
2237
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles5.label, { color: colors.text }], children: cell.label })
|
|
2238
|
+
]
|
|
2239
|
+
}
|
|
2240
|
+
);
|
|
2241
|
+
};
|
|
2242
|
+
var MonthStatusGrid = ({
|
|
2243
|
+
cells,
|
|
2244
|
+
onSelect,
|
|
2245
|
+
selectedId = null,
|
|
2246
|
+
columns = 12 /* Twelve */,
|
|
2247
|
+
accessibilityLabel,
|
|
2248
|
+
accessibilityHint,
|
|
2249
|
+
cellHint,
|
|
2250
|
+
testID = MONTH_STATUS_GRID_TEST_ID
|
|
2251
|
+
}) => {
|
|
2252
|
+
const { width: windowWidth } = reactNative.useWindowDimensions();
|
|
2253
|
+
const [measuredWidth, setMeasuredWidth] = React2.useState(null);
|
|
2254
|
+
const fitted = fitMonthGridColumns(columns, measuredWidth ?? windowWidth, GRID_GAP);
|
|
2255
|
+
const rows = React2.useMemo(() => chunkIntoRows(cells, fitted), [cells, fitted]);
|
|
2256
|
+
const onLayout = (event) => setMeasuredWidth(event.nativeEvent.layout.width);
|
|
2257
|
+
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { accessibilityHint, accessibilityLabel, onLayout, role: "group", style: styles5.grid, testID, children: rows.map((row) => /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles5.row, testID: `${testID}-row`, children: [
|
|
2258
|
+
row.map((cell) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2259
|
+
GridCell,
|
|
2260
|
+
{
|
|
2261
|
+
cell,
|
|
2262
|
+
hint: cellHint,
|
|
2263
|
+
isSelected: cell.id === selectedId,
|
|
2264
|
+
onSelect,
|
|
2265
|
+
testID: monthCellTestID(testID, cell.id)
|
|
2266
|
+
},
|
|
2267
|
+
cell.id
|
|
2268
|
+
)),
|
|
2269
|
+
Array.from({ length: fitted - row.length }, (_, index) => /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles5.filler }, index))
|
|
2270
|
+
] }, row[0]?.id)) });
|
|
2271
|
+
};
|
|
2272
|
+
|
|
2165
2273
|
Object.defineProperty(exports, "DEFAULT_TYPEAHEAD_MAX_SUGGESTIONS", {
|
|
2166
2274
|
enumerable: true,
|
|
2167
2275
|
get: function () { return uiForms.DEFAULT_TYPEAHEAD_MAX_SUGGESTIONS; }
|
|
@@ -2188,6 +2296,9 @@ exports.FILTERS_TEST_ID = FILTERS_TEST_ID;
|
|
|
2188
2296
|
exports.FilterBar = FilterBar;
|
|
2189
2297
|
exports.Filters = Filters;
|
|
2190
2298
|
exports.LedgerLayout = LedgerLayout;
|
|
2299
|
+
exports.MONTH_STATUS_GRID_TEST_ID = MONTH_STATUS_GRID_TEST_ID;
|
|
2300
|
+
exports.MonthGridColumns = MonthGridColumns;
|
|
2301
|
+
exports.MonthStatusGrid = MonthStatusGrid;
|
|
2191
2302
|
exports.Pager = Pager;
|
|
2192
2303
|
exports.RelativeTime = RelativeTime;
|
|
2193
2304
|
exports.STATUS_LEDGER_TEST_ID = STATUS_LEDGER_TEST_ID;
|
|
@@ -2203,10 +2314,12 @@ exports.clearTestID = clearTestID;
|
|
|
2203
2314
|
exports.distinctValues = distinctValues;
|
|
2204
2315
|
exports.fieldTestID = fieldTestID;
|
|
2205
2316
|
exports.filterLedgerRows = filterLedgerRows;
|
|
2317
|
+
exports.fitMonthGridColumns = fitMonthGridColumns;
|
|
2206
2318
|
exports.formatRelativeTime = formatRelativeTime;
|
|
2207
2319
|
exports.isAttentionTone = isAttentionTone;
|
|
2208
2320
|
exports.ledgerSectionTestID = ledgerSectionTestID;
|
|
2209
2321
|
exports.ledgerSortDirectionTestID = ledgerSortDirectionTestID;
|
|
2322
|
+
exports.monthCellTestID = monthCellTestID;
|
|
2210
2323
|
exports.rowDetailTestID = rowDetailTestID;
|
|
2211
2324
|
exports.rowFadeTestID = rowFadeTestID;
|
|
2212
2325
|
exports.rowSelectTestID = rowSelectTestID;
|