@arpproject/recrate 0.1.32-test → 0.1.32-test2

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.
@@ -1,8 +1,10 @@
1
1
  import { default as React } from 'react';
2
+ export type AiEditedFieldBadgeVariant = 'edited' | 'deleted';
2
3
  interface AiEditedFieldBadgeProps {
3
4
  className?: string;
4
5
  title?: string;
5
6
  ariaLabel?: string;
7
+ variant?: AiEditedFieldBadgeVariant;
6
8
  }
7
9
  declare const AiEditedFieldBadge: React.FC<AiEditedFieldBadgeProps>;
8
10
  export default AiEditedFieldBadge;
@@ -1,9 +1,11 @@
1
1
  import { default as React } from 'react';
2
+ import { AiEditedFieldBadgeVariant } from './AiEditedFieldBadge';
2
3
  interface DisplayPropertyNameProps {
3
4
  property: string;
4
5
  label?: string;
5
6
  className?: string;
6
7
  aiEdited?: boolean;
8
+ aiEditedVariant?: AiEditedFieldBadgeVariant;
7
9
  }
8
10
  declare const DisplayPropertyName: React.FC<DisplayPropertyNameProps>;
9
11
  export default DisplayPropertyName;
@@ -1,4 +1,5 @@
1
1
  import { default as React } from 'react';
2
+ import { AiEditedFieldBadgeVariant } from './AiEditedFieldBadge';
2
3
  interface EntityIdProps {
3
4
  entity: {
4
5
  '@id': string;
@@ -9,6 +10,7 @@ interface EntityIdProps {
9
10
  value: string;
10
11
  }) => void;
11
12
  aiEdited?: boolean;
13
+ aiEditedVariant?: AiEditedFieldBadgeVariant;
12
14
  }
13
15
  export declare const EntityId: React.FC<EntityIdProps>;
14
16
  export default EntityId;
@@ -1,4 +1,5 @@
1
1
  import { default as React } from 'react';
2
+ import { AiEditedFieldBadgeVariant } from './AiEditedFieldBadge';
2
3
  interface EntityNameProps {
3
4
  entity: {
4
5
  name: string;
@@ -10,6 +11,7 @@ interface EntityNameProps {
10
11
  }) => void;
11
12
  showHelp?: boolean;
12
13
  aiEdited?: boolean;
14
+ aiEditedVariant?: AiEditedFieldBadgeVariant;
13
15
  aiReview?: {
14
16
  operation?: string;
15
17
  previousValue?: any;
@@ -1,4 +1,5 @@
1
1
  import { default as React } from 'react';
2
+ import { AiEditedFieldBadgeVariant } from './AiEditedFieldBadge';
2
3
  interface EntityPropertyProps {
3
4
  entity: any;
4
5
  property: string;
@@ -7,6 +8,7 @@ interface EntityPropertyProps {
7
8
  savedProperty?: boolean;
8
9
  showHelp?: boolean;
9
10
  aiEdited?: boolean;
11
+ aiEditedVariant?: AiEditedFieldBadgeVariant;
10
12
  onLoadEntity: (data: {
11
13
  id: string;
12
14
  }) => void;
@@ -1,4 +1,5 @@
1
1
  import { default as React } from 'react';
2
+ import { AiEditedFieldBadgeVariant } from './AiEditedFieldBadge';
2
3
  interface EntityTypeProps {
3
4
  entity: {
4
5
  '@type': string[];
@@ -8,6 +9,7 @@ interface EntityTypeProps {
8
9
  value: string[];
9
10
  }) => void;
10
11
  aiEdited?: boolean;
12
+ aiEditedVariant?: AiEditedFieldBadgeVariant;
11
13
  }
12
14
  export declare const EntityType: React.FC<EntityTypeProps>;
13
15
  export default EntityType;
@@ -67666,10 +67666,19 @@ const useStateStore = () => {
67666
67666
  };
67667
67667
  const AiEditedFieldBadge = ({
67668
67668
  className = "",
67669
- title = "Edited by AI",
67670
- ariaLabel = "Edited by AI"
67671
- }) => /* @__PURE__ */ jsxRuntimeExports.jsx(Tooltip2, { title, children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: `describo-ai-edited-icon ${className}`, "aria-label": ariaLabel, children: "✦" }) });
67672
- const EntityId = ({ entity, onUpdate, aiEdited = false }) => {
67669
+ title,
67670
+ ariaLabel,
67671
+ variant = "edited"
67672
+ }) => {
67673
+ const label = variant === "deleted" ? "Deleted by AI" : "Edited by AI";
67674
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(Tooltip2, { title: title ?? label, children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: `describo-ai-edited-icon ${className}`, "aria-label": ariaLabel ?? label, children: "✦" }) });
67675
+ };
67676
+ const EntityId = ({
67677
+ entity,
67678
+ onUpdate,
67679
+ aiEdited = false,
67680
+ aiEditedVariant = "edited"
67681
+ }) => {
67673
67682
  var _a2;
67674
67683
  const state = useStateStore();
67675
67684
  const handleSave = async (data) => {
@@ -67685,7 +67694,7 @@ const EntityId = ({ entity, onUpdate, aiEdited = false }) => {
67685
67694
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-row", children: [
67686
67695
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "min-w-32 w-1/3 xl:w-1/5 describo-property-name describo-property-name-with-ai", children: [
67687
67696
  /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: "@id" }),
67688
- aiEdited && /* @__PURE__ */ jsxRuntimeExports.jsx(AiEditedFieldBadge, {})
67697
+ aiEdited && /* @__PURE__ */ jsxRuntimeExports.jsx(AiEditedFieldBadge, { variant: aiEditedVariant })
67689
67698
  ] }),
67690
67699
  !((_a2 = state.configuration) == null ? void 0 : _a2.readonly) ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "w-2/3 xl:w-4/5 flex flex-row describo-property-value", children: [
67691
67700
  isURL(entity["@id"]) && /* @__PURE__ */ jsxRuntimeExports.jsx(
@@ -67712,7 +67721,12 @@ const EntityId = ({ entity, onUpdate, aiEdited = false }) => {
67712
67721
  ] }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: entity["@id"] }) })
67713
67722
  ] });
67714
67723
  };
67715
- const EntityType = ({ entity, onUpdateEntity, aiEdited = false }) => {
67724
+ const EntityType = ({
67725
+ entity,
67726
+ onUpdateEntity,
67727
+ aiEdited = false,
67728
+ aiEditedVariant = "edited"
67729
+ }) => {
67716
67730
  var _a2;
67717
67731
  const [selectedClass, setSelectedClass] = useState(void 0);
67718
67732
  const profileManager = useContext(ProfileManagerContext);
@@ -67749,7 +67763,7 @@ const EntityType = ({ entity, onUpdateEntity, aiEdited = false }) => {
67749
67763
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(Flex, { className: "flex-row", children: [
67750
67764
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "min-w-32 w-1/3 xl:w-1/5 describo-property-name describo-property-name-with-ai", children: [
67751
67765
  /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: "@type" }),
67752
- aiEdited && /* @__PURE__ */ jsxRuntimeExports.jsx(AiEditedFieldBadge, {})
67766
+ aiEdited && /* @__PURE__ */ jsxRuntimeExports.jsx(AiEditedFieldBadge, { variant: aiEditedVariant })
67753
67767
  ] }),
67754
67768
  /* @__PURE__ */ jsxRuntimeExports.jsxs(Flex, { className: "w-2/3 xl:w-4/5 flex-row flex-wrap", children: [
67755
67769
  types2.map((etype) => /* @__PURE__ */ jsxRuntimeExports.jsx(
@@ -67828,6 +67842,7 @@ const EntityName = ({
67828
67842
  onUpdate,
67829
67843
  showHelp = true,
67830
67844
  aiEdited = false,
67845
+ aiEditedVariant = "edited",
67831
67846
  aiReview
67832
67847
  }) => {
67833
67848
  var _a2;
@@ -67851,7 +67866,7 @@ const EntityName = ({
67851
67866
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "min-w-32 w-1/3 xl:w-1/5 flex flex-col", children: [
67852
67867
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "describo-property-name describo-property-name-with-ai", children: [
67853
67868
  /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: t2("name_field_label") }),
67854
- aiEdited && /* @__PURE__ */ jsxRuntimeExports.jsx(AiEditedFieldBadge, {})
67869
+ aiEdited && /* @__PURE__ */ jsxRuntimeExports.jsx(AiEditedFieldBadge, { variant: aiEditedVariant })
67855
67870
  ] }),
67856
67871
  showHelp && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-gray-600 font-light text-xs pr-1 describo-property-help", children: t2("name_field_help") })
67857
67872
  ] }),
@@ -82332,11 +82347,12 @@ const DisplayPropertyName = ({
82332
82347
  label,
82333
82348
  className = "",
82334
82349
  // Default to empty string
82335
- aiEdited = false
82350
+ aiEdited = false,
82351
+ aiEditedVariant = "edited"
82336
82352
  }) => {
82337
82353
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: `describo-property-name describo-property-name-with-ai ${className}`, children: [
82338
82354
  /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: label || property }),
82339
- aiEdited && /* @__PURE__ */ jsxRuntimeExports.jsx(AiEditedFieldBadge, {})
82355
+ aiEdited && /* @__PURE__ */ jsxRuntimeExports.jsx(AiEditedFieldBadge, { variant: aiEditedVariant })
82340
82356
  ] });
82341
82357
  };
82342
82358
  const EntityProperty = ({
@@ -82347,6 +82363,7 @@ const EntityProperty = ({
82347
82363
  savedProperty = false,
82348
82364
  showHelp = true,
82349
82365
  aiEdited = false,
82366
+ aiEditedVariant = "edited",
82350
82367
  onLoadEntity,
82351
82368
  onCreateProperty,
82352
82369
  onCreateEntity,
@@ -82464,7 +82481,7 @@ const EntityProperty = ({
82464
82481
  }, [approvalContext, entity, property]);
82465
82482
  const handleSaveProperty = useCallback((data) => {
82466
82483
  var _a3;
82467
- if (unapprovedApprovalRecord) {
82484
+ if (approvalRecords.length > 0) {
82468
82485
  (_a3 = approvalContext == null ? void 0 : approvalContext.markApprovalPropertyApproved) == null ? void 0 : _a3.call(approvalContext, {
82469
82486
  entityId: entity == null ? void 0 : entity["@id"],
82470
82487
  propertyName: property,
@@ -82477,7 +82494,7 @@ const EntityProperty = ({
82477
82494
  return;
82478
82495
  }
82479
82496
  onSaveProperty(data);
82480
- }, [approvalContext, entity, hasCurrentPropertyValue, isAiDelete, onCreateProperty, onSaveProperty, property, unapprovedApprovalRecord]);
82497
+ }, [approvalContext, approvalRecords.length, entity, hasCurrentPropertyValue, isAiDelete, onCreateProperty, onSaveProperty, property]);
82481
82498
  const handleApproveAiSuggestion = useCallback(() => {
82482
82499
  markAiSuggestionApproved();
82483
82500
  }, [markAiSuggestionApproved]);
@@ -82521,7 +82538,8 @@ const EntityProperty = ({
82521
82538
  property,
82522
82539
  label: propertyDefinition == null ? void 0 : propertyDefinition.label,
82523
82540
  className: `inline-block ${isRequired && !isValid ? "text-red-600" : ""}`,
82524
- aiEdited
82541
+ aiEdited,
82542
+ aiEditedVariant
82525
82543
  }
82526
82544
  ),
82527
82545
  isRequired && !isValid && /* @__PURE__ */ jsxRuntimeExports.jsx(Badge, { status: "error", dot: true, className: "animate-pulse ml-2" })
@@ -113448,6 +113466,7 @@ const RenderEntity = forwardRef((props, ref) => {
113448
113466
  });
113449
113467
  };
113450
113468
  const getPendingApprovalForProperty = (property) => pendingAiApprovals.find((approvalRecord) => (approvalRecord == null ? void 0 : approvalRecord.propertyName) === property);
113469
+ const propertyHasApprovalRecord = (property) => pendingAiApprovalProperties.includes(property) || approvedAiApprovalProperties.includes(property);
113451
113470
  const handleApproveAiProperty = (property) => {
113452
113471
  var _a3;
113453
113472
  (_a3 = approvalContext == null ? void 0 : approvalContext.markApprovalPropertyApproved) == null ? void 0 : _a3.call(approvalContext, {
@@ -113482,8 +113501,7 @@ const RenderEntity = forwardRef((props, ref) => {
113482
113501
  };
113483
113502
  const handleUpdateCoreProperty = (data) => {
113484
113503
  var _a3;
113485
- const approvalRecord = getPendingApprovalForProperty(data.property);
113486
- if (approvalRecord) {
113504
+ if (propertyHasApprovalRecord(data.property)) {
113487
113505
  (_a3 = approvalContext == null ? void 0 : approvalContext.markApprovalPropertyApproved) == null ? void 0 : _a3.call(approvalContext, {
113488
113506
  entityId: entity["@id"],
113489
113507
  propertyName: data.property,
@@ -113675,6 +113693,7 @@ const RenderEntity = forwardRef((props, ref) => {
113675
113693
  };
113676
113694
  const fieldHasPendingAiApproval = (property) => pendingAiApprovalProperties.includes(property) || pendingDeletedEntityReviewProperties.includes(property);
113677
113695
  const fieldWasAiEdited = (property) => approvedAiApprovalProperties.includes(property);
113696
+ const fieldAiEditedVariant = (property) => approvedAiApprovals.some((approvalRecord) => (approvalRecord == null ? void 0 : approvalRecord.propertyName) === property && (approvalRecord == null ? void 0 : approvalRecord.operation) === "delete") ? "deleted" : "edited";
113678
113697
  const getFieldTitle = (property, label) => {
113679
113698
  var _a3, _b2;
113680
113699
  if (label) return label;
@@ -113820,7 +113839,15 @@ const RenderEntity = forwardRef((props, ref) => {
113820
113839
  {
113821
113840
  "data-recrate-property": "@id",
113822
113841
  className: `flex-grow describo-property describo-property-name-id ${savedProperty === "@id" ? "bg-green-200 rounded p-1 my-1" : ""} ${selectedAiApprovalProperty === "@id" ? "describo-ai-review-current" : ""}`,
113823
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(EntityId, { entity: contextEntity, onUpdate: handleUpdateEntity, aiEdited: fieldWasAiEdited("@id") })
113842
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(
113843
+ EntityId,
113844
+ {
113845
+ entity: contextEntity,
113846
+ onUpdate: handleUpdateCoreProperty,
113847
+ aiEdited: fieldWasAiEdited("@id"),
113848
+ aiEditedVariant: fieldAiEditedVariant("@id")
113849
+ }
113850
+ )
113824
113851
  }
113825
113852
  ),
113826
113853
  !((_g = state.configuration) == null ? void 0 : _g.readonly) && missingRequiredData && /* @__PURE__ */ jsxRuntimeExports.jsx(
@@ -113843,7 +113870,15 @@ const RenderEntity = forwardRef((props, ref) => {
113843
113870
  }
113844
113871
  )
113845
113872
  ] }),
113846
- shouldRenderCoreField("@type") && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { "data-recrate-property": "@type", className: `my-2 p-2 describo-property describo-property-name-type ${selectedAiApprovalProperty === "@type" ? "describo-ai-review-current" : ""}`, children: /* @__PURE__ */ jsxRuntimeExports.jsx(EntityType, { entity: contextEntity, onUpdateEntity: handleUpdateEntity, aiEdited: fieldWasAiEdited("@type") }) }),
113873
+ shouldRenderCoreField("@type") && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { "data-recrate-property": "@type", className: `my-2 p-2 describo-property describo-property-name-type ${selectedAiApprovalProperty === "@type" ? "describo-ai-review-current" : ""}`, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
113874
+ EntityType,
113875
+ {
113876
+ entity: contextEntity,
113877
+ onUpdateEntity: handleUpdateCoreProperty,
113878
+ aiEdited: fieldWasAiEdited("@type"),
113879
+ aiEditedVariant: fieldAiEditedVariant("@type")
113880
+ }
113881
+ ) }),
113847
113882
  shouldRenderCoreField("name") && /* @__PURE__ */ jsxRuntimeExports.jsx(
113848
113883
  "div",
113849
113884
  {
@@ -113856,6 +113891,7 @@ const RenderEntity = forwardRef((props, ref) => {
113856
113891
  onUpdate: handleUpdateCoreProperty,
113857
113892
  showHelp: showFieldHelp,
113858
113893
  aiEdited: fieldWasAiEdited("name"),
113894
+ aiEditedVariant: fieldAiEditedVariant("name"),
113859
113895
  aiReview: getCoreAiReviewProps("name")
113860
113896
  }
113861
113897
  )
@@ -113878,6 +113914,7 @@ const RenderEntity = forwardRef((props, ref) => {
113878
113914
  savedProperty: savedProperty === property,
113879
113915
  showHelp: showFieldHelp,
113880
113916
  aiEdited: fieldWasAiEdited(property),
113917
+ aiEditedVariant: fieldAiEditedVariant(property),
113881
113918
  onLoadEntity: handleLoadEntityWithContext,
113882
113919
  onCreateEntity: handleCreateEntity,
113883
113920
  onLinkEntity: handleLinkEntity,
@@ -113926,7 +113963,15 @@ const RenderEntity = forwardRef((props, ref) => {
113926
113963
  {
113927
113964
  "data-recrate-property": "@id",
113928
113965
  className: `flex-grow describo-property describo-property-name-id ${savedProperty === "@id" ? "bg-green-200 rounded p-1 my-1" : ""} ${selectedAiApprovalProperty === "@id" ? "describo-ai-review-current" : ""}`,
113929
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(EntityId, { entity: contextEntity, onUpdate: handleUpdateEntity, aiEdited: fieldWasAiEdited("@id") })
113966
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(
113967
+ EntityId,
113968
+ {
113969
+ entity: contextEntity,
113970
+ onUpdate: handleUpdateCoreProperty,
113971
+ aiEdited: fieldWasAiEdited("@id"),
113972
+ aiEditedVariant: fieldAiEditedVariant("@id")
113973
+ }
113974
+ )
113930
113975
  }
113931
113976
  ),
113932
113977
  !((_k = state.configuration) == null ? void 0 : _k.readonly) && missingRequiredData && /* @__PURE__ */ jsxRuntimeExports.jsx(
@@ -113949,7 +113994,15 @@ const RenderEntity = forwardRef((props, ref) => {
113949
113994
  }
113950
113995
  )
113951
113996
  ] }),
113952
- shouldRenderCoreField("@type") && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { "data-recrate-property": "@type", className: `my-2 p-2 describo-property describo-property-name-type ${selectedAiApprovalProperty === "@type" ? "describo-ai-review-current" : ""}`, children: /* @__PURE__ */ jsxRuntimeExports.jsx(EntityType, { entity: contextEntity, onUpdateEntity: handleUpdateEntity, aiEdited: fieldWasAiEdited("@type") }) }),
113997
+ shouldRenderCoreField("@type") && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { "data-recrate-property": "@type", className: `my-2 p-2 describo-property describo-property-name-type ${selectedAiApprovalProperty === "@type" ? "describo-ai-review-current" : ""}`, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
113998
+ EntityType,
113999
+ {
114000
+ entity: contextEntity,
114001
+ onUpdateEntity: handleUpdateCoreProperty,
114002
+ aiEdited: fieldWasAiEdited("@type"),
114003
+ aiEditedVariant: fieldAiEditedVariant("@type")
114004
+ }
114005
+ ) }),
113953
114006
  shouldRenderCoreField("name") && /* @__PURE__ */ jsxRuntimeExports.jsx(
113954
114007
  "div",
113955
114008
  {
@@ -113962,6 +114015,7 @@ const RenderEntity = forwardRef((props, ref) => {
113962
114015
  onUpdate: handleUpdateCoreProperty,
113963
114016
  showHelp: showFieldHelp,
113964
114017
  aiEdited: fieldWasAiEdited("name"),
114018
+ aiEditedVariant: fieldAiEditedVariant("name"),
113965
114019
  aiReview: getCoreAiReviewProps("name")
113966
114020
  }
113967
114021
  )
@@ -113984,6 +114038,7 @@ const RenderEntity = forwardRef((props, ref) => {
113984
114038
  savedProperty: savedProperty === property,
113985
114039
  showHelp: showFieldHelp,
113986
114040
  aiEdited: fieldWasAiEdited(property),
114041
+ aiEditedVariant: fieldAiEditedVariant(property),
113987
114042
  onLoadEntity: handleLoadEntityWithContext,
113988
114043
  onCreateEntity: handleCreateEntity,
113989
114044
  onLinkEntity: handleLinkEntity,
@@ -114031,10 +114086,26 @@ const RenderEntity = forwardRef((props, ref) => {
114031
114086
  {
114032
114087
  "data-recrate-property": "@id",
114033
114088
  className: `p-2 describo-property describo-property-name-id ${savedProperty === "@id" ? "bg-green-200 rounded" : ""} ${selectedAiApprovalProperty === "@id" ? "describo-ai-review-current" : ""}`,
114034
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(EntityId, { entity: contextEntity, onUpdate: handleUpdateEntity, aiEdited: fieldWasAiEdited("@id") })
114089
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(
114090
+ EntityId,
114091
+ {
114092
+ entity: contextEntity,
114093
+ onUpdate: handleUpdateCoreProperty,
114094
+ aiEdited: fieldWasAiEdited("@id"),
114095
+ aiEditedVariant: fieldAiEditedVariant("@id")
114096
+ }
114097
+ )
114035
114098
  }
114036
114099
  ),
114037
- shouldRenderCoreField("@type") && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { "data-recrate-property": "@type", className: `p-2 describo-property describo-property-name-type ${selectedAiApprovalProperty === "@type" ? "describo-ai-review-current" : ""}`, children: /* @__PURE__ */ jsxRuntimeExports.jsx(EntityType, { entity: contextEntity, onUpdateEntity: handleUpdateEntity, aiEdited: fieldWasAiEdited("@type") }) }),
114100
+ shouldRenderCoreField("@type") && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { "data-recrate-property": "@type", className: `p-2 describo-property describo-property-name-type ${selectedAiApprovalProperty === "@type" ? "describo-ai-review-current" : ""}`, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
114101
+ EntityType,
114102
+ {
114103
+ entity: contextEntity,
114104
+ onUpdateEntity: handleUpdateCoreProperty,
114105
+ aiEdited: fieldWasAiEdited("@type"),
114106
+ aiEditedVariant: fieldAiEditedVariant("@type")
114107
+ }
114108
+ ) }),
114038
114109
  shouldRenderCoreField("name") && /* @__PURE__ */ jsxRuntimeExports.jsx(
114039
114110
  "div",
114040
114111
  {
@@ -114047,6 +114118,7 @@ const RenderEntity = forwardRef((props, ref) => {
114047
114118
  onUpdate: handleUpdateCoreProperty,
114048
114119
  showHelp: showFieldHelp,
114049
114120
  aiEdited: fieldWasAiEdited("name"),
114121
+ aiEditedVariant: fieldAiEditedVariant("name"),
114050
114122
  aiReview: getCoreAiReviewProps("name")
114051
114123
  }
114052
114124
  )
@@ -114069,6 +114141,7 @@ const RenderEntity = forwardRef((props, ref) => {
114069
114141
  savedProperty: savedProperty === input.name,
114070
114142
  showHelp: showFieldHelp,
114071
114143
  aiEdited: fieldWasAiEdited(input.name),
114144
+ aiEditedVariant: fieldAiEditedVariant(input.name),
114072
114145
  onLoadEntity: handleLoadEntityWithContext,
114073
114146
  onCreateEntity: handleCreateEntity,
114074
114147
  onLinkEntity: handleLinkEntity,
@@ -114108,6 +114181,7 @@ const RenderEntity = forwardRef((props, ref) => {
114108
114181
  savedProperty: savedProperty === input.name,
114109
114182
  showHelp: showFieldHelp,
114110
114183
  aiEdited: fieldWasAiEdited(input.name),
114184
+ aiEditedVariant: fieldAiEditedVariant(input.name),
114111
114185
  onLoadEntity: handleLoadEntityWithContext,
114112
114186
  onCreateEntity: handleCreateEntity,
114113
114187
  onLinkEntity: handleLinkEntity,
@@ -122481,29 +122555,36 @@ var EmotionCacheContext = /* @__PURE__ */ React.createContext(
122481
122555
  }) : null
122482
122556
  );
122483
122557
  var CacheProvider = EmotionCacheContext.Provider;
122484
- const version = "0.1.32-test";
122558
+ const version = "0.1.32-test2";
122485
122559
  const pkg = {
122486
122560
  version
122487
122561
  };
122488
122562
  const antdCache = createScopedCache("recrate");
122489
- const markApprovalRecordsApproved = (approvalState, entityId, propertyName2) => {
122563
+ const markApprovalRecordsApproved = (approvalState, entityId, propertyName2, decision) => {
122490
122564
  const approvalRecords = [];
122491
122565
  let changed = false;
122566
+ const shouldRemove = decision === "reject" || decision === "manual-edit";
122567
+ const hasApprovalRecords = (entityApproval) => Array.isArray(entityApproval == null ? void 0 : entityApproval.approval) && entityApproval.approval.length > 0;
122492
122568
  const updateEntityApproval = (entityApproval) => {
122493
122569
  if (!entityApproval || !entityIdsMatch(entityApproval["@id"], entityId) || !Array.isArray(entityApproval.approval)) {
122494
122570
  return entityApproval;
122495
122571
  }
122496
122572
  let entityChanged = false;
122497
- const nextApprovalRecords = entityApproval.approval.map((approvalRecord) => {
122573
+ const nextApprovalRecords = entityApproval.approval.flatMap((approvalRecord) => {
122498
122574
  if ((approvalRecord == null ? void 0 : approvalRecord.propertyName) !== propertyName2) {
122499
- return approvalRecord;
122575
+ return [approvalRecord];
122576
+ }
122577
+ if (shouldRemove) {
122578
+ approvalRecords.push(approvalRecord);
122579
+ entityChanged = true;
122580
+ return [];
122500
122581
  }
122501
122582
  const nextApprovalRecord = { ...approvalRecord, approved: true };
122502
122583
  approvalRecords.push(nextApprovalRecord);
122503
122584
  if (approvalRecord.approved !== true) {
122504
122585
  entityChanged = true;
122505
122586
  }
122506
- return nextApprovalRecord;
122587
+ return [nextApprovalRecord];
122507
122588
  });
122508
122589
  if (!entityChanged) return entityApproval;
122509
122590
  changed = true;
@@ -122513,19 +122594,20 @@ const markApprovalRecordsApproved = (approvalState, entityId, propertyName2) =>
122513
122594
  };
122514
122595
  };
122515
122596
  if (Array.isArray(approvalState)) {
122516
- const nextApprovalState = approvalState.map(updateEntityApproval);
122597
+ const nextApprovalState = approvalState.map(updateEntityApproval).filter(hasApprovalRecords);
122517
122598
  return { nextApprovalState, approvalRecords, changed };
122518
122599
  }
122519
122600
  if (approvalState && typeof approvalState === "object") {
122520
122601
  if (Array.isArray(approvalState.approval)) {
122602
+ const nextApprovalState = updateEntityApproval(approvalState);
122521
122603
  return {
122522
- nextApprovalState: updateEntityApproval(approvalState),
122604
+ nextApprovalState: hasApprovalRecords(nextApprovalState) ? nextApprovalState : void 0,
122523
122605
  approvalRecords,
122524
122606
  changed
122525
122607
  };
122526
122608
  }
122527
122609
  if (Array.isArray(approvalState.items)) {
122528
- const nextItems = approvalState.items.map(updateEntityApproval);
122610
+ const nextItems = approvalState.items.map(updateEntityApproval).filter(hasApprovalRecords);
122529
122611
  return {
122530
122612
  nextApprovalState: changed ? { ...approvalState, items: nextItems } : approvalState,
122531
122613
  approvalRecords,
@@ -122535,22 +122617,29 @@ const markApprovalRecordsApproved = (approvalState, entityId, propertyName2) =>
122535
122617
  }
122536
122618
  return { nextApprovalState: approvalState, approvalRecords, changed };
122537
122619
  };
122538
- const markEntityApprovalRecordsApproved = (approvalState, entityId) => {
122620
+ const markEntityApprovalRecordsApproved = (approvalState, entityId, decision) => {
122539
122621
  const approvalRecords = [];
122540
122622
  let changed = false;
122623
+ const shouldRemove = decision === "reject" || decision === "manual-edit";
122624
+ const hasApprovalRecords = (entityApproval) => Array.isArray(entityApproval == null ? void 0 : entityApproval.approval) && entityApproval.approval.length > 0;
122541
122625
  const updateEntityApproval = (entityApproval) => {
122542
122626
  if (!entityApproval || !entityIdsMatch(entityApproval["@id"], entityId) || !Array.isArray(entityApproval.approval)) {
122543
122627
  return entityApproval;
122544
122628
  }
122545
122629
  let entityChanged = false;
122546
- const nextApprovalRecords = entityApproval.approval.map((approvalRecord) => {
122630
+ const nextApprovalRecords = entityApproval.approval.flatMap((approvalRecord) => {
122547
122631
  if ((approvalRecord == null ? void 0 : approvalRecord.approved) === true || (approvalRecord == null ? void 0 : approvalRecord.approved) === "true") {
122548
- return approvalRecord;
122632
+ return [approvalRecord];
122633
+ }
122634
+ if (shouldRemove) {
122635
+ approvalRecords.push(approvalRecord);
122636
+ entityChanged = true;
122637
+ return [];
122549
122638
  }
122550
122639
  const nextApprovalRecord = { ...approvalRecord, approved: true };
122551
122640
  approvalRecords.push(nextApprovalRecord);
122552
122641
  entityChanged = true;
122553
- return nextApprovalRecord;
122642
+ return [nextApprovalRecord];
122554
122643
  });
122555
122644
  if (!entityChanged) return entityApproval;
122556
122645
  changed = true;
@@ -122560,19 +122649,20 @@ const markEntityApprovalRecordsApproved = (approvalState, entityId) => {
122560
122649
  };
122561
122650
  };
122562
122651
  if (Array.isArray(approvalState)) {
122563
- const nextApprovalState = approvalState.map(updateEntityApproval);
122652
+ const nextApprovalState = approvalState.map(updateEntityApproval).filter(hasApprovalRecords);
122564
122653
  return { nextApprovalState, approvalRecords, changed };
122565
122654
  }
122566
122655
  if (approvalState && typeof approvalState === "object") {
122567
122656
  if (Array.isArray(approvalState.approval)) {
122657
+ const nextApprovalState = updateEntityApproval(approvalState);
122568
122658
  return {
122569
- nextApprovalState: updateEntityApproval(approvalState),
122659
+ nextApprovalState: hasApprovalRecords(nextApprovalState) ? nextApprovalState : void 0,
122570
122660
  approvalRecords,
122571
122661
  changed
122572
122662
  };
122573
122663
  }
122574
122664
  if (Array.isArray(approvalState.items)) {
122575
- const nextItems = approvalState.items.map(updateEntityApproval);
122665
+ const nextItems = approvalState.items.map(updateEntityApproval).filter(hasApprovalRecords);
122576
122666
  return {
122577
122667
  nextApprovalState: changed ? { ...approvalState, items: nextItems } : approvalState,
122578
122668
  approvalRecords,
@@ -122644,7 +122734,8 @@ function DescriboCrateBuilderInner(props) {
122644
122734
  const { nextApprovalState, approvalRecords, changed } = markApprovalRecordsApproved(
122645
122735
  approvalState,
122646
122736
  entityId2,
122647
- propertyName2
122737
+ propertyName2,
122738
+ decision
122648
122739
  );
122649
122740
  if (!changed && approvalRecords.length === 0) return;
122650
122741
  setApprovalState(nextApprovalState);
@@ -122662,7 +122753,8 @@ function DescriboCrateBuilderInner(props) {
122662
122753
  if (!entityId2) return;
122663
122754
  const { nextApprovalState, approvalRecords, changed } = markEntityApprovalRecordsApproved(
122664
122755
  approvalState,
122665
- entityId2
122756
+ entityId2,
122757
+ decision
122666
122758
  );
122667
122759
  if (!changed && approvalRecords.length === 0) return;
122668
122760
  setApprovalState(nextApprovalState);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arpproject/recrate",
3
- "version": "0.1.32-test",
3
+ "version": "0.1.32-test2",
4
4
  "type": "module",
5
5
  "main": "./dist/recrate.es.js",
6
6
  "module": "./dist/recrate.es.js",