@onsvisual/svelte-components 0.1.47 → 0.1.49

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.
@@ -1,5 +1,5 @@
1
1
  <script>
2
- import { format, ascending, descending } from "../../js/utils.js";
2
+ import { format, isNumeric, ascending, descending } from "../../js/utils.js";
3
3
 
4
4
  /**
5
5
  * An optional title for the table
@@ -126,7 +126,7 @@
126
126
  class="ons-table__cell"
127
127
  class:ons-table__cell--numeric="{col.numeric}"
128
128
  data-th="{col.label}"
129
- >{@html row[col.key] && col.numeric
129
+ >{@html col.numeric && isNumeric(row[col.key])
130
130
  ? format(row[col.key], col.dp)
131
131
  : row[col.key]
132
132
  ? row[col.key]
package/dist/js/utils.js CHANGED
@@ -16,6 +16,8 @@ export const slugify = (str, suffix = false) =>
16
16
  .concat(suffix ? `-${randomString()}` : "")
17
17
  : randomString();
18
18
 
19
+ export const isNumeric = (val) => isFinite(val) && val !== null;
20
+
19
21
  export const validDate = (str) => {
20
22
  if (!str) return false;
21
23
  const date = new Date(str);
@@ -34,7 +36,7 @@ export const formatDate = (
34
36
  };
35
37
 
36
38
  export const format = (val, dp = null) => {
37
- return dp
39
+ return Number.isInteger(dp)
38
40
  ? val.toLocaleString("en-GB", {
39
41
  minimumFractionDigits: dp,
40
42
  maximumFractionDigits: dp,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onsvisual/svelte-components",
3
- "version": "0.1.47",
3
+ "version": "0.1.49",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "homepage": "https://onsvisual.github.io/svelte-components",