@dloizides/ui-tables 1.25.0 → 1.27.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,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.27.0
4
+
5
+ ### Added
6
+
7
+ - `StatCard`: `value` accepts a preformatted string (shown as given; numbers still use `toLocaleString`), and an optional `tone` (`StatTone.Neutral` / `Error` / `Success`) colours the label from the theme's semantic 700 step, then 500, then `textSecondary`. `resolveStatToneColor` is exported. INVOICE-FU-9 "INVOICE-5 shared look leftovers", AC-STAT-1.
8
+
3
9
  ## 1.25.0
4
10
 
5
11
  ### Added
package/dist/index.d.mts CHANGED
@@ -1,18 +1,28 @@
1
1
  import React from 'react';
2
+ import { UiTheme } from '@dloizides/ui-feedback';
2
3
  import { StyleProp, ViewStyle, TextStyle } from 'react-native';
3
4
  import { DateRangeValue, ControlOption } from '@dloizides/ui-forms';
4
5
  export { DEFAULT_TYPEAHEAD_MAX_SUGGESTIONS, DEFAULT_TYPEAHEAD_MIN_CHARS, DateRangeValue, isUnmatched, suggestOptions } from '@dloizides/ui-forms';
5
6
 
7
+ declare const enum StatTone {
8
+ Neutral = "neutral",
9
+ Error = "error",
10
+ Success = "success"
11
+ }
12
+ /** The label colour for a tone: the semantic 700 step, then 500, then textSecondary. */
13
+ declare function resolveStatToneColor(theme: UiTheme, tone: StatTone): string;
14
+
6
15
  /**
7
16
  * StatCard — a single labelled metric tile (label + formatted numeric value).
8
17
  */
9
18
 
10
19
  interface StatCardProps {
11
20
  label: string;
12
- value: number;
21
+ value: number | string;
13
22
  testID: string;
23
+ tone?: StatTone;
14
24
  }
15
- declare const StatCard: React.MemoExoticComponent<({ label, value, testID }: StatCardProps) => React.ReactElement>;
25
+ declare const StatCard: React.MemoExoticComponent<({ label, value, testID, tone }: StatCardProps) => React.ReactElement>;
16
26
 
17
27
  /**
18
28
  * The DataTable contract — a `columns + rows` grid (the shape proven in the POC and
@@ -949,13 +959,14 @@ interface MonthStatusGridProps {
949
959
  selectedId?: string | null;
950
960
  columns?: MonthGridColumns;
951
961
  accessibilityLabel: string;
962
+ accessibilityHint?: string;
952
963
  cellHint: string;
953
964
  testID?: string;
954
965
  }
955
966
  /** 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;
967
+ declare const MonthStatusGrid: ({ cells, onSelect, selectedId, columns, accessibilityLabel, accessibilityHint, cellHint, testID, }: MonthStatusGridProps) => React.ReactElement;
957
968
 
958
969
  /** The widest allowed column count, up to `requested`, whose cells stay at least 44 px wide. */
959
970
  declare function fitMonthGridColumns(requested: MonthGridColumns, width: number, gap: number): MonthGridColumns;
960
971
 
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 };
972
+ 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, StatTone, 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, resolveStatToneColor, rowDetailTestID, rowFadeTestID, rowSelectTestID, rowTestID, selectAllTestID, sortLedgerRows, splitNeedsLook, toEpochMs, useFilterDraft, usePagedRows };
package/dist/index.d.ts CHANGED
@@ -1,18 +1,28 @@
1
1
  import React from 'react';
2
+ import { UiTheme } from '@dloizides/ui-feedback';
2
3
  import { StyleProp, ViewStyle, TextStyle } from 'react-native';
3
4
  import { DateRangeValue, ControlOption } from '@dloizides/ui-forms';
4
5
  export { DEFAULT_TYPEAHEAD_MAX_SUGGESTIONS, DEFAULT_TYPEAHEAD_MIN_CHARS, DateRangeValue, isUnmatched, suggestOptions } from '@dloizides/ui-forms';
5
6
 
7
+ declare const enum StatTone {
8
+ Neutral = "neutral",
9
+ Error = "error",
10
+ Success = "success"
11
+ }
12
+ /** The label colour for a tone: the semantic 700 step, then 500, then textSecondary. */
13
+ declare function resolveStatToneColor(theme: UiTheme, tone: StatTone): string;
14
+
6
15
  /**
7
16
  * StatCard — a single labelled metric tile (label + formatted numeric value).
8
17
  */
9
18
 
10
19
  interface StatCardProps {
11
20
  label: string;
12
- value: number;
21
+ value: number | string;
13
22
  testID: string;
23
+ tone?: StatTone;
14
24
  }
15
- declare const StatCard: React.MemoExoticComponent<({ label, value, testID }: StatCardProps) => React.ReactElement>;
25
+ declare const StatCard: React.MemoExoticComponent<({ label, value, testID, tone }: StatCardProps) => React.ReactElement>;
16
26
 
17
27
  /**
18
28
  * The DataTable contract — a `columns + rows` grid (the shape proven in the POC and
@@ -949,13 +959,14 @@ interface MonthStatusGridProps {
949
959
  selectedId?: string | null;
950
960
  columns?: MonthGridColumns;
951
961
  accessibilityLabel: string;
962
+ accessibilityHint?: string;
952
963
  cellHint: string;
953
964
  testID?: string;
954
965
  }
955
966
  /** 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;
967
+ declare const MonthStatusGrid: ({ cells, onSelect, selectedId, columns, accessibilityLabel, accessibilityHint, cellHint, testID, }: MonthStatusGridProps) => React.ReactElement;
957
968
 
958
969
  /** The widest allowed column count, up to `requested`, whose cells stay at least 44 px wide. */
959
970
  declare function fitMonthGridColumns(requested: MonthGridColumns, width: number, gap: number): MonthGridColumns;
960
971
 
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 };
972
+ 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, StatTone, 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, resolveStatToneColor, rowDetailTestID, rowFadeTestID, rowSelectTestID, rowTestID, selectAllTestID, sortLedgerRows, splitNeedsLook, toEpochMs, useFilterDraft, usePagedRows };
package/dist/index.js CHANGED
@@ -110,6 +110,21 @@ var TABLE_I18N = {
110
110
  statCardLabel: "analytics.statCardLabel",
111
111
  statHint: "analytics.statHint"
112
112
  };
113
+
114
+ // src/StatCard/StatTone.ts
115
+ var StatTone = /* @__PURE__ */ ((StatTone2) => {
116
+ StatTone2["Neutral"] = "neutral";
117
+ StatTone2["Error"] = "error";
118
+ StatTone2["Success"] = "success";
119
+ return StatTone2;
120
+ })(StatTone || {});
121
+ var TONE_STEP = "700";
122
+ var FALLBACK_STEP = "500";
123
+ function resolveStatToneColor(theme, tone) {
124
+ if (tone === "neutral" /* Neutral */) return theme.colors.textSecondary;
125
+ const scale = theme.semantic[tone];
126
+ return scale?.[TONE_STEP] ?? scale?.[FALLBACK_STEP] ?? theme.colors.textSecondary;
127
+ }
113
128
  var CARD_PADDING = 16;
114
129
  var CARD_BORDER_RADIUS = 12;
115
130
  var CARD_BORDER_WIDTH = 1;
@@ -132,10 +147,11 @@ var styles = reactNative.StyleSheet.create({
132
147
  lineHeight: VALUE_LINE_HEIGHT
133
148
  }
134
149
  });
135
- var StatCard = React2.memo(({ label, value, testID }) => {
150
+ var StatCard = React2.memo(({ label, value, testID, tone = "neutral" /* Neutral */ }) => {
136
151
  const { theme, t } = uiFeedback.useUi();
137
152
  const { colors } = theme;
138
- const formattedValue = value.toLocaleString();
153
+ const formattedValue = typeof value === "string" ? value : value.toLocaleString();
154
+ const labelColor = resolveStatToneColor(theme, tone);
139
155
  return /* @__PURE__ */ jsxRuntime.jsxs(
140
156
  reactNative.View,
141
157
  {
@@ -145,7 +161,7 @@ var StatCard = React2.memo(({ label, value, testID }) => {
145
161
  style: [styles.card, { backgroundColor: colors.surface, borderColor: colors.border }],
146
162
  testID,
147
163
  children: [
148
- /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles.label, { color: colors.textSecondary }], children: label }),
164
+ /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles.label, { color: labelColor }], children: label }),
149
165
  /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles.value, { color: colors.text }], children: formattedValue })
150
166
  ]
151
167
  }
@@ -2245,6 +2261,7 @@ var MonthStatusGrid = ({
2245
2261
  selectedId = null,
2246
2262
  columns = 12 /* Twelve */,
2247
2263
  accessibilityLabel,
2264
+ accessibilityHint,
2248
2265
  cellHint,
2249
2266
  testID = MONTH_STATUS_GRID_TEST_ID
2250
2267
  }) => {
@@ -2253,7 +2270,7 @@ var MonthStatusGrid = ({
2253
2270
  const fitted = fitMonthGridColumns(columns, measuredWidth ?? windowWidth, GRID_GAP);
2254
2271
  const rows = React2.useMemo(() => chunkIntoRows(cells, fitted), [cells, fitted]);
2255
2272
  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: [
2273
+ 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: [
2257
2274
  row.map((cell) => /* @__PURE__ */ jsxRuntime.jsx(
2258
2275
  GridCell,
2259
2276
  {
@@ -2303,6 +2320,7 @@ exports.RelativeTime = RelativeTime;
2303
2320
  exports.STATUS_LEDGER_TEST_ID = STATUS_LEDGER_TEST_ID;
2304
2321
  exports.SortDirection = SortDirection;
2305
2322
  exports.StatCard = StatCard;
2323
+ exports.StatTone = StatTone;
2306
2324
  exports.StatusLedger = StatusLedger;
2307
2325
  exports.StatusPill = StatusPill;
2308
2326
  exports.StatusTone = StatusTone;
@@ -2319,6 +2337,7 @@ exports.isAttentionTone = isAttentionTone;
2319
2337
  exports.ledgerSectionTestID = ledgerSectionTestID;
2320
2338
  exports.ledgerSortDirectionTestID = ledgerSortDirectionTestID;
2321
2339
  exports.monthCellTestID = monthCellTestID;
2340
+ exports.resolveStatToneColor = resolveStatToneColor;
2322
2341
  exports.rowDetailTestID = rowDetailTestID;
2323
2342
  exports.rowFadeTestID = rowFadeTestID;
2324
2343
  exports.rowSelectTestID = rowSelectTestID;