@widgetic/workflows 0.2.6 → 0.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +51 -44
- package/dist/api/types.d.ts +17 -0
- package/dist/api/types.js +7 -0
- package/dist/api/workflowsApi.js +23 -2
- package/dist/components/Workflows.svelte +13 -15
- package/dist/components/WorkflowsEmptyState.svelte +14 -12
- package/dist/components/WorkflowsHeader.svelte +9 -5
- package/dist/components/WorkflowsHeader.svelte.d.ts +4 -16
- package/dist/components/WorkflowsWorkspace.svelte +3 -2
- package/dist/components/canvas/AddBlockMenu.svelte +11 -2
- package/dist/components/canvas/CanvasToolbar.svelte +42 -31
- package/dist/components/canvas/CanvasToolbar.svelte.d.ts +2 -0
- package/dist/components/canvas/CompositionNodeView.svelte +58 -36
- package/dist/components/canvas/ConditionNodeView.svelte +31 -18
- package/dist/components/canvas/HandlePoint.svelte +10 -3
- package/dist/components/canvas/HandlePoint.svelte.d.ts +1 -1
- package/dist/components/canvas/TriggerNodeView.svelte +39 -13
- package/dist/components/canvas/WorkflowCanvas.svelte +22 -7
- package/dist/components/canvas/WorkflowCanvas.svelte.d.ts +2 -0
- package/dist/components/canvas/WorkflowEdgeView.svelte +5 -6
- package/dist/components/editor/ConflictBanner.svelte +1 -1
- package/dist/components/editor/EditorBanners.svelte +11 -4
- package/dist/components/editor/EditorCanvasArea.svelte +17 -10
- package/dist/components/editor/EditorTabs.svelte +10 -44
- package/dist/components/editor/EditorTopBar.svelte +166 -54
- package/dist/components/editor/PresenceBanner.svelte +106 -85
- package/dist/components/editor/RunsFlow.svelte +136 -42
- package/dist/components/editor/RunsTab.svelte +52 -46
- package/dist/components/editor/SettingsRow.svelte +35 -0
- package/dist/components/editor/SettingsRow.svelte.d.ts +14 -0
- package/dist/components/editor/SettingsTab.svelte +66 -50
- package/dist/components/editor/WorkflowEditor.svelte +4 -5
- package/dist/components/list/CreateWorkflowDialog.svelte +123 -73
- package/dist/components/list/WorkflowList.svelte +227 -100
- package/dist/components/list/WorkflowRow.svelte +84 -42
- package/dist/components/panel/BlockProblems.svelte +9 -8
- package/dist/components/panel/CompositionForm.svelte +52 -34
- package/dist/components/panel/CompositionPicker.svelte +43 -21
- package/dist/components/panel/CompositionPicker.svelte.d.ts +5 -0
- package/dist/components/panel/CompositionSelect.svelte +105 -0
- package/dist/components/panel/CompositionSelect.svelte.d.ts +23 -0
- package/dist/components/panel/ConditionForm.svelte +50 -17
- package/dist/components/panel/EventValueRow.svelte +5 -4
- package/dist/components/panel/ProblemsList.svelte +17 -19
- package/dist/components/panel/RuleCard.svelte +127 -89
- package/dist/components/panel/RuleCard.svelte.d.ts +2 -0
- package/dist/components/panel/SidePanel.svelte +101 -50
- package/dist/components/panel/TestResultLine.svelte +35 -0
- package/dist/components/panel/TestResultLine.svelte.d.ts +9 -0
- package/dist/components/panel/TestRow.svelte +21 -18
- package/dist/components/panel/TestRunPanel.svelte +61 -39
- package/dist/components/panel/TestTriggerCard.svelte +66 -6
- package/dist/components/panel/TestTriggerCard.svelte.d.ts +10 -0
- package/dist/components/panel/TriggerForm.svelte +24 -25
- package/dist/components/panel/VersionHistory.svelte +31 -43
- package/dist/components/ui/ActionButton.svelte +44 -12
- package/dist/components/ui/ActionButton.svelte.d.ts +2 -1
- package/dist/components/ui/Badge.svelte +39 -0
- package/dist/components/ui/Badge.svelte.d.ts +12 -0
- package/dist/components/ui/ConfirmDialog.svelte +4 -3
- package/dist/components/ui/Menu.svelte +28 -14
- package/dist/components/ui/Menu.svelte.d.ts +3 -1
- package/dist/components/ui/Modal.svelte +15 -8
- package/dist/components/ui/Notice.svelte +35 -11
- package/dist/components/ui/Notice.svelte.d.ts +4 -1
- package/dist/components/ui/SelectField.svelte +48 -20
- package/dist/components/ui/SelectField.svelte.d.ts +2 -0
- package/dist/components/ui/StatusBadge.svelte +13 -24
- package/dist/components/ui/StatusBadge.svelte.d.ts +0 -2
- package/dist/components/ui/Tabs.svelte +79 -0
- package/dist/components/ui/Tabs.svelte.d.ts +21 -0
- package/dist/components/ui/TextField.svelte +47 -27
- package/dist/components/ui/TextField.svelte.d.ts +5 -0
- package/dist/components/ui/icons.d.ts +43 -29
- package/dist/components/ui/icons.js +101 -40
- package/dist/editor/editorState.svelte.d.ts +23 -2
- package/dist/editor/editorState.svelte.js +36 -0
- package/dist/editor/listState.svelte.d.ts +32 -2
- package/dist/editor/listState.svelte.js +41 -0
- package/dist/editor/runsFlow.d.ts +28 -3
- package/dist/editor/runsFlow.js +27 -2
- package/dist/editor/runsFlowLayout.d.ts +6 -2
- package/dist/editor/runsFlowLayout.js +7 -2
- package/dist/editor/statsRange.d.ts +7 -1
- package/dist/editor/statsRange.js +14 -0
- package/dist/i18n/language.d.ts +3 -3
- package/dist/i18n/messages.d.ts +32 -13
- package/dist/i18n/messages.js +33 -14
- package/dist/i18n/statusWords.d.ts +12 -0
- package/dist/i18n/statusWords.js +12 -0
- package/package.json +3 -3
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
A small pill with a word in it: where something stands ("Live", "Draft"), that something is the start ("Starts here"), or
|
|
3
|
+
that something is wrong ("2 problems"). Figma: Badge (component set 50:4).
|
|
4
|
+
|
|
5
|
+
The word always carries the meaning; the colour and the dot only help the eye. The caller gives the word (already in the
|
|
6
|
+
page's language) as the content.
|
|
7
|
+
-->
|
|
8
|
+
<script lang="ts">
|
|
9
|
+
import type { Snippet } from 'svelte';
|
|
10
|
+
|
|
11
|
+
interface Props {
|
|
12
|
+
/** `neutral` is grey, `brand` is the sage of the design, `destructive` is red, `outline` has only a line. */
|
|
13
|
+
tone?: 'neutral' | 'brand' | 'destructive' | 'outline';
|
|
14
|
+
/** A small dot before the word. */
|
|
15
|
+
showDot?: boolean;
|
|
16
|
+
class?: string;
|
|
17
|
+
children: Snippet;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
let { tone = 'neutral', showDot = false, class: className = '', children }: Props = $props();
|
|
21
|
+
|
|
22
|
+
const toneClasses = {
|
|
23
|
+
neutral: 'border-transparent bg-secondary text-secondary-foreground',
|
|
24
|
+
brand: 'border-transparent bg-brand-subtle text-brand-foreground',
|
|
25
|
+
destructive: 'border-transparent bg-destructive text-destructive-foreground',
|
|
26
|
+
outline: 'border-border bg-transparent text-foreground'
|
|
27
|
+
};
|
|
28
|
+
</script>
|
|
29
|
+
|
|
30
|
+
<span
|
|
31
|
+
class="inline-flex h-5 max-w-full shrink-0 items-center gap-1.5 rounded-full border px-2 text-label-small whitespace-nowrap {toneClasses[
|
|
32
|
+
tone
|
|
33
|
+
]} {className}"
|
|
34
|
+
>
|
|
35
|
+
{#if showDot}
|
|
36
|
+
<span class="size-1.5 shrink-0 rounded-full bg-current" aria-hidden="true"></span>
|
|
37
|
+
{/if}
|
|
38
|
+
<span class="truncate">{@render children()}</span>
|
|
39
|
+
</span>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
interface Props {
|
|
3
|
+
/** `neutral` is grey, `brand` is the sage of the design, `destructive` is red, `outline` has only a line. */
|
|
4
|
+
tone?: 'neutral' | 'brand' | 'destructive' | 'outline';
|
|
5
|
+
/** A small dot before the word. */
|
|
6
|
+
showDot?: boolean;
|
|
7
|
+
class?: string;
|
|
8
|
+
children: Snippet;
|
|
9
|
+
}
|
|
10
|
+
declare const Badge: import("svelte").Component<Props, {}, "">;
|
|
11
|
+
type Badge = ReturnType<typeof Badge>;
|
|
12
|
+
export default Badge;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
<!--
|
|
2
2
|
A question with two answers, for a thing that cannot be taken back or that changes what visitors see. The caller says what
|
|
3
3
|
is about to happen and what the button that agrees is called; "Cancel" is always there and is where the focus starts, so
|
|
4
|
-
that an Enter pressed too quickly does not agree.
|
|
4
|
+
that an Enter pressed too quickly does not agree. The look is the design's confirmation (Figma "Dialog", Kind Delete): a
|
|
5
|
+
title, the words in the quiet colour, an outline "Cancel" and the button that agrees, red when it takes something away.
|
|
5
6
|
-->
|
|
6
7
|
<script lang="ts">
|
|
7
8
|
import { useWorkflowsLanguage } from '../../i18n/language.js';
|
|
@@ -36,9 +37,9 @@
|
|
|
36
37
|
</script>
|
|
37
38
|
|
|
38
39
|
<Modal {title} size="small" {busy} onclose={oncancel}>
|
|
39
|
-
<p class="text-
|
|
40
|
+
<p class="text-body text-muted-foreground">{message}</p>
|
|
40
41
|
{#snippet footer()}
|
|
41
|
-
<ActionButton variant="
|
|
42
|
+
<ActionButton variant="outline" disabled={busy} onclick={oncancel}
|
|
42
43
|
>{$t('workflows.common.cancel')}</ActionButton
|
|
43
44
|
>
|
|
44
45
|
<ActionButton
|
|
@@ -7,6 +7,10 @@
|
|
|
7
7
|
order (`aria-disabled`) so that the reason under it is read, and choosing it does nothing.
|
|
8
8
|
|
|
9
9
|
The listeners that watch for a press outside exist only while the menu is open.
|
|
10
|
+
|
|
11
|
+
The look is the design's menu (Figma "Menu", "Menu Item", "Menu Separator"): a flat list with a line around it, the lines
|
|
12
|
+
of a group close together and a thin rule between groups. It opens below the button, or above it (`placement`) when the
|
|
13
|
+
button sits at the bottom of the room, as the canvas toolbar does.
|
|
10
14
|
-->
|
|
11
15
|
<script lang="ts">
|
|
12
16
|
import { tick } from 'svelte';
|
|
@@ -21,11 +25,13 @@
|
|
|
21
25
|
label: string;
|
|
22
26
|
icon?: IconName;
|
|
23
27
|
iconOnly?: boolean;
|
|
24
|
-
variant?: 'primary' | 'secondary' | 'ghost';
|
|
28
|
+
variant?: 'primary' | 'outline' | 'secondary' | 'ghost' | 'accent';
|
|
25
29
|
size?: 'small' | 'medium';
|
|
26
30
|
disabled?: boolean;
|
|
27
31
|
/** Which edge of the button the list lines up with: `end` opens it toward the start of the line, away from the edge. */
|
|
28
32
|
align?: 'start' | 'end';
|
|
33
|
+
/** Where the list opens: `below` the button, or `above` it (for a button at the bottom of the room). */
|
|
34
|
+
placement?: 'below' | 'above';
|
|
29
35
|
class?: string;
|
|
30
36
|
onopen?: () => void;
|
|
31
37
|
}
|
|
@@ -35,10 +41,11 @@
|
|
|
35
41
|
label,
|
|
36
42
|
icon,
|
|
37
43
|
iconOnly = false,
|
|
38
|
-
variant = '
|
|
44
|
+
variant = 'outline',
|
|
39
45
|
size = 'medium',
|
|
40
46
|
disabled = false,
|
|
41
47
|
align = 'start',
|
|
48
|
+
placement = 'below',
|
|
42
49
|
class: className = '',
|
|
43
50
|
onopen
|
|
44
51
|
}: Props = $props();
|
|
@@ -171,16 +178,23 @@
|
|
|
171
178
|
id={menuId}
|
|
172
179
|
role="menu"
|
|
173
180
|
tabindex="-1"
|
|
174
|
-
class="absolute z-30
|
|
175
|
-
'
|
|
176
|
-
? '
|
|
177
|
-
: 'start-0'}"
|
|
181
|
+
class="absolute z-30 flex max-h-[min(30rem,70vh)] w-max max-w-80 min-w-50 flex-col overflow-auto rounded-xl border border-border bg-popover p-1 text-popover-foreground {placement ===
|
|
182
|
+
'above'
|
|
183
|
+
? 'bottom-full mb-1'
|
|
184
|
+
: 'mt-1'} {align === 'end' ? 'end-0' : 'start-0'}"
|
|
178
185
|
onkeydown={handleMenuKeydown}
|
|
179
186
|
>
|
|
180
|
-
{#each groups as group (group.key)}
|
|
181
|
-
<div
|
|
187
|
+
{#each groups as group, groupIndex (group.key)}
|
|
188
|
+
<div
|
|
189
|
+
role="group"
|
|
190
|
+
aria-label={group.heading}
|
|
191
|
+
class="flex flex-col {groupIndex > 0 ? 'mt-1 border-t border-border pt-1' : ''}"
|
|
192
|
+
>
|
|
182
193
|
{#if group.heading}
|
|
183
|
-
<p
|
|
194
|
+
<p
|
|
195
|
+
class="px-2 pt-1.5 pb-1 text-caption-medium text-muted-foreground"
|
|
196
|
+
aria-hidden="true"
|
|
197
|
+
>
|
|
184
198
|
{group.heading}
|
|
185
199
|
</p>
|
|
186
200
|
{/if}
|
|
@@ -189,17 +203,17 @@
|
|
|
189
203
|
type="button"
|
|
190
204
|
role="menuitem"
|
|
191
205
|
aria-disabled={item.disabled ? true : undefined}
|
|
192
|
-
class="flex w-full items-
|
|
206
|
+
class="flex w-full items-center gap-2 rounded-lg px-2 py-1.5 text-start text-body transition-colors duration-fast hover:bg-accent focus-visible:bg-accent focus-visible:outline-hidden {item.tone ===
|
|
193
207
|
'danger'
|
|
194
|
-
? 'text-
|
|
195
|
-
: 'text-
|
|
208
|
+
? 'text-destructive'
|
|
209
|
+
: 'text-foreground'} {item.disabled ? 'cursor-default' : ''}"
|
|
196
210
|
onclick={() => choose(item)}
|
|
197
211
|
>
|
|
198
|
-
{#if item.icon}<Icon name={item.icon} class="
|
|
212
|
+
{#if item.icon}<Icon name={item.icon} class="size-4 shrink-0" />{/if}
|
|
199
213
|
<span class="flex min-w-0 flex-col">
|
|
200
214
|
<span class={item.disabled ? 'opacity-60' : ''}>{item.label}</span>
|
|
201
215
|
{#if item.description}
|
|
202
|
-
<span class="text-
|
|
216
|
+
<span class="text-caption text-muted-foreground">{item.description}</span>
|
|
203
217
|
{/if}
|
|
204
218
|
</span>
|
|
205
219
|
</button>
|
|
@@ -6,11 +6,13 @@ interface Props {
|
|
|
6
6
|
label: string;
|
|
7
7
|
icon?: IconName;
|
|
8
8
|
iconOnly?: boolean;
|
|
9
|
-
variant?: 'primary' | 'secondary' | 'ghost';
|
|
9
|
+
variant?: 'primary' | 'outline' | 'secondary' | 'ghost' | 'accent';
|
|
10
10
|
size?: 'small' | 'medium';
|
|
11
11
|
disabled?: boolean;
|
|
12
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
13
|
align?: 'start' | 'end';
|
|
14
|
+
/** Where the list opens: `below` the button, or `above` it (for a button at the bottom of the room). */
|
|
15
|
+
placement?: 'below' | 'above';
|
|
14
16
|
class?: string;
|
|
15
17
|
onopen?: () => void;
|
|
16
18
|
}
|
|
@@ -6,6 +6,9 @@
|
|
|
6
6
|
|
|
7
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
8
|
the screen's own language, direction and styles wherever the screen is mounted, in a shadow root too.
|
|
9
|
+
|
|
10
|
+
The look is the design's dialog (Figma "Dialog"): a white panel with a line around it, 24 inside, the title and the
|
|
11
|
+
close button on one row, the words, and the buttons at the end. `small` is 400 wide, `medium` 480, `large` 566.
|
|
9
12
|
-->
|
|
10
13
|
<script lang="ts">
|
|
11
14
|
import { onMount, type Snippet } from 'svelte';
|
|
@@ -31,7 +34,11 @@
|
|
|
31
34
|
const FOCUSABLE_SELECTOR =
|
|
32
35
|
'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
|
|
33
36
|
|
|
34
|
-
const widthClasses = {
|
|
37
|
+
const widthClasses = {
|
|
38
|
+
small: 'w-dialog max-w-full',
|
|
39
|
+
medium: 'w-120 max-w-full',
|
|
40
|
+
large: 'w-file-dialog max-w-full'
|
|
41
|
+
};
|
|
35
42
|
|
|
36
43
|
let dialogElement = $state<HTMLDivElement>();
|
|
37
44
|
|
|
@@ -89,7 +96,7 @@
|
|
|
89
96
|
<!-- The dim part is a mouse convenience: the keyboard has Escape, handled on the window itself. -->
|
|
90
97
|
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
91
98
|
<div
|
|
92
|
-
class="fixed inset-0 z-50 flex items-center justify-center bg-
|
|
99
|
+
class="fixed inset-0 z-50 flex items-center justify-center bg-foreground/40 p-4 backdrop-blur-sm"
|
|
93
100
|
onmousedown={handleBackdropPress}
|
|
94
101
|
>
|
|
95
102
|
<div
|
|
@@ -98,16 +105,15 @@
|
|
|
98
105
|
aria-modal="true"
|
|
99
106
|
aria-labelledby={titleId}
|
|
100
107
|
tabindex="-1"
|
|
101
|
-
class="flex max-h-full
|
|
108
|
+
class="flex max-h-full flex-col gap-4 overflow-hidden rounded-panel border border-border bg-background p-6 text-start text-foreground focus:outline-hidden {widthClasses[
|
|
102
109
|
size
|
|
103
110
|
]}"
|
|
104
111
|
onkeydown={handleKeydown}
|
|
105
112
|
>
|
|
106
|
-
<header class="flex items-
|
|
107
|
-
<h2 id={titleId} class="
|
|
113
|
+
<header class="flex items-center gap-2">
|
|
114
|
+
<h2 id={titleId} class="min-w-0 flex-1 text-heading-page">{title}</h2>
|
|
108
115
|
<ActionButton
|
|
109
116
|
variant="ghost"
|
|
110
|
-
size="small"
|
|
111
117
|
iconOnly
|
|
112
118
|
disabled={busy}
|
|
113
119
|
ariaLabel={$t('workflows.common.close')}
|
|
@@ -117,11 +123,12 @@
|
|
|
117
123
|
<Icon name="close" />
|
|
118
124
|
</ActionButton>
|
|
119
125
|
</header>
|
|
120
|
-
|
|
126
|
+
<!-- The little overflow and the same padding keep the focus ring of a field from being cut off by the scroll. -->
|
|
127
|
+
<div class="-m-1 min-h-0 flex-1 overflow-auto p-1">
|
|
121
128
|
{@render children()}
|
|
122
129
|
</div>
|
|
123
130
|
{#if footer}
|
|
124
|
-
<footer class="flex flex-wrap items-center justify-end gap-2
|
|
131
|
+
<footer class="flex flex-wrap items-center justify-end gap-2">
|
|
125
132
|
{@render footer()}
|
|
126
133
|
</footer>
|
|
127
134
|
{/if}
|
|
@@ -3,34 +3,58 @@
|
|
|
3
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
4
|
its turn (`role="status"`).
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
The looks are the design's banner (Figma "Banner"): `info` is a quiet grey band, `brand` the sage one (something that
|
|
7
|
+
went well, or a draft waiting to be published) and `problem` has a red line around it. Each has its small picture at the
|
|
8
|
+
start; the words stay in the colour of the text so they read on every band. An action may sit at its end, e.g.
|
|
9
|
+
"Reload" next to "This workflow was changed elsewhere".
|
|
8
10
|
-->
|
|
9
11
|
<script lang="ts">
|
|
10
12
|
import type { Snippet } from 'svelte';
|
|
11
13
|
import Icon from './Icon.svelte';
|
|
14
|
+
import type { IconName } from './icons.js';
|
|
12
15
|
|
|
13
16
|
interface Props {
|
|
14
|
-
tone?: 'info' | 'problem';
|
|
17
|
+
tone?: 'info' | 'problem' | 'brand';
|
|
18
|
+
/** Another picture than the one of the tone. */
|
|
19
|
+
icon?: IconName;
|
|
15
20
|
/** The action at the end of the line, if there is one. */
|
|
16
21
|
action?: Snippet;
|
|
17
22
|
class?: string;
|
|
18
23
|
children: Snippet;
|
|
19
24
|
}
|
|
20
25
|
|
|
21
|
-
let { tone = 'info', action, class: className = '', children }: Props = $props();
|
|
26
|
+
let { tone = 'info', icon, action, class: className = '', children }: Props = $props();
|
|
27
|
+
|
|
28
|
+
const toneClasses = {
|
|
29
|
+
info: 'bg-muted',
|
|
30
|
+
brand: 'bg-brand-subtle',
|
|
31
|
+
problem: 'border border-destructive bg-background'
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const toneIcons = {
|
|
35
|
+
info: 'info',
|
|
36
|
+
brand: 'circleCheck',
|
|
37
|
+
problem: 'warning'
|
|
38
|
+
} as const satisfies Record<'info' | 'brand' | 'problem', IconName>;
|
|
22
39
|
</script>
|
|
23
40
|
|
|
24
41
|
<div
|
|
25
42
|
role={tone === 'problem' ? 'alert' : 'status'}
|
|
26
|
-
class="flex items-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
: 'border-grey2 text-ink-primary'} {className}"
|
|
43
|
+
class="flex items-center gap-3 rounded-xl py-2.5 ps-4 pe-3 text-start text-body text-foreground {toneClasses[
|
|
44
|
+
tone
|
|
45
|
+
]} {className}"
|
|
30
46
|
>
|
|
31
|
-
|
|
32
|
-
|
|
47
|
+
<Icon
|
|
48
|
+
name={icon ?? toneIcons[tone]}
|
|
49
|
+
class="size-4 shrink-0 {tone === 'problem' ? 'text-destructive' : ''}"
|
|
50
|
+
/>
|
|
51
|
+
<div class="min-w-0 flex-1 py-0.5">{@render children()}</div>
|
|
33
52
|
{#if action}
|
|
34
|
-
|
|
53
|
+
<!-- A button with a line (outline) keeps it here in the design's stronger line, so it stands out on the grey and the sage. -->
|
|
54
|
+
<div
|
|
55
|
+
class="flex shrink-0 flex-wrap items-center justify-end gap-2 [&_button]:border-border-strong"
|
|
56
|
+
>
|
|
57
|
+
{@render action()}
|
|
58
|
+
</div>
|
|
35
59
|
{/if}
|
|
36
60
|
</div>
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { IconName } from './icons.js';
|
|
2
3
|
interface Props {
|
|
3
|
-
tone?: 'info' | 'problem';
|
|
4
|
+
tone?: 'info' | 'problem' | 'brand';
|
|
5
|
+
/** Another picture than the one of the tone. */
|
|
6
|
+
icon?: IconName;
|
|
4
7
|
/** The action at the end of the line, if there is one. */
|
|
5
8
|
action?: Snippet;
|
|
6
9
|
class?: string;
|
|
@@ -2,10 +2,16 @@
|
|
|
2
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
3
|
the person's device does (a wheel on a phone, the keyboard everywhere) and needs nothing to float above the page.
|
|
4
4
|
|
|
5
|
+
The look is the design's select (Figma "Select" and "Select Trigger"): the real select lies over a drawn trigger and is
|
|
6
|
+
see-through, so a click, a tap and the keyboard all reach the browser's own control while the eye sees the trigger of
|
|
7
|
+
the design (the chosen words, a chevron, the focus ring). The drawn trigger is hidden from a screen reader: the select
|
|
8
|
+
says everything.
|
|
9
|
+
|
|
5
10
|
The choices come with their words already in the page's language. A choice whose words were written by a person (the
|
|
6
11
|
name of a composition, a column) keeps the direction of that text.
|
|
7
12
|
-->
|
|
8
13
|
<script lang="ts">
|
|
14
|
+
import Icon from './Icon.svelte';
|
|
9
15
|
import type { SelectChoice } from './types.js';
|
|
10
16
|
|
|
11
17
|
interface Props {
|
|
@@ -17,6 +23,8 @@
|
|
|
17
23
|
disabled?: boolean;
|
|
18
24
|
/** Hides the label but keeps it for a screen reader, when the surroundings already say what is chosen. */
|
|
19
25
|
hideLabel?: boolean;
|
|
26
|
+
/** Shows the label inside the trigger, before the chosen words ("Sort by Date created"), and not above it. */
|
|
27
|
+
inlineLabel?: boolean;
|
|
20
28
|
class?: string;
|
|
21
29
|
onchange?: (value: string) => void;
|
|
22
30
|
}
|
|
@@ -29,6 +37,7 @@
|
|
|
29
37
|
problem,
|
|
30
38
|
disabled = false,
|
|
31
39
|
hideLabel = false,
|
|
40
|
+
inlineLabel = false,
|
|
32
41
|
class: className = '',
|
|
33
42
|
onchange
|
|
34
43
|
}: Props = $props();
|
|
@@ -40,35 +49,54 @@
|
|
|
40
49
|
[help ? helpId : '', problem ? problemId : ''].filter(Boolean).join(' ') || undefined
|
|
41
50
|
);
|
|
42
51
|
|
|
52
|
+
/** The words of the chosen line, which the drawn trigger shows. */
|
|
53
|
+
const chosenLabel = $derived(choices.find((choice) => choice.value === value)?.label ?? '');
|
|
54
|
+
|
|
43
55
|
/** What the browser reports when the person picks: the value of the choice, which goes up to the one that listens. */
|
|
44
56
|
function reportChoice(event: Event & { currentTarget: HTMLSelectElement }): void {
|
|
45
57
|
onchange?.(event.currentTarget.value);
|
|
46
58
|
}
|
|
47
59
|
</script>
|
|
48
60
|
|
|
49
|
-
<div class="flex min-w-0 flex-col gap-1 text-start {className}">
|
|
50
|
-
<label
|
|
51
|
-
|
|
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}
|
|
61
|
+
<div class="flex min-w-0 flex-col gap-1.5 text-start {className}">
|
|
62
|
+
<label
|
|
63
|
+
for={fieldId}
|
|
64
|
+
class={hideLabel || inlineLabel ? 'sr-only' : 'text-body-medium text-foreground'}>{label}</label
|
|
63
65
|
>
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
<div class="relative">
|
|
67
|
+
<select
|
|
68
|
+
id={fieldId}
|
|
69
|
+
bind:value
|
|
70
|
+
{disabled}
|
|
71
|
+
class="peer absolute inset-0 z-10 size-full cursor-pointer text-body text-foreground opacity-0 disabled:cursor-default"
|
|
72
|
+
aria-invalid={problem ? true : undefined}
|
|
73
|
+
aria-describedby={describedBy}
|
|
74
|
+
onchange={reportChoice}
|
|
75
|
+
>
|
|
76
|
+
{#each choices as choice (choice.value)}
|
|
77
|
+
<option value={choice.value} disabled={choice.disabled}>{choice.label}</option>
|
|
78
|
+
{/each}
|
|
79
|
+
</select>
|
|
80
|
+
<!-- What the eye sees. The select above it is the control. -->
|
|
81
|
+
<div
|
|
82
|
+
class="flex h-9 items-center gap-1.5 rounded-lg border bg-background px-3 text-body text-foreground transition-colors duration-fast peer-hover:bg-accent peer-focus-visible:ring-2 peer-focus-visible:ring-ring peer-focus-visible:ring-offset-2 peer-focus-visible:ring-offset-background peer-disabled:opacity-50 {problem
|
|
83
|
+
? 'border-destructive'
|
|
84
|
+
: 'border-input'}"
|
|
85
|
+
aria-hidden="true"
|
|
86
|
+
>
|
|
87
|
+
{#if inlineLabel}
|
|
88
|
+
<span class="shrink-0 text-muted-foreground">{label}</span>
|
|
89
|
+
{/if}
|
|
90
|
+
<span class="min-w-0 flex-1 truncate {inlineLabel ? 'text-body-medium' : ''}" dir="auto"
|
|
91
|
+
>{chosenLabel}</span
|
|
92
|
+
>
|
|
93
|
+
<Icon name="down" class="size-4 shrink-0 opacity-50" />
|
|
94
|
+
</div>
|
|
95
|
+
</div>
|
|
68
96
|
{#if help}
|
|
69
|
-
<p id={helpId} class="text-
|
|
97
|
+
<p id={helpId} class="text-caption text-muted-foreground">{help}</p>
|
|
70
98
|
{/if}
|
|
71
99
|
{#if problem}
|
|
72
|
-
<p id={problemId} class="text-
|
|
100
|
+
<p id={problemId} class="text-caption text-destructive">{problem}</p>
|
|
73
101
|
{/if}
|
|
74
102
|
</div>
|
|
@@ -8,6 +8,8 @@ interface Props {
|
|
|
8
8
|
disabled?: boolean;
|
|
9
9
|
/** Hides the label but keeps it for a screen reader, when the surroundings already say what is chosen. */
|
|
10
10
|
hideLabel?: boolean;
|
|
11
|
+
/** Shows the label inside the trigger, before the chosen words ("Sort by Date created"), and not above it. */
|
|
12
|
+
inlineLabel?: boolean;
|
|
11
13
|
class?: string;
|
|
12
14
|
onchange?: (value: string) => void;
|
|
13
15
|
}
|
|
@@ -1,41 +1,30 @@
|
|
|
1
1
|
<!--
|
|
2
|
-
Where a workflow stands, as a
|
|
2
|
+
Where a workflow stands, as a pill: live (visitors move through it, with a dot), a draft that was never published, paused
|
|
3
3
|
(the embed shows only its first composition), archived. The word always carries the meaning; the dot only helps the eye,
|
|
4
4
|
so a person who cannot tell the colours apart loses nothing.
|
|
5
5
|
-->
|
|
6
6
|
<script lang="ts">
|
|
7
7
|
import { useWorkflowsLanguage } from '../../i18n/language.js';
|
|
8
|
+
import { STATUS_WORD_KEYS } from '../../i18n/statusWords.js';
|
|
8
9
|
import type { WorkflowStatus } from '../../api/types.js';
|
|
10
|
+
import Badge from './Badge.svelte';
|
|
9
11
|
|
|
10
12
|
interface Props {
|
|
11
13
|
status: WorkflowStatus;
|
|
12
|
-
/** Whether the draft holds changes that are not live yet (shown next to a live workflow). */
|
|
13
|
-
hasUnpublishedChanges?: boolean;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
let { status
|
|
16
|
+
let { status }: Props = $props();
|
|
17
17
|
|
|
18
18
|
const { t } = useWorkflowsLanguage();
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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;
|
|
20
|
+
/** The pill of each state: live is the sage one with a dot, a paused one has a line, the rest are grey. */
|
|
21
|
+
const toneByStatus = {
|
|
22
|
+
draft: 'neutral',
|
|
23
|
+
live: 'brand',
|
|
24
|
+
paused: 'outline',
|
|
25
|
+
archived: 'neutral'
|
|
26
|
+
} as const satisfies Record<WorkflowStatus, 'neutral' | 'brand' | 'outline'>;
|
|
33
27
|
</script>
|
|
34
28
|
|
|
35
|
-
<
|
|
36
|
-
|
|
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>
|
|
29
|
+
<Badge tone={toneByStatus[status]} showDot={status === 'live'}>{$t(STATUS_WORD_KEYS[status])}</Badge
|
|
30
|
+
>
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import type { WorkflowStatus } from '../../api/types.js';
|
|
2
2
|
interface Props {
|
|
3
3
|
status: WorkflowStatus;
|
|
4
|
-
/** Whether the draft holds changes that are not live yet (shown next to a live workflow). */
|
|
5
|
-
hasUnpublishedChanges?: boolean;
|
|
6
4
|
}
|
|
7
5
|
declare const StatusBadge: import("svelte").Component<Props, {}, "">;
|
|
8
6
|
type StatusBadge = ReturnType<typeof StatusBadge>;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
A row of tabs on a quiet band, one of them open (Figma "Tabs"). It is a tab list by the book: one tab is in the tab order,
|
|
3
|
+
the arrows move between tabs (and follow the way the page is read, so in a right-to-left language the arrow that points
|
|
4
|
+
at the next tab is the left one), Home and End go to the first and the last, and a tab opens as soon as it is reached.
|
|
5
|
+
|
|
6
|
+
The caller keeps which tab is open (`value`) and is told when another one is chosen (`onselect`); what each tab shows is
|
|
7
|
+
the caller's too. `controls` is the id of the panel the tabs control, for a screen reader.
|
|
8
|
+
-->
|
|
9
|
+
<script lang="ts">
|
|
10
|
+
interface TabItem {
|
|
11
|
+
/** Tells the tabs apart; never shown. */
|
|
12
|
+
key: string;
|
|
13
|
+
/** The words on the tab, already in the page's language. */
|
|
14
|
+
label: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
interface Props {
|
|
18
|
+
tabs: readonly TabItem[];
|
|
19
|
+
/** The key of the tab that is open. */
|
|
20
|
+
value: string;
|
|
21
|
+
/** The name of the list of tabs for a screen reader. */
|
|
22
|
+
label: string;
|
|
23
|
+
onselect: (key: string) => void;
|
|
24
|
+
/** The id of the panel the tabs control; each tab's id is made from it (`<idPrefix>-tab-<key>`). */
|
|
25
|
+
idPrefix?: string;
|
|
26
|
+
controls?: string;
|
|
27
|
+
class?: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
let { tabs, value, label, onselect, idPrefix, controls, class: className = '' }: Props = $props();
|
|
31
|
+
|
|
32
|
+
const fallbackPrefix = $props.id();
|
|
33
|
+
|
|
34
|
+
let tabListElement = $state<HTMLDivElement>();
|
|
35
|
+
|
|
36
|
+
function handleKeydown(event: KeyboardEvent, index: number): void {
|
|
37
|
+
const isRightToLeft = tabListElement
|
|
38
|
+
? getComputedStyle(tabListElement).direction === 'rtl'
|
|
39
|
+
: false;
|
|
40
|
+
let nextIndex: number | null = null;
|
|
41
|
+
if (event.key === 'ArrowRight') nextIndex = index + (isRightToLeft ? -1 : 1);
|
|
42
|
+
else if (event.key === 'ArrowLeft') nextIndex = index + (isRightToLeft ? 1 : -1);
|
|
43
|
+
else if (event.key === 'Home') nextIndex = 0;
|
|
44
|
+
else if (event.key === 'End') nextIndex = tabs.length - 1;
|
|
45
|
+
if (nextIndex === null) return;
|
|
46
|
+
event.preventDefault();
|
|
47
|
+
const target = tabs[(nextIndex + tabs.length) % tabs.length];
|
|
48
|
+
if (!target) return;
|
|
49
|
+
onselect(target.key);
|
|
50
|
+
tabListElement?.querySelector<HTMLButtonElement>(`[data-tab="${target.key}"]`)?.focus();
|
|
51
|
+
}
|
|
52
|
+
</script>
|
|
53
|
+
|
|
54
|
+
<div
|
|
55
|
+
bind:this={tabListElement}
|
|
56
|
+
role="tablist"
|
|
57
|
+
aria-label={label}
|
|
58
|
+
class="inline-flex h-9 items-center gap-0.5 rounded-xl bg-accent p-1 {className}"
|
|
59
|
+
>
|
|
60
|
+
{#each tabs as item, index (item.key)}
|
|
61
|
+
{@const isSelected = value === item.key}
|
|
62
|
+
<button
|
|
63
|
+
type="button"
|
|
64
|
+
role="tab"
|
|
65
|
+
id="{idPrefix ?? fallbackPrefix}-tab-{item.key}"
|
|
66
|
+
data-tab={item.key}
|
|
67
|
+
aria-selected={isSelected}
|
|
68
|
+
aria-controls={controls}
|
|
69
|
+
tabindex={isSelected ? 0 : -1}
|
|
70
|
+
class="inline-flex h-7 items-center justify-center rounded-lg px-3 text-label whitespace-nowrap transition-colors duration-fast focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background focus-visible:outline-hidden {isSelected
|
|
71
|
+
? 'bg-background text-foreground'
|
|
72
|
+
: 'text-muted-foreground hover:bg-accent hover:text-foreground'}"
|
|
73
|
+
onclick={() => onselect(item.key)}
|
|
74
|
+
onkeydown={(event) => handleKeydown(event, index)}
|
|
75
|
+
>
|
|
76
|
+
{item.label}
|
|
77
|
+
</button>
|
|
78
|
+
{/each}
|
|
79
|
+
</div>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
interface TabItem {
|
|
2
|
+
/** Tells the tabs apart; never shown. */
|
|
3
|
+
key: string;
|
|
4
|
+
/** The words on the tab, already in the page's language. */
|
|
5
|
+
label: string;
|
|
6
|
+
}
|
|
7
|
+
interface Props {
|
|
8
|
+
tabs: readonly TabItem[];
|
|
9
|
+
/** The key of the tab that is open. */
|
|
10
|
+
value: string;
|
|
11
|
+
/** The name of the list of tabs for a screen reader. */
|
|
12
|
+
label: string;
|
|
13
|
+
onselect: (key: string) => void;
|
|
14
|
+
/** The id of the panel the tabs control; each tab's id is made from it (`<idPrefix>-tab-<key>`). */
|
|
15
|
+
idPrefix?: string;
|
|
16
|
+
controls?: string;
|
|
17
|
+
class?: string;
|
|
18
|
+
}
|
|
19
|
+
declare const Tabs: import("svelte").Component<Props, {}, "">;
|
|
20
|
+
type Tabs = ReturnType<typeof Tabs>;
|
|
21
|
+
export default Tabs;
|