@widgetic/workflows 0.1.1 → 0.2.1
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 +118 -46
- package/dist/api/apiContext.d.ts +4 -0
- package/dist/api/apiContext.js +17 -0
- package/dist/api/types.d.ts +201 -0
- package/dist/api/types.js +3 -0
- package/dist/api/workflowsApi.d.ts +133 -0
- package/dist/api/workflowsApi.js +763 -0
- package/dist/components/Workflows.svelte +43 -17
- package/dist/components/WorkflowsEmptyState.svelte +16 -5
- package/dist/components/WorkflowsEmptyState.svelte.d.ts +5 -16
- package/dist/components/WorkflowsHeader.svelte +2 -2
- package/dist/components/WorkflowsWorkspace.svelte +90 -0
- package/dist/components/WorkflowsWorkspace.svelte.d.ts +15 -0
- package/dist/components/canvas/AddBlockMenu.svelte +101 -0
- package/dist/components/canvas/AddBlockMenu.svelte.d.ts +5 -0
- package/dist/components/canvas/CanvasToolbar.svelte +95 -0
- package/dist/components/canvas/CanvasToolbar.svelte.d.ts +9 -0
- package/dist/components/canvas/CompositionNodeView.svelte +125 -0
- package/dist/components/canvas/CompositionNodeView.svelte.d.ts +5 -0
- package/dist/components/canvas/ConditionNodeView.svelte +95 -0
- package/dist/components/canvas/ConditionNodeView.svelte.d.ts +5 -0
- package/dist/components/canvas/HandlePoint.svelte +32 -0
- package/dist/components/canvas/HandlePoint.svelte.d.ts +14 -0
- package/dist/components/canvas/TriggerNodeView.svelte +75 -0
- package/dist/components/canvas/TriggerNodeView.svelte.d.ts +5 -0
- package/dist/components/canvas/WorkflowCanvas.svelte +380 -0
- package/dist/components/canvas/WorkflowCanvas.svelte.d.ts +25 -0
- package/dist/components/canvas/WorkflowEdgeView.svelte +58 -0
- package/dist/components/canvas/WorkflowEdgeView.svelte.d.ts +4 -0
- package/dist/components/editor/ConflictBanner.svelte +78 -0
- package/dist/components/editor/ConflictBanner.svelte.d.ts +3 -0
- package/dist/components/editor/EditorBanners.svelte +141 -0
- package/dist/components/editor/EditorBanners.svelte.d.ts +7 -0
- package/dist/components/editor/EditorCanvasArea.svelte +85 -0
- package/dist/components/editor/EditorCanvasArea.svelte.d.ts +3 -0
- package/dist/components/editor/EditorTabs.svelte +81 -0
- package/dist/components/editor/EditorTabs.svelte.d.ts +7 -0
- package/dist/components/editor/EditorTopBar.svelte +132 -0
- package/dist/components/editor/EditorTopBar.svelte.d.ts +9 -0
- package/dist/components/editor/PresenceBanner.svelte +126 -0
- package/dist/components/editor/PresenceBanner.svelte.d.ts +3 -0
- package/dist/components/editor/RunsTab.svelte +256 -0
- package/dist/components/editor/RunsTab.svelte.d.ts +3 -0
- package/dist/components/editor/SettingsTab.svelte +180 -0
- package/dist/components/editor/SettingsTab.svelte.d.ts +7 -0
- package/dist/components/editor/WorkflowEditor.svelte +198 -0
- package/dist/components/editor/WorkflowEditor.svelte.d.ts +17 -0
- package/dist/components/index.d.ts +0 -2
- package/dist/components/index.js +0 -2
- package/dist/components/list/CreateWorkflowDialog.svelte +89 -0
- package/dist/components/list/CreateWorkflowDialog.svelte.d.ts +9 -0
- package/dist/components/list/WorkflowList.svelte +204 -0
- package/dist/components/list/WorkflowList.svelte.d.ts +12 -0
- package/dist/components/list/WorkflowRow.svelte +191 -0
- package/dist/components/list/WorkflowRow.svelte.d.ts +10 -0
- package/dist/components/panel/BlockProblems.svelte +47 -0
- package/dist/components/panel/BlockProblems.svelte.d.ts +6 -0
- package/dist/components/panel/CompositionForm.svelte +127 -0
- package/dist/components/panel/CompositionForm.svelte.d.ts +7 -0
- package/dist/components/panel/CompositionPicker.svelte +179 -0
- package/dist/components/panel/CompositionPicker.svelte.d.ts +14 -0
- package/dist/components/panel/ConditionForm.svelte +105 -0
- package/dist/components/panel/ConditionForm.svelte.d.ts +7 -0
- package/dist/components/panel/EventValueRow.svelte +85 -0
- package/dist/components/panel/EventValueRow.svelte.d.ts +12 -0
- package/dist/components/panel/NextStepSelect.svelte +70 -0
- package/dist/components/panel/NextStepSelect.svelte.d.ts +12 -0
- package/dist/components/panel/ProblemsList.svelte +101 -0
- package/dist/components/panel/ProblemsList.svelte.d.ts +3 -0
- package/dist/components/panel/RuleCard.svelte +191 -0
- package/dist/components/panel/RuleCard.svelte.d.ts +13 -0
- package/dist/components/panel/SidePanel.svelte +82 -0
- package/dist/components/panel/SidePanel.svelte.d.ts +3 -0
- package/dist/components/panel/TestRow.svelte +150 -0
- package/dist/components/panel/TestRow.svelte.d.ts +15 -0
- package/dist/components/panel/TestRunPanel.svelte +85 -0
- package/dist/components/panel/TestRunPanel.svelte.d.ts +3 -0
- package/dist/components/panel/TestTriggerCard.svelte +121 -0
- package/dist/components/panel/TestTriggerCard.svelte.d.ts +7 -0
- package/dist/components/panel/TriggerForm.svelte +385 -0
- package/dist/components/panel/TriggerForm.svelte.d.ts +7 -0
- package/dist/components/panel/VersionHistory.svelte +123 -0
- package/dist/components/panel/VersionHistory.svelte.d.ts +3 -0
- package/dist/components/ui/ActionButton.svelte +85 -0
- package/dist/components/ui/ActionButton.svelte.d.ts +27 -0
- package/dist/components/ui/ConfirmDialog.svelte +52 -0
- package/dist/components/ui/ConfirmDialog.svelte.d.ts +16 -0
- package/dist/components/ui/Icon.svelte +32 -0
- package/dist/components/ui/Icon.svelte.d.ts +9 -0
- package/dist/components/ui/Menu.svelte +211 -0
- package/dist/components/ui/Menu.svelte.d.ts +21 -0
- package/dist/components/ui/Modal.svelte +129 -0
- package/dist/components/ui/Modal.svelte.d.ts +13 -0
- package/dist/components/ui/Notice.svelte +36 -0
- package/dist/components/ui/Notice.svelte.d.ts +11 -0
- package/dist/components/ui/SelectField.svelte +74 -0
- package/dist/components/ui/SelectField.svelte.d.ts +16 -0
- package/dist/components/ui/StatusBadge.svelte +41 -0
- package/dist/components/ui/StatusBadge.svelte.d.ts +9 -0
- package/dist/components/ui/TextField.svelte +97 -0
- package/dist/components/ui/TextField.svelte.d.ts +29 -0
- package/dist/components/ui/icons.d.ts +34 -0
- package/dist/components/ui/icons.js +54 -0
- package/dist/components/ui/types.d.ts +26 -0
- package/dist/components/ui/types.js +1 -0
- package/dist/editor/apiErrorText.d.ts +10 -0
- package/dist/editor/apiErrorText.js +53 -0
- package/dist/editor/autosave.d.ts +47 -0
- package/dist/editor/autosave.js +119 -0
- package/dist/editor/blockLabels.d.ts +91 -0
- package/dist/editor/blockLabels.js +196 -0
- package/dist/editor/canvasContext.d.ts +52 -0
- package/dist/editor/canvasContext.js +37 -0
- package/dist/editor/canvasWords.d.ts +24 -0
- package/dist/editor/canvasWords.js +40 -0
- package/dist/editor/capabilityModel.d.ts +46 -0
- package/dist/editor/capabilityModel.js +113 -0
- package/dist/editor/editLeaseController.d.ts +162 -0
- package/dist/editor/editLeaseController.js +459 -0
- package/dist/editor/editorState.svelte.d.ts +277 -0
- package/dist/editor/editorState.svelte.js +862 -0
- package/dist/editor/flowAdapter.d.ts +59 -0
- package/dist/editor/flowAdapter.js +166 -0
- package/dist/editor/formatCount.d.ts +5 -0
- package/dist/editor/formatCount.js +15 -0
- package/dist/editor/graphDiff.d.ts +27 -0
- package/dist/editor/graphDiff.js +64 -0
- package/dist/editor/graphModel.d.ts +154 -0
- package/dist/editor/graphModel.js +457 -0
- package/dist/editor/issueText.d.ts +64 -0
- package/dist/editor/issueText.js +101 -0
- package/dist/editor/keepCopy.d.ts +41 -0
- package/dist/editor/keepCopy.js +52 -0
- package/dist/editor/listState.svelte.d.ts +82 -0
- package/dist/editor/listState.svelte.js +250 -0
- package/dist/editor/statsRange.d.ts +26 -0
- package/dist/editor/statsRange.js +41 -0
- package/dist/editor/testRun.d.ts +36 -0
- package/dist/editor/testRun.js +74 -0
- package/dist/editor/zonedTime.d.ts +20 -0
- package/dist/editor/zonedTime.js +134 -0
- package/dist/i18n/language.d.ts +3 -3
- package/dist/i18n/messages.d.ts +429 -4
- package/dist/i18n/messages.js +456 -8
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -1
- package/dist/types/index.d.ts +41 -3
- package/package.json +5 -1
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
interface Props {
|
|
2
|
+
title: string;
|
|
3
|
+
/** What is about to happen, in a sentence or two. */
|
|
4
|
+
message: string;
|
|
5
|
+
/** What the button that agrees says (`Delete`, `Publish`), never a bare "OK". */
|
|
6
|
+
confirmLabel: string;
|
|
7
|
+
/** `danger` for a thing that takes something away. */
|
|
8
|
+
tone?: 'normal' | 'danger';
|
|
9
|
+
/** While the thing is being done: both buttons wait and the window cannot be dismissed. */
|
|
10
|
+
busy?: boolean;
|
|
11
|
+
onconfirm: () => void;
|
|
12
|
+
oncancel: () => void;
|
|
13
|
+
}
|
|
14
|
+
declare const ConfirmDialog: import("svelte").Component<Props, {}, "">;
|
|
15
|
+
type ConfirmDialog = ReturnType<typeof ConfirmDialog>;
|
|
16
|
+
export default ConfirmDialog;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
A small picture of the screen (see `icons.ts`). It is decoration: the control that holds it carries the words (a label or
|
|
3
|
+
a title), so a screen reader skips the picture itself.
|
|
4
|
+
-->
|
|
5
|
+
<script lang="ts">
|
|
6
|
+
import { ICON_PATHS, type IconName } from './icons.js';
|
|
7
|
+
|
|
8
|
+
interface Props {
|
|
9
|
+
name: IconName;
|
|
10
|
+
/** Extra classes, for a size other than the text's. */
|
|
11
|
+
class?: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
let { name, class: className = 'size-4' }: Props = $props();
|
|
15
|
+
|
|
16
|
+
const pathData = $derived(ICON_PATHS[name]);
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<svg
|
|
20
|
+
class="shrink-0 {className}"
|
|
21
|
+
viewBox="0 0 24 24"
|
|
22
|
+
fill="none"
|
|
23
|
+
stroke="currentColor"
|
|
24
|
+
stroke-width="2"
|
|
25
|
+
stroke-linecap="round"
|
|
26
|
+
stroke-linejoin="round"
|
|
27
|
+
aria-hidden="true"
|
|
28
|
+
>
|
|
29
|
+
{#each pathData as segment (segment)}
|
|
30
|
+
<path d={segment} />
|
|
31
|
+
{/each}
|
|
32
|
+
</svg>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type IconName } from './icons.js';
|
|
2
|
+
interface Props {
|
|
3
|
+
name: IconName;
|
|
4
|
+
/** Extra classes, for a size other than the text's. */
|
|
5
|
+
class?: string;
|
|
6
|
+
}
|
|
7
|
+
declare const Icon: import("svelte").Component<Props, {}, "">;
|
|
8
|
+
type Icon = ReturnType<typeof Icon>;
|
|
9
|
+
export default Icon;
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
A button that opens a list of things to do. The lines come in groups, each with an optional heading; a line may carry a
|
|
3
|
+
second, quieter line under it (what it does, or why it cannot be used now).
|
|
4
|
+
|
|
5
|
+
Keyboard: Enter or Space (or the arrow down) opens it and lands on the first line; the arrows, Home and End move; Escape
|
|
6
|
+
closes it and goes back to the button; Tab leaves it. A line that cannot be used stays in the list and in the reading
|
|
7
|
+
order (`aria-disabled`) so that the reason under it is read, and choosing it does nothing.
|
|
8
|
+
|
|
9
|
+
The listeners that watch for a press outside exist only while the menu is open.
|
|
10
|
+
-->
|
|
11
|
+
<script lang="ts">
|
|
12
|
+
import { tick } from 'svelte';
|
|
13
|
+
import ActionButton from './ActionButton.svelte';
|
|
14
|
+
import Icon from './Icon.svelte';
|
|
15
|
+
import type { IconName } from './icons.js';
|
|
16
|
+
import type { MenuGroup, MenuItem } from './types.js';
|
|
17
|
+
|
|
18
|
+
interface Props {
|
|
19
|
+
groups: readonly MenuGroup[];
|
|
20
|
+
/** The words on the button; for a button of only a picture, its name for a screen reader. */
|
|
21
|
+
label: string;
|
|
22
|
+
icon?: IconName;
|
|
23
|
+
iconOnly?: boolean;
|
|
24
|
+
variant?: 'primary' | 'secondary' | 'ghost';
|
|
25
|
+
size?: 'small' | 'medium';
|
|
26
|
+
disabled?: boolean;
|
|
27
|
+
/** Which edge of the button the list lines up with: `end` opens it toward the start of the line, away from the edge. */
|
|
28
|
+
align?: 'start' | 'end';
|
|
29
|
+
class?: string;
|
|
30
|
+
onopen?: () => void;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
let {
|
|
34
|
+
groups,
|
|
35
|
+
label,
|
|
36
|
+
icon,
|
|
37
|
+
iconOnly = false,
|
|
38
|
+
variant = 'secondary',
|
|
39
|
+
size = 'medium',
|
|
40
|
+
disabled = false,
|
|
41
|
+
align = 'start',
|
|
42
|
+
class: className = '',
|
|
43
|
+
onopen
|
|
44
|
+
}: Props = $props();
|
|
45
|
+
|
|
46
|
+
const menuId = $props.id();
|
|
47
|
+
|
|
48
|
+
let isOpen = $state(false);
|
|
49
|
+
let rootElement = $state<HTMLDivElement>();
|
|
50
|
+
let menuElement = $state<HTMLDivElement>();
|
|
51
|
+
|
|
52
|
+
/** The lines that can be reached with the arrows. */
|
|
53
|
+
function listItemButtons(): HTMLButtonElement[] {
|
|
54
|
+
return menuElement
|
|
55
|
+
? [...menuElement.querySelectorAll<HTMLButtonElement>('[role="menuitem"]')]
|
|
56
|
+
: [];
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async function open(landOn: 'first' | 'last' = 'first'): Promise<void> {
|
|
60
|
+
if (disabled) return;
|
|
61
|
+
isOpen = true;
|
|
62
|
+
onopen?.();
|
|
63
|
+
await tick();
|
|
64
|
+
const buttons = listItemButtons();
|
|
65
|
+
(landOn === 'last' ? buttons[buttons.length - 1] : buttons[0])?.focus();
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** Opens the list from outside (a shortcut key of the screen). */
|
|
69
|
+
export function openMenu(): void {
|
|
70
|
+
void open('first');
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** The button that opens the menu: the first button of the root, before the lines of the list. */
|
|
74
|
+
function findTriggerButton(): HTMLButtonElement | null {
|
|
75
|
+
return rootElement?.querySelector<HTMLButtonElement>(':scope > button') ?? null;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function close(returnFocus: boolean): void {
|
|
79
|
+
if (!isOpen) return;
|
|
80
|
+
isOpen = false;
|
|
81
|
+
if (returnFocus) findTriggerButton()?.focus();
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function toggle(): void {
|
|
85
|
+
if (isOpen) close(false);
|
|
86
|
+
else void open();
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function choose(item: MenuItem): void {
|
|
90
|
+
if (item.disabled) return;
|
|
91
|
+
close(true);
|
|
92
|
+
item.onSelect();
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** The arrows on the button open the list, landing on its first or its last line. */
|
|
96
|
+
function handleTriggerKeydown(event: KeyboardEvent): void {
|
|
97
|
+
if (event.target !== findTriggerButton()) return;
|
|
98
|
+
if (event.key === 'ArrowDown') {
|
|
99
|
+
event.preventDefault();
|
|
100
|
+
void open('first');
|
|
101
|
+
} else if (event.key === 'ArrowUp') {
|
|
102
|
+
event.preventDefault();
|
|
103
|
+
void open('last');
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function handleMenuKeydown(event: KeyboardEvent): void {
|
|
108
|
+
const buttons = listItemButtons();
|
|
109
|
+
const position = buttons.findIndex(
|
|
110
|
+
(button) => button === (event.target as Element).closest('[role="menuitem"]')
|
|
111
|
+
);
|
|
112
|
+
let nextPosition: number | null = null;
|
|
113
|
+
if (event.key === 'ArrowDown') nextPosition = (position + 1) % buttons.length;
|
|
114
|
+
else if (event.key === 'ArrowUp')
|
|
115
|
+
nextPosition = (position - 1 + buttons.length) % buttons.length;
|
|
116
|
+
else if (event.key === 'Home') nextPosition = 0;
|
|
117
|
+
else if (event.key === 'End') nextPosition = buttons.length - 1;
|
|
118
|
+
else if (event.key === 'Escape') {
|
|
119
|
+
event.preventDefault();
|
|
120
|
+
event.stopPropagation();
|
|
121
|
+
close(true);
|
|
122
|
+
return;
|
|
123
|
+
} else if (event.key === 'Tab') {
|
|
124
|
+
close(false);
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
if (nextPosition !== null) {
|
|
128
|
+
event.preventDefault();
|
|
129
|
+
buttons[nextPosition]?.focus();
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// A press outside closes the menu. The listener lives only while the menu is open, and looks at the whole path of the
|
|
134
|
+
// event, because a press inside a shadow root is reported to the page as a press on the shadow's host.
|
|
135
|
+
$effect(() => {
|
|
136
|
+
if (!isOpen) return;
|
|
137
|
+
const closeOnOutsidePress = (event: Event) => {
|
|
138
|
+
if (rootElement && !event.composedPath().includes(rootElement)) isOpen = false;
|
|
139
|
+
};
|
|
140
|
+
document.addEventListener('pointerdown', closeOnOutsidePress, true);
|
|
141
|
+
return () => document.removeEventListener('pointerdown', closeOnOutsidePress, true);
|
|
142
|
+
});
|
|
143
|
+
</script>
|
|
144
|
+
|
|
145
|
+
<!-- The arrows are handled for the button inside; the root itself is not something a person operates. -->
|
|
146
|
+
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
147
|
+
<div
|
|
148
|
+
bind:this={rootElement}
|
|
149
|
+
class="relative inline-block text-start {className}"
|
|
150
|
+
onkeydown={handleTriggerKeydown}
|
|
151
|
+
>
|
|
152
|
+
<ActionButton
|
|
153
|
+
{variant}
|
|
154
|
+
{size}
|
|
155
|
+
{disabled}
|
|
156
|
+
{iconOnly}
|
|
157
|
+
ariaLabel={iconOnly ? label : undefined}
|
|
158
|
+
title={iconOnly ? label : undefined}
|
|
159
|
+
hasPopup="menu"
|
|
160
|
+
expanded={isOpen}
|
|
161
|
+
controls={menuId}
|
|
162
|
+
onclick={toggle}
|
|
163
|
+
>
|
|
164
|
+
{#if icon}<Icon name={icon} />{/if}
|
|
165
|
+
{#if !iconOnly}{label}{/if}
|
|
166
|
+
</ActionButton>
|
|
167
|
+
|
|
168
|
+
{#if isOpen}
|
|
169
|
+
<div
|
|
170
|
+
bind:this={menuElement}
|
|
171
|
+
id={menuId}
|
|
172
|
+
role="menu"
|
|
173
|
+
tabindex="-1"
|
|
174
|
+
class="absolute z-30 mt-1 flex max-h-[min(30rem,70vh)] min-w-56 max-w-80 flex-col gap-1 overflow-auto rounded-large border border-grey2 bg-white p-1 shadow-lg {align ===
|
|
175
|
+
'end'
|
|
176
|
+
? 'end-0'
|
|
177
|
+
: 'start-0'}"
|
|
178
|
+
onkeydown={handleMenuKeydown}
|
|
179
|
+
>
|
|
180
|
+
{#each groups as group (group.key)}
|
|
181
|
+
<div role="group" aria-label={group.heading} class="flex flex-col">
|
|
182
|
+
{#if group.heading}
|
|
183
|
+
<p class="px-3 pt-2 pb-1 text-xs font-medium text-ink-muted" aria-hidden="true">
|
|
184
|
+
{group.heading}
|
|
185
|
+
</p>
|
|
186
|
+
{/if}
|
|
187
|
+
{#each group.items as item (item.key)}
|
|
188
|
+
<button
|
|
189
|
+
type="button"
|
|
190
|
+
role="menuitem"
|
|
191
|
+
aria-disabled={item.disabled ? true : undefined}
|
|
192
|
+
class="flex w-full items-start gap-2 rounded-medium border border-transparent px-3 py-2 text-start text-sm hover:border-grey2 focus-visible:border-primary-green focus-visible:outline-none {item.tone ===
|
|
193
|
+
'danger'
|
|
194
|
+
? 'text-error'
|
|
195
|
+
: 'text-ink-primary'}"
|
|
196
|
+
onclick={() => choose(item)}
|
|
197
|
+
>
|
|
198
|
+
{#if item.icon}<Icon name={item.icon} class="mt-0.5 size-4" />{/if}
|
|
199
|
+
<span class="flex min-w-0 flex-col">
|
|
200
|
+
<span class={item.disabled ? 'opacity-60' : ''}>{item.label}</span>
|
|
201
|
+
{#if item.description}
|
|
202
|
+
<span class="text-xs text-ink-muted">{item.description}</span>
|
|
203
|
+
{/if}
|
|
204
|
+
</span>
|
|
205
|
+
</button>
|
|
206
|
+
{/each}
|
|
207
|
+
</div>
|
|
208
|
+
{/each}
|
|
209
|
+
</div>
|
|
210
|
+
{/if}
|
|
211
|
+
</div>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { IconName } from './icons.js';
|
|
2
|
+
import type { MenuGroup } from './types.js';
|
|
3
|
+
interface Props {
|
|
4
|
+
groups: readonly MenuGroup[];
|
|
5
|
+
/** The words on the button; for a button of only a picture, its name for a screen reader. */
|
|
6
|
+
label: string;
|
|
7
|
+
icon?: IconName;
|
|
8
|
+
iconOnly?: boolean;
|
|
9
|
+
variant?: 'primary' | 'secondary' | 'ghost';
|
|
10
|
+
size?: 'small' | 'medium';
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
/** Which edge of the button the list lines up with: `end` opens it toward the start of the line, away from the edge. */
|
|
13
|
+
align?: 'start' | 'end';
|
|
14
|
+
class?: string;
|
|
15
|
+
onopen?: () => void;
|
|
16
|
+
}
|
|
17
|
+
declare const Menu: import("svelte").Component<Props, {
|
|
18
|
+
openMenu: () => void;
|
|
19
|
+
}, "">;
|
|
20
|
+
type Menu = ReturnType<typeof Menu>;
|
|
21
|
+
export default Menu;
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
A window over the screen, for a question that must be answered or a thing that must be read before going on.
|
|
3
|
+
|
|
4
|
+
While it is open: the keyboard stays inside it (Tab goes round), Escape and a click on the dim part behind it close it, a
|
|
5
|
+
screen reader is told it is a dialog with a title, and when it closes the focus goes back to what had it before.
|
|
6
|
+
|
|
7
|
+
It is drawn in place (fixed over the element the screen is in) and not carried to the end of the page, so it is inside
|
|
8
|
+
the screen's own language, direction and styles wherever the screen is mounted, in a shadow root too.
|
|
9
|
+
-->
|
|
10
|
+
<script lang="ts">
|
|
11
|
+
import { onMount, type Snippet } from 'svelte';
|
|
12
|
+
import { useWorkflowsLanguage } from '../../i18n/language.js';
|
|
13
|
+
import ActionButton from './ActionButton.svelte';
|
|
14
|
+
import Icon from './Icon.svelte';
|
|
15
|
+
|
|
16
|
+
interface Props {
|
|
17
|
+
title: string;
|
|
18
|
+
onclose: () => void;
|
|
19
|
+
size?: 'small' | 'medium' | 'large';
|
|
20
|
+
/** While something is being done, the window cannot be dismissed by accident. */
|
|
21
|
+
busy?: boolean;
|
|
22
|
+
children: Snippet;
|
|
23
|
+
footer?: Snippet;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
let { title, onclose, size = 'medium', busy = false, children, footer }: Props = $props();
|
|
27
|
+
|
|
28
|
+
const { t } = useWorkflowsLanguage();
|
|
29
|
+
const titleId = $props.id();
|
|
30
|
+
|
|
31
|
+
const FOCUSABLE_SELECTOR =
|
|
32
|
+
'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
|
|
33
|
+
|
|
34
|
+
const widthClasses = { small: 'max-w-sm', medium: 'max-w-lg', large: 'max-w-3xl' };
|
|
35
|
+
|
|
36
|
+
let dialogElement = $state<HTMLDivElement>();
|
|
37
|
+
|
|
38
|
+
/** The element that has the focus now, looking into the shadow root the window is in. */
|
|
39
|
+
function readFocusedElement(): Element | null {
|
|
40
|
+
const root = dialogElement?.getRootNode();
|
|
41
|
+
return root instanceof ShadowRoot || root instanceof Document ? root.activeElement : null;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function requestClose(): void {
|
|
45
|
+
if (!busy) onclose();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** Keeps Tab inside the window and closes it on Escape. */
|
|
49
|
+
function handleKeydown(event: KeyboardEvent): void {
|
|
50
|
+
if (event.key === 'Escape') {
|
|
51
|
+
event.stopPropagation();
|
|
52
|
+
requestClose();
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (event.key !== 'Tab' || !dialogElement) return;
|
|
56
|
+
const focusable = [...dialogElement.querySelectorAll<HTMLElement>(FOCUSABLE_SELECTOR)];
|
|
57
|
+
if (focusable.length === 0) {
|
|
58
|
+
event.preventDefault();
|
|
59
|
+
dialogElement.focus();
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const first = focusable[0];
|
|
63
|
+
const last = focusable[focusable.length - 1];
|
|
64
|
+
const focused = readFocusedElement();
|
|
65
|
+
if (event.shiftKey && (focused === first || focused === dialogElement)) {
|
|
66
|
+
event.preventDefault();
|
|
67
|
+
last.focus();
|
|
68
|
+
} else if (!event.shiftKey && focused === last) {
|
|
69
|
+
event.preventDefault();
|
|
70
|
+
first.focus();
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** A press on the dim part behind the window (and not one that started inside it and ended outside) closes it. */
|
|
75
|
+
function handleBackdropPress(event: MouseEvent): void {
|
|
76
|
+
if (event.target === event.currentTarget) requestClose();
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
onMount(() => {
|
|
80
|
+
const focusedBefore = readFocusedElement();
|
|
81
|
+
// A field that asked for the focus (autofocus) has it by now; otherwise the window itself takes it.
|
|
82
|
+
if (!dialogElement?.contains(readFocusedElement())) dialogElement?.focus();
|
|
83
|
+
return () => {
|
|
84
|
+
if (focusedBefore instanceof HTMLElement && focusedBefore.isConnected) focusedBefore.focus();
|
|
85
|
+
};
|
|
86
|
+
});
|
|
87
|
+
</script>
|
|
88
|
+
|
|
89
|
+
<!-- The dim part is a mouse convenience: the keyboard has Escape, handled on the window itself. -->
|
|
90
|
+
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
91
|
+
<div
|
|
92
|
+
class="fixed inset-0 z-50 flex items-center justify-center bg-ink-primary/40 p-4"
|
|
93
|
+
onmousedown={handleBackdropPress}
|
|
94
|
+
>
|
|
95
|
+
<div
|
|
96
|
+
bind:this={dialogElement}
|
|
97
|
+
role="dialog"
|
|
98
|
+
aria-modal="true"
|
|
99
|
+
aria-labelledby={titleId}
|
|
100
|
+
tabindex="-1"
|
|
101
|
+
class="flex max-h-full w-full flex-col overflow-hidden rounded-large border border-grey2 bg-white text-start text-ink-primary shadow-lg focus:outline-none {widthClasses[
|
|
102
|
+
size
|
|
103
|
+
]}"
|
|
104
|
+
onkeydown={handleKeydown}
|
|
105
|
+
>
|
|
106
|
+
<header class="flex items-start justify-between gap-3 border-b border-grey2 px-5 py-4">
|
|
107
|
+
<h2 id={titleId} class="text-base font-semibold">{title}</h2>
|
|
108
|
+
<ActionButton
|
|
109
|
+
variant="ghost"
|
|
110
|
+
size="small"
|
|
111
|
+
iconOnly
|
|
112
|
+
disabled={busy}
|
|
113
|
+
ariaLabel={$t('workflows.common.close')}
|
|
114
|
+
title={$t('workflows.common.close')}
|
|
115
|
+
onclick={requestClose}
|
|
116
|
+
>
|
|
117
|
+
<Icon name="close" />
|
|
118
|
+
</ActionButton>
|
|
119
|
+
</header>
|
|
120
|
+
<div class="min-h-0 flex-1 overflow-auto px-5 py-4">
|
|
121
|
+
{@render children()}
|
|
122
|
+
</div>
|
|
123
|
+
{#if footer}
|
|
124
|
+
<footer class="flex flex-wrap items-center justify-end gap-2 border-t border-grey2 px-5 py-3">
|
|
125
|
+
{@render footer()}
|
|
126
|
+
</footer>
|
|
127
|
+
{/if}
|
|
128
|
+
</div>
|
|
129
|
+
</div>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type Snippet } from 'svelte';
|
|
2
|
+
interface Props {
|
|
3
|
+
title: string;
|
|
4
|
+
onclose: () => void;
|
|
5
|
+
size?: 'small' | 'medium' | 'large';
|
|
6
|
+
/** While something is being done, the window cannot be dismissed by accident. */
|
|
7
|
+
busy?: boolean;
|
|
8
|
+
children: Snippet;
|
|
9
|
+
footer?: Snippet;
|
|
10
|
+
}
|
|
11
|
+
declare const Modal: import("svelte").Component<Props, {}, "">;
|
|
12
|
+
type Modal = ReturnType<typeof Modal>;
|
|
13
|
+
export default Modal;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
A line that tells the person how something went, or what to do about it: a failed save, a draft with changes, a reason a
|
|
3
|
+
choice is off. A problem is announced to a screen reader as soon as it appears (`role="alert"`); the rest is read in
|
|
4
|
+
its turn (`role="status"`).
|
|
5
|
+
|
|
6
|
+
It has no fill (the palette's muted ink does not read on a grey), only a border and, for the tone, the colour of the
|
|
7
|
+
words that are the problem. An action may sit at its end, e.g. "Reload" next to "This workflow was changed elsewhere".
|
|
8
|
+
-->
|
|
9
|
+
<script lang="ts">
|
|
10
|
+
import type { Snippet } from 'svelte';
|
|
11
|
+
import Icon from './Icon.svelte';
|
|
12
|
+
|
|
13
|
+
interface Props {
|
|
14
|
+
tone?: 'info' | 'problem';
|
|
15
|
+
/** The action at the end of the line, if there is one. */
|
|
16
|
+
action?: Snippet;
|
|
17
|
+
class?: string;
|
|
18
|
+
children: Snippet;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
let { tone = 'info', action, class: className = '', children }: Props = $props();
|
|
22
|
+
</script>
|
|
23
|
+
|
|
24
|
+
<div
|
|
25
|
+
role={tone === 'problem' ? 'alert' : 'status'}
|
|
26
|
+
class="flex items-start gap-3 rounded-medium border bg-white px-3 py-2 text-start text-sm {tone ===
|
|
27
|
+
'problem'
|
|
28
|
+
? 'border-error text-error'
|
|
29
|
+
: 'border-grey2 text-ink-primary'} {className}"
|
|
30
|
+
>
|
|
31
|
+
{#if tone === 'problem'}<Icon name="warning" class="mt-0.5 size-4" />{/if}
|
|
32
|
+
<div class="min-w-0 flex-1">{@render children()}</div>
|
|
33
|
+
{#if action}
|
|
34
|
+
<div class="flex shrink-0 items-center gap-2">{@render action()}</div>
|
|
35
|
+
{/if}
|
|
36
|
+
</div>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
interface Props {
|
|
3
|
+
tone?: 'info' | 'problem';
|
|
4
|
+
/** The action at the end of the line, if there is one. */
|
|
5
|
+
action?: Snippet;
|
|
6
|
+
class?: string;
|
|
7
|
+
children: Snippet;
|
|
8
|
+
}
|
|
9
|
+
declare const Notice: import("svelte").Component<Props, {}, "">;
|
|
10
|
+
type Notice = ReturnType<typeof Notice>;
|
|
11
|
+
export default Notice;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
A choice of one among several, with its label above it. It is the browser's own select, so it opens the way every select of
|
|
3
|
+
the person's device does (a wheel on a phone, the keyboard everywhere) and needs nothing to float above the page.
|
|
4
|
+
|
|
5
|
+
The choices come with their words already in the page's language. A choice whose words were written by a person (the
|
|
6
|
+
name of a composition, a column) keeps the direction of that text.
|
|
7
|
+
-->
|
|
8
|
+
<script lang="ts">
|
|
9
|
+
import type { SelectChoice } from './types.js';
|
|
10
|
+
|
|
11
|
+
interface Props {
|
|
12
|
+
label: string;
|
|
13
|
+
value: string;
|
|
14
|
+
choices: readonly SelectChoice[];
|
|
15
|
+
help?: string;
|
|
16
|
+
problem?: string;
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
/** Hides the label but keeps it for a screen reader, when the surroundings already say what is chosen. */
|
|
19
|
+
hideLabel?: boolean;
|
|
20
|
+
class?: string;
|
|
21
|
+
onchange?: (value: string) => void;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
let {
|
|
25
|
+
label,
|
|
26
|
+
value = $bindable(),
|
|
27
|
+
choices,
|
|
28
|
+
help,
|
|
29
|
+
problem,
|
|
30
|
+
disabled = false,
|
|
31
|
+
hideLabel = false,
|
|
32
|
+
class: className = '',
|
|
33
|
+
onchange
|
|
34
|
+
}: Props = $props();
|
|
35
|
+
|
|
36
|
+
const fieldId = $props.id();
|
|
37
|
+
const helpId = $derived(`${fieldId}-help`);
|
|
38
|
+
const problemId = $derived(`${fieldId}-problem`);
|
|
39
|
+
const describedBy = $derived(
|
|
40
|
+
[help ? helpId : '', problem ? problemId : ''].filter(Boolean).join(' ') || undefined
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
/** What the browser reports when the person picks: the value of the choice, which goes up to the one that listens. */
|
|
44
|
+
function reportChoice(event: Event & { currentTarget: HTMLSelectElement }): void {
|
|
45
|
+
onchange?.(event.currentTarget.value);
|
|
46
|
+
}
|
|
47
|
+
</script>
|
|
48
|
+
|
|
49
|
+
<div class="flex min-w-0 flex-col gap-1 text-start {className}">
|
|
50
|
+
<label for={fieldId} class={hideLabel ? 'sr-only' : 'text-xs font-medium text-ink-primary'}
|
|
51
|
+
>{label}</label
|
|
52
|
+
>
|
|
53
|
+
<select
|
|
54
|
+
id={fieldId}
|
|
55
|
+
bind:value
|
|
56
|
+
{disabled}
|
|
57
|
+
class="w-full min-w-0 rounded-medium border bg-white px-3 py-2 text-sm text-ink-primary focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-primary-green disabled:cursor-not-allowed disabled:opacity-50 {problem
|
|
58
|
+
? 'border-error'
|
|
59
|
+
: 'border-grey2'}"
|
|
60
|
+
aria-invalid={problem ? true : undefined}
|
|
61
|
+
aria-describedby={describedBy}
|
|
62
|
+
onchange={reportChoice}
|
|
63
|
+
>
|
|
64
|
+
{#each choices as choice (choice.value)}
|
|
65
|
+
<option value={choice.value} disabled={choice.disabled}>{choice.label}</option>
|
|
66
|
+
{/each}
|
|
67
|
+
</select>
|
|
68
|
+
{#if help}
|
|
69
|
+
<p id={helpId} class="text-xs text-ink-muted">{help}</p>
|
|
70
|
+
{/if}
|
|
71
|
+
{#if problem}
|
|
72
|
+
<p id={problemId} class="text-xs text-error">{problem}</p>
|
|
73
|
+
{/if}
|
|
74
|
+
</div>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { SelectChoice } from './types.js';
|
|
2
|
+
interface Props {
|
|
3
|
+
label: string;
|
|
4
|
+
value: string;
|
|
5
|
+
choices: readonly SelectChoice[];
|
|
6
|
+
help?: string;
|
|
7
|
+
problem?: string;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
/** Hides the label but keeps it for a screen reader, when the surroundings already say what is chosen. */
|
|
10
|
+
hideLabel?: boolean;
|
|
11
|
+
class?: string;
|
|
12
|
+
onchange?: (value: string) => void;
|
|
13
|
+
}
|
|
14
|
+
declare const SelectField: import("svelte").Component<Props, {}, "value">;
|
|
15
|
+
type SelectField = ReturnType<typeof SelectField>;
|
|
16
|
+
export default SelectField;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Where a workflow stands, as a dot and a word: live (visitors move through it), a draft that was never published, paused
|
|
3
|
+
(the embed shows only its first composition), archived. The word always carries the meaning; the dot only helps the eye,
|
|
4
|
+
so a person who cannot tell the colours apart loses nothing.
|
|
5
|
+
-->
|
|
6
|
+
<script lang="ts">
|
|
7
|
+
import { useWorkflowsLanguage } from '../../i18n/language.js';
|
|
8
|
+
import type { WorkflowStatus } from '../../api/types.js';
|
|
9
|
+
|
|
10
|
+
interface Props {
|
|
11
|
+
status: WorkflowStatus;
|
|
12
|
+
/** Whether the draft holds changes that are not live yet (shown next to a live workflow). */
|
|
13
|
+
hasUnpublishedChanges?: boolean;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
let { status, hasUnpublishedChanges = false }: Props = $props();
|
|
17
|
+
|
|
18
|
+
const { t } = useWorkflowsLanguage();
|
|
19
|
+
|
|
20
|
+
const dotClasses: Record<WorkflowStatus, string> = {
|
|
21
|
+
draft: 'bg-ink-subtle',
|
|
22
|
+
live: 'bg-primary-green',
|
|
23
|
+
paused: 'bg-ink-muted',
|
|
24
|
+
archived: 'bg-ink-subtle'
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const wordKeys = {
|
|
28
|
+
draft: 'workflows.status.draft',
|
|
29
|
+
live: 'workflows.status.live',
|
|
30
|
+
paused: 'workflows.status.paused',
|
|
31
|
+
archived: 'workflows.status.archived'
|
|
32
|
+
} as const;
|
|
33
|
+
</script>
|
|
34
|
+
|
|
35
|
+
<span class="inline-flex items-center gap-1.5 text-xs text-ink-primary">
|
|
36
|
+
<span class="size-2 shrink-0 rounded-pill {dotClasses[status]}" aria-hidden="true"></span>
|
|
37
|
+
<span>{$t(wordKeys[status])}</span>
|
|
38
|
+
{#if hasUnpublishedChanges && status === 'live'}
|
|
39
|
+
<span class="text-ink-muted">· {$t('workflows.status.unpublishedChanges')}</span>
|
|
40
|
+
{/if}
|
|
41
|
+
</span>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { WorkflowStatus } from '../../api/types.js';
|
|
2
|
+
interface Props {
|
|
3
|
+
status: WorkflowStatus;
|
|
4
|
+
/** Whether the draft holds changes that are not live yet (shown next to a live workflow). */
|
|
5
|
+
hasUnpublishedChanges?: boolean;
|
|
6
|
+
}
|
|
7
|
+
declare const StatusBadge: import("svelte").Component<Props, {}, "">;
|
|
8
|
+
type StatusBadge = ReturnType<typeof StatusBadge>;
|
|
9
|
+
export default StatusBadge;
|