@arpproject/recrate 0.1.38 → 0.1.39

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.
@@ -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",
@@ -116646,6 +116680,11 @@ const RenderEntity = forwardRef((props, ref) => {
116646
116680
  )), [approvedAiApprovals]);
116647
116681
  const selectedAiApproval = pendingAiApprovals[selectedAiApprovalIndex] ?? pendingAiApprovals[0];
116648
116682
  const selectedAiApprovalProperty = (selectedAiApproval == null ? void 0 : selectedAiApproval.propertyName) ?? pendingDeletedEntityReviewProperties[0];
116683
+ const aiReviewPropertyNames = useMemo$1(() => Array.from(/* @__PURE__ */ new Set([
116684
+ ...pendingAiApprovalProperties,
116685
+ ...pendingDeletedEntityReviewProperties
116686
+ ])), [pendingAiApprovalProperties, pendingDeletedEntityReviewProperties]);
116687
+ const tabsWithAiReviewProperties = useMemo$1(() => addMissingReviewPropertiesToTabs(tabs, aiReviewPropertyNames), [aiReviewPropertyNames, tabs]);
116649
116688
  const pendingContextApprovalItems = useMemo$1(() => getPendingContextApprovalRecords(approvalContext == null ? void 0 : approvalContext.roCrateApproval), [approvalContext == null ? void 0 : approvalContext.roCrateApproval]);
116650
116689
  const currentContextApprovalItem = useMemo$1(() => {
116651
116690
  if (contextReviewEntityId) {
@@ -117179,7 +117218,7 @@ const RenderEntity = forwardRef((props, ref) => {
117179
117218
  }
117180
117219
  suppressAiScrollRestore();
117181
117220
  pendingAiScrollPropertyRef.current = property;
117182
- const propertyTab = renderTabs ? findTabForProperty(tabs, property) : null;
117221
+ const propertyTab = renderTabs ? findTabForProperty(tabsWithAiReviewProperties, property) : null;
117183
117222
  if ((propertyTab == null ? void 0 : propertyTab.name) && propertyTab.name !== activeTab) {
117184
117223
  captureViewContext(activeTab);
117185
117224
  setActiveTab(propertyTab.name);
@@ -117194,7 +117233,7 @@ const RenderEntity = forwardRef((props, ref) => {
117194
117233
  pendingAiApprovals,
117195
117234
  renderTabs,
117196
117235
  scrollToAiApprovalProperty,
117197
- tabs
117236
+ tabsWithAiReviewProperties
117198
117237
  ]);
117199
117238
  const navigateToAiApproval = useCallback((index2) => {
117200
117239
  if (!pendingAiApprovals.length) return;
@@ -117239,7 +117278,7 @@ const RenderEntity = forwardRef((props, ref) => {
117239
117278
  useEffect(() => {
117240
117279
  const pendingProperty = pendingAiScrollPropertyRef.current;
117241
117280
  if (!pendingProperty) return;
117242
- const propertyTab = renderTabs ? findTabForProperty(tabs, pendingProperty) : null;
117281
+ const propertyTab = renderTabs ? findTabForProperty(tabsWithAiReviewProperties, pendingProperty) : null;
117243
117282
  if ((propertyTab == null ? void 0 : propertyTab.name) && propertyTab.name !== activeTab) {
117244
117283
  setActiveTab(propertyTab.name);
117245
117284
  saveTabToState(propertyTab.name);
@@ -117256,7 +117295,7 @@ const RenderEntity = forwardRef((props, ref) => {
117256
117295
  cancelScroll();
117257
117296
  window.clearTimeout(captureTimer);
117258
117297
  };
117259
- }, [activeTab, contextEntity == null ? void 0 : contextEntity["@id"], renderTabs, selectedAiApprovalIndex, tabs, scrollToAiApprovalProperty]);
117298
+ }, [activeTab, contextEntity == null ? void 0 : contextEntity["@id"], renderTabs, selectedAiApprovalIndex, tabsWithAiReviewProperties, scrollToAiApprovalProperty]);
117260
117299
  const isEntityReference2 = (value) => Boolean(value && typeof value === "object" && typeof value["@id"] === "string");
117261
117300
  const restoreNonCoreApprovalValue = (approvalRecord) => {
117262
117301
  const property = approvalRecord == null ? void 0 : approvalRecord.propertyName;
@@ -117844,9 +117883,9 @@ const RenderEntity = forwardRef((props, ref) => {
117844
117883
  ),
117845
117884
  tabbedAboutContent: activeTab === "about" && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: showFieldHelp ? "space-y-3" : "space-y-1", children: [
117846
117885
  renderCoreEntityFields("tabbed"),
117847
- renderEntityPropertyFields(((_k = tabs.find((tab) => tab.name === "about")) == null ? void 0 : _k.inputs) ?? [], "tabbed")
117886
+ renderEntityPropertyFields(((_k = tabsWithAiReviewProperties.find((tab) => tab.name === "about")) == null ? void 0 : _k.inputs) ?? [], "tabbed")
117848
117887
  ] }),
117849
- tabbedOtherTabsContent: tabs.map((tab) => {
117888
+ tabbedOtherTabsContent: tabsWithAiReviewProperties.map((tab) => {
117850
117889
  if (tab.name === activeTab && tab.name !== "about") {
117851
117890
  return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: showFieldHelp ? "space-y-3" : "space-y-1", children: renderEntityPropertyFields(tab.inputs, "tabbed") }, tab.name);
117852
117891
  }
@@ -126465,7 +126504,7 @@ var EmotionCacheContext = /* @__PURE__ */ React.createContext(
126465
126504
  }) : null
126466
126505
  );
126467
126506
  var CacheProvider = EmotionCacheContext.Provider;
126468
- const version = "0.1.38";
126507
+ const version = "0.1.39";
126469
126508
  const pkg = {
126470
126509
  version
126471
126510
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arpproject/recrate",
3
- "version": "0.1.38",
3
+ "version": "0.1.39",
4
4
  "type": "module",
5
5
  "main": "./dist/recrate.es.js",
6
6
  "module": "./dist/recrate.es.js",