@picked/svelte 0.0.1-dev.1772493269328 → 0.0.1-dev.1773364848747
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/form/index.js +1 -1
- package/dist/hooks/step.js +1 -1
- package/dist/plugins/devtools/components/ExperienceInstanceListItem.svelte +1 -1
- package/dist/plugins/devtools/plugin.js +1 -1
- package/dist/plugins/devtools/screens/events/EventsListScreen.svelte +1 -1
- package/dist/plugins/devtools/screens/experiences/ExperienceDetailsScreen.svelte +2 -2
- package/dist/plugins/devtools/screens/experiences/ExperienceTreeScreen.svelte +3 -3
- package/dist/plugins/devtools/screens/responses/ResponseTableRow.svelte +20 -8
- package/dist/plugins/devtools/screens/responses/ResponsesTable.svelte +1 -1
- package/package.json +65 -4
package/dist/form/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createEvent as
|
|
1
|
+
import{createEvent as k,createEffect as m,attach as y,sample as b,split as D}from"effector";import{getPicked as F,getExperience as B}from"../hooks/client.js";import"@picked/client";import{getStep as N}from"../hooks/step.js";import"svelte";import"svelte/store";import"@picked/analytics";function z({id:l,title:d,onError:g,onSuccess:x}){const n=F(),E=N(),i=B(),{currentStepStore:u}=i,h=k(),v=m(e=>n.responses.commit(e)),S=y({source:{step:u},effect:m(({step:e})=>{n.eventBus({type:"form_submit_success",form:{id:l,title:d},experience:i,step:e??void 0}),x?.()})}),A=y({source:{step:u},mapParams:(e,a)=>({step:a.step,errors:e.errors}),effect:m(({step:e,errors:a})=>{n.eventBus({type:"form_submit_error",form:{id:l,title:d},exception:{reason:a},experience:i,step:e??void 0}),a.forEach(c=>{n.eventBus({type:"field_validation_error",exception:{reason:[c]},experience:i,step:e??void 0})}),g?.(a)})});return b({clock:h,source:{step:u},fn:({step:e})=>({formId:l,title:d,step:e}),target:m(({formId:e,title:a,step:c})=>{n.eventBus({type:"form_submit",form:{id:e,title:a},experience:i,step:c??void 0})})}),b({clock:h,source:{fields:n.fields.listStore,stepFields:E.fields,step:u},fn:({stepFields:e},a)=>{a.preventDefault();const c=new FormData(a.currentTarget),_=Array.from(c.entries()),p={data:{},push(t){const s=t.questionId,r=this.data[s];r?Array.isArray(r)&&Array.isArray(t.value)?Array.isArray(r)&&Array.isArray(t.value)&&(typeof r[0]=="string"?this.data[s]=[...r,...t.value].map(String):typeof r[0]=="number"?this.data[s]=[...r,...t.value].map(Number):typeof r[0]=="boolean"?this.data[s]=[...r,...t.value].map(o=>!!o):this.data[s]=t.value):this.data[s]=t.value:this.data[s]=t.value}};return e.forEach(t=>{const s=t.key??t.id??"";let r=_.filter(([o])=>o===s);r.length===0&&(r=[[s,""]]),r.forEach(([,o])=>{const f=s;if(o===""){p.push({questionId:f,value:null});return}switch(t.type){case"text":p.push({questionId:f,value:t.multiple?[String(o)]:String(o)});break;case"number":p.push({questionId:f,value:t.multiple?[Number(o)]:Number(o)});break;case"boolean":p.push({questionId:f,value:t.multiple?[o==="true"]:o==="true"});break}})}),p.data},target:v}),D({source:v.doneData,match:{hasErrors:({errors:e})=>e.length>0},cases:{hasErrors:A,__:S}}),{form:{onsubmit:h}}}export{z as getForm};
|
package/dist/hooks/step.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getContext as v,setContext as x}from"svelte";import{createStore as E,combine as
|
|
1
|
+
import{getContext as v,setContext as x}from"svelte";import{createStore as E,combine as l,attach as h,createEffect as w,sample as p}from"effector";import{getStepFields as A}from"@picked/client";import{STEP_CONTEXT_KEY as u}from"../context.js";import{getStepRouter as C}from"../router/context.js";import{getExperience as k,getPicked as y}from"./client.js";function D(){return v(u)}function N(s){const S=k(),o=y(),{activeStep:d}=C(),i=d.map(e=>e?.id===s),f=S.treeStore.map(e=>{const r=e.steps.find(t=>t.id===s);if(!r)throw new Error(`Step with id "${s}" not found in the experience tree.`);return r}),a=E([]),m=l({fields:a,responses:o.responses.listStore},({fields:e,responses:r})=>e.map(t=>{const c=r.find(g=>g.fieldId===t.id)?.value;return{...t,value:c}})),n=h({source:l({step:f,fields:o.fields.listStore}),effect:w(async({step:{fieldIds:e},fields:r})=>await A(o,r.filter(t=>{const c=t.key??t.id??"";return e.includes(c)})))});return p({source:{isActiveStep:i},filter:({isActiveStep:e})=>e,target:n}),p({clock:o.responses.listStore,source:{isActiveStep:i},filter:({isActiveStep:e})=>e,target:n}),p({source:n.doneData,target:a}),x(u,{step:f,fields:m,isActiveStep:i})}export{D as getStep,N as setStepContext};
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
<td>{$currentNode?.id || ''}</td>
|
|
21
21
|
<td>{$currentNode?.type || ''}</td>
|
|
22
22
|
<td>{$currentStep?.id || ''}</td>
|
|
23
|
-
<td>{$currentStep?.
|
|
23
|
+
<td>{$currentStep?.name || ''}</td>
|
|
24
24
|
<td>{totalNextStepNodes}</td>
|
|
25
25
|
<td>{$stepsToOrigin[0]} - {$stepsToOrigin[1]}</td>
|
|
26
26
|
<td>{$stepsToLeaf[0]} - {$stepsToLeaf[1]}</td>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__vitePreload as i}from"../../_virtual/preload-helper.js";import{lazyComponent as r}from"@picked/client";import{createExperience as p,createExperiencePlugin as a}from"@picked/client/plugins/create-experience";import{adaptSvelteComponent as
|
|
1
|
+
import{__vitePreload as i}from"../../_virtual/preload-helper.js";import{lazyComponent as r}from"@picked/client";import{createExperience as p,createExperiencePlugin as a}from"@picked/client/plugins/create-experience";import{adaptSvelteComponent as s}from"../../component.js";const v=t=>{const e=p({id:"devtools",name:"Picked Devtools",condition:!1,initializeOpen:!1,targets:[{selector:"body",placement:"append"}],component:s(r(()=>i(()=>import("./DevToolsExperience.svelte"),[])))});return e.addStep({name:"Tools"}),[{name:"svelte-devtools",setup:o=>{t?.enabled&&o.eventBus.watch(n=>{n.type==="ready"&&o.experiences.launch({id:e.id,options:{bypassCondition:!0}})})}},a({experiences:[e]})]};export{v as svelteDevtoolsPlugin};
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
let zoom = 1
|
|
10
10
|
let selectedNode = null
|
|
11
11
|
let highlightedPath: string[][] = []
|
|
12
|
-
let error = null
|
|
12
|
+
let error: string | null = null
|
|
13
13
|
const loading = false
|
|
14
14
|
|
|
15
15
|
let treeRenderingDone = false
|
|
@@ -100,7 +100,7 @@
|
|
|
100
100
|
const getNodeLabel = (node: ExperienceNode): string => {
|
|
101
101
|
if (node.type === 'origin') return 'Start'
|
|
102
102
|
if (node.type === 'step' && node.stepId)
|
|
103
|
-
return stepsMap.get(node.stepId)?.
|
|
103
|
+
return stepsMap.get(node.stepId)?.name ?? 'Unknown Step'
|
|
104
104
|
if (node.type === 'conditional' && node.conditionalId) {
|
|
105
105
|
const conditional = conditionalsMap.get(node.conditionalId)
|
|
106
106
|
if (conditional?.label) return conditional.label
|
|
@@ -186,7 +186,7 @@
|
|
|
186
186
|
const g = svg.append('g').attr('transform', `translate(${margin.left},${margin.top})`)
|
|
187
187
|
|
|
188
188
|
const linkGenerator = d3
|
|
189
|
-
.linkHorizontal<d3.HierarchyPointLink<ProcessedNode>, ProcessedNode
|
|
189
|
+
.linkHorizontal<d3.HierarchyPointLink<ProcessedNode>, d3.HierarchyPointNode<ProcessedNode>>()
|
|
190
190
|
.x((d) => d.y)
|
|
191
191
|
.y((d) => d.x)
|
|
192
192
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import type { ResponseListItem, PrimitiveFieldValue, Field } from '@picked/client'
|
|
2
|
+
import type { ResponseListItem, PrimitiveFieldValue, FieldValue, Field } from '@picked/client'
|
|
3
3
|
import { getPicked } from '../../../../hooks'
|
|
4
4
|
import { Button, Text, CodeBlock, Banner, Stack } from '../../ui'
|
|
5
5
|
|
|
@@ -8,6 +8,15 @@
|
|
|
8
8
|
|
|
9
9
|
const client = getPicked()
|
|
10
10
|
|
|
11
|
+
function isPrimitiveFieldValue(val: unknown): val is PrimitiveFieldValue {
|
|
12
|
+
return val === null || typeof val === 'string' || typeof val === 'number' || typeof val === 'boolean'
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function isOptionSelected(optionValue: unknown): boolean {
|
|
16
|
+
if (!isPrimitiveFieldValue(optionValue)) return false
|
|
17
|
+
return selectedOptions.has(optionValue)
|
|
18
|
+
}
|
|
19
|
+
|
|
11
20
|
let isEditing = false
|
|
12
21
|
let editValue = ''
|
|
13
22
|
let editError = ''
|
|
@@ -36,8 +45,8 @@
|
|
|
36
45
|
if (hasOptions) {
|
|
37
46
|
selectedOptions = new Set()
|
|
38
47
|
if (Array.isArray(currentValue)) {
|
|
39
|
-
currentValue.forEach((v) => selectedOptions.add(v))
|
|
40
|
-
} else if (currentValue
|
|
48
|
+
currentValue.forEach((v) => { if (isPrimitiveFieldValue(v)) selectedOptions.add(v) })
|
|
49
|
+
} else if (isPrimitiveFieldValue(currentValue)) {
|
|
41
50
|
selectedOptions.add(currentValue)
|
|
42
51
|
}
|
|
43
52
|
} else {
|
|
@@ -52,7 +61,8 @@
|
|
|
52
61
|
selectedOptions = new Set()
|
|
53
62
|
}
|
|
54
63
|
|
|
55
|
-
function toggleOption(optionValue:
|
|
64
|
+
function toggleOption(optionValue: unknown) {
|
|
65
|
+
if (!isPrimitiveFieldValue(optionValue)) return
|
|
56
66
|
if (field?.multiple) {
|
|
57
67
|
if (selectedOptions.has(optionValue)) {
|
|
58
68
|
selectedOptions.delete(optionValue)
|
|
@@ -65,7 +75,7 @@
|
|
|
65
75
|
}
|
|
66
76
|
}
|
|
67
77
|
|
|
68
|
-
function parseValue(input: string):
|
|
78
|
+
function parseValue(input: string): FieldValue {
|
|
69
79
|
input = input.trim()
|
|
70
80
|
|
|
71
81
|
if (input === '' || input === '-') {
|
|
@@ -99,7 +109,7 @@
|
|
|
99
109
|
|
|
100
110
|
async function saveEdit() {
|
|
101
111
|
try {
|
|
102
|
-
let newValue:
|
|
112
|
+
let newValue: FieldValue
|
|
103
113
|
|
|
104
114
|
if (hasOptions) {
|
|
105
115
|
const values = Array.from(selectedOptions)
|
|
@@ -112,6 +122,7 @@
|
|
|
112
122
|
newValue = parseValue(editValue)
|
|
113
123
|
}
|
|
114
124
|
|
|
125
|
+
if (field.id == null) return
|
|
115
126
|
const result = await client.responses.commit({ [field.id]: newValue })
|
|
116
127
|
|
|
117
128
|
if (result.errors.length > 0) {
|
|
@@ -128,6 +139,7 @@
|
|
|
128
139
|
}
|
|
129
140
|
|
|
130
141
|
function handleClear() {
|
|
142
|
+
if (field.id == null) return
|
|
131
143
|
client.responses.clear(field.id)
|
|
132
144
|
}
|
|
133
145
|
</script>
|
|
@@ -149,14 +161,14 @@
|
|
|
149
161
|
{#if field.multiple}
|
|
150
162
|
<input
|
|
151
163
|
type="checkbox"
|
|
152
|
-
checked={
|
|
164
|
+
checked={isOptionSelected(option.value)}
|
|
153
165
|
on:change={() => toggleOption(option.value)}
|
|
154
166
|
/>
|
|
155
167
|
{:else}
|
|
156
168
|
<input
|
|
157
169
|
type="radio"
|
|
158
170
|
name="field-{field.id}"
|
|
159
|
-
checked={
|
|
171
|
+
checked={isOptionSelected(option.value)}
|
|
160
172
|
on:change={() => toggleOption(option.value)}
|
|
161
173
|
/>
|
|
162
174
|
{/if}
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
$: responseMap = new Map(responses.map((r) => [r.fieldId, r]))
|
|
17
17
|
|
|
18
18
|
$: allFieldRows = allFields.map((field) => {
|
|
19
|
-
const response = responseMap.get(field.id)
|
|
19
|
+
const response = field.id != null ? responseMap.get(field.id) : undefined
|
|
20
20
|
return {
|
|
21
21
|
field,
|
|
22
22
|
response: response || null,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@picked/svelte",
|
|
3
|
-
"version": "0.0.1-dev.
|
|
3
|
+
"version": "0.0.1-dev.1773364848747",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"d3": "^7.9.0"
|
|
6
6
|
},
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
"@picked/client": "workspace:*",
|
|
10
10
|
"@repo/eslint-config": "workspace:*",
|
|
11
11
|
"@repo/typescript-config": "workspace:*",
|
|
12
|
+
"@size-limit/file": "^12.0.0",
|
|
12
13
|
"@sveltejs/package": "^2.3.11",
|
|
13
14
|
"@sveltejs/vite-plugin-svelte": "^6.2.4",
|
|
14
15
|
"@tsconfig/svelte": "^5.0.4",
|
|
@@ -18,6 +19,7 @@
|
|
|
18
19
|
"effector": "^23.3.0",
|
|
19
20
|
"fast-glob": "^3.3.3",
|
|
20
21
|
"happy-dom": "^20.0.2",
|
|
22
|
+
"size-limit": "^12.0.0",
|
|
21
23
|
"svelte": "^5.34.3",
|
|
22
24
|
"svelte-check": "^4.2.2",
|
|
23
25
|
"typedoc": "^0.28.5",
|
|
@@ -78,15 +80,43 @@
|
|
|
78
80
|
"knip",
|
|
79
81
|
"jscpd",
|
|
80
82
|
"eslint",
|
|
81
|
-
"tsc"
|
|
83
|
+
"tsc",
|
|
84
|
+
"attw"
|
|
82
85
|
],
|
|
86
|
+
"ignoreDependencies": [
|
|
87
|
+
"@picked/analytics",
|
|
88
|
+
"@picked/client",
|
|
89
|
+
"@repo/eslint-config",
|
|
90
|
+
"@repo/typescript-config",
|
|
91
|
+
"@sveltejs/package",
|
|
92
|
+
"@tsconfig/svelte"
|
|
93
|
+
],
|
|
94
|
+
"ignoreFiles": [
|
|
95
|
+
"eslint.config.js",
|
|
96
|
+
"src/components/index.ts",
|
|
97
|
+
"src/components/LazyImage.svelte",
|
|
98
|
+
"src/index.ts",
|
|
99
|
+
"src/plugins/devtools/index.ts",
|
|
100
|
+
"src/plugins/devtools/PickedLogo.svelte",
|
|
101
|
+
"src/plugins/framework/index.ts",
|
|
102
|
+
"src/router/index.ts",
|
|
103
|
+
"src/router/Step.svelte",
|
|
104
|
+
"src/router/StepRouter.svelte"
|
|
105
|
+
],
|
|
106
|
+
"ignoreIssues": {
|
|
107
|
+
"src/**": [
|
|
108
|
+
"exports",
|
|
109
|
+
"types",
|
|
110
|
+
"duplicates"
|
|
111
|
+
]
|
|
112
|
+
},
|
|
83
113
|
"entry": [
|
|
84
114
|
"src/plugins/devtools/ui/index.ts"
|
|
85
115
|
]
|
|
86
116
|
},
|
|
87
117
|
"module": "./dist/index.js",
|
|
88
118
|
"peerDependencies": {
|
|
89
|
-
"@picked/client": "0.0.1-dev.
|
|
119
|
+
"@picked/client": "0.0.1-dev.1773364848747",
|
|
90
120
|
"effector": "^23.3.0",
|
|
91
121
|
"svelte": "^5.34.3"
|
|
92
122
|
},
|
|
@@ -98,10 +128,11 @@
|
|
|
98
128
|
"dev": "vite build --watch",
|
|
99
129
|
"jscpd": "jscpd src",
|
|
100
130
|
"knip": "knip",
|
|
101
|
-
"lint": "eslint .",
|
|
131
|
+
"lint": "if [ \"$AGENT\" = \"true\" ]; then echo \"[AGENT HINT] Prefer running lint on specific files from the repo root: node scripts/lint-files.js <files>\"; fi && eslint .",
|
|
102
132
|
"lint-files": "eslint",
|
|
103
133
|
"lint:format": "eslint . --fix",
|
|
104
134
|
"lint:report": "eslint . -o './.reports/eslint.json' -f json || [ -f './.reports/eslint.json' ]",
|
|
135
|
+
"size": "size-limit",
|
|
105
136
|
"svelte-check": "svelte-check --tsconfig ./tsconfig.json",
|
|
106
137
|
"svelte-check:report": "mkdir -p ./.reports && pnpm svelte-check --tsconfig ./tsconfig.json --output=machine > ./.reports/svelte-check.txt || [ -f './.reports/svelte-check.txt' ]",
|
|
107
138
|
"test": "vitest run",
|
|
@@ -110,6 +141,36 @@
|
|
|
110
141
|
"test:watch": "vitest",
|
|
111
142
|
"type-check": "tsc -p . --noEmit"
|
|
112
143
|
},
|
|
144
|
+
"size-limit": [
|
|
145
|
+
{
|
|
146
|
+
"path": "dist/index.js",
|
|
147
|
+
"limit": "10 kB"
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
"path": "dist/server/index.js",
|
|
151
|
+
"limit": "10 kB"
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
"path": "dist/router/index.js",
|
|
155
|
+
"limit": "5 kB"
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
"path": "dist/form/index.js",
|
|
159
|
+
"limit": "5 kB"
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
"path": "dist/hooks/index.js",
|
|
163
|
+
"limit": "5 kB"
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
"path": "dist/plugins/framework/index.js",
|
|
167
|
+
"limit": "5 kB"
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
"path": "dist/plugins/devtools/index.js",
|
|
171
|
+
"limit": "5 kB"
|
|
172
|
+
}
|
|
173
|
+
],
|
|
113
174
|
"svelte": "./dist/index.js",
|
|
114
175
|
"type": "module",
|
|
115
176
|
"types": "./dist/index.d.ts"
|