strapi-plugin-bulk-updater 1.5.16 → 1.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.
@@ -354,6 +354,86 @@ function getEntryLifecycleStatus(entry, col, pendingBatches = []) {
354
354
  textColor: "neutral700"
355
355
  };
356
356
  }
357
+ const EMPTY_SEARCH_FILTER = {
358
+ searchAttribute: "",
359
+ filterOperator: "none",
360
+ filterQuery: "",
361
+ entrySearch: "",
362
+ statusFilter: "all",
363
+ useRegex: false,
364
+ regexPattern: ""
365
+ };
366
+ function areSearchFiltersEqual(a, b, options = {}) {
367
+ if ((a.searchAttribute || "") !== (b.searchAttribute || "") || (a.filterOperator || "none") !== (b.filterOperator || "none") || (a.filterQuery || "") !== (b.filterQuery || "") || (a.entrySearch || "") !== (b.entrySearch || "")) {
368
+ return false;
369
+ }
370
+ if (options.includeWorkspaceExtras) {
371
+ if ((a.statusFilter || "all") !== (b.statusFilter || "all") || Boolean(a.useRegex) !== Boolean(b.useRegex) || (a.regexPattern || "") !== (b.regexPattern || "")) {
372
+ return false;
373
+ }
374
+ }
375
+ return true;
376
+ }
377
+ function isSearchFilterActive(filter, selectedTargetAttribute = "") {
378
+ const hasAttrFilter = Boolean(filter.searchAttribute && filter.searchAttribute !== selectedTargetAttribute);
379
+ const hasOp = filter.filterOperator !== "none" && (["empty", "not_empty"].includes(filter.filterOperator) || Boolean((filter.filterQuery || "").trim()));
380
+ const hasSearchText = Boolean((filter.entrySearch || "").trim());
381
+ const hasStatus = Boolean(filter.statusFilter && filter.statusFilter !== "all");
382
+ const hasRegex = Boolean(filter.useRegex && (filter.regexPattern || "").trim());
383
+ return hasAttrFilter || hasOp || hasSearchText || hasStatus || hasRegex;
384
+ }
385
+ function buildEntriesQueryParams(options) {
386
+ const { page, pageSize, filter, selectedAttribute, sortField, sortOrder, includeAttributeEvenIfSame } = options;
387
+ const params = new URLSearchParams({
388
+ page: String(page),
389
+ pageSize: String(pageSize)
390
+ });
391
+ if (includeAttributeEvenIfSame) {
392
+ if (filter.searchAttribute) {
393
+ params.set("attribute", filter.searchAttribute);
394
+ params.set("searchAttribute", filter.searchAttribute);
395
+ }
396
+ } else {
397
+ if (selectedAttribute) params.set("attribute", selectedAttribute);
398
+ if (filter.searchAttribute && filter.searchAttribute !== selectedAttribute) {
399
+ params.set("searchAttribute", filter.searchAttribute);
400
+ }
401
+ }
402
+ if (filter.filterOperator && filter.filterOperator !== "none") {
403
+ params.set("filterOperator", filter.filterOperator);
404
+ if (filter.filterQuery) {
405
+ params.set("filterQuery", filter.filterQuery);
406
+ }
407
+ }
408
+ if (filter.entrySearch && filter.entrySearch.trim()) {
409
+ params.set("search", filter.entrySearch.trim());
410
+ }
411
+ if (sortField) {
412
+ params.set("sortField", sortField);
413
+ if (sortOrder) params.set("sortOrder", sortOrder);
414
+ }
415
+ return params;
416
+ }
417
+ function buildCsvExportQueryParams(options) {
418
+ const { limit, filter } = options;
419
+ const queryParams = new URLSearchParams();
420
+ if (limit && limit > 0) {
421
+ queryParams.set("limit", String(limit));
422
+ }
423
+ if (filter.searchAttribute) {
424
+ queryParams.set("searchAttribute", filter.searchAttribute);
425
+ }
426
+ if (filter.filterOperator && filter.filterOperator !== "none") {
427
+ queryParams.set("filterOperator", filter.filterOperator);
428
+ if (filter.filterQuery) {
429
+ queryParams.set("filterQuery", filter.filterQuery);
430
+ }
431
+ }
432
+ if (filter.entrySearch && filter.entrySearch.trim()) {
433
+ queryParams.set("search", filter.entrySearch.trim());
434
+ }
435
+ return queryParams;
436
+ }
357
437
  function CsvManagerTab() {
358
438
  const { get, post } = admin.useFetchClient();
359
439
  const { toggleNotification } = admin.useNotification();
@@ -370,8 +450,17 @@ function CsvManagerTab() {
370
450
  const [filterOperator, setFilterOperator] = React.useState("none");
371
451
  const [filterQuery, setFilterQuery] = React.useState("");
372
452
  const [entrySearch, setEntrySearch] = React.useState("");
453
+ const [appliedFilter, setAppliedFilter] = React.useState(EMPTY_SEARCH_FILTER);
454
+ const appliedFilterRef = React.useRef(EMPTY_SEARCH_FILTER);
373
455
  const [matchingCount, setMatchingCount] = React.useState(null);
374
456
  const [countLoading, setCountLoading] = React.useState(false);
457
+ const draftFilter = {
458
+ searchAttribute,
459
+ filterOperator,
460
+ filterQuery,
461
+ entrySearch
462
+ };
463
+ const hasPendingFilterChanges = !areSearchFiltersEqual(draftFilter, appliedFilter);
375
464
  const [searchRelationOptions, setSearchRelationOptions] = React.useState([]);
376
465
  const [searchRelationOptionsLoading, setSearchRelationOptionsLoading] = React.useState(false);
377
466
  const [exportLimit, setExportLimit] = React.useState(0);
@@ -491,53 +580,78 @@ function CsvManagerTab() {
491
580
  setFilterOperator("none");
492
581
  setFilterQuery("");
493
582
  setEntrySearch("");
583
+ appliedFilterRef.current = EMPTY_SEARCH_FILTER;
584
+ setAppliedFilter(EMPTY_SEARCH_FILTER);
494
585
  setMatchingCount(null);
495
586
  setCountLoading(Boolean(newUid));
496
587
  };
497
- React.useEffect(() => {
498
- if (!selectedUid) {
588
+ const executeMatchingCountSearch = async (targetUid, filterToApply) => {
589
+ if (!targetUid) {
499
590
  setMatchingCount(null);
500
591
  setCountLoading(false);
501
592
  return;
502
593
  }
594
+ if (countAbortControllerRef.current) {
595
+ countAbortControllerRef.current.abort();
596
+ }
597
+ const controller = new AbortController();
598
+ countAbortControllerRef.current = controller;
503
599
  setCountLoading(true);
504
- const timer = setTimeout(async () => {
505
- if (countAbortControllerRef.current) {
506
- countAbortControllerRef.current.abort();
600
+ try {
601
+ const params = buildEntriesQueryParams({
602
+ page: 1,
603
+ pageSize: 1,
604
+ filter: filterToApply,
605
+ includeAttributeEvenIfSame: true
606
+ });
607
+ const res = await get(`/bulk-updater/collections/${targetUid}/entries?${params.toString()}`, {
608
+ signal: controller.signal
609
+ });
610
+ if (countAbortControllerRef.current !== controller) return;
611
+ if (res.data) {
612
+ const total = res.data.pagination?.total ?? (Array.isArray(res.data.entries) ? res.data.entries.length : 0);
613
+ setMatchingCount(total);
507
614
  }
508
- const controller = new AbortController();
509
- countAbortControllerRef.current = controller;
510
- try {
511
- const params = new URLSearchParams({
512
- page: "1",
513
- pageSize: "1"
514
- });
515
- if (searchAttribute) {
516
- params.set("attribute", searchAttribute);
517
- params.set("searchAttribute", searchAttribute);
518
- }
519
- if (filterOperator && filterOperator !== "none") {
520
- params.set("filterOperator", filterOperator);
521
- if (filterQuery) params.set("filterQuery", filterQuery);
522
- }
523
- if (entrySearch && entrySearch.trim()) {
524
- params.set("search", entrySearch.trim());
525
- }
526
- const res = await get(`/bulk-updater/collections/${selectedUid}/entries?${params.toString()}`, {
527
- signal: controller.signal
528
- });
529
- if (res.data) {
530
- const total = res.data.pagination?.total ?? (Array.isArray(res.data.entries) ? res.data.entries.length : 0);
531
- setMatchingCount(total);
532
- }
533
- } catch (err) {
534
- if (!ValidationRulesTab.isAbortError(err)) ;
535
- } finally {
615
+ } catch (err) {
616
+ if (!ValidationRulesTab.isAbortError(err)) ;
617
+ } finally {
618
+ if (countAbortControllerRef.current === controller) {
536
619
  setCountLoading(false);
537
620
  }
538
- }, 300);
539
- return () => clearTimeout(timer);
540
- }, [selectedUid, searchAttribute, filterOperator, filterQuery, entrySearch]);
621
+ }
622
+ };
623
+ React.useEffect(() => {
624
+ if (!selectedUid) {
625
+ setMatchingCount(null);
626
+ setCountLoading(false);
627
+ return;
628
+ }
629
+ executeMatchingCountSearch(selectedUid, appliedFilterRef.current);
630
+ }, [selectedUid]);
631
+ const handleApplySearch = () => {
632
+ const nextApplied = {
633
+ searchAttribute,
634
+ filterOperator,
635
+ filterQuery,
636
+ entrySearch
637
+ };
638
+ appliedFilterRef.current = nextApplied;
639
+ setAppliedFilter(nextApplied);
640
+ if (selectedUid) {
641
+ executeMatchingCountSearch(selectedUid, nextApplied);
642
+ }
643
+ };
644
+ const handleClearFilters = () => {
645
+ setSearchAttribute("");
646
+ setFilterOperator("none");
647
+ setFilterQuery("");
648
+ setEntrySearch("");
649
+ appliedFilterRef.current = EMPTY_SEARCH_FILTER;
650
+ setAppliedFilter(EMPTY_SEARCH_FILTER);
651
+ if (selectedUid) {
652
+ executeMatchingCountSearch(selectedUid, EMPTY_SEARCH_FILTER);
653
+ }
654
+ };
541
655
  const fetchAndEnrichEntries = async (colUid, cols = collections, batches = pendingBatches) => {
542
656
  if (!colUid) return [];
543
657
  try {
@@ -620,16 +734,10 @@ function CsvManagerTab() {
620
734
  if (!selectedUid || exportingCollection) return;
621
735
  try {
622
736
  setExportingCollection(true);
623
- const queryParams = new URLSearchParams();
624
- if (exportLimit > 0) queryParams.set("limit", String(exportLimit));
625
- if (searchAttribute) queryParams.set("searchAttribute", searchAttribute);
626
- if (filterOperator && filterOperator !== "none") {
627
- queryParams.set("filterOperator", filterOperator);
628
- if (filterQuery) queryParams.set("filterQuery", filterQuery);
629
- }
630
- if (entrySearch && entrySearch.trim()) {
631
- queryParams.set("search", entrySearch.trim());
632
- }
737
+ const queryParams = buildCsvExportQueryParams({
738
+ limit: exportLimit,
739
+ filter: appliedFilterRef.current
740
+ });
633
741
  const res = await get(`/bulk-updater/csv/export/${selectedUid}?${queryParams.toString()}`);
634
742
  const csvStr = res.data?.csvContent || (typeof res.data === "string" ? res.data : "");
635
743
  const filename = res.data?.filename || `${selectedUid.split(".").pop()}_export.csv`;
@@ -1099,20 +1207,8 @@ function CsvManagerTab() {
1099
1207
  ]
1100
1208
  }
1101
1209
  ) : null,
1102
- (searchAttribute || filterOperator !== "none" || entrySearch.trim()) && /* @__PURE__ */ jsxRuntime.jsx(
1103
- designSystem.Button,
1104
- {
1105
- variant: "ghost",
1106
- size: "S",
1107
- onClick: () => {
1108
- setSearchAttribute("");
1109
- setFilterOperator("none");
1110
- setFilterQuery("");
1111
- setEntrySearch("");
1112
- },
1113
- children: "Clear Filters"
1114
- }
1115
- )
1210
+ hasPendingFilterChanges && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { backgroundColor: "warning100", textColor: "warning700", size: "S", children: "Filters modified — click Search to apply" }),
1211
+ (searchAttribute || filterOperator !== "none" || entrySearch.trim() || hasPendingFilterChanges) && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "ghost", size: "S", onClick: handleClearFilters, children: "Clear Filters" })
1116
1212
  ] })
1117
1213
  ] }),
1118
1214
  /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 3, alignItems: "flex-end", wrap: "wrap", children: [
@@ -1198,7 +1294,13 @@ function CsvManagerTab() {
1198
1294
  {
1199
1295
  placeholder: "Type value to match...",
1200
1296
  value: filterQuery,
1201
- onChange: (e) => setFilterQuery(e.target.value)
1297
+ onChange: (e) => setFilterQuery(e.target.value),
1298
+ onKeyDown: (e) => {
1299
+ if (e.key === "Enter") {
1300
+ e.preventDefault();
1301
+ handleApplySearch();
1302
+ }
1303
+ }
1202
1304
  }
1203
1305
  )
1204
1306
  ] }),
@@ -1209,10 +1311,27 @@ function CsvManagerTab() {
1209
1311
  {
1210
1312
  placeholder: "Search title, name, or text across records...",
1211
1313
  value: entrySearch,
1212
- onChange: (e) => setEntrySearch(e.target.value)
1314
+ onChange: (e) => setEntrySearch(e.target.value),
1315
+ onKeyDown: (e) => {
1316
+ if (e.key === "Enter") {
1317
+ e.preventDefault();
1318
+ handleApplySearch();
1319
+ }
1320
+ }
1213
1321
  }
1214
1322
  )
1215
- ] })
1323
+ ] }),
1324
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { children: /* @__PURE__ */ jsxRuntime.jsx(
1325
+ designSystem.Button,
1326
+ {
1327
+ variant: hasPendingFilterChanges ? "default" : "secondary",
1328
+ startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Search, {}),
1329
+ onClick: handleApplySearch,
1330
+ loading: countLoading,
1331
+ disabled: !selectedUid || countLoading,
1332
+ children: "Search"
1333
+ }
1334
+ ) })
1216
1335
  ] })
1217
1336
  ] }) : /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { padding: 4, background: "neutral0", hasRadius: true, marginBottom: 4, style: { border: "1px solid #eaeaef", textAlign: "center" }, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral500", children: "Please select a Target Collection Type above to configure search filters and export data." }) }),
1218
1337
  /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 4, wrap: "wrap", alignItems: "flex-end", marginTop: 3, children: [
@@ -2747,6 +2866,7 @@ const BulkUpdatePreviewModal = ({
2747
2866
  previewData,
2748
2867
  attribute,
2749
2868
  targetValueDisplay,
2869
+ editMode = "common",
2750
2870
  publishOnApproval = true,
2751
2871
  lifecycleStats
2752
2872
  }) => {
@@ -2761,12 +2881,14 @@ const BulkUpdatePreviewModal = ({
2761
2881
  if (searchQuery.trim()) {
2762
2882
  const q = searchQuery.toLowerCase().trim();
2763
2883
  items = items.filter(
2764
- (d) => d.label.toLowerCase().includes(q) || d.documentId.toLowerCase().includes(q) || d.collectionName.toLowerCase().includes(q) || String(d.oldDisplay || "").toLowerCase().includes(q) || String(d.newDisplay || "").toLowerCase().includes(q)
2884
+ (d) => d.label.toLowerCase().includes(q) || d.documentId.toLowerCase().includes(q) || d.collectionName.toLowerCase().includes(q) || String(d.attribute || "").toLowerCase().includes(q) || String(d.oldDisplay || "").toLowerCase().includes(q) || String(d.newDisplay || "").toLowerCase().includes(q)
2765
2885
  );
2766
2886
  }
2767
2887
  return items;
2768
2888
  }, [previewData, filterTab, searchQuery]);
2769
2889
  if (!isOpen) return null;
2890
+ const isGridMode = editMode === "grid" || previewData?.editMode === "grid";
2891
+ const willErrorCount = previewData?.summary?.willError || 0;
2770
2892
  return /* @__PURE__ */ jsxRuntime.jsx(
2771
2893
  "div",
2772
2894
  {
@@ -2790,7 +2912,7 @@ const BulkUpdatePreviewModal = ({
2790
2912
  hasRadius: true,
2791
2913
  shadow: "popupShadow",
2792
2914
  style: {
2793
- maxWidth: 1040,
2915
+ maxWidth: 1120,
2794
2916
  width: "95%",
2795
2917
  maxHeight: "calc(100vh - 48px)",
2796
2918
  display: "flex",
@@ -2817,13 +2939,16 @@ const BulkUpdatePreviewModal = ({
2817
2939
  /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Badge, { backgroundColor: "primary100", textColor: "primary700", children: [
2818
2940
  "Target: ",
2819
2941
  attribute
2820
- ] })
2942
+ ] }),
2943
+ isGridMode && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { backgroundColor: "secondary100", textColor: "secondary700", children: "GRID EDITING MODE" })
2821
2944
  ] }),
2822
2945
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: "Inspect exact before & after values across target records before applying changes to the database." })
2823
2946
  ] }),
2824
2947
  /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, alignItems: "center", wrap: "wrap", children: [
2825
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: "New Value:" }),
2826
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { backgroundColor: "success100", textColor: "success700", children: targetValueDisplay || "(empty)" }),
2948
+ !isGridMode ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2949
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: "New Value:" }),
2950
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { backgroundColor: "success100", textColor: "success700", children: targetValueDisplay || "(empty)" })
2951
+ ] }) : /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { backgroundColor: "secondary100", textColor: "secondary700", children: targetValueDisplay || "Per-Record & Component Grid Edits" }),
2827
2952
  /* @__PURE__ */ jsxRuntime.jsx(
2828
2953
  designSystem.Badge,
2829
2954
  {
@@ -2851,6 +2976,13 @@ const BulkUpdatePreviewModal = ({
2851
2976
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "delta", fontWeight: "semiBold", children: "Inspecting Target Records..." }),
2852
2977
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: "Computing proposed diffs and verifying against database schema." })
2853
2978
  ] }) }) : !previewData ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { padding: 6, style: { textAlign: "center" }, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral600", children: "No preview data available." }) }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2979
+ willErrorCount > 0 && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { marginBottom: 4, padding: 3, background: "danger100", hasRadius: true, style: { border: "1px solid #f5c0b8" }, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, alignItems: "center", children: [
2980
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", fontWeight: "bold", textColor: "danger700", children: "⚠️ Validation / Quota Violation Detected:" }),
2981
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { variant: "pi", textColor: "danger700", children: [
2982
+ willErrorCount,
2983
+ ' item(s) failed schema or quota validation rules. Inspect the rows marked "Validation Error" below; invalid records will be rejected during batch execution and retained for editing.'
2984
+ ] })
2985
+ ] }) }),
2854
2986
  publishOnApproval && lifecycleStats && lifecycleStats.unreviewedCount > 0 && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { marginBottom: 4, padding: 3, background: "warning100", hasRadius: true, style: { border: "1px solid #f5c0b8" }, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, alignItems: "center", children: [
2855
2987
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", fontWeight: "bold", textColor: "warning700", children: "⚠️ Safe Publishing Active:" }),
2856
2988
  /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { variant: "pi", textColor: "warning700", children: [
@@ -2916,7 +3048,7 @@ const BulkUpdatePreviewModal = ({
2916
3048
  variant: "sigma",
2917
3049
  textColor: previewData.summary.skipped > 0 ? "warning700" : "neutral600",
2918
3050
  display: "block",
2919
- children: "WILL SKIP (NO FIELD)"
3051
+ children: "WILL SKIP"
2920
3052
  }
2921
3053
  ),
2922
3054
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -2930,6 +3062,19 @@ const BulkUpdatePreviewModal = ({
2930
3062
  )
2931
3063
  ]
2932
3064
  }
3065
+ ),
3066
+ willErrorCount > 0 && /* @__PURE__ */ jsxRuntime.jsxs(
3067
+ designSystem.Box,
3068
+ {
3069
+ padding: 3,
3070
+ background: "danger100",
3071
+ hasRadius: true,
3072
+ style: { flex: 1, minWidth: 140, border: "1px solid #ffa39e" },
3073
+ children: [
3074
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "danger700", display: "block", children: "VALIDATION ERRORS" }),
3075
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "beta", fontWeight: "bold", textColor: "danger700", children: willErrorCount })
3076
+ ]
3077
+ }
2933
3078
  )
2934
3079
  ] }),
2935
3080
  /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", alignItems: "center", marginBottom: 3, wrap: "wrap", gap: 3, children: [
@@ -2942,7 +3087,7 @@ const BulkUpdatePreviewModal = ({
2942
3087
  onClick: () => setFilterTab("all"),
2943
3088
  children: [
2944
3089
  "All (",
2945
- previewData.summary.total,
3090
+ isGridMode ? previewData.diffs.length : previewData.summary.total,
2946
3091
  ")"
2947
3092
  ]
2948
3093
  }
@@ -2985,6 +3130,19 @@ const BulkUpdatePreviewModal = ({
2985
3130
  ")"
2986
3131
  ]
2987
3132
  }
3133
+ ),
3134
+ willErrorCount > 0 && /* @__PURE__ */ jsxRuntime.jsxs(
3135
+ designSystem.Button,
3136
+ {
3137
+ variant: filterTab === "will_error" ? "default" : "tertiary",
3138
+ size: "S",
3139
+ onClick: () => setFilterTab("will_error"),
3140
+ children: [
3141
+ "Errors (",
3142
+ willErrorCount,
3143
+ ")"
3144
+ ]
3145
+ }
2988
3146
  )
2989
3147
  ] }),
2990
3148
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { style: { width: 260 }, children: /* @__PURE__ */ jsxRuntime.jsx(
@@ -3007,20 +3165,22 @@ const BulkUpdatePreviewModal = ({
3007
3165
  overflowY: "auto",
3008
3166
  overflowX: "auto"
3009
3167
  },
3010
- children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Table, { colCount: 5, rowCount: filteredDiffs.length + 1, style: { width: "100%", minWidth: 780 }, children: [
3168
+ children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Table, { colCount: 6, rowCount: filteredDiffs.length + 1, style: { width: "100%", minWidth: 880 }, children: [
3011
3169
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Thead, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { children: [
3012
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { style: { width: 150 }, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: "COLLECTION" }) }),
3013
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { style: { minWidth: 200 }, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: "RECORD IDENTIFIER" }) }),
3014
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { style: { minWidth: 180 }, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: "CURRENT VALUE (BEFORE)" }) }),
3015
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { style: { minWidth: 180 }, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: "NEW VALUE (AFTER)" }) }),
3016
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { style: { width: 140, textAlign: "right" }, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: "IMPACT" }) })
3170
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { style: { width: 140 }, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: "COLLECTION" }) }),
3171
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { style: { minWidth: 185 }, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: "RECORD IDENTIFIER" }) }),
3172
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { style: { minWidth: 165 }, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: "ATTRIBUTE / BLOCK" }) }),
3173
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { style: { minWidth: 170 }, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: "CURRENT VALUE (BEFORE)" }) }),
3174
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { style: { minWidth: 170 }, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: "NEW VALUE (AFTER)" }) }),
3175
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { style: { width: 150, textAlign: "right" }, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: "IMPACT" }) })
3017
3176
  ] }) }),
3018
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tbody, { children: filteredDiffs.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tr, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { colSpan: 5, style: { textAlign: "center", padding: "24px" }, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral600", children: "No records match the current filter or search criteria." }) }) }) : filteredDiffs.map((diff) => /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { children: [
3177
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tbody, { children: filteredDiffs.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tr, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { colSpan: 6, style: { textAlign: "center", padding: "24px" }, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral600", children: "No records match the current filter or search criteria." }) }) }) : filteredDiffs.map((diff, idx) => /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { children: [
3019
3178
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { backgroundColor: "neutral150", textColor: "neutral700", children: diff.collectionName }) }),
3020
3179
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { children: [
3021
3180
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: "bold", display: "block", children: diff.label }),
3022
3181
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral500", children: /* @__PURE__ */ jsxRuntime.jsx("code", { children: diff.documentId }) })
3023
3182
  ] }) }),
3183
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", fontWeight: "semiBold", textColor: "primary700", children: diff.attribute || attribute }) }),
3024
3184
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(
3025
3185
  designSystem.Typography,
3026
3186
  {
@@ -3033,13 +3193,14 @@ const BulkUpdatePreviewModal = ({
3033
3193
  children: diff.oldDisplay || "(empty)"
3034
3194
  }
3035
3195
  ) }),
3036
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: diff.status === "will_skip" ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "warning700", children: "— Skipped (field absent) —" }) : diff.hasChange ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", fontWeight: "bold", textColor: "success700", style: { wordBreak: "break-all" }, children: diff.newDisplay || "(empty)" }) : /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", textColor: "neutral600", children: diff.newDisplay || "(already matching)" }) }),
3196
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: diff.status === "will_error" ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "danger700", fontWeight: "bold", children: diff.validationError || diff.message }) : diff.status === "will_skip" ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "warning700", children: "— Skipped (field absent) —" }) : diff.hasChange ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", fontWeight: "bold", textColor: "success700", style: { wordBreak: "break-all" }, children: diff.newDisplay || "(empty)" }) : /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", textColor: "neutral600", children: diff.newDisplay || "(already matching)" }) }),
3037
3197
  /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Td, { style: { textAlign: "right" }, children: [
3038
3198
  diff.status === "will_update" && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { backgroundColor: "success100", textColor: "success700", children: "✓ Will Update" }),
3039
3199
  diff.status === "unchanged" && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { backgroundColor: "neutral150", textColor: "neutral600", children: "= Unchanged" }),
3040
- diff.status === "will_skip" && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { backgroundColor: "warning100", textColor: "warning700", children: "⚠ Will Skip" })
3200
+ diff.status === "will_skip" && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { backgroundColor: "warning100", textColor: "warning700", children: "⚠ Will Skip" }),
3201
+ diff.status === "will_error" && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { backgroundColor: "danger100", textColor: "danger700", children: "✕ Error" })
3041
3202
  ] })
3042
- ] }, `${diff.uid}-${diff.documentId}`)) })
3203
+ ] }, `${diff.uid}-${diff.documentId}-${diff.attribute || "root"}-${idx}`)) })
3043
3204
  ] })
3044
3205
  }
3045
3206
  )
@@ -3067,7 +3228,7 @@ const BulkUpdatePreviewModal = ({
3067
3228
  onClose();
3068
3229
  onProceed();
3069
3230
  },
3070
- disabled: loading || !previewData || previewData.summary.total === 0,
3231
+ disabled: loading || !previewData || previewData.summary.total === 0 || isGridMode && previewData.summary.willUpdate === 0,
3071
3232
  children: [
3072
3233
  "Proceed to Execute (",
3073
3234
  previewData?.summary.willUpdate || 0,
@@ -3506,12 +3667,13 @@ const CheckerReviewModal = ({
3506
3667
  children: diff.oldDisplay || "(empty)"
3507
3668
  }
3508
3669
  ) }),
3509
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: diff.status === "will_create" ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", fontWeight: "bold", textColor: "success700", style: { wordBreak: "break-all" }, children: diff.newDisplay || "(new value)" }) : diff.status === "will_skip" ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "warning700", children: "— Skipped —" }) : diff.hasChange ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", fontWeight: "bold", textColor: "success700", style: { wordBreak: "break-all" }, children: diff.newDisplay || "(empty)" }) : /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", textColor: "neutral600", children: diff.newDisplay || "(matching)" }) }),
3670
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: diff.status === "will_create" ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", fontWeight: "bold", textColor: "success700", style: { wordBreak: "break-all" }, children: diff.newDisplay || "(new value)" }) : diff.status === "will_error" ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "danger700", fontWeight: "bold", children: diff.validationError || diff.message || "Validation error" }) : diff.status === "will_skip" ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "warning700", children: "— Skipped —" }) : diff.hasChange ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", fontWeight: "bold", textColor: "success700", style: { wordBreak: "break-all" }, children: diff.newDisplay || "(empty)" }) : /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", textColor: "neutral600", children: diff.newDisplay || "(matching)" }) }),
3510
3671
  /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Td, { style: { textAlign: "right" }, children: [
3511
3672
  diff.status === "will_create" && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { backgroundColor: "success100", textColor: "success700", children: "+ Will Create" }),
3512
3673
  diff.status === "will_update" && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { backgroundColor: "warning100", textColor: "warning700", children: "✎ Will Update" }),
3513
3674
  diff.status === "unchanged" && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { backgroundColor: "neutral150", textColor: "neutral600", children: "= Unchanged" }),
3514
- diff.status === "will_skip" && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { backgroundColor: "danger100", textColor: "danger700", children: "⚠ Will Skip" })
3675
+ diff.status === "will_skip" && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { backgroundColor: "warning100", textColor: "warning700", children: "⚠ Will Skip" }),
3676
+ diff.status === "will_error" && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { backgroundColor: "danger100", textColor: "danger700", children: "✕ Validation Error" })
3515
3677
  ] })
3516
3678
  ] }, `${diff.uid}-${diff.documentId}-${diff.attribute}-${idx}`)) })
3517
3679
  ] })
@@ -3589,14 +3751,19 @@ const CheckerReviewModal = ({
3589
3751
  }
3590
3752
  );
3591
3753
  };
3592
- function parseDynamicZonePath(path) {
3754
+ function formatComponentNameFriendly(compUid) {
3755
+ if (!compUid) return "Component";
3756
+ const name = compUid.includes(".") ? compUid.split(".")[1] : compUid;
3757
+ return name.split(/[-_]/).map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join(" ");
3758
+ }
3759
+ function parseAttrPathClient(path) {
3593
3760
  if (!path) return { cleanPath: "", rootKey: "", subPath: "" };
3594
- const bracketMatch = path.match(/^([^.[]+)\[([^\]]+)\]\.(.+)$/);
3761
+ const bracketMatch = path.match(/^([^.[]+)\[([^\]]+)\](?:\.(.+))?$/);
3595
3762
  if (bracketMatch) {
3596
3763
  const rootKey = bracketMatch[1];
3597
- const selector = bracketMatch[2];
3598
- const subPath = bracketMatch[3];
3599
- const cleanPath = `${rootKey}.${subPath}`;
3764
+ const selector = bracketMatch[2].trim();
3765
+ const subPath = bracketMatch[3] || "";
3766
+ const cleanPath = subPath ? `${rootKey}.${subPath}` : rootKey;
3600
3767
  if (/^\d+$/.test(selector)) {
3601
3768
  return { cleanPath, rootKey, subPath, targetIndex: parseInt(selector, 10) };
3602
3769
  }
@@ -3609,124 +3776,1408 @@ function parseDynamicZonePath(path) {
3609
3776
  subPath: parts.slice(1).join(".")
3610
3777
  };
3611
3778
  }
3612
- function formatComponentName(compUid) {
3613
- if (!compUid) return "Component";
3614
- const name = compUid.includes(".") ? compUid.split(".")[1] : compUid;
3615
- return name.split(/[-_]/).map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join(" ");
3779
+ function buildOccurrenceKey(segments) {
3780
+ if (!segments || segments.length === 0) return "__scalar__";
3781
+ return segments.map((seg) => {
3782
+ if (seg.index !== void 0) {
3783
+ return seg.componentId !== void 0 && seg.componentId !== null ? `${seg.key}[${seg.index}#${seg.componentId}]` : `${seg.key}[${seg.index}]`;
3784
+ }
3785
+ return seg.key;
3786
+ }).join(".");
3616
3787
  }
3617
- function getAllNestedValues(obj, path, availableAttributes) {
3618
- if (!obj || !path) return [];
3619
- const parsed = parseDynamicZonePath(path);
3620
- const parts = parsed.cleanPath.split(".");
3621
- const [head, ...tail] = parts;
3622
- const rootTarget = getPropertyValue(obj, head);
3623
- if (Array.isArray(rootTarget)) {
3624
- const results = [];
3625
- rootTarget.forEach((item, idx) => {
3626
- if (!item || typeof item !== "object") return;
3627
- if (parsed.targetIndex !== void 0 && idx !== parsed.targetIndex) return;
3628
- if (parsed.targetComponentUid && item.__component !== parsed.targetComponentUid) return;
3629
- const subPath = tail.join(".");
3630
- const scopedPath = item.__component ? `${head}[${item.__component}].${subPath}` : "";
3631
- const isSupported = availableAttributes ? availableAttributes.includes(scopedPath) : false;
3632
- const subVal = tail.length > 0 ? getNestedValue(item, subPath) : item;
3633
- if (subVal !== void 0 || isSupported) {
3634
- results.push({
3635
- index: idx,
3636
- componentUid: item.__component,
3637
- componentName: formatComponentName(item.__component),
3638
- value: subVal !== void 0 ? subVal : null,
3639
- path: `${head}[#${idx}${item.__component ? ` ${formatComponentName(item.__component)}` : ""}].${subPath}`
3640
- });
3788
+ function buildReadablePath(segments) {
3789
+ if (!segments || segments.length === 0) return "";
3790
+ return segments.map((seg) => {
3791
+ if (seg.index !== void 0) {
3792
+ const label = seg.componentUid ? ` ${formatComponentNameFriendly(seg.componentUid)}` : "";
3793
+ return `${seg.key}[#${seg.index}${label}]`;
3794
+ }
3795
+ return seg.key;
3796
+ }).join(".");
3797
+ }
3798
+ function getDirectProp(obj, key) {
3799
+ if (!obj || typeof obj !== "object") return void 0;
3800
+ if (obj[key] !== void 0) return obj[key];
3801
+ const camel = key.replace(/_([a-z0-9])/g, (_, l) => l.toUpperCase());
3802
+ if (obj[camel] !== void 0) return obj[camel];
3803
+ const snake = key.replace(/([A-Z])/g, "_$1").toLowerCase();
3804
+ if (obj[snake] !== void 0) return obj[snake];
3805
+ return void 0;
3806
+ }
3807
+ function resolveTailExistsOrValue(obj, parts) {
3808
+ let cur = obj;
3809
+ for (const p of parts) {
3810
+ if (cur === null || cur === void 0) return void 0;
3811
+ if (Array.isArray(cur)) {
3812
+ for (const item of cur) {
3813
+ const found = resolveTailExistsOrValue(item, parts.slice(parts.indexOf(p)));
3814
+ if (found !== void 0) return found;
3641
3815
  }
3642
- });
3643
- return results;
3816
+ return void 0;
3817
+ }
3818
+ cur = getDirectProp(cur, p);
3644
3819
  }
3645
- const singleVal = getNestedValue(obj, parsed.cleanPath);
3646
- if (singleVal !== void 0) {
3820
+ return cur;
3821
+ }
3822
+ function enumerateClientOccurrences(entry, attrPath, availableAttributes, attrMeta) {
3823
+ if (!entry || !attrPath) return [];
3824
+ const parsed = parseAttrPathClient(attrPath);
3825
+ const parts = parsed.cleanPath.split(".").filter(Boolean);
3826
+ if (parts.length === 0) return [];
3827
+ if (parts.length === 1 && !parsed.targetComponentUid && parsed.targetIndex === void 0) {
3828
+ const val = getDirectProp(entry, parts[0]);
3647
3829
  return [
3648
3830
  {
3831
+ occurrenceKey: "__scalar__",
3832
+ displayPath: parts[0],
3833
+ segments: [{ key: parts[0] }],
3834
+ value: val !== void 0 ? val : null,
3649
3835
  index: 0,
3650
- value: singleVal,
3651
- path: parsed.cleanPath
3836
+ isMissingIntermediate: false
3652
3837
  }
3653
3838
  ];
3654
3839
  }
3655
- return [];
3840
+ const results = [];
3841
+ function walk(currentVal, remainingParts, segments, missingIntermediate, firstArrayIndex, resolvedCompUid, resolvedCompId, isRootLevel) {
3842
+ if (remainingParts.length === 0) return;
3843
+ const [head, ...tail] = remainingParts;
3844
+ if (tail.length === 0) {
3845
+ const val = currentVal && typeof currentVal === "object" ? getDirectProp(currentVal, head) : void 0;
3846
+ const nextSegs = [...segments, { key: head }];
3847
+ results.push({
3848
+ occurrenceKey: buildOccurrenceKey(nextSegs),
3849
+ displayPath: buildReadablePath(nextSegs),
3850
+ segments: nextSegs,
3851
+ value: val !== void 0 ? val : null,
3852
+ componentUid: resolvedCompUid,
3853
+ componentName: resolvedCompUid ? formatComponentNameFriendly(resolvedCompUid) : void 0,
3854
+ componentId: resolvedCompId,
3855
+ index: firstArrayIndex ?? 0,
3856
+ isMissingIntermediate: missingIntermediate
3857
+ });
3858
+ return;
3859
+ }
3860
+ const nextVal = currentVal && typeof currentVal === "object" ? getDirectProp(currentVal, head) : void 0;
3861
+ const isExpectingRootArray = isRootLevel && (attrMeta?.rootType === "dynamiczone" || attrMeta?.rootRepeatable);
3862
+ if (Array.isArray(nextVal)) {
3863
+ const subPath = tail.join(".");
3864
+ nextVal.forEach((item, idx) => {
3865
+ if (!item || typeof item !== "object") return;
3866
+ if (isRootLevel && parsed.targetIndex !== void 0 && idx !== parsed.targetIndex) return;
3867
+ if (isRootLevel && parsed.targetComponentUid && item.__component !== parsed.targetComponentUid) return;
3868
+ if (item.__component && isRootLevel) {
3869
+ const scopedAttr = `${head}[${item.__component}].${subPath}`;
3870
+ const supportedBySchema = Array.isArray(availableAttributes) && availableAttributes.includes(scopedAttr);
3871
+ const presentInData = resolveTailExistsOrValue(item, tail) !== void 0;
3872
+ if (!supportedBySchema && !presentInData) {
3873
+ return;
3874
+ }
3875
+ }
3876
+ const seg2 = {
3877
+ key: head,
3878
+ index: idx,
3879
+ componentId: item.id,
3880
+ componentUid: item.__component || (isRootLevel ? attrMeta?.component : void 0)
3881
+ };
3882
+ walk(
3883
+ item,
3884
+ tail,
3885
+ [...segments, seg2],
3886
+ missingIntermediate,
3887
+ firstArrayIndex ?? idx,
3888
+ item.__component || resolvedCompUid,
3889
+ resolvedCompId ?? item.id,
3890
+ false
3891
+ );
3892
+ });
3893
+ return;
3894
+ }
3895
+ if (isExpectingRootArray) {
3896
+ return;
3897
+ }
3898
+ const isMissing = !nextVal || typeof nextVal !== "object";
3899
+ const seg = {
3900
+ key: head,
3901
+ componentId: !isMissing ? nextVal.id : void 0,
3902
+ componentUid: !isMissing && nextVal.__component ? nextVal.__component : void 0
3903
+ };
3904
+ walk(
3905
+ isMissing ? void 0 : nextVal,
3906
+ tail,
3907
+ [...segments, seg],
3908
+ missingIntermediate || isMissing,
3909
+ firstArrayIndex,
3910
+ resolvedCompUid,
3911
+ resolvedCompId,
3912
+ false
3913
+ );
3914
+ }
3915
+ walk(entry, parts, [], false, void 0, void 0, void 0, true);
3916
+ return results;
3656
3917
  }
3657
- function getPropertyValue(target, key) {
3658
- if (!target || typeof target !== "object" || !key) return void 0;
3659
- if (target[key] !== void 0 && target[key] !== null) return target[key];
3660
- const camelKey = key.replace(/_([a-z0-9])/g, (_, letter) => letter.toUpperCase());
3661
- if (target[camelKey] !== void 0 && target[camelKey] !== null) return target[camelKey];
3662
- const snakeKey = key.replace(/([A-Z])/g, "_$1").toLowerCase();
3663
- if (target[snakeKey] !== void 0 && target[snakeKey] !== null) return target[snakeKey];
3664
- const lowerKey = key.toLowerCase();
3665
- const lowerNoUnderscore = lowerKey.replace(/_/g, "");
3666
- const matchedKey = Object.keys(target).find((k) => {
3667
- const kLower = k.toLowerCase();
3668
- return kLower === lowerKey || kLower.replace(/_/g, "") === lowerNoUnderscore;
3669
- });
3670
- if (matchedKey && target[matchedKey] !== void 0 && target[matchedKey] !== null) {
3671
- return target[matchedKey];
3918
+ function normalizeDisplayCompareValue(v) {
3919
+ if (v === void 0 || v === null) return null;
3920
+ if (typeof v === "object" && v.isRelation) return v;
3921
+ return v;
3922
+ }
3923
+ function areClientValuesEqual(a, b) {
3924
+ const na = normalizeDisplayCompareValue(a);
3925
+ const nb = normalizeDisplayCompareValue(b);
3926
+ if (na === nb) return true;
3927
+ if (na === null || nb === null) return na === nb;
3928
+ if (typeof na === "object" || typeof nb === "object") {
3929
+ try {
3930
+ return JSON.stringify(na) === JSON.stringify(nb);
3931
+ } catch {
3932
+ return false;
3933
+ }
3672
3934
  }
3673
- if (key in target) return target[key];
3674
- if (camelKey in target) return target[camelKey];
3675
- if (snakeKey in target) return target[snakeKey];
3676
- return void 0;
3935
+ return String(na) === String(nb);
3677
3936
  }
3678
- function getNestedValue(obj, path) {
3679
- if (!obj || !path) return void 0;
3680
- const parsed = parseDynamicZonePath(path);
3681
- const parts = parsed.cleanPath.split(".");
3682
- function extract(current, remainingParts) {
3683
- if (current === void 0 || current === null) return void 0;
3684
- if (remainingParts.length === 0) return current;
3685
- const [head, ...tail] = remainingParts;
3686
- if (Array.isArray(current)) {
3687
- if (/^\d+$/.test(head)) {
3688
- return extract(current[parseInt(head, 10)], tail);
3689
- }
3690
- for (let idx = 0; idx < current.length; idx++) {
3691
- const item = current[idx];
3692
- if (parsed.targetIndex !== void 0 && idx !== parsed.targetIndex) continue;
3693
- if (parsed.targetComponentUid && item?.__component !== parsed.targetComponentUid) continue;
3694
- const found = extract(getPropertyValue(item, head), tail);
3695
- if (found !== void 0 && found !== null) return found;
3937
+ function extractRelationEditCommand(rawVal, currentDisplayVal, isMulti = false) {
3938
+ if (rawVal && typeof rawVal === "object" && !Array.isArray(rawVal) && rawVal.mode) {
3939
+ return {
3940
+ mode: rawVal.mode,
3941
+ documentIds: Array.isArray(rawVal.documentIds) ? rawVal.documentIds : rawVal.documentId ? [rawVal.documentId] : [],
3942
+ label: rawVal.label || ""
3943
+ };
3944
+ }
3945
+ if (Array.isArray(rawVal)) {
3946
+ return {
3947
+ mode: "set",
3948
+ documentIds: rawVal.map((r) => r?.documentId).filter(Boolean),
3949
+ label: rawVal.map((r) => r?.name || r?.title || r?.email || r?.documentId).filter(Boolean).join(", ")
3950
+ };
3951
+ }
3952
+ if (rawVal && typeof rawVal === "object" && rawVal.documentId) {
3953
+ return {
3954
+ mode: "set",
3955
+ documentIds: [rawVal.documentId],
3956
+ label: rawVal.name || rawVal.title || rawVal.email || rawVal.documentId
3957
+ };
3958
+ }
3959
+ if (typeof rawVal === "string") {
3960
+ try {
3961
+ const parsed = JSON.parse(rawVal);
3962
+ if (parsed && typeof parsed === "object" && parsed.mode) {
3963
+ return {
3964
+ mode: parsed.mode,
3965
+ documentIds: Array.isArray(parsed.documentIds) ? parsed.documentIds : [],
3966
+ label: parsed.label || ""
3967
+ };
3696
3968
  }
3697
- return void 0;
3969
+ } catch {
3698
3970
  }
3699
- return extract(getPropertyValue(current, head), tail);
3700
3971
  }
3701
- return extract(obj, parts);
3972
+ if (currentDisplayVal) {
3973
+ return extractRelationEditCommand(currentDisplayVal, void 0, isMulti);
3974
+ }
3975
+ return { mode: "clear", documentIds: [], label: "" };
3702
3976
  }
3703
- function getAvailableColumnsForCollection(col, selectedAttribute, searchAttribute) {
3704
- const cols = [
3705
- {
3706
- key: "select",
3707
- label: "Select",
3708
- isPermanent: true,
3709
- defaultVisible: true
3710
- },
3711
- {
3712
- key: "identifier",
3713
- label: "Identifier",
3714
- sortable: !col.isSingleType,
3715
- defaultVisible: true
3977
+ function validateClientFieldValue(value, attrMeta) {
3978
+ if (!attrMeta) return null;
3979
+ const type = String(attrMeta.type || "").toLowerCase();
3980
+ const isEmpty = value === null || value === void 0 || value === "";
3981
+ if (attrMeta.required && isEmpty && type !== "boolean") {
3982
+ return "Required field";
3983
+ }
3984
+ if (attrMeta.required && type === "boolean" && (value === null || value === void 0 || value === "")) {
3985
+ return "Required boolean";
3986
+ }
3987
+ if (isEmpty) return null;
3988
+ switch (type) {
3989
+ case "integer":
3990
+ case "biginteger": {
3991
+ const s = String(value).trim();
3992
+ if (!/^-?\d+$/.test(s)) return "Must be a valid integer";
3993
+ if (type === "integer") {
3994
+ const n = Number(s);
3995
+ if (!Number.isSafeInteger(n)) return "Integer out of range";
3996
+ if (typeof attrMeta.min === "number" && n < attrMeta.min) return `Min ${attrMeta.min}`;
3997
+ if (typeof attrMeta.max === "number" && n > attrMeta.max) return `Max ${attrMeta.max}`;
3998
+ }
3999
+ return null;
3716
4000
  }
3717
- ];
3718
- const candidateAttrs = col.attributes || [];
3719
- candidateAttrs.forEach((attr) => {
3720
- if (attr === "name" || attr === "title" || attr === selectedAttribute || searchAttribute && attr === searchAttribute) {
3721
- return;
4001
+ case "float":
4002
+ case "decimal": {
4003
+ const s = String(value).trim();
4004
+ if (!/^-?\d+(\.\d+)?$/.test(s)) return "Must be a valid number";
4005
+ const n = Number(s);
4006
+ if (typeof attrMeta.min === "number" && n < attrMeta.min) return `Min ${attrMeta.min}`;
4007
+ if (typeof attrMeta.max === "number" && n > attrMeta.max) return `Max ${attrMeta.max}`;
4008
+ return null;
3722
4009
  }
3723
- let formattedLabel = attr;
3724
- if (attr === "updated_at" || attr === "updatedAt") {
3725
- formattedLabel = "Updated At";
3726
- } else if (attr === "created_at" || attr === "createdAt") {
3727
- formattedLabel = "Created At";
3728
- } else if (attr === "published_at" || attr === "publishedAt") {
3729
- formattedLabel = "Published At";
4010
+ case "boolean": {
4011
+ if (typeof value === "boolean") return null;
4012
+ const lower = String(value).trim().toLowerCase();
4013
+ if (!["true", "false", "1", "0"].includes(lower)) return "Must be true or false";
4014
+ return null;
4015
+ }
4016
+ case "enumeration": {
4017
+ if (Array.isArray(attrMeta.enumOptions) && !attrMeta.enumOptions.includes(String(value))) {
4018
+ return `Must be one of: ${attrMeta.enumOptions.join(", ")}`;
4019
+ }
4020
+ return null;
4021
+ }
4022
+ case "email": {
4023
+ const s = String(value).trim();
4024
+ if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(s)) return "Invalid email";
4025
+ return null;
4026
+ }
4027
+ case "uid": {
4028
+ const s = String(value).trim();
4029
+ if (!/^[A-Za-z0-9\-_.~]*$/.test(s)) return "Invalid UID format";
4030
+ return null;
4031
+ }
4032
+ case "json":
4033
+ case "blocks": {
4034
+ if (typeof value === "string") {
4035
+ try {
4036
+ const parsed = JSON.parse(value);
4037
+ if (type === "blocks" && parsed !== null && !Array.isArray(parsed)) {
4038
+ return "Blocks must be a JSON array";
4039
+ }
4040
+ } catch (err) {
4041
+ return `Invalid JSON: ${err.message}`;
4042
+ }
4043
+ } else if (type === "blocks" && !Array.isArray(value)) {
4044
+ return "Blocks must be an array";
4045
+ }
4046
+ return null;
4047
+ }
4048
+ case "date":
4049
+ case "datetime": {
4050
+ const d = new Date(String(value).trim());
4051
+ if (isNaN(d.getTime())) return "Invalid date/datetime";
4052
+ return null;
4053
+ }
4054
+ case "time": {
4055
+ if (!/^\d{2}:\d{2}(:\d{2}(\.\d{1,3})?)?$/.test(String(value).trim())) {
4056
+ return "Invalid time (HH:mm or HH:mm:ss)";
4057
+ }
4058
+ return null;
4059
+ }
4060
+ default: {
4061
+ const str = typeof value === "object" ? JSON.stringify(value) : String(value);
4062
+ if (typeof attrMeta.minLength === "number" && str.length < attrMeta.minLength) {
4063
+ return `Min length ${attrMeta.minLength}`;
4064
+ }
4065
+ if (typeof attrMeta.maxLength === "number" && str.length > attrMeta.maxLength) {
4066
+ return `Max length ${attrMeta.maxLength}`;
4067
+ }
4068
+ if (attrMeta.regex) {
4069
+ try {
4070
+ if (!new RegExp(attrMeta.regex).test(str)) return `Must match /${attrMeta.regex}/`;
4071
+ } catch {
4072
+ }
4073
+ }
4074
+ return null;
4075
+ }
4076
+ }
4077
+ }
4078
+ function cleanRuleKey(str) {
4079
+ return (str || "").replace(/[-_]/g, "").toLowerCase().trim();
4080
+ }
4081
+ function matchesFieldRulePath(attrPath, targetField) {
4082
+ if (!attrPath || !targetField) return false;
4083
+ const cleanAttr = parseAttrPathClient(attrPath).cleanPath;
4084
+ const parts = cleanAttr.split(".").map(cleanRuleKey).filter(Boolean);
4085
+ const leaf = parts[parts.length - 1] || "";
4086
+ const targetClean = cleanRuleKey(targetField.replace(/^api::/i, ""));
4087
+ if (leaf === targetClean || cleanRuleKey(cleanAttr) === targetClean) return true;
4088
+ const tSegs = targetField.replace(/^api::/i, "").split(".").map(cleanRuleKey).filter(Boolean);
4089
+ if (tSegs.length === 1) return leaf === tSegs[0];
4090
+ return tSegs.every((t) => t === "*" || parts.includes(t));
4091
+ }
4092
+ function computeRecordQuotaUsage(entry, attrPath, excludeOccurrenceKey, recordEdits, colAttributes, attrMeta, validationRules) {
4093
+ const occs = enumerateClientOccurrences(entry, attrPath, colAttributes, attrMeta);
4094
+ const usageCounts = {};
4095
+ for (const occ of occs) {
4096
+ if (occ.occurrenceKey === excludeOccurrenceKey) continue;
4097
+ const edited = recordEdits?.occurrences?.[occ.occurrenceKey];
4098
+ const effectiveVal = edited ? edited.value : occ.value;
4099
+ if (effectiveVal !== void 0 && effectiveVal !== null && String(effectiveVal).trim() !== "") {
4100
+ const k = String(effectiveVal).toLowerCase().trim();
4101
+ usageCounts[k] = (usageCounts[k] || 0) + 1;
4102
+ }
4103
+ }
4104
+ const quotas = {};
4105
+ if (attrMeta?.options?.items) {
4106
+ for (const item of attrMeta.options.items) {
4107
+ if (typeof item.maxAllowed === "number" && item.maxAllowed > 0) {
4108
+ quotas[item.value.toLowerCase().trim()] = item.maxAllowed;
4109
+ }
4110
+ }
4111
+ }
4112
+ if (attrMeta?.options?.quotas) {
4113
+ for (const [k, v] of Object.entries(attrMeta.options.quotas)) {
4114
+ if (typeof v === "number" && v > 0) quotas[k.toLowerCase().trim()] = v;
4115
+ }
4116
+ }
4117
+ for (const rule of validationRules || []) {
4118
+ if (!rule.enabled) continue;
4119
+ if (rule.targetField && !matchesFieldRulePath(attrPath, rule.targetField)) continue;
4120
+ for (const [k, v] of Object.entries(rule.quotas || {})) {
4121
+ if (typeof v === "number" && v > 0) quotas[k.toLowerCase().trim()] = v;
4122
+ }
4123
+ }
4124
+ return { usageCounts, quotas };
4125
+ }
4126
+ function serializeGridTargets(gridEdits, selectedEntries, collectionPages = {}, attrMeta) {
4127
+ const targets = [];
4128
+ let totalEditCount = 0;
4129
+ let hasValidationErrors = false;
4130
+ for (const [key, rec] of Object.entries(gridEdits)) {
4131
+ if (!selectedEntries[key]) continue;
4132
+ const occEntries = Object.values(rec.occurrences || {});
4133
+ if (occEntries.length === 0) continue;
4134
+ for (const occ of occEntries) {
4135
+ if (occ.validationError) {
4136
+ hasValidationErrors = true;
4137
+ }
4138
+ }
4139
+ const colPage = collectionPages[rec.uid];
4140
+ const cachedEntry = colPage?.entries?.find((e) => e.documentId === rec.documentId);
4141
+ const targetObj = {
4142
+ uid: rec.uid,
4143
+ documentId: rec.documentId,
4144
+ status: cachedEntry?.status ?? rec.status,
4145
+ publishedAt: cachedEntry?.publishedAt ?? rec.publishedAt,
4146
+ locale: cachedEntry?.locale ?? rec.locale
4147
+ };
4148
+ const isScalarOnly = occEntries.length === 1 && occEntries[0].occurrenceKey === "__scalar__" && !attrMeta?.rootType;
4149
+ if (isScalarOnly) {
4150
+ targetObj.overrideValue = occEntries[0].value;
4151
+ totalEditCount += 1;
4152
+ } else {
4153
+ targetObj.occurrenceUpdates = occEntries.map((occ) => ({
4154
+ occurrenceKey: occ.occurrenceKey,
4155
+ segments: occ.segments,
4156
+ dynamicZoneIndex: occ.segments?.[0]?.index,
4157
+ componentId: occ.segments?.find((s) => s.componentId !== void 0)?.componentId,
4158
+ componentUid: occ.segments?.find((s) => s.componentUid)?.componentUid,
4159
+ value: occ.value
4160
+ }));
4161
+ totalEditCount += occEntries.length;
4162
+ }
4163
+ targets.push(targetObj);
4164
+ }
4165
+ return { targets, totalEditCount, hasValidationErrors };
4166
+ }
4167
+ const DEFAULT_HEADING_ITEMS = [
4168
+ { value: "h1", label: "H1 - Main Page Title", maxAllowed: 1 },
4169
+ { value: "h2", label: "H2 - Primary Section Heading", maxAllowed: 3 },
4170
+ { value: "h3", label: "H3 - Sub-section Heading", maxAllowed: null },
4171
+ { value: "h4", label: "H4 - Component Title", maxAllowed: null },
4172
+ { value: "h5", label: "H5 - Card / Item Heading", maxAllowed: null },
4173
+ { value: "h6", label: "H6 - Minor Heading", maxAllowed: null }
4174
+ ];
4175
+ function toTextInputString(val, type) {
4176
+ if (val === null || val === void 0) return "";
4177
+ if (type === "date" && typeof val === "string") {
4178
+ return val.slice(0, 10);
4179
+ }
4180
+ if (type === "datetime" && typeof val === "string") {
4181
+ const d = new Date(val);
4182
+ if (!isNaN(d.getTime())) {
4183
+ const pad = (n) => String(n).padStart(2, "0");
4184
+ return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}T${pad(d.getHours())}:${pad(d.getMinutes())}`;
4185
+ }
4186
+ return val.slice(0, 16);
4187
+ }
4188
+ if (type === "time" && typeof val === "string") {
4189
+ return val.slice(0, 8);
4190
+ }
4191
+ if (typeof val === "object") {
4192
+ try {
4193
+ return JSON.stringify(val);
4194
+ } catch {
4195
+ return String(val);
4196
+ }
4197
+ }
4198
+ return String(val);
4199
+ }
4200
+ const GridCellEditor = React__default.default.memo(
4201
+ ({
4202
+ entry,
4203
+ attribute,
4204
+ occurrence,
4205
+ attrMeta,
4206
+ editedValue,
4207
+ isDirty,
4208
+ validationError,
4209
+ relationOptions = [],
4210
+ relationOptionsLoading = false,
4211
+ relationIsMulti = false,
4212
+ validationRules = [],
4213
+ recordEdits,
4214
+ colAttributes,
4215
+ compact = false,
4216
+ onCommit,
4217
+ onReset
4218
+ }) => {
4219
+ const { get } = admin.useFetchClient();
4220
+ const fieldType = String(attrMeta?.type || "").toLowerCase();
4221
+ const isScopedSelect = attrMeta?.customField === "plugin::bulk-updater.scoped-select" || attrMeta?.customField === "global::scoped-select";
4222
+ const isRelation = Boolean(attrMeta?.isRelation || fieldType === "relation");
4223
+ const isMultiRelation = isRelation && Boolean(relationIsMulti || ["oneToMany", "manyToMany"].includes(attrMeta?.relationType || ""));
4224
+ const effectiveValue = isDirty ? editedValue : occurrence.value;
4225
+ const [localText, setLocalText] = React.useState(() => toTextInputString(effectiveValue, fieldType));
4226
+ const [showRichModal, setShowRichModal] = React.useState(false);
4227
+ const [richDraft, setRichDraft] = React.useState("");
4228
+ const [richError, setRichError] = React.useState(null);
4229
+ const [showMultiRelModal, setShowMultiRelModal] = React.useState(false);
4230
+ const [multiRelSelected, setMultiRelSelected] = React.useState([]);
4231
+ const [multiRelMode, setMultiRelMode] = React.useState("set");
4232
+ const [multiRelSearch, setMultiRelSearch] = React.useState("");
4233
+ const [showMediaModal, setShowMediaModal] = React.useState(false);
4234
+ const [mediaOptions, setMediaOptions] = React.useState([]);
4235
+ const [mediaSearch, setMediaSearch] = React.useState("");
4236
+ const [mediaLoading, setMediaLoading] = React.useState(false);
4237
+ const [selectedMediaIds, setSelectedMediaIds] = React.useState([]);
4238
+ React.useEffect(() => {
4239
+ setLocalText(toTextInputString(effectiveValue, fieldType));
4240
+ }, [effectiveValue, fieldType, occurrence.occurrenceKey]);
4241
+ const commitTypedValue = (rawVal) => {
4242
+ if (areClientValuesEqual(rawVal, occurrence.value)) {
4243
+ onReset(occurrence.occurrenceKey);
4244
+ return;
4245
+ }
4246
+ const err = validateClientFieldValue(rawVal, attrMeta);
4247
+ onCommit(occurrence, rawVal, err);
4248
+ };
4249
+ const loadMediaLibrary = async (query = "") => {
4250
+ try {
4251
+ setMediaLoading(true);
4252
+ const res = await get(`/bulk-updater/media-options?search=${encodeURIComponent(query)}`);
4253
+ if (res.data?.success && Array.isArray(res.data.options)) {
4254
+ setMediaOptions(res.data.options);
4255
+ }
4256
+ } catch {
4257
+ setMediaOptions([]);
4258
+ } finally {
4259
+ setMediaLoading(false);
4260
+ }
4261
+ };
4262
+ const quotaContext = React.useMemo(() => {
4263
+ if (!isScopedSelect) return null;
4264
+ return computeRecordQuotaUsage(
4265
+ entry,
4266
+ attribute,
4267
+ occurrence.occurrenceKey,
4268
+ recordEdits,
4269
+ colAttributes,
4270
+ attrMeta,
4271
+ validationRules
4272
+ );
4273
+ }, [isScopedSelect, entry, attribute, occurrence.occurrenceKey, recordEdits, colAttributes, attrMeta, validationRules]);
4274
+ const scopedItems = React.useMemo(() => {
4275
+ if (!isScopedSelect) return [];
4276
+ const base = attrMeta?.options?.items && attrMeta.options.items.length > 0 ? attrMeta.options.items : DEFAULT_HEADING_ITEMS;
4277
+ const quotas = quotaContext?.quotas || {};
4278
+ return base.map((it) => {
4279
+ const key = it.value.toLowerCase().trim();
4280
+ const maxAllowed = typeof quotas[key] === "number" ? quotas[key] : it.maxAllowed;
4281
+ const usedBySiblings = quotaContext?.usageCounts?.[key] || 0;
4282
+ return {
4283
+ ...it,
4284
+ maxAllowed,
4285
+ usedBySiblings,
4286
+ atLimit: typeof maxAllowed === "number" && maxAllowed > 0 && usedBySiblings >= maxAllowed
4287
+ };
4288
+ });
4289
+ }, [isScopedSelect, attrMeta, quotaContext]);
4290
+ const wrapperStyle = {
4291
+ borderLeft: isDirty ? "3px solid #4945ff" : "3px solid transparent",
4292
+ paddingLeft: 6,
4293
+ backgroundColor: validationError ? "rgba(208, 43, 32, 0.06)" : isDirty ? "rgba(73, 69, 255, 0.05)" : "transparent",
4294
+ borderRadius: 4,
4295
+ minWidth: compact ? 180 : 210,
4296
+ maxWidth: 320
4297
+ };
4298
+ const renderResetBtn = () => isDirty ? /* @__PURE__ */ jsxRuntime.jsx(
4299
+ designSystem.Button,
4300
+ {
4301
+ variant: "ghost",
4302
+ size: "S",
4303
+ onClick: () => onReset(occurrence.occurrenceKey),
4304
+ title: "Revert this cell back to original database value",
4305
+ style: { padding: "4px 6px", minWidth: 28, height: 28 },
4306
+ children: /* @__PURE__ */ jsxRuntime.jsx(icons.ArrowClockwise, {})
4307
+ }
4308
+ ) : null;
4309
+ if (isScopedSelect) {
4310
+ const currentValStr = effectiveValue !== null && effectiveValue !== void 0 ? String(effectiveValue) : "__clear__";
4311
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { style: wrapperStyle, children: [
4312
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 1, alignItems: "center", children: [
4313
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { style: { flex: 1, minWidth: 145 }, children: /* @__PURE__ */ jsxRuntime.jsxs(
4314
+ designSystem.SingleSelect,
4315
+ {
4316
+ size: "S",
4317
+ "aria-label": `Edit ${occurrence.displayPath}`,
4318
+ value: currentValStr,
4319
+ onChange: (val) => {
4320
+ const s = String(val);
4321
+ commitTypedValue(s === "__clear__" ? null : s);
4322
+ },
4323
+ children: [
4324
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "__clear__", children: "-- Unset --" }),
4325
+ scopedItems.map((it) => {
4326
+ const isCurrentlySelected = currentValStr.toLowerCase() === it.value.toLowerCase();
4327
+ const quotaNote = typeof it.maxAllowed === "number" && it.maxAllowed > 0 ? ` (${it.usedBySiblings + (isCurrentlySelected ? 1 : 0)}/${it.maxAllowed})` : "";
4328
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.SingleSelectOption, { value: it.value, children: [
4329
+ it.label,
4330
+ quotaNote,
4331
+ it.atLimit && !isCurrentlySelected ? " [QUOTA FULL]" : ""
4332
+ ] }, it.value);
4333
+ })
4334
+ ]
4335
+ }
4336
+ ) }),
4337
+ renderResetBtn()
4338
+ ] }),
4339
+ validationError && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "danger700", display: "block", style: { fontSize: "0.7rem", marginTop: 2 }, children: validationError })
4340
+ ] });
4341
+ }
4342
+ if (fieldType === "enumeration" && Array.isArray(attrMeta?.enumOptions)) {
4343
+ const currentValStr = effectiveValue !== null && effectiveValue !== void 0 && effectiveValue !== "" ? String(effectiveValue) : "__clear__";
4344
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { style: wrapperStyle, children: [
4345
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 1, alignItems: "center", children: [
4346
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { style: { flex: 1, minWidth: 145 }, children: /* @__PURE__ */ jsxRuntime.jsxs(
4347
+ designSystem.SingleSelect,
4348
+ {
4349
+ size: "S",
4350
+ "aria-label": `Edit ${occurrence.displayPath}`,
4351
+ value: currentValStr,
4352
+ onChange: (val) => {
4353
+ const s = String(val);
4354
+ commitTypedValue(s === "__clear__" ? null : s);
4355
+ },
4356
+ children: [
4357
+ !attrMeta.required && /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "__clear__", children: "-- Clear (null) --" }),
4358
+ attrMeta.enumOptions.map((opt) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: opt, children: opt }, opt))
4359
+ ]
4360
+ }
4361
+ ) }),
4362
+ renderResetBtn()
4363
+ ] }),
4364
+ validationError && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "danger700", display: "block", style: { fontSize: "0.7rem" }, children: validationError })
4365
+ ] });
4366
+ }
4367
+ if (fieldType === "boolean") {
4368
+ const strVal = effectiveValue === true ? "true" : effectiveValue === false ? "false" : "__unset__";
4369
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { style: wrapperStyle, children: [
4370
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 1, alignItems: "center", children: [
4371
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { style: { flex: 1, minWidth: 120 }, children: /* @__PURE__ */ jsxRuntime.jsxs(
4372
+ designSystem.SingleSelect,
4373
+ {
4374
+ size: "S",
4375
+ "aria-label": `Edit ${occurrence.displayPath}`,
4376
+ value: strVal,
4377
+ onChange: (val) => {
4378
+ const s = String(val);
4379
+ commitTypedValue(s === "true" ? true : s === "false" ? false : null);
4380
+ },
4381
+ children: [
4382
+ !attrMeta?.required && /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "__unset__", children: "-- Unset --" }),
4383
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "true", children: "true" }),
4384
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "false", children: "false" })
4385
+ ]
4386
+ }
4387
+ ) }),
4388
+ renderResetBtn()
4389
+ ] }),
4390
+ validationError && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "danger700", display: "block", style: { fontSize: "0.7rem" }, children: validationError })
4391
+ ] });
4392
+ }
4393
+ if (isRelation) {
4394
+ const cmd = extractRelationEditCommand(effectiveValue, occurrence.value, isMultiRelation);
4395
+ if (!isMultiRelation) {
4396
+ const selectedDocId = cmd.mode === "clear" ? "__clear__" : cmd.documentIds[0] || "__clear__";
4397
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { style: wrapperStyle, children: [
4398
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 1, alignItems: "center", children: [
4399
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { style: { flex: 1, minWidth: 165 }, children: /* @__PURE__ */ jsxRuntime.jsxs(
4400
+ designSystem.Combobox,
4401
+ {
4402
+ autocomplete: { type: "list", filter: "contains" },
4403
+ placeholder: relationOptionsLoading ? "Loading..." : "Pick relation...",
4404
+ value: selectedDocId,
4405
+ onChange: (val) => {
4406
+ const docId = val ? String(val) : "__clear__";
4407
+ if (docId === "__clear__") {
4408
+ commitTypedValue({ mode: "clear", documentIds: [], label: "(cleared / unlinked)" });
4409
+ } else {
4410
+ const opt = relationOptions.find((o) => o.documentId === docId);
4411
+ commitTypedValue({ mode: "set", documentIds: [docId], label: opt?.label || docId });
4412
+ }
4413
+ },
4414
+ children: [
4415
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.ComboboxOption, { value: "__clear__", textValue: "Clear / Unlink Relation", children: "-- Clear / Unlink --" }),
4416
+ relationOptions.map((opt) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.ComboboxOption, { value: opt.documentId, textValue: opt.label, children: opt.label }, opt.documentId))
4417
+ ]
4418
+ }
4419
+ ) }),
4420
+ renderResetBtn()
4421
+ ] }),
4422
+ validationError && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "danger700", display: "block", style: { fontSize: "0.7rem" }, children: validationError })
4423
+ ] });
4424
+ }
4425
+ const displaySummary = cmd.mode === "clear" ? "(cleared / empty)" : cmd.label || (cmd.documentIds.length > 0 ? `${cmd.documentIds.length} linked (${cmd.mode})` : "(unlinked)");
4426
+ const filteredRelOpts = relationOptions.filter(
4427
+ (o) => !multiRelSearch.trim() || o.label.toLowerCase().includes(multiRelSearch.toLowerCase())
4428
+ );
4429
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { style: wrapperStyle, children: [
4430
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 1, alignItems: "center", children: [
4431
+ /* @__PURE__ */ jsxRuntime.jsx(
4432
+ designSystem.Button,
4433
+ {
4434
+ variant: "tertiary",
4435
+ size: "S",
4436
+ onClick: () => {
4437
+ setMultiRelSelected(cmd.documentIds || []);
4438
+ setMultiRelMode(cmd.mode === "clear" && (cmd.documentIds || []).length === 0 ? "set" : cmd.mode);
4439
+ setMultiRelSearch("");
4440
+ setShowMultiRelModal(true);
4441
+ },
4442
+ style: { maxWidth: 230, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" },
4443
+ children: displaySummary
4444
+ }
4445
+ ),
4446
+ renderResetBtn()
4447
+ ] }),
4448
+ showMultiRelModal && /* @__PURE__ */ jsxRuntime.jsx(
4449
+ "div",
4450
+ {
4451
+ style: {
4452
+ position: "fixed",
4453
+ inset: 0,
4454
+ backgroundColor: "rgba(20, 20, 30, 0.55)",
4455
+ zIndex: 9999,
4456
+ display: "flex",
4457
+ alignItems: "center",
4458
+ justifyContent: "center",
4459
+ padding: 16
4460
+ },
4461
+ onClick: () => setShowMultiRelModal(false),
4462
+ children: /* @__PURE__ */ jsxRuntime.jsxs(
4463
+ designSystem.Box,
4464
+ {
4465
+ padding: 5,
4466
+ background: "neutral0",
4467
+ hasRadius: true,
4468
+ shadow: "popupShadow",
4469
+ style: { width: "92%", maxWidth: 520, maxHeight: "80vh", display: "flex", flexDirection: "column" },
4470
+ onClick: (e) => e.stopPropagation(),
4471
+ children: [
4472
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { variant: "delta", fontWeight: "bold", marginBottom: 2, children: [
4473
+ "Edit Multi-Relation: ",
4474
+ occurrence.displayPath
4475
+ ] }),
4476
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, marginBottom: 3, alignItems: "center", children: [
4477
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { style: { width: 180 }, children: /* @__PURE__ */ jsxRuntime.jsxs(
4478
+ designSystem.SingleSelect,
4479
+ {
4480
+ label: "Operation",
4481
+ value: multiRelMode,
4482
+ onChange: (v) => setMultiRelMode(String(v)),
4483
+ children: [
4484
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "set", children: "Set / Replace All" }),
4485
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "connect", children: "Add / Connect" }),
4486
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "disconnect", children: "Remove / Disconnect" }),
4487
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "clear", children: "Clear All" })
4488
+ ]
4489
+ }
4490
+ ) }),
4491
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { style: { flex: 1 }, children: /* @__PURE__ */ jsxRuntime.jsx(
4492
+ designSystem.TextInput,
4493
+ {
4494
+ label: "Filter items",
4495
+ placeholder: "Search relations...",
4496
+ value: multiRelSearch,
4497
+ onChange: (e) => setMultiRelSearch(e.target.value)
4498
+ }
4499
+ ) })
4500
+ ] }),
4501
+ multiRelMode !== "clear" && /* @__PURE__ */ jsxRuntime.jsx(
4502
+ designSystem.Box,
4503
+ {
4504
+ padding: 2,
4505
+ hasRadius: true,
4506
+ style: { border: "1px solid #eaeaef", overflowY: "auto", maxHeight: 280, marginBottom: 16 },
4507
+ children: filteredRelOpts.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: "No target entities found." }) : filteredRelOpts.map((opt) => {
4508
+ const checked = multiRelSelected.includes(opt.documentId);
4509
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { padding: 1, children: /* @__PURE__ */ jsxRuntime.jsx(
4510
+ designSystem.Checkbox,
4511
+ {
4512
+ checked,
4513
+ onCheckedChange: (isChecked) => {
4514
+ setMultiRelSelected(
4515
+ (prev) => isChecked ? [...prev, opt.documentId] : prev.filter((id) => id !== opt.documentId)
4516
+ );
4517
+ },
4518
+ children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", children: opt.label })
4519
+ }
4520
+ ) }, opt.documentId);
4521
+ })
4522
+ }
4523
+ ),
4524
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "flex-end", gap: 2, children: [
4525
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "tertiary", onClick: () => setShowMultiRelModal(false), children: "Cancel" }),
4526
+ /* @__PURE__ */ jsxRuntime.jsx(
4527
+ designSystem.Button,
4528
+ {
4529
+ variant: "default",
4530
+ startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Check, {}),
4531
+ onClick: () => {
4532
+ if (multiRelMode === "clear") {
4533
+ commitTypedValue({ mode: "clear", documentIds: [], label: "(cleared / unlinked)" });
4534
+ } else {
4535
+ const labels = relationOptions.filter((o) => multiRelSelected.includes(o.documentId)).map((o) => o.label).join(", ");
4536
+ commitTypedValue({
4537
+ mode: multiRelMode,
4538
+ documentIds: multiRelSelected,
4539
+ label: labels || `${multiRelSelected.length} selected`
4540
+ });
4541
+ }
4542
+ setShowMultiRelModal(false);
4543
+ },
4544
+ children: "Apply Relation Edit"
4545
+ }
4546
+ )
4547
+ ] })
4548
+ ]
4549
+ }
4550
+ )
4551
+ }
4552
+ )
4553
+ ] });
4554
+ }
4555
+ if (fieldType === "media") {
4556
+ const isMultiMedia = Boolean(attrMeta?.multiple);
4557
+ const currentIds = Array.isArray(effectiveValue) ? effectiveValue.map((v) => typeof v === "object" ? Number(v?.id) : Number(v)).filter((n) => !isNaN(n)) : typeof effectiveValue === "object" && effectiveValue?.id ? [Number(effectiveValue.id)] : typeof effectiveValue === "number" ? [effectiveValue] : [];
4558
+ const mediaSummary = currentIds.length === 0 ? "(no media — pick)" : Array.isArray(effectiveValue) ? `${currentIds.length} asset(s)` : effectiveValue?.name ? `${effectiveValue.name} (#${currentIds[0]})` : `Media #${currentIds[0]}`;
4559
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { style: wrapperStyle, children: [
4560
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 1, alignItems: "center", children: [
4561
+ /* @__PURE__ */ jsxRuntime.jsx(
4562
+ designSystem.Button,
4563
+ {
4564
+ variant: "tertiary",
4565
+ size: "S",
4566
+ onClick: () => {
4567
+ setSelectedMediaIds(currentIds);
4568
+ setMediaSearch("");
4569
+ setShowMediaModal(true);
4570
+ loadMediaLibrary("");
4571
+ },
4572
+ style: { maxWidth: 220, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" },
4573
+ children: mediaSummary
4574
+ }
4575
+ ),
4576
+ renderResetBtn()
4577
+ ] }),
4578
+ showMediaModal && /* @__PURE__ */ jsxRuntime.jsx(
4579
+ "div",
4580
+ {
4581
+ style: {
4582
+ position: "fixed",
4583
+ inset: 0,
4584
+ backgroundColor: "rgba(20, 20, 30, 0.55)",
4585
+ zIndex: 9999,
4586
+ display: "flex",
4587
+ alignItems: "center",
4588
+ justifyContent: "center",
4589
+ padding: 16
4590
+ },
4591
+ onClick: () => setShowMediaModal(false),
4592
+ children: /* @__PURE__ */ jsxRuntime.jsxs(
4593
+ designSystem.Box,
4594
+ {
4595
+ padding: 5,
4596
+ background: "neutral0",
4597
+ hasRadius: true,
4598
+ shadow: "popupShadow",
4599
+ style: { width: "92%", maxWidth: 620, maxHeight: "82vh", display: "flex", flexDirection: "column" },
4600
+ onClick: (e) => e.stopPropagation(),
4601
+ children: [
4602
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { variant: "delta", fontWeight: "bold", marginBottom: 3, children: [
4603
+ "Select Media Asset",
4604
+ isMultiMedia ? "s" : "",
4605
+ ": ",
4606
+ occurrence.displayPath
4607
+ ] }),
4608
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, marginBottom: 3, children: [
4609
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { style: { flex: 1 }, children: /* @__PURE__ */ jsxRuntime.jsx(
4610
+ designSystem.TextInput,
4611
+ {
4612
+ placeholder: "Search media filename or MIME...",
4613
+ value: mediaSearch,
4614
+ onChange: (e) => setMediaSearch(e.target.value)
4615
+ }
4616
+ ) }),
4617
+ /* @__PURE__ */ jsxRuntime.jsx(
4618
+ designSystem.Button,
4619
+ {
4620
+ variant: "secondary",
4621
+ startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Search, {}),
4622
+ onClick: () => loadMediaLibrary(mediaSearch),
4623
+ loading: mediaLoading,
4624
+ children: "Search"
4625
+ }
4626
+ )
4627
+ ] }),
4628
+ /* @__PURE__ */ jsxRuntime.jsx(
4629
+ designSystem.Box,
4630
+ {
4631
+ padding: 2,
4632
+ hasRadius: true,
4633
+ style: { border: "1px solid #eaeaef", overflowY: "auto", maxHeight: 320, marginBottom: 16 },
4634
+ children: mediaLoading ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", padding: 4, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Loader, { small: true, children: "Loading Media Library..." }) }) : mediaOptions.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: "No media files matched." }) : mediaOptions.map((file) => {
4635
+ const isChecked = selectedMediaIds.includes(file.id);
4636
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { padding: 2, style: { borderBottom: "1px solid #f0f0f5" }, children: /* @__PURE__ */ jsxRuntime.jsx(
4637
+ designSystem.Checkbox,
4638
+ {
4639
+ checked: isChecked,
4640
+ onCheckedChange: (checked) => {
4641
+ if (isMultiMedia) {
4642
+ setSelectedMediaIds(
4643
+ (prev) => checked ? [...prev, file.id] : prev.filter((id) => id !== file.id)
4644
+ );
4645
+ } else {
4646
+ setSelectedMediaIds(checked ? [file.id] : []);
4647
+ }
4648
+ },
4649
+ children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, alignItems: "center", children: [
4650
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Badge, { backgroundColor: "neutral150", textColor: "neutral700", size: "S", children: [
4651
+ "#",
4652
+ file.id
4653
+ ] }),
4654
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", fontWeight: "semiBold", children: file.name }),
4655
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { variant: "pi", textColor: "neutral500", children: [
4656
+ "(",
4657
+ file.mime,
4658
+ ")"
4659
+ ] })
4660
+ ] })
4661
+ }
4662
+ ) }, file.id);
4663
+ })
4664
+ }
4665
+ ),
4666
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", gap: 2, children: [
4667
+ /* @__PURE__ */ jsxRuntime.jsx(
4668
+ designSystem.Button,
4669
+ {
4670
+ variant: "danger-light",
4671
+ onClick: () => {
4672
+ commitTypedValue(isMultiMedia ? [] : null);
4673
+ setShowMediaModal(false);
4674
+ },
4675
+ children: "Clear Media"
4676
+ }
4677
+ ),
4678
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
4679
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "tertiary", onClick: () => setShowMediaModal(false), children: "Cancel" }),
4680
+ /* @__PURE__ */ jsxRuntime.jsx(
4681
+ designSystem.Button,
4682
+ {
4683
+ variant: "default",
4684
+ startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Check, {}),
4685
+ onClick: () => {
4686
+ commitTypedValue(isMultiMedia ? selectedMediaIds : selectedMediaIds[0] ?? null);
4687
+ setShowMediaModal(false);
4688
+ },
4689
+ children: "Apply Selection"
4690
+ }
4691
+ )
4692
+ ] })
4693
+ ] })
4694
+ ]
4695
+ }
4696
+ )
4697
+ }
4698
+ )
4699
+ ] });
4700
+ }
4701
+ if (fieldType === "richtext" || fieldType === "blocks" || fieldType === "json") {
4702
+ const isJsonOrBlocks = fieldType === "blocks" || fieldType === "json";
4703
+ const displayLabel = effectiveValue === null || effectiveValue === void 0 || effectiveValue === "" ? "(empty — edit)" : typeof effectiveValue === "object" ? JSON.stringify(effectiveValue).slice(0, 32) + (JSON.stringify(effectiveValue).length > 32 ? "…" : "") : String(effectiveValue).slice(0, 32) + (String(effectiveValue).length > 32 ? "…" : "");
4704
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { style: wrapperStyle, children: [
4705
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 1, alignItems: "center", children: [
4706
+ /* @__PURE__ */ jsxRuntime.jsx(
4707
+ designSystem.Button,
4708
+ {
4709
+ variant: "tertiary",
4710
+ size: "S",
4711
+ onClick: () => {
4712
+ const formatted = effectiveValue === null || effectiveValue === void 0 ? "" : typeof effectiveValue === "object" ? JSON.stringify(effectiveValue, null, 2) : String(effectiveValue);
4713
+ setRichDraft(formatted);
4714
+ setRichError(null);
4715
+ setShowRichModal(true);
4716
+ },
4717
+ style: { maxWidth: 230, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" },
4718
+ children: displayLabel
4719
+ }
4720
+ ),
4721
+ renderResetBtn()
4722
+ ] }),
4723
+ validationError && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "danger700", display: "block", style: { fontSize: "0.7rem" }, children: validationError }),
4724
+ showRichModal && /* @__PURE__ */ jsxRuntime.jsx(
4725
+ "div",
4726
+ {
4727
+ style: {
4728
+ position: "fixed",
4729
+ inset: 0,
4730
+ backgroundColor: "rgba(20, 20, 30, 0.55)",
4731
+ zIndex: 9999,
4732
+ display: "flex",
4733
+ alignItems: "center",
4734
+ justifyContent: "center",
4735
+ padding: 16
4736
+ },
4737
+ onClick: () => setShowRichModal(false),
4738
+ children: /* @__PURE__ */ jsxRuntime.jsxs(
4739
+ designSystem.Box,
4740
+ {
4741
+ padding: 5,
4742
+ background: "neutral0",
4743
+ hasRadius: true,
4744
+ shadow: "popupShadow",
4745
+ style: { width: "92%", maxWidth: 640, display: "flex", flexDirection: "column", gap: 12 },
4746
+ onClick: (e) => e.stopPropagation(),
4747
+ children: [
4748
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { variant: "delta", fontWeight: "bold", children: [
4749
+ "Edit ",
4750
+ fieldType.toUpperCase(),
4751
+ ": ",
4752
+ occurrence.displayPath
4753
+ ] }),
4754
+ /* @__PURE__ */ jsxRuntime.jsx(
4755
+ designSystem.Textarea,
4756
+ {
4757
+ name: "richDraft",
4758
+ "aria-label": "Rich content editor",
4759
+ value: richDraft,
4760
+ onChange: (e) => {
4761
+ setRichDraft(e.target.value);
4762
+ if (isJsonOrBlocks && e.target.value.trim()) {
4763
+ try {
4764
+ const parsed = JSON.parse(e.target.value);
4765
+ if (fieldType === "blocks" && !Array.isArray(parsed)) {
4766
+ setRichError("Strapi Blocks value must be a JSON array.");
4767
+ } else {
4768
+ setRichError(null);
4769
+ }
4770
+ } catch (err) {
4771
+ setRichError(`Invalid JSON: ${err.message}`);
4772
+ }
4773
+ } else {
4774
+ setRichError(null);
4775
+ }
4776
+ },
4777
+ style: { minHeight: 220, fontFamily: isJsonOrBlocks ? "monospace" : "inherit" }
4778
+ }
4779
+ ),
4780
+ richError && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "danger700", fontWeight: "bold", children: richError }),
4781
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", gap: 2, children: [
4782
+ /* @__PURE__ */ jsxRuntime.jsx(
4783
+ designSystem.Button,
4784
+ {
4785
+ variant: "danger-light",
4786
+ onClick: () => {
4787
+ commitTypedValue(isJsonOrBlocks ? null : "");
4788
+ setShowRichModal(false);
4789
+ },
4790
+ children: "Clear Value"
4791
+ }
4792
+ ),
4793
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
4794
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "tertiary", onClick: () => setShowRichModal(false), children: "Cancel" }),
4795
+ /* @__PURE__ */ jsxRuntime.jsx(
4796
+ designSystem.Button,
4797
+ {
4798
+ variant: "default",
4799
+ disabled: Boolean(richError),
4800
+ startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Check, {}),
4801
+ onClick: () => {
4802
+ if (isJsonOrBlocks) {
4803
+ if (!richDraft.trim()) {
4804
+ commitTypedValue(null);
4805
+ } else {
4806
+ commitTypedValue(JSON.parse(richDraft));
4807
+ }
4808
+ } else {
4809
+ commitTypedValue(richDraft);
4810
+ }
4811
+ setShowRichModal(false);
4812
+ },
4813
+ children: "Apply Edit"
4814
+ }
4815
+ )
4816
+ ] })
4817
+ ] })
4818
+ ]
4819
+ }
4820
+ )
4821
+ }
4822
+ )
4823
+ ] });
4824
+ }
4825
+ if (fieldType === "date" || fieldType === "time" || fieldType === "datetime") {
4826
+ const inputType = fieldType === "datetime" ? "datetime-local" : fieldType;
4827
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { style: wrapperStyle, children: [
4828
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 1, alignItems: "center", children: [
4829
+ /* @__PURE__ */ jsxRuntime.jsx(
4830
+ "input",
4831
+ {
4832
+ type: inputType,
4833
+ "aria-label": `Edit ${occurrence.displayPath}`,
4834
+ value: localText,
4835
+ step: fieldType === "time" ? 1 : void 0,
4836
+ onChange: (e) => {
4837
+ const v = e.target.value;
4838
+ setLocalText(v);
4839
+ commitTypedValue(v === "" ? null : v);
4840
+ },
4841
+ style: {
4842
+ padding: "6px 8px",
4843
+ borderRadius: 4,
4844
+ border: "1px solid #dcdce4",
4845
+ fontSize: "0.85rem",
4846
+ minWidth: 165
4847
+ }
4848
+ }
4849
+ ),
4850
+ renderResetBtn()
4851
+ ] }),
4852
+ validationError && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "danger700", display: "block", style: { fontSize: "0.7rem" }, children: validationError })
4853
+ ] });
4854
+ }
4855
+ const isNumeric = ["integer", "biginteger", "float", "decimal", "number"].includes(fieldType);
4856
+ const inputStep = fieldType === "integer" || fieldType === "biginteger" ? "1" : isNumeric ? "any" : void 0;
4857
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { style: wrapperStyle, children: [
4858
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 1, alignItems: "center", children: [
4859
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { style: { flex: 1, minWidth: 150 }, children: /* @__PURE__ */ jsxRuntime.jsx(
4860
+ designSystem.TextInput,
4861
+ {
4862
+ size: "S",
4863
+ type: isNumeric && fieldType !== "biginteger" ? "number" : "text",
4864
+ step: inputStep,
4865
+ "aria-label": `Edit ${occurrence.displayPath}`,
4866
+ placeholder: occurrence.isMissingIntermediate ? "Click to initialize..." : "(empty)",
4867
+ value: localText,
4868
+ onChange: (e) => {
4869
+ const next = e.target.value;
4870
+ setLocalText(next);
4871
+ commitTypedValue(isNumeric && next === "" ? null : next);
4872
+ }
4873
+ }
4874
+ ) }),
4875
+ renderResetBtn()
4876
+ ] }),
4877
+ validationError && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "danger700", display: "block", style: { fontSize: "0.7rem", marginTop: 2 }, children: validationError })
4878
+ ] });
4879
+ }
4880
+ );
4881
+ const ComponentOccurrencesDrawer = React__default.default.memo(
4882
+ ({
4883
+ colUid,
4884
+ rootKey,
4885
+ entry,
4886
+ selectedAttribute,
4887
+ attrMeta,
4888
+ colAttributes,
4889
+ gridEditMode,
4890
+ isSelected,
4891
+ selectedDzBlocks,
4892
+ occurrences,
4893
+ recordEdits,
4894
+ relationOptions,
4895
+ relationOptionsLoading,
4896
+ relationIsMulti,
4897
+ validationRules,
4898
+ onToggleDzBlock,
4899
+ onCommitEdit,
4900
+ onResetEdit
4901
+ }) => {
4902
+ const cleanRootKey = rootKey || (selectedAttribute || "").split("[")[0].split(".")[0];
4903
+ const selectedRootKey = selectedAttribute ? selectedAttribute.split("[")[0].split(".")[0] : "";
4904
+ const targetsThisRoot = Boolean(selectedAttribute && selectedRootKey === cleanRootKey);
4905
+ const blocks = Array.isArray(entry?.[cleanRootKey]) ? entry[cleanRootKey] : [];
4906
+ const isDynamicZone = blocks.some((b) => Boolean(b?.__component));
4907
+ if (blocks.length === 0) return null;
4908
+ const occByRootIndex = /* @__PURE__ */ new Map();
4909
+ occurrences.forEach((occ) => {
4910
+ if (occ.segments?.[0]?.key !== cleanRootKey || occ.segments?.[0]?.index === void 0) return;
4911
+ const rootIdx = occ.segments[0].index;
4912
+ const list = occByRootIndex.get(rootIdx) || [];
4913
+ list.push(occ);
4914
+ occByRootIndex.set(rootIdx, list);
4915
+ });
4916
+ const allApplicableIndexes = blocks.map((_, bIdx) => bIdx).filter((bIdx) => targetsThisRoot ? (occByRootIndex.get(bIdx) || []).length > 0 : true);
4917
+ return /* @__PURE__ */ jsxRuntime.jsxs(
4918
+ designSystem.Box,
4919
+ {
4920
+ padding: 3,
4921
+ background: "neutral0",
4922
+ hasRadius: true,
4923
+ style: { border: "1px solid rgba(73, 69, 255, 0.25)", boxShadow: "0 2px 8px rgba(0,0,0,0.05)" },
4924
+ children: [
4925
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", alignItems: "center", marginBottom: 2, children: [
4926
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, alignItems: "center", children: [
4927
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { variant: "sigma", textColor: "primary700", children: [
4928
+ isDynamicZone ? "DYNAMIC ZONE" : "REPEATABLE COMPONENT",
4929
+ ': "',
4930
+ cleanRootKey,
4931
+ '" (',
4932
+ blocks.length,
4933
+ " ",
4934
+ blocks.length === 1 ? "item" : "items",
4935
+ ")"
4936
+ ] }),
4937
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { backgroundColor: "primary100", textColor: "primary700", children: gridEditMode ? "Inline Per-Block Grid Editing" : "Selective Block Targeting" })
4938
+ ] }),
4939
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral500", children: gridEditMode ? "Edit each occurrence independently — component IDs & sibling blocks stay intact" : "Selectively choose which blocks to update for this entry" })
4940
+ ] }),
4941
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Table, { colCount: gridEditMode ? 4 : 5, rowCount: blocks.length + 1, style: { width: "100%", background: "#fff" }, children: [
4942
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Thead, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { children: [
4943
+ !gridEditMode && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { style: { width: 64 }, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", children: "Update?" }) }),
4944
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { style: { width: 85 }, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", children: "Pos / ID" }) }),
4945
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { style: { width: 210 }, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", children: "Component" }) }),
4946
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { variant: "sigma", children: [
4947
+ "Target Field Value (",
4948
+ selectedAttribute || "selected",
4949
+ ")"
4950
+ ] }) }),
4951
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", children: "Block Summary" }) })
4952
+ ] }) }),
4953
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tbody, { children: blocks.map((block, bIdx) => {
4954
+ const compUid = block?.__component || attrMeta?.component;
4955
+ const compLabel = formatComponentNameFriendly(compUid);
4956
+ const blockOccs = occByRootIndex.get(bIdx) || [];
4957
+ const hasTargetAttr = blockOccs.length > 0;
4958
+ const isBlockSelectable = targetsThisRoot ? hasTargetAttr : true;
4959
+ const isBlockChecked = !gridEditMode && isBlockSelectable && isSelected && (selectedDzBlocks !== void 0 ? selectedDzBlocks.includes(bIdx) : true);
4960
+ const hasDirtyOcc = blockOccs.some((o) => Boolean(recordEdits?.occurrences?.[o.occurrenceKey]));
4961
+ const blockSummaryText = block?.title || block?.name || block?.heading || block?.body || Object.keys(block || {}).filter((k) => !k.startsWith("_") && k !== "id").slice(0, 3).map((k) => {
4962
+ const v = block[k];
4963
+ if (v === null || v === void 0) return null;
4964
+ return `${k}: ${typeof v === "object" ? JSON.stringify(v).slice(0, 24) : String(v).slice(0, 24)}`;
4965
+ }).filter(Boolean).join(", ") || "-";
4966
+ return /* @__PURE__ */ jsxRuntime.jsxs(
4967
+ designSystem.Tr,
4968
+ {
4969
+ style: {
4970
+ backgroundColor: hasDirtyOcc || isBlockChecked ? "rgba(73, 69, 255, 0.07)" : void 0
4971
+ },
4972
+ children: [
4973
+ !gridEditMode && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(
4974
+ designSystem.Checkbox,
4975
+ {
4976
+ checked: isBlockChecked,
4977
+ disabled: !isBlockSelectable,
4978
+ onCheckedChange: () => {
4979
+ onToggleDzBlock(colUid, entry.documentId, bIdx, allApplicableIndexes);
4980
+ }
4981
+ }
4982
+ ) }),
4983
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Td, { children: [
4984
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { variant: "pi", fontWeight: "bold", display: "block", children: [
4985
+ "#",
4986
+ bIdx
4987
+ ] }),
4988
+ block?.id !== void 0 && /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { variant: "pi", textColor: "neutral500", style: { fontSize: "0.68rem" }, children: [
4989
+ "id:",
4990
+ block.id
4991
+ ] })
4992
+ ] }),
4993
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Td, { children: [
4994
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { backgroundColor: "neutral150", textColor: "neutral800", children: compLabel }),
4995
+ compUid && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral500", display: "block", style: { fontSize: "0.68rem", marginTop: 2 }, children: compUid })
4996
+ ] }),
4997
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: !targetsThisRoot ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral500", children: selectedAttribute ? `(targets "${selectedAttribute}")` : "(select attribute to inspect)" }) : !hasTargetAttr ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { backgroundColor: "neutral100", textColor: "neutral500", children: "Does not contain attribute" }) : gridEditMode ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", gap: 2, alignItems: "flex-start", children: blockOccs.map((occ) => {
4998
+ const editObj = recordEdits?.occurrences?.[occ.occurrenceKey];
4999
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { style: { width: "100%" }, children: [
5000
+ blockOccs.length > 1 && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", display: "block", style: { fontSize: "0.7rem", marginBottom: 2 }, children: occ.displayPath }),
5001
+ /* @__PURE__ */ jsxRuntime.jsx(
5002
+ GridCellEditor,
5003
+ {
5004
+ entry,
5005
+ attribute: selectedAttribute,
5006
+ occurrence: occ,
5007
+ attrMeta,
5008
+ editedValue: editObj?.value,
5009
+ isDirty: Boolean(editObj),
5010
+ validationError: editObj?.validationError,
5011
+ relationOptions,
5012
+ relationOptionsLoading,
5013
+ relationIsMulti,
5014
+ validationRules,
5015
+ recordEdits,
5016
+ colAttributes,
5017
+ onCommit: (o, val, err) => onCommitEdit(entry, colUid, o, val, err),
5018
+ onReset: (k) => onResetEdit(colUid, entry.documentId, k)
5019
+ }
5020
+ )
5021
+ ] }, occ.occurrenceKey);
5022
+ }) }) : /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", gap: 1, alignItems: "flex-start", children: blockOccs.map((occ) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.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)) }) }),
5023
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(
5024
+ designSystem.Typography,
5025
+ {
5026
+ variant: "pi",
5027
+ textColor: "neutral600",
5028
+ style: { maxWidth: 280, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" },
5029
+ children: blockSummaryText
5030
+ }
5031
+ ) })
5032
+ ]
5033
+ },
5034
+ block?.id ? `id_${block.id}_idx_${bIdx}` : `idx_${bIdx}`
5035
+ );
5036
+ }) })
5037
+ ] })
5038
+ ]
5039
+ }
5040
+ );
5041
+ }
5042
+ );
5043
+ function parseDynamicZonePath(path) {
5044
+ if (!path) return { cleanPath: "", rootKey: "", subPath: "" };
5045
+ const bracketMatch = path.match(/^([^.[]+)\[([^\]]+)\]\.(.+)$/);
5046
+ if (bracketMatch) {
5047
+ const rootKey = bracketMatch[1];
5048
+ const selector = bracketMatch[2];
5049
+ const subPath = bracketMatch[3];
5050
+ const cleanPath = `${rootKey}.${subPath}`;
5051
+ if (/^\d+$/.test(selector)) {
5052
+ return { cleanPath, rootKey, subPath, targetIndex: parseInt(selector, 10) };
5053
+ }
5054
+ return { cleanPath, rootKey, subPath, targetComponentUid: selector };
5055
+ }
5056
+ const parts = path.split(".");
5057
+ return {
5058
+ cleanPath: path,
5059
+ rootKey: parts[0] || "",
5060
+ subPath: parts.slice(1).join(".")
5061
+ };
5062
+ }
5063
+ function formatComponentName(compUid) {
5064
+ if (!compUid) return "Component";
5065
+ const name = compUid.includes(".") ? compUid.split(".")[1] : compUid;
5066
+ return name.split(/[-_]/).map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join(" ");
5067
+ }
5068
+ function getAllNestedValues(obj, path, availableAttributes) {
5069
+ if (!obj || !path) return [];
5070
+ const parsed = parseDynamicZonePath(path);
5071
+ const parts = parsed.cleanPath.split(".");
5072
+ const [head, ...tail] = parts;
5073
+ const rootTarget = getPropertyValue(obj, head);
5074
+ if (Array.isArray(rootTarget)) {
5075
+ const results = [];
5076
+ rootTarget.forEach((item, idx) => {
5077
+ if (!item || typeof item !== "object") return;
5078
+ if (parsed.targetIndex !== void 0 && idx !== parsed.targetIndex) return;
5079
+ if (parsed.targetComponentUid && item.__component !== parsed.targetComponentUid) return;
5080
+ const subPath = tail.join(".");
5081
+ const scopedPath = item.__component ? `${head}[${item.__component}].${subPath}` : "";
5082
+ const isSupported = availableAttributes ? availableAttributes.includes(scopedPath) : false;
5083
+ const subVal = tail.length > 0 ? getNestedValue(item, subPath) : item;
5084
+ if (subVal !== void 0 || isSupported) {
5085
+ results.push({
5086
+ index: idx,
5087
+ componentUid: item.__component,
5088
+ componentName: formatComponentName(item.__component),
5089
+ value: subVal !== void 0 ? subVal : null,
5090
+ path: `${head}[#${idx}${item.__component ? ` ${formatComponentName(item.__component)}` : ""}].${subPath}`
5091
+ });
5092
+ }
5093
+ });
5094
+ return results;
5095
+ }
5096
+ const singleVal = getNestedValue(obj, parsed.cleanPath);
5097
+ if (singleVal !== void 0) {
5098
+ return [
5099
+ {
5100
+ index: 0,
5101
+ value: singleVal,
5102
+ path: parsed.cleanPath
5103
+ }
5104
+ ];
5105
+ }
5106
+ return [];
5107
+ }
5108
+ function getPropertyValue(target, key) {
5109
+ if (!target || typeof target !== "object" || !key) return void 0;
5110
+ if (target[key] !== void 0 && target[key] !== null) return target[key];
5111
+ const camelKey = key.replace(/_([a-z0-9])/g, (_, letter) => letter.toUpperCase());
5112
+ if (target[camelKey] !== void 0 && target[camelKey] !== null) return target[camelKey];
5113
+ const snakeKey = key.replace(/([A-Z])/g, "_$1").toLowerCase();
5114
+ if (target[snakeKey] !== void 0 && target[snakeKey] !== null) return target[snakeKey];
5115
+ const lowerKey = key.toLowerCase();
5116
+ const lowerNoUnderscore = lowerKey.replace(/_/g, "");
5117
+ const matchedKey = Object.keys(target).find((k) => {
5118
+ const kLower = k.toLowerCase();
5119
+ return kLower === lowerKey || kLower.replace(/_/g, "") === lowerNoUnderscore;
5120
+ });
5121
+ if (matchedKey && target[matchedKey] !== void 0 && target[matchedKey] !== null) {
5122
+ return target[matchedKey];
5123
+ }
5124
+ if (key in target) return target[key];
5125
+ if (camelKey in target) return target[camelKey];
5126
+ if (snakeKey in target) return target[snakeKey];
5127
+ return void 0;
5128
+ }
5129
+ function getNestedValue(obj, path) {
5130
+ if (!obj || !path) return void 0;
5131
+ const parsed = parseDynamicZonePath(path);
5132
+ const parts = parsed.cleanPath.split(".");
5133
+ function extract(current, remainingParts) {
5134
+ if (current === void 0 || current === null) return void 0;
5135
+ if (remainingParts.length === 0) return current;
5136
+ const [head, ...tail] = remainingParts;
5137
+ if (Array.isArray(current)) {
5138
+ if (/^\d+$/.test(head)) {
5139
+ return extract(current[parseInt(head, 10)], tail);
5140
+ }
5141
+ for (let idx = 0; idx < current.length; idx++) {
5142
+ const item = current[idx];
5143
+ if (parsed.targetIndex !== void 0 && idx !== parsed.targetIndex) continue;
5144
+ if (parsed.targetComponentUid && item?.__component !== parsed.targetComponentUid) continue;
5145
+ const found = extract(getPropertyValue(item, head), tail);
5146
+ if (found !== void 0 && found !== null) return found;
5147
+ }
5148
+ return void 0;
5149
+ }
5150
+ return extract(getPropertyValue(current, head), tail);
5151
+ }
5152
+ return extract(obj, parts);
5153
+ }
5154
+ function getAvailableColumnsForCollection(col, selectedAttribute, searchAttribute) {
5155
+ const cols = [
5156
+ {
5157
+ key: "select",
5158
+ label: "Select",
5159
+ isPermanent: true,
5160
+ defaultVisible: true
5161
+ },
5162
+ {
5163
+ key: "identifier",
5164
+ label: "Identifier",
5165
+ sortable: !col.isSingleType,
5166
+ defaultVisible: true
5167
+ }
5168
+ ];
5169
+ const candidateAttrs = col.attributes || [];
5170
+ candidateAttrs.forEach((attr) => {
5171
+ if (attr === "name" || attr === "title" || attr === selectedAttribute || searchAttribute && attr === searchAttribute) {
5172
+ return;
5173
+ }
5174
+ let formattedLabel = attr;
5175
+ if (attr === "updated_at" || attr === "updatedAt") {
5176
+ formattedLabel = "Updated At";
5177
+ } else if (attr === "created_at" || attr === "createdAt") {
5178
+ formattedLabel = "Created At";
5179
+ } else if (attr === "published_at" || attr === "publishedAt") {
5180
+ formattedLabel = "Published At";
3730
5181
  } else {
3731
5182
  const bracketMatch = attr.match(/^([^.[]+)\[([^\]]+)\]\.(.+)$/);
3732
5183
  if (bracketMatch) {
@@ -4001,7 +5452,7 @@ function formatDisplayValue(val) {
4001
5452
  }
4002
5453
  return String(val);
4003
5454
  }
4004
- function renderCellContent(colDef, entry, col, selectedAttribute, searchAttribute, isMatch, hasAttr, isSelected, onToggleSelect, pendingBatches = [], isDzExpanded = false, onToggleExpandDz, filterQuery = "") {
5455
+ function renderCellContent(colDef, entry, col, selectedAttribute, searchAttribute, isMatch, hasAttr, isSelected, onToggleSelect, pendingBatches = [], isDzExpanded = false, onToggleExpandDz, filterQuery = "", gridCtx) {
4005
5456
  switch (colDef.key) {
4006
5457
  case "select":
4007
5458
  return /* @__PURE__ */ jsxRuntime.jsx(
@@ -4016,7 +5467,10 @@ function renderCellContent(colDef, entry, col, selectedAttribute, searchAttribut
4016
5467
  const dzField = Object.keys(entry).find(
4017
5468
  (k) => Array.isArray(entry[k]) && entry[k].length > 0 && entry[k].some((item) => item && item.__component)
4018
5469
  );
4019
- const dzItemsCount = dzField ? entry[dzField].length : 0;
5470
+ const selectedRootKey = selectedAttribute ? selectedAttribute.split("[")[0].split(".")[0] : "";
5471
+ const repeatableRoot = !dzField && gridCtx?.gridEditMode && selectedRootKey && gridCtx?.selectedAttrMeta?.rootRepeatable && Array.isArray(entry[selectedRootKey]) && entry[selectedRootKey].length > 0 ? selectedRootKey : void 0;
5472
+ const expandField = dzField || repeatableRoot;
5473
+ const dzItemsCount = expandField ? entry[expandField].length : 0;
4020
5474
  return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { children: [
4021
5475
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: "semiBold", children: mainText }),
4022
5476
  entry.email && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral500", display: "block", children: entry.email }),
@@ -4034,7 +5488,7 @@ function renderCellContent(colDef, entry, col, selectedAttribute, searchAttribut
4034
5488
  backgroundColor: isDzExpanded ? "rgba(73, 69, 255, 0.08)" : "rgba(0, 0, 0, 0.04)",
4035
5489
  borderRadius: 4
4036
5490
  },
4037
- children: isDzExpanded ? `▲ Hide ${dzField} (${dzItemsCount} blocks)` : `▼ View ${dzField} (${dzItemsCount} blocks)`
5491
+ children: isDzExpanded ? `▲ Hide ${expandField} (${dzItemsCount} ${dzField ? "blocks" : "items"})` : `▼ ${gridCtx?.gridEditMode ? "Edit" : "View"} ${expandField} (${dzItemsCount} ${dzField ? "blocks" : "items"})`
4038
5492
  }
4039
5493
  ) })
4040
5494
  ] });
@@ -4108,6 +5562,88 @@ function renderCellContent(colDef, entry, col, selectedAttribute, searchAttribut
4108
5562
  }) });
4109
5563
  }
4110
5564
  case "target_attr": {
5565
+ if (gridCtx?.gridEditMode) {
5566
+ if (selectedAttribute && !hasAttr) {
5567
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { backgroundColor: "neutral200", textColor: "neutral600", children: "Ignored (absent in schema)" });
5568
+ }
5569
+ const occs = enumerateClientOccurrences(
5570
+ entry,
5571
+ selectedAttribute,
5572
+ col?.attributes,
5573
+ gridCtx.selectedAttrMeta
5574
+ );
5575
+ if (occs.length === 0) {
5576
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral500", style: { fontStyle: "italic" }, children: "(no applicable block / item)" });
5577
+ }
5578
+ if (occs.length === 1 && !occs[0].segments.some((s) => s.index !== void 0)) {
5579
+ const occ = occs[0];
5580
+ const editObj = gridCtx.recordEdits?.occurrences?.[occ.occurrenceKey];
5581
+ return /* @__PURE__ */ jsxRuntime.jsx(
5582
+ GridCellEditor,
5583
+ {
5584
+ entry,
5585
+ attribute: selectedAttribute,
5586
+ occurrence: occ,
5587
+ attrMeta: gridCtx.selectedAttrMeta,
5588
+ editedValue: editObj?.value,
5589
+ isDirty: Boolean(editObj),
5590
+ validationError: editObj?.validationError,
5591
+ relationOptions: gridCtx.relationOptions,
5592
+ relationOptionsLoading: gridCtx.relationOptionsLoading,
5593
+ relationIsMulti: gridCtx.relationIsMulti,
5594
+ validationRules: gridCtx.validationRules,
5595
+ recordEdits: gridCtx.recordEdits,
5596
+ colAttributes: col?.attributes,
5597
+ onCommit: (o, val, err) => gridCtx.onCommitEdit(entry, col.uid, o, val, err),
5598
+ onReset: (k) => gridCtx.onResetEdit(col.uid, entry.documentId, k)
5599
+ }
5600
+ );
5601
+ }
5602
+ const maxInline = 3;
5603
+ const visibleOccs = occs.slice(0, maxInline);
5604
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 2, alignItems: "flex-start", children: [
5605
+ visibleOccs.map((occ) => {
5606
+ const editObj = gridCtx.recordEdits?.occurrences?.[occ.occurrenceKey];
5607
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { style: { width: "100%" }, children: [
5608
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 1, alignItems: "center", marginBottom: 1, children: [
5609
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Badge, { size: "S", backgroundColor: editObj ? "primary100" : "neutral200", textColor: editObj ? "primary700" : "neutral800", children: [
5610
+ "#",
5611
+ occ.index,
5612
+ " ",
5613
+ occ.componentName || "Item"
5614
+ ] }),
5615
+ occ.componentId !== void 0 && /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { variant: "pi", textColor: "neutral500", style: { fontSize: "0.68rem" }, children: [
5616
+ "id:",
5617
+ occ.componentId
5618
+ ] }),
5619
+ editObj && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { size: "S", backgroundColor: "secondary100", textColor: "secondary700", children: "Edited" })
5620
+ ] }),
5621
+ /* @__PURE__ */ jsxRuntime.jsx(
5622
+ GridCellEditor,
5623
+ {
5624
+ compact: true,
5625
+ entry,
5626
+ attribute: selectedAttribute,
5627
+ occurrence: occ,
5628
+ attrMeta: gridCtx.selectedAttrMeta,
5629
+ editedValue: editObj?.value,
5630
+ isDirty: Boolean(editObj),
5631
+ validationError: editObj?.validationError,
5632
+ relationOptions: gridCtx.relationOptions,
5633
+ relationOptionsLoading: gridCtx.relationOptionsLoading,
5634
+ relationIsMulti: gridCtx.relationIsMulti,
5635
+ validationRules: gridCtx.validationRules,
5636
+ recordEdits: gridCtx.recordEdits,
5637
+ colAttributes: col?.attributes,
5638
+ onCommit: (o, val, err) => gridCtx.onCommitEdit(entry, col.uid, o, val, err),
5639
+ onReset: (k) => gridCtx.onResetEdit(col.uid, entry.documentId, k)
5640
+ }
5641
+ )
5642
+ ] }, occ.occurrenceKey);
5643
+ }),
5644
+ occs.length > maxInline && onToggleExpandDz && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "tertiary", size: "S", onClick: onToggleExpandDz, children: isDzExpanded ? `▲ Collapse drawer` : `▼ Edit all ${occs.length} occurrences in drawer` })
5645
+ ] });
5646
+ }
4111
5647
  const matches = getAllNestedValues(entry, selectedAttribute, col?.attributes);
4112
5648
  if (matches.length === 0) {
4113
5649
  return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral500", style: { fontStyle: "italic" }, children: "(empty / not set)" });
@@ -4314,6 +5850,10 @@ const BulkUpdater = () => {
4314
5850
  const [searchAttribute, setSearchAttribute] = React.useState("");
4315
5851
  const [searchAttributeInput, setSearchAttributeInput] = React.useState("");
4316
5852
  const [attributesMeta, setAttributesMeta] = React.useState({});
5853
+ const [gridEditMode, setGridEditMode] = React.useState(false);
5854
+ const [gridEdits, setGridEdits] = React.useState({});
5855
+ const [gridFilterModifiedOnly, setGridFilterModifiedOnly] = React.useState(false);
5856
+ const [validationRules, setValidationRules] = React.useState([]);
4317
5857
  const effectiveSearchAttribute = searchAttribute || selectedAttribute;
4318
5858
  React.useEffect(() => {
4319
5859
  if (effectiveSearchAttribute && relationsMeta[effectiveSearchAttribute]) {
@@ -4327,7 +5867,27 @@ const BulkUpdater = () => {
4327
5867
  const [entrySearch, setEntrySearch] = React.useState("");
4328
5868
  const abortControllersRef = React.useRef({});
4329
5869
  const [statusFilter, setStatusFilter] = React.useState("all");
4330
- const isFilterActive = Boolean(searchAttribute && searchAttribute !== selectedAttribute) || filterOperator !== "none" && (["empty", "not_empty"].includes(filterOperator) || Boolean(filterQuery.trim())) || Boolean(entrySearch.trim()) || Boolean(statusFilter !== "all") || Boolean(useRegex && regexPattern.trim());
5870
+ const [appliedSearchFilter, setAppliedSearchFilter] = React.useState(EMPTY_SEARCH_FILTER);
5871
+ const appliedSearchFilterRef = React.useRef(EMPTY_SEARCH_FILTER);
5872
+ const draftSearchFilter = React.useMemo(
5873
+ () => ({
5874
+ searchAttribute,
5875
+ filterOperator,
5876
+ filterQuery,
5877
+ entrySearch,
5878
+ statusFilter,
5879
+ useRegex,
5880
+ regexPattern
5881
+ }),
5882
+ [searchAttribute, filterOperator, filterQuery, entrySearch, statusFilter, useRegex, regexPattern]
5883
+ );
5884
+ const hasPendingFilterChanges = React.useMemo(
5885
+ () => !areSearchFiltersEqual(draftSearchFilter, appliedSearchFilter, {
5886
+ includeWorkspaceExtras: true
5887
+ }),
5888
+ [draftSearchFilter, appliedSearchFilter]
5889
+ );
5890
+ const isFilterActive = isSearchFilterActive(appliedSearchFilter, selectedAttribute);
4331
5891
  const [lastResults, setLastResults] = React.useState(null);
4332
5892
  const [updateSummary, setUpdateSummary] = React.useState(null);
4333
5893
  const [collectionPages, setCollectionPages] = React.useState({});
@@ -4494,10 +6054,11 @@ const BulkUpdater = () => {
4494
6054
  const currentSort = collectionSorts[colUid] || { field: "createdAt", order: "desc" };
4495
6055
  const sortField = customSortField !== void 0 ? customSortField : currentSort.field;
4496
6056
  const sortOrder = customSortOrder !== void 0 ? customSortOrder : currentSort.order;
4497
- const op = overrideFilterOp !== void 0 ? overrideFilterOp : filterOperator;
4498
- const q = overrideFilterQuery !== void 0 ? overrideFilterQuery : filterQuery;
4499
- const s = overrideEntrySearch !== void 0 ? overrideEntrySearch : entrySearch;
4500
- const searchAttr = overrideSearchAttr !== void 0 ? overrideSearchAttr : searchAttribute;
6057
+ const appliedSnapshot = appliedSearchFilterRef.current;
6058
+ const op = overrideFilterOp !== void 0 ? overrideFilterOp : appliedSnapshot.filterOperator;
6059
+ const q = overrideFilterQuery !== void 0 ? overrideFilterQuery : appliedSnapshot.filterQuery;
6060
+ const s = overrideEntrySearch !== void 0 ? overrideEntrySearch : appliedSnapshot.entrySearch;
6061
+ const searchAttr = overrideSearchAttr !== void 0 ? overrideSearchAttr : appliedSnapshot.searchAttribute;
4501
6062
  setCollectionPages((prev) => ({
4502
6063
  ...prev,
4503
6064
  [colUid]: {
@@ -4505,34 +6066,30 @@ const BulkUpdater = () => {
4505
6066
  loading: true
4506
6067
  }
4507
6068
  }));
6069
+ let controller = null;
4508
6070
  try {
4509
- const params = new URLSearchParams({
4510
- page: String(targetPage),
4511
- pageSize: String(size)
6071
+ const params = buildEntriesQueryParams({
6072
+ page: targetPage,
6073
+ pageSize: size,
6074
+ filter: {
6075
+ searchAttribute: searchAttr,
6076
+ filterOperator: op,
6077
+ filterQuery: q,
6078
+ entrySearch: s
6079
+ },
6080
+ selectedAttribute,
6081
+ sortField,
6082
+ sortOrder
4512
6083
  });
4513
- if (selectedAttribute) params.set("attribute", selectedAttribute);
4514
- if (searchAttr && searchAttr !== selectedAttribute) {
4515
- params.set("searchAttribute", searchAttr);
4516
- }
4517
- if (op && op !== "none") {
4518
- params.set("filterOperator", op);
4519
- if (q) params.set("filterQuery", q);
4520
- }
4521
- if (s && s.trim()) {
4522
- params.set("search", s.trim());
4523
- }
4524
- if (sortField) {
4525
- params.set("sortField", sortField);
4526
- params.set("sortOrder", sortOrder);
4527
- }
4528
6084
  if (abortControllersRef.current[colUid]) {
4529
6085
  abortControllersRef.current[colUid].abort();
4530
6086
  }
4531
- const controller = new AbortController();
6087
+ controller = new AbortController();
4532
6088
  abortControllersRef.current[colUid] = controller;
4533
6089
  const res = await get(`/bulk-updater/collections/${colUid}/entries?${params.toString()}`, {
4534
6090
  signal: controller.signal
4535
6091
  });
6092
+ if (abortControllersRef.current[colUid] !== controller) return;
4536
6093
  if (res.data && (res.data.success || res.data.entries !== void 0)) {
4537
6094
  const fetchedEntries = res.data.entries || [];
4538
6095
  const pageNum = res.data.pagination?.page ?? targetPage ?? 1;
@@ -4580,13 +6137,15 @@ const BulkUpdater = () => {
4580
6137
  message: `Failed to load entries for ${colUid}: ${err?.message || "Network error"}`
4581
6138
  });
4582
6139
  }
4583
- setCollectionPages((prev) => ({
4584
- ...prev,
4585
- [colUid]: {
4586
- ...prev[colUid] || {},
4587
- loading: false
4588
- }
4589
- }));
6140
+ if (abortControllersRef.current[colUid] === controller) {
6141
+ setCollectionPages((prev) => ({
6142
+ ...prev,
6143
+ [colUid]: {
6144
+ ...prev[colUid] || {},
6145
+ loading: false
6146
+ }
6147
+ }));
6148
+ }
4590
6149
  }
4591
6150
  };
4592
6151
  const fetchAuditHistory = async () => {
@@ -4628,56 +6187,197 @@ const BulkUpdater = () => {
4628
6187
  setPendingBatchesLoading(false);
4629
6188
  }
4630
6189
  };
6190
+ const fetchValidationRules = async () => {
6191
+ try {
6192
+ const res = await get("/bulk-updater/validation-rules");
6193
+ if (res.data?.success && Array.isArray(res.data.rules)) {
6194
+ setValidationRules(res.data.rules);
6195
+ }
6196
+ } catch {
6197
+ }
6198
+ };
4631
6199
  React.useEffect(() => {
4632
6200
  fetchModels();
4633
6201
  fetchAuditHistory();
4634
6202
  fetchPendingBatches();
6203
+ fetchValidationRules();
4635
6204
  }, []);
4636
6205
  React.useEffect(() => {
4637
6206
  if (activeTab === "audit") {
4638
6207
  fetchAuditHistory();
4639
6208
  fetchPendingBatches();
4640
- }
4641
- }, [activeTab]);
4642
- const isInitialFilterMount = React.useRef(true);
4643
- React.useEffect(() => {
4644
- if (isInitialFilterMount.current) {
4645
- isInitialFilterMount.current = false;
4646
- return;
4647
- }
4648
- const timer = setTimeout(() => {
4649
- if (selectedCollectionUid) {
4650
- const isFilterActiveNow = Boolean(searchAttribute && searchAttribute !== selectedAttribute) || filterOperator !== "none" && (["empty", "not_empty"].includes(filterOperator) || Boolean(filterQuery.trim())) || Boolean(entrySearch.trim()) || Boolean(useRegex && regexPattern.trim());
4651
- if (isFilterActiveNow) {
4652
- setSelectedEntries({});
4653
- }
4654
- loadCollectionPage(
4655
- selectedCollectionUid,
4656
- 1,
4657
- void 0,
4658
- void 0,
4659
- void 0,
4660
- filterOperator,
4661
- filterQuery,
4662
- entrySearch,
4663
- true,
4664
- searchAttribute
4665
- );
6209
+ }
6210
+ }, [activeTab]);
6211
+ const handleApplySearch = () => {
6212
+ const nextApplied = {
6213
+ searchAttribute,
6214
+ filterOperator,
6215
+ filterQuery,
6216
+ entrySearch,
6217
+ statusFilter,
6218
+ useRegex,
6219
+ regexPattern
6220
+ };
6221
+ appliedSearchFilterRef.current = nextApplied;
6222
+ setAppliedSearchFilter(nextApplied);
6223
+ if (!selectedCollectionUid) return;
6224
+ const isFilterActiveNow = isSearchFilterActive(nextApplied, selectedAttribute);
6225
+ if (isFilterActiveNow) {
6226
+ if (gridEditMode) {
6227
+ setSelectedEntries((prev) => {
6228
+ const retained = {};
6229
+ Object.keys(gridEdits).forEach((k) => {
6230
+ if (prev[k]) retained[k] = true;
6231
+ });
6232
+ return retained;
6233
+ });
6234
+ } else {
6235
+ setSelectedEntries({});
4666
6236
  }
4667
- }, 350);
4668
- return () => clearTimeout(timer);
4669
- }, [selectedCollectionUid, searchAttribute, filterOperator, filterQuery, entrySearch, useRegex, regexPattern]);
6237
+ }
6238
+ loadCollectionPage(
6239
+ selectedCollectionUid,
6240
+ 1,
6241
+ void 0,
6242
+ void 0,
6243
+ void 0,
6244
+ nextApplied.filterOperator,
6245
+ nextApplied.filterQuery,
6246
+ nextApplied.entrySearch,
6247
+ true,
6248
+ nextApplied.searchAttribute
6249
+ );
6250
+ };
4670
6251
  const KEY_SEP = "@@@";
4671
6252
  const selectedCol = React.useMemo(() => {
4672
6253
  if (!collections.length || !selectedCollectionUid) return null;
4673
6254
  return collections.find((c) => c.uid === selectedCollectionUid) || null;
4674
6255
  }, [collections, selectedCollectionUid]);
6256
+ const activeAttrMeta = React.useMemo(() => {
6257
+ if (!selectedAttribute) return void 0;
6258
+ const base = selectedCol?.attributesMeta?.[selectedAttribute] || attributesMeta[selectedAttribute];
6259
+ const relMeta = selectedCol?.relations?.[selectedAttribute] || relationsMeta[selectedAttribute];
6260
+ if (!base && !relMeta) return void 0;
6261
+ if (relMeta && (!base || !base.isRelation)) {
6262
+ return {
6263
+ ...base || { depth: 0, type: "relation" },
6264
+ isRelation: true,
6265
+ relationType: relMeta.relationType,
6266
+ target: relMeta.targetUid
6267
+ };
6268
+ }
6269
+ return base;
6270
+ }, [selectedAttribute, selectedCol, attributesMeta, relationsMeta]);
6271
+ const totalDirtyRecordsCount = React.useMemo(() => Object.keys(gridEdits).length, [gridEdits]);
6272
+ const totalDirtyCellsCount = React.useMemo(
6273
+ () => Object.values(gridEdits).reduce(
6274
+ (sum, rec) => sum + Object.keys(rec.occurrences || {}).length,
6275
+ 0
6276
+ ),
6277
+ [gridEdits]
6278
+ );
6279
+ const gridSerialized = React.useMemo(
6280
+ () => serializeGridTargets(gridEdits, selectedEntries, collectionPages, activeAttrMeta),
6281
+ [gridEdits, selectedEntries, collectionPages, activeAttrMeta]
6282
+ );
6283
+ const handleGridCellCommit = React__default.default.useCallback(
6284
+ (entry, colUid, occ, newValue, validationError) => {
6285
+ const key = `${colUid}${KEY_SEP}${entry.documentId}`;
6286
+ const recordLabel = entry.name || entry.title || entry.email || `Entry #${entry.id || entry.documentId}`;
6287
+ setGridEdits((prev) => {
6288
+ const existingRec = prev[key] || {
6289
+ uid: colUid,
6290
+ documentId: entry.documentId,
6291
+ locale: entry.locale,
6292
+ status: entry.status,
6293
+ publishedAt: entry.publishedAt,
6294
+ recordLabel,
6295
+ occurrences: {}
6296
+ };
6297
+ return {
6298
+ ...prev,
6299
+ [key]: {
6300
+ ...existingRec,
6301
+ occurrences: {
6302
+ ...existingRec.occurrences,
6303
+ [occ.occurrenceKey]: {
6304
+ occurrenceKey: occ.occurrenceKey,
6305
+ displayPath: occ.displayPath,
6306
+ segments: occ.segments,
6307
+ originalValue: occ.value,
6308
+ value: newValue,
6309
+ fieldType: activeAttrMeta?.type || "string",
6310
+ validationError,
6311
+ touchedAt: Date.now()
6312
+ }
6313
+ }
6314
+ }
6315
+ };
6316
+ });
6317
+ setSelectedEntries((prev) => prev[key] ? prev : { ...prev, [key]: true });
6318
+ },
6319
+ [activeAttrMeta?.type]
6320
+ );
6321
+ const handleGridCellReset = React__default.default.useCallback((colUid, documentId, occKey) => {
6322
+ const key = `${colUid}${KEY_SEP}${documentId}`;
6323
+ setGridEdits((prev) => {
6324
+ const existingRec = prev[key];
6325
+ if (!existingRec) return prev;
6326
+ const nextOccs = { ...existingRec.occurrences };
6327
+ delete nextOccs[occKey];
6328
+ if (Object.keys(nextOccs).length === 0) {
6329
+ const next = { ...prev };
6330
+ delete next[key];
6331
+ return next;
6332
+ }
6333
+ return {
6334
+ ...prev,
6335
+ [key]: {
6336
+ ...existingRec,
6337
+ occurrences: nextOccs
6338
+ }
6339
+ };
6340
+ });
6341
+ }, []);
6342
+ const handleToggleGridEditMode = (checked) => {
6343
+ if (!checked && totalDirtyCellsCount > 0) {
6344
+ if (!window.confirm(`Disable Grid Editing Mode and discard ${totalDirtyCellsCount} unsaved edit(s)?`)) {
6345
+ return;
6346
+ }
6347
+ setGridEdits({});
6348
+ }
6349
+ setGridEditMode(checked);
6350
+ setGridFilterModifiedOnly(false);
6351
+ if (checked) {
6352
+ if (useRegex) setUseRegex(false);
6353
+ setRegexPattern("");
6354
+ if (selectedCollectionUid) {
6355
+ setCollectionColumnVisibility((prev) => {
6356
+ const existing = prev[selectedCollectionUid];
6357
+ if (existing && !existing.includes("target_attr")) {
6358
+ return { ...prev, [selectedCollectionUid]: [...existing, "target_attr"] };
6359
+ }
6360
+ return prev;
6361
+ });
6362
+ }
6363
+ }
6364
+ };
4675
6365
  const handleCollectionChange = (newUid) => {
4676
6366
  if (newUid === selectedCollectionUid) return;
6367
+ if (totalDirtyCellsCount > 0) {
6368
+ if (!window.confirm(
6369
+ `You have ${totalDirtyCellsCount} unsaved Grid Edit(s) in the current collection. Switching collections will discard them. Continue?`
6370
+ )) {
6371
+ return;
6372
+ }
6373
+ }
4677
6374
  if (abortControllersRef.current) {
4678
- Object.values(abortControllersRef.current).forEach((ctrl) => ctrl.abort());
6375
+ Object.values(abortControllersRef.current).forEach((ctrl) => ctrl?.abort());
4679
6376
  }
4680
6377
  setSelectedCollectionUid(newUid);
6378
+ setGridEdits({});
6379
+ setSelectedDzBlocks({});
6380
+ setExpandedDzEntries({});
4681
6381
  try {
4682
6382
  if (newUid) {
4683
6383
  localStorage.setItem(LAST_COLLECTION_KEY, newUid);
@@ -4688,6 +6388,12 @@ const BulkUpdater = () => {
4688
6388
  }
4689
6389
  setSelectedEntries({});
4690
6390
  setSearchAttribute("");
6391
+ const nextAppliedOnColSwitch = {
6392
+ ...appliedSearchFilterRef.current,
6393
+ searchAttribute: ""
6394
+ };
6395
+ appliedSearchFilterRef.current = nextAppliedOnColSwitch;
6396
+ setAppliedSearchFilter(nextAppliedOnColSwitch);
4691
6397
  if (!newUid || !newUid.trim()) {
4692
6398
  setAttributes([]);
4693
6399
  setSelectedAttribute("");
@@ -4707,10 +6413,29 @@ const BulkUpdater = () => {
4707
6413
  setSelectedRelationDocId("");
4708
6414
  setAttributeValue("");
4709
6415
  }
4710
- loadCollectionPage(newUid, 1, void 0, void 0, void 0, filterOperator, filterQuery, entrySearch, true, "");
6416
+ loadCollectionPage(
6417
+ newUid,
6418
+ 1,
6419
+ void 0,
6420
+ void 0,
6421
+ void 0,
6422
+ nextAppliedOnColSwitch.filterOperator,
6423
+ nextAppliedOnColSwitch.filterQuery,
6424
+ nextAppliedOnColSwitch.entrySearch,
6425
+ true,
6426
+ ""
6427
+ );
4711
6428
  };
4712
6429
  const handleAttributeChange = (newAttr) => {
4713
6430
  if (newAttr !== selectedAttribute) {
6431
+ if (totalDirtyCellsCount > 0) {
6432
+ if (!window.confirm(
6433
+ `You have ${totalDirtyCellsCount} unsaved Grid Edit(s) for "${selectedAttribute}". Switching Target Attribute will discard them. Continue?`
6434
+ )) {
6435
+ return;
6436
+ }
6437
+ }
6438
+ setGridEdits({});
4714
6439
  setSelectedAttribute(newAttr);
4715
6440
  try {
4716
6441
  if (newAttr) {
@@ -4732,13 +6457,13 @@ const BulkUpdater = () => {
4732
6457
  const filteredCollections = React.useMemo(() => {
4733
6458
  return selectedCol ? [selectedCol] : [];
4734
6459
  }, [selectedCol]);
4735
- const getAttrDepth = (attr) => attributesMeta[attr]?.depth ?? (attr.includes(".") ? attr.split(".").length - 1 : 0);
6460
+ const getAttrDepth = (attr) => selectedCol?.attributesMeta?.[attr]?.depth ?? attributesMeta[attr]?.depth ?? (attr.includes(".") ? attr.split(".").length - 1 : 0);
4736
6461
  const availableColAttributes = React.useMemo(() => {
4737
6462
  return selectedCol?.attributes || attributes || [];
4738
6463
  }, [selectedCol, attributes]);
4739
6464
  const depthFilteredAttributes = React.useMemo(() => {
4740
6465
  return availableColAttributes.filter((attr) => getAttrDepth(attr) <= componentDepth);
4741
- }, [availableColAttributes, componentDepth, attributesMeta]);
6466
+ }, [availableColAttributes, componentDepth, attributesMeta, selectedCol]);
4742
6467
  const memoizedComboboxOptions = React.useMemo(() => {
4743
6468
  if (depthFilteredAttributes.length === 0) {
4744
6469
  return /* @__PURE__ */ jsxRuntime.jsx(designSystem.ComboboxOption, { value: "__none__", disabled: true, textValue: "No attributes available", children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: [
@@ -4787,20 +6512,6 @@ const BulkUpdater = () => {
4787
6512
  const handleSearchAttributeChange = (newAttr) => {
4788
6513
  const finalAttr = newAttr === "__default__" ? "" : newAttr;
4789
6514
  setSearchAttribute(finalAttr);
4790
- if (selectedCollectionUid) {
4791
- loadCollectionPage(
4792
- selectedCollectionUid,
4793
- 1,
4794
- void 0,
4795
- void 0,
4796
- void 0,
4797
- filterOperator,
4798
- filterQuery,
4799
- entrySearch,
4800
- true,
4801
- finalAttr
4802
- );
4803
- }
4804
6515
  };
4805
6516
  const handleCollectionPageSizeChange = (colUid, newSize) => {
4806
6517
  const capped = Math.min(500, Math.max(1, newSize));
@@ -4856,9 +6567,13 @@ const BulkUpdater = () => {
4856
6567
  };
4857
6568
  const entryMatchesFilter = (entry, attr) => {
4858
6569
  const matches = getAllNestedValues(entry, attr);
4859
- if (useRegex && regexPattern.trim()) {
6570
+ const activeOp = appliedSearchFilter.filterOperator;
6571
+ const activeQuery = appliedSearchFilter.filterQuery || "";
6572
+ const activeUseRegex = Boolean(appliedSearchFilter.useRegex);
6573
+ const activeRegexPattern = appliedSearchFilter.regexPattern || "";
6574
+ if (activeUseRegex && activeRegexPattern.trim()) {
4860
6575
  try {
4861
- const regex = new RegExp(regexPattern, "i");
6576
+ const regex = new RegExp(activeRegexPattern, "i");
4862
6577
  const anyRegexMatch = matches.some((m) => regex.test(formatDisplayValue(m.value)));
4863
6578
  if (!anyRegexMatch) {
4864
6579
  return false;
@@ -4866,22 +6581,22 @@ const BulkUpdater = () => {
4866
6581
  } catch {
4867
6582
  }
4868
6583
  }
4869
- if (filterOperator === "none") return true;
6584
+ if (activeOp === "none") return true;
4870
6585
  if (matches.length === 0) {
4871
- return filterOperator === "empty";
6586
+ return activeOp === "empty";
4872
6587
  }
4873
6588
  const checkMatch = (val) => {
4874
6589
  const displayStr = formatDisplayValue(val);
4875
6590
  const isValEmpty = val === void 0 || val === null || Array.isArray(val) && val.length === 0 || displayStr.trim() === "" || displayStr.trim().toLowerCase() === "(not set)" || displayStr.trim().toLowerCase() === "(empty / not set)" || displayStr.trim().toLowerCase() === "(empty / unlinked)";
4876
- if (filterOperator === "empty") return isValEmpty;
4877
- if (filterOperator === "not_empty") return !isValEmpty;
6591
+ if (activeOp === "empty") return isValEmpty;
6592
+ if (activeOp === "not_empty") return !isValEmpty;
4878
6593
  if (isValEmpty) return false;
4879
- const q = filterQuery.trim().toLowerCase();
6594
+ const q = activeQuery.trim().toLowerCase();
4880
6595
  if (!q) return true;
4881
6596
  const testString = (str) => {
4882
6597
  if (str === void 0 || str === null) return false;
4883
6598
  const s = String(str).trim().toLowerCase();
4884
- switch (filterOperator) {
6599
+ switch (activeOp) {
4885
6600
  case "equals":
4886
6601
  return s === q;
4887
6602
  case "contains":
@@ -4912,18 +6627,22 @@ const BulkUpdater = () => {
4912
6627
  }
4913
6628
  return testString(displayStr);
4914
6629
  };
4915
- if (filterOperator === "empty") {
6630
+ if (activeOp === "empty") {
4916
6631
  return matches.every((m) => checkMatch(m.value));
4917
6632
  }
4918
6633
  return matches.some((m) => checkMatch(m.value));
4919
6634
  };
4920
6635
  const getVisibleEntries = (col) => {
4921
6636
  const pageState = collectionPages[col.uid];
4922
- const raw = pageState ? pageState.entries : col.entries || [];
4923
- if (statusFilter === "all") return raw;
6637
+ let raw = pageState ? pageState.entries : col.entries || [];
6638
+ if (gridEditMode && gridFilterModifiedOnly) {
6639
+ raw = raw.filter((entry) => Boolean(gridEdits[`${col.uid}${KEY_SEP}${entry.documentId}`]));
6640
+ }
6641
+ const activeStatus = appliedSearchFilter.statusFilter || "all";
6642
+ if (activeStatus === "all") return raw;
4924
6643
  return raw.filter((entry) => {
4925
6644
  const lifecycle = getEntryLifecycleStatus(entry, col, pendingBatches);
4926
- return lifecycle.status === statusFilter;
6645
+ return lifecycle.status === activeStatus;
4927
6646
  });
4928
6647
  };
4929
6648
  const matchingEntriesCount = React__default.default.useMemo(() => {
@@ -4933,7 +6652,7 @@ const BulkUpdater = () => {
4933
6652
  count += getVisibleEntries(col).length;
4934
6653
  });
4935
6654
  return count;
4936
- }, [filteredCollections, collectionPages, isFilterActive, statusFilter, pendingBatches]);
6655
+ }, [filteredCollections, collectionPages, isFilterActive, appliedSearchFilter, pendingBatches, gridEditMode, gridFilterModifiedOnly, gridEdits]);
4937
6656
  const selectAllMatching = () => {
4938
6657
  const updated = { ...selectedEntries };
4939
6658
  filteredCollections.forEach((col) => {
@@ -4961,7 +6680,19 @@ const BulkUpdater = () => {
4961
6680
  setEntrySearch("");
4962
6681
  setStatusFilter("all");
4963
6682
  setRegexPattern("");
4964
- setSelectedEntries({});
6683
+ appliedSearchFilterRef.current = EMPTY_SEARCH_FILTER;
6684
+ setAppliedSearchFilter(EMPTY_SEARCH_FILTER);
6685
+ if (gridEditMode) {
6686
+ setSelectedEntries((prev) => {
6687
+ const retained = {};
6688
+ Object.keys(gridEdits).forEach((k) => {
6689
+ if (prev[k]) retained[k] = true;
6690
+ });
6691
+ return retained;
6692
+ });
6693
+ } else {
6694
+ setSelectedEntries({});
6695
+ }
4965
6696
  collections.forEach((col) => {
4966
6697
  loadCollectionPage(col.uid, 1, void 0, void 0, void 0, "none", "", "", false, "");
4967
6698
  });
@@ -5006,58 +6737,71 @@ const BulkUpdater = () => {
5006
6737
  const deselectAll = () => {
5007
6738
  setSelectedEntries({});
5008
6739
  };
5009
- const getSelectedBreakdown = () => {
6740
+ const getSelectedBreakdown = (onlyKeys) => {
5010
6741
  const breakdown = {};
5011
- Object.keys(selectedEntries).forEach((key) => {
5012
- if (selectedEntries[key]) {
5013
- const parts = key.split(KEY_SEP);
5014
- if (parts.length === 2) {
5015
- const uid = parts[0];
5016
- const col = collections.find((c) => c.uid === uid);
5017
- const name = col?.displayName || uid;
5018
- breakdown[name] = (breakdown[name] || 0) + 1;
5019
- }
6742
+ const keysToCount = onlyKeys || Object.keys(selectedEntries).filter((k) => selectedEntries[k]);
6743
+ keysToCount.forEach((key) => {
6744
+ const parts = key.split(KEY_SEP);
6745
+ if (parts.length === 2) {
6746
+ const uid = parts[0];
6747
+ const col = collections.find((c) => c.uid === uid);
6748
+ const name = col?.displayName || uid;
6749
+ breakdown[name] = (breakdown[name] || 0) + 1;
5020
6750
  }
5021
6751
  });
5022
6752
  return breakdown;
5023
6753
  };
5024
- const selectedLifecycleStats = React.useMemo(() => {
5025
- let published = 0;
5026
- let modified = 0;
5027
- let draft = 0;
5028
- let pendingReview = 0;
5029
- let unknown = 0;
5030
- Object.keys(selectedEntries).forEach((key) => {
5031
- if (!selectedEntries[key]) return;
5032
- const parts = key.split(KEY_SEP);
5033
- if (parts.length !== 2) return;
5034
- const [uid, docId] = parts;
5035
- const col = collections.find((c) => c.uid === uid) || null;
5036
- const entry = collectionPages[uid]?.entries?.find((e) => e.documentId === docId || String(e.id) === docId) || col?.entries?.find((e) => e.documentId === docId || String(e.id) === docId);
5037
- if (col && col.draftAndPublish === false) {
5038
- published++;
5039
- } else if (entry) {
5040
- const { status } = getEntryLifecycleStatus(entry, col, pendingBatches);
5041
- if (status === "published") published++;
5042
- else if (status === "modified") modified++;
5043
- else if (status === "draft") draft++;
5044
- else if (status === "pending_review") pendingReview++;
5045
- else unknown++;
5046
- } else {
5047
- draft++;
5048
- }
5049
- });
5050
- const unreviewedCount = draft + modified + pendingReview + unknown;
5051
- return {
5052
- published,
5053
- modified,
5054
- draft,
5055
- pendingReview,
5056
- unknown,
5057
- unreviewedCount,
5058
- total: published + modified + draft + pendingReview + unknown
5059
- };
5060
- }, [selectedEntries, collections, collectionPages, pendingBatches]);
6754
+ const computeLifecycleStatsForKeys = React__default.default.useCallback(
6755
+ (keys) => {
6756
+ let published = 0;
6757
+ let modified = 0;
6758
+ let draft = 0;
6759
+ let pendingReview = 0;
6760
+ let unknown = 0;
6761
+ keys.forEach((key) => {
6762
+ const parts = key.split(KEY_SEP);
6763
+ if (parts.length !== 2) return;
6764
+ const [uid, docId] = parts;
6765
+ const col = collections.find((c) => c.uid === uid) || null;
6766
+ const entry = collectionPages[uid]?.entries?.find((e) => e.documentId === docId || String(e.id) === docId) || col?.entries?.find((e) => e.documentId === docId || String(e.id) === docId);
6767
+ if (col && col.draftAndPublish === false) {
6768
+ published++;
6769
+ } else if (entry) {
6770
+ const { status } = getEntryLifecycleStatus(entry, col, pendingBatches);
6771
+ if (status === "published") published++;
6772
+ else if (status === "modified") modified++;
6773
+ else if (status === "draft") draft++;
6774
+ else if (status === "pending_review") pendingReview++;
6775
+ else unknown++;
6776
+ } else {
6777
+ draft++;
6778
+ }
6779
+ });
6780
+ const unreviewedCount = draft + modified + pendingReview + unknown;
6781
+ return {
6782
+ published,
6783
+ modified,
6784
+ draft,
6785
+ pendingReview,
6786
+ unknown,
6787
+ unreviewedCount,
6788
+ total: published + modified + draft + pendingReview + unknown
6789
+ };
6790
+ },
6791
+ [collections, collectionPages, pendingBatches]
6792
+ );
6793
+ const selectedLifecycleStats = React.useMemo(
6794
+ () => computeLifecycleStatsForKeys(Object.keys(selectedEntries).filter((k) => selectedEntries[k])),
6795
+ [selectedEntries, computeLifecycleStatsForKeys]
6796
+ );
6797
+ const gridTargetKeys = React.useMemo(
6798
+ () => gridSerialized.targets.map((t) => `${t.uid}${KEY_SEP}${t.documentId}`),
6799
+ [gridSerialized]
6800
+ );
6801
+ const updateModalLifecycleStats = React.useMemo(
6802
+ () => gridEditMode ? computeLifecycleStatsForKeys(gridTargetKeys) : selectedLifecycleStats,
6803
+ [gridEditMode, gridTargetKeys, computeLifecycleStatsForKeys, selectedLifecycleStats]
6804
+ );
5061
6805
  const handleOpenConfirmModal = () => {
5062
6806
  if (!selectedAttribute) {
5063
6807
  toggleNotification({
@@ -5066,13 +6810,30 @@ const BulkUpdater = () => {
5066
6810
  });
5067
6811
  return;
5068
6812
  }
5069
- const totalSelected = Object.values(selectedEntries).filter(Boolean).length;
5070
- if (totalSelected === 0) {
5071
- toggleNotification({
5072
- type: "warning",
5073
- message: "Please select at least one collection type or entry to update"
5074
- });
5075
- return;
6813
+ if (gridEditMode) {
6814
+ if (gridSerialized.targets.length === 0) {
6815
+ toggleNotification({
6816
+ type: "warning",
6817
+ message: "Please edit at least one selected cell or block in the grid before updating"
6818
+ });
6819
+ return;
6820
+ }
6821
+ if (gridSerialized.hasValidationErrors) {
6822
+ toggleNotification({
6823
+ type: "danger",
6824
+ message: "Please resolve inline validation errors highlighted in red before updating"
6825
+ });
6826
+ return;
6827
+ }
6828
+ } else {
6829
+ const totalSelected = Object.values(selectedEntries).filter(Boolean).length;
6830
+ if (totalSelected === 0) {
6831
+ toggleNotification({
6832
+ type: "warning",
6833
+ message: "Please select at least one collection type or entry to update"
6834
+ });
6835
+ return;
6836
+ }
5076
6837
  }
5077
6838
  setPublishStrategy("safe");
5078
6839
  setUnreviewedConsent(false);
@@ -5086,44 +6847,63 @@ const BulkUpdater = () => {
5086
6847
  });
5087
6848
  return;
5088
6849
  }
5089
- const targets = [];
5090
- Object.keys(selectedEntries).forEach((key) => {
5091
- if (selectedEntries[key]) {
5092
- const parts = key.split(KEY_SEP);
5093
- if (parts.length === 2) {
5094
- const colUid = parts[0];
5095
- const docId = parts[1];
5096
- const targetObj = { uid: colUid, documentId: docId };
5097
- if (selectedDzBlocks[key] && selectedDzBlocks[key].length > 0) {
5098
- targetObj.dynamicZoneIndexes = selectedDzBlocks[key];
5099
- }
5100
- const colPage = collectionPages[colUid];
5101
- const cachedEntry = colPage?.entries?.find((e) => e.documentId === docId);
5102
- if (cachedEntry) {
5103
- if (cachedEntry.status) targetObj.status = cachedEntry.status;
5104
- if (cachedEntry.publishedAt) targetObj.publishedAt = cachedEntry.publishedAt;
5105
- if (cachedEntry.locale) targetObj.locale = cachedEntry.locale;
6850
+ let targets = [];
6851
+ if (gridEditMode) {
6852
+ if (gridSerialized.hasValidationErrors) {
6853
+ toggleNotification({
6854
+ type: "danger",
6855
+ message: "Please fix inline validation errors before previewing changes"
6856
+ });
6857
+ return;
6858
+ }
6859
+ targets = gridSerialized.targets;
6860
+ if (targets.length === 0) {
6861
+ toggleNotification({
6862
+ type: "warning",
6863
+ message: "Please modify and select at least one grid cell or block to preview"
6864
+ });
6865
+ return;
6866
+ }
6867
+ } else {
6868
+ Object.keys(selectedEntries).forEach((key) => {
6869
+ if (selectedEntries[key]) {
6870
+ const parts = key.split(KEY_SEP);
6871
+ if (parts.length === 2) {
6872
+ const colUid = parts[0];
6873
+ const docId = parts[1];
6874
+ const targetObj = { uid: colUid, documentId: docId };
6875
+ if (selectedDzBlocks[key] && selectedDzBlocks[key].length > 0) {
6876
+ targetObj.dynamicZoneIndexes = selectedDzBlocks[key];
6877
+ }
6878
+ const colPage = collectionPages[colUid];
6879
+ const cachedEntry = colPage?.entries?.find((e) => e.documentId === docId);
6880
+ if (cachedEntry) {
6881
+ if (cachedEntry.status) targetObj.status = cachedEntry.status;
6882
+ if (cachedEntry.publishedAt) targetObj.publishedAt = cachedEntry.publishedAt;
6883
+ if (cachedEntry.locale) targetObj.locale = cachedEntry.locale;
6884
+ }
6885
+ targets.push(targetObj);
5106
6886
  }
5107
- targets.push(targetObj);
5108
6887
  }
5109
- }
5110
- });
5111
- if (targets.length === 0) {
5112
- toggleNotification({
5113
- type: "warning",
5114
- message: "Please select at least one collection type or entry to preview"
5115
6888
  });
5116
- return;
6889
+ if (targets.length === 0) {
6890
+ toggleNotification({
6891
+ type: "warning",
6892
+ message: "Please select at least one collection type or entry to preview"
6893
+ });
6894
+ return;
6895
+ }
5117
6896
  }
5118
6897
  setShowPreviewModal(true);
5119
6898
  setPreviewLoading(true);
5120
6899
  try {
5121
6900
  const res = await post("/bulk-updater/preview", {
5122
6901
  attribute: selectedAttribute,
5123
- value: attributeValue,
6902
+ value: gridEditMode ? "" : attributeValue,
6903
+ editMode: gridEditMode ? "grid" : "common",
5124
6904
  selectedEntries: targets,
5125
- isRegex: useRegex,
5126
- regexPattern,
6905
+ isRegex: gridEditMode ? false : useRegex,
6906
+ regexPattern: gridEditMode ? "" : regexPattern,
5127
6907
  publishOnApproval
5128
6908
  });
5129
6909
  if (res.data && res.data.success) {
@@ -5144,28 +6924,33 @@ const BulkUpdater = () => {
5144
6924
  }
5145
6925
  };
5146
6926
  const executeBatchWithMode = async (executionMode, forceImmediate = false) => {
5147
- const targets = [];
5148
- Object.keys(selectedEntries).forEach((key) => {
5149
- if (selectedEntries[key]) {
5150
- const parts = key.split(KEY_SEP);
5151
- if (parts.length === 2) {
5152
- const colUid = parts[0];
5153
- const docId = parts[1];
5154
- const targetObj = { uid: colUid, documentId: docId };
5155
- if (selectedDzBlocks[key] && selectedDzBlocks[key].length > 0) {
5156
- targetObj.dynamicZoneIndexes = selectedDzBlocks[key];
5157
- }
5158
- const colPage = collectionPages[colUid];
5159
- const cachedEntry = colPage?.entries?.find((e) => e.documentId === docId);
5160
- if (cachedEntry) {
5161
- if (cachedEntry.status) targetObj.status = cachedEntry.status;
5162
- if (cachedEntry.publishedAt) targetObj.publishedAt = cachedEntry.publishedAt;
5163
- if (cachedEntry.locale) targetObj.locale = cachedEntry.locale;
6927
+ let targets = [];
6928
+ if (gridEditMode) {
6929
+ targets = gridSerialized.targets;
6930
+ } else {
6931
+ Object.keys(selectedEntries).forEach((key) => {
6932
+ if (selectedEntries[key]) {
6933
+ const parts = key.split(KEY_SEP);
6934
+ if (parts.length === 2) {
6935
+ const colUid = parts[0];
6936
+ const docId = parts[1];
6937
+ const targetObj = { uid: colUid, documentId: docId };
6938
+ if (selectedDzBlocks[key] && selectedDzBlocks[key].length > 0) {
6939
+ targetObj.dynamicZoneIndexes = selectedDzBlocks[key];
6940
+ }
6941
+ const colPage = collectionPages[colUid];
6942
+ const cachedEntry = colPage?.entries?.find((e) => e.documentId === docId);
6943
+ if (cachedEntry) {
6944
+ if (cachedEntry.status) targetObj.status = cachedEntry.status;
6945
+ if (cachedEntry.publishedAt) targetObj.publishedAt = cachedEntry.publishedAt;
6946
+ if (cachedEntry.locale) targetObj.locale = cachedEntry.locale;
6947
+ }
6948
+ targets.push(targetObj);
5164
6949
  }
5165
- targets.push(targetObj);
5166
6950
  }
5167
- }
5168
- });
6951
+ });
6952
+ }
6953
+ const displaySummaryVal = gridEditMode ? `Grid Editing (${gridSerialized.totalEditCount} edits across ${targets.length} records)` : attributeValue;
5169
6954
  try {
5170
6955
  setUpdating(true);
5171
6956
  setShowConfirmModal(false);
@@ -5180,7 +6965,7 @@ const BulkUpdater = () => {
5180
6965
  status: "processing",
5181
6966
  executionMode,
5182
6967
  attribute: selectedAttribute,
5183
- value: attributeValue,
6968
+ value: displaySummaryVal,
5184
6969
  totalTargets: targets.length,
5185
6970
  processedCount: 0,
5186
6971
  updatedCount: 0,
@@ -5195,10 +6980,11 @@ const BulkUpdater = () => {
5195
6980
  });
5196
6981
  const payload = {
5197
6982
  attribute: selectedAttribute,
5198
- value: attributeValue,
6983
+ value: gridEditMode ? "" : attributeValue,
6984
+ editMode: gridEditMode ? "grid" : "common",
5199
6985
  selectedEntries: targets,
5200
- isRegex: useRegex,
5201
- regexPattern,
6986
+ isRegex: gridEditMode ? false : useRegex,
6987
+ regexPattern: gridEditMode ? "" : regexPattern,
5202
6988
  executionMode,
5203
6989
  makerNotes: makerNotesInput,
5204
6990
  forceImmediate,
@@ -5210,11 +6996,12 @@ const BulkUpdater = () => {
5210
6996
  const res = await post("/bulk-updater/batch-update", payload);
5211
6997
  setIsSubmittingBatch(false);
5212
6998
  if (res.data && res.data.success) {
5213
- setSelectedEntries({});
5214
- setSelectedDzBlocks({});
5215
6999
  const finalBatchId = res.data.batchId;
5216
7000
  setDashboardBatchId(finalBatchId);
5217
7001
  if (res.data.pending) {
7002
+ setSelectedEntries({});
7003
+ setSelectedDzBlocks({});
7004
+ if (gridEditMode) setGridEdits({});
5218
7005
  setDashboardJob({
5219
7006
  id: finalBatchId,
5220
7007
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
@@ -5222,7 +7009,7 @@ const BulkUpdater = () => {
5222
7009
  executionMode,
5223
7010
  scheduledFor: res.data.scheduledFor,
5224
7011
  attribute: selectedAttribute,
5225
- value: attributeValue,
7012
+ value: displaySummaryVal,
5226
7013
  totalTargets: targets.length,
5227
7014
  processedCount: 0,
5228
7015
  updatedCount: 0,
@@ -5240,7 +7027,31 @@ const BulkUpdater = () => {
5240
7027
  });
5241
7028
  await fetchPendingBatches();
5242
7029
  } else {
5243
- setLastResults(res.data.results || []);
7030
+ const resultList = res.data.results || [];
7031
+ if (gridEditMode) {
7032
+ const failedKeys = new Set(
7033
+ resultList.filter((r) => r.status === "error" && r.uid && r.documentId).map((r) => `${r.uid}${KEY_SEP}${r.documentId}`)
7034
+ );
7035
+ setGridEdits((prev) => {
7036
+ const next = {};
7037
+ for (const k of Object.keys(prev)) {
7038
+ if (failedKeys.has(k)) next[k] = prev[k];
7039
+ }
7040
+ return next;
7041
+ });
7042
+ setSelectedEntries((prev) => {
7043
+ const next = {};
7044
+ for (const k of Object.keys(prev)) {
7045
+ if (failedKeys.has(k) && prev[k]) next[k] = true;
7046
+ }
7047
+ return next;
7048
+ });
7049
+ setSelectedDzBlocks({});
7050
+ } else {
7051
+ setSelectedEntries({});
7052
+ setSelectedDzBlocks({});
7053
+ }
7054
+ setLastResults(resultList);
5244
7055
  setUpdateSummary({
5245
7056
  updatedCount: res.data.updatedCount || 0,
5246
7057
  skippedCount: res.data.skippedCount || 0,
@@ -5253,15 +7064,15 @@ const BulkUpdater = () => {
5253
7064
  status: res.data.status || "successful",
5254
7065
  executionMode: "immediate",
5255
7066
  attribute: selectedAttribute,
5256
- value: attributeValue,
7067
+ value: res.data.value || displaySummaryVal,
5257
7068
  totalTargets: res.data.totalTargets || targets.length,
5258
- processedCount: res.data.results?.length || targets.length,
7069
+ processedCount: resultList.length || targets.length,
5259
7070
  updatedCount: res.data.updatedCount || 0,
5260
7071
  skippedCount: res.data.skippedCount || 0,
5261
7072
  failedCount: res.data.failedCount || 0,
5262
7073
  isLive: res.data.isLive !== false && res.data.updatedCount > 0,
5263
7074
  publishOnApproval,
5264
- results: res.data.results || []
7075
+ results: resultList
5265
7076
  });
5266
7077
  toggleNotification({
5267
7078
  type: "success",
@@ -5270,17 +7081,18 @@ const BulkUpdater = () => {
5270
7081
  await fetchModels();
5271
7082
  await fetchAuditHistory();
5272
7083
  if (selectedCollectionUid) {
7084
+ const appliedNow = appliedSearchFilterRef.current;
5273
7085
  loadCollectionPage(
5274
7086
  selectedCollectionUid,
5275
7087
  collectionPages[selectedCollectionUid]?.page || 1,
5276
7088
  void 0,
5277
7089
  void 0,
5278
7090
  void 0,
5279
- filterOperator,
5280
- filterQuery,
5281
- entrySearch,
7091
+ appliedNow.filterOperator,
7092
+ appliedNow.filterQuery,
7093
+ appliedNow.entrySearch,
5282
7094
  false,
5283
- searchAttribute
7095
+ appliedNow.searchAttribute
5284
7096
  );
5285
7097
  }
5286
7098
  }
@@ -5980,14 +7792,15 @@ const BulkUpdater = () => {
5980
7792
  matchingEntriesCount === 1 ? "entry" : "entries",
5981
7793
  " found in database"
5982
7794
  ] }),
5983
- searchAttribute && searchAttribute !== selectedAttribute && /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Badge, { backgroundColor: "secondary100", textColor: "secondary700", children: [
7795
+ appliedSearchFilter.searchAttribute && appliedSearchFilter.searchAttribute !== selectedAttribute && /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Badge, { backgroundColor: "secondary100", textColor: "secondary700", children: [
5984
7796
  "Searching by: ",
5985
- searchAttribute,
7797
+ appliedSearchFilter.searchAttribute,
5986
7798
  " → Target to update: ",
5987
7799
  selectedAttribute
5988
- ] })
7800
+ ] }),
7801
+ hasPendingFilterChanges && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { backgroundColor: "warning100", textColor: "warning700", children: "Filters modified — click Search to apply" })
5989
7802
  ] }),
5990
- isFilterActive && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "ghost", size: "S", onClick: clearFilter, children: "Clear Search & Filter" })
7803
+ (isFilterActive || hasPendingFilterChanges || Boolean(searchAttribute) || filterOperator !== "none" || Boolean(entrySearch.trim()) || statusFilter !== "all" || Boolean(useRegex && regexPattern.trim())) && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "ghost", size: "S", onClick: clearFilter, children: "Clear Search & Filter" })
5991
7804
  ] }),
5992
7805
  /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 3, alignItems: "flex-end", wrap: "wrap", children: [
5993
7806
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { style: { width: 280, minWidth: 230 }, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { children: [
@@ -6056,7 +7869,13 @@ const BulkUpdater = () => {
6056
7869
  label: effectiveSearchAttribute ? `Value for "${effectiveSearchAttribute}"` : "Value to match",
6057
7870
  placeholder: "Type value to match...",
6058
7871
  value: filterQuery,
6059
- onChange: (e) => setFilterQuery(e.target.value)
7872
+ onChange: (e) => setFilterQuery(e.target.value),
7873
+ onKeyDown: (e) => {
7874
+ if (e.key === "Enter") {
7875
+ e.preventDefault();
7876
+ handleApplySearch();
7877
+ }
7878
+ }
6060
7879
  }
6061
7880
  ) }),
6062
7881
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { style: { flex: 1, minWidth: 180 }, children: /* @__PURE__ */ jsxRuntime.jsx(
@@ -6065,7 +7884,13 @@ const BulkUpdater = () => {
6065
7884
  label: "Full-text Entry Search",
6066
7885
  placeholder: "Search title, name, or text across records...",
6067
7886
  value: entrySearch,
6068
- onChange: (e) => setEntrySearch(e.target.value)
7887
+ onChange: (e) => setEntrySearch(e.target.value),
7888
+ onKeyDown: (e) => {
7889
+ if (e.key === "Enter") {
7890
+ e.preventDefault();
7891
+ handleApplySearch();
7892
+ }
7893
+ }
6069
7894
  }
6070
7895
  ) }),
6071
7896
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { style: { width: 190, minWidth: 160 }, children: /* @__PURE__ */ jsxRuntime.jsxs(
@@ -6084,6 +7909,17 @@ const BulkUpdater = () => {
6084
7909
  ]
6085
7910
  }
6086
7911
  ) }),
7912
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { children: /* @__PURE__ */ jsxRuntime.jsx(
7913
+ designSystem.Button,
7914
+ {
7915
+ variant: hasPendingFilterChanges ? "default" : "secondary",
7916
+ startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Search, {}),
7917
+ onClick: handleApplySearch,
7918
+ loading: Boolean(selectedCollectionUid && collectionPages[selectedCollectionUid]?.loading),
7919
+ disabled: !selectedCollectionUid || Boolean(selectedCollectionUid && collectionPages[selectedCollectionUid]?.loading),
7920
+ children: "Search"
7921
+ }
7922
+ ) }),
6087
7923
  isFilterActive && /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, alignItems: "center", children: [
6088
7924
  /* @__PURE__ */ jsxRuntime.jsx(
6089
7925
  designSystem.Button,
@@ -6114,6 +7950,7 @@ const BulkUpdater = () => {
6114
7950
  designSystem.Checkbox,
6115
7951
  {
6116
7952
  checked: useRegex,
7953
+ disabled: gridEditMode,
6117
7954
  onCheckedChange: (checked) => setUseRegex(Boolean(checked)),
6118
7955
  children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: "bold", children: "Enable Regex Search & Replace" })
6119
7956
  }
@@ -6121,10 +7958,10 @@ const BulkUpdater = () => {
6121
7958
  /* @__PURE__ */ jsxRuntime.jsx(
6122
7959
  designSystem.Badge,
6123
7960
  {
6124
- backgroundColor: useRegex ? "secondary100" : "neutral200",
6125
- textColor: useRegex ? "secondary700" : "neutral600",
7961
+ backgroundColor: gridEditMode ? "neutral200" : useRegex ? "secondary100" : "neutral200",
7962
+ textColor: gridEditMode ? "neutral600" : useRegex ? "secondary700" : "neutral600",
6126
7963
  size: "S",
6127
- children: useRegex ? "REGEX SEARCH ACTIVE" : "REGEX OFF"
7964
+ children: gridEditMode ? "DISABLED IN GRID EDIT" : useRegex ? "REGEX SEARCH ACTIVE" : "REGEX OFF"
6128
7965
  }
6129
7966
  )
6130
7967
  ] }),
@@ -6549,6 +8386,72 @@ const BulkUpdater = () => {
6549
8386
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral500", children: col.isSingleType ? "1 single entry" : isFilterActive ? `${totalEntries} matching entries in DB` : `${totalEntries} entries` })
6550
8387
  ] })
6551
8388
  ] }),
8389
+ gridEditMode && /* @__PURE__ */ jsxRuntime.jsx(
8390
+ designSystem.Box,
8391
+ {
8392
+ padding: 3,
8393
+ marginBottom: 3,
8394
+ background: "primary100",
8395
+ hasRadius: true,
8396
+ style: { border: "1px solid #d9d8ff" },
8397
+ children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", alignItems: "center", wrap: "wrap", gap: 2, children: [
8398
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, alignItems: "center", wrap: "wrap", children: [
8399
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { backgroundColor: "primary600", textColor: "neutral0", children: "GRID EDITING MODE" }),
8400
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", fontWeight: "bold", textColor: "primary700", children: selectedAttribute ? `Editing "${selectedAttribute}" directly per record & component block` : 'Select an "Attribute to Update" below to enable inline cell editors' }),
8401
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Badge, { backgroundColor: "neutral0", textColor: "primary700", children: [
8402
+ totalDirtyCellsCount,
8403
+ " edit",
8404
+ totalDirtyCellsCount === 1 ? "" : "s",
8405
+ " across ",
8406
+ totalDirtyRecordsCount,
8407
+ " record",
8408
+ totalDirtyRecordsCount === 1 ? "" : "s"
8409
+ ] })
8410
+ ] }),
8411
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, alignItems: "center", wrap: "wrap", children: [
8412
+ (activeAttrMeta?.rootType === "dynamiczone" || activeAttrMeta?.rootRepeatable) && visibleEntries.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(
8413
+ designSystem.Button,
8414
+ {
8415
+ variant: "secondary",
8416
+ size: "S",
8417
+ onClick: () => {
8418
+ const allVisibleKeys = visibleEntries.map((e) => `${col.uid}${KEY_SEP}${e.documentId}`);
8419
+ const anyCollapsed = allVisibleKeys.some((k) => !expandedDzEntries[k]);
8420
+ setExpandedDzEntries((prev) => {
8421
+ const next = { ...prev };
8422
+ allVisibleKeys.forEach((k) => {
8423
+ next[k] = anyCollapsed;
8424
+ });
8425
+ return next;
8426
+ });
8427
+ },
8428
+ children: visibleEntries.some((e) => !expandedDzEntries[`${col.uid}${KEY_SEP}${e.documentId}`]) ? "Expand All Blocks" : "Collapse All Blocks"
8429
+ }
8430
+ ),
8431
+ /* @__PURE__ */ jsxRuntime.jsx(
8432
+ designSystem.Button,
8433
+ {
8434
+ variant: gridFilterModifiedOnly ? "default" : "tertiary",
8435
+ size: "S",
8436
+ onClick: () => setGridFilterModifiedOnly((v) => !v),
8437
+ disabled: totalDirtyRecordsCount === 0 && !gridFilterModifiedOnly,
8438
+ children: gridFilterModifiedOnly ? "Showing Modified Only" : "Filter: Modified Only"
8439
+ }
8440
+ ),
8441
+ /* @__PURE__ */ jsxRuntime.jsx(
8442
+ designSystem.Button,
8443
+ {
8444
+ variant: "danger-light",
8445
+ size: "S",
8446
+ disabled: totalDirtyCellsCount === 0,
8447
+ onClick: () => setGridEdits({}),
8448
+ children: "Discard All Edits"
8449
+ }
8450
+ )
8451
+ ] })
8452
+ ] })
8453
+ }
8454
+ ),
6552
8455
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { className: "bulk-updater-table-container", style: { width: "100%", maxWidth: "100%", minWidth: 0, overflowX: "auto" }, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Table, { colCount: activeColumns.length, rowCount: visibleEntries.length + 1, style: { width: "100%" }, children: [
6553
8456
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Thead, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tr, { children: activeColumns.map(
6554
8457
  (colDef) => renderHeaderCell(colDef, col, currentSort, selectedAttribute, searchAttribute, handleHeaderSortClick)
@@ -6565,12 +8468,27 @@ const BulkUpdater = () => {
6565
8468
  const dzFields = Object.keys(entry).filter(
6566
8469
  (k) => Array.isArray(entry[k]) && entry[k].length > 0 && entry[k].some((item) => item && item.__component)
6567
8470
  );
8471
+ const selectedRootKey = selectedAttribute ? selectedAttribute.split("[")[0].split(".")[0] : "";
8472
+ const expandableArrayFields = gridEditMode && selectedRootKey && activeAttrMeta?.rootRepeatable && !dzFields.includes(selectedRootKey) && Array.isArray(entry[selectedRootKey]) && entry[selectedRootKey].length > 0 ? [...dzFields, selectedRootKey] : dzFields;
8473
+ const recordEdits = gridEdits[key];
8474
+ const gridCtx = gridEditMode ? {
8475
+ gridEditMode: true,
8476
+ selectedAttrMeta: activeAttrMeta,
8477
+ recordEdits,
8478
+ relationOptions,
8479
+ relationOptionsLoading,
8480
+ relationIsMulti: Boolean(relationsMeta[selectedAttribute]?.isMulti),
8481
+ validationRules,
8482
+ onCommitEdit: handleGridCellCommit,
8483
+ onResetEdit: handleGridCellReset
8484
+ } : void 0;
8485
+ const rowOccs = gridEditMode && isDzExpanded && selectedAttribute ? enumerateClientOccurrences(entry, selectedAttribute, col?.attributes, activeAttrMeta) : [];
6568
8486
  return /* @__PURE__ */ jsxRuntime.jsxs(React__default.default.Fragment, { children: [
6569
8487
  /* @__PURE__ */ jsxRuntime.jsx(
6570
8488
  designSystem.Tr,
6571
8489
  {
6572
8490
  style: {
6573
- backgroundColor: isSelected ? "rgba(73, 69, 255, 0.14)" : isMatch ? "rgba(46, 213, 115, 0.08)" : void 0,
8491
+ backgroundColor: recordEdits ? "rgba(73, 69, 255, 0.10)" : isSelected ? "rgba(73, 69, 255, 0.14)" : isMatch ? "rgba(46, 213, 115, 0.08)" : void 0,
6574
8492
  boxShadow: isSelected ? "inset 3px 0 0 0 #4945ff" : isMatch ? "inset 3px 0 0 0 #2ed573" : void 0
6575
8493
  },
6576
8494
  children: activeColumns.map((colDef) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: renderCellContent(
@@ -6586,97 +8504,47 @@ const BulkUpdater = () => {
6586
8504
  pendingBatches,
6587
8505
  isDzExpanded,
6588
8506
  onToggleExpandDz,
6589
- filterQuery
8507
+ filterQuery,
8508
+ gridCtx
6590
8509
  ) }, colDef.key))
6591
8510
  }
6592
8511
  ),
6593
- isDzExpanded && dzFields.map((dzKey) => {
6594
- const blocks = entry[dzKey] || [];
6595
- const targetParsed = parseDynamicZonePath(selectedAttribute);
6596
- const isBlockApplicable = (blockItem) => {
6597
- if (!targetParsed.subPath) return true;
6598
- const scopedPath = `${dzKey}[${blockItem?.__component}].${targetParsed.subPath}`;
6599
- const componentSupports = (col?.attributes || attributes || []).includes(scopedPath);
6600
- return componentSupports || getNestedValue(blockItem, targetParsed.subPath) !== void 0;
6601
- };
6602
- const allApplicableIndexes = blocks.map((_, i) => i).filter((i) => isBlockApplicable(blocks[i]));
6603
- return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tr, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { colSpan: activeColumns.length, style: { padding: "12px 16px", backgroundColor: "rgba(73, 69, 255, 0.02)", borderBottom: "2px solid rgba(73, 69, 255, 0.15)" }, children: /* @__PURE__ */ jsxRuntime.jsxs(
6604
- designSystem.Box,
8512
+ isDzExpanded && expandableArrayFields.map((dzKey) => {
8513
+ const drawerOccurrences = gridEditMode && selectedAttribute ? rowOccs : enumerateClientOccurrences(entry, selectedAttribute, col?.attributes, activeAttrMeta);
8514
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tr, { children: /* @__PURE__ */ jsxRuntime.jsx(
8515
+ designSystem.Td,
6605
8516
  {
6606
- padding: 3,
6607
- background: "neutral0",
6608
- hasRadius: true,
6609
- style: { border: "1px solid rgba(73, 69, 255, 0.25)", boxShadow: "0 2px 8px rgba(0,0,0,0.05)" },
6610
- children: [
6611
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", alignItems: "center", marginBottom: 2, children: [
6612
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, alignItems: "center", children: [
6613
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { variant: "sigma", textColor: "primary700", children: [
6614
- 'DYNAMIC ZONE: "',
6615
- dzKey,
6616
- '" (',
6617
- blocks.length,
6618
- " blocks)"
6619
- ] }),
6620
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { backgroundColor: "primary100", textColor: "primary700", children: "Selective Block Targeting" })
6621
- ] }),
6622
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral500", children: "Selectively choose which blocks to update for this entry" })
6623
- ] }),
6624
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Table, { colCount: 5, rowCount: blocks.length + 1, style: { width: "100%", background: "#fff" }, children: [
6625
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Thead, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { children: [
6626
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { style: { width: 64 }, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", children: "Update?" }) }),
6627
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { style: { width: 60 }, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", children: "Pos" }) }),
6628
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { style: { width: 220 }, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", children: "Component" }) }),
6629
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { variant: "sigma", children: [
6630
- "Target Field Value (",
6631
- selectedAttribute || "selected",
6632
- ")"
6633
- ] }) }),
6634
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", children: "Block Summary" }) })
6635
- ] }) }),
6636
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tbody, { children: blocks.map((block, bIdx) => {
6637
- const compUid = block.__component;
6638
- const compLabel = formatComponentName(compUid);
6639
- const scopedPath = `${dzKey}[${compUid}].${targetParsed.subPath}`;
6640
- const componentSupports = (col?.attributes || attributes || []).includes(scopedPath);
6641
- const blockVal = targetParsed.subPath ? getNestedValue(block, targetParsed.subPath) : void 0;
6642
- const hasTargetAttr = componentSupports || blockVal !== void 0;
6643
- const isBlockChecked = hasTargetAttr && isSelected && (selectedDzBlocks[key] !== void 0 ? selectedDzBlocks[key].includes(bIdx) : true);
6644
- return /* @__PURE__ */ jsxRuntime.jsxs(
6645
- designSystem.Tr,
6646
- {
6647
- style: {
6648
- backgroundColor: isBlockChecked ? "rgba(73, 69, 255, 0.08)" : void 0
6649
- },
6650
- children: [
6651
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(
6652
- designSystem.Checkbox,
6653
- {
6654
- checked: isBlockChecked,
6655
- disabled: !hasTargetAttr,
6656
- onCheckedChange: () => {
6657
- toggleDzBlock(col.uid, entry.documentId, bIdx, allApplicableIndexes);
6658
- }
6659
- }
6660
- ) }),
6661
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { variant: "pi", fontWeight: "bold", children: [
6662
- "#",
6663
- bIdx
6664
- ] }) }),
6665
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Td, { children: [
6666
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { backgroundColor: "neutral150", textColor: "neutral800", children: compLabel }),
6667
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral500", display: "block", style: { fontSize: "0.68rem", marginTop: 2 }, children: compUid })
6668
- ] }),
6669
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: hasTargetAttr ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", fontWeight: "semiBold", textColor: "primary700", children: formatDisplayValue(blockVal) }) : /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { backgroundColor: "neutral100", textColor: "neutral500", children: "Does not contain attribute" }) }),
6670
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", style: { maxWidth: 300, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: block.title || block.name || block.heading || block.body || Object.keys(block).filter((k) => !k.startsWith("_") && k !== "id").slice(0, 3).map((k) => `${k}: ${formatDisplayValue(block[k])}`).join(", ") || "-" }) })
6671
- ]
6672
- },
6673
- bIdx
6674
- );
6675
- }) })
6676
- ] })
6677
- ]
8517
+ colSpan: activeColumns.length,
8518
+ style: {
8519
+ padding: "12px 16px",
8520
+ backgroundColor: "rgba(73, 69, 255, 0.02)",
8521
+ borderBottom: "2px solid rgba(73, 69, 255, 0.15)"
8522
+ },
8523
+ children: /* @__PURE__ */ jsxRuntime.jsx(
8524
+ ComponentOccurrencesDrawer,
8525
+ {
8526
+ colUid: col.uid,
8527
+ rootKey: dzKey,
8528
+ entry,
8529
+ selectedAttribute,
8530
+ attrMeta: activeAttrMeta,
8531
+ colAttributes: col?.attributes || attributes || [],
8532
+ gridEditMode,
8533
+ isSelected,
8534
+ selectedDzBlocks: selectedDzBlocks[key],
8535
+ occurrences: drawerOccurrences,
8536
+ recordEdits,
8537
+ relationOptions,
8538
+ relationOptionsLoading,
8539
+ relationIsMulti: Boolean(relationsMeta[selectedAttribute]?.isMulti),
8540
+ validationRules,
8541
+ onToggleDzBlock: toggleDzBlock,
8542
+ onCommitEdit: handleGridCellCommit,
8543
+ onResetEdit: handleGridCellReset
8544
+ }
8545
+ )
6678
8546
  }
6679
- ) }) }, `${key}-dz-${dzKey}`);
8547
+ ) }, `${key}-dz-${dzKey}`);
6680
8548
  })
6681
8549
  ] }, key);
6682
8550
  }) })
@@ -6775,10 +8643,38 @@ const BulkUpdater = () => {
6775
8643
  marginBottom: 6,
6776
8644
  style: { width: "100%", maxWidth: "100%", minWidth: 0, boxSizing: "border-box" },
6777
8645
  children: [
6778
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "space-between", alignItems: "center", marginBottom: 4, wrap: "wrap", gap: 3, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { children: [
6779
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "delta", tag: "h2", fontWeight: "semiBold", children: "2. Configure Attribute Update" }),
6780
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: "Select the target attribute to update and configure the replacement value for your selected entries." })
6781
- ] }) }),
8646
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", alignItems: "center", marginBottom: 4, wrap: "wrap", gap: 3, children: [
8647
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { children: [
8648
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "delta", tag: "h2", fontWeight: "semiBold", children: "2. Configure Attribute Update" }),
8649
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: "Select the target attribute to update and either apply a common value or enable inline Grid Editing." })
8650
+ ] }),
8651
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { gap: 3, alignItems: "center", wrap: "wrap", children: /* @__PURE__ */ jsxRuntime.jsx(
8652
+ designSystem.Box,
8653
+ {
8654
+ padding: 2,
8655
+ paddingLeft: 3,
8656
+ paddingRight: 3,
8657
+ background: gridEditMode ? "primary100" : "neutral100",
8658
+ hasRadius: true,
8659
+ style: { border: gridEditMode ? "1px solid #4945ff" : "1px solid #eaeaef" },
8660
+ children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, alignItems: "center", children: [
8661
+ /* @__PURE__ */ jsxRuntime.jsx(
8662
+ designSystem.Checkbox,
8663
+ {
8664
+ checked: gridEditMode,
8665
+ onCheckedChange: (checked) => handleToggleGridEditMode(Boolean(checked)),
8666
+ children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: "bold", textColor: gridEditMode ? "primary700" : "neutral800", children: "Edit Values in Grid" })
8667
+ }
8668
+ ),
8669
+ gridEditMode && /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Badge, { backgroundColor: "primary600", textColor: "neutral0", size: "S", children: [
8670
+ "ON (",
8671
+ gridSerialized.totalEditCount,
8672
+ " edits)"
8673
+ ] })
8674
+ ] })
8675
+ }
8676
+ ) })
8677
+ ] }),
6782
8678
  /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 3, alignItems: "flex-end", wrap: "wrap", children: [
6783
8679
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { style: { width: 280, minWidth: 230 }, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { children: [
6784
8680
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: "Attribute to Update" }),
@@ -6805,7 +8701,35 @@ const BulkUpdater = () => {
6805
8701
  `update-attr-${selectedCollectionUid}`
6806
8702
  )
6807
8703
  ] }) }),
6808
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { style: { flex: 1, minWidth: 340 }, children: relationsMeta[selectedAttribute] ? /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 1, style: { width: "100%" }, children: [
8704
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { style: { flex: 1, minWidth: 340 }, children: gridEditMode ? /* @__PURE__ */ jsxRuntime.jsx(
8705
+ designSystem.Box,
8706
+ {
8707
+ padding: 3,
8708
+ background: "primary100",
8709
+ hasRadius: true,
8710
+ style: { border: "1px solid #d9d8ff" },
8711
+ children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", alignItems: "center", wrap: "wrap", gap: 2, children: [
8712
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { children: [
8713
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", fontWeight: "bold", textColor: "primary700", display: "block", children: "Common value input hidden — Grid Editing Mode active" }),
8714
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral700", children: gridSerialized.targets.length > 0 ? `Ready: ${gridSerialized.totalEditCount} edited field/block value(s) across ${gridSerialized.targets.length} selected record(s).` : "Edit cell values directly in the table above (or expand component blocks) to queue heterogeneous updates." }),
8715
+ gridSerialized.hasValidationErrors && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "danger700", fontWeight: "bold", display: "block", children: "⚠️ Resolve inline red validation errors before previewing or updating." })
8716
+ ] }),
8717
+ totalDirtyCellsCount > 0 && /* @__PURE__ */ jsxRuntime.jsxs(
8718
+ designSystem.Button,
8719
+ {
8720
+ variant: "danger-light",
8721
+ size: "S",
8722
+ onClick: () => setGridEdits({}),
8723
+ children: [
8724
+ "Discard Edits (",
8725
+ totalDirtyCellsCount,
8726
+ ")"
8727
+ ]
8728
+ }
8729
+ )
8730
+ ] })
8731
+ }
8732
+ ) : relationsMeta[selectedAttribute] ? /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 1, style: { width: "100%" }, children: [
6809
8733
  /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, alignItems: "center", wrap: "wrap", children: [
6810
8734
  /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { variant: "pi", fontWeight: "bold", textColor: "neutral700", children: [
6811
8735
  "Target ",
@@ -6890,10 +8814,10 @@ const BulkUpdater = () => {
6890
8814
  size: "L",
6891
8815
  onClick: handleOpenPreviewModal,
6892
8816
  loading: previewLoading,
6893
- disabled: loading || totalSelectedCount === 0 || !selectedAttribute || !selectedAttribute.trim(),
8817
+ disabled: loading || !selectedAttribute || !selectedAttribute.trim() || (gridEditMode ? gridSerialized.targets.length === 0 || gridSerialized.hasValidationErrors : totalSelectedCount === 0),
6894
8818
  children: [
6895
8819
  "Preview Changes (",
6896
- totalSelectedCount,
8820
+ gridEditMode ? gridSerialized.targets.length : totalSelectedCount,
6897
8821
  ")"
6898
8822
  ]
6899
8823
  }
@@ -6906,10 +8830,10 @@ const BulkUpdater = () => {
6906
8830
  size: "L",
6907
8831
  onClick: handleOpenConfirmModal,
6908
8832
  loading: updating,
6909
- disabled: loading || totalSelectedCount === 0 || !selectedAttribute || !selectedAttribute.trim(),
8833
+ disabled: loading || !selectedAttribute || !selectedAttribute.trim() || (gridEditMode ? gridSerialized.targets.length === 0 || gridSerialized.hasValidationErrors : totalSelectedCount === 0),
6910
8834
  children: [
6911
8835
  "Update Selected (",
6912
- totalSelectedCount,
8836
+ gridEditMode ? gridSerialized.targets.length : totalSelectedCount,
6913
8837
  ")"
6914
8838
  ]
6915
8839
  }
@@ -6996,11 +8920,11 @@ const BulkUpdater = () => {
6996
8920
  "Attribute: ",
6997
8921
  selectedAttribute,
6998
8922
  " ",
6999
- attributesMeta[selectedAttribute]?.type ? `(${attributesMeta[selectedAttribute].type})` : ""
8923
+ activeAttrMeta?.type ? `(${activeAttrMeta.type})` : ""
7000
8924
  ] }),
7001
- attributesMeta[selectedAttribute]?.depth ? /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Badge, { backgroundColor: "neutral200", textColor: "neutral700", children: [
8925
+ activeAttrMeta?.depth ? /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Badge, { backgroundColor: "neutral200", textColor: "neutral700", children: [
7002
8926
  "Nesting Level: L",
7003
- attributesMeta[selectedAttribute].depth
8927
+ activeAttrMeta.depth
7004
8928
  ] }) : null,
7005
8929
  selectedCol.draftAndPublish ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { backgroundColor: "success100", textColor: "success700", children: "Draft & Publish Enabled" }) : /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { backgroundColor: "warning100", textColor: "warning700", children: "Direct Publish Only" })
7006
8930
  ] }) }) })
@@ -7438,7 +9362,15 @@ const BulkUpdater = () => {
7438
9362
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", children: "Previous Value" }) }),
7439
9363
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", children: "Applied Value" }) })
7440
9364
  ] }) }),
7441
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tbody, { children: rec.diffs.map((d, dIdx) => /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { children: [
9365
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tbody, { children: rec.diffs.flatMap(
9366
+ (d) => Array.isArray(d.dynamicZoneDiffs) && d.dynamicZoneDiffs.length > 0 ? d.dynamicZoneDiffs.map((dz) => ({
9367
+ collectionName: d.collectionName,
9368
+ label: `${d.label}${dz.componentName ? ` [${dz.componentName}]` : ""}`,
9369
+ attribute: dz.attribute || d.attribute,
9370
+ oldValue: dz.oldValue,
9371
+ newValue: dz.newValue
9372
+ })) : [d]
9373
+ ).map((d, dIdx) => /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { children: [
7442
9374
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: "semiBold", children: d.collectionName }) }),
7443
9375
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: d.label }) }),
7444
9376
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { backgroundColor: "secondary100", textColor: "secondary700", children: d.attribute || "field" }) }),
@@ -7527,7 +9459,13 @@ const BulkUpdater = () => {
7527
9459
  ] }),
7528
9460
  /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", alignItems: "center", children: [
7529
9461
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: "semiBold", children: "Target Value:" }),
7530
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", style: { wordBreak: "break-all", maxWidth: 360 }, children: relationsMeta[selectedAttribute] ? /* @__PURE__ */ jsxRuntime.jsx("span", { children: selectedRelationDocId === "__clear__" ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { backgroundColor: "danger100", textColor: "danger700", children: "Clear / Unlink Relation" }) : /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Badge, { backgroundColor: "secondary100", textColor: "secondary700", children: [
9462
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", style: { wordBreak: "break-all", maxWidth: 360 }, children: gridEditMode ? /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Badge, { backgroundColor: "secondary100", textColor: "secondary700", children: [
9463
+ "Grid Editing (",
9464
+ gridSerialized.totalEditCount,
9465
+ " heterogeneous edits across ",
9466
+ gridSerialized.targets.length,
9467
+ " records)"
9468
+ ] }) : relationsMeta[selectedAttribute] ? /* @__PURE__ */ jsxRuntime.jsx("span", { children: selectedRelationDocId === "__clear__" ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { backgroundColor: "danger100", textColor: "danger700", children: "Clear / Unlink Relation" }) : /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Badge, { backgroundColor: "secondary100", textColor: "secondary700", children: [
7531
9469
  relationsMeta[selectedAttribute].isMulti ? `[${relationMode.toUpperCase()}] ` : "",
7532
9470
  relationOptions.find((o) => o.documentId === selectedRelationDocId)?.label || selectedRelationDocId || "(none selected)"
7533
9471
  ] }) }) : useRegex ? /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
@@ -7552,7 +9490,7 @@ const BulkUpdater = () => {
7552
9490
  /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", children: [
7553
9491
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: "semiBold", children: "Total Selected Records:" }),
7554
9492
  /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { fontWeight: "bold", textColor: "primary600", children: [
7555
- totalSelectedCount,
9493
+ gridEditMode ? gridSerialized.targets.length : totalSelectedCount,
7556
9494
  " records"
7557
9495
  ] })
7558
9496
  ] }),
@@ -7588,31 +9526,31 @@ const BulkUpdater = () => {
7588
9526
  /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { marginBottom: 4, padding: 3, background: "neutral100", hasRadius: true, style: { border: "1px solid rgba(120, 120, 150, 0.15)" }, children: [
7589
9527
  /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { variant: "sigma", textColor: "neutral600", marginBottom: 2, display: "block", children: [
7590
9528
  "LIFECYCLE STATUS BREAKDOWN (",
7591
- totalSelectedCount,
9529
+ gridEditMode ? gridSerialized.targets.length : totalSelectedCount,
7592
9530
  " Selected)"
7593
9531
  ] }),
7594
9532
  /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, wrap: "wrap", children: [
7595
9533
  /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Badge, { backgroundColor: "success100", textColor: "success700", children: [
7596
9534
  "✓ Published / Approved: ",
7597
- selectedLifecycleStats.published
9535
+ updateModalLifecycleStats.published
7598
9536
  ] }),
7599
- selectedLifecycleStats.modified > 0 && /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Badge, { backgroundColor: "primary100", textColor: "primary700", children: [
9537
+ updateModalLifecycleStats.modified > 0 && /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Badge, { backgroundColor: "primary100", textColor: "primary700", children: [
7600
9538
  "📝 Modified (Unreviewed Revisions): ",
7601
- selectedLifecycleStats.modified
9539
+ updateModalLifecycleStats.modified
7602
9540
  ] }),
7603
- selectedLifecycleStats.draft > 0 && /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Badge, { backgroundColor: "neutral200", textColor: "neutral800", children: [
9541
+ updateModalLifecycleStats.draft > 0 && /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Badge, { backgroundColor: "neutral200", textColor: "neutral800", children: [
7604
9542
  "📄 Draft (Never Published): ",
7605
- selectedLifecycleStats.draft
9543
+ updateModalLifecycleStats.draft
7606
9544
  ] }),
7607
- selectedLifecycleStats.pendingReview > 0 && /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Badge, { backgroundColor: "warning100", textColor: "warning700", children: [
9545
+ updateModalLifecycleStats.pendingReview > 0 && /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Badge, { backgroundColor: "warning100", textColor: "warning700", children: [
7608
9546
  "⏳ Pending Review: ",
7609
- selectedLifecycleStats.pendingReview
9547
+ updateModalLifecycleStats.pendingReview
7610
9548
  ] })
7611
9549
  ] })
7612
9550
  ] }),
7613
9551
  /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { marginBottom: 4, children: [
7614
9552
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", marginBottom: 2, display: "block", children: "COLLECTION BREAKDOWN" }),
7615
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", gap: 1, children: Object.entries(getSelectedBreakdown()).map(([name, count]) => /* @__PURE__ */ jsxRuntime.jsxs(
9553
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", gap: 1, children: Object.entries(getSelectedBreakdown(gridEditMode ? gridTargetKeys : void 0)).map(([name, count]) => /* @__PURE__ */ jsxRuntime.jsxs(
7616
9554
  designSystem.Flex,
7617
9555
  {
7618
9556
  justifyContent: "space-between",
@@ -7660,7 +9598,7 @@ const BulkUpdater = () => {
7660
9598
  ] })
7661
9599
  }
7662
9600
  ),
7663
- publishOnApproval && selectedLifecycleStats.unreviewedCount > 0 && /* @__PURE__ */ jsxRuntime.jsxs(
9601
+ publishOnApproval && updateModalLifecycleStats.unreviewedCount > 0 && /* @__PURE__ */ jsxRuntime.jsxs(
7664
9602
  designSystem.Box,
7665
9603
  {
7666
9604
  padding: 4,
@@ -7704,11 +9642,11 @@ const BulkUpdater = () => {
7704
9642
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: "bold", display: "block", children: "🛡️ Safe Publishing (Recommended)" }),
7705
9643
  /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: [
7706
9644
  "Only publish records that are already approved & live (",
7707
- selectedLifecycleStats.published,
9645
+ updateModalLifecycleStats.published,
7708
9646
  " record",
7709
- selectedLifecycleStats.published === 1 ? "" : "s",
9647
+ updateModalLifecycleStats.published === 1 ? "" : "s",
7710
9648
  "). The ",
7711
- selectedLifecycleStats.unreviewedCount,
9649
+ updateModalLifecycleStats.unreviewedCount,
7712
9650
  " unreviewed or draft record(s) will receive the bulk update in Draft mode without publishing unreviewed draft revisions to visitors."
7713
9651
  ] })
7714
9652
  ] })
@@ -7742,9 +9680,9 @@ const BulkUpdater = () => {
7742
9680
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: "bold", textColor: "danger700", display: "block", children: "⚠️ Publish All Selected Records (Includes Unreviewed Drafts)" }),
7743
9681
  /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: [
7744
9682
  "Publish all ",
7745
- totalSelectedCount,
9683
+ gridEditMode ? gridSerialized.targets.length : totalSelectedCount,
7746
9684
  " records live to production immediately, pushing all pending unreviewed draft edits in the ",
7747
- selectedLifecycleStats.unreviewedCount,
9685
+ updateModalLifecycleStats.unreviewedCount,
7748
9686
  " draft/modified record(s) live."
7749
9687
  ] })
7750
9688
  ] })
@@ -7771,7 +9709,7 @@ const BulkUpdater = () => {
7771
9709
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: "bold", textColor: "danger700", display: "block", children: "Mandatory Risk Consent Required" }),
7772
9710
  /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { variant: "pi", textColor: "danger700", children: [
7773
9711
  "I understand and explicitly consent that ",
7774
- selectedLifecycleStats.unreviewedCount,
9712
+ updateModalLifecycleStats.unreviewedCount,
7775
9713
  " record(s) with unreviewed draft revisions or saved draft states will be published live to production visitors."
7776
9714
  ] })
7777
9715
  ] })
@@ -7809,7 +9747,7 @@ const BulkUpdater = () => {
7809
9747
  boxShadow: "0 -4px 16px rgba(0, 0, 0, 0.08)"
7810
9748
  },
7811
9749
  children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 2, style: { width: "100%" }, children: [
7812
- publishOnApproval && selectedLifecycleStats.unreviewedCount > 0 && publishStrategy === "all" && !unreviewedConsent && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "danger700", fontWeight: "bold", children: "⚠️ Explicit consent is required before publishing records with unreviewed draft revisions." }),
9750
+ publishOnApproval && updateModalLifecycleStats.unreviewedCount > 0 && publishStrategy === "all" && !unreviewedConsent && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "danger700", fontWeight: "bold", children: "⚠️ Explicit consent is required before publishing records with unreviewed draft revisions." }),
7813
9751
  /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", alignItems: "center", gap: 3, style: { width: "100%" }, children: [
7814
9752
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "tertiary", size: "M", onClick: () => setShowConfirmModal(false), children: "Cancel" }),
7815
9753
  /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, wrap: "wrap", justifyContent: "flex-end", alignItems: "center", children: [
@@ -7820,7 +9758,7 @@ const BulkUpdater = () => {
7820
9758
  size: "M",
7821
9759
  onClick: () => executeBatchWithMode("maker_checker"),
7822
9760
  loading: updating,
7823
- disabled: updating || publishOnApproval && selectedLifecycleStats.unreviewedCount > 0 && publishStrategy === "all" && !unreviewedConsent,
9761
+ disabled: updating || publishOnApproval && updateModalLifecycleStats.unreviewedCount > 0 && publishStrategy === "all" && !unreviewedConsent,
7824
9762
  children: "Submit for Checker Approval"
7825
9763
  }
7826
9764
  ),
@@ -7832,7 +9770,7 @@ const BulkUpdater = () => {
7832
9770
  size: "M",
7833
9771
  onClick: () => executeBatchWithMode("queue_offpeak"),
7834
9772
  loading: updating,
7835
- disabled: updating || publishOnApproval && selectedLifecycleStats.unreviewedCount > 0 && publishStrategy === "all" && !unreviewedConsent,
9773
+ disabled: updating || publishOnApproval && updateModalLifecycleStats.unreviewedCount > 0 && publishStrategy === "all" && !unreviewedConsent,
7836
9774
  children: [
7837
9775
  "Queue for Off-Peak (",
7838
9776
  executionWindow?.offPeakStartTime || "18:00",
@@ -7847,7 +9785,7 @@ const BulkUpdater = () => {
7847
9785
  size: "S",
7848
9786
  onClick: () => executeBatchWithMode("immediate", true),
7849
9787
  loading: updating,
7850
- disabled: updating || publishOnApproval && selectedLifecycleStats.unreviewedCount > 0 && publishStrategy === "all" && !unreviewedConsent,
9788
+ disabled: updating || publishOnApproval && updateModalLifecycleStats.unreviewedCount > 0 && publishStrategy === "all" && !unreviewedConsent,
7851
9789
  children: "Force Run Now"
7852
9790
  }
7853
9791
  )
@@ -7858,7 +9796,7 @@ const BulkUpdater = () => {
7858
9796
  size: "M",
7859
9797
  onClick: () => executeBatchWithMode("immediate"),
7860
9798
  loading: updating,
7861
- disabled: updating || publishOnApproval && selectedLifecycleStats.unreviewedCount > 0 && publishStrategy === "all" && !unreviewedConsent,
9799
+ disabled: updating || publishOnApproval && updateModalLifecycleStats.unreviewedCount > 0 && publishStrategy === "all" && !unreviewedConsent,
7862
9800
  children: "Confirm & Execute Now"
7863
9801
  }
7864
9802
  )
@@ -8147,9 +10085,10 @@ const BulkUpdater = () => {
8147
10085
  loading: previewLoading,
8148
10086
  previewData,
8149
10087
  attribute: selectedAttribute,
10088
+ editMode: gridEditMode ? "grid" : "common",
8150
10089
  publishOnApproval,
8151
10090
  lifecycleStats: selectedLifecycleStats,
8152
- targetValueDisplay: relationsMeta[selectedAttribute] ? selectedRelationDocId === "__clear__" ? "Clear / Unlink Relation" : relationOptions.find((o) => o.documentId === selectedRelationDocId)?.label || selectedRelationDocId || "(none)" : useRegex ? `Replace /${regexPattern}/g with "${attributeValue}"` : attributeValue
10091
+ targetValueDisplay: gridEditMode ? `Grid Editing (${gridSerialized.totalEditCount} edits across ${gridSerialized.targets.length} records)` : relationsMeta[selectedAttribute] ? selectedRelationDocId === "__clear__" ? "Clear / Unlink Relation" : relationOptions.find((o) => o.documentId === selectedRelationDocId)?.label || selectedRelationDocId || "(none)" : useRegex ? `Replace /${regexPattern}/g with "${attributeValue}"` : attributeValue
8153
10092
  }
8154
10093
  ),
8155
10094
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -8189,4 +10128,4 @@ exports.getNestedValue = getNestedValue;
8189
10128
  exports.getPropertyValue = getPropertyValue;
8190
10129
  exports.getSortOptionsForCollection = getSortOptionsForCollection;
8191
10130
  exports.parseDynamicZonePath = parseDynamicZonePath;
8192
- //# sourceMappingURL=BulkUpdater-C7-KHLWq.js.map
10131
+ //# sourceMappingURL=BulkUpdater-DTJLdJJy.js.map