@fctc/interface-logic 1.4.3 → 1.4.5
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/index.d.mts +1212 -0
- package/dist/index.d.ts +1212 -0
- package/dist/{hooks.js → index.js} +1012 -10
- package/dist/{hooks.mjs → index.mjs} +947 -5
- package/package.json +1 -1
- package/dist/configs.d.mts +0 -15
- package/dist/configs.d.ts +0 -15
- package/dist/configs.js +0 -2386
- package/dist/configs.mjs +0 -2349
- package/dist/constants.d.mts +0 -131
- package/dist/constants.d.ts +0 -131
- package/dist/constants.js +0 -205
- package/dist/constants.mjs +0 -166
- package/dist/environment.d.mts +0 -55
- package/dist/environment.d.ts +0 -55
- package/dist/environment.js +0 -3094
- package/dist/environment.mjs +0 -3054
- package/dist/hooks.d.mts +0 -359
- package/dist/hooks.d.ts +0 -359
- package/dist/provider.d.mts +0 -15
- package/dist/provider.d.ts +0 -15
- package/dist/provider.js +0 -3603
- package/dist/provider.mjs +0 -3564
- package/dist/services.d.mts +0 -255
- package/dist/services.d.ts +0 -255
- package/dist/services.js +0 -4662
- package/dist/services.mjs +0 -4617
- package/dist/store.d.mts +0 -643
- package/dist/store.d.ts +0 -643
- package/dist/store.js +0 -814
- package/dist/store.mjs +0 -709
- package/dist/types.d.mts +0 -17
- package/dist/types.d.ts +0 -17
- package/dist/types.js +0 -18
- package/dist/types.mjs +0 -0
- package/dist/utils.d.mts +0 -93
- package/dist/utils.d.ts +0 -93
- package/dist/utils.js +0 -2962
- package/dist/utils.mjs +0 -2896
- package/dist/view-type-BGJfDe73.d.mts +0 -113
- package/dist/view-type-BGJfDe73.d.ts +0 -113
|
@@ -1,5 +1,34 @@
|
|
|
1
|
-
// src/
|
|
2
|
-
import
|
|
1
|
+
// src/configs/axios-client.ts
|
|
2
|
+
import axios from "axios";
|
|
3
|
+
|
|
4
|
+
// src/constants/api/key-constant.ts
|
|
5
|
+
var KeyConstants = /* @__PURE__ */ ((KeyConstants2) => {
|
|
6
|
+
KeyConstants2["PROFILE"] = "userinfo";
|
|
7
|
+
KeyConstants2["CURRENT_COMPANY"] = "current_company";
|
|
8
|
+
KeyConstants2["LIST_COMPANY"] = "list_company";
|
|
9
|
+
KeyConstants2["COMPANY_INFO"] = "company_info";
|
|
10
|
+
KeyConstants2["MENU"] = "menus";
|
|
11
|
+
KeyConstants2["GET_VIEW_BY_ACTION"] = "get_view_by_action";
|
|
12
|
+
KeyConstants2["ACTION_DETAIL"] = "action_detail";
|
|
13
|
+
KeyConstants2["GET_DATA_SELECTION"] = "get_data_select";
|
|
14
|
+
KeyConstants2["WEB_SAVE"] = "web_save";
|
|
15
|
+
KeyConstants2["WEB_READ"] = "web_read";
|
|
16
|
+
KeyConstants2["GET_PROVIDER"] = "get_provider";
|
|
17
|
+
return KeyConstants2;
|
|
18
|
+
})(KeyConstants || {});
|
|
19
|
+
|
|
20
|
+
// src/constants/api/method-constant.ts
|
|
21
|
+
var MethodConstants = /* @__PURE__ */ ((MethodConstants2) => {
|
|
22
|
+
MethodConstants2["WEB_SEARCH_READ"] = "web_search_read";
|
|
23
|
+
MethodConstants2["WEB_READ_GROUP"] = "web_read_group";
|
|
24
|
+
MethodConstants2["WEB_READ"] = "web_read";
|
|
25
|
+
MethodConstants2["WEB_SAVE"] = "web_save";
|
|
26
|
+
MethodConstants2["UNLINK"] = "unlink";
|
|
27
|
+
MethodConstants2["ONCHANGE"] = "onchange";
|
|
28
|
+
MethodConstants2["GET_ONCHANGE_FIELDS"] = "get_fields_onchange";
|
|
29
|
+
MethodConstants2["GET_FIELD_VIEW"] = "get_fields_view_v2";
|
|
30
|
+
return MethodConstants2;
|
|
31
|
+
})(MethodConstants || {});
|
|
3
32
|
|
|
4
33
|
// src/constants/api/uri-constant.ts
|
|
5
34
|
var UriConstants = /* @__PURE__ */ ((UriConstants2) => {
|
|
@@ -31,11 +60,380 @@ var UriConstants = /* @__PURE__ */ ((UriConstants2) => {
|
|
|
31
60
|
return UriConstants2;
|
|
32
61
|
})(UriConstants || {});
|
|
33
62
|
|
|
34
|
-
// src/
|
|
35
|
-
|
|
63
|
+
// src/utils/error-handler.ts
|
|
64
|
+
var WesapError = class extends Error {
|
|
65
|
+
code;
|
|
66
|
+
constructor(message, code) {
|
|
67
|
+
super(message);
|
|
68
|
+
this.code = code;
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
function handleError(error, env2) {
|
|
72
|
+
if (error instanceof WesapError) {
|
|
73
|
+
env2.services.notification.error(error.message);
|
|
74
|
+
} else {
|
|
75
|
+
env2.services.notification.error("An unexpected error occurred");
|
|
76
|
+
}
|
|
77
|
+
}
|
|
36
78
|
|
|
37
79
|
// src/utils/format.ts
|
|
38
80
|
import moment from "moment";
|
|
81
|
+
var formatCurrency = (amount, currency = "USD") => {
|
|
82
|
+
const formatter = new Intl.NumberFormat("vi-VN", {
|
|
83
|
+
style: "currency",
|
|
84
|
+
currency,
|
|
85
|
+
minimumFractionDigits: 0
|
|
86
|
+
});
|
|
87
|
+
return formatter.format(amount).replaceAll(".", ",");
|
|
88
|
+
};
|
|
89
|
+
var formatDate = (date, locale = "en-US") => {
|
|
90
|
+
return new Intl.DateTimeFormat(locale).format(new Date(date));
|
|
91
|
+
};
|
|
92
|
+
var validateAndParseDate = (input, isDateTime = false) => {
|
|
93
|
+
if (!input || typeof input !== "string") return null;
|
|
94
|
+
const cleanInput = input.replace(/[^0-9-\/:\s]/g, "");
|
|
95
|
+
const dateFormat = "YYYY-MM-DD";
|
|
96
|
+
const dateTimeFormat = "YYYY-MM-DD HH:mm:ss";
|
|
97
|
+
const currentDay = moment().format("DD");
|
|
98
|
+
const currentMonth = moment().format("MM");
|
|
99
|
+
const currentYear = moment().format("YYYY");
|
|
100
|
+
const defaultTime = "00:00:00";
|
|
101
|
+
const maxYear = parseInt(currentYear) + 10;
|
|
102
|
+
const isValidDate = (day, month, year) => {
|
|
103
|
+
const date = moment(`${day}-${month}-${year}`, "DD-MM-YYYY", true);
|
|
104
|
+
return date.isValid();
|
|
105
|
+
};
|
|
106
|
+
const isValidTime = (hour, minute = "00", second = "00") => {
|
|
107
|
+
const h = parseInt(hour, 10);
|
|
108
|
+
const m = parseInt(minute, 10);
|
|
109
|
+
const s = parseInt(second, 10);
|
|
110
|
+
return h >= 0 && h <= 23 && m >= 0 && m <= 59 && s >= 0 && s <= 59;
|
|
111
|
+
};
|
|
112
|
+
const formatOutput = (day, month, year, time = defaultTime) => {
|
|
113
|
+
let result = moment(
|
|
114
|
+
`${day}-${month}-${year} ${time}`,
|
|
115
|
+
"DD-MM-YYYY HH:mm:ss"
|
|
116
|
+
);
|
|
117
|
+
if (!result.isValid()) return null;
|
|
118
|
+
if (isDateTime) {
|
|
119
|
+
result = result.subtract(7, "hours");
|
|
120
|
+
return result.format(dateTimeFormat);
|
|
121
|
+
}
|
|
122
|
+
return result.format(dateFormat);
|
|
123
|
+
};
|
|
124
|
+
if (isDateTime && input.match(
|
|
125
|
+
/^\d{1,2}[\/-]\d{1,2}[\/-]\d{2,4}\s+\d{1,2}(:\d{1,2}(:\d{1,2})?)?$/
|
|
126
|
+
)) {
|
|
127
|
+
const [datePart, timePart] = input.split(/\s+/);
|
|
128
|
+
const dateParts = datePart.split(/[\/-]/);
|
|
129
|
+
const timeParts = timePart.split(":");
|
|
130
|
+
const day = dateParts[0].padStart(2, "0");
|
|
131
|
+
const month = dateParts[1].padStart(2, "0");
|
|
132
|
+
const year = dateParts[2].length <= 2 ? `20${dateParts[2].padStart(2, "0")}` : dateParts[2].padStart(4, "0");
|
|
133
|
+
const hour = timeParts[0].padStart(2, "0");
|
|
134
|
+
const minute = timeParts[1] ? timeParts[1].padStart(2, "0") : "00";
|
|
135
|
+
const second = timeParts[2] ? timeParts[2].padStart(2, "0") : "00";
|
|
136
|
+
if (isValidDate(day, month, year) && isValidTime(hour, minute, second)) {
|
|
137
|
+
let result = moment(
|
|
138
|
+
`${day}-${month}-${year} ${hour}:${minute}:${second}`,
|
|
139
|
+
"DD-MM-YYYY HH:mm:ss"
|
|
140
|
+
);
|
|
141
|
+
if (!result.isValid()) return null;
|
|
142
|
+
result = result.subtract(7, "hours");
|
|
143
|
+
return result.format(dateTimeFormat);
|
|
144
|
+
}
|
|
145
|
+
return null;
|
|
146
|
+
}
|
|
147
|
+
if (cleanInput.match(/^\d{4}-\d{2}-\d{2}$/)) {
|
|
148
|
+
const [year, month, day] = cleanInput.split("-");
|
|
149
|
+
if (isValidDate(day, month, year)) {
|
|
150
|
+
return formatOutput(day, month, year);
|
|
151
|
+
}
|
|
152
|
+
return null;
|
|
153
|
+
}
|
|
154
|
+
if (cleanInput.match(/^\d{1,2}\/\d{1,2}\/\d{2,4}$/)) {
|
|
155
|
+
const [day, month, year] = cleanInput.split("/");
|
|
156
|
+
const paddedDay = day.padStart(2, "0");
|
|
157
|
+
const paddedMonth = month.padStart(2, "0");
|
|
158
|
+
const fullYear = year.length <= 2 ? `20${year.padStart(2, "0")}` : year.padStart(4, "0");
|
|
159
|
+
if (isValidDate(paddedDay, paddedMonth, fullYear)) {
|
|
160
|
+
return formatOutput(paddedDay, paddedMonth, fullYear);
|
|
161
|
+
}
|
|
162
|
+
return null;
|
|
163
|
+
}
|
|
164
|
+
if (cleanInput.match(/^\d{1,2}-\d{1,2}-\d{2,4}$/)) {
|
|
165
|
+
const [day, month, year] = cleanInput.split("-");
|
|
166
|
+
const paddedDay = day.padStart(2, "0");
|
|
167
|
+
const paddedMonth = month.padStart(2, "0");
|
|
168
|
+
const fullYear = year.length <= 2 ? `20${year.padStart(2, "0")}` : year.padStart(4, "0");
|
|
169
|
+
if (isValidDate(paddedDay, paddedMonth, fullYear)) {
|
|
170
|
+
return formatOutput(paddedDay, paddedMonth, fullYear);
|
|
171
|
+
}
|
|
172
|
+
return null;
|
|
173
|
+
}
|
|
174
|
+
if (cleanInput.match(/^\d{1,2}[\/-]\d{1,2}$/)) {
|
|
175
|
+
const [day, month] = cleanInput.split(/[\/-]/);
|
|
176
|
+
const paddedDay = day.padStart(2, "0");
|
|
177
|
+
const paddedMonth = month.padStart(2, "0");
|
|
178
|
+
if (isValidDate(paddedDay, paddedMonth, currentYear)) {
|
|
179
|
+
return formatOutput(paddedDay, paddedMonth, currentYear);
|
|
180
|
+
}
|
|
181
|
+
return null;
|
|
182
|
+
}
|
|
183
|
+
if (cleanInput.match(/^\d{4}$/)) {
|
|
184
|
+
const num = parseInt(cleanInput, 10);
|
|
185
|
+
if (num >= 2e3 && num <= maxYear) {
|
|
186
|
+
if (isValidDate(currentDay, currentMonth, num.toString())) {
|
|
187
|
+
return formatOutput(currentDay, currentMonth, num.toString());
|
|
188
|
+
}
|
|
189
|
+
return null;
|
|
190
|
+
}
|
|
191
|
+
const day = cleanInput.slice(0, 2);
|
|
192
|
+
const month = cleanInput.slice(2, 4);
|
|
193
|
+
if (isValidDate(day, month, currentYear)) {
|
|
194
|
+
return formatOutput(day, month, currentYear);
|
|
195
|
+
}
|
|
196
|
+
return null;
|
|
197
|
+
}
|
|
198
|
+
if (cleanInput.startsWith("-") && /^\-\d+$/.test(cleanInput)) {
|
|
199
|
+
const daysToSubtract = Math.abs(parseInt(cleanInput, 10));
|
|
200
|
+
let result = moment().subtract(daysToSubtract, "days");
|
|
201
|
+
if (isDateTime) {
|
|
202
|
+
result = result.subtract(7, "hours");
|
|
203
|
+
}
|
|
204
|
+
if (result.isValid()) {
|
|
205
|
+
return isDateTime ? result.format(dateTimeFormat) : result.format(dateFormat);
|
|
206
|
+
}
|
|
207
|
+
return null;
|
|
208
|
+
}
|
|
209
|
+
if (input.match(/^\d{1,2}[^0-9-\/]+\d{1,2}[^0-9-\/]+\d{2,4}.*$/)) {
|
|
210
|
+
const parts = input.split(/[^0-9-\/]+/).filter(Boolean);
|
|
211
|
+
const day = parts[0].padStart(2, "0");
|
|
212
|
+
const month = parts[1].padStart(2, "0");
|
|
213
|
+
let year = parts[2];
|
|
214
|
+
year = year.length === 2 ? `20${year}` : year.padStart(4, "0");
|
|
215
|
+
if (isValidDate(day, month, year)) {
|
|
216
|
+
return formatOutput(day, month, year);
|
|
217
|
+
}
|
|
218
|
+
return null;
|
|
219
|
+
}
|
|
220
|
+
if (isDateTime) {
|
|
221
|
+
if (cleanInput.length === 9) {
|
|
222
|
+
const day = cleanInput.slice(0, 2);
|
|
223
|
+
const month = cleanInput.slice(2, 4);
|
|
224
|
+
const year = cleanInput.slice(4, 8);
|
|
225
|
+
const hour = cleanInput.slice(8, 9).padStart(2, "0");
|
|
226
|
+
if (isValidDate(day, month, year) && isValidTime(hour)) {
|
|
227
|
+
let result = moment(
|
|
228
|
+
`${day}-${month}-${year} ${hour}:00:00`,
|
|
229
|
+
"DD-MM-YYYY HH:mm:ss"
|
|
230
|
+
);
|
|
231
|
+
if (!result.isValid()) return null;
|
|
232
|
+
result = result.subtract(7, "hours");
|
|
233
|
+
return result.format(dateTimeFormat);
|
|
234
|
+
}
|
|
235
|
+
return null;
|
|
236
|
+
}
|
|
237
|
+
if (cleanInput.length === 10) {
|
|
238
|
+
const day = cleanInput.slice(0, 2);
|
|
239
|
+
const month = cleanInput.slice(2, 4);
|
|
240
|
+
const year = cleanInput.slice(4, 8);
|
|
241
|
+
const hour = cleanInput.slice(8, 10);
|
|
242
|
+
if (isValidDate(day, month, year) && isValidTime(hour)) {
|
|
243
|
+
let result = moment(
|
|
244
|
+
`${day}-${month}-${year} ${hour}:00:00`,
|
|
245
|
+
"DD-MM-YYYY HH:mm:ss"
|
|
246
|
+
);
|
|
247
|
+
if (!result.isValid()) return null;
|
|
248
|
+
result = result.subtract(7, "hours");
|
|
249
|
+
return result.format(dateTimeFormat);
|
|
250
|
+
}
|
|
251
|
+
return null;
|
|
252
|
+
}
|
|
253
|
+
if (cleanInput.length === 11) {
|
|
254
|
+
const day = cleanInput.slice(0, 2);
|
|
255
|
+
const month = cleanInput.slice(2, 4);
|
|
256
|
+
const year = cleanInput.slice(4, 8);
|
|
257
|
+
const hour = cleanInput.slice(8, 10);
|
|
258
|
+
const minute = cleanInput.slice(10, 11).padStart(2, "0");
|
|
259
|
+
if (isValidDate(day, month, year) && isValidTime(hour, minute)) {
|
|
260
|
+
let result = moment(
|
|
261
|
+
`${day}-${month}-${year} ${hour}:${minute}:00`,
|
|
262
|
+
"DD-MM-YYYY HH:mm:ss"
|
|
263
|
+
);
|
|
264
|
+
if (!result.isValid()) return null;
|
|
265
|
+
result = result.subtract(7, "hours");
|
|
266
|
+
return result.format(dateTimeFormat);
|
|
267
|
+
}
|
|
268
|
+
return null;
|
|
269
|
+
}
|
|
270
|
+
if (cleanInput.length === 12) {
|
|
271
|
+
const day = cleanInput.slice(0, 2);
|
|
272
|
+
const month = cleanInput.slice(2, 4);
|
|
273
|
+
const year = cleanInput.slice(4, 8);
|
|
274
|
+
const hour = cleanInput.slice(8, 10);
|
|
275
|
+
const minute = cleanInput.slice(10, 12);
|
|
276
|
+
if (isValidDate(day, month, year) && isValidTime(hour, minute)) {
|
|
277
|
+
let result = moment(
|
|
278
|
+
`${day}-${month}-${year} ${hour}:${minute}:00`,
|
|
279
|
+
"DD-MM-YYYY HH:mm:ss"
|
|
280
|
+
);
|
|
281
|
+
if (!result.isValid()) return null;
|
|
282
|
+
result = result.subtract(7, "hours");
|
|
283
|
+
return result.format(dateTimeFormat);
|
|
284
|
+
}
|
|
285
|
+
return null;
|
|
286
|
+
}
|
|
287
|
+
if (cleanInput.length === 13) {
|
|
288
|
+
const day = cleanInput.slice(0, 2);
|
|
289
|
+
const month = cleanInput.slice(2, 4);
|
|
290
|
+
const year = cleanInput.slice(4, 8);
|
|
291
|
+
const hour = cleanInput.slice(8, 10);
|
|
292
|
+
const minute = cleanInput.slice(10, 12);
|
|
293
|
+
const second = cleanInput.slice(12, 13).padStart(2, "0");
|
|
294
|
+
if (isValidDate(day, month, year) && isValidTime(hour, minute, second)) {
|
|
295
|
+
let result = moment(
|
|
296
|
+
`${day}-${month}-${year} ${hour}:${minute}:${second}`,
|
|
297
|
+
"DD-MM-YYYY HH:mm:ss"
|
|
298
|
+
);
|
|
299
|
+
if (!result.isValid()) return null;
|
|
300
|
+
result = result.subtract(7, "hours");
|
|
301
|
+
return result.format(dateTimeFormat);
|
|
302
|
+
}
|
|
303
|
+
return null;
|
|
304
|
+
}
|
|
305
|
+
if (cleanInput.length === 14) {
|
|
306
|
+
const day = cleanInput.slice(0, 2);
|
|
307
|
+
const month = cleanInput.slice(2, 4);
|
|
308
|
+
const year = cleanInput.slice(4, 8);
|
|
309
|
+
const hour = cleanInput.slice(8, 10);
|
|
310
|
+
const minute = cleanInput.slice(10, 12);
|
|
311
|
+
const second = cleanInput.slice(12, 14);
|
|
312
|
+
if (isValidDate(day, month, year) && isValidTime(hour, minute, second)) {
|
|
313
|
+
let result = moment(
|
|
314
|
+
`${day}-${month}-${year} ${hour}:${minute}:${second}`,
|
|
315
|
+
"DD-MM-YYYY HH:mm:ss"
|
|
316
|
+
);
|
|
317
|
+
if (!result.isValid()) return null;
|
|
318
|
+
result = result.subtract(7, "hours");
|
|
319
|
+
return result.format(dateTimeFormat);
|
|
320
|
+
}
|
|
321
|
+
return null;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
const len = cleanInput.length;
|
|
325
|
+
if (len === 1 || len === 2) {
|
|
326
|
+
const paddedDay = cleanInput.padStart(2, "0");
|
|
327
|
+
if (isValidDate(paddedDay, currentMonth, currentYear)) {
|
|
328
|
+
return formatOutput(paddedDay, currentMonth, currentYear);
|
|
329
|
+
}
|
|
330
|
+
return null;
|
|
331
|
+
}
|
|
332
|
+
if (len === 3) {
|
|
333
|
+
const day = cleanInput.slice(0, 2);
|
|
334
|
+
const month = cleanInput.slice(2, 3).padStart(2, "0");
|
|
335
|
+
if (isValidDate(day, month, currentYear)) {
|
|
336
|
+
return formatOutput(day, month, currentYear);
|
|
337
|
+
}
|
|
338
|
+
return null;
|
|
339
|
+
}
|
|
340
|
+
if (len === 6) {
|
|
341
|
+
const day = cleanInput.slice(0, 2);
|
|
342
|
+
const month = cleanInput.slice(2, 4);
|
|
343
|
+
let year = cleanInput.slice(4, 6);
|
|
344
|
+
year = `20${year}`;
|
|
345
|
+
if (parseInt(month) > 12) {
|
|
346
|
+
if (isValidDate(day, currentMonth, currentYear)) {
|
|
347
|
+
return formatOutput(day, currentMonth, currentYear);
|
|
348
|
+
}
|
|
349
|
+
return null;
|
|
350
|
+
}
|
|
351
|
+
if (isValidDate(day, month, year)) {
|
|
352
|
+
return formatOutput(day, month, year);
|
|
353
|
+
}
|
|
354
|
+
return null;
|
|
355
|
+
}
|
|
356
|
+
if (len === 7) {
|
|
357
|
+
return null;
|
|
358
|
+
}
|
|
359
|
+
if (len === 8) {
|
|
360
|
+
const day = cleanInput.slice(0, 2);
|
|
361
|
+
const month = cleanInput.slice(2, 4);
|
|
362
|
+
const year = cleanInput.slice(4, 8);
|
|
363
|
+
if (isValidDate(day, month, year)) {
|
|
364
|
+
return formatOutput(day, month, year);
|
|
365
|
+
}
|
|
366
|
+
return null;
|
|
367
|
+
}
|
|
368
|
+
if (len > 8 && !isDateTime) {
|
|
369
|
+
return null;
|
|
370
|
+
}
|
|
371
|
+
return null;
|
|
372
|
+
};
|
|
373
|
+
|
|
374
|
+
// src/constants/field/field-type-constant.ts
|
|
375
|
+
var FieldTypeConstants = /* @__PURE__ */ ((FieldTypeConstants2) => {
|
|
376
|
+
FieldTypeConstants2["CHAR"] = "char";
|
|
377
|
+
FieldTypeConstants2["TEXT"] = "text";
|
|
378
|
+
FieldTypeConstants2["INTEGER"] = "integer";
|
|
379
|
+
FieldTypeConstants2["FLOAT"] = "float";
|
|
380
|
+
FieldTypeConstants2["BOOLEAN"] = "boolean";
|
|
381
|
+
FieldTypeConstants2["DATE"] = "date";
|
|
382
|
+
FieldTypeConstants2["DATETIME"] = "datetime";
|
|
383
|
+
FieldTypeConstants2["BINARY"] = "binary";
|
|
384
|
+
FieldTypeConstants2["SELECTION"] = "selection";
|
|
385
|
+
FieldTypeConstants2["HTML"] = "html";
|
|
386
|
+
FieldTypeConstants2["MANY2ONE"] = "many2one";
|
|
387
|
+
FieldTypeConstants2["ONE2MANY"] = "one2many";
|
|
388
|
+
FieldTypeConstants2["MANY2MANY"] = "many2many";
|
|
389
|
+
FieldTypeConstants2["MONETARY"] = "monetary";
|
|
390
|
+
FieldTypeConstants2["REFERENCE"] = "reference";
|
|
391
|
+
FieldTypeConstants2["FUNCTION"] = "function";
|
|
392
|
+
FieldTypeConstants2["PROPERTY"] = "property";
|
|
393
|
+
return FieldTypeConstants2;
|
|
394
|
+
})(FieldTypeConstants || {});
|
|
395
|
+
|
|
396
|
+
// src/constants/method/method-type-constant.ts
|
|
397
|
+
var MethodType = /* @__PURE__ */ ((MethodType2) => {
|
|
398
|
+
MethodType2[MethodType2["CREATE"] = 0] = "CREATE";
|
|
399
|
+
MethodType2[MethodType2["UPDATE"] = 1] = "UPDATE";
|
|
400
|
+
MethodType2[MethodType2["DELETE"] = 2] = "DELETE";
|
|
401
|
+
MethodType2[MethodType2["UNLINK"] = 3] = "UNLINK";
|
|
402
|
+
MethodType2[MethodType2["NO_CHANGE"] = 4] = "NO_CHANGE";
|
|
403
|
+
return MethodType2;
|
|
404
|
+
})(MethodType || {});
|
|
405
|
+
|
|
406
|
+
// src/constants/model/model-constant.ts
|
|
407
|
+
var ModelConstants = /* @__PURE__ */ ((ModelConstants2) => {
|
|
408
|
+
ModelConstants2["MENU"] = "ir.ui.menu";
|
|
409
|
+
ModelConstants2["USER"] = "res.users";
|
|
410
|
+
ModelConstants2["COMPANY"] = "res.company";
|
|
411
|
+
ModelConstants2["WINDOW_ACTION"] = "ir.actions.act_window";
|
|
412
|
+
ModelConstants2["BASE_IMPORT"] = "base_import.import";
|
|
413
|
+
ModelConstants2["GET_IMPORT"] = "get_import_templates";
|
|
414
|
+
return ModelConstants2;
|
|
415
|
+
})(ModelConstants || {});
|
|
416
|
+
|
|
417
|
+
// src/constants/type/index.ts
|
|
418
|
+
var ComponentType = /* @__PURE__ */ ((ComponentType2) => {
|
|
419
|
+
ComponentType2["GROUP"] = "group";
|
|
420
|
+
ComponentType2["FIELD"] = "field";
|
|
421
|
+
ComponentType2["TREE"] = "tree";
|
|
422
|
+
ComponentType2["DIV"] = "div";
|
|
423
|
+
ComponentType2["LIST"] = "list";
|
|
424
|
+
ComponentType2["FORM"] = "form";
|
|
425
|
+
ComponentType2["SETTINGS"] = "setting";
|
|
426
|
+
ComponentType2["SPAN"] = "span";
|
|
427
|
+
ComponentType2["KANBAN"] = "kanban";
|
|
428
|
+
ComponentType2["CALENDAR"] = "calendar";
|
|
429
|
+
ComponentType2["TYPE"] = "view-type";
|
|
430
|
+
return ComponentType2;
|
|
431
|
+
})(ComponentType || {});
|
|
432
|
+
var SearchType = {
|
|
433
|
+
FILTER: "filter_by",
|
|
434
|
+
SEARCH: "search_by",
|
|
435
|
+
GROUP: "group_by"
|
|
436
|
+
};
|
|
39
437
|
|
|
40
438
|
// src/constants/widget/widget-avatar-constant.ts
|
|
41
439
|
var WIDGETAVATAR = /* @__PURE__ */ ((WIDGETAVATAR2) => {
|
|
@@ -43,6 +441,28 @@ var WIDGETAVATAR = /* @__PURE__ */ ((WIDGETAVATAR2) => {
|
|
|
43
441
|
WIDGETAVATAR2["many2many_avatar_user"] = "many2many_avatar_user";
|
|
44
442
|
return WIDGETAVATAR2;
|
|
45
443
|
})(WIDGETAVATAR || {});
|
|
444
|
+
var WIDGETCURRENCY = /* @__PURE__ */ ((WIDGETCURRENCY2) => {
|
|
445
|
+
WIDGETCURRENCY2["many2one_avatar_user"] = "many2one_avatar_user";
|
|
446
|
+
WIDGETCURRENCY2["many2many_avatar_user"] = "many2many_avatar_user";
|
|
447
|
+
return WIDGETCURRENCY2;
|
|
448
|
+
})(WIDGETCURRENCY || {});
|
|
449
|
+
|
|
450
|
+
// src/constants/widget/widget-color-constant.ts
|
|
451
|
+
var WIDGETCOLOR = /* @__PURE__ */ ((WIDGETCOLOR2) => {
|
|
452
|
+
WIDGETCOLOR2["many2many_tags"] = "many2many_tags";
|
|
453
|
+
WIDGETCOLOR2["helpdesk_sla_many2many_tags"] = "helpdesk_sla_many2many_tags";
|
|
454
|
+
return WIDGETCOLOR2;
|
|
455
|
+
})(WIDGETCOLOR || {});
|
|
456
|
+
|
|
457
|
+
// src/constants/widget/widget-status-constant.ts
|
|
458
|
+
var WIDGETSTATUS = /* @__PURE__ */ ((WIDGETSTATUS2) => {
|
|
459
|
+
WIDGETSTATUS2["sla_status_ids"] = "sla_status_ids";
|
|
460
|
+
return WIDGETSTATUS2;
|
|
461
|
+
})(WIDGETSTATUS || {});
|
|
462
|
+
var WIDGETNOSTRING = /* @__PURE__ */ ((WIDGETNOSTRING2) => {
|
|
463
|
+
WIDGETNOSTRING2["sla_status_ids"] = "sla_status_ids";
|
|
464
|
+
return WIDGETNOSTRING2;
|
|
465
|
+
})(WIDGETNOSTRING || {});
|
|
46
466
|
|
|
47
467
|
// src/utils/domain/py_tokenizer.ts
|
|
48
468
|
var TokenizerError = class extends Error {
|
|
@@ -1811,6 +2231,48 @@ function parseExpr(expr) {
|
|
|
1811
2231
|
const tokens = tokenize(expr);
|
|
1812
2232
|
return parse(tokens);
|
|
1813
2233
|
}
|
|
2234
|
+
function evaluateExpr(expr, context = {}) {
|
|
2235
|
+
let ast;
|
|
2236
|
+
try {
|
|
2237
|
+
ast = parseExpr(expr);
|
|
2238
|
+
} catch (error) {
|
|
2239
|
+
throw new EvalError(
|
|
2240
|
+
`Can not parse python expression: (${expr})
|
|
2241
|
+
Error: ${error.message}`
|
|
2242
|
+
);
|
|
2243
|
+
}
|
|
2244
|
+
try {
|
|
2245
|
+
return evaluate(ast, context);
|
|
2246
|
+
} catch (error) {
|
|
2247
|
+
throw new EvalError(
|
|
2248
|
+
`Can not evaluate python expression: (${expr})
|
|
2249
|
+
Error: ${error.message}`
|
|
2250
|
+
);
|
|
2251
|
+
}
|
|
2252
|
+
}
|
|
2253
|
+
function evaluateBooleanExpr(expr, context = {}) {
|
|
2254
|
+
if (!expr || expr === "False" || expr === "0") {
|
|
2255
|
+
return false;
|
|
2256
|
+
}
|
|
2257
|
+
if (expr === "True" || expr === "1") {
|
|
2258
|
+
return true;
|
|
2259
|
+
}
|
|
2260
|
+
return evaluateExpr(`bool(${expr})`, context);
|
|
2261
|
+
}
|
|
2262
|
+
|
|
2263
|
+
// src/utils/domain/context.ts
|
|
2264
|
+
function evalPartialContext(_context, evaluationContext = {}) {
|
|
2265
|
+
const ast = parseExpr(_context);
|
|
2266
|
+
const context = {};
|
|
2267
|
+
for (const key in ast.value) {
|
|
2268
|
+
const value = ast.value[key];
|
|
2269
|
+
try {
|
|
2270
|
+
context[key] = evaluate(value, evaluationContext);
|
|
2271
|
+
} catch {
|
|
2272
|
+
}
|
|
2273
|
+
}
|
|
2274
|
+
return context;
|
|
2275
|
+
}
|
|
1814
2276
|
|
|
1815
2277
|
// src/utils/domain/objects.ts
|
|
1816
2278
|
function shallowEqual(obj1, obj2, comparisonFn = (a, b) => a === b) {
|
|
@@ -2149,14 +2611,280 @@ function matchDomain(record, domain) {
|
|
|
2149
2611
|
}
|
|
2150
2612
|
return matchCondition(record, condStack.pop());
|
|
2151
2613
|
}
|
|
2614
|
+
var checkDomain = (context, domain) => {
|
|
2615
|
+
try {
|
|
2616
|
+
if (domain === void 0 || domain === "0" || domain === "False" || domain === false) {
|
|
2617
|
+
return false;
|
|
2618
|
+
} else if (domain === "1" || domain === "True" || domain === true) {
|
|
2619
|
+
return true;
|
|
2620
|
+
}
|
|
2621
|
+
try {
|
|
2622
|
+
if (context && domain) {
|
|
2623
|
+
const d = new Domain(domain);
|
|
2624
|
+
return d.contains(context);
|
|
2625
|
+
}
|
|
2626
|
+
} catch (error) {
|
|
2627
|
+
if (context && domain) {
|
|
2628
|
+
const domainEval = evaluateBooleanExpr(domain, context);
|
|
2629
|
+
return domainEval;
|
|
2630
|
+
}
|
|
2631
|
+
return false;
|
|
2632
|
+
}
|
|
2633
|
+
return false;
|
|
2634
|
+
} catch (e) {
|
|
2635
|
+
return false;
|
|
2636
|
+
}
|
|
2637
|
+
};
|
|
2638
|
+
var matchDomains = (context, domains) => {
|
|
2639
|
+
if (Array.isArray(domains)) {
|
|
2640
|
+
if (domains?.length > 0) {
|
|
2641
|
+
return domains && domains.some((domain) => checkDomain(context, domain));
|
|
2642
|
+
}
|
|
2643
|
+
} else return checkDomain(context, domains);
|
|
2644
|
+
return false;
|
|
2645
|
+
};
|
|
2152
2646
|
|
|
2153
2647
|
// src/utils/function.ts
|
|
2154
2648
|
import { useEffect, useState } from "react";
|
|
2649
|
+
var evalJSONContext = (_context, context = {}) => {
|
|
2650
|
+
try {
|
|
2651
|
+
return evalPartialContext(_context, context);
|
|
2652
|
+
} catch (err) {
|
|
2653
|
+
return null;
|
|
2654
|
+
}
|
|
2655
|
+
};
|
|
2656
|
+
var evalJSONDomain = (domain, context) => {
|
|
2657
|
+
try {
|
|
2658
|
+
if (context) {
|
|
2659
|
+
Object.keys(context)?.forEach((key) => {
|
|
2660
|
+
if (Array.isArray(context[key])) {
|
|
2661
|
+
const isTypeObject = context[key]?.every(
|
|
2662
|
+
(item) => typeof item === "object" && item !== null && item?.id !== void 0
|
|
2663
|
+
);
|
|
2664
|
+
if (isTypeObject) {
|
|
2665
|
+
context[key] = context[key]?.map((item) => item?.id);
|
|
2666
|
+
}
|
|
2667
|
+
}
|
|
2668
|
+
});
|
|
2669
|
+
}
|
|
2670
|
+
const value = evaluateExpr(domain, context);
|
|
2671
|
+
return value;
|
|
2672
|
+
} catch (err) {
|
|
2673
|
+
try {
|
|
2674
|
+
const domainObject = new Domain(domain).toList(context);
|
|
2675
|
+
return domainObject;
|
|
2676
|
+
} catch (err2) {
|
|
2677
|
+
return [];
|
|
2678
|
+
}
|
|
2679
|
+
}
|
|
2680
|
+
};
|
|
2681
|
+
var formatSortingString = (input) => {
|
|
2682
|
+
if (!input) return null;
|
|
2683
|
+
return input.split(",").map((field) => {
|
|
2684
|
+
const [key, order] = field.trim().split(/\s+/);
|
|
2685
|
+
const sortOrder = order?.toUpperCase() === "DESC" ? "DESC" : "ASC";
|
|
2686
|
+
return `${key} ${sortOrder}`;
|
|
2687
|
+
}).join(", ");
|
|
2688
|
+
};
|
|
2689
|
+
var domainHelper = {
|
|
2690
|
+
checkDomain,
|
|
2691
|
+
matchDomains,
|
|
2692
|
+
Domain
|
|
2693
|
+
};
|
|
2155
2694
|
var toQueryString = (params) => {
|
|
2156
2695
|
return Object.keys(params).map(
|
|
2157
2696
|
(key) => encodeURIComponent(key) + "=" + encodeURIComponent(params[key].toString())
|
|
2158
2697
|
).join("&");
|
|
2159
2698
|
};
|
|
2699
|
+
var convertFloatToTime = (floatValue) => {
|
|
2700
|
+
const hours = Math.floor(floatValue);
|
|
2701
|
+
const minutes = Math.round((floatValue - hours) * 60);
|
|
2702
|
+
const formattedHours = String(hours).padStart(2, "0");
|
|
2703
|
+
const formattedMinutes = String(minutes).padStart(2, "0");
|
|
2704
|
+
return `${formattedHours}:${formattedMinutes}`;
|
|
2705
|
+
};
|
|
2706
|
+
var convertTimeToFloat = (timeString) => {
|
|
2707
|
+
const [hours, minutes] = timeString.split(":").map(Number);
|
|
2708
|
+
return hours + minutes / 60;
|
|
2709
|
+
};
|
|
2710
|
+
var stringToColor = (name, id) => {
|
|
2711
|
+
const combined = name + id / 2;
|
|
2712
|
+
let hash = 0;
|
|
2713
|
+
for (let i = 0; i < combined.length; i++) {
|
|
2714
|
+
hash = combined.charCodeAt(i) + ((hash << 5) - hash);
|
|
2715
|
+
}
|
|
2716
|
+
const r = hash >> 16 & 255;
|
|
2717
|
+
const g = hash >> 8 & 255;
|
|
2718
|
+
const b = hash & 255;
|
|
2719
|
+
const adjustedR = 120 + r % 61;
|
|
2720
|
+
const adjustedG = 120 + g % 61;
|
|
2721
|
+
const adjustedB = 120 + b % 61;
|
|
2722
|
+
return `#${adjustedR.toString(16).padStart(2, "0")}${adjustedG.toString(16).padStart(2, "0")}${adjustedB.toString(16).padStart(2, "0")}`;
|
|
2723
|
+
};
|
|
2724
|
+
var getFieldsOnChange = (fields) => {
|
|
2725
|
+
const result = [];
|
|
2726
|
+
function traverse(items) {
|
|
2727
|
+
for (const item of items) {
|
|
2728
|
+
if (item) {
|
|
2729
|
+
if (item?.type_co === "field" && matchDomains(fields, item?.on_change)) {
|
|
2730
|
+
result.push(item.name);
|
|
2731
|
+
}
|
|
2732
|
+
if (item?.fields && Array.isArray(item?.fields)) {
|
|
2733
|
+
traverse(item?.fields);
|
|
2734
|
+
}
|
|
2735
|
+
}
|
|
2736
|
+
}
|
|
2737
|
+
}
|
|
2738
|
+
traverse(fields);
|
|
2739
|
+
return result;
|
|
2740
|
+
};
|
|
2741
|
+
var filterFieldDirty = ({
|
|
2742
|
+
id,
|
|
2743
|
+
viewData,
|
|
2744
|
+
formValues,
|
|
2745
|
+
dirtyFields,
|
|
2746
|
+
model,
|
|
2747
|
+
defaultData
|
|
2748
|
+
}) => {
|
|
2749
|
+
const data = id ? { ...dirtyFields } : { ...formValues };
|
|
2750
|
+
for (const key in data) {
|
|
2751
|
+
if (viewData?.models?.[model]?.[key]?.type === "one2many" /* ONE2MANY */) {
|
|
2752
|
+
const lineData = [];
|
|
2753
|
+
(formValues[key] ?? []).forEach((itemData, index) => {
|
|
2754
|
+
if (typeof itemData?.id === "string" && itemData?.id.includes("virtual")) {
|
|
2755
|
+
delete itemData?.id;
|
|
2756
|
+
}
|
|
2757
|
+
if (!itemData?.id) {
|
|
2758
|
+
lineData.push([
|
|
2759
|
+
0 /* CREATE */,
|
|
2760
|
+
`virtual_${index}`,
|
|
2761
|
+
filterFieldDirty({
|
|
2762
|
+
id: itemData?.id,
|
|
2763
|
+
viewData,
|
|
2764
|
+
formValues: itemData,
|
|
2765
|
+
dirtyFields: {},
|
|
2766
|
+
model: viewData?.models?.[model]?.[key]?.relation,
|
|
2767
|
+
defaultData
|
|
2768
|
+
})
|
|
2769
|
+
]);
|
|
2770
|
+
} else if (dirtyFields[key]?.length) {
|
|
2771
|
+
dirtyFields[key].forEach((itemDirty, indexDirty) => {
|
|
2772
|
+
if (Object.values(itemDirty).includes(true) && indexDirty === index) {
|
|
2773
|
+
lineData.push([
|
|
2774
|
+
1 /* UPDATE */,
|
|
2775
|
+
itemData?.id,
|
|
2776
|
+
filterFieldDirty({
|
|
2777
|
+
id: itemData?.id,
|
|
2778
|
+
viewData,
|
|
2779
|
+
formValues: itemData,
|
|
2780
|
+
dirtyFields: itemDirty,
|
|
2781
|
+
model: viewData?.models?.[model]?.[key]?.relation,
|
|
2782
|
+
defaultData: {}
|
|
2783
|
+
})
|
|
2784
|
+
]);
|
|
2785
|
+
}
|
|
2786
|
+
});
|
|
2787
|
+
}
|
|
2788
|
+
});
|
|
2789
|
+
(defaultData[key] ?? []).forEach((item) => {
|
|
2790
|
+
if (!(formValues[key] ?? []).find(
|
|
2791
|
+
(itemData) => itemData?.id === item?.id
|
|
2792
|
+
)) {
|
|
2793
|
+
lineData.push([2 /* DELETE */, item?.id, item]);
|
|
2794
|
+
}
|
|
2795
|
+
});
|
|
2796
|
+
data[key] = lineData;
|
|
2797
|
+
} else if (viewData?.models?.[model]?.[key]?.type === "many2many" /* MANY2MANY */) {
|
|
2798
|
+
const lineData = [];
|
|
2799
|
+
(formValues[key] || []).forEach((itemData) => {
|
|
2800
|
+
if (itemData?.id) {
|
|
2801
|
+
lineData.push([4 /* NO_CHANGE */, itemData?.id]);
|
|
2802
|
+
}
|
|
2803
|
+
});
|
|
2804
|
+
(defaultData[key] ?? []).forEach((item) => {
|
|
2805
|
+
if (!(formValues[key] ?? []).find(
|
|
2806
|
+
(itemData) => itemData?.id === item?.id
|
|
2807
|
+
)) {
|
|
2808
|
+
lineData.push([3 /* UNLINK */, item?.id]);
|
|
2809
|
+
}
|
|
2810
|
+
});
|
|
2811
|
+
data[key] = lineData;
|
|
2812
|
+
} else {
|
|
2813
|
+
if (id && (typeof dirtyFields?.[key] === "object" && !dirtyFields?.[key]?.id || typeof dirtyFields[key] !== "object" && !dirtyFields[key])) {
|
|
2814
|
+
delete data[key];
|
|
2815
|
+
} else {
|
|
2816
|
+
if (!data[key]) {
|
|
2817
|
+
delete data[key];
|
|
2818
|
+
} else {
|
|
2819
|
+
data[key] = formValues?.[key]?.display_name ? formValues?.[key]?.id : formValues?.[key];
|
|
2820
|
+
}
|
|
2821
|
+
}
|
|
2822
|
+
}
|
|
2823
|
+
}
|
|
2824
|
+
return data;
|
|
2825
|
+
};
|
|
2826
|
+
var mergeObjects = (object1, object2) => {
|
|
2827
|
+
if (!object1 || !object2) return void 0;
|
|
2828
|
+
const mergedObject = { ...object2 };
|
|
2829
|
+
Object.keys(object1).forEach((key) => {
|
|
2830
|
+
if (Array.isArray(object1[key]) && Array.isArray(object2[key])) {
|
|
2831
|
+
mergedObject[key] = object2[key].map((item, index) => {
|
|
2832
|
+
if (object1[key][index]) {
|
|
2833
|
+
return {
|
|
2834
|
+
...item,
|
|
2835
|
+
...object1[key][index]
|
|
2836
|
+
};
|
|
2837
|
+
}
|
|
2838
|
+
return item;
|
|
2839
|
+
});
|
|
2840
|
+
} else if (typeof object1[key] === "object" && typeof object2[key] === "object" && object1[key] !== null && object2[key] !== null) {
|
|
2841
|
+
mergedObject[key] = mergeObjects(object1[key], object2[key]);
|
|
2842
|
+
} else {
|
|
2843
|
+
mergedObject[key] = object1[key] !== void 0 ? object1[key] : object2[key];
|
|
2844
|
+
}
|
|
2845
|
+
});
|
|
2846
|
+
if (object2) {
|
|
2847
|
+
Object.keys(object2).forEach((key) => {
|
|
2848
|
+
if (!mergedObject.hasOwnProperty(key)) {
|
|
2849
|
+
mergedObject[key] = object2[key];
|
|
2850
|
+
}
|
|
2851
|
+
});
|
|
2852
|
+
}
|
|
2853
|
+
return mergedObject;
|
|
2854
|
+
};
|
|
2855
|
+
var formatUrlPath = ({
|
|
2856
|
+
viewType,
|
|
2857
|
+
aid,
|
|
2858
|
+
model,
|
|
2859
|
+
id,
|
|
2860
|
+
actionPath
|
|
2861
|
+
}) => {
|
|
2862
|
+
let _url = `/${viewType}/${actionPath}?aid=${aid}&model=${model}`;
|
|
2863
|
+
if (id) {
|
|
2864
|
+
_url += `&id=${id}`;
|
|
2865
|
+
}
|
|
2866
|
+
return _url;
|
|
2867
|
+
};
|
|
2868
|
+
var removeUndefinedFields = (obj) => {
|
|
2869
|
+
const newObj = {};
|
|
2870
|
+
for (const key in obj) {
|
|
2871
|
+
if (obj[key] !== void 0) {
|
|
2872
|
+
newObj[key] = obj[key];
|
|
2873
|
+
}
|
|
2874
|
+
}
|
|
2875
|
+
return newObj;
|
|
2876
|
+
};
|
|
2877
|
+
var useTabModel = (viewData, onchangeData) => {
|
|
2878
|
+
const tabsData = viewData?.views?.form?.tabs?.filter((val) => {
|
|
2879
|
+
if (!val) return null;
|
|
2880
|
+
const hide = checkDomain(onchangeData, val.invisible);
|
|
2881
|
+
if (!hide) {
|
|
2882
|
+
return val;
|
|
2883
|
+
}
|
|
2884
|
+
return false;
|
|
2885
|
+
}) || [];
|
|
2886
|
+
return tabsData;
|
|
2887
|
+
};
|
|
2160
2888
|
var isBase64File = (str) => {
|
|
2161
2889
|
try {
|
|
2162
2890
|
const dataUriPattern = /^data:([a-zA-Z]+\/[a-zA-Z0-9-.+]+)?;base64,/;
|
|
@@ -2172,6 +2900,69 @@ var isBase64File = (str) => {
|
|
|
2172
2900
|
return false;
|
|
2173
2901
|
}
|
|
2174
2902
|
};
|
|
2903
|
+
var isBase64Image = (str) => {
|
|
2904
|
+
const base64Regex = /^data:image\/(png|jpeg|jpg|gif|webp);base64,/;
|
|
2905
|
+
if (!base64Regex.test(str)) {
|
|
2906
|
+
return false;
|
|
2907
|
+
}
|
|
2908
|
+
try {
|
|
2909
|
+
const base64Data = str.split(",")[1];
|
|
2910
|
+
return !!base64Data && atob(base64Data).length > 0;
|
|
2911
|
+
} catch (error) {
|
|
2912
|
+
return false;
|
|
2913
|
+
}
|
|
2914
|
+
};
|
|
2915
|
+
var checkIsImageLink = (url) => {
|
|
2916
|
+
const imageExtensions = /\.(jpg|jpeg|png|gif|bmp|webp|svg|tiff|ico)$/i;
|
|
2917
|
+
return imageExtensions.test(url) || isBase64Image(url);
|
|
2918
|
+
};
|
|
2919
|
+
var formatFileSize = (size) => {
|
|
2920
|
+
if (size < 1024) return `${size} B`;
|
|
2921
|
+
const i = Math.floor(Math.log(size) / Math.log(1024));
|
|
2922
|
+
const sizes = ["B", "KB", "MB", "GB", "TB"];
|
|
2923
|
+
return `${(size / Math.pow(1024, i)).toFixed(2)} ${sizes[i]}`;
|
|
2924
|
+
};
|
|
2925
|
+
var getSubdomain = (url = window.location.href) => {
|
|
2926
|
+
const parts = url?.split(".");
|
|
2927
|
+
if (parts.length > 2) {
|
|
2928
|
+
return parts[0].replace("https://", "").replace("http://", "");
|
|
2929
|
+
}
|
|
2930
|
+
return null;
|
|
2931
|
+
};
|
|
2932
|
+
var resequence = (arr, start, end) => {
|
|
2933
|
+
if (start < 0 || start >= arr.length || end < 0 || end >= arr.length) {
|
|
2934
|
+
return [];
|
|
2935
|
+
}
|
|
2936
|
+
const [element] = arr.splice(start, 1);
|
|
2937
|
+
arr.splice(end, 0, element);
|
|
2938
|
+
return arr.slice(Math.min(start, end), Math.max(start, end) + 1);
|
|
2939
|
+
};
|
|
2940
|
+
var getOffSet = (arr, start, end) => {
|
|
2941
|
+
if (start < 0 || start >= arr.length || end < 0 || end >= arr.length) {
|
|
2942
|
+
return 0;
|
|
2943
|
+
}
|
|
2944
|
+
if (start > end) {
|
|
2945
|
+
return end;
|
|
2946
|
+
}
|
|
2947
|
+
return arr.slice(0, start).length;
|
|
2948
|
+
};
|
|
2949
|
+
var copyTextToClipboard = async (text) => {
|
|
2950
|
+
if ("clipboard" in navigator) {
|
|
2951
|
+
return await navigator.clipboard.writeText(text);
|
|
2952
|
+
} else {
|
|
2953
|
+
const textArea = document.createElement("textarea");
|
|
2954
|
+
textArea.value = text;
|
|
2955
|
+
textArea.style.position = "fixed";
|
|
2956
|
+
document.body.appendChild(textArea);
|
|
2957
|
+
textArea.focus();
|
|
2958
|
+
textArea.select();
|
|
2959
|
+
try {
|
|
2960
|
+
document.execCommand("copy");
|
|
2961
|
+
} finally {
|
|
2962
|
+
document.body.removeChild(textArea);
|
|
2963
|
+
}
|
|
2964
|
+
}
|
|
2965
|
+
};
|
|
2175
2966
|
var updateTokenParamInOriginalRequest = (originalRequest, newAccessToken) => {
|
|
2176
2967
|
if (!originalRequest.data) return originalRequest.data;
|
|
2177
2968
|
if (typeof originalRequest.data === "string") {
|
|
@@ -2191,6 +2982,41 @@ var updateTokenParamInOriginalRequest = (originalRequest, newAccessToken) => {
|
|
|
2191
2982
|
}
|
|
2192
2983
|
return originalRequest.data;
|
|
2193
2984
|
};
|
|
2985
|
+
var isObjectEmpty = (obj) => {
|
|
2986
|
+
return Object.keys(obj).length === 0;
|
|
2987
|
+
};
|
|
2988
|
+
var useField = (props) => {
|
|
2989
|
+
const [invisible, setInvisible] = useState(true);
|
|
2990
|
+
const [required, setRequired] = useState(false);
|
|
2991
|
+
const [readonly, setReadOnly] = useState(false);
|
|
2992
|
+
const {
|
|
2993
|
+
invisible: inv,
|
|
2994
|
+
required: req,
|
|
2995
|
+
readonly: rea,
|
|
2996
|
+
onchangeData,
|
|
2997
|
+
rootField,
|
|
2998
|
+
index,
|
|
2999
|
+
name
|
|
3000
|
+
} = props;
|
|
3001
|
+
const nameField = rootField ? `${rootField?.name}.${index}.${name}` : null;
|
|
3002
|
+
useEffect(() => {
|
|
3003
|
+
if (onchangeData && Object.keys(onchangeData).length > 0) {
|
|
3004
|
+
setRequired(
|
|
3005
|
+
typeof req === "object" ? matchDomains(onchangeData, req) : checkDomain(onchangeData, req)
|
|
3006
|
+
);
|
|
3007
|
+
setInvisible(matchDomains(onchangeData, inv));
|
|
3008
|
+
setReadOnly(
|
|
3009
|
+
typeof req === "object" ? matchDomains(onchangeData, rea) : checkDomain(onchangeData, rea)
|
|
3010
|
+
);
|
|
3011
|
+
}
|
|
3012
|
+
}, [onchangeData]);
|
|
3013
|
+
return {
|
|
3014
|
+
invisible,
|
|
3015
|
+
required,
|
|
3016
|
+
readonly,
|
|
3017
|
+
nameField
|
|
3018
|
+
};
|
|
3019
|
+
};
|
|
2194
3020
|
|
|
2195
3021
|
// src/utils/storage/local-storage.ts
|
|
2196
3022
|
var localStorageUtils = () => {
|
|
@@ -2491,6 +3317,7 @@ var {
|
|
|
2491
3317
|
setConfig,
|
|
2492
3318
|
setEnvFile
|
|
2493
3319
|
} = envSlice.actions;
|
|
3320
|
+
var selectEnv = (state) => state.env;
|
|
2494
3321
|
var env_slice_default = envSlice.reducer;
|
|
2495
3322
|
|
|
2496
3323
|
// src/store/reducers/excel-slice/index.ts
|
|
@@ -3019,6 +3846,10 @@ var envStore = configureStore({
|
|
|
3019
3846
|
})
|
|
3020
3847
|
});
|
|
3021
3848
|
|
|
3849
|
+
// src/store/index.ts
|
|
3850
|
+
var useAppDispatch = useDispatch;
|
|
3851
|
+
var useAppSelector = useSelector;
|
|
3852
|
+
|
|
3022
3853
|
// src/environment/EnvStore.ts
|
|
3023
3854
|
var EnvStore = class {
|
|
3024
3855
|
envStore;
|
|
@@ -3100,6 +3931,9 @@ function getEnv() {
|
|
|
3100
3931
|
return env;
|
|
3101
3932
|
}
|
|
3102
3933
|
|
|
3934
|
+
// src/hooks/auth/use-forgot-password.ts
|
|
3935
|
+
import { useMutation } from "@tanstack/react-query";
|
|
3936
|
+
|
|
3103
3937
|
// src/services/action-service/index.ts
|
|
3104
3938
|
var ActionService = {
|
|
3105
3939
|
// Load Action
|
|
@@ -5843,7 +6677,112 @@ var useVerifyTotp = () => {
|
|
|
5843
6677
|
});
|
|
5844
6678
|
};
|
|
5845
6679
|
var use_verify_totp_default = useVerifyTotp;
|
|
6680
|
+
|
|
6681
|
+
// src/provider/react-query-provider.tsx
|
|
6682
|
+
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
6683
|
+
import { jsx } from "react/jsx-runtime";
|
|
6684
|
+
|
|
6685
|
+
// src/provider/redux-provider.tsx
|
|
6686
|
+
import { Provider } from "react-redux";
|
|
6687
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
6688
|
+
|
|
6689
|
+
// src/provider/main-provider.tsx
|
|
6690
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
6691
|
+
|
|
6692
|
+
// src/provider/version-gate-provider.tsx
|
|
6693
|
+
import { useEffect as useEffect2, useState as useState2 } from "react";
|
|
6694
|
+
import { useQueryClient } from "@tanstack/react-query";
|
|
6695
|
+
import { Fragment, jsx as jsx4 } from "react/jsx-runtime";
|
|
6696
|
+
var VersionGate = ({ children }) => {
|
|
6697
|
+
const queryClient = useQueryClient();
|
|
6698
|
+
const [ready, setReady] = useState2(false);
|
|
6699
|
+
useEffect2(() => {
|
|
6700
|
+
const clearVersion = () => {
|
|
6701
|
+
queryClient.clear();
|
|
6702
|
+
localStorage.removeItem("__api_version__");
|
|
6703
|
+
};
|
|
6704
|
+
const validateVersion = async () => {
|
|
6705
|
+
const serverVersion = await view_service_default.getVersion();
|
|
6706
|
+
const cached = localStorage.getItem("__api_version__");
|
|
6707
|
+
if (cached !== serverVersion?.api_version) {
|
|
6708
|
+
clearVersion();
|
|
6709
|
+
localStorage.setItem("__api_version__", serverVersion?.api_version);
|
|
6710
|
+
} else {
|
|
6711
|
+
console.log("Api version:", serverVersion?.api_version);
|
|
6712
|
+
}
|
|
6713
|
+
setReady(true);
|
|
6714
|
+
};
|
|
6715
|
+
validateVersion();
|
|
6716
|
+
if (typeof window !== "undefined") {
|
|
6717
|
+
const onKey = (e) => {
|
|
6718
|
+
const key = e.key.toLowerCase();
|
|
6719
|
+
const isHardRefresh = (key === "f5" || key === "r") && e.ctrlKey && (key !== "r" || e.shiftKey) || key === "r" && e.metaKey && e.shiftKey || key === "r" && e.metaKey && e.altKey;
|
|
6720
|
+
if (isHardRefresh) clearVersion();
|
|
6721
|
+
};
|
|
6722
|
+
window.addEventListener("keydown", onKey);
|
|
6723
|
+
return () => window.removeEventListener("keydown", onKey);
|
|
6724
|
+
}
|
|
6725
|
+
}, [queryClient]);
|
|
6726
|
+
return ready ? /* @__PURE__ */ jsx4(Fragment, { children }) : null;
|
|
6727
|
+
};
|
|
5846
6728
|
export {
|
|
6729
|
+
action_service_default as ActionService,
|
|
6730
|
+
auth_service_default as AuthService,
|
|
6731
|
+
company_service_default as CompanyService,
|
|
6732
|
+
ComponentType,
|
|
6733
|
+
EnvStore,
|
|
6734
|
+
excel_service_default as ExcelService,
|
|
6735
|
+
FieldTypeConstants,
|
|
6736
|
+
form_service_default as FormService,
|
|
6737
|
+
kanban_service_default as KanbanService,
|
|
6738
|
+
KeyConstants,
|
|
6739
|
+
MethodConstants,
|
|
6740
|
+
MethodType,
|
|
6741
|
+
ModelConstants,
|
|
6742
|
+
model_service_default as ModelService,
|
|
6743
|
+
SearchType,
|
|
6744
|
+
UriConstants,
|
|
6745
|
+
user_service_default as UserService,
|
|
6746
|
+
VersionGate,
|
|
6747
|
+
view_service_default as ViewService,
|
|
6748
|
+
WIDGETAVATAR,
|
|
6749
|
+
WIDGETCOLOR,
|
|
6750
|
+
WIDGETCURRENCY,
|
|
6751
|
+
WIDGETNOSTRING,
|
|
6752
|
+
WIDGETSTATUS,
|
|
6753
|
+
WesapError,
|
|
6754
|
+
axiosClient,
|
|
6755
|
+
checkIsImageLink,
|
|
6756
|
+
convertFloatToTime,
|
|
6757
|
+
convertTimeToFloat,
|
|
6758
|
+
copyTextToClipboard,
|
|
6759
|
+
domainHelper,
|
|
6760
|
+
evalJSONContext,
|
|
6761
|
+
evalJSONDomain,
|
|
6762
|
+
filterFieldDirty,
|
|
6763
|
+
formatCurrency,
|
|
6764
|
+
formatDate,
|
|
6765
|
+
formatFileSize,
|
|
6766
|
+
formatSortingString,
|
|
6767
|
+
formatUrlPath,
|
|
6768
|
+
getEnv,
|
|
6769
|
+
getFieldsOnChange,
|
|
6770
|
+
getOffSet,
|
|
6771
|
+
getSubdomain,
|
|
6772
|
+
handleError,
|
|
6773
|
+
isBase64File,
|
|
6774
|
+
isBase64Image,
|
|
6775
|
+
isObjectEmpty,
|
|
6776
|
+
mergeObjects,
|
|
6777
|
+
removeUndefinedFields,
|
|
6778
|
+
resequence,
|
|
6779
|
+
selectEnv,
|
|
6780
|
+
setEnvFile,
|
|
6781
|
+
stringToColor,
|
|
6782
|
+
toQueryString,
|
|
6783
|
+
updateTokenParamInOriginalRequest,
|
|
6784
|
+
useAppDispatch,
|
|
6785
|
+
useAppSelector,
|
|
5847
6786
|
use_button_default as useButton,
|
|
5848
6787
|
use_change_status_default as useChangeStatus,
|
|
5849
6788
|
use_delete_default as useDelete,
|
|
@@ -5851,6 +6790,7 @@ export {
|
|
|
5851
6790
|
use_duplicate_record_default as useDuplicateRecord,
|
|
5852
6791
|
uss_execute_import_default as useExecuteImport,
|
|
5853
6792
|
use_export_excel_default as useExportExcel,
|
|
6793
|
+
useField,
|
|
5854
6794
|
use_forgot_password_default as useForgotPassword,
|
|
5855
6795
|
use_forgotpassword_sso_default as useForgotPasswordSSO,
|
|
5856
6796
|
uset_get_2FA_method_default as useGet2FAMethods,
|
|
@@ -5906,10 +6846,12 @@ export {
|
|
|
5906
6846
|
use_settings_web_read_2fa_default as useSettingsWebRead2fa,
|
|
5907
6847
|
use_signin_sso_default as useSignInSSO,
|
|
5908
6848
|
use_switch_locale_default as useSwitchLocale,
|
|
6849
|
+
useTabModel,
|
|
5909
6850
|
use_update_password_default as useUpdatePassword,
|
|
5910
6851
|
use_upload_file_default as useUploadFile,
|
|
5911
6852
|
use_upload_id_file_default as useUploadIdFile,
|
|
5912
6853
|
use_upload_image_default as useUploadImage,
|
|
5913
6854
|
use_verify_2FA_default as useVerify2FA,
|
|
5914
|
-
use_verify_totp_default as useVerifyTotp
|
|
6855
|
+
use_verify_totp_default as useVerifyTotp,
|
|
6856
|
+
validateAndParseDate
|
|
5915
6857
|
};
|