@fctc/widget-logic 5.3.0 → 5.3.3
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 +0 -1
- package/dist/config.d.ts +0 -1
- package/dist/hooks.d.mts +9 -16
- package/dist/hooks.d.ts +9 -16
- package/dist/hooks.js +354 -165
- package/dist/hooks.mjs +334 -155
- package/dist/index.d.mts +3 -5
- package/dist/index.d.ts +3 -5
- package/dist/index.js +537 -4694
- package/dist/index.mjs +433 -4609
- package/dist/utils.d.mts +5 -8
- package/dist/utils.d.ts +5 -8
- package/dist/utils.js +326 -104
- package/dist/utils.mjs +313 -101
- package/dist/widget.d.mts +0 -5
- package/dist/widget.d.ts +0 -5
- package/dist/widget.js +504 -4379
- package/dist/widget.mjs +407 -4300
- package/package.json +69 -92
- package/dist/icons.d.mts +0 -27
- package/dist/icons.d.ts +0 -27
- package/dist/icons.js +0 -273
- package/dist/icons.mjs +0 -239
- package/dist/store.d.mts +0 -1
- package/dist/store.d.ts +0 -1
- package/dist/store.js +0 -24
- package/dist/store.mjs +0 -2
package/dist/hooks.mjs
CHANGED
|
@@ -44,7 +44,6 @@ import {
|
|
|
44
44
|
useGetFileExcel,
|
|
45
45
|
useGetFormView,
|
|
46
46
|
useGetGroups,
|
|
47
|
-
useGetImage,
|
|
48
47
|
useGetListCompany,
|
|
49
48
|
useGetListData,
|
|
50
49
|
useGetListMyBankAccount,
|
|
@@ -172,14 +171,14 @@ var useCallAction = () => {
|
|
|
172
171
|
var utils_exports = {};
|
|
173
172
|
__export(utils_exports, {
|
|
174
173
|
STORAGES: () => STORAGES,
|
|
175
|
-
combineContexts: () => combineContexts,
|
|
176
|
-
convertFieldsToArray: () => convertFieldsToArray,
|
|
177
174
|
countSum: () => countSum,
|
|
178
|
-
|
|
175
|
+
guessTypeFromUrl: () => guessTypeFromUrl,
|
|
176
|
+
isObjectEmpty: () => isObjectEmpty,
|
|
179
177
|
languages: () => languages,
|
|
180
178
|
mergeButtons: () => mergeButtons,
|
|
181
179
|
setStorageItemAsync: () => setStorageItemAsync,
|
|
182
|
-
useStorageState: () => useStorageState
|
|
180
|
+
useStorageState: () => useStorageState,
|
|
181
|
+
validateAndParseDate: () => validateAndParseDate
|
|
183
182
|
});
|
|
184
183
|
|
|
185
184
|
// src/utils/constants.ts
|
|
@@ -197,6 +196,9 @@ var countSum = (data, field) => {
|
|
|
197
196
|
0
|
|
198
197
|
);
|
|
199
198
|
};
|
|
199
|
+
var isObjectEmpty = (obj) => {
|
|
200
|
+
return Object.keys(obj).length === 0;
|
|
201
|
+
};
|
|
200
202
|
function mergeButtons(fields) {
|
|
201
203
|
const buttons = fields?.filter((f) => f.type_co === "button");
|
|
202
204
|
const others = fields?.filter((f) => f.type_co !== "button");
|
|
@@ -208,103 +210,6 @@ function mergeButtons(fields) {
|
|
|
208
210
|
}
|
|
209
211
|
return others;
|
|
210
212
|
}
|
|
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
|
-
}
|
|
308
213
|
var STORAGES = {
|
|
309
214
|
TOKEN: "accessToken",
|
|
310
215
|
USER_INFO: "USER_INFO"
|
|
@@ -345,6 +250,312 @@ function useStorageState(key) {
|
|
|
345
250
|
);
|
|
346
251
|
return [state, setValue];
|
|
347
252
|
}
|
|
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
|
+
};
|
|
348
559
|
|
|
349
560
|
// src/utils.ts
|
|
350
561
|
__reExport(utils_exports, utils_star);
|
|
@@ -364,7 +575,7 @@ var useMenu = ({
|
|
|
364
575
|
const menuData = useGetMenu2(
|
|
365
576
|
context,
|
|
366
577
|
specification,
|
|
367
|
-
!!context && !
|
|
578
|
+
!!context && !isObjectEmpty(context) && !!context?.uid && !!context?.lang,
|
|
368
579
|
domain,
|
|
369
580
|
defaultService
|
|
370
581
|
);
|
|
@@ -437,16 +648,17 @@ var useDetail = (sub) => {
|
|
|
437
648
|
// src/hooks/core/use-profile.ts
|
|
438
649
|
import { useQuery as useQuery2 } from "@tanstack/react-query";
|
|
439
650
|
import { useEffect as useEffect3, useMemo } from "react";
|
|
440
|
-
|
|
441
|
-
|
|
651
|
+
var useProfile = ({
|
|
652
|
+
service,
|
|
653
|
+
i18n
|
|
654
|
+
}) => {
|
|
442
655
|
const { setUid, setLang, setUserInfo, env } = (0, provider_exports.useEnv)();
|
|
443
656
|
const { useGetProfile: useGetProfile2 } = (0, provider_exports.useService)();
|
|
444
657
|
const getProfile = useGetProfile2(service);
|
|
445
|
-
const { i18n } = useTranslation();
|
|
446
658
|
const userInfoQuery = useQuery2({
|
|
447
659
|
queryKey: ["userInfo"],
|
|
448
660
|
queryFn: () => getProfile.mutateAsync(),
|
|
449
|
-
enabled:
|
|
661
|
+
enabled: isObjectEmpty(env?.user)
|
|
450
662
|
});
|
|
451
663
|
useEffect3(() => {
|
|
452
664
|
if (userInfoQuery.data) {
|
|
@@ -479,8 +691,8 @@ var useProfile = ({ service }) => {
|
|
|
479
691
|
};
|
|
480
692
|
|
|
481
693
|
// src/hooks/core/use-user.ts
|
|
482
|
-
var useUser = ({ service }) => {
|
|
483
|
-
const userProfile = useProfile({ service });
|
|
694
|
+
var useUser = ({ service, i18n }) => {
|
|
695
|
+
const userProfile = useProfile({ service, i18n });
|
|
484
696
|
const userDetail = useDetail(userProfile?.data?.sub);
|
|
485
697
|
return { userProfile, userDetail, context: userProfile?.context };
|
|
486
698
|
};
|
|
@@ -591,16 +803,17 @@ var ReactContext = createContext(AppProviderInitialValue);
|
|
|
591
803
|
var AppProvider = ({
|
|
592
804
|
children,
|
|
593
805
|
menuParams,
|
|
594
|
-
aid
|
|
806
|
+
aid,
|
|
807
|
+
i18n
|
|
595
808
|
}) => {
|
|
596
809
|
const { env } = (0, provider_exports.useEnv)();
|
|
597
|
-
const user = useUser({ service: env.default_service });
|
|
810
|
+
const user = useUser({ service: env.default_service, i18n });
|
|
598
811
|
const company = useCompany({ service: env.default_service });
|
|
599
812
|
const menuContext = useMemo4(() => {
|
|
600
|
-
return combineContexts([
|
|
813
|
+
return (0, utils_exports.combineContexts)([
|
|
601
814
|
{
|
|
602
815
|
...user?.context,
|
|
603
|
-
...!
|
|
816
|
+
...!isObjectEmpty(env?.user) ? { lang: env?.context?.lang } : {},
|
|
604
817
|
...menuParams?.context ?? {}
|
|
605
818
|
}
|
|
606
819
|
]);
|
|
@@ -617,7 +830,7 @@ var AppProvider = ({
|
|
|
617
830
|
return menu?.state?.action;
|
|
618
831
|
}, [menu?.state?.action, env?.context?.lang]);
|
|
619
832
|
const viewContext = useMemo4(() => {
|
|
620
|
-
return combineContexts([
|
|
833
|
+
return (0, utils_exports.combineContexts)([
|
|
621
834
|
menuContext,
|
|
622
835
|
{ ...(0, utils_exports.evalJSONContext)(action?.context) }
|
|
623
836
|
]);
|
|
@@ -754,46 +967,14 @@ var useGetSpecification = ({
|
|
|
754
967
|
import { useMemo as useMemo6, useState as useState5 } from "react";
|
|
755
968
|
import {
|
|
756
969
|
evalJSONDomain,
|
|
757
|
-
formatSortingString
|
|
758
|
-
isObjectEmpty as isObjectEmpty4
|
|
970
|
+
formatSortingString
|
|
759
971
|
} from "@fctc/interface-logic/utils";
|
|
760
972
|
|
|
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
|
-
|
|
792
973
|
// src/hooks/utils/use-debounce.ts
|
|
793
|
-
import { useEffect as
|
|
974
|
+
import { useEffect as useEffect6, useState as useState3 } from "react";
|
|
794
975
|
function useDebounce(value, delay) {
|
|
795
976
|
const [debouncedValue, setDebouncedValue] = useState3(value);
|
|
796
|
-
|
|
977
|
+
useEffect6(() => {
|
|
797
978
|
const handler = setTimeout(() => {
|
|
798
979
|
setDebouncedValue(value);
|
|
799
980
|
}, delay);
|
|
@@ -805,7 +986,7 @@ function useDebounce(value, delay) {
|
|
|
805
986
|
}
|
|
806
987
|
|
|
807
988
|
// src/hooks/utils/use-get-rowids.ts
|
|
808
|
-
import { useCallback as useCallback3, useEffect as
|
|
989
|
+
import { useCallback as useCallback3, useEffect as useEffect7, useRef, useState as useState4 } from "react";
|
|
809
990
|
var useGetRowIds = (tableRef) => {
|
|
810
991
|
function isElementVisible(el) {
|
|
811
992
|
const style = window.getComputedStyle(el);
|
|
@@ -823,7 +1004,7 @@ var useGetRowIds = (tableRef) => {
|
|
|
823
1004
|
return true;
|
|
824
1005
|
}
|
|
825
1006
|
const [rowIds, setRowIds] = useState4([]);
|
|
826
|
-
const lastRowIdsRef =
|
|
1007
|
+
const lastRowIdsRef = useRef([]);
|
|
827
1008
|
const updateVisibleRowIds = useCallback3(() => {
|
|
828
1009
|
const table = tableRef.current;
|
|
829
1010
|
if (!table) return;
|
|
@@ -842,7 +1023,7 @@ var useGetRowIds = (tableRef) => {
|
|
|
842
1023
|
setRowIds(uniqueIds);
|
|
843
1024
|
}
|
|
844
1025
|
}, [tableRef]);
|
|
845
|
-
|
|
1026
|
+
useEffect7(() => {
|
|
846
1027
|
const table = tableRef.current;
|
|
847
1028
|
if (!table) return;
|
|
848
1029
|
const mutationObserver = new MutationObserver(() => {
|
|
@@ -941,7 +1122,7 @@ var useListData = ({
|
|
|
941
1122
|
listDataProps?.specification,
|
|
942
1123
|
listDataProps?.mode
|
|
943
1124
|
],
|
|
944
|
-
!!listDataProps && !!specification && !
|
|
1125
|
+
!!listDataProps && !!specification && !isObjectEmpty(specification) && !!domain,
|
|
945
1126
|
service,
|
|
946
1127
|
xNode
|
|
947
1128
|
);
|
|
@@ -973,7 +1154,6 @@ export {
|
|
|
973
1154
|
useChangeOrderPreparationState,
|
|
974
1155
|
useChangeStatus,
|
|
975
1156
|
useCheckPayment,
|
|
976
|
-
useClickOutside,
|
|
977
1157
|
useCompany,
|
|
978
1158
|
useConfig,
|
|
979
1159
|
useCreateEntity,
|
|
@@ -1010,7 +1190,6 @@ export {
|
|
|
1010
1190
|
useGetFileExcel,
|
|
1011
1191
|
useGetFormView,
|
|
1012
1192
|
useGetGroups,
|
|
1013
|
-
useGetImage,
|
|
1014
1193
|
useGetList,
|
|
1015
1194
|
useGetListCompany,
|
|
1016
1195
|
useGetListData,
|
package/dist/index.d.mts
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
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,
|
|
2
|
-
export { ActionResultType, AppProvider, CompanyTuple, ContextProfile, CurrentCompany, RecordMenu, UseMenuReturn, ViewResponse, useAppProvider, useCallAction, useCallActionType,
|
|
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
|
+
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 { CheckIcon, ChevronBottomIcon, CloseIcon, EyeIcon, FilterIcon, GroupByIcon, LoadingIcon, SearchIcon } from './icons.mjs';
|
|
5
4
|
export { ISelctionStateProps, ITableHeadProps, ITableProps, binaryFieldController, colorFieldController, copyLinkButtonController, dateFieldController, downLoadBinaryController, downloadFileController, durationController, many2manyBinaryController, many2manyFieldController, many2manyTagsController, many2oneButtonController, many2oneFieldController, priorityFieldController, searchController, statusDropdownController, tableController, tableGroupController, tableHeadController } from './widget.mjs';
|
|
6
5
|
export * from '@fctc/interface-logic/types';
|
|
7
6
|
export { IInputFieldProps, ValuePropsType } from './types.mjs';
|
|
8
|
-
export { STORAGES,
|
|
7
|
+
export { STORAGES, countSum, guessTypeFromUrl, isObjectEmpty, languages, mergeButtons, setStorageItemAsync, useStorageState, validateAndParseDate } from './utils.mjs';
|
|
9
8
|
export * from '@fctc/interface-logic/utils';
|
|
10
|
-
export * from '@fctc/interface-logic/store';
|
|
11
9
|
export * from '@fctc/interface-logic/constants';
|
|
12
10
|
export * from '@fctc/interface-logic/environment';
|
|
13
11
|
export * from '@fctc/interface-logic/provider';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
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,
|
|
2
|
-
export { ActionResultType, AppProvider, CompanyTuple, ContextProfile, CurrentCompany, RecordMenu, UseMenuReturn, ViewResponse, useAppProvider, useCallAction, useCallActionType,
|
|
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
|
+
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.js';
|
|
3
3
|
export * from '@fctc/interface-logic/configs';
|
|
4
|
-
export { CheckIcon, ChevronBottomIcon, CloseIcon, EyeIcon, FilterIcon, GroupByIcon, LoadingIcon, SearchIcon } from './icons.js';
|
|
5
4
|
export { ISelctionStateProps, ITableHeadProps, ITableProps, binaryFieldController, colorFieldController, copyLinkButtonController, dateFieldController, downLoadBinaryController, downloadFileController, durationController, many2manyBinaryController, many2manyFieldController, many2manyTagsController, many2oneButtonController, many2oneFieldController, priorityFieldController, searchController, statusDropdownController, tableController, tableGroupController, tableHeadController } from './widget.js';
|
|
6
5
|
export * from '@fctc/interface-logic/types';
|
|
7
6
|
export { IInputFieldProps, ValuePropsType } from './types.js';
|
|
8
|
-
export { STORAGES,
|
|
7
|
+
export { STORAGES, countSum, guessTypeFromUrl, isObjectEmpty, languages, mergeButtons, setStorageItemAsync, useStorageState, validateAndParseDate } from './utils.js';
|
|
9
8
|
export * from '@fctc/interface-logic/utils';
|
|
10
|
-
export * from '@fctc/interface-logic/store';
|
|
11
9
|
export * from '@fctc/interface-logic/constants';
|
|
12
10
|
export * from '@fctc/interface-logic/environment';
|
|
13
11
|
export * from '@fctc/interface-logic/provider';
|