@dloizides/ui-tables 1.24.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/dist/index.mjs CHANGED
@@ -2157,6 +2157,113 @@ function RelativeTime({ value, nowMs, strings, hint, formatAbsolute = defaultAbs
2157
2157
  );
2158
2158
  }
2159
2159
 
2160
- export { CARD_STACK_BREAKPOINT, DEFAULT_PAGE_SIZE, DEFAULT_PAGE_SIZE_OPTIONS, DataTable, FIELD_MIN_WIDTH, FILTERS_I18N, FILTERS_TEST_ID, FilterBar, Filters, LedgerLayout, Pager, RelativeTime, STATUS_LEDGER_TEST_ID, SortDirection, StatCard, StatusLedger, StatusPill, StatusTone, TABLE_I18N, TABLE_TEST_IDS, applyTestID, clearTestID, distinctValues, fieldTestID, filterLedgerRows, formatRelativeTime, isAttentionTone, ledgerSectionTestID, ledgerSortDirectionTestID, rowDetailTestID, rowFadeTestID, rowSelectTestID, rowTestID, selectAllTestID, sortLedgerRows, splitNeedsLook, toEpochMs, useFilterDraft, usePagedRows };
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 };
2161
2268
  //# sourceMappingURL=index.mjs.map
2162
2269
  //# sourceMappingURL=index.mjs.map