@picked/svelte 0.0.1-dev.1793772853474 → 0.0.1-dev.1793835766402

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 (62) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/plugins/devtools/DevToolsExperience.svelte +169 -84
  3. package/dist/plugins/devtools/components/AdaptedToolHost.svelte +9 -3
  4. package/dist/plugins/devtools/customTools.d.ts +16 -7
  5. package/dist/plugins/devtools/customTools.js +1 -1
  6. package/dist/plugins/devtools/derive/answer-display/answer-display.d.ts +1 -1
  7. package/dist/plugins/devtools/derive/answer-display/answer-display.js +1 -1
  8. package/dist/plugins/devtools/derive/guide-sections/guide-sections.js +1 -1
  9. package/dist/plugins/devtools/derive/index.d.ts +3 -3
  10. package/dist/plugins/devtools/derive/index.js +1 -1
  11. package/dist/plugins/devtools/derive/journey-outline/journey-outline.js +1 -1
  12. package/dist/plugins/devtools/derive/journey-tree/journey-tree.js +1 -1
  13. package/dist/plugins/devtools/derive/persona-builder/persona-builder.js +1 -1
  14. package/dist/plugins/devtools/derive/personas/index.d.ts +2 -2
  15. package/dist/plugins/devtools/derive/personas/index.js +1 -1
  16. package/dist/plugins/devtools/derive/personas/personas.d.ts +89 -8
  17. package/dist/plugins/devtools/derive/personas/personas.js +1 -1
  18. package/dist/plugins/devtools/derive/plain-language/index.d.ts +1 -1
  19. package/dist/plugins/devtools/derive/plain-language/index.js +1 -1
  20. package/dist/plugins/devtools/derive/plain-language/plain-language.d.ts +20 -25
  21. package/dist/plugins/devtools/derive/plain-language/plain-language.js +1 -1
  22. package/dist/plugins/devtools/derive/plain-logic/plain-logic.d.ts +1 -1
  23. package/dist/plugins/devtools/derive/plain-logic/plain-logic.js +1 -1
  24. package/dist/plugins/devtools/derive/safety-posture/safety-posture.js +1 -1
  25. package/dist/plugins/devtools/index.d.ts +1 -1
  26. package/dist/plugins/devtools/launcher/Launcher.svelte +13 -4
  27. package/dist/plugins/devtools/options.d.ts +27 -24
  28. package/dist/plugins/devtools/options.js +1 -1
  29. package/dist/plugins/devtools/review/answers/AnswersPanel.svelte +14 -14
  30. package/dist/plugins/devtools/review/guide/GuidePanel.svelte +1 -1
  31. package/dist/plugins/devtools/review/index.d.ts +2 -2
  32. package/dist/plugins/devtools/review/journey/ExperienceDetails.svelte +129 -0
  33. package/dist/plugins/devtools/review/journey/JourneyMap.svelte +16 -14
  34. package/dist/plugins/devtools/review/journey/JourneyPanel.svelte +70 -24
  35. package/dist/plugins/devtools/review/journey/JourneyTimeline.svelte +22 -21
  36. package/dist/plugins/devtools/review/personas/PersonaBuilder.svelte +15 -46
  37. package/dist/plugins/devtools/review/personas/PersonaCard.svelte +227 -44
  38. package/dist/plugins/devtools/review/personas/PersonasPanel.svelte +191 -78
  39. package/dist/plugins/devtools/review/personas/load-persona.d.ts +43 -22
  40. package/dist/plugins/devtools/review/personas/load-persona.js +1 -1
  41. package/dist/plugins/devtools/review/personas/persona-route.d.ts +87 -0
  42. package/dist/plugins/devtools/review/personas/persona-route.js +1 -0
  43. package/dist/plugins/devtools/review/personas/persona-session.d.ts +94 -0
  44. package/dist/plugins/devtools/review/personas/persona-session.js +1 -0
  45. package/dist/plugins/devtools/review/session/SessionPanel.svelte +11 -11
  46. package/dist/plugins/devtools/review/variations/VariationsPanel.svelte +12 -13
  47. package/dist/plugins/devtools/screens/custom-tools/CustomToolsScreen.svelte +11 -25
  48. package/dist/plugins/devtools/sidebar/Sidebar.svelte +2 -33
  49. package/dist/plugins/devtools/sidebar/SidebarRow.svelte +5 -42
  50. package/dist/plugins/devtools/sidebar/nav.d.ts +26 -28
  51. package/dist/plugins/devtools/sidebar/nav.js +1 -1
  52. package/package.json +2 -2
  53. package/dist/plugins/devtools/screens/experience-instances/ExperienceInstancesListScreen.svelte +0 -10
  54. package/dist/plugins/devtools/screens/experiences/ExperienceDetailsScreen.svelte +0 -44
  55. package/dist/plugins/devtools/screens/experiences/ExperienceExperienceInstancesListScreen.svelte +0 -13
  56. package/dist/plugins/devtools/screens/experiences/ExperienceScreen.svelte +0 -32
  57. package/dist/plugins/devtools/screens/experiences/ExperienceTreeScreen.svelte +0 -500
  58. package/dist/plugins/devtools/screens/experiences/ExperiencesListScreen.svelte +0 -22
  59. package/dist/plugins/devtools/screens/features/FeaturesListScreen.svelte +0 -239
  60. package/dist/plugins/devtools/screens/responses/ResponseTableRow.svelte +0 -286
  61. package/dist/plugins/devtools/screens/responses/ResponsesListScreen.svelte +0 -12
  62. package/dist/plugins/devtools/screens/responses/ResponsesTable.svelte +0 -88
@@ -19,9 +19,7 @@
19
19
  type BuilderWalk,
20
20
  } from '../../derive'
21
21
  import ChoiceButton from './ChoiceButton.svelte'
22
-
23
- /** The rule type the client evaluates. */
24
- type Rule = Parameters<typeof evaluateRuleLogic>[1]
22
+ import { entryLocation, ruleEvaluator, type Rule } from './persona-route'
25
23
 
26
24
  interface PersonaBuilderProps {
27
25
  client: Picked
@@ -73,37 +71,8 @@
73
71
  [...graph.journeys.values()].map((journey) => ({ value: journey.key, label: journey.name })),
74
72
  )
75
73
 
76
- /** The entry page's address, as a rule on `location` reads it. */
77
- const location = $derived.by(() => {
78
- const url = new URL(entryUrl, window.location.origin)
79
- return {
80
- hash: url.hash,
81
- host: url.host,
82
- hostname: url.hostname,
83
- href: url.href,
84
- origin: url.origin,
85
- pathname: url.pathname,
86
- port: url.port,
87
- protocol: url.protocol,
88
- search: url.search,
89
- }
90
- })
91
-
92
- /**
93
- * Evaluates a rule against draft answers, on the entry page.
94
- *
95
- * @param {Rule} rule - The rule.
96
- * @param {Readonly<Record<string, FieldValue>>} responses - The answers it reads.
97
- * @returns {Promise<boolean>} Whether it holds.
98
- * @example await evaluate(condition.logic, { purpose: 'home' })
99
- */
100
- async function evaluate(
101
- rule: Rule,
102
- responses: Readonly<Record<string, FieldValue>>,
103
- ): Promise<boolean> {
104
- const result = await evaluateRuleLogic(client, rule, { responses: { ...responses }, location })
105
- return Boolean(result)
106
- }
74
+ /** Evaluates a rule against draft answers, on the entry page. */
75
+ const evaluate = $derived(ruleEvaluator(client, entryLocation(entryUrl, window.location.origin)))
107
76
 
108
77
  let walk = $state.raw<BuilderWalk | null>(null)
109
78
 
@@ -215,7 +184,7 @@
215
184
  if (typeof result === 'string' || result === false) {
216
185
  errors = {
217
186
  ...errors,
218
- [field.key]: typeof result === 'string' ? result : 'This answer is not accepted.',
187
+ [field.key]: typeof result === 'string' ? result : 'This response is not accepted.',
219
188
  }
220
189
  return
221
190
  }
@@ -245,13 +214,13 @@
245
214
  function endText(row: Extract<BuilderRow, { kind: 'end' }>): string {
246
215
  switch (row.reason) {
247
216
  case 'loop':
248
- return `The journey goes back to “${row.name ?? 'an earlier screen'}” here.`
217
+ return `The flow goes back to “${row.name ?? 'an earlier step'}” here.`
249
218
  case 'handoff':
250
- return `${row.name ?? 'Another journey'} takes over here, outside this build.`
219
+ return `${row.name ?? 'Another experience'} takes over here, outside this build.`
251
220
  case 'limit':
252
- return 'The journey is too long to walk here, so it stops.'
221
+ return 'The flow is too long to walk here, so it stops.'
253
222
  case 'end':
254
- return 'The journey ends here.'
223
+ return 'The experience ends here.'
255
224
  }
256
225
  }
257
226
 
@@ -274,18 +243,18 @@
274
243
 
275
244
  <div class="builder" data-testid="devtools-persona-builder">
276
245
  {#if journeyOptions.length === 0}
277
- <Text size="small" color="subdued">This page has no journeys to build a persona in.</Text>
246
+ <Text size="small" color="subdued">This page has no experiences to build a persona in.</Text>
278
247
  {:else}
279
248
  <Select
280
249
  label="Starts in"
281
250
  name="devtools-builder-start"
282
251
  options={journeyOptions}
283
252
  value={start}
284
- placeholder="Pick a journey"
253
+ placeholder="Pick an experience"
285
254
  onchange={onStartChange}
286
255
  />
287
256
  <Text size="small" color="subdued">
288
- Answer each screen; the next one appears below. Where the site's own code decides the route,
257
+ Complete each step; the next one appears below. Where the site's own code decides the route,
289
258
  pick the outcome to follow. The real outcome decides when the persona loads.
290
259
  </Text>
291
260
 
@@ -351,21 +320,21 @@
351
320
  </div>
352
321
  {:else if kind === 'system'}
353
322
  <Text size="small" color="subdued">
354
- This is answered on its own screen. The persona stops here, so load it and
355
- answer it there.
323
+ This is set on its own step. The persona stops here, so load it and set it
324
+ there.
356
325
  </Text>
357
326
  {/if}
358
327
  </div>
359
328
  {/if}
360
329
  {:else}
361
330
  <Text size="small" color="subdued">
362
- Nothing to answer here. The customer continues.
331
+ Nothing to fill in here. The visitor continues.
363
332
  </Text>
364
333
  {/each}
365
334
  </li>
366
335
  {:else if row.kind === 'choice'}
367
336
  <li class="decision" data-testid="devtools-builder-decision">
368
- <Text size="small">The site decides: {row.question}</Text>
337
+ <Text size="small">The site's code decides: {row.question}</Text>
369
338
  <div class="choices">
370
339
  <ChoiceButton
371
340
  label="Yes"
@@ -1,72 +1,207 @@
1
1
  <script lang="ts">
2
- /** @file One persona in the Personas & Scenarios tab: who it is, where it lands, Load and Delete. */
3
- import { Button, Card, Text } from '../../ui'
4
- import { describeLanding, type Persona } from '../../derive'
2
+ /**
3
+ * @file One persona in the Personas & Scenarios tab: who it is and where it lands, with Walk
4
+ * through, Jump to step, Edit, and Delete or Reset. Jump to step lists the screens on the
5
+ * persona's route; picking one walks the persona there.
6
+ */
7
+ import { Badge, Button, Card, CopyButton, Text } from '../../ui'
8
+ import { describeLanding, deslug, type Persona } from '../../derive'
9
+ import type { RouteScreen } from './persona-route'
5
10
 
6
11
  interface PersonaCardProps {
7
12
  persona: Persona
8
- /** Why Load is withheld; `undefined` while it is allowed. */
9
- loadReason: string | undefined
10
- /** True while this persona is loading. */
11
- loading: boolean
12
- onLoad: () => void
13
- /** Opens it in the form; absent for a persona the site defines. */
14
- onEdit?: () => void
15
- /** Deletes it; absent for a persona the site defines. */
13
+ /** Why starting it is withheld; `undefined` while it is allowed. */
14
+ startReason: string | undefined
15
+ /** True while this persona is starting. */
16
+ starting: boolean
17
+ /** True while the tab walks through as this persona. */
18
+ active: boolean
19
+ onWalkThrough: () => void
20
+ /** Works out the screens on its route; `null` when it has no journey. */
21
+ route: () => Promise<RouteScreen[] | null>
22
+ /**
23
+ * Walks the persona to a screen on its route.
24
+ *
25
+ * @param screen - The screen.
26
+ */
27
+ onJump: (screen: RouteScreen) => void
28
+ /** Opens it in the form. */
29
+ onEdit: () => void
30
+ /** Deletes a persona saved in this browser; absent for the site's own. */
16
31
  onDelete?: () => void
32
+ /** Drops this browser's edit of a site persona; absent otherwise. */
33
+ onReset?: () => void
34
+ /** The link that starts a walk-through as it in another browser; absent for a saved persona. */
35
+ link?: string
17
36
  }
18
37
 
19
- const { persona, loadReason, loading, onLoad, onEdit, onDelete }: PersonaCardProps = $props()
38
+ const {
39
+ persona,
40
+ startReason,
41
+ starting,
42
+ active,
43
+ onWalkThrough,
44
+ route,
45
+ onJump,
46
+ onEdit,
47
+ onDelete,
48
+ onReset,
49
+ link,
50
+ }: PersonaCardProps = $props()
20
51
 
21
52
  let confirming = $state(false)
53
+ let jumpOpen = $state(false)
54
+ /** The route's screens; `undefined` while they are worked out. */
55
+ let screens = $state.raw<RouteScreen[] | null | undefined>(undefined)
22
56
 
23
57
  const answers = $derived(Object.keys(persona.responses).length)
24
- const answerLabel = $derived(answers === 1 ? '1 answer' : `${answers} answers`)
58
+ const answerLabel = $derived(answers === 1 ? '1 response' : `${answers} responses`)
25
59
  const summary = $derived(
26
- persona.load === null
27
- ? `${answerLabel} · ${describeLanding(persona.landing)}`
28
- : 'Set up by this site',
60
+ [answerLabel, describeLanding(persona.landing), persona.edited ? 'Edited in this browser' : '']
61
+ .filter((part) => part.length > 0)
62
+ .join(' · '),
29
63
  )
64
+ const removeLabel = $derived(onReset ? 'Reset' : 'Delete')
65
+ const removeQuestion = $derived(
66
+ onReset ? `Undo your edits to ${persona.name}?` : `Delete ${persona.name}?`,
67
+ )
68
+
69
+ /**
70
+ * Opens or closes the list of screens to jump to, working the route out on first open.
71
+ *
72
+ * @returns {Promise<void>} Settles once the route is worked out.
73
+ * @example await toggleJump()
74
+ */
75
+ async function toggleJump(): Promise<void> {
76
+ jumpOpen = !jumpOpen
77
+ if (!jumpOpen) return
78
+ screens = undefined
79
+ try {
80
+ screens = await route()
81
+ } catch {
82
+ screens = null
83
+ }
84
+ }
85
+
86
+ /**
87
+ * A screen's name in the list.
88
+ *
89
+ * @param {RouteScreen} screen - The screen.
90
+ * @returns {string} Its name.
91
+ * @example screenLabel(screen) // 'Postcode'
92
+ */
93
+ function screenLabel(screen: RouteScreen): string {
94
+ return screen.stepName ?? deslug(screen.stepKey)
95
+ }
30
96
  </script>
31
97
 
32
98
  <Card>
33
99
  <div class="persona" data-testid="devtools-persona" data-persona-id={persona.id}>
34
- <div class="details">
35
- <Text weight="semibold">{persona.name}</Text>
36
- {#if persona.description}
37
- <Text size="small">{persona.description}</Text>
38
- {/if}
39
- <Text size="caption" color="subdued">{summary}</Text>
40
- </div>
41
- <div class="actions">
42
- {#if confirming && onDelete}
43
- <Text size="small">Delete {persona.name}?</Text>
44
- <Button variant="destructive" size="small" onclick={onDelete}>Yes, delete</Button>
45
- <Button variant="ghost" size="small" onclick={() => (confirming = false)}>Keep</Button>
46
- {:else}
47
- <Button
48
- variant="primary"
49
- size="small"
50
- disabled={loadReason !== undefined}
51
- title={loadReason}
52
- {loading}
53
- onclick={onLoad}
54
- >
55
- Load
56
- </Button>
57
- {#if onEdit}
58
- <Button variant="ghost" size="small" onclick={onEdit}>Edit</Button>
100
+ <div class="head">
101
+ <div class="details">
102
+ <Text weight="semibold">{persona.name}</Text>
103
+ {#if persona.description}
104
+ <Text size="small">{persona.description}</Text>
59
105
  {/if}
60
- {#if onDelete}
61
- <Button variant="ghost" size="small" onclick={() => (confirming = true)}>Delete</Button>
106
+ <Text size="caption" color="subdued">{summary}</Text>
107
+ {#if active}
108
+ <span><Badge status="info" size="small">Walking through now</Badge></span>
62
109
  {/if}
63
- {/if}
110
+ </div>
111
+ <div class="actions">
112
+ {#if confirming && (onDelete || onReset)}
113
+ <Text size="small">{removeQuestion}</Text>
114
+ <Button
115
+ variant="destructive"
116
+ size="small"
117
+ onclick={() => {
118
+ confirming = false
119
+ ;(onReset ?? onDelete)?.()
120
+ }}
121
+ >
122
+ Yes, {removeLabel.toLowerCase()}
123
+ </Button>
124
+ <Button variant="ghost" size="small" onclick={() => (confirming = false)}>Keep</Button>
125
+ {:else}
126
+ <Button
127
+ variant="primary"
128
+ size="small"
129
+ disabled={startReason !== undefined}
130
+ title={startReason}
131
+ loading={starting}
132
+ onclick={onWalkThrough}
133
+ >
134
+ Walk through
135
+ </Button>
136
+ <Button
137
+ variant="secondary"
138
+ size="small"
139
+ disabled={startReason !== undefined}
140
+ title={startReason}
141
+ onclick={() => void toggleJump()}
142
+ >
143
+ Jump to step
144
+ </Button>
145
+ <Button variant="ghost" size="small" onclick={onEdit}>Edit</Button>
146
+ {#if link}
147
+ <CopyButton
148
+ text={link}
149
+ label="Copy a link that walks through as {persona.name}"
150
+ testId="devtools-persona-link"
151
+ />
152
+ {/if}
153
+ {#if onDelete || onReset}
154
+ <Button variant="ghost" size="small" onclick={() => (confirming = true)}>
155
+ {removeLabel}
156
+ </Button>
157
+ {/if}
158
+ {/if}
159
+ </div>
64
160
  </div>
161
+
162
+ {#if jumpOpen}
163
+ <div class="jump" data-testid="devtools-persona-jump">
164
+ {#if screens === undefined}
165
+ <Text size="small" color="subdued">Working out the route…</Text>
166
+ {:else if screens === null || screens.length === 0}
167
+ <Text size="small" color="subdued">No steps to jump to from this page.</Text>
168
+ {:else}
169
+ <Text size="small" color="subdued">
170
+ Pick a step. The page reloads and walks there as {persona.name}.
171
+ </Text>
172
+ <ol class="steps">
173
+ {#each screens as screen (`${screen.experienceKey}/${screen.stepKey}`)}
174
+ <li>
175
+ <button
176
+ type="button"
177
+ class="step"
178
+ data-testid="devtools-persona-jump-step"
179
+ disabled={startReason !== undefined}
180
+ onclick={() => onJump(screen)}
181
+ >
182
+ <span class="step-name">{screenLabel(screen)}</span>
183
+ <span class="step-journey">{screen.experienceName}</span>
184
+ {#if screen.isStop}
185
+ <Badge size="small">Where it stops</Badge>
186
+ {/if}
187
+ </button>
188
+ </li>
189
+ {/each}
190
+ </ol>
191
+ {/if}
192
+ </div>
193
+ {/if}
65
194
  </div>
66
195
  </Card>
67
196
 
68
197
  <style>
69
198
  .persona {
199
+ display: flex;
200
+ flex-direction: column;
201
+ gap: var(--space-3);
202
+ }
203
+
204
+ .head {
70
205
  display: flex;
71
206
  flex-wrap: wrap;
72
207
  align-items: center;
@@ -88,4 +223,52 @@
88
223
  align-items: center;
89
224
  gap: var(--space-2);
90
225
  }
226
+
227
+ .jump {
228
+ display: flex;
229
+ flex-direction: column;
230
+ gap: var(--space-2);
231
+ padding-top: var(--space-3);
232
+ border-top: 1px solid var(--color-gray-200);
233
+ }
234
+
235
+ .steps {
236
+ display: flex;
237
+ flex-direction: column;
238
+ gap: var(--space-1);
239
+ margin: 0;
240
+ padding-left: var(--space-5);
241
+ }
242
+
243
+ .step {
244
+ display: flex;
245
+ flex-wrap: wrap;
246
+ align-items: center;
247
+ gap: var(--space-2);
248
+ width: 100%;
249
+ padding: var(--space-1-5) var(--space-2);
250
+ border: 0;
251
+ border-radius: var(--radius-sm);
252
+ background: transparent;
253
+ color: var(--color-gray-900);
254
+ font: inherit;
255
+ font-size: var(--text-sm);
256
+ text-align: left;
257
+ cursor: pointer;
258
+ }
259
+
260
+ .step:hover:not(:disabled),
261
+ .step:focus-visible {
262
+ background: var(--color-gray-100);
263
+ }
264
+
265
+ .step:disabled {
266
+ cursor: not-allowed;
267
+ opacity: 0.6;
268
+ }
269
+
270
+ .step-journey {
271
+ color: var(--color-gray-500);
272
+ font-size: var(--text-xs);
273
+ }
91
274
  </style>