@ixo/editor 3.0.0-beta.15 → 3.0.0-beta.17

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,4 +1,4 @@
1
- import { r as FlowNode, F as FlowNodeAuthzExtension, p as FlowNodeRuntimeState, J as IxoEditorType, S as SignedCapability, B as CreateRootDelegationParams, t as StoredDelegation, G as CreateDelegationParams, H as CreateInvocationParams, w as InvocationResult, x as ExecutionWithInvocationResult, s as UcanCapability, y as DelegationChainValidationResult, z as FindProofsResult, M as MigrationReport, U as UcanDelegationStore, l as InvocationStore, E as EvaluationStatus, C as Capability, a as CapabilityValidationResult } from './index-tyLe-Ge8.mjs';
1
+ import { r as FlowNode, F as FlowNodeAuthzExtension, p as FlowNodeRuntimeState, J as IxoEditorType, S as SignedCapability, B as CreateRootDelegationParams, t as StoredDelegation, G as CreateDelegationParams, H as CreateInvocationParams, w as InvocationResult, x as ExecutionWithInvocationResult, s as UcanCapability, y as DelegationChainValidationResult, z as FindProofsResult, M as MigrationReport, U as UcanDelegationStore, l as InvocationStore, E as EvaluationStatus, C as Capability, a as CapabilityValidationResult } from './index-C5pBDzcw.mjs';
2
2
  import { Delegation } from '@ixo/ucan';
3
3
  import { Doc, Map } from 'yjs';
4
4
 
@@ -16,7 +16,7 @@ import {
16
16
  isActorAuthorized,
17
17
  parseLinkedEntities,
18
18
  transformSurveyToCredentialSubject
19
- } from "./chunk-UHF7YDII.mjs";
19
+ } from "./chunk-MB36TYBB.mjs";
20
20
 
21
21
  // src/mantine/hooks/useCreateIxoEditor.ts
22
22
  import { useCreateBlockNote } from "@blocknote/react";
@@ -25638,8 +25638,13 @@ var EvaluateClaimFlowDetail = ({ inputs, editor, block, runtime, updateRuntime,
25638
25638
  const [evaluationLoading, setEvaluationLoading] = useState99(false);
25639
25639
  const [evaluationResult, setEvaluationResult] = useState99(null);
25640
25640
  const [activeFilter, setActiveFilter] = useState99("all");
25641
+ const [outcomeTemplateJson, setOutcomeTemplateJson] = useState99(null);
25642
+ const [outcomeTemplateLoading, setOutcomeTemplateLoading] = useState99(false);
25643
+ const [outcomeResponses, setOutcomeResponses] = useState99({});
25644
+ const [outcomeComplete, setOutcomeComplete] = useState99(false);
25641
25645
  const [submissionOpen, setSubmissionOpen] = useState99(false);
25642
25646
  const [aiEvalOpen, setAiEvalOpen] = useState99(false);
25647
+ const [outcomeOpen, setOutcomeOpen] = useState99(true);
25643
25648
  const [evaluationOpen, setEvaluationOpen] = useState99(true);
25644
25649
  const [isEvaluatorAuthorized, setIsEvaluatorAuthorized] = useState99(false);
25645
25650
  const [authChecking, setAuthChecking] = useState99(true);
@@ -25662,6 +25667,21 @@ var EvaluateClaimFlowDetail = ({ inputs, editor, block, runtime, updateRuntime,
25662
25667
  model.data = claimData;
25663
25668
  return model;
25664
25669
  }, [surveyJson, claimData]);
25670
+ const outcomeSurveyModel = useMemo96(() => {
25671
+ if (!outcomeTemplateJson) return null;
25672
+ const model = new SurveyModel11(outcomeTemplateJson);
25673
+ model.applyTheme(surveyTheme2);
25674
+ model.showQuestionNumbers = "off";
25675
+ model.questionsOnPageMode = "singlePage";
25676
+ model.onValueChanged.add((sender) => {
25677
+ setOutcomeResponses({ ...sender.data });
25678
+ });
25679
+ model.onComplete.add((sender) => {
25680
+ setOutcomeResponses({ ...sender.data });
25681
+ setOutcomeComplete(true);
25682
+ });
25683
+ return model;
25684
+ }, [outcomeTemplateJson]);
25665
25685
  const refreshClaims = useCallback79(async () => {
25666
25686
  if (!deedDid || !collectionId) return;
25667
25687
  setLoadingClaims(true);
@@ -25694,6 +25714,17 @@ var EvaluateClaimFlowDetail = ({ inputs, editor, block, runtime, updateRuntime,
25694
25714
  setClaimData(claimDataResult || null);
25695
25715
  const surveyResult = await handlers.getDeedSurveyTemplate(deedDid);
25696
25716
  setSurveyJson(surveyResult?.surveyTemplate || null);
25717
+ if (handlers.getEvaluationTemplate) {
25718
+ setOutcomeTemplateLoading(true);
25719
+ try {
25720
+ const evalTemplateResult = await handlers.getEvaluationTemplate(deedDid);
25721
+ setOutcomeTemplateJson(evalTemplateResult?.surveyTemplate || null);
25722
+ } catch {
25723
+ setOutcomeTemplateJson(null);
25724
+ } finally {
25725
+ setOutcomeTemplateLoading(false);
25726
+ }
25727
+ }
25697
25728
  if (handlers.getDeedRubric && handlers.evaluateWithRubric && claimDataResult) {
25698
25729
  setEvaluationLoading(true);
25699
25730
  try {
@@ -25734,6 +25765,9 @@ var EvaluateClaimFlowDetail = ({ inputs, editor, block, runtime, updateRuntime,
25734
25765
  setClaimData(null);
25735
25766
  setSurveyJson(null);
25736
25767
  setEvaluationResult(null);
25768
+ setOutcomeTemplateJson(null);
25769
+ setOutcomeResponses({});
25770
+ setOutcomeComplete(false);
25737
25771
  }, [deedDid, collectionId]);
25738
25772
  useEffect82(() => {
25739
25773
  if (!deedDid || !collectionId) return;
@@ -25827,14 +25861,18 @@ var EvaluateClaimFlowDetail = ({ inputs, editor, block, runtime, updateRuntime,
25827
25861
  }
25828
25862
  setSubmissionOpen(false);
25829
25863
  setAiEvalOpen(false);
25864
+ setOutcomeOpen(true);
25830
25865
  setEvaluationOpen(true);
25831
25866
  setPaymentRows([createPaymentRow2()]);
25867
+ setOutcomeResponses({});
25868
+ setOutcomeComplete(false);
25832
25869
  loadClaimDetail(selectedClaim);
25833
25870
  }, [selectedClaim, loadClaimDetail]);
25834
25871
  const isClaimAlreadyEvaluated = useMemo96(() => {
25835
25872
  if (!selectedClaim) return false;
25836
25873
  return isClaimEvaluated(selectedClaim);
25837
25874
  }, [selectedClaim]);
25875
+ const outcomeNotReady = Boolean(outcomeTemplateJson && !outcomeComplete);
25838
25876
  const addPaymentRow = useCallback79(() => {
25839
25877
  setPaymentRows((prev) => [...prev, createPaymentRow2()]);
25840
25878
  }, []);
@@ -25901,6 +25939,7 @@ var EvaluateClaimFlowDetail = ({ inputs, editor, block, runtime, updateRuntime,
25901
25939
  capabilityCid: capabilityId,
25902
25940
  rubricAuthority: deedDid,
25903
25941
  rubricId: deedDid,
25942
+ patch: Object.keys(outcomeResponses).length > 0 ? outcomeResponses : void 0,
25904
25943
  traceCid: evaluationResult?.trace?.result?.executionId,
25905
25944
  items: evaluationResult?.trace?.result?.steps?.map((step) => ({
25906
25945
  id: step.stepId,
@@ -25974,7 +26013,8 @@ var EvaluateClaimFlowDetail = ({ inputs, editor, block, runtime, updateRuntime,
25974
26013
  updateRuntime,
25975
26014
  refreshClaims,
25976
26015
  buildPaymentCoins,
25977
- evaluationResult
26016
+ evaluationResult,
26017
+ outcomeResponses
25978
26018
  ]
25979
26019
  );
25980
26020
  if (selectedClaim) {
@@ -26025,6 +26065,17 @@ var EvaluateClaimFlowDetail = ({ inputs, editor, block, runtime, updateRuntime,
26025
26065
  },
26026
26066
  /* @__PURE__ */ React246.createElement(UnstyledButton4, { onClick: () => setAiEvalOpen((v) => !v), style: { width: "100%" } }, /* @__PURE__ */ React246.createElement(Group93, { gap: "xs", align: "center" }, aiEvalOpen ? /* @__PURE__ */ React246.createElement(IconChevronDown10, { size: 16 }) : /* @__PURE__ */ React246.createElement(IconChevronRight13, { size: 16 }), /* @__PURE__ */ React246.createElement(Text140, { fw: 500, size: "sm" }, "AI Evaluation"))),
26027
26067
  /* @__PURE__ */ React246.createElement(Collapse10, { in: aiEvalOpen }, /* @__PURE__ */ React246.createElement(Box48, { mt: "sm" }, evaluationLoading ? /* @__PURE__ */ React246.createElement(Group93, { gap: "xs" }, /* @__PURE__ */ React246.createElement(Loader42, { size: "xs" }), /* @__PURE__ */ React246.createElement(Text140, { size: "xs", c: "dimmed" }, "Running rubric evaluation...")) : evaluationResult ? /* @__PURE__ */ React246.createElement(ScrollArea8, { h: 280 }, /* @__PURE__ */ React246.createElement(RubricEvaluationResults, { evaluation: evaluationResult })) : /* @__PURE__ */ React246.createElement(Text140, { size: "xs", c: "dimmed" }, "No rubric evaluation available for this claim.")))
26068
+ ), (outcomeTemplateLoading || outcomeTemplateJson) && /* @__PURE__ */ React246.createElement(
26069
+ Box48,
26070
+ {
26071
+ p: "sm",
26072
+ style: {
26073
+ borderRadius: 16,
26074
+ background: "var(--mantine-color-neutralColor-5)"
26075
+ }
26076
+ },
26077
+ /* @__PURE__ */ React246.createElement(UnstyledButton4, { onClick: () => setOutcomeOpen((v) => !v), style: { width: "100%" } }, /* @__PURE__ */ React246.createElement(Group93, { gap: "xs", align: "center" }, outcomeOpen ? /* @__PURE__ */ React246.createElement(IconChevronDown10, { size: 16 }) : /* @__PURE__ */ React246.createElement(IconChevronRight13, { size: 16 }), /* @__PURE__ */ React246.createElement(Text140, { fw: 500, size: "sm" }, "Outcome"), outcomeTemplateJson && !outcomeComplete && /* @__PURE__ */ React246.createElement(Text140, { size: "xs", c: "yellow" }, "(required)"), outcomeComplete && /* @__PURE__ */ React246.createElement(IconCheck19, { size: 14, color: "var(--mantine-color-green-6)" }))),
26078
+ /* @__PURE__ */ React246.createElement(Collapse10, { in: outcomeOpen }, /* @__PURE__ */ React246.createElement(Box48, { mt: "sm" }, outcomeTemplateLoading ? /* @__PURE__ */ React246.createElement(Group93, { gap: "xs" }, /* @__PURE__ */ React246.createElement(Loader42, { size: "xs" }), /* @__PURE__ */ React246.createElement(Text140, { size: "xs", c: "dimmed" }, "Loading evaluation template...")) : outcomeSurveyModel ? /* @__PURE__ */ React246.createElement(ScrollArea8, { h: 320 }, /* @__PURE__ */ React246.createElement(Survey11, { model: outcomeSurveyModel })) : /* @__PURE__ */ React246.createElement(Text140, { size: "xs", c: "dimmed" }, "No evaluation template available.")))
26028
26079
  ), /* @__PURE__ */ React246.createElement(
26029
26080
  Box48,
26030
26081
  {
@@ -26066,12 +26117,12 @@ var EvaluateClaimFlowDetail = ({ inputs, editor, block, runtime, updateRuntime,
26066
26117
  disabled: isDisabled || submitting
26067
26118
  }
26068
26119
  ))), /* @__PURE__ */ React246.createElement(Button43, { variant: "light", size: "xs", onClick: addPaymentRow, disabled: isDisabled || submitting }, "Add Payment"), /* @__PURE__ */ React246.createElement(Checkbox12, { label: "Generate UDID proof before evaluation", checked: createUdid, onChange: (event) => setCreateUdid(event.currentTarget.checked) })))
26069
- ), isClaimAlreadyEvaluated && /* @__PURE__ */ React246.createElement(Alert43, { color: "yellow", styles: actionAlertStyles }, "This claim is already evaluated. Re-evaluation is disabled."), !authChecking && !isEvaluatorAuthorized && /* @__PURE__ */ React246.createElement(Alert43, { color: "yellow", styles: actionAlertStyles }, "You need evaluator authorization for this collection to approve or reject claims."), /* @__PURE__ */ React246.createElement(Group93, { gap: "xs" }, /* @__PURE__ */ React246.createElement(
26120
+ ), outcomeNotReady && /* @__PURE__ */ React246.createElement(Alert43, { color: "yellow", styles: actionAlertStyles }, "Complete the Outcome evaluation template before approving or rejecting."), isClaimAlreadyEvaluated && /* @__PURE__ */ React246.createElement(Alert43, { color: "yellow", styles: actionAlertStyles }, "This claim is already evaluated. Re-evaluation is disabled."), !authChecking && !isEvaluatorAuthorized && /* @__PURE__ */ React246.createElement(Alert43, { color: "yellow", styles: actionAlertStyles }, "You need evaluator authorization for this collection to approve or reject claims."), /* @__PURE__ */ React246.createElement(Group93, { gap: "xs" }, /* @__PURE__ */ React246.createElement(
26070
26121
  BasePrimaryButton,
26071
26122
  {
26072
26123
  leftSection: /* @__PURE__ */ React246.createElement(IconThumbUp4, { size: 16 }),
26073
26124
  onClick: () => executeEvaluation("approve"),
26074
- disabled: isDisabled || submitting || authChecking || !isEvaluatorAuthorized || !adminAddress || isClaimAlreadyEvaluated
26125
+ disabled: isDisabled || submitting || authChecking || !isEvaluatorAuthorized || !adminAddress || isClaimAlreadyEvaluated || outcomeNotReady
26075
26126
  },
26076
26127
  "Approve"
26077
26128
  ), /* @__PURE__ */ React246.createElement(
@@ -26079,7 +26130,7 @@ var EvaluateClaimFlowDetail = ({ inputs, editor, block, runtime, updateRuntime,
26079
26130
  {
26080
26131
  leftSection: /* @__PURE__ */ React246.createElement(IconThumbDown2, { size: 16 }),
26081
26132
  onClick: () => executeEvaluation("reject"),
26082
- disabled: isDisabled || submitting || authChecking || !isEvaluatorAuthorized || !adminAddress || isClaimAlreadyEvaluated
26133
+ disabled: isDisabled || submitting || authChecking || !isEvaluatorAuthorized || !adminAddress || isClaimAlreadyEvaluated || outcomeNotReady
26083
26134
  },
26084
26135
  "Reject"
26085
26136
  )), error && /* @__PURE__ */ React246.createElement(Alert43, { color: "red", styles: actionAlertStyles }, error));
@@ -29843,13 +29894,19 @@ var MatrixMetadataManager = class {
29843
29894
  }
29844
29895
  try {
29845
29896
  const promises = [];
29846
- if ("cover" in metadata) {
29897
+ if ("cover" in metadata || "coverPosition" in metadata) {
29898
+ const room = this.matrixClient.getRoom(this.roomId);
29899
+ const existingEvent = room?.currentState.getStateEvents(COVER_IMAGE_EVENT_TYPE, "");
29900
+ const existingContent = existingEvent ? existingEvent.getContent() : {};
29901
+ const content = {
29902
+ url: "cover" in metadata ? metadata.cover || null : existingContent.url ?? null,
29903
+ position: "coverPosition" in metadata ? metadata.coverPosition ?? null : existingContent.position ?? null
29904
+ };
29847
29905
  promises.push(
29848
29906
  this.matrixClient.sendStateEvent(
29849
29907
  this.roomId,
29850
29908
  COVER_IMAGE_EVENT_TYPE,
29851
- { url: metadata.cover || null },
29852
- // Wrap in object - null means removed
29909
+ content,
29853
29910
  ""
29854
29911
  // Empty state key
29855
29912
  )
@@ -29892,6 +29949,7 @@ var MatrixMetadataManager = class {
29892
29949
  );
29893
29950
  const coverContent = coverEvent ? coverEvent.getContent() : null;
29894
29951
  const coverUrl = coverContent?.url || null;
29952
+ const coverPos = coverContent?.position ?? null;
29895
29953
  const iconEvent = room.currentState.getStateEvents(
29896
29954
  COVER_ICON_EVENT_TYPE,
29897
29955
  ""
@@ -29904,7 +29962,8 @@ var MatrixMetadataManager = class {
29904
29962
  }
29905
29963
  return {
29906
29964
  cover: coverUrl || void 0,
29907
- icon: iconUrl || void 0
29965
+ icon: iconUrl || void 0,
29966
+ coverPosition: coverPos ?? void 0
29908
29967
  };
29909
29968
  } catch (error) {
29910
29969
  console.error("Failed to get page metadata:", error);
@@ -30829,7 +30888,7 @@ function CoverImage({ coverImageUrl, logoUrl }) {
30829
30888
  const { editor, handlers, editable } = useBlocknoteContext();
30830
30889
  const [isHovering, setIsHovering] = useState127(false);
30831
30890
  const [isRepositioning, setIsRepositioning] = useState127(false);
30832
- const [coverPosition, setCoverPosition] = useState127(50);
30891
+ const [coverPosition, setCoverPosition] = useState127(() => editor?.getPageMetadata?.()?.coverPosition ?? 50);
30833
30892
  const coverFileInputRef = useRef27(null);
30834
30893
  const logoFileInputRef = useRef27(null);
30835
30894
  const [opened, { open, close }] = useDisclosure7(false);
@@ -30842,8 +30901,14 @@ function CoverImage({ coverImageUrl, logoUrl }) {
30842
30901
  }
30843
30902
  const initialMetadata = editor._metadataManager.getMetadata();
30844
30903
  setMetadata(initialMetadata);
30904
+ if (initialMetadata?.coverPosition != null) {
30905
+ setCoverPosition(initialMetadata.coverPosition);
30906
+ }
30845
30907
  const unsubscribe = editor._metadataManager.subscribe((newMetadata) => {
30846
30908
  setMetadata(newMetadata);
30909
+ if (newMetadata.coverPosition != null) {
30910
+ setCoverPosition(newMetadata.coverPosition);
30911
+ }
30847
30912
  });
30848
30913
  return unsubscribe;
30849
30914
  }, [editor]);
@@ -30911,7 +30976,7 @@ function CoverImage({ coverImageUrl, logoUrl }) {
30911
30976
  if (!isRepositioning) return;
30912
30977
  const rect = e.currentTarget.getBoundingClientRect();
30913
30978
  const y = e.clientY - rect.top;
30914
- const percentage = y / rect.height * 100;
30979
+ const percentage = Math.round(y / rect.height * 100);
30915
30980
  setCoverPosition(Math.max(0, Math.min(100, percentage)));
30916
30981
  };
30917
30982
  if (!editable && !hasCover && !hasLogo) {
@@ -31016,12 +31081,20 @@ function CoverImage({ coverImageUrl, logoUrl }) {
31016
31081
  onMouseEnter: () => editable && setIsHovering(true),
31017
31082
  onMouseLeave: () => {
31018
31083
  if (editable) {
31084
+ if (isRepositioning) {
31085
+ editor?.setPageMetadata?.({ coverPosition });
31086
+ }
31019
31087
  setIsHovering(false);
31020
31088
  setIsRepositioning(false);
31021
31089
  }
31022
31090
  },
31023
31091
  onMouseMove: handleMouseMove,
31024
- onClick: () => isRepositioning && setIsRepositioning(false)
31092
+ onClick: () => {
31093
+ if (isRepositioning) {
31094
+ setIsRepositioning(false);
31095
+ editor?.setPageMetadata?.({ coverPosition });
31096
+ }
31097
+ }
31025
31098
  },
31026
31099
  /* @__PURE__ */ React281.createElement(
31027
31100
  "img",
@@ -31053,11 +31126,23 @@ function CoverImage({ coverImageUrl, logoUrl }) {
31053
31126
  }
31054
31127
  },
31055
31128
  /* @__PURE__ */ React281.createElement(CoverImageButton, { onClick: () => coverFileInputRef.current?.click() }, "Change cover"),
31056
- /* @__PURE__ */ React281.createElement(CoverImageButton, { onClick: () => setIsRepositioning(!isRepositioning), isActive: isRepositioning }, isRepositioning ? "Done" : "Reposition"),
31129
+ /* @__PURE__ */ React281.createElement(
31130
+ CoverImageButton,
31131
+ {
31132
+ onClick: () => {
31133
+ if (isRepositioning) {
31134
+ editor?.setPageMetadata?.({ coverPosition });
31135
+ }
31136
+ setIsRepositioning(!isRepositioning);
31137
+ },
31138
+ isActive: isRepositioning
31139
+ },
31140
+ isRepositioning ? "Done" : "Reposition"
31141
+ ),
31057
31142
  /* @__PURE__ */ React281.createElement(CoverImageButton, { onClick: handleRemoveCover }, "Remove"),
31058
31143
  /* @__PURE__ */ React281.createElement(CoverImageButton, { onClick: openSettings }, "Settings")
31059
31144
  ),
31060
- /* @__PURE__ */ React281.createElement("div", { style: { maxWidth: "900px", margin: "0 auto", position: "absolute", bottom: 0, left: -40, right: 0, height: "70px" } }, /* @__PURE__ */ React281.createElement(
31145
+ /* @__PURE__ */ React281.createElement("div", { style: { maxWidth: "900px", margin: "0 auto", position: "absolute", bottom: 0, left: 0, right: 0, height: "70px" } }, /* @__PURE__ */ React281.createElement(
31061
31146
  Box58,
31062
31147
  {
31063
31148
  style: {
@@ -31069,7 +31154,7 @@ function CoverImage({ coverImageUrl, logoUrl }) {
31069
31154
  zIndex: 11
31070
31155
  }
31071
31156
  },
31072
- logoSrc && /* @__PURE__ */ React281.createElement(PageIcon, { src: logoSrc, iconSize: 64 }),
31157
+ logoSrc && /* @__PURE__ */ React281.createElement(PageIcon, { src: logoSrc, useCenter: true, iconSize: 64 }),
31073
31158
  editable && isHovering && /* @__PURE__ */ React281.createElement(React281.Fragment, null, logoSrc ? /* @__PURE__ */ React281.createElement(
31074
31159
  Group104,
31075
31160
  {
@@ -32332,4 +32417,4 @@ export {
32332
32417
  getExtraSlashMenuItems,
32333
32418
  useCreateIxoEditor
32334
32419
  };
32335
- //# sourceMappingURL=chunk-XSMXAAJC.mjs.map
32420
+ //# sourceMappingURL=chunk-5KCGR3WU.mjs.map