@picked/client 0.0.61 → 0.0.62-next.10

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 (135) hide show
  1. package/README.md +0 -8
  2. package/dist/{api-CjGYS0lP.js → api-C11HFYrl.js} +1 -1
  3. package/dist/api-DXosW8uz.cjs +1 -0
  4. package/dist/cjs/form/index.js +1 -1
  5. package/dist/cjs/index.js +4 -4
  6. package/dist/cjs/plugins/create-experience/index.js +1 -1
  7. package/dist/cjs/plugins/dom-observer/index.js +1 -0
  8. package/dist/cjs/plugins/dynamic-experiences/index.js +1 -1
  9. package/dist/cjs/plugins/experience-browser-storage/index.js +1 -1
  10. package/dist/cjs/plugins/history-browser-storage/index.js +1 -1
  11. package/dist/cjs/plugins/responses-browser-storage/index.js +1 -1
  12. package/dist/cjs/plugins/single-page-app/index.js +1 -1
  13. package/dist/cjs/plugins/web-components/index.js +1 -1
  14. package/dist/cjs/server/index.js +1 -1
  15. package/dist/docs/actions.mdx +0 -1
  16. package/dist/docs/api/authentication.md +376 -0
  17. package/dist/docs/api/authorization-and-scopes.md +262 -0
  18. package/dist/docs/api/error-handling.md +211 -0
  19. package/dist/docs/api/index.md +172 -11
  20. package/dist/docs/api/pagination.md +176 -0
  21. package/dist/docs/image-optimisation-service.md +72 -0
  22. package/dist/docs/index.md +0 -2
  23. package/dist/docs/pickedql/data-sources.md +2 -2
  24. package/dist/docs/pickedql/dimensions.md +2 -0
  25. package/dist/docs/pickedql/schema.md +2 -2
  26. package/dist/docs/pickedql/virtual-functions.md +27 -0
  27. package/dist/docs/sdk/actions.md +0 -1
  28. package/dist/docs/sdk/content-security-policy.md +8 -7
  29. package/dist/docs/sdk/features.md +0 -1
  30. package/dist/docs/sdk/fields.md +2 -2
  31. package/dist/docs/sdk/index.md +0 -1
  32. package/dist/docs/sdk/plugins/create-experience.md +0 -1
  33. package/dist/docs/sdk/plugins/dynamic-experiences.md +2 -3
  34. package/dist/docs/sdk/plugins/window-object.md +0 -1
  35. package/dist/docs/sdk/predicates.md +0 -1
  36. package/dist/docs/workspaces.mdx +60 -1
  37. package/dist/dom-C3C6Fmwz.cjs +1 -0
  38. package/dist/dom-DGePXPpM.js +84 -0
  39. package/dist/esm/form/index.js +41 -34
  40. package/dist/esm/index.js +1020 -494
  41. package/dist/esm/plugins/create-experience/index.js +1 -1
  42. package/dist/esm/plugins/dom-observer/index.js +87 -0
  43. package/dist/esm/plugins/dynamic-experiences/index.js +133 -60
  44. package/dist/esm/plugins/experience-browser-storage/index.js +9 -6
  45. package/dist/esm/plugins/history-browser-storage/index.js +1 -1
  46. package/dist/esm/plugins/responses-browser-storage/index.js +1 -1
  47. package/dist/esm/plugins/single-page-app/index.js +1 -1
  48. package/dist/esm/plugins/web-components/index.js +1 -1
  49. package/dist/esm/server/index.js +23 -13
  50. package/dist/experience-instance-DImym3m_.js +419 -0
  51. package/dist/experience-instance-DygAdzbn.cjs +1 -0
  52. package/dist/rules-logic-D_CVBuv7.js +13 -0
  53. package/dist/rules-logic-H6P8xwHF.cjs +1 -0
  54. package/dist/types/client.d.ts +2 -2
  55. package/dist/types/entities/action/action.d.ts +6 -3
  56. package/dist/types/entities/action/action.d.ts.map +1 -1
  57. package/dist/types/entities/component/component.d.ts +39 -2
  58. package/dist/types/entities/component/component.d.ts.map +1 -1
  59. package/dist/types/entities/content/content.d.ts +37 -0
  60. package/dist/types/entities/content/content.d.ts.map +1 -0
  61. package/dist/types/entities/experience/experience.d.ts +69 -113
  62. package/dist/types/entities/experience/experience.d.ts.map +1 -1
  63. package/dist/types/entities/experience-instance/experience-instance.d.ts +17 -2
  64. package/dist/types/entities/experience-instance/experience-instance.d.ts.map +1 -1
  65. package/dist/types/entities/feature/feature.d.ts +26 -2
  66. package/dist/types/entities/feature/feature.d.ts.map +1 -1
  67. package/dist/types/entities/field/field.d.ts.map +1 -1
  68. package/dist/types/entities/framework/framework.d.ts +24 -3
  69. package/dist/types/entities/framework/framework.d.ts.map +1 -1
  70. package/dist/types/entities/plugin/plugin.d.ts +32 -1
  71. package/dist/types/entities/plugin/plugin.d.ts.map +1 -1
  72. package/dist/types/entities/predicate/predicate.d.ts +24 -3
  73. package/dist/types/entities/predicate/predicate.d.ts.map +1 -1
  74. package/dist/types/entities/session/session.d.ts +45 -0
  75. package/dist/types/entities/session/session.d.ts.map +1 -0
  76. package/dist/types/entities/step/step.d.ts +17 -2
  77. package/dist/types/entities/step/step.d.ts.map +1 -1
  78. package/dist/types/exports.d.ts +9 -3
  79. package/dist/types/exports.d.ts.map +1 -1
  80. package/dist/types/form/create-form.d.ts +55 -0
  81. package/dist/types/form/create-form.d.ts.map +1 -1
  82. package/dist/types/index.d.ts +3 -1
  83. package/dist/types/index.d.ts.map +1 -1
  84. package/dist/types/lifecycle/lifecycle.d.ts +47 -0
  85. package/dist/types/lifecycle/lifecycle.d.ts.map +1 -0
  86. package/dist/types/lifecycle/rules-logic.d.ts +24 -0
  87. package/dist/types/lifecycle/rules-logic.d.ts.map +1 -0
  88. package/dist/types/lifecycle/state-snapshot.d.ts +37 -0
  89. package/dist/types/lifecycle/state-snapshot.d.ts.map +1 -0
  90. package/dist/types/logic-engine.d.ts +1 -1
  91. package/dist/types/logic-engine.d.ts.map +1 -1
  92. package/dist/types/picked.d.ts +141 -187
  93. package/dist/types/picked.d.ts.map +1 -1
  94. package/dist/types/plugins/dom-observer/index.d.ts +3 -0
  95. package/dist/types/plugins/dom-observer/index.d.ts.map +1 -0
  96. package/dist/types/plugins/dom-observer/plugin.d.ts +50 -0
  97. package/dist/types/plugins/dom-observer/plugin.d.ts.map +1 -0
  98. package/dist/types/plugins/dynamic-experiences/index.d.ts +2 -1
  99. package/dist/types/plugins/dynamic-experiences/index.d.ts.map +1 -1
  100. package/dist/types/plugins/dynamic-experiences/plugin.d.ts +18 -1
  101. package/dist/types/plugins/dynamic-experiences/plugin.d.ts.map +1 -1
  102. package/dist/types/plugins/dynamic-experiences/types.d.ts +63 -1
  103. package/dist/types/plugins/dynamic-experiences/types.d.ts.map +1 -1
  104. package/dist/types/plugins/experience-browser-storage/plugin.d.ts.map +1 -1
  105. package/dist/types/plugins/web-components/plugin.d.ts.map +1 -1
  106. package/dist/types/server/index.d.ts +7 -0
  107. package/dist/types/server/index.d.ts.map +1 -1
  108. package/dist/types/utils/events.d.ts +1 -1
  109. package/dist/types/utils/events.d.ts.map +1 -1
  110. package/dist/types/utils/picked-config.d.ts +12 -4
  111. package/dist/types/utils/picked-config.d.ts.map +1 -1
  112. package/dist/types/utils/rules-logic.d.ts +4 -9
  113. package/dist/types/utils/rules-logic.d.ts.map +1 -1
  114. package/package.json +12 -2
  115. package/dist/api-BarClNGB.cjs +0 -1
  116. package/dist/docs/reference/index.md +0 -11
  117. package/dist/docs/tooling/index.md +0 -19
  118. package/dist/experience-instance-DC2gKwA6.cjs +0 -1
  119. package/dist/experience-instance-DJaNc5Ob.js +0 -486
  120. package/dist/rules-logic-BTIxfrJJ.js +0 -240
  121. package/dist/rules-logic-DNLOv90w.cjs +0 -1
  122. package/dist/types/utils/state-snaphot.d.ts +0 -26
  123. package/dist/types/utils/state-snaphot.d.ts.map +0 -1
  124. package/dist/types/utils/user-session.d.ts +0 -12
  125. package/dist/types/utils/user-session.d.ts.map +0 -1
  126. /package/dist/docs/{tooling/chrome-extension.md → chrome-extension.md} +0 -0
  127. /package/dist/docs/{tooling/gtm-template.md → gtm-template.md} +0 -0
  128. /package/dist/docs/{tooling/mcp.md → mcp.md} +0 -0
  129. /package/dist/docs/{tooling/vite-plugin.md → vite-plugin.md} +0 -0
  130. /package/dist/{id-Bv44ilEo.cjs → id-Cg7fVl1O.cjs} +0 -0
  131. /package/dist/{id-CRqy981z.js → id-n2yrHvNo.js} +0 -0
  132. /package/dist/{object-C82v79xc.js → object-DvUDOytC.js} +0 -0
  133. /package/dist/{object-CUJOjanb.cjs → object-ThO1DEyl.cjs} +0 -0
  134. /package/dist/{storage-B6lQtc4-.cjs → storage-BXSlLTRa.cjs} +0 -0
  135. /package/dist/{storage-6Xk0uAxB.js → storage-hOHCCXvP.js} +0 -0
@@ -132,8 +132,8 @@ Aggregated step-transition edges for sankey / funnel charts. Parameters are supp
132
132
 
133
133
  | Column | Type | Description |
134
134
  |---|---|---|
135
- | `source` | String | Edge start, formatted as `NN. step_id` (e.g., `01. welcome`). |
136
- | `target` | String | Edge end, formatted as `NN. step_id`. |
135
+ | `source` | String | Edge start, formatted as `NN. <step title>` (e.g., `001. Welcome screen`) |
136
+ | `target` | String | Edge end, formatted as `NN. <step title>`.
137
137
  | `users` | UInt64 | Distinct `user_canonical_id` count that traversed this edge. |
138
138
 
139
139
  ### Parameters (via `WHERE`)
@@ -149,6 +149,33 @@ Funnel metrics are being continuously updated. Check back for new functions.
149
149
  | `step_enter_users()` | Users who entered a funnel step |
150
150
  | `step_enter_sessions()` | Sessions that entered a funnel step |
151
151
 
152
+ ## Cohort filters (`events` only)
153
+
154
+ Predicate-shaped functions that emit a `user_canonical_id IN (SELECT … FROM events …)` subquery. Use in `WHERE` to restrict any analysis to users who have at least one event matching a custom condition.
155
+
156
+ | Function | Description |
157
+ |---|---|
158
+ | `user_cohort_filter('<condition>')` | Restrict the query to users with ≥1 `events` row matching `<condition>` |
159
+ | `user_cohort_filter(filter='<condition>')` | Same, named-arg form |
160
+
161
+ `<condition>` uses the same `column=value [AND\|OR …]` shorthand as `control_users` / `variant_users`.
162
+
163
+ ```sql
164
+ -- Funnel scoped to users who eventually submitted lead capture
165
+ SELECT all_users(), all_purchase_users()
166
+ FROM events
167
+ WHERE project_id = 'proj-abc'
168
+ AND user_cohort_filter('event_type=lead_capture')
169
+
170
+ -- Multi-condition cohort with OR-grouping
171
+ SELECT all_sessions()
172
+ FROM events
173
+ WHERE project_id = 'proj-abc'
174
+ AND user_cohort_filter('event_type=signup OR event_type=trial_start')
175
+ ```
176
+
177
+ The outer query MUST filter by a single `project_id` — the function bakes that tenant into the inner subquery so the cohort scan is scoped to your project, not the whole warehouse.
178
+
152
179
  ## Feature functions (`features` / `events`)
153
180
 
154
181
  Parameterized functions that accept the feature name, bucket, and an optional feature key:
@@ -14,7 +14,6 @@ Register actions when creating the Picked client. Each key in the `actions` obje
14
14
  import { createClient } from '@picked/client'
15
15
 
16
16
  const picked = createClient({
17
- organizationId: 'your-org-id',
18
17
  projectId: 'your-project-id',
19
18
  actions: {
20
19
  'track-signup': () => {
@@ -4,21 +4,22 @@ layout: docs
4
4
 
5
5
  # Content Security Policy
6
6
 
7
- The Picked SDK makes outbound HTTPS requests to the following domains. Add them to your `connect-src` directive.
7
+ The Picked SDK loads resources from the following domains. Add each to the matching CSP directive.
8
8
 
9
9
  ## Required domains
10
10
 
11
- | Domain | Purpose |
12
- | --- | --- |
13
- | `api.picked.app` | API requests — project configuration, experiences, session tracking |
14
- | `evnts.pckd.dev` | Analytics event collection (Snowplow) |
11
+ | Domain | Directive | Purpose |
12
+ | --- | --- | --- |
13
+ | `api.picked.app` | `connect-src` | API requests, project configuration, experiences, session tracking |
14
+ | `evnts.pckd.dev` | `connect-src` | Analytics event collection (Snowplow) |
15
+ | `img.picked-content.com` | `img-src` | Optimised images served via the [image optimisation service](../image-optimisation-service.md) |
15
16
 
16
17
  ## Configuration
17
18
 
18
19
  As an HTTP header:
19
20
 
20
21
  ```
21
- Content-Security-Policy: connect-src 'self' https://api.picked.app https://evnts.pckd.dev;
22
+ Content-Security-Policy: connect-src 'self' https://api.picked.app https://evnts.pckd.dev; img-src 'self' https://img.picked-content.com;
22
23
  ```
23
24
 
24
25
  Or as a `<meta>` tag:
@@ -26,6 +27,6 @@ Or as a `<meta>` tag:
26
27
  ```html
27
28
  <meta
28
29
  http-equiv="Content-Security-Policy"
29
- content="connect-src 'self' https://api.picked.app https://evnts.pckd.dev;"
30
+ content="connect-src 'self' https://api.picked.app https://evnts.pckd.dev; img-src 'self' https://img.picked-content.com;"
30
31
  />
31
32
  ```
@@ -14,7 +14,6 @@ Define features when creating the Picked client by passing a `features` object.
14
14
  import { createClient } from '@picked/client'
15
15
 
16
16
  const client = createClient({
17
- organizationId: 'your-org-id',
18
17
  projectId: 'your-project-id',
19
18
  features: {
20
19
  'summer-sale': {
@@ -193,7 +193,7 @@ const sensitiveField = createField({
193
193
  required: true,
194
194
  policies: {
195
195
  doNotTrackValue: true, // Don't send value to analytics
196
- doNotStoreValue: true, // Don't persist value to backend
196
+ doNotStoreValue: true, // Don't persist value to browser storage
197
197
  },
198
198
  })
199
199
  ```
@@ -201,7 +201,7 @@ const sensitiveField = createField({
201
201
  **Privacy policies**:
202
202
 
203
203
  - `doNotTrackValue`: Excludes field value from analytics events (only field ID is tracked)
204
- - `doNotStoreValue`: Prevents field value from being persisted to backend storage
204
+ - `doNotStoreValue`: Prevents field value from being persisted to browser storage
205
205
 
206
206
  Use these policies for sensitive data like SSNs, credit cards, or passwords that should only exist client-side.
207
207
 
@@ -20,7 +20,6 @@ import { windowObjectPlugin } from '@picked/client/plugins/window-object'
20
20
  import { singlePageAppPlugin } from '@picked/client/plugins/single-page-app'
21
21
 
22
22
  const picked = createClient({
23
- organizationId: 'your-organization-id',
24
23
  projectId: 'your-project-id',
25
24
  plugins: [windowObjectPlugin(), singlePageAppPlugin()],
26
25
  })
@@ -17,7 +17,6 @@ import { funnelExperience } from '../experiences/funnel-experience'
17
17
  import { widgetExperience } from '../experiences/widget-experience'
18
18
 
19
19
  const client = createClient({
20
- organizationId: 'your-org-id',
21
20
  projectId: 'your-project-id',
22
21
  plugins: createExperiencePlugin({
23
22
  experiences: [funnelExperience, widgetExperience],
@@ -15,7 +15,6 @@ import { createClient } from '@picked/client'
15
15
  import { dynamicExperiencesPlugin } from '@picked/client/plugins/dynamic-experiences'
16
16
 
17
17
  const client = createClient({
18
- organizationId: 'your-org-id',
19
18
  projectId: 'your-project-id',
20
19
  plugins: [dynamicExperiencesPlugin()],
21
20
  })
@@ -35,14 +34,14 @@ When the client starts, the plugin resolves your project configuration using a t
35
34
 
36
35
  1. **Preview mode** — When you [enter preview mode from the dashboard](/workspaces#preview), the plugin fetches fresh config from the API. Feature decisions use session storage so they are not persisted beyond the current tab.
37
36
 
38
- 2. **Build-time config** — If `projectConfig` was passed as a plugin option, or the [Vite Plugin](/tooling/vite-plugin) injected config at build time, the plugin uses that config with no network request.
37
+ 2. **Build-time config** — If `projectConfig` was passed as a plugin option, or the [Vite Plugin](/vite-plugin) injected config at build time, the plugin uses that config with no network request.
39
38
 
40
39
  3. **Runtime fetch** — Otherwise, the plugin fetches config from the API when the client starts.
41
40
 
42
41
  Once resolved, the plugin registers all features, conditions, fields, steps, and experiences with the client. Experiences then initialize according to their [conditions](/sdk/conditions) and [target selectors](/sdk/experiences).
43
42
 
44
43
  :::note
45
- The [Vite Plugin](/tooling/vite-plugin) eliminates the runtime API request in production by embedding your project config at build time. This is the recommended setup for Vite-based applications.
44
+ The [Vite Plugin](/vite-plugin) eliminates the runtime API request in production by embedding your project config at build time. This is the recommended setup for Vite-based applications.
46
45
  :::
47
46
 
48
47
  ## Feature Allocation
@@ -13,7 +13,6 @@ import { createClient } from '@picked/client'
13
13
  import { windowObjectPlugin } from '@picked/client/plugins/window-object'
14
14
 
15
15
  const client = createClient({
16
- organizationId: 'your-org-id',
17
16
  projectId: 'your-project-id',
18
17
  plugins: [windowObjectPlugin()],
19
18
  })
@@ -14,7 +14,6 @@ Define predicates when creating the Picked client by passing a `predicates` obje
14
14
  import { createClient } from '@picked/client'
15
15
 
16
16
  const client = createClient({
17
- organizationId: 'your-org-id',
18
17
  projectId: 'your-project-id',
19
18
  predicates: {
20
19
  'is-example-page': ({ location }) => {
@@ -18,6 +18,12 @@ A workspace is a version of your project's configuration. Use workspaces to stag
18
18
 
19
19
  Each project has a workspace that holds your experiences, features, and entity configurations. When you make changes in the dashboard — editing a flow, updating a feature, or modifying an entity — those changes exist in the workspace until you publish.
20
20
 
21
+ A workspace is in one of three states:
22
+
23
+ - **Live** — the workspace the SDK serves to visitors. There is exactly one live workspace per project.
24
+ - **Draft** — a workspace not currently serving traffic. You can edit, preview, and publish a draft to make it live.
25
+ - **Archived** — a draft you have set aside. Archived workspaces stay editable but are filtered out of the default workspaces list.
26
+
21
27
  ## Preview
22
28
 
23
29
  Preview your workspace to see how changes look before publishing.
@@ -34,10 +40,63 @@ Your site opens in a new tab with the unpublished workspace applied. Preview use
34
40
  Publishing creates an immutable snapshot of your workspace. Once published, the SDK serves the new configuration to visitors.
35
41
 
36
42
  1. Click **Publish** in the workspace toolbar.
37
- 2. Confirm in the publish dialog.
43
+ 2. Review the change preview in the publish modal.
44
+ 3. Click **Publish** to confirm.
38
45
 
39
46
  The publish button is only enabled when there are unpublished changes. A status badge in the toolbar shows whether the workspace has unpublished changes or is up to date.
40
47
 
48
+ ## Change previews
49
+
50
+ The publish modal shows a side-by-side change preview comparing the current workspace against the last published snapshot. Use it to verify exactly what your visitors will see after publishing.
51
+
52
+ <Screenshot
53
+ route="/{orgSlug}/{projectId}/workspaces/{workspaceId}/experiences?action=publish"
54
+ alt="The publish modal showing a change preview with added experiences, steps, and conditions"
55
+ selector='[role="dialog"]'
56
+ wait='[role="dialog"]'
57
+ hide={['[data-testid="publish-diff-replaces-version"]']}
58
+ renderWidth={720}
59
+ renderHeight={579}
60
+ />
61
+
62
+ The preview groups changes by entity type — experiences, features, steps, fields, actions, and conditions. Each row shows whether the entity was **added**, **removed**, or **modified**. For modifications, expand the row to see which properties changed.
63
+
64
+ When the change preview includes breaking changes — for example, removing a field that other steps still reference — a banner highlights the breaking entries above the diff so you can reconsider before publishing.
65
+
66
+ The first publish of a workspace has no previous snapshot to compare against, so the publish modal shows the workspace's contents as the initial publish without a diff.
67
+
41
68
  ## Unpublished changes
42
69
 
43
70
  The workspace tracks whether any changes have been made since the last publish. If you create or update an experience, feature, or entity after the last publish, the toolbar shows a warning badge indicating unpublished changes.
71
+
72
+ ## Workspace settings
73
+
74
+ The workspace settings page (**Settings** in the workspace nav) covers renaming, archiving, and deleting a workspace.
75
+
76
+ ### Rename
77
+
78
+ Change the workspace name in the **Name** field and click **Save**. Names are unique within a project — duplicates are rejected with a validation error.
79
+
80
+ ### Archive
81
+
82
+ Archiving moves a draft workspace out of the default workspaces list without deleting it. Use it for drafts you want to set aside for later without losing the work.
83
+
84
+ 1. Open the workspace settings page.
85
+ 2. Click **Archive** in the page header.
86
+ 3. Confirm in the modal.
87
+
88
+ Live workspaces cannot be archived directly — make a different workspace live first, then archive the previous one.
89
+
90
+ ### Unarchive
91
+
92
+ Restore an archived workspace to draft status from the same page. The settings page detects the archived state and switches the toolbar button to **Unarchive**.
93
+
94
+ ### Delete
95
+
96
+ Deleting a workspace permanently removes it and its entities. This is destructive and cannot be undone — prefer archive when in doubt.
97
+
98
+ 1. Open the workspace settings page.
99
+ 2. In the **Danger zone** card at the bottom, click **Delete**.
100
+ 3. Confirm in the modal.
101
+
102
+ Live workspaces cannot be deleted. Archive or publish a different workspace first to free the workspace for deletion.
@@ -0,0 +1 @@
1
+ const e=require(`./supports-Dsjg-82e.cjs`);function t(t){return!e.d()||!e.r()?[]:Array.from(window.document.querySelectorAll(t)).filter(e=>e instanceof HTMLElement)}var n=`open`;function r(t){if(!e.l())throw Error(`Shadow DOM is not supported in this environment`);return t.attachShadow({mode:n})}function i(){return new Promise((t,n)=>{if(!e.r()){n();return}document.readyState===`loading`?document.addEventListener(`readystatechange`,()=>t(),{once:!0}):t()})}function a(e,t){let n=new MutationObserver(r=>{document.contains(e)||(n.disconnect(),t())});n.observe(document.body,{childList:!0,subtree:!0})}var o=`picked-root`,s=`picked-target`,c=`picked-root`;function l(e,n){return[...e,{selector:`${c}[experience-id="${n}"]`,placement:`replace`}].flatMap(e=>{let r=t(e.selector).filter(e=>!f(e,n)&&!p(e,n));return{...e,elements:r}})}function u(e,t,n){return e.flatMap(e=>e.elements.map(r=>h(r,e.placement,t,n)))}function d(e,t){e.classList.add(s),e.classList.add(`${s}-${t}`)}function f(e,t){return t?e.classList.contains(`${s}-${t}`):e.classList.contains(`${s}`)}function p(e,t){return t?e.classList.contains(`${o}-${t}`):e.classList.contains(o)}function m(e,t){let n=document.createElement(`div`);return n.style.display=`block`,n.classList.add(o),n.classList.add(`${o}-${e}`),n.classList.add(`${o}-${t}`),n}function h(e,t,n,r){let i,a=m(n,r);if(e instanceof Document)i=e.body.appendChild(a);else{switch(t){case`replace`:e.replaceWith(a);break;case`before`:e.before(a);break;case`after`:e.after(a);break;case`prepend`:e.prepend(a);break;case`append`:e.append(a);break}i=a}return i}Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return u}});
@@ -0,0 +1,84 @@
1
+ import { d as e, l as t, r as n } from "./supports-0XIfd4-R.js";
2
+ //#region src/utils/dom.ts
3
+ function r(t) {
4
+ return !e() || !n() ? [] : Array.from(window.document.querySelectorAll(t)).filter((e) => e instanceof HTMLElement);
5
+ }
6
+ var i = "open";
7
+ function a(e) {
8
+ if (!t()) throw Error("Shadow DOM is not supported in this environment");
9
+ return e.attachShadow({ mode: i });
10
+ }
11
+ function o() {
12
+ return new Promise((e, t) => {
13
+ if (!n()) {
14
+ t();
15
+ return;
16
+ }
17
+ document.readyState === "loading" ? document.addEventListener("readystatechange", () => e(), { once: !0 }) : e();
18
+ });
19
+ }
20
+ function s(e, t) {
21
+ let n = new MutationObserver((r) => {
22
+ document.contains(e) || (n.disconnect(), t());
23
+ });
24
+ n.observe(document.body, {
25
+ childList: !0,
26
+ subtree: !0
27
+ });
28
+ }
29
+ var c = "picked-root", l = "picked-target", u = "picked-root";
30
+ function d(e, t) {
31
+ return [...e, {
32
+ selector: `${u}[experience-id="${t}"]`,
33
+ placement: "replace"
34
+ }].flatMap((e) => {
35
+ let n = r(e.selector).filter((e) => !m(e, t) && !h(e, t));
36
+ return {
37
+ ...e,
38
+ elements: n
39
+ };
40
+ });
41
+ }
42
+ function f(e, t, n) {
43
+ return e.flatMap((e) => e.elements.map((r) => _(r, e.placement, t, n)));
44
+ }
45
+ function p(e, t) {
46
+ e.classList.add(l), e.classList.add(`${l}-${t}`);
47
+ }
48
+ function m(e, t) {
49
+ return t ? e.classList.contains(`${l}-${t}`) : e.classList.contains(`${l}`);
50
+ }
51
+ function h(e, t) {
52
+ return t ? e.classList.contains(`${c}-${t}`) : e.classList.contains(c);
53
+ }
54
+ function g(e, t) {
55
+ let n = document.createElement("div");
56
+ return n.style.display = "block", n.classList.add(c), n.classList.add(`${c}-${e}`), n.classList.add(`${c}-${t}`), n;
57
+ }
58
+ function _(e, t, n, r) {
59
+ let i, a = g(n, r);
60
+ if (e instanceof Document) i = e.body.appendChild(a);
61
+ else {
62
+ switch (t) {
63
+ case "replace":
64
+ e.replaceWith(a);
65
+ break;
66
+ case "before":
67
+ e.before(a);
68
+ break;
69
+ case "after":
70
+ e.after(a);
71
+ break;
72
+ case "prepend":
73
+ e.prepend(a);
74
+ break;
75
+ case "append":
76
+ e.append(a);
77
+ break;
78
+ }
79
+ i = a;
80
+ }
81
+ return i;
82
+ }
83
+ //#endregion
84
+ export { h as a, d as i, a as n, s as o, o as r, p as s, f as t };
@@ -1,4 +1,4 @@
1
- import { t as e } from "../../rules-logic-BTIxfrJJ.js";
1
+ import { t as e } from "../../rules-logic-D_CVBuv7.js";
2
2
  import { attach as t, combine as n, createEffect as r, createEvent as i, createStore as a, sample as o, split as s } from "effector";
3
3
  //#region src/form/build-responses.ts
4
4
  function c(e, t, n) {
@@ -389,7 +389,32 @@ function y(e) {
389
389
  if (t instanceof HTMLInputElement) return t.type === "checkbox" ? t.checked : t.value;
390
390
  if (t instanceof HTMLSelectElement || t instanceof HTMLTextAreaElement) return t.value;
391
391
  }
392
- function b(e, t, r, i) {
392
+ function b(e, t, n) {
393
+ let r = e.currentTarget;
394
+ if (t.multiple) {
395
+ if (r instanceof HTMLInputElement && r.type === "checkbox") return x(e, r, n);
396
+ if (r instanceof HTMLSelectElement && r.multiple) return Array.from(r.selectedOptions, (e) => e.value);
397
+ }
398
+ return y(e);
399
+ }
400
+ function x(e, t, n) {
401
+ if (e.type === "input") return;
402
+ let r = Array.isArray(n) ? n.map(String) : [];
403
+ return e.type === "change" ? S(r, String(t.value)) : r;
404
+ }
405
+ function S(e, t) {
406
+ return e.includes(t) ? e.filter((e) => e !== t) : [...e, t];
407
+ }
408
+ function C(e, t, n) {
409
+ return (r) => {
410
+ let i = b(r, e, t);
411
+ i !== void 0 && n({
412
+ fieldKey: e.key,
413
+ value: i
414
+ });
415
+ };
416
+ }
417
+ function w(e, t, r, i) {
393
418
  let { client: s, experienceInstance: c } = e, { currentStepStore: l, goToNextStep: u } = c, d = n(l, c, (e, t) => ({
394
419
  stepId: e?.id,
395
420
  experienceId: t.id
@@ -404,49 +429,31 @@ function b(e, t, r, i) {
404
429
  },
405
430
  target: f
406
431
  });
407
- let { fieldInputEvent: h, fieldChangeEvent: _, fieldBlurEvent: b, touchedStore: x, fieldErrorsStore: S, formErrorsStore: C } = g(s, p, f), w = n({
432
+ let { fieldInputEvent: h, fieldChangeEvent: _, fieldBlurEvent: y, touchedStore: b, fieldErrorsStore: x, formErrorsStore: S } = g(s, p, f), w = n({
408
433
  fields: p,
409
434
  responses: s.responses.listStore,
410
435
  staged: f,
411
- fieldErrors: S,
412
- touched: x,
436
+ fieldErrors: x,
437
+ touched: b,
413
438
  experienceAndStepId: d
414
439
  }, ({ fields: e, responses: t, staged: n, fieldErrors: r, touched: i, experienceAndStepId: a }) => e.map((e) => {
415
- let o = (t) => {
416
- let n = y(t);
417
- n !== void 0 && h({
418
- fieldKey: e.key,
419
- value: n
420
- });
421
- }, s = (t) => {
422
- let n = y(t);
423
- n !== void 0 && _({
424
- fieldKey: e.key,
425
- value: n
426
- });
427
- }, c = (t) => {
428
- let n = y(t);
429
- n !== void 0 && b({
430
- fieldKey: e.key,
431
- value: n
432
- });
433
- }, l = n[e.key] ?? t.find((t) => t.fieldKey === e.key)?.value ?? e.defaultValue, u = r[e.key], d = e.type === "number" ? "number" : "text", f = e.type === "boolean" ? "checkbox" : d, { experienceId: p, stepId: m } = a, g = `${p}-${m ?? "step"}-${e.id}`;
440
+ let o = n[e.key] ?? t.find((t) => t.fieldKey === e.key)?.value ?? e.defaultValue, s = C(e, o, h), c = C(e, o, _), l = C(e, o, y), u = r[e.key], d = e.type === "number" ? "number" : "text", f = e.type === "boolean" ? "checkbox" : d, { experienceId: p, stepId: m } = a, g = `${p}-${m ?? "step"}-${e.id}`;
434
441
  return {
435
442
  ...e,
436
- value: l,
443
+ value: o,
437
444
  error: u,
438
445
  touched: i[e.key] ?? !1,
439
446
  props: {
440
447
  id: g,
441
448
  name: e.key,
442
449
  key: e.key,
443
- value: l,
450
+ value: o,
444
451
  type: f,
445
452
  required: e.required,
446
453
  placeholder: e.placeholder,
447
- oninput: o,
448
- onchange: s,
449
- onblur: c
454
+ oninput: s,
455
+ onchange: c,
456
+ onblur: l
450
457
  }
451
458
  };
452
459
  })), { submitEvent: T, isFormSubmitting: E, onBeforeSubmit: D, onSuccess: O, onError: k, submitStarted: A, validationErrorsReceived: j } = v({
@@ -461,20 +468,20 @@ function b(e, t, r, i) {
461
468
  return o({
462
469
  clock: A,
463
470
  fn: () => ({}),
464
- target: x
471
+ target: b
465
472
  }), o({
466
473
  clock: A,
467
474
  fn: () => ({}),
468
- target: S
475
+ target: x
469
476
  }), o({
470
477
  clock: j,
471
478
  source: p,
472
479
  fn: (e, t) => Object.fromEntries(t.map((t) => [e.find((e) => e.key === t.fieldKey)?.key ?? t.fieldKey, t])),
473
- target: S
480
+ target: x
474
481
  }), {
475
482
  form: {
476
483
  props: { onsubmit: T },
477
- errors: C,
484
+ errors: S,
478
485
  submitting: E,
479
486
  onBeforeSubmit: D,
480
487
  onSuccess: O,
@@ -484,4 +491,4 @@ function b(e, t, r, i) {
484
491
  };
485
492
  }
486
493
  //#endregion
487
- export { l as buildResponsesFromFormData, m as createFieldEvaluator, g as createFieldValidation, b as createForm, v as createSubmitPipeline, y as getEventValue, p as getStepFields };
494
+ export { l as buildResponsesFromFormData, m as createFieldEvaluator, g as createFieldValidation, w as createForm, v as createSubmitPipeline, y as getEventValue, p as getStepFields };