@fctc/widget-logic 5.3.3 → 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/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
@@ -39,6 +29,7 @@ __export(hooks_exports, {
39
29
  useChangeOrderPreparationState: () => import_hooks2.useChangeOrderPreparationState,
40
30
  useChangeStatus: () => import_hooks2.useChangeStatus,
41
31
  useCheckPayment: () => import_hooks2.useCheckPayment,
32
+ useClickOutside: () => useClickOutside,
42
33
  useCompany: () => useCompany,
43
34
  useConfig: () => useConfig,
44
35
  useCreateEntity: () => import_hooks2.useCreateEntity,
@@ -75,6 +66,7 @@ __export(hooks_exports, {
75
66
  useGetFileExcel: () => import_hooks2.useGetFileExcel,
76
67
  useGetFormView: () => import_hooks2.useGetFormView,
77
68
  useGetGroups: () => import_hooks2.useGetGroups,
69
+ useGetImage: () => import_hooks2.useGetImage,
78
70
  useGetList: () => import_hooks2.useGetList,
79
71
  useGetListCompany: () => import_hooks2.useGetListCompany,
80
72
  useGetListData: () => import_hooks2.useGetListData,
@@ -200,14 +192,14 @@ var useCallAction = () => {
200
192
  var utils_exports = {};
201
193
  __export(utils_exports, {
202
194
  STORAGES: () => STORAGES,
195
+ combineContexts: () => combineContexts,
196
+ convertFieldsToArray: () => convertFieldsToArray,
203
197
  countSum: () => countSum,
204
- guessTypeFromUrl: () => guessTypeFromUrl,
205
- isObjectEmpty: () => isObjectEmpty,
198
+ getDateRange: () => getDateRange,
206
199
  languages: () => languages,
207
200
  mergeButtons: () => mergeButtons,
208
201
  setStorageItemAsync: () => setStorageItemAsync,
209
- useStorageState: () => useStorageState,
210
- validateAndParseDate: () => validateAndParseDate
202
+ useStorageState: () => useStorageState
211
203
  });
212
204
 
213
205
  // src/utils/constants.ts
@@ -225,9 +217,6 @@ var countSum = (data, field) => {
225
217
  0
226
218
  );
227
219
  };
228
- var isObjectEmpty = (obj) => {
229
- return Object.keys(obj).length === 0;
230
- };
231
220
  function mergeButtons(fields) {
232
221
  const buttons = fields?.filter((f) => f.type_co === "button");
233
222
  const others = fields?.filter((f) => f.type_co !== "button");
@@ -239,6 +228,103 @@ function mergeButtons(fields) {
239
228
  }
240
229
  return others;
241
230
  }
231
+ var getDateRange = (currentDate, unit) => {
232
+ const date = new Date(currentDate);
233
+ let dateStart, dateEnd;
234
+ function formatDate(d) {
235
+ 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");
236
+ }
237
+ switch (unit) {
238
+ case "month":
239
+ dateStart = new Date(
240
+ date.getFullYear(),
241
+ date.getMonth() + 1,
242
+ date.getDate(),
243
+ 23,
244
+ 59,
245
+ 59
246
+ );
247
+ dateStart.setHours(dateStart.getHours() - 7);
248
+ dateEnd = new Date(date.getFullYear(), date.getMonth(), 0, 0, 0, 0);
249
+ dateEnd.setHours(dateEnd.getHours() - 7);
250
+ break;
251
+ case "day":
252
+ dateStart = new Date(
253
+ date.getFullYear(),
254
+ date.getMonth(),
255
+ date.getDate(),
256
+ 23,
257
+ 59,
258
+ 59
259
+ );
260
+ dateStart.setHours(dateStart.getHours() - 7);
261
+ dateEnd = new Date(
262
+ date.getFullYear(),
263
+ date.getMonth(),
264
+ date.getDate(),
265
+ 0,
266
+ 0,
267
+ 0
268
+ );
269
+ dateEnd.setHours(dateEnd.getHours() - 7);
270
+ break;
271
+ case "week":
272
+ const dayOfWeek = date.getDay();
273
+ const daysToMonday = dayOfWeek === 0 ? -6 : 1 - dayOfWeek;
274
+ const daysToSunday = dayOfWeek === 0 ? 0 : 7 - dayOfWeek;
275
+ dateStart = new Date(
276
+ date.getFullYear(),
277
+ date.getMonth(),
278
+ date.getDate() + daysToSunday,
279
+ 23,
280
+ 59,
281
+ 59
282
+ );
283
+ dateStart.setHours(dateStart.getHours() - 7);
284
+ dateEnd = new Date(
285
+ date.getFullYear(),
286
+ date.getMonth(),
287
+ date.getDate() + daysToMonday,
288
+ 0,
289
+ 0,
290
+ 0
291
+ );
292
+ dateEnd.setHours(dateEnd.getHours() - 7);
293
+ break;
294
+ case "year":
295
+ dateStart = new Date(date.getFullYear(), 11, 31, 23, 59, 59);
296
+ dateStart.setHours(dateStart.getHours() - 7);
297
+ dateEnd = new Date(date.getFullYear() - 1, 11, 31, 0, 0, 0);
298
+ dateEnd.setHours(dateEnd.getHours() - 7);
299
+ break;
300
+ default:
301
+ throw new Error(
302
+ "\u0110\u01A1n v\u1ECB kh\xF4ng h\u1EE3p l\u1EC7. Ch\u1EC9 ch\u1EA5p nh\u1EADn: week, day, month, year"
303
+ );
304
+ }
305
+ return [
306
+ ["date_start", "<=", formatDate(dateStart)],
307
+ ["date_end", ">=", formatDate(dateEnd)]
308
+ ];
309
+ };
310
+ var convertFieldsToArray = (fields) => {
311
+ const defaultFields = ["display_name", "date_start", "date_end"];
312
+ if (!fields || !Array.isArray(fields)) {
313
+ return defaultFields;
314
+ }
315
+ const inputFields = fields.filter((field) => field && field.type_co === "field").map((field) => field.name);
316
+ return [...defaultFields, ...inputFields];
317
+ };
318
+ function combineContexts(contexts) {
319
+ if (contexts.some((context) => !context)) {
320
+ return void 0;
321
+ } else {
322
+ const res = contexts.reduce((acc, context) => {
323
+ return { ...acc, ...context };
324
+ }, {});
325
+ return res;
326
+ }
327
+ }
242
328
  var STORAGES = {
243
329
  TOKEN: "accessToken",
244
330
  USER_INFO: "USER_INFO"
@@ -279,312 +365,6 @@ function useStorageState(key) {
279
365
  );
280
366
  return [state, setValue];
281
367
  }
282
- var guessTypeFromUrl = (url) => {
283
- const ext = url.split(".").pop()?.toLowerCase();
284
- if (!ext) return null;
285
- const map = {
286
- jpg: "image/jpeg",
287
- jpeg: "image/jpeg",
288
- png: "image/png",
289
- webp: "image/webp",
290
- gif: "image/gif",
291
- svg: "image/svg+xml",
292
- bmp: "image/bmp",
293
- tiff: "image/tiff",
294
- pdf: "application/pdf",
295
- zip: "application/zip",
296
- rar: "application/x-rar-compressed",
297
- xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
298
- xls: "application/vnd.ms-excel",
299
- mp4: "video/mp4",
300
- mov: "video/quicktime"
301
- };
302
- return map[ext] || null;
303
- };
304
-
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
368
 
589
369
  // src/utils.ts
590
370
  __reExport(utils_exports, require("@fctc/interface-logic/utils"));
@@ -603,7 +383,7 @@ var useMenu = ({
603
383
  const menuData = useGetMenu2(
604
384
  context,
605
385
  specification,
606
- !!context && !isObjectEmpty(context) && !!context?.uid && !!context?.lang,
386
+ !!context && !(0, utils_exports.isObjectEmpty)(context) && !!context?.uid && !!context?.lang,
607
387
  domain,
608
388
  defaultService
609
389
  );
@@ -676,17 +456,16 @@ var useDetail = (sub) => {
676
456
  // src/hooks/core/use-profile.ts
677
457
  var import_react_query2 = require("@tanstack/react-query");
678
458
  var import_react5 = require("react");
679
- var useProfile = ({
680
- service,
681
- i18n
682
- }) => {
459
+ var import_react_i18next = require("react-i18next");
460
+ var useProfile = ({ service }) => {
683
461
  const { setUid, setLang, setUserInfo, env } = (0, provider_exports.useEnv)();
684
462
  const { useGetProfile: useGetProfile2 } = (0, provider_exports.useService)();
685
463
  const getProfile = useGetProfile2(service);
464
+ const { i18n } = (0, import_react_i18next.useTranslation)();
686
465
  const userInfoQuery = (0, import_react_query2.useQuery)({
687
466
  queryKey: ["userInfo"],
688
467
  queryFn: () => getProfile.mutateAsync(),
689
- enabled: isObjectEmpty(env?.user)
468
+ enabled: (0, utils_exports.isObjectEmpty)(env?.user)
690
469
  });
691
470
  (0, import_react5.useEffect)(() => {
692
471
  if (userInfoQuery.data) {
@@ -719,8 +498,8 @@ var useProfile = ({
719
498
  };
720
499
 
721
500
  // src/hooks/core/use-user.ts
722
- var useUser = ({ service, i18n }) => {
723
- const userProfile = useProfile({ service, i18n });
501
+ var useUser = ({ service }) => {
502
+ const userProfile = useProfile({ service });
724
503
  const userDetail = useDetail(userProfile?.data?.sub);
725
504
  return { userProfile, userDetail, context: userProfile?.context };
726
505
  };
@@ -831,17 +610,16 @@ var ReactContext = (0, import_react8.createContext)(AppProviderInitialValue);
831
610
  var AppProvider = ({
832
611
  children,
833
612
  menuParams,
834
- aid,
835
- i18n
613
+ aid
836
614
  }) => {
837
615
  const { env } = (0, provider_exports.useEnv)();
838
- const user = useUser({ service: env.default_service, i18n });
616
+ const user = useUser({ service: env.default_service });
839
617
  const company = useCompany({ service: env.default_service });
840
618
  const menuContext = (0, import_react8.useMemo)(() => {
841
- return (0, utils_exports.combineContexts)([
619
+ return combineContexts([
842
620
  {
843
621
  ...user?.context,
844
- ...!isObjectEmpty(env?.user) ? { lang: env?.context?.lang } : {},
622
+ ...!(0, utils_exports.isObjectEmpty)(env?.user) ? { lang: env?.context?.lang } : {},
845
623
  ...menuParams?.context ?? {}
846
624
  }
847
625
  ]);
@@ -858,7 +636,7 @@ var AppProvider = ({
858
636
  return menu?.state?.action;
859
637
  }, [menu?.state?.action, env?.context?.lang]);
860
638
  const viewContext = (0, import_react8.useMemo)(() => {
861
- return (0, utils_exports.combineContexts)([
639
+ return combineContexts([
862
640
  menuContext,
863
641
  { ...(0, utils_exports.evalJSONContext)(action?.context) }
864
642
  ]);
@@ -992,14 +770,45 @@ var useGetSpecification = ({
992
770
  };
993
771
 
994
772
  // src/hooks/core/use-list-data.ts
995
- var import_react13 = require("react");
773
+ var import_react14 = require("react");
996
774
  var import_utils5 = require("@fctc/interface-logic/utils");
997
775
 
998
- // src/hooks/utils/use-debounce.ts
776
+ // src/hooks/utils/use-click-outside.ts
999
777
  var import_react11 = require("react");
1000
- function useDebounce(value, delay) {
1001
- const [debouncedValue, setDebouncedValue] = (0, import_react11.useState)(value);
778
+ var DEFAULT_EVENTS = ["mousedown", "touchstart"];
779
+ var useClickOutside = ({
780
+ handler,
781
+ events = DEFAULT_EVENTS,
782
+ nodes = [],
783
+ refs
784
+ }) => {
785
+ const ref = (0, import_react11.useRef)(null);
1002
786
  (0, import_react11.useEffect)(() => {
787
+ const listener = (event) => {
788
+ const { target } = event;
789
+ if (refs && refs?.length > 0 && refs?.some((r) => r.current?.contains(target))) {
790
+ return;
791
+ }
792
+ if (!(target instanceof HTMLElement)) return;
793
+ const shouldIgnore = target.hasAttribute("data-ignore-outside-clicks") || !document.body.contains(target) && target.tagName !== "HTML";
794
+ const shouldTrigger = nodes.length > 0 ? nodes.every((node) => node && !event.composedPath().includes(node)) : ref.current && !ref.current.contains(target);
795
+ if (shouldTrigger && !shouldIgnore) {
796
+ handler(event);
797
+ }
798
+ };
799
+ events.forEach((event) => document.addEventListener(event, listener));
800
+ return () => {
801
+ events.forEach((event) => document.removeEventListener(event, listener));
802
+ };
803
+ }, [handler, nodes, events]);
804
+ return ref;
805
+ };
806
+
807
+ // src/hooks/utils/use-debounce.ts
808
+ var import_react12 = require("react");
809
+ function useDebounce(value, delay) {
810
+ const [debouncedValue, setDebouncedValue] = (0, import_react12.useState)(value);
811
+ (0, import_react12.useEffect)(() => {
1003
812
  const handler = setTimeout(() => {
1004
813
  setDebouncedValue(value);
1005
814
  }, delay);
@@ -1011,7 +820,7 @@ function useDebounce(value, delay) {
1011
820
  }
1012
821
 
1013
822
  // src/hooks/utils/use-get-rowids.ts
1014
- var import_react12 = require("react");
823
+ var import_react13 = require("react");
1015
824
  var useGetRowIds = (tableRef) => {
1016
825
  function isElementVisible(el) {
1017
826
  const style = window.getComputedStyle(el);
@@ -1028,9 +837,9 @@ var useGetRowIds = (tableRef) => {
1028
837
  }
1029
838
  return true;
1030
839
  }
1031
- const [rowIds, setRowIds] = (0, import_react12.useState)([]);
1032
- const lastRowIdsRef = (0, import_react12.useRef)([]);
1033
- const updateVisibleRowIds = (0, import_react12.useCallback)(() => {
840
+ const [rowIds, setRowIds] = (0, import_react13.useState)([]);
841
+ const lastRowIdsRef = (0, import_react13.useRef)([]);
842
+ const updateVisibleRowIds = (0, import_react13.useCallback)(() => {
1034
843
  const table = tableRef.current;
1035
844
  if (!table) return;
1036
845
  const rows = table.querySelectorAll("tr[data-row-id]");
@@ -1048,7 +857,7 @@ var useGetRowIds = (tableRef) => {
1048
857
  setRowIds(uniqueIds);
1049
858
  }
1050
859
  }, [tableRef]);
1051
- (0, import_react12.useEffect)(() => {
860
+ (0, import_react13.useEffect)(() => {
1052
861
  const table = tableRef.current;
1053
862
  if (!table) return;
1054
863
  const mutationObserver = new MutationObserver(() => {
@@ -1088,12 +897,12 @@ var useListData = ({
1088
897
  limit = 10
1089
898
  }) => {
1090
899
  const { useGetListData: useGetListData2 } = (0, provider_exports.useService)();
1091
- const [page, setPage] = (0, import_react13.useState)(0);
1092
- const [pageLimit, setPageLimit] = (0, import_react13.useState)(limit);
1093
- const [groupByList, setGroupByList] = (0, import_react13.useState)(null);
1094
- const [domain, setDomain] = (0, import_react13.useState)(null);
1095
- const [order, setOrder] = (0, import_react13.useState)("");
1096
- const [selectedRowKeys, setSelectedRowKeys] = (0, import_react13.useState)([]);
900
+ const [page, setPage] = (0, import_react14.useState)(0);
901
+ const [pageLimit, setPageLimit] = (0, import_react14.useState)(limit);
902
+ const [groupByList, setGroupByList] = (0, import_react14.useState)(null);
903
+ const [domain, setDomain] = (0, import_react14.useState)(null);
904
+ const [order, setOrder] = (0, import_react14.useState)("");
905
+ const [selectedRowKeys, setSelectedRowKeys] = (0, import_react14.useState)([]);
1097
906
  const [debouncedPage] = useDebounce(page, 500);
1098
907
  const [debouncedDomain] = useDebounce(domain, 500);
1099
908
  const { specification } = useGetSpecification({
@@ -1101,7 +910,7 @@ var useListData = ({
1101
910
  viewData,
1102
911
  fields: mode === "kanban" ? viewData?.views?.kanban?.fields : viewData?.views?.list?.fields
1103
912
  });
1104
- const listDataProps = (0, import_react13.useMemo)(() => {
913
+ const listDataProps = (0, import_react14.useMemo)(() => {
1105
914
  if (!viewData || !action || !context) {
1106
915
  return null;
1107
916
  }
@@ -1147,7 +956,7 @@ var useListData = ({
1147
956
  listDataProps?.specification,
1148
957
  listDataProps?.mode
1149
958
  ],
1150
- !!listDataProps && !!specification && !isObjectEmpty(specification) && !!domain,
959
+ !!listDataProps && !!specification && !(0, import_utils5.isObjectEmpty)(specification) && !!domain,
1151
960
  service,
1152
961
  xNode
1153
962
  );
@@ -1180,6 +989,7 @@ var useListData = ({
1180
989
  useChangeOrderPreparationState,
1181
990
  useChangeStatus,
1182
991
  useCheckPayment,
992
+ useClickOutside,
1183
993
  useCompany,
1184
994
  useConfig,
1185
995
  useCreateEntity,
@@ -1216,6 +1026,7 @@ var useListData = ({
1216
1026
  useGetFileExcel,
1217
1027
  useGetFormView,
1218
1028
  useGetGroups,
1029
+ useGetImage,
1219
1030
  useGetList,
1220
1031
  useGetListCompany,
1221
1032
  useGetListData,