@ea-lab/reactive-json 1.4.0 → 2.0.0
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/component/action/CustomEventListener.js +3 -2
- package/dist/component/action/ReactOnEvent.js +6 -5
- package/dist/component/attributeTransformer/setAttributeValue.js +20 -19
- package/dist/component/attributeTransformer/toggleAttributeValue.js +15 -14
- package/dist/component/attributeTransformer/unsetAttributeValue.js +8 -7
- package/dist/component/element/debug/VariablesDebug/VariablesDebug.js +74 -60
- package/dist/component/element/html/LabelFromValue.js +30 -18
- package/dist/component/element/index.js +28 -26
- package/dist/component/element/special/DataFilter.js +49 -40
- package/dist/component/element/special/DataSync.js +94 -0
- package/dist/component/element/special/index.js +15 -13
- package/dist/component/index.js +57 -55
- package/dist/component/reaction/fetchData.js +1 -1
- package/dist/component/reaction/index.js +1 -1
- package/dist/component/reaction/submitData.js +1 -1
- package/dist/component/reaction/utility/httpRequestCommon.js +118 -5
- package/dist/component/reaction/utility/index.js +1 -1
- package/dist/engine/DataStore.js +120 -0
- package/dist/engine/ReactiveJsonRoot.js +218 -277
- package/dist/engine/StoreContext.js +17 -0
- package/dist/engine/View.js +94 -58
- package/dist/engine/hook/useReactiveData.js +9 -0
- package/dist/engine/index.js +53 -45
- package/dist/engine/utility/formElementsCommon.js +36 -23
- package/dist/{httpRequestCommon-C7MsJIKA.js → index-BUPRVmV-.js} +616 -733
- package/dist/index-DJuOXIM5.js +25 -0
- package/dist/main.js +156 -146
- package/package.json +1 -1
- package/dist/index-Ya6_R5yr.js +0 -23
|
@@ -1,30 +1,37 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useContext as
|
|
3
|
-
import { isValid as
|
|
4
|
-
import { GlobalDataContext as
|
|
5
|
-
import { TemplateContext as
|
|
6
|
-
import { View as
|
|
7
|
-
const
|
|
8
|
-
var
|
|
9
|
-
const
|
|
10
|
-
|
|
1
|
+
import { jsx as l } from "react/jsx-runtime";
|
|
2
|
+
import { useContext as D, useReducer as A, useEffect as T } from "react";
|
|
3
|
+
import { isValid as W } from "../../../engine/Actions.js";
|
|
4
|
+
import { GlobalDataContext as v } from "../../../engine/GlobalDataContext.js";
|
|
5
|
+
import { TemplateContext as w } from "../../../engine/TemplateContext.js";
|
|
6
|
+
import { View as y } from "../../../engine/View.js";
|
|
7
|
+
const k = (t) => {
|
|
8
|
+
var d, b;
|
|
9
|
+
const e = D(v), n = D(w), r = { globalDataContext: e, templateContext: n }, [, u] = A((o) => o + 1, 0), f = e == null ? void 0 : e.store, { contextToFilter: m = "global", filters: C = [] } = t.props;
|
|
10
|
+
T(() => {
|
|
11
|
+
if (f) {
|
|
12
|
+
const o = m === "global" ? "" : n.templatePath, s = ((i) => !i || i === "data" ? "" : i.startsWith("data.") ? i.substring(5) : i)(o);
|
|
13
|
+
return f.subscribe(s, () => u());
|
|
14
|
+
}
|
|
15
|
+
}, [f, m, n.templatePath]);
|
|
16
|
+
const h = (o) => {
|
|
17
|
+
if (!o)
|
|
11
18
|
return !0;
|
|
12
|
-
for (const
|
|
13
|
-
const
|
|
14
|
-
if (!
|
|
19
|
+
for (const a of C) {
|
|
20
|
+
const s = (a == null ? void 0 : a.subjectsWithProperty) ?? void 0;
|
|
21
|
+
if (!s || !o.hasOwnProperty(s))
|
|
15
22
|
continue;
|
|
16
|
-
if (!
|
|
23
|
+
if (!W(a, r, /* @__PURE__ */ new Map([
|
|
17
24
|
[
|
|
18
25
|
"whenFilterableData",
|
|
19
|
-
({ condition:
|
|
20
|
-
const
|
|
21
|
-
let
|
|
22
|
-
for (const
|
|
23
|
-
const
|
|
24
|
-
if (
|
|
26
|
+
({ condition: j }) => {
|
|
27
|
+
const F = j.whenFilterableData.split(".");
|
|
28
|
+
let c = o;
|
|
29
|
+
for (const P of F) {
|
|
30
|
+
const x = parseInt(P);
|
|
31
|
+
if (c = c[isNaN(x) ? P : x], c === void 0)
|
|
25
32
|
return;
|
|
26
33
|
}
|
|
27
|
-
return
|
|
34
|
+
return c;
|
|
28
35
|
}
|
|
29
36
|
]
|
|
30
37
|
])))
|
|
@@ -32,47 +39,49 @@ const W = (t) => {
|
|
|
32
39
|
}
|
|
33
40
|
return !0;
|
|
34
41
|
};
|
|
35
|
-
switch (
|
|
42
|
+
switch (m) {
|
|
36
43
|
case "template":
|
|
37
|
-
|
|
38
|
-
|
|
44
|
+
const o = { ...n };
|
|
45
|
+
return o.templateData = p(n.templateData, h), o.templatePath = t.path, /* @__PURE__ */ l(w.Provider, { value: o, children: /* @__PURE__ */ l(
|
|
46
|
+
y,
|
|
39
47
|
{
|
|
40
48
|
props: t.props.content,
|
|
41
49
|
path: t.path + ".content",
|
|
42
50
|
datafield: "content",
|
|
43
|
-
currentData: ((
|
|
51
|
+
currentData: ((d = t.currentData) == null ? void 0 : d.content) ?? void 0
|
|
44
52
|
}
|
|
45
53
|
) });
|
|
46
54
|
case "global":
|
|
47
55
|
default:
|
|
48
|
-
|
|
49
|
-
|
|
56
|
+
const a = { ...e };
|
|
57
|
+
return a.templateData = p(e.templateData, h), /* @__PURE__ */ l(v.Provider, { value: a, children: /* @__PURE__ */ l(
|
|
58
|
+
y,
|
|
50
59
|
{
|
|
51
60
|
props: t.props.content,
|
|
52
61
|
path: t.path + ".content",
|
|
53
62
|
datafield: "content",
|
|
54
|
-
currentData: ((
|
|
63
|
+
currentData: ((b = t.currentData) == null ? void 0 : b.content) ?? void 0
|
|
55
64
|
}
|
|
56
65
|
) });
|
|
57
66
|
}
|
|
58
|
-
},
|
|
67
|
+
}, p = (t, e) => {
|
|
59
68
|
if (Array.isArray(t)) {
|
|
60
|
-
const
|
|
61
|
-
return t.forEach((
|
|
62
|
-
|
|
63
|
-
}),
|
|
69
|
+
const n = {};
|
|
70
|
+
return t.forEach((r, u) => {
|
|
71
|
+
e(r) && (n[u] = p(r, e));
|
|
72
|
+
}), n;
|
|
64
73
|
} else if (typeof t == "object" && t !== null) {
|
|
65
|
-
const
|
|
66
|
-
for (const
|
|
67
|
-
if (t.hasOwnProperty(
|
|
68
|
-
if (!
|
|
74
|
+
const n = {};
|
|
75
|
+
for (const r in t)
|
|
76
|
+
if (t.hasOwnProperty(r)) {
|
|
77
|
+
if (!e(t[r]))
|
|
69
78
|
continue;
|
|
70
|
-
|
|
79
|
+
n[r] = p(t[r], e);
|
|
71
80
|
}
|
|
72
|
-
return
|
|
81
|
+
return n;
|
|
73
82
|
} else
|
|
74
83
|
return t;
|
|
75
84
|
};
|
|
76
85
|
export {
|
|
77
|
-
|
|
86
|
+
k as DataFilter
|
|
78
87
|
};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { jsx as k } from "react/jsx-runtime";
|
|
2
|
+
import { useContext as T, useRef as m, useCallback as q, useEffect as v } from "react";
|
|
3
|
+
import { ActionDependant as A } from "../../../engine/Actions.js";
|
|
4
|
+
import { GlobalDataContext as $ } from "../../../engine/GlobalDataContext.js";
|
|
5
|
+
import { useStore as G } from "../../../engine/StoreContext.js";
|
|
6
|
+
import { TemplateContext as M } from "../../../engine/TemplateContext.js";
|
|
7
|
+
import { dataLocationToPath as C } from "../../../engine/TemplateSystem.js";
|
|
8
|
+
import { a as N } from "../../../index-BUPRVmV-.js";
|
|
9
|
+
import { l as E } from "../../../lodash-CYNxjS-I.js";
|
|
10
|
+
const I = (t) => t === "data" ? "" : t && t.startsWith("data.") ? t.substring(5) : t, X = ({ props: t }) => {
|
|
11
|
+
const S = T($), d = T(M), e = G(), h = m(void 0), g = m(null), a = m(null), c = m(null), p = m(!1), u = m(0), D = t.mode || "onIdle", R = t.idleDelay || 1e3, b = t.maxRetries ?? 0, L = t.retryDelay ?? 5e3;
|
|
12
|
+
let o = null;
|
|
13
|
+
try {
|
|
14
|
+
o = I(C({
|
|
15
|
+
dataLocation: t.path,
|
|
16
|
+
currentPath: d.templatePath,
|
|
17
|
+
globalDataContext: S,
|
|
18
|
+
templateContext: d
|
|
19
|
+
}));
|
|
20
|
+
} catch (r) {
|
|
21
|
+
console.error("DataSync: Invalid path", t.path, r);
|
|
22
|
+
}
|
|
23
|
+
let i = null;
|
|
24
|
+
if (t.trigger)
|
|
25
|
+
try {
|
|
26
|
+
i = I(C({
|
|
27
|
+
dataLocation: t.trigger,
|
|
28
|
+
currentPath: d.templatePath,
|
|
29
|
+
globalDataContext: S,
|
|
30
|
+
templateContext: d
|
|
31
|
+
}));
|
|
32
|
+
} catch (r) {
|
|
33
|
+
console.error("DataSync: Invalid trigger path", t.trigger, r);
|
|
34
|
+
}
|
|
35
|
+
const l = q(async (r) => {
|
|
36
|
+
var f, s;
|
|
37
|
+
if (!r || !r.submission_url) {
|
|
38
|
+
r && console.warn("DataSync: Missing submission_url in data object", r);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
if (!p.current && !(u.current > b)) {
|
|
42
|
+
p.current = !0, u.current++, h.current = r.data, e.set(`${o}.status`, {
|
|
43
|
+
type: "info",
|
|
44
|
+
message: "Synchronisation en cours..."
|
|
45
|
+
});
|
|
46
|
+
try {
|
|
47
|
+
const { submission_url: n } = r, y = (await N.post(n, r)).data;
|
|
48
|
+
g.current = y, u.current = 0, e.set(o, y);
|
|
49
|
+
} catch (n) {
|
|
50
|
+
console.error("DataSync error:", n);
|
|
51
|
+
const x = {
|
|
52
|
+
type: "error",
|
|
53
|
+
message: ((s = (f = n.response) == null ? void 0 : f.data) == null ? void 0 : s.message) || n.message || "Erreur inconnue"
|
|
54
|
+
};
|
|
55
|
+
e.set(`${o}.status`, x);
|
|
56
|
+
const y = n.response && n.response.status >= 500, P = !n.response && typeof navigator < "u" && !navigator.onLine;
|
|
57
|
+
(y || P) && u.current <= b && (c.current = setTimeout(() => {
|
|
58
|
+
const _ = e.get(o);
|
|
59
|
+
l(_);
|
|
60
|
+
}, L));
|
|
61
|
+
} finally {
|
|
62
|
+
p.current = !1;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}, [e, o, b]);
|
|
66
|
+
return v(() => {
|
|
67
|
+
if (!e || o === null) return;
|
|
68
|
+
const r = () => {
|
|
69
|
+
const s = e.get(o);
|
|
70
|
+
if (!s || s === g.current)
|
|
71
|
+
return;
|
|
72
|
+
const n = s.data;
|
|
73
|
+
h.current !== void 0 && E.isEqual(n, h.current) || g.current && E.isEqual(n, g.current.data) || (u.current = 0, c.current && (clearTimeout(c.current), c.current = null), D === "immediate" ? l(s) : D === "onIdle" && (a.current && clearTimeout(a.current), a.current = setTimeout(() => {
|
|
74
|
+
l(s);
|
|
75
|
+
}, R)));
|
|
76
|
+
}, f = e.subscribe(o, r);
|
|
77
|
+
return () => {
|
|
78
|
+
f(), a.current && clearTimeout(a.current), c.current && clearTimeout(c.current);
|
|
79
|
+
};
|
|
80
|
+
}, [e, o, D, R, l]), v(() => {
|
|
81
|
+
if (!e || i === null) return;
|
|
82
|
+
const r = () => {
|
|
83
|
+
if (e.get(i) === !0) {
|
|
84
|
+
e.set(i, !1), a.current && (clearTimeout(a.current), a.current = null), u.current = 0;
|
|
85
|
+
const n = e.get(o);
|
|
86
|
+
l(n);
|
|
87
|
+
}
|
|
88
|
+
}, f = e.subscribe(i, r);
|
|
89
|
+
return () => f();
|
|
90
|
+
}, [e, i, o, l]), /* @__PURE__ */ k(A, { ...t });
|
|
91
|
+
};
|
|
92
|
+
export {
|
|
93
|
+
X as DataSync
|
|
94
|
+
};
|
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
import { Count as e } from "./Count.js";
|
|
2
|
-
import { DataFilter as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
2
|
+
import { DataFilter as a } from "./DataFilter.js";
|
|
3
|
+
import { DataSync as p } from "./DataSync.js";
|
|
4
|
+
import { DelayedActions as x, getReactionFunctionsToExecute as c } from "./DelayedActions.js";
|
|
5
|
+
import { PageControls as i } from "./PageControls.js";
|
|
6
|
+
import { Phantom as u } from "./Phantom.js";
|
|
7
|
+
import { ReactiveJsonBasicComponentWrapper as C } from "./ReactiveJsonBasicComponentWrapper.js";
|
|
8
|
+
import { ReactiveJsonSubroot as R } from "./ReactiveJsonSubroot.js";
|
|
8
9
|
import { Switch as g } from "./Switch.js";
|
|
9
10
|
export {
|
|
10
11
|
e as Count,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
i as
|
|
15
|
-
u as
|
|
16
|
-
C as
|
|
12
|
+
a as DataFilter,
|
|
13
|
+
p as DataSync,
|
|
14
|
+
x as DelayedActions,
|
|
15
|
+
i as PageControls,
|
|
16
|
+
u as Phantom,
|
|
17
|
+
C as ReactiveJsonBasicComponentWrapper,
|
|
18
|
+
R as ReactiveJsonSubroot,
|
|
17
19
|
g as Switch,
|
|
18
|
-
|
|
20
|
+
c as getReactionFunctionsToExecute
|
|
19
21
|
};
|
package/dist/component/index.js
CHANGED
|
@@ -6,17 +6,17 @@ import { ReactOnEvent as l } from "./action/ReactOnEvent.js";
|
|
|
6
6
|
import { Redirect as s } from "./action/Redirect.js";
|
|
7
7
|
import { SetAttributeValue as F } from "./action/SetAttributeValue.js";
|
|
8
8
|
import { ToggleAttributeValue as u } from "./action/ToggleAttributeValue.js";
|
|
9
|
-
import { UnsetAttribute as
|
|
9
|
+
import { UnsetAttribute as C } from "./action/UnsetAttribute.js";
|
|
10
10
|
import { UnsetAttributeValue as g } from "./action/UnsetAttributeValue.js";
|
|
11
11
|
import { VisuallyHide as h } from "./action/VisuallyHide.js";
|
|
12
|
-
import { coreDataMappingComponents as
|
|
13
|
-
import { coreDataProcessorComponents as
|
|
12
|
+
import { coreDataMappingComponents as S } from "./dataMapping/index.js";
|
|
13
|
+
import { coreDataProcessorComponents as H } from "./dataProcessor/index.js";
|
|
14
14
|
import { coreElementComponents as E } from "./element/index.js";
|
|
15
15
|
import { coreHookComponents as V } from "./hook/index.js";
|
|
16
16
|
import { coreReactionComponents as k } from "./reaction/index.js";
|
|
17
17
|
import { simpleMapping as w } from "./dataMapping/simpleMapping.js";
|
|
18
|
-
import { VariablesDebug as
|
|
19
|
-
import { Input as
|
|
18
|
+
import { VariablesDebug as B } from "./element/debug/VariablesDebug/VariablesDebug.js";
|
|
19
|
+
import { Input as U } from "./element/form/Input.js";
|
|
20
20
|
import { CheckBoxField as J } from "./element/form/CheckBoxField.js";
|
|
21
21
|
import { ColorField as q } from "./element/form/ColorField.js";
|
|
22
22
|
import { DateField as j } from "./element/form/DateField.js";
|
|
@@ -33,97 +33,99 @@ import { SelectField as le } from "./element/form/SelectField.js";
|
|
|
33
33
|
import { TelField as se } from "./element/form/TelField.js";
|
|
34
34
|
import { TextAreaField as Fe } from "./element/form/TextAreaField.js";
|
|
35
35
|
import { TextField as ue } from "./element/form/TextField.js";
|
|
36
|
-
import { TimeField as
|
|
36
|
+
import { TimeField as Ce } from "./element/form/TimeField.js";
|
|
37
37
|
import { UrlField as ge } from "./element/form/UrlField.js";
|
|
38
38
|
import { WeekField as he } from "./element/form/WeekField.js";
|
|
39
|
-
import { FolderSortableTree as
|
|
40
|
-
import { FormatNumeral as
|
|
39
|
+
import { FolderSortableTree as Se } from "./element/html/FolderSortableTree.js";
|
|
40
|
+
import { FormatNumeral as He } from "./element/html/FormatNumeral.js";
|
|
41
41
|
import { Html as Ee } from "./element/html/Html.js";
|
|
42
42
|
import { LabelFromValue as Ve } from "./element/html/LabelFromValue.js";
|
|
43
43
|
import { PreformattedMarkup as ke } from "./element/html/PreformattedMarkup.js";
|
|
44
44
|
import { SortableTreeItemCollapseButton as we } from "./element/html/SortableTreeItemCollapseButton.js";
|
|
45
|
-
import { Count as
|
|
46
|
-
import { DataFilter as
|
|
47
|
-
import {
|
|
48
|
-
import {
|
|
49
|
-
import {
|
|
50
|
-
import {
|
|
51
|
-
import {
|
|
52
|
-
import {
|
|
53
|
-
import {
|
|
54
|
-
import {
|
|
55
|
-
import {
|
|
56
|
-
import {
|
|
57
|
-
import {
|
|
58
|
-
import {
|
|
59
|
-
import {
|
|
60
|
-
import {
|
|
61
|
-
import {
|
|
62
|
-
import {
|
|
63
|
-
import {
|
|
45
|
+
import { Count as Be } from "./element/special/Count.js";
|
|
46
|
+
import { DataFilter as Ue } from "./element/special/DataFilter.js";
|
|
47
|
+
import { DataSync as Je } from "./element/special/DataSync.js";
|
|
48
|
+
import { DelayedActions as qe, getReactionFunctionsToExecute as Oe } from "./element/special/DelayedActions.js";
|
|
49
|
+
import { PageControls as ze } from "./element/special/PageControls.js";
|
|
50
|
+
import { Phantom as Ke } from "./element/special/Phantom.js";
|
|
51
|
+
import { ReactiveJsonBasicComponentWrapper as Xe } from "./element/special/ReactiveJsonBasicComponentWrapper.js";
|
|
52
|
+
import { ReactiveJsonSubroot as Ze } from "./element/special/ReactiveJsonSubroot.js";
|
|
53
|
+
import { Switch as $e } from "./element/special/Switch.js";
|
|
54
|
+
import { addData as oo } from "./reaction/addData.js";
|
|
55
|
+
import { fetchData as to } from "./reaction/fetchData.js";
|
|
56
|
+
import { executeHttpRequest as po } from "./reaction/utility/httpRequestCommon.js";
|
|
57
|
+
import { moveData as fo } from "./reaction/moveData.js";
|
|
58
|
+
import { postMessage as io } from "./reaction/postMessage.js";
|
|
59
|
+
import { redirectNow as no } from "./reaction/redirectNow.js";
|
|
60
|
+
import { removeData as Fo } from "./reaction/removeData.js";
|
|
61
|
+
import { setClipboardData as uo } from "./reaction/setClipboardData.js";
|
|
62
|
+
import { setData as Co } from "./reaction/setData.js";
|
|
63
|
+
import { submitData as go } from "./reaction/submitData.js";
|
|
64
|
+
import { triggerEvent as ho } from "./reaction/triggerEvent.js";
|
|
64
65
|
export {
|
|
65
66
|
J as CheckBoxField,
|
|
66
67
|
q as ColorField,
|
|
67
|
-
|
|
68
|
+
Be as Count,
|
|
68
69
|
r as CustomEventListener,
|
|
69
|
-
|
|
70
|
+
Ue as DataFilter,
|
|
71
|
+
Je as DataSync,
|
|
70
72
|
j as DateField,
|
|
71
73
|
G as DateTimeField,
|
|
72
|
-
|
|
74
|
+
qe as DelayedActions,
|
|
73
75
|
Q as EmailField,
|
|
74
76
|
Y as FileField,
|
|
75
|
-
|
|
76
|
-
|
|
77
|
+
Se as FolderSortableTree,
|
|
78
|
+
He as FormatNumeral,
|
|
77
79
|
m as HashChangeListener,
|
|
78
80
|
_ as HiddenField,
|
|
79
81
|
x as Hide,
|
|
80
82
|
Ee as Html,
|
|
81
|
-
|
|
83
|
+
U as Input,
|
|
82
84
|
Ve as LabelFromValue,
|
|
83
85
|
a as MessageListener,
|
|
84
86
|
ee as MonthField,
|
|
85
87
|
re as NumberField,
|
|
86
|
-
|
|
88
|
+
ze as PageControls,
|
|
87
89
|
me as PasswordField,
|
|
88
|
-
|
|
90
|
+
Ke as Phantom,
|
|
89
91
|
ke as PreformattedMarkup,
|
|
90
92
|
xe as RangeField,
|
|
91
93
|
l as ReactOnEvent,
|
|
92
|
-
|
|
93
|
-
|
|
94
|
+
Xe as ReactiveJsonBasicComponentWrapper,
|
|
95
|
+
Ze as ReactiveJsonSubroot,
|
|
94
96
|
s as Redirect,
|
|
95
97
|
ae as SearchField,
|
|
96
98
|
le as SelectField,
|
|
97
99
|
F as SetAttributeValue,
|
|
98
100
|
we as SortableTreeItemCollapseButton,
|
|
99
|
-
|
|
101
|
+
$e as Switch,
|
|
100
102
|
se as TelField,
|
|
101
103
|
Fe as TextAreaField,
|
|
102
104
|
ue as TextField,
|
|
103
|
-
|
|
105
|
+
Ce as TimeField,
|
|
104
106
|
u as ToggleAttributeValue,
|
|
105
|
-
|
|
107
|
+
C as UnsetAttribute,
|
|
106
108
|
g as UnsetAttributeValue,
|
|
107
109
|
ge as UrlField,
|
|
108
|
-
|
|
110
|
+
B as VariablesDebug,
|
|
109
111
|
h as VisuallyHide,
|
|
110
112
|
he as WeekField,
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
113
|
+
oo as addData,
|
|
114
|
+
S as coreDataMappingComponents,
|
|
115
|
+
H as coreDataProcessorComponents,
|
|
114
116
|
E as coreElementComponents,
|
|
115
117
|
V as coreHookComponents,
|
|
116
118
|
k as coreReactionComponents,
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
119
|
+
po as executeHttpRequest,
|
|
120
|
+
to as fetchData,
|
|
121
|
+
Oe as getReactionFunctionsToExecute,
|
|
122
|
+
fo as moveData,
|
|
123
|
+
io as postMessage,
|
|
124
|
+
no as redirectNow,
|
|
125
|
+
Fo as removeData,
|
|
126
|
+
uo as setClipboardData,
|
|
127
|
+
Co as setData,
|
|
126
128
|
w as simpleMapping,
|
|
127
|
-
|
|
128
|
-
|
|
129
|
+
go as submitData,
|
|
130
|
+
ho as triggerEvent
|
|
129
131
|
};
|
|
@@ -8,7 +8,7 @@ import { setClipboardData as p } from "./setClipboardData.js";
|
|
|
8
8
|
import { setData as i } from "./setData.js";
|
|
9
9
|
import { submitData as f } from "./submitData.js";
|
|
10
10
|
import { triggerEvent as s } from "./triggerEvent.js";
|
|
11
|
-
import {
|
|
11
|
+
import { executeHttpRequest as q } from "./utility/httpRequestCommon.js";
|
|
12
12
|
const R = {
|
|
13
13
|
addData: t,
|
|
14
14
|
fetchData: o,
|
|
@@ -1,8 +1,121 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "../../../engine/TemplateSystem.js";
|
|
3
|
-
import "../../../engine/utility/alterData.js";
|
|
4
|
-
import "../../../engine/utility/dataMappingSystem.js";
|
|
1
|
+
import { a as z } from "../../../index-BUPRVmV-.js";
|
|
2
|
+
import { evaluateTemplateValue as G, dataLocationToPath as J } from "../../../engine/TemplateSystem.js";
|
|
3
|
+
import { alterData as H } from "../../../engine/utility/alterData.js";
|
|
4
|
+
import { applyDataMapping as K } from "../../../engine/utility/dataMappingSystem.js";
|
|
5
5
|
import "../../../js-yaml-CFDLc3Ha.js";
|
|
6
|
+
const Z = (t, m, c = "httpRequest") => {
|
|
7
|
+
var w, F, L, O, $, j, E, M, q;
|
|
8
|
+
const h = t == null ? void 0 : t.eventData, i = document.body, g = ((w = t == null ? void 0 : t.args) == null ? void 0 : w.allowConcurrent) === !0;
|
|
9
|
+
if (!g) {
|
|
10
|
+
if (i.dataset.htmlBuilderIsSubmitting === "true")
|
|
11
|
+
return;
|
|
12
|
+
i.dataset.htmlBuilderIsSubmitting = "true";
|
|
13
|
+
}
|
|
14
|
+
const S = typeof ((F = t == null ? void 0 : t.args) == null ? void 0 : F.submitSilently) == "boolean";
|
|
15
|
+
S && ((L = t == null ? void 0 : t.args) != null && L.submitSilently ? i.dataset.htmlBuilderIsSubmittingSilently = "true" : delete i.dataset.htmlBuilderIsSubmittingSilently);
|
|
16
|
+
const R = (e, a, s) => {
|
|
17
|
+
s || delete e.dataset.htmlBuilderIsSubmitting, S && delete e.dataset.htmlBuilderIsSubmittingSilently, a != null && a.dataset && delete a.dataset.isSubmitting;
|
|
18
|
+
}, n = h == null ? void 0 : h.currentTarget;
|
|
19
|
+
n != null && n.dataset && (n.dataset.isSubmitting = "true");
|
|
20
|
+
const { globalDataContext: f, templateContext: b } = t, d = f.getRootContext ? f.getRootContext() : f, B = (O = t == null ? void 0 : t.args) == null ? void 0 : O.dataMapping, V = (($ = t == null ? void 0 : t.args) == null ? void 0 : $.refreshAppOnResponse) ?? !0, C = ((j = t == null ? void 0 : t.args) == null ? void 0 : j.updateOnlyData) ?? !1, y = (E = t == null ? void 0 : t.args) == null ? void 0 : E.updateDataAtLocation, r = G({
|
|
21
|
+
valueToEvaluate: (M = t == null ? void 0 : t.args) == null ? void 0 : M.url,
|
|
22
|
+
globalDataContext: d,
|
|
23
|
+
templateContext: b
|
|
24
|
+
});
|
|
25
|
+
if (!r) {
|
|
26
|
+
R(i, n, g);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const x = d.headersForRjBuild ?? {}, { setData: v, setRawAppRjBuild: W, updateData: _ } = d, u = {
|
|
30
|
+
method: m.method,
|
|
31
|
+
url: r,
|
|
32
|
+
...m.data ? { data: m.data } : {}
|
|
33
|
+
};
|
|
34
|
+
Object.keys(x).length > 0 && (u.headers = x);
|
|
35
|
+
const A = ((q = d.plugins) == null ? void 0 : q.dataProcessor) || {};
|
|
36
|
+
let D = {
|
|
37
|
+
url: u.url,
|
|
38
|
+
method: u.method,
|
|
39
|
+
headers: u.headers || {},
|
|
40
|
+
body: u.data
|
|
41
|
+
}, o = null, l = null;
|
|
42
|
+
const I = C === !1;
|
|
43
|
+
z(u).then((e) => {
|
|
44
|
+
if (o = {
|
|
45
|
+
headers: e.headers || {},
|
|
46
|
+
status: e.status,
|
|
47
|
+
data: e.data
|
|
48
|
+
}, l = H({
|
|
49
|
+
requestContext: D,
|
|
50
|
+
responseContext: o,
|
|
51
|
+
responseBody: e.data,
|
|
52
|
+
isRjBuild: I,
|
|
53
|
+
dataProcessors: A
|
|
54
|
+
}), V)
|
|
55
|
+
if (C) {
|
|
56
|
+
if (B)
|
|
57
|
+
try {
|
|
58
|
+
K({
|
|
59
|
+
dataMapping: B,
|
|
60
|
+
responseData: l,
|
|
61
|
+
globalDataContext: d,
|
|
62
|
+
templateContext: b
|
|
63
|
+
});
|
|
64
|
+
return;
|
|
65
|
+
} catch (s) {
|
|
66
|
+
console.error(`reactionFunction:${c} : Error applying dataMapping:`, s);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
if (!y) {
|
|
70
|
+
v(l);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
const a = J({
|
|
74
|
+
dataLocation: y,
|
|
75
|
+
currentPath: "data",
|
|
76
|
+
globalDataContext: d,
|
|
77
|
+
templateContext: b
|
|
78
|
+
});
|
|
79
|
+
if (typeof a != "string" || !a.startsWith("data")) {
|
|
80
|
+
console.warn(
|
|
81
|
+
`reactionFunction:${c} : updateDataAtLocation evaluation did not result in a valid locationstring:`,
|
|
82
|
+
y,
|
|
83
|
+
"->",
|
|
84
|
+
a
|
|
85
|
+
);
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
if (a === "data") {
|
|
89
|
+
v(l);
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
_(l, a);
|
|
93
|
+
} else
|
|
94
|
+
W(l);
|
|
95
|
+
}).catch((e) => {
|
|
96
|
+
var a, s, P, k;
|
|
97
|
+
console.log(`reactionFunction:${c} : Could not execute request. Reason: ${e.message}`), o = {
|
|
98
|
+
headers: ((a = e == null ? void 0 : e.response) == null ? void 0 : a.headers) || {},
|
|
99
|
+
status: ((s = e == null ? void 0 : e.response) == null ? void 0 : s.status) || 500,
|
|
100
|
+
data: ((P = e == null ? void 0 : e.response) == null ? void 0 : P.data) || null
|
|
101
|
+
}, l = H({
|
|
102
|
+
requestContext: D,
|
|
103
|
+
responseContext: o,
|
|
104
|
+
responseBody: ((k = e == null ? void 0 : e.response) == null ? void 0 : k.data) || null,
|
|
105
|
+
isRjBuild: I,
|
|
106
|
+
dataProcessors: A
|
|
107
|
+
});
|
|
108
|
+
}).finally(() => {
|
|
109
|
+
R(i, n, g);
|
|
110
|
+
const e = new CustomEvent("response", {
|
|
111
|
+
bubbles: !1,
|
|
112
|
+
cancelable: !0,
|
|
113
|
+
composed: !0,
|
|
114
|
+
detail: { requestContext: D, value: l, responseContext: o }
|
|
115
|
+
});
|
|
116
|
+
console.log(`reactionFunction:${c} : Dispatching event: response`, e), console.log("currentTarget", n), n == null || n.dispatchEvent(e);
|
|
117
|
+
});
|
|
118
|
+
};
|
|
6
119
|
export {
|
|
7
|
-
|
|
120
|
+
Z as executeHttpRequest
|
|
8
121
|
};
|