@fctc/widget-logic 5.3.1 → 5.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/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
  );
@@ -685,7 +465,7 @@ var useProfile = ({ service }) => {
685
465
  const userInfoQuery = (0, import_react_query2.useQuery)({
686
466
  queryKey: ["userInfo"],
687
467
  queryFn: () => getProfile.mutateAsync(),
688
- enabled: isObjectEmpty(env?.user)
468
+ enabled: (0, utils_exports.isObjectEmpty)(env?.user)
689
469
  });
690
470
  (0, import_react5.useEffect)(() => {
691
471
  if (userInfoQuery.data) {
@@ -836,10 +616,10 @@ var AppProvider = ({
836
616
  const user = useUser({ service: env.default_service });
837
617
  const company = useCompany({ service: env.default_service });
838
618
  const menuContext = (0, import_react8.useMemo)(() => {
839
- return (0, utils_exports.combineContexts)([
619
+ return combineContexts([
840
620
  {
841
621
  ...user?.context,
842
- ...!isObjectEmpty(env?.user) ? { lang: env?.context?.lang } : {},
622
+ ...!(0, utils_exports.isObjectEmpty)(env?.user) ? { lang: env?.context?.lang } : {},
843
623
  ...menuParams?.context ?? {}
844
624
  }
845
625
  ]);
@@ -856,7 +636,7 @@ var AppProvider = ({
856
636
  return menu?.state?.action;
857
637
  }, [menu?.state?.action, env?.context?.lang]);
858
638
  const viewContext = (0, import_react8.useMemo)(() => {
859
- return (0, utils_exports.combineContexts)([
639
+ return combineContexts([
860
640
  menuContext,
861
641
  { ...(0, utils_exports.evalJSONContext)(action?.context) }
862
642
  ]);
@@ -990,14 +770,45 @@ var useGetSpecification = ({
990
770
  };
991
771
 
992
772
  // src/hooks/core/use-list-data.ts
993
- var import_react13 = require("react");
773
+ var import_react14 = require("react");
994
774
  var import_utils5 = require("@fctc/interface-logic/utils");
995
775
 
996
- // src/hooks/utils/use-debounce.ts
776
+ // src/hooks/utils/use-click-outside.ts
997
777
  var import_react11 = require("react");
998
- function useDebounce(value, delay) {
999
- 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);
1000
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)(() => {
1001
812
  const handler = setTimeout(() => {
1002
813
  setDebouncedValue(value);
1003
814
  }, delay);
@@ -1009,7 +820,7 @@ function useDebounce(value, delay) {
1009
820
  }
1010
821
 
1011
822
  // src/hooks/utils/use-get-rowids.ts
1012
- var import_react12 = require("react");
823
+ var import_react13 = require("react");
1013
824
  var useGetRowIds = (tableRef) => {
1014
825
  function isElementVisible(el) {
1015
826
  const style = window.getComputedStyle(el);
@@ -1026,9 +837,9 @@ var useGetRowIds = (tableRef) => {
1026
837
  }
1027
838
  return true;
1028
839
  }
1029
- const [rowIds, setRowIds] = (0, import_react12.useState)([]);
1030
- const lastRowIdsRef = (0, import_react12.useRef)([]);
1031
- 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)(() => {
1032
843
  const table = tableRef.current;
1033
844
  if (!table) return;
1034
845
  const rows = table.querySelectorAll("tr[data-row-id]");
@@ -1046,7 +857,7 @@ var useGetRowIds = (tableRef) => {
1046
857
  setRowIds(uniqueIds);
1047
858
  }
1048
859
  }, [tableRef]);
1049
- (0, import_react12.useEffect)(() => {
860
+ (0, import_react13.useEffect)(() => {
1050
861
  const table = tableRef.current;
1051
862
  if (!table) return;
1052
863
  const mutationObserver = new MutationObserver(() => {
@@ -1086,12 +897,12 @@ var useListData = ({
1086
897
  limit = 10
1087
898
  }) => {
1088
899
  const { useGetListData: useGetListData2 } = (0, provider_exports.useService)();
1089
- const [page, setPage] = (0, import_react13.useState)(0);
1090
- const [pageLimit, setPageLimit] = (0, import_react13.useState)(limit);
1091
- const [groupByList, setGroupByList] = (0, import_react13.useState)(null);
1092
- const [domain, setDomain] = (0, import_react13.useState)(null);
1093
- const [order, setOrder] = (0, import_react13.useState)("");
1094
- 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)([]);
1095
906
  const [debouncedPage] = useDebounce(page, 500);
1096
907
  const [debouncedDomain] = useDebounce(domain, 500);
1097
908
  const { specification } = useGetSpecification({
@@ -1099,7 +910,7 @@ var useListData = ({
1099
910
  viewData,
1100
911
  fields: mode === "kanban" ? viewData?.views?.kanban?.fields : viewData?.views?.list?.fields
1101
912
  });
1102
- const listDataProps = (0, import_react13.useMemo)(() => {
913
+ const listDataProps = (0, import_react14.useMemo)(() => {
1103
914
  if (!viewData || !action || !context) {
1104
915
  return null;
1105
916
  }
@@ -1145,7 +956,7 @@ var useListData = ({
1145
956
  listDataProps?.specification,
1146
957
  listDataProps?.mode
1147
958
  ],
1148
- !!listDataProps && !!specification && !isObjectEmpty(specification) && !!domain,
959
+ !!listDataProps && !!specification && !(0, import_utils5.isObjectEmpty)(specification) && !!domain,
1149
960
  service,
1150
961
  xNode
1151
962
  );
@@ -1178,6 +989,7 @@ var useListData = ({
1178
989
  useChangeOrderPreparationState,
1179
990
  useChangeStatus,
1180
991
  useCheckPayment,
992
+ useClickOutside,
1181
993
  useCompany,
1182
994
  useConfig,
1183
995
  useCreateEntity,
@@ -1214,6 +1026,7 @@ var useListData = ({
1214
1026
  useGetFileExcel,
1215
1027
  useGetFormView,
1216
1028
  useGetGroups,
1029
+ useGetImage,
1217
1030
  useGetList,
1218
1031
  useGetListCompany,
1219
1032
  useGetListData,