@dloizides/ui-tables 1.26.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
@@ -959,4 +969,4 @@ declare const MonthStatusGrid: ({ cells, onSelect, selectedId, columns, accessib
959
969
  /** The widest allowed column count, up to `requested`, whose cells stay at least 44 px wide. */
960
970
  declare function fitMonthGridColumns(requested: MonthGridColumns, width: number, gap: number): MonthGridColumns;
961
971
 
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 };
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
@@ -959,4 +969,4 @@ declare const MonthStatusGrid: ({ cells, onSelect, selectedId, columns, accessib
959
969
  /** The widest allowed column count, up to `requested`, whose cells stay at least 44 px wide. */
960
970
  declare function fitMonthGridColumns(requested: MonthGridColumns, width: number, gap: number): MonthGridColumns;
961
971
 
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 };
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
  }
@@ -2304,6 +2320,7 @@ exports.RelativeTime = RelativeTime;
2304
2320
  exports.STATUS_LEDGER_TEST_ID = STATUS_LEDGER_TEST_ID;
2305
2321
  exports.SortDirection = SortDirection;
2306
2322
  exports.StatCard = StatCard;
2323
+ exports.StatTone = StatTone;
2307
2324
  exports.StatusLedger = StatusLedger;
2308
2325
  exports.StatusPill = StatusPill;
2309
2326
  exports.StatusTone = StatusTone;
@@ -2320,6 +2337,7 @@ exports.isAttentionTone = isAttentionTone;
2320
2337
  exports.ledgerSectionTestID = ledgerSectionTestID;
2321
2338
  exports.ledgerSortDirectionTestID = ledgerSortDirectionTestID;
2322
2339
  exports.monthCellTestID = monthCellTestID;
2340
+ exports.resolveStatToneColor = resolveStatToneColor;
2323
2341
  exports.rowDetailTestID = rowDetailTestID;
2324
2342
  exports.rowFadeTestID = rowFadeTestID;
2325
2343
  exports.rowSelectTestID = rowSelectTestID;