persian-data-grid 0.5.0 → 0.6.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-J5Z2LRC5.cjs +131 -0
  4. package/dist/ERPTableGroupRow-J5Z2LRC5.cjs.map +1 -0
  5. package/dist/ERPTableGroupRow-PSAPAHGL.js +125 -0
  6. package/dist/ERPTableGroupRow-PSAPAHGL.js.map +1 -0
  7. package/dist/GridPlugin-CJCaYnlw.d.ts +57 -0
  8. package/dist/GridPlugin-oxhq8AsM.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-B-9lLcoB.d.cts +2492 -0
  14. package/dist/GridSession-Bc7UIawO.d.ts +2492 -0
  15. package/dist/GridSyncService-KTLB4KP3.js +3 -0
  16. package/dist/GridSyncService-KTLB4KP3.js.map +1 -0
  17. package/dist/GridSyncService-TAPAHABV.cjs +12 -0
  18. package/dist/GridSyncService-TAPAHABV.cjs.map +1 -0
  19. package/dist/PdfRenderer-1HFh6UeR.d.ts +22 -0
  20. package/dist/PdfRenderer-CBg7hWNS.d.cts +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-Cuwq481K.d.cts +632 -0
  28. package/dist/UITableController-DU8RopUM.d.ts +632 -0
  29. package/dist/VazirmatnPdfRenderer-BCMpC1zy.d.cts +96 -0
  30. package/dist/VazirmatnPdfRenderer-Dz_G-m3c.d.ts +96 -0
  31. package/dist/adapters/arian-erp.cjs +77 -0
  32. package/dist/adapters/arian-erp.cjs.map +1 -0
  33. package/dist/adapters/arian-erp.d.cts +60 -0
  34. package/dist/adapters/arian-erp.d.ts +60 -0
  35. package/dist/adapters/arian-erp.js +71 -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-BO6yxoAN.d.cts +135 -0
  42. package/dist/applyImportedRows-D4zVY8uD.d.ts +135 -0
  43. package/dist/applyRowVisibilityHandler-KS6TMCBN.js +83 -0
  44. package/dist/applyRowVisibilityHandler-KS6TMCBN.js.map +1 -0
  45. package/dist/applyRowVisibilityHandler-LXCOGESZ.cjs +85 -0
  46. package/dist/applyRowVisibilityHandler-LXCOGESZ.cjs.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-BlXO5NJz.d.ts +30 -0
  52. package/dist/callbackRemoteApi-DgnXH-i0.d.cts +30 -0
  53. package/dist/cellRenderContext-DB7V_mlu.d.ts +42 -0
  54. package/dist/cellRenderContext-DG5BOlxK.d.cts +42 -0
  55. package/dist/chunk-2BJCRYOS.cjs +936 -0
  56. package/dist/chunk-2BJCRYOS.cjs.map +1 -0
  57. package/dist/chunk-3Y3KKGEC.js +3 -0
  58. package/dist/chunk-3Y3KKGEC.js.map +1 -0
  59. package/dist/chunk-5ALMNLUR.cjs +1408 -0
  60. package/dist/chunk-5ALMNLUR.cjs.map +1 -0
  61. package/dist/chunk-5HKVMPBD.js +937 -0
  62. package/dist/chunk-5HKVMPBD.js.map +1 -0
  63. package/dist/chunk-633KP74Z.js +189 -0
  64. package/dist/chunk-633KP74Z.js.map +1 -0
  65. package/dist/chunk-6XBXZPBW.js +298 -0
  66. package/dist/chunk-6XBXZPBW.js.map +1 -0
  67. package/dist/chunk-77UXAJII.js +112 -0
  68. package/dist/chunk-77UXAJII.js.map +1 -0
  69. package/dist/chunk-ASPTRYRD.cjs +21 -0
  70. package/dist/chunk-ASPTRYRD.cjs.map +1 -0
  71. package/dist/chunk-AU3RDJYQ.js +243 -0
  72. package/dist/chunk-AU3RDJYQ.js.map +1 -0
  73. package/dist/chunk-BHDRUZH5.cjs +33 -0
  74. package/dist/chunk-BHDRUZH5.cjs.map +1 -0
  75. package/dist/chunk-BLYVOV3G.cjs +191 -0
  76. package/dist/chunk-BLYVOV3G.cjs.map +1 -0
  77. package/dist/chunk-CILNIWYW.cjs +100 -0
  78. package/dist/chunk-CILNIWYW.cjs.map +1 -0
  79. package/dist/chunk-DFFP7SJ6.cjs +257 -0
  80. package/dist/chunk-DFFP7SJ6.cjs.map +1 -0
  81. package/dist/chunk-DXRCYW42.cjs +568 -0
  82. package/dist/chunk-DXRCYW42.cjs.map +1 -0
  83. package/dist/chunk-EBV6HGZB.cjs +33 -0
  84. package/dist/chunk-EBV6HGZB.cjs.map +1 -0
  85. package/dist/chunk-EHHHC5JV.js +832 -0
  86. package/dist/chunk-EHHHC5JV.js.map +1 -0
  87. package/dist/chunk-F4PYOYHR.js +112 -0
  88. package/dist/chunk-F4PYOYHR.js.map +1 -0
  89. package/dist/chunk-GQEDLUMB.js +168 -0
  90. package/dist/chunk-GQEDLUMB.js.map +1 -0
  91. package/dist/chunk-H2LESGMX.cjs +319 -0
  92. package/dist/chunk-H2LESGMX.cjs.map +1 -0
  93. package/dist/chunk-HTNJT2QU.js +11674 -0
  94. package/dist/chunk-HTNJT2QU.js.map +1 -0
  95. package/dist/chunk-IIISFUW4.cjs +11786 -0
  96. package/dist/chunk-IIISFUW4.cjs.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-KHMG6EI2.js +13 -0
  108. package/dist/chunk-KHMG6EI2.js.map +1 -0
  109. package/dist/chunk-KMRURD5J.cjs +15 -0
  110. package/dist/chunk-KMRURD5J.cjs.map +1 -0
  111. package/dist/chunk-KRJG3KMP.cjs +174 -0
  112. package/dist/chunk-KRJG3KMP.cjs.map +1 -0
  113. package/dist/chunk-KUBVDIF7.cjs +653 -0
  114. package/dist/chunk-KUBVDIF7.cjs.map +1 -0
  115. package/dist/chunk-KYAOSBQN.js +31 -0
  116. package/dist/chunk-KYAOSBQN.js.map +1 -0
  117. package/dist/chunk-LJ7LMEXO.js +36 -0
  118. package/dist/chunk-LJ7LMEXO.js.map +1 -0
  119. package/dist/chunk-MT3KLB2Q.cjs +944 -0
  120. package/dist/chunk-MT3KLB2Q.cjs.map +1 -0
  121. package/dist/chunk-MU3RY46O.js +932 -0
  122. package/dist/chunk-MU3RY46O.js.map +1 -0
  123. package/dist/chunk-MUQQKPWR.js +84 -0
  124. package/dist/chunk-MUQQKPWR.js.map +1 -0
  125. package/dist/chunk-N7SJTINL.cjs +4 -0
  126. package/dist/chunk-N7SJTINL.cjs.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-PXCHPZTP.cjs +839 -0
  134. package/dist/chunk-PXCHPZTP.cjs.map +1 -0
  135. package/dist/chunk-Q7TBBUTX.cjs +110 -0
  136. package/dist/chunk-Q7TBBUTX.cjs.map +1 -0
  137. package/dist/chunk-QQMU44KJ.js +612 -0
  138. package/dist/chunk-QQMU44KJ.js.map +1 -0
  139. package/dist/chunk-QZN7R2WP.cjs +114 -0
  140. package/dist/chunk-QZN7R2WP.cjs.map +1 -0
  141. package/dist/chunk-RKVSJU46.js +35 -0
  142. package/dist/chunk-RKVSJU46.js.map +1 -0
  143. package/dist/chunk-RM6ZWNT3.js +561 -0
  144. package/dist/chunk-RM6ZWNT3.js.map +1 -0
  145. package/dist/chunk-SX4VQXAA.cjs +114 -0
  146. package/dist/chunk-SX4VQXAA.cjs.map +1 -0
  147. package/dist/chunk-SZ7BLAY3.js +92 -0
  148. package/dist/chunk-SZ7BLAY3.js.map +1 -0
  149. package/dist/chunk-TN4MG6FY.js +112 -0
  150. package/dist/chunk-TN4MG6FY.js.map +1 -0
  151. package/dist/chunk-UC7PHDM6.cjs +331 -0
  152. package/dist/chunk-UC7PHDM6.cjs.map +1 -0
  153. package/dist/chunk-UXVLYUUW.js +108 -0
  154. package/dist/chunk-UXVLYUUW.js.map +1 -0
  155. package/dist/chunk-VVGYRZ7S.cjs +38 -0
  156. package/dist/chunk-VVGYRZ7S.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-WUMOSOEK.cjs +62 -0
  160. package/dist/chunk-WUMOSOEK.cjs.map +1 -0
  161. package/dist/chunk-XLRE2J25.js +140 -0
  162. package/dist/chunk-XLRE2J25.js.map +1 -0
  163. package/dist/chunk-Y6W5V2CI.js +19 -0
  164. package/dist/chunk-Y6W5V2CI.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-Dmq3i5v3.d.cts +884 -0
  168. package/dist/createEngineGridQuery-Mt1hc33m.d.ts +884 -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 +504 -0
  188. package/dist/headless.d.ts +504 -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 +8002 -11409
  194. package/dist/index.cjs.map +1 -1
  195. package/dist/index.d.cts +437 -2305
  196. package/dist/index.d.ts +437 -2305
  197. package/dist/index.js +7244 -11083
  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 +184 -28
@@ -0,0 +1,944 @@
1
+ 'use strict';
2
+
3
+ var chunkNTV2UUAJ_cjs = require('./chunk-NTV2UUAJ.cjs');
4
+
5
+ // domain/events/index.ts
6
+ var CellChanged = class {
7
+ constructor(rowId, columnId, newValue, previousValue) {
8
+ this.rowId = rowId;
9
+ this.columnId = columnId;
10
+ this.newValue = newValue;
11
+ this.previousValue = previousValue;
12
+ this.type = "CELL_CHANGED";
13
+ }
14
+ };
15
+ var DisplayChanged = class {
16
+ constructor(rowId, columnId, newValue) {
17
+ this.rowId = rowId;
18
+ this.columnId = columnId;
19
+ this.newValue = newValue;
20
+ this.type = "DISPLAY_CHANGED";
21
+ }
22
+ };
23
+ var DescriptionSaved = class {
24
+ constructor(rowId, flag) {
25
+ this.rowId = rowId;
26
+ this.flag = flag;
27
+ this.type = "DESCRIPTION_SAVED";
28
+ }
29
+ };
30
+ var ColumnReordered = class {
31
+ constructor(sourceIndex, destIndex) {
32
+ this.sourceIndex = sourceIndex;
33
+ this.destIndex = destIndex;
34
+ this.type = "COLUMN_REORDERED";
35
+ }
36
+ };
37
+ var RowAdded = class {
38
+ constructor(rowId) {
39
+ this.rowId = rowId;
40
+ this.type = "ROW_ADDED";
41
+ }
42
+ };
43
+ var RowDeleted = class {
44
+ constructor(rowId) {
45
+ this.rowId = rowId;
46
+ this.type = "ROW_DELETED";
47
+ }
48
+ };
49
+ var RowRemoved = class {
50
+ constructor(rowId) {
51
+ this.rowId = rowId;
52
+ this.type = "NEW_ROW_REMOVED";
53
+ }
54
+ };
55
+ var MinimumRowConstraintViolated = class {
56
+ constructor(rowId) {
57
+ this.rowId = rowId;
58
+ this.type = "NEW_AND_FIRST_ROW_CAN_NOT_BE_REMOVE";
59
+ }
60
+ };
61
+ var RowRestored = class {
62
+ constructor(rowId) {
63
+ this.rowId = rowId;
64
+ this.type = "ROW_RESTORED";
65
+ }
66
+ };
67
+ var RowReordered = class {
68
+ constructor(draggedRowNum, droppedRowNum) {
69
+ this.draggedRowNum = draggedRowNum;
70
+ this.droppedRowNum = droppedRowNum;
71
+ this.type = "ROW_REORDERED";
72
+ }
73
+ };
74
+
75
+ // domain/entities/Cell.ts
76
+ function unwrap(value) {
77
+ if (value instanceof chunkNTV2UUAJ_cjs.CellValue) return value.value;
78
+ if (value instanceof chunkNTV2UUAJ_cjs.CellDisplay) return value.value;
79
+ return value;
80
+ }
81
+ var Cell = class _Cell {
82
+ constructor(rowId, columnId, value, originalValue, display) {
83
+ this.rowId = rowId;
84
+ this.columnId = columnId;
85
+ this.value = unwrap(value);
86
+ this.originalValue = unwrap(originalValue);
87
+ this.display = unwrap(display);
88
+ }
89
+ changeValue(newValue) {
90
+ const previousValue = this.value;
91
+ this.value = unwrap(newValue);
92
+ return new CellChanged(this.rowId, this.columnId, this.value, previousValue);
93
+ }
94
+ changeDisplay(newValue) {
95
+ const next = unwrap(newValue);
96
+ if (this.display === next) return null;
97
+ this.display = next;
98
+ return new DisplayChanged(this.rowId, this.columnId, next);
99
+ }
100
+ changeOriginalValue(newValue) {
101
+ const next = unwrap(newValue);
102
+ if (this.originalValue === next) return null;
103
+ const previousValue = this.originalValue;
104
+ this.originalValue = next;
105
+ return new CellChanged(this.rowId, this.columnId, next, previousValue);
106
+ }
107
+ getValue() {
108
+ return this.value;
109
+ }
110
+ getValueObject() {
111
+ return new chunkNTV2UUAJ_cjs.CellValue(this.value);
112
+ }
113
+ getDisplay() {
114
+ return this.display;
115
+ }
116
+ getDisplayObject() {
117
+ return new chunkNTV2UUAJ_cjs.CellDisplay(this.display);
118
+ }
119
+ getOriginalValue() {
120
+ return new chunkNTV2UUAJ_cjs.CellValue(this.originalValue);
121
+ }
122
+ clone() {
123
+ return new _Cell(
124
+ this.rowId,
125
+ this.columnId,
126
+ this.value,
127
+ this.originalValue,
128
+ this.display
129
+ );
130
+ }
131
+ };
132
+
133
+ // domain/entities/Collection.ts
134
+ var Collection = class {
135
+ constructor(name = "default", rows, columns) {
136
+ this.name = name;
137
+ this.rows = rows;
138
+ this.columns = columns;
139
+ }
140
+ setCollectionName(name) {
141
+ this.name = name;
142
+ }
143
+ getCollectionName() {
144
+ return this.name;
145
+ }
146
+ getRows() {
147
+ return this.rows;
148
+ }
149
+ setRows(rows) {
150
+ this.rows = rows;
151
+ }
152
+ getColumns() {
153
+ return this.columns;
154
+ }
155
+ };
156
+
157
+ // domain/entities/Row.ts
158
+ var Row = class _Row {
159
+ constructor(id, cells, rowState, changeFields = /* @__PURE__ */ new Set(), visibilityCondition, collection = "default", isSaveDescription, data, sourceId) {
160
+ this.id = id;
161
+ this.cells = cells;
162
+ this.rowState = rowState;
163
+ this.changeFields = changeFields;
164
+ this.visibilityCondition = visibilityCondition;
165
+ this.collection = collection;
166
+ this.isSaveDescription = isSaveDescription;
167
+ this.data = data;
168
+ this.sourceId = sourceId;
169
+ }
170
+ updateChangeFields(columnId) {
171
+ const cell = this.getCell(columnId.value);
172
+ if (!cell) return;
173
+ const value = cell.getValueObject();
174
+ const originalValue = cell.getOriginalValue();
175
+ if (this.rowState.value !== "Add" /* Added */) {
176
+ if (!value.equals(originalValue)) {
177
+ this.changeFields.add(columnId.value);
178
+ } else {
179
+ this.changeFields.delete(columnId.value);
180
+ }
181
+ if (this.changeFields.size > 0) {
182
+ this.rowState = new chunkNTV2UUAJ_cjs.RowState("Update" /* Modified */);
183
+ } else {
184
+ this.rowState = new chunkNTV2UUAJ_cjs.RowState("None" /* Unchanged */);
185
+ }
186
+ }
187
+ }
188
+ getCollection() {
189
+ return this.collection;
190
+ }
191
+ setCollection(collection) {
192
+ this.collection = collection;
193
+ }
194
+ getChangeFields() {
195
+ return Array.from(this.changeFields);
196
+ }
197
+ getSnapshotChangeFields() {
198
+ return Array.from(this.changeFields).map(
199
+ (field) => field.replace("index", "RowNum")
200
+ );
201
+ }
202
+ changeCell(columnId, value) {
203
+ const cell = this.getCell(columnId.value);
204
+ if (!cell) return null;
205
+ return cell.changeValue(value);
206
+ }
207
+ saveDescription(flag) {
208
+ this.isSaveDescription = flag;
209
+ return new DescriptionSaved(this.id, flag);
210
+ }
211
+ changeDisplay(columnId, value) {
212
+ const cell = this.getCell(columnId.value);
213
+ if (!cell) return null;
214
+ return cell.changeDisplay(value);
215
+ }
216
+ getCells() {
217
+ return new Map(this.cells);
218
+ }
219
+ /**
220
+ * Return a cell without materializing from host `data` (PR-101).
221
+ */
222
+ peekCell(columnId) {
223
+ return this.cells.get(columnId);
224
+ }
225
+ /**
226
+ * Lazy host cells (PR-101): when `rowData` left values on `data`, materialize
227
+ * a Cell on first read and cache it.
228
+ */
229
+ getCell(columnId) {
230
+ const existing = this.cells.get(columnId);
231
+ if (existing) return existing;
232
+ if (!this.data || typeof this.data !== "object") return void 0;
233
+ if (columnId === "index") return void 0;
234
+ const record = this.data;
235
+ if (!Object.prototype.hasOwnProperty.call(record, columnId)) {
236
+ return void 0;
237
+ }
238
+ const value = record[columnId];
239
+ const cell = new Cell(
240
+ this.id,
241
+ chunkNTV2UUAJ_cjs.ColumnId.for(columnId),
242
+ value,
243
+ value,
244
+ value
245
+ );
246
+ this.cells.set(columnId, cell);
247
+ return cell;
248
+ }
249
+ /**
250
+ * Read a cell value without allocating a Cell when the host object still
251
+ * holds the canonical value (PR-101 hot path for sort/filter/quick filter).
252
+ */
253
+ readValue(columnId) {
254
+ const existing = this.cells.get(columnId);
255
+ if (existing) return existing.getValue();
256
+ if (columnId === "index") return void 0;
257
+ if (this.data && typeof this.data === "object") {
258
+ const record = this.data;
259
+ if (Object.prototype.hasOwnProperty.call(record, columnId)) {
260
+ return record[columnId];
261
+ }
262
+ }
263
+ return void 0;
264
+ }
265
+ readDisplay(columnId) {
266
+ const existing = this.cells.get(columnId);
267
+ if (existing) return existing.getDisplay();
268
+ return this.readValue(columnId);
269
+ }
270
+ ensureCell(columnId, defaultValue, displayValue) {
271
+ if (this.cells.has(columnId.value)) return;
272
+ const newCell = new Cell(this.id, columnId, defaultValue, defaultValue, displayValue);
273
+ this.cells.set(columnId.value, newCell);
274
+ }
275
+ setRowId(rowId) {
276
+ this.id.set(rowId);
277
+ }
278
+ setVisibilityCondition(Condition) {
279
+ this.visibilityCondition = Condition;
280
+ }
281
+ getVisibilityCondition() {
282
+ return this.visibilityCondition;
283
+ }
284
+ removeCell(columnId) {
285
+ this.cells.delete(columnId.value);
286
+ }
287
+ setData(data) {
288
+ this.data = data;
289
+ }
290
+ getData() {
291
+ return this.data;
292
+ }
293
+ clone() {
294
+ const clonedCells = /* @__PURE__ */ new Map();
295
+ for (const [k, cell] of this.cells.entries()) {
296
+ const clonedCell = cell.clone();
297
+ clonedCells.set(k, clonedCell);
298
+ }
299
+ return new _Row(
300
+ this.id,
301
+ clonedCells,
302
+ this.rowState,
303
+ this.changeFields,
304
+ this.visibilityCondition,
305
+ this.collection,
306
+ this.isSaveDescription,
307
+ this.data,
308
+ this.sourceId
309
+ );
310
+ }
311
+ };
312
+
313
+ // domain/entities/Table.ts
314
+ var Table = class _Table {
315
+ constructor(id, collection, pagination, action, activeCollection = "default") {
316
+ this.id = id;
317
+ this.collection = collection;
318
+ this.pagination = pagination;
319
+ this.action = action;
320
+ this.activeCollection = activeCollection;
321
+ /**
322
+ * Page-window mode (persistence 'paged-idb'): the Collection row Maps hold
323
+ * ONLY the current page; Pagination.totalRows is the source of truth for
324
+ * totals. In the default mode the Maps hold every row and pagination slices.
325
+ */
326
+ this.pageWindow = false;
327
+ }
328
+ isPageWindow() {
329
+ return this.pageWindow;
330
+ }
331
+ setPageWindow(enabled) {
332
+ this.pageWindow = enabled;
333
+ return this;
334
+ }
335
+ // ─── Collection accessor helper ───────────────────────────────────────────
336
+ getActiveCollection() {
337
+ const collection = this.collection.get(this.activeCollection);
338
+ if (!collection) throw new Error(`Collection "${this.activeCollection}" not found`);
339
+ return collection;
340
+ }
341
+ getCollection(collectionName) {
342
+ const collection = this.collection.get(collectionName);
343
+ if (!collection) throw new Error(`Collection "${collectionName}" not found`);
344
+ return collection;
345
+ }
346
+ /** Finds which Collection currently owns a given column id (if any). */
347
+ findCollectionForColumn(columnKey) {
348
+ for (const col of this.collection.values()) {
349
+ if (col.getColumns().has(columnKey)) return col;
350
+ }
351
+ return void 0;
352
+ }
353
+ getCollections() {
354
+ return this.collection;
355
+ }
356
+ // ─── Column helpers ───────────────────────────────────────────────────────
357
+ getColumnSchema(columnId) {
358
+ return this.getActiveCollection().getColumns().get(columnId.value);
359
+ }
360
+ getActiveCollectionName() {
361
+ return this.activeCollection;
362
+ }
363
+ setActiveCollection(activeCollection) {
364
+ this.activeCollection = activeCollection;
365
+ }
366
+ getRowCollection(rowId) {
367
+ return this.getActiveCollection().getRows().get(rowId)?.getCollection();
368
+ }
369
+ setRowCollection(rowId, collection) {
370
+ this.getActiveCollection().getRows().get(rowId)?.setCollection(collection);
371
+ }
372
+ setColumnSchema(columnId, DetailColumnConfig) {
373
+ const prev = this.getActiveCollection().getColumns().get(columnId.value);
374
+ this.getActiveCollection().getColumns().set(columnId.value, DetailColumnConfig);
375
+ return prev;
376
+ }
377
+ getColumns() {
378
+ return Array.from(this.getActiveCollection().getColumns().values());
379
+ }
380
+ getActiveCollectionColumns() {
381
+ const allColumns = this.getActiveCollection().getColumns();
382
+ return Array.from(allColumns.values()).sort(
383
+ (a, b) => (a.order ?? 0) - (b.order ?? 0)
384
+ );
385
+ }
386
+ getColumnsForCollectionScope(collectionScope = "active") {
387
+ if (collectionScope === "active") return this.getActiveCollectionColumns();
388
+ const names = collectionScope === "all" ? Array.from(this.collection.keys()) : collectionScope;
389
+ const merged = /* @__PURE__ */ new Map();
390
+ for (const name of names) {
391
+ for (const [id, col] of this.getCollection(name).getColumns()) {
392
+ merged.set(id, col);
393
+ }
394
+ }
395
+ return Array.from(merged.values());
396
+ }
397
+ getColumnValues(colId) {
398
+ const result = [];
399
+ for (const row of this.getActiveCollection().getRows().values()) {
400
+ const cell = row.getCell(colId);
401
+ if (!cell) continue;
402
+ result.push(cell.getValue());
403
+ }
404
+ return result;
405
+ }
406
+ setColumns(newColumns) {
407
+ const existingByField = new Map(this.getActiveCollection().getColumns());
408
+ for (const col of this.collection.values()) {
409
+ col.getColumns().clear();
410
+ }
411
+ for (const col of newColumns) {
412
+ const existing = existingByField.get(col.fieldName);
413
+ const targetCollectionKey = col.fieldCollection ?? this.activeCollection;
414
+ const updatedCol = {
415
+ ...col,
416
+ fieldCollection: targetCollectionKey,
417
+ // Prefer explicit hidden from caller; otherwise keep persisted visibility.
418
+ hidden: col.hidden ?? existing?.hidden ?? false,
419
+ // PR-61: keep user/domain order across host schema refresh.
420
+ order: existing?.order ?? col.order
421
+ };
422
+ const targetCollection = this.collection.get(targetCollectionKey);
423
+ if (targetCollection) {
424
+ targetCollection.getColumns().set(col.fieldName, updatedCol);
425
+ }
426
+ }
427
+ for (const row of this.getActiveCollection().getRows().values()) {
428
+ for (const col of newColumns) {
429
+ if (!row.getCells().has(col.fieldName)) {
430
+ const defaultValue = col.fieldType === "number" ? new chunkNTV2UUAJ_cjs.CellValue(0) : new chunkNTV2UUAJ_cjs.CellValue("");
431
+ const defaultDisplay = col.fieldType === "number" ? new chunkNTV2UUAJ_cjs.CellValue(0) : new chunkNTV2UUAJ_cjs.CellValue("");
432
+ row.ensureCell(new chunkNTV2UUAJ_cjs.ColumnId(col.fieldName), defaultValue, defaultDisplay);
433
+ }
434
+ }
435
+ }
436
+ }
437
+ // ─── Cell mutations ───────────────────────────────────────────────────────
438
+ changeCell(rowId, columnId, value) {
439
+ const row = this.getActiveCollection().getRows().get(rowId.value);
440
+ if (!row) return null;
441
+ const ev = row.changeCell(columnId, value);
442
+ if (ev) row.updateChangeFields(columnId);
443
+ return ev;
444
+ }
445
+ changeDisplay(rowId, columnId, value) {
446
+ const row = this.getActiveCollection().getRows().get(rowId.value);
447
+ if (!row) return null;
448
+ return row.changeDisplay(columnId, value);
449
+ }
450
+ saveDescription(rowId, flag) {
451
+ const row = this.getActiveCollection().getRows().get(rowId.value);
452
+ if (!row) return null;
453
+ return row.saveDescription(flag);
454
+ }
455
+ // ─── Row operations ───────────────────────────────────────────────────────
456
+ duplicateRow(rowId) {
457
+ const col = this.getActiveCollection();
458
+ const target = col.getRows().get(rowId.value);
459
+ if (!target) throw new Error("Row not found");
460
+ const rowsArray = Array.from(col.getRows().values());
461
+ const targetIndex = rowsArray.findIndex((r) => r.id.value === rowId.value);
462
+ const nextRow = targetIndex < rowsArray.length - 1 ? rowsArray[targetIndex + 1] : void 0;
463
+ const targetIndexValue = target.getCell("index")?.getValue();
464
+ let x;
465
+ if (!nextRow) {
466
+ x = targetIndexValue + 1;
467
+ } else {
468
+ const nextIndexValue = nextRow.getCell("index")?.getValue();
469
+ x = (targetIndexValue + nextIndexValue) / 2;
470
+ }
471
+ const newRowId = new chunkNTV2UUAJ_cjs.RowId(Math.floor((1 + Math.random()) * 18446744073709552e3));
472
+ const newCells = /* @__PURE__ */ new Map();
473
+ const newIndex = new chunkNTV2UUAJ_cjs.CellValue(x);
474
+ const newDisplay = new chunkNTV2UUAJ_cjs.CellDisplay(x);
475
+ for (const [colId, cell] of target.getCells().entries()) {
476
+ if (colId === "index") {
477
+ newCells.set(colId, new Cell(newRowId, new chunkNTV2UUAJ_cjs.ColumnId(colId), newIndex, newIndex, newDisplay));
478
+ } else {
479
+ newCells.set(
480
+ colId,
481
+ new Cell(
482
+ newRowId,
483
+ new chunkNTV2UUAJ_cjs.ColumnId(colId),
484
+ cell.getValueObject(),
485
+ cell.getValueObject(),
486
+ cell.getDisplayObject()
487
+ )
488
+ );
489
+ }
490
+ }
491
+ const newRow = new Row(
492
+ newRowId,
493
+ newCells,
494
+ new chunkNTV2UUAJ_cjs.RowState("Add" /* Added */),
495
+ /* @__PURE__ */ new Set(),
496
+ target.visibilityCondition,
497
+ target.collection,
498
+ target.isSaveDescription
499
+ );
500
+ rowsArray.sort(
501
+ (a, b) => a.getCell("index")?.getValue() - b.getCell("index")?.getValue()
502
+ );
503
+ rowsArray.splice(targetIndex + 1, 0, newRow);
504
+ col.setRows(new Map(rowsArray.map((r) => [r.id.value, r])));
505
+ return new RowAdded(newRowId);
506
+ }
507
+ addRow(targetRowId, placedRowId) {
508
+ const col = this.getActiveCollection();
509
+ const target = col.getRows().get(targetRowId);
510
+ if (!target) throw new Error("Row not found");
511
+ const rowsArray = Array.from(col.getRows().values()).sort(
512
+ (a, b) => a.getCell("index")?.getValue() - b.getCell("index")?.getValue()
513
+ );
514
+ let placeIndex;
515
+ let x = 0;
516
+ if (placedRowId !== void 0) {
517
+ placeIndex = rowsArray.findIndex((r) => r.id.value === placedRowId);
518
+ const placedRow = rowsArray[placeIndex];
519
+ const placeIndexValue = placedRow?.getCell("index")?.getValue();
520
+ const nextRow = placeIndex < rowsArray.length - 1 ? rowsArray[placeIndex + 1] : void 0;
521
+ if (nextRow) {
522
+ const nextIndexValue = nextRow.getCell("index")?.getValue();
523
+ x = (placeIndexValue + nextIndexValue) / 2;
524
+ } else {
525
+ x = placeIndexValue + 1;
526
+ }
527
+ } else {
528
+ const lastRowIndexValue = rowsArray[rowsArray.length - 1].getCell("index")?.getValue();
529
+ x = lastRowIndexValue + 1;
530
+ }
531
+ const newRowId = new chunkNTV2UUAJ_cjs.RowId(Math.floor((1 + Math.random()) * 18446744073709552e3));
532
+ const newCells = /* @__PURE__ */ new Map();
533
+ const newIndex = new chunkNTV2UUAJ_cjs.CellValue(x);
534
+ const newDisplay = new chunkNTV2UUAJ_cjs.CellDisplay(x);
535
+ for (const [colId, cell] of target.getCells().entries()) {
536
+ if (colId === "index") {
537
+ newCells.set("index", new Cell(newRowId, new chunkNTV2UUAJ_cjs.ColumnId("index"), newIndex, newIndex, newDisplay));
538
+ } else {
539
+ newCells.set(
540
+ colId,
541
+ new Cell(
542
+ newRowId,
543
+ new chunkNTV2UUAJ_cjs.ColumnId(colId),
544
+ cell.getValueObject(),
545
+ cell.getValueObject(),
546
+ cell.getDisplayObject()
547
+ )
548
+ );
549
+ }
550
+ }
551
+ const newRow = new Row(
552
+ newRowId,
553
+ newCells,
554
+ new chunkNTV2UUAJ_cjs.RowState("Add" /* Added */),
555
+ /* @__PURE__ */ new Set(),
556
+ target.visibilityCondition,
557
+ target.collection,
558
+ target.isSaveDescription
559
+ );
560
+ rowsArray.splice((placeIndex ?? 0) + 1, 0, newRow);
561
+ col.setRows(new Map(rowsArray.map((r) => [r.id.value, r])));
562
+ return new RowAdded(newRowId);
563
+ }
564
+ addNewRow(data, nextIndex) {
565
+ const col = this.getActiveCollection();
566
+ const newRowId = new chunkNTV2UUAJ_cjs.RowId(Math.floor((1 + Math.random()) * 18446744073709552e3));
567
+ const rowId = new chunkNTV2UUAJ_cjs.RowId(newRowId.value);
568
+ const cells = /* @__PURE__ */ new Map();
569
+ const dataMap = data ? new Map(data.map((kv) => [kv.key, kv])) : void 0;
570
+ this.getColumns().forEach((column) => {
571
+ const columnId = column.fieldName;
572
+ let value = null;
573
+ let display = null;
574
+ if (columnId === "index") {
575
+ if (nextIndex != null) {
576
+ value = nextIndex;
577
+ display = value;
578
+ } else {
579
+ const rows = Array.from(col.getRows().values());
580
+ const maxIndex = rows.length ? Math.max(
581
+ ...rows.map(
582
+ (r) => Number(r.getCell("index")?.getValue() ?? 0)
583
+ )
584
+ ) : 0;
585
+ value = maxIndex + 1;
586
+ display = value;
587
+ }
588
+ } else if (dataMap?.has(columnId)) {
589
+ const item = dataMap.get(columnId);
590
+ value = item?.value;
591
+ display = item?.display;
592
+ }
593
+ const cellValue = new chunkNTV2UUAJ_cjs.CellValue(value);
594
+ const cellDisplay = new chunkNTV2UUAJ_cjs.CellValue(display);
595
+ cells.set(columnId, new Cell(rowId, new chunkNTV2UUAJ_cjs.ColumnId(columnId), cellValue, cellValue, cellDisplay));
596
+ });
597
+ const newRow = new Row(
598
+ newRowId,
599
+ cells,
600
+ new chunkNTV2UUAJ_cjs.RowState("Add" /* Added */),
601
+ /* @__PURE__ */ new Set(),
602
+ {},
603
+ this.activeCollection,
604
+ false
605
+ );
606
+ col.getRows().set(newRowId.value, newRow);
607
+ if (this.pageWindow) {
608
+ const totalRows = this.pagination.totalRows + 1;
609
+ const lastPage = Math.max(1, Math.ceil(totalRows / this.pagination.pageSize));
610
+ this.pagination = new chunkNTV2UUAJ_cjs.Pagination(lastPage, this.pagination.pageSize, totalRows);
611
+ } else {
612
+ const totalRows = col.getRows().size;
613
+ const lastPage = Math.ceil(totalRows / this.pagination.pageSize);
614
+ this.changePage(lastPage);
615
+ }
616
+ return new RowAdded(newRowId);
617
+ }
618
+ addNewRows(cmd) {
619
+ const events = [];
620
+ const existingValues = new Set(
621
+ this.getRows().map((r) => r.getCell(cmd.detailFieldKey)?.getValue())
622
+ );
623
+ for (const data of cmd.rows) {
624
+ const incomingValue = data.find((kv) => kv.key === cmd.detailFieldKey)?.value;
625
+ if (incomingValue !== void 0 && !existingValues.has(incomingValue)) {
626
+ events.push(this.addNewRow(data));
627
+ existingValues.add(incomingValue);
628
+ }
629
+ }
630
+ return events;
631
+ }
632
+ addColumns(newColumns) {
633
+ const added = [];
634
+ const allColumns = this.getActiveCollection().getColumns();
635
+ for (const incoming of newColumns) {
636
+ const key = incoming.fieldName;
637
+ const existing = allColumns.get(key);
638
+ const targetCollectionKey = incoming.fieldCollection ?? this.activeCollection;
639
+ const targetCollection = this.collection.get(targetCollectionKey);
640
+ if (!targetCollection) continue;
641
+ if (existing) {
642
+ const shouldUnhide = existing.hidden === true;
643
+ targetCollection.getColumns().set(key, {
644
+ ...existing,
645
+ editable: incoming.editable ?? existing.editable,
646
+ hidden: shouldUnhide ? false : existing.hidden
647
+ });
648
+ if (shouldUnhide) added.push(new chunkNTV2UUAJ_cjs.ColumnId(incoming.fieldName));
649
+ continue;
650
+ }
651
+ targetCollection.getColumns().set(key, {
652
+ ...incoming,
653
+ fieldCollection: targetCollectionKey,
654
+ hidden: incoming.hidden ?? false
655
+ });
656
+ added.push(new chunkNTV2UUAJ_cjs.ColumnId(incoming.fieldName));
657
+ for (const row of this.getActiveCollection().getRows().values()) {
658
+ const defaultValue = incoming.fieldType === "number" ? new chunkNTV2UUAJ_cjs.CellValue(0) : new chunkNTV2UUAJ_cjs.CellValue("");
659
+ const defaultDisplay = incoming.fieldType === "number" ? new chunkNTV2UUAJ_cjs.CellValue(0) : new chunkNTV2UUAJ_cjs.CellValue("");
660
+ row.ensureCell(new chunkNTV2UUAJ_cjs.ColumnId(incoming.fieldName), defaultValue, defaultDisplay);
661
+ }
662
+ }
663
+ return { added };
664
+ }
665
+ setColumnHidden(columnId, hidden) {
666
+ const cols = this.getActiveCollection().getColumns();
667
+ const existing = cols.get(columnId);
668
+ if (!existing) return false;
669
+ if (Boolean(existing.hidden) === hidden) return false;
670
+ cols.set(columnId, { ...existing, hidden });
671
+ return true;
672
+ }
673
+ /** Runtime pin on `columnDef.pinned` (PR-114). Index column is not mutable. */
674
+ setColumnPinned(columnId, pinned) {
675
+ const cols = this.getActiveCollection().getColumns();
676
+ const existing = cols.get(columnId);
677
+ if (!existing) return false;
678
+ const bridge = { ...existing.columnDef ?? {} };
679
+ if (pinned == null) delete bridge.pinned;
680
+ else bridge.pinned = pinned;
681
+ const nextPinned = bridge.pinned ?? null;
682
+ const prevPinned = existing.columnDef?.pinned ?? null;
683
+ if (nextPinned === prevPinned) return false;
684
+ cols.set(columnId, { ...existing, columnDef: bridge });
685
+ return true;
686
+ }
687
+ removeColumns(columnIds) {
688
+ const removed = [];
689
+ for (const colId of columnIds) {
690
+ const ownerCollection = this.findCollectionForColumn(colId.value);
691
+ if (!ownerCollection) continue;
692
+ const schema = ownerCollection.getColumns().get(colId.value);
693
+ if (!schema || schema.hidden) continue;
694
+ ownerCollection.getColumns().set(colId.value, { ...schema, hidden: true });
695
+ removed.push(colId);
696
+ }
697
+ return { removed };
698
+ }
699
+ // ─── Row reads ────────────────────────────────────────────────────────────
700
+ getRows(collectionScope = "active") {
701
+ if (collectionScope === "all") {
702
+ const rows = [];
703
+ for (const col of this.collection.values()) {
704
+ rows.push(...col.getRows().values());
705
+ }
706
+ return rows;
707
+ }
708
+ if (Array.isArray(collectionScope)) {
709
+ const rows = [];
710
+ for (const name of collectionScope) {
711
+ const collection = this.getCollection(name);
712
+ rows.push(...collection.getRows().values());
713
+ }
714
+ return rows;
715
+ }
716
+ return Array.from(this.getActiveCollection().getRows().values());
717
+ }
718
+ getCollectionsRows(collections) {
719
+ const rows = [];
720
+ for (const name of collections) {
721
+ const collection = this.getCollection(name);
722
+ rows.push(...collection.getRows().values());
723
+ }
724
+ return rows;
725
+ }
726
+ getRow(rowId) {
727
+ return this.getActiveCollection().getRows().get(rowId);
728
+ }
729
+ /** Host `rowData` sync (PR-82) — put without going through add/undo. */
730
+ hostPutRow(row) {
731
+ this.getActiveCollection().getRows().set(row.id.value, row);
732
+ }
733
+ /** Host `rowData` sync (PR-82) — drop to match the host array. */
734
+ hostRemoveRow(rowId) {
735
+ this.getActiveCollection().getRows().delete(rowId);
736
+ }
737
+ addRows(newRows) {
738
+ const rows = this.getActiveCollection().getRows();
739
+ newRows.forEach((r) => rows.set(r.id.value, r));
740
+ }
741
+ // ─── Pagination ───────────────────────────────────────────────────────────
742
+ getPagination() {
743
+ return this.pagination;
744
+ }
745
+ setPagination(pagination) {
746
+ this.pagination = pagination;
747
+ }
748
+ changePage(page) {
749
+ this.pagination = this.pagination.changePage(page);
750
+ }
751
+ changePageSize(size) {
752
+ this.pagination = this.pagination.changePageSize(size).changePage(1);
753
+ }
754
+ /**
755
+ * Rows currently held in RAM for the active collection.
756
+ * With page-window storage the Collection Map already contains only the
757
+ * current page — do not slice by pagination offsets.
758
+ */
759
+ getVisibleRows() {
760
+ const filteredRows = this.getRows().filter((r) => r.collection === this.activeCollection);
761
+ if (this.pageWindow) return filteredRows;
762
+ const start = (this.pagination.page - 1) * this.pagination.pageSize;
763
+ return filteredRows.slice(start, start + this.pagination.pageSize);
764
+ }
765
+ // ─── Actions ──────────────────────────────────────────────────────────────
766
+ setTableAction(action) {
767
+ this.action = action;
768
+ }
769
+ getTableAction() {
770
+ return this.action;
771
+ }
772
+ // ─── Delete / restore ─────────────────────────────────────────────────────
773
+ /**
774
+ * Re-inserts a previously Added row after hard-remove (undo of ADD → redo).
775
+ * Preserves rowId and cell values; no-ops if the id already exists.
776
+ */
777
+ restoreAddedRow(params) {
778
+ const col = this.getActiveCollection();
779
+ const existing = col.getRows().get(params.rowId);
780
+ if (existing) {
781
+ return new RowAdded(existing.id);
782
+ }
783
+ const rowId = new chunkNTV2UUAJ_cjs.RowId(params.rowId);
784
+ const cells = /* @__PURE__ */ new Map();
785
+ for (const [columnId, snap] of Object.entries(params.cells)) {
786
+ const value = new chunkNTV2UUAJ_cjs.CellValue(snap.value);
787
+ const original = new chunkNTV2UUAJ_cjs.CellValue(
788
+ snap.originalValue !== void 0 ? snap.originalValue : snap.value
789
+ );
790
+ const display = new chunkNTV2UUAJ_cjs.CellDisplay(
791
+ snap.display !== void 0 ? snap.display : snap.value
792
+ );
793
+ cells.set(
794
+ columnId,
795
+ new Cell(rowId, new chunkNTV2UUAJ_cjs.ColumnId(columnId), value, original, display)
796
+ );
797
+ }
798
+ for (const column of this.getColumns()) {
799
+ if (cells.has(column.fieldName)) continue;
800
+ const empty = new chunkNTV2UUAJ_cjs.CellValue(null);
801
+ cells.set(
802
+ column.fieldName,
803
+ new Cell(
804
+ rowId,
805
+ new chunkNTV2UUAJ_cjs.ColumnId(column.fieldName),
806
+ empty,
807
+ empty,
808
+ new chunkNTV2UUAJ_cjs.CellDisplay(null)
809
+ )
810
+ );
811
+ }
812
+ const newRow = new Row(
813
+ rowId,
814
+ cells,
815
+ new chunkNTV2UUAJ_cjs.RowState("Add" /* Added */),
816
+ /* @__PURE__ */ new Set(),
817
+ {},
818
+ params.collection ?? this.activeCollection,
819
+ params.isSaveDescription ?? false
820
+ );
821
+ col.getRows().set(rowId.value, newRow);
822
+ return new RowAdded(rowId);
823
+ }
824
+ /**
825
+ * Delete semantics:
826
+ * - `Added` → hard-remove from the table (physically gone).
827
+ * - `Deleted` → restore (قابل برگرداندن).
828
+ * - otherwise (`Unchanged` / `Modified`) → soft-delete (`rowState = Deleted`).
829
+ */
830
+ deleteRow(rowId) {
831
+ const col = this.getActiveCollection();
832
+ const rows = col.getRows();
833
+ const row = rows.get(rowId.value);
834
+ if (!row) return null;
835
+ if (row.rowState.value === "Add" /* Added */) {
836
+ if (rows.size === 1) {
837
+ rows.delete(rowId.value);
838
+ this.addNewRow();
839
+ return new MinimumRowConstraintViolated(rowId);
840
+ }
841
+ rows.delete(rowId.value);
842
+ return new RowRemoved(rowId);
843
+ }
844
+ if (row.rowState.value === "Delete" /* Deleted */) {
845
+ const otherChanges = row.getChangeFields().filter((field) => field !== "RowState");
846
+ row.rowState = new chunkNTV2UUAJ_cjs.RowState(
847
+ otherChanges.length > 0 ? "Update" /* Modified */ : "None" /* Unchanged */
848
+ );
849
+ row.updateChangeFields(new chunkNTV2UUAJ_cjs.ColumnId("RowState"));
850
+ return new RowRestored(rowId);
851
+ }
852
+ row.rowState = new chunkNTV2UUAJ_cjs.RowState("Delete" /* Deleted */);
853
+ row.updateChangeFields(new chunkNTV2UUAJ_cjs.ColumnId("RowState"));
854
+ return new RowDeleted(rowId);
855
+ }
856
+ // ─── Reorder ──────────────────────────────────────────────────────────────
857
+ reorderRows(draggedRowNum, droppedRowNum, position = "after") {
858
+ if (draggedRowNum === droppedRowNum) return new RowReordered(draggedRowNum, droppedRowNum);
859
+ const col = this.getActiveCollection();
860
+ const rowsArray = Array.from(col.getRows().values()).sort(
861
+ (a, b) => a.getCell("index")?.getValue() - b.getCell("index")?.getValue()
862
+ );
863
+ const fromIndex = rowsArray.findIndex((r) => r.id.value === draggedRowNum);
864
+ const toIndex = rowsArray.findIndex((r) => r.id.value === droppedRowNum);
865
+ if (fromIndex === -1 || toIndex === -1)
866
+ throw new Error(`Row ${draggedRowNum} or ${droppedRowNum} does not exist`);
867
+ const [moved] = rowsArray.splice(fromIndex, 1);
868
+ let insertIndex = toIndex;
869
+ if (position === "after") {
870
+ insertIndex = toIndex + 1;
871
+ if (fromIndex < toIndex) insertIndex -= 1;
872
+ } else {
873
+ if (fromIndex < toIndex) insertIndex -= 1;
874
+ }
875
+ let newIndex;
876
+ if (insertIndex === 0) {
877
+ newIndex = rowsArray[0]?.getCell("index")?.getValue() / 2;
878
+ } else if (insertIndex >= rowsArray.length) {
879
+ newIndex = rowsArray[rowsArray.length - 1]?.getCell("index")?.getValue() + 1;
880
+ } else {
881
+ const prevIndex = rowsArray[insertIndex - 1].getCell("index")?.getValue();
882
+ const nextIndex = rowsArray[insertIndex].getCell("index")?.getValue();
883
+ newIndex = (prevIndex + nextIndex) / 2;
884
+ }
885
+ moved.changeCell(new chunkNTV2UUAJ_cjs.ColumnId("index"), newIndex);
886
+ rowsArray.splice(insertIndex, 0, moved);
887
+ col.setRows(new Map(rowsArray.map((r) => [r.id.value, r])));
888
+ moved.updateChangeFields(new chunkNTV2UUAJ_cjs.ColumnId("index"));
889
+ return new RowReordered(draggedRowNum, droppedRowNum);
890
+ }
891
+ reorderColumns(sourceIndex, destIndex) {
892
+ const activeCollection = this.getActiveCollection();
893
+ const colsMap = activeCollection.getColumns();
894
+ const colsArray = Array.from(colsMap.values()).sort(
895
+ (a, b) => (a.order ?? 0) - (b.order ?? 0)
896
+ );
897
+ const [moved] = colsArray.splice(sourceIndex, 1);
898
+ if (!moved) {
899
+ return new ColumnReordered(sourceIndex, destIndex);
900
+ }
901
+ colsArray.splice(destIndex, 0, moved);
902
+ colsMap.clear();
903
+ for (let i = 0; i < colsArray.length; i += 1) {
904
+ const col = colsArray[i];
905
+ if (!col) continue;
906
+ colsMap.set(col.fieldName, { ...col, order: i });
907
+ }
908
+ return new ColumnReordered(sourceIndex, destIndex);
909
+ }
910
+ // ─── Clone ────────────────────────────────────────────────────────────────
911
+ clone() {
912
+ const clonedCollection = /* @__PURE__ */ new Map();
913
+ for (const [collectionName, col] of this.collection.entries()) {
914
+ const clonedRows = /* @__PURE__ */ new Map();
915
+ for (const [k, row] of col.getRows().entries()) {
916
+ clonedRows.set(k, row.clone());
917
+ }
918
+ clonedCollection.set(
919
+ collectionName,
920
+ new Collection(
921
+ col.getCollectionName(),
922
+ clonedRows,
923
+ new Map(col.getColumns())
924
+ )
925
+ );
926
+ }
927
+ return new _Table(
928
+ this.id,
929
+ clonedCollection,
930
+ this.pagination,
931
+ this.action,
932
+ this.activeCollection
933
+ ).setPageWindow(this.pageWindow);
934
+ }
935
+ };
936
+
937
+ exports.Cell = Cell;
938
+ exports.Collection = Collection;
939
+ exports.MinimumRowConstraintViolated = MinimumRowConstraintViolated;
940
+ exports.Row = Row;
941
+ exports.RowRemoved = RowRemoved;
942
+ exports.Table = Table;
943
+ //# sourceMappingURL=chunk-MT3KLB2Q.cjs.map
944
+ //# sourceMappingURL=chunk-MT3KLB2Q.cjs.map