@widgetic/workflows 0.2.11 → 0.2.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/workflowsApi.d.ts +9 -1
- package/dist/api/workflowsApi.js +2 -1
- package/dist/assistant/assistantEvents.d.ts +42 -0
- package/dist/assistant/assistantEvents.js +61 -0
- package/dist/assistant/assistantRemoteChange.d.ts +4 -0
- package/dist/assistant/assistantRemoteChange.js +8 -0
- package/dist/assistant/assistantSaveMode.d.ts +5 -0
- package/dist/assistant/assistantSaveMode.js +8 -0
- package/dist/assistant/assistantStream.d.ts +8 -0
- package/dist/assistant/assistantStream.js +140 -0
- package/dist/assistant/assistantTranscript.d.ts +11 -0
- package/dist/assistant/assistantTranscript.js +18 -0
- package/dist/assistant/types.d.ts +81 -0
- package/dist/assistant/types.js +1 -0
- package/dist/assistant/workflowPlanViewModel.d.ts +48 -0
- package/dist/assistant/workflowPlanViewModel.js +17 -0
- package/dist/components/Workflows.svelte +3 -1
- package/dist/components/WorkflowsWorkspace.svelte +4 -0
- package/dist/components/WorkflowsWorkspace.svelte.d.ts +1 -0
- package/dist/components/assistant/WorkflowAssistantPanel.svelte +384 -0
- package/dist/components/assistant/WorkflowAssistantPanel.svelte.d.ts +8 -0
- package/dist/components/canvas/WorkflowCanvas.svelte +16 -6
- package/dist/components/canvas/WorkflowCanvas.svelte.d.ts +2 -2
- package/dist/components/editor/EditorCanvasArea.svelte +57 -2
- package/dist/components/editor/EditorCanvasArea.svelte.d.ts +8 -1
- package/dist/components/editor/EditorTabs.svelte +1 -2
- package/dist/components/editor/EditorTopBar.svelte +23 -1
- package/dist/components/editor/EditorTopBar.svelte.d.ts +3 -0
- package/dist/components/editor/WorkflowEditor.svelte +31 -3
- package/dist/components/editor/WorkflowEditor.svelte.d.ts +5 -0
- package/dist/components/editor/WorkflowNameControl.svelte +10 -0
- package/dist/components/list/WorkflowList.svelte +25 -1
- package/dist/components/list/WorkflowList.svelte.d.ts +2 -0
- package/dist/components/list/WorkflowRow.svelte +2 -0
- package/dist/components/panel/ConditionForm.svelte +7 -7
- package/dist/components/ui/Menu.svelte +31 -7
- package/dist/components/ui/Menu.svelte.d.ts +4 -0
- package/dist/drafts/draftJournal.d.ts +59 -0
- package/dist/drafts/draftJournal.js +261 -0
- package/dist/drafts/workflowDraft.d.ts +72 -0
- package/dist/drafts/workflowDraft.js +151 -0
- package/dist/drafts/workflowListViewState.d.ts +30 -0
- package/dist/drafts/workflowListViewState.js +92 -0
- package/dist/editor/editorState.svelte.d.ts +68 -2
- package/dist/editor/editorState.svelte.js +273 -0
- package/dist/editor/listState.svelte.d.ts +51 -2
- package/dist/editor/listState.svelte.js +210 -1
- package/dist/i18n/language.d.ts +3 -3
- package/dist/i18n/messages.d.ts +32 -0
- package/dist/i18n/messages.js +34 -1
- package/dist/types/index.d.ts +4 -0
- package/package.json +8 -1
|
@@ -14,6 +14,8 @@
|
|
|
14
14
|
import { useWorkflowsApi } from '../../api/apiContext.js';
|
|
15
15
|
import { WorkflowEditorState, provideEditorState } from '../../editor/editorState.svelte.js';
|
|
16
16
|
import { useWorkflowsLanguage } from '../../i18n/language.js';
|
|
17
|
+
import type { DraftRestoredInfo } from '../../drafts/workflowDraft.js';
|
|
18
|
+
import type { WorkflowAssistantConfig } from '../../assistant/types.js';
|
|
17
19
|
import type { WorkflowsError } from '../../types/index.js';
|
|
18
20
|
import { Button } from '@widgetic/design-system/components';
|
|
19
21
|
import { dsButtonVariant } from '../ui/dsButtonProps.js';
|
|
@@ -38,6 +40,9 @@
|
|
|
38
40
|
onshowembedcode?: (workflowId: string) => void;
|
|
39
41
|
/** Tells who else is editing, and keeps the screen from writing over them. Read when the workflow is opened. */
|
|
40
42
|
presence?: boolean;
|
|
43
|
+
/** Called when unsaved edits were restored from the draft journal after load. */
|
|
44
|
+
onDraftRestored?: (info: DraftRestoredInfo) => void;
|
|
45
|
+
assistant?: WorkflowAssistantConfig | null;
|
|
41
46
|
}
|
|
42
47
|
|
|
43
48
|
let {
|
|
@@ -46,7 +51,9 @@
|
|
|
46
51
|
onopenworkflow,
|
|
47
52
|
onerror,
|
|
48
53
|
onshowembedcode,
|
|
49
|
-
presence = false
|
|
54
|
+
presence = false,
|
|
55
|
+
onDraftRestored,
|
|
56
|
+
assistant = null
|
|
50
57
|
}: Props = $props();
|
|
51
58
|
|
|
52
59
|
const api = useWorkflowsApi();
|
|
@@ -61,12 +68,25 @@
|
|
|
61
68
|
presence: untrack(() => presence),
|
|
62
69
|
reportError: (error) => onerror(error),
|
|
63
70
|
leave: () => onback(),
|
|
64
|
-
openWorkflow: (openedId) => onopenworkflow(openedId)
|
|
71
|
+
openWorkflow: (openedId) => onopenworkflow(openedId),
|
|
72
|
+
// A closure, so the latest callback of the screen is the one that is told.
|
|
73
|
+
onDraftRestored: (info) => onDraftRestored?.(info)
|
|
65
74
|
});
|
|
66
75
|
provideEditorState(editor);
|
|
67
76
|
|
|
68
77
|
let isAskingToPublish = $state(false);
|
|
69
78
|
let isAskingToLeave = $state(false);
|
|
79
|
+
let assistantPanelOpen = $state(true);
|
|
80
|
+
|
|
81
|
+
const assistantEnabled = $derived(Boolean(assistant?.enabled));
|
|
82
|
+
|
|
83
|
+
function toggleAssistantPanel(): void {
|
|
84
|
+
assistantPanelOpen = !assistantPanelOpen;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function openAssistantPanel(): void {
|
|
88
|
+
assistantPanelOpen = true;
|
|
89
|
+
}
|
|
70
90
|
|
|
71
91
|
const showEmbedCode = $derived(
|
|
72
92
|
onshowembedcode ? () => onshowembedcode(editor.workflowId) : undefined
|
|
@@ -145,6 +165,9 @@
|
|
|
145
165
|
onback={() => void goBack()}
|
|
146
166
|
onpublish={requestPublish}
|
|
147
167
|
onshowembedcode={showEmbedCode}
|
|
168
|
+
assistantEnabled={assistantEnabled}
|
|
169
|
+
assistantOpen={assistantPanelOpen}
|
|
170
|
+
onToggleAssistant={toggleAssistantPanel}
|
|
148
171
|
/>
|
|
149
172
|
<EditorTabs {panelId} />
|
|
150
173
|
<EditorBanners />
|
|
@@ -155,7 +178,12 @@
|
|
|
155
178
|
class="flex min-h-0 flex-1 min-w-0 flex-col"
|
|
156
179
|
>
|
|
157
180
|
{#if editor.tab === 'editor'}
|
|
158
|
-
<EditorCanvasArea
|
|
181
|
+
<EditorCanvasArea
|
|
182
|
+
{assistant}
|
|
183
|
+
assistantOpen={assistantPanelOpen}
|
|
184
|
+
onOpenAssistant={openAssistantPanel}
|
|
185
|
+
workflowId={workflowId}
|
|
186
|
+
/>
|
|
159
187
|
{:else if editor.tab === 'runs'}
|
|
160
188
|
<RunsTab />
|
|
161
189
|
{:else}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { DraftRestoredInfo } from '../../drafts/workflowDraft.js';
|
|
2
|
+
import type { WorkflowAssistantConfig } from '../../assistant/types.js';
|
|
1
3
|
import type { WorkflowsError } from '../../types/index.js';
|
|
2
4
|
interface Props {
|
|
3
5
|
workflowId: string;
|
|
@@ -11,6 +13,9 @@ interface Props {
|
|
|
11
13
|
onshowembedcode?: (workflowId: string) => void;
|
|
12
14
|
/** Tells who else is editing, and keeps the screen from writing over them. Read when the workflow is opened. */
|
|
13
15
|
presence?: boolean;
|
|
16
|
+
/** Called when unsaved edits were restored from the draft journal after load. */
|
|
17
|
+
onDraftRestored?: (info: DraftRestoredInfo) => void;
|
|
18
|
+
assistant?: WorkflowAssistantConfig | null;
|
|
14
19
|
}
|
|
15
20
|
declare const WorkflowEditor: import("svelte").Component<Props, {}, "">;
|
|
16
21
|
type WorkflowEditor = ReturnType<typeof WorkflowEditor>;
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
<script lang="ts">
|
|
6
6
|
import { tick } from 'svelte';
|
|
7
7
|
import { MAX_WORKFLOW_NAME_LENGTH } from '../../api/types.js';
|
|
8
|
+
import { useEditorState } from '../../editor/editorState.svelte.js';
|
|
8
9
|
import { decideWorkflowNameCommit } from '../../editor/workflowNameCommit.js';
|
|
9
10
|
import Icon from '../ui/Icon.svelte';
|
|
10
11
|
|
|
@@ -19,6 +20,8 @@
|
|
|
19
20
|
oncommit: (name: string) => void;
|
|
20
21
|
}
|
|
21
22
|
|
|
23
|
+
const editor = useEditorState();
|
|
24
|
+
|
|
22
25
|
let {
|
|
23
26
|
name,
|
|
24
27
|
label,
|
|
@@ -39,6 +42,7 @@
|
|
|
39
42
|
if (readonly || isEditing) return;
|
|
40
43
|
isEditing = true;
|
|
41
44
|
draft = name;
|
|
45
|
+
editor.setPendingWorkflowName(draft);
|
|
42
46
|
void tick().then(() => {
|
|
43
47
|
inputElement?.focus();
|
|
44
48
|
inputElement?.select();
|
|
@@ -61,10 +65,15 @@
|
|
|
61
65
|
}
|
|
62
66
|
}
|
|
63
67
|
isEditing = false;
|
|
68
|
+
editor.setPendingWorkflowName(null);
|
|
64
69
|
// The name button is not in the page until the update that follows `isEditing = false`, so it takes the focus after it.
|
|
65
70
|
if (restoreFocus) void tick().then(() => nameButton?.focus());
|
|
66
71
|
}
|
|
67
72
|
|
|
73
|
+
function handleDraftInput(): void {
|
|
74
|
+
if (isEditing) editor.setPendingWorkflowName(draft);
|
|
75
|
+
}
|
|
76
|
+
|
|
68
77
|
function handleViewKeydown(event: KeyboardEvent): void {
|
|
69
78
|
if (readonly) return;
|
|
70
79
|
if (event.key === 'Enter' || event.key === 'F2') {
|
|
@@ -93,6 +102,7 @@
|
|
|
93
102
|
type="text"
|
|
94
103
|
class="workflow-name-control-input w-full min-w-0 rounded-md border border-input bg-background px-2 py-1.5 text-body-medium text-foreground outline-none focus-visible:ring-2 focus-visible:ring-ring"
|
|
95
104
|
bind:value={draft}
|
|
105
|
+
oninput={handleDraftInput}
|
|
96
106
|
{maxlength}
|
|
97
107
|
aria-label={label}
|
|
98
108
|
onkeydown={handleInputKeydown}
|
|
@@ -39,6 +39,8 @@
|
|
|
39
39
|
import WorkflowRow from './WorkflowRow.svelte';
|
|
40
40
|
|
|
41
41
|
interface Props {
|
|
42
|
+
/** Keys persisted list view state and new-workflow dialog drafts for this workspace. */
|
|
43
|
+
workspaceId: string;
|
|
42
44
|
/** A workflow was chosen (or just made): open it. */
|
|
43
45
|
onopen: (workflowId: string) => void;
|
|
44
46
|
/** A failure the page should hear about. */
|
|
@@ -52,13 +54,14 @@
|
|
|
52
54
|
presence?: boolean;
|
|
53
55
|
}
|
|
54
56
|
|
|
55
|
-
let { onopen, onerror, onshowembedcode, presence = false }: Props = $props();
|
|
57
|
+
let { workspaceId, onopen, onerror, onshowembedcode, presence = false }: Props = $props();
|
|
56
58
|
|
|
57
59
|
const api = useWorkflowsApi();
|
|
58
60
|
const { t } = useWorkflowsLanguage();
|
|
59
61
|
|
|
60
62
|
const list = new WorkflowListState({
|
|
61
63
|
api,
|
|
64
|
+
workspaceId: untrack(() => workspaceId),
|
|
62
65
|
reportError: (error) => onerror(error),
|
|
63
66
|
// Read once, like the list: presence belongs to this opening of it.
|
|
64
67
|
presence: untrack(() => presence)
|
|
@@ -109,6 +112,8 @@
|
|
|
109
112
|
);
|
|
110
113
|
|
|
111
114
|
let searchDraft = $state('');
|
|
115
|
+
let listBodyElement = $state<HTMLDivElement | undefined>();
|
|
116
|
+
let restoredListScroll = $state(false);
|
|
112
117
|
|
|
113
118
|
function startNewWorkflow(): void {
|
|
114
119
|
void list.createBlankAndOpen(onopen);
|
|
@@ -118,7 +123,24 @@
|
|
|
118
123
|
list.chooseTab(key);
|
|
119
124
|
}
|
|
120
125
|
|
|
126
|
+
function handleListScroll(): void {
|
|
127
|
+
if (!listBodyElement) return;
|
|
128
|
+
list.followListScroll(listBodyElement.scrollTop);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
$effect(() => {
|
|
132
|
+
if (restoredListScroll || list.loadState !== 'ready' || !listBodyElement) return;
|
|
133
|
+
if (list.listScrollTop <= 0) {
|
|
134
|
+
restoredListScroll = true;
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
listBodyElement.scrollTop = list.listScrollTop;
|
|
138
|
+
restoredListScroll = true;
|
|
139
|
+
});
|
|
140
|
+
|
|
121
141
|
onMount(() => {
|
|
142
|
+
list.restorePersistedState();
|
|
143
|
+
searchDraft = list.search;
|
|
122
144
|
void list.load();
|
|
123
145
|
// Who is editing what is asked alongside the load (it looks again once the rows are there); nothing happens without `presence`.
|
|
124
146
|
list.startPresence();
|
|
@@ -289,11 +311,13 @@
|
|
|
289
311
|
|
|
290
312
|
<!-- List body -->
|
|
291
313
|
<div
|
|
314
|
+
bind:this={listBodyElement}
|
|
292
315
|
id={listPanelId}
|
|
293
316
|
role="tabpanel"
|
|
294
317
|
aria-labelledby="{listPanelId}-tab-{tabValue}"
|
|
295
318
|
class="flex min-h-0 flex-1 flex-col gap-1 overflow-auto px-4 pb-4 @3xl:px-4"
|
|
296
319
|
aria-label={$t('workflows.list.label')}
|
|
320
|
+
onscroll={handleListScroll}
|
|
297
321
|
>
|
|
298
322
|
{#if list.loadState === 'loading'}
|
|
299
323
|
<!-- Figma "Loading": the rows' own shape in `bg-muted` (tile, name bar, details bar, state pill). -->
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { WorkflowsError } from '../../types/index.js';
|
|
2
2
|
interface Props {
|
|
3
|
+
/** Keys persisted list view state and new-workflow dialog drafts for this workspace. */
|
|
4
|
+
workspaceId: string;
|
|
3
5
|
/** A workflow was chosen (or just made): open it. */
|
|
4
6
|
onopen: (workflowId: string) => void;
|
|
5
7
|
/** A failure the page should hear about. */
|
|
@@ -227,6 +227,8 @@
|
|
|
227
227
|
size="small"
|
|
228
228
|
align="end"
|
|
229
229
|
disabled={isBusy}
|
|
230
|
+
initialOpen={list.openMenuWorkflowId === item.id}
|
|
231
|
+
onOpenChange={(open) => list.followRowMenuOpen(open ? item.id : null)}
|
|
230
232
|
class="relative z-20 col-start-3 row-start-1 self-start transition-opacity duration-fast @3xl:col-start-4 @3xl:self-center pointer-fine:opacity-0 pointer-fine:group-focus-within:opacity-100 pointer-fine:group-hover:opacity-100 pointer-fine:[.group:has([aria-expanded=true])_&]:opacity-100"
|
|
231
233
|
/>
|
|
232
234
|
</div>
|
|
@@ -41,7 +41,6 @@
|
|
|
41
41
|
);
|
|
42
42
|
|
|
43
43
|
/** At most one rule card is expanded (accordion); new rules open the last card. */
|
|
44
|
-
let expandedRuleId = $state<string | null>(null);
|
|
45
44
|
let lastCaseCount = $state(0);
|
|
46
45
|
let wasConditionSelected = $state(false);
|
|
47
46
|
|
|
@@ -54,9 +53,9 @@
|
|
|
54
53
|
return;
|
|
55
54
|
}
|
|
56
55
|
if (!wasConditionSelected && count > 0) {
|
|
57
|
-
expandedRuleId = node.cases[0]!.id;
|
|
56
|
+
editor.expandedRuleId = node.cases[0]!.id;
|
|
58
57
|
} else if (count > lastCaseCount && count > 0) {
|
|
59
|
-
expandedRuleId = node.cases[count - 1]!.id;
|
|
58
|
+
editor.expandedRuleId = node.cases[count - 1]!.id;
|
|
60
59
|
}
|
|
61
60
|
wasConditionSelected = true;
|
|
62
61
|
lastCaseCount = count;
|
|
@@ -69,12 +68,13 @@
|
|
|
69
68
|
}
|
|
70
69
|
|
|
71
70
|
function toggleRule(ruleId: string): void {
|
|
72
|
-
expandedRuleId = expandedRuleId === ruleId ? null : ruleId;
|
|
71
|
+
editor.expandedRuleId = editor.expandedRuleId === ruleId ? null : ruleId;
|
|
72
|
+
editor.persistEditorViewState();
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
$effect(() => {
|
|
76
|
-
if (expandedRuleId !== null && !node.cases.some((c) => c.id === expandedRuleId)) {
|
|
77
|
-
expandedRuleId = node.cases[0]?.id ?? null;
|
|
76
|
+
if (editor.expandedRuleId !== null && !node.cases.some((c) => c.id === editor.expandedRuleId)) {
|
|
77
|
+
editor.expandedRuleId = node.cases[0]?.id ?? null;
|
|
78
78
|
}
|
|
79
79
|
});
|
|
80
80
|
</script>
|
|
@@ -99,7 +99,7 @@
|
|
|
99
99
|
{rule}
|
|
100
100
|
{index}
|
|
101
101
|
{choices}
|
|
102
|
-
expanded={expandedRuleId === rule.id}
|
|
102
|
+
expanded={editor.expandedRuleId === rule.id}
|
|
103
103
|
onToggle={() => toggleRule(rule.id)}
|
|
104
104
|
/>
|
|
105
105
|
{/each}
|
|
@@ -37,6 +37,10 @@
|
|
|
37
37
|
/** Classes for the button that opens the list (`class` is for the box around it and the list). */
|
|
38
38
|
triggerClass?: string;
|
|
39
39
|
onopen?: () => void;
|
|
40
|
+
/** Opens the menu once when the list restores which row had its menu up. */
|
|
41
|
+
initialOpen?: boolean;
|
|
42
|
+
/** Whether the menu is open (for persisting list view state). */
|
|
43
|
+
onOpenChange?: (open: boolean) => void;
|
|
40
44
|
}
|
|
41
45
|
|
|
42
46
|
let {
|
|
@@ -51,7 +55,9 @@
|
|
|
51
55
|
placement = 'below',
|
|
52
56
|
class: className = '',
|
|
53
57
|
triggerClass = '',
|
|
54
|
-
onopen
|
|
58
|
+
onopen,
|
|
59
|
+
initialOpen = false,
|
|
60
|
+
onOpenChange
|
|
55
61
|
}: Props = $props();
|
|
56
62
|
|
|
57
63
|
const menuId = $props.id();
|
|
@@ -59,6 +65,21 @@
|
|
|
59
65
|
let isOpen = $state(false);
|
|
60
66
|
let rootElement = $state<HTMLDivElement>();
|
|
61
67
|
let menuElement = $state<HTMLDivElement>();
|
|
68
|
+
let appliedInitialOpen = $state(false);
|
|
69
|
+
|
|
70
|
+
function notifyOpenChange(open: boolean): void {
|
|
71
|
+
try {
|
|
72
|
+
onOpenChange?.(open);
|
|
73
|
+
} catch {
|
|
74
|
+
// A handler of the page must not break the menu.
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
$effect(() => {
|
|
79
|
+
if (!initialOpen || appliedInitialOpen) return;
|
|
80
|
+
appliedInitialOpen = true;
|
|
81
|
+
void revealMenu('first');
|
|
82
|
+
});
|
|
62
83
|
|
|
63
84
|
/** The lines that can be reached with the arrows. */
|
|
64
85
|
function listItemButtons(): HTMLButtonElement[] {
|
|
@@ -67,9 +88,11 @@
|
|
|
67
88
|
: [];
|
|
68
89
|
}
|
|
69
90
|
|
|
70
|
-
async function
|
|
91
|
+
async function revealMenu(landOn: 'first' | 'last' = 'first'): Promise<void> {
|
|
71
92
|
if (disabled) return;
|
|
93
|
+
const wasOpen = isOpen;
|
|
72
94
|
isOpen = true;
|
|
95
|
+
if (!wasOpen) notifyOpenChange(true);
|
|
73
96
|
onopen?.();
|
|
74
97
|
await tick();
|
|
75
98
|
const buttons = listItemButtons();
|
|
@@ -78,7 +101,7 @@
|
|
|
78
101
|
|
|
79
102
|
/** Opens the list from outside (a shortcut key of the screen). */
|
|
80
103
|
export function openMenu(): void {
|
|
81
|
-
void
|
|
104
|
+
void revealMenu('first');
|
|
82
105
|
}
|
|
83
106
|
|
|
84
107
|
/** The button that opens the menu: the first button of the root, before the lines of the list. */
|
|
@@ -89,12 +112,13 @@
|
|
|
89
112
|
function close(returnFocus: boolean): void {
|
|
90
113
|
if (!isOpen) return;
|
|
91
114
|
isOpen = false;
|
|
115
|
+
notifyOpenChange(false);
|
|
92
116
|
if (returnFocus) findTriggerButton()?.focus();
|
|
93
117
|
}
|
|
94
118
|
|
|
95
119
|
function toggle(): void {
|
|
96
120
|
if (isOpen) close(false);
|
|
97
|
-
else void
|
|
121
|
+
else void revealMenu();
|
|
98
122
|
}
|
|
99
123
|
|
|
100
124
|
function choose(item: MenuItem): void {
|
|
@@ -108,10 +132,10 @@
|
|
|
108
132
|
if (event.target !== findTriggerButton()) return;
|
|
109
133
|
if (event.key === 'ArrowDown') {
|
|
110
134
|
event.preventDefault();
|
|
111
|
-
void
|
|
135
|
+
void revealMenu('first');
|
|
112
136
|
} else if (event.key === 'ArrowUp') {
|
|
113
137
|
event.preventDefault();
|
|
114
|
-
void
|
|
138
|
+
void revealMenu('last');
|
|
115
139
|
}
|
|
116
140
|
}
|
|
117
141
|
|
|
@@ -146,7 +170,7 @@
|
|
|
146
170
|
$effect(() => {
|
|
147
171
|
if (!isOpen) return;
|
|
148
172
|
const closeOnOutsidePress = (event: Event) => {
|
|
149
|
-
if (rootElement && !event.composedPath().includes(rootElement))
|
|
173
|
+
if (rootElement && !event.composedPath().includes(rootElement)) close(false);
|
|
150
174
|
};
|
|
151
175
|
document.addEventListener('pointerdown', closeOnOutsidePress, true);
|
|
152
176
|
return () => document.removeEventListener('pointerdown', closeOnOutsidePress, true);
|
|
@@ -17,6 +17,10 @@ interface Props {
|
|
|
17
17
|
/** Classes for the button that opens the list (`class` is for the box around it and the list). */
|
|
18
18
|
triggerClass?: string;
|
|
19
19
|
onopen?: () => void;
|
|
20
|
+
/** Opens the menu once when the list restores which row had its menu up. */
|
|
21
|
+
initialOpen?: boolean;
|
|
22
|
+
/** Whether the menu is open (for persisting list view state). */
|
|
23
|
+
onOpenChange?: (open: boolean) => void;
|
|
20
24
|
}
|
|
21
25
|
declare const Menu: import("svelte").Component<Props, {
|
|
22
26
|
openMenu: () => void;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/** Refresh-safe draft journal (localStorage). Copied per package; see QoL persistence spec. */
|
|
2
|
+
export declare const DRAFT_STORAGE_PREFIX = "widgetic:draft:";
|
|
3
|
+
export declare const DRAFT_FORMAT_VERSION = 1;
|
|
4
|
+
export declare const DEFAULT_DRAFT_MAX_BYTES: number;
|
|
5
|
+
export declare const DEFAULT_DRAFT_MAX_AGE_MS: number;
|
|
6
|
+
export declare const DRAFT_WRITE_THROTTLE_MS = 250;
|
|
7
|
+
export interface DraftJournalEntry<T> {
|
|
8
|
+
v: number;
|
|
9
|
+
savedAtMs: number;
|
|
10
|
+
baseRevision: string | null;
|
|
11
|
+
payload: T;
|
|
12
|
+
}
|
|
13
|
+
export interface DraftJournalStorage {
|
|
14
|
+
getItem(key: string): string | null;
|
|
15
|
+
setItem(key: string, value: string): void;
|
|
16
|
+
removeItem(key: string): void;
|
|
17
|
+
length: number;
|
|
18
|
+
key(index: number): string | null;
|
|
19
|
+
}
|
|
20
|
+
export interface DraftJournalClock {
|
|
21
|
+
now(): number;
|
|
22
|
+
}
|
|
23
|
+
export interface DraftJournalLogger {
|
|
24
|
+
debug(message: string, detail?: unknown): void;
|
|
25
|
+
}
|
|
26
|
+
export interface DraftJournalTimers {
|
|
27
|
+
setTimeout(callback: () => void, milliseconds: number): unknown;
|
|
28
|
+
clearTimeout(handle: unknown): void;
|
|
29
|
+
}
|
|
30
|
+
/** Minimal window/document surface for leave flushing (tests inject fakes). */
|
|
31
|
+
export interface DraftJournalWindow {
|
|
32
|
+
addEventListener(type: string, listener: () => void): void;
|
|
33
|
+
removeEventListener(type: string, listener: () => void): void;
|
|
34
|
+
}
|
|
35
|
+
export interface DraftJournalDocument {
|
|
36
|
+
addEventListener(type: string, listener: () => void): void;
|
|
37
|
+
removeEventListener(type: string, listener: () => void): void;
|
|
38
|
+
readonly visibilityState: DocumentVisibilityState | string;
|
|
39
|
+
}
|
|
40
|
+
export interface DraftJournalOptions {
|
|
41
|
+
storage?: DraftJournalStorage;
|
|
42
|
+
clock?: DraftJournalClock;
|
|
43
|
+
logger?: DraftJournalLogger;
|
|
44
|
+
timers?: DraftJournalTimers;
|
|
45
|
+
window?: DraftJournalWindow | null;
|
|
46
|
+
document?: DraftJournalDocument | null;
|
|
47
|
+
maxBytes?: number;
|
|
48
|
+
maxAgeMs?: number;
|
|
49
|
+
throttleMs?: number;
|
|
50
|
+
}
|
|
51
|
+
export interface DraftJournal<T> {
|
|
52
|
+
read(key: string): DraftJournalEntry<T> | null;
|
|
53
|
+
write(key: string, payload: T, baseRevision?: string | null): boolean;
|
|
54
|
+
flushNow(key: string, payload: T, baseRevision?: string | null): boolean;
|
|
55
|
+
clear(key: string): void;
|
|
56
|
+
purgeExpired(): number;
|
|
57
|
+
installFlushOnLeave(flushNow: () => void): () => void;
|
|
58
|
+
}
|
|
59
|
+
export declare function createDraftJournal<T>(namespace: string, options?: DraftJournalOptions): DraftJournal<T>;
|