persian-data-grid 0.5.0 → 0.7.0
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/OFL.txt +93 -0
- package/README.md +179 -22
- package/dist/ERPTableGroupRow-E5Q6FYDS.js +125 -0
- package/dist/ERPTableGroupRow-E5Q6FYDS.js.map +1 -0
- package/dist/ERPTableGroupRow-F2IPDYL5.cjs +131 -0
- package/dist/ERPTableGroupRow-F2IPDYL5.cjs.map +1 -0
- package/dist/GridPlugin-Bewn0X51.d.ts +57 -0
- package/dist/GridPlugin-DewWufGZ.d.cts +57 -0
- package/dist/GridPresenceService-GEH6535Q.js +3 -0
- package/dist/GridPresenceService-GEH6535Q.js.map +1 -0
- package/dist/GridPresenceService-RDN5FXHQ.cjs +12 -0
- package/dist/GridPresenceService-RDN5FXHQ.cjs.map +1 -0
- package/dist/GridSession-CeIfVFck.d.ts +2625 -0
- package/dist/GridSession-CmQn2RnL.d.cts +2625 -0
- package/dist/GridSyncService-3JQLEY65.cjs +12 -0
- package/dist/GridSyncService-3JQLEY65.cjs.map +1 -0
- package/dist/GridSyncService-GECXGEKL.js +3 -0
- package/dist/GridSyncService-GECXGEKL.js.map +1 -0
- package/dist/PdfRenderer-B9FJaCo_.d.cts +22 -0
- package/dist/PdfRenderer-bN7ca_Aj.d.ts +22 -0
- package/dist/RemoteApi-CCQxiSf1.d.cts +28 -0
- package/dist/RemoteApi-CCQxiSf1.d.ts +28 -0
- package/dist/SelectImpl-NM4O4IGW.js +447 -0
- package/dist/SelectImpl-NM4O4IGW.js.map +1 -0
- package/dist/SelectImpl-W2EI4T7O.cjs +453 -0
- package/dist/SelectImpl-W2EI4T7O.cjs.map +1 -0
- package/dist/UITableController-C71LXBiX.d.ts +678 -0
- package/dist/UITableController-CIwnHIw8.d.cts +678 -0
- package/dist/VazirmatnPdfRenderer-CpCqA-Wh.d.cts +96 -0
- package/dist/VazirmatnPdfRenderer-D46smncn.d.ts +96 -0
- package/dist/adapters/arian-erp.cjs +89 -0
- package/dist/adapters/arian-erp.cjs.map +1 -0
- package/dist/adapters/arian-erp.d.cts +62 -0
- package/dist/adapters/arian-erp.d.ts +62 -0
- package/dist/adapters/arian-erp.js +79 -0
- package/dist/adapters/arian-erp.js.map +1 -0
- package/dist/appendAtEnd-RHIQRG2W.cjs +35 -0
- package/dist/appendAtEnd-RHIQRG2W.cjs.map +1 -0
- package/dist/appendAtEnd-TJEABLGD.js +33 -0
- package/dist/appendAtEnd-TJEABLGD.js.map +1 -0
- package/dist/applyImportedRows-C2fWYoPy.d.cts +135 -0
- package/dist/applyImportedRows-Cqh_N_0k.d.ts +135 -0
- package/dist/applyRowVisibilityHandler-Q64ZFC7A.cjs +86 -0
- package/dist/applyRowVisibilityHandler-Q64ZFC7A.cjs.map +1 -0
- package/dist/applyRowVisibilityHandler-ZLZXQEGY.js +84 -0
- package/dist/applyRowVisibilityHandler-ZLZXQEGY.js.map +1 -0
- package/dist/broadcastChannelTransport-FHUMV76O.cjs +12 -0
- package/dist/broadcastChannelTransport-FHUMV76O.cjs.map +1 -0
- package/dist/broadcastChannelTransport-MIH53VNZ.js +3 -0
- package/dist/broadcastChannelTransport-MIH53VNZ.js.map +1 -0
- package/dist/callbackRemoteApi-BYLjmSI6.d.ts +51 -0
- package/dist/callbackRemoteApi-Cv26MmSD.d.cts +51 -0
- package/dist/cellRenderContext-BaNh4qn_.d.ts +42 -0
- package/dist/cellRenderContext-DvngkptV.d.cts +42 -0
- package/dist/chunk-27ALJSZP.js +12187 -0
- package/dist/chunk-27ALJSZP.js.map +1 -0
- package/dist/chunk-3HP3HQCW.cjs +688 -0
- package/dist/chunk-3HP3HQCW.cjs.map +1 -0
- package/dist/chunk-3Y3KKGEC.js +3 -0
- package/dist/chunk-3Y3KKGEC.js.map +1 -0
- package/dist/chunk-52LFOPXD.cjs +588 -0
- package/dist/chunk-52LFOPXD.cjs.map +1 -0
- package/dist/chunk-5ALMNLUR.cjs +1408 -0
- package/dist/chunk-5ALMNLUR.cjs.map +1 -0
- package/dist/chunk-5HKVMPBD.js +937 -0
- package/dist/chunk-5HKVMPBD.js.map +1 -0
- package/dist/chunk-72IVAOTK.cjs +38 -0
- package/dist/chunk-72IVAOTK.cjs.map +1 -0
- package/dist/chunk-77UXAJII.js +112 -0
- package/dist/chunk-77UXAJII.js.map +1 -0
- package/dist/chunk-7GWV5HGO.js +36 -0
- package/dist/chunk-7GWV5HGO.js.map +1 -0
- package/dist/chunk-7T6AWRPU.js +581 -0
- package/dist/chunk-7T6AWRPU.js.map +1 -0
- package/dist/chunk-AU3RDJYQ.js +243 -0
- package/dist/chunk-AU3RDJYQ.js.map +1 -0
- package/dist/chunk-CILNIWYW.cjs +100 -0
- package/dist/chunk-CILNIWYW.cjs.map +1 -0
- package/dist/chunk-CMQ4VLCW.cjs +840 -0
- package/dist/chunk-CMQ4VLCW.cjs.map +1 -0
- package/dist/chunk-DFFP7SJ6.cjs +257 -0
- package/dist/chunk-DFFP7SJ6.cjs.map +1 -0
- package/dist/chunk-E2J533UH.cjs +53 -0
- package/dist/chunk-E2J533UH.cjs.map +1 -0
- package/dist/chunk-EBV6HGZB.cjs +33 -0
- package/dist/chunk-EBV6HGZB.cjs.map +1 -0
- package/dist/chunk-F4PYOYHR.js +112 -0
- package/dist/chunk-F4PYOYHR.js.map +1 -0
- package/dist/chunk-F6EMC75A.cjs +34 -0
- package/dist/chunk-F6EMC75A.cjs.map +1 -0
- package/dist/chunk-GKE33FOJ.js +32 -0
- package/dist/chunk-GKE33FOJ.js.map +1 -0
- package/dist/chunk-GQEDLUMB.js +168 -0
- package/dist/chunk-GQEDLUMB.js.map +1 -0
- package/dist/chunk-HLOHWFOA.js +645 -0
- package/dist/chunk-HLOHWFOA.js.map +1 -0
- package/dist/chunk-IMPCRWYP.cjs +251 -0
- package/dist/chunk-IMPCRWYP.cjs.map +1 -0
- package/dist/chunk-IPPIXOVQ.js +317 -0
- package/dist/chunk-IPPIXOVQ.js.map +1 -0
- package/dist/chunk-J4XJ4UBC.js +1404 -0
- package/dist/chunk-J4XJ4UBC.js.map +1 -0
- package/dist/chunk-J7CPPFXT.cjs +89 -0
- package/dist/chunk-J7CPPFXT.cjs.map +1 -0
- package/dist/chunk-JOICD47Q.cjs +41 -0
- package/dist/chunk-JOICD47Q.cjs.map +1 -0
- package/dist/chunk-KCNTKYUY.js +206 -0
- package/dist/chunk-KCNTKYUY.js.map +1 -0
- package/dist/chunk-KHMG6EI2.js +13 -0
- package/dist/chunk-KHMG6EI2.js.map +1 -0
- package/dist/chunk-KMRURD5J.cjs +15 -0
- package/dist/chunk-KMRURD5J.cjs.map +1 -0
- package/dist/chunk-KRJG3KMP.cjs +174 -0
- package/dist/chunk-KRJG3KMP.cjs.map +1 -0
- package/dist/chunk-LY27YAXE.cjs +208 -0
- package/dist/chunk-LY27YAXE.cjs.map +1 -0
- package/dist/chunk-MT3KLB2Q.cjs +944 -0
- package/dist/chunk-MT3KLB2Q.cjs.map +1 -0
- package/dist/chunk-MUQQKPWR.js +84 -0
- package/dist/chunk-MUQQKPWR.js.map +1 -0
- package/dist/chunk-N7SJTINL.cjs +4 -0
- package/dist/chunk-N7SJTINL.cjs.map +1 -0
- package/dist/chunk-NB5GCGHL.js +833 -0
- package/dist/chunk-NB5GCGHL.js.map +1 -0
- package/dist/chunk-NQUVAJQA.js +298 -0
- package/dist/chunk-NQUVAJQA.js.map +1 -0
- package/dist/chunk-NTV2UUAJ.cjs +149 -0
- package/dist/chunk-NTV2UUAJ.cjs.map +1 -0
- package/dist/chunk-PJQWHF6T.js +31 -0
- package/dist/chunk-PJQWHF6T.js.map +1 -0
- package/dist/chunk-PQY54EL5.js +248 -0
- package/dist/chunk-PQY54EL5.js.map +1 -0
- package/dist/chunk-Q7TBBUTX.cjs +110 -0
- package/dist/chunk-Q7TBBUTX.cjs.map +1 -0
- package/dist/chunk-QZN7R2WP.cjs +114 -0
- package/dist/chunk-QZN7R2WP.cjs.map +1 -0
- package/dist/chunk-RKVSJU46.js +35 -0
- package/dist/chunk-RKVSJU46.js.map +1 -0
- package/dist/chunk-SVO62ZV2.js +50 -0
- package/dist/chunk-SVO62ZV2.js.map +1 -0
- package/dist/chunk-SX4VQXAA.cjs +114 -0
- package/dist/chunk-SX4VQXAA.cjs.map +1 -0
- package/dist/chunk-SZ7BLAY3.js +92 -0
- package/dist/chunk-SZ7BLAY3.js.map +1 -0
- package/dist/chunk-TN4MG6FY.js +112 -0
- package/dist/chunk-TN4MG6FY.js.map +1 -0
- package/dist/chunk-UC7PHDM6.cjs +331 -0
- package/dist/chunk-UC7PHDM6.cjs.map +1 -0
- package/dist/chunk-UXVLYUUW.js +108 -0
- package/dist/chunk-UXVLYUUW.js.map +1 -0
- package/dist/chunk-VBAZ77Q4.js +932 -0
- package/dist/chunk-VBAZ77Q4.js.map +1 -0
- package/dist/chunk-VSAFQTW5.cjs +319 -0
- package/dist/chunk-VSAFQTW5.cjs.map +1 -0
- package/dist/chunk-VYJQ2HTA.cjs +936 -0
- package/dist/chunk-VYJQ2HTA.cjs.map +1 -0
- package/dist/chunk-W5256BJ4.js +56 -0
- package/dist/chunk-W5256BJ4.js.map +1 -0
- package/dist/chunk-WTHTVKVI.cjs +12299 -0
- package/dist/chunk-WTHTVKVI.cjs.map +1 -0
- package/dist/chunk-WUMOSOEK.cjs +62 -0
- package/dist/chunk-WUMOSOEK.cjs.map +1 -0
- package/dist/chunk-XLRE2J25.js +140 -0
- package/dist/chunk-XLRE2J25.js.map +1 -0
- package/dist/chunk-Z4QPZ3Z3.cjs +114 -0
- package/dist/chunk-Z4QPZ3Z3.cjs.map +1 -0
- package/dist/createEngineGridQuery-BBkud5oE.d.ts +939 -0
- package/dist/createEngineGridQuery-D-fgO_jg.d.cts +939 -0
- package/dist/date-picker-jalali.cjs +263 -0
- package/dist/date-picker-jalali.cjs.map +1 -0
- package/dist/date-picker-jalali.d.cts +62 -0
- package/dist/date-picker-jalali.d.ts +62 -0
- package/dist/date-picker-jalali.js +256 -0
- package/dist/date-picker-jalali.js.map +1 -0
- package/dist/finance.cjs +205 -0
- package/dist/finance.cjs.map +1 -0
- package/dist/finance.d.cts +90 -0
- package/dist/finance.d.ts +90 -0
- package/dist/finance.js +157 -0
- package/dist/finance.js.map +1 -0
- package/dist/foldedColumn-IHDT4ARZ.cjs +66 -0
- package/dist/foldedColumn-IHDT4ARZ.cjs.map +1 -0
- package/dist/foldedColumn-TFURUKFG.js +64 -0
- package/dist/foldedColumn-TFURUKFG.js.map +1 -0
- package/dist/headless.cjs +729 -0
- package/dist/headless.cjs.map +1 -0
- package/dist/headless.d.cts +508 -0
- package/dist/headless.d.ts +508 -0
- package/dist/headless.js +226 -0
- package/dist/headless.js.map +1 -0
- package/dist/index-DN8M8Jkq.d.cts +14 -0
- package/dist/index-DmzL-F_o.d.ts +14 -0
- package/dist/index.cjs +8060 -11409
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +457 -2305
- package/dist/index.d.ts +457 -2305
- package/dist/index.js +7302 -11084
- package/dist/index.js.map +1 -1
- package/dist/locales/ar.cjs +12 -0
- package/dist/locales/ar.cjs.map +1 -0
- package/dist/locales/ar.d.cts +6 -0
- package/dist/locales/ar.d.ts +6 -0
- package/dist/locales/ar.js +3 -0
- package/dist/locales/ar.js.map +1 -0
- package/dist/locales/en.cjs +12 -0
- package/dist/locales/en.cjs.map +1 -0
- package/dist/locales/en.d.cts +6 -0
- package/dist/locales/en.d.ts +6 -0
- package/dist/locales/en.js +3 -0
- package/dist/locales/en.js.map +1 -0
- package/dist/locales/fa.cjs +12 -0
- package/dist/locales/fa.cjs.map +1 -0
- package/dist/locales/fa.d.cts +6 -0
- package/dist/locales/fa.d.ts +6 -0
- package/dist/locales/fa.js +3 -0
- package/dist/locales/fa.js.map +1 -0
- package/dist/locales/index.cjs +51 -0
- package/dist/locales/index.cjs.map +1 -0
- package/dist/locales/index.d.cts +5 -0
- package/dist/locales/index.d.ts +5 -0
- package/dist/locales/index.js +6 -0
- package/dist/locales/index.js.map +1 -0
- package/dist/memoryRecords-AWDKUJ2F.cjs +50 -0
- package/dist/memoryRecords-AWDKUJ2F.cjs.map +1 -0
- package/dist/memoryRecords-OJTGXLRH.js +47 -0
- package/dist/memoryRecords-OJTGXLRH.js.map +1 -0
- package/dist/pagedFooterTotals-DXCGDO6F.cjs +27 -0
- package/dist/pagedFooterTotals-DXCGDO6F.cjs.map +1 -0
- package/dist/pagedFooterTotals-ORWKUNE7.js +25 -0
- package/dist/pagedFooterTotals-ORWKUNE7.js.map +1 -0
- package/dist/pagedKit-MFGAJFSK.cjs +134 -0
- package/dist/pagedKit-MFGAJFSK.cjs.map +1 -0
- package/dist/pagedKit-WYWY4LRV.js +127 -0
- package/dist/pagedKit-WYWY4LRV.js.map +1 -0
- package/dist/pagedSearch-HCPJW7VM.js +38 -0
- package/dist/pagedSearch-HCPJW7VM.js.map +1 -0
- package/dist/pagedSearch-U3WCG4GN.cjs +42 -0
- package/dist/pagedSearch-U3WCG4GN.cjs.map +1 -0
- package/dist/plugins/csv.cjs +124 -0
- package/dist/plugins/csv.cjs.map +1 -0
- package/dist/plugins/csv.d.cts +44 -0
- package/dist/plugins/csv.d.ts +44 -0
- package/dist/plugins/csv.js +120 -0
- package/dist/plugins/csv.js.map +1 -0
- package/dist/plugins/excel.cjs +52 -0
- package/dist/plugins/excel.cjs.map +1 -0
- package/dist/plugins/excel.d.cts +14 -0
- package/dist/plugins/excel.d.ts +14 -0
- package/dist/plugins/excel.js +7 -0
- package/dist/plugins/excel.js.map +1 -0
- package/dist/plugins/pdf/fonts/vazirmatn.cjs +50 -0
- package/dist/plugins/pdf/fonts/vazirmatn.cjs.map +1 -0
- package/dist/plugins/pdf/fonts/vazirmatn.d.cts +24 -0
- package/dist/plugins/pdf/fonts/vazirmatn.d.ts +24 -0
- package/dist/plugins/pdf/fonts/vazirmatn.js +39 -0
- package/dist/plugins/pdf/fonts/vazirmatn.js.map +1 -0
- package/dist/plugins/pdf.cjs +24 -0
- package/dist/plugins/pdf.cjs.map +1 -0
- package/dist/plugins/pdf.d.cts +21 -0
- package/dist/plugins/pdf.d.ts +21 -0
- package/dist/plugins/pdf.js +7 -0
- package/dist/plugins/pdf.js.map +1 -0
- package/dist/presence.cjs +56 -0
- package/dist/presence.cjs.map +1 -0
- package/dist/presence.d.cts +17 -0
- package/dist/presence.d.ts +17 -0
- package/dist/presence.js +54 -0
- package/dist/presence.js.map +1 -0
- package/dist/rebuildRowVisibility-66EAZ356.cjs +21 -0
- package/dist/rebuildRowVisibility-66EAZ356.cjs.map +1 -0
- package/dist/rebuildRowVisibility-6TYM5BP2.js +19 -0
- package/dist/rebuildRowVisibility-6TYM5BP2.js.map +1 -0
- package/dist/styles.css +1440 -0
- package/dist/sync.cjs +148 -0
- package/dist/sync.cjs.map +1 -0
- package/dist/sync.d.cts +17 -0
- package/dist/sync.d.ts +17 -0
- package/dist/sync.js +146 -0
- package/dist/sync.js.map +1 -0
- package/dist/types-D__47BKv.d.cts +23 -0
- package/dist/types-D__47BKv.d.ts +23 -0
- package/package.json +185 -29
|
@@ -0,0 +1,645 @@
|
|
|
1
|
+
import { getLocalePack, resolveDirection } from './chunk-SZ7BLAY3.js';
|
|
2
|
+
import { jalaliAdapter, pad2, gregorianDateToJalali, jalaliToGregorianDate, jalaliMonthLength } from './chunk-GQEDLUMB.js';
|
|
3
|
+
import { subscribeCatalogHostEvents } from './chunk-MUQQKPWR.js';
|
|
4
|
+
import { normalizeDigits } from './chunk-AU3RDJYQ.js';
|
|
5
|
+
import { createContext, useContext, useMemo, useEffect, useCallback, useState, useRef } from 'react';
|
|
6
|
+
import { jsx } from 'react/jsx-runtime';
|
|
7
|
+
|
|
8
|
+
// infrastructure/date/gregorianAdapter.ts
|
|
9
|
+
var ISO_RE = /^(\d{4})-(\d{2})-(\d{2})$/;
|
|
10
|
+
var SLASH_RE = /^(\d{4})[/\-.](\d{1,2})[/\-.](\d{1,2})$/;
|
|
11
|
+
function utcDay(y, m, d) {
|
|
12
|
+
return new Date(Date.UTC(y, m - 1, d, 12, 0, 0));
|
|
13
|
+
}
|
|
14
|
+
function asUtcDay(date) {
|
|
15
|
+
return utcDay(date.getUTCFullYear(), date.getUTCMonth() + 1, date.getUTCDate());
|
|
16
|
+
}
|
|
17
|
+
var gregorianAdapter = {
|
|
18
|
+
id: "gregory",
|
|
19
|
+
parse(input) {
|
|
20
|
+
if (input == null || input === "") return null;
|
|
21
|
+
if (input instanceof Date && !Number.isNaN(input.getTime())) {
|
|
22
|
+
return asUtcDay(input);
|
|
23
|
+
}
|
|
24
|
+
if (typeof input === "number" && Number.isFinite(input)) {
|
|
25
|
+
const d = new Date(input);
|
|
26
|
+
return Number.isNaN(d.getTime()) ? null : asUtcDay(d);
|
|
27
|
+
}
|
|
28
|
+
const text = normalizeDigits(String(input).trim());
|
|
29
|
+
const iso = ISO_RE.exec(text);
|
|
30
|
+
if (iso) {
|
|
31
|
+
return utcDay(Number(iso[1]), Number(iso[2]), Number(iso[3]));
|
|
32
|
+
}
|
|
33
|
+
const slash = SLASH_RE.exec(text);
|
|
34
|
+
if (slash) {
|
|
35
|
+
return utcDay(Number(slash[1]), Number(slash[2]), Number(slash[3]));
|
|
36
|
+
}
|
|
37
|
+
const fallback = new Date(text);
|
|
38
|
+
return Number.isNaN(fallback.getTime()) ? null : asUtcDay(fallback);
|
|
39
|
+
},
|
|
40
|
+
format(date) {
|
|
41
|
+
const d = asUtcDay(date);
|
|
42
|
+
return `${d.getUTCFullYear()}-${pad2(d.getUTCMonth() + 1)}-${pad2(d.getUTCDate())}`;
|
|
43
|
+
},
|
|
44
|
+
addDays(date, days) {
|
|
45
|
+
const next = asUtcDay(date);
|
|
46
|
+
next.setUTCDate(next.getUTCDate() + days);
|
|
47
|
+
return next;
|
|
48
|
+
},
|
|
49
|
+
startOfMonth(date) {
|
|
50
|
+
const d = asUtcDay(date);
|
|
51
|
+
return utcDay(d.getUTCFullYear(), d.getUTCMonth() + 1, 1);
|
|
52
|
+
},
|
|
53
|
+
compare(a, b) {
|
|
54
|
+
return asUtcDay(a).getTime() - asUtcDay(b).getTime();
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
// infrastructure/date/jalaliCalendarModel.ts
|
|
59
|
+
var MONTH_NAMES_FA = [
|
|
60
|
+
"\u0641\u0631\u0648\u0631\u062F\u06CC\u0646",
|
|
61
|
+
"\u0627\u0631\u062F\u06CC\u0628\u0647\u0634\u062A",
|
|
62
|
+
"\u062E\u0631\u062F\u0627\u062F",
|
|
63
|
+
"\u062A\u06CC\u0631",
|
|
64
|
+
"\u0645\u0631\u062F\u0627\u062F",
|
|
65
|
+
"\u0634\u0647\u0631\u06CC\u0648\u0631",
|
|
66
|
+
"\u0645\u0647\u0631",
|
|
67
|
+
"\u0622\u0628\u0627\u0646",
|
|
68
|
+
"\u0622\u0630\u0631",
|
|
69
|
+
"\u062F\u06CC",
|
|
70
|
+
"\u0628\u0647\u0645\u0646",
|
|
71
|
+
"\u0627\u0633\u0641\u0646\u062F"
|
|
72
|
+
];
|
|
73
|
+
var JALALI_WEEKDAY_LABELS_FA = [
|
|
74
|
+
"\u0634",
|
|
75
|
+
"\u06CC",
|
|
76
|
+
"\u062F",
|
|
77
|
+
"\u0633",
|
|
78
|
+
"\u0686",
|
|
79
|
+
"\u067E",
|
|
80
|
+
"\u062C"
|
|
81
|
+
];
|
|
82
|
+
function jalaliMonthName(jm) {
|
|
83
|
+
return MONTH_NAMES_FA[jm - 1] ?? String(jm);
|
|
84
|
+
}
|
|
85
|
+
function toJalaliYmd(date) {
|
|
86
|
+
return gregorianDateToJalali(utcNoon(date));
|
|
87
|
+
}
|
|
88
|
+
function sameJalaliDay(a, b) {
|
|
89
|
+
const x = toJalaliYmd(a);
|
|
90
|
+
const y = toJalaliYmd(b);
|
|
91
|
+
return x.jy === y.jy && x.jm === y.jm && x.jd === y.jd;
|
|
92
|
+
}
|
|
93
|
+
function compareJalaliDay(a, b) {
|
|
94
|
+
return utcNoon(a).getTime() - utcNoon(b).getTime();
|
|
95
|
+
}
|
|
96
|
+
function addJalaliMonths(jy, jm, delta) {
|
|
97
|
+
const idx = jy * 12 + (jm - 1) + delta;
|
|
98
|
+
return {
|
|
99
|
+
jy: Math.floor(idx / 12),
|
|
100
|
+
jm: idx % 12 + 1
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
function buildJalaliMonthGrid(jy, jm) {
|
|
104
|
+
const first = jalaliToGregorianDate(jy, jm, 1);
|
|
105
|
+
const jsDow = first.getUTCDay();
|
|
106
|
+
const jalaliWeekStart = (jsDow + 1) % 7;
|
|
107
|
+
const daysInMonth = jalaliMonthLength(jy, jm);
|
|
108
|
+
const cells = [];
|
|
109
|
+
for (let i = 0; i < 42; i += 1) {
|
|
110
|
+
const offset = i - jalaliWeekStart;
|
|
111
|
+
let cellJy = jy;
|
|
112
|
+
let cellJm = jm;
|
|
113
|
+
let cellJd;
|
|
114
|
+
let inCurrentMonth = true;
|
|
115
|
+
if (offset < 0) {
|
|
116
|
+
const prev = addJalaliMonths(jy, jm, -1);
|
|
117
|
+
cellJy = prev.jy;
|
|
118
|
+
cellJm = prev.jm;
|
|
119
|
+
cellJd = jalaliMonthLength(cellJy, cellJm) + offset + 1;
|
|
120
|
+
inCurrentMonth = false;
|
|
121
|
+
} else if (offset >= daysInMonth) {
|
|
122
|
+
const next = addJalaliMonths(jy, jm, 1);
|
|
123
|
+
cellJy = next.jy;
|
|
124
|
+
cellJm = next.jm;
|
|
125
|
+
cellJd = offset - daysInMonth + 1;
|
|
126
|
+
inCurrentMonth = false;
|
|
127
|
+
} else {
|
|
128
|
+
cellJd = offset + 1;
|
|
129
|
+
}
|
|
130
|
+
const date = jalaliToGregorianDate(cellJy, cellJm, cellJd);
|
|
131
|
+
cells.push({
|
|
132
|
+
ymd: { jy: cellJy, jm: cellJm, jd: cellJd },
|
|
133
|
+
date,
|
|
134
|
+
inCurrentMonth,
|
|
135
|
+
weekday: i % 7
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
return cells;
|
|
139
|
+
}
|
|
140
|
+
function isDateInRange(date, range) {
|
|
141
|
+
if (!range.start) return false;
|
|
142
|
+
if (!range.end) return sameJalaliDay(date, range.start);
|
|
143
|
+
const t = utcNoon(date).getTime();
|
|
144
|
+
const a = utcNoon(range.start).getTime();
|
|
145
|
+
const b = utcNoon(range.end).getTime();
|
|
146
|
+
return t >= Math.min(a, b) && t <= Math.max(a, b);
|
|
147
|
+
}
|
|
148
|
+
function utcNoon(date) {
|
|
149
|
+
return new Date(
|
|
150
|
+
Date.UTC(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate(), 12)
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// ui/theme/GridTheme.ts
|
|
155
|
+
function aliasErpTokens(vars) {
|
|
156
|
+
const out = {};
|
|
157
|
+
for (const [key, value] of Object.entries(vars)) {
|
|
158
|
+
if (key.startsWith("--pdg-")) {
|
|
159
|
+
out[`--erp-${key.slice("--pdg-".length)}`] = value;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
return out;
|
|
163
|
+
}
|
|
164
|
+
var GridTheme = class _GridTheme {
|
|
165
|
+
constructor(params, extraCssVars = {}) {
|
|
166
|
+
this.params = params;
|
|
167
|
+
this.extraCssVars = extraCssVars;
|
|
168
|
+
}
|
|
169
|
+
withParams(partial) {
|
|
170
|
+
return new _GridTheme({ ...this.params, ...partial }, this.extraCssVars);
|
|
171
|
+
}
|
|
172
|
+
withExtraCssVars(extra) {
|
|
173
|
+
return new _GridTheme(this.params, { ...this.extraCssVars, ...extra });
|
|
174
|
+
}
|
|
175
|
+
toCssVars() {
|
|
176
|
+
const p = this.params;
|
|
177
|
+
const roles = {
|
|
178
|
+
"--pdg-bg": p.backgroundColor,
|
|
179
|
+
"--pdg-fg": p.foregroundColor,
|
|
180
|
+
"--pdg-accent": p.accentColor,
|
|
181
|
+
"--pdg-header-bg": p.headerBackgroundColor,
|
|
182
|
+
"--pdg-row-stripe": p.rowStripeColor,
|
|
183
|
+
"--pdg-row-selected": p.rowSelectedColor,
|
|
184
|
+
"--pdg-border": p.borderColor,
|
|
185
|
+
"--pdg-danger": p.dangerColor,
|
|
186
|
+
"--pdg-search-match": p.searchMatchColor,
|
|
187
|
+
"--pdg-font": p.fontFamily,
|
|
188
|
+
"--pdg-row-height": `${p.rowHeight}px`,
|
|
189
|
+
"--pdg-font-size": `${p.cellFontSize}px`,
|
|
190
|
+
"--pdg-radius": p.borderRadius
|
|
191
|
+
};
|
|
192
|
+
return {
|
|
193
|
+
...roles,
|
|
194
|
+
...aliasErpTokens(roles),
|
|
195
|
+
...this.extraCssVars,
|
|
196
|
+
...aliasErpTokens(this.extraCssVars)
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
var themeDefault = new GridTheme({
|
|
201
|
+
backgroundColor: "#fff",
|
|
202
|
+
foregroundColor: "#292929",
|
|
203
|
+
accentColor: "#0658b0",
|
|
204
|
+
headerBackgroundColor: "#f4f4f4",
|
|
205
|
+
rowStripeColor: "#ddecfd",
|
|
206
|
+
rowSelectedColor: "#dbeafe",
|
|
207
|
+
borderColor: "#ececec",
|
|
208
|
+
dangerColor: "#dc2626",
|
|
209
|
+
searchMatchColor: "#facc15",
|
|
210
|
+
fontFamily: "IRANSans, Tahoma, sans-serif",
|
|
211
|
+
rowHeight: 40,
|
|
212
|
+
cellFontSize: 12,
|
|
213
|
+
borderRadius: "0.25rem"
|
|
214
|
+
});
|
|
215
|
+
var themeErp = themeDefault;
|
|
216
|
+
var DARK_PALETTE_VARS = {
|
|
217
|
+
"--pdg-main-white": "#171717",
|
|
218
|
+
"--pdg-main-black": "#f4f4f4",
|
|
219
|
+
"--pdg-gray-3": "#262626",
|
|
220
|
+
"--pdg-gray-5": "#404040",
|
|
221
|
+
"--pdg-gray-6": "#525252",
|
|
222
|
+
"--pdg-gray-7": "#a3a3a3",
|
|
223
|
+
"--pdg-gray-8": "#d4d4d4",
|
|
224
|
+
"--pdg-gray-85": "#d4d4d4",
|
|
225
|
+
"--pdg-gray-9": "#e5e5e5",
|
|
226
|
+
"--pdg-gray-10": "#f5f5f5",
|
|
227
|
+
"--pdg-gray-11": "#fafafa",
|
|
228
|
+
"--pdg-black-6": "#f4f4f4",
|
|
229
|
+
"--pdg-blue-6": "#60a5fa",
|
|
230
|
+
"--pdg-blue-11": "#1e3a5f",
|
|
231
|
+
"--pdg-blue-100": "#1e3a8a",
|
|
232
|
+
"--pdg-red-100": "#7f1d1d",
|
|
233
|
+
"--pdg-red-300": "#fca5a5",
|
|
234
|
+
"--pdg-red-600": "#f87171",
|
|
235
|
+
"--pdg-yellow-200": "#854d0e",
|
|
236
|
+
"--pdg-yellow-400": "#eab308",
|
|
237
|
+
"--pdg-zinc-200": "#3f3f46",
|
|
238
|
+
"--pdg-neutral-500": "#a3a3a3",
|
|
239
|
+
"--pdg-gray-100": "#27272a",
|
|
240
|
+
"--pdg-scrollbar": "#525252",
|
|
241
|
+
"--pdg-overlay": "rgba(0, 0, 0, 0.55)"
|
|
242
|
+
};
|
|
243
|
+
var themeDark = themeDefault.withParams({
|
|
244
|
+
backgroundColor: "#171717",
|
|
245
|
+
foregroundColor: "#f4f4f4",
|
|
246
|
+
accentColor: "#60a5fa",
|
|
247
|
+
headerBackgroundColor: "#262626",
|
|
248
|
+
rowStripeColor: "#1e3a5f",
|
|
249
|
+
rowSelectedColor: "#1e3a8a",
|
|
250
|
+
borderColor: "#404040",
|
|
251
|
+
dangerColor: "#f87171",
|
|
252
|
+
searchMatchColor: "#eab308"
|
|
253
|
+
}).withExtraCssVars(DARK_PALETTE_VARS);
|
|
254
|
+
var themeErpDark = themeDark;
|
|
255
|
+
|
|
256
|
+
// ui/theme/resolveActiveTheme.ts
|
|
257
|
+
function themeParamsEqual(a, b) {
|
|
258
|
+
return a.backgroundColor === b.backgroundColor && a.foregroundColor === b.foregroundColor && a.accentColor === b.accentColor && a.headerBackgroundColor === b.headerBackgroundColor && a.rowStripeColor === b.rowStripeColor && a.rowSelectedColor === b.rowSelectedColor && a.borderColor === b.borderColor && a.dangerColor === b.dangerColor && a.searchMatchColor === b.searchMatchColor && a.fontFamily === b.fontFamily && a.rowHeight === b.rowHeight && a.cellFontSize === b.cellFontSize && a.borderRadius === b.borderRadius;
|
|
259
|
+
}
|
|
260
|
+
function isStockLightTheme(theme) {
|
|
261
|
+
return themeParamsEqual(theme.params, themeErp.params);
|
|
262
|
+
}
|
|
263
|
+
function isStockDarkTheme(theme) {
|
|
264
|
+
return themeParamsEqual(theme.params, themeErpDark.params);
|
|
265
|
+
}
|
|
266
|
+
function isStockTheme(theme) {
|
|
267
|
+
return isStockLightTheme(theme) || isStockDarkTheme(theme);
|
|
268
|
+
}
|
|
269
|
+
function resolveActiveTheme(input) {
|
|
270
|
+
const requested = input.requested ?? themeErp;
|
|
271
|
+
const locked = !isStockTheme(requested);
|
|
272
|
+
if (locked) return { theme: requested, locked: true };
|
|
273
|
+
return {
|
|
274
|
+
theme: input.preferDark ? themeErpDark : themeErp,
|
|
275
|
+
locked: false
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
// ui/theme/applyCssVars.ts
|
|
280
|
+
var lastVars = themeErp.toCssVars();
|
|
281
|
+
function rememberThemeVars(vars) {
|
|
282
|
+
lastVars = vars;
|
|
283
|
+
}
|
|
284
|
+
function themeToStyle(theme, extra) {
|
|
285
|
+
return { ...theme.toCssVars(), ...extra };
|
|
286
|
+
}
|
|
287
|
+
function assignThemeVars(el, vars = lastVars) {
|
|
288
|
+
for (const [key, value] of Object.entries(vars)) {
|
|
289
|
+
el.style.setProperty(key, value);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
// ui/host/messages.ts
|
|
294
|
+
var FA_MESSAGES = getLocalePack("fa");
|
|
295
|
+
var EN_MESSAGES = getLocalePack("en");
|
|
296
|
+
var AR_MESSAGES = getLocalePack("ar");
|
|
297
|
+
function translate(key, locale, overrides) {
|
|
298
|
+
const pack = getLocalePack(locale);
|
|
299
|
+
return overrides?.[key] ?? pack[key] ?? key;
|
|
300
|
+
}
|
|
301
|
+
function formatMessage(template, vars) {
|
|
302
|
+
return template.replace(/\{(\w+)\}/g, (_, name) => {
|
|
303
|
+
const value = vars[name];
|
|
304
|
+
return value == null ? `{${name}}` : String(value);
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
function defaultDateAdapter(locale) {
|
|
308
|
+
return locale === "fa" ? jalaliAdapter : gregorianAdapter;
|
|
309
|
+
}
|
|
310
|
+
var ERPTableHostContext = createContext({
|
|
311
|
+
locale: "fa",
|
|
312
|
+
direction: "rtl",
|
|
313
|
+
dateAdapter: jalaliAdapter,
|
|
314
|
+
theme: themeErp,
|
|
315
|
+
themeToggle: true,
|
|
316
|
+
themeLocked: false
|
|
317
|
+
});
|
|
318
|
+
function ERPTableHostProvider({
|
|
319
|
+
children,
|
|
320
|
+
locale = "fa",
|
|
321
|
+
direction,
|
|
322
|
+
numberingSystem,
|
|
323
|
+
dateAdapter,
|
|
324
|
+
remoteApi,
|
|
325
|
+
messages: messagesProp,
|
|
326
|
+
onToast: onToastProp,
|
|
327
|
+
theme = themeErp,
|
|
328
|
+
themeToggle = true,
|
|
329
|
+
themeLocked = false,
|
|
330
|
+
onToggleTheme,
|
|
331
|
+
components: componentsProp,
|
|
332
|
+
filterComponents: filterComponentsProp,
|
|
333
|
+
columnMenuItems: columnMenuItemsProp,
|
|
334
|
+
onColumnMenuAction: onColumnMenuActionProp,
|
|
335
|
+
useDependOn: useDependOnProp
|
|
336
|
+
}) {
|
|
337
|
+
const outer = useContext(ERPTableHostContext);
|
|
338
|
+
const messages = messagesProp ?? outer.messages;
|
|
339
|
+
const onToast = onToastProp ?? outer.onToast;
|
|
340
|
+
const components = componentsProp ?? outer.components;
|
|
341
|
+
const filterComponents = filterComponentsProp ?? outer.filterComponents;
|
|
342
|
+
const columnMenuItems = columnMenuItemsProp ?? outer.columnMenuItems;
|
|
343
|
+
const onColumnMenuAction = onColumnMenuActionProp ?? outer.onColumnMenuAction;
|
|
344
|
+
const useDependOn = useDependOnProp ?? outer.useDependOn;
|
|
345
|
+
const value = useMemo(
|
|
346
|
+
() => ({
|
|
347
|
+
locale,
|
|
348
|
+
direction: resolveDirection(locale, direction),
|
|
349
|
+
numberingSystem,
|
|
350
|
+
dateAdapter: dateAdapter ?? defaultDateAdapter(locale),
|
|
351
|
+
remoteApi,
|
|
352
|
+
messages,
|
|
353
|
+
onToast,
|
|
354
|
+
theme,
|
|
355
|
+
themeToggle,
|
|
356
|
+
themeLocked,
|
|
357
|
+
onToggleTheme,
|
|
358
|
+
components,
|
|
359
|
+
filterComponents,
|
|
360
|
+
columnMenuItems,
|
|
361
|
+
onColumnMenuAction,
|
|
362
|
+
useDependOn
|
|
363
|
+
}),
|
|
364
|
+
[
|
|
365
|
+
locale,
|
|
366
|
+
direction,
|
|
367
|
+
numberingSystem,
|
|
368
|
+
dateAdapter,
|
|
369
|
+
remoteApi,
|
|
370
|
+
messages,
|
|
371
|
+
onToast,
|
|
372
|
+
theme,
|
|
373
|
+
themeToggle,
|
|
374
|
+
themeLocked,
|
|
375
|
+
onToggleTheme,
|
|
376
|
+
components,
|
|
377
|
+
filterComponents,
|
|
378
|
+
columnMenuItems,
|
|
379
|
+
onColumnMenuAction,
|
|
380
|
+
useDependOn
|
|
381
|
+
]
|
|
382
|
+
);
|
|
383
|
+
useEffect(() => {
|
|
384
|
+
rememberThemeVars(theme.toCssVars());
|
|
385
|
+
}, [theme]);
|
|
386
|
+
return /* @__PURE__ */ jsx(ERPTableHostContext.Provider, { value, children });
|
|
387
|
+
}
|
|
388
|
+
function useERPTableHost() {
|
|
389
|
+
return useContext(ERPTableHostContext);
|
|
390
|
+
}
|
|
391
|
+
function useERPTableTheme() {
|
|
392
|
+
return useERPTableHost().theme ?? themeErp;
|
|
393
|
+
}
|
|
394
|
+
function useThemePortalStyle(extra) {
|
|
395
|
+
const theme = useERPTableTheme();
|
|
396
|
+
return themeToStyle(theme, extra);
|
|
397
|
+
}
|
|
398
|
+
function useTranslations() {
|
|
399
|
+
const { locale, messages } = useERPTableHost();
|
|
400
|
+
return useCallback(
|
|
401
|
+
(key, vars) => {
|
|
402
|
+
const raw = translate(key, locale, messages);
|
|
403
|
+
return vars ? formatMessage(raw, vars) : raw;
|
|
404
|
+
},
|
|
405
|
+
[locale, messages]
|
|
406
|
+
);
|
|
407
|
+
}
|
|
408
|
+
function useLocale() {
|
|
409
|
+
return useERPTableHost().locale;
|
|
410
|
+
}
|
|
411
|
+
function useNumberingSystem() {
|
|
412
|
+
return useERPTableHost().numberingSystem;
|
|
413
|
+
}
|
|
414
|
+
function useDateAdapter() {
|
|
415
|
+
return useERPTableHost().dateAdapter ?? jalaliAdapter;
|
|
416
|
+
}
|
|
417
|
+
function useDirection() {
|
|
418
|
+
return useERPTableHost().direction;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
// ui/host/dependOn.ts
|
|
422
|
+
var toList = (dependOn) => !dependOn ? [] : Array.isArray(dependOn) ? dependOn : [dependOn];
|
|
423
|
+
var getDependFieldName = (item) => typeof item === "string" ? item : item.fieldName;
|
|
424
|
+
var getStaticDependValue = (item) => typeof item === "object" ? item.value : void 0;
|
|
425
|
+
var hasDependValue = (dependOn, resolve = getStaticDependValue) => toList(dependOn).every((item) => resolve(item) != null);
|
|
426
|
+
var buildDependencyBody = (dependOn, resolve = getStaticDependValue) => Object.fromEntries(
|
|
427
|
+
toList(dependOn).map((item) => [getDependFieldName(item), resolve(item)])
|
|
428
|
+
);
|
|
429
|
+
var useStaticDependOn = (dependOn, options) => {
|
|
430
|
+
const unwrap = (value) => options?.unwrapObjectValue && value !== null && typeof value === "object" && !Array.isArray(value) && "value" in value ? value.value : value;
|
|
431
|
+
const resolve = (item) => unwrap(getStaticDependValue(item));
|
|
432
|
+
return {
|
|
433
|
+
isReady: hasDependValue(dependOn, resolve),
|
|
434
|
+
dependencyBody: buildDependencyBody(dependOn, resolve),
|
|
435
|
+
dependencyKey: JSON.stringify(dependOn ?? null)
|
|
436
|
+
};
|
|
437
|
+
};
|
|
438
|
+
var useHostDependOn = (dependOn, options) => {
|
|
439
|
+
const host = useERPTableHost();
|
|
440
|
+
const hook = host.useDependOn ?? useStaticDependOn;
|
|
441
|
+
return hook(dependOn, options);
|
|
442
|
+
};
|
|
443
|
+
|
|
444
|
+
// ui/host/bindGridHostEvents.ts
|
|
445
|
+
function selectedKeysEqual(a, b) {
|
|
446
|
+
const left = Object.keys(a ?? {});
|
|
447
|
+
const right = Object.keys(b ?? {});
|
|
448
|
+
if (left.length !== right.length) return false;
|
|
449
|
+
return left.every((key) => {
|
|
450
|
+
const id = Number(key);
|
|
451
|
+
return Boolean(a?.[id]) === Boolean(b?.[id]);
|
|
452
|
+
});
|
|
453
|
+
}
|
|
454
|
+
function activeCellEqual(a, b) {
|
|
455
|
+
return a?.rowId === b?.rowId && a?.columnId === b?.columnId;
|
|
456
|
+
}
|
|
457
|
+
function selectedRowIds(selected) {
|
|
458
|
+
return Object.keys(selected ?? {}).map(Number).filter((id) => Number.isFinite(id) && Boolean(selected?.[id]));
|
|
459
|
+
}
|
|
460
|
+
function bindGridHostEvents(input) {
|
|
461
|
+
const { eventStore, controller, tableKey, handlers } = input;
|
|
462
|
+
const unsubCatalog = subscribeCatalogHostEvents(
|
|
463
|
+
eventStore,
|
|
464
|
+
{
|
|
465
|
+
tableId: tableKey,
|
|
466
|
+
getRowData: (rowId) => controller.getAllRows()?.find((row) => row.id.value === rowId)?.data,
|
|
467
|
+
getAllRowData: () => (controller.getAllRows() ?? []).map((row) => row.data).filter((data) => data !== void 0)
|
|
468
|
+
},
|
|
469
|
+
handlers
|
|
470
|
+
);
|
|
471
|
+
const unsubSelection = controller.subscribeSelected(
|
|
472
|
+
() => controller.getSelectedRows(),
|
|
473
|
+
(selected) => {
|
|
474
|
+
const ids = selectedRowIds(selected);
|
|
475
|
+
const rows = controller.getAllRows() ?? [];
|
|
476
|
+
const selectedRows = ids.map((id) => rows.find((row) => row.id.value === id)?.data).filter((data) => data !== void 0);
|
|
477
|
+
handlers.onSelectionChanged?.({
|
|
478
|
+
selectedRowIds: ids,
|
|
479
|
+
selectedRows
|
|
480
|
+
});
|
|
481
|
+
},
|
|
482
|
+
selectedKeysEqual
|
|
483
|
+
);
|
|
484
|
+
const unsubFocus = controller.subscribeSelected(
|
|
485
|
+
() => controller.getActiveCell(),
|
|
486
|
+
(cell) => {
|
|
487
|
+
handlers.onCellFocused?.({
|
|
488
|
+
rowId: cell?.rowId ?? null,
|
|
489
|
+
colId: cell?.columnId ?? null
|
|
490
|
+
});
|
|
491
|
+
},
|
|
492
|
+
activeCellEqual
|
|
493
|
+
);
|
|
494
|
+
return () => {
|
|
495
|
+
unsubCatalog();
|
|
496
|
+
unsubSelection();
|
|
497
|
+
unsubFocus();
|
|
498
|
+
};
|
|
499
|
+
}
|
|
500
|
+
var QUERIES = {
|
|
501
|
+
XLUP: "(min-width: 1024px)",
|
|
502
|
+
XXLUP: "(min-width: 1366px)"
|
|
503
|
+
};
|
|
504
|
+
function useMediaQuery(query) {
|
|
505
|
+
const media = QUERIES[query] ?? query;
|
|
506
|
+
const [match, setMatch] = useState(() => {
|
|
507
|
+
if (typeof window === "undefined") return null;
|
|
508
|
+
return window.matchMedia(media).matches;
|
|
509
|
+
});
|
|
510
|
+
useEffect(() => {
|
|
511
|
+
const mql = window.matchMedia(media);
|
|
512
|
+
const onChange = () => setMatch(mql.matches);
|
|
513
|
+
onChange();
|
|
514
|
+
mql.addEventListener("change", onChange);
|
|
515
|
+
return () => mql.removeEventListener("change", onChange);
|
|
516
|
+
}, [media]);
|
|
517
|
+
return { match };
|
|
518
|
+
}
|
|
519
|
+
function useLatest(value) {
|
|
520
|
+
const ref = useRef(value);
|
|
521
|
+
ref.current = value;
|
|
522
|
+
return ref;
|
|
523
|
+
}
|
|
524
|
+
function errorMessage(error) {
|
|
525
|
+
return error instanceof Error ? error.message : "Remote request failed";
|
|
526
|
+
}
|
|
527
|
+
function useRemoteQuery(args) {
|
|
528
|
+
const { remoteApi, onToast } = useERPTableHost();
|
|
529
|
+
const toastRef = useLatest(onToast);
|
|
530
|
+
const [data, setData] = useState(null);
|
|
531
|
+
const [isFetching, setIsFetching] = useState(false);
|
|
532
|
+
const [error, setError] = useState(null);
|
|
533
|
+
const refetch = useCallback(async () => {
|
|
534
|
+
if (!args.url || args.skip || !remoteApi) {
|
|
535
|
+
setData(null);
|
|
536
|
+
return;
|
|
537
|
+
}
|
|
538
|
+
setIsFetching(true);
|
|
539
|
+
setError(null);
|
|
540
|
+
try {
|
|
541
|
+
const response = await remoteApi.request({
|
|
542
|
+
endpoint: args.url,
|
|
543
|
+
params: args.body,
|
|
544
|
+
method: "POST"
|
|
545
|
+
});
|
|
546
|
+
setData(response ?? null);
|
|
547
|
+
} catch (e) {
|
|
548
|
+
setData(null);
|
|
549
|
+
setError(e);
|
|
550
|
+
toastRef.current?.("error", errorMessage(e), e);
|
|
551
|
+
} finally {
|
|
552
|
+
setIsFetching(false);
|
|
553
|
+
}
|
|
554
|
+
}, [args.url, args.skip, args.noCache, JSON.stringify(args.body ?? {}), remoteApi]);
|
|
555
|
+
useEffect(() => {
|
|
556
|
+
void refetch();
|
|
557
|
+
}, [refetch]);
|
|
558
|
+
return { data, isFetching, error, refetch };
|
|
559
|
+
}
|
|
560
|
+
function useLazyRemote() {
|
|
561
|
+
const { remoteApi, onToast } = useERPTableHost();
|
|
562
|
+
const toastRef = useLatest(onToast);
|
|
563
|
+
const [data, setData] = useState(null);
|
|
564
|
+
const [isFetching, setIsFetching] = useState(false);
|
|
565
|
+
const [error, setError] = useState(null);
|
|
566
|
+
const trigger = useCallback(
|
|
567
|
+
async (args) => {
|
|
568
|
+
if (!args.url || !remoteApi) {
|
|
569
|
+
setData(null);
|
|
570
|
+
return;
|
|
571
|
+
}
|
|
572
|
+
setIsFetching(true);
|
|
573
|
+
setError(null);
|
|
574
|
+
try {
|
|
575
|
+
const response = await remoteApi.request({ endpoint: args.url, params: args.body, method: "POST" });
|
|
576
|
+
setData(response ?? null);
|
|
577
|
+
} catch (e) {
|
|
578
|
+
setData(null);
|
|
579
|
+
setError(e);
|
|
580
|
+
toastRef.current?.("error", errorMessage(e), e);
|
|
581
|
+
} finally {
|
|
582
|
+
setIsFetching(false);
|
|
583
|
+
}
|
|
584
|
+
},
|
|
585
|
+
[remoteApi]
|
|
586
|
+
);
|
|
587
|
+
return [trigger, { data, isFetching, error }];
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
// ui/host/toast.ts
|
|
591
|
+
function showSuccessToast(message, _detail) {
|
|
592
|
+
const text = String(message ?? "");
|
|
593
|
+
emitToast("success", text);
|
|
594
|
+
}
|
|
595
|
+
function showErrorToast(message, _detail) {
|
|
596
|
+
const text = String(message ?? "");
|
|
597
|
+
emitToast("error", text);
|
|
598
|
+
}
|
|
599
|
+
function emitToast(kind, message) {
|
|
600
|
+
if (typeof document === "undefined") return;
|
|
601
|
+
const existing = document.querySelector(".erp-table-toast");
|
|
602
|
+
existing?.remove();
|
|
603
|
+
const el = document.createElement("div");
|
|
604
|
+
el.className = `erp-table-toast is-${kind}`;
|
|
605
|
+
el.textContent = message;
|
|
606
|
+
assignThemeVars(el);
|
|
607
|
+
document.body.appendChild(el);
|
|
608
|
+
window.setTimeout(() => el.remove(), 2800);
|
|
609
|
+
}
|
|
610
|
+
function useHostToast() {
|
|
611
|
+
const host = useERPTableHost();
|
|
612
|
+
return {
|
|
613
|
+
success: (message, detail) => {
|
|
614
|
+
if (host.onToast) host.onToast("success", message, detail);
|
|
615
|
+
else showSuccessToast(message);
|
|
616
|
+
},
|
|
617
|
+
error: (message, detail) => {
|
|
618
|
+
if (host.onToast) host.onToast("error", message, detail);
|
|
619
|
+
else showErrorToast(message);
|
|
620
|
+
}
|
|
621
|
+
};
|
|
622
|
+
}
|
|
623
|
+
function useGridHostEvents(input) {
|
|
624
|
+
const handlersRef = useRef(input);
|
|
625
|
+
handlersRef.current = input;
|
|
626
|
+
useEffect(() => {
|
|
627
|
+
if (!input.ready || !input.controller || !input.eventStore) return;
|
|
628
|
+
return bindGridHostEvents({
|
|
629
|
+
eventStore: input.eventStore,
|
|
630
|
+
controller: input.controller,
|
|
631
|
+
tableKey: input.tableKey,
|
|
632
|
+
handlers: {
|
|
633
|
+
onCellValueChanged: (event) => handlersRef.current.onCellValueChanged?.(event),
|
|
634
|
+
onRowValueChanged: (event) => handlersRef.current.onRowValueChanged?.(event),
|
|
635
|
+
onRowDataUpdated: (event) => handlersRef.current.onRowDataUpdated?.(event),
|
|
636
|
+
onSelectionChanged: (event) => handlersRef.current.onSelectionChanged?.(event),
|
|
637
|
+
onCellFocused: (event) => handlersRef.current.onCellFocused?.(event)
|
|
638
|
+
}
|
|
639
|
+
});
|
|
640
|
+
}, [input.ready, input.controller, input.eventStore, input.tableKey]);
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
export { AR_MESSAGES, EN_MESSAGES, ERPTableHostProvider, FA_MESSAGES, GridTheme, JALALI_WEEKDAY_LABELS_FA, addJalaliMonths, bindGridHostEvents, buildDependencyBody, buildJalaliMonthGrid, compareJalaliDay, getDependFieldName, getStaticDependValue, gregorianAdapter, hasDependValue, isDateInRange, isStockDarkTheme, jalaliMonthName, resolveActiveTheme, sameJalaliDay, themeDark, themeDefault, themeErp, themeErpDark, themeToStyle, toJalaliYmd, translate, useDateAdapter, useDirection, useERPTableHost, useERPTableTheme, useGridHostEvents, useHostDependOn, useHostToast, useLazyRemote, useLocale, useMediaQuery, useNumberingSystem, useRemoteQuery, useStaticDependOn, useThemePortalStyle, useTranslations };
|
|
644
|
+
//# sourceMappingURL=chunk-HLOHWFOA.js.map
|
|
645
|
+
//# sourceMappingURL=chunk-HLOHWFOA.js.map
|