@pequity/squirrel 8.6.0 → 9.0.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 +1 -1
- package/dist/cjs/chunks/p-icon.js +1 -2058
- package/dist/cjs/number.js +3 -2
- package/dist/es/chunks/p-icon.js +1 -2058
- package/dist/es/number.js +3 -2
- package/package.json +4 -3
- package/squirrel/utils/number.spec.js +13 -3
- package/squirrel/utils/number.ts +5 -2
package/dist/es/number.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
const toNumberOrNull = (val) => {
|
|
2
|
-
if (val === "" || val === null
|
|
2
|
+
if (val === "" || val === null) {
|
|
3
3
|
return null;
|
|
4
4
|
}
|
|
5
|
-
|
|
5
|
+
const num = Number(val);
|
|
6
|
+
return isFinite(num) ? num : null;
|
|
6
7
|
};
|
|
7
8
|
export {
|
|
8
9
|
toNumberOrNull
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pequity/squirrel",
|
|
3
3
|
"description": "Squirrel component library",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "9.0.0",
|
|
5
5
|
"packageManager": "pnpm@10.15.1",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"scripts": {
|
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
"@tanstack/vue-virtual": "^3.8.3",
|
|
42
42
|
"@vuepic/vue-datepicker": "^11.0.1",
|
|
43
43
|
"floating-vue": "^5.2.2",
|
|
44
|
+
"iconify-icon": "^3.0.0",
|
|
44
45
|
"lodash-es": "^4.17.21",
|
|
45
46
|
"vue": "^3.4.33",
|
|
46
47
|
"vue-currency-input": "^3.1.0",
|
|
@@ -87,7 +88,7 @@
|
|
|
87
88
|
"resolve-tspaths": "^0.8.23",
|
|
88
89
|
"rimraf": "^6.0.1",
|
|
89
90
|
"sass": "^1.92.1",
|
|
90
|
-
"semantic-release": "^24.2.
|
|
91
|
+
"semantic-release": "^24.2.8",
|
|
91
92
|
"storybook": "^9.1.5",
|
|
92
93
|
"svgo": "^4.0.0",
|
|
93
94
|
"tailwindcss": "^3.4.17",
|
|
@@ -102,6 +103,6 @@
|
|
|
102
103
|
},
|
|
103
104
|
"dependencies": {
|
|
104
105
|
"tailwind-merge": "^3.3.1",
|
|
105
|
-
"tailwind-variants": "^3.1.
|
|
106
|
+
"tailwind-variants": "^3.1.1"
|
|
106
107
|
}
|
|
107
108
|
}
|
|
@@ -1,11 +1,21 @@
|
|
|
1
1
|
import { toNumberOrNull } from '@squirrel/utils/number';
|
|
2
2
|
|
|
3
3
|
describe('toNumberOrNull', () => {
|
|
4
|
-
it.each(['', null, 'abc', NaN, {}])('returns null if input is %s', (val) => {
|
|
4
|
+
it.each(['', null, 'abc', NaN, {}, Infinity, -Infinity])('returns null if input is %s', (val) => {
|
|
5
5
|
expect(toNumberOrNull(val)).toBeNull();
|
|
6
6
|
});
|
|
7
7
|
|
|
8
|
-
it('
|
|
9
|
-
|
|
8
|
+
it.each([123, '123', 0, '0', -42, '-42', 3.14, '3.14'])(
|
|
9
|
+
'returns a number if input is a valid finite number: %s',
|
|
10
|
+
(val) => {
|
|
11
|
+
expect(toNumberOrNull(val)).toBe(Number(val));
|
|
12
|
+
}
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
it('handles edge cases for infinite values', () => {
|
|
16
|
+
expect(toNumberOrNull('Infinity')).toBeNull();
|
|
17
|
+
expect(toNumberOrNull('-Infinity')).toBeNull();
|
|
18
|
+
expect(toNumberOrNull(Number.POSITIVE_INFINITY)).toBeNull();
|
|
19
|
+
expect(toNumberOrNull(Number.NEGATIVE_INFINITY)).toBeNull();
|
|
10
20
|
});
|
|
11
21
|
});
|
package/squirrel/utils/number.ts
CHANGED
|
@@ -7,8 +7,11 @@
|
|
|
7
7
|
* @returns a number or null
|
|
8
8
|
*/
|
|
9
9
|
export const toNumberOrNull = (val: unknown) => {
|
|
10
|
-
if (val === '' || val === null
|
|
10
|
+
if (val === '' || val === null) {
|
|
11
11
|
return null;
|
|
12
12
|
}
|
|
13
|
-
|
|
13
|
+
|
|
14
|
+
const num = Number(val);
|
|
15
|
+
|
|
16
|
+
return isFinite(num) ? num : null;
|
|
14
17
|
};
|