@inspectorhub/field-ui 0.6.0 → 0.6.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.
- package/dist/index.js +132 -80
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -9720,7 +9720,7 @@ var editor_route_mobile_begin = (
|
|
|
9720
9720
|
() => {
|
|
9721
9721
|
return (
|
|
9722
9722
|
/** @type {LocalizedString} */
|
|
9723
|
-
`
|
|
9723
|
+
`Open [\u2630 Sections] below to begin`
|
|
9724
9724
|
);
|
|
9725
9725
|
}
|
|
9726
9726
|
);
|
|
@@ -30398,7 +30398,7 @@ var editor_route_mobile_begin2 = (
|
|
|
30398
30398
|
() => {
|
|
30399
30399
|
return (
|
|
30400
30400
|
/** @type {LocalizedString} */
|
|
30401
|
-
`
|
|
30401
|
+
`Abra [\u2630 Secciones] abajo para comenzar`
|
|
30402
30402
|
);
|
|
30403
30403
|
}
|
|
30404
30404
|
);
|
|
@@ -63793,6 +63793,42 @@ function isMetaKey(key) {
|
|
|
63793
63793
|
return key.startsWith("_") && key.split(":").length < 3;
|
|
63794
63794
|
}
|
|
63795
63795
|
|
|
63796
|
+
// src/shared/photo-batch-order.ts
|
|
63797
|
+
import * as Y from "yjs";
|
|
63798
|
+
function matches(el, name) {
|
|
63799
|
+
return name.key ? el.get("key") === name.key : !!name.pendingId && el.get("pendingId") === name.pendingId;
|
|
63800
|
+
}
|
|
63801
|
+
function orderPhotoBatch(doc, findingKey3, selection) {
|
|
63802
|
+
const item = doc.getMap("results").get(findingKey3);
|
|
63803
|
+
if (!(item instanceof Y.Map)) return;
|
|
63804
|
+
const arr = item.get("photos");
|
|
63805
|
+
if (!(arr instanceof Y.Array)) return;
|
|
63806
|
+
const elements = [];
|
|
63807
|
+
const slots = [];
|
|
63808
|
+
for (const name of selection) {
|
|
63809
|
+
for (let i = 0; i < arr.length; i++) {
|
|
63810
|
+
const el = arr.get(i);
|
|
63811
|
+
if (!(el instanceof Y.Map) || slots.includes(i) || !matches(el, name)) continue;
|
|
63812
|
+
slots.push(i);
|
|
63813
|
+
elements.push(el);
|
|
63814
|
+
break;
|
|
63815
|
+
}
|
|
63816
|
+
}
|
|
63817
|
+
slots.sort((a, b) => a - b);
|
|
63818
|
+
const moves = slots.filter((slot, n) => arr.get(slot) !== elements[n]);
|
|
63819
|
+
if (moves.length === 0) return;
|
|
63820
|
+
doc.transact(() => {
|
|
63821
|
+
const copies = /* @__PURE__ */ new Map();
|
|
63822
|
+
for (const slot of moves) copies.set(slot, elements[slots.indexOf(slot)].toJSON());
|
|
63823
|
+
for (const slot of moves) {
|
|
63824
|
+
const el = new Y.Map();
|
|
63825
|
+
for (const [k, v] of Object.entries(copies.get(slot))) if (v !== void 0) el.set(k, v);
|
|
63826
|
+
arr.delete(slot, 1);
|
|
63827
|
+
arr.insert(slot, [el]);
|
|
63828
|
+
}
|
|
63829
|
+
});
|
|
63830
|
+
}
|
|
63831
|
+
|
|
63796
63832
|
// src/shared/findings-shared.ts
|
|
63797
63833
|
function cloneByScope(src, scope) {
|
|
63798
63834
|
if (scope === "all") return { ...src };
|
|
@@ -63808,7 +63844,7 @@ function cloneByScope(src, scope) {
|
|
|
63808
63844
|
}
|
|
63809
63845
|
|
|
63810
63846
|
// src/shared/results-doc.ts
|
|
63811
|
-
import * as
|
|
63847
|
+
import * as Y2 from "yjs";
|
|
63812
63848
|
|
|
63813
63849
|
// src/shared/repair-price-keys.ts
|
|
63814
63850
|
var REPAIR_PRICE_KEYS = [
|
|
@@ -63832,19 +63868,19 @@ function withoutRepairPriceRows(rows) {
|
|
|
63832
63868
|
|
|
63833
63869
|
// src/shared/results-doc.ts
|
|
63834
63870
|
function buildItemMap() {
|
|
63835
|
-
const item = new
|
|
63836
|
-
item.set("attributes", new
|
|
63837
|
-
const tabs = new
|
|
63838
|
-
tabs.set("information", new
|
|
63839
|
-
tabs.set("limitations", new
|
|
63840
|
-
tabs.set("defects", new
|
|
63871
|
+
const item = new Y2.Map();
|
|
63872
|
+
item.set("attributes", new Y2.Map());
|
|
63873
|
+
const tabs = new Y2.Map();
|
|
63874
|
+
tabs.set("information", new Y2.Array());
|
|
63875
|
+
tabs.set("limitations", new Y2.Array());
|
|
63876
|
+
tabs.set("defects", new Y2.Array());
|
|
63841
63877
|
item.set("tabs", tabs);
|
|
63842
|
-
item.set("photos", new
|
|
63843
|
-
item.set("recommendations", new
|
|
63844
|
-
const customComments = new
|
|
63845
|
-
customComments.set("information", new
|
|
63846
|
-
customComments.set("limitations", new
|
|
63847
|
-
customComments.set("defects", new
|
|
63878
|
+
item.set("photos", new Y2.Array());
|
|
63879
|
+
item.set("recommendations", new Y2.Array());
|
|
63880
|
+
const customComments = new Y2.Map();
|
|
63881
|
+
customComments.set("information", new Y2.Array());
|
|
63882
|
+
customComments.set("limitations", new Y2.Array());
|
|
63883
|
+
customComments.set("defects", new Y2.Array());
|
|
63848
63884
|
item.set("customComments", customComments);
|
|
63849
63885
|
return item;
|
|
63850
63886
|
}
|
|
@@ -63856,22 +63892,22 @@ function getOrSeedItem(results, findingKey3) {
|
|
|
63856
63892
|
}
|
|
63857
63893
|
function getOrCreateArray(parent, key) {
|
|
63858
63894
|
const existing = parent.get(key);
|
|
63859
|
-
if (existing instanceof
|
|
63860
|
-
const arr = new
|
|
63895
|
+
if (existing instanceof Y2.Array) return existing;
|
|
63896
|
+
const arr = new Y2.Array();
|
|
63861
63897
|
parent.set(key, arr);
|
|
63862
63898
|
return arr;
|
|
63863
63899
|
}
|
|
63864
63900
|
function getOrCreateMap(parent, key) {
|
|
63865
63901
|
const existing = parent.get(key);
|
|
63866
|
-
if (existing instanceof
|
|
63867
|
-
const map = new
|
|
63902
|
+
if (existing instanceof Y2.Map) return existing;
|
|
63903
|
+
const map = new Y2.Map();
|
|
63868
63904
|
parent.set(key, map);
|
|
63869
63905
|
return map;
|
|
63870
63906
|
}
|
|
63871
63907
|
function findElementByKey(arr, identityField, identityValue) {
|
|
63872
63908
|
for (let i = 0; i < arr.length; i++) {
|
|
63873
63909
|
const el = arr.get(i);
|
|
63874
|
-
if (el instanceof
|
|
63910
|
+
if (el instanceof Y2.Map && el.get(identityField) === identityValue) {
|
|
63875
63911
|
return el;
|
|
63876
63912
|
}
|
|
63877
63913
|
}
|
|
@@ -63890,14 +63926,14 @@ function upsertElement(arr, identityField, entry) {
|
|
|
63890
63926
|
assignFields(existing, entry);
|
|
63891
63927
|
return;
|
|
63892
63928
|
}
|
|
63893
|
-
const el = new
|
|
63929
|
+
const el = new Y2.Map();
|
|
63894
63930
|
assignFields(el, entry);
|
|
63895
63931
|
arr.push([el]);
|
|
63896
63932
|
}
|
|
63897
63933
|
function removeElement(arr, identityField, identityValue) {
|
|
63898
63934
|
for (let i = 0; i < arr.length; i++) {
|
|
63899
63935
|
const el = arr.get(i);
|
|
63900
|
-
if (el instanceof
|
|
63936
|
+
if (el instanceof Y2.Map && el.get(identityField) === identityValue) {
|
|
63901
63937
|
arr.delete(i, 1);
|
|
63902
63938
|
return;
|
|
63903
63939
|
}
|
|
@@ -63954,8 +63990,8 @@ function revertPhoto(doc, findingKey3, key) {
|
|
|
63954
63990
|
const arr = getOrCreateArray(item, "photos");
|
|
63955
63991
|
for (let i = 0; i < arr.length; i++) {
|
|
63956
63992
|
const el = arr.get(i);
|
|
63957
|
-
if (el instanceof
|
|
63958
|
-
const fresh = new
|
|
63993
|
+
if (el instanceof Y2.Map && el.get("key") === key) {
|
|
63994
|
+
const fresh = new Y2.Map();
|
|
63959
63995
|
fresh.set("key", key);
|
|
63960
63996
|
arr.delete(i, 1);
|
|
63961
63997
|
arr.insert(i, [fresh]);
|
|
@@ -63971,8 +64007,8 @@ function replacePhoto(doc, findingKey3, key, entry) {
|
|
|
63971
64007
|
const arr = getOrCreateArray(item, "photos");
|
|
63972
64008
|
for (let i = 0; i < arr.length; i++) {
|
|
63973
64009
|
const el = arr.get(i);
|
|
63974
|
-
if (el instanceof
|
|
63975
|
-
const fresh = new
|
|
64010
|
+
if (el instanceof Y2.Map && el.get("key") === key) {
|
|
64011
|
+
const fresh = new Y2.Map();
|
|
63976
64012
|
assignFields(fresh, { ...entry });
|
|
63977
64013
|
arr.delete(i, 1);
|
|
63978
64014
|
arr.insert(i, [fresh]);
|
|
@@ -63988,8 +64024,8 @@ function replacePhotoByPendingId(doc, findingKey3, pendingId, entry) {
|
|
|
63988
64024
|
const arr = getOrCreateArray(item, "photos");
|
|
63989
64025
|
for (let i = 0; i < arr.length; i++) {
|
|
63990
64026
|
const el = arr.get(i);
|
|
63991
|
-
if (el instanceof
|
|
63992
|
-
const fresh = new
|
|
64027
|
+
if (el instanceof Y2.Map && el.get("pendingId") === pendingId) {
|
|
64028
|
+
const fresh = new Y2.Map();
|
|
63993
64029
|
assignFields(fresh, { ...entry });
|
|
63994
64030
|
arr.delete(i, 1);
|
|
63995
64031
|
arr.insert(i, [fresh]);
|
|
@@ -64006,7 +64042,7 @@ function reorderPhotos(doc, findingKey3, orderedKeys) {
|
|
|
64006
64042
|
const byKey = /* @__PURE__ */ new Map();
|
|
64007
64043
|
for (let i = 0; i < arr.length; i++) {
|
|
64008
64044
|
const el = arr.get(i);
|
|
64009
|
-
if (el instanceof
|
|
64045
|
+
if (el instanceof Y2.Map) {
|
|
64010
64046
|
const entry = el.toJSON();
|
|
64011
64047
|
if (typeof entry.key === "string") byKey.set(entry.key, entry);
|
|
64012
64048
|
}
|
|
@@ -64019,7 +64055,7 @@ function reorderPhotos(doc, findingKey3, orderedKeys) {
|
|
|
64019
64055
|
}
|
|
64020
64056
|
arr.delete(0, arr.length);
|
|
64021
64057
|
const rebuilt = orderedKeys.map((k) => {
|
|
64022
|
-
const el = new
|
|
64058
|
+
const el = new Y2.Map();
|
|
64023
64059
|
assignFields(el, { ...byKey.get(k) });
|
|
64024
64060
|
return el;
|
|
64025
64061
|
});
|
|
@@ -64081,7 +64117,7 @@ function projectResults(doc) {
|
|
|
64081
64117
|
const results = doc.getMap("results");
|
|
64082
64118
|
const projection = {};
|
|
64083
64119
|
results.forEach((rawItem, findingKey3) => {
|
|
64084
|
-
if (!(rawItem instanceof
|
|
64120
|
+
if (!(rawItem instanceof Y2.Map) || isMetaKey(findingKey3)) return;
|
|
64085
64121
|
const entry = {};
|
|
64086
64122
|
const rating = rawItem.get("rating");
|
|
64087
64123
|
if (typeof rating === "string" && rating.length > 0) {
|
|
@@ -64100,17 +64136,17 @@ function projectResults(doc) {
|
|
|
64100
64136
|
entry.recommendation = recommendation;
|
|
64101
64137
|
}
|
|
64102
64138
|
const attributesRaw = rawItem.get("attributes");
|
|
64103
|
-
if (attributesRaw instanceof
|
|
64139
|
+
if (attributesRaw instanceof Y2.Map && attributesRaw.size > 0) {
|
|
64104
64140
|
entry.attributes = attributesRaw.toJSON();
|
|
64105
64141
|
}
|
|
64106
64142
|
const tabsRaw = rawItem.get("tabs");
|
|
64107
|
-
if (tabsRaw instanceof
|
|
64143
|
+
if (tabsRaw instanceof Y2.Map) {
|
|
64108
64144
|
const information = tabsRaw.get("information");
|
|
64109
64145
|
const limitations = tabsRaw.get("limitations");
|
|
64110
64146
|
const defects = tabsRaw.get("defects");
|
|
64111
|
-
const infoArr = information instanceof
|
|
64112
|
-
const limArr = limitations instanceof
|
|
64113
|
-
const defArr = defects instanceof
|
|
64147
|
+
const infoArr = information instanceof Y2.Array ? information.toJSON() : [];
|
|
64148
|
+
const limArr = limitations instanceof Y2.Array ? limitations.toJSON() : [];
|
|
64149
|
+
const defArr = defects instanceof Y2.Array ? withoutRepairPriceRows(defects.toJSON()) : [];
|
|
64114
64150
|
const tabsEntry = {};
|
|
64115
64151
|
if (infoArr.length > 0) tabsEntry.information = infoArr;
|
|
64116
64152
|
if (limArr.length > 0) tabsEntry.limitations = limArr;
|
|
@@ -64120,21 +64156,21 @@ function projectResults(doc) {
|
|
|
64120
64156
|
}
|
|
64121
64157
|
}
|
|
64122
64158
|
const photosRaw = rawItem.get("photos");
|
|
64123
|
-
if (photosRaw instanceof
|
|
64159
|
+
if (photosRaw instanceof Y2.Array && photosRaw.length > 0) {
|
|
64124
64160
|
entry.photos = photosRaw.toJSON();
|
|
64125
64161
|
}
|
|
64126
64162
|
const recsRaw = rawItem.get("recommendations");
|
|
64127
|
-
if (recsRaw instanceof
|
|
64163
|
+
if (recsRaw instanceof Y2.Array && recsRaw.length > 0) {
|
|
64128
64164
|
entry.recommendations = recsRaw.toJSON();
|
|
64129
64165
|
}
|
|
64130
64166
|
const customRaw = rawItem.get("customComments");
|
|
64131
|
-
if (customRaw instanceof
|
|
64167
|
+
if (customRaw instanceof Y2.Map) {
|
|
64132
64168
|
const ccInfo = customRaw.get("information");
|
|
64133
64169
|
const ccLim = customRaw.get("limitations");
|
|
64134
64170
|
const ccDef = customRaw.get("defects");
|
|
64135
|
-
const ccInfoArr = ccInfo instanceof
|
|
64136
|
-
const ccLimArr = ccLim instanceof
|
|
64137
|
-
const ccDefArr = ccDef instanceof
|
|
64171
|
+
const ccInfoArr = ccInfo instanceof Y2.Array ? ccInfo.toJSON() : [];
|
|
64172
|
+
const ccLimArr = ccLim instanceof Y2.Array ? ccLim.toJSON() : [];
|
|
64173
|
+
const ccDefArr = ccDef instanceof Y2.Array ? withoutRepairPriceRows(ccDef.toJSON()) : [];
|
|
64138
64174
|
if (ccInfoArr.length > 0 || ccLimArr.length > 0 || ccDefArr.length > 0) {
|
|
64139
64175
|
const ccEntry = {};
|
|
64140
64176
|
if (ccInfoArr.length > 0) ccEntry.information = ccInfoArr;
|
|
@@ -64144,14 +64180,14 @@ function projectResults(doc) {
|
|
|
64144
64180
|
}
|
|
64145
64181
|
}
|
|
64146
64182
|
const originalRaw = rawItem.get("original");
|
|
64147
|
-
if (originalRaw instanceof
|
|
64183
|
+
if (originalRaw instanceof Y2.Map) {
|
|
64148
64184
|
const orig = {};
|
|
64149
64185
|
const origRating = originalRaw.get("rating");
|
|
64150
64186
|
const origNotes = originalRaw.get("notes");
|
|
64151
64187
|
const origPhotos = originalRaw.get("photos");
|
|
64152
64188
|
if (origRating !== void 0) orig.rating = origRating;
|
|
64153
64189
|
if (origNotes !== void 0) orig.notes = origNotes;
|
|
64154
|
-
if (origPhotos instanceof
|
|
64190
|
+
if (origPhotos instanceof Y2.Array && origPhotos.length > 0) {
|
|
64155
64191
|
orig.photos = origPhotos.toJSON();
|
|
64156
64192
|
}
|
|
64157
64193
|
entry.original = orig;
|
|
@@ -64428,6 +64464,11 @@ function buildCollabFindingsApi(doc, deps) {
|
|
|
64428
64464
|
}
|
|
64429
64465
|
setDirty(true);
|
|
64430
64466
|
};
|
|
64467
|
+
const orderPhotoBatch2 = (itemId, selection) => {
|
|
64468
|
+
const sid = sectionIdForItem(itemId);
|
|
64469
|
+
if (!sid) return;
|
|
64470
|
+
orderPhotoBatch(doc, findingKey2(unit, sid, itemId), selection);
|
|
64471
|
+
};
|
|
64431
64472
|
const getPhotoCount = (itemId) => {
|
|
64432
64473
|
const r = getResult(itemId);
|
|
64433
64474
|
const photos = r.photos;
|
|
@@ -64473,6 +64514,7 @@ function buildCollabFindingsApi(doc, deps) {
|
|
|
64473
64514
|
batchSetRating,
|
|
64474
64515
|
addPhotoToItem,
|
|
64475
64516
|
addPhotoToDefect,
|
|
64517
|
+
orderPhotoBatch: orderPhotoBatch2,
|
|
64476
64518
|
getPhotoCount,
|
|
64477
64519
|
addCustomDefect: addCustomDefect2,
|
|
64478
64520
|
toggleCustomDefect: toggleCustomDefect2,
|
|
@@ -64526,6 +64568,7 @@ function useFindings(results, setResults, options) {
|
|
|
64526
64568
|
batchSetRating: () => 0,
|
|
64527
64569
|
addPhotoToItem: noop,
|
|
64528
64570
|
addPhotoToDefect: noop,
|
|
64571
|
+
orderPhotoBatch: noop,
|
|
64529
64572
|
getPhotoCount: (itemId) => {
|
|
64530
64573
|
const photos = getResult(itemId).photos;
|
|
64531
64574
|
return Array.isArray(photos) ? photos.length : 0;
|
|
@@ -68231,16 +68274,16 @@ function videoEntryIdentity(photo, idx) {
|
|
|
68231
68274
|
}
|
|
68232
68275
|
|
|
68233
68276
|
// src/shared/results-doc-media.ts
|
|
68234
|
-
import * as
|
|
68277
|
+
import * as Y3 from "yjs";
|
|
68235
68278
|
function removeMediaBy(doc, findingKey3, identityField, value) {
|
|
68236
68279
|
const item = doc.getMap("results").get(findingKey3);
|
|
68237
|
-
if (!(item instanceof
|
|
68280
|
+
if (!(item instanceof Y3.Map)) return;
|
|
68238
68281
|
const photos = item.get("photos");
|
|
68239
|
-
if (!(photos instanceof
|
|
68282
|
+
if (!(photos instanceof Y3.Array)) return;
|
|
68240
68283
|
doc.transact(() => {
|
|
68241
68284
|
for (let i = 0; i < photos.length; i++) {
|
|
68242
68285
|
const el = photos.get(i);
|
|
68243
|
-
if (el instanceof
|
|
68286
|
+
if (el instanceof Y3.Map && el.get(identityField) === value) {
|
|
68244
68287
|
photos.delete(i, 1);
|
|
68245
68288
|
return;
|
|
68246
68289
|
}
|
|
@@ -69594,6 +69637,7 @@ function usePhotoBatchUpload(inspectionId, doc) {
|
|
|
69594
69637
|
const uploader = dataSourceRef.current.media.uploader(inspectionRef.current, docRef.current);
|
|
69595
69638
|
const meta = metaOf(batch);
|
|
69596
69639
|
const results = new Array(batch.files.length);
|
|
69640
|
+
const pendingIds = new Array(batch.files.length).fill("");
|
|
69597
69641
|
let next = 0;
|
|
69598
69642
|
const worker = async () => {
|
|
69599
69643
|
for (; ; ) {
|
|
@@ -69608,6 +69652,7 @@ function usePhotoBatchUpload(inspectionId, doc) {
|
|
|
69608
69652
|
createdAt: Date.now(),
|
|
69609
69653
|
meta
|
|
69610
69654
|
};
|
|
69655
|
+
pendingIds[index] = rec.pendingId;
|
|
69611
69656
|
try {
|
|
69612
69657
|
const refusal = await photoRefusal(rec.blob);
|
|
69613
69658
|
if (refusal !== null) {
|
|
@@ -69627,6 +69672,7 @@ function usePhotoBatchUpload(inspectionId, doc) {
|
|
|
69627
69672
|
ok: batch.files.length > 0 && batch.itemId !== "" && results.every((r) => r.ok || r.kept === true),
|
|
69628
69673
|
keys,
|
|
69629
69674
|
results,
|
|
69675
|
+
pendingIds,
|
|
69630
69676
|
unsaved: batch.files.length === 0 || batch.itemId === "" || results.some((r) => !r.ok && r.kept !== true && r.permanent !== true),
|
|
69631
69677
|
itemId: batch.itemId,
|
|
69632
69678
|
targetType: batch.target === null ? "item" : "defect",
|
|
@@ -69648,6 +69694,7 @@ function usePhotoBatchUpload(inspectionId, doc) {
|
|
|
69648
69694
|
ok: false,
|
|
69649
69695
|
keys: [],
|
|
69650
69696
|
results: batch.files.map((_, index) => ({ index, ok: false, error: "EXCEPTION" })),
|
|
69697
|
+
pendingIds: batch.files.map(() => ""),
|
|
69651
69698
|
unsaved: true,
|
|
69652
69699
|
itemId: batch.itemId,
|
|
69653
69700
|
targetType: batch.target === null ? "item" : "defect",
|
|
@@ -69670,6 +69717,23 @@ function usePhotoBatchUpload(inspectionId, doc) {
|
|
|
69670
69717
|
return { busy: pending > 0, outcomes, failedSinceIdle, consume, submit };
|
|
69671
69718
|
}
|
|
69672
69719
|
|
|
69720
|
+
// src/hooks/attachPhotoBatch.ts
|
|
69721
|
+
function attachPhotoBatch(findings, d) {
|
|
69722
|
+
if (!d.keys.length || !d.itemId) return;
|
|
69723
|
+
for (const k of d.keys) {
|
|
69724
|
+
if (d.targetType === "defect" && d.customId) {
|
|
69725
|
+
findings.addPhotoToDefect(d.itemId, { kind: d.defectKind, id: d.customId }, k);
|
|
69726
|
+
} else {
|
|
69727
|
+
findings.addPhotoToItem(d.itemId, k);
|
|
69728
|
+
}
|
|
69729
|
+
}
|
|
69730
|
+
if (d.targetType === "defect" && d.customId) return;
|
|
69731
|
+
findings.orderPhotoBatch(
|
|
69732
|
+
d.itemId,
|
|
69733
|
+
d.results.flatMap((r) => r.ok && r.key ? [{ key: r.key }] : r.kept === true && d.pendingIds[r.index] ? [{ pendingId: d.pendingIds[r.index] }] : [])
|
|
69734
|
+
);
|
|
69735
|
+
}
|
|
69736
|
+
|
|
69673
69737
|
// src/hooks/useReportCoverWrites.ts
|
|
69674
69738
|
import { useCallback as useCallback22, useRef as useRef18 } from "react";
|
|
69675
69739
|
var FAILED_MS = 8e3;
|
|
@@ -69897,15 +69961,15 @@ function useResultsDoc(inspectionId, onSynced) {
|
|
|
69897
69961
|
import { useCallback as useCallback24, useEffect as useEffect17, useRef as useRef21 } from "react";
|
|
69898
69962
|
|
|
69899
69963
|
// src/collab/pending-photo-drop.ts
|
|
69900
|
-
import * as
|
|
69964
|
+
import * as Y4 from "yjs";
|
|
69901
69965
|
function dropPendingPhoto(doc, findingKey3, pendingId) {
|
|
69902
69966
|
const item = doc.getMap("results").get(findingKey3);
|
|
69903
|
-
if (!(item instanceof
|
|
69967
|
+
if (!(item instanceof Y4.Map)) return;
|
|
69904
69968
|
const photos = item.get("photos");
|
|
69905
|
-
if (!(photos instanceof
|
|
69969
|
+
if (!(photos instanceof Y4.Array)) return;
|
|
69906
69970
|
for (let i = 0; i < photos.length; i++) {
|
|
69907
69971
|
const el = photos.get(i);
|
|
69908
|
-
if (el instanceof
|
|
69972
|
+
if (el instanceof Y4.Map && el.get("pendingId") === pendingId) {
|
|
69909
69973
|
doc.transact(() => photos.delete(i, 1));
|
|
69910
69974
|
return;
|
|
69911
69975
|
}
|
|
@@ -69913,12 +69977,12 @@ function dropPendingPhoto(doc, findingKey3, pendingId) {
|
|
|
69913
69977
|
}
|
|
69914
69978
|
function clearPendingDerivative(doc, findingKey3, photoKey, pendingId) {
|
|
69915
69979
|
const item = doc.getMap("results").get(findingKey3);
|
|
69916
|
-
if (!(item instanceof
|
|
69980
|
+
if (!(item instanceof Y4.Map)) return;
|
|
69917
69981
|
const photos = item.get("photos");
|
|
69918
|
-
if (!(photos instanceof
|
|
69982
|
+
if (!(photos instanceof Y4.Array)) return;
|
|
69919
69983
|
for (let i = 0; i < photos.length; i++) {
|
|
69920
69984
|
const el = photos.get(i);
|
|
69921
|
-
if (el instanceof
|
|
69985
|
+
if (el instanceof Y4.Map && el.get("key") === photoKey && el.get("pendingId") === pendingId) {
|
|
69922
69986
|
doc.transact(() => {
|
|
69923
69987
|
if (el.get("pendingKind") === "annotate" && !el.get("annotatedKey")) el.delete("annotationsJson");
|
|
69924
69988
|
el.delete("pendingId");
|
|
@@ -70082,7 +70146,7 @@ async function addOfflinePhotos(store, doc, target, files) {
|
|
|
70082
70146
|
import { useEffect as useEffect18, useRef as useRef22 } from "react";
|
|
70083
70147
|
|
|
70084
70148
|
// src/collab/results-merge.ts
|
|
70085
|
-
import * as
|
|
70149
|
+
import * as Y5 from "yjs";
|
|
70086
70150
|
var SCALARS = ["rating", "notes", "value", "recommendation"];
|
|
70087
70151
|
var COLLECTIONS = ["attributes", "tabs", "recommendations", "customComments"];
|
|
70088
70152
|
function mergePhotos(before, docPhotos) {
|
|
@@ -70094,7 +70158,7 @@ function mergeUnsyncedResults(prev, doc) {
|
|
|
70094
70158
|
const projection = projectResults(doc);
|
|
70095
70159
|
const out = { ...prev };
|
|
70096
70160
|
doc.getMap("results").forEach((raw, key) => {
|
|
70097
|
-
if (!(raw instanceof
|
|
70161
|
+
if (!(raw instanceof Y5.Map)) return;
|
|
70098
70162
|
const { itemId, unitId } = parseFindingKey(key);
|
|
70099
70163
|
const projected = projection[key] ?? {};
|
|
70100
70164
|
const merged = { ...prev[key] ?? (unitId === "_default" ? prev[itemId] : void 0) ?? {} };
|
|
@@ -72012,7 +72076,7 @@ import { useState as useState32, useMemo as useMemo13, useEffect as useEffect28,
|
|
|
72012
72076
|
// src/components/editor/CommentTypeahead.tsx
|
|
72013
72077
|
import { jsx as jsx46, jsxs as jsxs36 } from "react/jsx-runtime";
|
|
72014
72078
|
function CommentTypeahead({
|
|
72015
|
-
matches,
|
|
72079
|
+
matches: matches2,
|
|
72016
72080
|
open,
|
|
72017
72081
|
selectedIndex,
|
|
72018
72082
|
onHoverIndex,
|
|
@@ -72023,13 +72087,13 @@ function CommentTypeahead({
|
|
|
72023
72087
|
information: index_exports.editor_typeahead_kind_info(),
|
|
72024
72088
|
limitations: index_exports.editor_typeahead_kind_limitations()
|
|
72025
72089
|
};
|
|
72026
|
-
if (!open ||
|
|
72090
|
+
if (!open || matches2.length === 0) return null;
|
|
72027
72091
|
return /* @__PURE__ */ jsx46(
|
|
72028
72092
|
"ul",
|
|
72029
72093
|
{
|
|
72030
72094
|
role: "listbox",
|
|
72031
72095
|
className: "absolute z-30 left-0 right-0 mt-1 max-h-64 overflow-y-auto rounded-lg border border-ih-border bg-ih-bg-card shadow-ih-popover",
|
|
72032
|
-
children:
|
|
72096
|
+
children: matches2.map((match, i) => /* @__PURE__ */ jsxs36(
|
|
72033
72097
|
"li",
|
|
72034
72098
|
{
|
|
72035
72099
|
role: "option",
|
|
@@ -72121,29 +72185,29 @@ function replaceFragmentBeforeCaret(value, caret, replacement) {
|
|
|
72121
72185
|
// src/hooks/useCommentTypeahead.ts
|
|
72122
72186
|
function useCommentTypeahead(entries, query, opts) {
|
|
72123
72187
|
const max = opts?.max ?? 8;
|
|
72124
|
-
const
|
|
72188
|
+
const matches2 = useMemo10(
|
|
72125
72189
|
() => rankTypeaheadMatches(entries, query).slice(0, max),
|
|
72126
72190
|
[entries, query, max]
|
|
72127
72191
|
);
|
|
72128
72192
|
const [selectedIndex, setSelectedIndex] = useState25(0);
|
|
72129
72193
|
useEffect22(() => {
|
|
72130
72194
|
setSelectedIndex(0);
|
|
72131
|
-
}, [query,
|
|
72195
|
+
}, [query, matches2.length]);
|
|
72132
72196
|
const move = useCallback26(
|
|
72133
72197
|
(delta) => {
|
|
72134
72198
|
setSelectedIndex((i) => {
|
|
72135
|
-
const n =
|
|
72199
|
+
const n = matches2.length;
|
|
72136
72200
|
if (n === 0) return 0;
|
|
72137
72201
|
return ((i + delta) % n + n) % n;
|
|
72138
72202
|
});
|
|
72139
72203
|
},
|
|
72140
|
-
[
|
|
72204
|
+
[matches2.length]
|
|
72141
72205
|
);
|
|
72142
72206
|
const current = useCallback26(
|
|
72143
|
-
() =>
|
|
72144
|
-
[
|
|
72207
|
+
() => matches2[selectedIndex] ?? null,
|
|
72208
|
+
[matches2, selectedIndex]
|
|
72145
72209
|
);
|
|
72146
|
-
return { matches, selectedIndex, setSelectedIndex, move, current };
|
|
72210
|
+
return { matches: matches2, selectedIndex, setSelectedIndex, move, current };
|
|
72147
72211
|
}
|
|
72148
72212
|
|
|
72149
72213
|
// src/components/editor/AiAssistPanel.tsx
|
|
@@ -83428,19 +83492,7 @@ function FieldEditorInner({ data }) {
|
|
|
83428
83492
|
for (const o of settled) processedUploads.current.add(o);
|
|
83429
83493
|
photoUpload.consume(photoUpload.outcomes.length);
|
|
83430
83494
|
for (const d of settled) {
|
|
83431
|
-
|
|
83432
|
-
for (const k of d.keys) {
|
|
83433
|
-
if (d.targetType === "defect" && d.customId) {
|
|
83434
|
-
findings.addPhotoToDefect(
|
|
83435
|
-
d.itemId,
|
|
83436
|
-
{ kind: d.defectKind, id: d.customId },
|
|
83437
|
-
k
|
|
83438
|
-
);
|
|
83439
|
-
} else {
|
|
83440
|
-
findings.addPhotoToItem(d.itemId, k);
|
|
83441
|
-
}
|
|
83442
|
-
}
|
|
83443
|
-
}
|
|
83495
|
+
attachPhotoBatch(findings, d);
|
|
83444
83496
|
const total = d.results.length;
|
|
83445
83497
|
const keptCount = d.results.filter((r) => !r.ok && r.kept === true).length;
|
|
83446
83498
|
const successCount = d.results.filter((r) => r.ok).length;
|