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.
Files changed (282) hide show
  1. package/OFL.txt +93 -0
  2. package/README.md +179 -22
  3. package/dist/ERPTableGroupRow-E5Q6FYDS.js +125 -0
  4. package/dist/ERPTableGroupRow-E5Q6FYDS.js.map +1 -0
  5. package/dist/ERPTableGroupRow-F2IPDYL5.cjs +131 -0
  6. package/dist/ERPTableGroupRow-F2IPDYL5.cjs.map +1 -0
  7. package/dist/GridPlugin-Bewn0X51.d.ts +57 -0
  8. package/dist/GridPlugin-DewWufGZ.d.cts +57 -0
  9. package/dist/GridPresenceService-GEH6535Q.js +3 -0
  10. package/dist/GridPresenceService-GEH6535Q.js.map +1 -0
  11. package/dist/GridPresenceService-RDN5FXHQ.cjs +12 -0
  12. package/dist/GridPresenceService-RDN5FXHQ.cjs.map +1 -0
  13. package/dist/GridSession-CeIfVFck.d.ts +2625 -0
  14. package/dist/GridSession-CmQn2RnL.d.cts +2625 -0
  15. package/dist/GridSyncService-3JQLEY65.cjs +12 -0
  16. package/dist/GridSyncService-3JQLEY65.cjs.map +1 -0
  17. package/dist/GridSyncService-GECXGEKL.js +3 -0
  18. package/dist/GridSyncService-GECXGEKL.js.map +1 -0
  19. package/dist/PdfRenderer-B9FJaCo_.d.cts +22 -0
  20. package/dist/PdfRenderer-bN7ca_Aj.d.ts +22 -0
  21. package/dist/RemoteApi-CCQxiSf1.d.cts +28 -0
  22. package/dist/RemoteApi-CCQxiSf1.d.ts +28 -0
  23. package/dist/SelectImpl-NM4O4IGW.js +447 -0
  24. package/dist/SelectImpl-NM4O4IGW.js.map +1 -0
  25. package/dist/SelectImpl-W2EI4T7O.cjs +453 -0
  26. package/dist/SelectImpl-W2EI4T7O.cjs.map +1 -0
  27. package/dist/UITableController-C71LXBiX.d.ts +678 -0
  28. package/dist/UITableController-CIwnHIw8.d.cts +678 -0
  29. package/dist/VazirmatnPdfRenderer-CpCqA-Wh.d.cts +96 -0
  30. package/dist/VazirmatnPdfRenderer-D46smncn.d.ts +96 -0
  31. package/dist/adapters/arian-erp.cjs +89 -0
  32. package/dist/adapters/arian-erp.cjs.map +1 -0
  33. package/dist/adapters/arian-erp.d.cts +62 -0
  34. package/dist/adapters/arian-erp.d.ts +62 -0
  35. package/dist/adapters/arian-erp.js +79 -0
  36. package/dist/adapters/arian-erp.js.map +1 -0
  37. package/dist/appendAtEnd-RHIQRG2W.cjs +35 -0
  38. package/dist/appendAtEnd-RHIQRG2W.cjs.map +1 -0
  39. package/dist/appendAtEnd-TJEABLGD.js +33 -0
  40. package/dist/appendAtEnd-TJEABLGD.js.map +1 -0
  41. package/dist/applyImportedRows-C2fWYoPy.d.cts +135 -0
  42. package/dist/applyImportedRows-Cqh_N_0k.d.ts +135 -0
  43. package/dist/applyRowVisibilityHandler-Q64ZFC7A.cjs +86 -0
  44. package/dist/applyRowVisibilityHandler-Q64ZFC7A.cjs.map +1 -0
  45. package/dist/applyRowVisibilityHandler-ZLZXQEGY.js +84 -0
  46. package/dist/applyRowVisibilityHandler-ZLZXQEGY.js.map +1 -0
  47. package/dist/broadcastChannelTransport-FHUMV76O.cjs +12 -0
  48. package/dist/broadcastChannelTransport-FHUMV76O.cjs.map +1 -0
  49. package/dist/broadcastChannelTransport-MIH53VNZ.js +3 -0
  50. package/dist/broadcastChannelTransport-MIH53VNZ.js.map +1 -0
  51. package/dist/callbackRemoteApi-BYLjmSI6.d.ts +51 -0
  52. package/dist/callbackRemoteApi-Cv26MmSD.d.cts +51 -0
  53. package/dist/cellRenderContext-BaNh4qn_.d.ts +42 -0
  54. package/dist/cellRenderContext-DvngkptV.d.cts +42 -0
  55. package/dist/chunk-27ALJSZP.js +12187 -0
  56. package/dist/chunk-27ALJSZP.js.map +1 -0
  57. package/dist/chunk-3HP3HQCW.cjs +688 -0
  58. package/dist/chunk-3HP3HQCW.cjs.map +1 -0
  59. package/dist/chunk-3Y3KKGEC.js +3 -0
  60. package/dist/chunk-3Y3KKGEC.js.map +1 -0
  61. package/dist/chunk-52LFOPXD.cjs +588 -0
  62. package/dist/chunk-52LFOPXD.cjs.map +1 -0
  63. package/dist/chunk-5ALMNLUR.cjs +1408 -0
  64. package/dist/chunk-5ALMNLUR.cjs.map +1 -0
  65. package/dist/chunk-5HKVMPBD.js +937 -0
  66. package/dist/chunk-5HKVMPBD.js.map +1 -0
  67. package/dist/chunk-72IVAOTK.cjs +38 -0
  68. package/dist/chunk-72IVAOTK.cjs.map +1 -0
  69. package/dist/chunk-77UXAJII.js +112 -0
  70. package/dist/chunk-77UXAJII.js.map +1 -0
  71. package/dist/chunk-7GWV5HGO.js +36 -0
  72. package/dist/chunk-7GWV5HGO.js.map +1 -0
  73. package/dist/chunk-7T6AWRPU.js +581 -0
  74. package/dist/chunk-7T6AWRPU.js.map +1 -0
  75. package/dist/chunk-AU3RDJYQ.js +243 -0
  76. package/dist/chunk-AU3RDJYQ.js.map +1 -0
  77. package/dist/chunk-CILNIWYW.cjs +100 -0
  78. package/dist/chunk-CILNIWYW.cjs.map +1 -0
  79. package/dist/chunk-CMQ4VLCW.cjs +840 -0
  80. package/dist/chunk-CMQ4VLCW.cjs.map +1 -0
  81. package/dist/chunk-DFFP7SJ6.cjs +257 -0
  82. package/dist/chunk-DFFP7SJ6.cjs.map +1 -0
  83. package/dist/chunk-E2J533UH.cjs +53 -0
  84. package/dist/chunk-E2J533UH.cjs.map +1 -0
  85. package/dist/chunk-EBV6HGZB.cjs +33 -0
  86. package/dist/chunk-EBV6HGZB.cjs.map +1 -0
  87. package/dist/chunk-F4PYOYHR.js +112 -0
  88. package/dist/chunk-F4PYOYHR.js.map +1 -0
  89. package/dist/chunk-F6EMC75A.cjs +34 -0
  90. package/dist/chunk-F6EMC75A.cjs.map +1 -0
  91. package/dist/chunk-GKE33FOJ.js +32 -0
  92. package/dist/chunk-GKE33FOJ.js.map +1 -0
  93. package/dist/chunk-GQEDLUMB.js +168 -0
  94. package/dist/chunk-GQEDLUMB.js.map +1 -0
  95. package/dist/chunk-HLOHWFOA.js +645 -0
  96. package/dist/chunk-HLOHWFOA.js.map +1 -0
  97. package/dist/chunk-IMPCRWYP.cjs +251 -0
  98. package/dist/chunk-IMPCRWYP.cjs.map +1 -0
  99. package/dist/chunk-IPPIXOVQ.js +317 -0
  100. package/dist/chunk-IPPIXOVQ.js.map +1 -0
  101. package/dist/chunk-J4XJ4UBC.js +1404 -0
  102. package/dist/chunk-J4XJ4UBC.js.map +1 -0
  103. package/dist/chunk-J7CPPFXT.cjs +89 -0
  104. package/dist/chunk-J7CPPFXT.cjs.map +1 -0
  105. package/dist/chunk-JOICD47Q.cjs +41 -0
  106. package/dist/chunk-JOICD47Q.cjs.map +1 -0
  107. package/dist/chunk-KCNTKYUY.js +206 -0
  108. package/dist/chunk-KCNTKYUY.js.map +1 -0
  109. package/dist/chunk-KHMG6EI2.js +13 -0
  110. package/dist/chunk-KHMG6EI2.js.map +1 -0
  111. package/dist/chunk-KMRURD5J.cjs +15 -0
  112. package/dist/chunk-KMRURD5J.cjs.map +1 -0
  113. package/dist/chunk-KRJG3KMP.cjs +174 -0
  114. package/dist/chunk-KRJG3KMP.cjs.map +1 -0
  115. package/dist/chunk-LY27YAXE.cjs +208 -0
  116. package/dist/chunk-LY27YAXE.cjs.map +1 -0
  117. package/dist/chunk-MT3KLB2Q.cjs +944 -0
  118. package/dist/chunk-MT3KLB2Q.cjs.map +1 -0
  119. package/dist/chunk-MUQQKPWR.js +84 -0
  120. package/dist/chunk-MUQQKPWR.js.map +1 -0
  121. package/dist/chunk-N7SJTINL.cjs +4 -0
  122. package/dist/chunk-N7SJTINL.cjs.map +1 -0
  123. package/dist/chunk-NB5GCGHL.js +833 -0
  124. package/dist/chunk-NB5GCGHL.js.map +1 -0
  125. package/dist/chunk-NQUVAJQA.js +298 -0
  126. package/dist/chunk-NQUVAJQA.js.map +1 -0
  127. package/dist/chunk-NTV2UUAJ.cjs +149 -0
  128. package/dist/chunk-NTV2UUAJ.cjs.map +1 -0
  129. package/dist/chunk-PJQWHF6T.js +31 -0
  130. package/dist/chunk-PJQWHF6T.js.map +1 -0
  131. package/dist/chunk-PQY54EL5.js +248 -0
  132. package/dist/chunk-PQY54EL5.js.map +1 -0
  133. package/dist/chunk-Q7TBBUTX.cjs +110 -0
  134. package/dist/chunk-Q7TBBUTX.cjs.map +1 -0
  135. package/dist/chunk-QZN7R2WP.cjs +114 -0
  136. package/dist/chunk-QZN7R2WP.cjs.map +1 -0
  137. package/dist/chunk-RKVSJU46.js +35 -0
  138. package/dist/chunk-RKVSJU46.js.map +1 -0
  139. package/dist/chunk-SVO62ZV2.js +50 -0
  140. package/dist/chunk-SVO62ZV2.js.map +1 -0
  141. package/dist/chunk-SX4VQXAA.cjs +114 -0
  142. package/dist/chunk-SX4VQXAA.cjs.map +1 -0
  143. package/dist/chunk-SZ7BLAY3.js +92 -0
  144. package/dist/chunk-SZ7BLAY3.js.map +1 -0
  145. package/dist/chunk-TN4MG6FY.js +112 -0
  146. package/dist/chunk-TN4MG6FY.js.map +1 -0
  147. package/dist/chunk-UC7PHDM6.cjs +331 -0
  148. package/dist/chunk-UC7PHDM6.cjs.map +1 -0
  149. package/dist/chunk-UXVLYUUW.js +108 -0
  150. package/dist/chunk-UXVLYUUW.js.map +1 -0
  151. package/dist/chunk-VBAZ77Q4.js +932 -0
  152. package/dist/chunk-VBAZ77Q4.js.map +1 -0
  153. package/dist/chunk-VSAFQTW5.cjs +319 -0
  154. package/dist/chunk-VSAFQTW5.cjs.map +1 -0
  155. package/dist/chunk-VYJQ2HTA.cjs +936 -0
  156. package/dist/chunk-VYJQ2HTA.cjs.map +1 -0
  157. package/dist/chunk-W5256BJ4.js +56 -0
  158. package/dist/chunk-W5256BJ4.js.map +1 -0
  159. package/dist/chunk-WTHTVKVI.cjs +12299 -0
  160. package/dist/chunk-WTHTVKVI.cjs.map +1 -0
  161. package/dist/chunk-WUMOSOEK.cjs +62 -0
  162. package/dist/chunk-WUMOSOEK.cjs.map +1 -0
  163. package/dist/chunk-XLRE2J25.js +140 -0
  164. package/dist/chunk-XLRE2J25.js.map +1 -0
  165. package/dist/chunk-Z4QPZ3Z3.cjs +114 -0
  166. package/dist/chunk-Z4QPZ3Z3.cjs.map +1 -0
  167. package/dist/createEngineGridQuery-BBkud5oE.d.ts +939 -0
  168. package/dist/createEngineGridQuery-D-fgO_jg.d.cts +939 -0
  169. package/dist/date-picker-jalali.cjs +263 -0
  170. package/dist/date-picker-jalali.cjs.map +1 -0
  171. package/dist/date-picker-jalali.d.cts +62 -0
  172. package/dist/date-picker-jalali.d.ts +62 -0
  173. package/dist/date-picker-jalali.js +256 -0
  174. package/dist/date-picker-jalali.js.map +1 -0
  175. package/dist/finance.cjs +205 -0
  176. package/dist/finance.cjs.map +1 -0
  177. package/dist/finance.d.cts +90 -0
  178. package/dist/finance.d.ts +90 -0
  179. package/dist/finance.js +157 -0
  180. package/dist/finance.js.map +1 -0
  181. package/dist/foldedColumn-IHDT4ARZ.cjs +66 -0
  182. package/dist/foldedColumn-IHDT4ARZ.cjs.map +1 -0
  183. package/dist/foldedColumn-TFURUKFG.js +64 -0
  184. package/dist/foldedColumn-TFURUKFG.js.map +1 -0
  185. package/dist/headless.cjs +729 -0
  186. package/dist/headless.cjs.map +1 -0
  187. package/dist/headless.d.cts +508 -0
  188. package/dist/headless.d.ts +508 -0
  189. package/dist/headless.js +226 -0
  190. package/dist/headless.js.map +1 -0
  191. package/dist/index-DN8M8Jkq.d.cts +14 -0
  192. package/dist/index-DmzL-F_o.d.ts +14 -0
  193. package/dist/index.cjs +8060 -11409
  194. package/dist/index.cjs.map +1 -1
  195. package/dist/index.d.cts +457 -2305
  196. package/dist/index.d.ts +457 -2305
  197. package/dist/index.js +7302 -11084
  198. package/dist/index.js.map +1 -1
  199. package/dist/locales/ar.cjs +12 -0
  200. package/dist/locales/ar.cjs.map +1 -0
  201. package/dist/locales/ar.d.cts +6 -0
  202. package/dist/locales/ar.d.ts +6 -0
  203. package/dist/locales/ar.js +3 -0
  204. package/dist/locales/ar.js.map +1 -0
  205. package/dist/locales/en.cjs +12 -0
  206. package/dist/locales/en.cjs.map +1 -0
  207. package/dist/locales/en.d.cts +6 -0
  208. package/dist/locales/en.d.ts +6 -0
  209. package/dist/locales/en.js +3 -0
  210. package/dist/locales/en.js.map +1 -0
  211. package/dist/locales/fa.cjs +12 -0
  212. package/dist/locales/fa.cjs.map +1 -0
  213. package/dist/locales/fa.d.cts +6 -0
  214. package/dist/locales/fa.d.ts +6 -0
  215. package/dist/locales/fa.js +3 -0
  216. package/dist/locales/fa.js.map +1 -0
  217. package/dist/locales/index.cjs +51 -0
  218. package/dist/locales/index.cjs.map +1 -0
  219. package/dist/locales/index.d.cts +5 -0
  220. package/dist/locales/index.d.ts +5 -0
  221. package/dist/locales/index.js +6 -0
  222. package/dist/locales/index.js.map +1 -0
  223. package/dist/memoryRecords-AWDKUJ2F.cjs +50 -0
  224. package/dist/memoryRecords-AWDKUJ2F.cjs.map +1 -0
  225. package/dist/memoryRecords-OJTGXLRH.js +47 -0
  226. package/dist/memoryRecords-OJTGXLRH.js.map +1 -0
  227. package/dist/pagedFooterTotals-DXCGDO6F.cjs +27 -0
  228. package/dist/pagedFooterTotals-DXCGDO6F.cjs.map +1 -0
  229. package/dist/pagedFooterTotals-ORWKUNE7.js +25 -0
  230. package/dist/pagedFooterTotals-ORWKUNE7.js.map +1 -0
  231. package/dist/pagedKit-MFGAJFSK.cjs +134 -0
  232. package/dist/pagedKit-MFGAJFSK.cjs.map +1 -0
  233. package/dist/pagedKit-WYWY4LRV.js +127 -0
  234. package/dist/pagedKit-WYWY4LRV.js.map +1 -0
  235. package/dist/pagedSearch-HCPJW7VM.js +38 -0
  236. package/dist/pagedSearch-HCPJW7VM.js.map +1 -0
  237. package/dist/pagedSearch-U3WCG4GN.cjs +42 -0
  238. package/dist/pagedSearch-U3WCG4GN.cjs.map +1 -0
  239. package/dist/plugins/csv.cjs +124 -0
  240. package/dist/plugins/csv.cjs.map +1 -0
  241. package/dist/plugins/csv.d.cts +44 -0
  242. package/dist/plugins/csv.d.ts +44 -0
  243. package/dist/plugins/csv.js +120 -0
  244. package/dist/plugins/csv.js.map +1 -0
  245. package/dist/plugins/excel.cjs +52 -0
  246. package/dist/plugins/excel.cjs.map +1 -0
  247. package/dist/plugins/excel.d.cts +14 -0
  248. package/dist/plugins/excel.d.ts +14 -0
  249. package/dist/plugins/excel.js +7 -0
  250. package/dist/plugins/excel.js.map +1 -0
  251. package/dist/plugins/pdf/fonts/vazirmatn.cjs +50 -0
  252. package/dist/plugins/pdf/fonts/vazirmatn.cjs.map +1 -0
  253. package/dist/plugins/pdf/fonts/vazirmatn.d.cts +24 -0
  254. package/dist/plugins/pdf/fonts/vazirmatn.d.ts +24 -0
  255. package/dist/plugins/pdf/fonts/vazirmatn.js +39 -0
  256. package/dist/plugins/pdf/fonts/vazirmatn.js.map +1 -0
  257. package/dist/plugins/pdf.cjs +24 -0
  258. package/dist/plugins/pdf.cjs.map +1 -0
  259. package/dist/plugins/pdf.d.cts +21 -0
  260. package/dist/plugins/pdf.d.ts +21 -0
  261. package/dist/plugins/pdf.js +7 -0
  262. package/dist/plugins/pdf.js.map +1 -0
  263. package/dist/presence.cjs +56 -0
  264. package/dist/presence.cjs.map +1 -0
  265. package/dist/presence.d.cts +17 -0
  266. package/dist/presence.d.ts +17 -0
  267. package/dist/presence.js +54 -0
  268. package/dist/presence.js.map +1 -0
  269. package/dist/rebuildRowVisibility-66EAZ356.cjs +21 -0
  270. package/dist/rebuildRowVisibility-66EAZ356.cjs.map +1 -0
  271. package/dist/rebuildRowVisibility-6TYM5BP2.js +19 -0
  272. package/dist/rebuildRowVisibility-6TYM5BP2.js.map +1 -0
  273. package/dist/styles.css +1440 -0
  274. package/dist/sync.cjs +148 -0
  275. package/dist/sync.cjs.map +1 -0
  276. package/dist/sync.d.cts +17 -0
  277. package/dist/sync.d.ts +17 -0
  278. package/dist/sync.js +146 -0
  279. package/dist/sync.js.map +1 -0
  280. package/dist/types-D__47BKv.d.cts +23 -0
  281. package/dist/types-D__47BKv.d.ts +23 -0
  282. package/package.json +185 -29
@@ -0,0 +1,840 @@
1
+ 'use strict';
2
+
3
+ var chunk72IVAOTK_cjs = require('./chunk-72IVAOTK.cjs');
4
+ var chunkIMPCRWYP_cjs = require('./chunk-IMPCRWYP.cjs');
5
+ var chunkF6EMC75A_cjs = require('./chunk-F6EMC75A.cjs');
6
+ var fflate = require('fflate');
7
+
8
+ // packages/plugins/excel/src/ExcelExportPlugin.ts
9
+ var ExcelExportPlugin = class {
10
+ constructor(options = {}) {
11
+ this.options = options;
12
+ this.name = "excel-export";
13
+ this.unsub = null;
14
+ }
15
+ register(ctx) {
16
+ this.unsub = ctx.bus.subscribeAll((event) => {
17
+ void this.onEvent(ctx, event);
18
+ });
19
+ }
20
+ dispose() {
21
+ this.unsub?.();
22
+ this.unsub = null;
23
+ }
24
+ async onEvent(ctx, event) {
25
+ if (event.type !== "EXPORT_REQUESTED") return;
26
+ if (event.tableId !== ctx.tableId) return;
27
+ const payload = event.payload;
28
+ if (payload.format !== "xlsx") return;
29
+ try {
30
+ const source = ctx.query.getExportSource(payload.collectionScope ?? "active");
31
+ if (!source) {
32
+ throw new Error("NO_EXPORT_SOURCE");
33
+ }
34
+ const table = chunk72IVAOTK_cjs.buildExportTable(source);
35
+ if (table.columns.length === 0 && table.rows.length === 0) {
36
+ throw new Error("NO_COLUMNS");
37
+ }
38
+ const fileName = payload.fileName ?? `export-${(/* @__PURE__ */ new Date()).toISOString().slice(0, 10)}.xlsx`;
39
+ const blob = chunkIMPCRWYP_cjs.buildXlsxBlob(table, {
40
+ sheetName: payload.sheetName,
41
+ direction: payload.direction ?? "rtl"
42
+ });
43
+ const columnCount = table.columns.length + 1;
44
+ const rowCount = table.rows.length;
45
+ if (this.options.download !== false) {
46
+ chunkIMPCRWYP_cjs.downloadBlob(blob, fileName);
47
+ }
48
+ this.options.onBlob?.(blob, { fileName, rowCount, columnCount });
49
+ await ctx.bus.publish({
50
+ eventId: `${Date.now()}-xlsx-ok`,
51
+ type: "XLSX_EXPORT_COMPLETED",
52
+ tableId: ctx.tableId,
53
+ streamId: `table/${ctx.tableId}/view`,
54
+ version: 0,
55
+ occurredAt: Date.now(),
56
+ actorId: event.actorId,
57
+ correlationId: event.correlationId,
58
+ causationId: event.eventId,
59
+ payload: {
60
+ format: "xlsx",
61
+ rowCount,
62
+ columnCount
63
+ }
64
+ });
65
+ } catch (err) {
66
+ const message = err instanceof Error ? err.message : String(err);
67
+ await ctx.bus.publish({
68
+ eventId: `${Date.now()}-xlsx-fail`,
69
+ type: "XLSX_EXPORT_FAILED",
70
+ tableId: ctx.tableId,
71
+ streamId: `table/${ctx.tableId}/view`,
72
+ version: 0,
73
+ occurredAt: Date.now(),
74
+ actorId: event.actorId,
75
+ correlationId: event.correlationId,
76
+ causationId: event.eventId,
77
+ payload: {
78
+ format: "xlsx",
79
+ code: message === "NO_COLUMNS" || message === "NO_EXPORT_SOURCE" ? message : "EXPORT_FAILED",
80
+ message
81
+ }
82
+ });
83
+ }
84
+ }
85
+ };
86
+
87
+ // packages/plugins/excel/src/applyImportedRows.ts
88
+ async function applyImportedRows(session, rows) {
89
+ if (rows.length === 0) {
90
+ return { rowCount: 0 };
91
+ }
92
+ const stamp = Date.now();
93
+ const engine = session.getEngine();
94
+ const payload = rows.map((cells, i) => [
95
+ {
96
+ key: "index",
97
+ value: `import-${stamp}-${i}`,
98
+ display: `import-${stamp}-${i}`
99
+ },
100
+ ...cells.filter((c) => c.key !== "index")
101
+ ]);
102
+ await engine.dispatch({
103
+ type: "ADD_NEW_ROWS",
104
+ store: session.store,
105
+ tableKey: session.tableKey,
106
+ detailFieldKey: "index",
107
+ rows: payload,
108
+ autoActivate: false
109
+ });
110
+ return { rowCount: rows.length };
111
+ }
112
+
113
+ // packages/plugins/excel/src/mapImportedSheet.ts
114
+ function normalizeHeader(h) {
115
+ return h.trim().toLowerCase().replace(/\s+/g, " ");
116
+ }
117
+ function coerceValue(raw, fieldType) {
118
+ const text = raw.trim();
119
+ if (text === "") return "";
120
+ switch (fieldType) {
121
+ case "number":
122
+ case "price": {
123
+ const n = Number(text.replace(/,/g, ""));
124
+ return Number.isFinite(n) ? n : text;
125
+ }
126
+ case "checkbox": {
127
+ const lower = text.toLowerCase();
128
+ if (["1", "true", "yes", "\u2714", "y"].includes(lower)) return true;
129
+ if (["0", "false", "no", "\u2718", "n"].includes(lower)) return false;
130
+ return text;
131
+ }
132
+ default:
133
+ return text;
134
+ }
135
+ }
136
+ function mapImportedSheet(sheet, columns) {
137
+ const importable = columns.filter(
138
+ (c) => c.fieldName !== "index" && c.fieldType !== "index" && c.fieldType !== "static"
139
+ );
140
+ const byCaption = /* @__PURE__ */ new Map();
141
+ const byField = /* @__PURE__ */ new Map();
142
+ for (const col of importable) {
143
+ byField.set(normalizeHeader(col.fieldName), col);
144
+ if (col.fieldCaption) {
145
+ byCaption.set(normalizeHeader(col.fieldCaption), col);
146
+ }
147
+ }
148
+ const mappedCols = [];
149
+ sheet.headers.forEach((header, colIndex) => {
150
+ const key = normalizeHeader(header);
151
+ if (!key) return;
152
+ const col = byCaption.get(key) ?? byField.get(key);
153
+ if (!col) return;
154
+ if (mappedCols.some((m) => m.fieldName === col.fieldName)) return;
155
+ mappedCols.push({
156
+ fieldName: col.fieldName,
157
+ fieldType: col.fieldType,
158
+ colIndex
159
+ });
160
+ });
161
+ if (mappedCols.length === 0 && sheet.headers.length > 0) {
162
+ importable.forEach((col, i) => {
163
+ if (i < sheet.headers.length) {
164
+ mappedCols.push({
165
+ fieldName: col.fieldName,
166
+ fieldType: col.fieldType,
167
+ colIndex: i
168
+ });
169
+ }
170
+ });
171
+ }
172
+ const rows = sheet.rows.map(
173
+ (line) => mappedCols.map((m) => {
174
+ const raw = line[m.colIndex] ?? "";
175
+ const value = coerceValue(raw, m.fieldType);
176
+ return { key: m.fieldName, value, display: value };
177
+ })
178
+ );
179
+ return {
180
+ columns: mappedCols.map(({ fieldName, fieldType }) => ({
181
+ fieldName,
182
+ fieldType
183
+ })),
184
+ rows
185
+ };
186
+ }
187
+ var textDecoder = new TextDecoder("utf-8");
188
+ function toUint8Array(data) {
189
+ if (data instanceof Uint8Array) return Promise.resolve(data);
190
+ if (data instanceof ArrayBuffer) return Promise.resolve(new Uint8Array(data));
191
+ return data.arrayBuffer().then((buf) => new Uint8Array(buf));
192
+ }
193
+ function decodeXml(bytes) {
194
+ return fflate.strFromU8(bytes) || textDecoder.decode(bytes);
195
+ }
196
+ function colIndexFromRef(ref) {
197
+ const letters = ref.match(/^([A-Za-z]+)/)?.[1];
198
+ if (!letters) return 0;
199
+ let n = 0;
200
+ for (const ch of letters.toUpperCase()) {
201
+ n = n * 26 + (ch.charCodeAt(0) - 64);
202
+ }
203
+ return n - 1;
204
+ }
205
+ function parseSharedStrings(xml) {
206
+ const out = [];
207
+ const siRe = /<si\b[^>]*>([\s\S]*?)<\/si>/gi;
208
+ let m;
209
+ while (m = siRe.exec(xml)) {
210
+ const inner = m[1];
211
+ const parts = [];
212
+ const tRe = /<t\b[^>]*>([\s\S]*?)<\/t>/gi;
213
+ let tm;
214
+ while (tm = tRe.exec(inner)) {
215
+ parts.push(decodeXmlEntities(tm[1]));
216
+ }
217
+ out.push(parts.join(""));
218
+ }
219
+ return out;
220
+ }
221
+ function decodeXmlEntities(s) {
222
+ return s.replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&apos;/g, "'").replace(/&amp;/g, "&");
223
+ }
224
+ function findSheetPath(files, sheetName) {
225
+ const preferred = "xl/worksheets/sheet1.xml";
226
+ if (!sheetName) {
227
+ if (files[preferred]) return preferred;
228
+ const first = Object.keys(files).find(
229
+ (k) => /^xl\/worksheets\/sheet\d+\.xml$/i.test(k)
230
+ );
231
+ if (!first) throw new Error("NO_SHEET");
232
+ return first;
233
+ }
234
+ const workbook = files["xl/workbook.xml"];
235
+ if (!workbook) throw new Error("NO_WORKBOOK");
236
+ const wbXml = decodeXml(workbook);
237
+ const sheetRe = /<sheet\b[^>]*name="([^"]+)"[^>]*r:id="([^"]+)"[^>]*\/?>/gi;
238
+ const nameToRid = /* @__PURE__ */ new Map();
239
+ let sm;
240
+ while (sm = sheetRe.exec(wbXml)) {
241
+ nameToRid.set(sm[1], sm[2]);
242
+ }
243
+ const rid = nameToRid.get(sheetName);
244
+ if (!rid) throw new Error("SHEET_NOT_FOUND");
245
+ const rels = files["xl/_rels/workbook.xml.rels"];
246
+ if (!rels) throw new Error("NO_RELS");
247
+ const relsXml = decodeXml(rels);
248
+ const relRe = /<Relationship\b[^>]*Id="([^"]+)"[^>]*Target="([^"]+)"[^>]*\/?>/gi;
249
+ let rm;
250
+ while (rm = relRe.exec(relsXml)) {
251
+ if (rm[1] === rid) {
252
+ const target = rm[2].replace(/^\//, "");
253
+ const path = target.startsWith("xl/") ? target : `xl/${target}`;
254
+ if (!files[path]) throw new Error("NO_SHEET");
255
+ return path;
256
+ }
257
+ }
258
+ throw new Error("SHEET_NOT_FOUND");
259
+ }
260
+ function parseSheetRows(sheetXml, shared) {
261
+ const rowRe = /<row\b[^>]*>([\s\S]*?)<\/row>/gi;
262
+ const matrix = [];
263
+ let rowMatch;
264
+ while (rowMatch = rowRe.exec(sheetXml)) {
265
+ const rowXml = rowMatch[1];
266
+ const cells = [];
267
+ const cellRe = /<c\b([^>]*)>([\s\S]*?)<\/c>|<c\b([^>]*)\/>/gi;
268
+ let cm;
269
+ while (cm = cellRe.exec(rowXml)) {
270
+ const attrs = cm[1] ?? cm[3] ?? "";
271
+ const body = cm[2] ?? "";
272
+ const ref = attrs.match(/\br="([^"]+)"/)?.[1] ?? "";
273
+ const t = attrs.match(/\bt="([^"]+)"/)?.[1] ?? "";
274
+ const col = colIndexFromRef(ref);
275
+ let text = "";
276
+ if (t === "inlineStr") {
277
+ const tm = body.match(/<t\b[^>]*>([\s\S]*?)<\/t>/i);
278
+ text = tm ? decodeXmlEntities(tm[1]) : "";
279
+ } else if (t === "s") {
280
+ const vm = body.match(/<v\b[^>]*>([\s\S]*?)<\/v>/i);
281
+ const idx = vm ? Number(vm[1]) : -1;
282
+ text = idx >= 0 ? shared[idx] ?? "" : "";
283
+ } else {
284
+ const vm = body.match(/<v\b[^>]*>([\s\S]*?)<\/v>/i);
285
+ text = vm ? decodeXmlEntities(vm[1]) : "";
286
+ }
287
+ cells.push({ col, text });
288
+ }
289
+ matrix.push(cells);
290
+ }
291
+ if (matrix.length === 0) {
292
+ return { headers: [], rows: [] };
293
+ }
294
+ const maxCol = Math.max(
295
+ 0,
296
+ ...matrix.flatMap((r) => r.map((c) => c.col))
297
+ );
298
+ const dense = matrix.map((rowCells) => {
299
+ const line = Array.from({ length: maxCol + 1 }, () => "");
300
+ for (const c of rowCells) {
301
+ if (c.col >= 0 && c.col <= maxCol) line[c.col] = c.text;
302
+ }
303
+ return line;
304
+ });
305
+ const header = dense[0] ?? [];
306
+ const rowHeaderHints = /* @__PURE__ */ new Set(["\u0631\u062F\u06CC\u0641", "row", "#", "row \xB7 actions", "row number"]);
307
+ const dropFirst = header.length > 1 && rowHeaderHints.has(header[0].trim().toLowerCase());
308
+ const slice = (line) => dropFirst ? line.slice(1) : line;
309
+ const headers = slice(header).map((h) => h.trim());
310
+ const rows = dense.slice(1).map(slice).map((line) => {
311
+ const padded = Array.from({ length: headers.length }, (_, i) => line[i] ?? "");
312
+ return padded;
313
+ }).filter((line) => line.some((c) => c.trim() !== ""));
314
+ return { headers, rows };
315
+ }
316
+ async function parseXlsxBlob(data, options) {
317
+ const bytes = await toUint8Array(data);
318
+ let files;
319
+ try {
320
+ files = fflate.unzipSync(bytes);
321
+ } catch {
322
+ throw new Error("INVALID_XLSX");
323
+ }
324
+ const sharedPath = Object.keys(files).find(
325
+ (k) => /xl\/sharedStrings\.xml$/i.test(k)
326
+ );
327
+ const shared = sharedPath ? parseSharedStrings(decodeXml(files[sharedPath])) : [];
328
+ const sheetPath = findSheetPath(files, options?.sheetName);
329
+ return parseSheetRows(decodeXml(files[sheetPath]), shared);
330
+ }
331
+
332
+ // packages/plugins/excel/src/ExcelImportPlugin.ts
333
+ var ExcelImportPlugin = class {
334
+ constructor(options = {}) {
335
+ this.options = options;
336
+ this.name = "excel-import";
337
+ this.unsub = null;
338
+ }
339
+ register(ctx) {
340
+ this.unsub = ctx.bus.subscribeAll((event) => {
341
+ void this.onEvent(ctx, event);
342
+ });
343
+ }
344
+ dispose() {
345
+ this.unsub?.();
346
+ this.unsub = null;
347
+ }
348
+ async onEvent(ctx, event) {
349
+ if (event.type !== "IMPORT_REQUESTED") return;
350
+ if (event.tableId !== ctx.tableId) return;
351
+ const payload = event.payload;
352
+ if (payload.format !== "xlsx") return;
353
+ try {
354
+ const correlationId = event.correlationId;
355
+ if (!correlationId) {
356
+ throw new Error("NO_IMPORT_DATA");
357
+ }
358
+ const bytes = ctx.resolveImportData?.(correlationId);
359
+ if (!bytes || bytes.byteLength === 0) {
360
+ throw new Error("NO_IMPORT_DATA");
361
+ }
362
+ const source = ctx.query.getExportSource(payload.collectionScope ?? "active");
363
+ if (!source) {
364
+ throw new Error("NO_IMPORT_TARGET");
365
+ }
366
+ const sheet = await parseXlsxBlob(bytes, {
367
+ sheetName: payload.sheetName
368
+ });
369
+ if (sheet.headers.length === 0) {
370
+ throw new Error("NO_COLUMNS");
371
+ }
372
+ const mapped = mapImportedSheet(sheet, source.columns);
373
+ if (mapped.columns.length === 0) {
374
+ throw new Error("NO_COLUMN_MATCH");
375
+ }
376
+ const { rowCount } = await applyImportedRows(ctx.session, mapped.rows);
377
+ const columnCount = mapped.columns.length;
378
+ this.options.onImported?.({ rowCount, columnCount });
379
+ await ctx.bus.publish({
380
+ eventId: `${Date.now()}-xlsx-import-ok`,
381
+ type: "XLSX_IMPORT_COMPLETED",
382
+ tableId: ctx.tableId,
383
+ streamId: `table/${ctx.tableId}/view`,
384
+ version: 0,
385
+ occurredAt: Date.now(),
386
+ actorId: event.actorId,
387
+ correlationId: event.correlationId,
388
+ causationId: event.eventId,
389
+ payload: {
390
+ format: "xlsx",
391
+ rowCount,
392
+ columnCount
393
+ }
394
+ });
395
+ } catch (err) {
396
+ const message = err instanceof Error ? err.message : String(err);
397
+ const known = /* @__PURE__ */ new Set([
398
+ "NO_IMPORT_DATA",
399
+ "NO_IMPORT_TARGET",
400
+ "NO_COLUMNS",
401
+ "NO_COLUMN_MATCH",
402
+ "INVALID_XLSX",
403
+ "NO_SHEET",
404
+ "SHEET_NOT_FOUND"
405
+ ]);
406
+ await ctx.bus.publish({
407
+ eventId: `${Date.now()}-xlsx-import-fail`,
408
+ type: "XLSX_IMPORT_FAILED",
409
+ tableId: ctx.tableId,
410
+ streamId: `table/${ctx.tableId}/view`,
411
+ version: 0,
412
+ occurredAt: Date.now(),
413
+ actorId: event.actorId,
414
+ correlationId: event.correlationId,
415
+ causationId: event.eventId,
416
+ payload: {
417
+ format: "xlsx",
418
+ code: known.has(message) ? message : "IMPORT_FAILED",
419
+ message
420
+ }
421
+ });
422
+ }
423
+ }
424
+ };
425
+
426
+ // packages/plugins/excel/src/exportActiveCollectionToExcelStreaming.ts
427
+ var EMPTY_PLACEHOLDERS = /* @__PURE__ */ new Set(["\u0627\u0646\u062A\u062E\u0627\u0628 \u06A9\u0646\u06CC\u062F", "select", "Select"]);
428
+ var escapeXml = (value) => value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;");
429
+ var hasMeaningfulValue = (value) => value !== void 0 && value !== null && value !== "";
430
+ var getExportColumns = (controller) => {
431
+ const view = controller.getViewState();
432
+ const columns = view?.activeCollectionColumn?.length ? view.activeCollectionColumn : view?.columns ?? [];
433
+ return columns.filter((col) => col.fieldType !== "index").sort((a, b) => (a.order ?? 0) - (b.order ?? 0));
434
+ };
435
+ var isExportableRecord = (record) => {
436
+ if (record.rowState === "Delete" /* Deleted */) return false;
437
+ return Object.entries(record.cells).some(
438
+ ([key, cell]) => key !== "index" && hasMeaningfulValue(cell.value)
439
+ );
440
+ };
441
+ var getRecordExportText = (record, column) => {
442
+ const cell = record.cells[column.fieldName];
443
+ if (!cell) return "";
444
+ const raw = cell.display ?? cell.value;
445
+ if (!hasMeaningfulValue(raw)) return "";
446
+ const text = chunkF6EMC75A_cjs.formatExportValue(raw, column.fieldType).trim();
447
+ if (!text || EMPTY_PLACEHOLDERS.has(text)) return "";
448
+ return text;
449
+ };
450
+ var toColumnLetter = (index) => {
451
+ let n = index + 1;
452
+ let result = "";
453
+ while (n > 0) {
454
+ const rem = (n - 1) % 26;
455
+ result = String.fromCharCode(65 + rem) + result;
456
+ n = Math.floor((n - 1) / 26);
457
+ }
458
+ return result;
459
+ };
460
+ var crcTable = (() => {
461
+ const table = new Uint32Array(256);
462
+ for (let i = 0; i < 256; i += 1) {
463
+ let c = i;
464
+ for (let k = 0; k < 8; k += 1) {
465
+ c = c & 1 ? 3988292384 ^ c >>> 1 : c >>> 8;
466
+ c = c >>> 0;
467
+ }
468
+ table[i] = c >>> 0;
469
+ }
470
+ return table;
471
+ })();
472
+ var crc32 = (data) => {
473
+ let crc = 4294967295;
474
+ for (let i = 0; i < data.length; i += 1) {
475
+ crc = crcTable[(crc ^ data[i]) & 255] ^ crc >>> 8;
476
+ }
477
+ return (crc ^ 4294967295) >>> 0;
478
+ };
479
+ var IncrementalCrc = class {
480
+ constructor() {
481
+ this.crc = 4294967295;
482
+ this.length = 0;
483
+ }
484
+ update(data) {
485
+ for (let i = 0; i < data.length; i += 1) {
486
+ this.crc = crcTable[(this.crc ^ data[i]) & 255] ^ this.crc >>> 8;
487
+ this.crc = this.crc >>> 0;
488
+ }
489
+ this.length += data.length;
490
+ }
491
+ finish() {
492
+ return { crc: (this.crc ^ 4294967295) >>> 0, size: this.length };
493
+ }
494
+ };
495
+ var textEncoder = new TextEncoder();
496
+ var buildZip = (entries) => {
497
+ const parts = [];
498
+ const centralParts = [];
499
+ let offset = 0;
500
+ for (const entry of entries) {
501
+ const nameBytes = textEncoder.encode(entry.name);
502
+ const data = entry.data;
503
+ const size = entry.size ?? (data instanceof Uint8Array ? data.length : data.size);
504
+ const crc = entry.crc ?? (data instanceof Uint8Array ? crc32(data) : 0);
505
+ const local = new Uint8Array(30 + nameBytes.length);
506
+ const lv = new DataView(local.buffer);
507
+ lv.setUint32(0, 67324752, true);
508
+ lv.setUint16(4, 20, true);
509
+ lv.setUint16(6, 0, true);
510
+ lv.setUint16(8, 0, true);
511
+ lv.setUint16(10, 0, true);
512
+ lv.setUint16(12, 0, true);
513
+ lv.setUint32(14, crc, true);
514
+ lv.setUint32(18, size, true);
515
+ lv.setUint32(22, size, true);
516
+ lv.setUint16(26, nameBytes.length, true);
517
+ lv.setUint16(28, 0, true);
518
+ local.set(nameBytes, 30);
519
+ parts.push(local, data);
520
+ const central = new Uint8Array(46 + nameBytes.length);
521
+ const cv = new DataView(central.buffer);
522
+ cv.setUint32(0, 33639248, true);
523
+ cv.setUint16(4, 20, true);
524
+ cv.setUint16(6, 20, true);
525
+ cv.setUint16(8, 0, true);
526
+ cv.setUint16(10, 0, true);
527
+ cv.setUint16(12, 0, true);
528
+ cv.setUint16(14, 0, true);
529
+ cv.setUint32(16, crc, true);
530
+ cv.setUint32(20, size, true);
531
+ cv.setUint32(24, size, true);
532
+ cv.setUint16(28, nameBytes.length, true);
533
+ cv.setUint16(30, 0, true);
534
+ cv.setUint16(32, 0, true);
535
+ cv.setUint16(34, 0, true);
536
+ cv.setUint16(36, 0, true);
537
+ cv.setUint32(38, 0, true);
538
+ cv.setUint32(42, offset, true);
539
+ central.set(nameBytes, 46);
540
+ centralParts.push(central);
541
+ offset += local.length + size;
542
+ }
543
+ const centralSize = centralParts.reduce((sum, p) => sum + p.length, 0);
544
+ const end = new Uint8Array(22);
545
+ const ev = new DataView(end.buffer);
546
+ ev.setUint32(0, 101010256, true);
547
+ ev.setUint16(4, 0, true);
548
+ ev.setUint16(6, 0, true);
549
+ ev.setUint16(8, entries.length, true);
550
+ ev.setUint16(10, entries.length, true);
551
+ ev.setUint32(12, centralSize, true);
552
+ ev.setUint32(16, offset, true);
553
+ ev.setUint16(20, 0, true);
554
+ return new Blob([...parts, ...centralParts, end], {
555
+ type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
556
+ });
557
+ };
558
+ var buildStylesXml = (direction) => {
559
+ const readingOrder = direction === "rtl" ? 2 : 1;
560
+ const horizontal = direction === "rtl" ? "right" : "left";
561
+ return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
562
+ <styleSheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
563
+ <fonts count="3">
564
+ <font><sz val="10"/><name val="Tahoma"/></font>
565
+ <font><b/><sz val="11"/><color rgb="FFFFFFFF"/><name val="Tahoma"/></font>
566
+ <font><b/><sz val="10"/><name val="Tahoma"/></font>
567
+ </fonts>
568
+ <fills count="4">
569
+ <fill><patternFill patternType="none"/></fill>
570
+ <fill><patternFill patternType="gray125"/></fill>
571
+ <fill><patternFill patternType="solid"><fgColor rgb="FF2F5496"/></patternFill></fill>
572
+ <fill><patternFill patternType="solid"><fgColor rgb="FFD6EAF8"/></patternFill></fill>
573
+ </fills>
574
+ <borders count="2">
575
+ <border><left/><right/><top/><bottom/><diagonal/></border>
576
+ <border>
577
+ <left style="thin"><color rgb="FFBDD7EE"/></left>
578
+ <right style="thin"><color rgb="FFBDD7EE"/></right>
579
+ <top style="thin"><color rgb="FFBDD7EE"/></top>
580
+ <bottom style="thin"><color rgb="FFBDD7EE"/></bottom>
581
+ </border>
582
+ </borders>
583
+ <cellStyleXfs count="1">
584
+ <xf numFmtId="0" fontId="0" fillId="0" borderId="0"/>
585
+ </cellStyleXfs>
586
+ <cellXfs count="6">
587
+ <xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0"/>
588
+ <xf numFmtId="0" fontId="1" fillId="2" borderId="1" xfId="0" applyFont="1" applyFill="1" applyBorder="1" applyAlignment="1">
589
+ <alignment horizontal="center" vertical="center" wrapText="1" readingOrder="${readingOrder}"/>
590
+ </xf>
591
+ <xf numFmtId="0" fontId="0" fillId="3" borderId="1" xfId="0" applyFill="1" applyBorder="1" applyAlignment="1">
592
+ <alignment horizontal="${horizontal}" vertical="center" readingOrder="${readingOrder}"/>
593
+ </xf>
594
+ <xf numFmtId="0" fontId="0" fillId="0" borderId="1" xfId="0" applyBorder="1" applyAlignment="1">
595
+ <alignment horizontal="${horizontal}" vertical="center" readingOrder="${readingOrder}"/>
596
+ </xf>
597
+ <xf numFmtId="0" fontId="2" fillId="3" borderId="1" xfId="0" applyFont="1" applyFill="1" applyBorder="1" applyAlignment="1">
598
+ <alignment horizontal="center" vertical="center" readingOrder="${readingOrder}"/>
599
+ </xf>
600
+ <xf numFmtId="0" fontId="2" fillId="0" borderId="1" xfId="0" applyFont="1" applyBorder="1" applyAlignment="1">
601
+ <alignment horizontal="center" vertical="center" readingOrder="${readingOrder}"/>
602
+ </xf>
603
+ </cellXfs>
604
+ </styleSheet>`;
605
+ };
606
+ var inlineStrCell = (ref, text, styleId) => `<c r="${ref}" t="inlineStr" s="${styleId}"><is><t>${escapeXml(text)}</t></is></c>`;
607
+ var numberCell = (ref, value, styleId) => `<c r="${ref}" s="${styleId}"><v>${value}</v></c>`;
608
+ var recordToRowXml = (record, columns, excelRow) => {
609
+ const isOdd = (excelRow - 2) % 2 === 0;
610
+ const dataStyle = isOdd ? 2 : 3;
611
+ const rowNumStyle = isOdd ? 4 : 5;
612
+ const cells = [
613
+ numberCell(`A${excelRow}`, excelRow - 1, rowNumStyle),
614
+ ...columns.map(
615
+ (col, i) => inlineStrCell(
616
+ `${toColumnLetter(i + 1)}${excelRow}`,
617
+ getRecordExportText(record, col),
618
+ dataStyle
619
+ )
620
+ )
621
+ ].join("");
622
+ return `<row r="${excelRow}" ht="18" customHeight="1">${cells}</row>`;
623
+ };
624
+ var buildSheetHeaderXml = (columns, options) => {
625
+ const { direction, rowHeaderLabel } = options;
626
+ const rightToLeft = direction === "rtl" ? "1" : "0";
627
+ const totalCols = columns.length + 1;
628
+ const colsXml = Array.from({ length: totalCols }, (_, i) => {
629
+ const width = i === 0 ? 6 : 18;
630
+ return `<col min="${i + 1}" max="${i + 1}" width="${width}" customWidth="1"/>`;
631
+ }).join("");
632
+ const headerCells = [
633
+ inlineStrCell("A1", rowHeaderLabel, 1),
634
+ ...columns.map(
635
+ (col, i) => inlineStrCell(
636
+ `${toColumnLetter(i + 1)}1`,
637
+ col.fieldCaption ?? col.fieldName,
638
+ 1
639
+ )
640
+ )
641
+ ].join("");
642
+ return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
643
+ <worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">
644
+ <sheetViews>
645
+ <sheetView workbookViewId="0" rightToLeft="${rightToLeft}"/>
646
+ </sheetViews>
647
+ <cols>${colsXml}</cols>
648
+ <sheetData>
649
+ <row r="1" ht="22" customHeight="1">${headerCells}</row>`;
650
+ };
651
+ var findColumnsWithData = async (controller, candidates) => {
652
+ const pending = new Set(candidates.map((c) => c.fieldName));
653
+ const byField = new Map(candidates.map((c) => [c.fieldName, c]));
654
+ await controller.iterateRowsFromDb("active", async (records) => {
655
+ for (const record of records) {
656
+ if (!isExportableRecord(record)) continue;
657
+ for (const field of Array.from(pending)) {
658
+ if (getRecordExportText(record, byField.get(field)) !== "") {
659
+ pending.delete(field);
660
+ }
661
+ }
662
+ if (pending.size === 0) return false;
663
+ }
664
+ });
665
+ return candidates.filter((c) => !pending.has(c.fieldName));
666
+ };
667
+ var buildSheetBlobStreaming = async (controller, columns, options) => {
668
+ const crc = new IncrementalCrc();
669
+ const blobParts = [];
670
+ let pendingChunks = [];
671
+ let pendingBytes = 0;
672
+ let rowCount = 0;
673
+ const pushChunk = (text) => {
674
+ const bytes = textEncoder.encode(text);
675
+ crc.update(bytes);
676
+ pendingChunks.push(bytes);
677
+ pendingBytes += bytes.length;
678
+ if (pendingBytes >= 4 * 1024 * 1024) {
679
+ blobParts.push(new Blob(pendingChunks));
680
+ pendingChunks = [];
681
+ pendingBytes = 0;
682
+ }
683
+ };
684
+ pushChunk(buildSheetHeaderXml(columns, options));
685
+ await controller.iterateRowsFromDb("active", async (records) => {
686
+ for (const record of records) {
687
+ if (!isExportableRecord(record)) continue;
688
+ rowCount += 1;
689
+ pushChunk(recordToRowXml(record, columns, rowCount + 1));
690
+ }
691
+ });
692
+ pushChunk(`
693
+ </sheetData>
694
+ </worksheet>`);
695
+ if (pendingChunks.length > 0) {
696
+ blobParts.push(new Blob(pendingChunks));
697
+ }
698
+ const { crc: sheetCrc, size } = crc.finish();
699
+ return { blob: new Blob(blobParts), rowCount, crc: sheetCrc, size };
700
+ };
701
+ var downloadBlob2 = (blob, fileName) => {
702
+ const url = URL.createObjectURL(blob);
703
+ const anchor = document.createElement("a");
704
+ anchor.href = url;
705
+ anchor.download = fileName;
706
+ document.body.appendChild(anchor);
707
+ anchor.click();
708
+ document.body.removeChild(anchor);
709
+ URL.revokeObjectURL(url);
710
+ };
711
+ async function exportActiveCollectionToExcelStreaming(controller, options) {
712
+ const allColumns = getExportColumns(controller);
713
+ const columns = await findColumnsWithData(controller, allColumns);
714
+ const direction = options?.direction ?? "rtl";
715
+ const rowHeaderLabel = options?.rowHeaderLabel ?? "\u0631\u062F\u06CC\u0641";
716
+ const sheetName = options?.sheetName ?? "Sheet1";
717
+ const fileName = options?.fileName ?? `export-${(/* @__PURE__ */ new Date()).toISOString().slice(0, 10)}.xlsx`;
718
+ await new Promise((resolve) => {
719
+ if (typeof setTimeout === "function") setTimeout(resolve, 0);
720
+ else resolve();
721
+ });
722
+ const { blob: sheetBlob, rowCount, crc: sheetCrc, size: sheetSize } = await buildSheetBlobStreaming(controller, columns, {
723
+ direction,
724
+ rowHeaderLabel
725
+ });
726
+ if (columns.length === 0 && rowCount === 0) {
727
+ throw new Error("NO_COLUMNS");
728
+ }
729
+ const safeSheetName = (sheetName.slice(0, 31) || "Sheet1").replace(
730
+ /[\\/*?:\[\]]/g,
731
+ ""
732
+ );
733
+ const contentTypes = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
734
+ <Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">
735
+ <Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/>
736
+ <Default Extension="xml" ContentType="application/xml"/>
737
+ <Override PartName="/xl/workbook.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"/>
738
+ <Override PartName="/xl/worksheets/sheet1.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"/>
739
+ <Override PartName="/xl/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml"/>
740
+ </Types>`;
741
+ const rootRels = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
742
+ <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
743
+ <Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="xl/workbook.xml"/>
744
+ </Relationships>`;
745
+ const workbook = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
746
+ <workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">
747
+ <sheets>
748
+ <sheet name="${escapeXml(safeSheetName)}" sheetId="1" r:id="rId1"/>
749
+ </sheets>
750
+ </workbook>`;
751
+ const workbookRels = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
752
+ <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
753
+ <Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/sheet1.xml"/>
754
+ <Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml"/>
755
+ </Relationships>`;
756
+ const styles = buildStylesXml(direction);
757
+ const zip = buildZip([
758
+ { name: "[Content_Types].xml", data: textEncoder.encode(contentTypes) },
759
+ { name: "_rels/.rels", data: textEncoder.encode(rootRels) },
760
+ { name: "xl/workbook.xml", data: textEncoder.encode(workbook) },
761
+ {
762
+ name: "xl/_rels/workbook.xml.rels",
763
+ data: textEncoder.encode(workbookRels)
764
+ },
765
+ { name: "xl/styles.xml", data: textEncoder.encode(styles) },
766
+ {
767
+ name: "xl/worksheets/sheet1.xml",
768
+ data: sheetBlob,
769
+ crc: sheetCrc,
770
+ size: sheetSize
771
+ }
772
+ ]);
773
+ if (options?.download !== false) downloadBlob2(zip, fileName);
774
+ return { rowCount, columnCount: columns.length + 1 };
775
+ }
776
+
777
+ // packages/plugins/excel/src/exportActiveCollectionToExcel.ts
778
+ var hasMeaningfulValue2 = (value) => value !== void 0 && value !== null && value !== "";
779
+ async function exportActiveCollectionToExcel(controller, options) {
780
+ await controller.flushCellEdit();
781
+ if (controller.isPagedWindow()) {
782
+ return exportActiveCollectionToExcelStreaming(controller, options);
783
+ }
784
+ const view = controller.getViewState();
785
+ const columns = (view?.activeCollectionColumn?.length ? view.activeCollectionColumn : view?.columns ?? []).filter((col) => col.fieldType !== "index").sort((a, b) => (a.order ?? 0) - (b.order ?? 0));
786
+ const rows = (controller.getAllRows() ?? []).filter((row) => {
787
+ if (row.rowState.value === "Delete" /* Deleted */) return false;
788
+ return Array.from(row.getCells().entries()).some(
789
+ ([key, cell]) => key !== "index" && hasMeaningfulValue2(cell.getValue())
790
+ );
791
+ });
792
+ const source = {
793
+ columns: columns.map((col) => ({
794
+ fieldName: col.fieldName,
795
+ fieldCaption: col.fieldCaption,
796
+ fieldType: col.fieldType,
797
+ order: col.order
798
+ })),
799
+ rows: rows.map((row) => ({
800
+ id: row.id.value,
801
+ rowState: String(row.rowState.value),
802
+ cells: Object.fromEntries(
803
+ [...row.getCells()].map(([key, cell]) => [
804
+ key,
805
+ { value: cell.getValue(), display: cell.getDisplay() }
806
+ ])
807
+ )
808
+ }))
809
+ };
810
+ const table = chunk72IVAOTK_cjs.buildExportTable(source);
811
+ if (table.columns.length === 0 && table.rows.length === 0) {
812
+ throw new Error("NO_COLUMNS");
813
+ }
814
+ const direction = options?.direction ?? "rtl";
815
+ const rowHeaderLabel = options?.rowHeaderLabel ?? "\u0631\u062F\u06CC\u0641";
816
+ const sheetName = options?.sheetName ?? "Sheet1";
817
+ const fileName = options?.fileName ?? `export-${(/* @__PURE__ */ new Date()).toISOString().slice(0, 10)}.xlsx`;
818
+ await new Promise((resolve) => {
819
+ if (typeof setTimeout === "function") setTimeout(resolve, 0);
820
+ else resolve();
821
+ });
822
+ const blob = chunkIMPCRWYP_cjs.buildXlsxBlob(table, {
823
+ direction,
824
+ rowHeaderLabel,
825
+ sheetName
826
+ });
827
+ if (options?.download !== false) {
828
+ chunkIMPCRWYP_cjs.downloadBlob(blob, fileName);
829
+ }
830
+ return { rowCount: table.rows.length, columnCount: table.columns.length + 1 };
831
+ }
832
+
833
+ exports.ExcelExportPlugin = ExcelExportPlugin;
834
+ exports.ExcelImportPlugin = ExcelImportPlugin;
835
+ exports.applyImportedRows = applyImportedRows;
836
+ exports.exportActiveCollectionToExcel = exportActiveCollectionToExcel;
837
+ exports.mapImportedSheet = mapImportedSheet;
838
+ exports.parseXlsxBlob = parseXlsxBlob;
839
+ //# sourceMappingURL=chunk-CMQ4VLCW.cjs.map
840
+ //# sourceMappingURL=chunk-CMQ4VLCW.cjs.map