@widgetic/workflows 0.2.15 → 0.2.16
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 +117 -3
- package/dist/api/types.d.ts +17 -0
- package/dist/api/workflowsApi.d.ts +12 -1
- package/dist/api/workflowsApi.js +37 -0
- package/dist/assistant/assistantEvents.d.ts +44 -2
- package/dist/assistant/assistantEvents.js +58 -2
- package/dist/assistant/assistantReferences.d.ts +66 -0
- package/dist/assistant/assistantReferences.js +109 -0
- package/dist/assistant/assistantSaveMode.d.ts +15 -3
- package/dist/assistant/assistantSaveMode.js +16 -2
- package/dist/assistant/assistantSeed.d.ts +55 -0
- package/dist/assistant/assistantSeed.js +90 -0
- package/dist/assistant/assistantStream.js +81 -3
- package/dist/assistant/assistantSuggest.d.ts +18 -0
- package/dist/assistant/assistantSuggest.js +21 -0
- package/dist/assistant/assistantTurns.d.ts +75 -0
- package/dist/assistant/assistantTurns.js +56 -0
- package/dist/assistant/attachmentUploads.d.ts +42 -0
- package/dist/assistant/attachmentUploads.js +69 -0
- package/dist/assistant/canvasLink.d.ts +30 -0
- package/dist/assistant/canvasLink.js +51 -0
- package/dist/assistant/compositionMention.d.ts +18 -0
- package/dist/assistant/compositionMention.js +47 -0
- package/dist/assistant/liveData.d.ts +150 -0
- package/dist/assistant/liveData.js +286 -0
- package/dist/assistant/mcpMention.d.ts +20 -0
- package/dist/assistant/mcpMention.js +30 -0
- package/dist/assistant/mentionEntries.d.ts +39 -0
- package/dist/assistant/mentionEntries.js +69 -0
- package/dist/assistant/planFlow.d.ts +26 -0
- package/dist/assistant/planFlow.js +57 -0
- package/dist/assistant/templateDestinations.d.ts +37 -0
- package/dist/assistant/templateDestinations.js +64 -0
- package/dist/assistant/types.d.ts +99 -2
- package/dist/assistant/workflowPlanViewModel.d.ts +13 -2
- package/dist/assistant/workflowPlanViewModel.js +9 -1
- package/dist/components/Workflows.svelte +7 -1
- package/dist/components/WorkflowsWorkspace.svelte +29 -1
- package/dist/components/WorkflowsWorkspace.svelte.d.ts +3 -0
- package/dist/components/assistant/AssistantPlanStepRow.svelte +56 -0
- package/dist/components/assistant/AssistantPlanStepRow.svelte.d.ts +9 -0
- package/dist/components/assistant/CompositionMentionMenu.svelte +135 -0
- package/dist/components/assistant/CompositionMentionMenu.svelte.d.ts +9 -0
- package/dist/components/assistant/DataPreviewCard.svelte +108 -0
- package/dist/components/assistant/DataPreviewCard.svelte.d.ts +7 -0
- package/dist/components/assistant/PlanBindingsBlock.svelte +200 -0
- package/dist/components/assistant/PlanBindingsBlock.svelte.d.ts +14 -0
- package/dist/components/assistant/TemplateProjectCard.svelte +81 -0
- package/dist/components/assistant/TemplateProjectCard.svelte.d.ts +14 -0
- package/dist/components/assistant/WorkflowAssistantPanel.svelte +1045 -147
- package/dist/components/assistant/WorkflowAssistantPanel.svelte.d.ts +5 -0
- package/dist/components/canvas/CanvasContextMenu.svelte +199 -0
- package/dist/components/canvas/CanvasContextMenu.svelte.d.ts +16 -0
- package/dist/components/canvas/CompositionNodeView.svelte +7 -2
- package/dist/components/canvas/ConditionNodeView.svelte +5 -1
- package/dist/components/canvas/HandlePoint.svelte +25 -3
- package/dist/components/canvas/WorkflowCanvas.svelte +351 -12
- package/dist/components/canvas/WorkflowCanvas.svelte.d.ts +12 -1
- package/dist/components/canvas/altDragDuplicateController.d.ts +29 -0
- package/dist/components/canvas/altDragDuplicateController.js +92 -0
- package/dist/components/canvas/connectionSnapController.d.ts +29 -0
- package/dist/components/canvas/connectionSnapController.js +182 -0
- package/dist/components/canvas/spacePanController.d.ts +16 -0
- package/dist/components/canvas/spacePanController.js +103 -0
- package/dist/components/editor/EditorCanvasArea.svelte +98 -4
- package/dist/components/editor/EditorCanvasArea.svelte.d.ts +5 -0
- package/dist/components/editor/EditorTopBar.svelte +53 -42
- package/dist/components/editor/WorkflowEditor.svelte +74 -41
- package/dist/components/editor/WorkflowEditor.svelte.d.ts +5 -0
- package/dist/components/editor/WorkflowNameControl.svelte +9 -8
- package/dist/components/editor/WorkflowNameControl.svelte.d.ts +3 -1
- package/dist/components/list/WorkflowList.svelte +34 -20
- package/dist/components/list/WorkflowList.svelte.d.ts +5 -0
- package/dist/components/panel/CompositionForm.svelte +3 -2
- package/dist/components/panel/CompositionPicker.svelte +15 -20
- package/dist/components/panel/CompositionPicker.svelte.d.ts +2 -2
- package/dist/components/panel/CompositionSelect.svelte +4 -4
- package/dist/components/panel/CompositionSelect.svelte.d.ts +2 -2
- package/dist/components/ui/icons.d.ts +8 -0
- package/dist/components/ui/icons.js +24 -1
- package/dist/editor/autoLayout.d.ts +38 -0
- package/dist/editor/autoLayout.js +403 -0
- package/dist/editor/blockClipboard.svelte.d.ts +9 -0
- package/dist/editor/blockClipboard.svelte.js +24 -0
- package/dist/editor/blockCopy.d.ts +39 -0
- package/dist/editor/blockCopy.js +137 -0
- package/dist/editor/canvasMenu.d.ts +45 -0
- package/dist/editor/canvasMenu.js +68 -0
- package/dist/editor/connectionSnap.d.ts +90 -0
- package/dist/editor/connectionSnap.js +98 -0
- package/dist/editor/editorState.svelte.d.ts +122 -13
- package/dist/editor/editorState.svelte.js +262 -22
- package/dist/editor/graphIssues.d.ts +5 -0
- package/dist/editor/graphIssues.js +18 -0
- package/dist/editor/graphModel.d.ts +6 -1
- package/dist/editor/graphModel.js +8 -1
- package/dist/editor/keyHints.d.ts +21 -0
- package/dist/editor/keyHints.js +30 -0
- package/dist/editor/listState.svelte.d.ts +4 -4
- package/dist/editor/staleGuard.d.ts +111 -0
- package/dist/editor/staleGuard.js +279 -0
- package/dist/i18n/language.d.ts +3 -3
- package/dist/i18n/messages.d.ts +84 -1
- package/dist/i18n/messages.js +97 -4
- package/dist/index.d.ts +1 -0
- package/dist/types/index.d.ts +19 -2
- package/package.json +10 -10
|
@@ -7,7 +7,9 @@
|
|
|
7
7
|
the person is asked before it is thrown away.
|
|
8
8
|
|
|
9
9
|
What it listens to outside itself it takes back when it goes: the media query for a screen touched by a finger, and the
|
|
10
|
-
page being put away (which sends what is waiting, as far as the browser lets it).
|
|
10
|
+
page being put away (which sends what is waiting, as far as the browser lets it). The editor's stale-tab guard listens
|
|
11
|
+
to the tab coming back; while it takes a newer draft (saved by the assistant, an MCP client, another tab) the whole
|
|
12
|
+
editor sits under a dark overlay that fades in and out, so nothing is changed on a draft that is out of date.
|
|
11
13
|
-->
|
|
12
14
|
<script lang="ts">
|
|
13
15
|
import { onDestroy, onMount, untrack } from 'svelte';
|
|
@@ -15,8 +17,10 @@
|
|
|
15
17
|
import { WorkflowEditorState, provideEditorState } from '../../editor/editorState.svelte.js';
|
|
16
18
|
import { useWorkflowsLanguage } from '../../i18n/language.js';
|
|
17
19
|
import type { DraftRestoredInfo } from '../../drafts/workflowDraft.js';
|
|
20
|
+
import type { ReadyAssistantSeed } from '../../assistant/assistantSeed.js';
|
|
18
21
|
import type { WorkflowAssistantConfig } from '../../assistant/types.js';
|
|
19
22
|
import type { WorkflowsError } from '../../types/index.js';
|
|
23
|
+
import { ContentRefreshOverlay } from '@widgetic/design-system/components';
|
|
20
24
|
import ConfirmDialog from '../ui/ConfirmDialog.svelte';
|
|
21
25
|
import EditorBanners from './EditorBanners.svelte';
|
|
22
26
|
import EditorCanvasArea from './EditorCanvasArea.svelte';
|
|
@@ -41,6 +45,10 @@
|
|
|
41
45
|
/** Called when unsaved edits were restored from the draft journal after load. */
|
|
42
46
|
onDraftRestored?: (info: DraftRestoredInfo) => void;
|
|
43
47
|
assistant?: WorkflowAssistantConfig | null;
|
|
48
|
+
/** The first message the page left waiting for the assistant of this workflow (already checked to be for it). */
|
|
49
|
+
assistantSeed?: ReadyAssistantSeed | null;
|
|
50
|
+
/** The assistant took the seed in, or left it alone because the person had begun: the page may stop holding it. */
|
|
51
|
+
onassistantseedapplied?: (workflowId: string) => void;
|
|
44
52
|
}
|
|
45
53
|
|
|
46
54
|
let {
|
|
@@ -51,7 +59,9 @@
|
|
|
51
59
|
onshowembedcode,
|
|
52
60
|
presence = false,
|
|
53
61
|
onDraftRestored,
|
|
54
|
-
assistant = null
|
|
62
|
+
assistant = null,
|
|
63
|
+
assistantSeed = null,
|
|
64
|
+
onassistantseedapplied
|
|
55
65
|
}: Props = $props();
|
|
56
66
|
|
|
57
67
|
const api = useWorkflowsApi();
|
|
@@ -74,10 +84,21 @@
|
|
|
74
84
|
|
|
75
85
|
let isAskingToPublish = $state(false);
|
|
76
86
|
let isAskingToLeave = $state(false);
|
|
87
|
+
// Open when the workflow is opened, so the message the page left for the assistant is in front of the person at once.
|
|
77
88
|
let assistantPanelOpen = $state(true);
|
|
78
89
|
|
|
79
90
|
const assistantEnabled = $derived(Boolean(assistant?.enabled));
|
|
80
91
|
|
|
92
|
+
// Read once, like the workflow: a seed belongs to this opening of it, so one that arrives later is not used. The assistant's panel
|
|
93
|
+
// is drawn again each time the person comes back to the Editor tab, and the page's message is written to its composer only the
|
|
94
|
+
// first time: once the panel has taken the seed in, nothing is handed over again.
|
|
95
|
+
let seedWaiting = $state.raw<ReadyAssistantSeed | null>(untrack(() => assistantSeed));
|
|
96
|
+
|
|
97
|
+
function noteSeedUsed(): void {
|
|
98
|
+
seedWaiting = null;
|
|
99
|
+
onassistantseedapplied?.(workflowId);
|
|
100
|
+
}
|
|
101
|
+
|
|
81
102
|
function toggleAssistantPanel(): void {
|
|
82
103
|
assistantPanelOpen = !assistantPanelOpen;
|
|
83
104
|
}
|
|
@@ -118,6 +139,8 @@
|
|
|
118
139
|
void editor.load();
|
|
119
140
|
// Who else is editing is asked alongside the load (it needs only the workflow's id); nothing happens without `presence`.
|
|
120
141
|
editor.startPresence();
|
|
142
|
+
// A tab that comes back after the draft was saved somewhere else (assistant, MCP, another tab) takes it behind the overlay.
|
|
143
|
+
editor.startStaleGuard();
|
|
121
144
|
|
|
122
145
|
// A finger cannot draw a line between two small points: on a touch screen the canvas only shows (the panel edits).
|
|
123
146
|
const touchQuery = window.matchMedia('(pointer: coarse)');
|
|
@@ -145,45 +168,55 @@
|
|
|
145
168
|
</script>
|
|
146
169
|
|
|
147
170
|
<div class="@container flex h-full min-h-0 w-full flex-col" data-workflows-editor>
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
171
|
+
<!-- Dark overlay while a newer draft is taken (the stale-tab guard): the editor under it cannot be touched. -->
|
|
172
|
+
<ContentRefreshOverlay
|
|
173
|
+
active={editor.staleGuardPhase === 'updating'}
|
|
174
|
+
message={$t('workflows.stale.updating')}
|
|
175
|
+
description={$t('workflows.stale.updatingDescription')}
|
|
176
|
+
class="flex h-full min-h-0 w-full flex-col"
|
|
177
|
+
>
|
|
178
|
+
{#if editor.loadState === 'loading'}
|
|
179
|
+
<p class="m-auto py-8 text-body text-muted-foreground" role="status">
|
|
180
|
+
{$t('workflows.common.loading')}
|
|
181
|
+
</p>
|
|
182
|
+
{:else if editor.loadState === 'failed'}
|
|
183
|
+
<EditorLoadFailure {onback} />
|
|
184
|
+
{:else}
|
|
185
|
+
<EditorTopBar
|
|
186
|
+
onback={() => void goBack()}
|
|
187
|
+
onpublish={requestPublish}
|
|
188
|
+
onshowembedcode={showEmbedCode}
|
|
189
|
+
assistantEnabled={assistantEnabled}
|
|
190
|
+
assistantOpen={assistantPanelOpen}
|
|
191
|
+
onToggleAssistant={toggleAssistantPanel}
|
|
192
|
+
/>
|
|
193
|
+
<EditorTabs {panelId} />
|
|
194
|
+
<EditorBanners />
|
|
195
|
+
<div
|
|
196
|
+
id={panelId}
|
|
197
|
+
role="tabpanel"
|
|
198
|
+
aria-labelledby="{panelId}-tab-{editor.tab}"
|
|
199
|
+
class="flex min-h-0 flex-1 min-w-0 flex-col"
|
|
200
|
+
>
|
|
201
|
+
{#if editor.tab === 'editor'}
|
|
202
|
+
<EditorCanvasArea
|
|
203
|
+
{assistant}
|
|
204
|
+
assistantSeed={seedWaiting}
|
|
205
|
+
onAssistantSeedApplied={noteSeedUsed}
|
|
206
|
+
assistantOpen={assistantPanelOpen}
|
|
207
|
+
onOpenAssistant={openAssistantPanel}
|
|
208
|
+
workflowId={workflowId}
|
|
209
|
+
/>
|
|
210
|
+
{:else if editor.tab === 'runs'}
|
|
211
|
+
<RunsTab />
|
|
212
|
+
{:else}
|
|
213
|
+
<div class="min-h-0 flex-1 overflow-auto">
|
|
214
|
+
<SettingsTab onshowembedcode={showEmbedCode} />
|
|
215
|
+
</div>
|
|
216
|
+
{/if}
|
|
217
|
+
</div>
|
|
218
|
+
{/if}
|
|
219
|
+
</ContentRefreshOverlay>
|
|
187
220
|
</div>
|
|
188
221
|
|
|
189
222
|
{#if isAskingToPublish}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { DraftRestoredInfo } from '../../drafts/workflowDraft.js';
|
|
2
|
+
import type { ReadyAssistantSeed } from '../../assistant/assistantSeed.js';
|
|
2
3
|
import type { WorkflowAssistantConfig } from '../../assistant/types.js';
|
|
3
4
|
import type { WorkflowsError } from '../../types/index.js';
|
|
4
5
|
interface Props {
|
|
@@ -16,6 +17,10 @@ interface Props {
|
|
|
16
17
|
/** Called when unsaved edits were restored from the draft journal after load. */
|
|
17
18
|
onDraftRestored?: (info: DraftRestoredInfo) => void;
|
|
18
19
|
assistant?: WorkflowAssistantConfig | null;
|
|
20
|
+
/** The first message the page left waiting for the assistant of this workflow (already checked to be for it). */
|
|
21
|
+
assistantSeed?: ReadyAssistantSeed | null;
|
|
22
|
+
/** The assistant took the seed in, or left it alone because the person had begun: the page may stop holding it. */
|
|
23
|
+
onassistantseedapplied?: (workflowId: string) => void;
|
|
19
24
|
}
|
|
20
25
|
declare const WorkflowEditor: import("svelte").Component<Props, {}, "">;
|
|
21
26
|
type WorkflowEditor = ReturnType<typeof WorkflowEditor>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<!--
|
|
2
2
|
The workflow name in the editor header: plain text until the person hovers and chooses to edit it, then a field that
|
|
3
|
-
commits on Enter or blur and cancels on Escape.
|
|
3
|
+
commits on Enter or blur and cancels on Escape. In edit mode the field uses a soft accent fill and grows wider than the title.
|
|
4
4
|
-->
|
|
5
5
|
<script lang="ts">
|
|
6
6
|
import { tick } from 'svelte';
|
|
@@ -17,6 +17,8 @@
|
|
|
17
17
|
readonly?: boolean;
|
|
18
18
|
maxlength?: number;
|
|
19
19
|
class?: string;
|
|
20
|
+
/** Whether the person is renaming (for siblings that sit beside the field). */
|
|
21
|
+
isEditing?: boolean;
|
|
20
22
|
oncommit: (name: string) => void;
|
|
21
23
|
}
|
|
22
24
|
|
|
@@ -28,10 +30,10 @@
|
|
|
28
30
|
readonly = false,
|
|
29
31
|
maxlength = MAX_WORKFLOW_NAME_LENGTH,
|
|
30
32
|
class: className = '',
|
|
33
|
+
isEditing = $bindable(false),
|
|
31
34
|
oncommit
|
|
32
35
|
}: Props = $props();
|
|
33
36
|
|
|
34
|
-
let isEditing = $state(false);
|
|
35
37
|
let draft = $state('');
|
|
36
38
|
let inputElement = $state<HTMLInputElement | null>(null);
|
|
37
39
|
let nameButton = $state<HTMLButtonElement | null>(null);
|
|
@@ -66,7 +68,6 @@
|
|
|
66
68
|
}
|
|
67
69
|
isEditing = false;
|
|
68
70
|
editor.setPendingWorkflowName(null);
|
|
69
|
-
// The name button is not in the page until the update that follows `isEditing = false`, so it takes the focus after it.
|
|
70
71
|
if (restoreFocus) void tick().then(() => nameButton?.focus());
|
|
71
72
|
}
|
|
72
73
|
|
|
@@ -94,13 +95,13 @@
|
|
|
94
95
|
}
|
|
95
96
|
</script>
|
|
96
97
|
|
|
97
|
-
<div class="min-w-0 {className}">
|
|
98
|
+
<div class="min-w-0 shrink {className}">
|
|
98
99
|
{#if isEditing}
|
|
99
100
|
<input
|
|
100
101
|
bind:this={inputElement}
|
|
101
102
|
id={fieldId}
|
|
102
103
|
type="text"
|
|
103
|
-
class="workflow-name-control-input
|
|
104
|
+
class="workflow-name-control-input h-9 min-w-[8rem] max-w-[min(100%,32rem)] shrink-0 rounded-lg border border-transparent bg-accent px-2 py-1.5 text-body-medium text-foreground outline-none transition-colors focus-visible:ring-2 focus-visible:ring-ring"
|
|
104
105
|
bind:value={draft}
|
|
105
106
|
oninput={handleDraftInput}
|
|
106
107
|
{maxlength}
|
|
@@ -111,7 +112,7 @@
|
|
|
111
112
|
{:else if readonly}
|
|
112
113
|
<p
|
|
113
114
|
id={fieldId}
|
|
114
|
-
class="workflow-name-control-view min-w-0 truncate px-2 py-1.5 text-body-medium text-foreground"
|
|
115
|
+
class="workflow-name-control-view min-w-0 max-w-full truncate px-2 py-1.5 text-body-medium text-foreground"
|
|
115
116
|
dir="auto"
|
|
116
117
|
>
|
|
117
118
|
{name}
|
|
@@ -121,12 +122,12 @@
|
|
|
121
122
|
bind:this={nameButton}
|
|
122
123
|
id={fieldId}
|
|
123
124
|
type="button"
|
|
124
|
-
class="workflow-name-control-view group flex w-full min-w-0 items-center gap-1.5 rounded-
|
|
125
|
+
class="workflow-name-control-view group flex max-w-full min-w-0 shrink items-center gap-1.5 rounded-lg border border-transparent px-2 py-1.5 text-start text-body-medium text-foreground transition-colors hover:cursor-text hover:bg-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
|
|
125
126
|
aria-label={label}
|
|
126
127
|
onclick={beginEditing}
|
|
127
128
|
onkeydown={handleViewKeydown}
|
|
128
129
|
>
|
|
129
|
-
<span class="min-w-0
|
|
130
|
+
<span class="min-w-0 truncate" dir="auto">{name}</span>
|
|
130
131
|
<Icon
|
|
131
132
|
name="pencil"
|
|
132
133
|
class="size-3.5 shrink-0 text-muted-foreground opacity-0 transition-opacity group-hover:opacity-100 group-focus-visible:opacity-100"
|
|
@@ -6,8 +6,10 @@ interface Props {
|
|
|
6
6
|
readonly?: boolean;
|
|
7
7
|
maxlength?: number;
|
|
8
8
|
class?: string;
|
|
9
|
+
/** Whether the person is renaming (for siblings that sit beside the field). */
|
|
10
|
+
isEditing?: boolean;
|
|
9
11
|
oncommit: (name: string) => void;
|
|
10
12
|
}
|
|
11
|
-
declare const WorkflowNameControl: import("svelte").Component<Props, {}, "">;
|
|
13
|
+
declare const WorkflowNameControl: import("svelte").Component<Props, {}, "isEditing">;
|
|
12
14
|
type WorkflowNameControl = ReturnType<typeof WorkflowNameControl>;
|
|
13
15
|
export default WorkflowNameControl;
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
import Notice from '../ui/Notice.svelte';
|
|
36
36
|
import SelectField from '../ui/SelectField.svelte';
|
|
37
37
|
import Tabs from '../ui/Tabs.svelte';
|
|
38
|
-
import
|
|
38
|
+
import { SearchInput } from '@widgetic/design-system/components';
|
|
39
39
|
import type { SelectChoice } from '../ui/types.js';
|
|
40
40
|
import WorkflowRow from './WorkflowRow.svelte';
|
|
41
41
|
|
|
@@ -55,6 +55,11 @@
|
|
|
55
55
|
presence?: boolean;
|
|
56
56
|
/** From Dexie via the host layout load — default list paints before `load()` runs. */
|
|
57
57
|
initialListPage?: { items: readonly import('../../api/types.js').WorkflowListItem[]; total: number } | null;
|
|
58
|
+
/**
|
|
59
|
+
* Host-built localStorage key for recent workflow searches (per person, workspace, page). Empty string leaves the
|
|
60
|
+
* field without a recents panel.
|
|
61
|
+
*/
|
|
62
|
+
recentSearchesKey?: string;
|
|
58
63
|
}
|
|
59
64
|
|
|
60
65
|
let {
|
|
@@ -63,7 +68,8 @@
|
|
|
63
68
|
onerror,
|
|
64
69
|
onshowembedcode,
|
|
65
70
|
presence = false,
|
|
66
|
-
initialListPage = null
|
|
71
|
+
initialListPage = null,
|
|
72
|
+
recentSearchesKey = ''
|
|
67
73
|
}: Props = $props();
|
|
68
74
|
|
|
69
75
|
const api = useWorkflowsApi();
|
|
@@ -166,16 +172,20 @@
|
|
|
166
172
|
<WorkflowsHeader class="min-w-0 shrink" />
|
|
167
173
|
{#if !isLibraryEmpty}
|
|
168
174
|
<div class="flex min-w-0 shrink-0 items-center gap-2">
|
|
169
|
-
<
|
|
170
|
-
|
|
171
|
-
type="search"
|
|
172
|
-
variant="soft"
|
|
173
|
-
icon="search"
|
|
174
|
-
label={$t('workflows.list.searchLabel')}
|
|
175
|
-
placeholder={$t('workflows.list.searchPlaceholder')}
|
|
176
|
-
hideLabel
|
|
175
|
+
<SearchInput
|
|
176
|
+
containerClass="w-60 shrink-0"
|
|
177
177
|
bind:value={searchDraft}
|
|
178
|
-
|
|
178
|
+
placeholder={$t('workflows.list.searchPlaceholder')}
|
|
179
|
+
clearLabel={$t('workflows.list.clearSearch')}
|
|
180
|
+
inputAttributes={{ 'aria-label': $t('workflows.list.searchLabel') }}
|
|
181
|
+
{recentSearchesKey}
|
|
182
|
+
recentSearchesLabel={$t('workflows.list.recentSearches')}
|
|
183
|
+
clearRecentSearchesLabel={$t('workflows.list.clearRecentSearches')}
|
|
184
|
+
onInput={() => list.setSearch(searchDraft)}
|
|
185
|
+
onClear={() => {
|
|
186
|
+
searchDraft = '';
|
|
187
|
+
list.setSearch('');
|
|
188
|
+
}}
|
|
179
189
|
/>
|
|
180
190
|
<!-- The design draws this button outlined while the list could not be read (the error state has the main action). -->
|
|
181
191
|
<Button
|
|
@@ -217,16 +227,20 @@
|
|
|
217
227
|
{/if}
|
|
218
228
|
</div>
|
|
219
229
|
{#if !isLibraryEmpty}
|
|
220
|
-
<
|
|
221
|
-
|
|
222
|
-
type="search"
|
|
223
|
-
variant="soft"
|
|
224
|
-
icon="search"
|
|
225
|
-
label={$t('workflows.list.searchLabel')}
|
|
226
|
-
placeholder={$t('workflows.list.searchPlaceholder')}
|
|
227
|
-
hideLabel
|
|
230
|
+
<SearchInput
|
|
231
|
+
containerClass="w-full min-w-0"
|
|
228
232
|
bind:value={searchDraft}
|
|
229
|
-
|
|
233
|
+
placeholder={$t('workflows.list.searchPlaceholder')}
|
|
234
|
+
clearLabel={$t('workflows.list.clearSearch')}
|
|
235
|
+
inputAttributes={{ 'aria-label': $t('workflows.list.searchLabel') }}
|
|
236
|
+
{recentSearchesKey}
|
|
237
|
+
recentSearchesLabel={$t('workflows.list.recentSearches')}
|
|
238
|
+
clearRecentSearchesLabel={$t('workflows.list.clearRecentSearches')}
|
|
239
|
+
onInput={() => list.setSearch(searchDraft)}
|
|
240
|
+
onClear={() => {
|
|
241
|
+
searchDraft = '';
|
|
242
|
+
list.setSearch('');
|
|
243
|
+
}}
|
|
230
244
|
/>
|
|
231
245
|
{/if}
|
|
232
246
|
</div>
|
|
@@ -18,6 +18,11 @@ interface Props {
|
|
|
18
18
|
items: readonly import('../../api/types.js').WorkflowListItem[];
|
|
19
19
|
total: number;
|
|
20
20
|
} | null;
|
|
21
|
+
/**
|
|
22
|
+
* Host-built localStorage key for recent workflow searches (per person, workspace, page). Empty string leaves the
|
|
23
|
+
* field without a recents panel.
|
|
24
|
+
*/
|
|
25
|
+
recentSearchesKey?: string;
|
|
21
26
|
}
|
|
22
27
|
declare const WorkflowList: import("svelte").Component<Props, {}, "">;
|
|
23
28
|
type WorkflowList = ReturnType<typeof WorkflowList>;
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
|
|
34
34
|
/** What the API says about the composition of this block; `undefined` before it answers, `null` when it is not there. */
|
|
35
35
|
const option = $derived(node.compositionId ? editor.options[node.compositionId] : undefined);
|
|
36
|
+
/** The compositions the other blocks show: the list marks them "Already in this workflow", and they stay free to choose. */
|
|
36
37
|
const otherCompositionIds = $derived(
|
|
37
38
|
editor.compositionIds.filter((compositionId) => compositionId !== node.compositionId)
|
|
38
39
|
);
|
|
@@ -63,7 +64,7 @@
|
|
|
63
64
|
valueLabel={chosenName}
|
|
64
65
|
placeholder={$t('workflows.create.compositionPlaceholder')}
|
|
65
66
|
selectedId={node.compositionId}
|
|
66
|
-
|
|
67
|
+
usedIds={otherCompositionIds}
|
|
67
68
|
disabled={editor.isReadOnly}
|
|
68
69
|
onpick={chooseComposition}
|
|
69
70
|
onread={(options) => editor.rememberCompositions(options)}
|
|
@@ -73,7 +74,7 @@
|
|
|
73
74
|
<CompositionPicker
|
|
74
75
|
selectedId={null}
|
|
75
76
|
bordered={false}
|
|
76
|
-
|
|
77
|
+
usedIds={otherCompositionIds}
|
|
77
78
|
onpick={chooseComposition}
|
|
78
79
|
onread={(options) => editor.rememberCompositions(options)}
|
|
79
80
|
/>
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
<!--
|
|
2
2
|
A list of the compositions a person may use in a workflow, with a search above it. Used where a composition is chosen: when a
|
|
3
3
|
workflow is made, and on a composition block. Each line has the composition's picture and name; one that is already in the
|
|
4
|
-
workflow
|
|
4
|
+
workflow says so and can still be chosen (the same composition may sit on several blocks), and one whose widget was never
|
|
5
|
+
published says so too.
|
|
5
6
|
|
|
6
7
|
It asks the API for twenty at a time (`composition-options`), and for the next twenty when asked. Every search replaces the
|
|
7
8
|
one before it: an answer to an older search that arrives late is dropped.
|
|
@@ -23,8 +24,8 @@
|
|
|
23
24
|
interface Props {
|
|
24
25
|
/** The composition that is chosen now, if any. */
|
|
25
26
|
selectedId?: string | null;
|
|
26
|
-
/** Compositions already
|
|
27
|
-
|
|
27
|
+
/** Compositions already on a block of the workflow: marked as such, and still free to choose again. */
|
|
28
|
+
usedIds?: readonly string[];
|
|
28
29
|
/** Called with every composition the person picks, so the owner can remember its name and picture. */
|
|
29
30
|
onpick: (option: CompositionOption) => void;
|
|
30
31
|
/** Called with each page of compositions that was read, so the owner can remember them. */
|
|
@@ -36,7 +37,7 @@
|
|
|
36
37
|
bordered?: boolean;
|
|
37
38
|
}
|
|
38
39
|
|
|
39
|
-
let { selectedId = null,
|
|
40
|
+
let { selectedId = null, usedIds = [], onpick, onread, bordered = true }: Props = $props();
|
|
40
41
|
|
|
41
42
|
const PAGE_SIZE = 20;
|
|
42
43
|
const SEARCH_DELAY_MILLISECONDS = 300;
|
|
@@ -54,7 +55,7 @@
|
|
|
54
55
|
let controller: AbortController | null = null;
|
|
55
56
|
let searchTimer: ReturnType<typeof setTimeout> | null = null;
|
|
56
57
|
|
|
57
|
-
const
|
|
58
|
+
const used = $derived(new Set(usedIds));
|
|
58
59
|
const hasMore = $derived(items.length < total);
|
|
59
60
|
|
|
60
61
|
/** Reads the first page for what is in the search box now (or the next page, when `append`). */
|
|
@@ -152,15 +153,14 @@
|
|
|
152
153
|
>
|
|
153
154
|
{#each items as option (option.id)}
|
|
154
155
|
{@const isSelected = option.id === selectedId}
|
|
155
|
-
{@const
|
|
156
|
+
{@const isUsed = used.has(option.id) && !isSelected}
|
|
156
157
|
<li role="none">
|
|
157
158
|
<button
|
|
158
159
|
type="button"
|
|
159
|
-
disabled={isTaken}
|
|
160
160
|
role="option"
|
|
161
161
|
aria-selected={isSelected}
|
|
162
162
|
aria-current={isSelected ? 'true' : undefined}
|
|
163
|
-
class="focus-visible:ring-ring flex w-full items-center gap-3 rounded-lg px-2 py-2 text-start text-body text-foreground hover:bg-accent
|
|
163
|
+
class="focus-visible:ring-ring flex w-full items-center gap-3 rounded-lg px-2 py-2 text-start text-body text-foreground hover:bg-accent focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-offset-background {isSelected
|
|
164
164
|
? 'bg-brand-subtle text-brand-foreground'
|
|
165
165
|
: ''}"
|
|
166
166
|
onclick={() => onpick(option)}
|
|
@@ -182,18 +182,13 @@
|
|
|
182
182
|
{/if}
|
|
183
183
|
<span class="flex min-w-0 flex-1 flex-col gap-0.5 text-start">
|
|
184
184
|
<span class="text-body-medium truncate" dir="auto">{option.name}</span>
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
{option.published
|
|
193
|
-
? $t('workflows.block.publishedMeta')
|
|
194
|
-
: $t('workflows.block.notPublished')}
|
|
195
|
-
</span>
|
|
196
|
-
{/if}
|
|
185
|
+
<!-- Whether the widget is published, as the design's rows say it, and that it is already in the workflow. -->
|
|
186
|
+
<span class="text-caption text-muted-foreground">
|
|
187
|
+
{option.published
|
|
188
|
+
? $t('workflows.block.publishedMeta')
|
|
189
|
+
: $t('workflows.block.notPublished')}{#if isUsed}
|
|
190
|
+
· {$t('workflows.composition.alreadyUsed')}{/if}
|
|
191
|
+
</span>
|
|
197
192
|
</span>
|
|
198
193
|
{#if isSelected}<Icon name="check" class="text-brand-foreground size-4 shrink-0" />{/if}
|
|
199
194
|
</button>
|
|
@@ -2,8 +2,8 @@ import type { CompositionOption } from '../../api/types.js';
|
|
|
2
2
|
interface Props {
|
|
3
3
|
/** The composition that is chosen now, if any. */
|
|
4
4
|
selectedId?: string | null;
|
|
5
|
-
/** Compositions already
|
|
6
|
-
|
|
5
|
+
/** Compositions already on a block of the workflow: marked as such, and still free to choose again. */
|
|
6
|
+
usedIds?: readonly string[];
|
|
7
7
|
/** Called with every composition the person picks, so the owner can remember its name and picture. */
|
|
8
8
|
onpick: (option: CompositionOption) => void;
|
|
9
9
|
/** Called with each page of compositions that was read, so the owner can remember them. */
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
help?: string | null;
|
|
26
26
|
/** The composition that is chosen now, so the list marks it. */
|
|
27
27
|
selectedId: string | null;
|
|
28
|
-
/** Compositions that are already
|
|
29
|
-
|
|
28
|
+
/** Compositions that are already on a block of the workflow: the list says so, and they can still be chosen again. */
|
|
29
|
+
usedIds?: readonly string[];
|
|
30
30
|
/** The person picked a line (the line that is already chosen too: the owner decides what that means). */
|
|
31
31
|
onpick: (option: CompositionOption) => void;
|
|
32
32
|
/** Each page of compositions the list read, so the owner can remember their names and pictures. */
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
placeholder,
|
|
41
41
|
help = null,
|
|
42
42
|
selectedId,
|
|
43
|
-
|
|
43
|
+
usedIds = [],
|
|
44
44
|
onpick,
|
|
45
45
|
onread,
|
|
46
46
|
disabled = false
|
|
@@ -103,7 +103,7 @@
|
|
|
103
103
|
{/if}
|
|
104
104
|
{#if isOpen}
|
|
105
105
|
<div id="{fieldId}-list" class="flex min-h-0 flex-col">
|
|
106
|
-
<CompositionPicker {selectedId} {
|
|
106
|
+
<CompositionPicker {selectedId} {usedIds} onpick={pick} {onread} />
|
|
107
107
|
</div>
|
|
108
108
|
{/if}
|
|
109
109
|
</div>
|
|
@@ -10,8 +10,8 @@ interface Props {
|
|
|
10
10
|
help?: string | null;
|
|
11
11
|
/** The composition that is chosen now, so the list marks it. */
|
|
12
12
|
selectedId: string | null;
|
|
13
|
-
/** Compositions that are already
|
|
14
|
-
|
|
13
|
+
/** Compositions that are already on a block of the workflow: the list says so, and they can still be chosen again. */
|
|
14
|
+
usedIds?: readonly string[];
|
|
15
15
|
/** The person picked a line (the line that is already chosen too: the owner decides what that means). */
|
|
16
16
|
onpick: (option: CompositionOption) => void;
|
|
17
17
|
/** Each page of compositions the list read, so the owner can remember their names and pictures. */
|
|
@@ -46,5 +46,13 @@ export declare const ICON_PATHS: {
|
|
|
46
46
|
readonly condition: readonly ["M12 18m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0", "M7 6m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0", "M17 6m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0", "M7 8v2a2 2 0 0 0 2 2h6a2 2 0 0 0 2 -2v-2", "M12 12l0 4"];
|
|
47
47
|
/** Small pencil shown on hover beside an editable title. */
|
|
48
48
|
readonly pencil: readonly ["M4 20h4l10.5 -10.5a2.828 2.828 0 1 0 -4 -4l-10.5 10.5v4", "M13.5 6.5l4 4"];
|
|
49
|
+
/** Arrow to the right, Tabler arrow-right: between the widgets of the flow in a plan. */
|
|
50
|
+
readonly arrowRight: readonly ["M5 12l14 0", "M13 18l6 -6", "M13 6l6 6"];
|
|
51
|
+
/** Chat / assistant, Tabler message-circle (the `Icon/message-circle` of the design's icon page). */
|
|
52
|
+
readonly chat: readonly ["M3 20l1.3 -3.9a9 8 0 1 1 3.4 2.9l-4.7 1"];
|
|
53
|
+
/** A document, Tabler file (the `Icon/file` of the design's icon page): the leading icon of an attached file's chip. */
|
|
54
|
+
readonly file: readonly ["M14 3v4a1 1 0 0 0 1 1h4", "M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2z"];
|
|
55
|
+
readonly plugConnected: readonly ["M7 12l5 5l-1.5 1.5a3.536 3.536 0 1 1 -5 -5l1.5 -1.5", "M17 12l-5 -5l1.5 -1.5a3.536 3.536 0 1 1 5 5l-1.5 1.5", "M3 21l2.5 -2.5", "M18.5 5.5l2.5 -2.5", "M10 11l-2 2", "M13 14l-2 2"];
|
|
56
|
+
readonly table: readonly ["M3 5a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v14a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-14", "M3 10h18", "M10 3v18"];
|
|
49
57
|
};
|
|
50
58
|
export type IconName = keyof typeof ICON_PATHS;
|
|
@@ -112,6 +112,29 @@ export const ICON_PATHS = {
|
|
|
112
112
|
'M12 12l0 4'
|
|
113
113
|
],
|
|
114
114
|
/** Small pencil shown on hover beside an editable title. */
|
|
115
|
-
pencil: ['M4 20h4l10.5 -10.5a2.828 2.828 0 1 0 -4 -4l-10.5 10.5v4', 'M13.5 6.5l4 4']
|
|
115
|
+
pencil: ['M4 20h4l10.5 -10.5a2.828 2.828 0 1 0 -4 -4l-10.5 10.5v4', 'M13.5 6.5l4 4'],
|
|
116
|
+
/** Arrow to the right, Tabler arrow-right: between the widgets of the flow in a plan. */
|
|
117
|
+
arrowRight: ['M5 12l14 0', 'M13 18l6 -6', 'M13 6l6 6'],
|
|
118
|
+
/** Chat / assistant, Tabler message-circle (the `Icon/message-circle` of the design's icon page). */
|
|
119
|
+
chat: ['M3 20l1.3 -3.9a9 8 0 1 1 3.4 2.9l-4.7 1'],
|
|
120
|
+
/** A document, Tabler file (the `Icon/file` of the design's icon page): the leading icon of an attached file's chip. */
|
|
121
|
+
file: [
|
|
122
|
+
'M14 3v4a1 1 0 0 0 1 1h4',
|
|
123
|
+
'M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2z'
|
|
124
|
+
],
|
|
125
|
+
// An Open MCP of the person (a server they connected), and a table of values (what a call would show).
|
|
126
|
+
plugConnected: [
|
|
127
|
+
'M7 12l5 5l-1.5 1.5a3.536 3.536 0 1 1 -5 -5l1.5 -1.5',
|
|
128
|
+
'M17 12l-5 -5l1.5 -1.5a3.536 3.536 0 1 1 5 5l-1.5 1.5',
|
|
129
|
+
'M3 21l2.5 -2.5',
|
|
130
|
+
'M18.5 5.5l2.5 -2.5',
|
|
131
|
+
'M10 11l-2 2',
|
|
132
|
+
'M13 14l-2 2'
|
|
133
|
+
],
|
|
134
|
+
table: [
|
|
135
|
+
'M3 5a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v14a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-14',
|
|
136
|
+
'M3 10h18',
|
|
137
|
+
'M10 3v18'
|
|
138
|
+
]
|
|
116
139
|
// [extra icons]
|
|
117
140
|
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { NodePosition, WorkflowGraph, WorkflowNode } from '@widgetic/workflows-engine';
|
|
2
|
+
/** What the layout needs to know about one block. Sizes are in canvas units; offsets are from the top of the block. */
|
|
3
|
+
export interface BlockMeasure {
|
|
4
|
+
width: number;
|
|
5
|
+
height: number;
|
|
6
|
+
/** The centre of the connection point lines come in at (default: the middle of the block). */
|
|
7
|
+
inputOffset?: number;
|
|
8
|
+
/** The centre of each place a line leaves from, by port: `out`, a rule's id or `default` (default: the middle). */
|
|
9
|
+
outputOffsets?: Readonly<Record<string, number>>;
|
|
10
|
+
}
|
|
11
|
+
export interface OrganiseOptions {
|
|
12
|
+
/** What the canvas measured of a block. A block it has no answer for gets an estimate. */
|
|
13
|
+
measureBlock?: (node: WorkflowNode) => BlockMeasure | undefined;
|
|
14
|
+
/** The room between two columns (default `COLUMN_GAP`). */
|
|
15
|
+
columnGap?: number;
|
|
16
|
+
/** The room between two blocks of a column (default `ROW_GAP`). */
|
|
17
|
+
rowGap?: number;
|
|
18
|
+
/** The room between two groups of blocks that are not connected (default `GROUP_GAP`). */
|
|
19
|
+
groupGap?: number;
|
|
20
|
+
/** Where the top left corner of the result goes (default: where the top left corner of the blocks is now). */
|
|
21
|
+
origin?: NodePosition;
|
|
22
|
+
}
|
|
23
|
+
/** The room between two columns: enough for the line between them to be seen and for its arrow. */
|
|
24
|
+
export declare const COLUMN_GAP = 120;
|
|
25
|
+
export declare const ROW_GAP = 48;
|
|
26
|
+
export declare const GROUP_GAP = 96;
|
|
27
|
+
/**
|
|
28
|
+
* How wide a row of blocks that are not connected may be at least, in canvas units: four compositions side by side. A row is
|
|
29
|
+
* as wide as the widest group of connected blocks when that one is wider, so the grid lines up with the flow above it.
|
|
30
|
+
*/
|
|
31
|
+
export declare const SHELF_MIN_WIDTH = 1500;
|
|
32
|
+
/** The ports of a block in the order they are drawn, top to bottom. */
|
|
33
|
+
export declare function listPorts(node: WorkflowNode): string[];
|
|
34
|
+
/**
|
|
35
|
+
* Where each block of the graph goes, as the new graph. A graph with no blocks, or in which no block needs to move, comes
|
|
36
|
+
* back as it is.
|
|
37
|
+
*/
|
|
38
|
+
export declare function organiseGraph(graph: WorkflowGraph, options?: OrganiseOptions): WorkflowGraph;
|