@widgetic/workflows 0.2.7 → 0.2.8
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/README.md +49 -43
- package/dist/components/Workflows.svelte +13 -15
- package/dist/components/WorkflowsEmptyState.svelte +14 -12
- package/dist/components/WorkflowsHeader.svelte +9 -5
- package/dist/components/WorkflowsHeader.svelte.d.ts +4 -16
- package/dist/components/WorkflowsWorkspace.svelte +3 -2
- package/dist/components/canvas/AddBlockMenu.svelte +11 -2
- package/dist/components/canvas/CanvasToolbar.svelte +42 -31
- package/dist/components/canvas/CanvasToolbar.svelte.d.ts +2 -0
- package/dist/components/canvas/CompositionNodeView.svelte +58 -36
- package/dist/components/canvas/ConditionNodeView.svelte +31 -18
- package/dist/components/canvas/HandlePoint.svelte +10 -3
- package/dist/components/canvas/HandlePoint.svelte.d.ts +1 -1
- package/dist/components/canvas/TriggerNodeView.svelte +39 -13
- package/dist/components/canvas/WorkflowCanvas.svelte +22 -7
- package/dist/components/canvas/WorkflowCanvas.svelte.d.ts +2 -0
- package/dist/components/canvas/WorkflowEdgeView.svelte +5 -6
- package/dist/components/editor/ConflictBanner.svelte +1 -1
- package/dist/components/editor/EditorBanners.svelte +11 -4
- package/dist/components/editor/EditorCanvasArea.svelte +17 -10
- package/dist/components/editor/EditorTabs.svelte +10 -44
- package/dist/components/editor/EditorTopBar.svelte +166 -54
- package/dist/components/editor/PresenceBanner.svelte +106 -85
- package/dist/components/editor/RunsFlow.svelte +100 -17
- package/dist/components/editor/RunsTab.svelte +52 -46
- package/dist/components/editor/SettingsRow.svelte +35 -0
- package/dist/components/editor/SettingsRow.svelte.d.ts +14 -0
- package/dist/components/editor/SettingsTab.svelte +66 -50
- package/dist/components/editor/WorkflowEditor.svelte +4 -5
- package/dist/components/list/CreateWorkflowDialog.svelte +123 -73
- package/dist/components/list/WorkflowList.svelte +227 -100
- package/dist/components/list/WorkflowRow.svelte +84 -42
- package/dist/components/panel/BlockProblems.svelte +9 -8
- package/dist/components/panel/CompositionForm.svelte +52 -34
- package/dist/components/panel/CompositionPicker.svelte +43 -21
- package/dist/components/panel/CompositionPicker.svelte.d.ts +5 -0
- package/dist/components/panel/CompositionSelect.svelte +105 -0
- package/dist/components/panel/CompositionSelect.svelte.d.ts +23 -0
- package/dist/components/panel/ConditionForm.svelte +50 -17
- package/dist/components/panel/EventValueRow.svelte +5 -4
- package/dist/components/panel/ProblemsList.svelte +17 -19
- package/dist/components/panel/RuleCard.svelte +127 -89
- package/dist/components/panel/RuleCard.svelte.d.ts +2 -0
- package/dist/components/panel/SidePanel.svelte +101 -50
- package/dist/components/panel/TestResultLine.svelte +35 -0
- package/dist/components/panel/TestResultLine.svelte.d.ts +9 -0
- package/dist/components/panel/TestRow.svelte +21 -18
- package/dist/components/panel/TestRunPanel.svelte +61 -39
- package/dist/components/panel/TestTriggerCard.svelte +66 -6
- package/dist/components/panel/TestTriggerCard.svelte.d.ts +10 -0
- package/dist/components/panel/TriggerForm.svelte +24 -25
- package/dist/components/panel/VersionHistory.svelte +31 -43
- package/dist/components/ui/ActionButton.svelte +44 -12
- package/dist/components/ui/ActionButton.svelte.d.ts +2 -1
- package/dist/components/ui/Badge.svelte +39 -0
- package/dist/components/ui/Badge.svelte.d.ts +12 -0
- package/dist/components/ui/ConfirmDialog.svelte +4 -3
- package/dist/components/ui/Menu.svelte +28 -14
- package/dist/components/ui/Menu.svelte.d.ts +3 -1
- package/dist/components/ui/Modal.svelte +15 -8
- package/dist/components/ui/Notice.svelte +35 -11
- package/dist/components/ui/Notice.svelte.d.ts +4 -1
- package/dist/components/ui/SelectField.svelte +48 -20
- package/dist/components/ui/SelectField.svelte.d.ts +2 -0
- package/dist/components/ui/StatusBadge.svelte +13 -24
- package/dist/components/ui/StatusBadge.svelte.d.ts +0 -2
- package/dist/components/ui/Tabs.svelte +79 -0
- package/dist/components/ui/Tabs.svelte.d.ts +21 -0
- package/dist/components/ui/TextField.svelte +47 -27
- package/dist/components/ui/TextField.svelte.d.ts +5 -0
- package/dist/components/ui/icons.d.ts +43 -29
- package/dist/components/ui/icons.js +101 -40
- package/dist/editor/editorState.svelte.d.ts +23 -2
- package/dist/editor/editorState.svelte.js +36 -0
- package/dist/editor/listState.svelte.d.ts +32 -2
- package/dist/editor/listState.svelte.js +41 -0
- package/dist/i18n/language.d.ts +3 -3
- package/dist/i18n/messages.d.ts +22 -13
- package/dist/i18n/messages.js +23 -14
- package/dist/i18n/statusWords.d.ts +12 -0
- package/dist/i18n/statusWords.js +12 -0
- package/package.json +3 -3
|
@@ -18,10 +18,11 @@
|
|
|
18
18
|
import { nameRule, summarizeRule } from '../../editor/blockLabels.js';
|
|
19
19
|
import { findEdgeFrom, useCanvasContext } from '../../editor/canvasContext.js';
|
|
20
20
|
import { useWorkflowsLanguage } from '../../i18n/language.js';
|
|
21
|
+
import Badge from '../ui/Badge.svelte';
|
|
21
22
|
import Icon from '../ui/Icon.svelte';
|
|
22
23
|
import HandlePoint from './HandlePoint.svelte';
|
|
23
24
|
|
|
24
|
-
let { id, data }: NodeProps<WorkflowBlockData> = $props();
|
|
25
|
+
let { id, data, selected, status }: NodeProps<WorkflowBlockData> = $props();
|
|
25
26
|
|
|
26
27
|
const { t } = useWorkflowsLanguage();
|
|
27
28
|
const textDirection = useTextDirection();
|
|
@@ -39,40 +40,52 @@
|
|
|
39
40
|
function labelField(field: FieldReference): string {
|
|
40
41
|
return readContext().words.labelField(id, field);
|
|
41
42
|
}
|
|
43
|
+
|
|
44
|
+
const rootBorder = $derived.by(() => {
|
|
45
|
+
if (status === 'error') return 'border-2 border-destructive';
|
|
46
|
+
if (selected) return 'border-2 border-primary';
|
|
47
|
+
return 'border border-border';
|
|
48
|
+
});
|
|
42
49
|
</script>
|
|
43
50
|
|
|
44
51
|
<div
|
|
45
|
-
class="relative flex w-
|
|
52
|
+
class="relative flex w-66 flex-col overflow-hidden rounded-xl bg-background text-start text-foreground {rootBorder}"
|
|
46
53
|
dir={$textDirection}
|
|
47
54
|
data-workflow-block="condition"
|
|
48
55
|
>
|
|
49
|
-
<div class="flex items-center gap-2 px-
|
|
50
|
-
<
|
|
51
|
-
|
|
56
|
+
<div class="flex h-12 items-center gap-2 px-4 py-3">
|
|
57
|
+
<div
|
|
58
|
+
class="flex size-6 shrink-0 items-center justify-center rounded-full bg-muted text-foreground"
|
|
59
|
+
>
|
|
60
|
+
<Icon name="condition" class="size-4" />
|
|
61
|
+
</div>
|
|
62
|
+
<p class="min-w-0 flex-1 truncate text-caption-medium text-muted-foreground">
|
|
52
63
|
{$t('workflows.block.condition')}
|
|
53
64
|
</p>
|
|
65
|
+
{#if problemCount > 0}
|
|
66
|
+
<Badge tone="destructive" class="shrink-0"
|
|
67
|
+
>{$t('workflows.block.conditionNoRulesBadge')}</Badge
|
|
68
|
+
>
|
|
69
|
+
{/if}
|
|
54
70
|
</div>
|
|
55
|
-
{#if problemCount > 0}
|
|
56
|
-
<p class="flex items-center gap-1 px-3 text-xs text-error">
|
|
57
|
-
<Icon name="warning" class="size-3.5" />
|
|
58
|
-
{$t('workflows.block.problems', { count: problemCount })}
|
|
59
|
-
</p>
|
|
60
|
-
{/if}
|
|
61
71
|
|
|
62
|
-
<!-- Each row is the positioned parent of its own connection point, which sits on the right edge in the middle of the row. -->
|
|
63
72
|
{#each node.cases as rule, index (rule.id)}
|
|
64
|
-
<div class="relative border-t border-
|
|
65
|
-
<p class="truncate pe-3 text-
|
|
66
|
-
|
|
73
|
+
<div class="relative min-h-13 border-t border-border px-4 py-2">
|
|
74
|
+
<p class="truncate pe-3 text-body-medium text-foreground" dir="auto">
|
|
75
|
+
{nameRule(rule, index, $t)}
|
|
76
|
+
</p>
|
|
77
|
+
<p class="line-clamp-2 pe-3 text-caption text-muted-foreground" dir="auto">
|
|
67
78
|
{summarizeRule(rule, labelField, $t)}
|
|
68
79
|
</p>
|
|
69
80
|
<HandlePoint id={rule.id} type="output" port={OUTPUT_PORT_TYPE.condition} position="right" />
|
|
70
81
|
</div>
|
|
71
82
|
{/each}
|
|
72
83
|
|
|
73
|
-
<div class="relative border-t border-
|
|
74
|
-
<p class="truncate pe-3 text-
|
|
75
|
-
|
|
84
|
+
<div class="relative min-h-13 border-t border-border px-4 py-2">
|
|
85
|
+
<p class="truncate pe-3 text-body-medium text-foreground">
|
|
86
|
+
{$t('workflows.condition.defaultName')}
|
|
87
|
+
</p>
|
|
88
|
+
<p class="text-caption text-muted-foreground">
|
|
76
89
|
{defaultStays
|
|
77
90
|
? $t('workflows.condition.defaultStays')
|
|
78
91
|
: $t('workflows.condition.defaultHint')}
|
|
@@ -18,15 +18,22 @@
|
|
|
18
18
|
port: string;
|
|
19
19
|
/** For an input: the ports it accepts. */
|
|
20
20
|
accept?: readonly string[];
|
|
21
|
-
/** The side of the block the point sits on. The canvas is always drawn left to right, so this is a physical side. */
|
|
21
|
+
/** The side of the block the point sits on. The canvas is always drawn left to right, so this is a physical side. rtl-ok: kaykay lays out LTR flow edges. */
|
|
22
22
|
position: HandlePosition;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
let { id, type, port, accept, position }: Props = $props();
|
|
26
26
|
</script>
|
|
27
27
|
|
|
28
|
-
<Handle
|
|
28
|
+
<Handle
|
|
29
|
+
{id}
|
|
30
|
+
{type}
|
|
31
|
+
{port}
|
|
32
|
+
accept={accept ? [...accept] : undefined}
|
|
33
|
+
{position}
|
|
34
|
+
class="group flex size-2.5 items-center justify-center border-0 bg-transparent p-0 [&_.kaykay-handle-label]:hidden"
|
|
35
|
+
>
|
|
29
36
|
<span
|
|
30
|
-
class="block size-
|
|
37
|
+
class="pointer-events-none block size-2.5 rounded-full border border-muted-foreground bg-background transition-colors duration-fast group-[.can-connect]:border-primary group-[.can-connect]:bg-primary group-[.connecting]:border-primary group-[.connecting]:bg-primary group-[.incompatible]:opacity-50"
|
|
31
38
|
></span>
|
|
32
39
|
</Handle>
|
|
@@ -6,7 +6,7 @@ interface Props {
|
|
|
6
6
|
port: string;
|
|
7
7
|
/** For an input: the ports it accepts. */
|
|
8
8
|
accept?: readonly string[];
|
|
9
|
-
/** The side of the block the point sits on. The canvas is always drawn left to right, so this is a physical side. */
|
|
9
|
+
/** The side of the block the point sits on. The canvas is always drawn left to right, so this is a physical side. rtl-ok: kaykay lays out LTR flow edges. */
|
|
10
10
|
position: HandlePosition;
|
|
11
11
|
}
|
|
12
12
|
declare const HandlePoint: import("svelte").Component<Props, {}, "">;
|
|
@@ -15,42 +15,68 @@
|
|
|
15
15
|
type WorkflowBlockData
|
|
16
16
|
} from '../../editor/flowAdapter.js';
|
|
17
17
|
import { TRIGGER_KIND_MESSAGE_KEYS } from '../../editor/blockLabels.js';
|
|
18
|
+
import type { TriggerKind } from '../../editor/graphModel.js';
|
|
18
19
|
import { useCanvasContext } from '../../editor/canvasContext.js';
|
|
19
20
|
import { useWorkflowsLanguage } from '../../i18n/language.js';
|
|
21
|
+
import Badge from '../ui/Badge.svelte';
|
|
20
22
|
import Icon from '../ui/Icon.svelte';
|
|
21
23
|
import HandlePoint from './HandlePoint.svelte';
|
|
22
24
|
|
|
23
|
-
let { id, data }: NodeProps<WorkflowBlockData> = $props();
|
|
25
|
+
let { id, data, selected, status }: NodeProps<WorkflowBlockData> = $props();
|
|
24
26
|
|
|
25
|
-
const { t } = useWorkflowsLanguage();
|
|
26
27
|
const textDirection = useTextDirection();
|
|
27
28
|
const readContext = useCanvasContext();
|
|
29
|
+
const { t } = useWorkflowsLanguage();
|
|
28
30
|
|
|
29
31
|
const node = $derived(data.node as TriggerNode);
|
|
30
32
|
const marks = $derived(readContext().marks);
|
|
31
33
|
/** What the trigger waits for, as one line. `summarizeTrigger` is read from the shared context so that it speaks the page's language. */
|
|
32
34
|
const summary = $derived(readContext().words.summarizeTrigger(node.trigger));
|
|
33
35
|
const problemCount = $derived(marks.problemCountOf(id));
|
|
36
|
+
|
|
37
|
+
const kind = $derived(node.trigger.kind as TriggerKind);
|
|
38
|
+
|
|
39
|
+
const triggerIcon = $derived.by(() => {
|
|
40
|
+
switch (kind) {
|
|
41
|
+
case 'pageEvent':
|
|
42
|
+
return 'bolt' as const;
|
|
43
|
+
case 'action':
|
|
44
|
+
return 'click' as const;
|
|
45
|
+
case 'input':
|
|
46
|
+
return 'forms' as const;
|
|
47
|
+
case 'scheduled':
|
|
48
|
+
return 'clock' as const;
|
|
49
|
+
default:
|
|
50
|
+
return 'trigger' as const;
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
const rootBorder = $derived.by(() => {
|
|
55
|
+
if (status === 'error') return 'border-2 border-destructive';
|
|
56
|
+
if (selected) return 'border-2 border-primary';
|
|
57
|
+
return 'border border-border';
|
|
58
|
+
});
|
|
34
59
|
</script>
|
|
35
60
|
|
|
36
61
|
<div
|
|
37
|
-
class="relative flex w-
|
|
62
|
+
class="relative flex w-58 flex-col gap-2 rounded-xl bg-background px-4 py-3 text-start text-foreground {rootBorder}"
|
|
38
63
|
dir={$textDirection}
|
|
39
64
|
data-workflow-block="trigger"
|
|
40
65
|
>
|
|
41
66
|
<div class="flex items-center gap-2">
|
|
42
|
-
<
|
|
43
|
-
|
|
44
|
-
|
|
67
|
+
<div
|
|
68
|
+
class="flex size-6 shrink-0 items-center justify-center rounded-full bg-brand-subtle text-brand-foreground"
|
|
69
|
+
>
|
|
70
|
+
<Icon name={triggerIcon} class="size-4" />
|
|
71
|
+
</div>
|
|
72
|
+
<p class="min-w-0 flex-1 truncate text-caption-medium text-muted-foreground">
|
|
73
|
+
{$t(TRIGGER_KIND_MESSAGE_KEYS[kind])}
|
|
45
74
|
</p>
|
|
75
|
+
{#if problemCount > 0}
|
|
76
|
+
<Badge tone="destructive" class="shrink-0">{$t('workflows.trigger.summaryUnfinished')}</Badge>
|
|
77
|
+
{/if}
|
|
46
78
|
</div>
|
|
47
|
-
<p class="text-
|
|
48
|
-
{#if problemCount > 0}
|
|
49
|
-
<p class="flex items-center gap-1 text-xs text-error">
|
|
50
|
-
<Icon name="warning" class="size-3.5" />
|
|
51
|
-
{$t('workflows.block.problems', { count: problemCount })}
|
|
52
|
-
</p>
|
|
53
|
-
{/if}
|
|
79
|
+
<p class="text-body-medium text-foreground break-words" dir="auto">{summary}</p>
|
|
54
80
|
|
|
55
81
|
<HandlePoint
|
|
56
82
|
id={INPUT_HANDLE_ID}
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
that one undo takes back; a whole new workflow (a reload, a version) comes in through `loadGraph` with no history.
|
|
11
11
|
- Lines can only be drawn where the engine allows them (`createConnectionValidator`): kaykay greys out the other places
|
|
12
12
|
while a line is dragged.
|
|
13
|
-
- Copy, paste and "log selection" are off (a pasted block would have the id of the one it was copied from, and
|
|
14
|
-
clipboard is the person's own); everything else of kaykay's keyboard stays (arrows move, Delete deletes, undo, redo).
|
|
13
|
+
- Copy, paste and "log selection" are off (a pasted block would have the id of the one it was copied from, and
|
|
14
|
+
the clipboard is the person's own); everything else of kaykay's keyboard stays (arrows move, Delete deletes, undo, redo).
|
|
15
15
|
- kaykay names its connection points in English; here they are named in the page's language.
|
|
16
16
|
|
|
17
17
|
It is always drawn left to right, whatever the page's direction: lines run from the composition on the left to the next
|
|
@@ -26,7 +26,8 @@
|
|
|
26
26
|
FlowConfig,
|
|
27
27
|
FlowState,
|
|
28
28
|
NodeStatus,
|
|
29
|
-
NodeTypes
|
|
29
|
+
NodeTypes,
|
|
30
|
+
Viewport
|
|
30
31
|
} from 'kaykay';
|
|
31
32
|
import type { WorkflowGraph } from '@widgetic/workflows-engine';
|
|
32
33
|
import { provideCanvasContext, type CanvasContext } from '../../editor/canvasContext.js';
|
|
@@ -62,6 +63,8 @@
|
|
|
62
63
|
onSelectionChange?: (nodeIds: readonly string[], edgeIds: readonly string[]) => void;
|
|
63
64
|
/** The `B` key was pressed on the canvas: the owner opens its Add block menu. */
|
|
64
65
|
onAddBlockShortcut?: () => void;
|
|
66
|
+
/** Pan/zoom updates (toolbar zoom label); not every `on_change` includes the viewport. */
|
|
67
|
+
onViewportZoom?: (zoom: number) => void;
|
|
65
68
|
/** Gives the owner the handle once the canvas is on the screen, and `null` when it leaves. */
|
|
66
69
|
onReady?: (handle: CanvasHandle | null) => void;
|
|
67
70
|
class?: string;
|
|
@@ -75,6 +78,7 @@
|
|
|
75
78
|
onGraphChange,
|
|
76
79
|
onSelectionChange,
|
|
77
80
|
onAddBlockShortcut,
|
|
81
|
+
onViewportZoom,
|
|
78
82
|
onReady,
|
|
79
83
|
class: className = ''
|
|
80
84
|
}: Props = $props();
|
|
@@ -108,6 +112,10 @@
|
|
|
108
112
|
return canvas?.getFlow();
|
|
109
113
|
}
|
|
110
114
|
|
|
115
|
+
function reportViewportZoom(viewport: Viewport): void {
|
|
116
|
+
onViewportZoom?.(viewport.zoom);
|
|
117
|
+
}
|
|
118
|
+
|
|
111
119
|
const flowConfig: FlowConfig = {
|
|
112
120
|
min_zoom: 0.25,
|
|
113
121
|
max_zoom: 1.5,
|
|
@@ -129,6 +137,7 @@
|
|
|
129
137
|
|
|
130
138
|
const flowCallbacks: FlowCallbacks = {
|
|
131
139
|
on_change: () => scheduleRead(),
|
|
140
|
+
on_viewport_change: (viewport) => reportViewportZoom(viewport),
|
|
132
141
|
on_selection_change: (nodeIds, edgeIds) => onSelectionChange?.(nodeIds, edgeIds)
|
|
133
142
|
};
|
|
134
143
|
|
|
@@ -257,6 +266,9 @@
|
|
|
257
266
|
},
|
|
258
267
|
get canRedo() {
|
|
259
268
|
return getFlow()?.canRedo ?? false;
|
|
269
|
+
},
|
|
270
|
+
get zoom() {
|
|
271
|
+
return getFlow()?.viewport.zoom ?? 1;
|
|
260
272
|
}
|
|
261
273
|
};
|
|
262
274
|
|
|
@@ -335,6 +347,8 @@
|
|
|
335
347
|
nameConnectionPoints();
|
|
336
348
|
}
|
|
337
349
|
fitSoon();
|
|
350
|
+
const flow = getFlow();
|
|
351
|
+
if (flow) reportViewportZoom(flow.viewport);
|
|
338
352
|
onReady?.(handle);
|
|
339
353
|
});
|
|
340
354
|
|
|
@@ -356,12 +370,13 @@
|
|
|
356
370
|
<!--
|
|
357
371
|
`dir="ltr"` (see the note at the top): the canvas is drawn left to right in every language.
|
|
358
372
|
`isolate`: kaykay gives its layers z-indexes up to 10000; this keeps them inside the canvas, below the rest of the screen.
|
|
359
|
-
|
|
360
|
-
|
|
373
|
+
kaykay reads CSS variables from the canvas element (`.kaykay-canvas`) and from the node wrapper (`.kaykay-node`).
|
|
374
|
+
The grid of dots keeps kaykay's own faint colour: the design draws a flat surface, and the dots only help the eye while the
|
|
375
|
+
canvas is panned and zoomed.
|
|
361
376
|
-->
|
|
362
377
|
<div
|
|
363
378
|
bind:this={wrapperElement}
|
|
364
|
-
class="isolate h-full min-h-0 w-full overflow-hidden rounded-
|
|
379
|
+
class="isolate h-full min-h-0 w-full overflow-hidden [&_.kaykay-canvas]:[--kaykay-canvas-bg:var(--color-muted)] [&_.kaykay-node]:rounded-xl [&_.kaykay-node.selected:not(.status-error):not(.status-running):not(.status-completed)]:[--kaykay-node-selected-outline:transparent] [&_.kaykay-node.status-error]:[--kaykay-node-error-outline:transparent] [&_.kaykay-node]:[--kaykay-node-running-outline:var(--color-primary)] [&_.kaykay-node]:[--kaykay-node-completed-outline:var(--color-brand)] [&_.kaykay-handle]:[--kaykay-handle-input-bg:var(--color-background)] [&_.kaykay-handle]:[--kaykay-handle-input-border:var(--color-muted-foreground)] [&_.kaykay-handle]:[--kaykay-handle-output-bg:var(--color-background)] [&_.kaykay-handle]:[--kaykay-handle-output-border:var(--color-muted-foreground)] [&_.kaykay-handle]:[--kaykay-handle-can-connect-bg:var(--color-primary)] [&_.kaykay-handle]:[--kaykay-handle-can-connect-border:var(--color-primary)] {className}"
|
|
365
380
|
dir="ltr"
|
|
366
381
|
role="region"
|
|
367
382
|
aria-label={$t('workflows.canvas.label')}
|
|
@@ -374,7 +389,7 @@
|
|
|
374
389
|
config={flowConfig}
|
|
375
390
|
callbacks={flowCallbacks}
|
|
376
391
|
node_statuses={statuses}
|
|
377
|
-
class="
|
|
392
|
+
class="h-full w-full min-h-0"
|
|
378
393
|
bind:this={canvas}
|
|
379
394
|
/>
|
|
380
395
|
</div>
|
|
@@ -16,6 +16,8 @@ interface Props {
|
|
|
16
16
|
onSelectionChange?: (nodeIds: readonly string[], edgeIds: readonly string[]) => void;
|
|
17
17
|
/** The `B` key was pressed on the canvas: the owner opens its Add block menu. */
|
|
18
18
|
onAddBlockShortcut?: () => void;
|
|
19
|
+
/** Pan/zoom updates (toolbar zoom label); not every `on_change` includes the viewport. */
|
|
20
|
+
onViewportZoom?: (zoom: number) => void;
|
|
19
21
|
/** Gives the owner the handle once the canvas is on the screen, and `null` when it leaves. */
|
|
20
22
|
onReady?: (handle: CanvasHandle | null) => void;
|
|
21
23
|
class?: string;
|
|
@@ -8,8 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
How many visitors followed a line is not drawn here: the Runs tab has a chart of its own for that (`RunsFlow`).
|
|
10
10
|
|
|
11
|
-
Colours
|
|
12
|
-
theme like everything else on the screen.
|
|
11
|
+
Colours use design tokens (`var(--color-*)`) so the line follows the theme like everything else on the screen.
|
|
13
12
|
-->
|
|
14
13
|
<script lang="ts">
|
|
15
14
|
import { BaseEdge } from 'kaykay';
|
|
@@ -26,13 +25,13 @@
|
|
|
26
25
|
|
|
27
26
|
const color = $derived(
|
|
28
27
|
hasProblem
|
|
29
|
-
? 'var(--color-
|
|
28
|
+
? 'var(--color-destructive)'
|
|
30
29
|
: selected || isTaken
|
|
31
|
-
? 'var(--color-primary
|
|
32
|
-
: 'var(--color-
|
|
30
|
+
? 'var(--color-primary)'
|
|
31
|
+
: 'var(--color-muted-foreground)'
|
|
33
32
|
);
|
|
34
33
|
|
|
35
|
-
/**
|
|
34
|
+
/** Thicker stroke for a line the test visitor followed; selection adds another pixel in BaseEdge. */
|
|
36
35
|
const strokeWidth = $derived(isTaken ? 3 : 2);
|
|
37
36
|
</script>
|
|
38
37
|
|
|
@@ -38,7 +38,12 @@
|
|
|
38
38
|
}
|
|
39
39
|
</script>
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
<!--
|
|
42
|
+
The band between the tabs and the canvas (Figma "Banner wrapper": 8 around on a phone, 16 on a wider screen). It takes room
|
|
43
|
+
only while one of its lines is drawn: every line is a direct child with a `role` (an alert or a status), so a draft with
|
|
44
|
+
nothing to say leaves no gap above the canvas.
|
|
45
|
+
-->
|
|
46
|
+
<div class="hidden flex-col gap-2 px-2 pb-2 has-[>[role]]:flex @3xl:px-4 @3xl:pb-4">
|
|
42
47
|
<!-- First: a teammate who is editing decides what the rest of the screen lets the person do. -->
|
|
43
48
|
<PresenceBanner />
|
|
44
49
|
|
|
@@ -103,23 +108,25 @@
|
|
|
103
108
|
{/if}
|
|
104
109
|
|
|
105
110
|
{#if hasUnpublishedChanges}
|
|
106
|
-
<Notice>
|
|
111
|
+
<Notice tone="brand" icon="circleCheck">
|
|
107
112
|
{$t('workflows.banner.unpublishedChanges')}
|
|
108
113
|
{#snippet action()}
|
|
109
114
|
<ActionButton
|
|
115
|
+
variant="outline"
|
|
110
116
|
size="small"
|
|
111
117
|
disabled={editor.isReadOnly || editor.busy !== null}
|
|
112
118
|
onclick={() => (isAskingToDiscard = true)}>{$t('workflows.banner.discard')}</ActionButton
|
|
113
119
|
>
|
|
114
120
|
<ActionButton
|
|
115
|
-
variant="
|
|
121
|
+
variant="outline"
|
|
116
122
|
size="small"
|
|
117
123
|
disabled={!editor.canTryPublish}
|
|
118
124
|
onclick={onpublish}>{$t('workflows.banner.publishChanges')}</ActionButton
|
|
119
125
|
>
|
|
120
126
|
{/snippet}
|
|
121
127
|
</Notice>
|
|
122
|
-
{:else if editor.status === 'draft' && editor.viewing === null}
|
|
128
|
+
{:else if editor.status === 'draft' && editor.viewing === null && editor.tab !== 'runs'}
|
|
129
|
+
<!-- The Runs tab of a draft says the same in its own words (nothing to count before a publish), so it does not repeat it. -->
|
|
123
130
|
<Notice>{$t('workflows.banner.neverPublished')}</Notice>
|
|
124
131
|
{/if}
|
|
125
132
|
|
|
@@ -18,6 +18,9 @@
|
|
|
18
18
|
const editor = useEditorState();
|
|
19
19
|
const { t, locale } = useWorkflowsLanguage();
|
|
20
20
|
|
|
21
|
+
/** Updated from the canvas viewport so the toolbar percentage stays live while zooming. */
|
|
22
|
+
let canvasZoom = $state(1);
|
|
23
|
+
|
|
21
24
|
let toolbar = $state<ReturnType<typeof CanvasToolbar>>();
|
|
22
25
|
|
|
23
26
|
const words = $derived(
|
|
@@ -57,10 +60,12 @@
|
|
|
57
60
|
});
|
|
58
61
|
</script>
|
|
59
62
|
|
|
60
|
-
<div
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
63
|
+
<div
|
|
64
|
+
class="flex min-h-0 flex-1 flex-col gap-2 pb-2 pe-4 ps-4 pt-0 @3xl:flex-row @3xl:gap-4 @3xl:pb-4 @3xl:pe-4 @3xl:ps-4 @3xl:pt-0"
|
|
65
|
+
>
|
|
66
|
+
<div class="relative min-h-80 min-w-0 flex-1 @3xl:min-h-0">
|
|
67
|
+
<!-- Canvas surface: muted, clipped; toolbar is the only floating shadow (see CanvasToolbar). -->
|
|
68
|
+
<div class="relative h-full min-h-0 w-full overflow-hidden rounded-xl bg-muted">
|
|
64
69
|
<WorkflowCanvas
|
|
65
70
|
initialGraph={editor.graph}
|
|
66
71
|
readContext={() => context}
|
|
@@ -69,14 +74,16 @@
|
|
|
69
74
|
onGraphChange={(graph) => editor.acceptCanvasGraph(graph)}
|
|
70
75
|
onSelectionChange={(nodeIds, edgeIds) => editor.followSelection(nodeIds, edgeIds)}
|
|
71
76
|
onAddBlockShortcut={() => toolbar?.openAddBlock()}
|
|
77
|
+
onViewportZoom={(z) => (canvasZoom = z)}
|
|
72
78
|
onReady={(handle) => (editor.canvas = handle)}
|
|
73
79
|
/>
|
|
74
|
-
<CanvasToolbar bind:this={toolbar} canEdit={!editor.isReadOnly} />
|
|
80
|
+
<CanvasToolbar bind:this={toolbar} canEdit={!editor.isReadOnly} zoomLevel={canvasZoom} />
|
|
75
81
|
</div>
|
|
76
82
|
</div>
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
83
|
+
<!-- The panel only when there is something to show; without it the canvas has the whole width (Figma "Editor"). -->
|
|
84
|
+
{#if editor.showsSidePanel}
|
|
85
|
+
<div class="min-h-0 w-full shrink-0 @3xl:w-90 @3xl:shrink-0">
|
|
86
|
+
<SidePanel />
|
|
87
|
+
</div>
|
|
88
|
+
{/if}
|
|
82
89
|
</div>
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
import { useEditorState } from '../../editor/editorState.svelte.js';
|
|
12
12
|
import { useWorkflowsLanguage } from '../../i18n/language.js';
|
|
13
13
|
import type { WorkflowsMessageKey } from '../../i18n/messages.js';
|
|
14
|
+
import Tabs from '../ui/Tabs.svelte';
|
|
14
15
|
|
|
15
16
|
interface Props {
|
|
16
17
|
/** The id of the panel the tabs control; each tab's id is made from it. */
|
|
@@ -28,54 +29,19 @@
|
|
|
28
29
|
{ tab: 'settings', labelKey: 'workflows.tabs.settings' }
|
|
29
30
|
];
|
|
30
31
|
|
|
31
|
-
let tabListElement = $state<HTMLDivElement>();
|
|
32
|
-
|
|
33
32
|
function open(tab: EditorTab): void {
|
|
34
33
|
if (tab !== 'editor' && editor.viewing) editor.leaveVersion();
|
|
35
34
|
editor.tab = tab;
|
|
36
35
|
}
|
|
37
|
-
|
|
38
|
-
function handleKeydown(event: KeyboardEvent, index: number): void {
|
|
39
|
-
const isRightToLeft = tabListElement
|
|
40
|
-
? getComputedStyle(tabListElement).direction === 'rtl'
|
|
41
|
-
: false;
|
|
42
|
-
let nextIndex: number | null = null;
|
|
43
|
-
if (event.key === 'ArrowRight') nextIndex = index + (isRightToLeft ? -1 : 1);
|
|
44
|
-
else if (event.key === 'ArrowLeft') nextIndex = index + (isRightToLeft ? 1 : -1);
|
|
45
|
-
else if (event.key === 'Home') nextIndex = 0;
|
|
46
|
-
else if (event.key === 'End') nextIndex = TABS.length - 1;
|
|
47
|
-
if (nextIndex === null) return;
|
|
48
|
-
event.preventDefault();
|
|
49
|
-
const target = TABS[(nextIndex + TABS.length) % TABS.length];
|
|
50
|
-
if (!target) return;
|
|
51
|
-
open(target.tab);
|
|
52
|
-
tabListElement?.querySelector<HTMLButtonElement>(`[data-tab="${target.tab}"]`)?.focus();
|
|
53
|
-
}
|
|
54
36
|
</script>
|
|
55
37
|
|
|
56
|
-
<div
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
{
|
|
64
|
-
|
|
65
|
-
type="button"
|
|
66
|
-
role="tab"
|
|
67
|
-
id="{panelId}-tab-{item.tab}"
|
|
68
|
-
data-tab={item.tab}
|
|
69
|
-
aria-selected={isSelected}
|
|
70
|
-
aria-controls={panelId}
|
|
71
|
-
tabindex={isSelected ? 0 : -1}
|
|
72
|
-
class="-mb-px border-b-2 px-3 py-2 text-sm focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-primary-green {isSelected
|
|
73
|
-
? 'border-primary-green font-medium text-ink-primary'
|
|
74
|
-
: 'border-transparent text-ink-muted hover:text-ink-primary'}"
|
|
75
|
-
onclick={() => open(item.tab)}
|
|
76
|
-
onkeydown={(event) => handleKeydown(event, index)}
|
|
77
|
-
>
|
|
78
|
-
{$t(item.labelKey)}
|
|
79
|
-
</button>
|
|
80
|
-
{/each}
|
|
38
|
+
<div class="px-4 pb-3 pt-0">
|
|
39
|
+
<Tabs
|
|
40
|
+
idPrefix={panelId}
|
|
41
|
+
controls={panelId}
|
|
42
|
+
label={$t('workflows.tabs.label')}
|
|
43
|
+
tabs={TABS.map((item) => ({ key: item.tab, label: $t(item.labelKey) }))}
|
|
44
|
+
value={editor.tab}
|
|
45
|
+
onselect={(key) => open(key as EditorTab)}
|
|
46
|
+
/>
|
|
81
47
|
</div>
|