@fctc/interface-logic 1.7.1 → 1.7.2
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/{configs.mjs → configs.cjs} +161 -111
- package/dist/{configs.d.mts → configs.d.cts} +2 -1
- package/dist/configs.d.ts +1 -0
- package/dist/configs.js +124 -146
- package/dist/{constants.mjs → constants.cjs} +40 -2
- package/dist/constants.js +2 -41
- package/dist/{environment.mjs → environment.cjs} +2029 -1967
- package/dist/environment.d.cts +56 -0
- package/dist/environment.d.ts +24 -6
- package/dist/environment.js +2235 -2248
- package/dist/{hooks.mjs → hooks.cjs} +4021 -3773
- package/dist/{hooks.d.mts → hooks.d.cts} +2 -7
- package/dist/hooks.d.ts +1 -6
- package/dist/hooks.js +3916 -3873
- package/dist/{provider.mjs → provider.cjs} +688 -586
- package/dist/{provider.d.mts → provider.d.cts} +1 -1
- package/dist/provider.d.ts +1 -1
- package/dist/provider.js +648 -620
- package/dist/{services.mjs → services.cjs} +4186 -3980
- package/dist/{services.d.mts → services.d.cts} +1 -2
- package/dist/services.d.ts +0 -1
- package/dist/services.js +4141 -4021
- package/dist/{store.mjs → store.cjs} +149 -33
- package/dist/{store.d.mts → store.d.cts} +127 -155
- package/dist/store.d.ts +127 -155
- package/dist/store.js +44 -134
- package/dist/types.cjs +17 -0
- package/dist/{types.d.mts → types.d.cts} +1 -1
- package/dist/types.js +0 -18
- package/dist/{utils.mjs → utils.cjs} +202 -115
- package/dist/{utils.d.mts → utils.d.cts} +2 -2
- package/dist/utils.d.ts +2 -2
- package/dist/utils.js +135 -176
- package/package.json +82 -81
- package/dist/environment.d.mts +0 -38
- package/dist/types.mjs +0 -0
- /package/dist/{constants.d.mts → constants.d.cts} +0 -0
- /package/dist/{view-type-BGJfDe73.d.mts → view-type-BGJfDe73.d.cts} +0 -0
|
@@ -1,6 +1,104 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
9
|
+
var __pow = Math.pow;
|
|
10
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
11
|
+
var __spreadValues = (a, b) => {
|
|
12
|
+
for (var prop in b || (b = {}))
|
|
13
|
+
if (__hasOwnProp.call(b, prop))
|
|
14
|
+
__defNormalProp(a, prop, b[prop]);
|
|
15
|
+
if (__getOwnPropSymbols)
|
|
16
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
17
|
+
if (__propIsEnum.call(b, prop))
|
|
18
|
+
__defNormalProp(a, prop, b[prop]);
|
|
19
|
+
}
|
|
20
|
+
return a;
|
|
21
|
+
};
|
|
22
|
+
var __export = (target, all) => {
|
|
23
|
+
for (var name in all)
|
|
24
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
25
|
+
};
|
|
26
|
+
var __copyProps = (to, from, except, desc) => {
|
|
27
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
28
|
+
for (let key of __getOwnPropNames(from))
|
|
29
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
30
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
31
|
+
}
|
|
32
|
+
return to;
|
|
33
|
+
};
|
|
34
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
35
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
36
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
37
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
38
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
39
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
40
|
+
mod
|
|
41
|
+
));
|
|
42
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
43
|
+
var __async = (__this, __arguments, generator) => {
|
|
44
|
+
return new Promise((resolve, reject) => {
|
|
45
|
+
var fulfilled = (value) => {
|
|
46
|
+
try {
|
|
47
|
+
step(generator.next(value));
|
|
48
|
+
} catch (e) {
|
|
49
|
+
reject(e);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
var rejected = (value) => {
|
|
53
|
+
try {
|
|
54
|
+
step(generator.throw(value));
|
|
55
|
+
} catch (e) {
|
|
56
|
+
reject(e);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
60
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
// src/utils.ts
|
|
65
|
+
var utils_exports = {};
|
|
66
|
+
__export(utils_exports, {
|
|
67
|
+
WesapError: () => WesapError,
|
|
68
|
+
checkIsImageLink: () => checkIsImageLink,
|
|
69
|
+
convertFloatToTime: () => convertFloatToTime,
|
|
70
|
+
convertTimeToFloat: () => convertTimeToFloat,
|
|
71
|
+
copyTextToClipboard: () => copyTextToClipboard,
|
|
72
|
+
domainHelper: () => domainHelper,
|
|
73
|
+
evalJSONContext: () => evalJSONContext,
|
|
74
|
+
evalJSONDomain: () => evalJSONDomain,
|
|
75
|
+
filterFieldDirty: () => filterFieldDirty,
|
|
76
|
+
formatCurrency: () => formatCurrency,
|
|
77
|
+
formatDate: () => formatDate,
|
|
78
|
+
formatFileSize: () => formatFileSize,
|
|
79
|
+
formatSortingString: () => formatSortingString,
|
|
80
|
+
formatUrlPath: () => formatUrlPath,
|
|
81
|
+
getFieldsOnChange: () => getFieldsOnChange,
|
|
82
|
+
getOffSet: () => getOffSet,
|
|
83
|
+
getSubdomain: () => getSubdomain,
|
|
84
|
+
handleError: () => handleError,
|
|
85
|
+
isBase64File: () => isBase64File,
|
|
86
|
+
isBase64Image: () => isBase64Image,
|
|
87
|
+
isObjectEmpty: () => isObjectEmpty,
|
|
88
|
+
mergeObjects: () => mergeObjects,
|
|
89
|
+
removeUndefinedFields: () => removeUndefinedFields,
|
|
90
|
+
resequence: () => resequence,
|
|
91
|
+
stringToColor: () => stringToColor,
|
|
92
|
+
toQueryString: () => toQueryString,
|
|
93
|
+
updateTokenParamInOriginalRequest: () => updateTokenParamInOriginalRequest,
|
|
94
|
+
useField: () => useField,
|
|
95
|
+
useTabModel: () => useTabModel,
|
|
96
|
+
validateAndParseDate: () => validateAndParseDate
|
|
97
|
+
});
|
|
98
|
+
module.exports = __toCommonJS(utils_exports);
|
|
99
|
+
|
|
1
100
|
// src/utils/error-handler.ts
|
|
2
101
|
var WesapError = class extends Error {
|
|
3
|
-
code;
|
|
4
102
|
constructor(message, code) {
|
|
5
103
|
super(message);
|
|
6
104
|
this.code = code;
|
|
@@ -15,7 +113,7 @@ function handleError(error, env) {
|
|
|
15
113
|
}
|
|
16
114
|
|
|
17
115
|
// src/utils/format.ts
|
|
18
|
-
|
|
116
|
+
var import_moment = __toESM(require("moment"), 1);
|
|
19
117
|
var formatCurrency = (amount, currency = "USD") => {
|
|
20
118
|
const formatter = new Intl.NumberFormat("vi-VN", {
|
|
21
119
|
style: "currency",
|
|
@@ -32,13 +130,13 @@ var validateAndParseDate = (input, isDateTime = false) => {
|
|
|
32
130
|
const cleanInput = input.replace(/[^0-9-\/:\s]/g, "");
|
|
33
131
|
const dateFormat = "YYYY-MM-DD";
|
|
34
132
|
const dateTimeFormat = "YYYY-MM-DD HH:mm:ss";
|
|
35
|
-
const currentDay =
|
|
36
|
-
const currentMonth =
|
|
37
|
-
const currentYear =
|
|
133
|
+
const currentDay = (0, import_moment.default)().format("DD");
|
|
134
|
+
const currentMonth = (0, import_moment.default)().format("MM");
|
|
135
|
+
const currentYear = (0, import_moment.default)().format("YYYY");
|
|
38
136
|
const defaultTime = "00:00:00";
|
|
39
137
|
const maxYear = parseInt(currentYear) + 10;
|
|
40
138
|
const isValidDate = (day, month, year) => {
|
|
41
|
-
const date =
|
|
139
|
+
const date = (0, import_moment.default)(`${day}-${month}-${year}`, "DD-MM-YYYY", true);
|
|
42
140
|
return date.isValid();
|
|
43
141
|
};
|
|
44
142
|
const isValidTime = (hour, minute = "00", second = "00") => {
|
|
@@ -48,7 +146,7 @@ var validateAndParseDate = (input, isDateTime = false) => {
|
|
|
48
146
|
return h >= 0 && h <= 23 && m >= 0 && m <= 59 && s >= 0 && s <= 59;
|
|
49
147
|
};
|
|
50
148
|
const formatOutput = (day, month, year, time = defaultTime) => {
|
|
51
|
-
let result =
|
|
149
|
+
let result = (0, import_moment.default)(
|
|
52
150
|
`${day}-${month}-${year} ${time}`,
|
|
53
151
|
"DD-MM-YYYY HH:mm:ss"
|
|
54
152
|
);
|
|
@@ -72,7 +170,7 @@ var validateAndParseDate = (input, isDateTime = false) => {
|
|
|
72
170
|
const minute = timeParts[1] ? timeParts[1].padStart(2, "0") : "00";
|
|
73
171
|
const second = timeParts[2] ? timeParts[2].padStart(2, "0") : "00";
|
|
74
172
|
if (isValidDate(day, month, year) && isValidTime(hour, minute, second)) {
|
|
75
|
-
let result =
|
|
173
|
+
let result = (0, import_moment.default)(
|
|
76
174
|
`${day}-${month}-${year} ${hour}:${minute}:${second}`,
|
|
77
175
|
"DD-MM-YYYY HH:mm:ss"
|
|
78
176
|
);
|
|
@@ -135,7 +233,7 @@ var validateAndParseDate = (input, isDateTime = false) => {
|
|
|
135
233
|
}
|
|
136
234
|
if (cleanInput.startsWith("-") && /^\-\d+$/.test(cleanInput)) {
|
|
137
235
|
const daysToSubtract = Math.abs(parseInt(cleanInput, 10));
|
|
138
|
-
let result =
|
|
236
|
+
let result = (0, import_moment.default)().subtract(daysToSubtract, "days");
|
|
139
237
|
if (isDateTime) {
|
|
140
238
|
result = result.subtract(7, "hours");
|
|
141
239
|
}
|
|
@@ -162,7 +260,7 @@ var validateAndParseDate = (input, isDateTime = false) => {
|
|
|
162
260
|
const year = cleanInput.slice(4, 8);
|
|
163
261
|
const hour = cleanInput.slice(8, 9).padStart(2, "0");
|
|
164
262
|
if (isValidDate(day, month, year) && isValidTime(hour)) {
|
|
165
|
-
let result =
|
|
263
|
+
let result = (0, import_moment.default)(
|
|
166
264
|
`${day}-${month}-${year} ${hour}:00:00`,
|
|
167
265
|
"DD-MM-YYYY HH:mm:ss"
|
|
168
266
|
);
|
|
@@ -178,7 +276,7 @@ var validateAndParseDate = (input, isDateTime = false) => {
|
|
|
178
276
|
const year = cleanInput.slice(4, 8);
|
|
179
277
|
const hour = cleanInput.slice(8, 10);
|
|
180
278
|
if (isValidDate(day, month, year) && isValidTime(hour)) {
|
|
181
|
-
let result =
|
|
279
|
+
let result = (0, import_moment.default)(
|
|
182
280
|
`${day}-${month}-${year} ${hour}:00:00`,
|
|
183
281
|
"DD-MM-YYYY HH:mm:ss"
|
|
184
282
|
);
|
|
@@ -195,7 +293,7 @@ var validateAndParseDate = (input, isDateTime = false) => {
|
|
|
195
293
|
const hour = cleanInput.slice(8, 10);
|
|
196
294
|
const minute = cleanInput.slice(10, 11).padStart(2, "0");
|
|
197
295
|
if (isValidDate(day, month, year) && isValidTime(hour, minute)) {
|
|
198
|
-
let result =
|
|
296
|
+
let result = (0, import_moment.default)(
|
|
199
297
|
`${day}-${month}-${year} ${hour}:${minute}:00`,
|
|
200
298
|
"DD-MM-YYYY HH:mm:ss"
|
|
201
299
|
);
|
|
@@ -212,7 +310,7 @@ var validateAndParseDate = (input, isDateTime = false) => {
|
|
|
212
310
|
const hour = cleanInput.slice(8, 10);
|
|
213
311
|
const minute = cleanInput.slice(10, 12);
|
|
214
312
|
if (isValidDate(day, month, year) && isValidTime(hour, minute)) {
|
|
215
|
-
let result =
|
|
313
|
+
let result = (0, import_moment.default)(
|
|
216
314
|
`${day}-${month}-${year} ${hour}:${minute}:00`,
|
|
217
315
|
"DD-MM-YYYY HH:mm:ss"
|
|
218
316
|
);
|
|
@@ -230,7 +328,7 @@ var validateAndParseDate = (input, isDateTime = false) => {
|
|
|
230
328
|
const minute = cleanInput.slice(10, 12);
|
|
231
329
|
const second = cleanInput.slice(12, 13).padStart(2, "0");
|
|
232
330
|
if (isValidDate(day, month, year) && isValidTime(hour, minute, second)) {
|
|
233
|
-
let result =
|
|
331
|
+
let result = (0, import_moment.default)(
|
|
234
332
|
`${day}-${month}-${year} ${hour}:${minute}:${second}`,
|
|
235
333
|
"DD-MM-YYYY HH:mm:ss"
|
|
236
334
|
);
|
|
@@ -248,7 +346,7 @@ var validateAndParseDate = (input, isDateTime = false) => {
|
|
|
248
346
|
const minute = cleanInput.slice(10, 12);
|
|
249
347
|
const second = cleanInput.slice(12, 14);
|
|
250
348
|
if (isValidDate(day, month, year) && isValidTime(hour, minute, second)) {
|
|
251
|
-
let result =
|
|
349
|
+
let result = (0, import_moment.default)(
|
|
252
350
|
`${day}-${month}-${year} ${hour}:${minute}:${second}`,
|
|
253
351
|
"DD-MM-YYYY HH:mm:ss"
|
|
254
352
|
);
|
|
@@ -1387,22 +1485,6 @@ var PyRelativeDelta = class _PyRelativeDelta {
|
|
|
1387
1485
|
this.microsecond = params.microsecond;
|
|
1388
1486
|
this.weekday = params.weekday;
|
|
1389
1487
|
}
|
|
1390
|
-
years;
|
|
1391
|
-
months;
|
|
1392
|
-
days;
|
|
1393
|
-
hours;
|
|
1394
|
-
minutes;
|
|
1395
|
-
seconds;
|
|
1396
|
-
microseconds;
|
|
1397
|
-
leapDays;
|
|
1398
|
-
year;
|
|
1399
|
-
month;
|
|
1400
|
-
day;
|
|
1401
|
-
hour;
|
|
1402
|
-
minute;
|
|
1403
|
-
second;
|
|
1404
|
-
microsecond;
|
|
1405
|
-
weekday;
|
|
1406
1488
|
negate() {
|
|
1407
1489
|
return new _PyRelativeDelta(this, -1);
|
|
1408
1490
|
}
|
|
@@ -1517,7 +1599,7 @@ function execOnIterable(iterable, func) {
|
|
|
1517
1599
|
if (typeof iterable === "object" && !Array.isArray(iterable) && !(iterable instanceof Set)) {
|
|
1518
1600
|
iterable = Object.keys(iterable);
|
|
1519
1601
|
}
|
|
1520
|
-
if (typeof iterable
|
|
1602
|
+
if (typeof (iterable == null ? void 0 : iterable[Symbol.iterator]) !== "function") {
|
|
1521
1603
|
throw new EvaluationError("value not iterable");
|
|
1522
1604
|
}
|
|
1523
1605
|
return func(iterable);
|
|
@@ -1840,7 +1922,7 @@ function applyBinaryOp(ast, context) {
|
|
|
1840
1922
|
}
|
|
1841
1923
|
return Math.floor(left / right);
|
|
1842
1924
|
case "**":
|
|
1843
|
-
return left
|
|
1925
|
+
return __pow(left, right);
|
|
1844
1926
|
case "==":
|
|
1845
1927
|
return isEqual(left, right);
|
|
1846
1928
|
case "<>":
|
|
@@ -1962,7 +2044,7 @@ function evaluate(ast, context = {}) {
|
|
|
1962
2044
|
const dicts = /* @__PURE__ */ new Set();
|
|
1963
2045
|
let pyContext;
|
|
1964
2046
|
const evalContext = Object.create(context);
|
|
1965
|
-
if (!evalContext
|
|
2047
|
+
if (!(evalContext == null ? void 0 : evalContext.context)) {
|
|
1966
2048
|
Object.defineProperty(evalContext, "context", {
|
|
1967
2049
|
get() {
|
|
1968
2050
|
if (!pyContext) {
|
|
@@ -1973,17 +2055,18 @@ function evaluate(ast, context = {}) {
|
|
|
1973
2055
|
});
|
|
1974
2056
|
}
|
|
1975
2057
|
function _innerEvaluate(ast2) {
|
|
1976
|
-
|
|
2058
|
+
var _a, _b, _c;
|
|
2059
|
+
switch (ast2 == null ? void 0 : ast2.type) {
|
|
1977
2060
|
case 0:
|
|
1978
2061
|
// Number
|
|
1979
2062
|
case 1:
|
|
1980
2063
|
return ast2.value;
|
|
1981
2064
|
case 5:
|
|
1982
2065
|
if (ast2.value in evalContext) {
|
|
1983
|
-
if (typeof evalContext[ast2.value] === "object" && evalContext[ast2.value]
|
|
1984
|
-
return evalContext[ast2.value]
|
|
2066
|
+
if (typeof evalContext[ast2.value] === "object" && ((_a = evalContext[ast2.value]) == null ? void 0 : _a.id)) {
|
|
2067
|
+
return (_b = evalContext[ast2.value]) == null ? void 0 : _b.id;
|
|
1985
2068
|
}
|
|
1986
|
-
return evalContext[ast2.value]
|
|
2069
|
+
return (_c = evalContext[ast2.value]) != null ? _c : false;
|
|
1987
2070
|
} else if (ast2.value in BUILTINS) {
|
|
1988
2071
|
return BUILTINS[ast2.value];
|
|
1989
2072
|
} else {
|
|
@@ -2020,7 +2103,7 @@ function evaluate(ast, context = {}) {
|
|
|
2020
2103
|
const args = ast2.args.map(_evaluate);
|
|
2021
2104
|
const kwargs = {};
|
|
2022
2105
|
for (const kwarg in ast2.kwargs) {
|
|
2023
|
-
kwargs[kwarg] = _evaluate(ast2
|
|
2106
|
+
kwargs[kwarg] = _evaluate(ast2 == null ? void 0 : ast2.kwargs[kwarg]);
|
|
2024
2107
|
}
|
|
2025
2108
|
if (fnValue === PyDate || fnValue === PyDateTime || fnValue === PyTime || fnValue === PyRelativeDelta || fnValue === PyTimeDelta) {
|
|
2026
2109
|
return fnValue.create(...args, kwargs);
|
|
@@ -2113,7 +2196,7 @@ function evalPartialContext(_context, evaluationContext = {}) {
|
|
|
2113
2196
|
const value = ast.value[key];
|
|
2114
2197
|
try {
|
|
2115
2198
|
context[key] = evaluate(value, evaluationContext);
|
|
2116
|
-
} catch {
|
|
2199
|
+
} catch (e) {
|
|
2117
2200
|
}
|
|
2118
2201
|
}
|
|
2119
2202
|
return context;
|
|
@@ -2141,9 +2224,25 @@ function escapeRegExp(str) {
|
|
|
2141
2224
|
var InvalidDomainError = class extends Error {
|
|
2142
2225
|
};
|
|
2143
2226
|
var Domain = class _Domain {
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2227
|
+
constructor(descr = []) {
|
|
2228
|
+
this.ast = { type: -1, value: null };
|
|
2229
|
+
if (descr instanceof _Domain) {
|
|
2230
|
+
return new _Domain(descr.toString());
|
|
2231
|
+
} else {
|
|
2232
|
+
let rawAST;
|
|
2233
|
+
try {
|
|
2234
|
+
rawAST = typeof descr === "string" ? parseExpr(descr) : toAST(descr);
|
|
2235
|
+
} catch (error) {
|
|
2236
|
+
throw new InvalidDomainError(
|
|
2237
|
+
`Invalid domain representation: ${descr}`,
|
|
2238
|
+
{
|
|
2239
|
+
cause: error
|
|
2240
|
+
}
|
|
2241
|
+
);
|
|
2242
|
+
}
|
|
2243
|
+
this.ast = normalizeDomainAST(rawAST);
|
|
2244
|
+
}
|
|
2245
|
+
}
|
|
2147
2246
|
static combine(domains, operator) {
|
|
2148
2247
|
if (domains.length === 0) {
|
|
2149
2248
|
return new _Domain([]);
|
|
@@ -2222,24 +2321,6 @@ var Domain = class _Domain {
|
|
|
2222
2321
|
processLeaf(d.ast.value, 0, "&", newDomain);
|
|
2223
2322
|
return newDomain;
|
|
2224
2323
|
}
|
|
2225
|
-
constructor(descr = []) {
|
|
2226
|
-
if (descr instanceof _Domain) {
|
|
2227
|
-
return new _Domain(descr.toString());
|
|
2228
|
-
} else {
|
|
2229
|
-
let rawAST;
|
|
2230
|
-
try {
|
|
2231
|
-
rawAST = typeof descr === "string" ? parseExpr(descr) : toAST(descr);
|
|
2232
|
-
} catch (error) {
|
|
2233
|
-
throw new InvalidDomainError(
|
|
2234
|
-
`Invalid domain representation: ${descr}`,
|
|
2235
|
-
{
|
|
2236
|
-
cause: error
|
|
2237
|
-
}
|
|
2238
|
-
);
|
|
2239
|
-
}
|
|
2240
|
-
this.ast = normalizeDomainAST(rawAST);
|
|
2241
|
-
}
|
|
2242
|
-
}
|
|
2243
2324
|
contains(record) {
|
|
2244
2325
|
const expr = evaluate(this.ast, record);
|
|
2245
2326
|
return matchDomain(record, expr);
|
|
@@ -2258,7 +2339,7 @@ var Domain = class _Domain {
|
|
|
2258
2339
|
return evaluatedAsList;
|
|
2259
2340
|
}
|
|
2260
2341
|
return this.toString();
|
|
2261
|
-
} catch {
|
|
2342
|
+
} catch (e) {
|
|
2262
2343
|
return this.toString();
|
|
2263
2344
|
}
|
|
2264
2345
|
}
|
|
@@ -2482,7 +2563,7 @@ var checkDomain = (context, domain) => {
|
|
|
2482
2563
|
};
|
|
2483
2564
|
var matchDomains = (context, domains) => {
|
|
2484
2565
|
if (Array.isArray(domains)) {
|
|
2485
|
-
if (domains
|
|
2566
|
+
if ((domains == null ? void 0 : domains.length) > 0) {
|
|
2486
2567
|
return domains && domains.some((domain) => checkDomain(context, domain));
|
|
2487
2568
|
}
|
|
2488
2569
|
} else return checkDomain(context, domains);
|
|
@@ -2490,7 +2571,7 @@ var matchDomains = (context, domains) => {
|
|
|
2490
2571
|
};
|
|
2491
2572
|
|
|
2492
2573
|
// src/utils/function.ts
|
|
2493
|
-
|
|
2574
|
+
var import_react = require("react");
|
|
2494
2575
|
var evalJSONContext = (_context, context = {}) => {
|
|
2495
2576
|
try {
|
|
2496
2577
|
return evalPartialContext(_context, context);
|
|
@@ -2499,15 +2580,17 @@ var evalJSONContext = (_context, context = {}) => {
|
|
|
2499
2580
|
}
|
|
2500
2581
|
};
|
|
2501
2582
|
var evalJSONDomain = (domain, context) => {
|
|
2583
|
+
var _a;
|
|
2502
2584
|
try {
|
|
2503
2585
|
if (context) {
|
|
2504
|
-
Object.keys(context)
|
|
2586
|
+
(_a = Object.keys(context)) == null ? void 0 : _a.forEach((key) => {
|
|
2587
|
+
var _a2, _b;
|
|
2505
2588
|
if (Array.isArray(context[key])) {
|
|
2506
|
-
const isTypeObject = context[key]
|
|
2507
|
-
(item) => typeof item === "object" && item !== null && item
|
|
2589
|
+
const isTypeObject = (_a2 = context[key]) == null ? void 0 : _a2.every(
|
|
2590
|
+
(item) => typeof item === "object" && item !== null && (item == null ? void 0 : item.id) !== void 0
|
|
2508
2591
|
);
|
|
2509
2592
|
if (isTypeObject) {
|
|
2510
|
-
context[key] = context[key]
|
|
2593
|
+
context[key] = (_b = context[key]) == null ? void 0 : _b.map((item) => item == null ? void 0 : item.id);
|
|
2511
2594
|
}
|
|
2512
2595
|
}
|
|
2513
2596
|
});
|
|
@@ -2527,7 +2610,7 @@ var formatSortingString = (input) => {
|
|
|
2527
2610
|
if (!input) return null;
|
|
2528
2611
|
return input.split(",").map((field) => {
|
|
2529
2612
|
const [key, order] = field.trim().split(/\s+/);
|
|
2530
|
-
const sortOrder = order
|
|
2613
|
+
const sortOrder = (order == null ? void 0 : order.toUpperCase()) === "DESC" ? "DESC" : "ASC";
|
|
2531
2614
|
return `${key} ${sortOrder}`;
|
|
2532
2615
|
}).join(", ");
|
|
2533
2616
|
};
|
|
@@ -2571,11 +2654,11 @@ var getFieldsOnChange = (fields) => {
|
|
|
2571
2654
|
function traverse(items) {
|
|
2572
2655
|
for (const item of items) {
|
|
2573
2656
|
if (item) {
|
|
2574
|
-
if (item
|
|
2657
|
+
if ((item == null ? void 0 : item.type_co) === "field" && matchDomains(fields, item == null ? void 0 : item.on_change)) {
|
|
2575
2658
|
result.push(item.name);
|
|
2576
2659
|
}
|
|
2577
|
-
if (item
|
|
2578
|
-
traverse(item
|
|
2660
|
+
if ((item == null ? void 0 : item.fields) && Array.isArray(item == null ? void 0 : item.fields)) {
|
|
2661
|
+
traverse(item == null ? void 0 : item.fields);
|
|
2579
2662
|
}
|
|
2580
2663
|
}
|
|
2581
2664
|
}
|
|
@@ -2591,39 +2674,42 @@ var filterFieldDirty = ({
|
|
|
2591
2674
|
model,
|
|
2592
2675
|
defaultData
|
|
2593
2676
|
}) => {
|
|
2594
|
-
|
|
2677
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
2678
|
+
const data = id ? __spreadValues({}, dirtyFields) : __spreadValues({}, formValues);
|
|
2595
2679
|
for (const key in data) {
|
|
2596
|
-
if (viewData
|
|
2680
|
+
if (((_c = (_b = (_a = viewData == null ? void 0 : viewData.models) == null ? void 0 : _a[model]) == null ? void 0 : _b[key]) == null ? void 0 : _c.type) === "one2many" /* ONE2MANY */) {
|
|
2597
2681
|
const lineData = [];
|
|
2598
|
-
(formValues[key]
|
|
2599
|
-
|
|
2600
|
-
|
|
2682
|
+
((_d = formValues[key]) != null ? _d : []).forEach((itemData, index) => {
|
|
2683
|
+
var _a2, _b2, _c2, _d2;
|
|
2684
|
+
if (typeof (itemData == null ? void 0 : itemData.id) === "string" && (itemData == null ? void 0 : itemData.id.includes("virtual"))) {
|
|
2685
|
+
itemData == null ? true : delete itemData.id;
|
|
2601
2686
|
}
|
|
2602
|
-
if (!itemData
|
|
2687
|
+
if (!(itemData == null ? void 0 : itemData.id)) {
|
|
2603
2688
|
lineData.push([
|
|
2604
2689
|
0 /* CREATE */,
|
|
2605
2690
|
`virtual_${index}`,
|
|
2606
2691
|
filterFieldDirty({
|
|
2607
|
-
id: itemData
|
|
2692
|
+
id: itemData == null ? void 0 : itemData.id,
|
|
2608
2693
|
viewData,
|
|
2609
2694
|
formValues: itemData,
|
|
2610
2695
|
dirtyFields: {},
|
|
2611
|
-
model: viewData
|
|
2696
|
+
model: (_c2 = (_b2 = (_a2 = viewData == null ? void 0 : viewData.models) == null ? void 0 : _a2[model]) == null ? void 0 : _b2[key]) == null ? void 0 : _c2.relation,
|
|
2612
2697
|
defaultData
|
|
2613
2698
|
})
|
|
2614
2699
|
]);
|
|
2615
|
-
} else if (dirtyFields[key]
|
|
2700
|
+
} else if ((_d2 = dirtyFields[key]) == null ? void 0 : _d2.length) {
|
|
2616
2701
|
dirtyFields[key].forEach((itemDirty, indexDirty) => {
|
|
2702
|
+
var _a3, _b3, _c3;
|
|
2617
2703
|
if (Object.values(itemDirty).includes(true) && indexDirty === index) {
|
|
2618
2704
|
lineData.push([
|
|
2619
2705
|
1 /* UPDATE */,
|
|
2620
|
-
itemData
|
|
2706
|
+
itemData == null ? void 0 : itemData.id,
|
|
2621
2707
|
filterFieldDirty({
|
|
2622
|
-
id: itemData
|
|
2708
|
+
id: itemData == null ? void 0 : itemData.id,
|
|
2623
2709
|
viewData,
|
|
2624
2710
|
formValues: itemData,
|
|
2625
2711
|
dirtyFields: itemDirty,
|
|
2626
|
-
model: viewData
|
|
2712
|
+
model: (_c3 = (_b3 = (_a3 = viewData == null ? void 0 : viewData.models) == null ? void 0 : _a3[model]) == null ? void 0 : _b3[key]) == null ? void 0 : _c3.relation,
|
|
2627
2713
|
defaultData: {}
|
|
2628
2714
|
})
|
|
2629
2715
|
]);
|
|
@@ -2631,37 +2717,39 @@ var filterFieldDirty = ({
|
|
|
2631
2717
|
});
|
|
2632
2718
|
}
|
|
2633
2719
|
});
|
|
2634
|
-
(defaultData[key]
|
|
2635
|
-
|
|
2636
|
-
|
|
2720
|
+
((_e = defaultData[key]) != null ? _e : []).forEach((item) => {
|
|
2721
|
+
var _a2;
|
|
2722
|
+
if (!((_a2 = formValues[key]) != null ? _a2 : []).find(
|
|
2723
|
+
(itemData) => (itemData == null ? void 0 : itemData.id) === (item == null ? void 0 : item.id)
|
|
2637
2724
|
)) {
|
|
2638
|
-
lineData.push([2 /* DELETE */, item
|
|
2725
|
+
lineData.push([2 /* DELETE */, item == null ? void 0 : item.id, item]);
|
|
2639
2726
|
}
|
|
2640
2727
|
});
|
|
2641
2728
|
data[key] = lineData;
|
|
2642
|
-
} else if (viewData
|
|
2729
|
+
} else if (((_h = (_g = (_f = viewData == null ? void 0 : viewData.models) == null ? void 0 : _f[model]) == null ? void 0 : _g[key]) == null ? void 0 : _h.type) === "many2many" /* MANY2MANY */) {
|
|
2643
2730
|
const lineData = [];
|
|
2644
2731
|
(formValues[key] || []).forEach((itemData) => {
|
|
2645
|
-
if (itemData
|
|
2646
|
-
lineData.push([4 /* NO_CHANGE */, itemData
|
|
2732
|
+
if (itemData == null ? void 0 : itemData.id) {
|
|
2733
|
+
lineData.push([4 /* NO_CHANGE */, itemData == null ? void 0 : itemData.id]);
|
|
2647
2734
|
}
|
|
2648
2735
|
});
|
|
2649
|
-
(defaultData[key]
|
|
2650
|
-
|
|
2651
|
-
|
|
2736
|
+
((_i = defaultData[key]) != null ? _i : []).forEach((item) => {
|
|
2737
|
+
var _a2;
|
|
2738
|
+
if (!((_a2 = formValues[key]) != null ? _a2 : []).find(
|
|
2739
|
+
(itemData) => (itemData == null ? void 0 : itemData.id) === (item == null ? void 0 : item.id)
|
|
2652
2740
|
)) {
|
|
2653
|
-
lineData.push([3 /* UNLINK */, item
|
|
2741
|
+
lineData.push([3 /* UNLINK */, item == null ? void 0 : item.id]);
|
|
2654
2742
|
}
|
|
2655
2743
|
});
|
|
2656
2744
|
data[key] = lineData;
|
|
2657
2745
|
} else {
|
|
2658
|
-
if (id && (typeof dirtyFields
|
|
2746
|
+
if (id && (typeof (dirtyFields == null ? void 0 : dirtyFields[key]) === "object" && !((_j = dirtyFields == null ? void 0 : dirtyFields[key]) == null ? void 0 : _j.id) || typeof dirtyFields[key] !== "object" && !dirtyFields[key])) {
|
|
2659
2747
|
delete data[key];
|
|
2660
2748
|
} else {
|
|
2661
2749
|
if (!data[key]) {
|
|
2662
2750
|
delete data[key];
|
|
2663
2751
|
} else {
|
|
2664
|
-
data[key] = formValues
|
|
2752
|
+
data[key] = ((_k = formValues == null ? void 0 : formValues[key]) == null ? void 0 : _k.display_name) ? (_l = formValues == null ? void 0 : formValues[key]) == null ? void 0 : _l.id : formValues == null ? void 0 : formValues[key];
|
|
2665
2753
|
}
|
|
2666
2754
|
}
|
|
2667
2755
|
}
|
|
@@ -2670,15 +2758,12 @@ var filterFieldDirty = ({
|
|
|
2670
2758
|
};
|
|
2671
2759
|
var mergeObjects = (object1, object2) => {
|
|
2672
2760
|
if (!object1 || !object2) return void 0;
|
|
2673
|
-
const mergedObject = {
|
|
2761
|
+
const mergedObject = __spreadValues({}, object2);
|
|
2674
2762
|
Object.keys(object1).forEach((key) => {
|
|
2675
2763
|
if (Array.isArray(object1[key]) && Array.isArray(object2[key])) {
|
|
2676
2764
|
mergedObject[key] = object2[key].map((item, index) => {
|
|
2677
2765
|
if (object1[key][index]) {
|
|
2678
|
-
return {
|
|
2679
|
-
...item,
|
|
2680
|
-
...object1[key][index]
|
|
2681
|
-
};
|
|
2766
|
+
return __spreadValues(__spreadValues({}, item), object1[key][index]);
|
|
2682
2767
|
}
|
|
2683
2768
|
return item;
|
|
2684
2769
|
});
|
|
@@ -2720,14 +2805,15 @@ var removeUndefinedFields = (obj) => {
|
|
|
2720
2805
|
return newObj;
|
|
2721
2806
|
};
|
|
2722
2807
|
var useTabModel = (viewData, onchangeData) => {
|
|
2723
|
-
|
|
2808
|
+
var _a, _b, _c;
|
|
2809
|
+
const tabsData = ((_c = (_b = (_a = viewData == null ? void 0 : viewData.views) == null ? void 0 : _a.form) == null ? void 0 : _b.tabs) == null ? void 0 : _c.filter((val) => {
|
|
2724
2810
|
if (!val) return null;
|
|
2725
2811
|
const hide = checkDomain(onchangeData, val.invisible);
|
|
2726
2812
|
if (!hide) {
|
|
2727
2813
|
return val;
|
|
2728
2814
|
}
|
|
2729
2815
|
return false;
|
|
2730
|
-
}) || [];
|
|
2816
|
+
})) || [];
|
|
2731
2817
|
return tabsData;
|
|
2732
2818
|
};
|
|
2733
2819
|
var isBase64File = (str) => {
|
|
@@ -2768,7 +2854,7 @@ var formatFileSize = (size) => {
|
|
|
2768
2854
|
return `${(size / Math.pow(1024, i)).toFixed(2)} ${sizes[i]}`;
|
|
2769
2855
|
};
|
|
2770
2856
|
var getSubdomain = (url = window.location.href) => {
|
|
2771
|
-
const parts = url
|
|
2857
|
+
const parts = url == null ? void 0 : url.split(".");
|
|
2772
2858
|
if (parts.length > 2) {
|
|
2773
2859
|
return parts[0].replace("https://", "").replace("http://", "");
|
|
2774
2860
|
}
|
|
@@ -2791,9 +2877,9 @@ var getOffSet = (arr, start, end) => {
|
|
|
2791
2877
|
}
|
|
2792
2878
|
return arr.slice(0, start).length;
|
|
2793
2879
|
};
|
|
2794
|
-
var copyTextToClipboard =
|
|
2880
|
+
var copyTextToClipboard = (text) => __async(null, null, function* () {
|
|
2795
2881
|
if ("clipboard" in navigator) {
|
|
2796
|
-
return
|
|
2882
|
+
return yield navigator.clipboard.writeText(text);
|
|
2797
2883
|
} else {
|
|
2798
2884
|
const textArea = document.createElement("textarea");
|
|
2799
2885
|
textArea.value = text;
|
|
@@ -2807,7 +2893,7 @@ var copyTextToClipboard = async (text) => {
|
|
|
2807
2893
|
document.body.removeChild(textArea);
|
|
2808
2894
|
}
|
|
2809
2895
|
}
|
|
2810
|
-
};
|
|
2896
|
+
});
|
|
2811
2897
|
var updateTokenParamInOriginalRequest = (originalRequest, newAccessToken) => {
|
|
2812
2898
|
if (!originalRequest.data) return originalRequest.data;
|
|
2813
2899
|
if (typeof originalRequest.data === "string") {
|
|
@@ -2831,9 +2917,9 @@ var isObjectEmpty = (obj) => {
|
|
|
2831
2917
|
return Object.keys(obj).length === 0;
|
|
2832
2918
|
};
|
|
2833
2919
|
var useField = (props) => {
|
|
2834
|
-
const [invisible, setInvisible] = useState(true);
|
|
2835
|
-
const [required, setRequired] = useState(false);
|
|
2836
|
-
const [readonly, setReadOnly] = useState(false);
|
|
2920
|
+
const [invisible, setInvisible] = (0, import_react.useState)(true);
|
|
2921
|
+
const [required, setRequired] = (0, import_react.useState)(false);
|
|
2922
|
+
const [readonly, setReadOnly] = (0, import_react.useState)(false);
|
|
2837
2923
|
const {
|
|
2838
2924
|
invisible: inv,
|
|
2839
2925
|
required: req,
|
|
@@ -2843,8 +2929,8 @@ var useField = (props) => {
|
|
|
2843
2929
|
index,
|
|
2844
2930
|
name
|
|
2845
2931
|
} = props;
|
|
2846
|
-
const nameField = rootField ? `${rootField
|
|
2847
|
-
useEffect(() => {
|
|
2932
|
+
const nameField = rootField ? `${rootField == null ? void 0 : rootField.name}.${index}.${name}` : null;
|
|
2933
|
+
(0, import_react.useEffect)(() => {
|
|
2848
2934
|
if (onchangeData && Object.keys(onchangeData).length > 0) {
|
|
2849
2935
|
setRequired(
|
|
2850
2936
|
typeof req === "object" ? matchDomains(onchangeData, req) : checkDomain(onchangeData, req)
|
|
@@ -2862,7 +2948,8 @@ var useField = (props) => {
|
|
|
2862
2948
|
nameField
|
|
2863
2949
|
};
|
|
2864
2950
|
};
|
|
2865
|
-
export
|
|
2951
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
2952
|
+
0 && (module.exports = {
|
|
2866
2953
|
WesapError,
|
|
2867
2954
|
checkIsImageLink,
|
|
2868
2955
|
convertFloatToTime,
|
|
@@ -2893,4 +2980,4 @@ export {
|
|
|
2893
2980
|
useField,
|
|
2894
2981
|
useTabModel,
|
|
2895
2982
|
validateAndParseDate
|
|
2896
|
-
};
|
|
2983
|
+
});
|
|
@@ -12,7 +12,7 @@ declare function handleError(error: Error, env: {
|
|
|
12
12
|
|
|
13
13
|
declare const formatCurrency: (amount: number, currency?: string) => string;
|
|
14
14
|
declare const formatDate: (date: string | Date, locale?: string) => string;
|
|
15
|
-
declare const validateAndParseDate: (input: string, isDateTime?: boolean) => string
|
|
15
|
+
declare const validateAndParseDate: (input: string, isDateTime?: boolean) => string;
|
|
16
16
|
|
|
17
17
|
type AST = {
|
|
18
18
|
type: number;
|
|
@@ -87,7 +87,7 @@ declare const useField: (props: any) => {
|
|
|
87
87
|
invisible: boolean;
|
|
88
88
|
required: boolean;
|
|
89
89
|
readonly: boolean;
|
|
90
|
-
nameField: string
|
|
90
|
+
nameField: string;
|
|
91
91
|
};
|
|
92
92
|
|
|
93
93
|
export { WesapError, checkIsImageLink, convertFloatToTime, convertTimeToFloat, copyTextToClipboard, domainHelper, evalJSONContext, evalJSONDomain, filterFieldDirty, formatCurrency, formatDate, formatFileSize, formatSortingString, formatUrlPath, getFieldsOnChange, getOffSet, getSubdomain, handleError, isBase64File, isBase64Image, isObjectEmpty, mergeObjects, removeUndefinedFields, resequence, stringToColor, toQueryString, updateTokenParamInOriginalRequest, useField, useTabModel, validateAndParseDate };
|
package/dist/utils.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ declare function handleError(error: Error, env: {
|
|
|
12
12
|
|
|
13
13
|
declare const formatCurrency: (amount: number, currency?: string) => string;
|
|
14
14
|
declare const formatDate: (date: string | Date, locale?: string) => string;
|
|
15
|
-
declare const validateAndParseDate: (input: string, isDateTime?: boolean) => string
|
|
15
|
+
declare const validateAndParseDate: (input: string, isDateTime?: boolean) => string;
|
|
16
16
|
|
|
17
17
|
type AST = {
|
|
18
18
|
type: number;
|
|
@@ -87,7 +87,7 @@ declare const useField: (props: any) => {
|
|
|
87
87
|
invisible: boolean;
|
|
88
88
|
required: boolean;
|
|
89
89
|
readonly: boolean;
|
|
90
|
-
nameField: string
|
|
90
|
+
nameField: string;
|
|
91
91
|
};
|
|
92
92
|
|
|
93
93
|
export { WesapError, checkIsImageLink, convertFloatToTime, convertTimeToFloat, copyTextToClipboard, domainHelper, evalJSONContext, evalJSONDomain, filterFieldDirty, formatCurrency, formatDate, formatFileSize, formatSortingString, formatUrlPath, getFieldsOnChange, getOffSet, getSubdomain, handleError, isBase64File, isBase64Image, isObjectEmpty, mergeObjects, removeUndefinedFields, resequence, stringToColor, toQueryString, updateTokenParamInOriginalRequest, useField, useTabModel, validateAndParseDate };
|