@ea-lab/reactive-json 1.3.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.
Files changed (33) hide show
  1. package/dist/component/action/CustomEventListener.js +4 -3
  2. package/dist/component/action/ReactOnEvent.js +7 -6
  3. package/dist/component/attributeTransformer/setAttributeValue.js +21 -20
  4. package/dist/component/attributeTransformer/toggleAttributeValue.js +16 -15
  5. package/dist/component/attributeTransformer/unsetAttributeValue.js +9 -8
  6. package/dist/component/element/debug/VariablesDebug/VariablesDebug.js +75 -61
  7. package/dist/component/element/html/LabelFromValue.js +30 -18
  8. package/dist/component/element/index.js +28 -26
  9. package/dist/component/element/special/Count.js +1 -1
  10. package/dist/component/element/special/DataFilter.js +49 -40
  11. package/dist/component/element/special/DataSync.js +94 -0
  12. package/dist/component/element/special/ReactiveJsonSubroot.js +1 -1
  13. package/dist/component/element/special/index.js +15 -13
  14. package/dist/component/index.js +57 -55
  15. package/dist/component/reaction/fetchData.js +1 -1
  16. package/dist/component/reaction/index.js +1 -1
  17. package/dist/component/reaction/submitData.js +1 -1
  18. package/dist/component/reaction/utility/httpRequestCommon.js +119 -6
  19. package/dist/component/reaction/utility/index.js +1 -1
  20. package/dist/engine/DataStore.js +120 -0
  21. package/dist/engine/ReactiveJsonRoot.js +218 -277
  22. package/dist/engine/StoreContext.js +17 -0
  23. package/dist/engine/View.js +94 -58
  24. package/dist/engine/hook/useReactiveData.js +9 -0
  25. package/dist/engine/index.js +53 -45
  26. package/dist/engine/utility/formElementsCommon.js +36 -23
  27. package/dist/engine/utility/parseRjBuild.js +1 -1
  28. package/dist/{httpRequestCommon-BNA1zivP.js → index-BUPRVmV-.js} +599 -704
  29. package/dist/index-DJuOXIM5.js +25 -0
  30. package/dist/{js-yaml-Bw0KO4XO.js → js-yaml-CFDLc3Ha.js} +196 -193
  31. package/dist/main.js +156 -146
  32. package/package.json +2 -2
  33. package/dist/index-Ya6_R5yr.js +0 -23
@@ -1,30 +1,37 @@
1
- import { jsx as a } from "react/jsx-runtime";
2
- import { useContext as b } from "react";
3
- import { isValid as P } from "../../../engine/Actions.js";
4
- import { GlobalDataContext as D } from "../../../engine/GlobalDataContext.js";
5
- import { TemplateContext as x } from "../../../engine/TemplateContext.js";
6
- import { View as v } from "../../../engine/View.js";
7
- const W = (t) => {
8
- var u, f;
9
- const o = b(D), e = b(x), n = { globalDataContext: o, templateContext: e }, { contextToFilter: l = "global", filters: y = [] } = t.props, s = (p) => {
10
- if (!p)
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 r of y) {
13
- const m = (r == null ? void 0 : r.subjectsWithProperty) ?? void 0;
14
- if (!m || !p.hasOwnProperty(m))
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 (!P(r, n, /* @__PURE__ */ new Map([
23
+ if (!W(a, r, /* @__PURE__ */ new Map([
17
24
  [
18
25
  "whenFilterableData",
19
- ({ condition: C }) => {
20
- const w = C.whenFilterableData.split(".");
21
- let i = p;
22
- for (const h of w) {
23
- const d = parseInt(h);
24
- if (i = i[isNaN(d) ? h : d], i === void 0)
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 i;
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 (l) {
42
+ switch (m) {
36
43
  case "template":
37
- return e.templateData = c(e.templateData, s), e.templatePath = t.path, /* @__PURE__ */ a(x.Provider, { value: e, children: /* @__PURE__ */ a(
38
- v,
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: ((u = t.currentData) == null ? void 0 : u.content) ?? void 0
51
+ currentData: ((d = t.currentData) == null ? void 0 : d.content) ?? void 0
44
52
  }
45
53
  ) });
46
54
  case "global":
47
55
  default:
48
- return o.templateData = c(o.templateData, s), /* @__PURE__ */ a(D.Provider, { value: o, children: /* @__PURE__ */ a(
49
- v,
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: ((f = t.currentData) == null ? void 0 : f.content) ?? void 0
63
+ currentData: ((b = t.currentData) == null ? void 0 : b.content) ?? void 0
55
64
  }
56
65
  ) });
57
66
  }
58
- }, c = (t, o) => {
67
+ }, p = (t, e) => {
59
68
  if (Array.isArray(t)) {
60
- const e = {};
61
- return t.forEach((n, l) => {
62
- o(n) && (e[l] = c(n, o));
63
- }), e;
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 e = {};
66
- for (const n in t)
67
- if (t.hasOwnProperty(n)) {
68
- if (!o(t[n]))
74
+ const n = {};
75
+ for (const r in t)
76
+ if (t.hasOwnProperty(r)) {
77
+ if (!e(t[r]))
69
78
  continue;
70
- e[n] = c(t[n], o);
79
+ n[r] = p(t[r], e);
71
80
  }
72
- return e;
81
+ return n;
73
82
  } else
74
83
  return t;
75
84
  };
76
85
  export {
77
- W as DataFilter
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
+ };
@@ -6,7 +6,7 @@ import { TemplateContext as I } from "../../../engine/TemplateContext.js";
6
6
  import { evaluateTemplateValueCollection as h, dataLocationToPath as T } from "../../../engine/TemplateSystem.js";
7
7
  import "../../../lodash-CYNxjS-I.js";
8
8
  import { analyzeDataOverrideReferences as E } from "../../../engine/utility/analyzeDataOverrideReferences.js";
9
- import "../../../js-yaml-Bw0KO4XO.js";
9
+ import "../../../js-yaml-CFDLc3Ha.js";
10
10
  const L = ({ props: t }) => {
11
11
  var d;
12
12
  const a = f(x), n = f(I), l = a.ReactiveJsonRoot;
@@ -1,19 +1,21 @@
1
1
  import { Count as e } from "./Count.js";
2
- import { DataFilter as n } from "./DataFilter.js";
3
- import { DelayedActions as a, getReactionFunctionsToExecute as m } from "./DelayedActions.js";
4
- import { PageControls as c } from "./PageControls.js";
5
- import { Phantom as i } from "./Phantom.js";
6
- import { ReactiveJsonBasicComponentWrapper as u } from "./ReactiveJsonBasicComponentWrapper.js";
7
- import { ReactiveJsonSubroot as C } from "./ReactiveJsonSubroot.js";
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
- n as DataFilter,
12
- a as DelayedActions,
13
- c as PageControls,
14
- i as Phantom,
15
- u as ReactiveJsonBasicComponentWrapper,
16
- C as ReactiveJsonSubroot,
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
- m as getReactionFunctionsToExecute
20
+ c as getReactionFunctionsToExecute
19
21
  };
@@ -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 D } from "./action/UnsetAttribute.js";
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 v } from "./dataMapping/index.js";
13
- import { coreDataProcessorComponents as S } from "./dataProcessor/index.js";
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 N } from "./element/debug/VariablesDebug/VariablesDebug.js";
19
- import { Input as y } from "./element/form/Input.js";
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 De } from "./element/form/TimeField.js";
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 ve } from "./element/html/FolderSortableTree.js";
40
- import { FormatNumeral as Se } from "./element/html/FormatNumeral.js";
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 Ne } from "./element/special/Count.js";
46
- import { DataFilter as ye } from "./element/special/DataFilter.js";
47
- import { DelayedActions as Je, getReactionFunctionsToExecute as We } from "./element/special/DelayedActions.js";
48
- import { PageControls as Oe } from "./element/special/PageControls.js";
49
- import { Phantom as ze } from "./element/special/Phantom.js";
50
- import { ReactiveJsonBasicComponentWrapper as Ke } from "./element/special/ReactiveJsonBasicComponentWrapper.js";
51
- import { ReactiveJsonSubroot as Xe } from "./element/special/ReactiveJsonSubroot.js";
52
- import { Switch as Ze } from "./element/special/Switch.js";
53
- import { addData as $e } from "./reaction/addData.js";
54
- import { fetchData as oo } from "./reaction/fetchData.js";
55
- import { e as to } from "../httpRequestCommon-BNA1zivP.js";
56
- import { moveData as po } from "./reaction/moveData.js";
57
- import { postMessage as fo } from "./reaction/postMessage.js";
58
- import { redirectNow as io } from "./reaction/redirectNow.js";
59
- import { removeData as no } from "./reaction/removeData.js";
60
- import { setClipboardData as Fo } from "./reaction/setClipboardData.js";
61
- import { setData as uo } from "./reaction/setData.js";
62
- import { submitData as Do } from "./reaction/submitData.js";
63
- import { triggerEvent as go } from "./reaction/triggerEvent.js";
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
- Ne as Count,
68
+ Be as Count,
68
69
  r as CustomEventListener,
69
- ye as DataFilter,
70
+ Ue as DataFilter,
71
+ Je as DataSync,
70
72
  j as DateField,
71
73
  G as DateTimeField,
72
- Je as DelayedActions,
74
+ qe as DelayedActions,
73
75
  Q as EmailField,
74
76
  Y as FileField,
75
- ve as FolderSortableTree,
76
- Se as FormatNumeral,
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
- y as Input,
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
- Oe as PageControls,
88
+ ze as PageControls,
87
89
  me as PasswordField,
88
- ze as Phantom,
90
+ Ke as Phantom,
89
91
  ke as PreformattedMarkup,
90
92
  xe as RangeField,
91
93
  l as ReactOnEvent,
92
- Ke as ReactiveJsonBasicComponentWrapper,
93
- Xe as ReactiveJsonSubroot,
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
- Ze as Switch,
101
+ $e as Switch,
100
102
  se as TelField,
101
103
  Fe as TextAreaField,
102
104
  ue as TextField,
103
- De as TimeField,
105
+ Ce as TimeField,
104
106
  u as ToggleAttributeValue,
105
- D as UnsetAttribute,
107
+ C as UnsetAttribute,
106
108
  g as UnsetAttributeValue,
107
109
  ge as UrlField,
108
- N as VariablesDebug,
110
+ B as VariablesDebug,
109
111
  h as VisuallyHide,
110
112
  he as WeekField,
111
- $e as addData,
112
- v as coreDataMappingComponents,
113
- S as coreDataProcessorComponents,
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
- to as executeHttpRequest,
118
- oo as fetchData,
119
- We as getReactionFunctionsToExecute,
120
- po as moveData,
121
- fo as postMessage,
122
- io as redirectNow,
123
- no as removeData,
124
- Fo as setClipboardData,
125
- uo as setData,
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
- Do as submitData,
128
- go as triggerEvent
129
+ go as submitData,
130
+ ho as triggerEvent
129
131
  };
@@ -1,4 +1,4 @@
1
- import { e as a } from "../../httpRequestCommon-BNA1zivP.js";
1
+ import { executeHttpRequest as a } from "./utility/httpRequestCommon.js";
2
2
  const c = (t) => {
3
3
  var e;
4
4
  a(
@@ -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 { e as q } from "../../httpRequestCommon-BNA1zivP.js";
11
+ import { executeHttpRequest as q } from "./utility/httpRequestCommon.js";
12
12
  const R = {
13
13
  addData: t,
14
14
  fetchData: o,
@@ -1,4 +1,4 @@
1
- import { e as D } from "../../httpRequestCommon-BNA1zivP.js";
1
+ import { executeHttpRequest as D } from "./utility/httpRequestCommon.js";
2
2
  import { evaluateTemplateValue as c } from "../../engine/TemplateSystem.js";
3
3
  const x = (t) => {
4
4
  var m, r;
@@ -1,8 +1,121 @@
1
- import { e as i } from "../../../httpRequestCommon-BNA1zivP.js";
2
- import "../../../engine/TemplateSystem.js";
3
- import "../../../engine/utility/alterData.js";
4
- import "../../../engine/utility/dataMappingSystem.js";
5
- import "../../../js-yaml-Bw0KO4XO.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
+ 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
- i as executeHttpRequest
120
+ Z as executeHttpRequest
8
121
  };
@@ -1,4 +1,4 @@
1
- import { e as o } from "../../../httpRequestCommon-BNA1zivP.js";
1
+ import { executeHttpRequest as o } from "./httpRequestCommon.js";
2
2
  export {
3
3
  o as executeHttpRequest
4
4
  };