@fctc/widget-logic 5.3.1 → 5.3.4
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/config.d.mts +1 -0
- package/dist/config.d.ts +1 -0
- package/dist/hooks.d.mts +13 -3
- package/dist/hooks.d.ts +13 -3
- package/dist/hooks.js +158 -345
- package/dist/hooks.mjs +148 -325
- package/dist/icons.d.mts +27 -0
- package/dist/icons.d.ts +27 -0
- package/dist/icons.js +273 -0
- package/dist/icons.mjs +239 -0
- package/dist/index.d.mts +5 -3
- package/dist/index.d.ts +5 -3
- package/dist/index.js +4674 -515
- package/dist/index.mjs +4594 -416
- package/dist/store.d.mts +1 -0
- package/dist/store.d.ts +1 -0
- package/dist/store.js +24 -0
- package/dist/store.mjs +2 -0
- package/dist/utils.d.mts +8 -5
- package/dist/utils.d.ts +8 -5
- package/dist/utils.js +104 -326
- package/dist/utils.mjs +101 -313
- package/dist/widget.d.mts +5 -0
- package/dist/widget.d.ts +5 -0
- package/dist/widget.js +4369 -495
- package/dist/widget.mjs +4290 -398
- package/package.json +33 -14
package/dist/hooks.mjs
CHANGED
|
@@ -44,6 +44,7 @@ import {
|
|
|
44
44
|
useGetFileExcel,
|
|
45
45
|
useGetFormView,
|
|
46
46
|
useGetGroups,
|
|
47
|
+
useGetImage,
|
|
47
48
|
useGetListCompany,
|
|
48
49
|
useGetListData,
|
|
49
50
|
useGetListMyBankAccount,
|
|
@@ -171,14 +172,14 @@ var useCallAction = () => {
|
|
|
171
172
|
var utils_exports = {};
|
|
172
173
|
__export(utils_exports, {
|
|
173
174
|
STORAGES: () => STORAGES,
|
|
175
|
+
combineContexts: () => combineContexts,
|
|
176
|
+
convertFieldsToArray: () => convertFieldsToArray,
|
|
174
177
|
countSum: () => countSum,
|
|
175
|
-
|
|
176
|
-
isObjectEmpty: () => isObjectEmpty,
|
|
178
|
+
getDateRange: () => getDateRange,
|
|
177
179
|
languages: () => languages,
|
|
178
180
|
mergeButtons: () => mergeButtons,
|
|
179
181
|
setStorageItemAsync: () => setStorageItemAsync,
|
|
180
|
-
useStorageState: () => useStorageState
|
|
181
|
-
validateAndParseDate: () => validateAndParseDate
|
|
182
|
+
useStorageState: () => useStorageState
|
|
182
183
|
});
|
|
183
184
|
|
|
184
185
|
// src/utils/constants.ts
|
|
@@ -196,9 +197,6 @@ var countSum = (data, field) => {
|
|
|
196
197
|
0
|
|
197
198
|
);
|
|
198
199
|
};
|
|
199
|
-
var isObjectEmpty = (obj) => {
|
|
200
|
-
return Object.keys(obj).length === 0;
|
|
201
|
-
};
|
|
202
200
|
function mergeButtons(fields) {
|
|
203
201
|
const buttons = fields?.filter((f) => f.type_co === "button");
|
|
204
202
|
const others = fields?.filter((f) => f.type_co !== "button");
|
|
@@ -210,6 +208,103 @@ function mergeButtons(fields) {
|
|
|
210
208
|
}
|
|
211
209
|
return others;
|
|
212
210
|
}
|
|
211
|
+
var getDateRange = (currentDate, unit) => {
|
|
212
|
+
const date = new Date(currentDate);
|
|
213
|
+
let dateStart, dateEnd;
|
|
214
|
+
function formatDate(d) {
|
|
215
|
+
return d.getFullYear() + "-" + String(d.getMonth() + 1).padStart(2, "0") + "-" + String(d.getDate()).padStart(2, "0") + " " + String(d.getHours()).padStart(2, "0") + ":" + String(d.getMinutes()).padStart(2, "0") + ":" + String(d.getSeconds()).padStart(2, "0");
|
|
216
|
+
}
|
|
217
|
+
switch (unit) {
|
|
218
|
+
case "month":
|
|
219
|
+
dateStart = new Date(
|
|
220
|
+
date.getFullYear(),
|
|
221
|
+
date.getMonth() + 1,
|
|
222
|
+
date.getDate(),
|
|
223
|
+
23,
|
|
224
|
+
59,
|
|
225
|
+
59
|
|
226
|
+
);
|
|
227
|
+
dateStart.setHours(dateStart.getHours() - 7);
|
|
228
|
+
dateEnd = new Date(date.getFullYear(), date.getMonth(), 0, 0, 0, 0);
|
|
229
|
+
dateEnd.setHours(dateEnd.getHours() - 7);
|
|
230
|
+
break;
|
|
231
|
+
case "day":
|
|
232
|
+
dateStart = new Date(
|
|
233
|
+
date.getFullYear(),
|
|
234
|
+
date.getMonth(),
|
|
235
|
+
date.getDate(),
|
|
236
|
+
23,
|
|
237
|
+
59,
|
|
238
|
+
59
|
|
239
|
+
);
|
|
240
|
+
dateStart.setHours(dateStart.getHours() - 7);
|
|
241
|
+
dateEnd = new Date(
|
|
242
|
+
date.getFullYear(),
|
|
243
|
+
date.getMonth(),
|
|
244
|
+
date.getDate(),
|
|
245
|
+
0,
|
|
246
|
+
0,
|
|
247
|
+
0
|
|
248
|
+
);
|
|
249
|
+
dateEnd.setHours(dateEnd.getHours() - 7);
|
|
250
|
+
break;
|
|
251
|
+
case "week":
|
|
252
|
+
const dayOfWeek = date.getDay();
|
|
253
|
+
const daysToMonday = dayOfWeek === 0 ? -6 : 1 - dayOfWeek;
|
|
254
|
+
const daysToSunday = dayOfWeek === 0 ? 0 : 7 - dayOfWeek;
|
|
255
|
+
dateStart = new Date(
|
|
256
|
+
date.getFullYear(),
|
|
257
|
+
date.getMonth(),
|
|
258
|
+
date.getDate() + daysToSunday,
|
|
259
|
+
23,
|
|
260
|
+
59,
|
|
261
|
+
59
|
|
262
|
+
);
|
|
263
|
+
dateStart.setHours(dateStart.getHours() - 7);
|
|
264
|
+
dateEnd = new Date(
|
|
265
|
+
date.getFullYear(),
|
|
266
|
+
date.getMonth(),
|
|
267
|
+
date.getDate() + daysToMonday,
|
|
268
|
+
0,
|
|
269
|
+
0,
|
|
270
|
+
0
|
|
271
|
+
);
|
|
272
|
+
dateEnd.setHours(dateEnd.getHours() - 7);
|
|
273
|
+
break;
|
|
274
|
+
case "year":
|
|
275
|
+
dateStart = new Date(date.getFullYear(), 11, 31, 23, 59, 59);
|
|
276
|
+
dateStart.setHours(dateStart.getHours() - 7);
|
|
277
|
+
dateEnd = new Date(date.getFullYear() - 1, 11, 31, 0, 0, 0);
|
|
278
|
+
dateEnd.setHours(dateEnd.getHours() - 7);
|
|
279
|
+
break;
|
|
280
|
+
default:
|
|
281
|
+
throw new Error(
|
|
282
|
+
"\u0110\u01A1n v\u1ECB kh\xF4ng h\u1EE3p l\u1EC7. Ch\u1EC9 ch\u1EA5p nh\u1EADn: week, day, month, year"
|
|
283
|
+
);
|
|
284
|
+
}
|
|
285
|
+
return [
|
|
286
|
+
["date_start", "<=", formatDate(dateStart)],
|
|
287
|
+
["date_end", ">=", formatDate(dateEnd)]
|
|
288
|
+
];
|
|
289
|
+
};
|
|
290
|
+
var convertFieldsToArray = (fields) => {
|
|
291
|
+
const defaultFields = ["display_name", "date_start", "date_end"];
|
|
292
|
+
if (!fields || !Array.isArray(fields)) {
|
|
293
|
+
return defaultFields;
|
|
294
|
+
}
|
|
295
|
+
const inputFields = fields.filter((field) => field && field.type_co === "field").map((field) => field.name);
|
|
296
|
+
return [...defaultFields, ...inputFields];
|
|
297
|
+
};
|
|
298
|
+
function combineContexts(contexts) {
|
|
299
|
+
if (contexts.some((context) => !context)) {
|
|
300
|
+
return void 0;
|
|
301
|
+
} else {
|
|
302
|
+
const res = contexts.reduce((acc, context) => {
|
|
303
|
+
return { ...acc, ...context };
|
|
304
|
+
}, {});
|
|
305
|
+
return res;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
213
308
|
var STORAGES = {
|
|
214
309
|
TOKEN: "accessToken",
|
|
215
310
|
USER_INFO: "USER_INFO"
|
|
@@ -250,312 +345,6 @@ function useStorageState(key) {
|
|
|
250
345
|
);
|
|
251
346
|
return [state, setValue];
|
|
252
347
|
}
|
|
253
|
-
var guessTypeFromUrl = (url) => {
|
|
254
|
-
const ext = url.split(".").pop()?.toLowerCase();
|
|
255
|
-
if (!ext) return null;
|
|
256
|
-
const map = {
|
|
257
|
-
jpg: "image/jpeg",
|
|
258
|
-
jpeg: "image/jpeg",
|
|
259
|
-
png: "image/png",
|
|
260
|
-
webp: "image/webp",
|
|
261
|
-
gif: "image/gif",
|
|
262
|
-
svg: "image/svg+xml",
|
|
263
|
-
bmp: "image/bmp",
|
|
264
|
-
tiff: "image/tiff",
|
|
265
|
-
pdf: "application/pdf",
|
|
266
|
-
zip: "application/zip",
|
|
267
|
-
rar: "application/x-rar-compressed",
|
|
268
|
-
xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
269
|
-
xls: "application/vnd.ms-excel",
|
|
270
|
-
mp4: "video/mp4",
|
|
271
|
-
mov: "video/quicktime"
|
|
272
|
-
};
|
|
273
|
-
return map[ext] || null;
|
|
274
|
-
};
|
|
275
|
-
|
|
276
|
-
// src/utils/format-date.ts
|
|
277
|
-
import moment from "moment";
|
|
278
|
-
var validateAndParseDate = (input, isDateTime = false) => {
|
|
279
|
-
if (!input || typeof input !== "string") return null;
|
|
280
|
-
const cleanInput = input.replace(/[^0-9-\/:\s]/g, "");
|
|
281
|
-
const dateFormat = "YYYY-MM-DD";
|
|
282
|
-
const dateTimeFormat = "YYYY-MM-DD HH:mm:ss";
|
|
283
|
-
const currentDay = moment().format("DD");
|
|
284
|
-
const currentMonth = moment().format("MM");
|
|
285
|
-
const currentYear = moment().format("YYYY");
|
|
286
|
-
const defaultTime = "00:00:00";
|
|
287
|
-
const maxYear = parseInt(currentYear) + 10;
|
|
288
|
-
const isValidDate = (day, month, year) => {
|
|
289
|
-
const date = moment(`${day}-${month}-${year}`, "DD-MM-YYYY", true);
|
|
290
|
-
return date.isValid();
|
|
291
|
-
};
|
|
292
|
-
const isValidTime = (hour, minute = "00", second = "00") => {
|
|
293
|
-
const h = parseInt(hour, 10);
|
|
294
|
-
const m = parseInt(minute, 10);
|
|
295
|
-
const s = parseInt(second, 10);
|
|
296
|
-
return h >= 0 && h <= 23 && m >= 0 && m <= 59 && s >= 0 && s <= 59;
|
|
297
|
-
};
|
|
298
|
-
const formatOutput = (day, month, year, time = defaultTime) => {
|
|
299
|
-
let result = moment(
|
|
300
|
-
`${day}-${month}-${year} ${time}`,
|
|
301
|
-
"DD-MM-YYYY HH:mm:ss"
|
|
302
|
-
);
|
|
303
|
-
if (!result.isValid()) return null;
|
|
304
|
-
if (isDateTime) {
|
|
305
|
-
result = result.subtract(7, "hours");
|
|
306
|
-
return result.format(dateTimeFormat);
|
|
307
|
-
}
|
|
308
|
-
return result.format(dateFormat);
|
|
309
|
-
};
|
|
310
|
-
if (isDateTime && input.match(
|
|
311
|
-
/^\d{1,2}[\/-]\d{1,2}[\/-]\d{2,4}\s+\d{1,2}(:\d{1,2}(:\d{1,2})?)?$/
|
|
312
|
-
)) {
|
|
313
|
-
const [datePart, timePart] = input.split(/\s+/);
|
|
314
|
-
const dateParts = datePart.split(/[\/-]/);
|
|
315
|
-
const timeParts = timePart.split(":");
|
|
316
|
-
const day = dateParts[0].padStart(2, "0");
|
|
317
|
-
const month = dateParts[1].padStart(2, "0");
|
|
318
|
-
const year = dateParts[2].length <= 2 ? `20${dateParts[2].padStart(2, "0")}` : dateParts[2].padStart(4, "0");
|
|
319
|
-
const hour = timeParts[0].padStart(2, "0");
|
|
320
|
-
const minute = timeParts[1] ? timeParts[1].padStart(2, "0") : "00";
|
|
321
|
-
const second = timeParts[2] ? timeParts[2].padStart(2, "0") : "00";
|
|
322
|
-
if (isValidDate(day, month, year) && isValidTime(hour, minute, second)) {
|
|
323
|
-
let result = moment(
|
|
324
|
-
`${day}-${month}-${year} ${hour}:${minute}:${second}`,
|
|
325
|
-
"DD-MM-YYYY HH:mm:ss"
|
|
326
|
-
);
|
|
327
|
-
if (!result.isValid()) return null;
|
|
328
|
-
result = result.subtract(7, "hours");
|
|
329
|
-
return result.format(dateTimeFormat);
|
|
330
|
-
}
|
|
331
|
-
return null;
|
|
332
|
-
}
|
|
333
|
-
if (cleanInput.match(/^\d{4}-\d{2}-\d{2}$/)) {
|
|
334
|
-
const [year, month, day] = cleanInput.split("-");
|
|
335
|
-
if (isValidDate(day, month, year)) {
|
|
336
|
-
return formatOutput(day, month, year);
|
|
337
|
-
}
|
|
338
|
-
return null;
|
|
339
|
-
}
|
|
340
|
-
if (cleanInput.match(/^\d{1,2}\/\d{1,2}\/\d{2,4}$/)) {
|
|
341
|
-
const [day, month, year] = cleanInput.split("/");
|
|
342
|
-
const paddedDay = day.padStart(2, "0");
|
|
343
|
-
const paddedMonth = month.padStart(2, "0");
|
|
344
|
-
const fullYear = year.length <= 2 ? `20${year.padStart(2, "0")}` : year.padStart(4, "0");
|
|
345
|
-
if (isValidDate(paddedDay, paddedMonth, fullYear)) {
|
|
346
|
-
return formatOutput(paddedDay, paddedMonth, fullYear);
|
|
347
|
-
}
|
|
348
|
-
return null;
|
|
349
|
-
}
|
|
350
|
-
if (cleanInput.match(/^\d{1,2}-\d{1,2}-\d{2,4}$/)) {
|
|
351
|
-
const [day, month, year] = cleanInput.split("-");
|
|
352
|
-
const paddedDay = day.padStart(2, "0");
|
|
353
|
-
const paddedMonth = month.padStart(2, "0");
|
|
354
|
-
const fullYear = year.length <= 2 ? `20${year.padStart(2, "0")}` : year.padStart(4, "0");
|
|
355
|
-
if (isValidDate(paddedDay, paddedMonth, fullYear)) {
|
|
356
|
-
return formatOutput(paddedDay, paddedMonth, fullYear);
|
|
357
|
-
}
|
|
358
|
-
return null;
|
|
359
|
-
}
|
|
360
|
-
if (cleanInput.match(/^\d{1,2}[\/-]\d{1,2}$/)) {
|
|
361
|
-
const [day, month] = cleanInput.split(/[\/-]/);
|
|
362
|
-
const paddedDay = day.padStart(2, "0");
|
|
363
|
-
const paddedMonth = month.padStart(2, "0");
|
|
364
|
-
if (isValidDate(paddedDay, paddedMonth, currentYear)) {
|
|
365
|
-
return formatOutput(paddedDay, paddedMonth, currentYear);
|
|
366
|
-
}
|
|
367
|
-
return null;
|
|
368
|
-
}
|
|
369
|
-
if (cleanInput.match(/^\d{4}$/)) {
|
|
370
|
-
const num = parseInt(cleanInput, 10);
|
|
371
|
-
if (num >= 2e3 && num <= maxYear) {
|
|
372
|
-
if (isValidDate(currentDay, currentMonth, num.toString())) {
|
|
373
|
-
return formatOutput(currentDay, currentMonth, num.toString());
|
|
374
|
-
}
|
|
375
|
-
return null;
|
|
376
|
-
}
|
|
377
|
-
const day = cleanInput.slice(0, 2);
|
|
378
|
-
const month = cleanInput.slice(2, 4);
|
|
379
|
-
if (isValidDate(day, month, currentYear)) {
|
|
380
|
-
return formatOutput(day, month, currentYear);
|
|
381
|
-
}
|
|
382
|
-
return null;
|
|
383
|
-
}
|
|
384
|
-
if (cleanInput.startsWith("-") && /^\-\d+$/.test(cleanInput)) {
|
|
385
|
-
const daysToSubtract = Math.abs(parseInt(cleanInput, 10));
|
|
386
|
-
let result = moment().subtract(daysToSubtract, "days");
|
|
387
|
-
if (isDateTime) {
|
|
388
|
-
result = result.subtract(7, "hours");
|
|
389
|
-
}
|
|
390
|
-
if (result.isValid()) {
|
|
391
|
-
return isDateTime ? result.format(dateTimeFormat) : result.format(dateFormat);
|
|
392
|
-
}
|
|
393
|
-
return null;
|
|
394
|
-
}
|
|
395
|
-
if (input.match(/^\d{1,2}[^0-9-\/]+\d{1,2}[^0-9-\/]+\d{2,4}.*$/)) {
|
|
396
|
-
const parts = input.split(/[^0-9-\/]+/).filter(Boolean);
|
|
397
|
-
const day = parts[0].padStart(2, "0");
|
|
398
|
-
const month = parts[1].padStart(2, "0");
|
|
399
|
-
let year = parts[2];
|
|
400
|
-
year = year.length === 2 ? `20${year}` : year.padStart(4, "0");
|
|
401
|
-
if (isValidDate(day, month, year)) {
|
|
402
|
-
return formatOutput(day, month, year);
|
|
403
|
-
}
|
|
404
|
-
return null;
|
|
405
|
-
}
|
|
406
|
-
if (isDateTime) {
|
|
407
|
-
if (cleanInput.length === 9) {
|
|
408
|
-
const day = cleanInput.slice(0, 2);
|
|
409
|
-
const month = cleanInput.slice(2, 4);
|
|
410
|
-
const year = cleanInput.slice(4, 8);
|
|
411
|
-
const hour = cleanInput.slice(8, 9).padStart(2, "0");
|
|
412
|
-
if (isValidDate(day, month, year) && isValidTime(hour)) {
|
|
413
|
-
let result = moment(
|
|
414
|
-
`${day}-${month}-${year} ${hour}:00:00`,
|
|
415
|
-
"DD-MM-YYYY HH:mm:ss"
|
|
416
|
-
);
|
|
417
|
-
if (!result.isValid()) return null;
|
|
418
|
-
result = result.subtract(7, "hours");
|
|
419
|
-
return result.format(dateTimeFormat);
|
|
420
|
-
}
|
|
421
|
-
return null;
|
|
422
|
-
}
|
|
423
|
-
if (cleanInput.length === 10) {
|
|
424
|
-
const day = cleanInput.slice(0, 2);
|
|
425
|
-
const month = cleanInput.slice(2, 4);
|
|
426
|
-
const year = cleanInput.slice(4, 8);
|
|
427
|
-
const hour = cleanInput.slice(8, 10);
|
|
428
|
-
if (isValidDate(day, month, year) && isValidTime(hour)) {
|
|
429
|
-
let result = moment(
|
|
430
|
-
`${day}-${month}-${year} ${hour}:00:00`,
|
|
431
|
-
"DD-MM-YYYY HH:mm:ss"
|
|
432
|
-
);
|
|
433
|
-
if (!result.isValid()) return null;
|
|
434
|
-
result = result.subtract(7, "hours");
|
|
435
|
-
return result.format(dateTimeFormat);
|
|
436
|
-
}
|
|
437
|
-
return null;
|
|
438
|
-
}
|
|
439
|
-
if (cleanInput.length === 11) {
|
|
440
|
-
const day = cleanInput.slice(0, 2);
|
|
441
|
-
const month = cleanInput.slice(2, 4);
|
|
442
|
-
const year = cleanInput.slice(4, 8);
|
|
443
|
-
const hour = cleanInput.slice(8, 10);
|
|
444
|
-
const minute = cleanInput.slice(10, 11).padStart(2, "0");
|
|
445
|
-
if (isValidDate(day, month, year) && isValidTime(hour, minute)) {
|
|
446
|
-
let result = moment(
|
|
447
|
-
`${day}-${month}-${year} ${hour}:${minute}:00`,
|
|
448
|
-
"DD-MM-YYYY HH:mm:ss"
|
|
449
|
-
);
|
|
450
|
-
if (!result.isValid()) return null;
|
|
451
|
-
result = result.subtract(7, "hours");
|
|
452
|
-
return result.format(dateTimeFormat);
|
|
453
|
-
}
|
|
454
|
-
return null;
|
|
455
|
-
}
|
|
456
|
-
if (cleanInput.length === 12) {
|
|
457
|
-
const day = cleanInput.slice(0, 2);
|
|
458
|
-
const month = cleanInput.slice(2, 4);
|
|
459
|
-
const year = cleanInput.slice(4, 8);
|
|
460
|
-
const hour = cleanInput.slice(8, 10);
|
|
461
|
-
const minute = cleanInput.slice(10, 12);
|
|
462
|
-
if (isValidDate(day, month, year) && isValidTime(hour, minute)) {
|
|
463
|
-
let result = moment(
|
|
464
|
-
`${day}-${month}-${year} ${hour}:${minute}:00`,
|
|
465
|
-
"DD-MM-YYYY HH:mm:ss"
|
|
466
|
-
);
|
|
467
|
-
if (!result.isValid()) return null;
|
|
468
|
-
result = result.subtract(7, "hours");
|
|
469
|
-
return result.format(dateTimeFormat);
|
|
470
|
-
}
|
|
471
|
-
return null;
|
|
472
|
-
}
|
|
473
|
-
if (cleanInput.length === 13) {
|
|
474
|
-
const day = cleanInput.slice(0, 2);
|
|
475
|
-
const month = cleanInput.slice(2, 4);
|
|
476
|
-
const year = cleanInput.slice(4, 8);
|
|
477
|
-
const hour = cleanInput.slice(8, 10);
|
|
478
|
-
const minute = cleanInput.slice(10, 12);
|
|
479
|
-
const second = cleanInput.slice(12, 13).padStart(2, "0");
|
|
480
|
-
if (isValidDate(day, month, year) && isValidTime(hour, minute, second)) {
|
|
481
|
-
let result = moment(
|
|
482
|
-
`${day}-${month}-${year} ${hour}:${minute}:${second}`,
|
|
483
|
-
"DD-MM-YYYY HH:mm:ss"
|
|
484
|
-
);
|
|
485
|
-
if (!result.isValid()) return null;
|
|
486
|
-
result = result.subtract(7, "hours");
|
|
487
|
-
return result.format(dateTimeFormat);
|
|
488
|
-
}
|
|
489
|
-
return null;
|
|
490
|
-
}
|
|
491
|
-
if (cleanInput.length === 14) {
|
|
492
|
-
const day = cleanInput.slice(0, 2);
|
|
493
|
-
const month = cleanInput.slice(2, 4);
|
|
494
|
-
const year = cleanInput.slice(4, 8);
|
|
495
|
-
const hour = cleanInput.slice(8, 10);
|
|
496
|
-
const minute = cleanInput.slice(10, 12);
|
|
497
|
-
const second = cleanInput.slice(12, 14);
|
|
498
|
-
if (isValidDate(day, month, year) && isValidTime(hour, minute, second)) {
|
|
499
|
-
let result = moment(
|
|
500
|
-
`${day}-${month}-${year} ${hour}:${minute}:${second}`,
|
|
501
|
-
"DD-MM-YYYY HH:mm:ss"
|
|
502
|
-
);
|
|
503
|
-
if (!result.isValid()) return null;
|
|
504
|
-
result = result.subtract(7, "hours");
|
|
505
|
-
return result.format(dateTimeFormat);
|
|
506
|
-
}
|
|
507
|
-
return null;
|
|
508
|
-
}
|
|
509
|
-
}
|
|
510
|
-
const len = cleanInput.length;
|
|
511
|
-
if (len === 1 || len === 2) {
|
|
512
|
-
const paddedDay = cleanInput.padStart(2, "0");
|
|
513
|
-
if (isValidDate(paddedDay, currentMonth, currentYear)) {
|
|
514
|
-
return formatOutput(paddedDay, currentMonth, currentYear);
|
|
515
|
-
}
|
|
516
|
-
return null;
|
|
517
|
-
}
|
|
518
|
-
if (len === 3) {
|
|
519
|
-
const day = cleanInput.slice(0, 2);
|
|
520
|
-
const month = cleanInput.slice(2, 3).padStart(2, "0");
|
|
521
|
-
if (isValidDate(day, month, currentYear)) {
|
|
522
|
-
return formatOutput(day, month, currentYear);
|
|
523
|
-
}
|
|
524
|
-
return null;
|
|
525
|
-
}
|
|
526
|
-
if (len === 6) {
|
|
527
|
-
const day = cleanInput.slice(0, 2);
|
|
528
|
-
const month = cleanInput.slice(2, 4);
|
|
529
|
-
let year = cleanInput.slice(4, 6);
|
|
530
|
-
year = `20${year}`;
|
|
531
|
-
if (parseInt(month) > 12) {
|
|
532
|
-
if (isValidDate(day, currentMonth, currentYear)) {
|
|
533
|
-
return formatOutput(day, currentMonth, currentYear);
|
|
534
|
-
}
|
|
535
|
-
return null;
|
|
536
|
-
}
|
|
537
|
-
if (isValidDate(day, month, year)) {
|
|
538
|
-
return formatOutput(day, month, year);
|
|
539
|
-
}
|
|
540
|
-
return null;
|
|
541
|
-
}
|
|
542
|
-
if (len === 7) {
|
|
543
|
-
return null;
|
|
544
|
-
}
|
|
545
|
-
if (len === 8) {
|
|
546
|
-
const day = cleanInput.slice(0, 2);
|
|
547
|
-
const month = cleanInput.slice(2, 4);
|
|
548
|
-
const year = cleanInput.slice(4, 8);
|
|
549
|
-
if (isValidDate(day, month, year)) {
|
|
550
|
-
return formatOutput(day, month, year);
|
|
551
|
-
}
|
|
552
|
-
return null;
|
|
553
|
-
}
|
|
554
|
-
if (len > 8 && !isDateTime) {
|
|
555
|
-
return null;
|
|
556
|
-
}
|
|
557
|
-
return null;
|
|
558
|
-
};
|
|
559
348
|
|
|
560
349
|
// src/utils.ts
|
|
561
350
|
__reExport(utils_exports, utils_star);
|
|
@@ -575,7 +364,7 @@ var useMenu = ({
|
|
|
575
364
|
const menuData = useGetMenu2(
|
|
576
365
|
context,
|
|
577
366
|
specification,
|
|
578
|
-
!!context && !isObjectEmpty(context) && !!context?.uid && !!context?.lang,
|
|
367
|
+
!!context && !(0, utils_exports.isObjectEmpty)(context) && !!context?.uid && !!context?.lang,
|
|
579
368
|
domain,
|
|
580
369
|
defaultService
|
|
581
370
|
);
|
|
@@ -657,7 +446,7 @@ var useProfile = ({ service }) => {
|
|
|
657
446
|
const userInfoQuery = useQuery2({
|
|
658
447
|
queryKey: ["userInfo"],
|
|
659
448
|
queryFn: () => getProfile.mutateAsync(),
|
|
660
|
-
enabled: isObjectEmpty(env?.user)
|
|
449
|
+
enabled: (0, utils_exports.isObjectEmpty)(env?.user)
|
|
661
450
|
});
|
|
662
451
|
useEffect3(() => {
|
|
663
452
|
if (userInfoQuery.data) {
|
|
@@ -808,10 +597,10 @@ var AppProvider = ({
|
|
|
808
597
|
const user = useUser({ service: env.default_service });
|
|
809
598
|
const company = useCompany({ service: env.default_service });
|
|
810
599
|
const menuContext = useMemo4(() => {
|
|
811
|
-
return
|
|
600
|
+
return combineContexts([
|
|
812
601
|
{
|
|
813
602
|
...user?.context,
|
|
814
|
-
...!isObjectEmpty(env?.user) ? { lang: env?.context?.lang } : {},
|
|
603
|
+
...!(0, utils_exports.isObjectEmpty)(env?.user) ? { lang: env?.context?.lang } : {},
|
|
815
604
|
...menuParams?.context ?? {}
|
|
816
605
|
}
|
|
817
606
|
]);
|
|
@@ -828,7 +617,7 @@ var AppProvider = ({
|
|
|
828
617
|
return menu?.state?.action;
|
|
829
618
|
}, [menu?.state?.action, env?.context?.lang]);
|
|
830
619
|
const viewContext = useMemo4(() => {
|
|
831
|
-
return
|
|
620
|
+
return combineContexts([
|
|
832
621
|
menuContext,
|
|
833
622
|
{ ...(0, utils_exports.evalJSONContext)(action?.context) }
|
|
834
623
|
]);
|
|
@@ -965,14 +754,46 @@ var useGetSpecification = ({
|
|
|
965
754
|
import { useMemo as useMemo6, useState as useState5 } from "react";
|
|
966
755
|
import {
|
|
967
756
|
evalJSONDomain,
|
|
968
|
-
formatSortingString
|
|
757
|
+
formatSortingString,
|
|
758
|
+
isObjectEmpty as isObjectEmpty4
|
|
969
759
|
} from "@fctc/interface-logic/utils";
|
|
970
760
|
|
|
761
|
+
// src/hooks/utils/use-click-outside.ts
|
|
762
|
+
import { useEffect as useEffect6, useRef } from "react";
|
|
763
|
+
var DEFAULT_EVENTS = ["mousedown", "touchstart"];
|
|
764
|
+
var useClickOutside = ({
|
|
765
|
+
handler,
|
|
766
|
+
events = DEFAULT_EVENTS,
|
|
767
|
+
nodes = [],
|
|
768
|
+
refs
|
|
769
|
+
}) => {
|
|
770
|
+
const ref = useRef(null);
|
|
771
|
+
useEffect6(() => {
|
|
772
|
+
const listener = (event) => {
|
|
773
|
+
const { target } = event;
|
|
774
|
+
if (refs && refs?.length > 0 && refs?.some((r) => r.current?.contains(target))) {
|
|
775
|
+
return;
|
|
776
|
+
}
|
|
777
|
+
if (!(target instanceof HTMLElement)) return;
|
|
778
|
+
const shouldIgnore = target.hasAttribute("data-ignore-outside-clicks") || !document.body.contains(target) && target.tagName !== "HTML";
|
|
779
|
+
const shouldTrigger = nodes.length > 0 ? nodes.every((node) => node && !event.composedPath().includes(node)) : ref.current && !ref.current.contains(target);
|
|
780
|
+
if (shouldTrigger && !shouldIgnore) {
|
|
781
|
+
handler(event);
|
|
782
|
+
}
|
|
783
|
+
};
|
|
784
|
+
events.forEach((event) => document.addEventListener(event, listener));
|
|
785
|
+
return () => {
|
|
786
|
+
events.forEach((event) => document.removeEventListener(event, listener));
|
|
787
|
+
};
|
|
788
|
+
}, [handler, nodes, events]);
|
|
789
|
+
return ref;
|
|
790
|
+
};
|
|
791
|
+
|
|
971
792
|
// src/hooks/utils/use-debounce.ts
|
|
972
|
-
import { useEffect as
|
|
793
|
+
import { useEffect as useEffect7, useState as useState3 } from "react";
|
|
973
794
|
function useDebounce(value, delay) {
|
|
974
795
|
const [debouncedValue, setDebouncedValue] = useState3(value);
|
|
975
|
-
|
|
796
|
+
useEffect7(() => {
|
|
976
797
|
const handler = setTimeout(() => {
|
|
977
798
|
setDebouncedValue(value);
|
|
978
799
|
}, delay);
|
|
@@ -984,7 +805,7 @@ function useDebounce(value, delay) {
|
|
|
984
805
|
}
|
|
985
806
|
|
|
986
807
|
// src/hooks/utils/use-get-rowids.ts
|
|
987
|
-
import { useCallback as useCallback3, useEffect as
|
|
808
|
+
import { useCallback as useCallback3, useEffect as useEffect8, useRef as useRef2, useState as useState4 } from "react";
|
|
988
809
|
var useGetRowIds = (tableRef) => {
|
|
989
810
|
function isElementVisible(el) {
|
|
990
811
|
const style = window.getComputedStyle(el);
|
|
@@ -1002,7 +823,7 @@ var useGetRowIds = (tableRef) => {
|
|
|
1002
823
|
return true;
|
|
1003
824
|
}
|
|
1004
825
|
const [rowIds, setRowIds] = useState4([]);
|
|
1005
|
-
const lastRowIdsRef =
|
|
826
|
+
const lastRowIdsRef = useRef2([]);
|
|
1006
827
|
const updateVisibleRowIds = useCallback3(() => {
|
|
1007
828
|
const table = tableRef.current;
|
|
1008
829
|
if (!table) return;
|
|
@@ -1021,7 +842,7 @@ var useGetRowIds = (tableRef) => {
|
|
|
1021
842
|
setRowIds(uniqueIds);
|
|
1022
843
|
}
|
|
1023
844
|
}, [tableRef]);
|
|
1024
|
-
|
|
845
|
+
useEffect8(() => {
|
|
1025
846
|
const table = tableRef.current;
|
|
1026
847
|
if (!table) return;
|
|
1027
848
|
const mutationObserver = new MutationObserver(() => {
|
|
@@ -1120,7 +941,7 @@ var useListData = ({
|
|
|
1120
941
|
listDataProps?.specification,
|
|
1121
942
|
listDataProps?.mode
|
|
1122
943
|
],
|
|
1123
|
-
!!listDataProps && !!specification && !
|
|
944
|
+
!!listDataProps && !!specification && !isObjectEmpty4(specification) && !!domain,
|
|
1124
945
|
service,
|
|
1125
946
|
xNode
|
|
1126
947
|
);
|
|
@@ -1152,6 +973,7 @@ export {
|
|
|
1152
973
|
useChangeOrderPreparationState,
|
|
1153
974
|
useChangeStatus,
|
|
1154
975
|
useCheckPayment,
|
|
976
|
+
useClickOutside,
|
|
1155
977
|
useCompany,
|
|
1156
978
|
useConfig,
|
|
1157
979
|
useCreateEntity,
|
|
@@ -1188,6 +1010,7 @@ export {
|
|
|
1188
1010
|
useGetFileExcel,
|
|
1189
1011
|
useGetFormView,
|
|
1190
1012
|
useGetGroups,
|
|
1013
|
+
useGetImage,
|
|
1191
1014
|
useGetList,
|
|
1192
1015
|
useGetListCompany,
|
|
1193
1016
|
useGetListData,
|
package/dist/icons.d.mts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
|
|
3
|
+
declare const EyeIcon: React.FC<React.SVGProps<SVGSVGElement>>;
|
|
4
|
+
|
|
5
|
+
declare const LoadingIcon: ({ width, height, ...props }: React.SVGProps<SVGSVGElement>) => react_jsx_runtime.JSX.Element;
|
|
6
|
+
|
|
7
|
+
declare const CloseIcon: ({ className }: {
|
|
8
|
+
className?: string;
|
|
9
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
10
|
+
|
|
11
|
+
declare const FilterIcon: ({ className }: {
|
|
12
|
+
className?: string;
|
|
13
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
14
|
+
|
|
15
|
+
declare const CheckIcon: () => react_jsx_runtime.JSX.Element;
|
|
16
|
+
|
|
17
|
+
declare const GroupByIcon: ({ className }: {
|
|
18
|
+
className?: string;
|
|
19
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
20
|
+
|
|
21
|
+
declare const SearchIcon: () => react_jsx_runtime.JSX.Element;
|
|
22
|
+
|
|
23
|
+
declare const ChevronBottomIcon: ({ className, }: {
|
|
24
|
+
className?: string;
|
|
25
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
26
|
+
|
|
27
|
+
export { CheckIcon, ChevronBottomIcon, CloseIcon, EyeIcon, FilterIcon, GroupByIcon, LoadingIcon, SearchIcon };
|
package/dist/icons.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
|
|
3
|
+
declare const EyeIcon: React.FC<React.SVGProps<SVGSVGElement>>;
|
|
4
|
+
|
|
5
|
+
declare const LoadingIcon: ({ width, height, ...props }: React.SVGProps<SVGSVGElement>) => react_jsx_runtime.JSX.Element;
|
|
6
|
+
|
|
7
|
+
declare const CloseIcon: ({ className }: {
|
|
8
|
+
className?: string;
|
|
9
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
10
|
+
|
|
11
|
+
declare const FilterIcon: ({ className }: {
|
|
12
|
+
className?: string;
|
|
13
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
14
|
+
|
|
15
|
+
declare const CheckIcon: () => react_jsx_runtime.JSX.Element;
|
|
16
|
+
|
|
17
|
+
declare const GroupByIcon: ({ className }: {
|
|
18
|
+
className?: string;
|
|
19
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
20
|
+
|
|
21
|
+
declare const SearchIcon: () => react_jsx_runtime.JSX.Element;
|
|
22
|
+
|
|
23
|
+
declare const ChevronBottomIcon: ({ className, }: {
|
|
24
|
+
className?: string;
|
|
25
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
26
|
+
|
|
27
|
+
export { CheckIcon, ChevronBottomIcon, CloseIcon, EyeIcon, FilterIcon, GroupByIcon, LoadingIcon, SearchIcon };
|