@fctc/interface-logic 5.2.6 → 5.2.8
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/{chunk-F2VAAEVB.mjs → chunk-6ARYI77N.mjs} +3 -12
- package/dist/chunk-6LSKTACC.js +687 -0
- package/dist/{chunk-ZDXEWQQD.mjs → chunk-ACSPOGTI.mjs} +7 -14
- package/dist/chunk-B432GFRR.mjs +606 -0
- package/dist/{chunk-HQVNK2EW.mjs → chunk-BPJZ3QRN.mjs} +770 -128
- package/dist/{chunk-FWBYTZIV.js → chunk-C5QQGBN4.js} +18 -23
- package/dist/chunk-COC7NGXP.js +19 -19
- package/dist/chunk-GGNOJ77I.js +2 -1
- package/dist/{chunk-F4RE57FT.mjs → chunk-ICDQN2GL.mjs} +539 -1393
- package/dist/{chunk-U4Q3MW45.js → chunk-JDXUTKMX.js} +852 -170
- package/dist/chunk-Q3Y6RCJ4.mjs +1 -18
- package/dist/{chunk-CCTDGAMA.js → chunk-Q5YXX4OR.js} +51 -52
- package/dist/{chunk-U2COUTK5.js → chunk-TX2WZCYM.js} +931 -1610
- package/dist/chunk-VBVNP77T.mjs +2 -6
- package/dist/chunk-WAXGOBY2.mjs +1 -0
- package/dist/chunk-WTPKTZQC.js +31 -33
- package/dist/configs.js +9 -4
- package/dist/configs.mjs +3 -7
- package/dist/constants.js +70 -36
- package/dist/constants.mjs +1 -36
- package/dist/environment.d.mts +1 -1
- package/dist/environment.d.ts +1 -1
- package/dist/environment.js +17 -8
- package/dist/environment.mjs +4 -12
- package/dist/hooks.d.mts +9 -3
- package/dist/hooks.d.ts +9 -3
- package/dist/hooks.js +617 -306
- package/dist/hooks.mjs +6 -312
- package/dist/index.d.mts +10 -4
- package/dist/index.d.ts +10 -4
- package/dist/index.js +1245 -433
- package/dist/index.mjs +8 -433
- package/dist/{local-storage-AbiOQTLK.d.mts → local-storage-BPvoMGYJ.d.mts} +1 -1
- package/dist/{local-storage-AbiOQTLK.d.ts → local-storage-BPvoMGYJ.d.ts} +1 -1
- package/dist/models.js +7 -3
- package/dist/models.mjs +2 -7
- package/dist/provider.d.mts +8 -3
- package/dist/provider.d.ts +8 -3
- package/dist/provider.js +45 -20
- package/dist/provider.mjs +6 -26
- package/dist/services.d.mts +2 -2
- package/dist/services.d.ts +2 -2
- package/dist/services.js +49 -24
- package/dist/services.mjs +6 -30
- package/dist/store.d.mts +382 -0
- package/dist/store.d.ts +382 -0
- package/dist/store.js +326 -0
- package/dist/store.mjs +1 -0
- package/dist/types.js +4 -1
- package/dist/types.mjs +1 -1
- package/dist/utils.d.mts +61 -33
- package/dist/utils.d.ts +61 -33
- package/dist/utils.js +139 -36
- package/dist/utils.mjs +2 -36
- package/package.json +93 -79
|
@@ -1,79 +1,319 @@
|
|
|
1
|
-
|
|
2
|
-
var localStorageUtils = () => {
|
|
3
|
-
const setToken = async (access_token) => {
|
|
4
|
-
localStorage.setItem("accessToken", access_token);
|
|
5
|
-
};
|
|
6
|
-
const setRefreshToken = async (refresh_token) => {
|
|
7
|
-
localStorage.setItem("refreshToken", refresh_token);
|
|
8
|
-
};
|
|
9
|
-
const getAccessToken = async () => {
|
|
10
|
-
return localStorage.getItem("accessToken");
|
|
11
|
-
};
|
|
12
|
-
const getRefreshToken = async () => {
|
|
13
|
-
return localStorage.getItem("refreshToken");
|
|
14
|
-
};
|
|
15
|
-
const clearToken = async () => {
|
|
16
|
-
localStorage.removeItem("accessToken");
|
|
17
|
-
localStorage.removeItem("refreshToken");
|
|
18
|
-
};
|
|
19
|
-
return {
|
|
20
|
-
setToken,
|
|
21
|
-
setRefreshToken,
|
|
22
|
-
getAccessToken,
|
|
23
|
-
getRefreshToken,
|
|
24
|
-
clearToken
|
|
25
|
-
};
|
|
26
|
-
};
|
|
1
|
+
'use strict';
|
|
27
2
|
|
|
28
|
-
|
|
29
|
-
var
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
3
|
+
var moment = require('moment');
|
|
4
|
+
var react = require('react');
|
|
5
|
+
|
|
6
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
7
|
+
|
|
8
|
+
var moment__default = /*#__PURE__*/_interopDefault(moment);
|
|
9
|
+
|
|
10
|
+
// src/utils/error-handler.ts
|
|
11
|
+
var WesapError = class extends Error {
|
|
12
|
+
code;
|
|
13
|
+
constructor(message, code) {
|
|
14
|
+
super(message);
|
|
15
|
+
this.code = code;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
function handleError(error, env) {
|
|
19
|
+
if (error instanceof WesapError) {
|
|
20
|
+
env.services.notification.error(error.message);
|
|
21
|
+
} else {
|
|
22
|
+
env.services.notification.error("An unexpected error occurred");
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
var formatCurrency = (amount, currency = "USD") => {
|
|
26
|
+
const formatter = new Intl.NumberFormat("vi-VN", {
|
|
27
|
+
style: "currency",
|
|
28
|
+
currency,
|
|
29
|
+
minimumFractionDigits: 0
|
|
30
|
+
});
|
|
31
|
+
return formatter.format(amount).replaceAll(".", ",");
|
|
32
|
+
};
|
|
33
|
+
var formatDate = (date, locale = "en-US") => {
|
|
34
|
+
return new Intl.DateTimeFormat(locale).format(new Date(date));
|
|
35
|
+
};
|
|
36
|
+
var validateAndParseDate = (input, isDateTime = false) => {
|
|
37
|
+
if (!input || typeof input !== "string") return null;
|
|
38
|
+
const cleanInput = input.replace(/[^0-9-\/:\s]/g, "");
|
|
39
|
+
const dateFormat = "YYYY-MM-DD";
|
|
40
|
+
const dateTimeFormat = "YYYY-MM-DD HH:mm:ss";
|
|
41
|
+
const currentDay = moment__default.default().format("DD");
|
|
42
|
+
const currentMonth = moment__default.default().format("MM");
|
|
43
|
+
const currentYear = moment__default.default().format("YYYY");
|
|
44
|
+
const defaultTime = "00:00:00";
|
|
45
|
+
const maxYear = parseInt(currentYear) + 10;
|
|
46
|
+
const isValidDate = (day, month, year) => {
|
|
47
|
+
const date = moment__default.default(`${day}-${month}-${year}`, "DD-MM-YYYY", true);
|
|
48
|
+
return date.isValid();
|
|
61
49
|
};
|
|
62
|
-
const
|
|
63
|
-
|
|
50
|
+
const isValidTime = (hour, minute = "00", second = "00") => {
|
|
51
|
+
const h = parseInt(hour, 10);
|
|
52
|
+
const m = parseInt(minute, 10);
|
|
53
|
+
const s = parseInt(second, 10);
|
|
54
|
+
return h >= 0 && h <= 23 && m >= 0 && m <= 59 && s >= 0 && s <= 59;
|
|
64
55
|
};
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
56
|
+
const formatOutput = (day, month, year, time = defaultTime) => {
|
|
57
|
+
let result = moment__default.default(
|
|
58
|
+
`${day}-${month}-${year} ${time}`,
|
|
59
|
+
"DD-MM-YYYY HH:mm:ss"
|
|
60
|
+
);
|
|
61
|
+
if (!result.isValid()) return null;
|
|
62
|
+
if (isDateTime) {
|
|
63
|
+
result = result.subtract(7, "hours");
|
|
64
|
+
return result.format(dateTimeFormat);
|
|
65
|
+
}
|
|
66
|
+
return result.format(dateFormat);
|
|
75
67
|
};
|
|
76
|
-
|
|
68
|
+
if (isDateTime && input.match(
|
|
69
|
+
/^\d{1,2}[\/-]\d{1,2}[\/-]\d{2,4}\s+\d{1,2}(:\d{1,2}(:\d{1,2})?)?$/
|
|
70
|
+
)) {
|
|
71
|
+
const [datePart, timePart] = input.split(/\s+/);
|
|
72
|
+
const dateParts = datePart.split(/[\/-]/);
|
|
73
|
+
const timeParts = timePart.split(":");
|
|
74
|
+
const day = dateParts[0].padStart(2, "0");
|
|
75
|
+
const month = dateParts[1].padStart(2, "0");
|
|
76
|
+
const year = dateParts[2].length <= 2 ? `20${dateParts[2].padStart(2, "0")}` : dateParts[2].padStart(4, "0");
|
|
77
|
+
const hour = timeParts[0].padStart(2, "0");
|
|
78
|
+
const minute = timeParts[1] ? timeParts[1].padStart(2, "0") : "00";
|
|
79
|
+
const second = timeParts[2] ? timeParts[2].padStart(2, "0") : "00";
|
|
80
|
+
if (isValidDate(day, month, year) && isValidTime(hour, minute, second)) {
|
|
81
|
+
let result = moment__default.default(
|
|
82
|
+
`${day}-${month}-${year} ${hour}:${minute}:${second}`,
|
|
83
|
+
"DD-MM-YYYY HH:mm:ss"
|
|
84
|
+
);
|
|
85
|
+
if (!result.isValid()) return null;
|
|
86
|
+
result = result.subtract(7, "hours");
|
|
87
|
+
return result.format(dateTimeFormat);
|
|
88
|
+
}
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
if (cleanInput.match(/^\d{4}-\d{2}-\d{2}$/)) {
|
|
92
|
+
const [year, month, day] = cleanInput.split("-");
|
|
93
|
+
if (isValidDate(day, month, year)) {
|
|
94
|
+
return formatOutput(day, month, year);
|
|
95
|
+
}
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
if (cleanInput.match(/^\d{1,2}\/\d{1,2}\/\d{2,4}$/)) {
|
|
99
|
+
const [day, month, year] = cleanInput.split("/");
|
|
100
|
+
const paddedDay = day.padStart(2, "0");
|
|
101
|
+
const paddedMonth = month.padStart(2, "0");
|
|
102
|
+
const fullYear = year.length <= 2 ? `20${year.padStart(2, "0")}` : year.padStart(4, "0");
|
|
103
|
+
if (isValidDate(paddedDay, paddedMonth, fullYear)) {
|
|
104
|
+
return formatOutput(paddedDay, paddedMonth, fullYear);
|
|
105
|
+
}
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
if (cleanInput.match(/^\d{1,2}-\d{1,2}-\d{2,4}$/)) {
|
|
109
|
+
const [day, month, year] = cleanInput.split("-");
|
|
110
|
+
const paddedDay = day.padStart(2, "0");
|
|
111
|
+
const paddedMonth = month.padStart(2, "0");
|
|
112
|
+
const fullYear = year.length <= 2 ? `20${year.padStart(2, "0")}` : year.padStart(4, "0");
|
|
113
|
+
if (isValidDate(paddedDay, paddedMonth, fullYear)) {
|
|
114
|
+
return formatOutput(paddedDay, paddedMonth, fullYear);
|
|
115
|
+
}
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
if (cleanInput.match(/^\d{1,2}[\/-]\d{1,2}$/)) {
|
|
119
|
+
const [day, month] = cleanInput.split(/[\/-]/);
|
|
120
|
+
const paddedDay = day.padStart(2, "0");
|
|
121
|
+
const paddedMonth = month.padStart(2, "0");
|
|
122
|
+
if (isValidDate(paddedDay, paddedMonth, currentYear)) {
|
|
123
|
+
return formatOutput(paddedDay, paddedMonth, currentYear);
|
|
124
|
+
}
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
if (cleanInput.match(/^\d{4}$/)) {
|
|
128
|
+
const num = parseInt(cleanInput, 10);
|
|
129
|
+
if (num >= 2e3 && num <= maxYear) {
|
|
130
|
+
if (isValidDate(currentDay, currentMonth, num.toString())) {
|
|
131
|
+
return formatOutput(currentDay, currentMonth, num.toString());
|
|
132
|
+
}
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
135
|
+
const day = cleanInput.slice(0, 2);
|
|
136
|
+
const month = cleanInput.slice(2, 4);
|
|
137
|
+
if (isValidDate(day, month, currentYear)) {
|
|
138
|
+
return formatOutput(day, month, currentYear);
|
|
139
|
+
}
|
|
140
|
+
return null;
|
|
141
|
+
}
|
|
142
|
+
if (cleanInput.startsWith("-") && /^\-\d+$/.test(cleanInput)) {
|
|
143
|
+
const daysToSubtract = Math.abs(parseInt(cleanInput, 10));
|
|
144
|
+
let result = moment__default.default().subtract(daysToSubtract, "days");
|
|
145
|
+
if (isDateTime) {
|
|
146
|
+
result = result.subtract(7, "hours");
|
|
147
|
+
}
|
|
148
|
+
if (result.isValid()) {
|
|
149
|
+
return isDateTime ? result.format(dateTimeFormat) : result.format(dateFormat);
|
|
150
|
+
}
|
|
151
|
+
return null;
|
|
152
|
+
}
|
|
153
|
+
if (input.match(/^\d{1,2}[^0-9-\/]+\d{1,2}[^0-9-\/]+\d{2,4}.*$/)) {
|
|
154
|
+
const parts = input.split(/[^0-9-\/]+/).filter(Boolean);
|
|
155
|
+
const day = parts[0].padStart(2, "0");
|
|
156
|
+
const month = parts[1].padStart(2, "0");
|
|
157
|
+
let year = parts[2];
|
|
158
|
+
year = year.length === 2 ? `20${year}` : year.padStart(4, "0");
|
|
159
|
+
if (isValidDate(day, month, year)) {
|
|
160
|
+
return formatOutput(day, month, year);
|
|
161
|
+
}
|
|
162
|
+
return null;
|
|
163
|
+
}
|
|
164
|
+
if (isDateTime) {
|
|
165
|
+
if (cleanInput.length === 9) {
|
|
166
|
+
const day = cleanInput.slice(0, 2);
|
|
167
|
+
const month = cleanInput.slice(2, 4);
|
|
168
|
+
const year = cleanInput.slice(4, 8);
|
|
169
|
+
const hour = cleanInput.slice(8, 9).padStart(2, "0");
|
|
170
|
+
if (isValidDate(day, month, year) && isValidTime(hour)) {
|
|
171
|
+
let result = moment__default.default(
|
|
172
|
+
`${day}-${month}-${year} ${hour}:00:00`,
|
|
173
|
+
"DD-MM-YYYY HH:mm:ss"
|
|
174
|
+
);
|
|
175
|
+
if (!result.isValid()) return null;
|
|
176
|
+
result = result.subtract(7, "hours");
|
|
177
|
+
return result.format(dateTimeFormat);
|
|
178
|
+
}
|
|
179
|
+
return null;
|
|
180
|
+
}
|
|
181
|
+
if (cleanInput.length === 10) {
|
|
182
|
+
const day = cleanInput.slice(0, 2);
|
|
183
|
+
const month = cleanInput.slice(2, 4);
|
|
184
|
+
const year = cleanInput.slice(4, 8);
|
|
185
|
+
const hour = cleanInput.slice(8, 10);
|
|
186
|
+
if (isValidDate(day, month, year) && isValidTime(hour)) {
|
|
187
|
+
let result = moment__default.default(
|
|
188
|
+
`${day}-${month}-${year} ${hour}:00:00`,
|
|
189
|
+
"DD-MM-YYYY HH:mm:ss"
|
|
190
|
+
);
|
|
191
|
+
if (!result.isValid()) return null;
|
|
192
|
+
result = result.subtract(7, "hours");
|
|
193
|
+
return result.format(dateTimeFormat);
|
|
194
|
+
}
|
|
195
|
+
return null;
|
|
196
|
+
}
|
|
197
|
+
if (cleanInput.length === 11) {
|
|
198
|
+
const day = cleanInput.slice(0, 2);
|
|
199
|
+
const month = cleanInput.slice(2, 4);
|
|
200
|
+
const year = cleanInput.slice(4, 8);
|
|
201
|
+
const hour = cleanInput.slice(8, 10);
|
|
202
|
+
const minute = cleanInput.slice(10, 11).padStart(2, "0");
|
|
203
|
+
if (isValidDate(day, month, year) && isValidTime(hour, minute)) {
|
|
204
|
+
let result = moment__default.default(
|
|
205
|
+
`${day}-${month}-${year} ${hour}:${minute}:00`,
|
|
206
|
+
"DD-MM-YYYY HH:mm:ss"
|
|
207
|
+
);
|
|
208
|
+
if (!result.isValid()) return null;
|
|
209
|
+
result = result.subtract(7, "hours");
|
|
210
|
+
return result.format(dateTimeFormat);
|
|
211
|
+
}
|
|
212
|
+
return null;
|
|
213
|
+
}
|
|
214
|
+
if (cleanInput.length === 12) {
|
|
215
|
+
const day = cleanInput.slice(0, 2);
|
|
216
|
+
const month = cleanInput.slice(2, 4);
|
|
217
|
+
const year = cleanInput.slice(4, 8);
|
|
218
|
+
const hour = cleanInput.slice(8, 10);
|
|
219
|
+
const minute = cleanInput.slice(10, 12);
|
|
220
|
+
if (isValidDate(day, month, year) && isValidTime(hour, minute)) {
|
|
221
|
+
let result = moment__default.default(
|
|
222
|
+
`${day}-${month}-${year} ${hour}:${minute}:00`,
|
|
223
|
+
"DD-MM-YYYY HH:mm:ss"
|
|
224
|
+
);
|
|
225
|
+
if (!result.isValid()) return null;
|
|
226
|
+
result = result.subtract(7, "hours");
|
|
227
|
+
return result.format(dateTimeFormat);
|
|
228
|
+
}
|
|
229
|
+
return null;
|
|
230
|
+
}
|
|
231
|
+
if (cleanInput.length === 13) {
|
|
232
|
+
const day = cleanInput.slice(0, 2);
|
|
233
|
+
const month = cleanInput.slice(2, 4);
|
|
234
|
+
const year = cleanInput.slice(4, 8);
|
|
235
|
+
const hour = cleanInput.slice(8, 10);
|
|
236
|
+
const minute = cleanInput.slice(10, 12);
|
|
237
|
+
const second = cleanInput.slice(12, 13).padStart(2, "0");
|
|
238
|
+
if (isValidDate(day, month, year) && isValidTime(hour, minute, second)) {
|
|
239
|
+
let result = moment__default.default(
|
|
240
|
+
`${day}-${month}-${year} ${hour}:${minute}:${second}`,
|
|
241
|
+
"DD-MM-YYYY HH:mm:ss"
|
|
242
|
+
);
|
|
243
|
+
if (!result.isValid()) return null;
|
|
244
|
+
result = result.subtract(7, "hours");
|
|
245
|
+
return result.format(dateTimeFormat);
|
|
246
|
+
}
|
|
247
|
+
return null;
|
|
248
|
+
}
|
|
249
|
+
if (cleanInput.length === 14) {
|
|
250
|
+
const day = cleanInput.slice(0, 2);
|
|
251
|
+
const month = cleanInput.slice(2, 4);
|
|
252
|
+
const year = cleanInput.slice(4, 8);
|
|
253
|
+
const hour = cleanInput.slice(8, 10);
|
|
254
|
+
const minute = cleanInput.slice(10, 12);
|
|
255
|
+
const second = cleanInput.slice(12, 14);
|
|
256
|
+
if (isValidDate(day, month, year) && isValidTime(hour, minute, second)) {
|
|
257
|
+
let result = moment__default.default(
|
|
258
|
+
`${day}-${month}-${year} ${hour}:${minute}:${second}`,
|
|
259
|
+
"DD-MM-YYYY HH:mm:ss"
|
|
260
|
+
);
|
|
261
|
+
if (!result.isValid()) return null;
|
|
262
|
+
result = result.subtract(7, "hours");
|
|
263
|
+
return result.format(dateTimeFormat);
|
|
264
|
+
}
|
|
265
|
+
return null;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
const len = cleanInput.length;
|
|
269
|
+
if (len === 1 || len === 2) {
|
|
270
|
+
const paddedDay = cleanInput.padStart(2, "0");
|
|
271
|
+
if (isValidDate(paddedDay, currentMonth, currentYear)) {
|
|
272
|
+
return formatOutput(paddedDay, currentMonth, currentYear);
|
|
273
|
+
}
|
|
274
|
+
return null;
|
|
275
|
+
}
|
|
276
|
+
if (len === 3) {
|
|
277
|
+
const day = cleanInput.slice(0, 2);
|
|
278
|
+
const month = cleanInput.slice(2, 3).padStart(2, "0");
|
|
279
|
+
if (isValidDate(day, month, currentYear)) {
|
|
280
|
+
return formatOutput(day, month, currentYear);
|
|
281
|
+
}
|
|
282
|
+
return null;
|
|
283
|
+
}
|
|
284
|
+
if (len === 6) {
|
|
285
|
+
const day = cleanInput.slice(0, 2);
|
|
286
|
+
const month = cleanInput.slice(2, 4);
|
|
287
|
+
let year = cleanInput.slice(4, 6);
|
|
288
|
+
year = `20${year}`;
|
|
289
|
+
if (parseInt(month) > 12) {
|
|
290
|
+
if (isValidDate(day, currentMonth, currentYear)) {
|
|
291
|
+
return formatOutput(day, currentMonth, currentYear);
|
|
292
|
+
}
|
|
293
|
+
return null;
|
|
294
|
+
}
|
|
295
|
+
if (isValidDate(day, month, year)) {
|
|
296
|
+
return formatOutput(day, month, year);
|
|
297
|
+
}
|
|
298
|
+
return null;
|
|
299
|
+
}
|
|
300
|
+
if (len === 7) {
|
|
301
|
+
return null;
|
|
302
|
+
}
|
|
303
|
+
if (len === 8) {
|
|
304
|
+
const day = cleanInput.slice(0, 2);
|
|
305
|
+
const month = cleanInput.slice(2, 4);
|
|
306
|
+
const year = cleanInput.slice(4, 8);
|
|
307
|
+
if (isValidDate(day, month, year)) {
|
|
308
|
+
return formatOutput(day, month, year);
|
|
309
|
+
}
|
|
310
|
+
return null;
|
|
311
|
+
}
|
|
312
|
+
if (len > 8 && !isDateTime) {
|
|
313
|
+
return null;
|
|
314
|
+
}
|
|
315
|
+
return null;
|
|
316
|
+
};
|
|
77
317
|
|
|
78
318
|
// src/utils/domain/py_tokenizer.ts
|
|
79
319
|
var TokenizerError = class extends Error {
|
|
@@ -229,7 +469,7 @@ var IntNumber = DecNumber;
|
|
|
229
469
|
var Exponent = "[eE][+-]?\\d+";
|
|
230
470
|
var PointFloat = group(`\\d+\\.\\d*(${Exponent})?`, `\\.\\d+(${Exponent})?`);
|
|
231
471
|
var FloatNumber = group(PointFloat, `\\d+${Exponent}`);
|
|
232
|
-
var
|
|
472
|
+
var Number2 = group(FloatNumber, IntNumber);
|
|
233
473
|
var Operator = group(
|
|
234
474
|
"\\*\\*=?",
|
|
235
475
|
">>=?",
|
|
@@ -247,8 +487,8 @@ var ContStr = group(
|
|
|
247
487
|
"([uU])?'([^\\n'\\\\]*(?:\\\\.[^\\n'\\\\]*)*)'",
|
|
248
488
|
'([uU])?"([^\\n"\\\\]*(?:\\\\.[^\\n"\\\\]*)*)"'
|
|
249
489
|
);
|
|
250
|
-
var PseudoToken = Whitespace + group(
|
|
251
|
-
var NumberPattern = new RegExp("^" +
|
|
490
|
+
var PseudoToken = Whitespace + group(Number2, Funny, ContStr, Name);
|
|
491
|
+
var NumberPattern = new RegExp("^" + Number2 + "$");
|
|
252
492
|
var StringPattern = new RegExp("^" + ContStr + "$");
|
|
253
493
|
var NamePattern = new RegExp("^" + Name + "$");
|
|
254
494
|
var strip = new RegExp("^" + Whitespace);
|
|
@@ -578,8 +818,6 @@ function parseInfix(left, current, tokens) {
|
|
|
578
818
|
ifTrue: left,
|
|
579
819
|
ifFalse
|
|
580
820
|
};
|
|
581
|
-
default:
|
|
582
|
-
break;
|
|
583
821
|
}
|
|
584
822
|
}
|
|
585
823
|
throw new ParserError("Token cannot be parsed");
|
|
@@ -1153,22 +1391,22 @@ var PyRelativeDelta = class _PyRelativeDelta {
|
|
|
1153
1391
|
this.microsecond = params.microsecond;
|
|
1154
1392
|
this.weekday = params.weekday;
|
|
1155
1393
|
}
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1394
|
+
years;
|
|
1395
|
+
months;
|
|
1396
|
+
days;
|
|
1397
|
+
hours;
|
|
1398
|
+
minutes;
|
|
1399
|
+
seconds;
|
|
1400
|
+
microseconds;
|
|
1401
|
+
leapDays;
|
|
1402
|
+
year;
|
|
1403
|
+
month;
|
|
1404
|
+
day;
|
|
1405
|
+
hour;
|
|
1406
|
+
minute;
|
|
1407
|
+
second;
|
|
1408
|
+
microsecond;
|
|
1409
|
+
weekday;
|
|
1172
1410
|
negate() {
|
|
1173
1411
|
return new _PyRelativeDelta(this, -1);
|
|
1174
1412
|
}
|
|
@@ -1283,7 +1521,7 @@ function execOnIterable(iterable, func) {
|
|
|
1283
1521
|
if (typeof iterable === "object" && !Array.isArray(iterable) && !(iterable instanceof Set)) {
|
|
1284
1522
|
iterable = Object.keys(iterable);
|
|
1285
1523
|
}
|
|
1286
|
-
if (typeof
|
|
1524
|
+
if (typeof iterable?.[Symbol.iterator] !== "function") {
|
|
1287
1525
|
throw new EvaluationError("value not iterable");
|
|
1288
1526
|
}
|
|
1289
1527
|
return func(iterable);
|
|
@@ -1728,7 +1966,7 @@ function evaluate(ast, context = {}) {
|
|
|
1728
1966
|
const dicts = /* @__PURE__ */ new Set();
|
|
1729
1967
|
let pyContext;
|
|
1730
1968
|
const evalContext = Object.create(context);
|
|
1731
|
-
if (!
|
|
1969
|
+
if (!evalContext?.context) {
|
|
1732
1970
|
Object.defineProperty(evalContext, "context", {
|
|
1733
1971
|
get() {
|
|
1734
1972
|
if (!pyContext) {
|
|
@@ -1739,17 +1977,17 @@ function evaluate(ast, context = {}) {
|
|
|
1739
1977
|
});
|
|
1740
1978
|
}
|
|
1741
1979
|
function _innerEvaluate(ast2) {
|
|
1742
|
-
switch (
|
|
1980
|
+
switch (ast2?.type) {
|
|
1743
1981
|
case 0:
|
|
1744
1982
|
// Number
|
|
1745
1983
|
case 1:
|
|
1746
1984
|
return ast2.value;
|
|
1747
1985
|
case 5:
|
|
1748
1986
|
if (ast2.value in evalContext) {
|
|
1749
|
-
if (typeof evalContext[ast2.value] === "object" &&
|
|
1750
|
-
return
|
|
1987
|
+
if (typeof evalContext[ast2.value] === "object" && evalContext[ast2.value]?.id && ast2?.value !== "parent") {
|
|
1988
|
+
return evalContext[ast2.value]?.id;
|
|
1751
1989
|
}
|
|
1752
|
-
return
|
|
1990
|
+
return evalContext[ast2.value] ?? false;
|
|
1753
1991
|
} else if (ast2.value in BUILTINS) {
|
|
1754
1992
|
return BUILTINS[ast2.value];
|
|
1755
1993
|
} else {
|
|
@@ -1786,7 +2024,7 @@ function evaluate(ast, context = {}) {
|
|
|
1786
2024
|
const args = ast2.args.map(_evaluate);
|
|
1787
2025
|
const kwargs = {};
|
|
1788
2026
|
for (const kwarg in ast2.kwargs) {
|
|
1789
|
-
kwargs[kwarg] = _evaluate(
|
|
2027
|
+
kwargs[kwarg] = _evaluate(ast2?.kwargs[kwarg]);
|
|
1790
2028
|
}
|
|
1791
2029
|
if (fnValue === PyDate || fnValue === PyDateTime || fnValue === PyTime || fnValue === PyRelativeDelta || fnValue === PyTimeDelta) {
|
|
1792
2030
|
return fnValue.create(...args, kwargs);
|
|
@@ -1817,11 +2055,11 @@ function evaluate(ast, context = {}) {
|
|
|
1817
2055
|
} else if (typeof leftVal === "number") {
|
|
1818
2056
|
result = leftVal;
|
|
1819
2057
|
} else if (Array.isArray(leftVal[ast2.key])) {
|
|
1820
|
-
result =
|
|
1821
|
-
(value) =>
|
|
1822
|
-
)
|
|
2058
|
+
result = leftVal[ast2.key]?.map(
|
|
2059
|
+
(value) => value?.id ?? value
|
|
2060
|
+
);
|
|
1823
2061
|
} else {
|
|
1824
|
-
result =
|
|
2062
|
+
result = leftVal[ast2.key]?.id ?? leftVal[ast2.key] ?? false;
|
|
1825
2063
|
}
|
|
1826
2064
|
if (typeof result === "function") {
|
|
1827
2065
|
const bound = result.bind(leftVal);
|
|
@@ -1878,18 +2116,6 @@ function evaluateBooleanExpr(expr, context = {}) {
|
|
|
1878
2116
|
}
|
|
1879
2117
|
|
|
1880
2118
|
// src/utils/domain/context.ts
|
|
1881
|
-
function makeContext(contexts, initialEvaluationContext) {
|
|
1882
|
-
const evaluationContext = Object.assign({}, initialEvaluationContext);
|
|
1883
|
-
const context = {};
|
|
1884
|
-
for (let ctx of contexts) {
|
|
1885
|
-
if (ctx !== "") {
|
|
1886
|
-
ctx = typeof ctx === "string" ? evaluateExpr(ctx, evaluationContext) : ctx || {};
|
|
1887
|
-
Object.assign(context, ctx);
|
|
1888
|
-
Object.assign(evaluationContext, context);
|
|
1889
|
-
}
|
|
1890
|
-
}
|
|
1891
|
-
return context;
|
|
1892
|
-
}
|
|
1893
2119
|
function evalPartialContext(_context, evaluationContext = {}) {
|
|
1894
2120
|
const ast = parseExpr(_context);
|
|
1895
2121
|
const context = {};
|
|
@@ -1897,7 +2123,7 @@ function evalPartialContext(_context, evaluationContext = {}) {
|
|
|
1897
2123
|
const value = ast.value[key];
|
|
1898
2124
|
try {
|
|
1899
2125
|
context[key] = evaluate(value, evaluationContext);
|
|
1900
|
-
} catch
|
|
2126
|
+
} catch {
|
|
1901
2127
|
}
|
|
1902
2128
|
}
|
|
1903
2129
|
return context;
|
|
@@ -1914,9 +2140,6 @@ function shallowEqual(obj1, obj2, comparisonFn = (a, b) => a === b) {
|
|
|
1914
2140
|
|
|
1915
2141
|
// src/utils/domain/arrays.ts
|
|
1916
2142
|
var shallowEqual2 = shallowEqual;
|
|
1917
|
-
|
|
1918
|
-
// src/utils/domain/strings.ts
|
|
1919
|
-
var escapeMethod = Symbol("html");
|
|
1920
2143
|
function escapeRegExp(str) {
|
|
1921
2144
|
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1922
2145
|
}
|
|
@@ -1924,10 +2147,10 @@ function escapeRegExp(str) {
|
|
|
1924
2147
|
// src/utils/domain/domain.ts
|
|
1925
2148
|
var InvalidDomainError = class extends Error {
|
|
1926
2149
|
};
|
|
1927
|
-
var Domain =
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
2150
|
+
var Domain = class _Domain {
|
|
2151
|
+
ast = { type: -1, value: null };
|
|
2152
|
+
static TRUE;
|
|
2153
|
+
static FALSE;
|
|
1931
2154
|
static combine(domains, operator) {
|
|
1932
2155
|
if (domains.length === 0) {
|
|
1933
2156
|
return new _Domain([]);
|
|
@@ -2006,7 +2229,7 @@ var Domain = (_class2 = class _Domain {
|
|
|
2006
2229
|
processLeaf(d.ast.value, 0, "&", newDomain);
|
|
2007
2230
|
return newDomain;
|
|
2008
2231
|
}
|
|
2009
|
-
constructor(descr = []) {
|
|
2232
|
+
constructor(descr = []) {
|
|
2010
2233
|
if (descr instanceof _Domain) {
|
|
2011
2234
|
return new _Domain(descr.toString());
|
|
2012
2235
|
} else {
|
|
@@ -2042,17 +2265,11 @@ var Domain = (_class2 = class _Domain {
|
|
|
2042
2265
|
return evaluatedAsList;
|
|
2043
2266
|
}
|
|
2044
2267
|
return this.toString();
|
|
2045
|
-
} catch
|
|
2268
|
+
} catch {
|
|
2046
2269
|
return this.toString();
|
|
2047
2270
|
}
|
|
2048
2271
|
}
|
|
2049
|
-
}
|
|
2050
|
-
function evalDomain(modifier, evalContext) {
|
|
2051
|
-
if (modifier && typeof modifier !== "boolean") {
|
|
2052
|
-
modifier = new Domain(modifier).contains(evalContext);
|
|
2053
|
-
}
|
|
2054
|
-
return Boolean(modifier);
|
|
2055
|
-
}
|
|
2272
|
+
};
|
|
2056
2273
|
var TRUE_LEAF = [1, "=", 1];
|
|
2057
2274
|
var FALSE_LEAF = [0, "=", 1];
|
|
2058
2275
|
var TRUE_DOMAIN = new Domain([TRUE_LEAF]);
|
|
@@ -2272,19 +2489,12 @@ var checkDomain = (context, domain) => {
|
|
|
2272
2489
|
};
|
|
2273
2490
|
var matchDomains = (context, domains) => {
|
|
2274
2491
|
if (Array.isArray(domains)) {
|
|
2275
|
-
if (
|
|
2492
|
+
if (domains?.length > 0) {
|
|
2276
2493
|
return domains && domains.some((domain) => checkDomain(context, domain));
|
|
2277
2494
|
}
|
|
2278
2495
|
} else return checkDomain(context, domains);
|
|
2279
2496
|
return false;
|
|
2280
2497
|
};
|
|
2281
|
-
|
|
2282
|
-
// src/utils/function/index.ts
|
|
2283
|
-
var domainHelper = {
|
|
2284
|
-
checkDomain,
|
|
2285
|
-
matchDomains,
|
|
2286
|
-
Domain
|
|
2287
|
-
};
|
|
2288
2498
|
var evalJSONContext = (_context, context = {}) => {
|
|
2289
2499
|
try {
|
|
2290
2500
|
return evalPartialContext(
|
|
@@ -2299,16 +2509,16 @@ var evalJSONDomain = (domain, context) => {
|
|
|
2299
2509
|
const cloneContext = JSON.parse(JSON.stringify(context));
|
|
2300
2510
|
try {
|
|
2301
2511
|
if (cloneContext) {
|
|
2302
|
-
|
|
2512
|
+
Object.keys(cloneContext)?.forEach((key) => {
|
|
2303
2513
|
if (Array.isArray(cloneContext[key])) {
|
|
2304
|
-
const isTypeObject =
|
|
2305
|
-
(item) => typeof item === "object" && item !== null &&
|
|
2306
|
-
)
|
|
2514
|
+
const isTypeObject = cloneContext[key]?.every(
|
|
2515
|
+
(item) => typeof item === "object" && item !== null && item?.id !== void 0
|
|
2516
|
+
);
|
|
2307
2517
|
if (isTypeObject) {
|
|
2308
|
-
cloneContext[key] =
|
|
2518
|
+
cloneContext[key] = cloneContext[key]?.map((item) => item?.id);
|
|
2309
2519
|
}
|
|
2310
2520
|
}
|
|
2311
|
-
})
|
|
2521
|
+
});
|
|
2312
2522
|
}
|
|
2313
2523
|
const value = evaluateExpr(domain, cloneContext);
|
|
2314
2524
|
return value;
|
|
@@ -2325,24 +2535,320 @@ var formatSortingString = (input) => {
|
|
|
2325
2535
|
if (!input) return null;
|
|
2326
2536
|
return input.split(",").map((field) => {
|
|
2327
2537
|
const [key, order] = field.trim().split(/\s+/);
|
|
2328
|
-
const sortOrder =
|
|
2538
|
+
const sortOrder = order?.toUpperCase() === "DESC" ? "DESC" : "ASC";
|
|
2329
2539
|
return `${key} ${sortOrder}`;
|
|
2330
2540
|
}).join(", ");
|
|
2331
2541
|
};
|
|
2542
|
+
var domainHelper = {
|
|
2543
|
+
checkDomain,
|
|
2544
|
+
matchDomains,
|
|
2545
|
+
Domain
|
|
2546
|
+
};
|
|
2332
2547
|
var toQueryString = (params) => {
|
|
2333
2548
|
return Object.keys(params).map(
|
|
2334
2549
|
(key) => encodeURIComponent(key) + "=" + encodeURIComponent(params[key].toString())
|
|
2335
2550
|
).join("&");
|
|
2336
2551
|
};
|
|
2337
|
-
|
|
2338
|
-
const
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2552
|
+
var convertFloatToTime = (floatValue) => {
|
|
2553
|
+
const hours = Math.floor(floatValue);
|
|
2554
|
+
const minutes = Math.round((floatValue - hours) * 60);
|
|
2555
|
+
const formattedHours = String(hours).padStart(2, "0");
|
|
2556
|
+
const formattedMinutes = String(minutes).padStart(2, "0");
|
|
2557
|
+
return `${formattedHours}:${formattedMinutes}`;
|
|
2558
|
+
};
|
|
2559
|
+
var convertTimeToFloat = (timeString) => {
|
|
2560
|
+
const [hours, minutes] = timeString.split(":").map(Number);
|
|
2561
|
+
return hours + minutes / 60;
|
|
2562
|
+
};
|
|
2563
|
+
var stringToColor = (name, id) => {
|
|
2564
|
+
const combined = name + id / 2;
|
|
2565
|
+
let hash = 0;
|
|
2566
|
+
for (let i = 0; i < combined.length; i++) {
|
|
2567
|
+
hash = combined.charCodeAt(i) + ((hash << 5) - hash);
|
|
2568
|
+
}
|
|
2569
|
+
const r = hash >> 16 & 255;
|
|
2570
|
+
const g = hash >> 8 & 255;
|
|
2571
|
+
const b = hash & 255;
|
|
2572
|
+
const rNorm = r / 255;
|
|
2573
|
+
const gNorm = g / 255;
|
|
2574
|
+
const bNorm = b / 255;
|
|
2575
|
+
const max = Math.max(rNorm, gNorm, bNorm);
|
|
2576
|
+
const min = Math.min(rNorm, gNorm, bNorm);
|
|
2577
|
+
const delta = max - min;
|
|
2578
|
+
let h = 0;
|
|
2579
|
+
if (delta !== 0) {
|
|
2580
|
+
if (max === rNorm) h = (gNorm - bNorm) / delta % 6;
|
|
2581
|
+
else if (max === gNorm) h = (bNorm - rNorm) / delta + 2;
|
|
2582
|
+
else h = (rNorm - gNorm) / delta + 4;
|
|
2583
|
+
}
|
|
2584
|
+
h = Math.round(h * 60);
|
|
2585
|
+
if (h < 0) h += 360;
|
|
2586
|
+
let l = (max + min) / 2;
|
|
2587
|
+
let s = delta === 0 ? 0 : delta / (1 - Math.abs(2 * l - 1));
|
|
2588
|
+
s = Math.min(1, s * 1.8);
|
|
2589
|
+
l = Math.min(0.75, l * 1.05);
|
|
2590
|
+
const c = (1 - Math.abs(2 * l - 1)) * s;
|
|
2591
|
+
const x = c * (1 - Math.abs(h / 60 % 2 - 1));
|
|
2592
|
+
const m = l - c / 2;
|
|
2593
|
+
let r2 = 0, g2 = 0, b2 = 0;
|
|
2594
|
+
if (0 <= h && h < 60) [r2, g2, b2] = [c, x, 0];
|
|
2595
|
+
else if (60 <= h && h < 120) [r2, g2, b2] = [x, c, 0];
|
|
2596
|
+
else if (120 <= h && h < 180) [r2, g2, b2] = [0, c, x];
|
|
2597
|
+
else if (180 <= h && h < 240) [r2, g2, b2] = [0, x, c];
|
|
2598
|
+
else if (240 <= h && h < 300) [r2, g2, b2] = [x, 0, c];
|
|
2599
|
+
else [r2, g2, b2] = [c, 0, x];
|
|
2600
|
+
const finalR = Math.round((r2 + m) * 255);
|
|
2601
|
+
const finalG = Math.round((g2 + m) * 255);
|
|
2602
|
+
const finalB = Math.round((b2 + m) * 255);
|
|
2603
|
+
return `#${finalR.toString(16).padStart(2, "0")}${finalG.toString(16).padStart(2, "0")}${finalB.toString(16).padStart(2, "0")}`;
|
|
2604
|
+
};
|
|
2605
|
+
var getFieldsOnChange = (fields) => {
|
|
2606
|
+
const result = [];
|
|
2607
|
+
function traverse(items) {
|
|
2608
|
+
for (const item of items) {
|
|
2609
|
+
if (item) {
|
|
2610
|
+
if (item?.type_co === "field" && matchDomains(fields, item?.on_change)) {
|
|
2611
|
+
result.push(item.name);
|
|
2612
|
+
}
|
|
2613
|
+
if (item?.fields && Array.isArray(item?.fields)) {
|
|
2614
|
+
traverse(item?.fields);
|
|
2615
|
+
}
|
|
2616
|
+
}
|
|
2342
2617
|
}
|
|
2343
2618
|
}
|
|
2619
|
+
traverse(fields);
|
|
2344
2620
|
return result;
|
|
2345
|
-
}
|
|
2621
|
+
};
|
|
2622
|
+
var filterFieldDirty = ({
|
|
2623
|
+
id,
|
|
2624
|
+
viewData,
|
|
2625
|
+
formValues,
|
|
2626
|
+
dirtyFields,
|
|
2627
|
+
model,
|
|
2628
|
+
defaultData,
|
|
2629
|
+
keepZeroValue = false
|
|
2630
|
+
}) => {
|
|
2631
|
+
const data = id ? { ...dirtyFields } : { ...formValues };
|
|
2632
|
+
for (const key in data) {
|
|
2633
|
+
if (viewData?.models?.[model]?.[key]?.type === "one2many" /* ONE2MANY */) {
|
|
2634
|
+
const lineData = [];
|
|
2635
|
+
(formValues[key] ?? []).forEach((itemData, index) => {
|
|
2636
|
+
if (typeof itemData?.id === "string" && itemData?.id.includes("virtual")) {
|
|
2637
|
+
delete itemData?.id;
|
|
2638
|
+
}
|
|
2639
|
+
if (!itemData?.id) {
|
|
2640
|
+
lineData.push([
|
|
2641
|
+
0 /* CREATE */,
|
|
2642
|
+
`virtual_${index}`,
|
|
2643
|
+
filterFieldDirty({
|
|
2644
|
+
id: itemData?.id,
|
|
2645
|
+
viewData,
|
|
2646
|
+
formValues: itemData,
|
|
2647
|
+
dirtyFields: {},
|
|
2648
|
+
model: viewData?.models?.[model]?.[key]?.relation,
|
|
2649
|
+
defaultData,
|
|
2650
|
+
keepZeroValue
|
|
2651
|
+
})
|
|
2652
|
+
]);
|
|
2653
|
+
} else if (dirtyFields[key]?.length) {
|
|
2654
|
+
dirtyFields[key].forEach((itemDirty, indexDirty) => {
|
|
2655
|
+
if (Object.values(itemDirty).includes(true) && indexDirty === index) {
|
|
2656
|
+
lineData.push([
|
|
2657
|
+
1 /* UPDATE */,
|
|
2658
|
+
itemData?.id,
|
|
2659
|
+
filterFieldDirty({
|
|
2660
|
+
id: itemData?.id,
|
|
2661
|
+
viewData,
|
|
2662
|
+
formValues: itemData,
|
|
2663
|
+
dirtyFields: itemDirty,
|
|
2664
|
+
model: viewData?.models?.[model]?.[key]?.relation,
|
|
2665
|
+
defaultData: {},
|
|
2666
|
+
keepZeroValue
|
|
2667
|
+
})
|
|
2668
|
+
]);
|
|
2669
|
+
}
|
|
2670
|
+
});
|
|
2671
|
+
}
|
|
2672
|
+
});
|
|
2673
|
+
(defaultData[key] ?? []).forEach((item) => {
|
|
2674
|
+
if (!(formValues[key] ?? []).find(
|
|
2675
|
+
(itemData) => itemData?.id === item?.id
|
|
2676
|
+
)) {
|
|
2677
|
+
lineData.push([2 /* DELETE */, item?.id, item]);
|
|
2678
|
+
}
|
|
2679
|
+
});
|
|
2680
|
+
data[key] = lineData;
|
|
2681
|
+
} else if (viewData?.models?.[model]?.[key]?.type === "many2many" /* MANY2MANY */) {
|
|
2682
|
+
const lineData = [];
|
|
2683
|
+
(formValues[key] || []).forEach((itemData) => {
|
|
2684
|
+
if (itemData?.id) {
|
|
2685
|
+
lineData.push([4 /* NO_CHANGE */, itemData?.id]);
|
|
2686
|
+
}
|
|
2687
|
+
});
|
|
2688
|
+
(defaultData[key] ?? []).forEach((item) => {
|
|
2689
|
+
if (!(formValues[key] ?? []).find(
|
|
2690
|
+
(itemData) => itemData?.id === item?.id
|
|
2691
|
+
)) {
|
|
2692
|
+
lineData.push([3 /* UNLINK */, item?.id]);
|
|
2693
|
+
}
|
|
2694
|
+
});
|
|
2695
|
+
data[key] = lineData;
|
|
2696
|
+
} else {
|
|
2697
|
+
if (id && (typeof dirtyFields?.[key] === "object" && !dirtyFields?.[key]?.id || typeof dirtyFields[key] !== "object" && !dirtyFields[key])) {
|
|
2698
|
+
if (!(keepZeroValue && (formValues[key] === 0 || formValues[key] === "0"))) {
|
|
2699
|
+
delete data[key];
|
|
2700
|
+
}
|
|
2701
|
+
} else {
|
|
2702
|
+
if (!data[key] && !(keepZeroValue && (data[key] === 0 || data[key] === "0"))) {
|
|
2703
|
+
delete data[key];
|
|
2704
|
+
} else {
|
|
2705
|
+
data[key] = formValues?.[key]?.display_name ? formValues?.[key]?.id : formValues?.[key];
|
|
2706
|
+
}
|
|
2707
|
+
}
|
|
2708
|
+
}
|
|
2709
|
+
}
|
|
2710
|
+
return data;
|
|
2711
|
+
};
|
|
2712
|
+
var mergeObjects = (object1, object2) => {
|
|
2713
|
+
if (!object1 || !object2) return void 0;
|
|
2714
|
+
const mergedObject = { ...object2 };
|
|
2715
|
+
Object.keys(object1).forEach((key) => {
|
|
2716
|
+
if (Array.isArray(object1[key]) && Array.isArray(object2[key])) {
|
|
2717
|
+
mergedObject[key] = object2[key].map((item, index) => {
|
|
2718
|
+
if (object1[key][index]) {
|
|
2719
|
+
return {
|
|
2720
|
+
...item,
|
|
2721
|
+
...object1[key][index]
|
|
2722
|
+
};
|
|
2723
|
+
}
|
|
2724
|
+
return item;
|
|
2725
|
+
});
|
|
2726
|
+
} else if (typeof object1[key] === "object" && typeof object2[key] === "object" && object1[key] !== null && object2[key] !== null) {
|
|
2727
|
+
mergedObject[key] = mergeObjects(object1[key], object2[key]);
|
|
2728
|
+
} else {
|
|
2729
|
+
mergedObject[key] = object1[key] !== void 0 ? object1[key] : object2[key];
|
|
2730
|
+
}
|
|
2731
|
+
});
|
|
2732
|
+
if (object2) {
|
|
2733
|
+
Object.keys(object2).forEach((key) => {
|
|
2734
|
+
if (!mergedObject.hasOwnProperty(key)) {
|
|
2735
|
+
mergedObject[key] = object2[key];
|
|
2736
|
+
}
|
|
2737
|
+
});
|
|
2738
|
+
}
|
|
2739
|
+
return mergedObject;
|
|
2740
|
+
};
|
|
2741
|
+
var formatUrlPath = ({
|
|
2742
|
+
viewType,
|
|
2743
|
+
aid,
|
|
2744
|
+
model,
|
|
2745
|
+
id,
|
|
2746
|
+
actionPath
|
|
2747
|
+
}) => {
|
|
2748
|
+
let _url = `/${viewType}/${actionPath}?aid=${aid}&model=${model}`;
|
|
2749
|
+
if (id) {
|
|
2750
|
+
_url += `&id=${id}`;
|
|
2751
|
+
}
|
|
2752
|
+
return _url;
|
|
2753
|
+
};
|
|
2754
|
+
var removeUndefinedFields = (obj) => {
|
|
2755
|
+
const newObj = {};
|
|
2756
|
+
for (const key in obj) {
|
|
2757
|
+
if (obj[key] !== void 0) {
|
|
2758
|
+
newObj[key] = obj[key];
|
|
2759
|
+
}
|
|
2760
|
+
}
|
|
2761
|
+
return newObj;
|
|
2762
|
+
};
|
|
2763
|
+
var useTabModel = (viewData, onchangeData) => {
|
|
2764
|
+
const tabsData = viewData?.views?.form?.tabs?.filter((val) => {
|
|
2765
|
+
if (!val) return null;
|
|
2766
|
+
const hide = checkDomain(onchangeData, val.invisible);
|
|
2767
|
+
if (!hide) {
|
|
2768
|
+
return val;
|
|
2769
|
+
}
|
|
2770
|
+
return false;
|
|
2771
|
+
}) || [];
|
|
2772
|
+
return tabsData;
|
|
2773
|
+
};
|
|
2774
|
+
var isBase64File = (str) => {
|
|
2775
|
+
try {
|
|
2776
|
+
const dataUriPattern = /^data:([a-zA-Z]+\/[a-zA-Z0-9-.+]+)?;base64,/;
|
|
2777
|
+
if (dataUriPattern.test(str)) {
|
|
2778
|
+
return true;
|
|
2779
|
+
}
|
|
2780
|
+
const base64Pattern = (
|
|
2781
|
+
// eslint-disable-next-line no-useless-escape
|
|
2782
|
+
/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{3}=|[A-Za-z0-9+\/]{2}==)?$/
|
|
2783
|
+
);
|
|
2784
|
+
return base64Pattern.test(str);
|
|
2785
|
+
} catch (e) {
|
|
2786
|
+
return false;
|
|
2787
|
+
}
|
|
2788
|
+
};
|
|
2789
|
+
var isBase64Image = (str) => {
|
|
2790
|
+
const base64Regex = /^data:image\/(png|jpeg|jpg|gif|webp);base64,/;
|
|
2791
|
+
if (!base64Regex.test(str)) {
|
|
2792
|
+
return false;
|
|
2793
|
+
}
|
|
2794
|
+
try {
|
|
2795
|
+
const base64Data = str.split(",")[1];
|
|
2796
|
+
return !!base64Data && atob(base64Data).length > 0;
|
|
2797
|
+
} catch (error) {
|
|
2798
|
+
return false;
|
|
2799
|
+
}
|
|
2800
|
+
};
|
|
2801
|
+
var checkIsImageLink = (url) => {
|
|
2802
|
+
const imageExtensions = /\.(jpg|jpeg|png|gif|bmp|webp|svg|tiff|ico)$/i;
|
|
2803
|
+
return imageExtensions.test(url) || isBase64Image(url);
|
|
2804
|
+
};
|
|
2805
|
+
var formatFileSize = (size) => {
|
|
2806
|
+
if (size < 1024) return `${size} B`;
|
|
2807
|
+
const i = Math.floor(Math.log(size) / Math.log(1024));
|
|
2808
|
+
const sizes = ["B", "KB", "MB", "GB", "TB"];
|
|
2809
|
+
return `${(size / Math.pow(1024, i)).toFixed(2)} ${sizes[i]}`;
|
|
2810
|
+
};
|
|
2811
|
+
var getSubdomain = (url = window.location.href) => {
|
|
2812
|
+
const parts = url?.split(".");
|
|
2813
|
+
if (parts.length > 2) {
|
|
2814
|
+
return parts[0].replace("https://", "").replace("http://", "");
|
|
2815
|
+
}
|
|
2816
|
+
return null;
|
|
2817
|
+
};
|
|
2818
|
+
var resequence = (arr, start, end) => {
|
|
2819
|
+
if (start < 0 || start >= arr.length || end < 0 || end >= arr.length) {
|
|
2820
|
+
return [];
|
|
2821
|
+
}
|
|
2822
|
+
const [element] = arr.splice(start, 1);
|
|
2823
|
+
arr.splice(end, 0, element);
|
|
2824
|
+
return arr.slice(Math.min(start, end), Math.max(start, end) + 1);
|
|
2825
|
+
};
|
|
2826
|
+
var getOffSet = (arr, start, end) => {
|
|
2827
|
+
if (start < 0 || start >= arr.length || end < 0 || end >= arr.length) {
|
|
2828
|
+
return 0;
|
|
2829
|
+
}
|
|
2830
|
+
if (start > end) {
|
|
2831
|
+
return end;
|
|
2832
|
+
}
|
|
2833
|
+
return arr.slice(0, start).length;
|
|
2834
|
+
};
|
|
2835
|
+
var copyTextToClipboard = async (text) => {
|
|
2836
|
+
if ("clipboard" in navigator) {
|
|
2837
|
+
return await navigator.clipboard.writeText(text);
|
|
2838
|
+
} else {
|
|
2839
|
+
const textArea = document.createElement("textarea");
|
|
2840
|
+
textArea.value = text;
|
|
2841
|
+
textArea.style.position = "fixed";
|
|
2842
|
+
document.body.appendChild(textArea);
|
|
2843
|
+
textArea.focus();
|
|
2844
|
+
textArea.select();
|
|
2845
|
+
try {
|
|
2846
|
+
document.execCommand("copy");
|
|
2847
|
+
} finally {
|
|
2848
|
+
document.body.removeChild(textArea);
|
|
2849
|
+
}
|
|
2850
|
+
}
|
|
2851
|
+
};
|
|
2346
2852
|
var updateTokenParamInOriginalRequest = (originalRequest, newAccessToken) => {
|
|
2347
2853
|
if (!originalRequest.data) return originalRequest.data;
|
|
2348
2854
|
if (typeof originalRequest.data === "string") {
|
|
@@ -2362,22 +2868,198 @@ var updateTokenParamInOriginalRequest = (originalRequest, newAccessToken) => {
|
|
|
2362
2868
|
}
|
|
2363
2869
|
return originalRequest.data;
|
|
2364
2870
|
};
|
|
2871
|
+
var isObjectEmpty = (obj) => {
|
|
2872
|
+
return Object.keys(obj).length === 0;
|
|
2873
|
+
};
|
|
2874
|
+
var useField = (props) => {
|
|
2875
|
+
const [invisible, setInvisible] = react.useState(true);
|
|
2876
|
+
const [required, setRequired] = react.useState(false);
|
|
2877
|
+
const [readonly, setReadOnly] = react.useState(false);
|
|
2878
|
+
const {
|
|
2879
|
+
invisible: inv,
|
|
2880
|
+
required: req,
|
|
2881
|
+
readonly: rea,
|
|
2882
|
+
onchangeData,
|
|
2883
|
+
rootField,
|
|
2884
|
+
index,
|
|
2885
|
+
name
|
|
2886
|
+
} = props;
|
|
2887
|
+
const nameField = rootField ? `${rootField?.name}.${index}.${name}` : null;
|
|
2888
|
+
react.useEffect(() => {
|
|
2889
|
+
if (onchangeData && Object.keys(onchangeData).length > 0) {
|
|
2890
|
+
setRequired(
|
|
2891
|
+
typeof req === "object" ? matchDomains(onchangeData, req) : checkDomain(onchangeData, req)
|
|
2892
|
+
);
|
|
2893
|
+
setInvisible(matchDomains(onchangeData, inv));
|
|
2894
|
+
setReadOnly(
|
|
2895
|
+
typeof req === "object" ? matchDomains(onchangeData, rea) : checkDomain(onchangeData, rea)
|
|
2896
|
+
);
|
|
2897
|
+
}
|
|
2898
|
+
}, [onchangeData]);
|
|
2899
|
+
return {
|
|
2900
|
+
invisible,
|
|
2901
|
+
required,
|
|
2902
|
+
readonly,
|
|
2903
|
+
nameField
|
|
2904
|
+
};
|
|
2905
|
+
};
|
|
2906
|
+
var downloadFile = async (url, filename) => {
|
|
2907
|
+
try {
|
|
2908
|
+
const response = await fetch(url);
|
|
2909
|
+
if (!response.ok) throw new Error(`Failed to fetch ${url}`);
|
|
2910
|
+
const contentType = response.headers.get("Content-Type") || "";
|
|
2911
|
+
let ext = "";
|
|
2912
|
+
if (contentType.includes("pdf")) ext = ".pdf";
|
|
2913
|
+
else if (contentType.includes("png")) ext = ".png";
|
|
2914
|
+
else if (contentType.includes("jpeg") || contentType.includes("jpg"))
|
|
2915
|
+
ext = ".jpg";
|
|
2916
|
+
else if (contentType.includes("zip")) ext = ".zip";
|
|
2917
|
+
else if (contentType.includes("msword")) ext = ".doc";
|
|
2918
|
+
else if (contentType.includes("spreadsheet")) ext = ".xls";
|
|
2919
|
+
else if (contentType.includes("json")) ext = ".json";
|
|
2920
|
+
else if (contentType.includes("text")) ext = ".txt";
|
|
2921
|
+
else {
|
|
2922
|
+
ext = "";
|
|
2923
|
+
}
|
|
2924
|
+
const blob = await response.blob();
|
|
2925
|
+
const urlBlob = window.URL.createObjectURL(blob);
|
|
2926
|
+
const link = document.createElement("a");
|
|
2927
|
+
link.href = urlBlob;
|
|
2928
|
+
link.download = (filename || "file") + ext;
|
|
2929
|
+
document.body.appendChild(link);
|
|
2930
|
+
link.click();
|
|
2931
|
+
document.body.removeChild(link);
|
|
2932
|
+
window.URL.revokeObjectURL(urlBlob);
|
|
2933
|
+
} catch (error) {
|
|
2934
|
+
console.error("File download failed:", error);
|
|
2935
|
+
}
|
|
2936
|
+
};
|
|
2937
|
+
function cleanObject(obj) {
|
|
2938
|
+
const result = {};
|
|
2939
|
+
for (const [k, v] of Object.entries(obj)) {
|
|
2940
|
+
if (v !== null && v !== void 0) {
|
|
2941
|
+
result[k] = v;
|
|
2942
|
+
}
|
|
2943
|
+
}
|
|
2944
|
+
return result;
|
|
2945
|
+
}
|
|
2946
|
+
var extractIdFromDomain = (domain) => {
|
|
2947
|
+
if (!domain || !Array.isArray(domain)) return null;
|
|
2948
|
+
const idCond = domain.find(
|
|
2949
|
+
([field, operator]) => field === "id" && operator === "="
|
|
2950
|
+
);
|
|
2951
|
+
return idCond ? Number(idCond[2]) : null;
|
|
2952
|
+
};
|
|
2365
2953
|
|
|
2954
|
+
// src/utils/storage/local-storage.ts
|
|
2955
|
+
var localStorageUtils = () => {
|
|
2956
|
+
const setToken = async (access_token) => {
|
|
2957
|
+
localStorage.setItem("accessToken", access_token);
|
|
2958
|
+
};
|
|
2959
|
+
const setRefreshToken = async (refresh_token) => {
|
|
2960
|
+
localStorage.setItem("refreshToken", refresh_token);
|
|
2961
|
+
};
|
|
2962
|
+
const getAccessToken = async () => {
|
|
2963
|
+
return localStorage.getItem("accessToken");
|
|
2964
|
+
};
|
|
2965
|
+
const getRefreshToken = async () => {
|
|
2966
|
+
return localStorage.getItem("refreshToken");
|
|
2967
|
+
};
|
|
2968
|
+
const clearToken = async () => {
|
|
2969
|
+
localStorage.removeItem("accessToken");
|
|
2970
|
+
localStorage.removeItem("refreshToken");
|
|
2971
|
+
};
|
|
2972
|
+
return {
|
|
2973
|
+
setToken,
|
|
2974
|
+
setRefreshToken,
|
|
2975
|
+
getAccessToken,
|
|
2976
|
+
getRefreshToken,
|
|
2977
|
+
clearToken
|
|
2978
|
+
};
|
|
2979
|
+
};
|
|
2366
2980
|
|
|
2981
|
+
// src/utils/storage/session-storage.ts
|
|
2982
|
+
var sessionStorageUtils = /* @__PURE__ */ (() => {
|
|
2983
|
+
const getMenuFocus = () => {
|
|
2984
|
+
const menuFocus = sessionStorage.getItem("menuFocus");
|
|
2985
|
+
return menuFocus ? JSON.parse(menuFocus) : {
|
|
2986
|
+
id: void 0,
|
|
2987
|
+
service: ""
|
|
2988
|
+
};
|
|
2989
|
+
};
|
|
2990
|
+
const setMenuFocus = (menuTree) => {
|
|
2991
|
+
sessionStorage.setItem("menuFocus", JSON.stringify({ ...menuTree }));
|
|
2992
|
+
};
|
|
2993
|
+
const getActionData = () => {
|
|
2994
|
+
const actionData = sessionStorage.getItem("actionData");
|
|
2995
|
+
return actionData ? JSON.parse(actionData) : {};
|
|
2996
|
+
};
|
|
2997
|
+
const setActionData = (actData) => {
|
|
2998
|
+
sessionStorage.setItem("actionData", JSON.stringify(actData));
|
|
2999
|
+
};
|
|
3000
|
+
const getViewData = () => {
|
|
3001
|
+
const viewData = sessionStorage.getItem("viewData");
|
|
3002
|
+
return viewData ? JSON.parse(viewData) : {};
|
|
3003
|
+
};
|
|
3004
|
+
const getBrowserSession = () => {
|
|
3005
|
+
const actionData = sessionStorage.getItem("browserSession");
|
|
3006
|
+
return actionData ? JSON.parse(actionData) : null;
|
|
3007
|
+
};
|
|
3008
|
+
const setViewData = (viewData) => {
|
|
3009
|
+
sessionStorage.setItem("viewData", JSON.stringify(viewData));
|
|
3010
|
+
};
|
|
3011
|
+
const getXNode = () => {
|
|
3012
|
+
const xNode = sessionStorage.getItem("xNode");
|
|
3013
|
+
return xNode;
|
|
3014
|
+
};
|
|
3015
|
+
const setXNode = (xNode) => {
|
|
3016
|
+
sessionStorage.setItem("xNode", xNode);
|
|
3017
|
+
};
|
|
3018
|
+
return {
|
|
3019
|
+
getMenuFocus,
|
|
3020
|
+
setMenuFocus,
|
|
3021
|
+
setActionData,
|
|
3022
|
+
getActionData,
|
|
3023
|
+
getViewData,
|
|
3024
|
+
setViewData,
|
|
3025
|
+
getBrowserSession,
|
|
3026
|
+
getXNode,
|
|
3027
|
+
setXNode
|
|
3028
|
+
};
|
|
3029
|
+
})();
|
|
2367
3030
|
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
exports.
|
|
3031
|
+
exports.WesapError = WesapError;
|
|
3032
|
+
exports.checkIsImageLink = checkIsImageLink;
|
|
3033
|
+
exports.cleanObject = cleanObject;
|
|
3034
|
+
exports.convertFloatToTime = convertFloatToTime;
|
|
3035
|
+
exports.convertTimeToFloat = convertTimeToFloat;
|
|
3036
|
+
exports.copyTextToClipboard = copyTextToClipboard;
|
|
3037
|
+
exports.domainHelper = domainHelper;
|
|
3038
|
+
exports.downloadFile = downloadFile;
|
|
3039
|
+
exports.evalJSONContext = evalJSONContext;
|
|
3040
|
+
exports.evalJSONDomain = evalJSONDomain;
|
|
3041
|
+
exports.extractIdFromDomain = extractIdFromDomain;
|
|
3042
|
+
exports.filterFieldDirty = filterFieldDirty;
|
|
3043
|
+
exports.formatCurrency = formatCurrency;
|
|
3044
|
+
exports.formatDate = formatDate;
|
|
3045
|
+
exports.formatFileSize = formatFileSize;
|
|
3046
|
+
exports.formatSortingString = formatSortingString;
|
|
3047
|
+
exports.formatUrlPath = formatUrlPath;
|
|
3048
|
+
exports.getFieldsOnChange = getFieldsOnChange;
|
|
3049
|
+
exports.getOffSet = getOffSet;
|
|
3050
|
+
exports.getSubdomain = getSubdomain;
|
|
3051
|
+
exports.handleError = handleError;
|
|
3052
|
+
exports.isBase64File = isBase64File;
|
|
3053
|
+
exports.isBase64Image = isBase64Image;
|
|
3054
|
+
exports.isObjectEmpty = isObjectEmpty;
|
|
3055
|
+
exports.localStorageUtils = localStorageUtils;
|
|
3056
|
+
exports.mergeObjects = mergeObjects;
|
|
3057
|
+
exports.removeUndefinedFields = removeUndefinedFields;
|
|
3058
|
+
exports.resequence = resequence;
|
|
3059
|
+
exports.sessionStorageUtils = sessionStorageUtils;
|
|
3060
|
+
exports.stringToColor = stringToColor;
|
|
3061
|
+
exports.toQueryString = toQueryString;
|
|
3062
|
+
exports.updateTokenParamInOriginalRequest = updateTokenParamInOriginalRequest;
|
|
3063
|
+
exports.useField = useField;
|
|
3064
|
+
exports.useTabModel = useTabModel;
|
|
3065
|
+
exports.validateAndParseDate = validateAndParseDate;
|