@fctc/widget-logic 5.3.7-beta.15 → 5.3.7-beta.17
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/hooks.js +3 -299
- package/dist/hooks.mjs +3 -292
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +88 -370
- package/dist/index.mjs +91 -366
- package/dist/types.d.mts +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/utils.d.mts +1 -3
- package/dist/utils.d.ts +1 -3
- package/dist/utils.js +1 -297
- package/dist/utils.mjs +1 -286
- package/dist/widget.d.mts +26 -22
- package/dist/widget.d.ts +26 -22
- package/dist/widget.js +170 -446
- package/dist/widget.mjs +160 -428
- package/package.json +1 -1
package/dist/hooks.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -18,14 +16,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
20
18
|
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
21
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
-
mod
|
|
28
|
-
));
|
|
29
19
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
20
|
|
|
31
21
|
// src/hooks.ts
|
|
@@ -206,8 +196,7 @@ __export(utils_exports, {
|
|
|
206
196
|
languages: () => languages,
|
|
207
197
|
mergeButtons: () => mergeButtons,
|
|
208
198
|
setStorageItemAsync: () => setStorageItemAsync,
|
|
209
|
-
useStorageState: () => useStorageState
|
|
210
|
-
validateAndParseDate: () => validateAndParseDate
|
|
199
|
+
useStorageState: () => useStorageState
|
|
211
200
|
});
|
|
212
201
|
|
|
213
202
|
// src/utils/constants.ts
|
|
@@ -302,290 +291,6 @@ var guessTypeFromUrl = (url) => {
|
|
|
302
291
|
return map[ext] || null;
|
|
303
292
|
};
|
|
304
293
|
|
|
305
|
-
// src/utils/format-date.ts
|
|
306
|
-
var import_moment = __toESM(require("moment"));
|
|
307
|
-
var validateAndParseDate = (input, isDateTime = false) => {
|
|
308
|
-
if (!input || typeof input !== "string") return null;
|
|
309
|
-
const cleanInput = input.replace(/[^0-9-\/:\s]/g, "");
|
|
310
|
-
const dateFormat = "YYYY-MM-DD";
|
|
311
|
-
const dateTimeFormat = "YYYY-MM-DD HH:mm:ss";
|
|
312
|
-
const currentDay = (0, import_moment.default)().format("DD");
|
|
313
|
-
const currentMonth = (0, import_moment.default)().format("MM");
|
|
314
|
-
const currentYear = (0, import_moment.default)().format("YYYY");
|
|
315
|
-
const defaultTime = "00:00:00";
|
|
316
|
-
const maxYear = parseInt(currentYear) + 10;
|
|
317
|
-
const isValidDate = (day, month, year) => {
|
|
318
|
-
const date = (0, import_moment.default)(`${day}-${month}-${year}`, "DD-MM-YYYY", true);
|
|
319
|
-
return date.isValid();
|
|
320
|
-
};
|
|
321
|
-
const isValidTime = (hour, minute = "00", second = "00") => {
|
|
322
|
-
const h = parseInt(hour, 10);
|
|
323
|
-
const m = parseInt(minute, 10);
|
|
324
|
-
const s = parseInt(second, 10);
|
|
325
|
-
return h >= 0 && h <= 23 && m >= 0 && m <= 59 && s >= 0 && s <= 59;
|
|
326
|
-
};
|
|
327
|
-
const formatOutput = (day, month, year, time = defaultTime) => {
|
|
328
|
-
let result = (0, import_moment.default)(
|
|
329
|
-
`${day}-${month}-${year} ${time}`,
|
|
330
|
-
"DD-MM-YYYY HH:mm:ss"
|
|
331
|
-
);
|
|
332
|
-
if (!result.isValid()) return null;
|
|
333
|
-
if (isDateTime) {
|
|
334
|
-
result = result.subtract(7, "hours");
|
|
335
|
-
return result.format(dateTimeFormat);
|
|
336
|
-
}
|
|
337
|
-
return result.format(dateFormat);
|
|
338
|
-
};
|
|
339
|
-
if (isDateTime && input.match(
|
|
340
|
-
/^\d{1,2}[\/-]\d{1,2}[\/-]\d{2,4}\s+\d{1,2}(:\d{1,2}(:\d{1,2})?)?$/
|
|
341
|
-
)) {
|
|
342
|
-
const [datePart, timePart] = input.split(/\s+/);
|
|
343
|
-
const dateParts = datePart.split(/[\/-]/);
|
|
344
|
-
const timeParts = timePart.split(":");
|
|
345
|
-
const day = dateParts[0].padStart(2, "0");
|
|
346
|
-
const month = dateParts[1].padStart(2, "0");
|
|
347
|
-
const year = dateParts[2].length <= 2 ? `20${dateParts[2].padStart(2, "0")}` : dateParts[2].padStart(4, "0");
|
|
348
|
-
const hour = timeParts[0].padStart(2, "0");
|
|
349
|
-
const minute = timeParts[1] ? timeParts[1].padStart(2, "0") : "00";
|
|
350
|
-
const second = timeParts[2] ? timeParts[2].padStart(2, "0") : "00";
|
|
351
|
-
if (isValidDate(day, month, year) && isValidTime(hour, minute, second)) {
|
|
352
|
-
let result = (0, import_moment.default)(
|
|
353
|
-
`${day}-${month}-${year} ${hour}:${minute}:${second}`,
|
|
354
|
-
"DD-MM-YYYY HH:mm:ss"
|
|
355
|
-
);
|
|
356
|
-
if (!result.isValid()) return null;
|
|
357
|
-
result = result.subtract(7, "hours");
|
|
358
|
-
return result.format(dateTimeFormat);
|
|
359
|
-
}
|
|
360
|
-
return null;
|
|
361
|
-
}
|
|
362
|
-
if (cleanInput.match(/^\d{4}-\d{2}-\d{2}$/)) {
|
|
363
|
-
const [year, month, day] = cleanInput.split("-");
|
|
364
|
-
if (isValidDate(day, month, year)) {
|
|
365
|
-
return formatOutput(day, month, year);
|
|
366
|
-
}
|
|
367
|
-
return null;
|
|
368
|
-
}
|
|
369
|
-
if (cleanInput.match(/^\d{1,2}\/\d{1,2}\/\d{2,4}$/)) {
|
|
370
|
-
const [day, month, year] = cleanInput.split("/");
|
|
371
|
-
const paddedDay = day.padStart(2, "0");
|
|
372
|
-
const paddedMonth = month.padStart(2, "0");
|
|
373
|
-
const fullYear = year.length <= 2 ? `20${year.padStart(2, "0")}` : year.padStart(4, "0");
|
|
374
|
-
if (isValidDate(paddedDay, paddedMonth, fullYear)) {
|
|
375
|
-
return formatOutput(paddedDay, paddedMonth, fullYear);
|
|
376
|
-
}
|
|
377
|
-
return null;
|
|
378
|
-
}
|
|
379
|
-
if (cleanInput.match(/^\d{1,2}-\d{1,2}-\d{2,4}$/)) {
|
|
380
|
-
const [day, month, year] = cleanInput.split("-");
|
|
381
|
-
const paddedDay = day.padStart(2, "0");
|
|
382
|
-
const paddedMonth = month.padStart(2, "0");
|
|
383
|
-
const fullYear = year.length <= 2 ? `20${year.padStart(2, "0")}` : year.padStart(4, "0");
|
|
384
|
-
if (isValidDate(paddedDay, paddedMonth, fullYear)) {
|
|
385
|
-
return formatOutput(paddedDay, paddedMonth, fullYear);
|
|
386
|
-
}
|
|
387
|
-
return null;
|
|
388
|
-
}
|
|
389
|
-
if (cleanInput.match(/^\d{1,2}[\/-]\d{1,2}$/)) {
|
|
390
|
-
const [day, month] = cleanInput.split(/[\/-]/);
|
|
391
|
-
const paddedDay = day.padStart(2, "0");
|
|
392
|
-
const paddedMonth = month.padStart(2, "0");
|
|
393
|
-
if (isValidDate(paddedDay, paddedMonth, currentYear)) {
|
|
394
|
-
return formatOutput(paddedDay, paddedMonth, currentYear);
|
|
395
|
-
}
|
|
396
|
-
return null;
|
|
397
|
-
}
|
|
398
|
-
if (cleanInput.match(/^\d{4}$/)) {
|
|
399
|
-
const num = parseInt(cleanInput, 10);
|
|
400
|
-
if (num >= 2e3 && num <= maxYear) {
|
|
401
|
-
if (isValidDate(currentDay, currentMonth, num.toString())) {
|
|
402
|
-
return formatOutput(currentDay, currentMonth, num.toString());
|
|
403
|
-
}
|
|
404
|
-
return null;
|
|
405
|
-
}
|
|
406
|
-
const day = cleanInput.slice(0, 2);
|
|
407
|
-
const month = cleanInput.slice(2, 4);
|
|
408
|
-
if (isValidDate(day, month, currentYear)) {
|
|
409
|
-
return formatOutput(day, month, currentYear);
|
|
410
|
-
}
|
|
411
|
-
return null;
|
|
412
|
-
}
|
|
413
|
-
if (cleanInput.startsWith("-") && /^\-\d+$/.test(cleanInput)) {
|
|
414
|
-
const daysToSubtract = Math.abs(parseInt(cleanInput, 10));
|
|
415
|
-
let result = (0, import_moment.default)().subtract(daysToSubtract, "days");
|
|
416
|
-
if (isDateTime) {
|
|
417
|
-
result = result.subtract(7, "hours");
|
|
418
|
-
}
|
|
419
|
-
if (result.isValid()) {
|
|
420
|
-
return isDateTime ? result.format(dateTimeFormat) : result.format(dateFormat);
|
|
421
|
-
}
|
|
422
|
-
return null;
|
|
423
|
-
}
|
|
424
|
-
if (input.match(/^\d{1,2}[^0-9-\/]+\d{1,2}[^0-9-\/]+\d{2,4}.*$/)) {
|
|
425
|
-
const parts = input.split(/[^0-9-\/]+/).filter(Boolean);
|
|
426
|
-
const day = parts[0].padStart(2, "0");
|
|
427
|
-
const month = parts[1].padStart(2, "0");
|
|
428
|
-
let year = parts[2];
|
|
429
|
-
year = year.length === 2 ? `20${year}` : year.padStart(4, "0");
|
|
430
|
-
if (isValidDate(day, month, year)) {
|
|
431
|
-
return formatOutput(day, month, year);
|
|
432
|
-
}
|
|
433
|
-
return null;
|
|
434
|
-
}
|
|
435
|
-
if (isDateTime) {
|
|
436
|
-
if (cleanInput.length === 9) {
|
|
437
|
-
const day = cleanInput.slice(0, 2);
|
|
438
|
-
const month = cleanInput.slice(2, 4);
|
|
439
|
-
const year = cleanInput.slice(4, 8);
|
|
440
|
-
const hour = cleanInput.slice(8, 9).padStart(2, "0");
|
|
441
|
-
if (isValidDate(day, month, year) && isValidTime(hour)) {
|
|
442
|
-
let result = (0, import_moment.default)(
|
|
443
|
-
`${day}-${month}-${year} ${hour}:00:00`,
|
|
444
|
-
"DD-MM-YYYY HH:mm:ss"
|
|
445
|
-
);
|
|
446
|
-
if (!result.isValid()) return null;
|
|
447
|
-
result = result.subtract(7, "hours");
|
|
448
|
-
return result.format(dateTimeFormat);
|
|
449
|
-
}
|
|
450
|
-
return null;
|
|
451
|
-
}
|
|
452
|
-
if (cleanInput.length === 10) {
|
|
453
|
-
const day = cleanInput.slice(0, 2);
|
|
454
|
-
const month = cleanInput.slice(2, 4);
|
|
455
|
-
const year = cleanInput.slice(4, 8);
|
|
456
|
-
const hour = cleanInput.slice(8, 10);
|
|
457
|
-
if (isValidDate(day, month, year) && isValidTime(hour)) {
|
|
458
|
-
let result = (0, import_moment.default)(
|
|
459
|
-
`${day}-${month}-${year} ${hour}:00:00`,
|
|
460
|
-
"DD-MM-YYYY HH:mm:ss"
|
|
461
|
-
);
|
|
462
|
-
if (!result.isValid()) return null;
|
|
463
|
-
result = result.subtract(7, "hours");
|
|
464
|
-
return result.format(dateTimeFormat);
|
|
465
|
-
}
|
|
466
|
-
return null;
|
|
467
|
-
}
|
|
468
|
-
if (cleanInput.length === 11) {
|
|
469
|
-
const day = cleanInput.slice(0, 2);
|
|
470
|
-
const month = cleanInput.slice(2, 4);
|
|
471
|
-
const year = cleanInput.slice(4, 8);
|
|
472
|
-
const hour = cleanInput.slice(8, 10);
|
|
473
|
-
const minute = cleanInput.slice(10, 11).padStart(2, "0");
|
|
474
|
-
if (isValidDate(day, month, year) && isValidTime(hour, minute)) {
|
|
475
|
-
let result = (0, import_moment.default)(
|
|
476
|
-
`${day}-${month}-${year} ${hour}:${minute}:00`,
|
|
477
|
-
"DD-MM-YYYY HH:mm:ss"
|
|
478
|
-
);
|
|
479
|
-
if (!result.isValid()) return null;
|
|
480
|
-
result = result.subtract(7, "hours");
|
|
481
|
-
return result.format(dateTimeFormat);
|
|
482
|
-
}
|
|
483
|
-
return null;
|
|
484
|
-
}
|
|
485
|
-
if (cleanInput.length === 12) {
|
|
486
|
-
const day = cleanInput.slice(0, 2);
|
|
487
|
-
const month = cleanInput.slice(2, 4);
|
|
488
|
-
const year = cleanInput.slice(4, 8);
|
|
489
|
-
const hour = cleanInput.slice(8, 10);
|
|
490
|
-
const minute = cleanInput.slice(10, 12);
|
|
491
|
-
if (isValidDate(day, month, year) && isValidTime(hour, minute)) {
|
|
492
|
-
let result = (0, import_moment.default)(
|
|
493
|
-
`${day}-${month}-${year} ${hour}:${minute}:00`,
|
|
494
|
-
"DD-MM-YYYY HH:mm:ss"
|
|
495
|
-
);
|
|
496
|
-
if (!result.isValid()) return null;
|
|
497
|
-
result = result.subtract(7, "hours");
|
|
498
|
-
return result.format(dateTimeFormat);
|
|
499
|
-
}
|
|
500
|
-
return null;
|
|
501
|
-
}
|
|
502
|
-
if (cleanInput.length === 13) {
|
|
503
|
-
const day = cleanInput.slice(0, 2);
|
|
504
|
-
const month = cleanInput.slice(2, 4);
|
|
505
|
-
const year = cleanInput.slice(4, 8);
|
|
506
|
-
const hour = cleanInput.slice(8, 10);
|
|
507
|
-
const minute = cleanInput.slice(10, 12);
|
|
508
|
-
const second = cleanInput.slice(12, 13).padStart(2, "0");
|
|
509
|
-
if (isValidDate(day, month, year) && isValidTime(hour, minute, second)) {
|
|
510
|
-
let result = (0, import_moment.default)(
|
|
511
|
-
`${day}-${month}-${year} ${hour}:${minute}:${second}`,
|
|
512
|
-
"DD-MM-YYYY HH:mm:ss"
|
|
513
|
-
);
|
|
514
|
-
if (!result.isValid()) return null;
|
|
515
|
-
result = result.subtract(7, "hours");
|
|
516
|
-
return result.format(dateTimeFormat);
|
|
517
|
-
}
|
|
518
|
-
return null;
|
|
519
|
-
}
|
|
520
|
-
if (cleanInput.length === 14) {
|
|
521
|
-
const day = cleanInput.slice(0, 2);
|
|
522
|
-
const month = cleanInput.slice(2, 4);
|
|
523
|
-
const year = cleanInput.slice(4, 8);
|
|
524
|
-
const hour = cleanInput.slice(8, 10);
|
|
525
|
-
const minute = cleanInput.slice(10, 12);
|
|
526
|
-
const second = cleanInput.slice(12, 14);
|
|
527
|
-
if (isValidDate(day, month, year) && isValidTime(hour, minute, second)) {
|
|
528
|
-
let result = (0, import_moment.default)(
|
|
529
|
-
`${day}-${month}-${year} ${hour}:${minute}:${second}`,
|
|
530
|
-
"DD-MM-YYYY HH:mm:ss"
|
|
531
|
-
);
|
|
532
|
-
if (!result.isValid()) return null;
|
|
533
|
-
result = result.subtract(7, "hours");
|
|
534
|
-
return result.format(dateTimeFormat);
|
|
535
|
-
}
|
|
536
|
-
return null;
|
|
537
|
-
}
|
|
538
|
-
}
|
|
539
|
-
const len = cleanInput.length;
|
|
540
|
-
if (len === 1 || len === 2) {
|
|
541
|
-
const paddedDay = cleanInput.padStart(2, "0");
|
|
542
|
-
if (isValidDate(paddedDay, currentMonth, currentYear)) {
|
|
543
|
-
return formatOutput(paddedDay, currentMonth, currentYear);
|
|
544
|
-
}
|
|
545
|
-
return null;
|
|
546
|
-
}
|
|
547
|
-
if (len === 3) {
|
|
548
|
-
const day = cleanInput.slice(0, 2);
|
|
549
|
-
const month = cleanInput.slice(2, 3).padStart(2, "0");
|
|
550
|
-
if (isValidDate(day, month, currentYear)) {
|
|
551
|
-
return formatOutput(day, month, currentYear);
|
|
552
|
-
}
|
|
553
|
-
return null;
|
|
554
|
-
}
|
|
555
|
-
if (len === 6) {
|
|
556
|
-
const day = cleanInput.slice(0, 2);
|
|
557
|
-
const month = cleanInput.slice(2, 4);
|
|
558
|
-
let year = cleanInput.slice(4, 6);
|
|
559
|
-
year = `20${year}`;
|
|
560
|
-
if (parseInt(month) > 12) {
|
|
561
|
-
if (isValidDate(day, currentMonth, currentYear)) {
|
|
562
|
-
return formatOutput(day, currentMonth, currentYear);
|
|
563
|
-
}
|
|
564
|
-
return null;
|
|
565
|
-
}
|
|
566
|
-
if (isValidDate(day, month, year)) {
|
|
567
|
-
return formatOutput(day, month, year);
|
|
568
|
-
}
|
|
569
|
-
return null;
|
|
570
|
-
}
|
|
571
|
-
if (len === 7) {
|
|
572
|
-
return null;
|
|
573
|
-
}
|
|
574
|
-
if (len === 8) {
|
|
575
|
-
const day = cleanInput.slice(0, 2);
|
|
576
|
-
const month = cleanInput.slice(2, 4);
|
|
577
|
-
const year = cleanInput.slice(4, 8);
|
|
578
|
-
if (isValidDate(day, month, year)) {
|
|
579
|
-
return formatOutput(day, month, year);
|
|
580
|
-
}
|
|
581
|
-
return null;
|
|
582
|
-
}
|
|
583
|
-
if (len > 8 && !isDateTime) {
|
|
584
|
-
return null;
|
|
585
|
-
}
|
|
586
|
-
return null;
|
|
587
|
-
};
|
|
588
|
-
|
|
589
294
|
// src/utils.ts
|
|
590
295
|
__reExport(utils_exports, require("@fctc/interface-logic/utils"));
|
|
591
296
|
|
|
@@ -993,7 +698,6 @@ var useGetSpecification = ({
|
|
|
993
698
|
|
|
994
699
|
// src/hooks/core/use-list-data.ts
|
|
995
700
|
var import_react13 = require("react");
|
|
996
|
-
var import_utils5 = require("@fctc/interface-logic/utils");
|
|
997
701
|
|
|
998
702
|
// src/hooks/utils/use-debounce.ts
|
|
999
703
|
var import_react11 = require("react");
|
|
@@ -1105,12 +809,12 @@ var useListData = ({
|
|
|
1105
809
|
if (!viewData || !action || !context) {
|
|
1106
810
|
return null;
|
|
1107
811
|
}
|
|
1108
|
-
const domainParse = domain ? [...domain] : action?.domain ? Array.isArray(action?.domain) ? [...action?.domain] : (0,
|
|
812
|
+
const domainParse = domain ? [...domain] : action?.domain ? Array.isArray(action?.domain) ? [...action?.domain] : (0, utils_exports.evalJSONDomain)(action?.domain, context) : [];
|
|
1109
813
|
const limit2 = pageLimit;
|
|
1110
814
|
const offset = debouncedPage * pageLimit;
|
|
1111
815
|
const fields = typeof groupByList === "object" ? groupByList?.fields : void 0;
|
|
1112
816
|
const groupby = typeof groupByList === "object" ? [groupByList?.contexts?.[0]?.group_by] : [];
|
|
1113
|
-
const sort = order ?? (0,
|
|
817
|
+
const sort = order ?? (0, utils_exports.formatSortingString)(
|
|
1114
818
|
(mode === "kanban" ? viewData?.views?.kanban : viewData?.views?.list)?.default_order
|
|
1115
819
|
) ?? "";
|
|
1116
820
|
return {
|
package/dist/hooks.mjs
CHANGED
|
@@ -177,8 +177,7 @@ __export(utils_exports, {
|
|
|
177
177
|
languages: () => languages,
|
|
178
178
|
mergeButtons: () => mergeButtons,
|
|
179
179
|
setStorageItemAsync: () => setStorageItemAsync,
|
|
180
|
-
useStorageState: () => useStorageState
|
|
181
|
-
validateAndParseDate: () => validateAndParseDate
|
|
180
|
+
useStorageState: () => useStorageState
|
|
182
181
|
});
|
|
183
182
|
|
|
184
183
|
// src/utils/constants.ts
|
|
@@ -273,290 +272,6 @@ var guessTypeFromUrl = (url) => {
|
|
|
273
272
|
return map[ext] || null;
|
|
274
273
|
};
|
|
275
274
|
|
|
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
|
-
|
|
560
275
|
// src/utils.ts
|
|
561
276
|
__reExport(utils_exports, utils_star);
|
|
562
277
|
import * as utils_star from "@fctc/interface-logic/utils";
|
|
@@ -965,10 +680,6 @@ var useGetSpecification = ({
|
|
|
965
680
|
|
|
966
681
|
// src/hooks/core/use-list-data.ts
|
|
967
682
|
import { useMemo as useMemo6, useState as useState5 } from "react";
|
|
968
|
-
import {
|
|
969
|
-
evalJSONDomain,
|
|
970
|
-
formatSortingString
|
|
971
|
-
} from "@fctc/interface-logic/utils";
|
|
972
683
|
|
|
973
684
|
// src/hooks/utils/use-debounce.ts
|
|
974
685
|
import { useEffect as useEffect6, useState as useState3 } from "react";
|
|
@@ -1080,12 +791,12 @@ var useListData = ({
|
|
|
1080
791
|
if (!viewData || !action || !context) {
|
|
1081
792
|
return null;
|
|
1082
793
|
}
|
|
1083
|
-
const domainParse = domain ? [...domain] : action?.domain ? Array.isArray(action?.domain) ? [...action?.domain] : evalJSONDomain(action?.domain, context) : [];
|
|
794
|
+
const domainParse = domain ? [...domain] : action?.domain ? Array.isArray(action?.domain) ? [...action?.domain] : (0, utils_exports.evalJSONDomain)(action?.domain, context) : [];
|
|
1084
795
|
const limit2 = pageLimit;
|
|
1085
796
|
const offset = debouncedPage * pageLimit;
|
|
1086
797
|
const fields = typeof groupByList === "object" ? groupByList?.fields : void 0;
|
|
1087
798
|
const groupby = typeof groupByList === "object" ? [groupByList?.contexts?.[0]?.group_by] : [];
|
|
1088
|
-
const sort = order ?? formatSortingString(
|
|
799
|
+
const sort = order ?? (0, utils_exports.formatSortingString)(
|
|
1089
800
|
(mode === "kanban" ? viewData?.views?.kanban : viewData?.views?.list)?.default_order
|
|
1090
801
|
) ?? "";
|
|
1091
802
|
return {
|
package/dist/index.d.mts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export { useAddEntity, useButton, useChangeOrderPreparationState, useChangeStatus, useCheckPayment, useCreateEntity, useCreatePosConfig, useCreateSession, useDelete, useDeleteComment, useDeleteEntity, useDuplicateRecord, useExecuteImport, useExportExcel, useForgotPassword, useForgotPasswordSSO, useGenSerialNumber, useGeneratePaymentQrInfo, useGet2FAMethods, useGetASession, useGetAccessByCode, useGetActionDetail, useGetAll, useGetCalendar, useGetComment, useGetCompanyInfo, useGetConversionRate, useGetCurrency, useGetCurrentCompany, useGetDetail, useGetExternalTabs, useGetFieldExport, useGetFieldOnChange, useGetFileExcel, useGetFormView, useGetGroups, useGetList, useGetListCompany, useGetListData, useGetListMyBankAccount, useGetMenu, useGetOrderLine, useGetPinCode, useGetPrintReport, useGetProGressBar, useGetProfile, useGetProvider, useGetResequence, useGetSelection, useGetUser, useGetView, useGrantAccess, useIsValidToken, useLoadAction, useLoadMessage, useLoginCredential, useLoginSocial, useLogout, useModel, useOdooDataTransform, useOnChangeForm, useParsePreview, usePrint, useReadGroup, useRemoveRow, useRemoveTotpSetup, useRequestSetupTotp, useResetPassword, useResetPasswordSSO, useRunAction, useSave, useSendComment, useSettingsWebRead2fa, useSignInSSO, useSwitchLocale, useUpdatePassword, useUploadFile, useUploadFileExcel, useUploadIdFile, useUploadImage, useValidateActionToken, useVerify2FA, useVerifyTotp } from '@fctc/interface-logic/hooks';
|
|
2
2
|
export { ActionResultType, AppProvider, CompanyTuple, ContextProfile, CurrentCompany, RecordMenu, UseMenuReturn, ViewResponse, useAppProvider, useCallAction, useCallActionType, useCompany, useCompanyType, useConfig, useConfigType, useDebounce, useDetail, useGetAction, useGetRowIds, useGetSpecification, useListData, useListDataType, useMenu, useMenuType, useProfile, useUser, useUserType, useViewV2, useViewV2Type } from './hooks.mjs';
|
|
3
3
|
export * from '@fctc/interface-logic/configs';
|
|
4
|
-
export { ISelctionStateProps, ITableHeadProps, ITableProps, binaryFieldController, colorFieldController, copyLinkButtonController, downLoadBinaryController, downloadFileController, durationController, many2manyBinaryController, many2manyFieldController, many2manyTagsController, many2oneButtonController, many2oneFieldController, priorityFieldController, providerEinvoiceFieldController, searchController, statusDropdownController, tableController, tableGroupController, tableHeadController } from './widget.mjs';
|
|
4
|
+
export { ISearchFieldProps, ISelctionStateProps, ITableHeadProps, ITableProps, binaryFieldController, colorFieldController, copyLinkButtonController, downLoadBinaryController, downloadFileController, durationController, many2manyBinaryController, many2manyFieldController, many2manyTagsController, many2oneButtonController, many2oneFieldController, priorityFieldController, providerEinvoiceFieldController, searchController, statusDropdownController, tableController, tableGroupController, tableHeadController } from './widget.mjs';
|
|
5
5
|
export * from '@fctc/interface-logic/types';
|
|
6
6
|
export { IInputFieldProps, ValuePropsType } from './types.mjs';
|
|
7
|
-
export { STORAGES, countSum, guessTypeFromUrl, isObjectEmpty, languages, mergeButtons, setStorageItemAsync, useStorageState
|
|
7
|
+
export { STORAGES, countSum, guessTypeFromUrl, isObjectEmpty, languages, mergeButtons, setStorageItemAsync, useStorageState } from './utils.mjs';
|
|
8
8
|
export * from '@fctc/interface-logic/utils';
|
|
9
9
|
export * from '@fctc/interface-logic/constants';
|
|
10
10
|
export * from '@fctc/interface-logic/environment';
|