@picked/client 0.0.1-dev.1777614791290 → 0.0.1-dev.1777616114652
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/{api-PefU2fcg.cjs → api-BryLRI2Y.cjs} +1 -1
- package/dist/{api-mpZ1gccM.js → api-Dn57QBPm.js} +1 -1
- package/dist/cjs/form/index.js +1 -1
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/plugins/create-experience/index.js +1 -1
- package/dist/cjs/plugins/dom-observer/index.js +1 -0
- package/dist/cjs/plugins/dynamic-experiences/index.js +1 -1
- package/dist/cjs/plugins/experience-browser-storage/index.js +1 -1
- package/dist/cjs/plugins/history-browser-storage/index.js +1 -1
- package/dist/cjs/plugins/responses-browser-storage/index.js +1 -1
- package/dist/cjs/server/index.js +1 -1
- package/dist/esm/form/index.js +33 -40
- package/dist/esm/index.js +174 -298
- package/dist/esm/plugins/create-experience/index.js +1 -1
- package/dist/esm/plugins/dom-observer/index.js +81 -0
- package/dist/esm/plugins/dynamic-experiences/index.js +1 -1
- package/dist/esm/plugins/experience-browser-storage/index.js +1 -1
- package/dist/esm/plugins/history-browser-storage/index.js +1 -1
- package/dist/esm/plugins/responses-browser-storage/index.js +1 -1
- package/dist/esm/server/index.js +1 -1
- package/dist/experience-BhteyYBl.cjs +1 -0
- package/dist/experience-CoMdlvyn.js +136 -0
- package/dist/experience-instance-CZDcicPj.cjs +1 -0
- package/dist/experience-instance-IkIw31Cg.js +387 -0
- package/dist/nodes-ChVU1VZO.js +101 -0
- package/dist/nodes-DDDs-rC2.cjs +1 -0
- package/dist/types/entities/history/history.d.ts +3 -0
- package/dist/types/entities/history/history.d.ts.map +1 -1
- package/dist/types/form/create-form.d.ts +0 -55
- package/dist/types/form/create-form.d.ts.map +1 -1
- package/dist/types/picked.d.ts +3 -0
- package/dist/types/picked.d.ts.map +1 -1
- package/dist/types/plugins/dom-observer/index.d.ts +3 -0
- package/dist/types/plugins/dom-observer/index.d.ts.map +1 -0
- package/dist/types/plugins/dom-observer/plugin.d.ts +39 -0
- package/dist/types/plugins/dom-observer/plugin.d.ts.map +1 -0
- package/package.json +11 -1
- package/dist/experience-instance-DC2gKwA6.cjs +0 -1
- package/dist/experience-instance-DJaNc5Ob.js +0 -486
- /package/dist/{id-CRqy981z.js → id-B-N2zNbS.js} +0 -0
- /package/dist/{id-Bv44ilEo.cjs → id-Bbodazn8.cjs} +0 -0
- /package/dist/{storage-B6lQtc4-.cjs → storage-BXSlLTRa.cjs} +0 -0
- /package/dist/{storage-6Xk0uAxB.js → storage-hOHCCXvP.js} +0 -0
|
@@ -0,0 +1,101 @@
|
|
|
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
|
+
//#region src/utils/nodes.ts
|
|
85
|
+
function v(e) {
|
|
86
|
+
return e.type === "condition";
|
|
87
|
+
}
|
|
88
|
+
function y(e) {
|
|
89
|
+
return e.type === "step";
|
|
90
|
+
}
|
|
91
|
+
function b(e) {
|
|
92
|
+
return e.type === "experience";
|
|
93
|
+
}
|
|
94
|
+
function x(e) {
|
|
95
|
+
return e.type === "origin";
|
|
96
|
+
}
|
|
97
|
+
function S(e) {
|
|
98
|
+
return e.type === "action";
|
|
99
|
+
}
|
|
100
|
+
//#endregion
|
|
101
|
+
export { y as a, o as c, s as d, p as f, x as i, d as l, v as n, f as o, b as r, a as s, S as t, h as u };
|
|
@@ -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}function g(e){return e.type===`condition`}function _(e){return e.type===`step`}function v(e){return e.type===`experience`}function y(e){return e.type===`origin`}function b(e){return e.type===`action`}Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return _}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,`d`,{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,`f`,{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return v}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,`u`,{enumerable:!0,get:function(){return p}});
|
|
@@ -20,6 +20,9 @@ export declare function createHistory(): {
|
|
|
20
20
|
restore: import('effector').EventCallable<{
|
|
21
21
|
entries: HistoryEntry[];
|
|
22
22
|
}>;
|
|
23
|
+
clearForExperience: import('effector').EventCallable<{
|
|
24
|
+
experienceId: string;
|
|
25
|
+
}>;
|
|
23
26
|
entriesStore: import('effector').Store<HistoryEntry[]>;
|
|
24
27
|
};
|
|
25
28
|
//# sourceMappingURL=history.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../../../../src/entities/history/history.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../../../../src/entities/history/history.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAM9D,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,cAAc,CAAA;IACpB,EAAE,EAAE,MAAM,CAAA;IACV,YAAY,EAAE,MAAM,CAAA;CACrB;AAkGD,wBAAgB,aAAa;;sBAjFsB,MAAM;cAAQ,cAAc;;;sBACzB,MAAM;cAAQ,cAAc;;;uBAC9B,MAAM;;;iBACT,YAAY,EAAE;;;sBACE,MAAM;;;EA+EtE"}
|
|
@@ -69,61 +69,6 @@ export interface FormInstance<TFieldKeys extends string = string> {
|
|
|
69
69
|
* ```
|
|
70
70
|
*/
|
|
71
71
|
export declare function getEventValue(e: Event): FieldValue | undefined;
|
|
72
|
-
/**
|
|
73
|
-
* Extracts the staged value for a field from a form event. For a multi-value
|
|
74
|
-
* checkbox group, toggles the clicked option's value into or out of
|
|
75
|
-
* `currentValue` rather than reading the DOM — under React-controlled
|
|
76
|
-
* checkboxes, reconciliation reverts `el.checked` to match the prop before
|
|
77
|
-
* the change event fires, so any DOM-based read returns the pre-toggle
|
|
78
|
-
* state. For `<select multiple>`, reads `el.selectedOptions` (React does
|
|
79
|
-
* not race the change event there). Falls back to {@link getEventValue}
|
|
80
|
-
* for single-value fields and unrelated targets.
|
|
81
|
-
*
|
|
82
|
-
* For multi-checkbox events other than `change`: returns `undefined` for
|
|
83
|
-
* `input` so the caller skips dispatch (both `input` and `change` fire on a
|
|
84
|
-
* single click; only `change` should toggle, otherwise the toggle would run
|
|
85
|
-
* twice and cancel out). Returns `currentValue` (coerced to an array) for
|
|
86
|
-
* any non-change event so the caller can still dispatch — keeping
|
|
87
|
-
* touched-tracking and required-validation on `blur` working.
|
|
88
|
-
*
|
|
89
|
-
* Not re-exported from the form barrel; intended for use by the form's own
|
|
90
|
-
* field handlers and for direct unit testing.
|
|
91
|
-
*
|
|
92
|
-
* @param {Event} e - The DOM event from a form input.
|
|
93
|
-
* @param {Field} field - The field whose handler received the event.
|
|
94
|
-
* @param {FieldValue | undefined} currentValue - The field's currently staged or committed value.
|
|
95
|
-
* @returns {FieldValue | undefined} The value to stage, or undefined if the caller should skip dispatch.
|
|
96
|
-
* @example
|
|
97
|
-
* ```ts
|
|
98
|
-
* input.addEventListener('change', (e) => {
|
|
99
|
-
* const value = getStagedEventValue(e, field, field.value)
|
|
100
|
-
* })
|
|
101
|
-
* ```
|
|
102
|
-
*/
|
|
103
|
-
export declare function getStagedEventValue(e: Event, field: Field, currentValue: FieldValue | undefined): FieldValue | undefined;
|
|
104
|
-
/**
|
|
105
|
-
* Builds a DOM event handler that derives the next staged value via
|
|
106
|
-
* {@link getStagedEventValue} and dispatches the given event-callable when
|
|
107
|
-
* the helper returns a defined value. Skips dispatch if the helper returns
|
|
108
|
-
* undefined (e.g. `input` events on multi-select checkboxes, where dispatch
|
|
109
|
-
* is owned by the change event to avoid double-toggling).
|
|
110
|
-
*
|
|
111
|
-
* Not re-exported from the form barrel; intended for use by `createForm`
|
|
112
|
-
* and for direct unit testing.
|
|
113
|
-
*
|
|
114
|
-
* @param {Field} field - The field bound to the handler.
|
|
115
|
-
* @param {FieldValue | undefined} value - The field's currently staged or committed value.
|
|
116
|
-
* @param {EventCallable<{ fieldKey: string; value: FieldValue }>} dispatch - The event-callable to fire when the helper returns a value.
|
|
117
|
-
* @returns {(e: Event) => void} The handler to attach to a DOM event.
|
|
118
|
-
* @example
|
|
119
|
-
* ```ts
|
|
120
|
-
* const onChange = createFieldHandler(field, value, fieldChangeEvent)
|
|
121
|
-
* ```
|
|
122
|
-
*/
|
|
123
|
-
export declare function createFieldHandler(field: Field, value: FieldValue | undefined, dispatch: EventCallable<{
|
|
124
|
-
fieldKey: string;
|
|
125
|
-
value: FieldValue;
|
|
126
|
-
}>): (e: Event) => void;
|
|
127
72
|
/**
|
|
128
73
|
* Creates a form instance tied to a set of field keys.
|
|
129
74
|
* Handles field evaluation, form submission, data transformation,
|
|
@@ -1 +1 @@
|
|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ChC,iEAAiE;QACjE,UAAU,EAAE,KAAK,CAAC,OAAO,CAAC,CAAA;QAC1B,4FAA4F;QAC5F,cAAc,EAAE,CAAC,QAAQ,EAAE,cAAc,CAAC,UAAU,CAAC,KAAK,MAAM,IAAI,CAAA;QACpE,oFAAoF;QACpF,SAAS,EAAE,CAAC,QAAQ,EAAE,eAAe,CAAC,UAAU,CAAC,KAAK,MAAM,IAAI,CAAA;QAChE,gFAAgF;QAChF,OAAO,EAAE,CAAC,QAAQ,EAAE,aAAa,KAAK,MAAM,IAAI,CAAA;KACjD,CAAA;IACD,+FAA+F;IAC/F,MAAM,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC,CAAA;CAC3B;AAED;;;;;;;;;;;GAWG;AAEH,wBAAgB,aAAa,CAAC,CAAC,EAAE,KAAK,GAAG,UAAU,GAAG,SAAS,CAW9D;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,UAAU,CACxB,IAAI,EAAE,cAAc,EACpB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,EACpB,SAAS,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,GACzB,YAAY,CAoLd"}
|
package/dist/types/picked.d.ts
CHANGED
|
@@ -46,6 +46,9 @@ export declare class Picked {
|
|
|
46
46
|
restore: import('effector').EventCallable<{
|
|
47
47
|
entries: import('.').HistoryEntry[];
|
|
48
48
|
}>;
|
|
49
|
+
clearForExperience: import('effector').EventCallable<{
|
|
50
|
+
experienceId: string;
|
|
51
|
+
}>;
|
|
49
52
|
entriesStore: import('effector').Store<import('.').HistoryEntry[]>;
|
|
50
53
|
};
|
|
51
54
|
readonly components: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"picked.d.ts","sourceRoot":"","sources":["../../src/picked.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,UAAU,EAEf,KAAK,uBAAuB,EAC7B,MAAM,kCAAkC,CAAA;AACzC,OA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,CAEf;IAED;;;;;;;;OAQG;IAEH,kBAAkB,GAAU,cAAc,MAAM,KAAG,OAAO,CAAC,IAAI,CAAC,CAE/D;IAED;;;;;;;;OAQG;IAEH,mBAAmB,GAAU,eAAe,MAAM,KAAG,OAAO,CAAC,IAAI,CAAC,CAEjE;YAEa,mBAAmB;YAMnB,YAAY;IAc1B,OAAO,CAAC,YAAY;IA6BpB,OAAO,CAAC,aAAa;IA8CrB,OAAO,CAAC,eAAe;IAgBvB,OAAO,CAAC,YAAY;IAgBpB,OAAO,CAAC,eAAe;IAWvB,eAAe,GAAI,YAAY,MAAM,KAAG,iBAAiB,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAE1F;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAsCG;IACH,YAAY,GAAI,UAAU,MAAM,EAAE,UAAU,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAG,MAAM,CAY3E;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/dom-observer/index.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Plugin } from '../../entities/plugin/plugin';
|
|
2
|
+
/**
|
|
3
|
+
* Watches the document for added nodes that match an experience target
|
|
4
|
+
* selector, and re-runs `initialiseExperiences` when one appears.
|
|
5
|
+
*
|
|
6
|
+
* Decouples DOM-driven reconciliation from route detection so that any
|
|
7
|
+
* DOM addition bringing a target into existence — SPA navigations, lazy
|
|
8
|
+
* mounts, framework hydration, modal opens, infinite scroll — spawns the
|
|
9
|
+
* experience without the consumer wiring a router-specific hook.
|
|
10
|
+
*
|
|
11
|
+
* Installs a single `MutationObserver` on `document.body` with
|
|
12
|
+
* `{ childList: true, subtree: true }`. Each matching batch schedules a
|
|
13
|
+
* coalesced reconcile on the next animation frame; further mutations
|
|
14
|
+
* during that frame collapse into the same call. A trailing call is
|
|
15
|
+
* scheduled if mutations arrive while reconciliation is in flight. The
|
|
16
|
+
* selector set is rebuilt whenever `client.experiences.listStore` changes
|
|
17
|
+
* or any registered experience's `configStore` updates, so newly
|
|
18
|
+
* registered experiences and re-merged target selectors both extend the
|
|
19
|
+
* watch list without restarting the observer.
|
|
20
|
+
*
|
|
21
|
+
* Before each reconcile, history is cleared for any experience whose
|
|
22
|
+
* instance was previously observed alive but is no longer present,
|
|
23
|
+
* preventing a re-spawn from inheriting a stale `currentNode`. Cold
|
|
24
|
+
* inits with restored history left by `historyBrowserStoragePlugin` are
|
|
25
|
+
* left untouched because no prior instance has been observed.
|
|
26
|
+
*
|
|
27
|
+
* No-ops outside browser environments and on partial-DOM runtimes that
|
|
28
|
+
* lack `MutationObserver`, `requestAnimationFrame`, or `document.body`.
|
|
29
|
+
*
|
|
30
|
+
* @returns {Plugin} The plugin.
|
|
31
|
+
* @example
|
|
32
|
+
* ```typescript
|
|
33
|
+
* createClient({
|
|
34
|
+
* plugins: [domObserverPlugin()]
|
|
35
|
+
* })
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export declare const domObserverPlugin: () => Plugin;
|
|
39
|
+
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../src/plugins/dom-observer/plugin.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAA;AAK1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,eAAO,MAAM,iBAAiB,QAAO,MAiBpC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@picked/client",
|
|
3
|
-
"version": "0.0.1-dev.
|
|
3
|
+
"version": "0.0.1-dev.1777616114652",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"@withease/factories": "^1.0.5"
|
|
6
6
|
},
|
|
@@ -89,6 +89,12 @@
|
|
|
89
89
|
"require": "./dist/cjs/plugins/dynamic-experiences/index.js",
|
|
90
90
|
"default": "./dist/esm/plugins/dynamic-experiences/index.js"
|
|
91
91
|
},
|
|
92
|
+
"./plugins/dom-observer": {
|
|
93
|
+
"types": "./dist/types/plugins/dom-observer/index.d.ts",
|
|
94
|
+
"import": "./dist/esm/plugins/dom-observer/index.js",
|
|
95
|
+
"require": "./dist/cjs/plugins/dom-observer/index.js",
|
|
96
|
+
"default": "./dist/esm/plugins/dom-observer/index.js"
|
|
97
|
+
},
|
|
92
98
|
"./form": {
|
|
93
99
|
"types": "./dist/types/form/index.d.ts",
|
|
94
100
|
"import": "./dist/esm/form/index.js",
|
|
@@ -198,6 +204,10 @@
|
|
|
198
204
|
"path": "dist/esm/plugins/web-components/index.js",
|
|
199
205
|
"limit": "10 kB"
|
|
200
206
|
},
|
|
207
|
+
{
|
|
208
|
+
"path": "dist/esm/plugins/dom-observer/index.js",
|
|
209
|
+
"limit": "5 kB"
|
|
210
|
+
},
|
|
201
211
|
{
|
|
202
212
|
"path": "dist/esm/form/index.js",
|
|
203
213
|
"limit": "5 kB"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const e=require(`./rules-logic-DNLOv90w.cjs`);require(`./logger-fbvQC40v.cjs`);const t=require(`./supports-Dsjg-82e.cjs`);let n=require(`effector`),r=require(`@withease/factories`);function i(e){return!t.d()||!t.r()?[]:Array.from(window.document.querySelectorAll(e)).filter(e=>e instanceof HTMLElement)}var a=`open`;function o(e){if(!t.l())throw Error(`Shadow DOM is not supported in this environment`);return e.attachShadow({mode:a})}function s(){return new Promise((e,n)=>{if(!t.r()){n();return}document.readyState===`loading`?document.addEventListener(`readystatechange`,()=>e(),{once:!0}):e()})}function c(e,t){let n=new MutationObserver(r=>{document.contains(e)||(n.disconnect(),t())});n.observe(document.body,{childList:!0,subtree:!0})}var l=`picked-root`,u=`picked-target`,d=`picked-root`;function f(e,t){return[...e,{selector:`${d}[experience-id="${t}"]`,placement:`replace`}].flatMap(e=>{let n=i(e.selector).filter(e=>!h(e,t)&&!g(e,t));return{...e,elements:n}})}function p(e,t,n){return e.flatMap(e=>e.elements.map(r=>v(r,e.placement,t,n)))}function m(e,t){e.classList.add(u),e.classList.add(`${u}-${t}`)}function h(e,t){return t?e.classList.contains(`${u}-${t}`):e.classList.contains(`${u}`)}function g(e,t){return t?e.classList.contains(`${l}-${t}`):e.classList.contains(l)}function _(e,t){let n=document.createElement(`div`);return n.style.display=`block`,n.classList.add(l),n.classList.add(`${l}-${e}`),n.classList.add(`${l}-${t}`),n}function v(e,t,n,r){let i,a=_(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}function y(e){return e.type===`condition`}function b(e){return e.type===`step`}function x(e){return e.type===`experience`}function S(e){return e.type===`origin`}function C(e){return e.type===`action`}var w=(e,t,n,r,i=new Set)=>i.has(n.id)?[]:(i.add(n.id),b(n)&&!r?[n]:t.filter(e=>e.sourceNodeId===n.id).flatMap(n=>{let r=e.find(e=>e.id===n.destinationNodeId);return r?w(e,t,r,!1,i):[]})),T=(e,t,n)=>w(e,t,n,!0,new Set),E=(e,t,n,r,i=new Set)=>{if(i.has(n.id))return[-1,-1];i.add(n.id);let a=t.filter(e=>e.sourceNodeId===n.id);if(a.length===0)return[0,0];let o=1/0,s=-1/0;for(let n of a){let r=e.find(e=>e.id===n.destinationNodeId);if(!r)continue;let[a,c]=E(e,t,r,!1,new Set(i));a!==-1&&(o=Math.min(o,a+1),s=Math.max(s,c+1))}return o===1/0?[-1,-1]:[o,s]},D=(e,t,n)=>E(e,t,n,!0,new Set),O=(e,t,n,r=new Set)=>{if(r.has(n.id))return[-1,-1];if(r.add(n.id),n.type===`origin`)return[0,0];let i=t.filter(e=>e.destinationNodeId===n.id);if(i.length===0)return[-1,-1];let a=1/0,o=-1/0;for(let n of i){let i=e.find(e=>e.id===n.sourceNodeId);if(!i)continue;let[s,c]=O(e,t,i,new Set(r));s!==-1&&(a=Math.min(a,s+1),o=Math.max(o,c+1))}return a===1/0?[-1,-1]:[a,o]},k=(e,t,n)=>O(e,t,n,new Set),A=e=>e.find(e=>e.type===`origin`)||null,j=(e,t,n)=>{if(!e)return A(t);let r=n.find(t=>t.sourceNodeId===e.id);return r&&t.find(e=>e.id===r.destinationNodeId)||null};async function M(e,t,n,r){let i=e?`true`:`false`,a=r.find(e=>e.sourceHandle===i&&e.sourceNodeId===t);return n.find(e=>e.id===a?.destinationNodeId)}var N=(0,n.createDomain)(`experience-instance`),P=(0,r.createFactory)(({client:t,experience:r,target:i,options:a})=>{let o=(0,n.createEvent)(),s=(0,n.createEvent)(),c=(0,n.createEvent)(),l=(0,n.createEvent)(),u=(0,n.createEvent)(),d=(0,n.createEvent)(),f=r.componentStore,p=N.store(`transitioning`),m=t.history.entriesStore.map(e=>e.filter(e=>e.experienceId===r.id)),h=m.map(e=>e.filter(e=>b(e.node))),g=m.map(e=>e.at(-1)?.node||null),_=(0,n.combine)(t.steps.listStore,g,(e,t)=>e.find(e=>t&&b(t)&&e.id===t.stepId)||null),v=(0,n.combine)(t.steps.listStore,h,(e,t)=>{let n=t.at(-2);if(!n||!b(n.node))return null;let r=n.node;return e.find(e=>e.id===r.stepId)||null}),w=(0,n.combine)(r.treeStore,g,({nodes:e,edges:t},n)=>n?T(e,t,n):[]),E=(0,n.combine)(r.treeStore,g,({nodes:e,edges:t},n)=>n?k(e,t,n):[-1,-1]),O=(0,n.combine)(r.treeStore,g,({nodes:e,edges:t},n)=>n?D(e,t,n):[-1,-1]),P=N.store(!1),F=(0,n.createApi)(P,{open:()=>!0,close:()=>!1,toggle:e=>!e,set:(e,t)=>t}),I=(0,n.createEffect)(async()=>{t.history.back({experienceId:r.id})}),L=(0,n.attach)({source:r.treeStore,effect:async(e,n)=>{let i=e.nodes.find(e=>b(e)&&e.stepId===n);i&&t.history.push({experienceId:r.id,node:i})}}),R=(0,n.attach)({source:g,effect:e=>{}}),z=(0,n.attach)({source:r.treeStore,effect:async({nodes:e})=>A(e)}),B=(0,n.attach)({source:r.treeStore,effect:async({nodes:e,edges:t},n)=>{if(S(n))return j(n,e,t)}}),V=(0,n.attach)({source:r.treeStore,effect:async({nodes:n,edges:r,conditions:i},a)=>{if(!y(a))return;let o=i.find(e=>e.id===a.conditionId)?.logic;return o?M(!!await e.t(t,o),a.id,n,r):void 0}}),H=(0,n.attach)({source:r.treeStore,effect:async({nodes:e,edges:n},r)=>{if(!C(r))return;let i=r.actionKey;if(!i){`${r.id}`;return}let a=t.actions.getByKey(i).getState();if(!a){`${i}`;let t=n.find(e=>e.sourceNodeId===r.id&&e.sourceHandle===`false`);return t?e.find(e=>e.id===t.destinationNodeId):null}if(typeof a!=`function`){`${i}`;let t=n.find(e=>e.sourceNodeId===r.id&&e.sourceHandle===`false`);return t?e.find(e=>e.id===t.destinationNodeId):null}try{`${i}`,await a({...t.getStateSnapshot(),args:[]},{experience:J});let o=n.find(e=>e.sourceNodeId===r.id&&e.sourceHandle===`true`);if(!o)return`${r.id}`,null;let s=e.find(e=>e.id===o.destinationNodeId);return`${i}${s?.id}`,s||null}catch{`${i}`;let t=n.find(e=>e.sourceNodeId===r.id&&e.sourceHandle===`false`);if(!t)return`${r.id}`,null;let a=e.find(e=>e.id===t.destinationNodeId);return`${i}${a?.id}`,a||null}}}),U=(0,n.createEffect)(e=>{x(e)&&t.experiences.launch({key:e.experienceKey})}),W=(0,n.attach)({source:[g,r.treeStore],effect:async([e,{nodes:t,edges:n}])=>j(e,t,n)}),G=(0,n.attach)({source:[g,r.treeStore],effect:async([e,{nodes:t,edges:n}])=>j(e,t,n)}),K=(0,n.createEffect)(e=>{t.history.push({experienceId:r.id,node:e})}),q=(0,n.attach)({source:r.configStore,effect:async({initializeOpenLogic:n})=>a?.initialiseOpen===void 0?e.n(n)?!!await e.t(t,n):n??!1:a.initialiseOpen}),J=Object.freeze({id:Math.random().toString(36).substring(7),experienceKey:r.key,experienceId:r.id,configStore:r.configStore,target:i,componentStore:f,stateStore:p,isOpenStore:P,open:F.open,close:F.close,toggleOpen:F.toggle,setOpen:F.set,treeStore:r.treeStore,currentNodeStore:g,currentStepStore:_,previousStepStore:v,nextReachableStepNodesStore:w,stepsToOriginStore:E,stepsToLeafStore:O,goToNextStep:s,goToPreviousStep:c,goToStepById:l,stepsHistoryStore:h}),Y=(0,n.createEvent)(),X=(0,n.createEvent)();return(0,n.sample)({clock:g,target:Y}),(0,n.sample)({clock:Y,filter:e=>e===null,target:z}),(0,n.sample)({clock:Y,filter:e=>e!==null,target:X}),(0,n.split)({source:X,match:e=>y(e)?`condition`:b(e)?`step`:x(e)?`launchExperience`:S(e)?`origin`:C(e)?`action`:`other`,cases:{origin:B,condition:V,step:R,launchExperience:U,action:H,__:(0,n.createEvent)()}}),(0,n.sample)({clock:[V.doneData,B.doneData,z.doneData,G.doneData,W.doneData,H.doneData],filter:Boolean,target:K}),(0,n.sample)({clock:s,target:G}),(0,n.sample)({clock:s,source:_,filter:Boolean,target:t.eventBus.prepend(e=>({type:`step_submit`,step:e,experience:J}))}),(0,n.sample)({clock:G.done,source:_,filter:Boolean,target:t.eventBus.prepend(e=>({type:`step_submit_success`,step:e,experience:J}))}),(0,n.sample)({clock:G.fail,source:_,filter:Boolean,target:t.eventBus.prepend(e=>({type:`step_submit_error`,step:e,experience:J}))}),(0,n.sample)({clock:c,target:I}),(0,n.sample)({clock:l,target:L}),(0,n.sample)({source:(0,n.combine)([V.pending,B.pending,z.pending,G.pending]),fn:e=>e.some(Boolean)?`transitioning`:`ready`,target:p}),(0,n.sample)({clock:R.doneData,source:_,filter:Boolean,target:t.eventBus.prepend(e=>({type:`step_enter`,step:e,experience:J}))}),(0,n.sample)({clock:d,target:q}),(0,n.sample)({source:q.doneData,fn:Boolean,target:P}),(0,n.sample)({source:g,clock:o,filter:e=>e?S(e):!0,target:W}),(0,n.sample)({source:P,filter:Boolean,target:o}),(0,n.sample)({source:P,filter:Boolean,target:t.eventBus.prepend(()=>({type:`experience_open`,experience:J}))}),(0,n.sample)({source:P,filter:e=>!e,target:t.eventBus.prepend(()=>({type:`experience_close`,experience:J}))}),(0,n.sample)({clock:u,target:[d]}),u(),J});function F(e){return(0,r.invoke)(P,e)}var I=(0,r.createFactory)(({client:e})=>{let t=N.store({}),r=(0,n.createEvent)(),i=(0,n.createEvent)(),a=(0,n.createEvent)(),s=(0,n.createApi)(t,{register(e,t){let n=[...e[t.experienceId]??[]];return n.push(t),{...e,[t.experienceId]:n}},unregister(e,t){let n=t.experienceId,r=e[n]?.filter(e=>e!==t);return{...e,[n]:r??[]}}}),l=(0,n.createEffect)(({experience:t,target:n,options:r})=>F({client:e,experience:t,target:n,options:r})),u=(0,n.createEffect)(e=>{s.register(e)}),d=(0,n.createEffect)(e=>{e.target&&c(e.target,()=>{a(e)})}),f=(0,n.createEffect)(e=>{s.unregister(e)}),p=(0,n.createEffect)(t=>{let n=t.componentStore.getState();if(!n)return;let r=n.frameworkStore.getState();if(!r){`${n.name}`;return}let i=t.target;if(!i){`${t.experienceId}`;return}let a=o(i);try{r.render(a,n.component,e,t)}catch{}});(0,n.sample)({clock:r,target:l}),(0,n.sample)({clock:a,target:f}),(0,n.sample)({clock:l.doneData,target:[u,d,i]}),(0,n.sample)({clock:l.doneData,target:e.eventBus.prepend(e=>({type:`experience_initialize`,experience:e}))}),(0,n.sample)({clock:i,target:p});function m(e,t,n){r({experience:e,target:t,options:n})}let h=t.map(e=>Object.values(e).flat());function g(e){return h.map(t=>t.filter(t=>t.experienceKey===e),{skipVoid:!1})}function _(e){return t.map(t=>t[e]||[],{skipVoid:!1})}return{spawn:m,getByExperienceKey:g,getByExperienceId:_,listStore:h}});function L(e){return(0,r.invoke)(I,e)}Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return L}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return F}});
|