@dloizides/ui-tables 3.2.0 → 3.4.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 +1 -0
- package/dist/index.d.mts +95 -1
- package/dist/index.d.ts +95 -1
- package/dist/index.js +268 -83
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +254 -84
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -2048,6 +2048,70 @@ var TONE_GLYPH = {
|
|
|
2048
2048
|
};
|
|
2049
2049
|
var ledgerSectionTestID = (testID, section) => `${testID}-section-${section}`;
|
|
2050
2050
|
var ledgerSortDirectionTestID = (testID) => `${testID}-sort-direction`;
|
|
2051
|
+
|
|
2052
|
+
// src/StatusLedger/SortDirection.ts
|
|
2053
|
+
var SortDirection = /* @__PURE__ */ ((SortDirection2) => {
|
|
2054
|
+
SortDirection2["Asc"] = "asc";
|
|
2055
|
+
SortDirection2["Desc"] = "desc";
|
|
2056
|
+
return SortDirection2;
|
|
2057
|
+
})(SortDirection || {});
|
|
2058
|
+
function LedgerFilterBar({ view, labels, resultsCount, testID }) {
|
|
2059
|
+
const ascending = view.direction === "asc" /* Asc */;
|
|
2060
|
+
return /* @__PURE__ */ jsx(
|
|
2061
|
+
Filters,
|
|
2062
|
+
{
|
|
2063
|
+
actions: /* @__PURE__ */ jsx(
|
|
2064
|
+
ActionButton,
|
|
2065
|
+
{
|
|
2066
|
+
hint: labels.sortDirectionHint,
|
|
2067
|
+
label: ascending ? labels.sortAscending : labels.sortDescending,
|
|
2068
|
+
onPress: view.toggleDirection,
|
|
2069
|
+
testID: ledgerSortDirectionTestID(testID),
|
|
2070
|
+
tone: "ghost"
|
|
2071
|
+
}
|
|
2072
|
+
),
|
|
2073
|
+
clearHint: labels.clearHint,
|
|
2074
|
+
clearLabel: labels.clear,
|
|
2075
|
+
fields: view.fields,
|
|
2076
|
+
onChange: view.setValues,
|
|
2077
|
+
onClear: view.clear,
|
|
2078
|
+
resultsCount,
|
|
2079
|
+
resultsLabel: labels.results,
|
|
2080
|
+
testID: `${testID}-filters`,
|
|
2081
|
+
values: view.values
|
|
2082
|
+
}
|
|
2083
|
+
);
|
|
2084
|
+
}
|
|
2085
|
+
var GAP = 12;
|
|
2086
|
+
var HEADING_FONT = 15;
|
|
2087
|
+
var HEADING_WEIGHT = "700";
|
|
2088
|
+
var styles2 = StyleSheet.create({
|
|
2089
|
+
root: { gap: GAP },
|
|
2090
|
+
heading: { fontSize: HEADING_FONT, fontWeight: HEADING_WEIGHT },
|
|
2091
|
+
note: { paddingVertical: GAP }
|
|
2092
|
+
});
|
|
2093
|
+
var expandedKeys = (key) => key === null || key === void 0 ? void 0 : [key];
|
|
2094
|
+
function LedgerSection({ title, rows, columns, emptyLabel, testID, ledger, heading }) {
|
|
2095
|
+
const { theme } = useUi();
|
|
2096
|
+
return /* @__PURE__ */ jsxs(View, { style: styles2.root, testID, children: [
|
|
2097
|
+
heading ?? /* @__PURE__ */ jsx(Text, { accessibilityRole: "header", style: [styles2.heading, { color: theme.colors.text }], children: `${title} \xB7 ${rows.length}` }),
|
|
2098
|
+
rows.length === 0 ? /* @__PURE__ */ jsx(Text, { style: [styles2.note, { color: theme.colors.textSecondary }], children: emptyLabel }) : /* @__PURE__ */ jsx(
|
|
2099
|
+
DataTable,
|
|
2100
|
+
{
|
|
2101
|
+
columns,
|
|
2102
|
+
expandedRowKeys: expandedKeys(ledger.expandedRowKey),
|
|
2103
|
+
getRowAccessibilityLabel: ledger.getRowAccessibilityLabel,
|
|
2104
|
+
getRowDetailAccessibilityLabel: ledger.getRowAccessibilityLabel,
|
|
2105
|
+
keyExtractor: ledger.keyExtractor,
|
|
2106
|
+
...pickRowAction(ledger),
|
|
2107
|
+
renderRowDetail: ledger.renderRowDetail,
|
|
2108
|
+
rows,
|
|
2109
|
+
stackBreakpoint: ledger.breakpoint ?? CARD_STACK_BREAKPOINT,
|
|
2110
|
+
testID: `${testID}-table`
|
|
2111
|
+
}
|
|
2112
|
+
)
|
|
2113
|
+
] });
|
|
2114
|
+
}
|
|
2051
2115
|
var PILL_RADIUS2 = 999;
|
|
2052
2116
|
var PILL_BORDER = 1;
|
|
2053
2117
|
var PILL_PAD_H = 8;
|
|
@@ -2055,7 +2119,7 @@ var PILL_PAD_V = 2;
|
|
|
2055
2119
|
var PILL_GAP = 6;
|
|
2056
2120
|
var PILL_FONT = 13;
|
|
2057
2121
|
var PILL_WEIGHT = "600";
|
|
2058
|
-
var
|
|
2122
|
+
var styles3 = StyleSheet.create({
|
|
2059
2123
|
pill: {
|
|
2060
2124
|
flexDirection: "row",
|
|
2061
2125
|
alignItems: "center",
|
|
@@ -2069,19 +2133,12 @@ var styles2 = StyleSheet.create({
|
|
|
2069
2133
|
text: { fontSize: PILL_FONT, fontWeight: PILL_WEIGHT }
|
|
2070
2134
|
});
|
|
2071
2135
|
function StatusPill({ label, tone, color, testID }) {
|
|
2072
|
-
return /* @__PURE__ */ jsxs(View, { accessibilityLabel: label, accessibilityRole: "text", style: [
|
|
2073
|
-
/* @__PURE__ */ jsx(Text, { "aria-hidden": true, style: [
|
|
2074
|
-
/* @__PURE__ */ jsx(Text, { style: [
|
|
2136
|
+
return /* @__PURE__ */ jsxs(View, { accessibilityLabel: label, accessibilityRole: "text", style: [styles3.pill, { borderColor: color }], testID, children: [
|
|
2137
|
+
/* @__PURE__ */ jsx(Text, { "aria-hidden": true, style: [styles3.text, { color }], children: TONE_GLYPH[tone] }),
|
|
2138
|
+
/* @__PURE__ */ jsx(Text, { style: [styles3.text, { color }], children: label })
|
|
2075
2139
|
] });
|
|
2076
2140
|
}
|
|
2077
2141
|
|
|
2078
|
-
// src/StatusLedger/SortDirection.ts
|
|
2079
|
-
var SortDirection = /* @__PURE__ */ ((SortDirection2) => {
|
|
2080
|
-
SortDirection2["Asc"] = "asc";
|
|
2081
|
-
SortDirection2["Desc"] = "desc";
|
|
2082
|
-
return SortDirection2;
|
|
2083
|
-
})(SortDirection || {});
|
|
2084
|
-
|
|
2085
2142
|
// src/StatusLedger/utils/ledgerLogic.ts
|
|
2086
2143
|
var BEFORE = -1;
|
|
2087
2144
|
var AFTER = 1;
|
|
@@ -2194,68 +2251,17 @@ var LedgerLayout = /* @__PURE__ */ ((LedgerLayout2) => {
|
|
|
2194
2251
|
LedgerLayout2["Feed"] = "feed";
|
|
2195
2252
|
return LedgerLayout2;
|
|
2196
2253
|
})(LedgerLayout || {});
|
|
2197
|
-
var
|
|
2198
|
-
var
|
|
2199
|
-
|
|
2200
|
-
var expandedKeys = (key) => key === null || key === void 0 ? void 0 : [key];
|
|
2201
|
-
var styles3 = StyleSheet.create({
|
|
2202
|
-
root: { gap: GAP },
|
|
2203
|
-
heading: { fontSize: HEADING_FONT, fontWeight: HEADING_WEIGHT },
|
|
2204
|
-
note: { paddingVertical: GAP }
|
|
2254
|
+
var GAP2 = 12;
|
|
2255
|
+
var styles4 = StyleSheet.create({
|
|
2256
|
+
root: { gap: GAP2 }
|
|
2205
2257
|
});
|
|
2206
|
-
function LedgerSection({ title, rows, columns, emptyLabel, testID, ledger }) {
|
|
2207
|
-
const { theme } = useUi();
|
|
2208
|
-
return /* @__PURE__ */ jsxs(View, { style: styles3.root, testID, children: [
|
|
2209
|
-
/* @__PURE__ */ jsx(Text, { accessibilityRole: "header", style: [styles3.heading, { color: theme.colors.text }], children: `${title} \xB7 ${rows.length}` }),
|
|
2210
|
-
rows.length === 0 ? /* @__PURE__ */ jsx(Text, { style: [styles3.note, { color: theme.colors.textSecondary }], children: emptyLabel }) : /* @__PURE__ */ jsx(
|
|
2211
|
-
DataTable,
|
|
2212
|
-
{
|
|
2213
|
-
columns,
|
|
2214
|
-
expandedRowKeys: expandedKeys(ledger.expandedRowKey),
|
|
2215
|
-
getRowAccessibilityLabel: ledger.getRowAccessibilityLabel,
|
|
2216
|
-
getRowDetailAccessibilityLabel: ledger.getRowAccessibilityLabel,
|
|
2217
|
-
keyExtractor: ledger.keyExtractor,
|
|
2218
|
-
...pickRowAction(ledger),
|
|
2219
|
-
renderRowDetail: ledger.renderRowDetail,
|
|
2220
|
-
rows,
|
|
2221
|
-
stackBreakpoint: ledger.breakpoint ?? CARD_STACK_BREAKPOINT,
|
|
2222
|
-
testID: `${testID}-table`
|
|
2223
|
-
}
|
|
2224
|
-
)
|
|
2225
|
-
] });
|
|
2226
|
-
}
|
|
2227
2258
|
function StatusLedger(props) {
|
|
2228
2259
|
const { labels, layout = "auto" /* Auto */, breakpoint = CARD_STACK_BREAKPOINT, loading, testID = STATUS_LEDGER_TEST_ID } = props;
|
|
2229
2260
|
const { width } = useWindowDimensions();
|
|
2230
2261
|
const view = useLedgerView(props);
|
|
2231
2262
|
const feed = layout === "feed" /* Feed */ || layout === "auto" /* Auto */ && width < breakpoint;
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
ActionButton,
|
|
2235
|
-
{
|
|
2236
|
-
hint: labels.sortDirectionHint,
|
|
2237
|
-
label: ascending ? labels.sortAscending : labels.sortDescending,
|
|
2238
|
-
onPress: view.toggleDirection,
|
|
2239
|
-
testID: ledgerSortDirectionTestID(testID),
|
|
2240
|
-
tone: "ghost"
|
|
2241
|
-
}
|
|
2242
|
-
);
|
|
2243
|
-
return /* @__PURE__ */ jsxs(View, { style: styles3.root, testID, children: [
|
|
2244
|
-
/* @__PURE__ */ jsx(
|
|
2245
|
-
Filters,
|
|
2246
|
-
{
|
|
2247
|
-
actions: directionButton,
|
|
2248
|
-
clearHint: labels.clearHint,
|
|
2249
|
-
clearLabel: labels.clear,
|
|
2250
|
-
fields: view.fields,
|
|
2251
|
-
onChange: view.setValues,
|
|
2252
|
-
onClear: view.clear,
|
|
2253
|
-
resultsCount: view.visible.length,
|
|
2254
|
-
resultsLabel: labels.results,
|
|
2255
|
-
testID: `${testID}-filters`,
|
|
2256
|
-
values: view.values
|
|
2257
|
-
}
|
|
2258
|
-
),
|
|
2263
|
+
return /* @__PURE__ */ jsxs(View, { style: styles4.root, testID, children: [
|
|
2264
|
+
/* @__PURE__ */ jsx(LedgerFilterBar, { labels, resultsCount: view.visible.length, testID, view }),
|
|
2259
2265
|
feed && !loading ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2260
2266
|
/* @__PURE__ */ jsx(LedgerSection, { columns: view.tableColumns, emptyLabel: labels.allClear, ledger: props, rows: view.split.attention, testID: ledgerSectionTestID(testID, "attention"), title: labels.needsLook }),
|
|
2261
2267
|
/* @__PURE__ */ jsx(LedgerSection, { columns: view.tableColumns, emptyLabel: labels.empty, ledger: props, rows: view.split.rest, testID: ledgerSectionTestID(testID, "rest"), title: labels.everythingElse })
|
|
@@ -2305,7 +2311,7 @@ function formatRelativeTime(value, nowMs, strings) {
|
|
|
2305
2311
|
if (distance < MS_PER_DAY) return fill(units.hours, Math.floor(distance / MS_PER_HOUR));
|
|
2306
2312
|
return fill(units.days, Math.floor(distance / MS_PER_DAY));
|
|
2307
2313
|
}
|
|
2308
|
-
var
|
|
2314
|
+
var styles5 = StyleSheet.create({
|
|
2309
2315
|
target: { minHeight: MIN_TARGET_PX, minWidth: MIN_TARGET_PX, justifyContent: "center" }
|
|
2310
2316
|
});
|
|
2311
2317
|
var defaultAbsolute = (ms) => new Date(ms).toLocaleString();
|
|
@@ -2327,13 +2333,175 @@ function RelativeTime({ value, nowMs, strings, hint, formatAbsolute = defaultAbs
|
|
|
2327
2333
|
setShowAbsolute((current) => !current);
|
|
2328
2334
|
pressRow?.();
|
|
2329
2335
|
},
|
|
2330
|
-
style:
|
|
2336
|
+
style: styles5.target,
|
|
2331
2337
|
testID,
|
|
2332
2338
|
children: /* @__PURE__ */ jsx(Text, { style: { color: theme.colors.text }, children: showAbsolute ? absolute : relative })
|
|
2333
2339
|
}
|
|
2334
2340
|
);
|
|
2335
2341
|
}
|
|
2336
2342
|
|
|
2343
|
+
// src/StatusLedger/DurationUnit.ts
|
|
2344
|
+
var DurationUnit = /* @__PURE__ */ ((DurationUnit2) => {
|
|
2345
|
+
DurationUnit2["Minute"] = "minute";
|
|
2346
|
+
DurationUnit2["Hour"] = "hour";
|
|
2347
|
+
DurationUnit2["Day"] = "day";
|
|
2348
|
+
return DurationUnit2;
|
|
2349
|
+
})(DurationUnit || {});
|
|
2350
|
+
|
|
2351
|
+
// src/StatusLedger/utils/duration.ts
|
|
2352
|
+
var MS_PER_SECOND2 = 1e3;
|
|
2353
|
+
var SECONDS_PER_MINUTE2 = 60;
|
|
2354
|
+
var MINUTES_PER_HOUR2 = 60;
|
|
2355
|
+
var HOURS_PER_DAY2 = 24;
|
|
2356
|
+
var MS_PER_MINUTE2 = MS_PER_SECOND2 * SECONDS_PER_MINUTE2;
|
|
2357
|
+
var MS_PER_HOUR2 = MS_PER_MINUTE2 * MINUTES_PER_HOUR2;
|
|
2358
|
+
var MS_PER_DAY2 = MS_PER_HOUR2 * HOURS_PER_DAY2;
|
|
2359
|
+
var TOKEN = /\{\{(\w+)\}\}/g;
|
|
2360
|
+
function fillTemplate(template, values) {
|
|
2361
|
+
return template.replace(TOKEN, (whole, key) => values[key] ?? whole);
|
|
2362
|
+
}
|
|
2363
|
+
var fillCount = (template, count) => fillTemplate(template, { n: String(count) });
|
|
2364
|
+
function elapsedMs(start, nowMs) {
|
|
2365
|
+
const ms = toEpochMs(start);
|
|
2366
|
+
return ms === null ? null : Math.max(0, nowMs - ms);
|
|
2367
|
+
}
|
|
2368
|
+
function formatDuration(durationMs, strings, largestUnit = "day" /* Day */) {
|
|
2369
|
+
if (durationMs === null) return strings.unknown;
|
|
2370
|
+
if (durationMs < MS_PER_MINUTE2) return strings.lessThanMinute;
|
|
2371
|
+
const inMinutes = largestUnit === "minute" /* Minute */ || durationMs < MS_PER_HOUR2;
|
|
2372
|
+
if (inMinutes) return fillCount(strings.minutes, Math.floor(durationMs / MS_PER_MINUTE2));
|
|
2373
|
+
const inHours = largestUnit === "hour" /* Hour */ || durationMs < MS_PER_DAY2;
|
|
2374
|
+
if (inHours) return fillCount(strings.hours, Math.floor(durationMs / MS_PER_HOUR2));
|
|
2375
|
+
return fillCount(strings.days, Math.floor(durationMs / MS_PER_DAY2));
|
|
2376
|
+
}
|
|
2377
|
+
function ageFraction(ageMs, limitMs) {
|
|
2378
|
+
if (ageMs === null) return 0;
|
|
2379
|
+
if (limitMs <= 0) return 1;
|
|
2380
|
+
return Math.min(1, Math.max(0, ageMs / limitMs));
|
|
2381
|
+
}
|
|
2382
|
+
var AGE_FONT = 14;
|
|
2383
|
+
var AGE_WEIGHT = "600";
|
|
2384
|
+
var styles6 = StyleSheet.create({
|
|
2385
|
+
text: { fontSize: AGE_FONT, fontWeight: AGE_WEIGHT, fontVariant: ["tabular-nums"] }
|
|
2386
|
+
});
|
|
2387
|
+
function AgeLabel({ ageMs, strings, largestUnit = "day" /* Day */, color, testID }) {
|
|
2388
|
+
const { theme } = useUi();
|
|
2389
|
+
return /* @__PURE__ */ jsx(Text, { style: [styles6.text, { color: color ?? theme.colors.text }], testID, children: formatDuration(ageMs, strings, largestUnit) });
|
|
2390
|
+
}
|
|
2391
|
+
var BAR_HEIGHT = 6;
|
|
2392
|
+
var BAR_RADIUS = 3;
|
|
2393
|
+
var GAP3 = 8;
|
|
2394
|
+
var LABEL_FONT = 13;
|
|
2395
|
+
var PERCENT = 100;
|
|
2396
|
+
var styles7 = StyleSheet.create({
|
|
2397
|
+
row: { flexDirection: "row", alignItems: "center", gap: GAP3, flexGrow: 1 },
|
|
2398
|
+
track: { flexGrow: 1, flexShrink: 1, height: BAR_HEIGHT, borderRadius: BAR_RADIUS, overflow: "hidden" },
|
|
2399
|
+
fill: { height: BAR_HEIGHT, borderRadius: BAR_RADIUS },
|
|
2400
|
+
label: { fontSize: LABEL_FONT, fontVariant: ["tabular-nums"] }
|
|
2401
|
+
});
|
|
2402
|
+
function AgeBar({ fraction, color, label, testID }) {
|
|
2403
|
+
const { theme } = useUi();
|
|
2404
|
+
return /* @__PURE__ */ jsxs(View, { style: styles7.row, testID, children: [
|
|
2405
|
+
/* @__PURE__ */ jsx(View, { "aria-hidden": true, style: [styles7.track, { backgroundColor: theme.colors.border }], children: /* @__PURE__ */ jsx(View, { style: [styles7.fill, { width: `${Math.round(fraction * PERCENT)}%`, backgroundColor: color }] }) }),
|
|
2406
|
+
/* @__PURE__ */ jsx(Text, { style: [styles7.label, { color: theme.colors.text }], children: label })
|
|
2407
|
+
] });
|
|
2408
|
+
}
|
|
2409
|
+
|
|
2410
|
+
// src/StatusLedger/utils/ageBands.ts
|
|
2411
|
+
var oldestFloorFirst = (bands) => [...bands].sort((a, b) => b.minAgeMs - a.minAgeMs);
|
|
2412
|
+
function assignAgeBand(ageMs, bands) {
|
|
2413
|
+
const ordered = oldestFloorFirst(bands);
|
|
2414
|
+
const youngest = ordered[ordered.length - 1];
|
|
2415
|
+
if (ageMs === null) return youngest;
|
|
2416
|
+
return ordered.find((band) => ageMs >= band.minAgeMs) ?? youngest;
|
|
2417
|
+
}
|
|
2418
|
+
function groupByAgeBand(rows, ageOf, bands) {
|
|
2419
|
+
return oldestFloorFirst(bands).map((band) => ({ band, rows: rows.filter((row) => assignAgeBand(ageOf(row), bands)?.key === band.key) })).filter((group) => group.rows.length > 0);
|
|
2420
|
+
}
|
|
2421
|
+
function sortOldestFirst(rows, ageOf) {
|
|
2422
|
+
return sortLedgerRows(rows, ageOf, "desc" /* Desc */);
|
|
2423
|
+
}
|
|
2424
|
+
|
|
2425
|
+
// src/WorkQueue/constants.ts
|
|
2426
|
+
var WORK_QUEUE_TEST_ID = "ui-work-queue";
|
|
2427
|
+
var AGE_COLUMN_KEY = "age";
|
|
2428
|
+
var AGE_MIN_WIDTH = 88;
|
|
2429
|
+
var AGE_BAR_MIN_WIDTH = 200;
|
|
2430
|
+
var EMPTY_QUEUE_NO_ROW_ACTION = "empty or loading work queue: there is no row to open";
|
|
2431
|
+
var workQueueBandTestID = (testID, bandKey) => `${testID}-band-${bandKey}`;
|
|
2432
|
+
var workQueueLedgerTestID = (testID) => `${testID}-ledger`;
|
|
2433
|
+
var GAP4 = 12;
|
|
2434
|
+
var COUNT_FONT = 13;
|
|
2435
|
+
var styles8 = StyleSheet.create({
|
|
2436
|
+
root: { gap: GAP4 },
|
|
2437
|
+
heading: { flexDirection: "row", alignItems: "center", gap: GAP4 },
|
|
2438
|
+
count: { fontSize: COUNT_FONT }
|
|
2439
|
+
});
|
|
2440
|
+
function AgeBandQueue({ ledger, ageOf, bands, bandCountLabel, testID }) {
|
|
2441
|
+
const { theme } = useUi();
|
|
2442
|
+
const view = useLedgerView(ledger);
|
|
2443
|
+
const toneColor = useToneColor(ledger.toneColors);
|
|
2444
|
+
const groups = useMemo(() => groupByAgeBand(view.visible, ageOf, bands), [view.visible, ageOf, bands]);
|
|
2445
|
+
const { labels } = ledger;
|
|
2446
|
+
const nothingToGroup = ledger.loading === true || groups.length === 0;
|
|
2447
|
+
return /* @__PURE__ */ jsxs(View, { style: styles8.root, testID, children: [
|
|
2448
|
+
/* @__PURE__ */ jsx(LedgerFilterBar, { labels, resultsCount: view.visible.length, testID: ledger.testID, view }),
|
|
2449
|
+
nothingToGroup ? /* @__PURE__ */ jsx(DataTable, { columns: view.tableColumns, emptyLabel: labels.empty, keyExtractor: ledger.keyExtractor, loading: ledger.loading, rowAction: { none: EMPTY_QUEUE_NO_ROW_ACTION }, rows: [], testID: `${ledger.testID}-table` }) : groups.map(({ band, rows }) => /* @__PURE__ */ jsx(
|
|
2450
|
+
LedgerSection,
|
|
2451
|
+
{
|
|
2452
|
+
columns: view.tableColumns,
|
|
2453
|
+
emptyLabel: labels.empty,
|
|
2454
|
+
heading: /* @__PURE__ */ jsxs(View, { accessibilityRole: "header", style: styles8.heading, children: [
|
|
2455
|
+
/* @__PURE__ */ jsx(StatusPill, { color: toneColor(band.tone), label: band.label, tone: band.tone }),
|
|
2456
|
+
/* @__PURE__ */ jsx(Text, { style: [styles8.count, { color: theme.colors.textSecondary }], children: fillTemplate(bandCountLabel, { n: String(rows.length) }) })
|
|
2457
|
+
] }),
|
|
2458
|
+
ledger,
|
|
2459
|
+
rows,
|
|
2460
|
+
testID: workQueueBandTestID(testID, band.key),
|
|
2461
|
+
title: band.label
|
|
2462
|
+
},
|
|
2463
|
+
band.key
|
|
2464
|
+
))
|
|
2465
|
+
] });
|
|
2466
|
+
}
|
|
2467
|
+
function AgeLabelCell({ ageMs, color, strings, largestUnit }) {
|
|
2468
|
+
return /* @__PURE__ */ jsx(AgeLabel, { ageMs, color, largestUnit, strings });
|
|
2469
|
+
}
|
|
2470
|
+
function AgeBarCell({ ageMs, color, strings, limitMs, ageOfLimit, largestUnit }) {
|
|
2471
|
+
const label = fillTemplate(ageOfLimit, { age: formatDuration(ageMs, strings, largestUnit), limit: formatDuration(limitMs, strings, largestUnit) });
|
|
2472
|
+
return /* @__PURE__ */ jsx(AgeBar, { color, fraction: ageFraction(ageMs, limitMs), label });
|
|
2473
|
+
}
|
|
2474
|
+
function buildAgeColumn(options) {
|
|
2475
|
+
const { Cell, minWidth, ageOf, bands, strings, labels, limitMs, toneColor, largestUnit } = options;
|
|
2476
|
+
const render = (row) => {
|
|
2477
|
+
const age = ageOf(row);
|
|
2478
|
+
const color = toneColor(assignAgeBand(age, bands)?.tone ?? "neutral" /* Neutral */);
|
|
2479
|
+
return /* @__PURE__ */ jsx(Cell, { ageMs: age, ageOfLimit: labels.ageOfLimit, color, largestUnit, limitMs, strings });
|
|
2480
|
+
};
|
|
2481
|
+
return { key: AGE_COLUMN_KEY, header: labels.age, minWidth, sortValue: ageOf, render };
|
|
2482
|
+
}
|
|
2483
|
+
|
|
2484
|
+
// src/WorkQueue/WorkQueueVariant.ts
|
|
2485
|
+
var WorkQueueVariant = /* @__PURE__ */ ((WorkQueueVariant2) => {
|
|
2486
|
+
WorkQueueVariant2["Table"] = "table";
|
|
2487
|
+
WorkQueueVariant2["Bands"] = "bands";
|
|
2488
|
+
WorkQueueVariant2["Bar"] = "bar";
|
|
2489
|
+
return WorkQueueVariant2;
|
|
2490
|
+
})(WorkQueueVariant || {});
|
|
2491
|
+
function WorkQueue(props) {
|
|
2492
|
+
const { ledger, getStartedAt, nowMs, bands, durationStrings, labels, variant = "bands" /* Bands */, limitMs, largestUnit, testID = WORK_QUEUE_TEST_ID } = props;
|
|
2493
|
+
const toneColor = useToneColor(ledger.toneColors);
|
|
2494
|
+
const ageOf = useCallback((row) => elapsedMs(getStartedAt(row), nowMs), [getStartedAt, nowMs]);
|
|
2495
|
+
const limit = limitMs ?? Math.max(0, ...bands.map((band) => band.minAgeMs));
|
|
2496
|
+
const queueLedger = useMemo(() => {
|
|
2497
|
+
const asBar = variant === "bar" /* Bar */;
|
|
2498
|
+
const ageColumn = buildAgeColumn({ Cell: asBar ? AgeBarCell : AgeLabelCell, minWidth: asBar ? AGE_BAR_MIN_WIDTH : AGE_MIN_WIDTH, ageOf, bands, strings: durationStrings, labels, limitMs: limit, toneColor, largestUnit });
|
|
2499
|
+
return { ...ledger, rows: sortOldestFirst(ledger.rows, ageOf), columns: [ageColumn, ...ledger.columns], testID: workQueueLedgerTestID(testID) };
|
|
2500
|
+
}, [ledger, ageOf, bands, durationStrings, labels, limit, toneColor, largestUnit, variant, testID]);
|
|
2501
|
+
if (variant === "bands" /* Bands */) return /* @__PURE__ */ jsx(AgeBandQueue, { ageOf, bandCountLabel: labels.bandCount, bands, ledger: queueLedger, testID });
|
|
2502
|
+
return /* @__PURE__ */ jsx(View, { testID, children: /* @__PURE__ */ jsx(StatusLedger, { ...queueLedger }) });
|
|
2503
|
+
}
|
|
2504
|
+
|
|
2337
2505
|
// src/MonthStatusGrid/MonthGridColumns.ts
|
|
2338
2506
|
var MonthGridColumns = /* @__PURE__ */ ((MonthGridColumns2) => {
|
|
2339
2507
|
MonthGridColumns2[MonthGridColumns2["Twelve"] = 12] = "Twelve";
|
|
@@ -2365,7 +2533,7 @@ var CELL_INNER_GAP = 4;
|
|
|
2365
2533
|
var LABEL_SIZE = 14;
|
|
2366
2534
|
var SELECTED_BORDER = 2;
|
|
2367
2535
|
var COLOR_STEP = "500";
|
|
2368
|
-
var
|
|
2536
|
+
var styles9 = StyleSheet.create({
|
|
2369
2537
|
grid: { gap: GRID_GAP },
|
|
2370
2538
|
row: { flexDirection: "row", gap: GRID_GAP },
|
|
2371
2539
|
filler: { flex: 1 },
|
|
@@ -2397,16 +2565,16 @@ var GridCell = ({ cell, isSelected, onSelect, hint, testID }) => {
|
|
|
2397
2565
|
"aria-pressed": isSelected,
|
|
2398
2566
|
onPress: () => onSelect(cell.id),
|
|
2399
2567
|
style: [
|
|
2400
|
-
|
|
2568
|
+
styles9.cell,
|
|
2401
2569
|
{ backgroundColor: isSelected ? colors.background : colors.surface, borderColor: colors.border },
|
|
2402
|
-
cell.dashed === true &&
|
|
2403
|
-
isSelected &&
|
|
2570
|
+
cell.dashed === true && styles9.dashed,
|
|
2571
|
+
isSelected && styles9.selected,
|
|
2404
2572
|
isSelected && { borderColor: theme.palette.primary[COLOR_STEP] }
|
|
2405
2573
|
],
|
|
2406
2574
|
testID,
|
|
2407
2575
|
children: [
|
|
2408
2576
|
cell.icon !== void 0 && cell.icon !== null ? /* @__PURE__ */ jsx(View, { "aria-hidden": true, children: cell.icon }) : null,
|
|
2409
|
-
/* @__PURE__ */ jsx(Text, { style: [
|
|
2577
|
+
/* @__PURE__ */ jsx(Text, { style: [styles9.label, { color: colors.text }], children: cell.label })
|
|
2410
2578
|
]
|
|
2411
2579
|
}
|
|
2412
2580
|
);
|
|
@@ -2426,7 +2594,7 @@ var MonthStatusGrid = ({
|
|
|
2426
2594
|
const fitted = fitMonthGridColumns(columns, measuredWidth ?? windowWidth, GRID_GAP);
|
|
2427
2595
|
const rows = useMemo(() => chunkIntoRows(cells, fitted), [cells, fitted]);
|
|
2428
2596
|
const onLayout = (event) => setMeasuredWidth(event.nativeEvent.layout.width);
|
|
2429
|
-
return /* @__PURE__ */ jsx(View, { accessibilityHint, accessibilityLabel, onLayout, role: "group", style:
|
|
2597
|
+
return /* @__PURE__ */ jsx(View, { accessibilityHint, accessibilityLabel, onLayout, role: "group", style: styles9.grid, testID, children: rows.map((row) => /* @__PURE__ */ jsxs(View, { style: styles9.row, testID: `${testID}-row`, children: [
|
|
2430
2598
|
row.map((cell) => /* @__PURE__ */ jsx(
|
|
2431
2599
|
GridCell,
|
|
2432
2600
|
{
|
|
@@ -2438,7 +2606,7 @@ var MonthStatusGrid = ({
|
|
|
2438
2606
|
},
|
|
2439
2607
|
cell.id
|
|
2440
2608
|
)),
|
|
2441
|
-
Array.from({ length: fitted - row.length }, (_, index) => /* @__PURE__ */ jsx(View, { style:
|
|
2609
|
+
Array.from({ length: fitted - row.length }, (_, index) => /* @__PURE__ */ jsx(View, { style: styles9.filler }, index))
|
|
2442
2610
|
] }, row[0]?.id)) });
|
|
2443
2611
|
};
|
|
2444
2612
|
|
|
@@ -2478,7 +2646,8 @@ function FilterSidePanel({ visible, onClose, title, closeLabel, closeHint, child
|
|
|
2478
2646
|
const { theme } = useUi();
|
|
2479
2647
|
const { width } = useWindowDimensions();
|
|
2480
2648
|
const panelWidth = Math.min(PANEL_MAX_WIDTH, Math.round(width * PANEL_SCREEN_SHARE));
|
|
2481
|
-
|
|
2649
|
+
const focusTitleOnOpen = useCallback((node) => node?.focus(), []);
|
|
2650
|
+
return /* @__PURE__ */ jsx(Modal, { transparent: true, animationType: "fade", visible, onRequestClose: onClose, children: /* @__PURE__ */ jsxs(View, { style: styles10.root, children: [
|
|
2482
2651
|
/* @__PURE__ */ jsx(
|
|
2483
2652
|
Pressable,
|
|
2484
2653
|
{
|
|
@@ -2494,11 +2663,11 @@ function FilterSidePanel({ visible, onClose, title, closeLabel, closeHint, child
|
|
|
2494
2663
|
View,
|
|
2495
2664
|
{
|
|
2496
2665
|
accessibilityViewIsModal: true,
|
|
2497
|
-
style: [
|
|
2666
|
+
style: [styles10.panel, { width: panelWidth, backgroundColor: theme.colors.surface, borderColor: theme.colors.border }],
|
|
2498
2667
|
testID,
|
|
2499
2668
|
children: [
|
|
2500
|
-
/* @__PURE__ */ jsxs(View, { style:
|
|
2501
|
-
/* @__PURE__ */ jsx(Text, { accessibilityRole: "header", style: [
|
|
2669
|
+
/* @__PURE__ */ jsxs(View, { style: styles10.header, children: [
|
|
2670
|
+
/* @__PURE__ */ jsx(View, { ref: focusTitleOnOpen, focusable: true, style: styles10.titleBox, testID: `${testID}-title`, children: /* @__PURE__ */ jsx(Text, { accessibilityRole: "header", style: [styles10.title, { color: theme.colors.text }], children: title }) }),
|
|
2502
2671
|
/* @__PURE__ */ jsx(ActionButton, { label: closeLabel, hint: closeHint, tone: "primary", onPress: onClose, testID: `${testID}-close` })
|
|
2503
2672
|
] }),
|
|
2504
2673
|
/* @__PURE__ */ jsx(ScrollView, { children })
|
|
@@ -2507,10 +2676,11 @@ function FilterSidePanel({ visible, onClose, title, closeLabel, closeHint, child
|
|
|
2507
2676
|
)
|
|
2508
2677
|
] }) });
|
|
2509
2678
|
}
|
|
2510
|
-
var
|
|
2679
|
+
var styles10 = StyleSheet.create({
|
|
2511
2680
|
root: { flex: 1, flexDirection: "row", justifyContent: "flex-end" },
|
|
2512
2681
|
panel: { height: "100%", padding: PANEL_PAD, borderLeftWidth: PANEL_BORDER },
|
|
2513
2682
|
header: { flexDirection: "row", alignItems: "center", justifyContent: "space-between", gap: HEADER_GAP, marginBottom: HEADER_BOTTOM },
|
|
2683
|
+
titleBox: { flexShrink: 1 },
|
|
2514
2684
|
title: { flexShrink: 1, fontSize: TITLE_FONT, fontWeight: "700" }
|
|
2515
2685
|
});
|
|
2516
2686
|
|
|
@@ -2656,7 +2826,7 @@ function ReportFilters({
|
|
|
2656
2826
|
const isCompact = compact ?? width < CARD_STACK_BREAKPOINT;
|
|
2657
2827
|
const renderBar = (barTestID, barActions) => /* @__PURE__ */ jsx(Filters, { fields, values, onChange: handleChange, actions: barActions, renderSelect, testID: barTestID });
|
|
2658
2828
|
if (!isCompact) return renderBar(testID, actions);
|
|
2659
|
-
return /* @__PURE__ */ jsxs(View, { style:
|
|
2829
|
+
return /* @__PURE__ */ jsxs(View, { style: styles11.compactRow, testID, children: [
|
|
2660
2830
|
/* @__PURE__ */ jsx(
|
|
2661
2831
|
ActionButton,
|
|
2662
2832
|
{
|
|
@@ -2682,7 +2852,7 @@ function ReportFilters({
|
|
|
2682
2852
|
)
|
|
2683
2853
|
] });
|
|
2684
2854
|
}
|
|
2685
|
-
var
|
|
2855
|
+
var styles11 = StyleSheet.create({
|
|
2686
2856
|
compactRow: { flexDirection: "row", flexWrap: "wrap", alignItems: "center", gap: COMPACT_GAP }
|
|
2687
2857
|
});
|
|
2688
2858
|
function useReportFilterQuery({
|
|
@@ -2805,6 +2975,6 @@ async function fetchAllPages(fetchPage, { pageSize, maxPages, concurrency = DEFA
|
|
|
2805
2975
|
return { rows: pages.flatMap((page) => [...page.items]), truncated: first.totalPages > maxPages };
|
|
2806
2976
|
}
|
|
2807
2977
|
|
|
2808
|
-
export { CARD_STACK_BREAKPOINT, DEFAULT_FETCH_CONCURRENCY, DEFAULT_PAGE_SIZE, DEFAULT_PAGE_SIZE_OPTIONS, DEFAULT_REPORT_QUERY_KEYS, DataTable, EMPTY_REPORT_FILTERS, EXPORT_CSV_TEST_ID, ExportCsvAction, ExportOutcome, FIELD_MIN_WIDTH, FILTERS_I18N, FILTERS_TEST_ID, FilterBar, FilterSidePanel, Filters, LedgerLayout, MONTH_STATUS_GRID_TEST_ID, MonthGridColumns, MonthStatusGrid, PagedTableLayout, PagedTableLayoutKind, Pager, REPORT_FIELD_KEYS, REPORT_FILTERS_TEST_ID, RelativeTime, ReportFilters, STATUS_LEDGER_TEST_ID, SortDirection, StatCard, StatTone, StatusLedger, StatusPill, StatusTone, TABLE_I18N, TABLE_TEST_IDS, applyTestID, buildReportFields, clearTestID, countActiveReportFilters, csvFilename, distinctValues, downloadCsv, fetchAllPages, fieldTestID, filterLedgerRows, fitMonthGridColumns, formatRelativeTime, fromFilterValues, isAttentionTone, isIsoDate, isRangeInverted, ledgerSectionTestID, ledgerSortDirectionTestID, monthCellTestID, openPanelTestID, panelFiltersTestID, panelTestID, reportFiltersFromQuery, reportFiltersToParams, reportFiltersToQuery, reportFiltersToSearch, resolveStatToneColor, rowDetailTestID, rowFadeTestID, rowSelectTestID, rowTestID, runCsvExport, selectAllTestID, sortLedgerRows, splitNeedsLook, toEpochMs, toFilterValues, useFilterDraft, usePagedRows, useReportDraft, useReportFilterQuery };
|
|
2978
|
+
export { AgeBar, AgeLabel, CARD_STACK_BREAKPOINT, DEFAULT_FETCH_CONCURRENCY, DEFAULT_PAGE_SIZE, DEFAULT_PAGE_SIZE_OPTIONS, DEFAULT_REPORT_QUERY_KEYS, DataTable, DurationUnit, EMPTY_REPORT_FILTERS, EXPORT_CSV_TEST_ID, ExportCsvAction, ExportOutcome, FIELD_MIN_WIDTH, FILTERS_I18N, FILTERS_TEST_ID, FilterBar, FilterSidePanel, Filters, LedgerLayout, MONTH_STATUS_GRID_TEST_ID, MonthGridColumns, MonthStatusGrid, PagedTableLayout, PagedTableLayoutKind, Pager, REPORT_FIELD_KEYS, REPORT_FILTERS_TEST_ID, RelativeTime, ReportFilters, STATUS_LEDGER_TEST_ID, SortDirection, StatCard, StatTone, StatusLedger, StatusPill, StatusTone, TABLE_I18N, TABLE_TEST_IDS, WORK_QUEUE_TEST_ID, WorkQueue, WorkQueueVariant, ageFraction, applyTestID, assignAgeBand, buildReportFields, clearTestID, countActiveReportFilters, csvFilename, distinctValues, downloadCsv, elapsedMs, fetchAllPages, fieldTestID, fillTemplate, filterLedgerRows, fitMonthGridColumns, formatDuration, formatRelativeTime, fromFilterValues, groupByAgeBand, isAttentionTone, isIsoDate, isRangeInverted, ledgerSectionTestID, ledgerSortDirectionTestID, monthCellTestID, openPanelTestID, panelFiltersTestID, panelTestID, reportFiltersFromQuery, reportFiltersToParams, reportFiltersToQuery, reportFiltersToSearch, resolveStatToneColor, rowDetailTestID, rowFadeTestID, rowSelectTestID, rowTestID, runCsvExport, selectAllTestID, sortLedgerRows, sortOldestFirst, splitNeedsLook, toEpochMs, toFilterValues, useFilterDraft, usePagedRows, useReportDraft, useReportFilterQuery, workQueueBandTestID, workQueueLedgerTestID };
|
|
2809
2979
|
//# sourceMappingURL=index.mjs.map
|
|
2810
2980
|
//# sourceMappingURL=index.mjs.map
|