strapi-plugin-bulk-updater 1.6.2 → 1.6.4

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.
@@ -4200,6 +4200,401 @@ function serializeGridTargets(gridEdits, selectedEntries, collectionPages = {},
4200
4200
  }
4201
4201
  return { targets, totalEditCount, hasValidationErrors };
4202
4202
  }
4203
+ function parseDynamicZonePath(path) {
4204
+ if (!path) return { cleanPath: "", rootKey: "", subPath: "" };
4205
+ const bracketMatch = path.match(/^([^.[]+)\[([^\]]+)\]\.(.+)$/);
4206
+ if (bracketMatch) {
4207
+ const rootKey = bracketMatch[1];
4208
+ const selector = bracketMatch[2];
4209
+ const subPath = bracketMatch[3];
4210
+ const cleanPath = `${rootKey}.${subPath}`;
4211
+ if (/^\d+$/.test(selector)) {
4212
+ return { cleanPath, rootKey, subPath, targetIndex: parseInt(selector, 10) };
4213
+ }
4214
+ return { cleanPath, rootKey, subPath, targetComponentUid: selector };
4215
+ }
4216
+ const parts = path.split(".");
4217
+ return {
4218
+ cleanPath: path,
4219
+ rootKey: parts[0] || "",
4220
+ subPath: parts.slice(1).join(".")
4221
+ };
4222
+ }
4223
+ function formatComponentName(compUid) {
4224
+ if (!compUid) return "Component";
4225
+ const name = compUid.includes(".") ? compUid.split(".")[1] : compUid;
4226
+ return name.split(/[-_]/).map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join(" ");
4227
+ }
4228
+ function getPropertyValue(target, key) {
4229
+ if (!target || typeof target !== "object" || !key) return void 0;
4230
+ if (target[key] !== void 0 && target[key] !== null) return target[key];
4231
+ const camelKey = key.replace(/_([a-z0-9])/g, (_, letter) => letter.toUpperCase());
4232
+ if (target[camelKey] !== void 0 && target[camelKey] !== null) return target[camelKey];
4233
+ const snakeKey = key.replace(/([A-Z])/g, "_$1").toLowerCase();
4234
+ if (target[snakeKey] !== void 0 && target[snakeKey] !== null) return target[snakeKey];
4235
+ const lowerKey = key.toLowerCase();
4236
+ const lowerNoUnderscore = lowerKey.replace(/_/g, "");
4237
+ const matchedKey = Object.keys(target).find((k) => {
4238
+ const kLower = k.toLowerCase();
4239
+ return kLower === lowerKey || kLower.replace(/_/g, "") === lowerNoUnderscore;
4240
+ });
4241
+ if (matchedKey && target[matchedKey] !== void 0 && target[matchedKey] !== null) {
4242
+ return target[matchedKey];
4243
+ }
4244
+ if (key in target) return target[key];
4245
+ if (camelKey in target) return target[camelKey];
4246
+ if (snakeKey in target) return target[snakeKey];
4247
+ return void 0;
4248
+ }
4249
+ function getNestedValue(obj, path) {
4250
+ if (!obj || !path) return void 0;
4251
+ const parsed = parseDynamicZonePath(path);
4252
+ const parts = parsed.cleanPath.split(".");
4253
+ function extract(current, remainingParts) {
4254
+ if (current === void 0 || current === null) return void 0;
4255
+ if (remainingParts.length === 0) return current;
4256
+ const [head, ...tail] = remainingParts;
4257
+ if (Array.isArray(current)) {
4258
+ if (/^\d+$/.test(head)) {
4259
+ return extract(current[parseInt(head, 10)], tail);
4260
+ }
4261
+ for (let idx = 0; idx < current.length; idx++) {
4262
+ const item = current[idx];
4263
+ if (parsed.targetIndex !== void 0 && idx !== parsed.targetIndex) continue;
4264
+ if (parsed.targetComponentUid && item?.__component !== parsed.targetComponentUid) continue;
4265
+ const found = extract(getPropertyValue(item, head), tail);
4266
+ if (found !== void 0 && found !== null) return found;
4267
+ }
4268
+ return void 0;
4269
+ }
4270
+ return extract(getPropertyValue(current, head), tail);
4271
+ }
4272
+ return extract(obj, parts);
4273
+ }
4274
+ function getAllNestedValues(obj, path, availableAttributes) {
4275
+ if (!obj || !path) return [];
4276
+ const parsed = parseDynamicZonePath(path);
4277
+ const parts = parsed.cleanPath.split(".");
4278
+ const [head, ...tail] = parts;
4279
+ const rootTarget = getPropertyValue(obj, head);
4280
+ if (rootTarget === void 0 || rootTarget === null) return [];
4281
+ if (Array.isArray(rootTarget)) {
4282
+ const results = [];
4283
+ rootTarget.forEach((item, idx) => {
4284
+ if (!item || typeof item !== "object") return;
4285
+ if (parsed.targetIndex !== void 0 && idx !== parsed.targetIndex) return;
4286
+ if (parsed.targetComponentUid && item.__component !== parsed.targetComponentUid) return;
4287
+ const subPath = tail.join(".");
4288
+ const scopedPath = item.__component ? `${head}[${item.__component}].${subPath}` : "";
4289
+ const isSupported = availableAttributes ? availableAttributes.includes(scopedPath) : false;
4290
+ if (tail.length > 0) {
4291
+ const subMatches = getAllNestedValues(item, subPath, availableAttributes);
4292
+ if (subMatches.length > 0) {
4293
+ subMatches.forEach((sm) => {
4294
+ results.push({
4295
+ index: idx,
4296
+ componentUid: item.__component || sm.componentUid,
4297
+ componentName: item.__component ? formatComponentName(item.__component) : sm.componentName,
4298
+ componentId: item.id !== void 0 && item.id !== null ? item.id : sm.componentId,
4299
+ value: sm.value,
4300
+ path: `${head}[#${idx}${item.__component ? ` ${formatComponentName(item.__component)}` : ""}].${sm.path}`
4301
+ });
4302
+ });
4303
+ return;
4304
+ }
4305
+ }
4306
+ const subVal = tail.length > 0 ? getNestedValue(item, subPath) : item;
4307
+ if (subVal !== void 0 || isSupported) {
4308
+ results.push({
4309
+ index: idx,
4310
+ componentUid: item.__component,
4311
+ componentName: formatComponentName(item.__component),
4312
+ componentId: item.id !== void 0 && item.id !== null ? item.id : void 0,
4313
+ value: subVal !== void 0 ? subVal : null,
4314
+ path: `${head}[#${idx}${item.__component ? ` ${formatComponentName(item.__component)}` : ""}].${subPath}`
4315
+ });
4316
+ }
4317
+ });
4318
+ return results;
4319
+ }
4320
+ if (typeof rootTarget === "object" && tail.length > 0) {
4321
+ const subMatches = getAllNestedValues(rootTarget, tail.join("."), availableAttributes);
4322
+ if (subMatches.length > 0) {
4323
+ return subMatches.map((sm) => ({
4324
+ ...sm,
4325
+ path: `${head}.${sm.path}`
4326
+ }));
4327
+ }
4328
+ }
4329
+ const singleVal = getNestedValue(obj, parsed.cleanPath);
4330
+ if (singleVal !== void 0) {
4331
+ return [
4332
+ {
4333
+ index: 0,
4334
+ value: singleVal,
4335
+ path: parsed.cleanPath
4336
+ }
4337
+ ];
4338
+ }
4339
+ return [];
4340
+ }
4341
+ function getAvailableColumnsForCollection(col, selectedAttribute, searchAttribute) {
4342
+ const cols = [
4343
+ {
4344
+ key: "select",
4345
+ label: "Select",
4346
+ isPermanent: true,
4347
+ defaultVisible: true
4348
+ },
4349
+ {
4350
+ key: "identifier",
4351
+ label: "Identifier",
4352
+ sortable: !col.isSingleType,
4353
+ defaultVisible: true
4354
+ }
4355
+ ];
4356
+ const candidateAttrs = col.attributes || [];
4357
+ candidateAttrs.forEach((attr) => {
4358
+ if (attr === "name" || attr === "title" || attr === selectedAttribute || searchAttribute && attr === searchAttribute) {
4359
+ return;
4360
+ }
4361
+ let formattedLabel = attr;
4362
+ if (attr === "updated_at" || attr === "updatedAt") {
4363
+ formattedLabel = "Updated At";
4364
+ } else if (attr === "created_at" || attr === "createdAt") {
4365
+ formattedLabel = "Created At";
4366
+ } else if (attr === "published_at" || attr === "publishedAt") {
4367
+ formattedLabel = "Published At";
4368
+ } else {
4369
+ const bracketMatch = attr.match(/^([^.[]+)\[([^\]]+)\]\.(.+)$/);
4370
+ if (bracketMatch) {
4371
+ const root = bracketMatch[1].charAt(0).toUpperCase() + bracketMatch[1].slice(1);
4372
+ const comp = formatComponentName(bracketMatch[2]);
4373
+ const sub = bracketMatch[3].split(".").map((s) => s.charAt(0).toUpperCase() + s.slice(1)).join(" > ");
4374
+ formattedLabel = `${root} [${comp}] > ${sub}`;
4375
+ } else if (attr.includes(".")) {
4376
+ formattedLabel = attr.split(".").map((s) => s.charAt(0).toUpperCase() + s.slice(1)).join(" > ");
4377
+ } else {
4378
+ formattedLabel = attr.replace(/_/g, " ").replace(/\b\w/g, (l) => l.toUpperCase());
4379
+ }
4380
+ }
4381
+ cols.push({
4382
+ key: `attr_${attr}`,
4383
+ label: formattedLabel,
4384
+ sortable: !col.isSingleType,
4385
+ defaultVisible: ["department", "email", "location", "updated_at", "updatedAt"].includes(attr)
4386
+ });
4387
+ });
4388
+ const hasUpdatedAt = candidateAttrs.some((a) => a === "updatedAt" || a === "updated_at");
4389
+ const hasCreatedAt = candidateAttrs.some((a) => a === "createdAt" || a === "created_at");
4390
+ const hasPublishedAt = candidateAttrs.some((a) => a === "publishedAt" || a === "published_at");
4391
+ if (!hasUpdatedAt) {
4392
+ cols.push({
4393
+ key: "attr_updatedAt",
4394
+ label: "Updated At",
4395
+ sortable: !col.isSingleType,
4396
+ defaultVisible: false
4397
+ });
4398
+ }
4399
+ if (!hasCreatedAt) {
4400
+ cols.push({
4401
+ key: "attr_createdAt",
4402
+ label: "Created At",
4403
+ sortable: !col.isSingleType,
4404
+ defaultVisible: false
4405
+ });
4406
+ }
4407
+ if (!hasPublishedAt && col.draftAndPublish) {
4408
+ cols.push({
4409
+ key: "attr_publishedAt",
4410
+ label: "Published At",
4411
+ sortable: !col.isSingleType,
4412
+ defaultVisible: false
4413
+ });
4414
+ }
4415
+ if (searchAttribute && searchAttribute !== selectedAttribute) {
4416
+ let formattedSearchLabel = searchAttribute;
4417
+ const bracketMatch = searchAttribute.match(/^([^.[]+)\[([^\]]+)\]\.(.+)$/);
4418
+ if (bracketMatch) {
4419
+ const root = bracketMatch[1].charAt(0).toUpperCase() + bracketMatch[1].slice(1);
4420
+ const comp = formatComponentName(bracketMatch[2]);
4421
+ const sub = bracketMatch[3].split(".").map((s) => s.charAt(0).toUpperCase() + s.slice(1)).join(" > ");
4422
+ formattedSearchLabel = `${root} [${comp}] > ${sub}`;
4423
+ } else if (searchAttribute.includes(".")) {
4424
+ formattedSearchLabel = searchAttribute.split(".").map((s) => s.charAt(0).toUpperCase() + s.slice(1)).join(" > ");
4425
+ }
4426
+ cols.push({
4427
+ key: "search_attr",
4428
+ label: `Search: "${formattedSearchLabel}"`,
4429
+ sortable: !col.isSingleType && col.attributes.includes(searchAttribute),
4430
+ defaultVisible: true
4431
+ });
4432
+ }
4433
+ if (selectedAttribute && selectedAttribute.trim()) {
4434
+ let formattedTargetLabel = selectedAttribute;
4435
+ const bracketMatch = selectedAttribute.match(/^([^.[]+)\[([^\]]+)\]\.(.+)$/);
4436
+ if (bracketMatch) {
4437
+ const root = bracketMatch[1].charAt(0).toUpperCase() + bracketMatch[1].slice(1);
4438
+ const comp = formatComponentName(bracketMatch[2]);
4439
+ const sub = bracketMatch[3].split(".").map((s) => s.charAt(0).toUpperCase() + s.slice(1)).join(" > ");
4440
+ formattedTargetLabel = `${root} [${comp}] > ${sub}`;
4441
+ } else if (selectedAttribute.includes(".")) {
4442
+ formattedTargetLabel = selectedAttribute.split(".").map((s) => s.charAt(0).toUpperCase() + s.slice(1)).join(" > ");
4443
+ } else {
4444
+ formattedTargetLabel = selectedAttribute.replace(/_/g, " ").replace(/\b\w/g, (l) => l.toUpperCase());
4445
+ }
4446
+ cols.push({
4447
+ key: "current_attr",
4448
+ label: `Current Value: "${formattedTargetLabel}"`,
4449
+ sortable: !col.isSingleType && col.attributes.includes(selectedAttribute),
4450
+ defaultVisible: true
4451
+ });
4452
+ cols.push({
4453
+ key: "target_attr",
4454
+ label: `Target Updated Value: "${formattedTargetLabel}"`,
4455
+ sortable: !col.isSingleType && col.attributes.includes(selectedAttribute),
4456
+ defaultVisible: true
4457
+ });
4458
+ }
4459
+ cols.push({
4460
+ key: "status",
4461
+ label: "Status",
4462
+ sortable: false,
4463
+ defaultVisible: true
4464
+ });
4465
+ return cols;
4466
+ }
4467
+ function formatFullTooltipValue(val) {
4468
+ if (val === void 0 || val === null || val === "") {
4469
+ return "(empty / not set)";
4470
+ }
4471
+ if (typeof val === "boolean") {
4472
+ return String(val);
4473
+ }
4474
+ if (typeof val === "number") {
4475
+ return String(val);
4476
+ }
4477
+ if (val instanceof Date) {
4478
+ return isNaN(val.getTime()) ? "(invalid date)" : val.toISOString();
4479
+ }
4480
+ if (typeof val === "string") {
4481
+ return val;
4482
+ }
4483
+ if (Array.isArray(val)) {
4484
+ if (val.length === 0) return "(empty array)";
4485
+ try {
4486
+ return JSON.stringify(val, null, 2);
4487
+ } catch {
4488
+ return String(val);
4489
+ }
4490
+ }
4491
+ if (typeof val === "object") {
4492
+ if (val.isRelation && val.display) return val.display;
4493
+ try {
4494
+ return JSON.stringify(val, null, 2);
4495
+ } catch {
4496
+ return String(val);
4497
+ }
4498
+ }
4499
+ return String(val);
4500
+ }
4501
+ function getCellTooltipText(colDef, entry, colAttributes, selectedAttribute, searchAttribute, recordEdits) {
4502
+ if (!colDef || !entry) return void 0;
4503
+ switch (colDef.key) {
4504
+ case "select":
4505
+ return void 0;
4506
+ case "identifier": {
4507
+ const mainText = entry.name || entry.title || `Entry #${entry.id || entry.documentId}`;
4508
+ const parts = [String(mainText)];
4509
+ if (entry.documentId) parts.push(`Document ID: ${entry.documentId}`);
4510
+ if (entry.id && String(entry.id) !== String(entry.documentId)) parts.push(`ID: ${entry.id}`);
4511
+ if (entry.email) parts.push(`Email: ${entry.email}`);
4512
+ return parts.join("\n");
4513
+ }
4514
+ case "status": {
4515
+ if (selectedAttribute && colAttributes && !colAttributes.includes(selectedAttribute)) {
4516
+ return "Status: Ignored (absent in schema)";
4517
+ }
4518
+ return void 0;
4519
+ }
4520
+ case "current_attr": {
4521
+ if (!selectedAttribute) return void 0;
4522
+ const rootKey = selectedAttribute.split("[")[0].split(".")[0];
4523
+ const hasSchemaAttr = !colAttributes || colAttributes.includes(selectedAttribute) || colAttributes.includes(rootKey);
4524
+ if (!hasSchemaAttr) {
4525
+ return "Ignored (absent in schema)";
4526
+ }
4527
+ const matches = getAllNestedValues(entry, selectedAttribute, colAttributes);
4528
+ if (matches.length === 0) return "(empty / not set)";
4529
+ if (matches.length === 1 && !matches[0].componentUid && !matches[0].path.includes("[#")) {
4530
+ return formatFullTooltipValue(matches[0].value);
4531
+ }
4532
+ return matches.map((m) => {
4533
+ const compLabel = m.componentName ? `#${m.index} ${m.componentName}${m.componentId !== void 0 ? ` (id: ${m.componentId})` : ""}` : `#${m.index}`;
4534
+ const valStr = formatFullTooltipValue(m.value);
4535
+ return `${compLabel}: ${valStr}`;
4536
+ }).join("\n\n");
4537
+ }
4538
+ case "target_attr": {
4539
+ if (!selectedAttribute) return void 0;
4540
+ const rootKey = selectedAttribute.split("[")[0].split(".")[0];
4541
+ const hasSchemaAttr = !colAttributes || colAttributes.includes(selectedAttribute) || colAttributes.includes(rootKey);
4542
+ if (!hasSchemaAttr) {
4543
+ return "Ignored (absent in schema)";
4544
+ }
4545
+ if (recordEdits?.occurrences) {
4546
+ const occEntries = Object.entries(recordEdits.occurrences);
4547
+ if (occEntries.length > 0) {
4548
+ return occEntries.map(([occKey, editObj]) => {
4549
+ const valStr = formatFullTooltipValue(editObj?.value);
4550
+ return `Target [${occKey}]: ${valStr}${editObj?.validationError ? ` (Error: ${editObj.validationError})` : ""}`;
4551
+ }).join("\n\n");
4552
+ }
4553
+ }
4554
+ const matches = getAllNestedValues(entry, selectedAttribute, colAttributes);
4555
+ if (matches.length === 0) return "(empty / not set)";
4556
+ if (matches.length === 1 && !matches[0].componentUid && !matches[0].path.includes("[#")) {
4557
+ return formatFullTooltipValue(matches[0].value);
4558
+ }
4559
+ return matches.map((m) => {
4560
+ const compLabel = m.componentName ? `#${m.index} ${m.componentName}${m.componentId !== void 0 ? ` (id: ${m.componentId})` : ""}` : `#${m.index}`;
4561
+ const valStr = formatFullTooltipValue(m.value);
4562
+ return `${compLabel}: ${valStr}`;
4563
+ }).join("\n\n");
4564
+ }
4565
+ case "search_attr": {
4566
+ if (!searchAttribute) return void 0;
4567
+ const rootKey = searchAttribute.split("[")[0].split(".")[0];
4568
+ const hasSchemaAttr = !colAttributes || colAttributes.includes(searchAttribute) || colAttributes.includes(rootKey);
4569
+ if (!hasSchemaAttr) {
4570
+ return "Ignored (absent in schema)";
4571
+ }
4572
+ const matches = getAllNestedValues(entry, searchAttribute, colAttributes);
4573
+ if (matches.length === 0) return "(empty / not set)";
4574
+ if (matches.length === 1 && !matches[0].componentUid && !matches[0].path.includes("[#")) {
4575
+ return formatFullTooltipValue(matches[0].value);
4576
+ }
4577
+ return matches.map((m) => {
4578
+ const compLabel = m.componentName ? `#${m.index} ${m.componentName}${m.componentId !== void 0 ? ` (id: ${m.componentId})` : ""}` : `#${m.index}`;
4579
+ const valStr = formatFullTooltipValue(m.value);
4580
+ return `${compLabel}: ${valStr}`;
4581
+ }).join("\n\n");
4582
+ }
4583
+ default: {
4584
+ const attrName = colDef.key.replace("attr_", "");
4585
+ const matches = getAllNestedValues(entry, attrName, colAttributes);
4586
+ if (matches.length === 0) return "(empty / not set)";
4587
+ if (matches.length === 1 && !matches[0].componentUid && !matches[0].path.includes("[#")) {
4588
+ return formatFullTooltipValue(matches[0].value);
4589
+ }
4590
+ return matches.map((m) => {
4591
+ const compLabel = m.componentName ? `#${m.index} ${m.componentName}${m.componentId !== void 0 ? ` (id: ${m.componentId})` : ""}` : `#${m.index}`;
4592
+ const valStr = formatFullTooltipValue(m.value);
4593
+ return `${compLabel}: ${valStr}`;
4594
+ }).join("\n\n");
4595
+ }
4596
+ }
4597
+ }
4203
4598
  const DEFAULT_HEADING_ITEMS = [
4204
4599
  { value: "h1", label: "H1 - Main Page Title", maxAllowed: 1 },
4205
4600
  { value: "h2", label: "H2 - Primary Section Heading", maxAllowed: 3 },
@@ -5024,288 +5419,58 @@ const ComponentOccurrencesDrawer = React__default.memo(
5024
5419
  block?.id !== void 0 && /* @__PURE__ */ jsxs(Typography, { variant: "pi", textColor: "neutral500", style: { fontSize: "0.68rem" }, children: [
5025
5420
  "id:",
5026
5421
  block.id
5027
- ] })
5028
- ] }),
5029
- /* @__PURE__ */ jsxs(Td, { children: [
5030
- /* @__PURE__ */ jsx(Badge, { backgroundColor: "neutral150", textColor: "neutral800", children: compLabel }),
5031
- compUid && /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral500", display: "block", style: { fontSize: "0.68rem", marginTop: 2 }, children: compUid })
5032
- ] }),
5033
- /* @__PURE__ */ jsx(Td, { children: !targetsThisRoot ? /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral500", children: selectedAttribute ? `(targets "${selectedAttribute}")` : "(select attribute to inspect)" }) : !hasTargetAttr ? /* @__PURE__ */ jsx(Badge, { backgroundColor: "neutral100", textColor: "neutral500", children: "Does not contain attribute" }) : gridEditMode ? /* @__PURE__ */ jsx(Flex, { direction: "column", gap: 2, alignItems: "flex-start", children: blockOccs.map((occ) => {
5034
- const editObj = recordEdits?.occurrences?.[occ.occurrenceKey];
5035
- return /* @__PURE__ */ jsxs(Box, { style: { width: "100%" }, children: [
5036
- blockOccs.length > 1 && /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", display: "block", style: { fontSize: "0.7rem", marginBottom: 2 }, children: occ.displayPath }),
5037
- /* @__PURE__ */ jsx(
5038
- GridCellEditor,
5039
- {
5040
- entry,
5041
- attribute: selectedAttribute,
5042
- occurrence: occ,
5043
- attrMeta,
5044
- editedValue: editObj?.value,
5045
- isDirty: Boolean(editObj),
5046
- validationError: editObj?.validationError,
5047
- relationOptions,
5048
- relationOptionsLoading,
5049
- relationIsMulti,
5050
- validationRules,
5051
- recordEdits,
5052
- colAttributes,
5053
- onCommit: (o, val, err) => onCommitEdit(entry, colUid, o, val, err),
5054
- onReset: (k) => onResetEdit(colUid, entry.documentId, k)
5055
- }
5056
- )
5057
- ] }, occ.occurrenceKey);
5058
- }) }) : /* @__PURE__ */ jsx(Flex, { direction: "column", gap: 1, alignItems: "flex-start", children: blockOccs.map((occ) => /* @__PURE__ */ jsx(Typography, { variant: "omega", fontWeight: "semiBold", textColor: "primary700", children: occ.value !== null && occ.value !== void 0 && occ.value !== "" ? typeof occ.value === "object" ? JSON.stringify(occ.value) : String(occ.value) : "(empty / not set)" }, occ.occurrenceKey)) }) }),
5059
- /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(
5060
- Typography,
5061
- {
5062
- variant: "pi",
5063
- textColor: "neutral600",
5064
- style: { maxWidth: 280, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" },
5065
- children: blockSummaryText
5066
- }
5067
- ) })
5068
- ]
5069
- },
5070
- block?.id ? `id_${block.id}_idx_${bIdx}` : `idx_${bIdx}`
5071
- );
5072
- }) })
5073
- ] })
5074
- ]
5075
- }
5076
- );
5077
- }
5078
- );
5079
- function parseDynamicZonePath(path) {
5080
- if (!path) return { cleanPath: "", rootKey: "", subPath: "" };
5081
- const bracketMatch = path.match(/^([^.[]+)\[([^\]]+)\]\.(.+)$/);
5082
- if (bracketMatch) {
5083
- const rootKey = bracketMatch[1];
5084
- const selector = bracketMatch[2];
5085
- const subPath = bracketMatch[3];
5086
- const cleanPath = `${rootKey}.${subPath}`;
5087
- if (/^\d+$/.test(selector)) {
5088
- return { cleanPath, rootKey, subPath, targetIndex: parseInt(selector, 10) };
5089
- }
5090
- return { cleanPath, rootKey, subPath, targetComponentUid: selector };
5091
- }
5092
- const parts = path.split(".");
5093
- return {
5094
- cleanPath: path,
5095
- rootKey: parts[0] || "",
5096
- subPath: parts.slice(1).join(".")
5097
- };
5098
- }
5099
- function formatComponentName(compUid) {
5100
- if (!compUid) return "Component";
5101
- const name = compUid.includes(".") ? compUid.split(".")[1] : compUid;
5102
- return name.split(/[-_]/).map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join(" ");
5103
- }
5104
- function getAllNestedValues(obj, path, availableAttributes) {
5105
- if (!obj || !path) return [];
5106
- const parsed = parseDynamicZonePath(path);
5107
- const parts = parsed.cleanPath.split(".");
5108
- const [head, ...tail] = parts;
5109
- const rootTarget = getPropertyValue(obj, head);
5110
- if (Array.isArray(rootTarget)) {
5111
- const results = [];
5112
- rootTarget.forEach((item, idx) => {
5113
- if (!item || typeof item !== "object") return;
5114
- if (parsed.targetIndex !== void 0 && idx !== parsed.targetIndex) return;
5115
- if (parsed.targetComponentUid && item.__component !== parsed.targetComponentUid) return;
5116
- const subPath = tail.join(".");
5117
- const scopedPath = item.__component ? `${head}[${item.__component}].${subPath}` : "";
5118
- const isSupported = availableAttributes ? availableAttributes.includes(scopedPath) : false;
5119
- const subVal = tail.length > 0 ? getNestedValue(item, subPath) : item;
5120
- if (subVal !== void 0 || isSupported) {
5121
- results.push({
5122
- index: idx,
5123
- componentUid: item.__component,
5124
- componentName: formatComponentName(item.__component),
5125
- value: subVal !== void 0 ? subVal : null,
5126
- path: `${head}[#${idx}${item.__component ? ` ${formatComponentName(item.__component)}` : ""}].${subPath}`
5127
- });
5128
- }
5129
- });
5130
- return results;
5131
- }
5132
- const singleVal = getNestedValue(obj, parsed.cleanPath);
5133
- if (singleVal !== void 0) {
5134
- return [
5135
- {
5136
- index: 0,
5137
- value: singleVal,
5138
- path: parsed.cleanPath
5139
- }
5140
- ];
5141
- }
5142
- return [];
5143
- }
5144
- function getPropertyValue(target, key) {
5145
- if (!target || typeof target !== "object" || !key) return void 0;
5146
- if (target[key] !== void 0 && target[key] !== null) return target[key];
5147
- const camelKey = key.replace(/_([a-z0-9])/g, (_, letter) => letter.toUpperCase());
5148
- if (target[camelKey] !== void 0 && target[camelKey] !== null) return target[camelKey];
5149
- const snakeKey = key.replace(/([A-Z])/g, "_$1").toLowerCase();
5150
- if (target[snakeKey] !== void 0 && target[snakeKey] !== null) return target[snakeKey];
5151
- const lowerKey = key.toLowerCase();
5152
- const lowerNoUnderscore = lowerKey.replace(/_/g, "");
5153
- const matchedKey = Object.keys(target).find((k) => {
5154
- const kLower = k.toLowerCase();
5155
- return kLower === lowerKey || kLower.replace(/_/g, "") === lowerNoUnderscore;
5156
- });
5157
- if (matchedKey && target[matchedKey] !== void 0 && target[matchedKey] !== null) {
5158
- return target[matchedKey];
5159
- }
5160
- if (key in target) return target[key];
5161
- if (camelKey in target) return target[camelKey];
5162
- if (snakeKey in target) return target[snakeKey];
5163
- return void 0;
5164
- }
5165
- function getNestedValue(obj, path) {
5166
- if (!obj || !path) return void 0;
5167
- const parsed = parseDynamicZonePath(path);
5168
- const parts = parsed.cleanPath.split(".");
5169
- function extract(current, remainingParts) {
5170
- if (current === void 0 || current === null) return void 0;
5171
- if (remainingParts.length === 0) return current;
5172
- const [head, ...tail] = remainingParts;
5173
- if (Array.isArray(current)) {
5174
- if (/^\d+$/.test(head)) {
5175
- return extract(current[parseInt(head, 10)], tail);
5176
- }
5177
- for (let idx = 0; idx < current.length; idx++) {
5178
- const item = current[idx];
5179
- if (parsed.targetIndex !== void 0 && idx !== parsed.targetIndex) continue;
5180
- if (parsed.targetComponentUid && item?.__component !== parsed.targetComponentUid) continue;
5181
- const found = extract(getPropertyValue(item, head), tail);
5182
- if (found !== void 0 && found !== null) return found;
5183
- }
5184
- return void 0;
5185
- }
5186
- return extract(getPropertyValue(current, head), tail);
5187
- }
5188
- return extract(obj, parts);
5189
- }
5190
- function getAvailableColumnsForCollection(col, selectedAttribute, searchAttribute) {
5191
- const cols = [
5192
- {
5193
- key: "select",
5194
- label: "Select",
5195
- isPermanent: true,
5196
- defaultVisible: true
5197
- },
5198
- {
5199
- key: "identifier",
5200
- label: "Identifier",
5201
- sortable: !col.isSingleType,
5202
- defaultVisible: true
5203
- }
5204
- ];
5205
- const candidateAttrs = col.attributes || [];
5206
- candidateAttrs.forEach((attr) => {
5207
- if (attr === "name" || attr === "title" || attr === selectedAttribute || searchAttribute && attr === searchAttribute) {
5208
- return;
5209
- }
5210
- let formattedLabel = attr;
5211
- if (attr === "updated_at" || attr === "updatedAt") {
5212
- formattedLabel = "Updated At";
5213
- } else if (attr === "created_at" || attr === "createdAt") {
5214
- formattedLabel = "Created At";
5215
- } else if (attr === "published_at" || attr === "publishedAt") {
5216
- formattedLabel = "Published At";
5217
- } else {
5218
- const bracketMatch = attr.match(/^([^.[]+)\[([^\]]+)\]\.(.+)$/);
5219
- if (bracketMatch) {
5220
- const root = bracketMatch[1].charAt(0).toUpperCase() + bracketMatch[1].slice(1);
5221
- const comp = formatComponentName(bracketMatch[2]);
5222
- const sub = bracketMatch[3].split(".").map((s) => s.charAt(0).toUpperCase() + s.slice(1)).join(" > ");
5223
- formattedLabel = `${root} [${comp}] > ${sub}`;
5224
- } else if (attr.includes(".")) {
5225
- formattedLabel = attr.split(".").map((s) => s.charAt(0).toUpperCase() + s.slice(1)).join(" > ");
5226
- } else {
5227
- formattedLabel = attr.replace(/_/g, " ").replace(/\b\w/g, (l) => l.toUpperCase());
5422
+ ] })
5423
+ ] }),
5424
+ /* @__PURE__ */ jsxs(Td, { children: [
5425
+ /* @__PURE__ */ jsx(Badge, { backgroundColor: "neutral150", textColor: "neutral800", children: compLabel }),
5426
+ compUid && /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral500", display: "block", style: { fontSize: "0.68rem", marginTop: 2 }, children: compUid })
5427
+ ] }),
5428
+ /* @__PURE__ */ jsx(Td, { children: !targetsThisRoot ? /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral500", children: selectedAttribute ? `(targets "${selectedAttribute}")` : "(select attribute to inspect)" }) : !hasTargetAttr ? /* @__PURE__ */ jsx(Badge, { backgroundColor: "neutral100", textColor: "neutral500", children: "Does not contain attribute" }) : gridEditMode ? /* @__PURE__ */ jsx(Flex, { direction: "column", gap: 2, alignItems: "flex-start", children: blockOccs.map((occ) => {
5429
+ const editObj = recordEdits?.occurrences?.[occ.occurrenceKey];
5430
+ return /* @__PURE__ */ jsxs(Box, { style: { width: "100%" }, children: [
5431
+ blockOccs.length > 1 && /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", display: "block", style: { fontSize: "0.7rem", marginBottom: 2 }, children: occ.displayPath }),
5432
+ /* @__PURE__ */ jsx(
5433
+ GridCellEditor,
5434
+ {
5435
+ entry,
5436
+ attribute: selectedAttribute,
5437
+ occurrence: occ,
5438
+ attrMeta,
5439
+ editedValue: editObj?.value,
5440
+ isDirty: Boolean(editObj),
5441
+ validationError: editObj?.validationError,
5442
+ relationOptions,
5443
+ relationOptionsLoading,
5444
+ relationIsMulti,
5445
+ validationRules,
5446
+ recordEdits,
5447
+ colAttributes,
5448
+ onCommit: (o, val, err) => onCommitEdit(entry, colUid, o, val, err),
5449
+ onReset: (k) => onResetEdit(colUid, entry.documentId, k)
5450
+ }
5451
+ )
5452
+ ] }, occ.occurrenceKey);
5453
+ }) }) : /* @__PURE__ */ jsx(Flex, { direction: "column", gap: 1, alignItems: "flex-start", children: blockOccs.map((occ) => /* @__PURE__ */ jsx(Typography, { variant: "omega", fontWeight: "semiBold", textColor: "primary700", children: occ.value !== null && occ.value !== void 0 && occ.value !== "" ? typeof occ.value === "object" ? JSON.stringify(occ.value) : String(occ.value) : "(empty / not set)" }, occ.occurrenceKey)) }) }),
5454
+ /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(
5455
+ Typography,
5456
+ {
5457
+ variant: "pi",
5458
+ textColor: "neutral600",
5459
+ style: { maxWidth: 280, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" },
5460
+ children: blockSummaryText
5461
+ }
5462
+ ) })
5463
+ ]
5464
+ },
5465
+ block?.id ? `id_${block.id}_idx_${bIdx}` : `idx_${bIdx}`
5466
+ );
5467
+ }) })
5468
+ ] })
5469
+ ]
5228
5470
  }
5229
- }
5230
- cols.push({
5231
- key: `attr_${attr}`,
5232
- label: formattedLabel,
5233
- sortable: !col.isSingleType,
5234
- defaultVisible: ["department", "email", "location", "updated_at", "updatedAt"].includes(attr)
5235
- });
5236
- });
5237
- const hasUpdatedAt = candidateAttrs.some((a) => a === "updatedAt" || a === "updated_at");
5238
- const hasCreatedAt = candidateAttrs.some((a) => a === "createdAt" || a === "created_at");
5239
- const hasPublishedAt = candidateAttrs.some((a) => a === "publishedAt" || a === "published_at");
5240
- if (!hasUpdatedAt) {
5241
- cols.push({
5242
- key: "attr_updatedAt",
5243
- label: "Updated At",
5244
- sortable: !col.isSingleType,
5245
- defaultVisible: false
5246
- });
5247
- }
5248
- if (!hasCreatedAt) {
5249
- cols.push({
5250
- key: "attr_createdAt",
5251
- label: "Created At",
5252
- sortable: !col.isSingleType,
5253
- defaultVisible: false
5254
- });
5255
- }
5256
- if (!hasPublishedAt && col.draftAndPublish) {
5257
- cols.push({
5258
- key: "attr_publishedAt",
5259
- label: "Published At",
5260
- sortable: !col.isSingleType,
5261
- defaultVisible: false
5262
- });
5263
- }
5264
- if (searchAttribute && searchAttribute !== selectedAttribute) {
5265
- let formattedSearchLabel = searchAttribute;
5266
- const bracketMatch = searchAttribute.match(/^([^.[]+)\[([^\]]+)\]\.(.+)$/);
5267
- if (bracketMatch) {
5268
- const root = bracketMatch[1].charAt(0).toUpperCase() + bracketMatch[1].slice(1);
5269
- const comp = formatComponentName(bracketMatch[2]);
5270
- const sub = bracketMatch[3].split(".").map((s) => s.charAt(0).toUpperCase() + s.slice(1)).join(" > ");
5271
- formattedSearchLabel = `${root} [${comp}] > ${sub}`;
5272
- } else if (searchAttribute.includes(".")) {
5273
- formattedSearchLabel = searchAttribute.split(".").map((s) => s.charAt(0).toUpperCase() + s.slice(1)).join(" > ");
5274
- }
5275
- cols.push({
5276
- key: "search_attr",
5277
- label: `Search: "${formattedSearchLabel}"`,
5278
- sortable: !col.isSingleType && col.attributes.includes(searchAttribute),
5279
- defaultVisible: true
5280
- });
5281
- }
5282
- if (selectedAttribute && selectedAttribute.trim()) {
5283
- let formattedTargetLabel = selectedAttribute;
5284
- const bracketMatch = selectedAttribute.match(/^([^.[]+)\[([^\]]+)\]\.(.+)$/);
5285
- if (bracketMatch) {
5286
- const root = bracketMatch[1].charAt(0).toUpperCase() + bracketMatch[1].slice(1);
5287
- const comp = formatComponentName(bracketMatch[2]);
5288
- const sub = bracketMatch[3].split(".").map((s) => s.charAt(0).toUpperCase() + s.slice(1)).join(" > ");
5289
- formattedTargetLabel = `${root} [${comp}] > ${sub}`;
5290
- } else if (selectedAttribute.includes(".")) {
5291
- formattedTargetLabel = selectedAttribute.split(".").map((s) => s.charAt(0).toUpperCase() + s.slice(1)).join(" > ");
5292
- }
5293
- const targetLabel = searchAttribute && searchAttribute !== selectedAttribute ? `Update Target: "${formattedTargetLabel}"` : `Current "${formattedTargetLabel}"`;
5294
- cols.push({
5295
- key: "target_attr",
5296
- label: targetLabel,
5297
- sortable: !col.isSingleType && col.attributes.includes(selectedAttribute),
5298
- defaultVisible: true
5299
- });
5471
+ );
5300
5472
  }
5301
- cols.push({
5302
- key: "status",
5303
- label: "Status",
5304
- sortable: false,
5305
- defaultVisible: true
5306
- });
5307
- return cols;
5308
- }
5473
+ );
5309
5474
  function getActiveSortLabel(currentSort, col) {
5310
5475
  const f = currentSort.field;
5311
5476
  const o = currentSort.order;
@@ -5435,7 +5600,7 @@ function renderHeaderCell(colDef, col, currentSort, selectedAttribute, searchAtt
5435
5600
  if (colDef.key === "select") {
5436
5601
  return /* @__PURE__ */ jsx(Th, { style: { width: 48 }, children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", children: "Select" }) }, "select");
5437
5602
  }
5438
- const isCurrentSorted = colDef.key === "identifier" && (currentSort.field === "name" || currentSort.field === "title" || currentSort.field === "id") || colDef.key === "search_attr" && currentSort.field === searchAttribute || colDef.key === "target_attr" && currentSort.field === selectedAttribute || colDef.key.startsWith("attr_") && (currentSort.field === colDef.key.replace("attr_", "") || currentSort.field === "updatedAt" && colDef.key === "attr_updated_at" || currentSort.field === "updated_at" && colDef.key === "attr_updatedAt" || currentSort.field === "createdAt" && colDef.key === "attr_created_at" || currentSort.field === "created_at" && colDef.key === "attr_createdAt" || currentSort.field === "publishedAt" && colDef.key === "attr_published_at" || currentSort.field === "published_at" && colDef.key === "attr_publishedAt");
5603
+ const isCurrentSorted = colDef.key === "identifier" && (currentSort.field === "name" || currentSort.field === "title" || currentSort.field === "id") || colDef.key === "search_attr" && currentSort.field === searchAttribute || (colDef.key === "target_attr" || colDef.key === "current_attr") && currentSort.field === selectedAttribute || colDef.key.startsWith("attr_") && (currentSort.field === colDef.key.replace("attr_", "") || currentSort.field === "updatedAt" && colDef.key === "attr_updated_at" || currentSort.field === "updated_at" && colDef.key === "attr_updatedAt" || currentSort.field === "createdAt" && colDef.key === "attr_created_at" || currentSort.field === "created_at" && colDef.key === "attr_createdAt" || currentSort.field === "publishedAt" && colDef.key === "attr_published_at" || currentSort.field === "published_at" && colDef.key === "attr_publishedAt");
5439
5604
  const sortArrow = isCurrentSorted ? currentSort.order === "asc" ? "▲" : "▼" : "⇅";
5440
5605
  const handleClick = () => {
5441
5606
  if (!colDef.sortable) return;
@@ -5444,7 +5609,7 @@ function renderHeaderCell(colDef, col, currentSort, selectedAttribute, searchAtt
5444
5609
  onSort(col.uid, field);
5445
5610
  } else if (colDef.key === "search_attr") {
5446
5611
  onSort(col.uid, searchAttribute);
5447
- } else if (colDef.key === "target_attr") {
5612
+ } else if (colDef.key === "target_attr" || colDef.key === "current_attr") {
5448
5613
  onSort(col.uid, selectedAttribute);
5449
5614
  } else if (colDef.key.startsWith("attr_")) {
5450
5615
  onSort(col.uid, colDef.key.replace("attr_", ""));
@@ -5488,7 +5653,7 @@ function formatDisplayValue(val) {
5488
5653
  }
5489
5654
  return String(val);
5490
5655
  }
5491
- function renderCellContent(colDef, entry, col, selectedAttribute, searchAttribute, isMatch, hasAttr, isSelected, onToggleSelect, pendingBatches = [], isDzExpanded = false, onToggleExpandDz, filterQuery = "", gridCtx) {
5656
+ function renderCellContent(colDef, entry, col, selectedAttribute, searchAttribute, isMatch, hasAttr, isSelected, onToggleSelect, pendingBatches = [], isDzExpanded = false, onToggleExpandDz, filterQuery = "", gridCtx, cellTooltip) {
5492
5657
  switch (colDef.key) {
5493
5658
  case "select":
5494
5659
  return /* @__PURE__ */ jsx(
@@ -5540,6 +5705,7 @@ function renderCellContent(colDef, entry, col, selectedAttribute, searchAttribut
5540
5705
  return /* @__PURE__ */ jsx(
5541
5706
  Typography,
5542
5707
  {
5708
+ title: cellTooltip || displayStr,
5543
5709
  textColor: isUnset ? "neutral500" : "primary700",
5544
5710
  fontWeight: "semiBold",
5545
5711
  style: {
@@ -5558,9 +5724,11 @@ function renderCellContent(colDef, entry, col, selectedAttribute, searchAttribut
5558
5724
  return /* @__PURE__ */ jsx(Flex, { direction: "column", gap: 1, alignItems: "flex-start", style: { maxWidth: 320 }, children: matches.map((m) => {
5559
5725
  const displayStr = formatDisplayValue(m.value);
5560
5726
  const isMatchItem = qLower && displayStr.toLowerCase().includes(qLower);
5727
+ const occTooltip = `#${m.index} ${m.componentName || "Item"}${m.componentId !== void 0 ? ` (id: ${m.componentId})` : ""}: ${formatFullTooltipValue(m.value)}`;
5561
5728
  return /* @__PURE__ */ jsxs(
5562
5729
  Flex,
5563
5730
  {
5731
+ title: occTooltip,
5564
5732
  gap: 1,
5565
5733
  alignItems: "center",
5566
5734
  style: {
@@ -5580,6 +5748,7 @@ function renderCellContent(colDef, entry, col, selectedAttribute, searchAttribut
5580
5748
  Typography,
5581
5749
  {
5582
5750
  variant: "pi",
5751
+ title: occTooltip,
5583
5752
  fontWeight: isMatchItem ? "bold" : "normal",
5584
5753
  textColor: isMatchItem ? "success700" : "neutral800",
5585
5754
  style: {
@@ -5597,6 +5766,80 @@ function renderCellContent(colDef, entry, col, selectedAttribute, searchAttribut
5597
5766
  );
5598
5767
  }) });
5599
5768
  }
5769
+ case "current_attr": {
5770
+ if (selectedAttribute && !hasAttr) {
5771
+ return /* @__PURE__ */ jsx(Badge, { backgroundColor: "neutral200", textColor: "neutral600", children: "Ignored (absent in schema)" });
5772
+ }
5773
+ const matches = getAllNestedValues(entry, selectedAttribute, col?.attributes);
5774
+ if (matches.length === 0) {
5775
+ return /* @__PURE__ */ jsx(Typography, { textColor: "neutral500", style: { fontStyle: "italic" }, children: "(empty / not set)" });
5776
+ }
5777
+ if (matches.length === 1 && !matches[0].componentUid && !matches[0].path.includes("[#")) {
5778
+ const displayStr = formatDisplayValue(matches[0].value);
5779
+ const isUnset = displayStr === "(empty / not set)" || displayStr === "(empty / unlinked)";
5780
+ return /* @__PURE__ */ jsx(
5781
+ Typography,
5782
+ {
5783
+ title: cellTooltip || displayStr,
5784
+ textColor: isUnset ? "neutral500" : "neutral800",
5785
+ style: {
5786
+ fontStyle: isUnset ? "italic" : "normal",
5787
+ display: "inline-block",
5788
+ maxWidth: 260,
5789
+ overflow: "hidden",
5790
+ textOverflow: "ellipsis",
5791
+ whiteSpace: "nowrap"
5792
+ },
5793
+ children: displayStr
5794
+ }
5795
+ );
5796
+ }
5797
+ return /* @__PURE__ */ jsx(Flex, { direction: "column", gap: 1, alignItems: "flex-start", style: { maxWidth: 320 }, children: matches.map((m) => {
5798
+ const displayStr = formatDisplayValue(m.value);
5799
+ const occTooltip = `#${m.index} ${m.componentName || "Item"}${m.componentId !== void 0 ? ` (id: ${m.componentId})` : ""}: ${formatFullTooltipValue(m.value)}`;
5800
+ return /* @__PURE__ */ jsxs(
5801
+ Flex,
5802
+ {
5803
+ title: occTooltip,
5804
+ gap: 1,
5805
+ alignItems: "center",
5806
+ style: {
5807
+ backgroundColor: "rgba(0, 0, 0, 0.03)",
5808
+ padding: "2px 6px",
5809
+ borderRadius: 4
5810
+ },
5811
+ children: [
5812
+ /* @__PURE__ */ jsxs(Badge, { size: "S", backgroundColor: "neutral200", textColor: "neutral800", children: [
5813
+ "#",
5814
+ m.index,
5815
+ " ",
5816
+ m.componentName || "Item"
5817
+ ] }),
5818
+ m.componentId !== void 0 && /* @__PURE__ */ jsxs(Typography, { variant: "pi", textColor: "neutral500", style: { fontSize: "0.68rem" }, children: [
5819
+ "id:",
5820
+ m.componentId
5821
+ ] }),
5822
+ /* @__PURE__ */ jsx(
5823
+ Typography,
5824
+ {
5825
+ variant: "pi",
5826
+ title: occTooltip,
5827
+ textColor: "neutral800",
5828
+ style: {
5829
+ maxWidth: 200,
5830
+ overflow: "hidden",
5831
+ textOverflow: "ellipsis",
5832
+ whiteSpace: "nowrap"
5833
+ },
5834
+ children: displayStr
5835
+ }
5836
+ )
5837
+ ]
5838
+ },
5839
+ m.index
5840
+ );
5841
+ }) });
5842
+ }
5600
5843
  case "target_attr": {
5601
5844
  if (gridCtx?.gridEditMode) {
5602
5845
  if (selectedAttribute && !hasAttr) {
@@ -5690,6 +5933,7 @@ function renderCellContent(colDef, entry, col, selectedAttribute, searchAttribut
5690
5933
  return /* @__PURE__ */ jsx(
5691
5934
  Typography,
5692
5935
  {
5936
+ title: cellTooltip || displayStr,
5693
5937
  textColor: isUnset ? "neutral500" : "neutral800",
5694
5938
  style: {
5695
5939
  fontStyle: isUnset ? "italic" : "normal",
@@ -5705,9 +5949,11 @@ function renderCellContent(colDef, entry, col, selectedAttribute, searchAttribut
5705
5949
  }
5706
5950
  return /* @__PURE__ */ jsx(Flex, { direction: "column", gap: 1, alignItems: "flex-start", style: { maxWidth: 320 }, children: matches.map((m) => {
5707
5951
  const displayStr = formatDisplayValue(m.value);
5952
+ const occTooltip = `#${m.index} ${m.componentName || "Item"}${m.componentId !== void 0 ? ` (id: ${m.componentId})` : ""}: ${formatFullTooltipValue(m.value)}`;
5708
5953
  return /* @__PURE__ */ jsxs(
5709
5954
  Flex,
5710
5955
  {
5956
+ title: occTooltip,
5711
5957
  gap: 1,
5712
5958
  alignItems: "center",
5713
5959
  style: {
@@ -5720,12 +5966,17 @@ function renderCellContent(colDef, entry, col, selectedAttribute, searchAttribut
5720
5966
  "#",
5721
5967
  m.index,
5722
5968
  " ",
5723
- m.componentName
5969
+ m.componentName || "Item"
5970
+ ] }),
5971
+ m.componentId !== void 0 && /* @__PURE__ */ jsxs(Typography, { variant: "pi", textColor: "neutral500", style: { fontSize: "0.68rem" }, children: [
5972
+ "id:",
5973
+ m.componentId
5724
5974
  ] }),
5725
5975
  /* @__PURE__ */ jsx(
5726
5976
  Typography,
5727
5977
  {
5728
5978
  variant: "pi",
5979
+ title: occTooltip,
5729
5980
  textColor: "neutral800",
5730
5981
  style: {
5731
5982
  maxWidth: 200,
@@ -5754,16 +6005,67 @@ function renderCellContent(colDef, entry, col, selectedAttribute, searchAttribut
5754
6005
  }
5755
6006
  default: {
5756
6007
  const attrName = colDef.key.replace("attr_", "");
5757
- const rawVal = getNestedValue(entry, attrName);
5758
- const displayStr = formatDisplayValue(rawVal);
5759
- return /* @__PURE__ */ jsx(
5760
- Typography,
5761
- {
5762
- textColor: "neutral700",
5763
- style: { maxWidth: 200, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" },
5764
- children: displayStr === "(empty / not set)" ? "-" : displayStr
5765
- }
5766
- );
6008
+ const matches = getAllNestedValues(entry, attrName, col?.attributes);
6009
+ if (matches.length === 0) {
6010
+ return /* @__PURE__ */ jsx(Typography, { textColor: "neutral500", style: { fontStyle: "italic" }, children: "-" });
6011
+ }
6012
+ if (matches.length === 1 && !matches[0].componentUid && !matches[0].path.includes("[#")) {
6013
+ const displayStr = formatDisplayValue(matches[0].value);
6014
+ return /* @__PURE__ */ jsx(
6015
+ Typography,
6016
+ {
6017
+ title: cellTooltip || (displayStr === "(empty / not set)" ? void 0 : displayStr),
6018
+ textColor: "neutral700",
6019
+ style: { maxWidth: 200, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" },
6020
+ children: displayStr === "(empty / not set)" ? "-" : displayStr
6021
+ }
6022
+ );
6023
+ }
6024
+ return /* @__PURE__ */ jsx(Flex, { direction: "column", gap: 1, alignItems: "flex-start", style: { maxWidth: 320 }, children: matches.map((m, mIdx) => {
6025
+ const displayStr = formatDisplayValue(m.value);
6026
+ const occTooltip = `#${m.index} ${m.componentName || "Item"}${m.componentId !== void 0 ? ` (id: ${m.componentId})` : ""}: ${formatFullTooltipValue(m.value)}`;
6027
+ return /* @__PURE__ */ jsxs(
6028
+ Flex,
6029
+ {
6030
+ title: occTooltip,
6031
+ gap: 1,
6032
+ alignItems: "center",
6033
+ style: {
6034
+ backgroundColor: "rgba(0, 0, 0, 0.03)",
6035
+ padding: "2px 6px",
6036
+ borderRadius: 4
6037
+ },
6038
+ children: [
6039
+ /* @__PURE__ */ jsxs(Badge, { size: "S", backgroundColor: "neutral200", textColor: "neutral800", children: [
6040
+ "#",
6041
+ m.index,
6042
+ " ",
6043
+ m.componentName || "Item"
6044
+ ] }),
6045
+ m.componentId !== void 0 && /* @__PURE__ */ jsxs(Typography, { variant: "pi", textColor: "neutral500", style: { fontSize: "0.68rem" }, children: [
6046
+ "id:",
6047
+ m.componentId
6048
+ ] }),
6049
+ /* @__PURE__ */ jsx(
6050
+ Typography,
6051
+ {
6052
+ variant: "pi",
6053
+ title: occTooltip,
6054
+ textColor: "neutral800",
6055
+ style: {
6056
+ maxWidth: 200,
6057
+ overflow: "hidden",
6058
+ textOverflow: "ellipsis",
6059
+ whiteSpace: "nowrap"
6060
+ },
6061
+ children: displayStr
6062
+ }
6063
+ )
6064
+ ]
6065
+ },
6066
+ `${m.index}_${m.componentId ?? mIdx}_${m.componentUid ?? ""}`
6067
+ );
6068
+ }) });
5767
6069
  }
5768
6070
  }
5769
6071
  }
@@ -6390,8 +6692,11 @@ const BulkUpdater = () => {
6390
6692
  if (selectedCollectionUid) {
6391
6693
  setCollectionColumnVisibility((prev) => {
6392
6694
  const existing = prev[selectedCollectionUid];
6393
- if (existing && !existing.includes("target_attr")) {
6394
- return { ...prev, [selectedCollectionUid]: [...existing, "target_attr"] };
6695
+ if (existing) {
6696
+ const next = [...existing];
6697
+ if (!next.includes("current_attr")) next.push("current_attr");
6698
+ if (!next.includes("target_attr")) next.push("target_attr");
6699
+ return { ...prev, [selectedCollectionUid]: next };
6395
6700
  }
6396
6701
  return prev;
6397
6702
  });
@@ -6473,6 +6778,18 @@ const BulkUpdater = () => {
6473
6778
  }
6474
6779
  setGridEdits({});
6475
6780
  setSelectedAttribute(newAttr);
6781
+ if (newAttr && selectedCollectionUid) {
6782
+ setCollectionColumnVisibility((prev) => {
6783
+ const existing = prev[selectedCollectionUid];
6784
+ if (existing) {
6785
+ const next = [...existing];
6786
+ if (!next.includes("current_attr")) next.push("current_attr");
6787
+ if (!next.includes("target_attr")) next.push("target_attr");
6788
+ return { ...prev, [selectedCollectionUid]: next };
6789
+ }
6790
+ return prev;
6791
+ });
6792
+ }
6476
6793
  try {
6477
6794
  if (newAttr) {
6478
6795
  localStorage.setItem(LAST_ATTR_KEY, newAttr);
@@ -7180,7 +7497,31 @@ const BulkUpdater = () => {
7180
7497
  }
7181
7498
  try {
7182
7499
  setBulkExporting(true);
7183
- const res = await post("/bulk-updater/csv/export-bulk", { selectedEntries: targets });
7500
+ const targetUids = Array.from(new Set(targets.map((t) => t.uid)));
7501
+ let bulkSelectedCols;
7502
+ if (targetUids.length === 1 && selectedCol && selectedCol.uid === targetUids[0]) {
7503
+ const availCols = getAvailableColumnsForCollection(selectedCol, selectedAttribute, searchAttribute);
7504
+ const savedKeys = collectionColumnVisibility[selectedCol.uid];
7505
+ const activeCols = savedKeys ? availCols.filter((c) => c.isPermanent || savedKeys.includes(c.key)) : availCols.filter((c) => c.defaultVisible);
7506
+ const selectedDataAttrs = [];
7507
+ for (const c of activeCols) {
7508
+ if (c.key.startsWith("attr_")) {
7509
+ const attr = c.key.slice(5);
7510
+ if (!selectedDataAttrs.includes(attr)) selectedDataAttrs.push(attr);
7511
+ } else if ((c.key === "target_attr" || c.key === "current_attr") && selectedAttribute) {
7512
+ if (!selectedDataAttrs.includes(selectedAttribute)) selectedDataAttrs.push(selectedAttribute);
7513
+ } else if (c.key === "search_attr" && searchAttribute) {
7514
+ if (!selectedDataAttrs.includes(searchAttribute)) selectedDataAttrs.push(searchAttribute);
7515
+ }
7516
+ }
7517
+ if (selectedDataAttrs.length > 0) {
7518
+ bulkSelectedCols = selectedDataAttrs;
7519
+ }
7520
+ }
7521
+ const res = await post("/bulk-updater/csv/export-bulk", {
7522
+ selectedEntries: targets,
7523
+ selectedColumns: bulkSelectedCols
7524
+ });
7184
7525
  const csvStr = res.data?.csvContent || (typeof res.data === "string" ? res.data : "");
7185
7526
  if (!csvStr) {
7186
7527
  toggleNotification({
@@ -8386,6 +8727,21 @@ const BulkUpdater = () => {
8386
8727
  if (colSelectedDocIds.length > 0) {
8387
8728
  params.set("documentIds", colSelectedDocIds.join(","));
8388
8729
  }
8730
+ const selectedDataAttrs = [];
8731
+ for (const c of activeColumns) {
8732
+ if (c.key.startsWith("attr_")) {
8733
+ const attr = c.key.slice(5);
8734
+ if (!selectedDataAttrs.includes(attr)) selectedDataAttrs.push(attr);
8735
+ } else if ((c.key === "target_attr" || c.key === "current_attr") && selectedAttribute) {
8736
+ if (!selectedDataAttrs.includes(selectedAttribute)) selectedDataAttrs.push(selectedAttribute);
8737
+ } else if (c.key === "search_attr" && searchAttribute) {
8738
+ if (!selectedDataAttrs.includes(searchAttribute)) selectedDataAttrs.push(searchAttribute);
8739
+ }
8740
+ }
8741
+ if (selectedDataAttrs.length > 0) {
8742
+ params.set("selectedColumns", selectedDataAttrs.join(","));
8743
+ params.set("exportMode", "selective");
8744
+ }
8389
8745
  const res = await get(`/bulk-updater/csv/export/${col.uid}?${params.toString()}`);
8390
8746
  const csvStr = res.data?.csvContent || (typeof res.data === "string" ? res.data : "");
8391
8747
  if (!csvStr) {
@@ -8527,22 +8883,33 @@ const BulkUpdater = () => {
8527
8883
  backgroundColor: recordEdits ? "rgba(73, 69, 255, 0.10)" : isSelected ? "rgba(73, 69, 255, 0.14)" : isMatch ? "rgba(46, 213, 115, 0.08)" : void 0,
8528
8884
  boxShadow: isSelected ? "inset 3px 0 0 0 #4945ff" : isMatch ? "inset 3px 0 0 0 #2ed573" : void 0
8529
8885
  },
8530
- children: activeColumns.map((colDef) => /* @__PURE__ */ jsx(Td, { children: renderCellContent(
8531
- colDef,
8532
- entry,
8533
- col,
8534
- selectedAttribute,
8535
- searchAttribute,
8536
- isMatch,
8537
- hasAttr,
8538
- isSelected,
8539
- () => toggleEntry(col.uid, entry.documentId),
8540
- pendingBatches,
8541
- isDzExpanded,
8542
- onToggleExpandDz,
8543
- filterQuery,
8544
- gridCtx
8545
- ) }, colDef.key))
8886
+ children: activeColumns.map((colDef) => {
8887
+ const cellTooltip = getCellTooltipText(
8888
+ colDef,
8889
+ entry,
8890
+ col?.attributes,
8891
+ selectedAttribute,
8892
+ searchAttribute,
8893
+ recordEdits
8894
+ );
8895
+ return /* @__PURE__ */ jsx(Td, { title: cellTooltip, children: renderCellContent(
8896
+ colDef,
8897
+ entry,
8898
+ col,
8899
+ selectedAttribute,
8900
+ searchAttribute,
8901
+ isMatch,
8902
+ hasAttr,
8903
+ isSelected,
8904
+ () => toggleEntry(col.uid, entry.documentId),
8905
+ pendingBatches,
8906
+ isDzExpanded,
8907
+ onToggleExpandDz,
8908
+ filterQuery,
8909
+ gridCtx,
8910
+ cellTooltip
8911
+ ) }, colDef.key);
8912
+ })
8546
8913
  }
8547
8914
  ),
8548
8915
  isDzExpanded && expandableArrayFields.map((dzKey) => {
@@ -10157,13 +10524,15 @@ export {
10157
10524
  BulkUpdater as default,
10158
10525
  formatComponentName,
10159
10526
  formatDisplayValue,
10527
+ formatFullTooltipValue,
10160
10528
  getActiveSortLabel,
10161
10529
  getAllNestedValues,
10162
10530
  getAvailableColumnsForCollection,
10531
+ getCellTooltipText,
10163
10532
  getEntryLifecycleStatus,
10164
10533
  getNestedValue,
10165
10534
  getPropertyValue,
10166
10535
  getSortOptionsForCollection,
10167
10536
  parseDynamicZonePath
10168
10537
  };
10169
- //# sourceMappingURL=BulkUpdater-e7N4vMse.mjs.map
10538
+ //# sourceMappingURL=BulkUpdater-C670oEo7.mjs.map