@widgetic/workflows 0.2.6 → 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.
Files changed (91) hide show
  1. package/README.md +51 -44
  2. package/dist/api/types.d.ts +17 -0
  3. package/dist/api/types.js +7 -0
  4. package/dist/api/workflowsApi.js +23 -2
  5. package/dist/components/Workflows.svelte +13 -15
  6. package/dist/components/WorkflowsEmptyState.svelte +14 -12
  7. package/dist/components/WorkflowsHeader.svelte +9 -5
  8. package/dist/components/WorkflowsHeader.svelte.d.ts +4 -16
  9. package/dist/components/WorkflowsWorkspace.svelte +3 -2
  10. package/dist/components/canvas/AddBlockMenu.svelte +11 -2
  11. package/dist/components/canvas/CanvasToolbar.svelte +42 -31
  12. package/dist/components/canvas/CanvasToolbar.svelte.d.ts +2 -0
  13. package/dist/components/canvas/CompositionNodeView.svelte +58 -36
  14. package/dist/components/canvas/ConditionNodeView.svelte +31 -18
  15. package/dist/components/canvas/HandlePoint.svelte +10 -3
  16. package/dist/components/canvas/HandlePoint.svelte.d.ts +1 -1
  17. package/dist/components/canvas/TriggerNodeView.svelte +39 -13
  18. package/dist/components/canvas/WorkflowCanvas.svelte +22 -7
  19. package/dist/components/canvas/WorkflowCanvas.svelte.d.ts +2 -0
  20. package/dist/components/canvas/WorkflowEdgeView.svelte +5 -6
  21. package/dist/components/editor/ConflictBanner.svelte +1 -1
  22. package/dist/components/editor/EditorBanners.svelte +11 -4
  23. package/dist/components/editor/EditorCanvasArea.svelte +17 -10
  24. package/dist/components/editor/EditorTabs.svelte +10 -44
  25. package/dist/components/editor/EditorTopBar.svelte +166 -54
  26. package/dist/components/editor/PresenceBanner.svelte +106 -85
  27. package/dist/components/editor/RunsFlow.svelte +136 -42
  28. package/dist/components/editor/RunsTab.svelte +52 -46
  29. package/dist/components/editor/SettingsRow.svelte +35 -0
  30. package/dist/components/editor/SettingsRow.svelte.d.ts +14 -0
  31. package/dist/components/editor/SettingsTab.svelte +66 -50
  32. package/dist/components/editor/WorkflowEditor.svelte +4 -5
  33. package/dist/components/list/CreateWorkflowDialog.svelte +123 -73
  34. package/dist/components/list/WorkflowList.svelte +227 -100
  35. package/dist/components/list/WorkflowRow.svelte +84 -42
  36. package/dist/components/panel/BlockProblems.svelte +9 -8
  37. package/dist/components/panel/CompositionForm.svelte +52 -34
  38. package/dist/components/panel/CompositionPicker.svelte +43 -21
  39. package/dist/components/panel/CompositionPicker.svelte.d.ts +5 -0
  40. package/dist/components/panel/CompositionSelect.svelte +105 -0
  41. package/dist/components/panel/CompositionSelect.svelte.d.ts +23 -0
  42. package/dist/components/panel/ConditionForm.svelte +50 -17
  43. package/dist/components/panel/EventValueRow.svelte +5 -4
  44. package/dist/components/panel/ProblemsList.svelte +17 -19
  45. package/dist/components/panel/RuleCard.svelte +127 -89
  46. package/dist/components/panel/RuleCard.svelte.d.ts +2 -0
  47. package/dist/components/panel/SidePanel.svelte +101 -50
  48. package/dist/components/panel/TestResultLine.svelte +35 -0
  49. package/dist/components/panel/TestResultLine.svelte.d.ts +9 -0
  50. package/dist/components/panel/TestRow.svelte +21 -18
  51. package/dist/components/panel/TestRunPanel.svelte +61 -39
  52. package/dist/components/panel/TestTriggerCard.svelte +66 -6
  53. package/dist/components/panel/TestTriggerCard.svelte.d.ts +10 -0
  54. package/dist/components/panel/TriggerForm.svelte +24 -25
  55. package/dist/components/panel/VersionHistory.svelte +31 -43
  56. package/dist/components/ui/ActionButton.svelte +44 -12
  57. package/dist/components/ui/ActionButton.svelte.d.ts +2 -1
  58. package/dist/components/ui/Badge.svelte +39 -0
  59. package/dist/components/ui/Badge.svelte.d.ts +12 -0
  60. package/dist/components/ui/ConfirmDialog.svelte +4 -3
  61. package/dist/components/ui/Menu.svelte +28 -14
  62. package/dist/components/ui/Menu.svelte.d.ts +3 -1
  63. package/dist/components/ui/Modal.svelte +15 -8
  64. package/dist/components/ui/Notice.svelte +35 -11
  65. package/dist/components/ui/Notice.svelte.d.ts +4 -1
  66. package/dist/components/ui/SelectField.svelte +48 -20
  67. package/dist/components/ui/SelectField.svelte.d.ts +2 -0
  68. package/dist/components/ui/StatusBadge.svelte +13 -24
  69. package/dist/components/ui/StatusBadge.svelte.d.ts +0 -2
  70. package/dist/components/ui/Tabs.svelte +79 -0
  71. package/dist/components/ui/Tabs.svelte.d.ts +21 -0
  72. package/dist/components/ui/TextField.svelte +47 -27
  73. package/dist/components/ui/TextField.svelte.d.ts +5 -0
  74. package/dist/components/ui/icons.d.ts +43 -29
  75. package/dist/components/ui/icons.js +101 -40
  76. package/dist/editor/editorState.svelte.d.ts +23 -2
  77. package/dist/editor/editorState.svelte.js +36 -0
  78. package/dist/editor/listState.svelte.d.ts +32 -2
  79. package/dist/editor/listState.svelte.js +41 -0
  80. package/dist/editor/runsFlow.d.ts +28 -3
  81. package/dist/editor/runsFlow.js +27 -2
  82. package/dist/editor/runsFlowLayout.d.ts +6 -2
  83. package/dist/editor/runsFlowLayout.js +7 -2
  84. package/dist/editor/statsRange.d.ts +7 -1
  85. package/dist/editor/statsRange.js +14 -0
  86. package/dist/i18n/language.d.ts +3 -3
  87. package/dist/i18n/messages.d.ts +32 -13
  88. package/dist/i18n/messages.js +33 -14
  89. package/dist/i18n/statusWords.d.ts +12 -0
  90. package/dist/i18n/statusWords.js +12 -0
  91. package/package.json +3 -3
@@ -19,10 +19,11 @@
19
19
  } from '../../editor/flowAdapter.js';
20
20
  import { useCanvasContext } from '../../editor/canvasContext.js';
21
21
  import { useWorkflowsLanguage } from '../../i18n/language.js';
22
+ import Badge from '../ui/Badge.svelte';
22
23
  import Icon from '../ui/Icon.svelte';
23
24
  import HandlePoint from './HandlePoint.svelte';
24
25
 
25
- let { id, data }: NodeProps<WorkflowBlockData> = $props();
26
+ let { id, data, selected, status }: NodeProps<WorkflowBlockData> = $props();
26
27
 
27
28
  const { t } = useWorkflowsLanguage();
28
29
  const textDirection = useTextDirection();
@@ -42,7 +43,16 @@
42
43
  if (composition === null) return $t('workflows.block.compositionUnavailable');
43
44
  return composition?.name?.trim() ? composition.name : $t('workflows.block.compositionLoading');
44
45
  });
45
- const isTitleMissing = $derived(!node.compositionId || composition === null);
46
+ const isEmpty = $derived(!node.compositionId);
47
+ const isTitleMuted = $derived(isEmpty || composition === null);
48
+
49
+ const metaLine = $derived.by(() => {
50
+ if (isEmpty) return $t('workflows.block.emptyCompositionHelp');
51
+ if (composition === null || composition === undefined) return '';
52
+ return composition.published
53
+ ? $t('workflows.block.publishedMeta')
54
+ : $t('workflows.block.draftMeta');
55
+ });
46
56
 
47
57
  /** A picture that failed to load is left out, and the block looks as it would without one. It is tried again for another address. */
48
58
  const thumbnailUrl = $derived(composition?.thumbnailUrl ?? null);
@@ -50,50 +60,62 @@
50
60
  const hasThumbnailFailed = $derived(
51
61
  failedThumbnailUrl !== null && failedThumbnailUrl === thumbnailUrl
52
62
  );
63
+
64
+ const rootBorder = $derived.by(() => {
65
+ if (status === 'error') return 'border-2 border-destructive';
66
+ if (selected) return 'border-2 border-primary';
67
+ if (isEmpty) return 'border border-dashed border-input';
68
+ return 'border border-border';
69
+ });
53
70
  </script>
54
71
 
55
72
  <div
56
- class="relative flex w-64 flex-col gap-2 rounded-large border border-grey2 bg-white p-3 text-start text-ink-primary shadow-sm"
73
+ class="relative flex w-60 flex-col overflow-hidden rounded-xl bg-background text-start text-foreground {rootBorder}"
57
74
  dir={$textDirection}
58
75
  data-workflow-block="composition"
59
76
  >
60
- <div class="flex items-center gap-2">
61
- <Icon name="composition" class="size-4 text-ink-muted" />
62
- <p
63
- class="min-w-0 flex-1 truncate text-sm font-medium {isTitleMissing ? 'text-ink-muted' : ''}"
64
- dir={isTitleMissing ? undefined : 'auto'}
65
- >
66
- {title}
67
- </p>
77
+ <div class="relative h-28 w-full shrink-0 overflow-hidden rounded-t-xl bg-muted">
78
+ {#if thumbnailUrl && !hasThumbnailFailed}
79
+ <img
80
+ src={thumbnailUrl}
81
+ alt=""
82
+ loading="lazy"
83
+ draggable="false"
84
+ class="h-full w-full object-cover"
85
+ onerror={() => (failedThumbnailUrl = thumbnailUrl)}
86
+ />
87
+ {:else}
88
+ <div class="flex h-full w-full items-center justify-center">
89
+ <Icon name="composition" class="size-4 text-muted-foreground" />
90
+ </div>
91
+ {/if}
68
92
  {#if node.startsHere}
69
- <span
70
- class="shrink-0 rounded-pill border border-primary-green px-2 py-0.5 text-xs text-primary-green"
71
- >
72
- {$t('workflows.block.startsHere')}
73
- </span>
93
+ <div class="absolute top-2 start-2">
94
+ <Badge tone="brand">{$t('workflows.block.startsHere')}</Badge>
95
+ </div>
74
96
  {/if}
75
97
  </div>
76
98
 
77
- {#if thumbnailUrl && !hasThumbnailFailed}
78
- <img
79
- src={thumbnailUrl}
80
- alt=""
81
- loading="lazy"
82
- draggable="false"
83
- class="h-24 w-full rounded-medium border border-grey2 object-cover"
84
- onerror={() => (failedThumbnailUrl = thumbnailUrl)}
85
- />
86
- {/if}
87
-
88
- {#if composition && !composition.published}
89
- <p class="text-xs text-ink-muted">{$t('workflows.block.notPublished')}</p>
90
- {/if}
91
- {#if problemCount > 0}
92
- <p class="flex items-center gap-1 text-xs text-error">
93
- <Icon name="warning" class="size-3.5" />
94
- {$t('workflows.block.problems', { count: problemCount })}
95
- </p>
96
- {/if}
99
+ <div class="flex flex-col gap-0.5 p-3">
100
+ <div class="flex items-start gap-2">
101
+ <p
102
+ class="min-w-0 flex-1 truncate text-body-medium {isTitleMuted
103
+ ? 'text-muted-foreground'
104
+ : 'text-foreground'}"
105
+ dir={isTitleMuted ? undefined : 'auto'}
106
+ >
107
+ {title}
108
+ </p>
109
+ {#if problemCount > 0}
110
+ <Badge tone="destructive" class="shrink-0">
111
+ {$t('workflows.block.problems', { count: problemCount })}
112
+ </Badge>
113
+ {/if}
114
+ </div>
115
+ {#if metaLine}
116
+ <p class="text-caption text-muted-foreground">{metaLine}</p>
117
+ {/if}
118
+ </div>
97
119
 
98
120
  <HandlePoint
99
121
  id={INPUT_HANDLE_ID}
@@ -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-72 flex-col gap-1 rounded-large border border-grey2 bg-white py-3 text-start text-ink-primary shadow-sm"
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-3 pb-1">
50
- <Icon name="condition" class="size-4 text-ink-muted" />
51
- <p class="min-w-0 flex-1 truncate text-xs font-medium text-ink-muted">
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-grey2 px-3 py-2">
65
- <p class="truncate pe-3 text-sm font-medium" dir="auto">{nameRule(rule, index, $t)}</p>
66
- <p class="line-clamp-2 pe-3 text-xs text-ink-muted" dir="auto">
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-grey2 px-3 py-2">
74
- <p class="truncate pe-3 text-sm font-medium">{$t('workflows.condition.defaultName')}</p>
75
- <p class="text-xs text-ink-muted">
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 {id} {type} {port} accept={accept ? [...accept] : undefined} {position} class="group">
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-3.5 rounded-pill border-2 border-ink-subtle bg-white transition-colors group-hover:border-primary-green group-[.can-connect]:border-primary-green group-[.can-connect]:bg-primary-green group-[.connecting]:border-primary-green group-[.connecting]:bg-primary-green"
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-60 flex-col gap-1.5 rounded-large border border-grey2 bg-white p-3 text-start text-ink-primary shadow-sm"
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
- <Icon name="trigger" class="size-4 text-ink-muted" />
43
- <p class="min-w-0 flex-1 truncate text-xs font-medium text-ink-muted">
44
- {$t(TRIGGER_KIND_MESSAGE_KEYS[node.trigger.kind])}
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-sm break-words" dir="auto">{summary}</p>
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 the
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
- The two `--kaykay-*` lines below the canvas colour are what kaykay reads from the element around it; its own background
360
- variable is set on the canvas element itself, so it needs the `!`.
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-large border border-grey2 [--kaykay-node-completed-outline:var(--color-primary-green)] [--kaykay-node-error-outline:var(--color-error)] [--kaykay-node-running-outline:var(--color-forest-green)] [--kaykay-node-selected-outline:var(--color-primary-green)] [&_.kaykay-node]:rounded-large {className}"
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="[--kaykay-canvas-bg:var(--color-surface-canvas)]!"
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 are the palette's custom properties (`--color-*`), which the page or a ui-sdk theme sets, so the line follows the
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-error)'
28
+ ? 'var(--color-destructive)'
30
29
  : selected || isTaken
31
- ? 'var(--color-primary-green)'
32
- : 'var(--color-ink-subtle)'
30
+ ? 'var(--color-primary)'
31
+ : 'var(--color-muted-foreground)'
33
32
  );
34
33
 
35
- /** 2 pixels, 3 for a line a test visitor followed. */
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
 
@@ -71,7 +71,7 @@
71
71
  title={$t('workflows.conflict.loadTitle')}
72
72
  message={$t('workflows.conflict.loadMessage')}
73
73
  confirmLabel={$t('workflows.banner.reload')}
74
- tone="danger"
74
+ tone="normal"
75
75
  onconfirm={loadLatest}
76
76
  oncancel={() => (isAskingToLoad = false)}
77
77
  />
@@ -38,7 +38,12 @@
38
38
  }
39
39
  </script>
40
40
 
41
- <div class="flex flex-col gap-2">
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="primary"
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 class="flex min-h-0 flex-1 flex-col @3xl:flex-row">
61
- <div class="min-h-80 min-w-0 flex-1 p-3">
62
- <!-- The tools are laid over the canvas, in its own corner. -->
63
- <div class="relative h-full min-h-0 w-full">
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
- <div
78
- class="flex max-h-[60%] min-h-0 shrink-0 flex-col border-t border-grey2 @3xl:max-h-none @3xl:w-96 @3xl:border-s @3xl:border-t-0"
79
- >
80
- <SidePanel />
81
- </div>
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
- bind:this={tabListElement}
58
- role="tablist"
59
- aria-label={$t('workflows.tabs.label')}
60
- class="flex gap-1 border-b border-grey2 px-4"
61
- >
62
- {#each TABS as item, index (item.tab)}
63
- {@const isSelected = editor.tab === item.tab}
64
- <button
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>