@onehat/data 1.22.2 → 1.22.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.
|
@@ -44,6 +44,7 @@ describe('Property', function() {
|
|
|
44
44
|
title: null,
|
|
45
45
|
tooltip: null,
|
|
46
46
|
viewerType: null,
|
|
47
|
+
formatter: null,
|
|
47
48
|
};
|
|
48
49
|
// console.log(defaults);
|
|
49
50
|
// console.log(expected);
|
|
@@ -81,9 +82,14 @@ describe('Property', function() {
|
|
|
81
82
|
|
|
82
83
|
it('getDisplayValue & displayValue', function() {
|
|
83
84
|
this.property.setValue('12');
|
|
84
|
-
|
|
85
|
+
let value = this.property.getDisplayValue();
|
|
85
86
|
expect(value).to.be.eq(12);
|
|
86
87
|
expect(value).to.be.eq(this.property.displayValue);
|
|
88
|
+
|
|
89
|
+
this.property.setFormatter('FormatInt');
|
|
90
|
+
this.property.setValue('12345');
|
|
91
|
+
value = this.property.getDisplayValue();
|
|
92
|
+
expect(value).to.be.eq('12,345');
|
|
87
93
|
});
|
|
88
94
|
|
|
89
95
|
it('hasMapping', function() {
|
package/cypress/support/e2e.js
CHANGED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// ***********************************************************
|
|
2
|
+
// This example support/index.js is processed and
|
|
3
|
+
// loaded automatically before your test files.
|
|
4
|
+
//
|
|
5
|
+
// This is a great place to put global configuration and
|
|
6
|
+
// behavior that modifies Cypress.
|
|
7
|
+
//
|
|
8
|
+
// You can change the location of this file or turn off
|
|
9
|
+
// automatically serving support files with the
|
|
10
|
+
// 'supportFile' configuration option.
|
|
11
|
+
//
|
|
12
|
+
// You can read more here:
|
|
13
|
+
// https://on.cypress.io/configuration
|
|
14
|
+
// ***********************************************************
|
|
15
|
+
|
|
16
|
+
// Import commands.js using ES2015 syntax:
|
|
17
|
+
import './commands'
|
|
18
|
+
|
|
19
|
+
// Alternatively you can use CommonJS syntax:
|
|
20
|
+
// require('./commands')
|
package/cypress.config.js
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { defineConfig } from "cypress";
|
|
2
2
|
import webpackPreprocessor from "@cypress/webpack-preprocessor";
|
|
3
|
+
import localstoragePlugin from 'cypress-localstorage-commands/plugin.js';
|
|
3
4
|
|
|
4
5
|
export default defineConfig({
|
|
5
6
|
e2e: {
|
|
6
7
|
experimentalRunAllSpecs: true,
|
|
7
8
|
chromeWebSecurity: false,
|
|
8
|
-
setupNodeEvents(on) {
|
|
9
|
+
setupNodeEvents(on, config) {
|
|
9
10
|
const options = webpackPreprocessor.defaultOptions;
|
|
10
11
|
if (!options.module) {
|
|
11
12
|
options.module = {
|
|
12
13
|
rules: [],
|
|
13
|
-
}
|
|
14
|
+
};
|
|
14
15
|
}
|
|
15
16
|
if (!options.module.rules) {
|
|
16
17
|
options.module.rules = [];
|
|
@@ -18,24 +19,25 @@ export default defineConfig({
|
|
|
18
19
|
options.module.rules.push({
|
|
19
20
|
test: /\.(js|jsx|mjs)$/,
|
|
20
21
|
exclude: [/node_modules\/(?!(@onehat)\/).*/],
|
|
21
|
-
use: [
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
'@babel/preset-env'
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
22
|
+
use: [
|
|
23
|
+
{
|
|
24
|
+
loader: 'babel-loader',
|
|
25
|
+
options: {
|
|
26
|
+
cacheDirectory: false,
|
|
27
|
+
presets: ['@babel/preset-env'],
|
|
28
|
+
plugins: [
|
|
29
|
+
'@babel/plugin-transform-class-properties',
|
|
30
|
+
'@babel/plugin-transform-runtime',
|
|
31
|
+
],
|
|
32
|
+
sourceType: 'unambiguous',
|
|
33
|
+
},
|
|
33
34
|
},
|
|
34
|
-
|
|
35
|
-
|
|
35
|
+
],
|
|
36
36
|
});
|
|
37
37
|
|
|
38
38
|
on('file:preprocessor', webpackPreprocessor(options));
|
|
39
|
+
|
|
40
|
+
localstoragePlugin(on, config);
|
|
39
41
|
},
|
|
40
42
|
}
|
|
41
43
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onehat/data",
|
|
3
|
-
"version": "1.22.
|
|
3
|
+
"version": "1.22.4",
|
|
4
4
|
"description": "JS data modeling package with adapters for many storage mediums.",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
"homepage": "https://github.com/OneHatRepo/data#readme",
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@onehat/events": "^1.6.6",
|
|
40
|
-
"async-wait-until": "^2.0.12",
|
|
41
40
|
"accounting-js": "^1.1.1",
|
|
41
|
+
"async-wait-until": "^2.0.12",
|
|
42
42
|
"axios": "^1.6.2",
|
|
43
43
|
"chrono-node": "^2.7.3",
|
|
44
44
|
"he": "^1.2.0",
|
|
@@ -57,20 +57,18 @@
|
|
|
57
57
|
"store2": "^2.14.3"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
|
-
"@babel/core": "^7.
|
|
61
|
-
"@babel/
|
|
62
|
-
"@babel/plugin-transform-
|
|
63
|
-
"@babel/plugin-transform-runtime": "^7.
|
|
64
|
-
"@babel/preset-env": "^7.
|
|
65
|
-
"@babel/
|
|
66
|
-
"@babel/runtime": "^7.22.3",
|
|
60
|
+
"@babel/core": "^7.24.5",
|
|
61
|
+
"@babel/plugin-transform-class-properties": "^7.24.1",
|
|
62
|
+
"@babel/plugin-transform-export-namespace-from": "^7.24.1",
|
|
63
|
+
"@babel/plugin-transform-runtime": "^7.24.3",
|
|
64
|
+
"@babel/preset-env": "^7.24.5",
|
|
65
|
+
"@babel/runtime": "^7.24.5",
|
|
67
66
|
"@cypress/webpack-preprocessor": "^5.17.1",
|
|
68
|
-
"
|
|
69
|
-
"cypress": "
|
|
67
|
+
"cypress": "^13.15.2",
|
|
68
|
+
"cypress-localstorage-commands": "^2.2.7",
|
|
70
69
|
"ink-docstrap": "^1.3.2",
|
|
71
70
|
"joi": "^17.9.2",
|
|
72
71
|
"jsdoc": "^4.0.2",
|
|
73
|
-
"webpack": "^5.85.0",
|
|
74
72
|
"yup": "^1.2.0"
|
|
75
73
|
}
|
|
76
74
|
}
|
package/src/Property/Property.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/** @module Property */
|
|
2
2
|
|
|
3
3
|
import EventEmitter from '@onehat/events';
|
|
4
|
+
import Formatters from '../Util/Formatters.js';
|
|
4
5
|
import _ from 'lodash';
|
|
5
6
|
|
|
6
7
|
/**
|
|
@@ -137,6 +138,12 @@ export default class Property extends EventEmitter {
|
|
|
137
138
|
*/
|
|
138
139
|
defaultValue: null,
|
|
139
140
|
|
|
141
|
+
/**
|
|
142
|
+
* @member {string} formatter - The name of the formatter to use for this property
|
|
143
|
+
* @private
|
|
144
|
+
*/
|
|
145
|
+
formatter: null,
|
|
146
|
+
|
|
140
147
|
};
|
|
141
148
|
|
|
142
149
|
/**
|
|
@@ -278,6 +285,9 @@ export default class Property extends EventEmitter {
|
|
|
278
285
|
if (this.isDestroyed) {
|
|
279
286
|
throw Error('this.getDisplayValue is no longer valid. Property has been destroyed.');
|
|
280
287
|
}
|
|
288
|
+
if (this.formatter) {
|
|
289
|
+
return Formatters[this.formatter](this.parsedValue);
|
|
290
|
+
}
|
|
281
291
|
return this.parsedValue;
|
|
282
292
|
}
|
|
283
293
|
|
|
@@ -428,6 +438,17 @@ export default class Property extends EventEmitter {
|
|
|
428
438
|
return value;
|
|
429
439
|
}
|
|
430
440
|
|
|
441
|
+
/**
|
|
442
|
+
* Sets the formatter for this Property.
|
|
443
|
+
* @param {*} formatter
|
|
444
|
+
*/
|
|
445
|
+
setFormatter(formatter) {
|
|
446
|
+
if (this.isDestroyed) {
|
|
447
|
+
throw Error('this.setFormatter is no longer valid. Property has been destroyed.');
|
|
448
|
+
}
|
|
449
|
+
this.formatter = formatter;
|
|
450
|
+
}
|
|
451
|
+
|
|
431
452
|
|
|
432
453
|
|
|
433
454
|
|