@widgetic/workflows 0.2.7 → 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.
Files changed (82) hide show
  1. package/README.md +49 -43
  2. package/dist/components/Workflows.svelte +13 -15
  3. package/dist/components/WorkflowsEmptyState.svelte +14 -12
  4. package/dist/components/WorkflowsHeader.svelte +9 -5
  5. package/dist/components/WorkflowsHeader.svelte.d.ts +4 -16
  6. package/dist/components/WorkflowsWorkspace.svelte +3 -2
  7. package/dist/components/canvas/AddBlockMenu.svelte +11 -2
  8. package/dist/components/canvas/CanvasToolbar.svelte +42 -31
  9. package/dist/components/canvas/CanvasToolbar.svelte.d.ts +2 -0
  10. package/dist/components/canvas/CompositionNodeView.svelte +58 -36
  11. package/dist/components/canvas/ConditionNodeView.svelte +31 -18
  12. package/dist/components/canvas/HandlePoint.svelte +10 -3
  13. package/dist/components/canvas/HandlePoint.svelte.d.ts +1 -1
  14. package/dist/components/canvas/TriggerNodeView.svelte +39 -13
  15. package/dist/components/canvas/WorkflowCanvas.svelte +22 -7
  16. package/dist/components/canvas/WorkflowCanvas.svelte.d.ts +2 -0
  17. package/dist/components/canvas/WorkflowEdgeView.svelte +5 -6
  18. package/dist/components/editor/ConflictBanner.svelte +1 -1
  19. package/dist/components/editor/EditorBanners.svelte +11 -4
  20. package/dist/components/editor/EditorCanvasArea.svelte +17 -10
  21. package/dist/components/editor/EditorTabs.svelte +10 -44
  22. package/dist/components/editor/EditorTopBar.svelte +166 -54
  23. package/dist/components/editor/PresenceBanner.svelte +106 -85
  24. package/dist/components/editor/RunsFlow.svelte +100 -17
  25. package/dist/components/editor/RunsTab.svelte +52 -46
  26. package/dist/components/editor/SettingsRow.svelte +35 -0
  27. package/dist/components/editor/SettingsRow.svelte.d.ts +14 -0
  28. package/dist/components/editor/SettingsTab.svelte +66 -50
  29. package/dist/components/editor/WorkflowEditor.svelte +4 -5
  30. package/dist/components/list/CreateWorkflowDialog.svelte +123 -73
  31. package/dist/components/list/WorkflowList.svelte +227 -100
  32. package/dist/components/list/WorkflowRow.svelte +84 -42
  33. package/dist/components/panel/BlockProblems.svelte +9 -8
  34. package/dist/components/panel/CompositionForm.svelte +52 -34
  35. package/dist/components/panel/CompositionPicker.svelte +43 -21
  36. package/dist/components/panel/CompositionPicker.svelte.d.ts +5 -0
  37. package/dist/components/panel/CompositionSelect.svelte +105 -0
  38. package/dist/components/panel/CompositionSelect.svelte.d.ts +23 -0
  39. package/dist/components/panel/ConditionForm.svelte +50 -17
  40. package/dist/components/panel/EventValueRow.svelte +5 -4
  41. package/dist/components/panel/ProblemsList.svelte +17 -19
  42. package/dist/components/panel/RuleCard.svelte +127 -89
  43. package/dist/components/panel/RuleCard.svelte.d.ts +2 -0
  44. package/dist/components/panel/SidePanel.svelte +101 -50
  45. package/dist/components/panel/TestResultLine.svelte +35 -0
  46. package/dist/components/panel/TestResultLine.svelte.d.ts +9 -0
  47. package/dist/components/panel/TestRow.svelte +21 -18
  48. package/dist/components/panel/TestRunPanel.svelte +61 -39
  49. package/dist/components/panel/TestTriggerCard.svelte +66 -6
  50. package/dist/components/panel/TestTriggerCard.svelte.d.ts +10 -0
  51. package/dist/components/panel/TriggerForm.svelte +24 -25
  52. package/dist/components/panel/VersionHistory.svelte +31 -43
  53. package/dist/components/ui/ActionButton.svelte +44 -12
  54. package/dist/components/ui/ActionButton.svelte.d.ts +2 -1
  55. package/dist/components/ui/Badge.svelte +39 -0
  56. package/dist/components/ui/Badge.svelte.d.ts +12 -0
  57. package/dist/components/ui/ConfirmDialog.svelte +4 -3
  58. package/dist/components/ui/Menu.svelte +28 -14
  59. package/dist/components/ui/Menu.svelte.d.ts +3 -1
  60. package/dist/components/ui/Modal.svelte +15 -8
  61. package/dist/components/ui/Notice.svelte +35 -11
  62. package/dist/components/ui/Notice.svelte.d.ts +4 -1
  63. package/dist/components/ui/SelectField.svelte +48 -20
  64. package/dist/components/ui/SelectField.svelte.d.ts +2 -0
  65. package/dist/components/ui/StatusBadge.svelte +13 -24
  66. package/dist/components/ui/StatusBadge.svelte.d.ts +0 -2
  67. package/dist/components/ui/Tabs.svelte +79 -0
  68. package/dist/components/ui/Tabs.svelte.d.ts +21 -0
  69. package/dist/components/ui/TextField.svelte +47 -27
  70. package/dist/components/ui/TextField.svelte.d.ts +5 -0
  71. package/dist/components/ui/icons.d.ts +43 -29
  72. package/dist/components/ui/icons.js +101 -40
  73. package/dist/editor/editorState.svelte.d.ts +23 -2
  74. package/dist/editor/editorState.svelte.js +36 -0
  75. package/dist/editor/listState.svelte.d.ts +32 -2
  76. package/dist/editor/listState.svelte.js +41 -0
  77. package/dist/i18n/language.d.ts +3 -3
  78. package/dist/i18n/messages.d.ts +22 -13
  79. package/dist/i18n/messages.js +23 -14
  80. package/dist/i18n/statusWords.d.ts +12 -0
  81. package/dist/i18n/statusWords.js +12 -0
  82. package/package.json +3 -3
@@ -6,7 +6,7 @@
6
6
  <script lang="ts">
7
7
  import type { CompositionNode } from '@widgetic/workflows-engine';
8
8
  import type { CompositionOption } from '../../api/types.js';
9
- import { CAPABILITY_REASON_MESSAGE_KEYS } from '../../editor/blockLabels.js';
9
+ import { CAPABILITY_REASON_MESSAGE_KEYS, makeBlockDescriber } from '../../editor/blockLabels.js';
10
10
  import {
11
11
  listActionChoices,
12
12
  listInputTables,
@@ -18,6 +18,7 @@
18
18
  import Icon from '../ui/Icon.svelte';
19
19
  import BlockProblems from './BlockProblems.svelte';
20
20
  import CompositionPicker from './CompositionPicker.svelte';
21
+ import CompositionSelect from './CompositionSelect.svelte';
21
22
 
22
23
  interface Props {
23
24
  node: CompositionNode;
@@ -35,6 +36,9 @@
35
36
  editor.compositionIds.filter((compositionId) => compositionId !== node.compositionId)
36
37
  );
37
38
 
39
+ /** What the closed field says: the composition's own name (the same words the block has on the canvas). */
40
+ const chosenName = $derived(makeBlockDescriber(editor.graph, editor.options, $t)(node.id));
41
+
38
42
  const inputAvailability = $derived(readTriggerAvailability(option, 'input'));
39
43
  const actionAvailability = $derived(readTriggerAvailability(option, 'action'));
40
44
 
@@ -45,16 +49,29 @@
45
49
  </script>
46
50
 
47
51
  <div class="flex flex-col gap-4">
48
- <div>
49
- <h3 class="text-sm font-semibold">{$t('workflows.composition.heading')}</h3>
50
- <p class="text-xs text-ink-muted">{$t('workflows.composition.help')}</p>
52
+ <div class="flex flex-col gap-2">
53
+ <p class="text-body text-muted-foreground">{$t('workflows.composition.help')}</p>
51
54
  </div>
52
55
 
53
56
  <BlockProblems nodeId={node.id} />
54
57
 
55
- {#if !editor.isReadOnly}
58
+ {#if node.compositionId}
59
+ <!-- A block with a composition shows it as a field; the list of the others opens under the field. -->
60
+ <CompositionSelect
61
+ label={$t('workflows.composition.label')}
62
+ valueLabel={chosenName}
63
+ placeholder={$t('workflows.create.compositionPlaceholder')}
64
+ selectedId={node.compositionId}
65
+ takenIds={otherCompositionIds}
66
+ disabled={editor.isReadOnly}
67
+ onpick={chooseComposition}
68
+ onread={(options) => editor.rememberCompositions(options)}
69
+ />
70
+ {:else if !editor.isReadOnly}
71
+ <!-- A block with none shows the list at once: the search and the compositions to choose from. -->
56
72
  <CompositionPicker
57
- selectedId={node.compositionId || null}
73
+ selectedId={null}
74
+ bordered={false}
58
75
  takenIds={otherCompositionIds}
59
76
  onpick={chooseComposition}
60
77
  onread={(options) => editor.rememberCompositions(options)}
@@ -62,28 +79,28 @@
62
79
  {/if}
63
80
 
64
81
  {#if node.startsHere}
65
- <p class="flex items-center gap-2 text-xs text-primary-green">
66
- <Icon name="check" class="size-3.5" />
82
+ <p class="text-caption-medium flex items-center gap-2 text-brand-foreground">
83
+ <Icon name="check" class="size-4 shrink-0" />
67
84
  {$t('workflows.composition.isStart')}
68
85
  </p>
69
86
  {:else if !editor.isReadOnly}
70
- <ActionButton size="small" onclick={() => editor.makeStart(node.id)}
71
- >{$t('workflows.composition.makeStart')}</ActionButton
72
- >
87
+ <ActionButton variant="secondary" class="w-full" onclick={() => editor.makeStart(node.id)}>
88
+ <Icon name="play" class="size-4" />
89
+ {$t('workflows.composition.makeStart')}
90
+ </ActionButton>
73
91
  {/if}
74
92
 
75
93
  {#if option}
76
- <section
77
- class="flex flex-col gap-2 border-t border-grey2 pt-3"
78
- aria-labelledby={capabilitiesHeadingId}
79
- >
80
- <h4 id={capabilitiesHeadingId} class="text-xs font-semibold">
94
+ <section class="flex flex-col gap-3" aria-labelledby={capabilitiesHeadingId}>
95
+ <h3 id={capabilitiesHeadingId} class="text-body-medium text-foreground">
81
96
  {$t('workflows.composition.capabilitiesHeading')}
82
- </h4>
83
- <dl class="flex flex-col gap-2 text-xs">
84
- <div class="flex flex-col gap-0.5">
85
- <dt class="text-ink-muted">{$t('workflows.composition.capabilityInput')}</dt>
86
- <dd>
97
+ </h3>
98
+ <dl class="flex flex-col gap-3">
99
+ <div class="flex flex-col gap-1">
100
+ <dt class="text-caption-medium text-muted-foreground">
101
+ {$t('workflows.composition.capabilityInput')}
102
+ </dt>
103
+ <dd class="text-body text-foreground">
87
104
  {#if inputAvailability.enabled}
88
105
  {$t('workflows.composition.inputTables', {
89
106
  tables: listInputTables(option).join(', ')
@@ -93,9 +110,11 @@
93
110
  {/if}
94
111
  </dd>
95
112
  </div>
96
- <div class="flex flex-col gap-0.5">
97
- <dt class="text-ink-muted">{$t('workflows.composition.capabilityAction')}</dt>
98
- <dd>
113
+ <div class="flex flex-col gap-1">
114
+ <dt class="text-caption-medium text-muted-foreground">
115
+ {$t('workflows.composition.capabilityAction')}
116
+ </dt>
117
+ <dd class="text-body text-foreground">
99
118
  {#if actionAvailability.enabled}
100
119
  {$t('workflows.composition.actionCount', { count: listActionChoices(option).length })}
101
120
  {:else}
@@ -104,9 +123,13 @@
104
123
  </dd>
105
124
  </div>
106
125
  {#if option.allowedWebsites.length > 0}
107
- <div class="flex flex-col gap-0.5">
108
- <dt class="text-ink-muted">{$t('workflows.composition.capabilityWebsites')}</dt>
109
- <dd class="break-words">{option.allowedWebsites.join(', ')}</dd>
126
+ <div class="flex flex-col gap-1">
127
+ <dt class="text-caption-medium text-muted-foreground">
128
+ {$t('workflows.composition.capabilityWebsites')}
129
+ </dt>
130
+ <dd class="break-words text-body text-foreground">
131
+ {option.allowedWebsites.join(', ')}
132
+ </dd>
110
133
  </div>
111
134
  {/if}
112
135
  </dl>
@@ -114,13 +137,8 @@
114
137
  {/if}
115
138
 
116
139
  {#if !editor.isReadOnly}
117
- <ActionButton
118
- variant="danger"
119
- size="small"
120
- class="self-start"
121
- onclick={() => editor.removeBlock(node.id)}
122
- >
123
- <Icon name="trash" />
140
+ <ActionButton variant="secondary" class="w-full" onclick={() => editor.removeBlock(node.id)}>
141
+ <Icon name="trash" class="size-4" />
124
142
  {$t('workflows.panel.removeBlock')}
125
143
  </ActionButton>
126
144
  {/if}
@@ -28,9 +28,14 @@
28
28
  onpick: (option: CompositionOption) => void;
29
29
  /** Called with each page of compositions that was read, so the owner can remember them. */
30
30
  onread?: (options: readonly CompositionOption[]) => void;
31
+ /**
32
+ * The list sits in its own bordered box with a height of its own (it opens under a field, like a menu), or, with
33
+ * `false`, runs as plain rows down the panel that holds it (a block with no composition yet).
34
+ */
35
+ bordered?: boolean;
31
36
  }
32
37
 
33
- let { selectedId = null, takenIds = [], onpick, onread }: Props = $props();
38
+ let { selectedId = null, takenIds = [], onpick, onread, bordered = true }: Props = $props();
34
39
 
35
40
  const PAGE_SIZE = 20;
36
41
  const SEARCH_DELAY_MILLISECONDS = 300;
@@ -106,6 +111,8 @@
106
111
  <div class="flex min-h-0 flex-col gap-2">
107
112
  <TextField
108
113
  type="search"
114
+ variant="soft"
115
+ icon="search"
109
116
  label={$t('workflows.composition.searchLabel')}
110
117
  placeholder={$t('workflows.composition.searchPlaceholder')}
111
118
  hideLabel
@@ -114,31 +121,40 @@
114
121
  />
115
122
 
116
123
  {#if loadState === 'loading'}
117
- <p class="py-4 text-center text-sm text-ink-muted" role="status">
124
+ <p class="text-body text-muted-foreground py-4 text-center" role="status">
118
125
  {$t('workflows.common.loading')}
119
126
  </p>
120
127
  {:else if loadState === 'failed'}
121
128
  <div class="flex flex-col items-start gap-2 py-2">
122
- <p class="text-sm text-error" role="alert">{failureKey ? $t(failureKey) : ''}</p>
123
- <ActionButton size="small" onclick={() => void read(false)}
124
- >{$t('workflows.error.retry')}</ActionButton
125
- >
129
+ <p class="text-body text-destructive" role="alert">{failureKey ? $t(failureKey) : ''}</p>
130
+ <ActionButton size="small" onclick={() => void read(false)}>
131
+ {$t('workflows.error.retry')}
132
+ </ActionButton>
126
133
  </div>
127
134
  {:else if items.length === 0}
128
- <p class="py-4 text-center text-sm text-ink-muted">{$t('workflows.composition.none')}</p>
135
+ <p class="text-body text-muted-foreground py-4 text-center">
136
+ {$t('workflows.composition.none')}
137
+ </p>
129
138
  {:else}
130
- <ul class="flex max-h-72 flex-col gap-1 overflow-auto">
139
+ <ul
140
+ class="flex flex-col gap-0.5 {bordered
141
+ ? 'max-h-72 overflow-auto rounded-xl border border-border bg-popover p-1'
142
+ : ''}"
143
+ role="listbox"
144
+ >
131
145
  {#each items as option (option.id)}
132
146
  {@const isSelected = option.id === selectedId}
133
147
  {@const isTaken = taken.has(option.id) && !isSelected}
134
- <li>
148
+ <li role="none">
135
149
  <button
136
150
  type="button"
137
151
  disabled={isTaken}
152
+ role="option"
153
+ aria-selected={isSelected}
138
154
  aria-current={isSelected ? 'true' : undefined}
139
- class="flex w-full items-center gap-3 rounded-medium border px-2 py-2 text-start text-sm focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-primary-green disabled:cursor-not-allowed disabled:opacity-50 {isSelected
140
- ? 'border-primary-green'
141
- : 'border-grey2 hover:border-ink-subtle'}"
155
+ class="focus-visible:ring-ring flex w-full items-center gap-3 rounded-lg px-2 py-2 text-start text-body text-foreground hover:bg-accent disabled:pointer-events-none disabled:opacity-50 focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-offset-background {isSelected
156
+ ? 'bg-brand-subtle text-brand-foreground'
157
+ : ''}"
142
158
  onclick={() => onpick(option)}
143
159
  >
144
160
  {#if option.thumbnailUrl}
@@ -147,25 +163,31 @@
147
163
  alt=""
148
164
  loading="lazy"
149
165
  draggable="false"
150
- class="h-10 w-14 shrink-0 rounded-small border border-grey2 object-cover"
166
+ class="border-border h-8 w-8 shrink-0 rounded-lg border object-cover"
151
167
  />
152
168
  {:else}
153
169
  <span
154
- class="flex h-10 w-14 shrink-0 items-center justify-center rounded-small border border-grey2 text-ink-muted"
170
+ class="bg-muted text-muted-foreground flex size-8 shrink-0 items-center justify-center rounded-lg"
155
171
  >
156
- <Icon name="composition" />
172
+ <Icon name="composition" class="size-4" />
157
173
  </span>
158
174
  {/if}
159
- <span class="flex min-w-0 flex-1 flex-col">
160
- <span class="truncate font-medium" dir="auto">{option.name}</span>
175
+ <span class="flex min-w-0 flex-1 flex-col gap-0.5 text-start">
176
+ <span class="text-body-medium truncate" dir="auto">{option.name}</span>
161
177
  {#if isTaken}
162
- <span class="text-xs text-ink-muted">{$t('workflows.composition.alreadyUsed')}</span
178
+ <span class="text-caption text-muted-foreground"
179
+ >{$t('workflows.composition.alreadyUsed')}</span
163
180
  >
164
- {:else if !option.published}
165
- <span class="text-xs text-ink-muted">{$t('workflows.block.notPublished')}</span>
181
+ {:else}
182
+ <!-- Whether the widget is published, as the design's rows say it. -->
183
+ <span class="text-caption text-muted-foreground">
184
+ {option.published
185
+ ? $t('workflows.block.publishedMeta')
186
+ : $t('workflows.block.notPublished')}
187
+ </span>
166
188
  {/if}
167
189
  </span>
168
- {#if isSelected}<Icon name="check" class="size-4 text-primary-green" />{/if}
190
+ {#if isSelected}<Icon name="check" class="text-brand-foreground size-4 shrink-0" />{/if}
169
191
  </button>
170
192
  </li>
171
193
  {/each}
@@ -8,6 +8,11 @@ interface Props {
8
8
  onpick: (option: CompositionOption) => void;
9
9
  /** Called with each page of compositions that was read, so the owner can remember them. */
10
10
  onread?: (options: readonly CompositionOption[]) => void;
11
+ /**
12
+ * The list sits in its own bordered box with a height of its own (it opens under a field, like a menu), or, with
13
+ * `false`, runs as plain rows down the panel that holds it (a block with no composition yet).
14
+ */
15
+ bordered?: boolean;
11
16
  }
12
17
  declare const CompositionPicker: import("svelte").Component<Props, {}, "">;
13
18
  type CompositionPicker = ReturnType<typeof CompositionPicker>;
@@ -0,0 +1,105 @@
1
+ <!--
2
+ A composition field that looks like the design's select (the chosen name, or a placeholder, and a chevron) and opens the
3
+ list of compositions right under it, with the search above the list, so a long library is searched and not scrolled through.
4
+ Choosing a line closes the list and the owner decides what the choice does (the "New workflow" dialog takes a second choice
5
+ of the same line back; a composition block just keeps it).
6
+
7
+ Used where a composition is chosen but the choice is not the main thing on the screen: the "First composition" of "New
8
+ workflow" and the "Composition" of a block that already has one. A block with none shows the list at once (`CompositionPicker`).
9
+
10
+ Escape closes the list and goes back to the field; it does not close the dialog or the panel that holds it.
11
+ -->
12
+ <script lang="ts">
13
+ import type { CompositionOption } from '../../api/types.js';
14
+ import Icon from '../ui/Icon.svelte';
15
+ import CompositionPicker from './CompositionPicker.svelte';
16
+
17
+ interface Props {
18
+ /** What the field is called ("First composition", "Composition"). */
19
+ label: string;
20
+ /** What the closed field says: the name of the chosen composition, or `null` for none (the placeholder is shown). */
21
+ valueLabel: string | null;
22
+ /** What the closed field says while nothing is chosen. */
23
+ placeholder: string;
24
+ /** One line under the field, if there is one. */
25
+ help?: string | null;
26
+ /** The composition that is chosen now, so the list marks it. */
27
+ selectedId: string | null;
28
+ /** Compositions that are already in the workflow: the list shows them but they cannot be chosen again. */
29
+ takenIds?: readonly string[];
30
+ /** The person picked a line (the line that is already chosen too: the owner decides what that means). */
31
+ onpick: (option: CompositionOption) => void;
32
+ /** Each page of compositions the list read, so the owner can remember their names and pictures. */
33
+ onread?: (options: readonly CompositionOption[]) => void;
34
+ disabled?: boolean;
35
+ }
36
+
37
+ let {
38
+ label,
39
+ valueLabel,
40
+ placeholder,
41
+ help = null,
42
+ selectedId,
43
+ takenIds = [],
44
+ onpick,
45
+ onread,
46
+ disabled = false
47
+ }: Props = $props();
48
+
49
+ const fieldId = $props.id();
50
+
51
+ let isOpen = $state(false);
52
+
53
+ /** Puts the focus back on the field's button (found by its id, which this field makes up from its own). */
54
+ function focusTrigger(): void {
55
+ document.getElementById(`${fieldId}-trigger`)?.focus();
56
+ }
57
+
58
+ /** A line was picked: the owner remembers it, and the list closes. */
59
+ function pick(option: CompositionOption): void {
60
+ onpick(option);
61
+ isOpen = false;
62
+ focusTrigger();
63
+ }
64
+
65
+ /** Escape closes the list (and only the list) while it is open. */
66
+ function handleKeydown(event: KeyboardEvent): void {
67
+ if (event.key !== 'Escape' || !isOpen) return;
68
+ event.stopPropagation();
69
+ isOpen = false;
70
+ focusTrigger();
71
+ }
72
+ </script>
73
+
74
+ <!-- The keys are handled for the field inside; the wrapper itself is not something a person operates. -->
75
+ <!-- svelte-ignore a11y_no_static_element_interactions -->
76
+ <div class="flex min-w-0 flex-col gap-1.5 text-start" onkeydown={handleKeydown}>
77
+ <span id="{fieldId}-label" class="text-body-medium text-foreground">{label}</span>
78
+ <button
79
+ id="{fieldId}-trigger"
80
+ type="button"
81
+ {disabled}
82
+ aria-expanded={isOpen}
83
+ aria-controls="{fieldId}-list"
84
+ aria-labelledby="{fieldId}-label {fieldId}-value"
85
+ class="flex h-9 w-full items-center gap-1.5 rounded-lg border border-input bg-background px-3 text-start text-body transition-colors duration-fast hover:bg-accent focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:opacity-50"
86
+ onclick={() => (isOpen = !isOpen)}
87
+ >
88
+ <span
89
+ id="{fieldId}-value"
90
+ class="min-w-0 flex-1 truncate {valueLabel ? 'text-foreground' : 'text-muted-foreground'}"
91
+ dir="auto"
92
+ >
93
+ {valueLabel ?? placeholder}
94
+ </span>
95
+ <Icon name="down" class="size-4 shrink-0 opacity-50 {isOpen ? 'rotate-180' : ''}" />
96
+ </button>
97
+ {#if help}
98
+ <p class="text-caption text-muted-foreground">{help}</p>
99
+ {/if}
100
+ {#if isOpen}
101
+ <div id="{fieldId}-list" class="flex min-h-0 flex-col">
102
+ <CompositionPicker {selectedId} {takenIds} onpick={pick} {onread} />
103
+ </div>
104
+ {/if}
105
+ </div>
@@ -0,0 +1,23 @@
1
+ import type { CompositionOption } from '../../api/types.js';
2
+ interface Props {
3
+ /** What the field is called ("First composition", "Composition"). */
4
+ label: string;
5
+ /** What the closed field says: the name of the chosen composition, or `null` for none (the placeholder is shown). */
6
+ valueLabel: string | null;
7
+ /** What the closed field says while nothing is chosen. */
8
+ placeholder: string;
9
+ /** One line under the field, if there is one. */
10
+ help?: string | null;
11
+ /** The composition that is chosen now, so the list marks it. */
12
+ selectedId: string | null;
13
+ /** Compositions that are already in the workflow: the list shows them but they cannot be chosen again. */
14
+ takenIds?: readonly string[];
15
+ /** The person picked a line (the line that is already chosen too: the owner decides what that means). */
16
+ onpick: (option: CompositionOption) => void;
17
+ /** Each page of compositions the list read, so the owner can remember their names and pictures. */
18
+ onread?: (options: readonly CompositionOption[]) => void;
19
+ disabled?: boolean;
20
+ }
21
+ declare const CompositionSelect: import("svelte").Component<Props, {}, "">;
22
+ type CompositionSelect = ReturnType<typeof CompositionSelect>;
23
+ export default CompositionSelect;
@@ -39,49 +39,87 @@
39
39
  findUpstreamTrigger(buildGraphIndex(editor.graph), node.id) !== undefined
40
40
  );
41
41
 
42
+ /** At most one rule card is expanded (accordion); new rules open the last card. */
43
+ let expandedRuleId = $state<string | null>(null);
44
+ let lastCaseCount = $state(0);
45
+ let wasConditionSelected = $state(false);
46
+
47
+ $effect(() => {
48
+ const selected = editor.selectedNodeIds.length === 1 && editor.selectedNodeIds[0] === node.id;
49
+ const count = node.cases.length;
50
+ if (!selected) {
51
+ wasConditionSelected = false;
52
+ lastCaseCount = count;
53
+ return;
54
+ }
55
+ if (!wasConditionSelected && count > 0) {
56
+ expandedRuleId = node.cases[0]!.id;
57
+ } else if (count > lastCaseCount && count > 0) {
58
+ expandedRuleId = node.cases[count - 1]!.id;
59
+ }
60
+ wasConditionSelected = true;
61
+ lastCaseCount = count;
62
+ });
63
+
42
64
  function addNewRule(): void {
43
65
  if (!canAddRule(node)) return;
44
66
  // A new rule starts with the first value there is to compare, so it is never an empty shell.
45
67
  editor.replaceBlock(addRule(node, makeRule(collectTakenIds(editor.graph), choices[0]?.field)));
46
68
  }
69
+
70
+ function toggleRule(ruleId: string): void {
71
+ expandedRuleId = expandedRuleId === ruleId ? null : ruleId;
72
+ }
73
+
74
+ $effect(() => {
75
+ if (expandedRuleId !== null && !node.cases.some((c) => c.id === expandedRuleId)) {
76
+ expandedRuleId = node.cases[0]?.id ?? null;
77
+ }
78
+ });
47
79
  </script>
48
80
 
49
81
  <div class="flex flex-col gap-4">
50
- <div>
51
- <h3 class="text-sm font-semibold">{$t('workflows.condition.heading')}</h3>
52
- <p class="text-xs text-ink-muted">{$t('workflows.condition.help')}</p>
82
+ <div class="flex flex-col gap-2">
83
+ <p class="text-body text-muted-foreground">{$t('workflows.condition.help')}</p>
53
84
  </div>
54
85
 
55
86
  <BlockProblems nodeId={node.id} />
56
87
 
57
88
  {#if !hasTrigger}
58
- <p class="text-xs text-ink-muted">{$t('workflows.condition.noTrigger')}</p>
89
+ <p class="text-caption text-muted-foreground">{$t('workflows.condition.noTrigger')}</p>
59
90
  {:else if choices.length === 0}
60
- <p class="text-xs text-ink-muted">{$t('workflows.condition.noValues')}</p>
91
+ <p class="text-caption text-muted-foreground">{$t('workflows.condition.noValues')}</p>
61
92
  {/if}
62
93
 
63
94
  <div class="flex flex-col gap-3">
64
95
  {#each node.cases as rule, index (rule.id)}
65
- <RuleCard {node} {rule} {index} {choices} />
96
+ <RuleCard
97
+ {node}
98
+ {rule}
99
+ {index}
100
+ {choices}
101
+ expanded={expandedRuleId === rule.id}
102
+ onToggle={() => toggleRule(rule.id)}
103
+ />
66
104
  {/each}
67
105
  </div>
68
106
 
69
107
  {#if !editor.isReadOnly}
70
108
  <ActionButton
71
- size="small"
72
- class="self-start"
109
+ variant="secondary"
110
+ class="w-full"
73
111
  disabled={!canAddRule(node)}
74
112
  title={canAddRule(node)
75
113
  ? undefined
76
114
  : $t('workflows.condition.ruleLimit', { max: MAX_CASES_PER_CONDITION })}
77
115
  onclick={addNewRule}
78
116
  >
79
- <Icon name="plus" />
117
+ <Icon name="plus" class="size-4" />
80
118
  {$t('workflows.condition.addRule')}
81
119
  </ActionButton>
82
120
  {/if}
83
121
 
84
- <div class="flex flex-col gap-1 border-t border-grey2 pt-3">
122
+ <div class="border-border flex flex-col gap-2 border-t pt-4">
85
123
  <NextStepSelect
86
124
  sourceId={node.id}
87
125
  sourcePort={DEFAULT_PORT}
@@ -92,13 +130,8 @@
92
130
  </div>
93
131
 
94
132
  {#if !editor.isReadOnly}
95
- <ActionButton
96
- variant="danger"
97
- size="small"
98
- class="self-start"
99
- onclick={() => editor.removeBlock(node.id)}
100
- >
101
- <Icon name="trash" />
133
+ <ActionButton variant="secondary" class="w-full" onclick={() => editor.removeBlock(node.id)}>
134
+ <Icon name="trash" class="size-4" />
102
135
  {$t('workflows.panel.removeBlock')}
103
136
  </ActionButton>
104
137
  {/if}
@@ -51,9 +51,9 @@
51
51
  }
52
52
  </script>
53
53
 
54
- <div class="flex items-start gap-2">
54
+ <div class="flex flex-wrap items-center gap-2">
55
55
  <TextField
56
- class="flex-1"
56
+ class="min-w-0 flex-1"
57
57
  label={$t('workflows.event.valueName', { number: index + 1 })}
58
58
  hideLabel
59
59
  placeholder={$t('workflows.event.valueNamePlaceholder')}
@@ -64,7 +64,7 @@
64
64
  onchange={commitName}
65
65
  />
66
66
  <SelectField
67
- class="w-28"
67
+ class="w-28 shrink-0"
68
68
  label={$t('workflows.event.valueType', { number: index + 1 })}
69
69
  hideLabel
70
70
  {disabled}
@@ -75,11 +75,12 @@
75
75
  <ActionButton
76
76
  variant="ghost"
77
77
  iconOnly
78
+ size="small"
78
79
  {disabled}
79
80
  ariaLabel={$t('workflows.event.removeValue', { number: index + 1 })}
80
81
  title={$t('workflows.event.removeValue', { number: index + 1 })}
81
82
  onclick={onremove}
82
83
  >
83
- <Icon name="trash" />
84
+ <Icon name="close" />
84
85
  </ActionButton>
85
86
  </div>
@@ -1,6 +1,6 @@
1
1
  <!--
2
- Everything the check finds wrong with the draft, in sentences. It is what stops a publish, so it is the first thing the
3
- panel shows when no block is selected. A problem that belongs to a block is a button that selects the block, so the person
2
+ Everything the check finds wrong with the draft, in sentences. It is what stops a publish, so it is what the panel shows
3
+ when no block is selected. A problem that belongs to a block is a button that selects the block, so the person
4
4
  lands on the form that fixes it. Warnings are advice and do not stop a publish.
5
5
 
6
6
  It also lists what a refused publish said (the server checks again with what it knows), in the same place, so there is one
@@ -64,38 +64,36 @@
64
64
  </script>
65
65
 
66
66
  {#if sentences.length > 0}
67
- <ul class="flex flex-col gap-1" aria-label={$t('workflows.panel.problemsLabel')}>
67
+ <ul class="flex flex-col gap-2" aria-label={$t('workflows.panel.problemsLabel')}>
68
68
  {#each sentences as sentence (sentence.key)}
69
69
  <li>
70
70
  {#if sentence.nodeId}
71
71
  {@const nodeId = sentence.nodeId}
72
72
  <button
73
73
  type="button"
74
- class="flex w-full items-start gap-2 rounded-medium px-2 py-1.5 text-start text-xs hover:text-ink-primary focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-primary-green {sentence.severity ===
75
- 'error'
76
- ? 'text-error'
77
- : 'text-ink-muted'}"
74
+ class="hover:bg-accent focus-visible:ring-ring flex w-full items-start gap-2 rounded-lg px-2 py-2 text-start text-body text-foreground duration-fast focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-offset-background"
78
75
  onclick={() => goToBlock(nodeId)}
79
76
  >
80
- <Icon name="warning" class="mt-0.5 size-3.5" />
77
+ <Icon
78
+ name="warning"
79
+ class="mt-0.5 size-4 shrink-0 {sentence.severity === 'error'
80
+ ? 'text-destructive'
81
+ : 'text-warning'}"
82
+ />
81
83
  <span>{sentence.text}</span>
82
84
  </button>
83
85
  {:else}
84
- <p
85
- class="flex items-start gap-2 px-2 py-1.5 text-xs {sentence.severity === 'error'
86
- ? 'text-error'
87
- : 'text-ink-muted'}"
88
- >
89
- <Icon name="warning" class="mt-0.5 size-3.5" />
86
+ <p class="flex items-start gap-2 px-2 py-2 text-body text-foreground">
87
+ <Icon
88
+ name="warning"
89
+ class="mt-0.5 size-4 shrink-0 {sentence.severity === 'error'
90
+ ? 'text-destructive'
91
+ : 'text-warning'}"
92
+ />
90
93
  <span>{sentence.text}</span>
91
94
  </p>
92
95
  {/if}
93
96
  </li>
94
97
  {/each}
95
98
  </ul>
96
- {:else}
97
- <p class="flex items-center gap-2 text-xs text-ink-muted">
98
- <Icon name="check" class="size-3.5 text-primary-green" />
99
- {$t('workflows.panel.noProblems')}
100
- </p>
101
99
  {/if}