@alfadocs/ui-kit-debug 1.118.0 → 1.120.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 (260) hide show
  1. package/dist/_chunks/{address-autocomplete-zLygkxFc.js → address-autocomplete-D2uNpxcE.js} +2 -2
  2. package/dist/_chunks/{address-autocomplete-zLygkxFc.js.map → address-autocomplete-D2uNpxcE.js.map} +1 -1
  3. package/dist/_chunks/{address-fields-Dl1ALKhP.js → address-fields-BU65pA-V.js} +2 -2
  4. package/dist/_chunks/{address-fields-Dl1ALKhP.js.map → address-fields-BU65pA-V.js.map} +1 -1
  5. package/dist/_chunks/bill-line-table-DUMEHnQ4.js +1754 -0
  6. package/dist/_chunks/bill-line-table-DUMEHnQ4.js.map +1 -0
  7. package/dist/_chunks/{calendar-appointment-editor-dialog-BEmBcb61.js → calendar-appointment-editor-dialog-rw02sXGw.js} +4 -4
  8. package/dist/_chunks/{calendar-appointment-editor-dialog-BEmBcb61.js.map → calendar-appointment-editor-dialog-rw02sXGw.js.map} +1 -1
  9. package/dist/_chunks/{compact-editor-fields-6sTWRLtf.js → compact-editor-fields-cP6yh7xv.js} +3 -3
  10. package/dist/_chunks/{compact-editor-fields-6sTWRLtf.js.map → compact-editor-fields-cP6yh7xv.js.map} +1 -1
  11. package/dist/_chunks/counts-BXtzNv_G.js +92 -0
  12. package/dist/_chunks/counts-BXtzNv_G.js.map +1 -0
  13. package/dist/_chunks/{data-grid-DiBSbN2Y.js → data-grid-Bbf8t4z3.js} +2 -2
  14. package/dist/_chunks/{data-grid-DiBSbN2Y.js.map → data-grid-Bbf8t4z3.js.map} +1 -1
  15. package/dist/_chunks/{default-tabs-CD285u0C.js → default-tabs-Cxkw1Ws0.js} +332 -368
  16. package/dist/_chunks/default-tabs-Cxkw1Ws0.js.map +1 -0
  17. package/dist/_chunks/{document-scanner-5p-Uu8dy.js → document-scanner-CETscDea.js} +2 -2
  18. package/dist/_chunks/{document-scanner-5p-Uu8dy.js.map → document-scanner-CETscDea.js.map} +1 -1
  19. package/dist/_chunks/file-code-Cf-_gSzd.js +23 -0
  20. package/dist/_chunks/file-code-Cf-_gSzd.js.map +1 -0
  21. package/dist/_chunks/{file-manager-CV1_GtjC.js → file-manager-DNq-sEsy.js} +2 -2
  22. package/dist/_chunks/{file-manager-CV1_GtjC.js.map → file-manager-DNq-sEsy.js.map} +1 -1
  23. package/dist/_chunks/{file-upload-CxjCs7TX.js → file-upload-DQc0LsBM.js} +385 -311
  24. package/dist/_chunks/file-upload-DQc0LsBM.js.map +1 -0
  25. package/dist/_chunks/invoice-upload-list-CsFsRgbt.js +952 -0
  26. package/dist/_chunks/invoice-upload-list-CsFsRgbt.js.map +1 -0
  27. package/dist/_chunks/map-view-h6ngp2xi.js +1578 -0
  28. package/dist/_chunks/map-view-h6ngp2xi.js.map +1 -0
  29. package/dist/_chunks/maps-MpMxTBov.js +63 -0
  30. package/dist/_chunks/maps-MpMxTBov.js.map +1 -0
  31. package/dist/_chunks/maps-core-gate-DKx96CC_.js +1492 -0
  32. package/dist/_chunks/{maps-core-gate-C4dyo1ic.js.map → maps-core-gate-DKx96CC_.js.map} +1 -1
  33. package/dist/_chunks/{notes-panel-CHR-Jv6N.js → notes-panel-BOwlTz2-.js} +2 -2
  34. package/dist/_chunks/{notes-panel-CHR-Jv6N.js.map → notes-panel-BOwlTz2-.js.map} +1 -1
  35. package/dist/_chunks/package-plus-CTecQK3x.js +25 -0
  36. package/dist/_chunks/package-plus-CTecQK3x.js.map +1 -0
  37. package/dist/_chunks/{practice-results-b3uchdBn.js → practice-results-yCresv86.js} +759 -750
  38. package/dist/_chunks/practice-results-yCresv86.js.map +1 -0
  39. package/dist/_chunks/{public-footer-CB7ruuLI.js → public-footer-C8UIzqLJ.js} +326 -243
  40. package/dist/_chunks/public-footer-C8UIzqLJ.js.map +1 -0
  41. package/dist/_chunks/{radiograph-panel.agent-9jwXlOXB.js → radiograph-panel.agent-Dcv16n7u.js} +2 -2
  42. package/dist/_chunks/{radiograph-panel.agent-9jwXlOXB.js.map → radiograph-panel.agent-Dcv16n7u.js.map} +1 -1
  43. package/dist/_chunks/{reserved.agent-V2Eqoabh.js → reserved.agent-DRSZ8UcL.js} +2 -2
  44. package/dist/_chunks/{reserved.agent-V2Eqoabh.js.map → reserved.agent-DRSZ8UcL.js.map} +1 -1
  45. package/dist/_chunks/{rich-text-editor-CMPA5Wgy.js → rich-text-editor-BLEdXJ0l.js} +2 -2
  46. package/dist/_chunks/{rich-text-editor-CMPA5Wgy.js.map → rich-text-editor-BLEdXJ0l.js.map} +1 -1
  47. package/dist/_chunks/{signed-out-frame-bh7fn_Px.js → signed-out-frame-fUf7tqs3.js} +2 -2
  48. package/dist/_chunks/{signed-out-frame-bh7fn_Px.js.map → signed-out-frame-fUf7tqs3.js.map} +1 -1
  49. package/dist/_chunks/{task-editor-WdDCqbIL.js → task-editor-Czcx9B-3.js} +2 -2
  50. package/dist/_chunks/{task-editor-WdDCqbIL.js.map → task-editor-Czcx9B-3.js.map} +1 -1
  51. package/dist/_chunks/{toolbar-z8vXnpXz.js → toolbar-DoKcoE2q.js} +2 -2
  52. package/dist/_chunks/{toolbar-z8vXnpXz.js.map → toolbar-DoKcoE2q.js.map} +1 -1
  53. package/dist/_chunks/types-BrJRsnSG.js +291 -0
  54. package/dist/_chunks/types-BrJRsnSG.js.map +1 -0
  55. package/dist/_chunks/warehouse-load-summary-D88M4Ii7.js +255 -0
  56. package/dist/_chunks/warehouse-load-summary-D88M4Ii7.js.map +1 -0
  57. package/dist/agent-catalog.json +360 -14
  58. package/dist/agent-i18n/en.json +31 -2
  59. package/dist/browser-support.js +1 -1
  60. package/dist/components/_shared/warehouse-load/counts.d.ts +82 -0
  61. package/dist/components/_shared/warehouse-load/counts.d.ts.map +1 -0
  62. package/dist/components/_shared/warehouse-load/index.d.ts +4 -0
  63. package/dist/components/_shared/warehouse-load/index.d.ts.map +1 -0
  64. package/dist/components/_shared/warehouse-load/maps.d.ts +67 -0
  65. package/dist/components/_shared/warehouse-load/maps.d.ts.map +1 -0
  66. package/dist/components/_shared/warehouse-load/types.d.ts +18 -0
  67. package/dist/components/_shared/warehouse-load/types.d.ts.map +1 -0
  68. package/dist/components/address-autocomplete/index.js +1 -1
  69. package/dist/components/address-fields/index.js +1 -1
  70. package/dist/components/bill-line-table/bill-line-table.columns.d.ts +2 -0
  71. package/dist/components/bill-line-table/bill-line-table.columns.d.ts.map +1 -1
  72. package/dist/components/bill-line-table/bill-line-table.d.ts.map +1 -1
  73. package/dist/components/bill-line-table/bill-line-table.header.d.ts +7 -0
  74. package/dist/components/bill-line-table/bill-line-table.header.d.ts.map +1 -0
  75. package/dist/components/bill-line-table/bill-line-table.model.d.ts +10 -1
  76. package/dist/components/bill-line-table/bill-line-table.model.d.ts.map +1 -1
  77. package/dist/components/bill-line-table/bill-line-table.types.d.ts +66 -1
  78. package/dist/components/bill-line-table/bill-line-table.types.d.ts.map +1 -1
  79. package/dist/components/bill-line-table/bill-line-table.variants.d.ts +12 -0
  80. package/dist/components/bill-line-table/bill-line-table.variants.d.ts.map +1 -1
  81. package/dist/components/bill-line-table/index.d.ts +2 -2
  82. package/dist/components/bill-line-table/index.d.ts.map +1 -1
  83. package/dist/components/bill-line-table/index.js +10 -8
  84. package/dist/components/bill-table/index.js +1 -1
  85. package/dist/components/booking/index.js +1 -1
  86. package/dist/components/data-grid/data-grid.variants.d.ts +1 -1
  87. package/dist/components/data-grid/index.js +2 -2
  88. package/dist/components/document-scanner/index.js +1 -1
  89. package/dist/components/file-manager/index.js +1 -1
  90. package/dist/components/file-upload/file-upload.d.ts +30 -1
  91. package/dist/components/file-upload/file-upload.d.ts.map +1 -1
  92. package/dist/components/file-upload/index.js +1 -1
  93. package/dist/components/flag/flag-view.d.ts +1 -1
  94. package/dist/components/index.d.ts +3 -0
  95. package/dist/components/index.d.ts.map +1 -1
  96. package/dist/components/invoice-upload/index.d.ts +5 -0
  97. package/dist/components/invoice-upload/index.d.ts.map +1 -0
  98. package/dist/components/invoice-upload/index.js +7 -0
  99. package/dist/components/invoice-upload/index.js.map +1 -0
  100. package/dist/components/invoice-upload/invoice-upload.agent.d.ts +4 -0
  101. package/dist/components/invoice-upload/invoice-upload.agent.d.ts.map +1 -0
  102. package/dist/components/invoice-upload/invoice-upload.d.ts +3 -0
  103. package/dist/components/invoice-upload/invoice-upload.d.ts.map +1 -0
  104. package/dist/components/invoice-upload/types.d.ts +72 -0
  105. package/dist/components/invoice-upload/types.d.ts.map +1 -0
  106. package/dist/components/invoice-upload-list/cells.d.ts +36 -0
  107. package/dist/components/invoice-upload-list/cells.d.ts.map +1 -0
  108. package/dist/components/invoice-upload-list/columns.d.ts +14 -0
  109. package/dist/components/invoice-upload-list/columns.d.ts.map +1 -0
  110. package/dist/components/invoice-upload-list/handle.d.ts +18 -0
  111. package/dist/components/invoice-upload-list/handle.d.ts.map +1 -0
  112. package/dist/components/invoice-upload-list/index.d.ts +5 -0
  113. package/dist/components/invoice-upload-list/index.d.ts.map +1 -0
  114. package/dist/components/invoice-upload-list/index.js +10 -0
  115. package/dist/components/invoice-upload-list/index.js.map +1 -0
  116. package/dist/components/invoice-upload-list/invoice-upload-list.agent.d.ts +4 -0
  117. package/dist/components/invoice-upload-list/invoice-upload-list.agent.d.ts.map +1 -0
  118. package/dist/components/invoice-upload-list/invoice-upload-list.d.ts +10 -0
  119. package/dist/components/invoice-upload-list/invoice-upload-list.d.ts.map +1 -0
  120. package/dist/components/invoice-upload-list/invoice-upload-list.variants.d.ts +28 -0
  121. package/dist/components/invoice-upload-list/invoice-upload-list.variants.d.ts.map +1 -0
  122. package/dist/components/invoice-upload-list/model.d.ts +40 -0
  123. package/dist/components/invoice-upload-list/model.d.ts.map +1 -0
  124. package/dist/components/invoice-upload-list/types.d.ts +154 -0
  125. package/dist/components/invoice-upload-list/types.d.ts.map +1 -0
  126. package/dist/components/map-view/index.js +1 -1
  127. package/dist/components/map-view/map-view-pin-geometry.d.ts +39 -0
  128. package/dist/components/map-view/map-view-pin-geometry.d.ts.map +1 -0
  129. package/dist/components/map-view/map-view-pin.d.ts +15 -0
  130. package/dist/components/map-view/map-view-pin.d.ts.map +1 -0
  131. package/dist/components/map-view/map-view.d.ts.map +1 -1
  132. package/dist/components/notes-panel/index.js +1 -1
  133. package/dist/components/practice-results/index.js +1 -1
  134. package/dist/components/practice-results/practice-results.d.ts +8 -0
  135. package/dist/components/practice-results/practice-results.d.ts.map +1 -1
  136. package/dist/components/public-footer/index.js +1 -1
  137. package/dist/components/public-footer/public-footer.d.ts +24 -0
  138. package/dist/components/public-footer/public-footer.d.ts.map +1 -1
  139. package/dist/components/public-header/public-header.d.ts +1 -1
  140. package/dist/components/radiograph-panel/index.js +1 -1
  141. package/dist/components/rich-text-editor/index.js +1 -1
  142. package/dist/components/task-editor/index.js +1 -1
  143. package/dist/components/warehouse-load-summary/index.d.ts +4 -0
  144. package/dist/components/warehouse-load-summary/index.d.ts.map +1 -0
  145. package/dist/components/warehouse-load-summary/index.js +6 -0
  146. package/dist/components/warehouse-load-summary/index.js.map +1 -0
  147. package/dist/components/warehouse-load-summary/model.d.ts +8 -0
  148. package/dist/components/warehouse-load-summary/model.d.ts.map +1 -0
  149. package/dist/components/warehouse-load-summary/types.d.ts +50 -0
  150. package/dist/components/warehouse-load-summary/types.d.ts.map +1 -0
  151. package/dist/components/warehouse-load-summary/warehouse-load-summary.agent.d.ts +4 -0
  152. package/dist/components/warehouse-load-summary/warehouse-load-summary.agent.d.ts.map +1 -0
  153. package/dist/components/warehouse-load-summary/warehouse-load-summary.d.ts +7 -0
  154. package/dist/components/warehouse-load-summary/warehouse-load-summary.d.ts.map +1 -0
  155. package/dist/core.css +1 -1
  156. package/dist/i18n/locales/ar.d.ts +203 -0
  157. package/dist/i18n/locales/ar.d.ts.map +1 -1
  158. package/dist/i18n/locales/ar.js +197 -4
  159. package/dist/i18n/locales/ar.js.map +1 -1
  160. package/dist/i18n/locales/de.d.ts +203 -0
  161. package/dist/i18n/locales/de.d.ts.map +1 -1
  162. package/dist/i18n/locales/de.js +201 -4
  163. package/dist/i18n/locales/de.js.map +1 -1
  164. package/dist/i18n/locales/el.d.ts +203 -0
  165. package/dist/i18n/locales/el.d.ts.map +1 -1
  166. package/dist/i18n/locales/el.js +201 -4
  167. package/dist/i18n/locales/el.js.map +1 -1
  168. package/dist/i18n/locales/en.d.ts +203 -0
  169. package/dist/i18n/locales/en.d.ts.map +1 -1
  170. package/dist/i18n/locales/en.js +203 -0
  171. package/dist/i18n/locales/en.js.map +1 -1
  172. package/dist/i18n/locales/es.d.ts +203 -0
  173. package/dist/i18n/locales/es.d.ts.map +1 -1
  174. package/dist/i18n/locales/es.js +199 -4
  175. package/dist/i18n/locales/es.js.map +1 -1
  176. package/dist/i18n/locales/fr.d.ts +203 -0
  177. package/dist/i18n/locales/fr.d.ts.map +1 -1
  178. package/dist/i18n/locales/fr.js +199 -4
  179. package/dist/i18n/locales/fr.js.map +1 -1
  180. package/dist/i18n/locales/hi.d.ts +203 -0
  181. package/dist/i18n/locales/hi.d.ts.map +1 -1
  182. package/dist/i18n/locales/hi.js +197 -4
  183. package/dist/i18n/locales/hi.js.map +1 -1
  184. package/dist/i18n/locales/it.d.ts +203 -0
  185. package/dist/i18n/locales/it.d.ts.map +1 -1
  186. package/dist/i18n/locales/it.js +197 -4
  187. package/dist/i18n/locales/it.js.map +1 -1
  188. package/dist/i18n/locales/ja.d.ts +203 -0
  189. package/dist/i18n/locales/ja.d.ts.map +1 -1
  190. package/dist/i18n/locales/ja.js +197 -4
  191. package/dist/i18n/locales/ja.js.map +1 -1
  192. package/dist/i18n/locales/nl.d.ts +203 -0
  193. package/dist/i18n/locales/nl.d.ts.map +1 -1
  194. package/dist/i18n/locales/nl.js +197 -4
  195. package/dist/i18n/locales/nl.js.map +1 -1
  196. package/dist/i18n/locales/pl.d.ts +203 -0
  197. package/dist/i18n/locales/pl.d.ts.map +1 -1
  198. package/dist/i18n/locales/pl.js +197 -4
  199. package/dist/i18n/locales/pl.js.map +1 -1
  200. package/dist/i18n/locales/pt.d.ts +203 -0
  201. package/dist/i18n/locales/pt.d.ts.map +1 -1
  202. package/dist/i18n/locales/pt.js +199 -4
  203. package/dist/i18n/locales/pt.js.map +1 -1
  204. package/dist/i18n/locales/ro.d.ts +203 -0
  205. package/dist/i18n/locales/ro.d.ts.map +1 -1
  206. package/dist/i18n/locales/ro.js +197 -4
  207. package/dist/i18n/locales/ro.js.map +1 -1
  208. package/dist/i18n/locales/ru.d.ts +203 -0
  209. package/dist/i18n/locales/ru.d.ts.map +1 -1
  210. package/dist/i18n/locales/ru.js +197 -4
  211. package/dist/i18n/locales/ru.js.map +1 -1
  212. package/dist/i18n/locales/sq.d.ts +203 -0
  213. package/dist/i18n/locales/sq.d.ts.map +1 -1
  214. package/dist/i18n/locales/sq.js +199 -4
  215. package/dist/i18n/locales/sq.js.map +1 -1
  216. package/dist/i18n/locales/sv.d.ts +203 -0
  217. package/dist/i18n/locales/sv.d.ts.map +1 -1
  218. package/dist/i18n/locales/sv.js +197 -4
  219. package/dist/i18n/locales/sv.js.map +1 -1
  220. package/dist/i18n/locales/tr.d.ts +203 -0
  221. package/dist/i18n/locales/tr.d.ts.map +1 -1
  222. package/dist/i18n/locales/tr.js +197 -4
  223. package/dist/i18n/locales/tr.js.map +1 -1
  224. package/dist/i18n/locales/zh.d.ts +203 -0
  225. package/dist/i18n/locales/zh.d.ts.map +1 -1
  226. package/dist/i18n/locales/zh.js +197 -4
  227. package/dist/i18n/locales/zh.js.map +1 -1
  228. package/dist/index.js +1190 -1174
  229. package/dist/index.js.map +1 -1
  230. package/dist/locales/ar.json +207 -4
  231. package/dist/locales/de.json +207 -4
  232. package/dist/locales/el.json +207 -4
  233. package/dist/locales/en.json +203 -0
  234. package/dist/locales/es.json +207 -4
  235. package/dist/locales/fr.json +207 -4
  236. package/dist/locales/hi.json +207 -4
  237. package/dist/locales/it.json +207 -4
  238. package/dist/locales/ja.json +207 -4
  239. package/dist/locales/nl.json +207 -4
  240. package/dist/locales/pl.json +207 -4
  241. package/dist/locales/pt.json +207 -4
  242. package/dist/locales/ro.json +207 -4
  243. package/dist/locales/ru.json +207 -4
  244. package/dist/locales/sq.json +207 -4
  245. package/dist/locales/sv.json +207 -4
  246. package/dist/locales/tr.json +207 -4
  247. package/dist/locales/zh.json +207 -4
  248. package/dist/patterns/calendar/index.js +1 -1
  249. package/dist/patterns/signed-out-frame/index.js +1 -1
  250. package/dist/tokens.css +1 -1
  251. package/package.json +16 -1
  252. package/dist/_chunks/bill-line-table-vCnVo7_a.js +0 -1565
  253. package/dist/_chunks/bill-line-table-vCnVo7_a.js.map +0 -1
  254. package/dist/_chunks/default-tabs-CD285u0C.js.map +0 -1
  255. package/dist/_chunks/file-upload-CxjCs7TX.js.map +0 -1
  256. package/dist/_chunks/map-view-CHeGd94F.js +0 -1443
  257. package/dist/_chunks/map-view-CHeGd94F.js.map +0 -1
  258. package/dist/_chunks/maps-core-gate-C4dyo1ic.js +0 -1571
  259. package/dist/_chunks/practice-results-b3uchdBn.js.map +0 -1
  260. package/dist/_chunks/public-footer-CB7ruuLI.js.map +0 -1
@@ -1,1565 +0,0 @@
1
- import { jsx as o, jsxs as O, Fragment as wt } from "react/jsx-runtime";
2
- import { createContext as Nt, useContext as fe, useRef as I, useLayoutEffect as cn, useMemo as b, forwardRef as un, useEffect as Pe, useState as Te, useCallback as k, useImperativeHandle as dn } from "react";
3
- import { useTranslation as mn } from "react-i18next";
4
- import { u as fn } from "./registry-DvAUVLHh.js";
5
- import { e as yn } from "./data-grid-DiBSbN2Y.js";
6
- import { a as K } from "./format-number-DdzqwMs1.js";
7
- import { i as pn } from "./is-development-CLUAnsU7.js";
8
- import { B as Ln } from "./badge-BUk4RjTS.js";
9
- import { C as hn } from "./combobox-BBCVQS-S.js";
10
- import { M as gn } from "./money-OE6_oDPH.js";
11
- import { V as Ye } from "./visually-hidden-BHxEUGyT.js";
12
- import { divideDecimal as vn, formatDecimal as se, multiplyDecimal as bn, sumDecimals as ke, parseDecimal as _e, FATTURAPA_VALUE as Ee, compareDecimal as xe, decimalToNumber as Se, rescaleDecimal as kt, numberToDecimal as In, shiftDecimal as Tn } from "../decimal/index.js";
13
- import { c as _ } from "./index-D2ZczOXr.js";
14
- import { E as wn } from "./compact-editor-fields-6sTWRLtf.js";
15
- import { C as Nn } from "./check-DrFSN__t.js";
16
- import { P as kn } from "./plus-DzMQ_c6b.js";
17
- import { C as _n } from "./circle-alert-rGDZ73Wh.js";
18
- import { T as En } from "./triangle-alert-CBnO6nq_.js";
19
- function dt(e, t) {
20
- throw new Error(`${e}: ${t}`);
21
- }
22
- const xn = "^[0-9]{1,8}([.][0-9]{1,8})?$", de = { type: "string", minLength: 1 }, we = "{ id, lineNumber, matchState, selected, selectable, readOnly, quantityLocked, itemKind, itemId, quantity, removesStock, warningCodes, invalid }", Sn = {
23
- id: "bill-line-table",
24
- // select_multiple: ticks. set_value: a line's quantity and its item
25
- // (whole-value assignment to a NumberInput and a Combobox, 26 section 4).
26
- // scroll: focus_line. No `confirm`: loading is the host's.
27
- capabilities: ["select_multiple", "set_value", "scroll"],
28
- state: {
29
- lines: {
30
- type: `Array<${we}>`,
31
- descriptionKey: "ui.agent.billLineTable.state.lines",
32
- description: "Every invoice line in invoice order, with what Confirm will do with it. Quantities are exact decimal text as shown, unsigned; there are no descriptions or names.",
33
- read: (e) => e.getLines()
34
- },
35
- selection: {
36
- type: "string[]",
37
- descriptionKey: "ui.agent.billLineTable.state.selection",
38
- description: "Ids of the ticked lines: the lines Confirm will load.",
39
- read: (e) => e.getSelection()
40
- },
41
- summary: {
42
- type: "{ lineCount, selectedCount, matchedCount, newItemCount, skippedCount, alreadyLoadedCount, warningLineCount, invoiceLoaded, invalidCount, net, vat, gross, canConfirm, dirty }",
43
- descriptionKey: "ui.agent.billLineTable.state.summary",
44
- description: 'Counts and totals of the ticked lines. net, vat and gross are exact decimal text with 2 places ("14.58"). canConfirm is false while no line is ticked, a ticked line cannot load, or the invoice is already loaded (invoiceLoaded).',
45
- read: (e) => e.getSummary()
46
- },
47
- invalidLineIds: {
48
- type: "string[]",
49
- descriptionKey: "ui.agent.billLineTable.state.invalidLineIds",
50
- description: "Ticked lines that cannot load as they are: an empty or zero quantity, an item no longer in the warehouse, or an error from the server.",
51
- read: (e) => e.getInvalidLineIds()
52
- }
53
- },
54
- actions: {
55
- select_lines: {
56
- safety: "write",
57
- idempotent: !0,
58
- argsType: "{ ids: string[]; mode?: 'replace' | 'add' | 'remove' }",
59
- argsSchema: {
60
- type: "object",
61
- properties: {
62
- ids: { type: "array", items: de, uniqueItems: !0 },
63
- mode: { type: "string", enum: ["replace", "add", "remove"] }
64
- },
65
- required: ["ids"],
66
- additionalProperties: !1
67
- },
68
- returns: "string[]",
69
- errors: ["UNKNOWN_LINE", "LINE_READ_ONLY", "TABLE_READ_ONLY"],
70
- examples: [{ args: { ids: ["ln-3", "ln-4"], mode: "add" } }],
71
- descriptionKey: "ui.agent.billLineTable.actions.selectLines",
72
- description: "Tick or untick lines. Lines of an invoice that is already loaded cannot be ticked. Returns the ticked ids.",
73
- invoke: (e, t) => {
74
- for (const u of t.ids)
75
- e.getLine(u) || dt("UNKNOWN_LINE", `no line "${u}".`);
76
- const i = e.getSelection(), n = t.mode ?? "replace", r = n === "replace" ? t.ids : n === "add" ? [...i, ...t.ids] : i.filter((u) => !t.ids.includes(u));
77
- return e.setSelection(r), e.getSelection();
78
- }
79
- },
80
- select_all_lines: {
81
- safety: "write",
82
- idempotent: !0,
83
- returns: "string[]",
84
- errors: ["TABLE_READ_ONLY"],
85
- descriptionKey: "ui.agent.billLineTable.actions.selectAllLines",
86
- description: "Tick every line that can load. Returns the ticked ids.",
87
- invoke: (e) => (e.selectAll(), e.getSelection())
88
- },
89
- clear_selection: {
90
- safety: "write",
91
- idempotent: !0,
92
- returns: "string[]",
93
- errors: ["TABLE_READ_ONLY"],
94
- descriptionKey: "ui.agent.billLineTable.actions.clearSelection",
95
- description: "Untick every line.",
96
- invoke: (e) => (e.clearSelection(), e.getSelection())
97
- },
98
- set_quantity: {
99
- safety: "write",
100
- idempotent: !0,
101
- argsType: "{ lineId: string; quantity: string }",
102
- argsSchema: {
103
- type: "object",
104
- properties: {
105
- lineId: de,
106
- quantity: { type: "string", pattern: xn }
107
- },
108
- required: ["lineId", "quantity"],
109
- additionalProperties: !1
110
- },
111
- returns: we,
112
- errors: [
113
- "UNKNOWN_LINE",
114
- "INVALID_QUANTITY",
115
- "TABLE_READ_ONLY",
116
- "LINE_READ_ONLY"
117
- ],
118
- examples: [
119
- { args: { lineId: "ln-2", quantity: "2.5" } },
120
- {
121
- args: { lineId: "ln-7", quantity: "3" },
122
- note: "On a credit note this removes 3 from stock."
123
- }
124
- ],
125
- descriptionKey: "ui.agent.billLineTable.actions.setQuantity",
126
- description: "Set the quantity of a line as shown in the table: a decimal above 0 and at most 10000000, with a dot and up to 8 places, never signed. On a credit note it is the quantity to remove. The line amount stays as invoiced. Does not tick the line.",
127
- invoke: (e, t) => (e.setQuantity(t.lineId, t.quantity), e.getLine(t.lineId))
128
- },
129
- set_item: {
130
- safety: "write",
131
- idempotent: !0,
132
- argsType: "{ lineId: string; itemId: string }",
133
- argsSchema: {
134
- type: "object",
135
- properties: {
136
- lineId: de,
137
- itemId: { type: "string", minLength: 1 }
138
- },
139
- required: ["lineId", "itemId"],
140
- additionalProperties: !1
141
- },
142
- returns: we,
143
- errors: [
144
- "UNKNOWN_LINE",
145
- "UNKNOWN_ITEM",
146
- "TABLE_READ_ONLY",
147
- "LINE_READ_ONLY"
148
- ],
149
- descriptionKey: "ui.agent.billLineTable.actions.setItem",
150
- description: "Load a line into an existing warehouse item, by item id. Does not tick the line.",
151
- invoke: (e, t) => (e.setItem(t.lineId, { kind: "existing", itemId: t.itemId }), e.getLine(t.lineId))
152
- },
153
- create_new_item: {
154
- safety: "write",
155
- idempotent: !0,
156
- argsType: "{ lineId: string; name?: string }",
157
- argsSchema: {
158
- type: "object",
159
- properties: {
160
- lineId: de,
161
- // DoctorInventoryItem.name is a string of 255.
162
- name: { type: "string", minLength: 1, maxLength: 255 }
163
- },
164
- required: ["lineId"],
165
- additionalProperties: !1
166
- },
167
- returns: we,
168
- errors: [
169
- "UNKNOWN_LINE",
170
- "INVALID_ARGS",
171
- "TABLE_READ_ONLY",
172
- "LINE_READ_ONLY"
173
- ],
174
- descriptionKey: "ui.agent.billLineTable.actions.createNewItem",
175
- description: "Mark a line to create a new warehouse item when the invoice is loaded. Without a name, the item takes the line description. Nothing is created until Confirm. Does not tick the line.",
176
- invoke: (e, t) => {
177
- var n;
178
- const i = (n = t.name) == null ? void 0 : n.trim();
179
- return t.name !== void 0 && !i && dt("INVALID_ARGS", "name is empty."), e.setItem(t.lineId, { kind: "new", name: i ?? "" }), e.getLine(t.lineId);
180
- }
181
- },
182
- focus_line: {
183
- safety: "read",
184
- idempotent: !0,
185
- argsType: "{ lineId: string; field?: 'select' | 'quantity' | 'item' }",
186
- argsSchema: {
187
- type: "object",
188
- properties: {
189
- lineId: de,
190
- field: { type: "string", enum: ["select", "quantity", "item"] }
191
- },
192
- required: ["lineId"],
193
- additionalProperties: !1
194
- },
195
- errors: ["UNKNOWN_LINE"],
196
- descriptionKey: "ui.agent.billLineTable.actions.focusLine",
197
- description: "Scroll a line into view and move focus to its checkbox, quantity or item field.",
198
- invoke: (e, t) => {
199
- e.focusLine(t.lineId, t.field);
200
- }
201
- }
202
- },
203
- domHooks: {
204
- root: {
205
- attr: "data-component",
206
- value: "bill-line-table",
207
- description: "Marks the element as a kit BillLineTable."
208
- },
209
- instanceId: {
210
- attr: "data-component-id",
211
- sourceProp: "gridId",
212
- description: "The agent instance id."
213
- },
214
- item: {
215
- attr: "data-row-id",
216
- sourceProp: "lines[].id",
217
- description: "BillLine.id on each body row (written by DataGrid). The only line datum in the DOM."
218
- }
219
- }
220
- }, ae = 8, _t = 8, Cn = 2, ye = 1e7, mt = 255, le = "bill-line-table:new-item", Et = "quantityTooLarge", me = { units: 0, scale: 0 }, xt = { units: ye, scale: 0 }, qn = {
221
- ...Ee.quantity,
222
- allowNegative: !0
223
- };
224
- function Ce(e) {
225
- let { units: t, scale: i } = e;
226
- for (; i > 0 && t % 10 === 0; )
227
- t /= 10, i -= 1;
228
- return { units: t || 0, scale: i };
229
- }
230
- function Ue(e) {
231
- return { units: Math.abs(e.units), scale: e.scale };
232
- }
233
- function A(e) {
234
- const t = {
235
- empty: !0,
236
- wellFormed: !1,
237
- positive: !1,
238
- value: null,
239
- editorNumber: null
240
- };
241
- if (e === null || e.trim() === "") return t;
242
- const i = _e(e, qn);
243
- if (i.ok) {
244
- const n = Se(i.value);
245
- return {
246
- empty: !1,
247
- wellFormed: !0,
248
- positive: i.value.units > 0,
249
- value: i.value,
250
- editorNumber: n !== null && Math.abs(n) <= ye ? n : null
251
- };
252
- }
253
- return i.error === "unsafe" ? {
254
- empty: !1,
255
- wellFormed: !0,
256
- positive: !e.trim().startsWith("-"),
257
- value: null,
258
- editorNumber: null
259
- } : { ...t, empty: !1 };
260
- }
261
- function $e(e) {
262
- const t = A(e);
263
- return !t.wellFormed || t.editorNumber !== null;
264
- }
265
- function On(e) {
266
- const t = In(e, ae);
267
- return t ? se(Ce(t)) : null;
268
- }
269
- function oe(e) {
270
- const t = _e(e, Ee.lineTotal);
271
- return t.ok ? t.value : null;
272
- }
273
- function St(e) {
274
- if (e === null) return null;
275
- const t = _e(e, Ee.rate);
276
- return t.ok ? t.value : null;
277
- }
278
- function An(e, t) {
279
- const i = oe(e), n = A(t).value;
280
- if (!i || !n || n.units === 0) return null;
281
- const r = vn(i, n, _t);
282
- return r ? se(Ce(r)) : null;
283
- }
284
- function Rn(e, t) {
285
- const i = oe(e), n = oe(t);
286
- return !i || !n ? e.trim() === t.trim() : xe(Ue(i), Ue(n)) === 0;
287
- }
288
- function W(e) {
289
- const t = e.trim(), i = Array.from(t);
290
- return i.length > mt ? i.slice(0, mt).join("").trim() : t;
291
- }
292
- function Qe(e, t) {
293
- if (e.kind === "existing")
294
- return { kind: "existing", itemId: e.itemId };
295
- const i = W(e.name);
296
- return {
297
- kind: "new",
298
- name: i === "" ? W(t.description) : i
299
- };
300
- }
301
- function Vn(e) {
302
- const t = A(e);
303
- return t.wellFormed ? t.value === null ? !0 : xe(Ue(t.value), xt) > 0 : !1;
304
- }
305
- function Ct(e, t) {
306
- return Vn(t.quantity) && !At(t.quantity, e.quantity);
307
- }
308
- function qt(e) {
309
- return e.item.kind === "new" && W(e.item.name) === "";
310
- }
311
- function Dn(e, t) {
312
- if (t.item.kind !== "new") return !1;
313
- const i = W(t.item.name);
314
- return i !== "" && i === W(e.description);
315
- }
316
- function te(e) {
317
- return e.some((t) => t.alreadyLoaded);
318
- }
319
- function z(e) {
320
- return {
321
- quantity: e.quantity,
322
- item: e.proposal === "existing" && e.proposedItemId !== null ? { kind: "existing", itemId: e.proposedItemId } : { kind: "new", name: W(e.description) }
323
- };
324
- }
325
- function Vi(e) {
326
- const t = {};
327
- for (const i of e) t[i.id] = z(i);
328
- return t;
329
- }
330
- function Ke(e) {
331
- return te(e) ? [] : e.filter((t) => t.proposal !== "skip").map((t) => t.id);
332
- }
333
- function ft(e, t) {
334
- const i = {};
335
- for (const n of e)
336
- i[n.id] = t[n.id] ?? z(n);
337
- return i;
338
- }
339
- function Bn(e, t) {
340
- return !e.alreadyLoaded;
341
- }
342
- function $(e, t) {
343
- if (te(e) || t.length === 0) return [];
344
- const n = new Set(t);
345
- return e.filter((r) => n.has(r.id) && Bn(r)).map((r) => r.id);
346
- }
347
- function Ot(e, t) {
348
- return e.kind === "existing" ? t.kind === "existing" && e.itemId === t.itemId : t.kind === "new" && W(e.name) === W(t.name);
349
- }
350
- function At(e, t) {
351
- if (e === t) return !0;
352
- if (e === null || t === null) return !1;
353
- const i = A(e).value, n = A(t).value;
354
- return i && n ? xe(i, n) === 0 : e.trim() === t.trim();
355
- }
356
- function Rt(e, t) {
357
- return At(e.quantity, t.quantity) && Ot(e.item, t.item);
358
- }
359
- function Mn(e, t, i) {
360
- return e.alreadyLoaded ? "alreadyLoaded" : i ? t.item.kind === "existing" ? "matched" : "newItem" : "skip";
361
- }
362
- function ze(e, t, i = !0) {
363
- const n = A(t.quantity);
364
- return !n.wellFormed || !n.positive || Ct(e, t) || !oe(e.lineTotal) || t.item.kind === "existing" && !i || qt(t) ? !0 : e.warnings.some((r) => r.severity === "error");
365
- }
366
- const Vt = () => !0;
367
- function Dt(e, t) {
368
- return e.item.kind !== "existing" || t(e.item.itemId);
369
- }
370
- function yt(e) {
371
- const t = ke(e);
372
- if (t) return t;
373
- const i = [];
374
- for (const n of e) {
375
- const r = kt(n, 2);
376
- r && i.push(r);
377
- }
378
- return ke(i) ?? me;
379
- }
380
- function Ne(e) {
381
- return kt(e, 2) ?? me;
382
- }
383
- const Fe = (e) => se(e, 2);
384
- function pt(e, t, i, n, r = Vt) {
385
- const u = te(e), E = new Set($(e, i));
386
- let T = 0, p = 0, g = 0, N = 0, R = 0, q = 0, V = 0;
387
- const D = [], B = /* @__PURE__ */ new Map();
388
- for (const m of e) {
389
- const H = t[m.id] ?? z(m);
390
- if ((m.warnings.length > 0 || !$e(m.quantity)) && (q += 1), m.alreadyLoaded) {
391
- R += 1;
392
- continue;
393
- }
394
- if (!E.has(m.id)) {
395
- N += 1;
396
- continue;
397
- }
398
- T += 1, H.item.kind === "existing" ? p += 1 : g += 1, ze(m, H, Dt(H, r)) && (V += 1);
399
- const F = oe(m.lineTotal);
400
- if (!F) continue;
401
- D.push(F);
402
- const f = St(m.vatPercent);
403
- if (f) {
404
- const he = se(Ce(f)), X = B.get(he);
405
- X ? X.amounts.push(F) : B.set(he, { rate: f, amounts: [F] });
406
- }
407
- }
408
- const j = Ne(yt(D)), y = [];
409
- for (const m of B.values()) {
410
- const H = {
411
- units: m.rate.units,
412
- scale: m.rate.scale + 2
413
- }, F = Ne(yt(m.amounts));
414
- y.push(bn(F, H, 2) ?? me);
415
- }
416
- const v = ke(y) ?? me, M = ke([j, v]) ?? me, G = $(e, n.selection), Le = G.length !== E.size || G.some((m) => !E.has(m)) || e.some(
417
- (m) => !Rt(
418
- t[m.id] ?? z(m),
419
- n.values[m.id] ?? z(m)
420
- )
421
- );
422
- return {
423
- lineCount: e.length,
424
- selectedCount: T,
425
- matchedCount: p,
426
- newItemCount: g,
427
- skippedCount: N,
428
- alreadyLoadedCount: R,
429
- warningLineCount: q,
430
- invoiceLoaded: u,
431
- invalidCount: V,
432
- net: Fe(j),
433
- vat: Fe(Ne(v)),
434
- gross: Fe(Ne(M)),
435
- canConfirm: T > 0 && V === 0,
436
- dirty: Le
437
- };
438
- }
439
- function Pn(e) {
440
- const t = A(e).value;
441
- return t ? se(t) : e.trim();
442
- }
443
- function Kn(e, t, i, n, r = Vt) {
444
- if (te(e)) return { ok: !1, invalidLineIds: [] };
445
- const u = new Set($(e, i)), E = [], T = [];
446
- for (const p of e) {
447
- if (!u.has(p.id)) continue;
448
- const g = t[p.id] ?? z(p);
449
- if (g.quantity === null || ze(p, g, Dt(g, r))) {
450
- T.push(p.id);
451
- continue;
452
- }
453
- const N = Pn(g.quantity);
454
- E.push({
455
- lineId: p.id,
456
- quantity: n === "creditNote" ? `-${N}` : N,
457
- item: Qe(g.item, p)
458
- });
459
- }
460
- return T.length > 0 ? { ok: !1, invalidLineIds: T } : { ok: !0, lines: E };
461
- }
462
- function Bt(e, t, i) {
463
- const n = i.ticked.has(e.id), r = t.item.kind === "existing" ? i.findItem(t.item.itemId) ?? null : null, u = t.item.kind !== "existing" || r !== null;
464
- return {
465
- line: e,
466
- value: t,
467
- selected: n,
468
- matchState: Mn(e, t, n),
469
- invalid: n && ze(e, t, u),
470
- readOnly: i.invoiceLoaded,
471
- quantityLocked: !$e(e.quantity),
472
- item: r,
473
- itemKnown: u
474
- };
475
- }
476
- function Fn(e, t) {
477
- return e === t ? !0 : e === null || t === null ? !1 : e.id === t.id && e.name === t.name && e.code === t.code;
478
- }
479
- function Un(e, t) {
480
- return e.line === t.line && e.value.quantity === t.value.quantity && Ot(e.value.item, t.value.item) && e.selected === t.selected && e.matchState === t.matchState && e.invalid === t.invalid && e.readOnly === t.readOnly && e.quantityLocked === t.quantityLocked && e.itemKnown === t.itemKnown && Fn(e.item, t.item);
481
- }
482
- function Lt(e) {
483
- const t = {
484
- invoiceLoaded: te(e.lines),
485
- ticked: new Set($(e.lines, e.selection)),
486
- findItem: e.findItem
487
- };
488
- return e.lines.map((i) => {
489
- var u;
490
- const n = Bt(
491
- i,
492
- e.values[i.id] ?? z(i),
493
- t
494
- ), r = (u = e.previous) == null ? void 0 : u.get(i.id);
495
- return r && Un(r, n) ? r : n;
496
- });
497
- }
498
- function Qn(e, t) {
499
- const i = e.line.warnings.map((r) => r.code);
500
- e.quantityLocked && i.push(Et);
501
- const n = e.readOnly || e.line.alreadyLoaded;
502
- return {
503
- id: e.line.id,
504
- lineNumber: e.line.lineNumber,
505
- matchState: e.matchState,
506
- selected: e.selected,
507
- selectable: !n && !t.tableReadOnly,
508
- readOnly: n || t.tableReadOnly,
509
- quantityLocked: e.quantityLocked,
510
- itemKind: e.value.item.kind,
511
- itemId: e.value.item.kind === "existing" ? e.value.item.itemId : null,
512
- quantity: e.value.quantity,
513
- removesStock: t.documentKind === "creditNote",
514
- warningCodes: i,
515
- invalid: e.invalid
516
- };
517
- }
518
- function Yn(e) {
519
- const t = _e(e, Ee.quantity);
520
- return !t.ok || t.value.units <= 0 || xe(t.value, xt) > 0 ? null : se(Ce(t.value));
521
- }
522
- const $n = _("ds:flex ds:min-w-0 ds:flex-col", {
523
- variants: {
524
- height: {
525
- auto: "",
526
- fill: "ds:min-h-0 ds:flex-1"
527
- }
528
- },
529
- defaultVariants: { height: "fill" }
530
- }), zn = _([
531
- "ds:w-full ds:min-w-0",
532
- wn
533
- ]), Mt = _("ds:flex ds:flex-col", {
534
- variants: {
535
- align: {
536
- start: "ds:items-start",
537
- end: "ds:items-end"
538
- }
539
- },
540
- defaultVariants: { align: "start" }
541
- }), Pt = _(
542
- "type-body-sm ds:text-[color:var(--muted-foreground)]"
543
- ), Kt = _(
544
- "ds:m-0 ds:flex ds:list-none ds:flex-col ds:gap-[var(--spacing-2xs)] ds:p-0",
545
- {
546
- variants: {
547
- align: {
548
- start: "ds:items-start",
549
- end: "ds:items-end"
550
- }
551
- },
552
- defaultVariants: { align: "start" }
553
- }
554
- ), qe = _("ds:tabular-nums"), Wn = _(
555
- "ds:flex ds:items-start ds:gap-[var(--spacing-xs)]"
556
- ), ht = _(
557
- "ds:mt-[var(--spacing-2xs)] ds:size-4 ds:shrink-0",
558
- {
559
- variants: {
560
- severity: {
561
- warning: "ds:text-[color:var(--warning-foreground)]",
562
- error: "ds:text-[color:var(--error-foreground)]"
563
- }
564
- },
565
- defaultVariants: { severity: "warning" }
566
- }
567
- ), jn = _("ds:text-[color:var(--foreground)]"), Gn = _(
568
- "ds:m-0 ds:grid ds:grid-cols-1 ds:justify-items-end ds:text-end"
569
- ), gt = _(
570
- "type-meta ds:text-[color:var(--muted-foreground)]"
571
- ), vt = _(
572
- "ds:m-0 ds:[&:not(:last-child)]:mb-[var(--spacing-2xs)]"
573
- ), Hn = {
574
- itemOptions: [],
575
- itemOptionIds: /* @__PURE__ */ new Set(),
576
- serverSearch: !1,
577
- itemsLoading: !1,
578
- searchingLineId: null
579
- }, Ft = Nt(Hn), pe = Nt(
580
- null
581
- ), Xn = {
582
- matched: { variant: "success", check: !1 },
583
- newItem: { variant: "info", check: !1 },
584
- skip: { variant: "neutral", check: !1 },
585
- alreadyLoaded: { variant: "neutral", check: !0 }
586
- };
587
- function bt(e, t) {
588
- return e === "matched" ? t("billLineTable.match.matched", "Matched") : e === "newItem" ? t("billLineTable.match.newItem", "New item") : e === "alreadyLoaded" ? t("billLineTable.match.alreadyLoaded", "Already loaded") : t("billLineTable.match.skip", "Skip");
589
- }
590
- function Ut(e, t) {
591
- const i = St(e), n = i ? Se(i) : null;
592
- return n === null ? e.trim() : K(Tn(n, -2), t, {
593
- style: "percent",
594
- minimumFractionDigits: 0,
595
- maximumFractionDigits: Cn
596
- });
597
- }
598
- function ne({
599
- value: e,
600
- currency: t,
601
- fractionDigits: i = _t,
602
- tone: n = "default"
603
- }) {
604
- const r = oe(e);
605
- return r ? /* @__PURE__ */ o(
606
- gn,
607
- {
608
- size: "sm",
609
- tone: n,
610
- value: r.units,
611
- scale: r.scale,
612
- currency: t,
613
- minimumFractionDigits: Math.min(2, i),
614
- maximumFractionDigits: i
615
- }
616
- ) : /* @__PURE__ */ o("span", { dir: "ltr", className: qe(), children: e.trim() });
617
- }
618
- function Jn(e, t) {
619
- const i = e.value.quantity;
620
- if (i === null) return null;
621
- const n = A(i), r = n.value ? Se(n.value) : null;
622
- return /* @__PURE__ */ O("span", { className: qe(), children: [
623
- r === null ? (
624
- // More digits than a double holds: every digit, as sent.
625
- /* @__PURE__ */ o("span", { dir: "ltr", children: i.trim() })
626
- ) : K(r, t, {
627
- maximumFractionDigits: ae
628
- }),
629
- e.line.unitOfMeasure ? /* @__PURE__ */ O(wt, { children: [
630
- " ",
631
- /* @__PURE__ */ o("span", { dir: "auto", children: e.line.unitOfMeasure })
632
- ] }) : null
633
- ] });
634
- }
635
- function Zn(e, t) {
636
- const { t: i } = t;
637
- if (!e.selected) return;
638
- const n = A(e.value.quantity);
639
- if (n.empty)
640
- return i("billLineTable.quantity.errorRequired", "Enter a quantity");
641
- if (!n.wellFormed || !n.positive)
642
- return i(
643
- "billLineTable.quantity.errorNotPositive",
644
- "Enter a quantity above 0"
645
- );
646
- if (Ct(e.line, e.value))
647
- return i("billLineTable.quantity.errorTooLarge", {
648
- max: K(ye, t.language),
649
- defaultValue: "Enter a quantity of {{max}} or less"
650
- });
651
- const r = e.line.warnings.find(
652
- (u) => u.severity === "error"
653
- );
654
- return r == null ? void 0 : r.message;
655
- }
656
- function ei(e, t) {
657
- if (!e.itemKnown)
658
- return t(
659
- "billLineTable.item.errorUnknown",
660
- "This item is no longer in the warehouse. Choose another."
661
- );
662
- if (e.selected && qt(e.value))
663
- return t(
664
- "billLineTable.item.errorNameRequired",
665
- "Enter a name for the new item"
666
- );
667
- }
668
- function ti(e, t) {
669
- const i = An(e.line.lineTotal, e.value.quantity), n = i !== null && !Rn(i, e.line.unitPrice) ? i : null;
670
- return /* @__PURE__ */ O("span", { className: Mt({ align: "end" }), children: [
671
- /* @__PURE__ */ o(ne, { value: e.line.unitPrice, currency: t.currency }),
672
- n !== null ? /* @__PURE__ */ O("span", { className: Pt(), children: [
673
- t.t("billLineTable.unitPrice.netLabel", "Net per unit"),
674
- " ",
675
- /* @__PURE__ */ o(
676
- ne,
677
- {
678
- value: n,
679
- currency: t.currency,
680
- tone: "muted"
681
- }
682
- )
683
- ] }) : null
684
- ] });
685
- }
686
- function ni(e, t) {
687
- return e.line.adjustments.length === 0 ? null : /* @__PURE__ */ o("ul", { className: Kt({ align: "end" }), children: e.line.adjustments.map((i, n) => (
688
- // Index key: the blocks have no identity and never reorder.
689
- /* @__PURE__ */ O("li", { className: qe(), children: [
690
- /* @__PURE__ */ o(Ye, { children: i.type === "discount" ? t.t("billLineTable.adjustment.discount", "Discount") : t.t("billLineTable.adjustment.surcharge", "Surcharge") }),
691
- /* @__PURE__ */ o("span", { "aria-hidden": "true", children: i.type === "discount" ? "−" : "+" }),
692
- i.percent !== null ? Ut(i.percent, t.language) : i.amount !== null ? /* @__PURE__ */ o(ne, { value: i.amount, currency: t.currency }) : null
693
- ] }, n)
694
- )) });
695
- }
696
- function ii(e, t) {
697
- if (e.line.vatPercent === null)
698
- return /* @__PURE__ */ O(wt, { children: [
699
- /* @__PURE__ */ o("span", { "aria-hidden": "true", children: "–" }),
700
- /* @__PURE__ */ o(Ye, { children: t.t("billLineTable.vat.none", "No VAT rate") })
701
- ] });
702
- const i = Ut(e.line.vatPercent, t.language);
703
- return e.line.vatNature ? t.t("billLineTable.vat.withNature", {
704
- rate: i,
705
- nature: e.line.vatNature,
706
- defaultValue: "{{rate}} ({{nature}})"
707
- }) : i;
708
- }
709
- function We(e, t) {
710
- return t.privacyMode ? t.t("billLineTable.item.newOptionMasked", "New item") : t.t("billLineTable.item.newOption", {
711
- name: e,
712
- defaultValue: "New item: {{name}}"
713
- });
714
- }
715
- function ri(e, t) {
716
- const i = [We("", { ...t, privacyMode: !1 }).trim()];
717
- t.privacyMode && i.push(t.t("billLineTable.item.newOptionMasked", "New item"));
718
- for (const n of i)
719
- if (n !== "" && e.startsWith(n))
720
- return e.slice(n.length).trim();
721
- return e.trim();
722
- }
723
- function It(e, t) {
724
- var n;
725
- const i = e.value.item;
726
- return i.kind === "new" ? We(i.name, t) : ((n = e.item) == null ? void 0 : n.name) ?? "";
727
- }
728
- function Qt(e) {
729
- return {
730
- value: e.id,
731
- label: e.name,
732
- description: e.code ?? void 0,
733
- // Item names are text a practice wrote.
734
- dir: "auto"
735
- };
736
- }
737
- const ai = () => 1;
738
- function li(e, t) {
739
- const i = [...e.line.warnings];
740
- return e.quantityLocked && i.push({
741
- code: Et,
742
- message: t.t(
743
- "billLineTable.quantity.tooLarge",
744
- "This quantity is too large to edit here. It loads as on the invoice."
745
- ),
746
- severity: "warning"
747
- }), t.privacyMode && e.selected && Dn(e.line, e.value) && i.push({
748
- code: "newItemNameHidden",
749
- message: t.t(
750
- "billLineTable.item.checkNameHidden",
751
- "The new item takes the line description as its name. Turn off privacy mode to check it before you load."
752
- ),
753
- severity: "warning"
754
- }), i.length === 0 ? null : /* @__PURE__ */ o("ul", { className: Kt(), children: i.map((n, r) => (
755
- // Index key: warnings have no identity of their own.
756
- /* @__PURE__ */ O("li", { className: Wn(), children: [
757
- n.severity === "error" ? /* @__PURE__ */ o(
758
- _n,
759
- {
760
- "aria-hidden": "true",
761
- className: ht({ severity: "error" })
762
- }
763
- ) : /* @__PURE__ */ o(
764
- En,
765
- {
766
- "aria-hidden": "true",
767
- className: ht({ severity: "warning" })
768
- }
769
- ),
770
- /* @__PURE__ */ O("span", { className: jn(), children: [
771
- /* @__PURE__ */ o(Ye, { children: n.severity === "error" ? t.t("billLineTable.warnings.error", "Error:") : t.t("billLineTable.warnings.warning", "Warning:") }),
772
- /* @__PURE__ */ o("span", { dir: "auto", children: n.message })
773
- ] })
774
- ] }, r)
775
- )) });
776
- }
777
- function oi({
778
- row: e,
779
- context: t,
780
- deps: i
781
- }) {
782
- const n = fe(Ft), { t: r, setItem: u, queryItems: E } = i, { line: T, value: p, item: g } = e, N = p.item.kind === "new" ? p.item.name : null, R = I(null), q = I(i.privacyMode), V = I(0), D = I(!1);
783
- if (q.current !== i.privacyMode) {
784
- q.current = i.privacyMode;
785
- const y = R.current;
786
- y !== null && y.contains(y.ownerDocument.activeElement) && (V.current += 1, D.current = !0);
787
- }
788
- cn(() => {
789
- if (!D.current) return;
790
- D.current = !1;
791
- const y = () => {
792
- var v, M;
793
- return (M = (v = R.current) == null ? void 0 : v.querySelector('input[role="combobox"]')) == null ? void 0 : M.focus();
794
- };
795
- y(), queueMicrotask(y);
796
- }, [i.privacyMode]);
797
- const B = b(() => N !== null ? [
798
- {
799
- value: le,
800
- label: We(N, i),
801
- description: r(
802
- "billLineTable.item.newOptionDescription",
803
- "Created when you load the invoice"
804
- )
805
- },
806
- ...n.itemOptions
807
- ] : g && !n.itemOptionIds.has(g.id) ? [Qt(g), ...n.itemOptions] : n.itemOptions, [N, g, n.itemOptions, n.itemOptionIds, i, r]), j = b(
808
- () => ({
809
- label: r("billLineTable.item.createNew", "Create new item"),
810
- icon: /* @__PURE__ */ o(kn, {}),
811
- // Marks the line only; nothing is created before Confirm (D5). The
812
- // typed text names the item; with none, the description does.
813
- onSelect: (y) => u(T.id, {
814
- kind: "new",
815
- name: ri(y, i)
816
- })
817
- }),
818
- [r, u, T.id, i]
819
- );
820
- return /* @__PURE__ */ o("div", { ref: R, className: zn(), children: /* @__PURE__ */ o(
821
- hn,
822
- {
823
- "aria-labelledby": t.labelledBy,
824
- "aria-invalid": t.invalid || void 0,
825
- "aria-describedby": t.errorId,
826
- options: B,
827
- value: p.item.kind === "existing" ? p.item.itemId : le,
828
- onValueChange: (y) => {
829
- y === "" || y === le || u(T.id, { kind: "existing", itemId: y });
830
- },
831
- placeholder: r("billLineTable.item.placeholder", "Choose an item"),
832
- openOnFocus: !1,
833
- popoverSize: "md",
834
- wrapOptionLabels: !0,
835
- action: j,
836
- onQueryChange: n.serverSearch ? (y) => E(T.id, y) : void 0,
837
- filter: n.serverSearch ? ai : void 0,
838
- loading: n.serverSearch ? n.searchingLineId === T.id && n.itemsLoading : void 0
839
- },
840
- V.current
841
- ) });
842
- }
843
- function si({ deps: e }) {
844
- const t = fe(pe);
845
- if (!t) return null;
846
- const i = t.lineCount - t.alreadyLoadedCount;
847
- return /* @__PURE__ */ O("span", { className: Mt(), children: [
848
- /* @__PURE__ */ o("span", { children: e.t("billLineTable.footer.ticked", {
849
- count: i,
850
- selected: K(t.selectedCount, e.language),
851
- total: K(i, e.language),
852
- defaultValue: "{{selected}} of {{total}} lines ticked",
853
- defaultValue_one: "{{selected}} of {{total}} line ticked",
854
- defaultValue_other: "{{selected}} of {{total}} lines ticked"
855
- }) }),
856
- t.newItemCount > 0 ? /* @__PURE__ */ o("span", { className: Pt(), children: e.t("billLineTable.footer.newItems", {
857
- count: t.newItemCount,
858
- countText: K(t.newItemCount, e.language),
859
- defaultValue: "{{countText}} new items",
860
- defaultValue_one: "{{countText}} new item",
861
- defaultValue_other: "{{countText}} new items"
862
- }) }) : null
863
- ] });
864
- }
865
- function ci({ currency: e }) {
866
- const t = fe(pe);
867
- return t ? /* @__PURE__ */ o(ne, { value: t.vat, currency: e, fractionDigits: 2 }) : null;
868
- }
869
- function ui({ deps: e }) {
870
- const t = fe(pe);
871
- return t ? /* @__PURE__ */ O("dl", { className: Gn(), children: [
872
- /* @__PURE__ */ o("dt", { className: gt(), children: e.t("billLineTable.footer.net", "Net") }),
873
- /* @__PURE__ */ o("dd", { className: vt(), children: /* @__PURE__ */ o(
874
- ne,
875
- {
876
- value: t.net,
877
- currency: e.currency,
878
- fractionDigits: 2
879
- }
880
- ) }),
881
- /* @__PURE__ */ o("dt", { className: gt(), children: e.t("billLineTable.footer.gross", "Total with VAT") }),
882
- /* @__PURE__ */ o("dd", { className: vt(), children: /* @__PURE__ */ o(
883
- ne,
884
- {
885
- value: t.gross,
886
- currency: e.currency,
887
- fractionDigits: 2
888
- }
889
- ) })
890
- ] }) : null;
891
- }
892
- function di({ deps: e }) {
893
- const t = fe(pe);
894
- return !t || t.warningLineCount === 0 ? null : /* @__PURE__ */ o("span", { children: e.t("billLineTable.footer.warningLines", {
895
- count: t.warningLineCount,
896
- countText: K(t.warningLineCount, e.language),
897
- defaultValue: "{{countText}} lines with warnings",
898
- defaultValue_one: "{{countText}} line with warnings",
899
- defaultValue_other: "{{countText}} lines with warnings"
900
- }) });
901
- }
902
- function mi(e) {
903
- const { t } = e, i = {
904
- kind: "number",
905
- mode: "decimal",
906
- // The float lives only inside NumberInput: every change goes back to
907
- // exact text at once, within BILL_LINE_MAX_QUANTITY. Unsigned in the
908
- // field and in the value: the document carries the sign (D6).
909
- // A typed value above the limit stays in the field with its error
910
- // (`quantityError`); an invoiced one is locked by `isEditable`.
911
- getValue: (n) => {
912
- const r = A(n.value.quantity).value;
913
- return r ? Se(r) : null;
914
- },
915
- onChange: (n, r) => e.setQuantity(
916
- n.line.id,
917
- r === null ? null : On(r)
918
- ),
919
- // A quantity the editor cannot hold exactly stays text, never clamped.
920
- isEditable: (n) => !n.readOnly && !n.quantityLocked,
921
- min: 0,
922
- max: ye,
923
- step: 1,
924
- maximumFractionDigits: ae,
925
- // DG-1: FatturaPA UnitaMisura per line, as the supplier wrote it.
926
- unit: (n) => n.line.unitOfMeasure ?? void 0,
927
- error: (n) => Zn(n, e),
928
- // WCAG 3.3.2: the field says how many decimals it takes, since a digit
929
- // past the limit is refused as it is typed. Kit copy and a constant
930
- // only, so it shows in privacy mode too (`hostTextPrivacySafe`).
931
- description: () => t(
932
- "billLineTable.quantity.precision",
933
- "Up to {{formatted}} decimal places",
934
- {
935
- count: ae,
936
- formatted: K(
937
- ae,
938
- e.language
939
- )
940
- }
941
- )
942
- };
943
- return [
944
- {
945
- id: "description",
946
- header: t("billLineTable.column.description", "Description"),
947
- rowHeader: !0,
948
- pin: "start",
949
- wrap: !0,
950
- // Lab invoices can name a patient here (D9).
951
- privacy: "mask",
952
- cell: (n) => /* @__PURE__ */ o("span", { dir: "auto", children: n.line.description }),
953
- value: (n) => n.line.description,
954
- // No sorting in any mode (D10); privacy mode would turn it off anyway.
955
- sort: !1,
956
- size: 240,
957
- minSize: 192,
958
- hideable: !1,
959
- reorderable: !1,
960
- // The totals row's header cell.
961
- footer: () => /* @__PURE__ */ o(si, { deps: e })
962
- },
963
- {
964
- id: "quantity",
965
- header: e.documentKind === "creditNote" ? t("billLineTable.column.quantityCreditNote", "Quantity to remove") : t("billLineTable.column.quantity", "Quantity"),
966
- align: "end",
967
- // Read-only lines (a loaded invoice, the table while loading, or a
968
- // locked quantity): the unsigned value as text, plus the unit.
969
- cell: (n) => Jn(n, e.language),
970
- exportValue: (n) => n.value.quantity,
971
- edit: i,
972
- size: 128,
973
- hideable: !1,
974
- reorderable: !1
975
- },
976
- {
977
- id: "item",
978
- header: t("billLineTable.column.item", "Warehouse item"),
979
- cell: (n) => /* @__PURE__ */ o("span", { dir: "auto", children: It(n, e) }),
980
- exportValue: (n) => It(n, e) || null,
981
- edit: {
982
- kind: "custom",
983
- render: (n, r) => /* @__PURE__ */ o(oi, { row: n, context: r, deps: e }),
984
- error: (n) => ei(n, t)
985
- },
986
- size: 240,
987
- minSize: 192,
988
- hideable: !1,
989
- reorderable: !1
990
- },
991
- {
992
- id: "match",
993
- header: t("billLineTable.column.match", "Status"),
994
- cell: (n) => {
995
- const r = Xn[n.matchState];
996
- return /* @__PURE__ */ o(
997
- Ln,
998
- {
999
- size: "sm",
1000
- variant: r.variant,
1001
- leading: r.check ? /* @__PURE__ */ o(Nn, {}) : void 0,
1002
- children: bt(n.matchState, t)
1003
- }
1004
- );
1005
- },
1006
- exportValue: (n) => bt(n.matchState, t),
1007
- size: 136,
1008
- hideable: !1,
1009
- reorderable: !1
1010
- },
1011
- {
1012
- id: "warnings",
1013
- header: t("billLineTable.column.warnings", "Warnings"),
1014
- wrap: !0,
1015
- // Not masked: a warning must not quote the description
1016
- // (BillLineWarning.message), so errors stay readable (D9).
1017
- cell: (n) => li(n, e),
1018
- exportValue: (n) => n.line.warnings.map((r) => r.message).join("; ") || null,
1019
- size: 184,
1020
- hideable: !1,
1021
- reorderable: !1,
1022
- footer: () => /* @__PURE__ */ o(di, { deps: e })
1023
- },
1024
- {
1025
- id: "lineTotal",
1026
- header: t("billLineTable.column.lineTotal", "Amount"),
1027
- align: "end",
1028
- cell: (n) => /* @__PURE__ */ o(ne, { value: n.line.lineTotal, currency: e.currency }),
1029
- exportValue: (n) => n.line.lineTotal,
1030
- size: 128,
1031
- hideable: !1,
1032
- reorderable: !1,
1033
- // From the summary (exact decimals, ticked lines), not from the
1034
- // footer context's rows.
1035
- footer: () => /* @__PURE__ */ o(ui, { deps: e })
1036
- },
1037
- {
1038
- id: "unitPrice",
1039
- header: t("billLineTable.column.unitPrice", "Unit price"),
1040
- align: "end",
1041
- cell: (n) => ti(n, e),
1042
- exportValue: (n) => n.line.unitPrice,
1043
- size: 128,
1044
- hideable: !1,
1045
- reorderable: !1
1046
- },
1047
- {
1048
- id: "vat",
1049
- header: t("billLineTable.column.vat", "VAT"),
1050
- align: "end",
1051
- cell: (n) => ii(n, e),
1052
- exportValue: (n) => n.line.vatPercent,
1053
- size: 88,
1054
- hideable: !1,
1055
- reorderable: !1,
1056
- // VAT of the ticked lines, under the VAT header.
1057
- footer: () => /* @__PURE__ */ o(ci, { currency: e.currency })
1058
- },
1059
- {
1060
- id: "adjustment",
1061
- header: t("billLineTable.column.adjustment", "Discount or surcharge"),
1062
- align: "end",
1063
- cell: (n) => ni(n, e),
1064
- exportValue: (n) => n.line.adjustments.map(
1065
- (r) => `${r.type === "discount" ? "-" : "+"}${r.percent !== null ? `${r.percent}%` : r.amount ?? ""}`
1066
- ).join(", ") || null,
1067
- size: 112,
1068
- hideable: !1,
1069
- reorderable: !1
1070
- },
1071
- {
1072
- id: "supplierCode",
1073
- header: t("billLineTable.column.supplierCode", "Supplier code"),
1074
- cell: (n) => n.line.supplierCode === null ? null : /* @__PURE__ */ o("span", { dir: "ltr", className: qe(), children: n.line.supplierCode }),
1075
- exportValue: (n) => n.line.supplierCode,
1076
- size: 112,
1077
- hideable: !1,
1078
- reorderable: !1
1079
- }
1080
- ];
1081
- }
1082
- function fi(e) {
1083
- return e.map(Qt);
1084
- }
1085
- const Tt = {};
1086
- function ee(e, t) {
1087
- return new Error(`${e}: ${t}`);
1088
- }
1089
- function yi(e, t) {
1090
- return e.length === t.length && e.every((i, n) => i === t[n]);
1091
- }
1092
- function pi(e) {
1093
- return JSON.stringify(e);
1094
- }
1095
- const Li = un(function({
1096
- lines: t,
1097
- items: i,
1098
- selectedItems: n,
1099
- documentKind: r = "invoice",
1100
- currency: u = "EUR",
1101
- gridId: E,
1102
- caption: T,
1103
- values: p,
1104
- defaultValues: g,
1105
- onValuesChange: N,
1106
- selection: R,
1107
- defaultSelection: q,
1108
- onSelectionChange: V,
1109
- onSummaryChange: D,
1110
- onItemQueryChange: B,
1111
- itemsLoading: j = !1,
1112
- status: y = "ready",
1113
- error: v,
1114
- readOnly: M = !1,
1115
- privacyMode: G = !1,
1116
- height: Le = "fill",
1117
- className: m,
1118
- ...H
1119
- }, F) {
1120
- const { t: f, i18n: he } = mn("ui"), X = he.language, Oe = I(null), ge = M !== !1, Yt = I(/* @__PURE__ */ new Map()), ie = b(() => {
1121
- const a = Yt.current;
1122
- for (const c of n ?? []) a.set(c.id, c);
1123
- for (const c of i) a.set(c.id, c);
1124
- return new Map(a);
1125
- }, [i, n]);
1126
- Pe(() => {
1127
- pn() && i.some((a) => a.id === le) && console.warn(
1128
- `[BillLineTable] an item id equals "${le}", the value of the new-item option, so that item cannot be chosen.`
1129
- );
1130
- }, [i]);
1131
- const je = b(() => fi(i), [i]), Ge = b(
1132
- () => new Set(i.map((a) => a.id)),
1133
- [i]
1134
- ), [He, $t] = Te(null), Xe = B !== void 0, zt = b(
1135
- () => ({
1136
- itemOptions: je,
1137
- itemOptionIds: Ge,
1138
- serverSearch: Xe,
1139
- itemsLoading: j,
1140
- searchingLineId: He
1141
- }),
1142
- [je, Ge, Xe, j, He]
1143
- ), Je = p !== void 0, [Wt, jt] = Te(
1144
- () => g ?? Tt
1145
- ), x = p ?? Wt, Ae = R !== void 0, [Re, Ze] = Te(
1146
- () => q ?? Ke(t)
1147
- ), [et, Gt] = Te(t);
1148
- if (et !== t && (Gt(t), !Ae && q === void 0)) {
1149
- const a = new Set(et.map((d) => d.id)), c = Ke(t).filter(
1150
- (d) => !a.has(d) && !Re.includes(d)
1151
- );
1152
- c.length > 0 && Ze([...Re, ...c]);
1153
- }
1154
- const S = R ?? Re, U = I(x);
1155
- U.current = x;
1156
- const Q = I(S);
1157
- Q.current = S;
1158
- const tt = I(null), nt = I(null), ve = b(
1159
- () => ({
1160
- values: g ?? Tt,
1161
- selection: q ?? Ke(t)
1162
- }),
1163
- [g, q, t]
1164
- ), it = I(/* @__PURE__ */ new Map()), Ve = b(() => {
1165
- const a = Lt({
1166
- lines: t,
1167
- values: x,
1168
- selection: S,
1169
- findItem: (c) => ie.get(c),
1170
- previous: it.current
1171
- });
1172
- return it.current = new Map(a.map((c) => [c.line.id, c])), a;
1173
- }, [t, x, S, ie]), Ht = b(
1174
- () => Ve.filter((a) => a.selected).map((a) => a.line.id),
1175
- [Ve]
1176
- ), rt = k(
1177
- (a) => ie.has(a),
1178
- [ie]
1179
- ), ce = b(
1180
- () => pt(
1181
- t,
1182
- x,
1183
- S,
1184
- ve,
1185
- rt
1186
- ),
1187
- [t, x, S, ve, rt]
1188
- ), at = b(
1189
- () => new Map(t.map((a) => [a.id, a])),
1190
- [t]
1191
- ), L = I({
1192
- lines: t,
1193
- lineById: at,
1194
- itemIndex: ie,
1195
- defaults: ve,
1196
- documentKind: r,
1197
- tableReadOnly: ge,
1198
- valuesControlled: Je,
1199
- selectionControlled: Ae
1200
- });
1201
- L.current = {
1202
- lines: t,
1203
- lineById: at,
1204
- itemIndex: ie,
1205
- defaults: ve,
1206
- documentKind: r,
1207
- tableReadOnly: ge,
1208
- valuesControlled: Je,
1209
- selectionControlled: Ae
1210
- };
1211
- const ue = I({
1212
- onValuesChange: N,
1213
- onSelectionChange: V,
1214
- onSummaryChange: D,
1215
- onItemQueryChange: B
1216
- });
1217
- ue.current = {
1218
- onValuesChange: N,
1219
- onSelectionChange: V,
1220
- onSummaryChange: D,
1221
- onItemQueryChange: B
1222
- };
1223
- const De = I(/* @__PURE__ */ new Set()), Y = k((a) => {
1224
- for (const c of [...De.current]) c(a);
1225
- }, []), J = k(
1226
- (a, c, d, h) => {
1227
- var Z, Ie;
1228
- const C = L.current;
1229
- if (!C.lineById.has(a)) return;
1230
- const P = ft(C.lines, U.current), l = P[a], s = { ...l, ...d };
1231
- if (Rt(l, s)) return;
1232
- const w = {
1233
- ...P,
1234
- [a]: s
1235
- };
1236
- U.current = w, tt.current = w, C.valuesControlled || jt(w), (Ie = (Z = ue.current).onValuesChange) == null || Ie.call(Z, w, { lineId: a, field: c, source: h }), Y({ event: "values", source: h });
1237
- },
1238
- [Y]
1239
- ), re = k(
1240
- (a, c) => {
1241
- var P, l;
1242
- const d = L.current, h = $(d.lines, a), C = $(
1243
- d.lines,
1244
- Q.current
1245
- );
1246
- yi(h, C) || (Q.current = h, nt.current = h, d.selectionControlled || Ze(h), (l = (P = ue.current).onSelectionChange) == null || l.call(P, h), Y({ event: "selection", source: c }));
1247
- },
1248
- [Y]
1249
- ), lt = k(
1250
- (a, c) => J(a, "quantity", { quantity: c }, "user"),
1251
- [J]
1252
- ), ot = k(
1253
- (a, c) => {
1254
- const d = L.current.lineById.get(a);
1255
- d && J(
1256
- a,
1257
- "item",
1258
- { item: Qe(c, d) },
1259
- "user"
1260
- );
1261
- },
1262
- [J]
1263
- ), st = k((a, c) => {
1264
- var d, h;
1265
- $t(a), (h = (d = ue.current).onItemQueryChange) == null || h.call(d, a, c);
1266
- }, []), Xt = k(
1267
- (a) => re(a, "user"),
1268
- [re]
1269
- ), ct = I(null);
1270
- Pe(() => {
1271
- var c, d;
1272
- const a = pi(ce);
1273
- a !== ct.current && (ct.current = a, (d = (c = ue.current).onSummaryChange) == null || d.call(c, ce));
1274
- }, [ce]);
1275
- const be = `${y}:${ge ? "readOnly" : "editable"}`, ut = I({
1276
- lines: t,
1277
- values: x,
1278
- selection: S,
1279
- status: be
1280
- });
1281
- Pe(() => {
1282
- const a = ut.current;
1283
- (a.lines !== t || a.values !== x && x !== tt.current) && Y({ event: "values", source: "host" }), a.selection !== S && S !== nt.current && Y({ event: "selection", source: "host" }), a.status !== be && Y({ event: "status", source: "host" }), ut.current = {
1284
- lines: t,
1285
- values: x,
1286
- selection: S,
1287
- status: be
1288
- };
1289
- }, [t, x, S, be, Y]);
1290
- const Be = b(() => {
1291
- const a = () => {
1292
- const l = L.current;
1293
- return Lt({
1294
- lines: l.lines,
1295
- values: U.current,
1296
- selection: Q.current,
1297
- findItem: (s) => l.itemIndex.get(s)
1298
- });
1299
- }, c = (l) => Qn(l, {
1300
- tableReadOnly: L.current.tableReadOnly,
1301
- documentKind: L.current.documentKind
1302
- }), d = (l) => L.current.itemIndex.has(l), h = (l) => {
1303
- const s = L.current.lineById.get(l);
1304
- if (!s) throw ee("UNKNOWN_LINE", `no line "${l}".`);
1305
- return s;
1306
- }, C = () => {
1307
- if (L.current.tableReadOnly)
1308
- throw ee(
1309
- "TABLE_READ_ONLY",
1310
- "the table is read-only while the load request runs."
1311
- );
1312
- }, P = (l) => {
1313
- if (te(L.current.lines))
1314
- throw ee(
1315
- "LINE_READ_ONLY",
1316
- `line "${l}" belongs to an invoice that is already loaded.`
1317
- );
1318
- };
1319
- return {
1320
- getLineIds: () => L.current.lines.map((l) => l.id),
1321
- getLine: (l) => {
1322
- const s = L.current, w = s.lineById.get(l);
1323
- if (!w) return null;
1324
- const Z = Bt(
1325
- w,
1326
- U.current[l] ?? z(w),
1327
- {
1328
- invoiceLoaded: te(s.lines),
1329
- ticked: new Set(
1330
- $(s.lines, Q.current)
1331
- ),
1332
- findItem: (Ie) => s.itemIndex.get(Ie)
1333
- }
1334
- );
1335
- return c(Z);
1336
- },
1337
- getLines: () => a().map(c),
1338
- getSelection: () => $(L.current.lines, Q.current),
1339
- getValues: () => ft(L.current.lines, U.current),
1340
- getSummary: () => {
1341
- const l = L.current;
1342
- return pt(
1343
- l.lines,
1344
- U.current,
1345
- Q.current,
1346
- l.defaults,
1347
- d
1348
- );
1349
- },
1350
- getInvalidLineIds: () => a().filter((l) => l.invalid).map((l) => l.line.id),
1351
- getLoadPayload: () => {
1352
- const l = L.current;
1353
- return Kn(
1354
- l.lines,
1355
- U.current,
1356
- Q.current,
1357
- l.documentKind,
1358
- d
1359
- );
1360
- },
1361
- setSelection: (l) => {
1362
- for (const s of l) h(s);
1363
- C();
1364
- for (const s of l) {
1365
- if (h(s).alreadyLoaded)
1366
- throw ee(
1367
- "LINE_READ_ONLY",
1368
- `line "${s}" is already loaded.`
1369
- );
1370
- P(s);
1371
- }
1372
- re(l, "api");
1373
- },
1374
- selectAll: () => {
1375
- C(), re(
1376
- L.current.lines.map((l) => l.id),
1377
- "api"
1378
- );
1379
- },
1380
- clearSelection: () => {
1381
- C(), re([], "api");
1382
- },
1383
- setQuantity: (l, s) => {
1384
- const w = h(l), Z = Yn(s);
1385
- if (Z === null)
1386
- throw ee(
1387
- "INVALID_QUANTITY",
1388
- `"${s}" is not a quantity above 0 and at most ${ye}, with at most ${ae} decimal places.`
1389
- );
1390
- if (C(), P(l), !$e(w.quantity))
1391
- throw ee(
1392
- "LINE_READ_ONLY",
1393
- `line "${l}" has a quantity too large to edit; it loads as invoiced.`
1394
- );
1395
- J(l, "quantity", { quantity: Z }, "api");
1396
- },
1397
- setItem: (l, s) => {
1398
- const w = h(l);
1399
- if (s.kind === "existing" && (s.itemId === le || !d(s.itemId)))
1400
- throw ee("UNKNOWN_ITEM", `no item "${s.itemId}".`);
1401
- C(), P(l), J(
1402
- l,
1403
- "item",
1404
- { item: Qe(s, w) },
1405
- "api"
1406
- );
1407
- },
1408
- focusLine: (l, s = "select") => {
1409
- var w;
1410
- h(l), (w = Oe.current) == null || w.focusRow(
1411
- l,
1412
- s === "select" ? void 0 : s
1413
- );
1414
- },
1415
- scrollToLine: (l) => {
1416
- var s;
1417
- h(l), (s = Oe.current) == null || s.scrollToRow(l);
1418
- },
1419
- subscribe: (l) => (De.current.add(l), () => {
1420
- De.current.delete(l);
1421
- })
1422
- };
1423
- }, [re, J]);
1424
- dn(F, () => Be, [Be]), fn(Sn, Be, E);
1425
- const Jt = b(
1426
- () => mi({
1427
- t: f,
1428
- language: X,
1429
- documentKind: r,
1430
- currency: u,
1431
- privacyMode: G,
1432
- setQuantity: lt,
1433
- setItem: ot,
1434
- queryItems: st
1435
- }),
1436
- [
1437
- f,
1438
- X,
1439
- r,
1440
- u,
1441
- G,
1442
- lt,
1443
- ot,
1444
- st
1445
- ]
1446
- ), Zt = k((a) => a.line.id, []), en = k((a) => a.readOnly, []), tn = k(
1447
- (a) => f("billLineTable.rowLabel", {
1448
- number: K(a.line.lineNumber, X),
1449
- defaultValue: "Line {{number}}"
1450
- }),
1451
- [f, X]
1452
- ), nn = k(
1453
- (a) => a.line.alreadyLoaded ? {
1454
- state: "none",
1455
- reason: f(
1456
- "billLineTable.selection.alreadyLoadedReason",
1457
- "Already loaded into the warehouse"
1458
- )
1459
- } : a.readOnly ? {
1460
- state: "none",
1461
- reason: f(
1462
- "billLineTable.selection.invoiceLoadedReason",
1463
- "This invoice was already loaded. Lines left out then cannot be loaded later."
1464
- )
1465
- } : "selectable",
1466
- [f]
1467
- ), rn = ce.invoiceLoaded, Me = ge ? typeof M == "object" && M.reason !== "" && !G ? M.reason : f(
1468
- "billLineTable.selection.readOnlyReason",
1469
- "Loading into the warehouse"
1470
- ) : rn ? f(
1471
- "billLineTable.selection.invoiceLoadedReason",
1472
- "This invoice was already loaded. Lines left out then cannot be loaded later."
1473
- ) : null, an = b(
1474
- () => Me === null ? !1 : { reason: Me },
1475
- [Me]
1476
- ), ln = b(
1477
- () => ({
1478
- title: (v == null ? void 0 : v.title) ?? f("billLineTable.error.title", "The invoice lines could not be read"),
1479
- description: (v == null ? void 0 : v.description) ?? f(
1480
- "billLineTable.error.description",
1481
- "Try again. If it keeps failing, open the invoice to check it."
1482
- ),
1483
- onRetry: v == null ? void 0 : v.onRetry
1484
- }),
1485
- [v, f]
1486
- ), on = b(
1487
- () => ({
1488
- title: f(
1489
- "billLineTable.empty.title",
1490
- "This invoice has no lines to load"
1491
- ),
1492
- description: f(
1493
- "billLineTable.empty.description",
1494
- "Open the invoice to check what the supplier sent."
1495
- )
1496
- }),
1497
- [f]
1498
- ), sn = T ?? (r === "creditNote" ? f("billLineTable.captionCreditNote", "Credit note lines") : f("billLineTable.caption", "Invoice lines"));
1499
- return /* @__PURE__ */ o(
1500
- "div",
1501
- {
1502
- ...H,
1503
- "data-component": "bill-line-table",
1504
- "data-component-id": E,
1505
- className: $n({ height: Le, className: m }),
1506
- children: /* @__PURE__ */ o(Ft.Provider, { value: zt, children: /* @__PURE__ */ o(pe.Provider, { value: ce, children: /* @__PURE__ */ o(
1507
- yn,
1508
- {
1509
- ref: Oe,
1510
- caption: sn,
1511
- columns: Jt,
1512
- rows: Ve,
1513
- getRowId: Zt,
1514
- registerAgent: !1,
1515
- persistColumnState: !1,
1516
- dataMode: "client",
1517
- selectionMode: "multiple",
1518
- rowSelection: Ht,
1519
- onRowSelectionChange: Xt,
1520
- getRowSelectability: nn,
1521
- selectAllScope: "all",
1522
- rangeSelection: !0,
1523
- isRowReadOnly: en,
1524
- readOnly: an,
1525
- getRowLabel: tn,
1526
- rowLabelPrivacySafe: !0,
1527
- hostTextPrivacySafe: !0,
1528
- multiSort: !1,
1529
- columnResizing: !1,
1530
- responsiveColumns: !1,
1531
- status: y,
1532
- error: ln,
1533
- empty: on,
1534
- density: "default",
1535
- height: Le,
1536
- virtualization: "auto",
1537
- privacyMode: G
1538
- }
1539
- ) }) })
1540
- }
1541
- );
1542
- });
1543
- Li.displayName = "BillLineTable";
1544
- export {
1545
- mt as B,
1546
- ye as a,
1547
- le as b,
1548
- Cn as c,
1549
- _t as d,
1550
- ae as e,
1551
- Et as f,
1552
- Li as g,
1553
- Sn as h,
1554
- Kn as i,
1555
- Mn as j,
1556
- Ke as k,
1557
- z as l,
1558
- Vi as m,
1559
- te as n,
1560
- ze as o,
1561
- $e as p,
1562
- An as q,
1563
- pt as s
1564
- };
1565
- //# sourceMappingURL=bill-line-table-vCnVo7_a.js.map