@arpproject/recrate 0.1.38 → 0.1.40

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.
@@ -0,0 +1,7 @@
1
+ export declare const CORE_AI_REVIEW_PROPERTY_ORDER: string[];
2
+ export declare const getDisplayedAiReviewPropertyOrder: ({ renderTabs, tabs, untabbedProperties, }: {
3
+ renderTabs: boolean;
4
+ tabs: any[];
5
+ untabbedProperties: unknown[];
6
+ }) => string[];
7
+ export declare const orderAiApprovalsByDisplayedFields: (approvals: any[], displayedPropertyOrder: string[]) => any[];
@@ -8,6 +8,7 @@ export declare const findAddedProfileTab: (tabs: any[], previousTabKeys: Set<str
8
8
  export declare const isAboutTab: (tab: any) => boolean;
9
9
  export declare const tabContainsProperty: (tab: any, property: string) => boolean;
10
10
  export declare const findTabForProperty: (tabs: any[], property: string) => any;
11
+ export declare const addMissingReviewPropertiesToTabs: (tabs: any[], properties: string[]) => any[];
11
12
  export declare const clampLabelTabPaneWidth: (width: number) => number;
12
13
  export declare const readPendingAddedProfileTabKeys: (entityId: string) => string[] | null;
13
14
  export declare const writePendingAddedProfileTabKeys: (entityId: string, tabKeys: string[]) => void;
@@ -59412,6 +59412,27 @@ const findTabForProperty = (tabs, property) => {
59412
59412
  const matchingTabs = tabs.filter((tab) => tabContainsProperty(tab, property));
59413
59413
  return matchingTabs.find((tab) => !isAboutTab(tab)) ?? matchingTabs[0] ?? tabs.find((tab) => ["overflow", "other"].includes(String((tab == null ? void 0 : tab.name) || "").toLowerCase()));
59414
59414
  };
59415
+ const addMissingReviewPropertiesToTabs = (tabs, properties) => {
59416
+ const uniqueProperties = Array.from(new Set(
59417
+ properties.filter((property) => typeof property === "string" && property.length > 0)
59418
+ ));
59419
+ if (!tabs.length || !uniqueProperties.length) return tabs;
59420
+ const assignedProperties = new Set(
59421
+ tabs.flatMap((tab) => Array.isArray(tab == null ? void 0 : tab.inputs) ? tab.inputs.flatMap((input) => [input == null ? void 0 : input.name, input == null ? void 0 : input.id]) : []).filter((property) => typeof property === "string" && property.length > 0)
59422
+ );
59423
+ const missingProperties = uniqueProperties.filter((property) => !assignedProperties.has(property));
59424
+ if (!missingProperties.length) return tabs;
59425
+ const fallbackTabIndex = tabs.findIndex((tab) => ["overflow", "other"].includes(String((tab == null ? void 0 : tab.name) || "").toLowerCase()));
59426
+ const aboutTabIndex = tabs.findIndex(isAboutTab);
59427
+ const targetTabIndex = fallbackTabIndex >= 0 ? fallbackTabIndex : aboutTabIndex >= 0 ? aboutTabIndex : 0;
59428
+ return tabs.map((tab, index2) => index2 === targetTabIndex ? {
59429
+ ...tab,
59430
+ inputs: [
59431
+ ...Array.isArray(tab == null ? void 0 : tab.inputs) ? tab.inputs : [],
59432
+ ...missingProperties.map((property) => ({ name: property }))
59433
+ ]
59434
+ } : tab);
59435
+ };
59415
59436
  const clampLabelTabPaneWidth = (width) => Math.max(MIN_LABEL_TAB_PANE_WIDTH, Math.min(MAX_LABEL_TAB_PANE_WIDTH, Math.round(width)));
59416
59437
  const getPendingAddedProfileStorageKey = (entityId) => `recrate.pending-added-profile-tab.${entityId}`;
59417
59438
  const readPendingAddedProfileTabKeys = (entityId) => {
@@ -85864,7 +85885,7 @@ const RenderLinkedItem = ({
85864
85885
  {
85865
85886
  entityId: entity["@id"],
85866
85887
  rows: aiEntityDiffRows,
85867
- readonly: Boolean(((_b = state.configuration) == null ? void 0 : _b.readonly) || readonly),
85888
+ readonly: Boolean((_b = state.configuration) == null ? void 0 : _b.readonly),
85868
85889
  onClose: () => setShowAiEntityDiff(false),
85869
85890
  onAccept: () => onAcceptAiEntityEdit == null ? void 0 : onAcceptAiEntityEdit(effectiveEntity),
85870
85891
  onReject: () => onRejectAiEntityEdit == null ? void 0 : onRejectAiEntityEdit(effectiveEntity)
@@ -85888,7 +85909,7 @@ const RenderLinkedItem = ({
85888
85909
  displayEntity: linkDisplayEntity,
85889
85910
  property,
85890
85911
  sourceEntityId: aiUnlinkSourceEntityId,
85891
- readonly: Boolean(((_d = state.configuration) == null ? void 0 : _d.readonly) || readonly),
85912
+ readonly: Boolean((_d = state.configuration) == null ? void 0 : _d.readonly),
85892
85913
  onLoadEntity: handleLoadEntity,
85893
85914
  onAcceptUnlink: onAcceptAiEntityUnlink,
85894
85915
  onRejectUnlink: onRejectAiEntityUnlink
@@ -87829,6 +87850,67 @@ const EntityProperty = ({
87829
87850
  idx
87830
87851
  });
87831
87852
  }, [approvalContext, entity, hasCurrentPropertyValue, isAiDelete, onCreateProperty, onSaveProperty, previousValueDiffers, property, unapprovedApprovalRecord]);
87853
+ const renderAiActions = (idx) => {
87854
+ var _a3, _b2;
87855
+ return showAiReview && idx === ((_a3 = renderedSimpleInstances[0]) == null ? void 0 : _a3.idx) && !((_b2 = state.configuration) == null ? void 0 : _b2.readonly) ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "recrate-ai-actions", children: [
87856
+ showAiDiffToggle && /* @__PURE__ */ jsxRuntimeExports.jsx(Tooltip2, { title: showAiDiff ? t2("ai_hide_diff") : t2("ai_show_diff"), children: /* @__PURE__ */ jsxRuntimeExports.jsx(
87857
+ Button$1,
87858
+ {
87859
+ size: "middle",
87860
+ className: "recrate-ai-action-diff",
87861
+ icon: /* @__PURE__ */ jsxRuntimeExports.jsx(RefIcon$7, {}),
87862
+ "aria-label": showAiDiff ? String(t2("ai_hide_ai_diff_aria")) : String(t2("ai_show_ai_diff_aria")),
87863
+ "aria-pressed": showAiDiff,
87864
+ onClick: () => setShowAiDiff((visible) => !visible)
87865
+ }
87866
+ ) }),
87867
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Tooltip2, { title: isAiDelete ? t2("ai_approve_deletion_tooltip") : t2("ai_approve_suggested_value_tooltip"), children: /* @__PURE__ */ jsxRuntimeExports.jsx(
87868
+ Button$1,
87869
+ {
87870
+ size: "middle",
87871
+ className: "recrate-ai-action-approve",
87872
+ onClick: handleApproveAiSuggestion,
87873
+ children: isAiDelete ? t2("ai_delete") : t2("ai_accept")
87874
+ }
87875
+ ) }),
87876
+ previousValueDiffers && /* @__PURE__ */ jsxRuntimeExports.jsx(Tooltip2, { title: t2("ai_restore_previous_value_tooltip"), children: /* @__PURE__ */ jsxRuntimeExports.jsx(
87877
+ Button$1,
87878
+ {
87879
+ size: "middle",
87880
+ className: "recrate-ai-action-reject",
87881
+ onClick: () => handleRejectAiSuggestion(idx),
87882
+ children: isAiDelete ? t2("ai_restore") : t2("ai_reject")
87883
+ }
87884
+ ) })
87885
+ ] }) : null;
87886
+ };
87887
+ const renderPropertyValue = (instance2) => {
87888
+ if (showAiDiff && showAiDiffToggle) {
87889
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
87890
+ AiFieldDiffView,
87891
+ {
87892
+ previousValue: unapprovedApprovalRecord == null ? void 0 : unapprovedApprovalRecord.previousValue,
87893
+ currentValue: instance2.value,
87894
+ operation: unapprovedApprovalRecord == null ? void 0 : unapprovedApprovalRecord.operation
87895
+ }
87896
+ );
87897
+ }
87898
+ if (propertyDefinition == null ? void 0 : propertyDefinition.readonly) {
87899
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: showAiReview ? "recrate-property-value-readonly recrate-ai-field-control" : "recrate-property-value-readonly", children: instance2.value });
87900
+ }
87901
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
87902
+ EntityPropertyInstance,
87903
+ {
87904
+ className: "flex-grow",
87905
+ property,
87906
+ value: instance2.value,
87907
+ idx: instance2.idx,
87908
+ definition: propertyDefinition,
87909
+ onSaveProperty: handleSaveProperty,
87910
+ onCreateEntity
87911
+ }
87912
+ );
87913
+ };
87832
87914
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(
87833
87915
  "div",
87834
87916
  {
@@ -87862,59 +87944,11 @@ const EntityProperty = ({
87862
87944
  ] }),
87863
87945
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "w-2/3 xl:w-4/5 flex flex-col flex-grow recrate-property-value", children: [
87864
87946
  /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-col space-y-1", children: renderedSimpleInstances.map((instance2) => {
87865
- var _a3, _b2, _c, _d;
87866
- return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: (propertyDefinition == null ? void 0 : propertyDefinition.readonly) ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: showAiReview ? "recrate-property-value-readonly recrate-ai-field-control" : "recrate-property-value-readonly", children: instance2.value }) : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: `flex flex-row gap-2 ${showAiReview ? "recrate-ai-field-row" : ""}`, children: [
87867
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `flex-grow min-w-0 ${showAiReview ? "recrate-ai-field-control" : ""}`, children: showAiDiff && showAiDiffToggle ? /* @__PURE__ */ jsxRuntimeExports.jsx(
87868
- AiFieldDiffView,
87869
- {
87870
- previousValue: unapprovedApprovalRecord == null ? void 0 : unapprovedApprovalRecord.previousValue,
87871
- currentValue: instance2.value,
87872
- operation: unapprovedApprovalRecord == null ? void 0 : unapprovedApprovalRecord.operation
87873
- }
87874
- ) : /* @__PURE__ */ jsxRuntimeExports.jsx(
87875
- EntityPropertyInstance,
87876
- {
87877
- className: "flex-grow",
87878
- property,
87879
- value: instance2.value,
87880
- idx: instance2.idx,
87881
- definition: propertyDefinition,
87882
- onSaveProperty: handleSaveProperty,
87883
- onCreateEntity
87884
- }
87885
- ) }),
87886
- showAiReview && instance2.idx === ((_a3 = renderedSimpleInstances[0]) == null ? void 0 : _a3.idx) && !((_b2 = state.configuration) == null ? void 0 : _b2.readonly) && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "recrate-ai-actions", children: [
87887
- showAiDiffToggle && /* @__PURE__ */ jsxRuntimeExports.jsx(Tooltip2, { title: showAiDiff ? t2("ai_hide_diff") : t2("ai_show_diff"), children: /* @__PURE__ */ jsxRuntimeExports.jsx(
87888
- Button$1,
87889
- {
87890
- size: "middle",
87891
- className: "recrate-ai-action-diff",
87892
- icon: /* @__PURE__ */ jsxRuntimeExports.jsx(RefIcon$7, {}),
87893
- "aria-label": showAiDiff ? String(t2("ai_hide_ai_diff_aria")) : String(t2("ai_show_ai_diff_aria")),
87894
- "aria-pressed": showAiDiff,
87895
- onClick: () => setShowAiDiff((visible) => !visible)
87896
- }
87897
- ) }),
87898
- /* @__PURE__ */ jsxRuntimeExports.jsx(Tooltip2, { title: isAiDelete ? t2("ai_approve_deletion_tooltip") : t2("ai_approve_suggested_value_tooltip"), children: /* @__PURE__ */ jsxRuntimeExports.jsx(
87899
- Button$1,
87900
- {
87901
- size: "middle",
87902
- className: "recrate-ai-action-approve",
87903
- onClick: handleApproveAiSuggestion,
87904
- children: isAiDelete ? t2("ai_delete") : t2("ai_accept")
87905
- }
87906
- ) }),
87907
- previousValueDiffers && /* @__PURE__ */ jsxRuntimeExports.jsx(Tooltip2, { title: t2("ai_restore_previous_value_tooltip"), children: /* @__PURE__ */ jsxRuntimeExports.jsx(
87908
- Button$1,
87909
- {
87910
- size: "middle",
87911
- className: "recrate-ai-action-reject",
87912
- onClick: () => handleRejectAiSuggestion(instance2.idx),
87913
- children: isAiDelete ? t2("ai_restore") : t2("ai_reject")
87914
- }
87915
- ) })
87916
- ] }),
87917
- isNotValue && !showAiReview && !((_c = state.configuration) == null ? void 0 : _c.readonly) && (instance2.value || instance2.value === false) && !((_d = instance2.value) == null ? void 0 : _d["@id"]) && /* @__PURE__ */ jsxRuntimeExports.jsx(
87947
+ var _a3, _b2;
87948
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: `flex flex-row gap-2 ${showAiReview ? "recrate-ai-field-row" : ""}`, children: [
87949
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `flex-grow min-w-0 ${showAiReview ? "recrate-ai-field-control" : ""}`, children: renderPropertyValue(instance2) }),
87950
+ renderAiActions(instance2.idx),
87951
+ isNotValue && !(propertyDefinition == null ? void 0 : propertyDefinition.readonly) && !showAiReview && !((_a3 = state.configuration) == null ? void 0 : _a3.readonly) && (instance2.value || instance2.value === false) && !((_b2 = instance2.value) == null ? void 0 : _b2["@id"]) && /* @__PURE__ */ jsxRuntimeExports.jsx(
87918
87952
  DeleteProperty,
87919
87953
  {
87920
87954
  type: "delete",
@@ -115888,6 +115922,61 @@ const useEntityScrollRestoration = ({
115888
115922
  };
115889
115923
  }, [activeTab, contextEntity == null ? void 0 : contextEntity["@id"], tabsLength, extraPropertiesLength]);
115890
115924
  };
115925
+ const CORE_AI_REVIEW_PROPERTY_ORDER = ["@id", "@type", "name"];
115926
+ const getFieldNames = (field) => {
115927
+ if (typeof field === "string") return [field];
115928
+ if (!field || typeof field !== "object") return [];
115929
+ const { name: name2, id: id2 } = field;
115930
+ return [name2, id2].filter((value) => typeof value === "string" && value.length > 0);
115931
+ };
115932
+ const addUniqueProperties = (order, seen, fields) => {
115933
+ fields.flatMap(getFieldNames).forEach((property) => {
115934
+ if (seen.has(property)) return;
115935
+ seen.add(property);
115936
+ order.push(property);
115937
+ });
115938
+ };
115939
+ const getDisplayedAiReviewPropertyOrder = ({
115940
+ renderTabs,
115941
+ tabs,
115942
+ untabbedProperties
115943
+ }) => {
115944
+ const order = [];
115945
+ const seen = /* @__PURE__ */ new Set();
115946
+ if (!renderTabs) {
115947
+ addUniqueProperties(order, seen, CORE_AI_REVIEW_PROPERTY_ORDER);
115948
+ addUniqueProperties(order, seen, untabbedProperties);
115949
+ return order;
115950
+ }
115951
+ let foundAboutTab = false;
115952
+ tabs.forEach((tab) => {
115953
+ if (isAboutTab(tab)) {
115954
+ foundAboutTab = true;
115955
+ addUniqueProperties(order, seen, CORE_AI_REVIEW_PROPERTY_ORDER);
115956
+ }
115957
+ addUniqueProperties(
115958
+ order,
115959
+ seen,
115960
+ Array.isArray(tab == null ? void 0 : tab.inputs) ? tab.inputs : []
115961
+ );
115962
+ });
115963
+ if (!foundAboutTab) {
115964
+ addUniqueProperties(order, seen, CORE_AI_REVIEW_PROPERTY_ORDER);
115965
+ }
115966
+ return order;
115967
+ };
115968
+ const orderAiApprovalsByDisplayedFields = (approvals, displayedPropertyOrder) => {
115969
+ const displayIndexByProperty = new Map(
115970
+ displayedPropertyOrder.map((property, index2) => [property, index2])
115971
+ );
115972
+ return approvals.map((approvalRecord, originalIndex) => ({ approvalRecord, originalIndex })).sort((left, right) => {
115973
+ var _a2, _b;
115974
+ const leftIndex = displayIndexByProperty.get((_a2 = left.approvalRecord) == null ? void 0 : _a2.propertyName) ?? Number.POSITIVE_INFINITY;
115975
+ const rightIndex = displayIndexByProperty.get((_b = right.approvalRecord) == null ? void 0 : _b.propertyName) ?? Number.POSITIVE_INFINITY;
115976
+ if (leftIndex !== rightIndex) return leftIndex - rightIndex;
115977
+ return left.originalIndex - right.originalIndex;
115978
+ }).map(({ approvalRecord }) => approvalRecord);
115979
+ };
115891
115980
  var _baseDifference;
115892
115981
  var hasRequired_baseDifference;
115893
115982
  function require_baseDifference() {
@@ -116468,6 +116557,12 @@ function applyTabDataIndicators({
116468
116557
  return tabs;
116469
116558
  }
116470
116559
  const AI_SCROLL_RESTORE_SUPPRESSION_MS = 2500;
116560
+ const hasProfileLayouts = (layouts) => {
116561
+ if (!layouts) return false;
116562
+ if (Array.isArray(layouts)) return layouts.length > 0;
116563
+ if (typeof layouts === "object") return Object.keys(layouts).length > 0;
116564
+ return false;
116565
+ };
116471
116566
  const buildAiApprovalNavigationKey = (entityId, approvalRecord) => {
116472
116567
  const propertyName2 = String((approvalRecord == null ? void 0 : approvalRecord.propertyName) ?? "");
116473
116568
  const operation = String((approvalRecord == null ? void 0 : approvalRecord.operation) ?? "");
@@ -116481,7 +116576,7 @@ const buildAiApprovalNavigationKey = (entityId, approvalRecord) => {
116481
116576
  return `${entityId}:${propertyName2}:${operation}:${timestamp}:${previousValue}`;
116482
116577
  };
116483
116578
  const RenderEntity = forwardRef((props, ref) => {
116484
- var _a2, _b, _c, _d, _e2, _f, _g, _h, _i, _j, _k, _l;
116579
+ var _a2, _b, _c, _d, _e2, _f, _g, _h, _i, _j, _k;
116485
116580
  const {
116486
116581
  entity,
116487
116582
  onLoadEntity,
@@ -116622,14 +116717,14 @@ const RenderEntity = forwardRef((props, ref) => {
116622
116717
  captureViewContext,
116623
116718
  debugScroll
116624
116719
  });
116625
- const pendingAiApprovals = useMemo$1(() => getPendingEntityApprovalRecords(approvalContext == null ? void 0 : approvalContext.roCrateApproval, contextEntity == null ? void 0 : contextEntity["@id"]), [approvalContext == null ? void 0 : approvalContext.roCrateApproval, contextEntity == null ? void 0 : contextEntity["@id"]]);
116626
- const pendingAiApprovalProperties = useMemo$1(() => pendingAiApprovals.map((approvalRecord) => approvalRecord == null ? void 0 : approvalRecord.propertyName).filter((property) => typeof property === "string" && property.length > 0), [pendingAiApprovals]);
116720
+ const pendingAiApprovalRecords = useMemo$1(() => getPendingEntityApprovalRecords(approvalContext == null ? void 0 : approvalContext.roCrateApproval, contextEntity == null ? void 0 : contextEntity["@id"]), [approvalContext == null ? void 0 : approvalContext.roCrateApproval, contextEntity == null ? void 0 : contextEntity["@id"]]);
116721
+ const pendingAiApprovalProperties = useMemo$1(() => pendingAiApprovalRecords.map((approvalRecord) => approvalRecord == null ? void 0 : approvalRecord.propertyName).filter((property) => typeof property === "string" && property.length > 0), [pendingAiApprovalRecords]);
116627
116722
  const pendingDeletedEntityReviewProperties = useMemo$1(() => {
116628
116723
  const reverseDeletedEntityProperties = getPendingDeletedEntityReversePropertiesForSource(
116629
116724
  approvalContext == null ? void 0 : approvalContext.roCrateApproval,
116630
116725
  contextEntity == null ? void 0 : contextEntity["@id"]
116631
116726
  );
116632
- const removedReferenceDeletedEntityProperties = pendingAiApprovals.map((approvalRecord) => approvalRecord == null ? void 0 : approvalRecord.propertyName).filter((property) => typeof property === "string" && property.length > 0).filter((property) => getPendingDeletedEntitiesForRemovedReferences(
116727
+ const removedReferenceDeletedEntityProperties = pendingAiApprovalRecords.map((approvalRecord) => approvalRecord == null ? void 0 : approvalRecord.propertyName).filter((property) => typeof property === "string" && property.length > 0).filter((property) => getPendingDeletedEntitiesForRemovedReferences(
116633
116728
  approvalContext == null ? void 0 : approvalContext.roCrateApproval,
116634
116729
  contextEntity == null ? void 0 : contextEntity["@id"],
116635
116730
  property,
@@ -116639,11 +116734,28 @@ const RenderEntity = forwardRef((props, ref) => {
116639
116734
  ...reverseDeletedEntityProperties,
116640
116735
  ...removedReferenceDeletedEntityProperties
116641
116736
  ]));
116642
- }, [approvalContext == null ? void 0 : approvalContext.roCrateApproval, contextEntity, pendingAiApprovals]);
116737
+ }, [approvalContext == null ? void 0 : approvalContext.roCrateApproval, contextEntity, pendingAiApprovalRecords]);
116643
116738
  const approvedAiApprovals = useMemo$1(() => getApprovedEntityApprovalRecords(approvalContext == null ? void 0 : approvalContext.roCrateApproval, contextEntity == null ? void 0 : contextEntity["@id"]), [approvalContext == null ? void 0 : approvalContext.roCrateApproval, contextEntity == null ? void 0 : contextEntity["@id"]]);
116644
116739
  const approvedAiApprovalProperties = useMemo$1(() => Array.from(new Set(
116645
116740
  approvedAiApprovals.map((approvalRecord) => approvalRecord == null ? void 0 : approvalRecord.propertyName).filter((property) => typeof property === "string" && property.length > 0)
116646
116741
  )), [approvedAiApprovals]);
116742
+ const aiReviewPropertyNames = useMemo$1(() => Array.from(/* @__PURE__ */ new Set([
116743
+ ...pendingAiApprovalProperties,
116744
+ ...pendingDeletedEntityReviewProperties
116745
+ ])), [pendingAiApprovalProperties, pendingDeletedEntityReviewProperties]);
116746
+ const tabsWithAiReviewProperties = useMemo$1(() => addMissingReviewPropertiesToTabs(tabs, aiReviewPropertyNames), [aiReviewPropertyNames, tabs]);
116747
+ const entityPropertyNames = useMemo$1(() => Array.from(/* @__PURE__ */ new Set([
116748
+ ...Object.keys(contextEntity ?? {}),
116749
+ ...pendingAiApprovalProperties,
116750
+ ...pendingDeletedEntityReviewProperties,
116751
+ ...approvedAiApprovalProperties
116752
+ ])).sort(), [approvedAiApprovalProperties, contextEntity, pendingAiApprovalProperties, pendingDeletedEntityReviewProperties]);
116753
+ const displayedAiReviewPropertyOrder = useMemo$1(() => getDisplayedAiReviewPropertyOrder({
116754
+ renderTabs,
116755
+ tabs: tabsWithAiReviewProperties,
116756
+ untabbedProperties: entityPropertyNames
116757
+ }), [entityPropertyNames, renderTabs, tabsWithAiReviewProperties]);
116758
+ const pendingAiApprovals = useMemo$1(() => orderAiApprovalsByDisplayedFields(pendingAiApprovalRecords, displayedAiReviewPropertyOrder), [displayedAiReviewPropertyOrder, pendingAiApprovalRecords]);
116647
116759
  const selectedAiApproval = pendingAiApprovals[selectedAiApprovalIndex] ?? pendingAiApprovals[0];
116648
116760
  const selectedAiApprovalProperty = (selectedAiApproval == null ? void 0 : selectedAiApproval.propertyName) ?? pendingDeletedEntityReviewProperties[0];
116649
116761
  const pendingContextApprovalItems = useMemo$1(() => getPendingContextApprovalRecords(approvalContext == null ? void 0 : approvalContext.roCrateApproval), [approvalContext == null ? void 0 : approvalContext.roCrateApproval]);
@@ -117143,12 +117255,12 @@ const RenderEntity = forwardRef((props, ref) => {
117143
117255
  let attempts = 0;
117144
117256
  let timerId = 0;
117145
117257
  let rafId = 0;
117146
- const maxAttempts = 30;
117258
+ const maxAttempts = 100;
117147
117259
  const attemptScroll = () => {
117148
117260
  attempts += 1;
117149
117261
  const propertyElement = findPropertyElement(property);
117150
117262
  const viewport = activeContentRef.current;
117151
- if (propertyElement && viewport) {
117263
+ if (propertyElement && viewport && viewport.clientHeight > 0 && viewport.scrollHeight > 0) {
117152
117264
  const viewportRect = viewport.getBoundingClientRect();
117153
117265
  const propertyRect = propertyElement.getBoundingClientRect();
117154
117266
  const targetTop = viewport.scrollTop + propertyRect.top - viewportRect.top - 8;
@@ -117179,7 +117291,7 @@ const RenderEntity = forwardRef((props, ref) => {
117179
117291
  }
117180
117292
  suppressAiScrollRestore();
117181
117293
  pendingAiScrollPropertyRef.current = property;
117182
- const propertyTab = renderTabs ? findTabForProperty(tabs, property) : null;
117294
+ const propertyTab = renderTabs ? findTabForProperty(tabsWithAiReviewProperties, property) : null;
117183
117295
  if ((propertyTab == null ? void 0 : propertyTab.name) && propertyTab.name !== activeTab) {
117184
117296
  captureViewContext(activeTab);
117185
117297
  setActiveTab(propertyTab.name);
@@ -117194,7 +117306,7 @@ const RenderEntity = forwardRef((props, ref) => {
117194
117306
  pendingAiApprovals,
117195
117307
  renderTabs,
117196
117308
  scrollToAiApprovalProperty,
117197
- tabs
117309
+ tabsWithAiReviewProperties
117198
117310
  ]);
117199
117311
  const navigateToAiApproval = useCallback((index2) => {
117200
117312
  if (!pendingAiApprovals.length) return;
@@ -117206,9 +117318,9 @@ const RenderEntity = forwardRef((props, ref) => {
117206
117318
  navigateToAiApprovalProperty(property);
117207
117319
  }, [navigateToAiApprovalProperty, pendingAiApprovals]);
117208
117320
  useEffect(() => {
117209
- var _a3, _b2;
117321
+ var _a3;
117210
117322
  const entityId = contextEntity == null ? void 0 : contextEntity["@id"];
117211
- const profileHasTabbedLayout = Boolean((_b2 = (_a3 = profileManager == null ? void 0 : profileManager.profile) == null ? void 0 : _a3.layouts) == null ? void 0 : _b2.length);
117323
+ const profileHasTabbedLayout = hasProfileLayouts((_a3 = profileManager == null ? void 0 : profileManager.profile) == null ? void 0 : _a3.layouts);
117212
117324
  if (profileHasTabbedLayout && tabs.length === 0) {
117213
117325
  return;
117214
117326
  }
@@ -117218,7 +117330,8 @@ const RenderEntity = forwardRef((props, ref) => {
117218
117330
  lastAutoNavigatedAiApprovalRef.current = null;
117219
117331
  return;
117220
117332
  }
117221
- const autoNavigationKey = firstPendingApproval ? `${(profileManager == null ? void 0 : profileManager.$key) ?? 0}:${buildAiApprovalNavigationKey(entityId, firstPendingApproval)}` : `${(profileManager == null ? void 0 : profileManager.$key) ?? 0}:${entityId}:${firstPendingProperty}:deleted-entity-review`;
117333
+ const displayedOrderKey = displayedAiReviewPropertyOrder.join("\0");
117334
+ const autoNavigationKey = firstPendingApproval ? `${(profileManager == null ? void 0 : profileManager.$key) ?? 0}:${displayedOrderKey}:${buildAiApprovalNavigationKey(entityId, firstPendingApproval)}` : `${(profileManager == null ? void 0 : profileManager.$key) ?? 0}:${displayedOrderKey}:${entityId}:${firstPendingProperty}:deleted-entity-review`;
117222
117335
  if (lastAutoNavigatedAiApprovalRef.current === autoNavigationKey) return;
117223
117336
  lastAutoNavigatedAiApprovalRef.current = autoNavigationKey;
117224
117337
  if (firstPendingApproval) {
@@ -117232,14 +117345,15 @@ const RenderEntity = forwardRef((props, ref) => {
117232
117345
  navigateToAiApprovalProperty,
117233
117346
  pendingAiApprovals,
117234
117347
  pendingDeletedEntityReviewProperties,
117348
+ displayedAiReviewPropertyOrder,
117235
117349
  profileManager == null ? void 0 : profileManager.$key,
117236
- (_d = (_c = profileManager == null ? void 0 : profileManager.profile) == null ? void 0 : _c.layouts) == null ? void 0 : _d.length,
117350
+ (_c = profileManager == null ? void 0 : profileManager.profile) == null ? void 0 : _c.layouts,
117237
117351
  tabs.length
117238
117352
  ]);
117239
117353
  useEffect(() => {
117240
117354
  const pendingProperty = pendingAiScrollPropertyRef.current;
117241
117355
  if (!pendingProperty) return;
117242
- const propertyTab = renderTabs ? findTabForProperty(tabs, pendingProperty) : null;
117356
+ const propertyTab = renderTabs ? findTabForProperty(tabsWithAiReviewProperties, pendingProperty) : null;
117243
117357
  if ((propertyTab == null ? void 0 : propertyTab.name) && propertyTab.name !== activeTab) {
117244
117358
  setActiveTab(propertyTab.name);
117245
117359
  saveTabToState(propertyTab.name);
@@ -117256,7 +117370,7 @@ const RenderEntity = forwardRef((props, ref) => {
117256
117370
  cancelScroll();
117257
117371
  window.clearTimeout(captureTimer);
117258
117372
  };
117259
- }, [activeTab, contextEntity == null ? void 0 : contextEntity["@id"], renderTabs, selectedAiApprovalIndex, tabs, scrollToAiApprovalProperty]);
117373
+ }, [activeTab, contextEntity == null ? void 0 : contextEntity["@id"], renderTabs, selectedAiApprovalIndex, tabsWithAiReviewProperties, scrollToAiApprovalProperty]);
117260
117374
  const isEntityReference2 = (value) => Boolean(value && typeof value === "object" && typeof value["@id"] === "string");
117261
117375
  const restoreNonCoreApprovalValue = (approvalRecord) => {
117262
117376
  const property = approvalRecord == null ? void 0 : approvalRecord.propertyName;
@@ -117711,12 +117825,6 @@ const RenderEntity = forwardRef((props, ref) => {
117711
117825
  };
117712
117826
  const shouldRenderCoreField = (property, label) => matchesFieldFilter(property, label) && (!showAiEditedFields || fieldWasAiEdited(property));
117713
117827
  const shouldRenderField = (property, label) => matchesFieldFilter(property, label) && (!showAiEditedFields || fieldWasAiEdited(property)) && (fieldHasPendingAiApproval(property) || !hideEmptyFields || hasFieldValue(contextEntity == null ? void 0 : contextEntity[property]));
117714
- const entityPropertyNames = useMemo$1(() => Array.from(/* @__PURE__ */ new Set([
117715
- ...Object.keys(contextEntity ?? {}),
117716
- ...pendingAiApprovalProperties,
117717
- ...pendingDeletedEntityReviewProperties,
117718
- ...approvedAiApprovalProperties
117719
- ])).sort(), [approvedAiApprovalProperties, contextEntity, pendingAiApprovalProperties, pendingDeletedEntityReviewProperties]);
117720
117828
  const editorScrollClassName = `recrate-editor-scroll ${quickSettingsVisible ? "px-3 pb-3 pt-0" : "p-3"}`;
117721
117829
  const renderCoreEntityFields = (layout, options) => {
117722
117830
  var _a3;
@@ -117777,13 +117885,13 @@ const RenderEntity = forwardRef((props, ref) => {
117777
117885
  }
117778
117886
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-row", children: [
117779
117887
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col w-full", children: [
117780
- ((_e2 = state.configuration) == null ? void 0 : _e2.showControls) && /* @__PURE__ */ jsxRuntimeExports.jsx(
117888
+ ((_d = state.configuration) == null ? void 0 : _d.showControls) && /* @__PURE__ */ jsxRuntimeExports.jsx(
117781
117889
  EntityEditorToolbar,
117782
117890
  {
117783
117891
  entity: contextEntity,
117784
117892
  quickSettingsVisible,
117785
117893
  reverseSidebarVisible,
117786
- enableReverseLinkBrowser: (_f = state.configuration) == null ? void 0 : _f.enableReverseLinkBrowser,
117894
+ enableReverseLinkBrowser: (_e2 = state.configuration) == null ? void 0 : _e2.enableReverseLinkBrowser,
117787
117895
  onLoadEntity: handleLoadEntityWithContext,
117788
117896
  onBack: () => {
117789
117897
  captureCurrentViewContext(activeTab);
@@ -117809,7 +117917,7 @@ const RenderEntity = forwardRef((props, ref) => {
117809
117917
  activePropertyLabel: selectedAiApprovalProperty ? getFieldTitle(selectedAiApprovalProperty) : void 0,
117810
117918
  remainingEntityCount: pendingOtherAiApprovalEntities.length,
117811
117919
  remainingFieldCount: pendingOtherAiApprovalFieldCount,
117812
- readonly: (_g = state.configuration) == null ? void 0 : _g.readonly,
117920
+ readonly: (_f = state.configuration) == null ? void 0 : _f.readonly,
117813
117921
  canGoPrevious: selectedAiApprovalIndex > 0,
117814
117922
  canGoNext: selectedAiApprovalIndex < pendingAiApprovals.length - 1,
117815
117923
  onPrevious: () => navigateToAiApproval(selectedAiApprovalIndex - 1),
@@ -117823,7 +117931,7 @@ const RenderEntity = forwardRef((props, ref) => {
117823
117931
  EntityEditorLayout,
117824
117932
  {
117825
117933
  renderTabs,
117826
- tabLocation: (_h = state.configuration) == null ? void 0 : _h.tabLocation,
117934
+ tabLocation: (_g = state.configuration) == null ? void 0 : _g.tabLocation,
117827
117935
  iconView,
117828
117936
  tabPaneWidth,
117829
117937
  scrollViewportHeight,
@@ -117836,7 +117944,7 @@ const RenderEntity = forwardRef((props, ref) => {
117836
117944
  quickSettingsHeader: renderQuickSettingsHeader(),
117837
117945
  untabbedContent: renderUntabbedEntityFields(),
117838
117946
  untabbedTopContent: renderUntabbedEntityFields({ untabbedNameSavedClassName: "bg-green-200 rounded p-1 my-1" }),
117839
- tabbedRequiredWarning: !((_i = state.configuration) == null ? void 0 : _i.readonly) && ((_j = tabs.find((t22) => t22.name === activeTab)) == null ? void 0 : _j.missingRequiredData) && /* @__PURE__ */ jsxRuntimeExports.jsx(
117947
+ tabbedRequiredWarning: !((_h = state.configuration) == null ? void 0 : _h.readonly) && ((_i = tabs.find((t22) => t22.name === activeTab)) == null ? void 0 : _i.missingRequiredData) && /* @__PURE__ */ jsxRuntimeExports.jsx(
117840
117948
  FloatingRequiredPropertiesWarning,
117841
117949
  {
117842
117950
  onClick: () => setHighlightRequiredProperties(!highlightRequiredProperties)
@@ -117844,9 +117952,9 @@ const RenderEntity = forwardRef((props, ref) => {
117844
117952
  ),
117845
117953
  tabbedAboutContent: activeTab === "about" && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: showFieldHelp ? "space-y-3" : "space-y-1", children: [
117846
117954
  renderCoreEntityFields("tabbed"),
117847
- renderEntityPropertyFields(((_k = tabs.find((tab) => tab.name === "about")) == null ? void 0 : _k.inputs) ?? [], "tabbed")
117955
+ renderEntityPropertyFields(((_j = tabsWithAiReviewProperties.find((tab) => tab.name === "about")) == null ? void 0 : _j.inputs) ?? [], "tabbed")
117848
117956
  ] }),
117849
- tabbedOtherTabsContent: tabs.map((tab) => {
117957
+ tabbedOtherTabsContent: tabsWithAiReviewProperties.map((tab) => {
117850
117958
  if (tab.name === activeTab && tab.name !== "about") {
117851
117959
  return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: showFieldHelp ? "space-y-3" : "space-y-1", children: renderEntityPropertyFields(tab.inputs, "tabbed") }, tab.name);
117852
117960
  }
@@ -117865,7 +117973,7 @@ const RenderEntity = forwardRef((props, ref) => {
117865
117973
  onClose: handleCloseContextReviewDialog,
117866
117974
  onUpdateContext: handleUpdateContext,
117867
117975
  approvalRecord: currentContextApprovalItem == null ? void 0 : currentContextApprovalItem.approvalRecord,
117868
- readonly: (_l = state.configuration) == null ? void 0 : _l.readonly,
117976
+ readonly: (_k = state.configuration) == null ? void 0 : _k.readonly,
117869
117977
  onAcceptAiContext: handleAcceptAiContext,
117870
117978
  onRejectAiContext: handleRejectAiContext
117871
117979
  }
@@ -126465,7 +126573,7 @@ var EmotionCacheContext = /* @__PURE__ */ React.createContext(
126465
126573
  }) : null
126466
126574
  );
126467
126575
  var CacheProvider = EmotionCacheContext.Provider;
126468
- const version = "0.1.38";
126576
+ const version = "0.1.40";
126469
126577
  const pkg = {
126470
126578
  version
126471
126579
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arpproject/recrate",
3
- "version": "0.1.38",
3
+ "version": "0.1.40",
4
4
  "type": "module",
5
5
  "main": "./dist/recrate.es.js",
6
6
  "module": "./dist/recrate.es.js",