@dou-ui/flow 0.1.0-alpha.2 → 0.1.0-alpha.21
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/collaboration/index.js +114 -6
- package/dist/collaboration/index.js.map +1 -1
- package/dist/comments.js +245 -0
- package/dist/comments.js.map +1 -0
- package/dist/components/default-node.js.map +1 -1
- package/dist/components/default-node.vue_vue_type_script_setup_true_lang.js +4 -4
- package/dist/components/default-node.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/default-node2.js.map +1 -1
- package/dist/components/flow-comments.js +6 -0
- package/dist/components/flow-comments.js.map +1 -0
- package/dist/components/flow-comments.vue_vue_type_script_setup_true_lang.js +218 -0
- package/dist/components/flow-comments.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/flow-port.js.map +1 -1
- package/dist/components/flow-port.vue_vue_type_script_setup_true_lang.js +7 -42
- package/dist/components/flow-port.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/node-view.js.map +1 -1
- package/dist/components/node-view.vue_vue_type_script_setup_true_lang.js +2 -2
- package/dist/components/node-view.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/port-view.js +6 -0
- package/dist/components/port-view.js.map +1 -0
- package/dist/components/port-view.vue_vue_type_script_setup_true_lang.js +60 -0
- package/dist/components/port-view.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/port.js +7 -0
- package/dist/components/port.js.map +1 -0
- package/dist/context.js.map +1 -1
- package/dist/core/edge-types.js +107 -3
- package/dist/core/edge-types.js.map +1 -1
- package/dist/core/extension.js.map +1 -1
- package/dist/core/history.js +26 -0
- package/dist/core/history.js.map +1 -1
- package/dist/core/model.js.map +1 -1
- package/dist/core/node-types.js +39 -1
- package/dist/core/node-types.js.map +1 -1
- package/dist/core/transaction.js +112 -15
- package/dist/core/transaction.js.map +1 -1
- package/dist/document.js +1 -1
- package/dist/export/render.js +78 -0
- package/dist/export/render.js.map +1 -0
- package/dist/flow-editor.js.map +1 -1
- package/dist/flow-editor.vue_vue_type_script_setup_true_lang.js +484 -39
- package/dist/flow-editor.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/index.js +6 -6
- package/dist/index.js.map +1 -1
- package/dist/kit.js +1 -1
- package/dist/locale.js +21 -9
- package/dist/locale.js.map +1 -1
- package/dist/style.css +1 -1
- package/dist/style.js +1 -1
- package/dist/types/collaboration/index.d.ts +32 -4
- package/dist/types/comments.d.ts +73 -0
- package/dist/types/components/default-node.d.ts +1 -1
- package/dist/types/components/flow-comments.vue.d.ts +35 -0
- package/dist/types/components/flow-port.vue.d.ts +8 -2
- package/dist/types/components/port-view.vue.d.ts +10 -0
- package/dist/types/components/port.d.ts +7 -0
- package/dist/types/context.d.ts +54 -1
- package/dist/types/core/extension.d.ts +9 -1
- package/dist/types/core/history.d.ts +10 -0
- package/dist/types/core/menu.d.ts +5 -0
- package/dist/types/core/model.d.ts +28 -0
- package/dist/types/core/node-types.d.ts +18 -2
- package/dist/types/core/transaction.d.ts +23 -1
- package/dist/types/export/render.d.ts +27 -0
- package/dist/types/flow-editor.vue.d.ts +11 -0
- package/dist/types/index.d.ts +37 -10
- package/dist/types/locale.d.ts +11 -3
- package/dist/types/whiteboard/model.d.ts +2 -11
- package/dist/types/whiteboard/state.d.ts +2 -0
- package/dist/whiteboard/board-node.js.map +1 -1
- package/dist/whiteboard/board-node.vue_vue_type_script_setup_true_lang.js +30 -14
- package/dist/whiteboard/board-node.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/whiteboard/connector.js +5 -10
- package/dist/whiteboard/connector.js.map +1 -1
- package/dist/whiteboard/kit.js +63 -8
- package/dist/whiteboard/kit.js.map +1 -1
- package/dist/whiteboard/model.js +4 -31
- package/dist/whiteboard/model.js.map +1 -1
- package/dist/whiteboard/state.js +6 -1
- package/dist/whiteboard/state.js.map +1 -1
- package/dist/whiteboard/whiteboard-toolbar.js.map +1 -1
- package/dist/whiteboard/whiteboard-toolbar.vue_vue_type_script_setup_true_lang.js +14 -7
- package/dist/whiteboard/whiteboard-toolbar.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default-node.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createElementBlock","_createElementVNode","_createBlock","FlowPortView","_createCommentVNode","_resolveDynamicComponent","_toDisplayString","_normalizeClass","_unref","_Fragment","_renderList","_createVNode","_createTextVNode"],"sources":["../../src/components/default-node.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed } from 'vue'\nimport { portSide, type NodeViewProps } from '../core/node-types'\nimport { useFlowEditor } from '../context'\nimport type { DefaultNodeData } from './default-node'\nimport FlowPortView from './
|
|
1
|
+
{"version":3,"file":"default-node.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createElementBlock","_createElementVNode","_createBlock","FlowPortView","_createCommentVNode","_resolveDynamicComponent","_toDisplayString","_normalizeClass","_unref","_Fragment","_renderList","_createVNode","_createTextVNode"],"sources":["../../src/components/default-node.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed } from 'vue'\nimport { portSide, type NodeViewProps } from '../core/node-types'\nimport { useFlowEditor } from '../context'\nimport type { DefaultNodeData } from './default-node'\nimport FlowPortView from './port-view.vue'\n\nconst props = defineProps<NodeViewProps<DefaultNodeData>>()\nconst { messages } = useFlowEditor()\n\n// Ports on the top or bottom are placed by the editor.\nconst inputs = computed(() =>\n props.ports.filter((p) => p.kind === 'input' && portSide(p) === 'left'),\n)\nconst outputs = computed(() =>\n props.ports.filter((p) => p.kind === 'output' && portSide(p) === 'right'),\n)\n// A single unnamed input and output sit on the title row.\nconst inline = computed(\n () =>\n inputs.value.length <= 1 &&\n outputs.value.length <= 1 &&\n [...inputs.value, ...outputs.value].every((p) => !p.label),\n)\nconst rows = computed(() => {\n if (inline.value) return []\n const count = Math.max(inputs.value.length, outputs.value.length)\n return Array.from({ length: count }, (_, i) => ({\n input: inputs.value[i],\n output: outputs.value[i],\n }))\n})\n</script>\n\n<template>\n <div class=\"dou-flow-default-node\">\n <div class=\"dou-flow-default-node__head\">\n <FlowPortView v-if=\"inline && inputs[0]\" :id=\"inputs[0].id\" />\n <span v-if=\"data.icon\" class=\"dou-flow-default-node__icon\">\n <component :is=\"data.icon\" />\n </span>\n <span class=\"dou-flow-default-node__title\">{{ data.label }}</span>\n <span\n v-if=\"data.status\"\n class=\"dou-flow-default-node__status\"\n :class=\"`is-${data.status}`\"\n role=\"img\"\n :aria-label=\"messages.status[data.status]\"\n />\n <FlowPortView v-if=\"inline && outputs[0]\" :id=\"outputs[0].id\" />\n </div>\n <p v-if=\"data.description\" class=\"dou-flow-default-node__description\">\n {{ data.description }}\n </p>\n <div v-if=\"rows.length\" class=\"dou-flow-default-node__ports\">\n <div v-for=\"(row, i) in rows\" :key=\"i\" class=\"dou-flow-default-node__row\">\n <span v-if=\"row.input\" class=\"dou-flow-default-node__port is-input\">\n <FlowPortView :id=\"row.input.id\" />\n {{ row.input.label ?? messages.input }}\n </span>\n <span v-if=\"row.output\" class=\"dou-flow-default-node__port is-output\">\n {{ row.output.label ?? messages.output }}\n <FlowPortView :id=\"row.output.id\" />\n </span>\n </div>\n </div>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAOA,MAAM,QAAQ;EACd,MAAM,EAAE,aAAa,cAAc;EAGnC,MAAM,SAAS,eACb,MAAM,MAAM,QAAQ,MAAM,EAAE,SAAS,WAAW,SAAS,CAAC,MAAM,MAAM,CACxE;EACA,MAAM,UAAU,eACd,MAAM,MAAM,QAAQ,MAAM,EAAE,SAAS,YAAY,SAAS,CAAC,MAAM,OAAO,CAC1E;EAEA,MAAM,SAAS,eAEX,OAAO,MAAM,UAAU,KACvB,QAAQ,MAAM,UAAU,KACxB,CAAC,GAAG,OAAO,OAAO,GAAG,QAAQ,KAAK,CAAC,CAAC,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,GAAAC,mBASM,OAAA;MATyB,KAAK;MAAG,OAAM;K,IAC/B,IAAI,SAAhBD,UAAA,GAAAC,mBAGO,QAHP,YAGO,CAFLW,YAAmCR,mBAAA,EAApB,IAAI,IAAI,MAAM,G,qBAAMS,gBAAA,MACnCN,gBAAG,IAAI,MAAM,SAASE,MAAA,QAAA,CAAQ,CAAC,KAAK,GAAA,CAAA,C,oCAE1B,IAAI,UAAhBT,UAAA,GAAAC,mBAGO,QAHP,YAGO,CAFFY,gBAAAN,gBAAA,IAAI,OAAO,SAASE,MAAA,QAAA,CAAQ,CAAC,MAAM,IAAG,KACzC,CAAA,GAAAG,YAAoCR,mBAAA,EAArB,IAAI,IAAI,OAAO,G"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default-node2.js","names":["DefaultNode"],"sources":["../../src/components/default-node.ts"],"sourcesContent":["import { defineNodeType } from '../core/node-types'\nimport { drawCard } from '../export/draw'\nimport type { Component } from 'vue'\nimport type { FlowPortSpec } from '../core/model'\nimport DefaultNode from './default-node.vue'\n\nconst px = (value: string, fallback: number) => Number.parseFloat(value) || fallback\n\nexport interface DefaultNodeData {\n [key: string]: unknown\n /** The title. */\n label?: string\n description?: string\n icon?: Component\n status?: '
|
|
1
|
+
{"version":3,"file":"default-node2.js","names":["DefaultNode"],"sources":["../../src/components/default-node.ts"],"sourcesContent":["import { defineNodeType } from '../core/node-types'\nimport { drawCard } from '../export/draw'\nimport type { Component } from 'vue'\nimport type { FlowPortSpec } from '../core/model'\nimport DefaultNode from './default-node.vue'\n\nconst px = (value: string, fallback: number) => Number.parseFloat(value) || fallback\n\nexport interface DefaultNodeData {\n [key: string]: unknown\n /** The title. */\n label?: string\n description?: string\n icon?: Component\n status?: 'pending' | 'running' | 'done' | 'error'\n inputs?: Omit<FlowPortSpec, 'kind'>[]\n outputs?: Omit<FlowPortSpec, 'kind'>[]\n}\n\n/**\n * A titled card: an optional icon, a status dot and a description, then a\n * row per port, inputs on the left and outputs on the right. A single\n * unnamed input and output sit on the title row.\n */\nexport const defaultNode = defineNodeType<DefaultNodeData>({\n type: 'default',\n component: DefaultNode,\n ports: (node) => [\n ...(node.data?.inputs ?? []).map((port) => ({ ...port, kind: 'input' as const })),\n ...(node.data?.outputs ?? []).map((port) => ({ ...port, kind: 'output' as const })),\n ],\n defaults: () => ({ label: '' }),\n draw(node, draw) {\n const data = node.data ?? {}\n const t = draw.messages\n const parts = [drawCard(draw)]\n const head = draw.style('dou-flow-default-node__head')\n const headHeight = px(head.minHeight, 44)\n const inputs = data.inputs ?? []\n const outputs = data.outputs ?? []\n const inline =\n inputs.length <= 1 && outputs.length <= 1 && ![...inputs, ...outputs].some((p) => p.label)\n let left = 12\n let right = draw.width - 12\n if (data.icon) {\n const box = draw.style('dou-flow-default-node__icon')\n const y = (headHeight - 24) / 2\n parts.push(\n `<rect x=\"${left}\" y=\"${y}\" width=\"24\" height=\"24\" rx=\"${px(box.borderTopLeftRadius, 6)}\" fill=\"${draw.color(box.backgroundColor)}\"/>`,\n draw.icon(\n data.icon,\n { x: left + 4, y: y + 4, width: 16, height: 16 },\n draw.color(box.color),\n ),\n )\n left += 32\n }\n if (data.status) {\n const dot = draw.style(`dou-flow-default-node__status is-${data.status}`)\n parts.push(\n `<circle cx=\"${right - 4}\" cy=\"${headHeight / 2}\" r=\"4\" fill=\"${draw.color(dot.backgroundColor)}\"/>`,\n )\n right -= 16\n }\n const title = draw.style('dou-flow-default-node__title')\n parts.push(\n draw.text(\n data.label ?? '',\n { x: left, y: 0, width: Math.max(0, right - left), height: headHeight },\n { weight: title.fontWeight, valign: 'middle', nowrap: true, lineHeight: headHeight },\n ),\n )\n let y = headHeight\n if (data.description) {\n const text = draw.style('dou-flow-default-node__description')\n const lineHeight = px(text.lineHeight, 20)\n const width = draw.width - 24\n const lines = draw.text(\n data.description,\n { x: 12, y: y - 4, width, height: 1e6 },\n {\n size: px(text.fontSize, 12),\n lineHeight,\n color: draw.color(text.color),\n },\n )\n parts.push(lines)\n y += (lines.match(/<tspan/g)?.length ?? 1) * lineHeight + 12 - 4\n }\n if (!inline) {\n const rows = draw.style('dou-flow-default-node__ports')\n const row = draw.style('dou-flow-default-node__row')\n parts.push(\n `<rect x=\"1\" y=\"${y}\" width=\"${draw.width - 2}\" height=\"1\" fill=\"${draw.color(rows.borderTopColor)}\"/>`,\n )\n y += 1 + px(rows.paddingTop, 3)\n const height = px(row.height, 28)\n const size = px(row.fontSize, 12)\n const color = draw.color(row.color)\n const half = (draw.width - 24) / 2\n for (let i = 0; i < Math.max(inputs.length, outputs.length); i++) {\n const input = inputs[i]\n const output = outputs[i]\n const box = (x: number) => ({ x, y: y + i * height, width: half - 4, height })\n const options = { size, color, valign: 'middle' as const, nowrap: true, lineHeight: height }\n if (input) parts.push(draw.text(input.label ?? t.input, box(12), options))\n if (output)\n parts.push(\n draw.text(output.label ?? t.output, box(draw.width / 2 + 4), {\n ...options,\n align: 'end',\n }),\n )\n }\n }\n for (const id of draw.ports.keys()) parts.push(draw.port(id))\n return parts.join('')\n },\n})\n"],"mappings":";;;;AAMA,IAAM,MAAM,OAAe,aAAqB,OAAO,WAAW,KAAK,KAAK;;;;;;AAkB5E,IAAa,cAAc,eAAgC;CACzD,MAAM;CACN,WAAWA;CACX,QAAQ,SAAS,CACf,IAAI,KAAK,MAAM,UAAU,CAAC,EAAA,CAAG,KAAK,UAAU;EAAE,GAAG;EAAM,MAAM;CAAiB,EAAE,GAChF,IAAI,KAAK,MAAM,WAAW,CAAC,EAAA,CAAG,KAAK,UAAU;EAAE,GAAG;EAAM,MAAM;CAAkB,EAAE,CACpF;CACA,iBAAiB,EAAE,OAAO,GAAG;CAC7B,KAAK,MAAM,MAAM;EACf,MAAM,OAAO,KAAK,QAAQ,CAAC;EAC3B,MAAM,IAAI,KAAK;EACf,MAAM,QAAQ,CAAC,SAAS,IAAI,CAAC;EAE7B,MAAM,aAAa,GADN,KAAK,MAAM,6BACF,CAAA,CAAK,WAAW,EAAE;EACxC,MAAM,S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MAAM,MAAM,KAAK,MAAM,KAAK,GAAG,MAAM,KAAK,KAAK,KAAK,EAAE,CAAC;EAC5D,OAAO,MAAM,KAAK,EAAE;CACtB;AACF,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import flow_comments_vue_vue_type_script_setup_true_lang_default from "./flow-comments.vue_vue_type_script_setup_true_lang.js";
|
|
2
|
+
// src/components/flow-comments.vue
|
|
3
|
+
var flow_comments_default = flow_comments_vue_vue_type_script_setup_true_lang_default;
|
|
4
|
+
export { flow_comments_default as default };
|
|
5
|
+
|
|
6
|
+
//# sourceMappingURL=flow-comments.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flow-comments.js","names":["_sfc_main"],"sources":["../../src/components/flow-comments.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { MessageCircleIcon } from '@dou-ui/icons'\nimport {\n DouCommentThread,\n useFloating,\n useLayer,\n useZIndex,\n type CommentThread,\n type VirtualElement,\n} from 'dou-ui'\nimport { computed, nextTick, shallowRef, useTemplateRef, watch } from 'vue'\nimport type { FlowComments } from '../comments'\nimport type { FlowCommentAnchor } from '../context'\nimport { format, type FlowMessages } from '../locale'\n\n/*\n * The comments over the canvas: a marker on each node and edge with open\n * threads, and the card with the threads of the one opened, or the box\n * for a thread being started.\n */\n\nexport interface FlowCommentMarker {\n key: string\n anchor: FlowCommentAnchor\n /** The open threads there, oldest first, counted on the marker; empty for a thread being started. */\n threads: string[]\n /** The threads its card shows: the open ones, and a resolved one opened from outside. */\n shown: string[]\n /** A thread is being started here. */\n pending: boolean\n /** Where it goes, in px within the editor. */\n x: number\n y: number\n /** Above an edge's label: a finger's target keeps clear of the label. */\n lifted: boolean\n /**\n * A pin on a point of a node: its place among the open pins there, from\n * 1; `0` for one being started or a resolved one opened from outside.\n */\n number?: number\n /** The name of the node it is on, for screen readers. */\n node?: string\n}\n\nconst props = defineProps<{\n comments: FlowComments\n markers: FlowCommentMarker[]\n messages: FlowMessages\n /** Gives the focus back to what a thread is about, after the card closes. */\n restore: (anchor: FlowCommentAnchor | null) => void\n}>()\n\nconst { comments } = props\nconst panel = shallowRef<HTMLElement | null>(null)\nconst markerEls = new Map<string, HTMLElement>()\n\n/** The marker the card belongs to: the active thread's, or the one being started. */\nconst current = computed<FlowCommentMarker | null>(() => {\n if (comments.pending.value) return props.markers.find((m) => m.pending) ?? null\n const id = comments.active.value\n return (id && props.markers.find((m) => m.shown.includes(id))) || null\n})\n\n/** The threads the card shows: every open one there, or the active one opened from elsewhere. */\nconst shown = computed<CommentThread[]>(() => {\n const marker = current.value\n if (!marker || comments.pending.value) return []\n const byId = new Map(comments.threads.value.map((t) => [t.id, t]))\n return marker.shown.flatMap((id) => byId.get(id) ?? [])\n})\n\nconst open = computed(() => !!current.value)\n\nconst layer = shallowRef<HTMLElement | null>(null)\n/** The marker has been panned out of the editor: the card waits, hidden, until it is back. */\nconst away = computed(() => {\n const marker = current.value\n const el = layer.value\n if (!marker || !el) return false\n return marker.x < 0 || marker.y < 0 || marker.x > el.clientWidth || marker.y > el.clientHeight\n})\n\n// Hiding the card drops the focus in it: give it back when the card returns.\nlet awayFocus: HTMLElement | null = null\nwatch(away, async (now) => {\n if (now) {\n const el = document.activeElement\n awayFocus = el instanceof HTMLElement && panel.value?.contains(el) ? el : null\n return\n }\n const el = awayFocus\n awayFocus = null\n await nextTick()\n const at = document.activeElement\n if (el?.isConnected && (!at || at === document.body)) el.focus({ preventScroll: true })\n})\n\n/** Narrower than this, the card can't sit beside a node: it goes under (or over) the whole node. */\nconst NARROW = 600\n\nconst anchor: VirtualElement = {\n getBoundingClientRect() {\n const marker = current.value\n const el = marker && markerEls.get(marker.key)\n if (!el) return new DOMRect()\n const rect = el.getBoundingClientRect()\n const root = layer.value\n if (!root || root.clientWidth >= NARROW || !('node' in marker.anchor)) return rect\n // on a phone, the card would cover the node it is about\n const node = root\n .closest('.dou-flow-editor')\n ?.querySelector(`[data-node-id=\"${CSS.escape(marker.anchor.node)}\"]`)\n if (!node) return rect\n const box = node.getBoundingClientRect()\n const left = Math.min(rect.left, box.left)\n const top = Math.min(rect.top, box.top)\n return new DOMRect(\n left,\n top,\n Math.max(rect.right, box.right) - left,\n Math.max(rect.bottom, box.bottom) - top,\n )\n },\n}\n\nconst { style, placement, update } = useFloating(() => (open.value ? anchor : null), panel, {\n open,\n placement: 'bottom-start',\n offset: 6,\n})\nconst { next } = useZIndex()\nconst zIndex = shallowRef(0)\nwatch(open, (value) => value && (zIndex.value = next()), { immediate: true })\n// follows its marker as the canvas pans and zooms\nwatch(\n () => current.value && [current.value.x, current.value.y],\n () => open.value && void nextTick(update),\n)\n\nlet lastAnchor: FlowCommentAnchor | null = null\nwatch(current, (marker) => marker && (lastAnchor = marker.anchor), { immediate: true })\n\nconst focusLost = () => {\n const el = document.activeElement\n return !el || el === document.body || !!panel.value?.contains(el)\n}\n\nfunction close() {\n const refocus = focusLost()\n comments.close()\n if (refocus) props.restore(lastAnchor)\n}\n\nuseLayer({\n open,\n elements: () => [panel.value, ...markerEls.values()],\n onEscape: () => close(),\n onOutside: () => comments.close(),\n})\n\nconst views = useTemplateRef<InstanceType<typeof DouCommentThread>[]>('views')\n// asked to (the keyboard shortcut, or a thread just started): the reply box\nwatch(\n () => comments.focusRequest.value,\n async () => {\n await nextTick()\n await nextTick()\n const id = comments.active.value\n const index = shown.value.findIndex((t) => t.id === id)\n views.value?.[Math.max(0, index)]?.focus()\n },\n)\n\n// a thread resolved or removed from the card: back to what it is about,\n// once the card is gone\nfunction onClosed() {\n const el = document.activeElement\n if (!el || el === document.body) props.restore(lastAnchor)\n}\n\n/**\n * When the thread being started was opened. A tap that starts one (the\n * whiteboard's comment tool) is followed by the click the browser makes\n * from it, which lands on the new pin just drawn under the finger: that\n * one doesn't close it.\n */\nlet startedAt = -Infinity\nwatch(\n () => comments.pending.value,\n (now) => now && (startedAt = performance.now()),\n)\n\nfunction press(marker: FlowCommentMarker, event: MouseEvent) {\n if (marker.pending && performance.now() - startedAt < 500) return\n if (current.value?.key === marker.key) return comments.close()\n // pressed from the keyboard (no clicks counted): straight into the reply box;\n // a click or tap only shows the threads, without bringing up a phone's keyboard\n const focus = event.detail === 0\n const [first] = marker.threads\n if (first) comments.show(first, focus)\n else comments.start(marker.anchor, focus)\n}\n\nconst label = (marker: FlowCommentMarker) =>\n marker.number\n ? format(props.messages.commentPin, { number: marker.number, node: marker.node ?? '' })\n : marker.threads.length\n ? format(props.messages.comments, { count: marker.threads.length })\n : props.messages.comment\n</script>\n\n<template>\n <div ref=\"layer\" class=\"dou-flow-editor__comments\">\n <button\n v-for=\"marker in markers\"\n :key=\"marker.key\"\n :ref=\"\n (el) => (el ? markerEls.set(marker.key, el as HTMLElement) : markerEls.delete(marker.key))\n \"\n type=\"button\"\n class=\"dou-flow-editor__comment\"\n :class=\"{\n 'is-active': current?.key === marker.key,\n 'is-new': !marker.threads.length,\n 'is-node': 'node' in marker.anchor && marker.number === undefined,\n 'is-pin': marker.number !== undefined,\n 'is-lifted': marker.lifted,\n }\"\n :style=\"{ translate: `${marker.x}px ${marker.y}px` }\"\n :aria-label=\"label(marker)\"\n :aria-expanded=\"current?.key === marker.key\"\n :data-thread=\"marker.threads[0]\"\n @click=\"press(marker, $event)\"\n >\n <span v-if=\"marker.number\" class=\"dou-flow-editor__comment-count\">{{ marker.number }}</span>\n <template v-else>\n <MessageCircleIcon aria-hidden=\"true\" />\n <span\n v-if=\"marker.number === undefined && marker.threads.length > 1\"\n class=\"dou-flow-editor__comment-count\"\n >{{ marker.threads.length }}</span\n >\n </template>\n </button>\n </div>\n <Transition name=\"dou-floating\" @after-leave=\"onClosed\">\n <div\n v-if=\"open\"\n ref=\"panel\"\n class=\"dou-floating dou-flow-editor__comment-card\"\n :class=\"{ 'is-away': away }\"\n role=\"dialog\"\n :aria-label=\"messages.comment\"\n :style=\"[style, { zIndex }]\"\n :data-placement=\"placement\"\n >\n <template v-if=\"comments.pending.value\">\n <DouCommentThread\n ref=\"views\"\n key=\"new\"\n :thread=\"null\"\n :author=\"comments.author.value\"\n :autofocus=\"comments.pendingFocus.value\"\n @action=\"comments.apply\"\n @cancel=\"close\"\n />\n </template>\n <template v-else>\n <DouCommentThread\n v-for=\"thread in shown\"\n :key=\"thread.id\"\n ref=\"views\"\n :thread=\"thread\"\n :author=\"comments.author.value\"\n :readonly=\"!comments.writable.value\"\n @action=\"comments.apply\"\n @cancel=\"close\"\n />\n </template>\n </div>\n </Transition>\n</template>\n"],"mappings":""}
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import { format } from "../locale.js";
|
|
2
|
+
import { DouCommentThread, useFloating, useLayer, useZIndex } from "dou-ui";
|
|
3
|
+
import { Fragment, Transition, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createVNode, defineComponent, nextTick, normalizeClass, normalizeStyle, openBlock, renderList, shallowRef, toDisplayString, unref, useTemplateRef, watch, withCtx } from "vue";
|
|
4
|
+
import { MessageCircleIcon } from "@dou-ui/icons";
|
|
5
|
+
// src/components/flow-comments.vue?vue&type=script&setup=true&lang.ts
|
|
6
|
+
var _hoisted_1 = [
|
|
7
|
+
"aria-label",
|
|
8
|
+
"aria-expanded",
|
|
9
|
+
"data-thread",
|
|
10
|
+
"onClick"
|
|
11
|
+
];
|
|
12
|
+
var _hoisted_2 = {
|
|
13
|
+
key: 0,
|
|
14
|
+
class: "dou-flow-editor__comment-count"
|
|
15
|
+
};
|
|
16
|
+
var _hoisted_3 = {
|
|
17
|
+
key: 0,
|
|
18
|
+
class: "dou-flow-editor__comment-count"
|
|
19
|
+
};
|
|
20
|
+
var _hoisted_4 = ["aria-label", "data-placement"];
|
|
21
|
+
var NARROW = 600;
|
|
22
|
+
var flow_comments_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComponent({
|
|
23
|
+
__name: "flow-comments",
|
|
24
|
+
props: {
|
|
25
|
+
comments: {},
|
|
26
|
+
markers: {},
|
|
27
|
+
messages: {},
|
|
28
|
+
restore: { type: Function }
|
|
29
|
+
},
|
|
30
|
+
setup(__props) {
|
|
31
|
+
const props = __props;
|
|
32
|
+
const { comments } = props;
|
|
33
|
+
const panel = shallowRef(null);
|
|
34
|
+
const markerEls = /* @__PURE__ */ new Map();
|
|
35
|
+
/** The marker the card belongs to: the active thread's, or the one being started. */
|
|
36
|
+
const current = computed(() => {
|
|
37
|
+
if (comments.pending.value) return props.markers.find((m) => m.pending) ?? null;
|
|
38
|
+
const id = comments.active.value;
|
|
39
|
+
return id && props.markers.find((m) => m.shown.includes(id)) || null;
|
|
40
|
+
});
|
|
41
|
+
/** The threads the card shows: every open one there, or the active one opened from elsewhere. */
|
|
42
|
+
const shown = computed(() => {
|
|
43
|
+
const marker = current.value;
|
|
44
|
+
if (!marker || comments.pending.value) return [];
|
|
45
|
+
const byId = new Map(comments.threads.value.map((t) => [t.id, t]));
|
|
46
|
+
return marker.shown.flatMap((id) => byId.get(id) ?? []);
|
|
47
|
+
});
|
|
48
|
+
const open = computed(() => !!current.value);
|
|
49
|
+
const layer = shallowRef(null);
|
|
50
|
+
/** The marker has been panned out of the editor: the card waits, hidden, until it is back. */
|
|
51
|
+
const away = computed(() => {
|
|
52
|
+
const marker = current.value;
|
|
53
|
+
const el = layer.value;
|
|
54
|
+
if (!marker || !el) return false;
|
|
55
|
+
return marker.x < 0 || marker.y < 0 || marker.x > el.clientWidth || marker.y > el.clientHeight;
|
|
56
|
+
});
|
|
57
|
+
let awayFocus = null;
|
|
58
|
+
watch(away, async (now) => {
|
|
59
|
+
if (now) {
|
|
60
|
+
const el = document.activeElement;
|
|
61
|
+
awayFocus = el instanceof HTMLElement && panel.value?.contains(el) ? el : null;
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
const el = awayFocus;
|
|
65
|
+
awayFocus = null;
|
|
66
|
+
await nextTick();
|
|
67
|
+
const at = document.activeElement;
|
|
68
|
+
if (el?.isConnected && (!at || at === document.body)) el.focus({ preventScroll: true });
|
|
69
|
+
});
|
|
70
|
+
/** Narrower than this, the card can't sit beside a node: it goes under (or over) the whole node. */
|
|
71
|
+
const anchor = { getBoundingClientRect() {
|
|
72
|
+
const marker = current.value;
|
|
73
|
+
const el = marker && markerEls.get(marker.key);
|
|
74
|
+
if (!el) return new DOMRect();
|
|
75
|
+
const rect = el.getBoundingClientRect();
|
|
76
|
+
const root = layer.value;
|
|
77
|
+
if (!root || root.clientWidth >= NARROW || !("node" in marker.anchor)) return rect;
|
|
78
|
+
const node = root.closest(".dou-flow-editor")?.querySelector(`[data-node-id="${CSS.escape(marker.anchor.node)}"]`);
|
|
79
|
+
if (!node) return rect;
|
|
80
|
+
const box = node.getBoundingClientRect();
|
|
81
|
+
const left = Math.min(rect.left, box.left);
|
|
82
|
+
const top = Math.min(rect.top, box.top);
|
|
83
|
+
return new DOMRect(left, top, Math.max(rect.right, box.right) - left, Math.max(rect.bottom, box.bottom) - top);
|
|
84
|
+
} };
|
|
85
|
+
const { style, placement, update } = useFloating(() => open.value ? anchor : null, panel, {
|
|
86
|
+
open,
|
|
87
|
+
placement: "bottom-start",
|
|
88
|
+
offset: 6
|
|
89
|
+
});
|
|
90
|
+
const { next } = useZIndex();
|
|
91
|
+
const zIndex = shallowRef(0);
|
|
92
|
+
watch(open, (value) => value && (zIndex.value = next()), { immediate: true });
|
|
93
|
+
watch(() => current.value && [current.value.x, current.value.y], () => open.value && void nextTick(update));
|
|
94
|
+
let lastAnchor = null;
|
|
95
|
+
watch(current, (marker) => marker && (lastAnchor = marker.anchor), { immediate: true });
|
|
96
|
+
const focusLost = () => {
|
|
97
|
+
const el = document.activeElement;
|
|
98
|
+
return !el || el === document.body || !!panel.value?.contains(el);
|
|
99
|
+
};
|
|
100
|
+
function close() {
|
|
101
|
+
const refocus = focusLost();
|
|
102
|
+
comments.close();
|
|
103
|
+
if (refocus) props.restore(lastAnchor);
|
|
104
|
+
}
|
|
105
|
+
useLayer({
|
|
106
|
+
open,
|
|
107
|
+
elements: () => [panel.value, ...markerEls.values()],
|
|
108
|
+
onEscape: () => close(),
|
|
109
|
+
onOutside: () => comments.close()
|
|
110
|
+
});
|
|
111
|
+
const views = useTemplateRef("views");
|
|
112
|
+
watch(() => comments.focusRequest.value, async () => {
|
|
113
|
+
await nextTick();
|
|
114
|
+
await nextTick();
|
|
115
|
+
const id = comments.active.value;
|
|
116
|
+
const index = shown.value.findIndex((t) => t.id === id);
|
|
117
|
+
views.value?.[Math.max(0, index)]?.focus();
|
|
118
|
+
});
|
|
119
|
+
function onClosed() {
|
|
120
|
+
const el = document.activeElement;
|
|
121
|
+
if (!el || el === document.body) props.restore(lastAnchor);
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* When the thread being started was opened. A tap that starts one (the
|
|
125
|
+
* whiteboard's comment tool) is followed by the click the browser makes
|
|
126
|
+
* from it, which lands on the new pin just drawn under the finger: that
|
|
127
|
+
* one doesn't close it.
|
|
128
|
+
*/
|
|
129
|
+
let startedAt = -Infinity;
|
|
130
|
+
watch(() => comments.pending.value, (now) => now && (startedAt = performance.now()));
|
|
131
|
+
function press(marker, event) {
|
|
132
|
+
if (marker.pending && performance.now() - startedAt < 500) return;
|
|
133
|
+
if (current.value?.key === marker.key) return comments.close();
|
|
134
|
+
const focus = event.detail === 0;
|
|
135
|
+
const [first] = marker.threads;
|
|
136
|
+
if (first) comments.show(first, focus);
|
|
137
|
+
else comments.start(marker.anchor, focus);
|
|
138
|
+
}
|
|
139
|
+
const label = (marker) => marker.number ? format(props.messages.commentPin, {
|
|
140
|
+
number: marker.number,
|
|
141
|
+
node: marker.node ?? ""
|
|
142
|
+
}) : marker.threads.length ? format(props.messages.comments, { count: marker.threads.length }) : props.messages.comment;
|
|
143
|
+
return (_ctx, _cache) => {
|
|
144
|
+
return openBlock(), createElementBlock(Fragment, null, [createElementVNode("div", {
|
|
145
|
+
ref_key: "layer",
|
|
146
|
+
ref: layer,
|
|
147
|
+
class: "dou-flow-editor__comments"
|
|
148
|
+
}, [(openBlock(true), createElementBlock(Fragment, null, renderList(__props.markers, (marker) => {
|
|
149
|
+
return openBlock(), createElementBlock("button", {
|
|
150
|
+
key: marker.key,
|
|
151
|
+
ref_for: true,
|
|
152
|
+
ref: (el) => el ? unref(markerEls).set(marker.key, el) : unref(markerEls).delete(marker.key),
|
|
153
|
+
type: "button",
|
|
154
|
+
class: normalizeClass(["dou-flow-editor__comment", {
|
|
155
|
+
"is-active": current.value?.key === marker.key,
|
|
156
|
+
"is-new": !marker.threads.length,
|
|
157
|
+
"is-node": "node" in marker.anchor && marker.number === void 0,
|
|
158
|
+
"is-pin": marker.number !== void 0,
|
|
159
|
+
"is-lifted": marker.lifted
|
|
160
|
+
}]),
|
|
161
|
+
style: normalizeStyle({ translate: `${marker.x}px ${marker.y}px` }),
|
|
162
|
+
"aria-label": label(marker),
|
|
163
|
+
"aria-expanded": current.value?.key === marker.key,
|
|
164
|
+
"data-thread": marker.threads[0],
|
|
165
|
+
onClick: ($event) => press(marker, $event)
|
|
166
|
+
}, [marker.number ? (openBlock(), createElementBlock("span", _hoisted_2, toDisplayString(marker.number), 1)) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [createVNode(unref(MessageCircleIcon), { "aria-hidden": "true" }), marker.number === void 0 && marker.threads.length > 1 ? (openBlock(), createElementBlock("span", _hoisted_3, toDisplayString(marker.threads.length), 1)) : createCommentVNode("", true)], 64))], 14, _hoisted_1);
|
|
167
|
+
}), 128))], 512), createVNode(Transition, {
|
|
168
|
+
name: "dou-floating",
|
|
169
|
+
onAfterLeave: onClosed
|
|
170
|
+
}, {
|
|
171
|
+
default: withCtx(() => [open.value ? (openBlock(), createElementBlock("div", {
|
|
172
|
+
key: 0,
|
|
173
|
+
ref_key: "panel",
|
|
174
|
+
ref: panel,
|
|
175
|
+
class: normalizeClass(["dou-floating dou-flow-editor__comment-card", { "is-away": away.value }]),
|
|
176
|
+
role: "dialog",
|
|
177
|
+
"aria-label": __props.messages.comment,
|
|
178
|
+
style: normalizeStyle([unref(style), { zIndex: zIndex.value }]),
|
|
179
|
+
"data-placement": unref(placement)
|
|
180
|
+
}, [unref(comments).pending.value ? (openBlock(), createBlock(unref(DouCommentThread), {
|
|
181
|
+
ref_key: "views",
|
|
182
|
+
ref: views,
|
|
183
|
+
key: "new",
|
|
184
|
+
thread: null,
|
|
185
|
+
author: unref(comments).author.value,
|
|
186
|
+
autofocus: unref(comments).pendingFocus.value,
|
|
187
|
+
onAction: unref(comments).apply,
|
|
188
|
+
onCancel: close
|
|
189
|
+
}, null, 8, [
|
|
190
|
+
"author",
|
|
191
|
+
"autofocus",
|
|
192
|
+
"onAction"
|
|
193
|
+
])) : (openBlock(true), createElementBlock(Fragment, { key: 1 }, renderList(shown.value, (thread) => {
|
|
194
|
+
return openBlock(), createBlock(unref(DouCommentThread), {
|
|
195
|
+
key: thread.id,
|
|
196
|
+
ref_for: true,
|
|
197
|
+
ref_key: "views",
|
|
198
|
+
ref: views,
|
|
199
|
+
thread,
|
|
200
|
+
author: unref(comments).author.value,
|
|
201
|
+
readonly: !unref(comments).writable.value,
|
|
202
|
+
onAction: unref(comments).apply,
|
|
203
|
+
onCancel: close
|
|
204
|
+
}, null, 8, [
|
|
205
|
+
"thread",
|
|
206
|
+
"author",
|
|
207
|
+
"readonly",
|
|
208
|
+
"onAction"
|
|
209
|
+
]);
|
|
210
|
+
}), 128))], 14, _hoisted_4)) : createCommentVNode("", true)]),
|
|
211
|
+
_: 1
|
|
212
|
+
})], 64);
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
export { flow_comments_vue_vue_type_script_setup_true_lang_default as default };
|
|
217
|
+
|
|
218
|
+
//# sourceMappingURL=flow-comments.vue_vue_type_script_setup_true_lang.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flow-comments.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createElementBlock","_Fragment","_createElementVNode","_renderList","_unref","_normalizeClass","_normalizeStyle","_toDisplayString","_createVNode","_createCommentVNode","_Transition","_withCtx","_createBlock"],"sources":["../../src/components/flow-comments.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { MessageCircleIcon } from '@dou-ui/icons'\nimport {\n DouCommentThread,\n useFloating,\n useLayer,\n useZIndex,\n type CommentThread,\n type VirtualElement,\n} from 'dou-ui'\nimport { computed, nextTick, shallowRef, useTemplateRef, watch } from 'vue'\nimport type { FlowComments } from '../comments'\nimport type { FlowCommentAnchor } from '../context'\nimport { format, type FlowMessages } from '../locale'\n\n/*\n * The comments over the canvas: a marker on each node and edge with open\n * threads, and the card with the threads of the one opened, or the box\n * for a thread being started.\n */\n\nexport interface FlowCommentMarker {\n key: string\n anchor: FlowCommentAnchor\n /** The open threads there, oldest first, counted on the marker; empty for a thread being started. */\n threads: string[]\n /** The threads its card shows: the open ones, and a resolved one opened from outside. */\n shown: string[]\n /** A thread is being started here. */\n pending: boolean\n /** Where it goes, in px within the editor. */\n x: number\n y: number\n /** Above an edge's label: a finger's target keeps clear of the label. */\n lifted: boolean\n /**\n * A pin on a point of a node: its place among the open pins there, from\n * 1; `0` for one being started or a resolved one opened from outside.\n */\n number?: number\n /** The name of the node it is on, for screen readers. */\n node?: string\n}\n\nconst props = defineProps<{\n comments: FlowComments\n markers: FlowCommentMarker[]\n messages: FlowMessages\n /** Gives the focus back to what a thread is about, after the card closes. */\n restore: (anchor: FlowCommentAnchor | null) => void\n}>()\n\nconst { comments } = props\nconst panel = shallowRef<HTMLElement | null>(null)\nconst markerEls = new Map<string, HTMLElement>()\n\n/** The marker the card belongs to: the active thread's, or the one being started. */\nconst current = computed<FlowCommentMarker | null>(() => {\n if (comments.pending.value) return props.markers.find((m) => m.pending) ?? null\n const id = comments.active.value\n return (id && props.markers.find((m) => m.shown.includes(id))) || null\n})\n\n/** The threads the card shows: every open one there, or the active one opened from elsewhere. */\nconst shown = computed<CommentThread[]>(() => {\n const marker = current.value\n if (!marker || comments.pending.value) return []\n const byId = new Map(comments.threads.value.map((t) => [t.id, t]))\n return marker.shown.flatMap((id) => byId.get(id) ?? [])\n})\n\nconst open = computed(() => !!current.value)\n\nconst layer = shallowRef<HTMLElement | null>(null)\n/** The marker has been panned out of the editor: the card waits, hidden, until it is back. */\nconst away = computed(() => {\n const marker = current.value\n const el = layer.value\n if (!marker || !el) return false\n return marker.x < 0 || marker.y < 0 || marker.x > el.clientWidth || marker.y > el.clientHeight\n})\n\n// Hiding the card drops the focus in it: give it back when the card returns.\nlet awayFocus: HTMLElement | null = null\nwatch(away, async (now) => {\n if (now) {\n const el = document.activeElement\n awayFocus = el instanceof HTMLElement && panel.value?.contains(el) ? el : null\n return\n }\n const el = awayFocus\n awayFocus = null\n await nextTick()\n const at = document.activeElement\n if (el?.isConnected && (!at || at === document.body)) el.focus({ preventScroll: true })\n})\n\n/** Narrower than this, the card can't sit beside a node: it goes under (or over) the whole node. */\nconst NARROW = 600\n\nconst anchor: VirtualElement = {\n getBoundingClientRect() {\n const marker = current.value\n const el = marker && markerEls.get(marker.key)\n if (!el) return new DOMRect()\n const rect = el.getBoundingClientRect()\n const root = layer.value\n if (!root || root.clientWidth >= NARROW || !('node' in marker.anchor)) return rect\n // on a phone, the card would cover the node it is about\n const node = root\n .closest('.dou-flow-editor')\n ?.querySelector(`[data-node-id=\"${CSS.escape(marker.anchor.node)}\"]`)\n if (!node) return rect\n const box = node.getBoundingClientRect()\n const left = Math.min(rect.left, box.left)\n const top = Math.min(rect.top, box.top)\n return new DOMRect(\n left,\n top,\n Math.max(rect.right, box.right) - left,\n Math.max(rect.bottom, box.bottom) - top,\n )\n },\n}\n\nconst { style, placement, update } = useFloating(() => (open.value ? anchor : null), panel, {\n open,\n placement: 'bottom-start',\n offset: 6,\n})\nconst { next } = useZIndex()\nconst zIndex = shallowRef(0)\nwatch(open, (value) => value && (zIndex.value = next()), { immediate: true })\n// follows its marker as the canvas pans and zooms\nwatch(\n () => current.value && [current.value.x, current.value.y],\n () => open.value && void nextTick(update),\n)\n\nlet lastAnchor: FlowCommentAnchor | null = null\nwatch(current, (marker) => marker && (lastAnchor = marker.anchor), { immediate: true })\n\nconst focusLost = () => {\n const el = document.activeElement\n return !el || el === document.body || !!panel.value?.contains(el)\n}\n\nfunction close() {\n const refocus = focusLost()\n comments.close()\n if (refocus) props.restore(lastAnchor)\n}\n\nuseLayer({\n open,\n elements: () => [panel.value, ...markerEls.values()],\n onEscape: () => close(),\n onOutside: () => comments.close(),\n})\n\nconst views = useTemplateRef<InstanceType<typeof DouCommentThread>[]>('views')\n// asked to (the keyboard shortcut, or a thread just started): the reply box\nwatch(\n () => comments.focusRequest.value,\n async () => {\n await nextTick()\n await nextTick()\n const id = comments.active.value\n const index = shown.value.findIndex((t) => t.id === id)\n views.value?.[Math.max(0, index)]?.focus()\n },\n)\n\n// a thread resolved or removed from the card: back to what it is about,\n// once the card is gone\nfunction onClosed() {\n const el = document.activeElement\n if (!el || el === document.body) props.restore(lastAnchor)\n}\n\n/**\n * When the thread being started was opened. A tap that starts one (the\n * whiteboard's comment tool) is followed by the click the browser makes\n * from it, which lands on the new pin just drawn under the finger: that\n * one doesn't close it.\n */\nlet startedAt = -Infinity\nwatch(\n () => comments.pending.value,\n (now) => now && (startedAt = performance.now()),\n)\n\nfunction press(marker: FlowCommentMarker, event: MouseEvent) {\n if (marker.pending && performance.now() - startedAt < 500) return\n if (current.value?.key === marker.key) return comments.close()\n // pressed from the keyboard (no clicks counted): straight into the reply box;\n // a click or tap only shows the threads, without bringing up a phone's keyboard\n const focus = event.detail === 0\n const [first] = marker.threads\n if (first) comments.show(first, focus)\n else comments.start(marker.anchor, focus)\n}\n\nconst label = (marker: FlowCommentMarker) =>\n marker.number\n ? format(props.messages.commentPin, { number: marker.number, node: marker.node ?? '' })\n : marker.threads.length\n ? format(props.messages.comments, { count: marker.threads.length })\n : props.messages.comment\n</script>\n\n<template>\n <div ref=\"layer\" class=\"dou-flow-editor__comments\">\n <button\n v-for=\"marker in markers\"\n :key=\"marker.key\"\n :ref=\"\n (el) => (el ? markerEls.set(marker.key, el as HTMLElement) : markerEls.delete(marker.key))\n \"\n type=\"button\"\n class=\"dou-flow-editor__comment\"\n :class=\"{\n 'is-active': current?.key === marker.key,\n 'is-new': !marker.threads.length,\n 'is-node': 'node' in marker.anchor && marker.number === undefined,\n 'is-pin': marker.number !== undefined,\n 'is-lifted': marker.lifted,\n }\"\n :style=\"{ translate: `${marker.x}px ${marker.y}px` }\"\n :aria-label=\"label(marker)\"\n :aria-expanded=\"current?.key === marker.key\"\n :data-thread=\"marker.threads[0]\"\n @click=\"press(marker, $event)\"\n >\n <span v-if=\"marker.number\" class=\"dou-flow-editor__comment-count\">{{ marker.number }}</span>\n <template v-else>\n <MessageCircleIcon aria-hidden=\"true\" />\n <span\n v-if=\"marker.number === undefined && marker.threads.length > 1\"\n class=\"dou-flow-editor__comment-count\"\n >{{ marker.threads.length }}</span\n >\n </template>\n </button>\n </div>\n <Transition name=\"dou-floating\" @after-leave=\"onClosed\">\n <div\n v-if=\"open\"\n ref=\"panel\"\n class=\"dou-floating dou-flow-editor__comment-card\"\n :class=\"{ 'is-away': away }\"\n role=\"dialog\"\n :aria-label=\"messages.comment\"\n :style=\"[style, { zIndex }]\"\n :data-placement=\"placement\"\n >\n <template v-if=\"comments.pending.value\">\n <DouCommentThread\n ref=\"views\"\n key=\"new\"\n :thread=\"null\"\n :author=\"comments.author.value\"\n :autofocus=\"comments.pendingFocus.value\"\n @action=\"comments.apply\"\n @cancel=\"close\"\n />\n </template>\n <template v-else>\n <DouCommentThread\n v-for=\"thread in shown\"\n :key=\"thread.id\"\n ref=\"views\"\n :thread=\"thread\"\n :author=\"comments.author.value\"\n :readonly=\"!comments.writable.value\"\n @action=\"comments.apply\"\n @cancel=\"close\"\n />\n </template>\n </div>\n </Transition>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAkGA,IAAM,SAAS;;;;;;;;;;EAtDf,MAAM,QAAQ;EAQd,MAAM,EAAE,aAAa;EACrB,MAAM,QAAQ,WAA+B,IAAI;EACjD,MAAM,4BAAY,IAAI,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A/BA,SAAA;KAAJ,KAAI;KACJ,OAAKK,eAAA,CAAC,8CAA4C,EAAA,WAC7B,KAAA,MAAI,CAAA,CAAA;KACzB,MAAK;KACJ,cAAY,QAAA,SAAS;KACrB,OAAKC,eAAA,CAAGF,MAAA,KAAA,GAAK,EAAA,QAAI,OAAA,MAAM,CAAA,CAAA;KACvB,kBAAgBA,MAAA,SAAA;I,IAEDA,MAAA,QAAA,CAAQ,CAAC,QAAQ,SAC/BL,UAAA,GAAAa,YAQER,MAAA,gBAAA,GAAA;KAPI,SAAA;KAAJ,KAAI;KACJ,KAAI;KACH,QAAQ;KACR,QAAQA,MAAA,QAAA,CAAQ,CAAC,OAAO;KACxB,WAAWA,MAAA,QAAA,CAAQ,CAAC,aAAa;KACjC,UAAQA,MAAA,QAAA,CAAQ,CAAC;KACjB,UAAQ;;;;;I,OAIXL,UAAA,IAAA,GAAAC,mBASEC,UAAA,EAAA,KAAA,EAAA,GAAAE,WARiB,MAAA,QAAV,WAAM;KADf,OAAAJ,UAAA,GAAAa,YASER,MAAA,gBAAA,GAAA;MAPC,KAAK,OAAO;;MACT,SAAA;MAAJ,KAAI;MACK;MACR,QAAQA,MAAA,QAAA,CAAQ,CAAC,OAAO;MACxB,UAAQ,CAAGA,MAAA,QAAA,CAAQ,CAAC,SAAS;MAC7B,UAAQA,MAAA,QAAA,CAAQ,CAAC;MACjB,UAAQ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flow-port.js","names":["_sfc_main"],"sources":["../../src/components/flow-port.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport
|
|
1
|
+
{"version":3,"file":"flow-port.js","names":["_sfc_main"],"sources":["../../src/components/flow-port.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { FlowPortVisible } from '../core/model'\nimport PortView from './port-view.vue'\n\ndefineOptions({ name: 'DouFlowPort' })\n\ndefineProps<{\n /** The id of one of the node's ports. */\n id: string\n /**\n * When the port shows: `always`; `hover`, on a hovered or selected node,\n * or one with the keyboard focus in it (a field being typed in);\n * or `connecting`, only while an edge is drawn. Never shown in a\n * readonly editor. Defaults to the port's own `visible`, else `always`.\n */\n visible?: FlowPortVisible\n}>()\n</script>\n\n<template>\n <PortView :id=\"id\" :visible=\"visible\" />\n</template>\n"],"mappings":""}
|
|
@@ -1,54 +1,19 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import { computed, createCommentVNode, createElementBlock, createElementVNode, defineComponent, inject, normalizeClass, normalizeStyle, onBeforeUnmount, onMounted, openBlock, useTemplateRef } from "vue";
|
|
1
|
+
import port_view_default from "./port-view.js";
|
|
2
|
+
import { createBlock, defineComponent, openBlock } from "vue";
|
|
4
3
|
// src/components/flow-port.vue?vue&type=script&setup=true&lang.ts
|
|
5
|
-
var _hoisted_1 = ["data-port"];
|
|
6
|
-
var _hoisted_2 = {
|
|
7
|
-
key: 0,
|
|
8
|
-
viewBox: "0 0 10 10"
|
|
9
|
-
};
|
|
10
4
|
var flow_port_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComponent({
|
|
11
5
|
name: "DouFlowPort",
|
|
12
6
|
__name: "flow-port",
|
|
13
7
|
props: {
|
|
14
8
|
id: {},
|
|
15
|
-
|
|
9
|
+
visible: {}
|
|
16
10
|
},
|
|
17
11
|
setup(__props) {
|
|
18
|
-
const props = __props;
|
|
19
|
-
const node = inject(flowNodeKey, null);
|
|
20
|
-
const el = useTemplateRef("el");
|
|
21
|
-
const port = computed(() => node?.ports.value.find((p) => p.id === props.id));
|
|
22
|
-
const side = computed(() => port.value ? portSide(port.value) : "left");
|
|
23
|
-
const connected = computed(() => !!node?.connected.value.has(props.id));
|
|
24
|
-
const editor = inject(flowEditorKey, null);
|
|
25
|
-
const type = computed(() => port.value ? editor?.portTypeOf(port.value) : void 0);
|
|
26
|
-
const shape = computed(() => type.value?.shape ?? "circle");
|
|
27
|
-
const color = computed(() => editor?.colorOf(type.value));
|
|
28
|
-
const states = computed(() => node?.portStates.value);
|
|
29
|
-
const state = computed(() => states.value?.get(props.id));
|
|
30
|
-
onMounted(() => {
|
|
31
|
-
if (el.value) node?.registerPort(props.id, el.value, props.auto);
|
|
32
|
-
});
|
|
33
|
-
onBeforeUnmount(() => node?.unregisterPort(props.id, props.auto));
|
|
34
12
|
return (_ctx, _cache) => {
|
|
35
|
-
return openBlock(),
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
`is-${side.value}`,
|
|
40
|
-
`is-${port.value?.kind ?? "input"}`,
|
|
41
|
-
`is-${shape.value}`,
|
|
42
|
-
state.value && `is-${state.value}`,
|
|
43
|
-
{
|
|
44
|
-
"is-connected": connected.value,
|
|
45
|
-
"is-unavailable": states.value && !state.value
|
|
46
|
-
}
|
|
47
|
-
]]),
|
|
48
|
-
style: normalizeStyle(color.value ? { "--dou-flow-port-color": color.value } : void 0),
|
|
49
|
-
"data-port": __props.id,
|
|
50
|
-
"aria-hidden": "true"
|
|
51
|
-
}, [shape.value === "triangle" ? (openBlock(), createElementBlock("svg", _hoisted_2, [..._cache[0] || (_cache[0] = [createElementVNode("path", { d: "M2 1.5 8 5 2 8.5Z" }, null, -1)])])) : createCommentVNode("", true)], 14, _hoisted_1);
|
|
13
|
+
return openBlock(), createBlock(port_view_default, {
|
|
14
|
+
id: __props.id,
|
|
15
|
+
visible: __props.visible
|
|
16
|
+
}, null, 8, ["id", "visible"]);
|
|
52
17
|
};
|
|
53
18
|
}
|
|
54
19
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flow-port.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","
|
|
1
|
+
{"version":3,"file":"flow-port.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createBlock","PortView"],"sources":["../../src/components/flow-port.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { FlowPortVisible } from '../core/model'\nimport PortView from './port-view.vue'\n\ndefineOptions({ name: 'DouFlowPort' })\n\ndefineProps<{\n /** The id of one of the node's ports. */\n id: string\n /**\n * When the port shows: `always`; `hover`, on a hovered or selected node,\n * or one with the keyboard focus in it (a field being typed in);\n * or `connecting`, only while an edge is drawn. Never shown in a\n * readonly editor. Defaults to the port's own `visible`, else `always`.\n */\n visible?: FlowPortVisible\n}>()\n</script>\n\n<template>\n <PortView :id=\"id\" :visible=\"visible\" />\n</template>\n"],"mappings":";;;;;;;;;;;;GAoBE,OAAAA,UAAA,GAAAC,YAAwCC,mBAAA;IAA7B,IAAI,QAAA;IAAK,SAAS,QAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-view.js","names":["_sfc_main"],"sources":["../../src/components/node-view.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport {\n computed,\n nextTick,\n onBeforeUnmount,\n onMounted,\n provide,\n shallowRef,\n useTemplateRef,\n watch,\n} from 'vue'\nimport type { CSSProperties } from 'vue'\nimport { flowNodeKey, type NodeMetrics, type PortAnchor, type PortState } from '../context'\nimport type { FlowNode, FlowPortSpec, PortSide } from '../core/model'\nimport { portSide, portsOf, resizeOf, type NodeTypeSpec } from '../core/node-types'\nimport DefaultNode from './default-node.vue'\nimport FlowPortView from './
|
|
1
|
+
{"version":3,"file":"node-view.js","names":["_sfc_main"],"sources":["../../src/components/node-view.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport {\n computed,\n nextTick,\n onBeforeUnmount,\n onMounted,\n provide,\n shallowRef,\n useTemplateRef,\n watch,\n} from 'vue'\nimport type { CSSProperties } from 'vue'\nimport { flowNodeKey, type NodeMetrics, type PortAnchor, type PortState } from '../context'\nimport type { FlowNode, FlowPortSpec, PortSide } from '../core/model'\nimport { portSide, portsOf, resizeOf, type NodeTypeSpec } from '../core/node-types'\nimport DefaultNode from './default-node.vue'\nimport FlowPortView from './port-view.vue'\n\nconst props = defineProps<{\n node: FlowNode\n spec: NodeTypeSpec | undefined\n selected: boolean\n readonly: boolean\n dragging: boolean\n connected: Set<string>\n portStates: Map<string, PortState> | null\n roleDescription: string\n /** The node's accessible name. */\n label: string\n /** Read out after the name, e.g. the port counts. */\n description: string\n /** Where the nodes being dragged will be put. */\n dropTarget?: boolean\n}>()\nconst emit = defineEmits<{\n measure: [id: string, metrics: NodeMetrics]\n update: [id: string, patch: Record<string, unknown>]\n}>()\n\nconst el = useTemplateRef<HTMLElement>('el')\nconst ports = computed(() => portsOf(props.spec, props.node))\n\n// Ports placed by the node's component, and the ones the editor places.\nconst placed = new Map<string, HTMLElement>()\nconst autoPlaced = new Map<string, HTMLElement>()\nconst placedIds = shallowRef(new Set<string>())\nconst mounted = shallowRef(false)\n\nprovide(flowNodeKey, {\n node: computed(() => props.node),\n ports,\n connected: computed(() => props.connected),\n portStates: computed(() => props.portStates),\n registerPort(id, portEl, auto) {\n if (auto) autoPlaced.set(id, portEl)\n else {\n placed.set(id, portEl)\n placedIds.value = new Set(placed.keys())\n }\n scheduleMeasure()\n },\n unregisterPort(id, auto) {\n if (auto) autoPlaced.delete(id)\n else {\n placed.delete(id)\n placedIds.value = new Set(placed.keys())\n }\n scheduleMeasure()\n },\n})\n\nconst autoPorts = computed(() =>\n mounted.value ? ports.value.filter((port) => !placedIds.value.has(port.id)) : [],\n)\n\n/** Spreads the editor-placed ports evenly along each side. */\nfunction autoStyle(port: FlowPortSpec): CSSProperties {\n const side = portSide(port)\n const same = autoPorts.value.filter((p) => portSide(p) === side)\n const at = `${((same.indexOf(port) + 1) / (same.length + 1)) * 100}%`\n return side === 'left' || side === 'right' ? { top: at } : { left: at }\n}\n\nfunction measure() {\n const node = el.value\n if (!node || !node.offsetWidth) return\n const box = node.getBoundingClientRect()\n // The canvas is scaled; measure in its own units.\n const scale = box.width / node.offsetWidth || 1\n const anchors = new Map<string, PortAnchor>()\n for (const port of ports.value) {\n const portEl = placed.get(port.id) ?? autoPlaced.get(port.id)\n if (!portEl) continue\n const rect = portEl.getBoundingClientRect()\n const side: PortSide = portSide(port)\n anchors.set(port.id, {\n x: (rect.left + rect.width / 2 - box.left) / scale,\n y: (rect.top + rect.height / 2 - box.top) / scale,\n side,\n })\n }\n emit('measure', props.node.id, {\n width: node.offsetWidth,\n height: node.offsetHeight,\n ports: anchors,\n })\n}\n\nlet pending = false\nfunction scheduleMeasure() {\n if (pending) return\n pending = true\n void nextTick(() => {\n pending = false\n measure()\n })\n}\n\nlet observer: ResizeObserver | undefined\nonMounted(() => {\n mounted.value = true\n if (typeof ResizeObserver !== 'undefined') {\n observer = new ResizeObserver(() => measure())\n observer.observe(el.value!)\n }\n scheduleMeasure()\n})\nonBeforeUnmount(() => observer?.disconnect())\n\n// Content changes can move ports without resizing the node.\nwatch(\n () => [props.node.data, props.node.type, ports.value],\n () => scheduleMeasure(),\n { flush: 'post' },\n)\n\nconst container = computed(() => !!props.spec?.container)\n// A collapsed container is as tall as its content, its title.\nconst collapsed = computed(() => container.value && !!props.node.data?.collapsed)\nconst resizable = computed(\n () => !!resizeOf(props.spec, props.node) && !props.readonly && !collapsed.value,\n)\n\n/** How far the node is drawn turned, so its selection outline turns with it. */\nconst rotation = computed(() => props.spec?.rotation?.(props.node) ?? 0)\n\nconst style = computed<CSSProperties>(() => ({\n transform: `translate(${props.node.x}px, ${props.node.y}px)`,\n '--dou-flow-node-rotation': rotation.value ? `${rotation.value}deg` : undefined,\n width: props.node.width != null ? `${props.node.width}px` : undefined,\n height: props.node.height != null && !collapsed.value ? `${props.node.height}px` : undefined,\n}))\n\nconst viewProps = computed(() => ({\n node: props.node,\n data: props.node.data ?? {},\n ports: ports.value,\n selected: props.selected,\n readonly: props.readonly,\n updateData: (patch: Record<string, unknown>) => emit('update', props.node.id, patch),\n}))\n</script>\n\n<template>\n <div\n ref=\"el\"\n class=\"dou-flow-editor__node\"\n :class=\"{\n 'is-selected': selected,\n 'is-locked': node.locked,\n 'is-dragging': dragging,\n 'is-sized': node.width != null,\n 'is-container': container,\n 'is-bare': spec?.frame === false,\n 'is-turned': !!rotation,\n 'is-collapsed': collapsed,\n 'is-drop-target': dropTarget,\n }\"\n :style=\"style\"\n :data-node-id=\"node.id\"\n role=\"group\"\n :aria-roledescription=\"roleDescription\"\n :aria-label=\"label\"\n :aria-description=\"description || undefined\"\n tabindex=\"-1\"\n >\n <component :is=\"spec?.component ?? DefaultNode\" v-bind=\"viewProps\" />\n <FlowPortView\n v-for=\"port in autoPorts\"\n :id=\"port.id\"\n :key=\"port.id\"\n auto\n class=\"is-auto\"\n :style=\"autoStyle(port)\"\n />\n <span v-if=\"resizable && selected\" class=\"dou-flow-editor__resize\" aria-hidden=\"true\" />\n </div>\n</template>\n"],"mappings":""}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { flowNodeKey } from "../context.js";
|
|
2
2
|
import { portSide, portsOf, resizeOf } from "../core/node-types.js";
|
|
3
|
-
import
|
|
3
|
+
import port_view_default from "./port-view.js";
|
|
4
4
|
import default_node_default from "./default-node.js";
|
|
5
5
|
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, defineComponent, guardReactiveProps, nextTick, normalizeClass, normalizeProps, normalizeStyle, onBeforeUnmount, onMounted, openBlock, provide, renderList, resolveDynamicComponent, shallowRef, useTemplateRef, watch } from "vue";
|
|
6
6
|
// src/components/node-view.vue?vue&type=script&setup=true&lang.ts
|
|
@@ -161,7 +161,7 @@ var node_view_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ define
|
|
|
161
161
|
}, [
|
|
162
162
|
(openBlock(), createBlock(resolveDynamicComponent(__props.spec?.component ?? default_node_default), normalizeProps(guardReactiveProps(viewProps.value)), null, 16)),
|
|
163
163
|
(openBlock(true), createElementBlock(Fragment, null, renderList(autoPorts.value, (port) => {
|
|
164
|
-
return openBlock(), createBlock(
|
|
164
|
+
return openBlock(), createBlock(port_view_default, {
|
|
165
165
|
id: port.id,
|
|
166
166
|
key: port.id,
|
|
167
167
|
auto: "",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-view.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createElementBlock","_normalizeClass","_normalizeStyle","_createBlock","_resolveDynamicComponent","DefaultNode","_normalizeProps","_guardReactiveProps","_Fragment","_renderList","FlowPortView","_createCommentVNode"],"sources":["../../src/components/node-view.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport {\n computed,\n nextTick,\n onBeforeUnmount,\n onMounted,\n provide,\n shallowRef,\n useTemplateRef,\n watch,\n} from 'vue'\nimport type { CSSProperties } from 'vue'\nimport { flowNodeKey, type NodeMetrics, type PortAnchor, type PortState } from '../context'\nimport type { FlowNode, FlowPortSpec, PortSide } from '../core/model'\nimport { portSide, portsOf, resizeOf, type NodeTypeSpec } from '../core/node-types'\nimport DefaultNode from './default-node.vue'\nimport FlowPortView from './
|
|
1
|
+
{"version":3,"file":"node-view.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createElementBlock","_normalizeClass","_normalizeStyle","_createBlock","_resolveDynamicComponent","DefaultNode","_normalizeProps","_guardReactiveProps","_Fragment","_renderList","FlowPortView","_createCommentVNode"],"sources":["../../src/components/node-view.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport {\n computed,\n nextTick,\n onBeforeUnmount,\n onMounted,\n provide,\n shallowRef,\n useTemplateRef,\n watch,\n} from 'vue'\nimport type { CSSProperties } from 'vue'\nimport { flowNodeKey, type NodeMetrics, type PortAnchor, type PortState } from '../context'\nimport type { FlowNode, FlowPortSpec, PortSide } from '../core/model'\nimport { portSide, portsOf, resizeOf, type NodeTypeSpec } from '../core/node-types'\nimport DefaultNode from './default-node.vue'\nimport FlowPortView from './port-view.vue'\n\nconst props = defineProps<{\n node: FlowNode\n spec: NodeTypeSpec | undefined\n selected: boolean\n readonly: boolean\n dragging: boolean\n connected: Set<string>\n portStates: Map<string, PortState> | null\n roleDescription: string\n /** The node's accessible name. */\n label: string\n /** Read out after the name, e.g. the port counts. */\n description: string\n /** Where the nodes being dragged will be put. */\n dropTarget?: boolean\n}>()\nconst emit = defineEmits<{\n measure: [id: string, metrics: NodeMetrics]\n update: [id: string, patch: Record<string, unknown>]\n}>()\n\nconst el = useTemplateRef<HTMLElement>('el')\nconst ports = computed(() => portsOf(props.spec, props.node))\n\n// Ports placed by the node's component, and the ones the editor places.\nconst placed = new Map<string, HTMLElement>()\nconst autoPlaced = new Map<string, HTMLElement>()\nconst placedIds = shallowRef(new Set<string>())\nconst mounted = shallowRef(false)\n\nprovide(flowNodeKey, {\n node: computed(() => props.node),\n ports,\n connected: computed(() => props.connected),\n portStates: computed(() => props.portStates),\n registerPort(id, portEl, auto) {\n if (auto) autoPlaced.set(id, portEl)\n else {\n placed.set(id, portEl)\n placedIds.value = new Set(placed.keys())\n }\n scheduleMeasure()\n },\n unregisterPort(id, auto) {\n if (auto) autoPlaced.delete(id)\n else {\n placed.delete(id)\n placedIds.value = new Set(placed.keys())\n }\n scheduleMeasure()\n },\n})\n\nconst autoPorts = computed(() =>\n mounted.value ? ports.value.filter((port) => !placedIds.value.has(port.id)) : [],\n)\n\n/** Spreads the editor-placed ports evenly along each side. */\nfunction autoStyle(port: FlowPortSpec): CSSProperties {\n const side = portSide(port)\n const same = autoPorts.value.filter((p) => portSide(p) === side)\n const at = `${((same.indexOf(port) + 1) / (same.length + 1)) * 100}%`\n return side === 'left' || side === 'right' ? { top: at } : { left: at }\n}\n\nfunction measure() {\n const node = el.value\n if (!node || !node.offsetWidth) return\n const box = node.getBoundingClientRect()\n // The canvas is scaled; measure in its own units.\n const scale = box.width / node.offsetWidth || 1\n const anchors = new Map<string, PortAnchor>()\n for (const port of ports.value) {\n const portEl = placed.get(port.id) ?? autoPlaced.get(port.id)\n if (!portEl) continue\n const rect = portEl.getBoundingClientRect()\n const side: PortSide = portSide(port)\n anchors.set(port.id, {\n x: (rect.left + rect.width / 2 - box.left) / scale,\n y: (rect.top + rect.height / 2 - box.top) / scale,\n side,\n })\n }\n emit('measure', props.node.id, {\n width: node.offsetWidth,\n height: node.offsetHeight,\n ports: anchors,\n })\n}\n\nlet pending = false\nfunction scheduleMeasure() {\n if (pending) return\n pending = true\n void nextTick(() => {\n pending = false\n measure()\n })\n}\n\nlet observer: ResizeObserver | undefined\nonMounted(() => {\n mounted.value = true\n if (typeof ResizeObserver !== 'undefined') {\n observer = new ResizeObserver(() => measure())\n observer.observe(el.value!)\n }\n scheduleMeasure()\n})\nonBeforeUnmount(() => observer?.disconnect())\n\n// Content changes can move ports without resizing the node.\nwatch(\n () => [props.node.data, props.node.type, ports.value],\n () => scheduleMeasure(),\n { flush: 'post' },\n)\n\nconst container = computed(() => !!props.spec?.container)\n// A collapsed container is as tall as its content, its title.\nconst collapsed = computed(() => container.value && !!props.node.data?.collapsed)\nconst resizable = computed(\n () => !!resizeOf(props.spec, props.node) && !props.readonly && !collapsed.value,\n)\n\n/** How far the node is drawn turned, so its selection outline turns with it. */\nconst rotation = computed(() => props.spec?.rotation?.(props.node) ?? 0)\n\nconst style = computed<CSSProperties>(() => ({\n transform: `translate(${props.node.x}px, ${props.node.y}px)`,\n '--dou-flow-node-rotation': rotation.value ? `${rotation.value}deg` : undefined,\n width: props.node.width != null ? `${props.node.width}px` : undefined,\n height: props.node.height != null && !collapsed.value ? `${props.node.height}px` : undefined,\n}))\n\nconst viewProps = computed(() => ({\n node: props.node,\n data: props.node.data ?? {},\n ports: ports.value,\n selected: props.selected,\n readonly: props.readonly,\n updateData: (patch: Record<string, unknown>) => emit('update', props.node.id, patch),\n}))\n</script>\n\n<template>\n <div\n ref=\"el\"\n class=\"dou-flow-editor__node\"\n :class=\"{\n 'is-selected': selected,\n 'is-locked': node.locked,\n 'is-dragging': dragging,\n 'is-sized': node.width != null,\n 'is-container': container,\n 'is-bare': spec?.frame === false,\n 'is-turned': !!rotation,\n 'is-collapsed': collapsed,\n 'is-drop-target': dropTarget,\n }\"\n :style=\"style\"\n :data-node-id=\"node.id\"\n role=\"group\"\n :aria-roledescription=\"roleDescription\"\n :aria-label=\"label\"\n :aria-description=\"description || undefined\"\n tabindex=\"-1\"\n >\n <component :is=\"spec?.component ?? DefaultNode\" v-bind=\"viewProps\" />\n <FlowPortView\n v-for=\"port in autoPorts\"\n :id=\"port.id\"\n :key=\"port.id\"\n auto\n class=\"is-auto\"\n :style=\"autoStyle(port)\"\n />\n <span v-if=\"resizable && selected\" class=\"dou-flow-editor__resize\" aria-hidden=\"true\" />\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkBA,MAAM,QAAQ;EAgBd,MAAM,OAAO;EAKb,MAAM,KAAK,eAA4B,IAAI;EAC3C,MAAM,QAAQ,eAAe,QAAQ,MAAM,MAAM,MAAM,IAAI,CAAC;EAG5D,MAAM,yBAAS,IAAI,IAAyB;EAC5C,MAAM,6BAAa,IAAI,IAAyB;EAChD,MAAM,YAAY,2BAAW,IAAI,IAAY,CAAC;EAC9C,MAAM,UAAU,WAAW,KAAK;EAEhC,QAAQ,aAAa;GACnB,MAAM,eAAe,MAAM,IAAI;GAC/B;GACA,WAAW,eAAe,MAAM,SAAS;GACzC,YAAY,eAAe,MAAM,UAAU;GAC3C,aAAa,IAAI,QAAQ,MAAM;IAC7B,IAAI,MAAM,WAAW,IAAI,IAAI,MAAM;SAC9B;KACH,OAAO,IAAI,IAAI,MAAM;KACrB,UAAU,QAAQ,IAAI,IAAI,OAAO,KAAK,CAAC;IACzC;IACA,gBAAgB;GAClB;GACA,eAAe,IAAI,MAAM;IACvB,IAAI,MAAM,WAAW,OAAO,EAAE;SACzB;KACH,OAAO,OAAO,EAAE;KAChB,UAAU,QAAQ,IAAI,IAAI,OAAO,KAAK,CAAC;IACzC;IACA,gBAAgB;GAClB;EACF,CAAC;EAED,MAAM,YAAY,eAChB,QAAQ,QAAQ,MAAM,MAAM,QAAQ,SAAS,CAAC,UAAU,MAAM,IAAI,KAAK,EAAE,CAAC,IAAI,CAAC,CACjF;;EAGA,SAAS,UAAU,MAAmC;GACpD,MAAM,OAAO,SAAS,IAAI;GAC1B,MAAM,OAAO,UAAU,MAAM,QAAQ,MAAM,SAAS,CAAC,MAAM,IAAI;GAC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BAAc,QAAA,KAAK;IACpB,MAAK;IACJ,wBAAsB,QAAA;IACtB,cAAY,QAAA;IACZ,oBAAkB,QAAA,eAAe,KAAA;IAClC,UAAS;;KAETH,UAAA,GAAAI,YAAqEC,wBAArD,QAAA,MAAM,aAAaC,oBAAW,GAAAC,eAAAC,mBAAU,UAAA,KAAS,CAAA,GAAA,MAAA,EAAA;KACjER,UAAA,IAAA,GAAAC,mBAOEQ,UAAA,MAAAC,WANe,UAAA,QAAR,SAAI;KADb,OAAAV,UAAA,GAAAI,YAOEO,mBAAA;MALC,IAAI,KAAK;MACT,KAAK,KAAK;MACX,MAAA;MACA,OAAM;MACL,OAAKR,eAAE,UAAU,IAAI,CAAA;;;IAEZ,UAAA,SAAa,QAAA,YAAzBH,UAAA,GAAAC,mBAAwF,QAAxF,UAAwF,K"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import port_view_vue_vue_type_script_setup_true_lang_default from "./port-view.vue_vue_type_script_setup_true_lang.js";
|
|
2
|
+
// src/components/port-view.vue
|
|
3
|
+
var port_view_default = port_view_vue_vue_type_script_setup_true_lang_default;
|
|
4
|
+
export { port_view_default as default };
|
|
5
|
+
|
|
6
|
+
//# sourceMappingURL=port-view.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"port-view.js","names":["_sfc_main"],"sources":["../../src/components/port-view.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed, inject, onBeforeUnmount, onMounted, useTemplateRef } from 'vue'\nimport { flowEditorKey, flowNodeKey } from '../context'\nimport type { FlowPortVisible } from '../core/model'\nimport { portSide } from '../core/node-types'\n\ndefineOptions({ name: 'DouFlowPortView' })\n\n// The port itself. `<DouFlowPort>` is the public face; the editor places\n// the ports a node's component leaves out with `auto`.\nconst props = defineProps<{\n id: string\n visible?: FlowPortVisible\n /** placed by the editor, not by the node's component */\n auto?: boolean\n}>()\n\nconst node = inject(flowNodeKey, null)\n\nconst el = useTemplateRef<HTMLElement>('el')\nconst port = computed(() => node?.ports.value.find((p) => p.id === props.id))\nconst side = computed(() => (port.value ? portSide(port.value) : 'left'))\nconst connected = computed(() => !!node?.connected.value.has(props.id))\nconst editor = inject(flowEditorKey, null)\nconst type = computed(() => (port.value ? editor?.portTypeOf(port.value) : undefined))\nconst shape = computed(() => type.value?.shape ?? 'circle')\nconst color = computed(() => editor?.colorOf(type.value))\nconst visible = computed(() => props.visible ?? port.value?.visible ?? 'always')\nconst states = computed(() => node?.portStates.value)\nconst state = computed(() => states.value?.get(props.id))\n\nonMounted(() => {\n if (el.value) node?.registerPort(props.id, el.value, props.auto)\n})\nonBeforeUnmount(() => node?.unregisterPort(props.id, props.auto))\n</script>\n\n<template>\n <span\n ref=\"el\"\n class=\"dou-flow-port\"\n :class=\"[\n `is-${side}`,\n `is-${port?.kind ?? 'input'}`,\n `is-${shape}`,\n state && `is-${state}`,\n { 'is-connected': connected, 'is-unavailable': states && !state },\n ]\"\n :style=\"color ? { '--dou-flow-port-color': color } : undefined\"\n :data-port=\"id\"\n :data-visible=\"visible === 'always' ? undefined : visible\"\n aria-hidden=\"true\"\n >\n <svg v-if=\"shape === 'triangle'\" viewBox=\"0 0 10 10\">\n <path d=\"M2 1.5 8 5 2 8.5Z\" />\n </svg>\n </span>\n</template>\n"],"mappings":""}
|