@timeax/service-builder 0.0.10 → 0.0.11
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/index.js +91 -13
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4234,6 +4234,8 @@ import { LuTags as LuTags2 } from "react-icons/lu";
|
|
|
4234
4234
|
import { MdOutlineRadioButtonChecked as MdOutlineRadioButtonChecked2 } from "react-icons/md";
|
|
4235
4235
|
import { RxInput as RxInput2 } from "react-icons/rx";
|
|
4236
4236
|
import { Fragment as Fragment5, jsx as jsx15, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
4237
|
+
var ACTIVE_NODE_RING_CLASS = "ring-2 ring-sky-300 shadow-lg shadow-sky-300/20 dark:ring-sky-400";
|
|
4238
|
+
var HIGHLIGHT_NODE_OUTLINE_CLASS = "outline-2 outline-solid outline-amber-300 dark:outline-amber-200";
|
|
4237
4239
|
function NodeShell({
|
|
4238
4240
|
label,
|
|
4239
4241
|
icon,
|
|
@@ -4264,7 +4266,7 @@ function NodeShell({
|
|
|
4264
4266
|
isManualHighlighted ? "manual-highlighted" : "",
|
|
4265
4267
|
focusDimLevel && focusDimLevel !== "none" ? `dim-${focusDimLevel}` : ""
|
|
4266
4268
|
].filter(Boolean).join(" "),
|
|
4267
|
-
className: "group relative min-w-44 rounded-lg bg-white p-3 ring-1 ring-slate-200 shadow-[0_4px_12px_rgba(0,0,0,0.05)] transition-all duration-200 dark:bg-slate-900 dark:ring-slate-700 " + (selected ?
|
|
4269
|
+
className: "group relative min-w-44 rounded-lg bg-white p-3 ring-1 ring-slate-200 shadow-[0_4px_12px_rgba(0,0,0,0.05)] transition-all duration-200 dark:bg-slate-900 dark:ring-slate-700 " + (selected ? `${ACTIVE_NODE_RING_CLASS} ` : "hover:shadow-lg ") + (isActiveNode ? `${ACTIVE_NODE_RING_CLASS} ` : "") + (isCurrentTag ? "ring-2 ring-emerald-500 bg-emerald-50/70 shadow-lg shadow-emerald-500/25 dark:bg-emerald-500/10 " : "") + (isVisibleGroupField ? "ring-2 ring-emerald-300 bg-emerald-50/35 dark:bg-emerald-500/5 " : "") + (isRelatedTag ? "ring-1 ring-teal-300 bg-teal-50/25 dark:bg-teal-500/8 " : "") + (isManualHighlighted ? `${HIGHLIGHT_NODE_OUTLINE_CLASS} ` : "") + (draggingService && canAssignService2 ? "border border-dashed border-emerald-400 " : "") + (!canAssignService2 && draggingService ? "opacity-70 " : "") + dimClass,
|
|
4268
4270
|
onDragOver: (event) => {
|
|
4269
4271
|
if (!canAcceptDropPayload?.(event.dataTransfer)) return;
|
|
4270
4272
|
event.preventDefault();
|
|
@@ -4361,7 +4363,7 @@ function OptionNode(props) {
|
|
|
4361
4363
|
props.data.isManualHighlighted ? "manual-highlighted" : "",
|
|
4362
4364
|
props.data.focusDimLevel && props.data.focusDimLevel !== "none" ? `dim-${props.data.focusDimLevel}` : ""
|
|
4363
4365
|
].filter(Boolean).join(" "),
|
|
4364
|
-
className: "relative rounded-full border px-4 py-1.5 text-sm bg-white text-slate-800 transition dark:bg-slate-900 dark:text-slate-200 " + (props.selected ? "border-
|
|
4366
|
+
className: "relative rounded-full border px-4 py-1.5 text-sm bg-white text-slate-800 transition dark:bg-slate-900 dark:text-slate-200 " + (props.selected ? "border-sky-300 bg-sky-50 text-sky-700 dark:bg-sky-500/15 dark:border-sky-400 " : "border-slate-300 dark:border-slate-700 ") + (props.data.isActiveNode ? `${ACTIVE_NODE_RING_CLASS} ` : "") + (props.data.isCurrentTag ? "ring-2 ring-emerald-500 bg-emerald-50/70 dark:bg-emerald-500/10 " : "") + (props.data.isVisibleGroupField ? "ring-2 ring-emerald-300 bg-emerald-50/35 dark:bg-emerald-500/5 " : "") + (props.data.isRelatedTag ? "ring-1 ring-teal-300 bg-teal-50/25 dark:bg-teal-500/8 " : "") + (props.data.isManualHighlighted ? `${HIGHLIGHT_NODE_OUTLINE_CLASS} ` : "") + (props.data.focusDimLevel === "soft" ? "opacity-80 " : props.data.focusDimLevel === "medium" ? "opacity-[0.55] " : props.data.focusDimLevel === "strong" ? "opacity-35 " : ""),
|
|
4365
4367
|
onDragOver: (event) => {
|
|
4366
4368
|
if (!props.data.canAcceptDropPayload?.(event.dataTransfer)) return;
|
|
4367
4369
|
event.preventDefault();
|
|
@@ -4388,14 +4390,20 @@ function OptionNode(props) {
|
|
|
4388
4390
|
function CommentNode(props) {
|
|
4389
4391
|
const thread = props.data.thread;
|
|
4390
4392
|
const main = thread?.messages?.find((message) => message.isMain) ?? thread?.messages?.[0];
|
|
4391
|
-
return /* @__PURE__ */ jsxs11(
|
|
4392
|
-
|
|
4393
|
-
|
|
4394
|
-
|
|
4395
|
-
|
|
4396
|
-
|
|
4397
|
-
|
|
4398
|
-
|
|
4393
|
+
return /* @__PURE__ */ jsxs11(
|
|
4394
|
+
"div",
|
|
4395
|
+
{
|
|
4396
|
+
className: "h-48 w-64 rounded-lg border border-[#E0E0E0] bg-[#FEFBEA] shadow-md transition-all hover:shadow-lg dark:border-[#555] dark:bg-[#4a4a38] " + (props.selected ? `${ACTIVE_NODE_RING_CLASS} ` : ""),
|
|
4397
|
+
children: [
|
|
4398
|
+
/* @__PURE__ */ jsxs11("div", { className: "flex items-center gap-2 border-b border-[#E0E0E0]/70 px-3 py-2 text-xs font-medium text-slate-600 dark:border-[#555] dark:text-slate-300", children: [
|
|
4399
|
+
/* @__PURE__ */ jsx15(BsChatSquareQuote2, {}),
|
|
4400
|
+
/* @__PURE__ */ jsx15("span", { children: main?.authorName ?? "Comment" })
|
|
4401
|
+
] }),
|
|
4402
|
+
/* @__PURE__ */ jsx15("div", { className: "px-3 py-2 text-sm leading-5 text-slate-700 dark:text-slate-200", children: main?.body ?? "" }),
|
|
4403
|
+
/* @__PURE__ */ jsx15("div", { className: "absolute bottom-2 right-2 text-[10px] uppercase tracking-[0.14em] text-slate-400", children: thread?.resolved ? "Resolved" : "Open" })
|
|
4404
|
+
]
|
|
4405
|
+
}
|
|
4406
|
+
);
|
|
4399
4407
|
}
|
|
4400
4408
|
var nodeTypes = {
|
|
4401
4409
|
tag: TagNode,
|
|
@@ -5275,7 +5283,6 @@ function CanvasPanel({
|
|
|
5275
5283
|
}, [canvas.api]);
|
|
5276
5284
|
function setSnapshot(event) {
|
|
5277
5285
|
const nextSnapshot = event?.snapshot;
|
|
5278
|
-
console.log("this is the changed...");
|
|
5279
5286
|
if (!nextSnapshot) return;
|
|
5280
5287
|
const nextHash = hashSnapshot(nextSnapshot);
|
|
5281
5288
|
setCurrentSnapshotHash((current) => current === nextHash ? current : nextHash);
|
|
@@ -5287,7 +5294,6 @@ function CanvasPanel({
|
|
|
5287
5294
|
useEffect8(() => {
|
|
5288
5295
|
const catalogChange = canvas.api.on("catalog:change", setSnapshot);
|
|
5289
5296
|
const offEditorChange = canvas.api.on("editor:change", (event) => {
|
|
5290
|
-
console.log("this snapshot changed via the editor...");
|
|
5291
5297
|
setSnapshot(event);
|
|
5292
5298
|
if (event?.reason === "mutation" || event?.reason === "transaction") {
|
|
5293
5299
|
setHistoryState({ canUndo: true, canRedo: false });
|
|
@@ -9184,6 +9190,68 @@ import { LuTags as LuTags3 } from "react-icons/lu";
|
|
|
9184
9190
|
import { MdOutlineAdd } from "react-icons/md";
|
|
9185
9191
|
import { RxInput as RxInput3 } from "react-icons/rx";
|
|
9186
9192
|
import { VscNewFolder } from "react-icons/vsc";
|
|
9193
|
+
|
|
9194
|
+
// src/panels/left/layers/reorder.ts
|
|
9195
|
+
function isOptionId(id) {
|
|
9196
|
+
return id.startsWith("o:");
|
|
9197
|
+
}
|
|
9198
|
+
function parentPathKey(path) {
|
|
9199
|
+
if (!path?.length) return "";
|
|
9200
|
+
return path.map(String).join("/");
|
|
9201
|
+
}
|
|
9202
|
+
function canDropSameParentOnly(args) {
|
|
9203
|
+
if (!args.from) return true;
|
|
9204
|
+
return parentPathKey(args.from.parentPath) === parentPathKey(args.to.parentPath);
|
|
9205
|
+
}
|
|
9206
|
+
function canDropFieldsSameParentOnly(args) {
|
|
9207
|
+
if (!canDropSameParentOnly(args)) return false;
|
|
9208
|
+
if (!args.dragged) return true;
|
|
9209
|
+
const draggedId = String(args.dragged.id);
|
|
9210
|
+
const parentId = args.to.parent ? String(args.to.parent.id) : "";
|
|
9211
|
+
if (isOptionId(draggedId)) {
|
|
9212
|
+
return parentId.startsWith("f:");
|
|
9213
|
+
}
|
|
9214
|
+
return parentId === "";
|
|
9215
|
+
}
|
|
9216
|
+
function isReorderLike(detail) {
|
|
9217
|
+
return detail.type === "move" || detail.type === "reorder";
|
|
9218
|
+
}
|
|
9219
|
+
function applyTagTreeReorder(detail, editor) {
|
|
9220
|
+
if (!isReorderLike(detail)) return false;
|
|
9221
|
+
detail.preventDefault();
|
|
9222
|
+
editor.placeNode(String(detail.node.id), { index: detail.to.index });
|
|
9223
|
+
return true;
|
|
9224
|
+
}
|
|
9225
|
+
function applyFieldTreeReorder(detail, args) {
|
|
9226
|
+
if (!isReorderLike(detail)) return false;
|
|
9227
|
+
detail.preventDefault();
|
|
9228
|
+
const nodeId = String(detail.node.id);
|
|
9229
|
+
if (isOptionId(nodeId)) {
|
|
9230
|
+
args.editor.placeOption(nodeId, { index: detail.to.index });
|
|
9231
|
+
return true;
|
|
9232
|
+
}
|
|
9233
|
+
const writeAndPlace = () => {
|
|
9234
|
+
args.editor.patchProps?.((props) => {
|
|
9235
|
+
const map = props.order_for_tags ??= {};
|
|
9236
|
+
map[args.currentTagId] = [...args.contextFieldOrder];
|
|
9237
|
+
});
|
|
9238
|
+
args.editor.placeNode(nodeId, {
|
|
9239
|
+
scopeTagId: args.currentTagId,
|
|
9240
|
+
index: detail.to.index
|
|
9241
|
+
});
|
|
9242
|
+
};
|
|
9243
|
+
if (typeof args.editor.transact === "function" && typeof args.editor.patchProps === "function") {
|
|
9244
|
+
args.editor.transact("Reorder field in context", writeAndPlace);
|
|
9245
|
+
return true;
|
|
9246
|
+
}
|
|
9247
|
+
args.editor.placeNode(nodeId, {
|
|
9248
|
+
scopeTagId: args.currentTagId,
|
|
9249
|
+
index: detail.to.index
|
|
9250
|
+
});
|
|
9251
|
+
return true;
|
|
9252
|
+
}
|
|
9253
|
+
|
|
9254
|
+
// src/panels/left/layers/index.tsx
|
|
9187
9255
|
import { jsx as jsx38, jsxs as jsxs25 } from "react/jsx-runtime";
|
|
9188
9256
|
function filterTree(nodes, query) {
|
|
9189
9257
|
if (!query.trim()) return nodes;
|
|
@@ -9223,6 +9291,7 @@ var Layers = () => {
|
|
|
9223
9291
|
canvas.api.addToSelection(ids);
|
|
9224
9292
|
};
|
|
9225
9293
|
const handleTagChange = (_next, detail) => {
|
|
9294
|
+
if (applyTagTreeReorder(detail, canvas.api.editor)) return;
|
|
9226
9295
|
detail.preventDefault?.();
|
|
9227
9296
|
if (detail.type === "update") {
|
|
9228
9297
|
canvas.api.editor.editLabel(detail.node.id, detail.node.title);
|
|
@@ -9234,6 +9303,13 @@ var Layers = () => {
|
|
|
9234
9303
|
}
|
|
9235
9304
|
};
|
|
9236
9305
|
const handleFieldChange = (_next, detail) => {
|
|
9306
|
+
if (applyFieldTreeReorder(detail, {
|
|
9307
|
+
editor: canvas.api.editor,
|
|
9308
|
+
currentTagId: canvas.api.selection.currentTag?.() ?? "t:root",
|
|
9309
|
+
contextFieldOrder: canvas.layers.fields.map((node) => String(node.id)).filter((id) => !id.startsWith("o:"))
|
|
9310
|
+
})) {
|
|
9311
|
+
return;
|
|
9312
|
+
}
|
|
9237
9313
|
if (detail.type === "update") {
|
|
9238
9314
|
detail.preventDefault();
|
|
9239
9315
|
canvas.api.editor.editLabel(detail.node.id, detail.node.title);
|
|
@@ -9328,6 +9404,7 @@ var Layers = () => {
|
|
|
9328
9404
|
value: canvas.selectionInfo.tagIds,
|
|
9329
9405
|
rowClassName: "mb-1 rounded-xl border border-transparent px-1 hover:border-slate-200 hover:bg-slate-50 dark:hover:border-slate-800 dark:hover:bg-slate-900/70",
|
|
9330
9406
|
data: tags,
|
|
9407
|
+
canDrop: canDropSameParentOnly,
|
|
9331
9408
|
activeClassName: (e) => e.node.id === canvas.activeId ? "border-blue-300! bg-blue-50/80 dark:border-blue-500/40! dark:bg-blue-500/10!" : "",
|
|
9332
9409
|
onChange: handleTagChange,
|
|
9333
9410
|
onContextMenu: (detail) => {
|
|
@@ -9448,6 +9525,7 @@ var Layers = () => {
|
|
|
9448
9525
|
value: [...canvas.selectionInfo.fieldIds, ...canvas.selectionInfo.optionIds],
|
|
9449
9526
|
rowClassName: "mb-1 rounded-xl border border-transparent px-1 hover:border-slate-200 hover:bg-slate-50 dark:hover:border-slate-800 dark:hover:bg-slate-900/70",
|
|
9450
9527
|
data: fields,
|
|
9528
|
+
canDrop: canDropFieldsSameParentOnly,
|
|
9451
9529
|
onChange: handleFieldChange,
|
|
9452
9530
|
onContextMenu: (detail) => {
|
|
9453
9531
|
const nodeId = String(detail.node.id);
|
|
@@ -10098,7 +10176,7 @@ var Comments = () => {
|
|
|
10098
10176
|
branchId: ws.branches.currentId
|
|
10099
10177
|
}).finally(() => setValue(""));
|
|
10100
10178
|
},
|
|
10101
|
-
className: "cursor-pointer rounded-
|
|
10179
|
+
className: "cursor-pointer rounded-full bg-blue-600 px-2 py-2 text-white transition hover:bg-blue-700",
|
|
10102
10180
|
disabled: !ws.boot.isReady,
|
|
10103
10181
|
children: /* @__PURE__ */ jsx45(MdOutlineSend, {})
|
|
10104
10182
|
}
|