@stonecrop/atable 0.16.2 → 0.16.4

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.
@@ -19,6 +19,10 @@ import type { TableColumn } from './types';
19
19
  * explicit `format`, a synchronous `format` is added that renders the `{ qty, uom }` value (see
20
20
  * `QuantityValue` in `@stonecrop/aform`) as `"<qty> <uom>"`.
21
21
  *
22
+ * For currency fields — those whose `component` carries the `'currency'` category — without an
23
+ * explicit `format`, a synchronous `format` is added that renders the `{ amount, currency }` value
24
+ * (see `CurrencyValue` in `@stonecrop/aform`) as `"<amount> <currency>"`.
25
+ *
22
26
  * @public
23
27
  */
24
28
  export declare function schemaToColumns(schema: ColumnSchema[]): TableColumn[];
@@ -1 +1 @@
1
- {"version":3,"file":"schemaToColumns.d.ts","sourceRoot":"","sources":["../../src/schemaToColumns.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAErD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAG1C;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,YAAY,EAAE,GAAG,WAAW,EAAE,CA8BrE"}
1
+ {"version":3,"file":"schemaToColumns.d.ts","sourceRoot":"","sources":["../../src/schemaToColumns.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAErD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAG1C;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,YAAY,EAAE,GAAG,WAAW,EAAE,CAmCrE"}
@@ -1,5 +1,5 @@
1
1
  import { componentCategory } from '@stonecrop/schema';
2
- import { formatQuantity } from './utils';
2
+ import { formatCurrency, formatQuantity } from './utils';
3
3
  /**
4
4
  * Convert an array of doctype field descriptors into ATable column definitions.
5
5
  *
@@ -19,6 +19,10 @@ import { formatQuantity } from './utils';
19
19
  * explicit `format`, a synchronous `format` is added that renders the `{ qty, uom }` value (see
20
20
  * `QuantityValue` in `@stonecrop/aform`) as `"<qty> <uom>"`.
21
21
  *
22
+ * For currency fields — those whose `component` carries the `'currency'` category — without an
23
+ * explicit `format`, a synchronous `format` is added that renders the `{ amount, currency }` value
24
+ * (see `CurrencyValue` in `@stonecrop/aform`) as `"<amount> <currency>"`.
25
+ *
22
26
  * @public
23
27
  */
24
28
  export function schemaToColumns(schema) {
@@ -46,6 +50,10 @@ export function schemaToColumns(schema) {
46
50
  if (componentCategory(rest.component) === 'quantity' && !rest.format) {
47
51
  col.format = formatQuantity;
48
52
  }
53
+ // Currency fields: render the composite { amount, currency } value as "<amount> <currency>".
54
+ if (componentCategory(rest.component) === 'currency' && !rest.format) {
55
+ col.format = formatCurrency;
56
+ }
49
57
  return col;
50
58
  });
51
59
  }
@@ -1 +1 @@
1
- {"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../../src/stores/table.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,aAAa,EAAiB,MAAM,KAAK,CAAA;AAEvD,OAAO,KAAK,EACX,WAAW,EACX,gBAAgB,EAChB,cAAc,EACd,YAAY,EACZ,cAAc,EACd,WAAW,EACX,WAAW,EACX,YAAY,EACZ,UAAU,EACV,QAAQ,EACR,MAAM,UAAU,CAAA;AAGjB;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC3B,4BAA4B;IAC5B,KAAK,EAAE,GAAG,CAAA;IACV,yCAAyC;IACzC,UAAU,CAAC,EAAE,GAAG,CAAA;IAChB,uCAAuC;IACvC,QAAQ,CAAC,EAAE,GAAG,CAAA;CACd;AAED;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAA;AAwG3D;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,QAAQ,EAAE,MAAM,E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AM;2CAsIK,MAAM;gCAlBjB,MAAM;4BAjCV,cAAc;0BAxJhB,QAAQ,EAAE;+kBAyiBxC,CAAA"}
@@ -1,12 +1,25 @@
1
1
  import { defineStore } from 'pinia';
2
2
  import { componentCategory } from '@stonecrop/schema';
3
3
  import { computed, ref } from 'vue';
4
- import { formatQuantity, generateHash } from '../utils';
4
+ import { formatCurrency, formatQuantity, generateHash } from '../utils';
5
5
  // Quantity columns hold a composite `{ qty, uom, ... }` value (see `QuantityValue` in
6
6
  // `@stonecrop/aform`); numeric comparisons (filtering, sorting) operate on `qty`.
7
+ //
8
+ // Currency columns hold a composite `{ amount, currency, baseAmount, ... }` value (see
9
+ // `CurrencyValue` in `@stonecrop/aform`), and a single column routinely mixes currencies —
10
+ // comparing raw `amount` would rank 5 EUR equal to 5 USD and match 100 JPY against a `> 100`
11
+ // filter. `baseAmount` is the whole reason the value carries one: it restates every row in the
12
+ // record's base currency, which is the only axis on which they are comparable. Fall back to
13
+ // `amount` for a value that predates the base conversion (or was authored without one).
7
14
  function toComparableNumber(cellValue) {
8
- if (cellValue !== null && typeof cellValue === 'object' && 'qty' in cellValue) {
9
- return Number(cellValue.qty);
15
+ if (cellValue !== null && typeof cellValue === 'object') {
16
+ if ('qty' in cellValue)
17
+ return Number(cellValue.qty);
18
+ if ('baseAmount' in cellValue && cellValue.baseAmount != null) {
19
+ return Number(cellValue.baseAmount);
20
+ }
21
+ if ('amount' in cellValue)
22
+ return Number(cellValue.amount);
10
23
  }
11
24
  return Number(cellValue);
12
25
  }
@@ -429,6 +442,8 @@ export const createTableStore = (initData) => {
429
442
  return value != null ? new Date(String(value)).toLocaleString() : value;
430
443
  if (category === 'quantity')
431
444
  return formatQuantity(value);
445
+ if (category === 'currency')
446
+ return formatCurrency(value);
432
447
  return value;
433
448
  }
434
449
  if (typeof format === 'function') {
@@ -6,4 +6,12 @@ export declare const generateHash: (length?: number) => string;
6
6
  * the `format` that `schemaToColumns` attaches, and the table store's category-based default.
7
7
  */
8
8
  export declare const formatQuantity: (value: any) => string;
9
+ /**
10
+ * Render a composite currency value (`{ amount, currency }`, see `CurrencyValue` in
11
+ * `@stonecrop/aform`) as `"<amount> <currency>"`. `currency` is an AFormLinkValue FK reference —
12
+ * its `displayText` is preferred, falling back to `id`. Shared by the two paths a currency column
13
+ * can reach formatting through: the `format` that `schemaToColumns` attaches, and the table
14
+ * store's category-based default.
15
+ */
16
+ export declare const formatCurrency: (value: any) => string;
9
17
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY,GAAI,YAAY,MAAM,YAG9C,CAAA;AAED,eAAO,MAAM,YAAY,GAAI,eAAU,WAEtC,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,cAAc,GAAI,OAAO,GAAG,KAAG,MAQ3C,CAAA"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY,GAAI,YAAY,MAAM,YAG9C,CAAA;AAED,eAAO,MAAM,YAAY,GAAI,eAAU,WAEtC,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,cAAc,GAAI,OAAO,GAAG,KAAG,MAQ3C,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,GAAI,OAAO,GAAG,KAAG,MAQ3C,CAAA"}
package/dist/src/utils.js CHANGED
@@ -20,3 +20,20 @@ export const formatQuantity = (value) => {
20
20
  }
21
21
  return String(value);
22
22
  };
23
+ /**
24
+ * Render a composite currency value (`{ amount, currency }`, see `CurrencyValue` in
25
+ * `@stonecrop/aform`) as `"<amount> <currency>"`. `currency` is an AFormLinkValue FK reference —
26
+ * its `displayText` is preferred, falling back to `id`. Shared by the two paths a currency column
27
+ * can reach formatting through: the `format` that `schemaToColumns` attaches, and the table
28
+ * store's category-based default.
29
+ */
30
+ export const formatCurrency = (value) => {
31
+ if (value === null || value === undefined)
32
+ return '';
33
+ if (typeof value === 'object') {
34
+ const amount = value.amount ?? '';
35
+ const currency = value.currency?.displayText ?? value.currency?.id ?? '';
36
+ return currency ? `${amount} ${currency}`.trim() : String(amount);
37
+ }
38
+ return String(value);
39
+ };
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.58.7"
8
+ "packageVersion": "7.58.11"
9
9
  }
10
10
  ]
11
11
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stonecrop/atable",
3
- "version": "0.16.2",
3
+ "version": "0.16.4",
4
4
  "description": "Advanced data table component for Stonecrop",
5
5
  "bugs": {
6
6
  "url": "https://github.com/agritheory/stonecrop/issues"
@@ -35,9 +35,9 @@
35
35
  "dependencies": {
36
36
  "@vueuse/components": "^14.2.1",
37
37
  "@vueuse/core": "^14.2.1",
38
- "@stonecrop/schema": "0.16.2",
39
- "@stonecrop/themes": "0.16.2",
40
- "@stonecrop/utilities": "0.16.2"
38
+ "@stonecrop/schema": "0.16.4",
39
+ "@stonecrop/themes": "0.16.4",
40
+ "@stonecrop/utilities": "0.16.4"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@microsoft/api-documenter": "^7.30.5",
@@ -71,8 +71,8 @@
71
71
  "access": "public"
72
72
  },
73
73
  "scripts": {
74
- "_phase:build": "heft build && vite build && rushx docs",
75
- "build": "heft build && vite build && rushx docs",
74
+ "_phase:build": "heft build --clean && vite build && rushx docs",
75
+ "build": "heft build --clean && vite build && rushx docs",
76
76
  "dev": "vite",
77
77
  "docs": "bash ../common/scripts/run-docs.sh atable",
78
78
  "lint": "oxlint",
@@ -83,6 +83,7 @@ const CATEGORY_FILTER: Record<ComponentCategory, 'text' | 'select' | 'number' |
83
83
  link: 'text',
84
84
  attach: 'text',
85
85
  quantity: 'number',
86
+ currency: 'number',
86
87
  }
87
88
 
88
89
  const { column, colIndex, store } = defineProps<{
@@ -2,7 +2,7 @@ import { componentCategory } from '@stonecrop/schema'
2
2
  import type { ColumnSchema } from '@stonecrop/schema'
3
3
 
4
4
  import type { TableColumn } from './types'
5
- import { formatQuantity } from './utils'
5
+ import { formatCurrency, formatQuantity } from './utils'
6
6
 
7
7
  /**
8
8
  * Convert an array of doctype field descriptors into ATable column definitions.
@@ -23,6 +23,10 @@ import { formatQuantity } from './utils'
23
23
  * explicit `format`, a synchronous `format` is added that renders the `{ qty, uom }` value (see
24
24
  * `QuantityValue` in `@stonecrop/aform`) as `"<qty> <uom>"`.
25
25
  *
26
+ * For currency fields — those whose `component` carries the `'currency'` category — without an
27
+ * explicit `format`, a synchronous `format` is added that renders the `{ amount, currency }` value
28
+ * (see `CurrencyValue` in `@stonecrop/aform`) as `"<amount> <currency>"`.
29
+ *
26
30
  * @public
27
31
  */
28
32
  export function schemaToColumns(schema: ColumnSchema[]): TableColumn[] {
@@ -53,6 +57,11 @@ export function schemaToColumns(schema: ColumnSchema[]): TableColumn[] {
53
57
  col.format = formatQuantity
54
58
  }
55
59
 
60
+ // Currency fields: render the composite { amount, currency } value as "<amount> <currency>".
61
+ if (componentCategory(rest.component) === 'currency' && !rest.format) {
62
+ col.format = formatCurrency
63
+ }
64
+
56
65
  return col
57
66
  })
58
67
  }
@@ -14,7 +14,7 @@ import type {
14
14
  TableModal,
15
15
  TableRow,
16
16
  } from '../types'
17
- import { formatQuantity, generateHash } from '../utils'
17
+ import { formatCurrency, formatQuantity, generateHash } from '../utils'
18
18
 
19
19
  /**
20
20
  * Represents the state of a single filter
@@ -37,9 +37,20 @@ export type FilterStateRecord = Record<number, FilterState>
37
37
 
38
38
  // Quantity columns hold a composite `{ qty, uom, ... }` value (see `QuantityValue` in
39
39
  // `@stonecrop/aform`); numeric comparisons (filtering, sorting) operate on `qty`.
40
+ //
41
+ // Currency columns hold a composite `{ amount, currency, baseAmount, ... }` value (see
42
+ // `CurrencyValue` in `@stonecrop/aform`), and a single column routinely mixes currencies —
43
+ // comparing raw `amount` would rank 5 EUR equal to 5 USD and match 100 JPY against a `> 100`
44
+ // filter. `baseAmount` is the whole reason the value carries one: it restates every row in the
45
+ // record's base currency, which is the only axis on which they are comparable. Fall back to
46
+ // `amount` for a value that predates the base conversion (or was authored without one).
40
47
  function toComparableNumber(cellValue: unknown): number {
41
- if (cellValue !== null && typeof cellValue === 'object' && 'qty' in cellValue) {
42
- return Number(cellValue.qty)
48
+ if (cellValue !== null && typeof cellValue === 'object') {
49
+ if ('qty' in cellValue) return Number(cellValue.qty)
50
+ if ('baseAmount' in cellValue && (cellValue as { baseAmount: unknown }).baseAmount != null) {
51
+ return Number((cellValue as { baseAmount: unknown }).baseAmount)
52
+ }
53
+ if ('amount' in cellValue) return Number((cellValue as { amount: unknown }).amount)
43
54
  }
44
55
  return Number(cellValue)
45
56
  }
@@ -531,6 +542,7 @@ export const createTableStore = (initData: {
531
542
  if (category === 'date') return value != null ? new Date(String(value)).toLocaleDateString() : value
532
543
  if (category === 'datetime') return value != null ? new Date(String(value)).toLocaleString() : value
533
544
  if (category === 'quantity') return formatQuantity(value)
545
+ if (category === 'currency') return formatCurrency(value)
534
546
  return value
535
547
  }
536
548
 
package/src/utils.ts CHANGED
@@ -21,3 +21,20 @@ export const formatQuantity = (value: any): string => {
21
21
  }
22
22
  return String(value)
23
23
  }
24
+
25
+ /**
26
+ * Render a composite currency value (`{ amount, currency }`, see `CurrencyValue` in
27
+ * `@stonecrop/aform`) as `"<amount> <currency>"`. `currency` is an AFormLinkValue FK reference —
28
+ * its `displayText` is preferred, falling back to `id`. Shared by the two paths a currency column
29
+ * can reach formatting through: the `format` that `schemaToColumns` attaches, and the table
30
+ * store's category-based default.
31
+ */
32
+ export const formatCurrency = (value: any): string => {
33
+ if (value === null || value === undefined) return ''
34
+ if (typeof value === 'object') {
35
+ const amount = value.amount ?? ''
36
+ const currency = value.currency?.displayText ?? value.currency?.id ?? ''
37
+ return currency ? `${amount} ${currency}`.trim() : String(amount)
38
+ }
39
+ return String(value)
40
+ }