@richardmcquiston01/dashboard-widgets-toolkit 0.6.0 → 0.7.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/README.md CHANGED
@@ -31,7 +31,7 @@ The widget kinds:
31
31
  | `TEXT` | `value: string`, `label` | A count or status as text |
32
32
  | `KPI` | `value: number`, `previous?: number \| null`, `format`, `currency?`, `label`, `hint?`, `higherIsBetter?` | Stat tile with a change vs previous period |
33
33
  | `GAUGE` | `value`, `max`, `label` | A meter (unread of total, quota used) |
34
- | `TABLE` | `columns: {label, numeric?}[]`, `rows: {text, href?}[][]`, `footer?` | Small data tables |
34
+ | `TABLE` | `columns: {label, numeric?}[]`, `rows: {text, href?, value?}[][]`, `footer?` | Small data tables |
35
35
  | `BAR_LIST` | `items: {label, value, display?}[]`, `total?` | Ratings breakdown, purchases by country |
36
36
  | `ALERT_LIST` | `items: {title, href?, thumbnailUrl?, valueLabel, detail?}[]`, `total`, `emptyText` | Low stock, stale listings, expiring soon |
37
37
  | `GRAPH` | `series: {name, points: {label, value}[]}[]`, `chartType: 'bar' \| 'line'`, `valueFormat`, `currency?`, `xLabel?` | Revenue by month, views per day |
@@ -41,6 +41,11 @@ in major units (12.5 is $12.50) and percents are fractions (0.25 is 25%). Any
41
41
  widget may instead return an empty state, `{ empty: true, text: 'No orders
42
42
  synced yet.' }`.
43
43
 
44
+ A `TABLE` cell's optional `value` (a string or number) is what the card's
45
+ table controls (`tableControls` on the definition) and the detail view sort
46
+ and search on, when `text` is formatted for reading: a timestamp behind
47
+ "3 days ago", a rating behind stars, an amount behind "$1,234.00".
48
+
44
49
  ## Getting Started
45
50
 
46
51
  See [GETTING_STARTED.md](./GETTING_STARTED.md)
package/dist/core.cjs CHANGED
@@ -826,6 +826,14 @@ function optionalNumber(record, field, path, problems) {
826
826
  requireNumber(record, field, path, problems);
827
827
  }
828
828
  }
829
+ function optionalSortValue(record, path, problems) {
830
+ const value = record["value"];
831
+ if (value !== void 0 && typeof value !== "string" && !(typeof value === "number" && Number.isFinite(value))) {
832
+ problems.push(
833
+ `${path}.value must be a string or a finite number, got ${describeType2(value)}.`
834
+ );
835
+ }
836
+ }
829
837
  function optionalBoolean(record, field, path, problems) {
830
838
  const value = record[field];
831
839
  if (value !== void 0 && typeof value !== "boolean") {
@@ -929,6 +937,7 @@ function checkPayloadFields(kind, data, problems) {
929
937
  }
930
938
  eachRecord(row, rowPath, problems, (cell, cellPath) => {
931
939
  requireString(cell, "text", cellPath, problems);
940
+ optionalSortValue(cell, cellPath, problems);
932
941
  optionalUrl(
933
942
  cell,
934
943
  "href",