@jsonui/core 0.2.0 → 0.4.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/dist/cjs/index.js +350 -411
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/index.d.ts +2 -2
- package/dist/cjs/types/stock/Stock.d.ts +2 -2
- package/dist/cjs/types/store/root/selectors.d.ts +2 -6
- package/dist/cjs/types/utils/constants.d.ts +8 -0
- package/dist/cjs/types/utils/contextHandler.d.ts +1 -1
- package/dist/cjs/types/utils/types.d.ts +5 -0
- package/dist/cjs/types/utils/util.d.ts +1 -0
- package/dist/cjs/types/wrapper/wrapperUtil.d.ts +22 -6
- package/dist/cjs/types/wrapper/wrapperUtil.test.d.ts +1 -0
- package/dist/esm/index.js +350 -411
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/index.d.ts +2 -2
- package/dist/esm/types/stock/Stock.d.ts +2 -2
- package/dist/esm/types/store/root/selectors.d.ts +2 -6
- package/dist/esm/types/utils/constants.d.ts +8 -0
- package/dist/esm/types/utils/contextHandler.d.ts +1 -1
- package/dist/esm/types/utils/types.d.ts +5 -0
- package/dist/esm/types/utils/util.d.ts +1 -0
- package/dist/esm/types/wrapper/wrapperUtil.d.ts +22 -6
- package/dist/esm/types/wrapper/wrapperUtil.test.d.ts +1 -0
- package/dist/index.d.ts +94 -36
- package/package.json +2 -2
- package/dist/cjs/types/utils/jsonRefResolver.d.ts +0 -2
- package/dist/esm/types/utils/jsonRefResolver.d.ts +0 -2
package/dist/esm/index.js
CHANGED
|
@@ -1,4 +1,40 @@
|
|
|
1
|
-
import require$$0,{createContext}from'react'
|
|
1
|
+
import require$$0,{createContext}from'react';class Stock {
|
|
2
|
+
constructor(newStock, Wrapper, reduxStore) {
|
|
3
|
+
this.init = ({ components, functions }) => {
|
|
4
|
+
this.stock.components = Object.assign(Object.assign({}, this.stock.components), components);
|
|
5
|
+
this.stock.functions = Object.assign(Object.assign({}, this.stock.functions), functions);
|
|
6
|
+
};
|
|
7
|
+
this.registerComponent = (key, value) => {
|
|
8
|
+
if (!!key && typeof key === 'string' && key.length > 0 && !(key in this.stock.components)) {
|
|
9
|
+
this.stock.components[key] = value;
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
this.registerFunction = (key, value) => {
|
|
13
|
+
if (!!key && typeof key === 'string' && key.length > 0 && !(key in this.stock.functions)) {
|
|
14
|
+
this.stock.functions[key] = value;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
this.callFunction = (name, attr, props, callerArgs) => {
|
|
18
|
+
if (!!attr && !!name && name in this.stock.functions) {
|
|
19
|
+
const result = this.stock.functions[name](attr, props, callerArgs, this);
|
|
20
|
+
return result;
|
|
21
|
+
}
|
|
22
|
+
return null;
|
|
23
|
+
};
|
|
24
|
+
this.getComponent = (componentName) => !!componentName && componentName in this.stock.components
|
|
25
|
+
? this.stock.components[componentName]
|
|
26
|
+
: // eslint-disable-next-line no-underscore-dangle
|
|
27
|
+
this.stock.components._Undefined;
|
|
28
|
+
this.stock = {
|
|
29
|
+
components: {},
|
|
30
|
+
functions: {},
|
|
31
|
+
};
|
|
32
|
+
this.Wrapper = Wrapper;
|
|
33
|
+
this.validations = [];
|
|
34
|
+
this.reduxStore = reduxStore;
|
|
35
|
+
this.init(newStock);
|
|
36
|
+
}
|
|
37
|
+
}/*! *****************************************************************************
|
|
2
38
|
Copyright (c) Microsoft Corporation.
|
|
3
39
|
|
|
4
40
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
@@ -13,17 +49,6 @@ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
|
13
49
|
PERFORMANCE OF THIS SOFTWARE.
|
|
14
50
|
***************************************************************************** */
|
|
15
51
|
|
|
16
|
-
var __assign = function() {
|
|
17
|
-
__assign = Object.assign || function __assign(t) {
|
|
18
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
19
|
-
s = arguments[i];
|
|
20
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
21
|
-
}
|
|
22
|
-
return t;
|
|
23
|
-
};
|
|
24
|
-
return __assign.apply(this, arguments);
|
|
25
|
-
};
|
|
26
|
-
|
|
27
52
|
function __rest(s, e) {
|
|
28
53
|
var t = {};
|
|
29
54
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -44,86 +69,7 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
44
69
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
45
70
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
46
71
|
});
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
function __generator(thisArg, body) {
|
|
50
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
51
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
52
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
53
|
-
function step(op) {
|
|
54
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
55
|
-
while (_) try {
|
|
56
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
57
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
58
|
-
switch (op[0]) {
|
|
59
|
-
case 0: case 1: t = op; break;
|
|
60
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
61
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
62
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
63
|
-
default:
|
|
64
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
65
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
66
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
67
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
68
|
-
if (t[2]) _.ops.pop();
|
|
69
|
-
_.trys.pop(); continue;
|
|
70
|
-
}
|
|
71
|
-
op = body.call(thisArg, _);
|
|
72
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
73
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
function __spreadArray(to, from, pack) {
|
|
78
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
79
|
-
if (ar || !(i in from)) {
|
|
80
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
81
|
-
ar[i] = from[i];
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
85
|
-
}var Stock = /** @class */ (function () {
|
|
86
|
-
function Stock(newStock, Wrapper, reduxStore) {
|
|
87
|
-
var _this = this;
|
|
88
|
-
this.init = function (_a) {
|
|
89
|
-
var components = _a.components, functions = _a.functions;
|
|
90
|
-
_this.stock.components = __assign(__assign({}, _this.stock.components), components);
|
|
91
|
-
_this.stock.functions = __assign(__assign({}, _this.stock.functions), functions);
|
|
92
|
-
};
|
|
93
|
-
this.registerComponent = function (key, value) {
|
|
94
|
-
if (!!key && typeof key === 'string' && key.length > 0 && !(key in _this.stock.components)) {
|
|
95
|
-
_this.stock.components[key] = value;
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
this.registerFunction = function (key, value) {
|
|
99
|
-
if (!!key && typeof key === 'string' && key.length > 0 && !(key in _this.stock.functions)) {
|
|
100
|
-
_this.stock.functions[key] = value;
|
|
101
|
-
}
|
|
102
|
-
};
|
|
103
|
-
this.callFunction = function (name, attr, props, callerArgs) {
|
|
104
|
-
if (!!attr && !!name && name in _this.stock.functions) {
|
|
105
|
-
var result = _this.stock.functions[name](attr, props, callerArgs, _this);
|
|
106
|
-
return result;
|
|
107
|
-
}
|
|
108
|
-
return null;
|
|
109
|
-
};
|
|
110
|
-
this.getComponent = function (componentName) {
|
|
111
|
-
return !!componentName && componentName in _this.stock.components
|
|
112
|
-
? _this.stock.components[componentName]
|
|
113
|
-
: // eslint-disable-next-line no-underscore-dangle
|
|
114
|
-
_this.stock.components._Undefined;
|
|
115
|
-
};
|
|
116
|
-
this.stock = {
|
|
117
|
-
components: {},
|
|
118
|
-
functions: {},
|
|
119
|
-
};
|
|
120
|
-
this.Wrapper = Wrapper;
|
|
121
|
-
this.validations = [];
|
|
122
|
-
this.reduxStore = reduxStore;
|
|
123
|
-
this.init(newStock);
|
|
124
|
-
}
|
|
125
|
-
return Stock;
|
|
126
|
-
}());var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
72
|
+
}var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
127
73
|
|
|
128
74
|
function getDefaultExportFromCjs (x) {
|
|
129
75
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
@@ -5010,31 +4956,38 @@ var hasOwnProperty$3 = Object.hasOwnProperty || function (obj, key) {
|
|
|
5010
4956
|
return key in obj;
|
|
5011
4957
|
};
|
|
5012
4958
|
|
|
5013
|
-
var traverse$3 = traverse$4.exports;
|
|
5014
|
-
|
|
5015
|
-
|
|
5016
|
-
|
|
5017
|
-
|
|
5018
|
-
|
|
5019
|
-
|
|
5020
|
-
|
|
5021
|
-
|
|
5022
|
-
|
|
5023
|
-
|
|
5024
|
-
|
|
5025
|
-
|
|
5026
|
-
|
|
5027
|
-
|
|
5028
|
-
|
|
5029
|
-
|
|
5030
|
-
|
|
5031
|
-
|
|
5032
|
-
|
|
5033
|
-
|
|
5034
|
-
|
|
5035
|
-
|
|
5036
|
-
|
|
5037
|
-
|
|
4959
|
+
var traverse$3 = traverse$4.exports;const SEPARATOR = '/';
|
|
4960
|
+
const STORE_ERROR_POSTFIX = '.error';
|
|
4961
|
+
const PATH_MODIFIERS_KEY = '$pathModifiers';
|
|
4962
|
+
const MODIFIER_KEY = '$modifier';
|
|
4963
|
+
const ACTION_KEY = '$action';
|
|
4964
|
+
const PERSIST_STORAGE_KEY = '$persistStores';
|
|
4965
|
+
const PERSIST_STORAGE_NAMES = ['data'];
|
|
4966
|
+
const REF_ASSETS = '$assetsRef';
|
|
4967
|
+
const REF_LOCALES = '$locales';
|
|
4968
|
+
const REF_VALIDATES = '$validations';
|
|
4969
|
+
const STYLE_WEB_NAME = 'styleWeb';
|
|
4970
|
+
const STYLE_RN_NAME = 'styleRN';
|
|
4971
|
+
const REDUX_GET_FUNCTION = 'get';
|
|
4972
|
+
const REDUX_SET_FUNCTION = 'set';
|
|
4973
|
+
const REDUX_FUNCTIONS = [REDUX_GET_FUNCTION, REDUX_SET_FUNCTION];
|
|
4974
|
+
const PATHNAME = 'path';
|
|
4975
|
+
const SIMPLE_DATA_TYPES = ['string', 'number', 'boolean', 'null'];
|
|
4976
|
+
const V_CHILDREN_NAME = '$children';
|
|
4977
|
+
const V_COMP_NAME = '$comp';
|
|
4978
|
+
const LIST_SEMAPHORE = '$isList';
|
|
4979
|
+
const LIST_ITEM = '$listItem';
|
|
4980
|
+
const LIST_PAGE = '$page';
|
|
4981
|
+
const LIST_ITEM_PER_PAGE = '$itemPerPage';
|
|
4982
|
+
const LIST_LENGTH = '$listLength';
|
|
4983
|
+
const LIST_ITEM_PER_PAGE_DEFAULT = 10;
|
|
4984
|
+
const REDUX_PATHS = '$$reduxPaths';
|
|
4985
|
+
const V_CHILDREN_PREFIX = '$child';
|
|
4986
|
+
const PARENT_PROP_NAME = '__parentprop';
|
|
4987
|
+
const CURRENT_PATH_NAME = '__currentPaths';
|
|
4988
|
+
const PRIMITIVE_COMP_NAME = '_PrimitiveProp'; // TODO check all literal and replace with this constant
|
|
4989
|
+
const FRAGMENT_COMP_NAME = 'Fragment'; // TODO check all literal and replace with this constant
|
|
4990
|
+
var constants=/*#__PURE__*/Object.freeze({__proto__:null,SEPARATOR:SEPARATOR,STORE_ERROR_POSTFIX:STORE_ERROR_POSTFIX,PATH_MODIFIERS_KEY:PATH_MODIFIERS_KEY,MODIFIER_KEY:MODIFIER_KEY,ACTION_KEY:ACTION_KEY,PERSIST_STORAGE_KEY:PERSIST_STORAGE_KEY,PERSIST_STORAGE_NAMES:PERSIST_STORAGE_NAMES,REF_ASSETS:REF_ASSETS,REF_LOCALES:REF_LOCALES,REF_VALIDATES:REF_VALIDATES,STYLE_WEB_NAME:STYLE_WEB_NAME,STYLE_RN_NAME:STYLE_RN_NAME,REDUX_GET_FUNCTION:REDUX_GET_FUNCTION,REDUX_SET_FUNCTION:REDUX_SET_FUNCTION,REDUX_FUNCTIONS:REDUX_FUNCTIONS,PATHNAME:PATHNAME,SIMPLE_DATA_TYPES:SIMPLE_DATA_TYPES,V_CHILDREN_NAME:V_CHILDREN_NAME,V_COMP_NAME:V_COMP_NAME,LIST_SEMAPHORE:LIST_SEMAPHORE,LIST_ITEM:LIST_ITEM,LIST_PAGE:LIST_PAGE,LIST_ITEM_PER_PAGE:LIST_ITEM_PER_PAGE,LIST_LENGTH:LIST_LENGTH,LIST_ITEM_PER_PAGE_DEFAULT:LIST_ITEM_PER_PAGE_DEFAULT,REDUX_PATHS:REDUX_PATHS,V_CHILDREN_PREFIX:V_CHILDREN_PREFIX,PARENT_PROP_NAME:PARENT_PROP_NAME,CURRENT_PATH_NAME:CURRENT_PATH_NAME,PRIMITIVE_COMP_NAME:PRIMITIVE_COMP_NAME,FRAGMENT_COMP_NAME:FRAGMENT_COMP_NAME});var jsonpointer = {};var hasExcape = /~/;
|
|
5038
4991
|
var escapeMatcher = /~[01]/g;
|
|
5039
4992
|
function escapeReplacer (m) {
|
|
5040
4993
|
switch (m) {
|
|
@@ -6613,35 +6566,32 @@ var pullAll_1 = pullAll$1;var baseRest = _baseRest,
|
|
|
6613
6566
|
*/
|
|
6614
6567
|
var pull = baseRest(pullAll);
|
|
6615
6568
|
|
|
6616
|
-
var pull_1 = pull;
|
|
6617
|
-
|
|
6569
|
+
var pull_1 = pull;const findLastIndex = (arr, func) => {
|
|
6570
|
+
const reverseIdx = [...arr].reverse().findIndex(func);
|
|
6618
6571
|
return reverseIdx === -1 ? reverseIdx : arr.length - (reverseIdx + 1);
|
|
6619
6572
|
};
|
|
6620
|
-
|
|
6621
|
-
|
|
6622
|
-
|
|
6623
|
-
};
|
|
6624
|
-
var isNumber = function (a) { return typeof a === 'number'; };
|
|
6625
|
-
var jsonPointerGet = function (json, path) {
|
|
6573
|
+
const drop = (arr, n = 1) => arr.slice(n);
|
|
6574
|
+
const isNumber = (a) => typeof a === 'number';
|
|
6575
|
+
const jsonPointerGet = (json, path) => {
|
|
6626
6576
|
if (json === undefined || path === null || path === undefined || typeof path !== 'string')
|
|
6627
6577
|
return undefined;
|
|
6628
6578
|
if (path === SEPARATOR /* || path === '' same effect */)
|
|
6629
6579
|
return json;
|
|
6630
6580
|
try {
|
|
6631
|
-
return jsonpointer.get(json, path.startsWith(SEPARATOR) ? path :
|
|
6581
|
+
return jsonpointer.get(json, path.startsWith(SEPARATOR) ? path : `${SEPARATOR}${path}`);
|
|
6632
6582
|
}
|
|
6633
6583
|
catch (e) {
|
|
6634
6584
|
return undefined;
|
|
6635
6585
|
}
|
|
6636
6586
|
};
|
|
6637
|
-
|
|
6587
|
+
const jsonPointerSet = (json, path, value) => {
|
|
6638
6588
|
if (json === undefined || path === null || path === undefined || typeof path !== 'string')
|
|
6639
6589
|
return json;
|
|
6640
6590
|
if (path === SEPARATOR || path === '') {
|
|
6641
6591
|
return value;
|
|
6642
6592
|
}
|
|
6643
6593
|
try {
|
|
6644
|
-
jsonpointer.set(json, path.startsWith(SEPARATOR) ? path :
|
|
6594
|
+
jsonpointer.set(json, path.startsWith(SEPARATOR) ? path : `${SEPARATOR}${path}`, value);
|
|
6645
6595
|
return json;
|
|
6646
6596
|
// eslint-disable-next-line no-empty
|
|
6647
6597
|
}
|
|
@@ -6649,47 +6599,48 @@ var jsonPointerSet = function (json, path, value) {
|
|
|
6649
6599
|
return json;
|
|
6650
6600
|
}
|
|
6651
6601
|
};
|
|
6652
|
-
|
|
6653
|
-
|
|
6654
|
-
};
|
|
6655
|
-
var pathArrayToJsonPointer = function (array) { return "/".concat(array.join('/')); };
|
|
6602
|
+
const pathArrayToPathString = (array) => array.map((i, index) => (Number.isInteger(i) ? `[${i}]` : `${index > 0 ? '.' : ''}${i}`)).join('');
|
|
6603
|
+
const pathArrayToJsonPointer = (array) => `/${array.join('/')}`;
|
|
6656
6604
|
function isOnlyObject(item) {
|
|
6657
6605
|
return !!item && typeof item === 'object' && !Array.isArray(item);
|
|
6658
6606
|
}
|
|
6659
|
-
|
|
6607
|
+
const mergePath = (target, newState) => {
|
|
6660
6608
|
if (!newState || typeof newState !== 'object')
|
|
6661
6609
|
return target;
|
|
6662
|
-
|
|
6663
|
-
Object.entries(newState).forEach(
|
|
6664
|
-
var key = _a[0], value = _a[1];
|
|
6610
|
+
let newTarget = cloneDeep_1(target);
|
|
6611
|
+
Object.entries(newState).forEach(([key, value]) => {
|
|
6665
6612
|
newTarget = jsonPointerSet(newTarget, key, value);
|
|
6666
6613
|
});
|
|
6667
6614
|
return newTarget;
|
|
6668
6615
|
};
|
|
6669
6616
|
// eslint-disable-next-line import/prefer-default-export
|
|
6670
|
-
|
|
6671
|
-
|
|
6617
|
+
const changeRelativePath = (path) => {
|
|
6618
|
+
let pathArray = path.split(SEPARATOR);
|
|
6672
6619
|
// remove last /
|
|
6673
6620
|
if (pathArray && pathArray.length > 1 && pathArray[pathArray.length - 1] === '' && !(pathArray.length === 2 && pathArray[0] === '')) {
|
|
6674
6621
|
pathArray.pop();
|
|
6675
6622
|
}
|
|
6676
6623
|
// the last / is meaningful
|
|
6677
|
-
|
|
6624
|
+
const absolutepathIndex = findLastIndex(pathArray, (i) => i === '');
|
|
6678
6625
|
if (absolutepathIndex > 0) {
|
|
6679
6626
|
pathArray = drop(pathArray, absolutepathIndex);
|
|
6680
6627
|
}
|
|
6681
6628
|
// all . need to remove because is just pointing the prev level
|
|
6682
6629
|
pathArray = pull_1(pathArray, '.');
|
|
6683
|
-
|
|
6684
|
-
|
|
6630
|
+
let count = 0;
|
|
6631
|
+
let relativepathIndex = -1;
|
|
6685
6632
|
do {
|
|
6686
6633
|
count += 1;
|
|
6687
|
-
relativepathIndex = findIndex_1(pathArray,
|
|
6634
|
+
relativepathIndex = findIndex_1(pathArray, (i) => i === '..');
|
|
6688
6635
|
if (relativepathIndex !== -1) {
|
|
6689
6636
|
pathArray.splice(relativepathIndex, 1);
|
|
6690
6637
|
pathArray.splice(relativepathIndex - 1, 1);
|
|
6691
6638
|
}
|
|
6692
6639
|
} while (relativepathIndex !== -1 && count < 100);
|
|
6640
|
+
pathArray = pull_1(pathArray, '..');
|
|
6641
|
+
if (pathArray.length === 1 && pathArray[0] !== '') {
|
|
6642
|
+
pathArray = ['', ...pathArray];
|
|
6643
|
+
}
|
|
6693
6644
|
return pathArray.join(SEPARATOR);
|
|
6694
6645
|
};
|
|
6695
6646
|
/**
|
|
@@ -6697,171 +6648,170 @@ var changeRelativePath = function (path) {
|
|
|
6697
6648
|
* @param target
|
|
6698
6649
|
* @param ...sources
|
|
6699
6650
|
*/
|
|
6700
|
-
function mergeDeep(target) {
|
|
6701
|
-
var _a, _b;
|
|
6702
|
-
var sources = [];
|
|
6703
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
6704
|
-
sources[_i - 1] = arguments[_i];
|
|
6705
|
-
}
|
|
6651
|
+
function mergeDeep(target, ...sources) {
|
|
6706
6652
|
if (!sources.length)
|
|
6707
6653
|
return target;
|
|
6708
|
-
|
|
6654
|
+
const source = sources.shift();
|
|
6709
6655
|
if (isOnlyObject(target) && isOnlyObject(source)) {
|
|
6710
6656
|
// eslint-disable-next-line no-restricted-syntax
|
|
6711
|
-
for (
|
|
6657
|
+
for (const key in source) {
|
|
6712
6658
|
if (isOnlyObject(source[key])) {
|
|
6713
6659
|
if (!target[key])
|
|
6714
|
-
Object.assign(target,
|
|
6660
|
+
Object.assign(target, { [key]: {} });
|
|
6715
6661
|
mergeDeep(target[key], source[key]);
|
|
6716
6662
|
}
|
|
6717
6663
|
else {
|
|
6718
|
-
Object.assign(target,
|
|
6664
|
+
Object.assign(target, { [key]: source[key] });
|
|
6719
6665
|
}
|
|
6720
6666
|
}
|
|
6721
6667
|
}
|
|
6722
|
-
return mergeDeep
|
|
6668
|
+
return mergeDeep(target, ...sources);
|
|
6723
6669
|
}
|
|
6724
|
-
|
|
6725
|
-
|
|
6670
|
+
const collectObjMerge = (refConst, json) => {
|
|
6671
|
+
const res = {};
|
|
6726
6672
|
if (refConst && json && typeof json === 'object') {
|
|
6727
|
-
|
|
6673
|
+
const refs = [];
|
|
6728
6674
|
// eslint-disable-next-line func-names
|
|
6729
6675
|
traverse$3(json).forEach(function (x) {
|
|
6730
6676
|
if (x && !!x[refConst] && !!this && !this.circular) {
|
|
6731
|
-
|
|
6677
|
+
refs.push(x[refConst]);
|
|
6732
6678
|
}
|
|
6733
6679
|
});
|
|
6734
|
-
|
|
6680
|
+
refs.filter((i) => !!i).forEach((i) => mergeDeep(res, i));
|
|
6735
6681
|
}
|
|
6736
6682
|
return res;
|
|
6737
6683
|
};
|
|
6738
|
-
|
|
6684
|
+
const collectObjToArray = (refConst, json) => {
|
|
6739
6685
|
if (refConst && json && typeof json === 'object') {
|
|
6740
|
-
|
|
6686
|
+
const refs = [];
|
|
6741
6687
|
// eslint-disable-next-line func-names
|
|
6742
6688
|
traverse$3(json).forEach(function (x) {
|
|
6743
6689
|
if (x && !!x[refConst] && !!this && !this.circular) {
|
|
6744
|
-
|
|
6690
|
+
refs.push(x[refConst]);
|
|
6745
6691
|
}
|
|
6746
6692
|
});
|
|
6747
|
-
return
|
|
6693
|
+
return refs;
|
|
6748
6694
|
}
|
|
6749
6695
|
return [];
|
|
6750
|
-
};
|
|
6751
|
-
|
|
6752
|
-
|
|
6753
|
-
|
|
6754
|
-
|
|
6755
|
-
|
|
6756
|
-
|
|
6757
|
-
|
|
6758
|
-
|
|
6759
|
-
|
|
6760
|
-
|
|
6761
|
-
|
|
6762
|
-
|
|
6763
|
-
|
|
6764
|
-
|
|
6765
|
-
|
|
6766
|
-
|
|
6767
|
-
|
|
6768
|
-
|
|
6769
|
-
|
|
6770
|
-
|
|
6771
|
-
|
|
6696
|
+
};
|
|
6697
|
+
const isCircular = (d) => {
|
|
6698
|
+
try {
|
|
6699
|
+
JSON.stringify(d);
|
|
6700
|
+
}
|
|
6701
|
+
catch (e) {
|
|
6702
|
+
return true;
|
|
6703
|
+
}
|
|
6704
|
+
return false;
|
|
6705
|
+
};var util$1=/*#__PURE__*/Object.freeze({__proto__:null,findLastIndex:findLastIndex,drop:drop,isNumber:isNumber,jsonPointerGet:jsonPointerGet,jsonPointerSet:jsonPointerSet,pathArrayToPathString:pathArrayToPathString,pathArrayToJsonPointer:pathArrayToJsonPointer,isOnlyObject:isOnlyObject,mergePath:mergePath,changeRelativePath:changeRelativePath,mergeDeep:mergeDeep,collectObjMerge:collectObjMerge,collectObjToArray:collectObjToArray,isCircular:isCircular});const getFilteredPath = (_a, func) => {
|
|
6706
|
+
var _b = PARENT_PROP_NAME; _a[_b]; var propsNew = __rest(_a, [_b + ""]);
|
|
6707
|
+
const paths = [];
|
|
6708
|
+
function* jsonTraverse(o) {
|
|
6709
|
+
const memory = new Set();
|
|
6710
|
+
function* innerTraversal(oo, path = []) {
|
|
6711
|
+
var _a;
|
|
6712
|
+
if (memory.has(oo)) {
|
|
6713
|
+
return; // circular
|
|
6714
|
+
}
|
|
6715
|
+
memory.add(oo);
|
|
6716
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
6717
|
+
for (const i of Object.keys(oo)) {
|
|
6718
|
+
const itemPath = path.concat(i);
|
|
6719
|
+
if (itemPath && itemPath.length > 1 && typeof oo[i] === 'object' && ((_a = oo[i]) === null || _a === void 0 ? void 0 : _a[V_COMP_NAME])) {
|
|
6720
|
+
// eslint-disable-next-line no-continue
|
|
6721
|
+
continue;
|
|
6772
6722
|
}
|
|
6773
|
-
|
|
6774
|
-
|
|
6775
|
-
|
|
6776
|
-
|
|
6777
|
-
|
|
6778
|
-
|
|
6779
|
-
|
|
6780
|
-
|
|
6781
|
-
|
|
6782
|
-
}
|
|
6783
|
-
}
|
|
6784
|
-
|
|
6785
|
-
|
|
6786
|
-
}
|
|
6787
|
-
|
|
6788
|
-
|
|
6789
|
-
|
|
6790
|
-
|
|
6791
|
-
|
|
6792
|
-
|
|
6793
|
-
|
|
6794
|
-
|
|
6795
|
-
|
|
6796
|
-
|
|
6723
|
+
if (i === PARENT_PROP_NAME || i === CURRENT_PATH_NAME || i === LIST_ITEM) {
|
|
6724
|
+
// eslint-disable-next-line no-continue
|
|
6725
|
+
continue;
|
|
6726
|
+
}
|
|
6727
|
+
if (func({ key: i, value: oo[i], path, parent: oo, level: path.length })) {
|
|
6728
|
+
yield { key: i, value: oo[i], path, parent: oo, level: path.length };
|
|
6729
|
+
}
|
|
6730
|
+
if (oo[i] !== null && typeof oo[i] === 'object') {
|
|
6731
|
+
yield* innerTraversal(oo[i], itemPath);
|
|
6732
|
+
}
|
|
6733
|
+
}
|
|
6734
|
+
}
|
|
6735
|
+
yield* innerTraversal(o);
|
|
6736
|
+
}
|
|
6737
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
6738
|
+
for (const filteredvalue of jsonTraverse(propsNew)) {
|
|
6739
|
+
paths.push(filteredvalue);
|
|
6740
|
+
}
|
|
6741
|
+
return paths;
|
|
6742
|
+
};
|
|
6743
|
+
const actionBuilder = (props, stock) => {
|
|
6744
|
+
const _a = props, _b = PARENT_PROP_NAME; _a[_b]; const propsNew = __rest(_a, [_b + ""]);
|
|
6745
|
+
const paths = getFilteredPath(propsNew, ({ key }) => key === ACTION_KEY);
|
|
6746
|
+
orderBy_1(paths, ['level'], ['desc']).forEach((i) => __awaiter(void 0, void 0, void 0, function* () {
|
|
6747
|
+
const _c = traverse$3(props).get(i.path), _d = ACTION_KEY, functionName = _c[_d], functionParams = __rest(_c, [_d + ""]);
|
|
6748
|
+
traverse$3(props).set(i.path, (...callerArgs) => __awaiter(void 0, void 0, void 0, function* () {
|
|
6749
|
+
yield stock.callFunction(functionName, functionParams, props, callerArgs);
|
|
6750
|
+
}));
|
|
6751
|
+
}));
|
|
6752
|
+
};
|
|
6753
|
+
const calculatePropsFromModifier = (props, stock) => {
|
|
6754
|
+
const reduxPaths = [];
|
|
6755
|
+
const _a = props, _b = PARENT_PROP_NAME; _a[_b]; const propsNew = __rest(_a, [_b + ""]);
|
|
6756
|
+
const paths = getFilteredPath(propsNew, ({ key }) => key === MODIFIER_KEY);
|
|
6757
|
+
orderBy_1(paths, ['level'], ['desc']).forEach((i) => __awaiter(void 0, void 0, void 0, function* () {
|
|
6758
|
+
const _c = traverse$3(props).get(i.path), _d = MODIFIER_KEY, functionName = _c[_d], functionParams = __rest(_c, [_d + ""]);
|
|
6759
|
+
if (typeof functionName === 'string' && functionName === REDUX_GET_FUNCTION) {
|
|
6760
|
+
reduxPaths.push(functionParams);
|
|
6797
6761
|
}
|
|
6762
|
+
traverse$3(props).set(i.path, stock.callFunction(functionName, functionParams, props));
|
|
6763
|
+
}));
|
|
6764
|
+
return reduxPaths.map((i) => {
|
|
6765
|
+
return { store: i === null || i === void 0 ? void 0 : i.store, path: i === null || i === void 0 ? void 0 : i.path };
|
|
6798
6766
|
});
|
|
6799
|
-
orderBy_1(paths, ['level'], ['desc']).forEach(function (i) { return __awaiter(void 0, void 0, void 0, function () {
|
|
6800
|
-
var _a, _b, functionName, functionParams;
|
|
6801
|
-
return __generator(this, function (_c) {
|
|
6802
|
-
_a = traverse$3(props).get(i.path), _b = MODIFIER_KEY, functionName = _a[_b], functionParams = __rest(_a, [typeof _b === "symbol" ? _b : _b + ""]);
|
|
6803
|
-
traverse$3(props).set(i.path, stock.callFunction(functionName, functionParams, props));
|
|
6804
|
-
return [2 /*return*/];
|
|
6805
|
-
});
|
|
6806
|
-
}); });
|
|
6807
6767
|
};
|
|
6808
|
-
|
|
6809
|
-
|
|
6810
|
-
var modified = false;
|
|
6768
|
+
const getCurrentPaths = (props, pathModifier) => {
|
|
6769
|
+
const currentPaths = Object.assign({}, props[CURRENT_PATH_NAME]);
|
|
6811
6770
|
if (pathModifier && Object.keys(pathModifier).length !== 0) {
|
|
6812
|
-
Object.keys(pathModifier).forEach(
|
|
6813
|
-
var _a, _b;
|
|
6771
|
+
Object.keys(pathModifier).forEach((key) => {
|
|
6814
6772
|
if (!!key && !!pathModifier[key] && pathModifier[key][PATHNAME] !== undefined && pathModifier[key][PATHNAME] !== null) {
|
|
6815
|
-
|
|
6816
|
-
|
|
6817
|
-
|
|
6818
|
-
|
|
6819
|
-
currentPaths[key] = (_a = {}, _a[PATHNAME] = path, _a);
|
|
6773
|
+
const path = pathModifier[key][PATHNAME];
|
|
6774
|
+
const parent = currentPaths[key];
|
|
6775
|
+
if (`${path}`.startsWith(SEPARATOR) || !(parent && parent[PATHNAME])) {
|
|
6776
|
+
currentPaths[key] = { [PATHNAME]: path };
|
|
6820
6777
|
}
|
|
6821
6778
|
else {
|
|
6822
|
-
currentPaths[key] =
|
|
6779
|
+
currentPaths[key] = { [PATHNAME]: changeRelativePath(`${parent[PATHNAME]}${SEPARATOR}${path}`) };
|
|
6823
6780
|
}
|
|
6824
|
-
if (!!currentPaths[key] &&
|
|
6825
|
-
currentPaths[key][PATHNAME] =
|
|
6781
|
+
if (!!currentPaths[key] && !`${currentPaths[key][PATHNAME]}`.startsWith(SEPARATOR)) {
|
|
6782
|
+
currentPaths[key][PATHNAME] = `${SEPARATOR}${currentPaths[key][PATHNAME]}`;
|
|
6826
6783
|
}
|
|
6827
6784
|
}
|
|
6828
6785
|
});
|
|
6829
6786
|
}
|
|
6830
|
-
return
|
|
6787
|
+
return currentPaths;
|
|
6831
6788
|
};
|
|
6832
|
-
|
|
6833
|
-
|
|
6834
|
-
|
|
6835
|
-
return _a = {},
|
|
6836
|
-
_a[V_COMP_NAME] = 'Fragment',
|
|
6837
|
-
_a[V_CHILDREN_NAME] = props,
|
|
6838
|
-
_a;
|
|
6789
|
+
const normalisePrimitives = (props, parentComp) => {
|
|
6790
|
+
if (!!props && Array.isArray(props)) {
|
|
6791
|
+
return { [V_COMP_NAME]: FRAGMENT_COMP_NAME, [V_CHILDREN_NAME]: props, [PARENT_PROP_NAME]: parentComp };
|
|
6839
6792
|
}
|
|
6840
|
-
|
|
6841
|
-
|
|
6842
|
-
|
|
6843
|
-
|
|
6844
|
-
delete res[i];
|
|
6845
|
-
return res;
|
|
6793
|
+
if (props === null || SIMPLE_DATA_TYPES.includes(typeof props)) {
|
|
6794
|
+
return { [V_COMP_NAME]: PRIMITIVE_COMP_NAME, [V_CHILDREN_NAME]: props, [PARENT_PROP_NAME]: parentComp };
|
|
6795
|
+
}
|
|
6796
|
+
return Object.assign(Object.assign({}, props), { [PARENT_PROP_NAME]: parentComp });
|
|
6846
6797
|
};
|
|
6847
|
-
|
|
6848
|
-
|
|
6849
|
-
|
|
6850
|
-
|
|
6851
|
-
|
|
6852
|
-
var listItem = props[LIST_ITEM];
|
|
6798
|
+
const genChildenFromListItem = (props, stock) => {
|
|
6799
|
+
let page = !!props[LIST_PAGE] && isNumber(props[LIST_PAGE]) ? props[LIST_PAGE] : 0;
|
|
6800
|
+
let listLength = !!props[LIST_LENGTH] && isNumber(props[LIST_LENGTH]) ? props[LIST_LENGTH] : undefined;
|
|
6801
|
+
let itemPerPage = !!props[LIST_ITEM_PER_PAGE] && isNumber(props[LIST_ITEM_PER_PAGE]) ? props[LIST_ITEM_PER_PAGE] : undefined;
|
|
6802
|
+
const listItem = props[LIST_ITEM];
|
|
6853
6803
|
if (!listItem)
|
|
6854
6804
|
return undefined;
|
|
6855
|
-
|
|
6805
|
+
const currentPaths = props[CURRENT_PATH_NAME];
|
|
6856
6806
|
if (!currentPaths)
|
|
6857
6807
|
return undefined;
|
|
6858
|
-
|
|
6808
|
+
const store = Object.keys(currentPaths)[0];
|
|
6859
6809
|
if (!store)
|
|
6860
6810
|
return undefined;
|
|
6861
|
-
|
|
6811
|
+
const { path } = currentPaths[store];
|
|
6862
6812
|
if (currentPaths && !listLength) {
|
|
6863
6813
|
if (path) {
|
|
6864
|
-
|
|
6814
|
+
const list = stock.callFunction('get', { store, path });
|
|
6865
6815
|
listLength = !!list && Array.isArray(list) ? list.length : 0;
|
|
6866
6816
|
}
|
|
6867
6817
|
}
|
|
@@ -6871,45 +6821,80 @@ var genChildenFromListItem = function (props, stock) {
|
|
|
6871
6821
|
page = Number.isInteger(page) && page >= 0 ? page : 0;
|
|
6872
6822
|
itemPerPage = !!itemPerPage && Number.isInteger(itemPerPage) && itemPerPage >= 0 ? itemPerPage : 0;
|
|
6873
6823
|
listLength = !!listLength && Number.isInteger(listLength) && listLength >= 0 ? listLength : 0;
|
|
6874
|
-
|
|
6875
|
-
|
|
6824
|
+
const offset = page * itemPerPage <= listLength ? page * itemPerPage : 0;
|
|
6825
|
+
const children = [];
|
|
6876
6826
|
// eslint-disable-next-line no-plusplus
|
|
6877
|
-
for (
|
|
6878
|
-
children.push(
|
|
6879
|
-
|
|
6880
|
-
|
|
6881
|
-
|
|
6882
|
-
|
|
6827
|
+
for (let i = offset; i < listLength && i < offset + itemPerPage; i++) {
|
|
6828
|
+
children.push(Object.assign(Object.assign({}, listItem), { [PATH_MODIFIERS_KEY]: {
|
|
6829
|
+
[store]: {
|
|
6830
|
+
path: `.${SEPARATOR}${i}`,
|
|
6831
|
+
},
|
|
6832
|
+
} }));
|
|
6883
6833
|
}
|
|
6884
6834
|
return children.length > 0 ? children : undefined;
|
|
6885
6835
|
};
|
|
6886
|
-
|
|
6887
|
-
|
|
6888
|
-
|
|
6836
|
+
const getRootWrapperProps = (props, stock) => {
|
|
6837
|
+
const newProps = Object.assign({}, props);
|
|
6838
|
+
const subscriberPaths = calculatePropsFromModifier(newProps, stock);
|
|
6889
6839
|
actionBuilder(newProps, stock);
|
|
6890
6840
|
if (newProps[LIST_SEMAPHORE]) {
|
|
6891
6841
|
newProps[V_CHILDREN_NAME] = genChildenFromListItem(newProps, stock);
|
|
6892
6842
|
}
|
|
6843
|
+
newProps.subscriberPaths = subscriberPaths;
|
|
6893
6844
|
return newProps;
|
|
6894
6845
|
};
|
|
6895
|
-
|
|
6896
|
-
|
|
6846
|
+
const isChildrenProps = (propName) => !!propName && typeof propName === 'string' && propName.startsWith(V_CHILDREN_PREFIX);
|
|
6847
|
+
const getParentProps = (props) => {
|
|
6848
|
+
return props && typeof props === 'object' && !Array.isArray(props)
|
|
6849
|
+
? Object.keys(props)
|
|
6850
|
+
.filter((key) => !isChildrenProps(key) && key !== PARENT_PROP_NAME)
|
|
6851
|
+
.reduce((newObj, key) => {
|
|
6852
|
+
// eslint-disable-next-line no-param-reassign
|
|
6853
|
+
newObj[key] = props[key];
|
|
6854
|
+
return newObj;
|
|
6855
|
+
}, {})
|
|
6856
|
+
: {};
|
|
6857
|
+
};
|
|
6858
|
+
const getPropsChildrenFilter = ({ props, filter }) => props && typeof props === 'object' && !Array.isArray(props)
|
|
6859
|
+
? Object.keys(props)
|
|
6860
|
+
.filter((key) => ((filter === 'withoutChildren' && !isChildrenProps(key)) || (filter === 'onlyChildren' && isChildrenProps(key))) && key !== PARENT_PROP_NAME)
|
|
6861
|
+
.reduce((newObj, key) => {
|
|
6862
|
+
// eslint-disable-next-line no-param-reassign
|
|
6863
|
+
newObj[key] = props[key];
|
|
6864
|
+
return newObj;
|
|
6865
|
+
}, {})
|
|
6866
|
+
: {};
|
|
6867
|
+
const getChildrensForRoot = (props, children, Wrapper) => {
|
|
6897
6868
|
// eslint-disable-next-line no-nested-ternary
|
|
6898
6869
|
if (!!props && Array.isArray(children)) {
|
|
6899
|
-
return children.map(
|
|
6870
|
+
return children.map((childrenItem, index) => {
|
|
6900
6871
|
// eslint-disable-next-line react/no-array-index-key
|
|
6901
|
-
return jsxRuntime.exports.jsx(Wrapper,
|
|
6872
|
+
return jsxRuntime.exports.jsx(Wrapper, { props: normalisePrimitives(childrenItem, getParentProps(props)) }, index);
|
|
6902
6873
|
});
|
|
6903
6874
|
}
|
|
6904
6875
|
if (!!props && !!children) {
|
|
6905
|
-
return jsxRuntime.exports.jsx(Wrapper,
|
|
6876
|
+
return jsxRuntime.exports.jsx(Wrapper, { props: normalisePrimitives(children, getParentProps(props)) }, void 0);
|
|
6877
|
+
}
|
|
6878
|
+
return undefined;
|
|
6879
|
+
};
|
|
6880
|
+
const generateChildren = (props, { Wrapper }) => props[V_COMP_NAME] !== '_PrimitiveProp' ? getChildrensForRoot(props, props[V_CHILDREN_NAME], Wrapper) : props[V_CHILDREN_NAME];
|
|
6881
|
+
const generateNewChildren = (props, { Wrapper }) => {
|
|
6882
|
+
// eslint-disable-next-line no-nested-ternary
|
|
6883
|
+
if (props) {
|
|
6884
|
+
if (Array.isArray(props)) {
|
|
6885
|
+
return props.map((childrenItem, index) => {
|
|
6886
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
6887
|
+
return jsxRuntime.exports.jsx(Wrapper, { props: normalisePrimitives(childrenItem, getParentProps(props)) }, index);
|
|
6888
|
+
});
|
|
6889
|
+
}
|
|
6890
|
+
return jsxRuntime.exports.jsx(Wrapper, { props: normalisePrimitives(props, getParentProps(props)) }, void 0);
|
|
6906
6891
|
}
|
|
6907
6892
|
return undefined;
|
|
6908
6893
|
};
|
|
6909
|
-
|
|
6910
|
-
|
|
6911
|
-
return
|
|
6912
|
-
};var wrapperUtil=/*#__PURE__*/Object.freeze({__proto__:null,actionBuilder:actionBuilder,
|
|
6894
|
+
const removeTechnicalProps = (changeableProps) => {
|
|
6895
|
+
const _a = changeableProps, _b = PARENT_PROP_NAME; _a[_b]; const _c = STYLE_WEB_NAME; _a[_c]; const _d = V_COMP_NAME; _a[_d]; const _e = PATH_MODIFIERS_KEY; _a[_e]; const _f = CURRENT_PATH_NAME; _a[_f]; const _g = PATH_MODIFIERS_KEY; _a[_g]; const _h = LIST_SEMAPHORE; _a[_h]; const _j = LIST_ITEM; _a[_j]; const _k = LIST_PAGE; _a[_k]; const _l = LIST_ITEM_PER_PAGE; _a[_l]; const _m = LIST_LENGTH; _a[_m]; const newProps = __rest(_a, [_b + "", "style", _c + "", _d + "", _e + "", _f + "", "subscriberPaths", _g + "", _h + "", _j + "", _k + "", _l + "", _m + ""]);
|
|
6896
|
+
return newProps;
|
|
6897
|
+
};var wrapperUtil=/*#__PURE__*/Object.freeze({__proto__:null,getFilteredPath:getFilteredPath,actionBuilder:actionBuilder,calculatePropsFromModifier:calculatePropsFromModifier,getCurrentPaths:getCurrentPaths,normalisePrimitives:normalisePrimitives,getRootWrapperProps:getRootWrapperProps,isChildrenProps:isChildrenProps,getParentProps:getParentProps,getPropsChildrenFilter:getPropsChildrenFilter,getChildrensForRoot:getChildrensForRoot,generateChildren:generateChildren,generateNewChildren:generateNewChildren,removeTechnicalProps:removeTechnicalProps});var ajv = {exports: {}};var core$2 = {};var validate = {};var boolSchema = {};var errors = {};var codegen = {};var code$1 = {};(function (exports) {
|
|
6913
6898
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6914
6899
|
exports.regexpCode = exports.getEsmExportName = exports.getProperty = exports.safeStringify = exports.stringify = exports.strConcat = exports.addCodeArg = exports.str = exports._ = exports.nil = exports._Code = exports.Name = exports.IDENTIFIER = exports._CodeOrName = void 0;
|
|
6915
6900
|
class _CodeOrName {
|
|
@@ -13834,7 +13819,7 @@ var src = function(str, data, delimiter = [ '{{ ', ' }}' ]) {
|
|
|
13834
13819
|
|
|
13835
13820
|
return str
|
|
13836
13821
|
|
|
13837
|
-
};
|
|
13822
|
+
};const I18nSchema = {
|
|
13838
13823
|
$id: 'http://example.com/schemas/schema.json',
|
|
13839
13824
|
type: 'object',
|
|
13840
13825
|
additionalProperties: {
|
|
@@ -13859,28 +13844,26 @@ var src = function(str, data, delimiter = [ '{{ ', ' }}' ]) {
|
|
|
13859
13844
|
},
|
|
13860
13845
|
minProperties: 1,
|
|
13861
13846
|
};
|
|
13862
|
-
|
|
13847
|
+
class I18n {
|
|
13863
13848
|
// eslint-disable-next-line consistent-this
|
|
13864
|
-
|
|
13865
|
-
|
|
13866
|
-
|
|
13867
|
-
this.getLocales = function () { return (_this.language.includes('-') ? _this.language.split('-') : _this.language.split('_') || [])[0]; };
|
|
13868
|
-
this.t = function (key, options, language) {
|
|
13849
|
+
constructor({ language = 'en', resources, nonExistsHandler, keyPrefix = '{{', keyPostfix = '}}' }) {
|
|
13850
|
+
this.getLocales = () => (this.language.includes('-') ? this.language.split('-') : this.language.split('_') || [])[0];
|
|
13851
|
+
this.t = (key, options, language) => {
|
|
13869
13852
|
if (!(typeof key === 'string')) {
|
|
13870
13853
|
return key;
|
|
13871
13854
|
}
|
|
13872
|
-
if (!
|
|
13855
|
+
if (!this.resources || (!this.resources && !this.language && !language) || !this.resources[`${this.availableLanguageKey || language}`]) {
|
|
13873
13856
|
return key;
|
|
13874
13857
|
}
|
|
13875
|
-
|
|
13858
|
+
const value = this.resources[`${this.availableLanguageKey || language}`].translation[key];
|
|
13876
13859
|
if (value === undefined) {
|
|
13877
|
-
if (
|
|
13878
|
-
return
|
|
13860
|
+
if (this.nonExistsHandler && typeof this.nonExistsHandler === 'function') {
|
|
13861
|
+
return this.nonExistsHandler(key);
|
|
13879
13862
|
}
|
|
13880
13863
|
return key;
|
|
13881
13864
|
}
|
|
13882
13865
|
if (options) {
|
|
13883
|
-
return src(value, options, [
|
|
13866
|
+
return src(value, options, [this.keyPrefix, this.keyPostfix]);
|
|
13884
13867
|
}
|
|
13885
13868
|
return value;
|
|
13886
13869
|
};
|
|
@@ -13888,9 +13871,9 @@ var I18n = /** @class */ (function () {
|
|
|
13888
13871
|
this.nonExistsHandler = nonExistsHandler;
|
|
13889
13872
|
this.keyPrefix = keyPrefix;
|
|
13890
13873
|
this.keyPostfix = keyPostfix;
|
|
13891
|
-
|
|
13892
|
-
|
|
13893
|
-
|
|
13874
|
+
const ajv = new Ajv();
|
|
13875
|
+
const validate = ajv.compile(I18nSchema);
|
|
13876
|
+
const isValid = validate(resources);
|
|
13894
13877
|
if (isValid) {
|
|
13895
13878
|
this.resources = resources;
|
|
13896
13879
|
}
|
|
@@ -13902,84 +13885,49 @@ var I18n = /** @class */ (function () {
|
|
|
13902
13885
|
this.availableLanguageKey = this.getLocales();
|
|
13903
13886
|
}
|
|
13904
13887
|
}
|
|
13905
|
-
|
|
13906
|
-
}
|
|
13907
|
-
|
|
13908
|
-
|
|
13909
|
-
|
|
13910
|
-
var store = _a.store, path = _a.path, _b = _a.isError, isError = _b === void 0 ? false : _b;
|
|
13911
|
-
var state = getState(globalState);
|
|
13888
|
+
}const StockContext = createContext(null);
|
|
13889
|
+
const PathModifierContext = createContext({});const getState = (state) => state === null || state === void 0 ? void 0 : state.root;
|
|
13890
|
+
const getValue = (state, store, path) => jsonPointerGet(state[store], path) || null;
|
|
13891
|
+
const getStateValue$1 = (globalState, { store, path, isError = false }, currentPaths) => {
|
|
13892
|
+
const state = getState(globalState);
|
|
13912
13893
|
if (state && store && path) {
|
|
13913
|
-
|
|
13914
|
-
return getValue(state,
|
|
13894
|
+
const convertedPath = currentPaths && currentPaths[store] && currentPaths[store].path ? changeRelativePath(`${currentPaths[store].path}${SEPARATOR}${path}`) : path;
|
|
13895
|
+
return getValue(state, `${store}${isError ? STORE_ERROR_POSTFIX : ''}`, convertedPath);
|
|
13915
13896
|
}
|
|
13916
13897
|
return null;
|
|
13917
13898
|
};
|
|
13918
|
-
|
|
13919
|
-
|
|
13920
|
-
|
|
13921
|
-
|
|
13922
|
-
|
|
13923
|
-
|
|
13924
|
-
|
|
13925
|
-
|
|
13926
|
-
|
|
13927
|
-
if (!!x && !!x[MODIFIER_KEY] && x[MODIFIER_KEY] === 'get' && !(this.path.length > 1 && this.path.includes(V_CHILDREN_NAME))) {
|
|
13928
|
-
paths.push({ path: this.path, level: this.level });
|
|
13929
|
-
}
|
|
13930
|
-
});
|
|
13931
|
-
orderBy_1(paths, ['level'], ['desc']).forEach(function (i) { return __awaiter(void 0, void 0, void 0, function () {
|
|
13932
|
-
var _a, _b, functionName, functionParams, value, jsonata, expression;
|
|
13933
|
-
return __generator(this, function (_c) {
|
|
13934
|
-
_a = traverse$3(props).get(i.path), _b = MODIFIER_KEY, functionName = _a[_b], functionParams = __rest(_a, [typeof _b === "symbol" ? _b : _b + ""]);
|
|
13935
|
-
if (functionName === 'get' && functionParams.store && functionParams.path) {
|
|
13936
|
-
value = getStateValue$1(globalState, functionParams, currentPaths);
|
|
13937
|
-
if (functionParams.jsonataDef) {
|
|
13938
|
-
try {
|
|
13939
|
-
jsonata = require('jsonata');
|
|
13940
|
-
expression = jsonata(functionParams.jsonataDef);
|
|
13941
|
-
value = expression.evaluate(value);
|
|
13942
|
-
}
|
|
13943
|
-
catch (error) {
|
|
13944
|
-
// eslint-disable-next-line no-console
|
|
13945
|
-
console.error('jsonata error', error, functionParams.jsonataDef);
|
|
13946
|
-
}
|
|
13947
|
-
}
|
|
13948
|
-
// traverse(result).set(i.path, value)
|
|
13949
|
-
result[pathArrayToJsonPointer(i.path)] = value;
|
|
13950
|
-
}
|
|
13951
|
-
return [2 /*return*/];
|
|
13952
|
-
});
|
|
13953
|
-
}); });
|
|
13954
|
-
return result;
|
|
13955
|
-
};var DATA_UPDATE = 'DATA_UPDATE';
|
|
13956
|
-
var PURGE = 'PURGE';
|
|
13957
|
-
var set$1 = function (payload) { return ({
|
|
13899
|
+
const compSelectorHook = (currentPaths, subscriberPaths) => (state) => {
|
|
13900
|
+
if (typeof subscriberPaths === 'object' && Array.isArray(subscriberPaths) && (subscriberPaths === null || subscriberPaths === void 0 ? void 0 : subscriberPaths.length) > 0) {
|
|
13901
|
+
return subscriberPaths.map((subscriberPath) => getStateValue$1(state, subscriberPath, currentPaths));
|
|
13902
|
+
}
|
|
13903
|
+
// TODO isError, currentPaths, root need to solve propperly
|
|
13904
|
+
return undefined;
|
|
13905
|
+
};const DATA_UPDATE = 'DATA_UPDATE';
|
|
13906
|
+
const PURGE = 'PURGE';
|
|
13907
|
+
const set$1 = (payload) => ({
|
|
13958
13908
|
type: DATA_UPDATE,
|
|
13959
|
-
payload
|
|
13960
|
-
});
|
|
13961
|
-
|
|
13909
|
+
payload,
|
|
13910
|
+
});
|
|
13911
|
+
const purge = (payload) => ({
|
|
13962
13912
|
type: PURGE,
|
|
13963
|
-
payload
|
|
13964
|
-
});
|
|
13965
|
-
|
|
13966
|
-
|
|
13967
|
-
|
|
13968
|
-
|
|
13969
|
-
}
|
|
13970
|
-
|
|
13971
|
-
|
|
13972
|
-
|
|
13973
|
-
|
|
13974
|
-
|
|
13975
|
-
};
|
|
13976
|
-
var set = function (attr, props, callerArgs, stock) {
|
|
13977
|
-
stock.reduxStore.dispatch(set$1(__assign(__assign({}, attr), { value: attr && attr.value !== undefined ? attr.value : callerArgs[0], currentPaths: props.currentPaths, stock: stock })));
|
|
13913
|
+
payload,
|
|
13914
|
+
});const getStateValue = (attr, { [CURRENT_PATH_NAME]: currentPaths } = {}, callerArgs, stock) => {
|
|
13915
|
+
const { store, path } = attr;
|
|
13916
|
+
const state = stock.reduxStore.getState();
|
|
13917
|
+
return getStateValue$1(state, { store, path }, currentPaths);
|
|
13918
|
+
};
|
|
13919
|
+
const get = (attr, { [CURRENT_PATH_NAME]: currentPaths } = {}, callerArgs, stock) => {
|
|
13920
|
+
const { store, path } = attr;
|
|
13921
|
+
const state = stock.reduxStore.getState();
|
|
13922
|
+
return getStateValue$1(state, { store, path }, currentPaths);
|
|
13923
|
+
};
|
|
13924
|
+
const set = (attr, props, callerArgs, stock) => {
|
|
13925
|
+
stock.reduxStore.dispatch(set$1(Object.assign(Object.assign({}, attr), { value: attr && attr.value !== undefined ? attr.value : callerArgs[0], [CURRENT_PATH_NAME]: props[CURRENT_PATH_NAME], stock })));
|
|
13978
13926
|
};
|
|
13979
13927
|
var functions = {
|
|
13980
|
-
getStateValue
|
|
13981
|
-
get
|
|
13982
|
-
set
|
|
13928
|
+
getStateValue,
|
|
13929
|
+
get,
|
|
13930
|
+
set,
|
|
13983
13931
|
};/**
|
|
13984
13932
|
* Adapted from React: https://github.com/facebook/react/blob/master/packages/shared/formatProdErrorMessage.js
|
|
13985
13933
|
*
|
|
@@ -14485,11 +14433,11 @@ var pick = flatRest(function(object, paths) {
|
|
|
14485
14433
|
return object == null ? {} : basePick(object, paths);
|
|
14486
14434
|
});
|
|
14487
14435
|
|
|
14488
|
-
var pick_1 = pick;
|
|
14436
|
+
var pick_1 = pick;const SetTransform = createTransform((inboundState, key) => {
|
|
14489
14437
|
if (key !== 'root')
|
|
14490
14438
|
return inboundState;
|
|
14491
14439
|
return pick_1(inboundState, PERSIST_STORAGE_NAMES);
|
|
14492
|
-
},
|
|
14440
|
+
}, (outboundState, key) => {
|
|
14493
14441
|
if (key !== 'root')
|
|
14494
14442
|
return outboundState;
|
|
14495
14443
|
return pick_1(outboundState, PERSIST_STORAGE_NAMES);
|
|
@@ -14499,81 +14447,80 @@ var persistConfig = {
|
|
|
14499
14447
|
whitelist: ['root'],
|
|
14500
14448
|
transforms: [SetTransform],
|
|
14501
14449
|
};function n(n){for(var r=arguments.length,t=Array(r>1?r-1:0),e=1;e<r;e++)t[e-1]=arguments[e];if("production"!==process.env.NODE_ENV){var i=Y[n],o=i?"function"==typeof i?i.apply(null,t):i:"unknown error nr: "+n;throw Error("[Immer] "+o)}throw Error("[Immer] minified error nr: "+n+(t.length?" "+t.map((function(n){return "'"+n+"'"})).join(","):"")+". Find the full error at: https://bit.ly/3cXEKWf")}function r(n){return !!n&&!!n[Q]}function t(n){return !!n&&(function(n){if(!n||"object"!=typeof n)return !1;var r=Object.getPrototypeOf(n);if(null===r)return !0;var t=Object.hasOwnProperty.call(r,"constructor")&&r.constructor;return t===Object||"function"==typeof t&&Function.toString.call(t)===Z}(n)||Array.isArray(n)||!!n[L]||!!n.constructor[L]||s(n)||v(n))}function i(n,r,t){void 0===t&&(t=!1),0===o(n)?(t?Object.keys:nn)(n).forEach((function(e){t&&"symbol"==typeof e||r(e,n[e],n);})):n.forEach((function(t,e){return r(e,t,n)}));}function o(n){var r=n[Q];return r?r.i>3?r.i-4:r.i:Array.isArray(n)?1:s(n)?2:v(n)?3:0}function u(n,r){return 2===o(n)?n.has(r):Object.prototype.hasOwnProperty.call(n,r)}function a(n,r){return 2===o(n)?n.get(r):n[r]}function f(n,r,t){var e=o(n);2===e?n.set(r,t):3===e?(n.delete(r),n.add(t)):n[r]=t;}function c(n,r){return n===r?0!==n||1/n==1/r:n!=n&&r!=r}function s(n){return X&&n instanceof Map}function v(n){return q&&n instanceof Set}function p(n){return n.o||n.t}function l(n){if(Array.isArray(n))return Array.prototype.slice.call(n);var r=rn(n);delete r[Q];for(var t=nn(r),e=0;e<t.length;e++){var i=t[e],o=r[i];!1===o.writable&&(o.writable=!0,o.configurable=!0),(o.get||o.set)&&(r[i]={configurable:!0,writable:!0,enumerable:o.enumerable,value:n[i]});}return Object.create(Object.getPrototypeOf(n),r)}function d(n,e){return void 0===e&&(e=!1),y(n)||r(n)||!t(n)?n:(o(n)>1&&(n.set=n.add=n.clear=n.delete=h),Object.freeze(n),e&&i(n,(function(n,r){return d(r,!0)}),!0),n)}function h(){n(2);}function y(n){return null==n||"object"!=typeof n||Object.isFrozen(n)}function b(r){var t=tn[r];return t||n(18,r),t}function _(){return "production"===process.env.NODE_ENV||U||n(0),U}function j(n,r){r&&(b("Patches"),n.u=[],n.s=[],n.v=r);}function O(n){g(n),n.p.forEach(S),n.p=null;}function g(n){n===U&&(U=n.l);}function w(n){return U={p:[],l:U,h:n,m:!0,_:0}}function S(n){var r=n[Q];0===r.i||1===r.i?r.j():r.O=!0;}function P(r,e){e._=e.p.length;var i=e.p[0],o=void 0!==r&&r!==i;return e.h.g||b("ES5").S(e,r,o),o?(i[Q].P&&(O(e),n(4)),t(r)&&(r=M(e,r),e.l||x(e,r)),e.u&&b("Patches").M(i[Q].t,r,e.u,e.s)):r=M(e,i,[]),O(e),e.u&&e.v(e.u,e.s),r!==H?r:void 0}function M(n,r,t){if(y(r))return r;var e=r[Q];if(!e)return i(r,(function(i,o){return A(n,e,r,i,o,t)}),!0),r;if(e.A!==n)return r;if(!e.P)return x(n,e.t,!0),e.t;if(!e.I){e.I=!0,e.A._--;var o=4===e.i||5===e.i?e.o=l(e.k):e.o;i(3===e.i?new Set(o):o,(function(r,i){return A(n,e,o,r,i,t)})),x(n,o,!1),t&&n.u&&b("Patches").R(e,t,n.u,n.s);}return e.o}function A(e,i,o,a,c,s){if("production"!==process.env.NODE_ENV&&c===o&&n(5),r(c)){var v=M(e,c,s&&i&&3!==i.i&&!u(i.D,a)?s.concat(a):void 0);if(f(o,a,v),!r(v))return;e.m=!1;}if(t(c)&&!y(c)){if(!e.h.F&&e._<1)return;M(e,c),i&&i.A.l||x(e,c);}}function x(n,r,t){void 0===t&&(t=!1),n.h.F&&n.m&&d(r,t);}function z(n,r){var t=n[Q];return (t?p(t):n)[r]}function I(n,r){if(r in n)for(var t=Object.getPrototypeOf(n);t;){var e=Object.getOwnPropertyDescriptor(t,r);if(e)return e;t=Object.getPrototypeOf(t);}}function k(n){n.P||(n.P=!0,n.l&&k(n.l));}function E(n){n.o||(n.o=l(n.t));}function R(n,r,t){var e=s(r)?b("MapSet").N(r,t):v(r)?b("MapSet").T(r,t):n.g?function(n,r){var t=Array.isArray(n),e={i:t?1:0,A:r?r.A:_(),P:!1,I:!1,D:{},l:r,t:n,k:null,o:null,j:null,C:!1},i=e,o=en;t&&(i=[e],o=on);var u=Proxy.revocable(i,o),a=u.revoke,f=u.proxy;return e.k=f,e.j=a,f}(r,t):b("ES5").J(r,t);return (t?t.A:_()).p.push(e),e}function D(e){return r(e)||n(22,e),function n(r){if(!t(r))return r;var e,u=r[Q],c=o(r);if(u){if(!u.P&&(u.i<4||!b("ES5").K(u)))return u.t;u.I=!0,e=F(r,c),u.I=!1;}else e=F(r,c);return i(e,(function(r,t){u&&a(u.t,r)===t||f(e,r,n(t));})),3===c?new Set(e):e}(e)}function F(n,r){switch(r){case 2:return new Map(n);case 3:return Array.from(n)}return l(n)}var G,U,W="undefined"!=typeof Symbol&&"symbol"==typeof Symbol("x"),X="undefined"!=typeof Map,q="undefined"!=typeof Set,B="undefined"!=typeof Proxy&&void 0!==Proxy.revocable&&"undefined"!=typeof Reflect,H=W?Symbol.for("immer-nothing"):((G={})["immer-nothing"]=!0,G),L=W?Symbol.for("immer-draftable"):"__$immer_draftable",Q=W?Symbol.for("immer-state"):"__$immer_state",Y={0:"Illegal state",1:"Immer drafts cannot have computed properties",2:"This object has been frozen and should not be mutated",3:function(n){return "Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+n},4:"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.",5:"Immer forbids circular references",6:"The first or second argument to `produce` must be a function",7:"The third argument to `produce` must be a function or undefined",8:"First argument to `createDraft` must be a plain object, an array, or an immerable object",9:"First argument to `finishDraft` must be a draft returned by `createDraft`",10:"The given draft is already finalized",11:"Object.defineProperty() cannot be used on an Immer draft",12:"Object.setPrototypeOf() cannot be used on an Immer draft",13:"Immer only supports deleting array indices",14:"Immer only supports setting array indices and the 'length' property",15:function(n){return "Cannot apply patch, path doesn't resolve: "+n},16:'Sets cannot have "replace" patches.',17:function(n){return "Unsupported patch operation: "+n},18:function(n){return "The plugin for '"+n+"' has not been loaded into Immer. To enable the plugin, import and call `enable"+n+"()` when initializing your application."},20:"Cannot use proxies if Proxy, Proxy.revocable or Reflect are not available",21:function(n){return "produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '"+n+"'"},22:function(n){return "'current' expects a draft, got: "+n},23:function(n){return "'original' expects a draft, got: "+n},24:"Patching reserved attributes like __proto__, prototype and constructor is not allowed"},Z=""+Object.prototype.constructor,nn="undefined"!=typeof Reflect&&Reflect.ownKeys?Reflect.ownKeys:void 0!==Object.getOwnPropertySymbols?function(n){return Object.getOwnPropertyNames(n).concat(Object.getOwnPropertySymbols(n))}:Object.getOwnPropertyNames,rn=Object.getOwnPropertyDescriptors||function(n){var r={};return nn(n).forEach((function(t){r[t]=Object.getOwnPropertyDescriptor(n,t);})),r},tn={},en={get:function(n,r){if(r===Q)return n;var e=p(n);if(!u(e,r))return function(n,r,t){var e,i=I(r,t);return i?"value"in i?i.value:null===(e=i.get)||void 0===e?void 0:e.call(n.k):void 0}(n,e,r);var i=e[r];return n.I||!t(i)?i:i===z(n.t,r)?(E(n),n.o[r]=R(n.A.h,i,n)):i},has:function(n,r){return r in p(n)},ownKeys:function(n){return Reflect.ownKeys(p(n))},set:function(n,r,t){var e=I(p(n),r);if(null==e?void 0:e.set)return e.set.call(n.k,t),!0;if(!n.P){var i=z(p(n),r),o=null==i?void 0:i[Q];if(o&&o.t===t)return n.o[r]=t,n.D[r]=!1,!0;if(c(t,i)&&(void 0!==t||u(n.t,r)))return !0;E(n),k(n);}return n.o[r]===t&&"number"!=typeof t&&(void 0!==t||r in n.o)||(n.o[r]=t,n.D[r]=!0,!0)},deleteProperty:function(n,r){return void 0!==z(n.t,r)||r in n.t?(n.D[r]=!1,E(n),k(n)):delete n.D[r],n.o&&delete n.o[r],!0},getOwnPropertyDescriptor:function(n,r){var t=p(n),e=Reflect.getOwnPropertyDescriptor(t,r);return e?{writable:!0,configurable:1!==n.i||"length"!==r,enumerable:e.enumerable,value:t[r]}:e},defineProperty:function(){n(11);},getPrototypeOf:function(n){return Object.getPrototypeOf(n.t)},setPrototypeOf:function(){n(12);}},on={};i(en,(function(n,r){on[n]=function(){return arguments[0]=arguments[0][0],r.apply(this,arguments)};})),on.deleteProperty=function(r,t){return "production"!==process.env.NODE_ENV&&isNaN(parseInt(t))&&n(13),on.set.call(this,r,t,void 0)},on.set=function(r,t,e){return "production"!==process.env.NODE_ENV&&"length"!==t&&isNaN(parseInt(t))&&n(14),en.set.call(this,r[0],t,e,r[0])};var un=function(){function e(r){var e=this;this.g=B,this.F=!0,this.produce=function(r,i,o){if("function"==typeof r&&"function"!=typeof i){var u=i;i=r;var a=e;return function(n){var r=this;void 0===n&&(n=u);for(var t=arguments.length,e=Array(t>1?t-1:0),o=1;o<t;o++)e[o-1]=arguments[o];return a.produce(n,(function(n){var t;return (t=i).call.apply(t,[r,n].concat(e))}))}}var f;if("function"!=typeof i&&n(6),void 0!==o&&"function"!=typeof o&&n(7),t(r)){var c=w(e),s=R(e,r,void 0),v=!0;try{f=i(s),v=!1;}finally{v?O(c):g(c);}return "undefined"!=typeof Promise&&f instanceof Promise?f.then((function(n){return j(c,o),P(n,c)}),(function(n){throw O(c),n})):(j(c,o),P(f,c))}if(!r||"object"!=typeof r){if(void 0===(f=i(r))&&(f=r),f===H&&(f=void 0),e.F&&d(f,!0),o){var p=[],l=[];b("Patches").M(r,f,p,l),o(p,l);}return f}n(21,r);},this.produceWithPatches=function(n,r){if("function"==typeof n)return function(r){for(var t=arguments.length,i=Array(t>1?t-1:0),o=1;o<t;o++)i[o-1]=arguments[o];return e.produceWithPatches(r,(function(r){return n.apply(void 0,[r].concat(i))}))};var t,i,o=e.produce(n,r,(function(n,r){t=n,i=r;}));return "undefined"!=typeof Promise&&o instanceof Promise?o.then((function(n){return [n,t,i]})):[o,t,i]},"boolean"==typeof(null==r?void 0:r.useProxies)&&this.setUseProxies(r.useProxies),"boolean"==typeof(null==r?void 0:r.autoFreeze)&&this.setAutoFreeze(r.autoFreeze);}var i=e.prototype;return i.createDraft=function(e){t(e)||n(8),r(e)&&(e=D(e));var i=w(this),o=R(this,e,void 0);return o[Q].C=!0,g(i),o},i.finishDraft=function(r,t){var e=r&&r[Q];"production"!==process.env.NODE_ENV&&(e&&e.C||n(9),e.I&&n(10));var i=e.A;return j(i,t),P(void 0,i)},i.setAutoFreeze=function(n){this.F=n;},i.setUseProxies=function(r){r&&!B&&n(20),this.g=r;},i.applyPatches=function(n,t){var e;for(e=t.length-1;e>=0;e--){var i=t[e];if(0===i.path.length&&"replace"===i.op){n=i.value;break}}e>-1&&(t=t.slice(e+1));var o=b("Patches").$;return r(n)?o(n,t):this.produce(n,(function(n){return o(n,t)}))},e}(),an=new un,fn=an.produce;an.produceWithPatches.bind(an);an.setAutoFreeze.bind(an);an.setUseProxies.bind(an);an.applyPatches.bind(an);an.createDraft.bind(an);an.finishDraft.bind(an);var produce = fn;
|
|
14502
|
-
|
|
14503
|
-
|
|
14504
|
-
|
|
14450
|
+
const pathConverter = (path) => path.replace(/\./g, SEPARATOR);
|
|
14451
|
+
const errorConverter = (errors) => {
|
|
14452
|
+
const res = {};
|
|
14505
14453
|
if (errors) {
|
|
14506
|
-
errors.forEach(
|
|
14454
|
+
errors.forEach((i) => {
|
|
14507
14455
|
if (i.keyword === 'required') {
|
|
14508
|
-
jsonpointer.set(res,
|
|
14456
|
+
jsonpointer.set(res, `${pathConverter(`${i.instancePath}.${i.params.missingProperty}`)}/-`, i.message);
|
|
14509
14457
|
}
|
|
14510
14458
|
else {
|
|
14511
|
-
jsonpointer.set(res,
|
|
14459
|
+
jsonpointer.set(res, `${pathConverter(i.instancePath)}/-`, i.message);
|
|
14512
14460
|
}
|
|
14513
14461
|
});
|
|
14514
14462
|
}
|
|
14515
14463
|
return res;
|
|
14516
14464
|
};
|
|
14517
|
-
|
|
14518
|
-
|
|
14519
|
-
|
|
14520
|
-
|
|
14465
|
+
const validateJSON = (schema, store, data) => {
|
|
14466
|
+
const ajv = new Ajv({ allErrors: true });
|
|
14467
|
+
const validate = ajv.compile(schema);
|
|
14468
|
+
const valid = validate(data);
|
|
14521
14469
|
return {
|
|
14522
|
-
store:
|
|
14523
|
-
valid
|
|
14470
|
+
store: `${store}${STORE_ERROR_POSTFIX}`,
|
|
14471
|
+
valid,
|
|
14524
14472
|
value: valid ? null : errorConverter(validate.errors),
|
|
14525
14473
|
};
|
|
14526
|
-
};
|
|
14527
|
-
|
|
14474
|
+
};const initialState = {};
|
|
14475
|
+
const validateNewState = (stock, newState, actionStore, actionPath) => {
|
|
14528
14476
|
if (stock === null || stock === void 0 ? void 0 : stock.validations) {
|
|
14529
|
-
stock.validations.forEach(
|
|
14530
|
-
if (validateItem.store === actionStore &&
|
|
14477
|
+
stock.validations.forEach((validateItem) => {
|
|
14478
|
+
if (validateItem.store === actionStore && `${actionPath}`.startsWith(validateItem.path)) {
|
|
14531
14479
|
if (validateItem.schema) {
|
|
14532
|
-
|
|
14533
|
-
|
|
14480
|
+
const stateToBeValidated = jsonPointerGet(newState, `${SEPARATOR}${actionStore}${validateItem.path}`);
|
|
14481
|
+
const errors = validateJSON(validateItem.schema, actionStore, stateToBeValidated);
|
|
14534
14482
|
// console.log('matched validator', `${c.SEPARATOR}${errors.store}${validateItem.path}`, errors)
|
|
14535
14483
|
// eslint-disable-next-line no-param-reassign
|
|
14536
|
-
newState = jsonPointerSet(newState,
|
|
14484
|
+
newState = jsonPointerSet(newState, `${SEPARATOR}${errors.store}${validateItem.path}`, errors.value);
|
|
14537
14485
|
}
|
|
14538
14486
|
}
|
|
14539
14487
|
});
|
|
14540
14488
|
}
|
|
14541
14489
|
};
|
|
14542
|
-
|
|
14543
|
-
if (state === void 0) { state = initialState; }
|
|
14490
|
+
const reducer = (state = initialState, action) => {
|
|
14544
14491
|
switch (action === null || action === void 0 ? void 0 : action.type) {
|
|
14545
14492
|
case DATA_UPDATE: {
|
|
14546
|
-
|
|
14547
|
-
if (
|
|
14548
|
-
|
|
14549
|
-
|
|
14550
|
-
? changeRelativePath(
|
|
14493
|
+
const { store = undefined, path = undefined, value = undefined, jsonataDef = undefined, [CURRENT_PATH_NAME]: currentPaths = undefined, stock = undefined, } = (action === null || action === void 0 ? void 0 : action.payload) || {};
|
|
14494
|
+
if (store && path && !isCircular(value)) {
|
|
14495
|
+
const storekey = `${store}`;
|
|
14496
|
+
let convertedPath = currentPaths && currentPaths[storekey] && currentPaths[storekey].path
|
|
14497
|
+
? changeRelativePath(`${currentPaths[storekey].path}${SEPARATOR}${path}`)
|
|
14551
14498
|
: changeRelativePath(path);
|
|
14552
|
-
|
|
14553
|
-
|
|
14554
|
-
|
|
14555
|
-
if (
|
|
14499
|
+
convertedPath = convertedPath.startsWith(SEPARATOR) ? convertedPath : `${SEPARATOR}${convertedPath}`;
|
|
14500
|
+
const absolutePathWithStoreKey = `${SEPARATOR}${storekey}${convertedPath}`;
|
|
14501
|
+
const newState = produce(state, (draft) => {
|
|
14502
|
+
if (jsonataDef) {
|
|
14556
14503
|
try {
|
|
14557
14504
|
// eslint-disable-next-line global-require, @typescript-eslint/no-var-requires
|
|
14558
|
-
|
|
14559
|
-
|
|
14560
|
-
|
|
14505
|
+
const jsonata = require('jsonata');
|
|
14506
|
+
const expression = jsonata(jsonataDef);
|
|
14507
|
+
const newValue = expression.evaluate(value);
|
|
14561
14508
|
// eslint-disable-next-line no-param-reassign
|
|
14562
|
-
draft = jsonPointerSet(draft,
|
|
14509
|
+
draft = jsonPointerSet(draft, absolutePathWithStoreKey, newValue);
|
|
14563
14510
|
}
|
|
14564
14511
|
catch (error) {
|
|
14565
14512
|
// eslint-disable-next-line no-console
|
|
14566
|
-
console.error('jsonata error', error,
|
|
14513
|
+
console.error('jsonata error', error, jsonataDef);
|
|
14567
14514
|
// eslint-disable-next-line no-param-reassign
|
|
14568
|
-
draft = jsonPointerSet(draft,
|
|
14515
|
+
draft = jsonPointerSet(draft, absolutePathWithStoreKey, value);
|
|
14569
14516
|
}
|
|
14570
14517
|
}
|
|
14571
14518
|
else {
|
|
14572
14519
|
// eslint-disable-next-line no-param-reassign
|
|
14573
|
-
draft = jsonPointerSet(draft,
|
|
14520
|
+
draft = jsonPointerSet(draft, absolutePathWithStoreKey, value);
|
|
14574
14521
|
}
|
|
14575
14522
|
// if validatior has match, need to validate it synchronously
|
|
14576
|
-
validateNewState(
|
|
14523
|
+
validateNewState(stock, draft, store, convertedPath);
|
|
14577
14524
|
});
|
|
14578
14525
|
return newState;
|
|
14579
14526
|
}
|
|
@@ -14585,16 +14532,8 @@ var reducer = function (state, action) {
|
|
|
14585
14532
|
default:
|
|
14586
14533
|
return state;
|
|
14587
14534
|
}
|
|
14588
|
-
};
|
|
14589
|
-
|
|
14590
|
-
|
|
14591
|
-
|
|
14592
|
-
|
|
14593
|
-
return [4 /*yield*/, stock.callFunction('reloadApp', {})];
|
|
14594
|
-
case 1:
|
|
14595
|
-
_a.sent();
|
|
14596
|
-
return [2 /*return*/];
|
|
14597
|
-
}
|
|
14598
|
-
});
|
|
14599
|
-
}); };
|
|
14600
|
-
var appRootFunctions = { deletePersistDataStore: deletePersistDataStore };export{I18n,PathModifierContext,Stock,StockContext,appRootFunctions,constants,genAllStateProps,persistConfig,functions as stockFunctions,rootReducer as storeReducers,util$1 as util,wrapperUtil};//# sourceMappingURL=index.js.map
|
|
14535
|
+
};const rootReducer = combineReducers({ root: reducer });const deletePersistDataStore = (attr, props, callerArgs, stock) => __awaiter(void 0, void 0, void 0, function* () {
|
|
14536
|
+
stock.reduxStore.dispatch(purge(null));
|
|
14537
|
+
yield stock.callFunction('reloadApp', {});
|
|
14538
|
+
});
|
|
14539
|
+
const appRootFunctions = { deletePersistDataStore };export{I18n,PathModifierContext,Stock,StockContext,appRootFunctions,compSelectorHook,constants,persistConfig,functions as stockFunctions,rootReducer as storeReducers,util$1 as util,wrapperUtil};//# sourceMappingURL=index.js.map
|