@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 CHANGED
@@ -1,5 +1,21 @@
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
+
9
+ ## 1.24.0
10
+
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").**
12
+
13
+ Every desktop cell was `flex: weight` with react-native-web's `min-width: 0`, so on a crowded row the
14
+ actions cell shrank below its button and the table wrap's `overflow: hidden` cut "Run now" in half
15
+ (63 of 100 px visible at 1024); the status pill could spill into the next cell the same way.
16
+ `DataTableColumn` gains an optional `minWidth` (px), applied to the header and body cell alike so
17
+ they stay aligned; the ledger sets 120 on status and 136 on actions. Additive.
18
+
3
19
  ## 1.23.0
4
20
 
5
21
  **A press anywhere on an interactive `DataTable` / `StatusLedger` row opens it, including on a time cell (JOBS-NOLOSS-1 "Restore everything the old Jobs page showed").**
package/dist/index.d.mts CHANGED
@@ -78,6 +78,8 @@ interface DataTableColumn<T> {
78
78
  numeric?: boolean;
79
79
  /** Flex weight on desktop. Default 1. */
80
80
  weight?: number;
81
+ /** Desktop width floor (px): the column never shrinks below it, so a button or pill in it is not clipped. */
82
+ minWidth?: number;
81
83
  render: (row: T) => React.ReactNode;
82
84
  }
83
85
  interface DataTableProps<T> {
@@ -925,4 +927,35 @@ declare function splitNeedsLook<T>(rows: readonly T[], needsLook: (row: T) => bo
925
927
  /** Distinct non-empty values in first-seen order. */
926
928
  declare function distinctValues<T>(rows: readonly T[], pick: (row: T) => string | undefined): string[];
927
929
 
928
- 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, 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, formatRelativeTime, isAttentionTone, ledgerSectionTestID, ledgerSortDirectionTestID, rowDetailTestID, rowFadeTestID, rowSelectTestID, rowTestID, selectAllTestID, sortLedgerRows, splitNeedsLook, toEpochMs, useFilterDraft, usePagedRows };
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
+ cellHint: string;
953
+ testID?: string;
954
+ }
955
+ /** One selectable status cell per period, in 12, 6 or 4 columns, narrowing when a cell would drop below 44 px. */
956
+ declare const MonthStatusGrid: ({ cells, onSelect, selectedId, columns, accessibilityLabel, cellHint, testID, }: MonthStatusGridProps) => React.ReactElement;
957
+
958
+ /** The widest allowed column count, up to `requested`, whose cells stay at least 44 px wide. */
959
+ declare function fitMonthGridColumns(requested: MonthGridColumns, width: number, gap: number): MonthGridColumns;
960
+
961
+ 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
@@ -78,6 +78,8 @@ interface DataTableColumn<T> {
78
78
  numeric?: boolean;
79
79
  /** Flex weight on desktop. Default 1. */
80
80
  weight?: number;
81
+ /** Desktop width floor (px): the column never shrinks below it, so a button or pill in it is not clipped. */
82
+ minWidth?: number;
81
83
  render: (row: T) => React.ReactNode;
82
84
  }
83
85
  interface DataTableProps<T> {
@@ -925,4 +927,35 @@ declare function splitNeedsLook<T>(rows: readonly T[], needsLook: (row: T) => bo
925
927
  /** Distinct non-empty values in first-seen order. */
926
928
  declare function distinctValues<T>(rows: readonly T[], pick: (row: T) => string | undefined): string[];
927
929
 
928
- 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, 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, formatRelativeTime, isAttentionTone, ledgerSectionTestID, ledgerSortDirectionTestID, rowDetailTestID, rowFadeTestID, rowSelectTestID, rowTestID, selectAllTestID, sortLedgerRows, splitNeedsLook, toEpochMs, useFilterDraft, usePagedRows };
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
+ cellHint: string;
953
+ testID?: string;
954
+ }
955
+ /** One selectable status cell per period, in 12, 6 or 4 columns, narrowing when a cell would drop below 44 px. */
956
+ declare const MonthStatusGrid: ({ cells, onSelect, selectedId, columns, accessibilityLabel, cellHint, testID, }: MonthStatusGridProps) => React.ReactElement;
957
+
958
+ /** The widest allowed column count, up to `requested`, whose cells stay at least 44 px wide. */
959
+ declare function fitMonthGridColumns(requested: MonthGridColumns, width: number, gap: number): MonthGridColumns;
960
+
961
+ 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
@@ -338,7 +338,7 @@ function DesktopCell({ column, row, textColor, testID, styleOverrides, inGrid })
338
338
  reactNative.View,
339
339
  {
340
340
  style: [
341
- { flex: column.weight ?? 1, alignItems: column.numeric ? "flex-end" : "flex-start" },
341
+ { flex: column.weight ?? 1, minWidth: column.minWidth, alignItems: column.numeric ? "flex-end" : "flex-start" },
342
342
  styleOverrides?.cellWrap
343
343
  ],
344
344
  testID,
@@ -640,7 +640,7 @@ function TableHeader({ columns, stickyHeader, selection, inGrid, styleOverrides:
640
640
  columns.map((col) => /* @__PURE__ */ jsxRuntime.jsx(
641
641
  reactNative.Text,
642
642
  {
643
- style: [tableStyles.headCell, { color: colors.textSecondary, flex: col.weight ?? 1, textAlign: col.numeric ? "right" : "left" }, o?.headCell],
643
+ style: [tableStyles.headCell, { color: colors.textSecondary, flex: col.weight ?? 1, minWidth: col.minWidth, textAlign: col.numeric ? "right" : "left" }, o?.headCell],
644
644
  ...inGrid ? { role: "columnheader" } : null,
645
645
  children: col.header
646
646
  },
@@ -1858,6 +1858,8 @@ var STATUS_LEDGER_TEST_ID = "ui-status-ledger";
1858
1858
  var STATUS_COLUMN_KEY = "status";
1859
1859
  var ACTIONS_COLUMN_KEY = "actions";
1860
1860
  var ALL_VALUE = "";
1861
+ var STATUS_MIN_WIDTH = 120;
1862
+ var ACTIONS_MIN_WIDTH = 136;
1861
1863
  var TONE_RANK = {
1862
1864
  ["bad" /* Bad */]: 0,
1863
1865
  ["warn" /* Warn */]: 1,
@@ -1980,10 +1982,11 @@ function useLedgerView(props) {
1980
1982
  const status = {
1981
1983
  key: STATUS_COLUMN_KEY,
1982
1984
  header: labels.status,
1985
+ minWidth: STATUS_MIN_WIDTH,
1983
1986
  sortValue: (row) => toneRank(toneOf(row)),
1984
1987
  render: (row) => /* @__PURE__ */ jsxRuntime.jsx(StatusPill, { color: toneColor(toneOf(row)), label: statusLabel(getStatus(row)), tone: toneOf(row) })
1985
1988
  };
1986
- const actions = renderActions === void 0 ? [] : [{ key: ACTIONS_COLUMN_KEY, header: labels.actions, render: renderActions }];
1989
+ const actions = renderActions === void 0 ? [] : [{ key: ACTIONS_COLUMN_KEY, header: labels.actions, minWidth: ACTIONS_MIN_WIDTH, render: renderActions }];
1987
1990
  return [columns[0], status, ...columns.slice(1), ...actions].filter((c) => c !== void 0);
1988
1991
  }, [columns, labels, toneOf, toneColor, statusLabel, getStatus, renderActions]);
1989
1992
  const fields = React2.useMemo(() => {
@@ -2159,6 +2162,113 @@ function RelativeTime({ value, nowMs, strings, hint, formatAbsolute = defaultAbs
2159
2162
  );
2160
2163
  }
2161
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
+ cellHint,
2249
+ testID = MONTH_STATUS_GRID_TEST_ID
2250
+ }) => {
2251
+ const { width: windowWidth } = reactNative.useWindowDimensions();
2252
+ const [measuredWidth, setMeasuredWidth] = React2.useState(null);
2253
+ const fitted = fitMonthGridColumns(columns, measuredWidth ?? windowWidth, GRID_GAP);
2254
+ const rows = React2.useMemo(() => chunkIntoRows(cells, fitted), [cells, fitted]);
2255
+ const onLayout = (event) => setMeasuredWidth(event.nativeEvent.layout.width);
2256
+ return /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { accessibilityLabel, onLayout, role: "group", style: styles5.grid, testID, children: rows.map((row) => /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles5.row, testID: `${testID}-row`, children: [
2257
+ row.map((cell) => /* @__PURE__ */ jsxRuntime.jsx(
2258
+ GridCell,
2259
+ {
2260
+ cell,
2261
+ hint: cellHint,
2262
+ isSelected: cell.id === selectedId,
2263
+ onSelect,
2264
+ testID: monthCellTestID(testID, cell.id)
2265
+ },
2266
+ cell.id
2267
+ )),
2268
+ Array.from({ length: fitted - row.length }, (_, index) => /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles5.filler }, index))
2269
+ ] }, row[0]?.id)) });
2270
+ };
2271
+
2162
2272
  Object.defineProperty(exports, "DEFAULT_TYPEAHEAD_MAX_SUGGESTIONS", {
2163
2273
  enumerable: true,
2164
2274
  get: function () { return uiForms.DEFAULT_TYPEAHEAD_MAX_SUGGESTIONS; }
@@ -2185,6 +2295,9 @@ exports.FILTERS_TEST_ID = FILTERS_TEST_ID;
2185
2295
  exports.FilterBar = FilterBar;
2186
2296
  exports.Filters = Filters;
2187
2297
  exports.LedgerLayout = LedgerLayout;
2298
+ exports.MONTH_STATUS_GRID_TEST_ID = MONTH_STATUS_GRID_TEST_ID;
2299
+ exports.MonthGridColumns = MonthGridColumns;
2300
+ exports.MonthStatusGrid = MonthStatusGrid;
2188
2301
  exports.Pager = Pager;
2189
2302
  exports.RelativeTime = RelativeTime;
2190
2303
  exports.STATUS_LEDGER_TEST_ID = STATUS_LEDGER_TEST_ID;
@@ -2200,10 +2313,12 @@ exports.clearTestID = clearTestID;
2200
2313
  exports.distinctValues = distinctValues;
2201
2314
  exports.fieldTestID = fieldTestID;
2202
2315
  exports.filterLedgerRows = filterLedgerRows;
2316
+ exports.fitMonthGridColumns = fitMonthGridColumns;
2203
2317
  exports.formatRelativeTime = formatRelativeTime;
2204
2318
  exports.isAttentionTone = isAttentionTone;
2205
2319
  exports.ledgerSectionTestID = ledgerSectionTestID;
2206
2320
  exports.ledgerSortDirectionTestID = ledgerSortDirectionTestID;
2321
+ exports.monthCellTestID = monthCellTestID;
2207
2322
  exports.rowDetailTestID = rowDetailTestID;
2208
2323
  exports.rowFadeTestID = rowFadeTestID;
2209
2324
  exports.rowSelectTestID = rowSelectTestID;