@ixo/editor 1.4.0 → 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-BO2JVTVH.mjs → chunk-VGSTHGS4.mjs} +370 -565
- package/dist/chunk-VGSTHGS4.mjs.map +1 -0
- package/dist/index.d.ts +10 -36
- package/dist/index.mjs +1 -1
- package/dist/mantine/index.mjs +1 -1
- package/package.json +7 -7
- package/style-mantine.css +1 -1
- package/style.css +1 -1
- package/dist/chunk-BO2JVTVH.mjs.map +0 -1
|
@@ -3207,57 +3207,6 @@ var OverviewBlock = createReactBlockSpec3(
|
|
|
3207
3207
|
}
|
|
3208
3208
|
);
|
|
3209
3209
|
|
|
3210
|
-
// src/mantine/context/types.ts
|
|
3211
|
-
var StakeType = {
|
|
3212
|
-
Delegate: "delegate",
|
|
3213
|
-
Undelegate: "undelegate",
|
|
3214
|
-
Redelegate: "redelegate",
|
|
3215
|
-
WithdrawDelegatorReward: "withdraw_delegator_reward"
|
|
3216
|
-
};
|
|
3217
|
-
var AuthzExecActionTypes = {
|
|
3218
|
-
Delegate: "/cosmos.staking.v1beta1.MsgDelegate",
|
|
3219
|
-
Undelegate: "/cosmos.staking.v1beta1.MsgUndelegate",
|
|
3220
|
-
Redelegate: "/cosmos.staking.v1beta1.MsgBeginRedelegate",
|
|
3221
|
-
ClaimRewards: "/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward",
|
|
3222
|
-
Custom: "custom"
|
|
3223
|
-
};
|
|
3224
|
-
var ValidatorActionType = /* @__PURE__ */ ((ValidatorActionType2) => {
|
|
3225
|
-
ValidatorActionType2["CreateValidator"] = "/cosmos.staking.v1beta1.MsgCreateValidator";
|
|
3226
|
-
ValidatorActionType2["EditValidator"] = "/cosmos.staking.v1beta1.MsgEditValidator";
|
|
3227
|
-
ValidatorActionType2["UnjailValidator"] = "/cosmos.slashing.v1beta1.MsgUnjail";
|
|
3228
|
-
ValidatorActionType2["WithdrawValidatorCommission"] = "/cosmos.distribution.v1beta1.MsgWithdrawValidatorCommission";
|
|
3229
|
-
return ValidatorActionType2;
|
|
3230
|
-
})(ValidatorActionType || {});
|
|
3231
|
-
|
|
3232
|
-
// src/mantine/context/hooks/useSharedProposal.ts
|
|
3233
|
-
import { useState as useState7, useEffect as useEffect7, useCallback as useCallback9 } from "react";
|
|
3234
|
-
var useSharedProposal = ({ proposalId, contractAddress, autoFetch = true }) => {
|
|
3235
|
-
const { sharedProposals, fetchSharedProposal, invalidateProposal, subscribeToProposal } = useBlocknoteContext();
|
|
3236
|
-
const [localProposal, setLocalProposal] = useState7(null);
|
|
3237
|
-
const cacheKey = `${contractAddress}:${proposalId}`;
|
|
3238
|
-
useEffect7(() => {
|
|
3239
|
-
if (!proposalId || !contractAddress || !autoFetch) return;
|
|
3240
|
-
fetchSharedProposal(proposalId, contractAddress).then(setLocalProposal).catch((error) => {
|
|
3241
|
-
console.error("Failed to fetch proposal:", error);
|
|
3242
|
-
});
|
|
3243
|
-
}, [proposalId, contractAddress, fetchSharedProposal, autoFetch]);
|
|
3244
|
-
useEffect7(() => {
|
|
3245
|
-
const proposal = subscribeToProposal(cacheKey);
|
|
3246
|
-
if (proposal) {
|
|
3247
|
-
setLocalProposal(proposal);
|
|
3248
|
-
}
|
|
3249
|
-
}, [subscribeToProposal, cacheKey]);
|
|
3250
|
-
const refetch = useCallback9(() => fetchSharedProposal(proposalId, contractAddress, true), [fetchSharedProposal, proposalId, contractAddress]);
|
|
3251
|
-
const invalidate = useCallback9(() => invalidateProposal(proposalId), [invalidateProposal, proposalId]);
|
|
3252
|
-
return {
|
|
3253
|
-
proposal: localProposal,
|
|
3254
|
-
loading: sharedProposals[cacheKey]?.loading ?? false,
|
|
3255
|
-
error: sharedProposals[cacheKey]?.error,
|
|
3256
|
-
refetch,
|
|
3257
|
-
invalidate
|
|
3258
|
-
};
|
|
3259
|
-
};
|
|
3260
|
-
|
|
3261
3210
|
// src/mantine/blocks/proposalVote/ProposalVoteBlockSpec.tsx
|
|
3262
3211
|
import React46 from "react";
|
|
3263
3212
|
import { createReactBlockSpec as createReactBlockSpec4 } from "@blocknote/react";
|
|
@@ -3266,121 +3215,131 @@ import { createReactBlockSpec as createReactBlockSpec4 } from "@blocknote/react"
|
|
|
3266
3215
|
import React45 from "react";
|
|
3267
3216
|
|
|
3268
3217
|
// src/mantine/blocks/proposalVote/template/TemplateView.tsx
|
|
3269
|
-
import React41, { useMemo as
|
|
3218
|
+
import React41, { useMemo as useMemo9 } from "react";
|
|
3270
3219
|
|
|
3271
3220
|
// src/mantine/blocks/proposalVote/template/TemplateConfig.tsx
|
|
3272
|
-
import React40, { useCallback as useCallback10
|
|
3221
|
+
import React40, { useCallback as useCallback10 } from "react";
|
|
3273
3222
|
import { Paper as Paper2, CloseButton as CloseButton2, Title as Title2 } from "@mantine/core";
|
|
3274
3223
|
|
|
3275
3224
|
// src/mantine/blocks/proposalVote/template/GeneralTab.tsx
|
|
3276
|
-
import React39, { useState as useState8, useEffect as useEffect8, useMemo as
|
|
3225
|
+
import React39, { useState as useState8, useEffect as useEffect8, useMemo as useMemo8 } from "react";
|
|
3277
3226
|
import { Stack as Stack25, Text as Text25, Group as Group9, Card as Card5, Button as Button9, Select as Select3 } from "@mantine/core";
|
|
3278
3227
|
|
|
3279
|
-
// src/mantine/blocks/
|
|
3280
|
-
|
|
3281
|
-
|
|
3228
|
+
// src/mantine/blocks/hooks/useBlockDependencies.ts
|
|
3229
|
+
import { useMemo as useMemo7, useEffect as useEffect7, useState as useState7, useCallback as useCallback9 } from "react";
|
|
3230
|
+
function parseDependsOn(block) {
|
|
3231
|
+
if (!block?.props?.dependsOn) {
|
|
3282
3232
|
return null;
|
|
3283
3233
|
}
|
|
3284
3234
|
try {
|
|
3285
|
-
if (typeof block.props.
|
|
3286
|
-
return block.props.
|
|
3235
|
+
if (typeof block.props.dependsOn === "object") {
|
|
3236
|
+
return block.props.dependsOn;
|
|
3287
3237
|
}
|
|
3288
|
-
if (typeof block.props.
|
|
3289
|
-
return JSON.parse(block.props.
|
|
3238
|
+
if (typeof block.props.dependsOn === "string") {
|
|
3239
|
+
return JSON.parse(block.props.dependsOn);
|
|
3290
3240
|
}
|
|
3291
3241
|
return null;
|
|
3292
3242
|
} catch (error) {
|
|
3293
|
-
console.error("[
|
|
3243
|
+
console.error("[useBlockDependencies] Failed to parse dependsOn:", error);
|
|
3294
3244
|
return null;
|
|
3295
3245
|
}
|
|
3296
3246
|
}
|
|
3297
|
-
function
|
|
3298
|
-
|
|
3299
|
-
|
|
3300
|
-
return;
|
|
3301
|
-
}
|
|
3302
|
-
const
|
|
3303
|
-
|
|
3304
|
-
editor
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3247
|
+
function useBlockDependencies(block, editor) {
|
|
3248
|
+
const editorDocument = editor?.document;
|
|
3249
|
+
const dependencies = useMemo7(() => {
|
|
3250
|
+
return parseDependsOn(block);
|
|
3251
|
+
}, [block?.props?.dependsOn]);
|
|
3252
|
+
const [sourceBlockVersion, setSourceBlockVersion] = useState7(0);
|
|
3253
|
+
useEffect7(() => {
|
|
3254
|
+
if (!editor || !dependencies) {
|
|
3255
|
+
return;
|
|
3256
|
+
}
|
|
3257
|
+
const sourceBlockIds = new Set(
|
|
3258
|
+
Object.values(dependencies).filter((dep) => dep && dep.blockId).map((dep) => dep.blockId)
|
|
3259
|
+
);
|
|
3260
|
+
if (sourceBlockIds.size === 0) {
|
|
3261
|
+
return;
|
|
3262
|
+
}
|
|
3263
|
+
const cleanup = editor.onChange(() => {
|
|
3264
|
+
setSourceBlockVersion((prev) => prev + 1);
|
|
3265
|
+
});
|
|
3266
|
+
return cleanup;
|
|
3267
|
+
}, [editor, dependencies]);
|
|
3268
|
+
const resolvedDependencies = useMemo7(() => {
|
|
3269
|
+
if (!editorDocument || !block || !dependencies) {
|
|
3270
|
+
return {};
|
|
3271
|
+
}
|
|
3272
|
+
const resolved = {};
|
|
3273
|
+
Object.entries(dependencies).forEach(([depType, config]) => {
|
|
3274
|
+
if (!config || !config.blockId || config.blockId === "") {
|
|
3275
|
+
resolved[depType] = null;
|
|
3276
|
+
return;
|
|
3277
|
+
}
|
|
3278
|
+
const targetBlock = editorDocument.find((docBlock) => docBlock.id === config.blockId && docBlock.type === depType);
|
|
3279
|
+
if (!targetBlock) {
|
|
3280
|
+
resolved[depType] = null;
|
|
3281
|
+
return;
|
|
3309
3282
|
}
|
|
3283
|
+
const extracted = { blockId: config.blockId };
|
|
3284
|
+
Object.entries(config.subscribes).forEach(([prop, shouldSubscribe]) => {
|
|
3285
|
+
if (shouldSubscribe === true && targetBlock.props && prop in targetBlock.props) {
|
|
3286
|
+
extracted[prop] = targetBlock.props[prop];
|
|
3287
|
+
}
|
|
3288
|
+
});
|
|
3289
|
+
resolved[depType] = extracted;
|
|
3310
3290
|
});
|
|
3311
|
-
|
|
3312
|
-
}
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3318
|
-
if (!currentDeps[dependencyType]) {
|
|
3319
|
-
let dependsOnConfig = null;
|
|
3320
|
-
try {
|
|
3321
|
-
if (block?.props?.dependsOn) {
|
|
3322
|
-
dependsOnConfig = typeof block.props.dependsOn === "string" ? JSON.parse(block.props.dependsOn) : block.props.dependsOn;
|
|
3291
|
+
return resolved;
|
|
3292
|
+
}, [dependencies, editorDocument, block?.id, sourceBlockVersion]);
|
|
3293
|
+
const updateDependency2 = useCallback9(
|
|
3294
|
+
(dependencyType, targetBlockId) => {
|
|
3295
|
+
if (!block || !editor) {
|
|
3296
|
+
console.error("[useBlockDependencies] Cannot update: missing block or editor");
|
|
3297
|
+
return;
|
|
3323
3298
|
}
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
|
|
3335
|
-
|
|
3336
|
-
|
|
3337
|
-
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
|
|
3351
|
-
|
|
3352
|
-
|
|
3353
|
-
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
const defaults = getDefaultDependencyConfig(block);
|
|
3357
|
-
if (defaults && !getDependencies(block)) {
|
|
3358
|
-
setDependencies(editor, block, defaults);
|
|
3359
|
-
}
|
|
3299
|
+
const currentDeps = parseDependsOn(block) || {};
|
|
3300
|
+
if (!currentDeps[dependencyType]) {
|
|
3301
|
+
console.error(`[useBlockDependencies] No dependency config for type: ${dependencyType}`);
|
|
3302
|
+
return;
|
|
3303
|
+
}
|
|
3304
|
+
const updatedDeps = {
|
|
3305
|
+
...currentDeps,
|
|
3306
|
+
[dependencyType]: {
|
|
3307
|
+
...currentDeps[dependencyType],
|
|
3308
|
+
blockId: targetBlockId || ""
|
|
3309
|
+
}
|
|
3310
|
+
};
|
|
3311
|
+
const depsString = JSON.stringify(updatedDeps);
|
|
3312
|
+
try {
|
|
3313
|
+
editor.updateBlock(block.id, {
|
|
3314
|
+
...block,
|
|
3315
|
+
props: {
|
|
3316
|
+
...block.props,
|
|
3317
|
+
dependsOn: depsString
|
|
3318
|
+
}
|
|
3319
|
+
});
|
|
3320
|
+
console.log("[useBlockDependencies] Updated dependsOn for block:", block.id, updatedDeps);
|
|
3321
|
+
} catch (error) {
|
|
3322
|
+
console.error("[useBlockDependencies] Failed to update block:", error);
|
|
3323
|
+
}
|
|
3324
|
+
},
|
|
3325
|
+
[block, editor]
|
|
3326
|
+
);
|
|
3327
|
+
return {
|
|
3328
|
+
dependencies: resolvedDependencies,
|
|
3329
|
+
updateDependency: updateDependency2
|
|
3330
|
+
};
|
|
3360
3331
|
}
|
|
3361
3332
|
|
|
3362
3333
|
// src/mantine/blocks/proposalVote/template/GeneralTab.tsx
|
|
3363
|
-
var GeneralTab2 = ({ block, editor,
|
|
3364
|
-
const [selectedDependency, setSelectedDependency] = useState8(
|
|
3365
|
-
|
|
3366
|
-
);
|
|
3367
|
-
const blockSupportsDependencies = block?.props?.hasDependencies === true;
|
|
3334
|
+
var GeneralTab2 = ({ block, editor, proposalData }) => {
|
|
3335
|
+
const [selectedDependency, setSelectedDependency] = useState8("");
|
|
3336
|
+
const { dependencies: resolvedDeps, updateDependency: updateDependency2 } = useBlockDependencies(block, editor);
|
|
3368
3337
|
useEffect8(() => {
|
|
3369
3338
|
if (!block) return;
|
|
3370
|
-
|
|
3371
|
-
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
const deps = getDependencies(block);
|
|
3375
|
-
const proposalDep = deps?.proposal;
|
|
3376
|
-
setSelectedDependency(proposalDep?.blockId || block.props?.proposalBlockId || "");
|
|
3377
|
-
}, [
|
|
3378
|
-
block?.id,
|
|
3379
|
-
blockSupportsDependencies,
|
|
3380
|
-
block?.props?.proposalBlockId,
|
|
3381
|
-
block?.props?.dependencies
|
|
3382
|
-
]);
|
|
3383
|
-
const availableBlocks = useMemo7(() => {
|
|
3339
|
+
const proposalDep = resolvedDeps?.proposal;
|
|
3340
|
+
setSelectedDependency(proposalDep?.blockId || "");
|
|
3341
|
+
}, [block?.id, resolvedDeps]);
|
|
3342
|
+
const availableBlocks = useMemo8(() => {
|
|
3384
3343
|
if (!editor?.document) return [];
|
|
3385
3344
|
const proposalBlocks = editor.document.filter((editorBlock) => editorBlock.type === "proposal").map((editorBlock) => ({
|
|
3386
3345
|
id: editorBlock.id,
|
|
@@ -3391,25 +3350,16 @@ var GeneralTab2 = ({ block, editor, proposal }) => {
|
|
|
3391
3350
|
return proposalBlocks;
|
|
3392
3351
|
}, [editor?.document]);
|
|
3393
3352
|
const hasDependency = Boolean(selectedDependency);
|
|
3394
|
-
const showDependencyDropdown =
|
|
3353
|
+
const showDependencyDropdown = !hasDependency;
|
|
3395
3354
|
const handleUpdateDependency = (blockId) => {
|
|
3396
|
-
if (!block
|
|
3355
|
+
if (!block) {
|
|
3397
3356
|
return;
|
|
3398
3357
|
}
|
|
3399
3358
|
const nextValue = blockId || "";
|
|
3400
|
-
|
|
3401
|
-
updateDependency(editor, block, "proposal", blockId, "proposalVote");
|
|
3359
|
+
updateDependency2("proposal", blockId);
|
|
3402
3360
|
setSelectedDependency(nextValue);
|
|
3403
|
-
if (editor && typeof editor.updateBlock === "function" && currentValue !== nextValue) {
|
|
3404
|
-
editor.updateBlock(block, {
|
|
3405
|
-
props: {
|
|
3406
|
-
...block.props,
|
|
3407
|
-
proposalBlockId: nextValue
|
|
3408
|
-
}
|
|
3409
|
-
});
|
|
3410
|
-
}
|
|
3411
3361
|
};
|
|
3412
|
-
return /* @__PURE__ */ React39.createElement(Stack25, { gap: "lg" },
|
|
3362
|
+
return /* @__PURE__ */ React39.createElement(Stack25, { gap: "lg" }, showDependencyDropdown && /* @__PURE__ */ React39.createElement(Stack25, { gap: "md" }, /* @__PURE__ */ React39.createElement(
|
|
3413
3363
|
Card5,
|
|
3414
3364
|
{
|
|
3415
3365
|
padding: "md",
|
|
@@ -3457,31 +3407,12 @@ var GeneralTab2 = ({ block, editor, proposal }) => {
|
|
|
3457
3407
|
}
|
|
3458
3408
|
}
|
|
3459
3409
|
}
|
|
3460
|
-
), availableBlocks.length === 0 && /* @__PURE__ */ React39.createElement(Text25, { size: "xs", style: { color: "#868e96" } }, "No proposals available. Create a proposal first.")),
|
|
3461
|
-
Button9,
|
|
3462
|
-
{
|
|
3463
|
-
variant: "subtle",
|
|
3464
|
-
size: "xs",
|
|
3465
|
-
color: "red",
|
|
3466
|
-
onClick: () => handleUpdateDependency(null)
|
|
3467
|
-
},
|
|
3468
|
-
"Disconnect"
|
|
3469
|
-
)), /* @__PURE__ */ React39.createElement(
|
|
3470
|
-
Card5,
|
|
3471
|
-
{
|
|
3472
|
-
padding: "sm",
|
|
3473
|
-
radius: "md",
|
|
3474
|
-
style: { backgroundColor: "#2a2a2a", border: "1px solid #333" }
|
|
3475
|
-
},
|
|
3476
|
-
/* @__PURE__ */ React39.createElement(Text25, { size: "sm", fw: 500, style: { color: "#f1f3f5" } }, proposal?.proposal?.title || "Connected Proposal"),
|
|
3477
|
-
proposal?.proposal?.description && /* @__PURE__ */ React39.createElement(Text25, { size: "xs", style: { color: "#adb5bd" } }, proposal.proposal.description)
|
|
3478
|
-
)));
|
|
3410
|
+
), availableBlocks.length === 0 && /* @__PURE__ */ React39.createElement(Text25, { size: "xs", style: { color: "#868e96" } }, "No proposals available. Create a proposal first.")), hasDependency && /* @__PURE__ */ React39.createElement(Stack25, { gap: "md" }, /* @__PURE__ */ React39.createElement(Group9, { justify: "space-between", align: "center" }, /* @__PURE__ */ React39.createElement(Text25, { size: "sm", fw: 500, style: { color: "#adb5bd" } }, "Connected Proposal"), /* @__PURE__ */ React39.createElement(Button9, { variant: "subtle", size: "xs", color: "red", onClick: () => handleUpdateDependency(null) }, "Disconnect")), /* @__PURE__ */ React39.createElement(Card5, { padding: "sm", radius: "md", style: { backgroundColor: "#2a2a2a", border: "1px solid #333" } }, /* @__PURE__ */ React39.createElement(Text25, { size: "sm", fw: 500, style: { color: "#f1f3f5" } }, proposalData?.title || "Connected Proposal"), proposalData?.description && /* @__PURE__ */ React39.createElement(Text25, { size: "xs", style: { color: "#adb5bd" } }, proposalData.description), proposalData?.proposalId && /* @__PURE__ */ React39.createElement(Text25, { size: "xs", style: { color: "#51cf66", marginTop: 4 } }, "Proposal ID: #", proposalData.proposalId), proposalData?.status && /* @__PURE__ */ React39.createElement(Text25, { size: "xs", style: { color: "#adb5bd", marginTop: 4 } }, "Status: ", proposalData.status))));
|
|
3479
3411
|
};
|
|
3480
3412
|
|
|
3481
3413
|
// src/mantine/blocks/proposalVote/template/TemplateConfig.tsx
|
|
3482
3414
|
var TemplateConfig2 = ({ editor, block }) => {
|
|
3483
3415
|
const { closePanel } = usePanelStore();
|
|
3484
|
-
const [proposalContractAddress, setProposalContractAddress] = useState9(null);
|
|
3485
3416
|
const updateProp = useCallback10(
|
|
3486
3417
|
(key, value) => {
|
|
3487
3418
|
editor.updateBlock(block, {
|
|
@@ -3499,15 +3430,8 @@ var TemplateConfig2 = ({ editor, block }) => {
|
|
|
3499
3430
|
},
|
|
3500
3431
|
[updateProp]
|
|
3501
3432
|
);
|
|
3502
|
-
const
|
|
3503
|
-
const
|
|
3504
|
-
const proposalId = proposalBlock?.props?.proposalId || "";
|
|
3505
|
-
const { proposal } = useSharedProposal({
|
|
3506
|
-
proposalId,
|
|
3507
|
-
contractAddress: proposalContractAddress || "",
|
|
3508
|
-
autoFetch: false
|
|
3509
|
-
// Don't auto-fetch in template mode
|
|
3510
|
-
});
|
|
3433
|
+
const { dependencies } = useBlockDependencies(block, editor);
|
|
3434
|
+
const proposalData = dependencies?.proposal || null;
|
|
3511
3435
|
return /* @__PURE__ */ React40.createElement(
|
|
3512
3436
|
Paper2,
|
|
3513
3437
|
{
|
|
@@ -3539,15 +3463,7 @@ var TemplateConfig2 = ({ editor, block }) => {
|
|
|
3539
3463
|
{
|
|
3540
3464
|
label: "General",
|
|
3541
3465
|
value: "general",
|
|
3542
|
-
content: /* @__PURE__ */ React40.createElement(
|
|
3543
|
-
GeneralTab2,
|
|
3544
|
-
{
|
|
3545
|
-
block,
|
|
3546
|
-
editor,
|
|
3547
|
-
proposal,
|
|
3548
|
-
proposalContractAddress
|
|
3549
|
-
}
|
|
3550
|
-
)
|
|
3466
|
+
content: /* @__PURE__ */ React40.createElement(GeneralTab2, { block, editor, proposalData })
|
|
3551
3467
|
}
|
|
3552
3468
|
],
|
|
3553
3469
|
context: { editor, block },
|
|
@@ -3578,7 +3494,7 @@ var getStatusColor = (status) => {
|
|
|
3578
3494
|
};
|
|
3579
3495
|
var ProposalVoteTemplateView = ({ editor, block }) => {
|
|
3580
3496
|
const panelId = `${PROPOSAL_VOTE_TEMPLATE_PANEL_ID}-${block.id}`;
|
|
3581
|
-
const panelContent =
|
|
3497
|
+
const panelContent = useMemo9(
|
|
3582
3498
|
() => /* @__PURE__ */ React41.createElement(TemplateConfig2, { editor, block }),
|
|
3583
3499
|
[editor, block]
|
|
3584
3500
|
);
|
|
@@ -3597,52 +3513,15 @@ var ProposalVoteTemplateView = ({ editor, block }) => {
|
|
|
3597
3513
|
};
|
|
3598
3514
|
|
|
3599
3515
|
// src/mantine/blocks/proposalVote/flow/FlowView.tsx
|
|
3600
|
-
import React44, { useMemo as
|
|
3516
|
+
import React44, { useMemo as useMemo11 } from "react";
|
|
3601
3517
|
|
|
3602
3518
|
// src/mantine/blocks/proposalVote/flow/FlowConfig.tsx
|
|
3603
3519
|
import React43 from "react";
|
|
3604
3520
|
import { Paper as Paper3, CloseButton as CloseButton3, Title as Title3 } from "@mantine/core";
|
|
3605
3521
|
|
|
3606
3522
|
// src/mantine/blocks/proposalVote/flow/GeneralTab.tsx
|
|
3607
|
-
import React42, { useState as
|
|
3523
|
+
import React42, { useState as useState9 } from "react";
|
|
3608
3524
|
import { Stack as Stack27, Text as Text27, Group as Group11, Card as Card7, Button as Button10, Progress as Progress2, Box as Box15, Textarea as Textarea2, Tooltip as Tooltip3 } from "@mantine/core";
|
|
3609
|
-
var calculateTimeRemaining = (proposal) => {
|
|
3610
|
-
if (!proposal?.proposal.expiration || "never" in proposal.proposal.expiration) {
|
|
3611
|
-
return "Never expires";
|
|
3612
|
-
}
|
|
3613
|
-
if ("at_height" in proposal.proposal.expiration) {
|
|
3614
|
-
return `Expires at block ${proposal.proposal.expiration.at_height}`;
|
|
3615
|
-
}
|
|
3616
|
-
if ("at_time" in proposal.proposal.expiration) {
|
|
3617
|
-
const timestamp = proposal.proposal.expiration.at_time;
|
|
3618
|
-
let expirationTime;
|
|
3619
|
-
if (timestamp.length > 13) {
|
|
3620
|
-
expirationTime = parseInt(timestamp) / 1e6;
|
|
3621
|
-
} else {
|
|
3622
|
-
expirationTime = parseInt(timestamp);
|
|
3623
|
-
if (timestamp.length === 10) {
|
|
3624
|
-
expirationTime *= 1e3;
|
|
3625
|
-
}
|
|
3626
|
-
}
|
|
3627
|
-
const now = Date.now();
|
|
3628
|
-
const diffMs = expirationTime - now;
|
|
3629
|
-
const days = Math.floor(diffMs / (1e3 * 60 * 60 * 24));
|
|
3630
|
-
const hours = Math.floor(diffMs % (1e3 * 60 * 60 * 24) / (1e3 * 60 * 60));
|
|
3631
|
-
const minutes = Math.floor(diffMs % (1e3 * 60 * 60) / (1e3 * 60));
|
|
3632
|
-
if (diffMs <= 0) return "Expired";
|
|
3633
|
-
if (days > 0) return `${days} days ${hours}h ${minutes}m`;
|
|
3634
|
-
return `${hours}h ${minutes}m`;
|
|
3635
|
-
}
|
|
3636
|
-
return "Unknown";
|
|
3637
|
-
};
|
|
3638
|
-
var calculateOutcome = (proposal) => {
|
|
3639
|
-
if (!proposal?.proposal.votes) return "0%";
|
|
3640
|
-
const { yes, no, abstain } = proposal.proposal.votes;
|
|
3641
|
-
const totalVotes = parseInt(yes) + parseInt(no) + parseInt(abstain);
|
|
3642
|
-
if (totalVotes === 0) return "0%";
|
|
3643
|
-
const yesPercentage = parseInt(yes) / totalVotes * 100;
|
|
3644
|
-
return `${yesPercentage.toFixed(1)}% approve`;
|
|
3645
|
-
};
|
|
3646
3525
|
var getVoteIcon = (voteType) => {
|
|
3647
3526
|
switch (voteType) {
|
|
3648
3527
|
case "yes":
|
|
@@ -3657,7 +3536,10 @@ var getVoteIcon = (voteType) => {
|
|
|
3657
3536
|
}
|
|
3658
3537
|
};
|
|
3659
3538
|
var FlowGeneralTab = ({
|
|
3660
|
-
|
|
3539
|
+
proposalId,
|
|
3540
|
+
proposalTitle,
|
|
3541
|
+
proposalDescription,
|
|
3542
|
+
proposalStatus,
|
|
3661
3543
|
userVote,
|
|
3662
3544
|
proposalContractAddress,
|
|
3663
3545
|
onVote,
|
|
@@ -3665,13 +3547,14 @@ var FlowGeneralTab = ({
|
|
|
3665
3547
|
isDisabled
|
|
3666
3548
|
}) => {
|
|
3667
3549
|
const disabled = isDisabled?.isDisabled === "disable";
|
|
3668
|
-
const [selectedVote, setSelectedVote] =
|
|
3669
|
-
const [rationale, setRationale] =
|
|
3670
|
-
const hasSubmittedProposal = Boolean(
|
|
3550
|
+
const [selectedVote, setSelectedVote] = useState9("");
|
|
3551
|
+
const [rationale, setRationale] = useState9("");
|
|
3552
|
+
const hasSubmittedProposal = Boolean(proposalId);
|
|
3553
|
+
const hasVoted = Boolean(userVote?.vote);
|
|
3671
3554
|
const handleSlideToSign = () => {
|
|
3672
|
-
if (selectedVote &&
|
|
3555
|
+
if (selectedVote && proposalId && proposalContractAddress) {
|
|
3673
3556
|
onVote?.({
|
|
3674
|
-
proposalId:
|
|
3557
|
+
proposalId: parseInt(proposalId),
|
|
3675
3558
|
rationale: rationale.trim() || void 0,
|
|
3676
3559
|
vote: selectedVote,
|
|
3677
3560
|
proposalContractAddress
|
|
@@ -3680,7 +3563,6 @@ var FlowGeneralTab = ({
|
|
|
3680
3563
|
setRationale("");
|
|
3681
3564
|
}
|
|
3682
3565
|
};
|
|
3683
|
-
const hasDependency = Boolean(proposal);
|
|
3684
3566
|
return /* @__PURE__ */ React42.createElement(Stack27, { gap: "lg" }, !hasSubmittedProposal && /* @__PURE__ */ React42.createElement(
|
|
3685
3567
|
Card7,
|
|
3686
3568
|
{
|
|
@@ -3726,17 +3608,17 @@ var FlowGeneralTab = ({
|
|
|
3726
3608
|
borderRadius: "50%"
|
|
3727
3609
|
}
|
|
3728
3610
|
}
|
|
3729
|
-
), /* @__PURE__ */ React42.createElement(Text27, { size: "sm", style: { color: "#adb5bd" } }, "Status")), /* @__PURE__ */ React42.createElement(Text27, { size: "sm", fw: 500, style: { color: "#f1f3f5" } }, hasSubmittedProposal ?
|
|
3611
|
+
), /* @__PURE__ */ React42.createElement(Text27, { size: "sm", style: { color: "#adb5bd" } }, "Status")), /* @__PURE__ */ React42.createElement(Text27, { size: "sm", fw: 500, style: { color: "#f1f3f5" } }, hasSubmittedProposal ? proposalStatus === "open" ? "Active" : proposalStatus || "Active" : "Waiting")), /* @__PURE__ */ React42.createElement(Group11, { justify: "space-between" }, /* @__PURE__ */ React42.createElement(Group11, { gap: "xs" }, /* @__PURE__ */ React42.createElement(Box15, { w: 8, h: 8, style: { backgroundColor: "#adb5bd", borderRadius: "50%" } }), /* @__PURE__ */ React42.createElement(Text27, { size: "sm", style: { color: "#adb5bd" } }, "Proposal ID")), /* @__PURE__ */ React42.createElement(Text27, { size: "sm", fw: 500, style: { color: "#f1f3f5" } }, hasSubmittedProposal ? `#${proposalId}` : "TBD")), /* @__PURE__ */ React42.createElement(Group11, { justify: "space-between" }, /* @__PURE__ */ React42.createElement(Group11, { gap: "xs" }, /* @__PURE__ */ React42.createElement(Box15, { w: 8, h: 8, style: { backgroundColor: "#adb5bd", borderRadius: "50%" } }), /* @__PURE__ */ React42.createElement(Text27, { size: "sm", style: { color: "#adb5bd" } }, "Title")), /* @__PURE__ */ React42.createElement(
|
|
3730
3612
|
Text27,
|
|
3731
3613
|
{
|
|
3732
3614
|
size: "sm",
|
|
3733
3615
|
fw: 500,
|
|
3734
3616
|
style: {
|
|
3735
|
-
color: hasSubmittedProposal ? "#
|
|
3617
|
+
color: hasSubmittedProposal ? "#f1f3f5" : "#868e96"
|
|
3736
3618
|
}
|
|
3737
3619
|
},
|
|
3738
|
-
hasSubmittedProposal ?
|
|
3739
|
-
)), /* @__PURE__ */ React42.createElement(Group11, { justify: "space-between" }, /* @__PURE__ */ React42.createElement(Group11, { gap: "xs" }, /* @__PURE__ */ React42.createElement(Box15, { w: 8, h: 8, style: { backgroundColor: "#adb5bd", borderRadius: "50%" } }), /* @__PURE__ */ React42.createElement(Text27, { size: "sm", style: { color: "#adb5bd" } }, "My Vote")), /* @__PURE__ */ React42.createElement(Text27, { size: "sm", fw: 500, style: { color: "#f1f3f5" } }, hasSubmittedProposal ? userVote?.vote ? userVote.vote.vote : "Pending" : "N/A"))),
|
|
3620
|
+
hasSubmittedProposal ? proposalTitle || "Untitled" : "N/A"
|
|
3621
|
+
)), /* @__PURE__ */ React42.createElement(Group11, { justify: "space-between" }, /* @__PURE__ */ React42.createElement(Group11, { gap: "xs" }, /* @__PURE__ */ React42.createElement(Box15, { w: 8, h: 8, style: { backgroundColor: "#adb5bd", borderRadius: "50%" } }), /* @__PURE__ */ React42.createElement(Text27, { size: "sm", style: { color: "#adb5bd" } }, "Description")), /* @__PURE__ */ React42.createElement(Text27, { size: "sm", fw: 500, style: { color: "#f1f3f5" }, title: proposalDescription }, hasSubmittedProposal ? proposalDescription ? proposalDescription.length > 30 ? proposalDescription.substring(0, 30) + "..." : proposalDescription : "No description" : "N/A")), /* @__PURE__ */ React42.createElement(Group11, { justify: "space-between" }, /* @__PURE__ */ React42.createElement(Group11, { gap: "xs" }, /* @__PURE__ */ React42.createElement(Box15, { w: 8, h: 8, style: { backgroundColor: "#adb5bd", borderRadius: "50%" } }), /* @__PURE__ */ React42.createElement(Text27, { size: "sm", style: { color: "#adb5bd" } }, "My Vote")), /* @__PURE__ */ React42.createElement(Text27, { size: "sm", fw: 500, style: { color: "#f1f3f5" } }, hasSubmittedProposal ? userVote?.vote ? userVote.vote.vote : "Pending" : "N/A"))),
|
|
3740
3622
|
/* @__PURE__ */ React42.createElement(Stack27, { gap: "xs" }, /* @__PURE__ */ React42.createElement(Text27, { size: "sm", style: { color: "#adb5bd" } }, hasSubmittedProposal ? "Voting is open" : "Voting pending"), /* @__PURE__ */ React42.createElement(
|
|
3741
3623
|
Progress2,
|
|
3742
3624
|
{
|
|
@@ -3750,7 +3632,7 @@ var FlowGeneralTab = ({
|
|
|
3750
3632
|
}
|
|
3751
3633
|
}
|
|
3752
3634
|
))
|
|
3753
|
-
),
|
|
3635
|
+
), hasSubmittedProposal && !hasVoted && (status === "open" || proposalStatus === "open") && /* @__PURE__ */ React42.createElement(Stack27, { gap: "lg" }, disabled && isDisabled?.message && /* @__PURE__ */ React42.createElement(
|
|
3754
3636
|
Card7,
|
|
3755
3637
|
{
|
|
3756
3638
|
padding: "md",
|
|
@@ -3772,36 +3654,27 @@ var FlowGeneralTab = ({
|
|
|
3772
3654
|
}
|
|
3773
3655
|
}
|
|
3774
3656
|
), /* @__PURE__ */ React42.createElement(Text27, { size: "sm", fw: 500, style: { color: "#ffd43b" } }, isDisabled.message))
|
|
3775
|
-
), /* @__PURE__ */ React42.createElement(Stack27, { gap: "md" }, ["yes", "no", "no_with_veto", "abstain"].map((voteType) => /* @__PURE__ */ React42.createElement(
|
|
3776
|
-
|
|
3657
|
+
), /* @__PURE__ */ React42.createElement(Stack27, { gap: "md" }, ["yes", "no", "no_with_veto", "abstain"].map((voteType) => /* @__PURE__ */ React42.createElement(Tooltip3, { key: voteType, label: disabled ? isDisabled?.message : void 0, disabled: !disabled, position: "top" }, /* @__PURE__ */ React42.createElement(
|
|
3658
|
+
Button10,
|
|
3777
3659
|
{
|
|
3778
|
-
|
|
3779
|
-
|
|
3780
|
-
|
|
3781
|
-
|
|
3660
|
+
variant: "outline",
|
|
3661
|
+
leftSection: getVoteIcon(voteType),
|
|
3662
|
+
onClick: () => !disabled && setSelectedVote(voteType),
|
|
3663
|
+
disabled,
|
|
3664
|
+
size: "md",
|
|
3665
|
+
style: {
|
|
3666
|
+
backgroundColor: selectedVote === voteType ? "#333" : "#2a2a2a",
|
|
3667
|
+
borderColor: selectedVote === voteType ? "#51cf66" : "#444",
|
|
3668
|
+
borderWidth: selectedVote === voteType ? "2px" : "1px",
|
|
3669
|
+
color: disabled ? "#666" : "#f1f3f5",
|
|
3670
|
+
justifyContent: "flex-start",
|
|
3671
|
+
padding: "12px",
|
|
3672
|
+
textAlign: "left",
|
|
3673
|
+
opacity: disabled ? 0.5 : 1
|
|
3674
|
+
}
|
|
3782
3675
|
},
|
|
3783
|
-
/* @__PURE__ */ React42.createElement(
|
|
3784
|
-
|
|
3785
|
-
{
|
|
3786
|
-
variant: "outline",
|
|
3787
|
-
leftSection: getVoteIcon(voteType),
|
|
3788
|
-
onClick: () => !disabled && setSelectedVote(voteType),
|
|
3789
|
-
disabled,
|
|
3790
|
-
size: "md",
|
|
3791
|
-
style: {
|
|
3792
|
-
backgroundColor: selectedVote === voteType ? "#333" : "#2a2a2a",
|
|
3793
|
-
borderColor: selectedVote === voteType ? "#51cf66" : "#444",
|
|
3794
|
-
borderWidth: selectedVote === voteType ? "2px" : "1px",
|
|
3795
|
-
color: disabled ? "#666" : "#f1f3f5",
|
|
3796
|
-
justifyContent: "flex-start",
|
|
3797
|
-
padding: "12px",
|
|
3798
|
-
textAlign: "left",
|
|
3799
|
-
opacity: disabled ? 0.5 : 1
|
|
3800
|
-
}
|
|
3801
|
-
},
|
|
3802
|
-
/* @__PURE__ */ React42.createElement(Text27, { fw: 500, tt: "capitalize", style: { textAlign: "left" } }, voteType === "no_with_veto" ? "No with Veto" : voteType)
|
|
3803
|
-
)
|
|
3804
|
-
))), /* @__PURE__ */ React42.createElement(Stack27, { gap: "xs" }, /* @__PURE__ */ React42.createElement(Text27, { size: "sm", style: { color: "#adb5bd" } }, "Rationale (optional)"), /* @__PURE__ */ React42.createElement(
|
|
3676
|
+
/* @__PURE__ */ React42.createElement(Text27, { fw: 500, tt: "capitalize", style: { textAlign: "left" } }, voteType === "no_with_veto" ? "No with Veto" : voteType)
|
|
3677
|
+
)))), /* @__PURE__ */ React42.createElement(Stack27, { gap: "xs" }, /* @__PURE__ */ React42.createElement(Text27, { size: "sm", style: { color: "#adb5bd" } }, "Rationale (optional)"), /* @__PURE__ */ React42.createElement(
|
|
3805
3678
|
Textarea2,
|
|
3806
3679
|
{
|
|
3807
3680
|
value: rationale,
|
|
@@ -3818,7 +3691,7 @@ var FlowGeneralTab = ({
|
|
|
3818
3691
|
}
|
|
3819
3692
|
}
|
|
3820
3693
|
}
|
|
3821
|
-
))), (status === "executed" ||
|
|
3694
|
+
))), (status === "executed" || proposalStatus === "executed") && /* @__PURE__ */ React42.createElement(
|
|
3822
3695
|
Card7,
|
|
3823
3696
|
{
|
|
3824
3697
|
padding: "md",
|
|
@@ -3829,33 +3702,25 @@ var FlowGeneralTab = ({
|
|
|
3829
3702
|
}
|
|
3830
3703
|
},
|
|
3831
3704
|
/* @__PURE__ */ React42.createElement(Stack27, { gap: "xs" }, /* @__PURE__ */ React42.createElement(Text27, { fw: 500, size: "sm", style: { color: "#f1f3f5" } }, "Proposal Executed"), /* @__PURE__ */ React42.createElement(Text27, { size: "sm", style: { color: "#adb5bd" } }, "This proposal has been successfully executed."))
|
|
3832
|
-
),
|
|
3833
|
-
|
|
3705
|
+
), !hasSubmittedProposal && /* @__PURE__ */ React42.createElement(Stack27, { gap: "lg" }, /* @__PURE__ */ React42.createElement(Stack27, { gap: "md" }, ["yes", "no", "no_with_veto", "abstain"].map((voteType) => /* @__PURE__ */ React42.createElement(Tooltip3, { key: voteType, label: "Proposal must be submitted before voting", position: "top" }, /* @__PURE__ */ React42.createElement(
|
|
3706
|
+
Button10,
|
|
3834
3707
|
{
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
3708
|
+
variant: "outline",
|
|
3709
|
+
leftSection: getVoteIcon(voteType),
|
|
3710
|
+
size: "md",
|
|
3711
|
+
disabled: true,
|
|
3712
|
+
style: {
|
|
3713
|
+
backgroundColor: "#1a1a1a",
|
|
3714
|
+
borderColor: "#333",
|
|
3715
|
+
color: "#666",
|
|
3716
|
+
justifyContent: "flex-start",
|
|
3717
|
+
padding: "12px",
|
|
3718
|
+
textAlign: "left",
|
|
3719
|
+
opacity: 0.5
|
|
3720
|
+
}
|
|
3838
3721
|
},
|
|
3839
|
-
/* @__PURE__ */ React42.createElement(
|
|
3840
|
-
|
|
3841
|
-
{
|
|
3842
|
-
variant: "outline",
|
|
3843
|
-
leftSection: getVoteIcon(voteType),
|
|
3844
|
-
size: "md",
|
|
3845
|
-
disabled: true,
|
|
3846
|
-
style: {
|
|
3847
|
-
backgroundColor: "#1a1a1a",
|
|
3848
|
-
borderColor: "#333",
|
|
3849
|
-
color: "#666",
|
|
3850
|
-
justifyContent: "flex-start",
|
|
3851
|
-
padding: "12px",
|
|
3852
|
-
textAlign: "left",
|
|
3853
|
-
opacity: 0.5
|
|
3854
|
-
}
|
|
3855
|
-
},
|
|
3856
|
-
/* @__PURE__ */ React42.createElement(Text27, { fw: 500, tt: "capitalize", style: { textAlign: "left" } }, voteType === "no_with_veto" ? "No with Veto" : voteType)
|
|
3857
|
-
)
|
|
3858
|
-
)))), hasDependency && hasSubmittedProposal && selectedVote && (status === "open" || proposal?.proposal.status === "open") && /* @__PURE__ */ React42.createElement(Tooltip3, { label: disabled ? isDisabled?.message : "Sign to vote", position: "top" }, /* @__PURE__ */ React42.createElement("div", null, /* @__PURE__ */ React42.createElement(
|
|
3722
|
+
/* @__PURE__ */ React42.createElement(Text27, { fw: 500, tt: "capitalize", style: { textAlign: "left" } }, voteType === "no_with_veto" ? "No with Veto" : voteType)
|
|
3723
|
+
))))), hasSubmittedProposal && !hasVoted && selectedVote && (status === "open" || proposalStatus === "open") && /* @__PURE__ */ React42.createElement(Tooltip3, { label: disabled ? isDisabled?.message : "Sign to vote", position: "top" }, /* @__PURE__ */ React42.createElement("div", null, /* @__PURE__ */ React42.createElement(
|
|
3859
3724
|
Button10,
|
|
3860
3725
|
{
|
|
3861
3726
|
size: "sm",
|
|
@@ -3871,12 +3736,38 @@ var FlowGeneralTab = ({
|
|
|
3871
3736
|
}
|
|
3872
3737
|
},
|
|
3873
3738
|
"Sign"
|
|
3874
|
-
)))
|
|
3739
|
+
))), hasVoted && hasSubmittedProposal && /* @__PURE__ */ React42.createElement(
|
|
3740
|
+
Card7,
|
|
3741
|
+
{
|
|
3742
|
+
padding: "md",
|
|
3743
|
+
radius: "md",
|
|
3744
|
+
style: {
|
|
3745
|
+
backgroundColor: "#2a2a2a",
|
|
3746
|
+
border: "1px solid #51cf66",
|
|
3747
|
+
color: "#f1f3f5"
|
|
3748
|
+
}
|
|
3749
|
+
},
|
|
3750
|
+
/* @__PURE__ */ React42.createElement(Stack27, { gap: "xs" }, /* @__PURE__ */ React42.createElement(Group11, { gap: "xs", align: "center" }, /* @__PURE__ */ React42.createElement(
|
|
3751
|
+
Box15,
|
|
3752
|
+
{
|
|
3753
|
+
style: {
|
|
3754
|
+
width: 8,
|
|
3755
|
+
height: 8,
|
|
3756
|
+
backgroundColor: "#51cf66",
|
|
3757
|
+
borderRadius: "50%"
|
|
3758
|
+
}
|
|
3759
|
+
}
|
|
3760
|
+
), /* @__PURE__ */ React42.createElement(Text27, { size: "sm", fw: 500, style: { color: "#51cf66" } }, "Vote Submitted")), /* @__PURE__ */ React42.createElement(Text27, { size: "xs", style: { color: "#adb5bd" } }, "You have already voted on this proposal. Your vote:", " ", /* @__PURE__ */ React42.createElement(Text27, { span: true, fw: 500, tt: "capitalize" }, userVote?.vote?.vote)))
|
|
3761
|
+
));
|
|
3875
3762
|
};
|
|
3876
3763
|
|
|
3877
3764
|
// src/mantine/blocks/proposalVote/flow/FlowConfig.tsx
|
|
3878
3765
|
var FlowConfig = ({
|
|
3879
|
-
|
|
3766
|
+
proposalData,
|
|
3767
|
+
proposalId,
|
|
3768
|
+
proposalTitle,
|
|
3769
|
+
proposalDescription,
|
|
3770
|
+
proposalStatus,
|
|
3880
3771
|
userVote,
|
|
3881
3772
|
proposalContractAddress,
|
|
3882
3773
|
onVote,
|
|
@@ -3920,7 +3811,11 @@ var FlowConfig = ({
|
|
|
3920
3811
|
content: /* @__PURE__ */ React43.createElement(
|
|
3921
3812
|
FlowGeneralTab,
|
|
3922
3813
|
{
|
|
3923
|
-
|
|
3814
|
+
proposalData,
|
|
3815
|
+
proposalId,
|
|
3816
|
+
proposalTitle,
|
|
3817
|
+
proposalDescription,
|
|
3818
|
+
proposalStatus,
|
|
3924
3819
|
userVote,
|
|
3925
3820
|
proposalContractAddress,
|
|
3926
3821
|
onVote,
|
|
@@ -3938,114 +3833,17 @@ var FlowConfig = ({
|
|
|
3938
3833
|
};
|
|
3939
3834
|
|
|
3940
3835
|
// src/mantine/blocks/proposalVote/flow/FlowView.tsx
|
|
3941
|
-
import { Card as Card8, Group as Group12, Stack as Stack28, Text as Text28, ActionIcon as ActionIcon5, Alert as Alert5,
|
|
3942
|
-
|
|
3943
|
-
// src/mantine/blocks/proposalVote/flow/useFlowBusinessLogic.ts
|
|
3944
|
-
import { useEffect as useEffect9, useState as useState11, useMemo as useMemo11 } from "react";
|
|
3945
|
-
|
|
3946
|
-
// src/mantine/blocks/hooks/useBlockDependencies.ts
|
|
3947
|
-
import { useMemo as useMemo10 } from "react";
|
|
3948
|
-
|
|
3949
|
-
// src/mantine/blocks/hooks/useDependsOn.ts
|
|
3950
|
-
import { useMemo as useMemo9 } from "react";
|
|
3951
|
-
function useDependsOn(block, editor) {
|
|
3952
|
-
const editorDocument = editor?.document;
|
|
3953
|
-
const dependsOnConfig = useMemo9(() => {
|
|
3954
|
-
if (!block?.props?.dependsOn) {
|
|
3955
|
-
return null;
|
|
3956
|
-
}
|
|
3957
|
-
try {
|
|
3958
|
-
const config = typeof block.props.dependsOn === "string" ? JSON.parse(block.props.dependsOn) : block.props.dependsOn;
|
|
3959
|
-
console.log("[useDependsOn] Parsed dependsOn config:", config);
|
|
3960
|
-
return config;
|
|
3961
|
-
} catch (error) {
|
|
3962
|
-
console.error("[useDependsOn] Failed to parse dependsOn prop:", error);
|
|
3963
|
-
return null;
|
|
3964
|
-
}
|
|
3965
|
-
}, [block?.props?.dependsOn]);
|
|
3966
|
-
const dependencies = useMemo9(() => {
|
|
3967
|
-
return getDependencies(block);
|
|
3968
|
-
}, [block?.props?.dependencies]);
|
|
3969
|
-
const resolvedDependencies = useMemo9(() => {
|
|
3970
|
-
if (!block || !editorDocument) {
|
|
3971
|
-
return {};
|
|
3972
|
-
}
|
|
3973
|
-
const deps = dependencies;
|
|
3974
|
-
if (!deps) {
|
|
3975
|
-
return {};
|
|
3976
|
-
}
|
|
3977
|
-
const resolved = {};
|
|
3978
|
-
Object.entries(deps).forEach(([depType, config]) => {
|
|
3979
|
-
if (!config || !config.blockId || config.blockId === "") {
|
|
3980
|
-
resolved[depType] = null;
|
|
3981
|
-
return;
|
|
3982
|
-
}
|
|
3983
|
-
const targetBlock = editorDocument.find(
|
|
3984
|
-
(docBlock) => docBlock.id === config.blockId && docBlock.type === depType
|
|
3985
|
-
);
|
|
3986
|
-
if (!targetBlock) {
|
|
3987
|
-
resolved[depType] = null;
|
|
3988
|
-
return;
|
|
3989
|
-
}
|
|
3990
|
-
const extracted = {};
|
|
3991
|
-
Object.entries(config.subscribes).forEach(([prop, shouldSubscribe]) => {
|
|
3992
|
-
if (shouldSubscribe === true && targetBlock.props && prop in targetBlock.props) {
|
|
3993
|
-
extracted[prop] = targetBlock.props[prop];
|
|
3994
|
-
}
|
|
3995
|
-
});
|
|
3996
|
-
resolved[depType] = extracted;
|
|
3997
|
-
});
|
|
3998
|
-
console.log("[useDependsOn] Resolved dependencies:", resolved);
|
|
3999
|
-
return resolved;
|
|
4000
|
-
}, [
|
|
4001
|
-
dependencies,
|
|
4002
|
-
// Re-run when dependencies change
|
|
4003
|
-
editorDocument,
|
|
4004
|
-
// Re-run when document changes (more stable than editor?.document)
|
|
4005
|
-
block?.id
|
|
4006
|
-
]);
|
|
4007
|
-
return {
|
|
4008
|
-
dependsOnConfig,
|
|
4009
|
-
dependencies,
|
|
4010
|
-
resolvedDependencies
|
|
4011
|
-
};
|
|
4012
|
-
}
|
|
4013
|
-
|
|
4014
|
-
// src/mantine/blocks/hooks/useBlockDependencies.ts
|
|
4015
|
-
function useBlockDependencies(block, blockType, editor, hasDependencies = true) {
|
|
4016
|
-
const editorDocument = editor?.document;
|
|
4017
|
-
const updateBlock = editor?.updateBlock;
|
|
4018
|
-
const blockObj = typeof block === "string" ? editorDocument?.find((b) => b.id === block) : block;
|
|
4019
|
-
console.log(
|
|
4020
|
-
`[useBlockDependencies] Hook called for blockId: ${blockObj?.id}, blockType: ${blockType}`
|
|
4021
|
-
);
|
|
4022
|
-
if (!hasDependencies || !blockObj?.props?.dependsOn) {
|
|
4023
|
-
console.log(
|
|
4024
|
-
`[useBlockDependencies] Block ${blockObj?.id} doesn't support dependencies, returning {}`
|
|
4025
|
-
);
|
|
4026
|
-
return {};
|
|
4027
|
-
}
|
|
4028
|
-
useMemo10(() => {
|
|
4029
|
-
if (updateBlock && blockObj && !blockObj.props.dependencies) {
|
|
4030
|
-
console.log(`[useBlockDependencies] Initializing dependencies for ${blockObj.id}`);
|
|
4031
|
-
initializeBlockDependencies(editor, blockObj, blockType);
|
|
4032
|
-
}
|
|
4033
|
-
}, [blockObj?.id, blockType, updateBlock]);
|
|
4034
|
-
const { resolvedDependencies } = useDependsOn(blockObj, editor);
|
|
4035
|
-
console.log(
|
|
4036
|
-
`[useBlockDependencies] Returning resolved dependencies for ${blockObj?.id}:`,
|
|
4037
|
-
resolvedDependencies
|
|
4038
|
-
);
|
|
4039
|
-
return resolvedDependencies;
|
|
4040
|
-
}
|
|
3836
|
+
import { Card as Card8, Group as Group12, Stack as Stack28, Text as Text28, ActionIcon as ActionIcon5, Alert as Alert5, Badge as Badge5 } from "@mantine/core";
|
|
4041
3837
|
|
|
4042
3838
|
// src/mantine/blocks/proposalVote/flow/useFlowBusinessLogic.ts
|
|
3839
|
+
import { useState as useState10, useMemo as useMemo10, useEffect as useEffect9 } from "react";
|
|
4043
3840
|
var useFlowBusinessLogic = ({ block, editor }) => {
|
|
4044
3841
|
const { blockRequirements } = useBlocknoteContext();
|
|
4045
|
-
const
|
|
4046
|
-
const [localError, setLocalError] =
|
|
4047
|
-
const [userVote, setUserVote] =
|
|
4048
|
-
const
|
|
3842
|
+
const coreAddress = blockRequirements?.proposal?.coreAddress;
|
|
3843
|
+
const [localError, setLocalError] = useState10(null);
|
|
3844
|
+
const [userVote, setUserVote] = useState10(null);
|
|
3845
|
+
const [proposalContractAddress, setProposalContractAddress] = useState10(null);
|
|
3846
|
+
const hydratedBlock = useMemo10(() => {
|
|
4049
3847
|
if (editor && typeof editor.getUserProps === "function") {
|
|
4050
3848
|
return {
|
|
4051
3849
|
...block,
|
|
@@ -4054,54 +3852,64 @@ var useFlowBusinessLogic = ({ block, editor }) => {
|
|
|
4054
3852
|
}
|
|
4055
3853
|
return block;
|
|
4056
3854
|
}, [block, editor]);
|
|
4057
|
-
const dependencies = useBlockDependencies(hydratedBlock,
|
|
3855
|
+
const { dependencies } = useBlockDependencies(hydratedBlock, editor);
|
|
4058
3856
|
let handlers = null;
|
|
4059
3857
|
try {
|
|
4060
3858
|
handlers = useBlocknoteHandlers();
|
|
4061
3859
|
} catch {
|
|
4062
3860
|
handlers = null;
|
|
4063
3861
|
}
|
|
4064
|
-
const
|
|
4065
|
-
const
|
|
4066
|
-
const
|
|
4067
|
-
const
|
|
4068
|
-
const
|
|
4069
|
-
proposalId,
|
|
4070
|
-
contractAddress: proposalContractAddress || "",
|
|
4071
|
-
autoFetch: !!proposalContractAddress && !!proposalId
|
|
4072
|
-
});
|
|
3862
|
+
const proposalData = dependencies?.proposal || null;
|
|
3863
|
+
const proposalId = proposalData?.proposalId || "";
|
|
3864
|
+
const proposalTitle = proposalData?.title || "";
|
|
3865
|
+
const proposalDescription = proposalData?.description || "";
|
|
3866
|
+
const proposalStatus = proposalData?.status || "draft";
|
|
4073
3867
|
useEffect9(() => {
|
|
4074
|
-
if (!handlers || !
|
|
3868
|
+
if (!handlers || !coreAddress || !proposalId) {
|
|
3869
|
+
setProposalContractAddress(null);
|
|
4075
3870
|
return;
|
|
4076
3871
|
}
|
|
4077
|
-
|
|
3872
|
+
let isCancelled = false;
|
|
3873
|
+
const loadProposalContract = async () => {
|
|
4078
3874
|
try {
|
|
4079
|
-
const { proposalContractAddress:
|
|
4080
|
-
|
|
4081
|
-
|
|
4082
|
-
|
|
4083
|
-
} catch (
|
|
4084
|
-
|
|
4085
|
-
|
|
3875
|
+
const { proposalContractAddress: resolvedAddress } = await handlers.getProposalContractAddress({ coreAddress });
|
|
3876
|
+
if (!isCancelled) {
|
|
3877
|
+
setProposalContractAddress(resolvedAddress);
|
|
3878
|
+
}
|
|
3879
|
+
} catch (error) {
|
|
3880
|
+
if (!isCancelled) {
|
|
3881
|
+
console.error("[ProposalVote] Failed to fetch proposal contract address:", error);
|
|
3882
|
+
}
|
|
4086
3883
|
}
|
|
4087
3884
|
};
|
|
4088
|
-
|
|
4089
|
-
|
|
3885
|
+
void loadProposalContract();
|
|
3886
|
+
return () => {
|
|
3887
|
+
isCancelled = true;
|
|
3888
|
+
};
|
|
3889
|
+
}, [handlers, coreAddress, proposalId]);
|
|
4090
3890
|
useEffect9(() => {
|
|
4091
|
-
if (!handlers || !proposalContractAddress || !proposalId
|
|
3891
|
+
if (!handlers || !proposalContractAddress || !proposalId) {
|
|
4092
3892
|
return;
|
|
4093
3893
|
}
|
|
3894
|
+
let isCancelled = false;
|
|
4094
3895
|
const loadUserVote = async () => {
|
|
4095
3896
|
try {
|
|
4096
3897
|
const user = handlers.getCurrentUser();
|
|
4097
3898
|
const vote = await handlers.getVote(proposalContractAddress, proposalId, user.address);
|
|
4098
|
-
|
|
4099
|
-
|
|
4100
|
-
|
|
3899
|
+
if (!isCancelled) {
|
|
3900
|
+
setUserVote(vote);
|
|
3901
|
+
}
|
|
3902
|
+
} catch (error) {
|
|
3903
|
+
if (!isCancelled) {
|
|
3904
|
+
console.error("[ProposalVote] Failed to fetch user vote:", error);
|
|
3905
|
+
}
|
|
4101
3906
|
}
|
|
4102
3907
|
};
|
|
4103
|
-
loadUserVote();
|
|
4104
|
-
|
|
3908
|
+
void loadUserVote();
|
|
3909
|
+
return () => {
|
|
3910
|
+
isCancelled = true;
|
|
3911
|
+
};
|
|
3912
|
+
}, [handlers, proposalContractAddress, proposalId]);
|
|
4105
3913
|
const updateProp = (key, value) => {
|
|
4106
3914
|
editor.updateBlock(hydratedBlock, {
|
|
4107
3915
|
props: {
|
|
@@ -4114,7 +3922,7 @@ var useFlowBusinessLogic = ({ block, editor }) => {
|
|
|
4114
3922
|
if (!handlers) return;
|
|
4115
3923
|
try {
|
|
4116
3924
|
await handlers.vote(voteParams);
|
|
4117
|
-
const user = handlers.getCurrentUser();
|
|
3925
|
+
const user = await handlers.getCurrentUser();
|
|
4118
3926
|
const vote = await handlers.getVote(voteParams.proposalContractAddress, voteParams.proposalId.toString(), user.address);
|
|
4119
3927
|
setUserVote(vote);
|
|
4120
3928
|
} catch (err) {
|
|
@@ -4125,22 +3933,22 @@ var useFlowBusinessLogic = ({ block, editor }) => {
|
|
|
4125
3933
|
const handleIconChange = (icon) => {
|
|
4126
3934
|
updateProp("icon", icon);
|
|
4127
3935
|
};
|
|
4128
|
-
const status =
|
|
3936
|
+
const status = proposalStatus || hydratedBlock.props.status || "open";
|
|
4129
3937
|
return {
|
|
4130
3938
|
// Block props
|
|
4131
3939
|
hydratedBlock,
|
|
4132
|
-
title: hydratedBlock.props.title,
|
|
4133
|
-
subtitle: hydratedBlock.props.subtitle,
|
|
3940
|
+
title: proposalTitle || hydratedBlock.props.title,
|
|
3941
|
+
subtitle: proposalDescription || hydratedBlock.props.subtitle,
|
|
4134
3942
|
icon: hydratedBlock.props.icon,
|
|
4135
3943
|
status,
|
|
4136
|
-
// Proposal data
|
|
4137
|
-
|
|
3944
|
+
// Proposal data (from dependency, not blockchain)
|
|
3945
|
+
proposalData,
|
|
3946
|
+
proposalId,
|
|
3947
|
+
proposalTitle,
|
|
3948
|
+
proposalDescription,
|
|
4138
3949
|
userVote,
|
|
4139
|
-
proposalContractAddress,
|
|
4140
|
-
// Loading states
|
|
4141
|
-
loading,
|
|
3950
|
+
proposalContractAddress: proposalContractAddress || "",
|
|
4142
3951
|
// Errors
|
|
4143
|
-
error,
|
|
4144
3952
|
localError,
|
|
4145
3953
|
// Handlers
|
|
4146
3954
|
handleVote,
|
|
@@ -4168,25 +3976,16 @@ var getStatusColor2 = (status) => {
|
|
|
4168
3976
|
};
|
|
4169
3977
|
var ProposalVoteFlowView = ({ block, editor, isDisabled }) => {
|
|
4170
3978
|
const panelId = `${PROPOSAL_VOTE_FLOW_PANEL_ID}-${block.id}`;
|
|
4171
|
-
const {
|
|
4172
|
-
|
|
4173
|
-
title,
|
|
4174
|
-
subtitle,
|
|
4175
|
-
icon,
|
|
4176
|
-
status,
|
|
4177
|
-
proposal,
|
|
4178
|
-
userVote,
|
|
4179
|
-
proposalContractAddress,
|
|
4180
|
-
loading,
|
|
4181
|
-
error,
|
|
4182
|
-
localError,
|
|
4183
|
-
handleVote
|
|
4184
|
-
} = useFlowBusinessLogic({ block, editor });
|
|
4185
|
-
const panelContent = useMemo12(
|
|
3979
|
+
const { hydratedBlock, title, subtitle, icon, status, proposalData, proposalId, proposalTitle, proposalDescription, userVote, proposalContractAddress, localError, handleVote } = useFlowBusinessLogic({ block, editor });
|
|
3980
|
+
const panelContent = useMemo11(
|
|
4186
3981
|
() => /* @__PURE__ */ React44.createElement(
|
|
4187
3982
|
FlowConfig,
|
|
4188
3983
|
{
|
|
4189
|
-
|
|
3984
|
+
proposalData,
|
|
3985
|
+
proposalId,
|
|
3986
|
+
proposalTitle,
|
|
3987
|
+
proposalDescription,
|
|
3988
|
+
proposalStatus: status,
|
|
4190
3989
|
userVote,
|
|
4191
3990
|
proposalContractAddress,
|
|
4192
3991
|
onVote: handleVote,
|
|
@@ -4196,41 +3995,10 @@ var ProposalVoteFlowView = ({ block, editor, isDisabled }) => {
|
|
|
4196
3995
|
isDisabled
|
|
4197
3996
|
}
|
|
4198
3997
|
),
|
|
4199
|
-
[
|
|
4200
|
-
proposal,
|
|
4201
|
-
userVote,
|
|
4202
|
-
proposalContractAddress,
|
|
4203
|
-
handleVote,
|
|
4204
|
-
hydratedBlock,
|
|
4205
|
-
status,
|
|
4206
|
-
editor,
|
|
4207
|
-
isDisabled
|
|
4208
|
-
]
|
|
3998
|
+
[proposalData, proposalId, proposalTitle, proposalDescription, status, userVote, proposalContractAddress, handleVote, hydratedBlock, editor, isDisabled]
|
|
4209
3999
|
);
|
|
4210
4000
|
const { open } = usePanel(panelId, panelContent);
|
|
4211
|
-
return /* @__PURE__ */ React44.createElement(
|
|
4212
|
-
Card8,
|
|
4213
|
-
{
|
|
4214
|
-
withBorder: true,
|
|
4215
|
-
padding: "md",
|
|
4216
|
-
radius: "md",
|
|
4217
|
-
style: { width: "100%", cursor: "pointer" },
|
|
4218
|
-
onClick: open
|
|
4219
|
-
},
|
|
4220
|
-
loading && /* @__PURE__ */ React44.createElement(Stack28, null, /* @__PURE__ */ React44.createElement(Skeleton, { height: 20, width: "70%" }), /* @__PURE__ */ React44.createElement(Skeleton, { height: 16 }), /* @__PURE__ */ React44.createElement(Skeleton, { height: 16, width: "40%" })),
|
|
4221
|
-
(error || localError) && /* @__PURE__ */ React44.createElement(Alert5, { color: "red", title: "Error", mb: "md" }, String(error || localError)),
|
|
4222
|
-
!loading && !error && !localError && /* @__PURE__ */ React44.createElement(Group12, { wrap: "nowrap", justify: "space-between", align: "center" }, /* @__PURE__ */ React44.createElement(Group12, { wrap: "nowrap", align: "center" }, /* @__PURE__ */ React44.createElement(
|
|
4223
|
-
ActionIcon5,
|
|
4224
|
-
{
|
|
4225
|
-
variant: "light",
|
|
4226
|
-
color: "blue",
|
|
4227
|
-
size: "xl",
|
|
4228
|
-
radius: "xl",
|
|
4229
|
-
style: { flexShrink: 0 }
|
|
4230
|
-
},
|
|
4231
|
-
getIcon(icon, 24, 1.5, "checklist")
|
|
4232
|
-
), /* @__PURE__ */ React44.createElement(Stack28, { gap: "xs", style: { flex: 1 } }, /* @__PURE__ */ React44.createElement(Text28, { fw: 500, size: "sm", contentEditable: false }, proposal?.proposal?.title || title || "Proposal Vote"), /* @__PURE__ */ React44.createElement(Text28, { size: "xs", c: "dimmed", contentEditable: false }, proposal?.proposal?.description || subtitle || "Cast your vote"))), /* @__PURE__ */ React44.createElement(Badge5, { color: getStatusColor2(status), variant: "filled", size: "sm" }, status.toUpperCase()))
|
|
4233
|
-
);
|
|
4001
|
+
return /* @__PURE__ */ React44.createElement(Card8, { withBorder: true, padding: "md", radius: "md", style: { width: "100%", cursor: "pointer" }, onClick: open }, localError && /* @__PURE__ */ React44.createElement(Alert5, { color: "red", title: "Error", mb: "md" }, String(localError)), !localError && /* @__PURE__ */ React44.createElement(Group12, { wrap: "nowrap", justify: "space-between", align: "center" }, /* @__PURE__ */ React44.createElement(Group12, { wrap: "nowrap", align: "center" }, /* @__PURE__ */ React44.createElement(ActionIcon5, { variant: "light", color: "blue", size: "xl", radius: "xl", style: { flexShrink: 0 } }, getIcon(icon, 24, 1.5, "checklist")), /* @__PURE__ */ React44.createElement(Stack28, { gap: "xs", style: { flex: 1 } }, /* @__PURE__ */ React44.createElement(Text28, { fw: 500, size: "sm", contentEditable: false }, "Proposal Vote"), /* @__PURE__ */ React44.createElement(Text28, { size: "xs", c: "dimmed", contentEditable: false }, "Cast your vote"))), /* @__PURE__ */ React44.createElement(Badge5, { color: getStatusColor2(status), variant: "filled", size: "sm" }, status.toUpperCase())));
|
|
4234
4002
|
};
|
|
4235
4003
|
|
|
4236
4004
|
// src/mantine/blocks/proposalVote/ProposalVoteBlock.tsx
|
|
@@ -4283,21 +4051,15 @@ var ProposalVoteBlockSpec = createReactBlockSpec4(
|
|
|
4283
4051
|
proposal: {
|
|
4284
4052
|
blockId: "",
|
|
4285
4053
|
subscribes: {
|
|
4286
|
-
proposalId: true
|
|
4054
|
+
proposalId: true,
|
|
4055
|
+
title: true,
|
|
4056
|
+
description: true,
|
|
4057
|
+
status: true,
|
|
4058
|
+
icon: true
|
|
4287
4059
|
}
|
|
4288
4060
|
}
|
|
4289
4061
|
})
|
|
4290
4062
|
},
|
|
4291
|
-
// Legacy dependency fields (for backward compatibility)
|
|
4292
|
-
proposalBlockId: {
|
|
4293
|
-
default: ""
|
|
4294
|
-
},
|
|
4295
|
-
hasDependencies: {
|
|
4296
|
-
default: true
|
|
4297
|
-
},
|
|
4298
|
-
dependencies: {
|
|
4299
|
-
default: ""
|
|
4300
|
-
},
|
|
4301
4063
|
// Display props (collaborative)
|
|
4302
4064
|
title: {
|
|
4303
4065
|
default: ""
|
|
@@ -4333,6 +4095,57 @@ var ProposalVoteBlockSpec = createReactBlockSpec4(
|
|
|
4333
4095
|
}
|
|
4334
4096
|
);
|
|
4335
4097
|
|
|
4098
|
+
// src/mantine/context/types.ts
|
|
4099
|
+
var StakeType = {
|
|
4100
|
+
Delegate: "delegate",
|
|
4101
|
+
Undelegate: "undelegate",
|
|
4102
|
+
Redelegate: "redelegate",
|
|
4103
|
+
WithdrawDelegatorReward: "withdraw_delegator_reward"
|
|
4104
|
+
};
|
|
4105
|
+
var AuthzExecActionTypes = {
|
|
4106
|
+
Delegate: "/cosmos.staking.v1beta1.MsgDelegate",
|
|
4107
|
+
Undelegate: "/cosmos.staking.v1beta1.MsgUndelegate",
|
|
4108
|
+
Redelegate: "/cosmos.staking.v1beta1.MsgBeginRedelegate",
|
|
4109
|
+
ClaimRewards: "/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward",
|
|
4110
|
+
Custom: "custom"
|
|
4111
|
+
};
|
|
4112
|
+
var ValidatorActionType = /* @__PURE__ */ ((ValidatorActionType2) => {
|
|
4113
|
+
ValidatorActionType2["CreateValidator"] = "/cosmos.staking.v1beta1.MsgCreateValidator";
|
|
4114
|
+
ValidatorActionType2["EditValidator"] = "/cosmos.staking.v1beta1.MsgEditValidator";
|
|
4115
|
+
ValidatorActionType2["UnjailValidator"] = "/cosmos.slashing.v1beta1.MsgUnjail";
|
|
4116
|
+
ValidatorActionType2["WithdrawValidatorCommission"] = "/cosmos.distribution.v1beta1.MsgWithdrawValidatorCommission";
|
|
4117
|
+
return ValidatorActionType2;
|
|
4118
|
+
})(ValidatorActionType || {});
|
|
4119
|
+
|
|
4120
|
+
// src/mantine/context/hooks/useSharedProposal.ts
|
|
4121
|
+
import { useState as useState11, useEffect as useEffect10, useCallback as useCallback11 } from "react";
|
|
4122
|
+
var useSharedProposal = ({ proposalId, contractAddress, autoFetch = true }) => {
|
|
4123
|
+
const { sharedProposals, fetchSharedProposal, invalidateProposal, subscribeToProposal } = useBlocknoteContext();
|
|
4124
|
+
const [localProposal, setLocalProposal] = useState11(null);
|
|
4125
|
+
const cacheKey = `${contractAddress}:${proposalId}`;
|
|
4126
|
+
useEffect10(() => {
|
|
4127
|
+
if (!proposalId || !contractAddress || !autoFetch) return;
|
|
4128
|
+
fetchSharedProposal(proposalId, contractAddress).then(setLocalProposal).catch((error) => {
|
|
4129
|
+
console.error("Failed to fetch proposal:", error);
|
|
4130
|
+
});
|
|
4131
|
+
}, [proposalId, contractAddress, fetchSharedProposal, autoFetch]);
|
|
4132
|
+
useEffect10(() => {
|
|
4133
|
+
const proposal = subscribeToProposal(cacheKey);
|
|
4134
|
+
if (proposal) {
|
|
4135
|
+
setLocalProposal(proposal);
|
|
4136
|
+
}
|
|
4137
|
+
}, [subscribeToProposal, cacheKey]);
|
|
4138
|
+
const refetch = useCallback11(() => fetchSharedProposal(proposalId, contractAddress, true), [fetchSharedProposal, proposalId, contractAddress]);
|
|
4139
|
+
const invalidate = useCallback11(() => invalidateProposal(proposalId), [invalidateProposal, proposalId]);
|
|
4140
|
+
return {
|
|
4141
|
+
proposal: localProposal,
|
|
4142
|
+
loading: sharedProposals[cacheKey]?.loading ?? false,
|
|
4143
|
+
error: sharedProposals[cacheKey]?.error,
|
|
4144
|
+
refetch,
|
|
4145
|
+
invalidate
|
|
4146
|
+
};
|
|
4147
|
+
};
|
|
4148
|
+
|
|
4336
4149
|
// src/mantine/blocks/proposal/ProposalBlockSpec.tsx
|
|
4337
4150
|
import React54 from "react";
|
|
4338
4151
|
import { createReactBlockSpec as createReactBlockSpec5 } from "@blocknote/react";
|
|
@@ -4341,14 +4154,14 @@ import { createReactBlockSpec as createReactBlockSpec5 } from "@blocknote/react"
|
|
|
4341
4154
|
import React53 from "react";
|
|
4342
4155
|
|
|
4343
4156
|
// src/mantine/blocks/proposal/template/TemplateView.tsx
|
|
4344
|
-
import React49, { useMemo as
|
|
4157
|
+
import React49, { useMemo as useMemo12 } from "react";
|
|
4345
4158
|
|
|
4346
4159
|
// src/mantine/blocks/proposal/template/TemplateConfig.tsx
|
|
4347
|
-
import React48, { useCallback as
|
|
4160
|
+
import React48, { useCallback as useCallback12 } from "react";
|
|
4348
4161
|
import { Paper as Paper4, CloseButton as CloseButton4, Title as Title4 } from "@mantine/core";
|
|
4349
4162
|
|
|
4350
4163
|
// src/mantine/blocks/proposal/template/GeneralTab.tsx
|
|
4351
|
-
import React47, { useEffect as
|
|
4164
|
+
import React47, { useEffect as useEffect11, useState as useState12 } from "react";
|
|
4352
4165
|
import { Stack as Stack29, Text as Text29, TextInput as TextInput5, Textarea as Textarea3 } from "@mantine/core";
|
|
4353
4166
|
var GeneralTab3 = ({
|
|
4354
4167
|
title,
|
|
@@ -4361,13 +4174,13 @@ var GeneralTab3 = ({
|
|
|
4361
4174
|
const [localTitle, setLocalTitle] = useState12(title || "");
|
|
4362
4175
|
const [localDescription, setLocalDescription] = useState12(description || "");
|
|
4363
4176
|
const [localIcon, setLocalIcon] = useState12(icon || "\u{1F4DD}");
|
|
4364
|
-
|
|
4177
|
+
useEffect11(() => {
|
|
4365
4178
|
setLocalTitle(title || "");
|
|
4366
4179
|
}, [title]);
|
|
4367
|
-
|
|
4180
|
+
useEffect11(() => {
|
|
4368
4181
|
setLocalDescription(description || "");
|
|
4369
4182
|
}, [description]);
|
|
4370
|
-
|
|
4183
|
+
useEffect11(() => {
|
|
4371
4184
|
setLocalIcon(icon || "\u{1F4DD}");
|
|
4372
4185
|
}, [icon]);
|
|
4373
4186
|
return /* @__PURE__ */ React47.createElement(Stack29, { gap: "lg" }, /* @__PURE__ */ React47.createElement(Stack29, { gap: "xs" }, /* @__PURE__ */ React47.createElement(Text29, { size: "sm", fw: 600, style: { color: "#f1f3f5" } }, "Title"), /* @__PURE__ */ React47.createElement(
|
|
@@ -4433,7 +4246,7 @@ var GeneralTab3 = ({
|
|
|
4433
4246
|
// src/mantine/blocks/proposal/template/TemplateConfig.tsx
|
|
4434
4247
|
var TemplateConfig3 = ({ editor, block }) => {
|
|
4435
4248
|
const { closePanel } = usePanelStore();
|
|
4436
|
-
const updateProp =
|
|
4249
|
+
const updateProp = useCallback12(
|
|
4437
4250
|
(key, value) => {
|
|
4438
4251
|
editor.updateBlock(block, {
|
|
4439
4252
|
props: {
|
|
@@ -4499,7 +4312,7 @@ import { Card as Card9, Group as Group13, Stack as Stack30, Text as Text30, Acti
|
|
|
4499
4312
|
var PROPOSAL_TEMPLATE_PANEL_ID = "proposal-template-panel";
|
|
4500
4313
|
var ProposalTemplateView = ({ editor, block }) => {
|
|
4501
4314
|
const panelId = `${PROPOSAL_TEMPLATE_PANEL_ID}-${block.id}`;
|
|
4502
|
-
const panelContent =
|
|
4315
|
+
const panelContent = useMemo12(
|
|
4503
4316
|
() => /* @__PURE__ */ React49.createElement(TemplateConfig3, { editor, block }),
|
|
4504
4317
|
[editor, block]
|
|
4505
4318
|
);
|
|
@@ -4518,7 +4331,7 @@ var ProposalTemplateView = ({ editor, block }) => {
|
|
|
4518
4331
|
};
|
|
4519
4332
|
|
|
4520
4333
|
// src/mantine/blocks/proposal/flow/FlowView.tsx
|
|
4521
|
-
import React52, { useMemo as
|
|
4334
|
+
import React52, { useMemo as useMemo13 } from "react";
|
|
4522
4335
|
|
|
4523
4336
|
// src/mantine/blocks/proposal/components/OnChainProposalCard.tsx
|
|
4524
4337
|
import React50 from "react";
|
|
@@ -4567,7 +4380,7 @@ var OnChainProposalCard = ({
|
|
|
4567
4380
|
},
|
|
4568
4381
|
isFetching && /* @__PURE__ */ React50.createElement(Stack31, null, /* @__PURE__ */ React50.createElement(Skeleton2, { height: 20, width: "70%" }), /* @__PURE__ */ React50.createElement(Skeleton2, { height: 16 }), /* @__PURE__ */ React50.createElement(Skeleton2, { height: 16, width: "40%" })),
|
|
4569
4382
|
error && /* @__PURE__ */ React50.createElement(Text31, { size: "sm", c: "red" }, typeof error === "string" ? error : error.message || "An error occurred while loading the proposal."),
|
|
4570
|
-
!isFetching && /* @__PURE__ */ React50.createElement(Group14, { justify: "space-between", align: "flex-start" }, /* @__PURE__ */ React50.createElement(Group14, { align: "flex-start", gap: "md", style: { flex: 1 } }, /* @__PURE__ */ React50.createElement(ActionIcon7, { variant: "light", color: "blue", size: "xl", radius: "xl", style: { flexShrink: 0 } }, getIcon(icon, 24, 1.5, "file-text")), /* @__PURE__ */ React50.createElement(Stack31, { gap: "xs", style: { flex: 1 } }, /* @__PURE__ */ React50.createElement(Group14, { gap: "xs" }, /* @__PURE__ */ React50.createElement(Text31, { size: "md", fw: 600 }, title || "Proposal"), /* @__PURE__ */ React50.createElement(Badge6, { color: statusColor[status], variant: "filled", size: "sm", radius: "sm" }, status.replace(/_/g, " ").toUpperCase())), /* @__PURE__ */ React50.createElement(Text31, { size: "sm", c: "dimmed" }, getDisplayDescription(description)), status === "passed" && onExecute && /* @__PURE__ */ React50.createElement(
|
|
4383
|
+
!isFetching && /* @__PURE__ */ React50.createElement(Group14, { justify: "space-between", align: "flex-start" }, /* @__PURE__ */ React50.createElement(Group14, { align: "flex-start", gap: "md", style: { flex: 1 } }, /* @__PURE__ */ React50.createElement(ActionIcon7, { variant: "light", color: "blue", size: "xl", radius: "xl", style: { flexShrink: 0 } }, getIcon(icon, 24, 1.5, "file-text")), /* @__PURE__ */ React50.createElement(Stack31, { gap: "xs", style: { flex: 1 } }, /* @__PURE__ */ React50.createElement(Group14, { gap: "xs" }, /* @__PURE__ */ React50.createElement(Text31, { size: "md", fw: 600 }, title || "Proposal"), /* @__PURE__ */ React50.createElement(Badge6, { color: statusColor[status], variant: "filled", size: "sm", radius: "sm" }, status.replace(/_/g, " ").toUpperCase())), /* @__PURE__ */ React50.createElement(Text31, { size: "sm", c: "dimmed" }, getDisplayDescription(description)))), status === "passed" && onExecute && /* @__PURE__ */ React50.createElement(
|
|
4571
4384
|
Button11,
|
|
4572
4385
|
{
|
|
4573
4386
|
size: "sm",
|
|
@@ -4578,16 +4391,15 @@ var OnChainProposalCard = ({
|
|
|
4578
4391
|
e.stopPropagation();
|
|
4579
4392
|
onExecute();
|
|
4580
4393
|
},
|
|
4581
|
-
|
|
4582
|
-
w: "fit-content"
|
|
4394
|
+
style: { flexShrink: 0 }
|
|
4583
4395
|
},
|
|
4584
4396
|
"Execute"
|
|
4585
|
-
))
|
|
4397
|
+
))
|
|
4586
4398
|
);
|
|
4587
4399
|
};
|
|
4588
4400
|
|
|
4589
4401
|
// src/mantine/blocks/proposal/flow/FlowConfig.tsx
|
|
4590
|
-
import React51, { useCallback as
|
|
4402
|
+
import React51, { useCallback as useCallback13, useState as useState14 } from "react";
|
|
4591
4403
|
import {
|
|
4592
4404
|
Paper as Paper5,
|
|
4593
4405
|
CloseButton as CloseButton5,
|
|
@@ -4601,16 +4413,8 @@ import {
|
|
|
4601
4413
|
} from "@mantine/core";
|
|
4602
4414
|
|
|
4603
4415
|
// src/mantine/blocks/proposal/flow/useFlowBusinessLogic.ts
|
|
4604
|
-
import { useEffect as
|
|
4605
|
-
var CHAIN_STATUSES = [
|
|
4606
|
-
"open",
|
|
4607
|
-
"passed",
|
|
4608
|
-
"rejected",
|
|
4609
|
-
"executed",
|
|
4610
|
-
"closed",
|
|
4611
|
-
"execution_failed",
|
|
4612
|
-
"veto_timelock"
|
|
4613
|
-
];
|
|
4416
|
+
import { useEffect as useEffect12, useState as useState13 } from "react";
|
|
4417
|
+
var CHAIN_STATUSES = ["open", "passed", "rejected", "executed", "closed", "execution_failed", "veto_timelock"];
|
|
4614
4418
|
var isChainStatus = (value) => {
|
|
4615
4419
|
return CHAIN_STATUSES.includes(value);
|
|
4616
4420
|
};
|
|
@@ -4653,7 +4457,7 @@ var useFlowBusinessLogic2 = ({ block, editor }) => {
|
|
|
4653
4457
|
props: { ...block.props, ...nextProps }
|
|
4654
4458
|
});
|
|
4655
4459
|
};
|
|
4656
|
-
|
|
4460
|
+
useEffect12(() => {
|
|
4657
4461
|
if (!handlers || !coreAddress || !proposalId) {
|
|
4658
4462
|
setProposalContractAddress(null);
|
|
4659
4463
|
return;
|
|
@@ -4676,7 +4480,7 @@ var useFlowBusinessLogic2 = ({ block, editor }) => {
|
|
|
4676
4480
|
isCancelled = true;
|
|
4677
4481
|
};
|
|
4678
4482
|
}, [handlers, coreAddress, proposalId]);
|
|
4679
|
-
|
|
4483
|
+
useEffect12(() => {
|
|
4680
4484
|
if (!proposal) return;
|
|
4681
4485
|
const chainStatus = proposal.proposal.status;
|
|
4682
4486
|
const parsedStatus = parseStatus(chainStatus);
|
|
@@ -4722,7 +4526,7 @@ var useFlowBusinessLogic2 = ({ block, editor }) => {
|
|
|
4722
4526
|
description: localDescription
|
|
4723
4527
|
};
|
|
4724
4528
|
const createdProposalId = await handlers.createProposal(params);
|
|
4725
|
-
updateBlockProps({ proposalId: createdProposalId });
|
|
4529
|
+
updateBlockProps({ proposalId: createdProposalId, status: "open" });
|
|
4726
4530
|
return createdProposalId;
|
|
4727
4531
|
};
|
|
4728
4532
|
return {
|
|
@@ -4757,7 +4561,7 @@ var FlowConfig2 = ({ editor, block }) => {
|
|
|
4757
4561
|
editor
|
|
4758
4562
|
});
|
|
4759
4563
|
const isProposalCreated = !!proposalId;
|
|
4760
|
-
const updateProp =
|
|
4564
|
+
const updateProp = useCallback13(
|
|
4761
4565
|
(key, value) => {
|
|
4762
4566
|
editor.updateBlock(block, {
|
|
4763
4567
|
props: {
|
|
@@ -4881,7 +4685,7 @@ var ProposalFlowView = ({ block, editor }) => {
|
|
|
4881
4685
|
handleExecuteProposal,
|
|
4882
4686
|
handleIconChange
|
|
4883
4687
|
} = useFlowBusinessLogic2({ block, editor });
|
|
4884
|
-
const panelContent =
|
|
4688
|
+
const panelContent = useMemo13(() => /* @__PURE__ */ React52.createElement(FlowConfig2, { editor, block }), [editor, block]);
|
|
4885
4689
|
const { open } = usePanel(panelId, panelContent);
|
|
4886
4690
|
return /* @__PURE__ */ React52.createElement(
|
|
4887
4691
|
OnChainProposalCard,
|
|
@@ -4956,7 +4760,7 @@ import React57 from "react";
|
|
|
4956
4760
|
import { createReactBlockSpec as createReactBlockSpec6 } from "@blocknote/react";
|
|
4957
4761
|
|
|
4958
4762
|
// src/mantine/blocks/proposalActions/ProposalActionsBlock.tsx
|
|
4959
|
-
import React56, { useCallback as
|
|
4763
|
+
import React56, { useCallback as useCallback14 } from "react";
|
|
4960
4764
|
|
|
4961
4765
|
// src/mantine/blocks/proposalActions/components/ActionsCard.tsx
|
|
4962
4766
|
import React55 from "react";
|
|
@@ -5111,7 +4915,7 @@ var ProposalActionsBlock = ({ block, editor }) => {
|
|
|
5111
4915
|
};
|
|
5112
4916
|
const storedActionsJson = block?.props?.actions || "[]";
|
|
5113
4917
|
const actions = parseActions(storedActionsJson);
|
|
5114
|
-
const updateActions =
|
|
4918
|
+
const updateActions = useCallback14(
|
|
5115
4919
|
(newActions) => {
|
|
5116
4920
|
editor.updateBlock(block, {
|
|
5117
4921
|
props: {
|
|
@@ -5121,18 +4925,18 @@ var ProposalActionsBlock = ({ block, editor }) => {
|
|
|
5121
4925
|
},
|
|
5122
4926
|
[block, editor]
|
|
5123
4927
|
);
|
|
5124
|
-
const handleAddAction =
|
|
4928
|
+
const handleAddAction = useCallback14(() => {
|
|
5125
4929
|
}, []);
|
|
5126
|
-
const handleEditAction =
|
|
4930
|
+
const handleEditAction = useCallback14(() => {
|
|
5127
4931
|
}, []);
|
|
5128
|
-
const handleRemoveAction =
|
|
4932
|
+
const handleRemoveAction = useCallback14(
|
|
5129
4933
|
(index) => {
|
|
5130
4934
|
const newActions = actions.filter((_, i) => i !== index);
|
|
5131
4935
|
updateActions(newActions);
|
|
5132
4936
|
},
|
|
5133
4937
|
[actions, updateActions]
|
|
5134
4938
|
);
|
|
5135
|
-
const handleCardClick =
|
|
4939
|
+
const handleCardClick = useCallback14(() => {
|
|
5136
4940
|
}, []);
|
|
5137
4941
|
return /* @__PURE__ */ React56.createElement(ActionsCard, { actions, isSelected: true, onClick: handleCardClick, onAddAction: handleAddAction, onEditAction: handleEditAction, onRemoveAction: handleRemoveAction });
|
|
5138
4942
|
};
|
|
@@ -5177,7 +4981,7 @@ var ProposalActionsBlockSpec = createReactBlockSpec6(
|
|
|
5177
4981
|
);
|
|
5178
4982
|
|
|
5179
4983
|
// src/mantine/blocks/proposalActions/ProposalActionsDrawer.tsx
|
|
5180
|
-
import React88, { useState as useState21, useEffect as
|
|
4984
|
+
import React88, { useState as useState21, useEffect as useEffect14, useMemo as useMemo14 } from "react";
|
|
5181
4985
|
import { Stack as Stack64, Select as Select10, Button as Button19, Group as Group26, Text as Text41, Card as Card18, Badge as Badge10, Divider as Divider3, ScrollArea as ScrollArea3, Alert as Alert8, Tabs as Tabs2, SimpleGrid, Paper as Paper6 } from "@mantine/core";
|
|
5182
4986
|
|
|
5183
4987
|
// src/mantine/blocks/proposalActions/components/SpendActionForm.tsx
|
|
@@ -5667,7 +5471,7 @@ var ExecuteActionForm = ({ data, onChange }) => {
|
|
|
5667
5471
|
};
|
|
5668
5472
|
|
|
5669
5473
|
// src/mantine/blocks/proposalActions/components/forms/CustomActionForm.tsx
|
|
5670
|
-
import React64, { useState as useState17, useEffect as
|
|
5474
|
+
import React64, { useState as useState17, useEffect as useEffect13 } from "react";
|
|
5671
5475
|
import { Stack as Stack40, Textarea as Textarea6, Alert as Alert6, Text as Text36, Badge as Badge9 } from "@mantine/core";
|
|
5672
5476
|
import { Group as Group18 } from "@mantine/core";
|
|
5673
5477
|
var inputStyles5 = {
|
|
@@ -5685,7 +5489,7 @@ var inputStyles5 = {
|
|
|
5685
5489
|
var CustomActionForm = ({ data, onChange }) => {
|
|
5686
5490
|
const [isValid, setIsValid] = useState17(true);
|
|
5687
5491
|
const [error, setError] = useState17("");
|
|
5688
|
-
|
|
5492
|
+
useEffect13(() => {
|
|
5689
5493
|
try {
|
|
5690
5494
|
if (data.message) {
|
|
5691
5495
|
JSON.parse(data.message);
|
|
@@ -8034,7 +7838,7 @@ var actionRegistry = /* @__PURE__ */ new Map([
|
|
|
8034
7838
|
]);
|
|
8035
7839
|
|
|
8036
7840
|
// src/mantine/blocks/enumChecklist/EnumChecklistBlock.tsx
|
|
8037
|
-
import React94, { useState as useState23, useEffect as
|
|
7841
|
+
import React94, { useState as useState23, useEffect as useEffect15, useMemo as useMemo15, useCallback as useCallback15 } from "react";
|
|
8038
7842
|
import { createReactBlockSpec as createReactBlockSpec7 } from "@blocknote/react";
|
|
8039
7843
|
import { Stack as Stack69, Text as Text46, Button as Button23, ActionIcon as ActionIcon10, Center as Center3, Flex as Flex16 } from "@mantine/core";
|
|
8040
7844
|
|
|
@@ -8380,7 +8184,7 @@ var EnumChecklistBlockContent = ({ block, editor }) => {
|
|
|
8380
8184
|
const [modalOpened, setModalOpened] = useState23(false);
|
|
8381
8185
|
const { editable } = useBlocknoteContext();
|
|
8382
8186
|
const listType = block.props.listType && block.props.listType !== "" ? block.props.listType : null;
|
|
8383
|
-
const listConfig =
|
|
8187
|
+
const listConfig = useMemo15(() => {
|
|
8384
8188
|
if (block.props.listConfig && block.props.listConfig !== "{}") {
|
|
8385
8189
|
try {
|
|
8386
8190
|
return JSON.parse(block.props.listConfig);
|
|
@@ -8391,7 +8195,7 @@ var EnumChecklistBlockContent = ({ block, editor }) => {
|
|
|
8391
8195
|
}
|
|
8392
8196
|
return {};
|
|
8393
8197
|
}, [block.props.listConfig]);
|
|
8394
|
-
const selectedIds =
|
|
8198
|
+
const selectedIds = useMemo15(() => {
|
|
8395
8199
|
if (block.props.selectedIds && block.props.selectedIds !== "[]") {
|
|
8396
8200
|
try {
|
|
8397
8201
|
return new Set(JSON.parse(block.props.selectedIds));
|
|
@@ -8402,7 +8206,7 @@ var EnumChecklistBlockContent = ({ block, editor }) => {
|
|
|
8402
8206
|
}
|
|
8403
8207
|
return /* @__PURE__ */ new Set();
|
|
8404
8208
|
}, [block.props.selectedIds]);
|
|
8405
|
-
|
|
8209
|
+
useEffect15(() => {
|
|
8406
8210
|
if (listConfig?.selection_mode === "single" && selectedIds.size > 1) {
|
|
8407
8211
|
const arr = Array.from(selectedIds);
|
|
8408
8212
|
const lastSelected = arr.length > 0 ? arr[arr.length - 1] : void 0;
|
|
@@ -8411,13 +8215,13 @@ var EnumChecklistBlockContent = ({ block, editor }) => {
|
|
|
8411
8215
|
});
|
|
8412
8216
|
}
|
|
8413
8217
|
}, [listConfig?.selection_mode, selectedIds]);
|
|
8414
|
-
const isItemChecked =
|
|
8218
|
+
const isItemChecked = useCallback15(
|
|
8415
8219
|
(id) => {
|
|
8416
8220
|
return selectedIds.has(id);
|
|
8417
8221
|
},
|
|
8418
8222
|
[selectedIds]
|
|
8419
8223
|
);
|
|
8420
|
-
const onItemCheck =
|
|
8224
|
+
const onItemCheck = useCallback15(
|
|
8421
8225
|
(id, checked) => {
|
|
8422
8226
|
const currentSelectedIds = Array.from(selectedIds);
|
|
8423
8227
|
let newSelectedIds;
|
|
@@ -8603,6 +8407,9 @@ blockRegistry.register({
|
|
|
8603
8407
|
defaultProps: {}
|
|
8604
8408
|
});
|
|
8605
8409
|
|
|
8410
|
+
// src/mantine/blocks/hooks/useDependsOn.ts
|
|
8411
|
+
import { useMemo as useMemo16 } from "react";
|
|
8412
|
+
|
|
8606
8413
|
// src/mantine/blocks/index.ts
|
|
8607
8414
|
var blockSpecs = {
|
|
8608
8415
|
checkbox: CheckboxBlockSpec,
|
|
@@ -8717,8 +8524,6 @@ var getExtraSlashMenuItems = (editor) => [
|
|
|
8717
8524
|
icon: 'A\uFFFD\uFFFD,\uFFFD?"A3A_A,A?',
|
|
8718
8525
|
status: "open",
|
|
8719
8526
|
daysLeft: 0,
|
|
8720
|
-
proposalId: "",
|
|
8721
|
-
proposalBlockId: "",
|
|
8722
8527
|
conditions: ""
|
|
8723
8528
|
}
|
|
8724
8529
|
}
|
|
@@ -8849,15 +8654,10 @@ function useCreateIxoEditor(options) {
|
|
|
8849
8654
|
|
|
8850
8655
|
// src/mantine/hooks/useCollaborativeIxoEditor.ts
|
|
8851
8656
|
import { useCreateBlockNote as useCreateBlockNote2 } from "@blocknote/react";
|
|
8852
|
-
import {
|
|
8853
|
-
BlockNoteSchema as BlockNoteSchema2,
|
|
8854
|
-
defaultBlockSpecs as defaultBlockSpecs2,
|
|
8855
|
-
defaultInlineContentSpecs as defaultInlineContentSpecs2,
|
|
8856
|
-
defaultStyleSpecs as defaultStyleSpecs2
|
|
8857
|
-
} from "@blocknote/core";
|
|
8657
|
+
import { BlockNoteSchema as BlockNoteSchema2, defaultBlockSpecs as defaultBlockSpecs2, defaultInlineContentSpecs as defaultInlineContentSpecs2, defaultStyleSpecs as defaultStyleSpecs2 } from "@blocknote/core";
|
|
8858
8658
|
|
|
8859
8659
|
// src/core/hooks/useMatrixProvider.ts
|
|
8860
|
-
import { useEffect as
|
|
8660
|
+
import { useEffect as useEffect16, useState as useState24, useRef as useRef3, useCallback as useCallback16, useMemo as useMemo17 } from "react";
|
|
8861
8661
|
import { MatrixProvider } from "@ixo/matrix-crdt";
|
|
8862
8662
|
function useMatrixProvider({
|
|
8863
8663
|
matrixClient,
|
|
@@ -8884,22 +8684,22 @@ function useMatrixProvider({
|
|
|
8884
8684
|
}),
|
|
8885
8685
|
[]
|
|
8886
8686
|
);
|
|
8887
|
-
const handleDocumentAvailable =
|
|
8687
|
+
const handleDocumentAvailable = useCallback16(() => {
|
|
8888
8688
|
if (isMountedRef.current) {
|
|
8889
8689
|
setStatus("connected");
|
|
8890
8690
|
}
|
|
8891
8691
|
}, []);
|
|
8892
|
-
const handleDocumentUnavailable =
|
|
8692
|
+
const handleDocumentUnavailable = useCallback16(() => {
|
|
8893
8693
|
if (isMountedRef.current) {
|
|
8894
8694
|
setStatus("failed");
|
|
8895
8695
|
}
|
|
8896
8696
|
}, []);
|
|
8897
|
-
const handleCanWriteChanged =
|
|
8697
|
+
const handleCanWriteChanged = useCallback16(() => {
|
|
8898
8698
|
if (isMountedRef.current && providerRef.current) {
|
|
8899
8699
|
setStatus(providerRef.current.canWrite ? "connected" : "failed");
|
|
8900
8700
|
}
|
|
8901
8701
|
}, []);
|
|
8902
|
-
const initProvider =
|
|
8702
|
+
const initProvider = useCallback16(async () => {
|
|
8903
8703
|
if (!isMountedRef.current) return;
|
|
8904
8704
|
if (retryTimeoutRef.current) {
|
|
8905
8705
|
clearTimeout(retryTimeoutRef.current);
|
|
@@ -8944,7 +8744,7 @@ function useMatrixProvider({
|
|
|
8944
8744
|
handleDocumentUnavailable,
|
|
8945
8745
|
handleCanWriteChanged
|
|
8946
8746
|
]);
|
|
8947
|
-
|
|
8747
|
+
useEffect16(() => {
|
|
8948
8748
|
isMountedRef.current = true;
|
|
8949
8749
|
initProvider();
|
|
8950
8750
|
return () => {
|
|
@@ -8961,7 +8761,7 @@ function useMatrixProvider({
|
|
|
8961
8761
|
setStatus("disconnected");
|
|
8962
8762
|
};
|
|
8963
8763
|
}, [initProvider]);
|
|
8964
|
-
|
|
8764
|
+
useEffect16(() => {
|
|
8965
8765
|
return () => {
|
|
8966
8766
|
isMountedRef.current = false;
|
|
8967
8767
|
};
|
|
@@ -8982,6 +8782,7 @@ function useCollaborativeYDoc(options) {
|
|
|
8982
8782
|
root.set("doc_id", options.docId || `flow_${Date.now()}`);
|
|
8983
8783
|
root.set("createdAt", (/* @__PURE__ */ new Date()).toISOString());
|
|
8984
8784
|
root.set("createdBy", options.user?.id || "anonymous");
|
|
8785
|
+
root.set("docType", "");
|
|
8985
8786
|
const titleText = doc.getText("title");
|
|
8986
8787
|
if (titleText.length === 0 && options.title) {
|
|
8987
8788
|
titleText.insert(0, options.title);
|
|
@@ -8992,7 +8793,7 @@ function useCollaborativeYDoc(options) {
|
|
|
8992
8793
|
}
|
|
8993
8794
|
|
|
8994
8795
|
// src/mantine/hooks/useCollaborativeIxoEditor.ts
|
|
8995
|
-
import { useMemo as useMemo19, useEffect as
|
|
8796
|
+
import { useMemo as useMemo19, useEffect as useEffect17 } from "react";
|
|
8996
8797
|
function useCreateCollaborativeIxoEditor(options) {
|
|
8997
8798
|
const yDoc = useCollaborativeYDoc(options);
|
|
8998
8799
|
const {
|
|
@@ -9128,8 +8929,12 @@ function useCreateCollaborativeIxoEditor(options) {
|
|
|
9128
8929
|
ixoEditor.getFlow = () => {
|
|
9129
8930
|
return flowArray.toArray();
|
|
9130
8931
|
};
|
|
8932
|
+
ixoEditor.getDocType = () => root.get("docType") || "";
|
|
8933
|
+
ixoEditor.setDocType = (value) => {
|
|
8934
|
+
root.set("docType", value);
|
|
8935
|
+
};
|
|
9131
8936
|
}
|
|
9132
|
-
|
|
8937
|
+
useEffect17(() => {
|
|
9133
8938
|
if (ixoEditor) {
|
|
9134
8939
|
ixoEditor.isEditable = editable;
|
|
9135
8940
|
}
|
|
@@ -9335,10 +9140,10 @@ export {
|
|
|
9335
9140
|
CheckboxBlockSpec,
|
|
9336
9141
|
ListBlock,
|
|
9337
9142
|
OverviewBlock,
|
|
9143
|
+
ProposalVoteBlockSpec,
|
|
9338
9144
|
StakeType,
|
|
9339
9145
|
AuthzExecActionTypes,
|
|
9340
9146
|
ValidatorActionType,
|
|
9341
|
-
ProposalVoteBlockSpec,
|
|
9342
9147
|
blockSpecs,
|
|
9343
9148
|
getExtraSlashMenuItems,
|
|
9344
9149
|
useCreateIxoEditor,
|
|
@@ -9348,4 +9153,4 @@ export {
|
|
|
9348
9153
|
ixoGraphQLClient,
|
|
9349
9154
|
getEntity
|
|
9350
9155
|
};
|
|
9351
|
-
//# sourceMappingURL=chunk-
|
|
9156
|
+
//# sourceMappingURL=chunk-VGSTHGS4.mjs.map
|