@fctc/interface-logic 5.2.6 → 5.2.7
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 +7 -1
- package/dist/hooks.d.ts +7 -1
- 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.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 +28 -14
|
@@ -1,79 +1,313 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
+
import moment from 'moment';
|
|
2
|
+
import { useState, useEffect } from 'react';
|
|
27
3
|
|
|
28
|
-
// src/utils/
|
|
29
|
-
var
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
4
|
+
// src/utils/error-handler.ts
|
|
5
|
+
var WesapError = class extends Error {
|
|
6
|
+
code;
|
|
7
|
+
constructor(message, code) {
|
|
8
|
+
super(message);
|
|
9
|
+
this.code = code;
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
function handleError(error, env) {
|
|
13
|
+
if (error instanceof WesapError) {
|
|
14
|
+
env.services.notification.error(error.message);
|
|
15
|
+
} else {
|
|
16
|
+
env.services.notification.error("An unexpected error occurred");
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
var formatCurrency = (amount, currency = "USD") => {
|
|
20
|
+
const formatter = new Intl.NumberFormat("vi-VN", {
|
|
21
|
+
style: "currency",
|
|
22
|
+
currency,
|
|
23
|
+
minimumFractionDigits: 0
|
|
24
|
+
});
|
|
25
|
+
return formatter.format(amount).replaceAll(".", ",");
|
|
26
|
+
};
|
|
27
|
+
var formatDate = (date, locale = "en-US") => {
|
|
28
|
+
return new Intl.DateTimeFormat(locale).format(new Date(date));
|
|
29
|
+
};
|
|
30
|
+
var validateAndParseDate = (input, isDateTime = false) => {
|
|
31
|
+
if (!input || typeof input !== "string") return null;
|
|
32
|
+
const cleanInput = input.replace(/[^0-9-\/:\s]/g, "");
|
|
33
|
+
const dateFormat = "YYYY-MM-DD";
|
|
34
|
+
const dateTimeFormat = "YYYY-MM-DD HH:mm:ss";
|
|
35
|
+
const currentDay = moment().format("DD");
|
|
36
|
+
const currentMonth = moment().format("MM");
|
|
37
|
+
const currentYear = moment().format("YYYY");
|
|
38
|
+
const defaultTime = "00:00:00";
|
|
39
|
+
const maxYear = parseInt(currentYear) + 10;
|
|
40
|
+
const isValidDate = (day, month, year) => {
|
|
41
|
+
const date = moment(`${day}-${month}-${year}`, "DD-MM-YYYY", true);
|
|
42
|
+
return date.isValid();
|
|
61
43
|
};
|
|
62
|
-
const
|
|
63
|
-
|
|
44
|
+
const isValidTime = (hour, minute = "00", second = "00") => {
|
|
45
|
+
const h = parseInt(hour, 10);
|
|
46
|
+
const m = parseInt(minute, 10);
|
|
47
|
+
const s = parseInt(second, 10);
|
|
48
|
+
return h >= 0 && h <= 23 && m >= 0 && m <= 59 && s >= 0 && s <= 59;
|
|
64
49
|
};
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
50
|
+
const formatOutput = (day, month, year, time = defaultTime) => {
|
|
51
|
+
let result = moment(
|
|
52
|
+
`${day}-${month}-${year} ${time}`,
|
|
53
|
+
"DD-MM-YYYY HH:mm:ss"
|
|
54
|
+
);
|
|
55
|
+
if (!result.isValid()) return null;
|
|
56
|
+
if (isDateTime) {
|
|
57
|
+
result = result.subtract(7, "hours");
|
|
58
|
+
return result.format(dateTimeFormat);
|
|
59
|
+
}
|
|
60
|
+
return result.format(dateFormat);
|
|
75
61
|
};
|
|
76
|
-
|
|
62
|
+
if (isDateTime && input.match(
|
|
63
|
+
/^\d{1,2}[\/-]\d{1,2}[\/-]\d{2,4}\s+\d{1,2}(:\d{1,2}(:\d{1,2})?)?$/
|
|
64
|
+
)) {
|
|
65
|
+
const [datePart, timePart] = input.split(/\s+/);
|
|
66
|
+
const dateParts = datePart.split(/[\/-]/);
|
|
67
|
+
const timeParts = timePart.split(":");
|
|
68
|
+
const day = dateParts[0].padStart(2, "0");
|
|
69
|
+
const month = dateParts[1].padStart(2, "0");
|
|
70
|
+
const year = dateParts[2].length <= 2 ? `20${dateParts[2].padStart(2, "0")}` : dateParts[2].padStart(4, "0");
|
|
71
|
+
const hour = timeParts[0].padStart(2, "0");
|
|
72
|
+
const minute = timeParts[1] ? timeParts[1].padStart(2, "0") : "00";
|
|
73
|
+
const second = timeParts[2] ? timeParts[2].padStart(2, "0") : "00";
|
|
74
|
+
if (isValidDate(day, month, year) && isValidTime(hour, minute, second)) {
|
|
75
|
+
let result = moment(
|
|
76
|
+
`${day}-${month}-${year} ${hour}:${minute}:${second}`,
|
|
77
|
+
"DD-MM-YYYY HH:mm:ss"
|
|
78
|
+
);
|
|
79
|
+
if (!result.isValid()) return null;
|
|
80
|
+
result = result.subtract(7, "hours");
|
|
81
|
+
return result.format(dateTimeFormat);
|
|
82
|
+
}
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
if (cleanInput.match(/^\d{4}-\d{2}-\d{2}$/)) {
|
|
86
|
+
const [year, month, day] = cleanInput.split("-");
|
|
87
|
+
if (isValidDate(day, month, year)) {
|
|
88
|
+
return formatOutput(day, month, year);
|
|
89
|
+
}
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
if (cleanInput.match(/^\d{1,2}\/\d{1,2}\/\d{2,4}$/)) {
|
|
93
|
+
const [day, month, year] = cleanInput.split("/");
|
|
94
|
+
const paddedDay = day.padStart(2, "0");
|
|
95
|
+
const paddedMonth = month.padStart(2, "0");
|
|
96
|
+
const fullYear = year.length <= 2 ? `20${year.padStart(2, "0")}` : year.padStart(4, "0");
|
|
97
|
+
if (isValidDate(paddedDay, paddedMonth, fullYear)) {
|
|
98
|
+
return formatOutput(paddedDay, paddedMonth, fullYear);
|
|
99
|
+
}
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
if (cleanInput.match(/^\d{1,2}-\d{1,2}-\d{2,4}$/)) {
|
|
103
|
+
const [day, month, year] = cleanInput.split("-");
|
|
104
|
+
const paddedDay = day.padStart(2, "0");
|
|
105
|
+
const paddedMonth = month.padStart(2, "0");
|
|
106
|
+
const fullYear = year.length <= 2 ? `20${year.padStart(2, "0")}` : year.padStart(4, "0");
|
|
107
|
+
if (isValidDate(paddedDay, paddedMonth, fullYear)) {
|
|
108
|
+
return formatOutput(paddedDay, paddedMonth, fullYear);
|
|
109
|
+
}
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
if (cleanInput.match(/^\d{1,2}[\/-]\d{1,2}$/)) {
|
|
113
|
+
const [day, month] = cleanInput.split(/[\/-]/);
|
|
114
|
+
const paddedDay = day.padStart(2, "0");
|
|
115
|
+
const paddedMonth = month.padStart(2, "0");
|
|
116
|
+
if (isValidDate(paddedDay, paddedMonth, currentYear)) {
|
|
117
|
+
return formatOutput(paddedDay, paddedMonth, currentYear);
|
|
118
|
+
}
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
if (cleanInput.match(/^\d{4}$/)) {
|
|
122
|
+
const num = parseInt(cleanInput, 10);
|
|
123
|
+
if (num >= 2e3 && num <= maxYear) {
|
|
124
|
+
if (isValidDate(currentDay, currentMonth, num.toString())) {
|
|
125
|
+
return formatOutput(currentDay, currentMonth, num.toString());
|
|
126
|
+
}
|
|
127
|
+
return null;
|
|
128
|
+
}
|
|
129
|
+
const day = cleanInput.slice(0, 2);
|
|
130
|
+
const month = cleanInput.slice(2, 4);
|
|
131
|
+
if (isValidDate(day, month, currentYear)) {
|
|
132
|
+
return formatOutput(day, month, currentYear);
|
|
133
|
+
}
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
if (cleanInput.startsWith("-") && /^\-\d+$/.test(cleanInput)) {
|
|
137
|
+
const daysToSubtract = Math.abs(parseInt(cleanInput, 10));
|
|
138
|
+
let result = moment().subtract(daysToSubtract, "days");
|
|
139
|
+
if (isDateTime) {
|
|
140
|
+
result = result.subtract(7, "hours");
|
|
141
|
+
}
|
|
142
|
+
if (result.isValid()) {
|
|
143
|
+
return isDateTime ? result.format(dateTimeFormat) : result.format(dateFormat);
|
|
144
|
+
}
|
|
145
|
+
return null;
|
|
146
|
+
}
|
|
147
|
+
if (input.match(/^\d{1,2}[^0-9-\/]+\d{1,2}[^0-9-\/]+\d{2,4}.*$/)) {
|
|
148
|
+
const parts = input.split(/[^0-9-\/]+/).filter(Boolean);
|
|
149
|
+
const day = parts[0].padStart(2, "0");
|
|
150
|
+
const month = parts[1].padStart(2, "0");
|
|
151
|
+
let year = parts[2];
|
|
152
|
+
year = year.length === 2 ? `20${year}` : year.padStart(4, "0");
|
|
153
|
+
if (isValidDate(day, month, year)) {
|
|
154
|
+
return formatOutput(day, month, year);
|
|
155
|
+
}
|
|
156
|
+
return null;
|
|
157
|
+
}
|
|
158
|
+
if (isDateTime) {
|
|
159
|
+
if (cleanInput.length === 9) {
|
|
160
|
+
const day = cleanInput.slice(0, 2);
|
|
161
|
+
const month = cleanInput.slice(2, 4);
|
|
162
|
+
const year = cleanInput.slice(4, 8);
|
|
163
|
+
const hour = cleanInput.slice(8, 9).padStart(2, "0");
|
|
164
|
+
if (isValidDate(day, month, year) && isValidTime(hour)) {
|
|
165
|
+
let result = moment(
|
|
166
|
+
`${day}-${month}-${year} ${hour}:00:00`,
|
|
167
|
+
"DD-MM-YYYY HH:mm:ss"
|
|
168
|
+
);
|
|
169
|
+
if (!result.isValid()) return null;
|
|
170
|
+
result = result.subtract(7, "hours");
|
|
171
|
+
return result.format(dateTimeFormat);
|
|
172
|
+
}
|
|
173
|
+
return null;
|
|
174
|
+
}
|
|
175
|
+
if (cleanInput.length === 10) {
|
|
176
|
+
const day = cleanInput.slice(0, 2);
|
|
177
|
+
const month = cleanInput.slice(2, 4);
|
|
178
|
+
const year = cleanInput.slice(4, 8);
|
|
179
|
+
const hour = cleanInput.slice(8, 10);
|
|
180
|
+
if (isValidDate(day, month, year) && isValidTime(hour)) {
|
|
181
|
+
let result = moment(
|
|
182
|
+
`${day}-${month}-${year} ${hour}:00:00`,
|
|
183
|
+
"DD-MM-YYYY HH:mm:ss"
|
|
184
|
+
);
|
|
185
|
+
if (!result.isValid()) return null;
|
|
186
|
+
result = result.subtract(7, "hours");
|
|
187
|
+
return result.format(dateTimeFormat);
|
|
188
|
+
}
|
|
189
|
+
return null;
|
|
190
|
+
}
|
|
191
|
+
if (cleanInput.length === 11) {
|
|
192
|
+
const day = cleanInput.slice(0, 2);
|
|
193
|
+
const month = cleanInput.slice(2, 4);
|
|
194
|
+
const year = cleanInput.slice(4, 8);
|
|
195
|
+
const hour = cleanInput.slice(8, 10);
|
|
196
|
+
const minute = cleanInput.slice(10, 11).padStart(2, "0");
|
|
197
|
+
if (isValidDate(day, month, year) && isValidTime(hour, minute)) {
|
|
198
|
+
let result = moment(
|
|
199
|
+
`${day}-${month}-${year} ${hour}:${minute}:00`,
|
|
200
|
+
"DD-MM-YYYY HH:mm:ss"
|
|
201
|
+
);
|
|
202
|
+
if (!result.isValid()) return null;
|
|
203
|
+
result = result.subtract(7, "hours");
|
|
204
|
+
return result.format(dateTimeFormat);
|
|
205
|
+
}
|
|
206
|
+
return null;
|
|
207
|
+
}
|
|
208
|
+
if (cleanInput.length === 12) {
|
|
209
|
+
const day = cleanInput.slice(0, 2);
|
|
210
|
+
const month = cleanInput.slice(2, 4);
|
|
211
|
+
const year = cleanInput.slice(4, 8);
|
|
212
|
+
const hour = cleanInput.slice(8, 10);
|
|
213
|
+
const minute = cleanInput.slice(10, 12);
|
|
214
|
+
if (isValidDate(day, month, year) && isValidTime(hour, minute)) {
|
|
215
|
+
let result = moment(
|
|
216
|
+
`${day}-${month}-${year} ${hour}:${minute}:00`,
|
|
217
|
+
"DD-MM-YYYY HH:mm:ss"
|
|
218
|
+
);
|
|
219
|
+
if (!result.isValid()) return null;
|
|
220
|
+
result = result.subtract(7, "hours");
|
|
221
|
+
return result.format(dateTimeFormat);
|
|
222
|
+
}
|
|
223
|
+
return null;
|
|
224
|
+
}
|
|
225
|
+
if (cleanInput.length === 13) {
|
|
226
|
+
const day = cleanInput.slice(0, 2);
|
|
227
|
+
const month = cleanInput.slice(2, 4);
|
|
228
|
+
const year = cleanInput.slice(4, 8);
|
|
229
|
+
const hour = cleanInput.slice(8, 10);
|
|
230
|
+
const minute = cleanInput.slice(10, 12);
|
|
231
|
+
const second = cleanInput.slice(12, 13).padStart(2, "0");
|
|
232
|
+
if (isValidDate(day, month, year) && isValidTime(hour, minute, second)) {
|
|
233
|
+
let result = moment(
|
|
234
|
+
`${day}-${month}-${year} ${hour}:${minute}:${second}`,
|
|
235
|
+
"DD-MM-YYYY HH:mm:ss"
|
|
236
|
+
);
|
|
237
|
+
if (!result.isValid()) return null;
|
|
238
|
+
result = result.subtract(7, "hours");
|
|
239
|
+
return result.format(dateTimeFormat);
|
|
240
|
+
}
|
|
241
|
+
return null;
|
|
242
|
+
}
|
|
243
|
+
if (cleanInput.length === 14) {
|
|
244
|
+
const day = cleanInput.slice(0, 2);
|
|
245
|
+
const month = cleanInput.slice(2, 4);
|
|
246
|
+
const year = cleanInput.slice(4, 8);
|
|
247
|
+
const hour = cleanInput.slice(8, 10);
|
|
248
|
+
const minute = cleanInput.slice(10, 12);
|
|
249
|
+
const second = cleanInput.slice(12, 14);
|
|
250
|
+
if (isValidDate(day, month, year) && isValidTime(hour, minute, second)) {
|
|
251
|
+
let result = moment(
|
|
252
|
+
`${day}-${month}-${year} ${hour}:${minute}:${second}`,
|
|
253
|
+
"DD-MM-YYYY HH:mm:ss"
|
|
254
|
+
);
|
|
255
|
+
if (!result.isValid()) return null;
|
|
256
|
+
result = result.subtract(7, "hours");
|
|
257
|
+
return result.format(dateTimeFormat);
|
|
258
|
+
}
|
|
259
|
+
return null;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
const len = cleanInput.length;
|
|
263
|
+
if (len === 1 || len === 2) {
|
|
264
|
+
const paddedDay = cleanInput.padStart(2, "0");
|
|
265
|
+
if (isValidDate(paddedDay, currentMonth, currentYear)) {
|
|
266
|
+
return formatOutput(paddedDay, currentMonth, currentYear);
|
|
267
|
+
}
|
|
268
|
+
return null;
|
|
269
|
+
}
|
|
270
|
+
if (len === 3) {
|
|
271
|
+
const day = cleanInput.slice(0, 2);
|
|
272
|
+
const month = cleanInput.slice(2, 3).padStart(2, "0");
|
|
273
|
+
if (isValidDate(day, month, currentYear)) {
|
|
274
|
+
return formatOutput(day, month, currentYear);
|
|
275
|
+
}
|
|
276
|
+
return null;
|
|
277
|
+
}
|
|
278
|
+
if (len === 6) {
|
|
279
|
+
const day = cleanInput.slice(0, 2);
|
|
280
|
+
const month = cleanInput.slice(2, 4);
|
|
281
|
+
let year = cleanInput.slice(4, 6);
|
|
282
|
+
year = `20${year}`;
|
|
283
|
+
if (parseInt(month) > 12) {
|
|
284
|
+
if (isValidDate(day, currentMonth, currentYear)) {
|
|
285
|
+
return formatOutput(day, currentMonth, currentYear);
|
|
286
|
+
}
|
|
287
|
+
return null;
|
|
288
|
+
}
|
|
289
|
+
if (isValidDate(day, month, year)) {
|
|
290
|
+
return formatOutput(day, month, year);
|
|
291
|
+
}
|
|
292
|
+
return null;
|
|
293
|
+
}
|
|
294
|
+
if (len === 7) {
|
|
295
|
+
return null;
|
|
296
|
+
}
|
|
297
|
+
if (len === 8) {
|
|
298
|
+
const day = cleanInput.slice(0, 2);
|
|
299
|
+
const month = cleanInput.slice(2, 4);
|
|
300
|
+
const year = cleanInput.slice(4, 8);
|
|
301
|
+
if (isValidDate(day, month, year)) {
|
|
302
|
+
return formatOutput(day, month, year);
|
|
303
|
+
}
|
|
304
|
+
return null;
|
|
305
|
+
}
|
|
306
|
+
if (len > 8 && !isDateTime) {
|
|
307
|
+
return null;
|
|
308
|
+
}
|
|
309
|
+
return null;
|
|
310
|
+
};
|
|
77
311
|
|
|
78
312
|
// src/utils/domain/py_tokenizer.ts
|
|
79
313
|
var TokenizerError = class extends Error {
|
|
@@ -229,7 +463,7 @@ var IntNumber = DecNumber;
|
|
|
229
463
|
var Exponent = "[eE][+-]?\\d+";
|
|
230
464
|
var PointFloat = group(`\\d+\\.\\d*(${Exponent})?`, `\\.\\d+(${Exponent})?`);
|
|
231
465
|
var FloatNumber = group(PointFloat, `\\d+${Exponent}`);
|
|
232
|
-
var
|
|
466
|
+
var Number2 = group(FloatNumber, IntNumber);
|
|
233
467
|
var Operator = group(
|
|
234
468
|
"\\*\\*=?",
|
|
235
469
|
">>=?",
|
|
@@ -247,8 +481,8 @@ var ContStr = group(
|
|
|
247
481
|
"([uU])?'([^\\n'\\\\]*(?:\\\\.[^\\n'\\\\]*)*)'",
|
|
248
482
|
'([uU])?"([^\\n"\\\\]*(?:\\\\.[^\\n"\\\\]*)*)"'
|
|
249
483
|
);
|
|
250
|
-
var PseudoToken = Whitespace + group(
|
|
251
|
-
var NumberPattern = new RegExp("^" +
|
|
484
|
+
var PseudoToken = Whitespace + group(Number2, Funny, ContStr, Name);
|
|
485
|
+
var NumberPattern = new RegExp("^" + Number2 + "$");
|
|
252
486
|
var StringPattern = new RegExp("^" + ContStr + "$");
|
|
253
487
|
var NamePattern = new RegExp("^" + Name + "$");
|
|
254
488
|
var strip = new RegExp("^" + Whitespace);
|
|
@@ -578,8 +812,6 @@ function parseInfix(left, current, tokens) {
|
|
|
578
812
|
ifTrue: left,
|
|
579
813
|
ifFalse
|
|
580
814
|
};
|
|
581
|
-
default:
|
|
582
|
-
break;
|
|
583
815
|
}
|
|
584
816
|
}
|
|
585
817
|
throw new ParserError("Token cannot be parsed");
|
|
@@ -1878,18 +2110,6 @@ function evaluateBooleanExpr(expr, context = {}) {
|
|
|
1878
2110
|
}
|
|
1879
2111
|
|
|
1880
2112
|
// 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
2113
|
function evalPartialContext(_context, evaluationContext = {}) {
|
|
1894
2114
|
const ast = parseExpr(_context);
|
|
1895
2115
|
const context = {};
|
|
@@ -1914,9 +2134,6 @@ function shallowEqual(obj1, obj2, comparisonFn = (a, b) => a === b) {
|
|
|
1914
2134
|
|
|
1915
2135
|
// src/utils/domain/arrays.ts
|
|
1916
2136
|
var shallowEqual2 = shallowEqual;
|
|
1917
|
-
|
|
1918
|
-
// src/utils/domain/strings.ts
|
|
1919
|
-
var escapeMethod = Symbol("html");
|
|
1920
2137
|
function escapeRegExp(str) {
|
|
1921
2138
|
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1922
2139
|
}
|
|
@@ -2047,12 +2264,6 @@ var Domain = class _Domain {
|
|
|
2047
2264
|
}
|
|
2048
2265
|
}
|
|
2049
2266
|
};
|
|
2050
|
-
function evalDomain(modifier, evalContext) {
|
|
2051
|
-
if (modifier && typeof modifier !== "boolean") {
|
|
2052
|
-
modifier = new Domain(modifier).contains(evalContext);
|
|
2053
|
-
}
|
|
2054
|
-
return Boolean(modifier);
|
|
2055
|
-
}
|
|
2056
2267
|
var TRUE_LEAF = [1, "=", 1];
|
|
2057
2268
|
var FALSE_LEAF = [0, "=", 1];
|
|
2058
2269
|
var TRUE_DOMAIN = new Domain([TRUE_LEAF]);
|
|
@@ -2278,13 +2489,6 @@ var matchDomains = (context, domains) => {
|
|
|
2278
2489
|
} else return checkDomain(context, domains);
|
|
2279
2490
|
return false;
|
|
2280
2491
|
};
|
|
2281
|
-
|
|
2282
|
-
// src/utils/function/index.ts
|
|
2283
|
-
var domainHelper = {
|
|
2284
|
-
checkDomain,
|
|
2285
|
-
matchDomains,
|
|
2286
|
-
Domain
|
|
2287
|
-
};
|
|
2288
2492
|
var evalJSONContext = (_context, context = {}) => {
|
|
2289
2493
|
try {
|
|
2290
2494
|
return evalPartialContext(
|
|
@@ -2329,20 +2533,316 @@ var formatSortingString = (input) => {
|
|
|
2329
2533
|
return `${key} ${sortOrder}`;
|
|
2330
2534
|
}).join(", ");
|
|
2331
2535
|
};
|
|
2536
|
+
var domainHelper = {
|
|
2537
|
+
checkDomain,
|
|
2538
|
+
matchDomains,
|
|
2539
|
+
Domain
|
|
2540
|
+
};
|
|
2332
2541
|
var toQueryString = (params) => {
|
|
2333
2542
|
return Object.keys(params).map(
|
|
2334
2543
|
(key) => encodeURIComponent(key) + "=" + encodeURIComponent(params[key].toString())
|
|
2335
2544
|
).join("&");
|
|
2336
2545
|
};
|
|
2337
|
-
|
|
2338
|
-
const
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2546
|
+
var convertFloatToTime = (floatValue) => {
|
|
2547
|
+
const hours = Math.floor(floatValue);
|
|
2548
|
+
const minutes = Math.round((floatValue - hours) * 60);
|
|
2549
|
+
const formattedHours = String(hours).padStart(2, "0");
|
|
2550
|
+
const formattedMinutes = String(minutes).padStart(2, "0");
|
|
2551
|
+
return `${formattedHours}:${formattedMinutes}`;
|
|
2552
|
+
};
|
|
2553
|
+
var convertTimeToFloat = (timeString) => {
|
|
2554
|
+
const [hours, minutes] = timeString.split(":").map(Number);
|
|
2555
|
+
return hours + minutes / 60;
|
|
2556
|
+
};
|
|
2557
|
+
var stringToColor = (name, id) => {
|
|
2558
|
+
const combined = name + id / 2;
|
|
2559
|
+
let hash = 0;
|
|
2560
|
+
for (let i = 0; i < combined.length; i++) {
|
|
2561
|
+
hash = combined.charCodeAt(i) + ((hash << 5) - hash);
|
|
2562
|
+
}
|
|
2563
|
+
const r = hash >> 16 & 255;
|
|
2564
|
+
const g = hash >> 8 & 255;
|
|
2565
|
+
const b = hash & 255;
|
|
2566
|
+
const rNorm = r / 255;
|
|
2567
|
+
const gNorm = g / 255;
|
|
2568
|
+
const bNorm = b / 255;
|
|
2569
|
+
const max = Math.max(rNorm, gNorm, bNorm);
|
|
2570
|
+
const min = Math.min(rNorm, gNorm, bNorm);
|
|
2571
|
+
const delta = max - min;
|
|
2572
|
+
let h = 0;
|
|
2573
|
+
if (delta !== 0) {
|
|
2574
|
+
if (max === rNorm) h = (gNorm - bNorm) / delta % 6;
|
|
2575
|
+
else if (max === gNorm) h = (bNorm - rNorm) / delta + 2;
|
|
2576
|
+
else h = (rNorm - gNorm) / delta + 4;
|
|
2577
|
+
}
|
|
2578
|
+
h = Math.round(h * 60);
|
|
2579
|
+
if (h < 0) h += 360;
|
|
2580
|
+
let l = (max + min) / 2;
|
|
2581
|
+
let s = delta === 0 ? 0 : delta / (1 - Math.abs(2 * l - 1));
|
|
2582
|
+
s = Math.min(1, s * 1.8);
|
|
2583
|
+
l = Math.min(0.75, l * 1.05);
|
|
2584
|
+
const c = (1 - Math.abs(2 * l - 1)) * s;
|
|
2585
|
+
const x = c * (1 - Math.abs(h / 60 % 2 - 1));
|
|
2586
|
+
const m = l - c / 2;
|
|
2587
|
+
let r2 = 0, g2 = 0, b2 = 0;
|
|
2588
|
+
if (0 <= h && h < 60) [r2, g2, b2] = [c, x, 0];
|
|
2589
|
+
else if (60 <= h && h < 120) [r2, g2, b2] = [x, c, 0];
|
|
2590
|
+
else if (120 <= h && h < 180) [r2, g2, b2] = [0, c, x];
|
|
2591
|
+
else if (180 <= h && h < 240) [r2, g2, b2] = [0, x, c];
|
|
2592
|
+
else if (240 <= h && h < 300) [r2, g2, b2] = [x, 0, c];
|
|
2593
|
+
else [r2, g2, b2] = [c, 0, x];
|
|
2594
|
+
const finalR = Math.round((r2 + m) * 255);
|
|
2595
|
+
const finalG = Math.round((g2 + m) * 255);
|
|
2596
|
+
const finalB = Math.round((b2 + m) * 255);
|
|
2597
|
+
return `#${finalR.toString(16).padStart(2, "0")}${finalG.toString(16).padStart(2, "0")}${finalB.toString(16).padStart(2, "0")}`;
|
|
2598
|
+
};
|
|
2599
|
+
var getFieldsOnChange = (fields) => {
|
|
2600
|
+
const result = [];
|
|
2601
|
+
function traverse(items) {
|
|
2602
|
+
for (const item of items) {
|
|
2603
|
+
if (item) {
|
|
2604
|
+
if (item?.type_co === "field" && matchDomains(fields, item?.on_change)) {
|
|
2605
|
+
result.push(item.name);
|
|
2606
|
+
}
|
|
2607
|
+
if (item?.fields && Array.isArray(item?.fields)) {
|
|
2608
|
+
traverse(item?.fields);
|
|
2609
|
+
}
|
|
2610
|
+
}
|
|
2342
2611
|
}
|
|
2343
2612
|
}
|
|
2613
|
+
traverse(fields);
|
|
2344
2614
|
return result;
|
|
2345
|
-
}
|
|
2615
|
+
};
|
|
2616
|
+
var filterFieldDirty = ({
|
|
2617
|
+
id,
|
|
2618
|
+
viewData,
|
|
2619
|
+
formValues,
|
|
2620
|
+
dirtyFields,
|
|
2621
|
+
model,
|
|
2622
|
+
defaultData,
|
|
2623
|
+
keepZeroValue = false
|
|
2624
|
+
}) => {
|
|
2625
|
+
const data = id ? { ...dirtyFields } : { ...formValues };
|
|
2626
|
+
for (const key in data) {
|
|
2627
|
+
if (viewData?.models?.[model]?.[key]?.type === "one2many" /* ONE2MANY */) {
|
|
2628
|
+
const lineData = [];
|
|
2629
|
+
(formValues[key] ?? []).forEach((itemData, index) => {
|
|
2630
|
+
if (typeof itemData?.id === "string" && itemData?.id.includes("virtual")) {
|
|
2631
|
+
delete itemData?.id;
|
|
2632
|
+
}
|
|
2633
|
+
if (!itemData?.id) {
|
|
2634
|
+
lineData.push([
|
|
2635
|
+
0 /* CREATE */,
|
|
2636
|
+
`virtual_${index}`,
|
|
2637
|
+
filterFieldDirty({
|
|
2638
|
+
id: itemData?.id,
|
|
2639
|
+
viewData,
|
|
2640
|
+
formValues: itemData,
|
|
2641
|
+
dirtyFields: {},
|
|
2642
|
+
model: viewData?.models?.[model]?.[key]?.relation,
|
|
2643
|
+
defaultData,
|
|
2644
|
+
keepZeroValue
|
|
2645
|
+
})
|
|
2646
|
+
]);
|
|
2647
|
+
} else if (dirtyFields[key]?.length) {
|
|
2648
|
+
dirtyFields[key].forEach((itemDirty, indexDirty) => {
|
|
2649
|
+
if (Object.values(itemDirty).includes(true) && indexDirty === index) {
|
|
2650
|
+
lineData.push([
|
|
2651
|
+
1 /* UPDATE */,
|
|
2652
|
+
itemData?.id,
|
|
2653
|
+
filterFieldDirty({
|
|
2654
|
+
id: itemData?.id,
|
|
2655
|
+
viewData,
|
|
2656
|
+
formValues: itemData,
|
|
2657
|
+
dirtyFields: itemDirty,
|
|
2658
|
+
model: viewData?.models?.[model]?.[key]?.relation,
|
|
2659
|
+
defaultData: {},
|
|
2660
|
+
keepZeroValue
|
|
2661
|
+
})
|
|
2662
|
+
]);
|
|
2663
|
+
}
|
|
2664
|
+
});
|
|
2665
|
+
}
|
|
2666
|
+
});
|
|
2667
|
+
(defaultData[key] ?? []).forEach((item) => {
|
|
2668
|
+
if (!(formValues[key] ?? []).find(
|
|
2669
|
+
(itemData) => itemData?.id === item?.id
|
|
2670
|
+
)) {
|
|
2671
|
+
lineData.push([2 /* DELETE */, item?.id, item]);
|
|
2672
|
+
}
|
|
2673
|
+
});
|
|
2674
|
+
data[key] = lineData;
|
|
2675
|
+
} else if (viewData?.models?.[model]?.[key]?.type === "many2many" /* MANY2MANY */) {
|
|
2676
|
+
const lineData = [];
|
|
2677
|
+
(formValues[key] || []).forEach((itemData) => {
|
|
2678
|
+
if (itemData?.id) {
|
|
2679
|
+
lineData.push([4 /* NO_CHANGE */, itemData?.id]);
|
|
2680
|
+
}
|
|
2681
|
+
});
|
|
2682
|
+
(defaultData[key] ?? []).forEach((item) => {
|
|
2683
|
+
if (!(formValues[key] ?? []).find(
|
|
2684
|
+
(itemData) => itemData?.id === item?.id
|
|
2685
|
+
)) {
|
|
2686
|
+
lineData.push([3 /* UNLINK */, item?.id]);
|
|
2687
|
+
}
|
|
2688
|
+
});
|
|
2689
|
+
data[key] = lineData;
|
|
2690
|
+
} else {
|
|
2691
|
+
if (id && (typeof dirtyFields?.[key] === "object" && !dirtyFields?.[key]?.id || typeof dirtyFields[key] !== "object" && !dirtyFields[key])) {
|
|
2692
|
+
if (!(keepZeroValue && (formValues[key] === 0 || formValues[key] === "0"))) {
|
|
2693
|
+
delete data[key];
|
|
2694
|
+
}
|
|
2695
|
+
} else {
|
|
2696
|
+
if (!data[key] && !(keepZeroValue && (data[key] === 0 || data[key] === "0"))) {
|
|
2697
|
+
delete data[key];
|
|
2698
|
+
} else {
|
|
2699
|
+
data[key] = formValues?.[key]?.display_name ? formValues?.[key]?.id : formValues?.[key];
|
|
2700
|
+
}
|
|
2701
|
+
}
|
|
2702
|
+
}
|
|
2703
|
+
}
|
|
2704
|
+
return data;
|
|
2705
|
+
};
|
|
2706
|
+
var mergeObjects = (object1, object2) => {
|
|
2707
|
+
if (!object1 || !object2) return void 0;
|
|
2708
|
+
const mergedObject = { ...object2 };
|
|
2709
|
+
Object.keys(object1).forEach((key) => {
|
|
2710
|
+
if (Array.isArray(object1[key]) && Array.isArray(object2[key])) {
|
|
2711
|
+
mergedObject[key] = object2[key].map((item, index) => {
|
|
2712
|
+
if (object1[key][index]) {
|
|
2713
|
+
return {
|
|
2714
|
+
...item,
|
|
2715
|
+
...object1[key][index]
|
|
2716
|
+
};
|
|
2717
|
+
}
|
|
2718
|
+
return item;
|
|
2719
|
+
});
|
|
2720
|
+
} else if (typeof object1[key] === "object" && typeof object2[key] === "object" && object1[key] !== null && object2[key] !== null) {
|
|
2721
|
+
mergedObject[key] = mergeObjects(object1[key], object2[key]);
|
|
2722
|
+
} else {
|
|
2723
|
+
mergedObject[key] = object1[key] !== void 0 ? object1[key] : object2[key];
|
|
2724
|
+
}
|
|
2725
|
+
});
|
|
2726
|
+
if (object2) {
|
|
2727
|
+
Object.keys(object2).forEach((key) => {
|
|
2728
|
+
if (!mergedObject.hasOwnProperty(key)) {
|
|
2729
|
+
mergedObject[key] = object2[key];
|
|
2730
|
+
}
|
|
2731
|
+
});
|
|
2732
|
+
}
|
|
2733
|
+
return mergedObject;
|
|
2734
|
+
};
|
|
2735
|
+
var formatUrlPath = ({
|
|
2736
|
+
viewType,
|
|
2737
|
+
aid,
|
|
2738
|
+
model,
|
|
2739
|
+
id,
|
|
2740
|
+
actionPath
|
|
2741
|
+
}) => {
|
|
2742
|
+
let _url = `/${viewType}/${actionPath}?aid=${aid}&model=${model}`;
|
|
2743
|
+
if (id) {
|
|
2744
|
+
_url += `&id=${id}`;
|
|
2745
|
+
}
|
|
2746
|
+
return _url;
|
|
2747
|
+
};
|
|
2748
|
+
var removeUndefinedFields = (obj) => {
|
|
2749
|
+
const newObj = {};
|
|
2750
|
+
for (const key in obj) {
|
|
2751
|
+
if (obj[key] !== void 0) {
|
|
2752
|
+
newObj[key] = obj[key];
|
|
2753
|
+
}
|
|
2754
|
+
}
|
|
2755
|
+
return newObj;
|
|
2756
|
+
};
|
|
2757
|
+
var useTabModel = (viewData, onchangeData) => {
|
|
2758
|
+
const tabsData = viewData?.views?.form?.tabs?.filter((val) => {
|
|
2759
|
+
if (!val) return null;
|
|
2760
|
+
const hide = checkDomain(onchangeData, val.invisible);
|
|
2761
|
+
if (!hide) {
|
|
2762
|
+
return val;
|
|
2763
|
+
}
|
|
2764
|
+
return false;
|
|
2765
|
+
}) || [];
|
|
2766
|
+
return tabsData;
|
|
2767
|
+
};
|
|
2768
|
+
var isBase64File = (str) => {
|
|
2769
|
+
try {
|
|
2770
|
+
const dataUriPattern = /^data:([a-zA-Z]+\/[a-zA-Z0-9-.+]+)?;base64,/;
|
|
2771
|
+
if (dataUriPattern.test(str)) {
|
|
2772
|
+
return true;
|
|
2773
|
+
}
|
|
2774
|
+
const base64Pattern = (
|
|
2775
|
+
// eslint-disable-next-line no-useless-escape
|
|
2776
|
+
/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{3}=|[A-Za-z0-9+\/]{2}==)?$/
|
|
2777
|
+
);
|
|
2778
|
+
return base64Pattern.test(str);
|
|
2779
|
+
} catch (e) {
|
|
2780
|
+
return false;
|
|
2781
|
+
}
|
|
2782
|
+
};
|
|
2783
|
+
var isBase64Image = (str) => {
|
|
2784
|
+
const base64Regex = /^data:image\/(png|jpeg|jpg|gif|webp);base64,/;
|
|
2785
|
+
if (!base64Regex.test(str)) {
|
|
2786
|
+
return false;
|
|
2787
|
+
}
|
|
2788
|
+
try {
|
|
2789
|
+
const base64Data = str.split(",")[1];
|
|
2790
|
+
return !!base64Data && atob(base64Data).length > 0;
|
|
2791
|
+
} catch (error) {
|
|
2792
|
+
return false;
|
|
2793
|
+
}
|
|
2794
|
+
};
|
|
2795
|
+
var checkIsImageLink = (url) => {
|
|
2796
|
+
const imageExtensions = /\.(jpg|jpeg|png|gif|bmp|webp|svg|tiff|ico)$/i;
|
|
2797
|
+
return imageExtensions.test(url) || isBase64Image(url);
|
|
2798
|
+
};
|
|
2799
|
+
var formatFileSize = (size) => {
|
|
2800
|
+
if (size < 1024) return `${size} B`;
|
|
2801
|
+
const i = Math.floor(Math.log(size) / Math.log(1024));
|
|
2802
|
+
const sizes = ["B", "KB", "MB", "GB", "TB"];
|
|
2803
|
+
return `${(size / Math.pow(1024, i)).toFixed(2)} ${sizes[i]}`;
|
|
2804
|
+
};
|
|
2805
|
+
var getSubdomain = (url = window.location.href) => {
|
|
2806
|
+
const parts = url?.split(".");
|
|
2807
|
+
if (parts.length > 2) {
|
|
2808
|
+
return parts[0].replace("https://", "").replace("http://", "");
|
|
2809
|
+
}
|
|
2810
|
+
return null;
|
|
2811
|
+
};
|
|
2812
|
+
var resequence = (arr, start, end) => {
|
|
2813
|
+
if (start < 0 || start >= arr.length || end < 0 || end >= arr.length) {
|
|
2814
|
+
return [];
|
|
2815
|
+
}
|
|
2816
|
+
const [element] = arr.splice(start, 1);
|
|
2817
|
+
arr.splice(end, 0, element);
|
|
2818
|
+
return arr.slice(Math.min(start, end), Math.max(start, end) + 1);
|
|
2819
|
+
};
|
|
2820
|
+
var getOffSet = (arr, start, end) => {
|
|
2821
|
+
if (start < 0 || start >= arr.length || end < 0 || end >= arr.length) {
|
|
2822
|
+
return 0;
|
|
2823
|
+
}
|
|
2824
|
+
if (start > end) {
|
|
2825
|
+
return end;
|
|
2826
|
+
}
|
|
2827
|
+
return arr.slice(0, start).length;
|
|
2828
|
+
};
|
|
2829
|
+
var copyTextToClipboard = async (text) => {
|
|
2830
|
+
if ("clipboard" in navigator) {
|
|
2831
|
+
return await navigator.clipboard.writeText(text);
|
|
2832
|
+
} else {
|
|
2833
|
+
const textArea = document.createElement("textarea");
|
|
2834
|
+
textArea.value = text;
|
|
2835
|
+
textArea.style.position = "fixed";
|
|
2836
|
+
document.body.appendChild(textArea);
|
|
2837
|
+
textArea.focus();
|
|
2838
|
+
textArea.select();
|
|
2839
|
+
try {
|
|
2840
|
+
document.execCommand("copy");
|
|
2841
|
+
} finally {
|
|
2842
|
+
document.body.removeChild(textArea);
|
|
2843
|
+
}
|
|
2844
|
+
}
|
|
2845
|
+
};
|
|
2346
2846
|
var updateTokenParamInOriginalRequest = (originalRequest, newAccessToken) => {
|
|
2347
2847
|
if (!originalRequest.data) return originalRequest.data;
|
|
2348
2848
|
if (typeof originalRequest.data === "string") {
|
|
@@ -2362,22 +2862,164 @@ var updateTokenParamInOriginalRequest = (originalRequest, newAccessToken) => {
|
|
|
2362
2862
|
}
|
|
2363
2863
|
return originalRequest.data;
|
|
2364
2864
|
};
|
|
2865
|
+
var isObjectEmpty = (obj) => {
|
|
2866
|
+
return Object.keys(obj).length === 0;
|
|
2867
|
+
};
|
|
2868
|
+
var useField = (props) => {
|
|
2869
|
+
const [invisible, setInvisible] = useState(true);
|
|
2870
|
+
const [required, setRequired] = useState(false);
|
|
2871
|
+
const [readonly, setReadOnly] = useState(false);
|
|
2872
|
+
const {
|
|
2873
|
+
invisible: inv,
|
|
2874
|
+
required: req,
|
|
2875
|
+
readonly: rea,
|
|
2876
|
+
onchangeData,
|
|
2877
|
+
rootField,
|
|
2878
|
+
index,
|
|
2879
|
+
name
|
|
2880
|
+
} = props;
|
|
2881
|
+
const nameField = rootField ? `${rootField?.name}.${index}.${name}` : null;
|
|
2882
|
+
useEffect(() => {
|
|
2883
|
+
if (onchangeData && Object.keys(onchangeData).length > 0) {
|
|
2884
|
+
setRequired(
|
|
2885
|
+
typeof req === "object" ? matchDomains(onchangeData, req) : checkDomain(onchangeData, req)
|
|
2886
|
+
);
|
|
2887
|
+
setInvisible(matchDomains(onchangeData, inv));
|
|
2888
|
+
setReadOnly(
|
|
2889
|
+
typeof req === "object" ? matchDomains(onchangeData, rea) : checkDomain(onchangeData, rea)
|
|
2890
|
+
);
|
|
2891
|
+
}
|
|
2892
|
+
}, [onchangeData]);
|
|
2893
|
+
return {
|
|
2894
|
+
invisible,
|
|
2895
|
+
required,
|
|
2896
|
+
readonly,
|
|
2897
|
+
nameField
|
|
2898
|
+
};
|
|
2899
|
+
};
|
|
2900
|
+
var downloadFile = async (url, filename) => {
|
|
2901
|
+
try {
|
|
2902
|
+
const response = await fetch(url);
|
|
2903
|
+
if (!response.ok) throw new Error(`Failed to fetch ${url}`);
|
|
2904
|
+
const contentType = response.headers.get("Content-Type") || "";
|
|
2905
|
+
let ext = "";
|
|
2906
|
+
if (contentType.includes("pdf")) ext = ".pdf";
|
|
2907
|
+
else if (contentType.includes("png")) ext = ".png";
|
|
2908
|
+
else if (contentType.includes("jpeg") || contentType.includes("jpg"))
|
|
2909
|
+
ext = ".jpg";
|
|
2910
|
+
else if (contentType.includes("zip")) ext = ".zip";
|
|
2911
|
+
else if (contentType.includes("msword")) ext = ".doc";
|
|
2912
|
+
else if (contentType.includes("spreadsheet")) ext = ".xls";
|
|
2913
|
+
else if (contentType.includes("json")) ext = ".json";
|
|
2914
|
+
else if (contentType.includes("text")) ext = ".txt";
|
|
2915
|
+
else {
|
|
2916
|
+
ext = "";
|
|
2917
|
+
}
|
|
2918
|
+
const blob = await response.blob();
|
|
2919
|
+
const urlBlob = window.URL.createObjectURL(blob);
|
|
2920
|
+
const link = document.createElement("a");
|
|
2921
|
+
link.href = urlBlob;
|
|
2922
|
+
link.download = (filename || "file") + ext;
|
|
2923
|
+
document.body.appendChild(link);
|
|
2924
|
+
link.click();
|
|
2925
|
+
document.body.removeChild(link);
|
|
2926
|
+
window.URL.revokeObjectURL(urlBlob);
|
|
2927
|
+
} catch (error) {
|
|
2928
|
+
console.error("File download failed:", error);
|
|
2929
|
+
}
|
|
2930
|
+
};
|
|
2931
|
+
function cleanObject(obj) {
|
|
2932
|
+
const result = {};
|
|
2933
|
+
for (const [k, v] of Object.entries(obj)) {
|
|
2934
|
+
if (v !== null && v !== void 0) {
|
|
2935
|
+
result[k] = v;
|
|
2936
|
+
}
|
|
2937
|
+
}
|
|
2938
|
+
return result;
|
|
2939
|
+
}
|
|
2940
|
+
var extractIdFromDomain = (domain) => {
|
|
2941
|
+
if (!domain || !Array.isArray(domain)) return null;
|
|
2942
|
+
const idCond = domain.find(
|
|
2943
|
+
([field, operator]) => field === "id" && operator === "="
|
|
2944
|
+
);
|
|
2945
|
+
return idCond ? Number(idCond[2]) : null;
|
|
2946
|
+
};
|
|
2365
2947
|
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2948
|
+
// src/utils/storage/local-storage.ts
|
|
2949
|
+
var localStorageUtils = () => {
|
|
2950
|
+
const setToken = async (access_token) => {
|
|
2951
|
+
localStorage.setItem("accessToken", access_token);
|
|
2952
|
+
};
|
|
2953
|
+
const setRefreshToken = async (refresh_token) => {
|
|
2954
|
+
localStorage.setItem("refreshToken", refresh_token);
|
|
2955
|
+
};
|
|
2956
|
+
const getAccessToken = async () => {
|
|
2957
|
+
return localStorage.getItem("accessToken");
|
|
2958
|
+
};
|
|
2959
|
+
const getRefreshToken = async () => {
|
|
2960
|
+
return localStorage.getItem("refreshToken");
|
|
2961
|
+
};
|
|
2962
|
+
const clearToken = async () => {
|
|
2963
|
+
localStorage.removeItem("accessToken");
|
|
2964
|
+
localStorage.removeItem("refreshToken");
|
|
2965
|
+
};
|
|
2966
|
+
return {
|
|
2967
|
+
setToken,
|
|
2968
|
+
setRefreshToken,
|
|
2969
|
+
getAccessToken,
|
|
2970
|
+
getRefreshToken,
|
|
2971
|
+
clearToken
|
|
2972
|
+
};
|
|
2383
2973
|
};
|
|
2974
|
+
|
|
2975
|
+
// src/utils/storage/session-storage.ts
|
|
2976
|
+
var sessionStorageUtils = /* @__PURE__ */ (() => {
|
|
2977
|
+
const getMenuFocus = () => {
|
|
2978
|
+
const menuFocus = sessionStorage.getItem("menuFocus");
|
|
2979
|
+
return menuFocus ? JSON.parse(menuFocus) : {
|
|
2980
|
+
id: void 0,
|
|
2981
|
+
service: ""
|
|
2982
|
+
};
|
|
2983
|
+
};
|
|
2984
|
+
const setMenuFocus = (menuTree) => {
|
|
2985
|
+
sessionStorage.setItem("menuFocus", JSON.stringify({ ...menuTree }));
|
|
2986
|
+
};
|
|
2987
|
+
const getActionData = () => {
|
|
2988
|
+
const actionData = sessionStorage.getItem("actionData");
|
|
2989
|
+
return actionData ? JSON.parse(actionData) : {};
|
|
2990
|
+
};
|
|
2991
|
+
const setActionData = (actData) => {
|
|
2992
|
+
sessionStorage.setItem("actionData", JSON.stringify(actData));
|
|
2993
|
+
};
|
|
2994
|
+
const getViewData = () => {
|
|
2995
|
+
const viewData = sessionStorage.getItem("viewData");
|
|
2996
|
+
return viewData ? JSON.parse(viewData) : {};
|
|
2997
|
+
};
|
|
2998
|
+
const getBrowserSession = () => {
|
|
2999
|
+
const actionData = sessionStorage.getItem("browserSession");
|
|
3000
|
+
return actionData ? JSON.parse(actionData) : null;
|
|
3001
|
+
};
|
|
3002
|
+
const setViewData = (viewData) => {
|
|
3003
|
+
sessionStorage.setItem("viewData", JSON.stringify(viewData));
|
|
3004
|
+
};
|
|
3005
|
+
const getXNode = () => {
|
|
3006
|
+
const xNode = sessionStorage.getItem("xNode");
|
|
3007
|
+
return xNode;
|
|
3008
|
+
};
|
|
3009
|
+
const setXNode = (xNode) => {
|
|
3010
|
+
sessionStorage.setItem("xNode", xNode);
|
|
3011
|
+
};
|
|
3012
|
+
return {
|
|
3013
|
+
getMenuFocus,
|
|
3014
|
+
setMenuFocus,
|
|
3015
|
+
setActionData,
|
|
3016
|
+
getActionData,
|
|
3017
|
+
getViewData,
|
|
3018
|
+
setViewData,
|
|
3019
|
+
getBrowserSession,
|
|
3020
|
+
getXNode,
|
|
3021
|
+
setXNode
|
|
3022
|
+
};
|
|
3023
|
+
})();
|
|
3024
|
+
|
|
3025
|
+
export { WesapError, checkIsImageLink, cleanObject, convertFloatToTime, convertTimeToFloat, copyTextToClipboard, domainHelper, downloadFile, evalJSONContext, evalJSONDomain, extractIdFromDomain, filterFieldDirty, formatCurrency, formatDate, formatFileSize, formatSortingString, formatUrlPath, getFieldsOnChange, getOffSet, getSubdomain, handleError, isBase64File, isBase64Image, isObjectEmpty, localStorageUtils, mergeObjects, removeUndefinedFields, resequence, sessionStorageUtils, stringToColor, toQueryString, updateTokenParamInOriginalRequest, useField, useTabModel, validateAndParseDate };
|