@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
|
@@ -1,7 +1,12 @@
|
|
|
1
|
+
import { type ReadyAssistantSeed } from '../../assistant/assistantSeed.js';
|
|
1
2
|
import type { WorkflowAssistantConfig } from '../../assistant/types.js';
|
|
2
3
|
interface Props {
|
|
3
4
|
workflowId: string;
|
|
4
5
|
config: WorkflowAssistantConfig;
|
|
6
|
+
/** The first message the page left waiting for the assistant of this workflow. Read once, when the panel is first drawn. */
|
|
7
|
+
seed?: ReadyAssistantSeed | null;
|
|
8
|
+
/** The seed was written to the composer, or left alone because the person had already begun. Called once, with no arguments. */
|
|
9
|
+
onseedapplied?: () => void;
|
|
5
10
|
}
|
|
6
11
|
declare const WorkflowAssistantPanel: import("svelte").Component<Props, {}, "">;
|
|
7
12
|
type WorkflowAssistantPanel = ReturnType<typeof WorkflowAssistantPanel>;
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
The menu a right click opens on the canvas, in the look of the Widgetic canvas's menu: rows of a plain list, the words on
|
|
3
|
+
the left and the shortcut ("Cmd X", "Ctrl X") on the right in a quieter colour, thin rules between groups, Delete in the
|
|
4
|
+
colour of a destructive action, a row that cannot act on what is selected dimmed.
|
|
5
|
+
|
|
6
|
+
On a block it has Cut, Copy, Paste, Duplicate; Select all; Delete. On the empty canvas it has Paste; Select all; Organise
|
|
7
|
+
and Disconnect (the two for the lines). Which rows there are, and which can act, is `buildCanvasMenu`; this draws them and
|
|
8
|
+
asks the owner to run the one that is chosen.
|
|
9
|
+
|
|
10
|
+
The menu is drawn where it is used, inside `container` (the canvas's own box), and not in a layer of the page: this package
|
|
11
|
+
also runs inside the shadow root of a page, where a menu drawn elsewhere would lose its styles. It opens at the point that
|
|
12
|
+
was pressed and stays inside the box (it opens toward the other side near an edge).
|
|
13
|
+
|
|
14
|
+
Keyboard: it opens with the first row that can act focused; the arrows, Home and End move; Enter or Space chooses; Escape
|
|
15
|
+
closes it and the focus goes back to the canvas, where the shortcuts are read; Tab leaves it. A press outside, a scroll of
|
|
16
|
+
the canvas and a click of the right button elsewhere close it. The listeners exist only while it is open.
|
|
17
|
+
-->
|
|
18
|
+
<script lang="ts">
|
|
19
|
+
import { tick } from 'svelte';
|
|
20
|
+
import {
|
|
21
|
+
buildCanvasMenu,
|
|
22
|
+
type CanvasMenuAction,
|
|
23
|
+
type CanvasMenuRequest,
|
|
24
|
+
type CanvasMenuState
|
|
25
|
+
} from '../../editor/canvasMenu.js';
|
|
26
|
+
import { ariaKeyShortcut, isApplePlatform, menuChordText } from '../../editor/keyHints.js';
|
|
27
|
+
import { useWorkflowsLanguage } from '../../i18n/language.js';
|
|
28
|
+
|
|
29
|
+
interface Props {
|
|
30
|
+
/** Where the menu is open and what it is on. `null` while it is closed. */
|
|
31
|
+
request: CanvasMenuRequest | null;
|
|
32
|
+
/** The box the menu is drawn into: the point that was pressed is turned into a place in it. */
|
|
33
|
+
container: HTMLElement | null;
|
|
34
|
+
/** What decides which rows can act. */
|
|
35
|
+
menuState: CanvasMenuState;
|
|
36
|
+
/** A row was chosen. The owner closes the menu and does the work. */
|
|
37
|
+
onChoose: (action: CanvasMenuAction, request: CanvasMenuRequest) => void;
|
|
38
|
+
/** The menu asks to be closed (Escape, a press outside, a scroll). */
|
|
39
|
+
onClose: () => void;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
let { request, container, menuState, onChoose, onClose }: Props = $props();
|
|
43
|
+
|
|
44
|
+
const { t } = useWorkflowsLanguage();
|
|
45
|
+
const apple = isApplePlatform();
|
|
46
|
+
|
|
47
|
+
/** The room kept between the menu and the edge of the box. */
|
|
48
|
+
const EDGE_GAP = 8;
|
|
49
|
+
|
|
50
|
+
const groups = $derived(request ? buildCanvasMenu(request.target, menuState) : []);
|
|
51
|
+
|
|
52
|
+
let menuElement = $state<HTMLDivElement>();
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Where the menu goes, as the styles that place it: at the pressed point, moved back inside the box when it would run out
|
|
56
|
+
* of it. The distance is measured from the start of the line (the right edge on a right to left page), so the menu opens
|
|
57
|
+
* from the pointer toward the end of the line, as a menu does in either direction. `null` until the menu has been drawn
|
|
58
|
+
* once and measured; it is invisible until then, so that it never shows at the corner for a frame.
|
|
59
|
+
*/
|
|
60
|
+
const placement = $derived.by(() => {
|
|
61
|
+
if (!request || !container || !menuElement) return null;
|
|
62
|
+
const bounds = container.getBoundingClientRect();
|
|
63
|
+
const width = menuElement.offsetWidth;
|
|
64
|
+
const height = menuElement.offsetHeight;
|
|
65
|
+
const isRightToLeft = getComputedStyle(container).direction === 'rtl';
|
|
66
|
+
const wantedStart = isRightToLeft
|
|
67
|
+
? bounds.right - request.clientX
|
|
68
|
+
: request.clientX - bounds.left;
|
|
69
|
+
const wantedTop = request.clientY - bounds.top;
|
|
70
|
+
const lastStart = Math.max(bounds.width - width - EDGE_GAP, EDGE_GAP);
|
|
71
|
+
const lastTop = Math.max(bounds.height - height - EDGE_GAP, EDGE_GAP);
|
|
72
|
+
const start = Math.round(Math.min(Math.max(wantedStart, EDGE_GAP), lastStart));
|
|
73
|
+
const top = Math.round(Math.min(Math.max(wantedTop, EDGE_GAP), lastTop));
|
|
74
|
+
return { start: `${start}px`, top: `${top}px` };
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
/** The rows that can be reached with the arrows. */
|
|
78
|
+
function listRowButtons(): HTMLButtonElement[] {
|
|
79
|
+
return menuElement
|
|
80
|
+
? [...menuElement.querySelectorAll<HTMLButtonElement>('[role="menuitem"]')]
|
|
81
|
+
: [];
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// The first row that can act has the focus when the menu opens
|
|
85
|
+
$effect(() => {
|
|
86
|
+
if (!request || !menuElement) return;
|
|
87
|
+
void tick().then(() => {
|
|
88
|
+
const firstEnabled = listRowButtons().find(
|
|
89
|
+
(button) => button.getAttribute('aria-disabled') !== 'true'
|
|
90
|
+
);
|
|
91
|
+
(firstEnabled ?? listRowButtons()[0])?.focus({ preventScroll: true });
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
/** Gives the keyboard back to the canvas, where the shortcuts are read. */
|
|
96
|
+
function returnFocusToCanvas(): void {
|
|
97
|
+
container?.querySelector<HTMLElement>('.kaykay-canvas')?.focus({ preventScroll: true });
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function choose(action: CanvasMenuAction, isDisabled: boolean): void {
|
|
101
|
+
if (isDisabled || !request) return;
|
|
102
|
+
returnFocusToCanvas();
|
|
103
|
+
onChoose(action, request);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function handleMenuKeydown(event: KeyboardEvent): void {
|
|
107
|
+
const buttons = listRowButtons();
|
|
108
|
+
const focusedIndex = buttons.findIndex(
|
|
109
|
+
(button) => button === (event.target as Element).closest('[role="menuitem"]')
|
|
110
|
+
);
|
|
111
|
+
let nextPosition: number | null = null;
|
|
112
|
+
if (event.key === 'ArrowDown') nextPosition = (focusedIndex + 1) % buttons.length;
|
|
113
|
+
else if (event.key === 'ArrowUp')
|
|
114
|
+
nextPosition = (focusedIndex - 1 + buttons.length) % buttons.length;
|
|
115
|
+
else if (event.key === 'Home') nextPosition = 0;
|
|
116
|
+
else if (event.key === 'End') nextPosition = buttons.length - 1;
|
|
117
|
+
else if (event.key === 'Escape') {
|
|
118
|
+
event.preventDefault();
|
|
119
|
+
event.stopPropagation();
|
|
120
|
+
returnFocusToCanvas();
|
|
121
|
+
onClose();
|
|
122
|
+
return;
|
|
123
|
+
} else if (event.key === 'Tab') {
|
|
124
|
+
onClose();
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
if (nextPosition !== null) {
|
|
128
|
+
event.preventDefault();
|
|
129
|
+
buttons[nextPosition]?.focus();
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// A press outside closes the menu, and so does a scroll that moves what it was opened on. The listeners live only while
|
|
134
|
+
// the menu is open, and look at the whole path of the event, because a press inside a shadow root is reported to the page
|
|
135
|
+
// as a press on the shadow's host.
|
|
136
|
+
$effect(() => {
|
|
137
|
+
if (!request) return;
|
|
138
|
+
const closeOnOutsidePress = (event: Event) => {
|
|
139
|
+
if (menuElement && !event.composedPath().includes(menuElement)) onClose();
|
|
140
|
+
};
|
|
141
|
+
const closeOnScroll = () => onClose();
|
|
142
|
+
document.addEventListener('pointerdown', closeOnOutsidePress, true);
|
|
143
|
+
container?.addEventListener('wheel', closeOnScroll, { capture: true, passive: true });
|
|
144
|
+
window.addEventListener('resize', closeOnScroll);
|
|
145
|
+
return () => {
|
|
146
|
+
document.removeEventListener('pointerdown', closeOnOutsidePress, true);
|
|
147
|
+
container?.removeEventListener('wheel', closeOnScroll, true);
|
|
148
|
+
window.removeEventListener('resize', closeOnScroll);
|
|
149
|
+
};
|
|
150
|
+
});
|
|
151
|
+
</script>
|
|
152
|
+
|
|
153
|
+
{#if request}
|
|
154
|
+
<!-- A right click on the menu itself is not a new menu: the browser's own is not wanted here either. -->
|
|
155
|
+
<div
|
|
156
|
+
bind:this={menuElement}
|
|
157
|
+
role="menu"
|
|
158
|
+
tabindex="-1"
|
|
159
|
+
aria-label={$t('workflows.canvasMenu.label')}
|
|
160
|
+
data-workflow-canvas-menu
|
|
161
|
+
class="absolute z-30 flex w-60 flex-col rounded-xl border border-border bg-popover p-1 text-start text-popover-foreground shadow-floating focus-visible:outline-hidden {placement
|
|
162
|
+
? ''
|
|
163
|
+
: 'invisible'}"
|
|
164
|
+
style:inset-inline-start={placement?.start}
|
|
165
|
+
style:top={placement?.top}
|
|
166
|
+
onkeydown={handleMenuKeydown}
|
|
167
|
+
oncontextmenu={(event) => event.preventDefault()}
|
|
168
|
+
>
|
|
169
|
+
{#each groups as group, groupIndex (groupIndex)}
|
|
170
|
+
<div
|
|
171
|
+
role="group"
|
|
172
|
+
class="flex flex-col {groupIndex > 0 ? 'mt-1 border-t border-border pt-1' : ''}"
|
|
173
|
+
>
|
|
174
|
+
{#each group as row (row.action)}
|
|
175
|
+
<button
|
|
176
|
+
type="button"
|
|
177
|
+
role="menuitem"
|
|
178
|
+
aria-disabled={row.disabled ? true : undefined}
|
|
179
|
+
aria-keyshortcuts={row.chord ? ariaKeyShortcut(row.chord, apple) : undefined}
|
|
180
|
+
data-variant={row.isDestructive ? 'destructive' : undefined}
|
|
181
|
+
class="flex h-8 min-h-8 w-full items-center gap-2 rounded-lg px-2 py-1.5 text-start text-body transition-colors duration-fast focus-visible:outline-hidden {row.disabled
|
|
182
|
+
? 'cursor-default opacity-50'
|
|
183
|
+
: 'hover:bg-accent focus-visible:bg-accent'} {row.isDestructive
|
|
184
|
+
? 'text-destructive'
|
|
185
|
+
: 'text-foreground'}"
|
|
186
|
+
onclick={() => choose(row.action, row.disabled)}
|
|
187
|
+
>
|
|
188
|
+
<span class="min-w-0 flex-1 truncate">{$t(row.messageKey)}</span>
|
|
189
|
+
{#if row.chord}
|
|
190
|
+
<span class="ms-auto shrink-0 text-caption text-muted-foreground" aria-hidden="true">
|
|
191
|
+
{menuChordText(row.chord, apple, $t)}
|
|
192
|
+
</span>
|
|
193
|
+
{/if}
|
|
194
|
+
</button>
|
|
195
|
+
{/each}
|
|
196
|
+
</div>
|
|
197
|
+
{/each}
|
|
198
|
+
</div>
|
|
199
|
+
{/if}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type CanvasMenuAction, type CanvasMenuRequest, type CanvasMenuState } from '../../editor/canvasMenu.js';
|
|
2
|
+
interface Props {
|
|
3
|
+
/** Where the menu is open and what it is on. `null` while it is closed. */
|
|
4
|
+
request: CanvasMenuRequest | null;
|
|
5
|
+
/** The box the menu is drawn into: the point that was pressed is turned into a place in it. */
|
|
6
|
+
container: HTMLElement | null;
|
|
7
|
+
/** What decides which rows can act. */
|
|
8
|
+
menuState: CanvasMenuState;
|
|
9
|
+
/** A row was chosen. The owner closes the menu and does the work. */
|
|
10
|
+
onChoose: (action: CanvasMenuAction, request: CanvasMenuRequest) => void;
|
|
11
|
+
/** The menu asks to be closed (Escape, a press outside, a scroll). */
|
|
12
|
+
onClose: () => void;
|
|
13
|
+
}
|
|
14
|
+
declare const CanvasContextMenu: import("svelte").Component<Props, {}, "">;
|
|
15
|
+
type CanvasContextMenu = ReturnType<typeof CanvasContextMenu>;
|
|
16
|
+
export default CanvasContextMenu;
|
|
@@ -69,12 +69,17 @@
|
|
|
69
69
|
});
|
|
70
70
|
</script>
|
|
71
71
|
|
|
72
|
+
<!--
|
|
73
|
+
The block does not clip what it holds: the connection points sit outside its border (see `HandlePoint`), and a clipped root
|
|
74
|
+
would cut them off. The picture below clips itself instead, with the curve of the inside of the border (the root's 12px
|
|
75
|
+
corner minus its 2px border).
|
|
76
|
+
-->
|
|
72
77
|
<div
|
|
73
|
-
class="relative flex w-60 flex-col
|
|
78
|
+
class="relative flex w-60 flex-col rounded-xl border-2 bg-background text-start text-foreground {rootBorder}"
|
|
74
79
|
dir={$textDirection}
|
|
75
80
|
data-workflow-block="composition"
|
|
76
81
|
>
|
|
77
|
-
<div class="relative h-28 w-full shrink-0 overflow-hidden rounded-t-
|
|
82
|
+
<div class="relative h-28 w-full shrink-0 overflow-hidden rounded-t-[10px] bg-muted">
|
|
78
83
|
{#if thumbnailUrl && !hasThumbnailFailed}
|
|
79
84
|
<img
|
|
80
85
|
src={thumbnailUrl}
|
|
@@ -48,8 +48,12 @@
|
|
|
48
48
|
});
|
|
49
49
|
</script>
|
|
50
50
|
|
|
51
|
+
<!--
|
|
52
|
+
The block does not clip what it holds: the connection points sit outside its border (see `HandlePoint`), and a clipped root
|
|
53
|
+
would cut them off. Nothing inside has a background of its own, so no corner needs clipping.
|
|
54
|
+
-->
|
|
51
55
|
<div
|
|
52
|
-
class="relative flex w-66 flex-col
|
|
56
|
+
class="relative flex w-66 flex-col rounded-xl border-2 bg-background text-start text-foreground {rootBorder}"
|
|
53
57
|
dir={$textDirection}
|
|
54
58
|
data-workflow-block="condition"
|
|
55
59
|
>
|
|
@@ -2,10 +2,27 @@
|
|
|
2
2
|
A connection point of a block: the small circle a line starts from or ends at. kaykay places it, measures it and runs the
|
|
3
3
|
dragging; this only draws it, in the screen's palette. While a line is being dragged, kaykay marks every point with what
|
|
4
4
|
it would do (`can-connect`, `connecting`, `incompatible`) and this picture follows: a point that accepts the line turns
|
|
5
|
-
green, one that cannot is dimmed by kaykay itself.
|
|
5
|
+
green, one that cannot is dimmed by kaykay itself. The canvas marks the point a line would snap to (`data-snapped`, see
|
|
6
|
+
`connectionSnapController.ts`) and the circle grows and gets a halo.
|
|
6
7
|
|
|
7
8
|
The circle is the handle's one child, so kaykay drops its own square look (`has-custom-shape`) and leaves the drawing to
|
|
8
9
|
the classes below. `group` lets the circle react to the class kaykay puts on the handle around it.
|
|
10
|
+
|
|
11
|
+
The circle sits HALF OVER the edge of its block, as in the design (Figma "Workflows / Editor test run": a 10px circle with a
|
|
12
|
+
1.5px border whose centre is on the edge of the block). kaykay already hangs a point on the border: it puts the handle at
|
|
13
|
+
6px outside the block's padding box (`left: -6px`, `right: -6px`, `top: 50%`), which centres a 10px handle on the middle
|
|
14
|
+
of the 2px border. But kaykay's own look gives a handle with a custom shape a minimum of 12px (`min-width: 12px`,
|
|
15
|
+
`min-height: 12px`, in a rule without a layer, so no utility class beats it, only an important one), and a 12px handle puts
|
|
16
|
+
the circle's centre on the INNER edge of the border (a third of the circle outside, two thirds in) and one pixel low. So the
|
|
17
|
+
handle is made exactly the size of the circle (`size-2.5! min-h-0! min-w-0!`), which is what makes kaykay's six pixels the
|
|
18
|
+
right ones; `mt-[-5px]!` then centres it on the row. It also keeps the circle whole: no block clips its own root (a clipped
|
|
19
|
+
root cut the outer half of it off, which is why it was once moved right outside), and the circle is above what the block
|
|
20
|
+
shows. kaykay measures the centre of the handle in the page, so a line still starts exactly at the circle. `before:` only
|
|
21
|
+
makes the area that takes the mouse larger than the 10px circle (a 22px square, half of it over the block); it draws
|
|
22
|
+
nothing.
|
|
23
|
+
|
|
24
|
+
The 1.5px border is written as the property `[border-width:1.5px]`, not `border-[1.5px]`: the theming audit reads every
|
|
25
|
+
`border-[...]` as a colour, and this is a width (the scales have 1px and 2px, the design says 1.5px).
|
|
9
26
|
-->
|
|
10
27
|
<script lang="ts">
|
|
11
28
|
import { Handle } from 'kaykay';
|
|
@@ -25,15 +42,20 @@
|
|
|
25
42
|
let { id, type, port, accept, position }: Props = $props();
|
|
26
43
|
</script>
|
|
27
44
|
|
|
45
|
+
<!--
|
|
46
|
+
`mt-[-5px]!`, `size-2.5!`, `min-h-0!` and `min-w-0!` are important on purpose: kaykay writes `margin-top: -6px`, `width: auto`
|
|
47
|
+
and `min-width: 12px` (and the heights) with a selector more specific than a utility class and no layer, so only an
|
|
48
|
+
important utility wins. Without them the handle is 12px and the circle sits on the inner edge of the border.
|
|
49
|
+
-->
|
|
28
50
|
<Handle
|
|
29
51
|
{id}
|
|
30
52
|
{type}
|
|
31
53
|
{port}
|
|
32
54
|
accept={accept ? [...accept] : undefined}
|
|
33
55
|
{position}
|
|
34
|
-
class="group z-10 flex size-2.5 items-center justify-center border-0 bg-transparent p-0 [&_.kaykay-handle-label]:hidden"
|
|
56
|
+
class="group z-10 mt-[-5px]! flex size-2.5! min-h-0! min-w-0! items-center justify-center border-0 bg-transparent p-0 before:absolute before:-inset-1.5 [&_.kaykay-handle-label]:hidden"
|
|
35
57
|
>
|
|
36
58
|
<span
|
|
37
|
-
class="pointer-events-none block size-2.5 rounded-full border border-muted-foreground bg-background transition-
|
|
59
|
+
class="pointer-events-none block size-2.5 rounded-full border-solid [border-width:1.5px] border-muted-foreground bg-background transition-[color,background-color,border-color,box-shadow,transform] duration-fast group-[.can-connect]:border-primary group-[.can-connect]:bg-primary group-[.connecting]:border-primary group-[.connecting]:bg-primary group-[.incompatible]:opacity-50 group-data-[snapped=true]:scale-125 group-data-[snapped=true]:border-primary group-data-[snapped=true]:bg-primary group-data-[snapped=true]:shadow-[0_0_0_4px_color-mix(in_oklab,var(--color-primary)_25%,transparent)]"
|
|
38
60
|
></span>
|
|
39
61
|
</Handle>
|