@wisemen/wise-invoicing-web 0.1.0 → 0.1.1

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.
@@ -1156,6 +1156,15 @@ var [ar, or] = ir("BillingDocumentLineItemsTable"), sr = [
1156
1156
  }
1157
1157
  return i !== void 0 && this.isLineRow(i) && i.groupId !== null ? i.groupId : null;
1158
1158
  }
1159
+ static restoreUnsavedRows(e, t) {
1160
+ if (t.size === 0) return e;
1161
+ let n = [];
1162
+ for (let r = 0; r <= e.length; r += 1) {
1163
+ let i = e[r];
1164
+ n.push(...t.get(r) ?? []), i !== void 0 && n.push(i);
1165
+ }
1166
+ return n;
1167
+ }
1159
1168
  static serializeLineFields(e) {
1160
1169
  return this.isLineRow(e) ? {
1161
1170
  groupId: e.groupId,
@@ -1179,16 +1188,25 @@ var [ar, or] = ir("BillingDocumentLineItemsTable"), sr = [
1179
1188
  } : e);
1180
1189
  }
1181
1190
  static syncBillingDocumentLineItemRowsWithServer(e, t) {
1182
- let n = /* @__PURE__ */ new Map();
1183
- for (let [r, i] of e.entries()) {
1184
- if (!this.isGroupRow(i)) continue;
1185
- let e = t[r];
1186
- e !== void 0 && this.isGroupRow(e) && n.set(i.id, e.id);
1187
- }
1188
- return e.map((e, r) => {
1189
- let i = t[r], a = i !== void 0 && i.type === e.type ? i.id : e.id;
1191
+ let n = [], r = /* @__PURE__ */ new Map();
1192
+ for (let i of t) {
1193
+ if (!this.isTransientEmptyLineRow(i)) {
1194
+ n.push(i);
1195
+ continue;
1196
+ }
1197
+ let t = Math.min(n.length, e.length), a = r.get(t) ?? [];
1198
+ a.push(i), r.set(t, a);
1199
+ }
1200
+ let i = /* @__PURE__ */ new Map();
1201
+ for (let [t, r] of e.entries()) {
1202
+ if (!this.isGroupRow(r)) continue;
1203
+ let e = n[t];
1204
+ e !== void 0 && this.isGroupRow(e) && i.set(r.id, e.id);
1205
+ }
1206
+ let a = e.map((e, t) => {
1207
+ let r = n[t], a = r !== void 0 && r.type === e.type ? r.id : e.id;
1190
1208
  if (this.isLineRow(e) && e.groupId !== null) {
1191
- let t = n.get(e.groupId);
1209
+ let t = i.get(e.groupId);
1192
1210
  return {
1193
1211
  ...e,
1194
1212
  id: a,
@@ -1200,6 +1218,7 @@ var [ar, or] = ir("BillingDocumentLineItemsTable"), sr = [
1200
1218
  id: a
1201
1219
  };
1202
1220
  });
1221
+ return this.restoreUnsavedRows(a, r);
1203
1222
  }
1204
1223
  static trimOrNull(e) {
1205
1224
  if (e === null) return null;
@@ -4906,7 +4925,8 @@ function Vs(e) {
4906
4925
  return a.value.splice(e, 0, n), o.syncSelection(), n.id;
4907
4926
  }
4908
4927
  function m() {
4909
- return p(a.value.length);
4928
+ let e = H.createNewBillingDocumentLineItemRow(s.value);
4929
+ return a.value.push(e), o.syncSelection(), e.id;
4910
4930
  }
4911
4931
  function h(e) {
4912
4932
  let t = H.createNewBillingDocumentLineItemGroupRow();
@@ -5072,7 +5092,9 @@ function Us(e) {
5072
5092
  updateLines: e.updateLines,
5073
5093
  meta: s
5074
5094
  });
5075
- return ht(m, () => _.applyServerRows(), { immediate: !0 }), {
5095
+ return ht(m, (e, t) => {
5096
+ t !== void 0 && d.value || _.applyServerRows();
5097
+ }, { immediate: !0 }), {
5076
5098
  hasInvalidRows: p,
5077
5099
  hasSaveError: r,
5078
5100
  isDirty: d,
@@ -8,7 +8,7 @@ import { n as _, t as ee } from "./dist-boJIIxnT.js";
8
8
  import { i as te, r as v } from "./CustomFieldValueText-BGbQwhON.js";
9
9
  import { t as y } from "./formango.util-D5c2ql--.js";
10
10
  import { n as b, r as x, t as S } from "./creditNoteDetail.query-BcPsB96h.js";
11
- import { C, S as ne, _ as w, a as T, b as re, c as E, d as D, f as O, g as k, h as ie, i as ae, m as oe, n as se, o as ce, p as le, r as ue, s as de, t as fe, u as pe, v as me, w as A, x as he, y as ge } from "./BillingDocumentDetailViewDataProvider-BemnzVNY.js";
11
+ import { C, S as ne, _ as w, a as T, b as re, c as E, d as D, f as O, g as k, h as ie, i as ae, m as oe, n as se, o as ce, p as le, r as ue, s as de, t as fe, u as pe, v as me, w as A, x as he, y as ge } from "./BillingDocumentDetailViewDataProvider-f5goWm_i.js";
12
12
  import { useRouter as _e } from "vue-router";
13
13
  import ve, { z as j } from "zod";
14
14
  import { useI18n as M } from "vue-i18n";
@@ -13,7 +13,7 @@ import { i as D, n as me, r as he } from "./CustomFieldValueText-BGbQwhON.js";
13
13
  import { t as O } from "./formango.util-D5c2ql--.js";
14
14
  import { a as ge, c as _e, i as ve, n as ye, o as be, r as xe, s as Se, t as Ce, u as we } from "./invoiceDeliveryStatus.util-BPkGCQM6.js";
15
15
  import { t as Te } from "./issuerSettings.query-Bvz-Oj5D.js";
16
- import { C as Ee, S as De, _ as Oe, a as ke, b as Ae, c as je, d as Me, f as Ne, g as Pe, h as Fe, i as Ie, l as Le, m as Re, n as ze, o as Be, p as Ve, r as He, s as Ue, t as We, u as Ge, v as Ke, w as qe, x as Je, y as Ye } from "./BillingDocumentDetailViewDataProvider-BemnzVNY.js";
16
+ import { C as Ee, S as De, _ as Oe, a as ke, b as Ae, c as je, d as Me, f as Ne, g as Pe, h as Fe, i as Ie, l as Le, m as Re, n as ze, o as Be, p as Ve, r as He, s as Ue, t as We, u as Ge, v as Ke, w as qe, x as Je, y as Ye } from "./BillingDocumentDetailViewDataProvider-f5goWm_i.js";
17
17
  import { t as Xe } from "./invoiceDetail.query-Cek8nyaw.js";
18
18
  import { RouterLink as Ze, useRouter as Qe } from "vue-router";
19
19
  import $e, { z as k } from "zod";
package/dist/index.js CHANGED
@@ -677,7 +677,7 @@ function ht(e) {
677
677
  name: "invoicing-invoice-detail",
678
678
  props: !0,
679
679
  path: ":invoiceUuid",
680
- component: () => import("./InvoiceDetailViewDataProvider-D6E7YVV1.js"),
680
+ component: () => import("./InvoiceDetailViewDataProvider-BU6jZfD7.js"),
681
681
  meta: { permission: "invoice.read" }
682
682
  }]
683
683
  }]);
@@ -708,7 +708,7 @@ var yt = [{
708
708
  name: "invoicing-credit-note-detail",
709
709
  props: !0,
710
710
  path: ":creditNoteUuid",
711
- component: () => import("./CreditNoteDetailViewDataProvider-BuY9ELoK.js"),
711
+ component: () => import("./CreditNoteDetailViewDataProvider-Byd1QvfY.js"),
712
712
  meta: { permission: "invoice.read" }
713
713
  }]
714
714
  }], bt = [{
@@ -101,9 +101,24 @@ export declare class BillingDocumentLineItemsEditorUtil {
101
101
  * borders, which is what the insert indicators and keyboard inserts expect.
102
102
  */
103
103
  static resolveInsertGroupId(rows: BillingDocumentLineItemEditorRow[], index: number, dropIntent?: BillingDocumentLineItemDropIntent | null): string | null;
104
+ /**
105
+ * Puts the rows that were never sent back between the synced rows, at the
106
+ * offset they held among the rows that were.
107
+ */
108
+ private static restoreUnsavedRows;
104
109
  private static serializeLineFields;
105
110
  static setUnitForSelectedRows(rows: BillingDocumentLineItemEditorRow[], selectedIds: ReadonlySet<string>, unit: UnitOfMeasurement): BillingDocumentLineItemEditorRow[];
106
111
  static setVatRateForSelectedRows(rows: BillingDocumentLineItemEditorRow[], selectedIds: ReadonlySet<string>, vatRate: VatRate): BillingDocumentLineItemEditorRow[];
112
+ /**
113
+ * Re-aligns the editor rows with the rows the server returned.
114
+ *
115
+ * Rows are matched by position so a saved row keeps its client id and the
116
+ * field the user is typing in is not remounted. Rows the payload never sent —
117
+ * a line that was just inserted and has no name yet — are invisible to that
118
+ * match, so they are lifted out before it and put back at the same offset
119
+ * after. Without that they are dropped on the next save and the server row
120
+ * landing on their index inherits their id.
121
+ */
107
122
  static syncBillingDocumentLineItemRowsWithServer(serverRows: BillingDocumentLineItemEditorRow[], currentRows: BillingDocumentLineItemEditorRow[]): BillingDocumentLineItemEditorRow[];
108
123
  private static trimOrNull;
109
124
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@wisemen/wise-invoicing-web",
3
3
  "type": "module",
4
- "version": "0.1.0",
4
+ "version": "0.1.1",
5
5
  "private": false,
6
6
  "description": "Invoicing frontend package with Vue 3 components, composables and types",
7
7
  "author": "Wisemen",