@plitzi/sdk-elements 0.30.19 → 0.31.1
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/CHANGELOG.md +38 -3
- package/dist/Element/RootElement.mjs +45 -46
- package/dist/Element/hooks/useElementDataSource.d.ts +2 -4
- package/dist/Element/hooks/useElementDataSource.mjs +13 -10
- package/dist/Element/hooks/useElementInternal.d.ts +19 -2
- package/dist/Element/hooks/useElementInternal.mjs +29 -30
- package/dist/Element/hooks/useInternalItems.mjs +1 -1
- package/dist/dataSource/GlobalSources.d.ts +7 -0
- package/dist/dataSource/GlobalSources.mjs +135 -0
- package/dist/dataSource/getBindingsDetails.d.ts +10 -0
- package/dist/dataSource/getBindingsDetails.mjs +49 -0
- package/dist/dataSource/getSourcesByElementId.d.ts +3 -0
- package/dist/dataSource/getSourcesByElementId.mjs +12 -0
- package/dist/dataSource/index.d.ts +4 -0
- package/dist/dataSource/index.mjs +5 -0
- package/dist/dataSource/utility/arrayMap.d.ts +6 -0
- package/dist/dataSource/utility/arrayMap.mjs +28 -0
- package/dist/dataSource/utility/capitalize.d.ts +3 -0
- package/dist/dataSource/utility/capitalize.mjs +11 -0
- package/dist/dataSource/utility/dateConverter.d.ts +3 -0
- package/dist/dataSource/utility/dateConverter.mjs +60 -0
- package/dist/dataSource/utility/index.d.ts +7 -0
- package/dist/dataSource/utility/index.mjs +22 -0
- package/dist/dataSource/utility/staticValue.d.ts +3 -0
- package/dist/dataSource/utility/staticValue.mjs +47 -0
- package/dist/dataSource/utility/stringToArray.d.ts +3 -0
- package/dist/dataSource/utility/stringToArray.mjs +20 -0
- package/dist/dataSource/utility/styleSelector.d.ts +3 -0
- package/dist/dataSource/utility/styleSelector.mjs +42 -0
- package/dist/dataSource/utility/twigTemplate.d.ts +3 -0
- package/dist/dataSource/utility/twigTemplate.mjs +26 -0
- package/dist/elements/advanced/Reference/Reference.mjs +2 -2
- package/dist/elements/advanced/Reference/Settings.mjs +1 -1
- package/dist/elements/basic/Link/Link.mjs +4 -4
- package/dist/elements/basic/Link/Settings.mjs +1 -1
- package/dist/elements/form/Form/Form.mjs +70 -66
- package/dist/elements/form/FormControl/FormControl.mjs +13 -15
- package/dist/elements/form/FormControl/hocs/withFieldValue.mjs +46 -49
- package/dist/elements/internal/LayoutContainer/Settings.mjs +1 -1
- package/dist/elements/internal/Page/Settings.mjs +1 -1
- package/dist/elements/provider/ApiContainer/ApiContainer.mjs +47 -43
- package/dist/elements/provider/ApiContainer/Settings.mjs +1 -1
- package/dist/elements/provider/CollectionContainer/CollectionContainer.mjs +35 -31
- package/dist/elements/structure/DialogContainer/DialogContainer.mjs +53 -51
- package/dist/elements/structure/List/modes/ListControlled/ListControlled.mjs +32 -30
- package/dist/elements/structure/List/modes/ListControlled/ListControlledItem.d.ts +2 -2
- package/dist/elements/structure/List/modes/ListControlled/ListControlledItem.mjs +24 -22
- package/dist/elements/structure/ModalContainer/ModalContainer.mjs +41 -39
- package/package.json +95 -13
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,40 @@
|
|
|
1
1
|
# @plitzi/sdk-elements
|
|
2
2
|
|
|
3
|
+
## 0.31.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- v0.31.1
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @plitzi/nexus@0.31.1
|
|
10
|
+
- @plitzi/sdk-auth@0.31.1
|
|
11
|
+
- @plitzi/sdk-dev-tools@0.31.1
|
|
12
|
+
- @plitzi/sdk-event-bridge@0.31.1
|
|
13
|
+
- @plitzi/sdk-interactions@0.31.1
|
|
14
|
+
- @plitzi/sdk-navigation@0.31.1
|
|
15
|
+
- @plitzi/sdk-schema@0.31.1
|
|
16
|
+
- @plitzi/sdk-shared@0.31.1
|
|
17
|
+
- @plitzi/sdk-state@0.31.1
|
|
18
|
+
|
|
19
|
+
## 0.31.0
|
|
20
|
+
|
|
21
|
+
### Minor Changes
|
|
22
|
+
|
|
23
|
+
- v0.31.0
|
|
24
|
+
|
|
25
|
+
### Patch Changes
|
|
26
|
+
|
|
27
|
+
- Updated dependencies
|
|
28
|
+
- @plitzi/sdk-auth@0.31.0
|
|
29
|
+
- @plitzi/sdk-dev-tools@0.31.0
|
|
30
|
+
- @plitzi/sdk-event-bridge@0.31.0
|
|
31
|
+
- @plitzi/sdk-interactions@0.31.0
|
|
32
|
+
- @plitzi/sdk-navigation@0.31.0
|
|
33
|
+
- @plitzi/sdk-schema@0.31.0
|
|
34
|
+
- @plitzi/sdk-shared@0.31.0
|
|
35
|
+
- @plitzi/sdk-state@0.31.0
|
|
36
|
+
- @plitzi/nexus@0.31.0
|
|
37
|
+
|
|
3
38
|
## 0.30.19
|
|
4
39
|
|
|
5
40
|
### Patch Changes
|
|
@@ -12,7 +47,7 @@
|
|
|
12
47
|
- @plitzi/sdk-interactions@0.30.19
|
|
13
48
|
- @plitzi/sdk-schema@0.30.19
|
|
14
49
|
- @plitzi/sdk-shared@0.30.19
|
|
15
|
-
- @plitzi/
|
|
50
|
+
- @plitzi/nexus@0.30.19
|
|
16
51
|
|
|
17
52
|
## 0.30.18
|
|
18
53
|
|
|
@@ -26,7 +61,7 @@
|
|
|
26
61
|
- @plitzi/sdk-interactions@0.30.18
|
|
27
62
|
- @plitzi/sdk-schema@0.30.18
|
|
28
63
|
- @plitzi/sdk-shared@0.30.18
|
|
29
|
-
- @plitzi/
|
|
64
|
+
- @plitzi/nexus@0.30.18
|
|
30
65
|
|
|
31
66
|
## 0.30.17
|
|
32
67
|
|
|
@@ -40,7 +75,7 @@
|
|
|
40
75
|
- @plitzi/sdk-interactions@0.30.17
|
|
41
76
|
- @plitzi/sdk-schema@0.30.17
|
|
42
77
|
- @plitzi/sdk-shared@0.30.17
|
|
43
|
-
- @plitzi/
|
|
78
|
+
- @plitzi/nexus@0.30.17
|
|
44
79
|
|
|
45
80
|
## 0.30.16
|
|
46
81
|
|
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
import e from "./
|
|
2
|
-
import
|
|
3
|
-
import r from "./
|
|
4
|
-
import i from "./hooks/
|
|
5
|
-
import a from "
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
1
|
+
import { interactionBasicTriggers as e, nativeEventsList as t } from "./helpers/elementConstants.mjs";
|
|
2
|
+
import n from "./helpers/parseStyle.mjs";
|
|
3
|
+
import r from "./hooks/useElementInteractions.mjs";
|
|
4
|
+
import i from "./hooks/useInternalClassName.mjs";
|
|
5
|
+
import { use as a, useCallback as o, useEffect as s, useMemo as c, useRef as ee } from "react";
|
|
6
|
+
import te from "@plitzi/sdk-shared/elements/ElementContext";
|
|
7
|
+
import l from "@plitzi/sdk-shared/hooks/usePlitziServiceContext";
|
|
8
|
+
import { get as u } from "@plitzi/plitzi-ui/helpers";
|
|
9
|
+
import { createStoreHook as d } from "@plitzi/nexus/createStore";
|
|
10
|
+
import { emptyObject as f } from "@plitzi/sdk-shared/helpers/utils";
|
|
10
11
|
import { jsx as p } from "react/jsx-runtime";
|
|
11
12
|
import m from "clsx";
|
|
12
13
|
import { pConsole as h } from "@plitzi/sdk-shared/devTools/utils/PlitziConsole";
|
|
13
14
|
//#region src/Element/RootElement.tsx
|
|
14
15
|
var g = ({ ref: g, children: _, tag: v = "div", className: y = "", interactionTriggers: b, interactionCallbacks: x, style: S, ...C }) => {
|
|
15
|
-
let w =
|
|
16
|
+
let w = c(() => n(S), [S]), T = v, E = a(te);
|
|
16
17
|
if (!E) throw Error("This element can be rendered only under withElement HOC or inside ElementContext");
|
|
17
18
|
let { id: D, rootId: O } = E;
|
|
18
19
|
if (!T) throw Error(`One of these parameters [tag] is missing in elementId: ${D}`);
|
|
@@ -24,7 +25,7 @@ var g = ({ ref: g, children: _, tag: v = "div", className: y = "", interactionTr
|
|
|
24
25
|
...C,
|
|
25
26
|
children: _
|
|
26
27
|
});
|
|
27
|
-
let k =
|
|
28
|
+
let k = l(), A = u(k, "settings.previewMode", !0), j = u(k, "settings.debugMode", !1), M = u(k, "root.baseElementId"), { className: N, attributes: P, definition: F, definition: { interactions: I, type: L, label: R, runtime: ne }, plitziElementLayout: z, style: B, elementState: V, setElementState: H } = E, U = ne === "server" ? { "data-rsc-id": D } : void 0, W = c(() => !j && (A || !L || O !== M) ? {} : {
|
|
28
29
|
"data-id": D,
|
|
29
30
|
"data-name": R || L || "unknown",
|
|
30
31
|
"data-root-id": O,
|
|
@@ -38,60 +39,58 @@ var g = ({ ref: g, children: _, tag: v = "div", className: y = "", interactionTr
|
|
|
38
39
|
D,
|
|
39
40
|
R,
|
|
40
41
|
L
|
|
41
|
-
]),
|
|
42
|
-
if (!
|
|
42
|
+
]), G = u(k, "contexts.InteractionsContext");
|
|
43
|
+
if (!G) return /* @__PURE__ */ p(T, {
|
|
43
44
|
ref: g,
|
|
44
45
|
style: {
|
|
45
|
-
...
|
|
46
|
+
...B,
|
|
46
47
|
...w
|
|
47
48
|
},
|
|
48
49
|
className: y,
|
|
49
50
|
...C,
|
|
50
|
-
...G,
|
|
51
51
|
...W,
|
|
52
|
+
...U,
|
|
52
53
|
children: _
|
|
53
54
|
});
|
|
54
|
-
let { interactionsManager:
|
|
55
|
-
i || e.preventDefault(), r && r(e), i || e.preventDefault(),
|
|
56
|
-
}, [
|
|
57
|
-
let n =
|
|
55
|
+
let { interactionsManager: K, useInteractions: q } = a(G), J = o((e, t, n, r, i = !1) => {
|
|
56
|
+
i || e.preventDefault(), r && r(e), i || e.preventDefault(), K.interactionTrigger(t, n, { event: e });
|
|
57
|
+
}, [K]), Y = c(() => !A || !I ? {} : Object.values(I).filter((e) => e.type === "trigger" && e.action && t.includes(e.action) && e.enabled).reduce((e, t) => {
|
|
58
|
+
let n = u(t, "params.propagateEvent", !1);
|
|
58
59
|
return {
|
|
59
60
|
...e,
|
|
60
|
-
[t.action]: (e) =>
|
|
61
|
+
[t.action]: (e) => J(e, D, t.action, C[t.action], n)
|
|
61
62
|
};
|
|
62
63
|
}, {}), [
|
|
63
64
|
D,
|
|
64
65
|
I,
|
|
65
66
|
C,
|
|
66
67
|
A,
|
|
67
|
-
|
|
68
|
-
]),
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
let te = s(() => ({ dataSource: Q.current }), [Q]), ne = l(() => ({
|
|
76
|
-
...t,
|
|
68
|
+
J
|
|
69
|
+
]), X = j || !!(I && Object.keys(I).length), { useStore: Z } = d(), [re] = Z("runtime.sources", {
|
|
70
|
+
enabled: X,
|
|
71
|
+
defaultValue: f
|
|
72
|
+
}), Q = ee({});
|
|
73
|
+
Q.current = re;
|
|
74
|
+
let ie = o(() => ({ dataSource: Q.current }), [Q]), ae = c(() => ({
|
|
75
|
+
...e,
|
|
77
76
|
...b
|
|
78
|
-
}), [b]), $ =
|
|
77
|
+
}), [b]), $ = r({
|
|
79
78
|
attributes: P,
|
|
80
79
|
definition: F,
|
|
81
|
-
setElementState:
|
|
80
|
+
setElementState: H
|
|
82
81
|
});
|
|
83
|
-
|
|
82
|
+
q({
|
|
84
83
|
id: D,
|
|
85
84
|
interactions: I,
|
|
86
|
-
triggers:
|
|
87
|
-
callbacks:
|
|
85
|
+
triggers: ae,
|
|
86
|
+
callbacks: c(() => ({
|
|
88
87
|
...x,
|
|
89
88
|
...$
|
|
90
89
|
}), [x, $]),
|
|
91
|
-
getAdditionalParams:
|
|
92
|
-
}),
|
|
93
|
-
!A || !I || !Object.keys(I).length ||
|
|
94
|
-
}, []),
|
|
90
|
+
getAdditionalParams: ie
|
|
91
|
+
}), s(() => {
|
|
92
|
+
!A || !I || !Object.keys(I).length || K.interactionTrigger(D, "onLoad", {});
|
|
93
|
+
}, []), s(() => {
|
|
95
94
|
if (j) return h.addProviderMethod(`getElementDataSource-${D}`, () => Q.current), () => {
|
|
96
95
|
h.removeProviderMethod(`getElementDataSource-${D}`);
|
|
97
96
|
};
|
|
@@ -100,26 +99,26 @@ var g = ({ ref: g, children: _, tag: v = "div", className: y = "", interactionTr
|
|
|
100
99
|
Q,
|
|
101
100
|
D
|
|
102
101
|
]);
|
|
103
|
-
let
|
|
102
|
+
let oe = i({
|
|
104
103
|
id: D,
|
|
105
104
|
className: y,
|
|
106
105
|
previewMode: A,
|
|
107
106
|
baseElementId: M,
|
|
108
107
|
definition: F,
|
|
109
|
-
elementState:
|
|
110
|
-
plitziElementLayout:
|
|
108
|
+
elementState: V,
|
|
109
|
+
plitziElementLayout: z
|
|
111
110
|
});
|
|
112
111
|
return /* @__PURE__ */ p(T, {
|
|
113
112
|
ref: g,
|
|
114
113
|
style: {
|
|
115
|
-
...
|
|
114
|
+
...B,
|
|
116
115
|
...w
|
|
117
116
|
},
|
|
118
|
-
className: m(N,
|
|
117
|
+
className: m(N, oe),
|
|
119
118
|
...C,
|
|
120
|
-
...G,
|
|
121
|
-
...X,
|
|
122
119
|
...W,
|
|
120
|
+
...Y,
|
|
121
|
+
...U,
|
|
123
122
|
children: _
|
|
124
123
|
});
|
|
125
124
|
};
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { ElementBinding
|
|
1
|
+
import { ElementBinding } from '@plitzi/sdk-shared';
|
|
2
2
|
export type UseElementDataSourceProps = {
|
|
3
|
-
id: string;
|
|
4
3
|
bindings?: Record<string, ElementBinding[]>;
|
|
5
|
-
filterMode?: UseDataSourceFilter;
|
|
6
4
|
sources?: string[];
|
|
7
5
|
};
|
|
8
|
-
declare const useElementDataSource: ({
|
|
6
|
+
declare const useElementDataSource: ({ bindings, sources: sourcesProp }: UseElementDataSourceProps) => Record<string, unknown>;
|
|
9
7
|
export default useElementDataSource;
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import { useMemo as e } from "react";
|
|
2
|
-
import t from "@plitzi/
|
|
2
|
+
import { createStoreHook as t } from "@plitzi/nexus/createStore";
|
|
3
3
|
//#region src/Element/hooks/useElementDataSource.ts
|
|
4
|
-
var n = ({
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
let e = new Set(i ?? []);
|
|
9
|
-
for (let t of Object.values(r ?? {})) if (Array.isArray(t)) for (let { source: n } of t) n && e.add(n);
|
|
4
|
+
var n = ({ bindings: n, sources: r }) => {
|
|
5
|
+
let i = e(() => {
|
|
6
|
+
let e = new Set(r ?? []);
|
|
7
|
+
for (let t of Object.values(n ?? {})) if (Array.isArray(t)) for (let { source: n } of t) n && e.add(n);
|
|
10
8
|
return e.size > 0 && !e.has("variables") && e.add("variables"), [...e];
|
|
11
|
-
}, [r, i]),
|
|
12
|
-
|
|
13
|
-
}
|
|
9
|
+
}, [n, r]), a = e(() => i.map((e) => `runtime.sources.${e}`), [i]), { useStore: o } = t(), [s] = o(a);
|
|
10
|
+
return e(() => {
|
|
11
|
+
let e = {};
|
|
12
|
+
return i.forEach((t, n) => {
|
|
13
|
+
e[t] = s[n];
|
|
14
|
+
}), e;
|
|
15
|
+
}, [i, s]);
|
|
16
|
+
};
|
|
14
17
|
//#endregion
|
|
15
18
|
export { n as default };
|
|
@@ -1,5 +1,22 @@
|
|
|
1
|
-
import { InternalPropsSTG1 } from '@plitzi/sdk-shared';
|
|
1
|
+
import { Element, InternalPropsSTG1 } from '@plitzi/sdk-shared';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
+
export declare const getProps: (element: Element, internalProps: InternalPropsSTG1, dataSource?: Record<string, unknown>, state?: Record<string, unknown>) => {
|
|
4
|
+
rootId: string | undefined;
|
|
5
|
+
attributes: {
|
|
6
|
+
[x: string]: unknown;
|
|
7
|
+
subType?: string;
|
|
8
|
+
};
|
|
9
|
+
definition: import('@plitzi/sdk-shared').ElementDefinition;
|
|
10
|
+
elementState: {
|
|
11
|
+
[x: string]: unknown;
|
|
12
|
+
styleVariant?: Partial<Record<string, Partial<Record<string, string | string[]>>>>;
|
|
13
|
+
styleSelectors?: import('@plitzi/sdk-shared').ElementDefinition["styleSelectors"];
|
|
14
|
+
visibility?: boolean;
|
|
15
|
+
};
|
|
16
|
+
style: Record<string, string> | undefined;
|
|
17
|
+
id: string;
|
|
18
|
+
plitziElementLayout?: import('@plitzi/sdk-shared').ElementLayout;
|
|
19
|
+
};
|
|
3
20
|
export type UseElementInternalProps = {
|
|
4
21
|
children?: ReactNode;
|
|
5
22
|
internalProps: InternalPropsSTG1;
|
|
@@ -42,7 +59,7 @@ declare const useElementInternal: ({ children, internalProps, previewMode, baseE
|
|
|
42
59
|
style: Record<string, string> | undefined;
|
|
43
60
|
id: string;
|
|
44
61
|
plitziElementLayout?: import('@plitzi/sdk-shared').ElementLayout;
|
|
45
|
-
}, "
|
|
62
|
+
}, "style" | "id" | "definition" | "attributes" | "rootId" | "plitziElementLayout" | "setElementState" | "elementState">;
|
|
46
63
|
children: ReactNode;
|
|
47
64
|
};
|
|
48
65
|
export default useElementInternal;
|
|
@@ -1,48 +1,48 @@
|
|
|
1
1
|
import e from "./useElementDataSource.mjs";
|
|
2
2
|
import t from "./useElementState.mjs";
|
|
3
3
|
import n from "./useInternalItems.mjs";
|
|
4
|
-
import r from "
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import s from "@plitzi/
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
4
|
+
import r from "../../dataSource/getBindingsDetails.mjs";
|
|
5
|
+
import i from "../helpers/parseStyleSelectors.mjs";
|
|
6
|
+
import { useMemo as a } from "react";
|
|
7
|
+
import { get as o, omit as s } from "@plitzi/plitzi-ui/helpers";
|
|
8
|
+
import { createStoreHook as c } from "@plitzi/nexus/createStore";
|
|
9
|
+
import { hasValidToken as l, processTwig as u } from "@plitzi/sdk-shared/helpers/twigWrapper";
|
|
10
10
|
//#region src/Element/hooks/useElementInternal.ts
|
|
11
|
-
var d = (e, t, n = {},
|
|
12
|
-
let
|
|
11
|
+
var d = (e, t, n = {}, a = {}) => {
|
|
12
|
+
let c, { attributes: d, definition: f } = e, { rootId: p, plitziElementLayout: m } = t;
|
|
13
13
|
if (t.attributes && (d = {
|
|
14
14
|
...d,
|
|
15
15
|
...t.attributes
|
|
16
16
|
}), Object.keys(n).length > 0) {
|
|
17
|
-
let t =
|
|
17
|
+
let t = r(n, {
|
|
18
18
|
...e,
|
|
19
19
|
attributes: d
|
|
20
|
-
},
|
|
21
|
-
({attributes: d, definition: f, style:
|
|
20
|
+
}, c);
|
|
21
|
+
({attributes: d, definition: f, style: c} = t);
|
|
22
22
|
}
|
|
23
23
|
let { variables: h } = n;
|
|
24
|
-
return h && Object.keys(h).length > 0 && (d = Object.keys(d).reduce((e, t) => typeof d[t] == "string" &&
|
|
24
|
+
return h && Object.keys(h).length > 0 && (d = Object.keys(d).reduce((e, t) => typeof d[t] == "string" && l(d[t]) ? {
|
|
25
25
|
...e,
|
|
26
|
-
[t]:
|
|
26
|
+
[t]: u(d[t], h, !0)
|
|
27
27
|
} : {
|
|
28
28
|
...e,
|
|
29
29
|
[t]: d[t]
|
|
30
30
|
}, {})), d = {
|
|
31
31
|
...d,
|
|
32
|
-
...
|
|
32
|
+
...s(a, ["visibility", "styleSelectors"])
|
|
33
33
|
}, f = {
|
|
34
34
|
...f,
|
|
35
35
|
styleSelectors: {
|
|
36
36
|
...f.styleSelectors,
|
|
37
37
|
...f.initialState?.styleSelectors,
|
|
38
|
-
...
|
|
38
|
+
...a.styleSelectors ?? {}
|
|
39
39
|
}
|
|
40
|
-
}, f.styleSelectors =
|
|
40
|
+
}, f.styleSelectors = i(f), {
|
|
41
41
|
...t,
|
|
42
|
-
rootId:
|
|
42
|
+
rootId: o(m, "rootId", p),
|
|
43
43
|
attributes: {
|
|
44
44
|
...d,
|
|
45
|
-
...
|
|
45
|
+
...s(t, [
|
|
46
46
|
"id",
|
|
47
47
|
"rootId",
|
|
48
48
|
"attributes",
|
|
@@ -53,33 +53,32 @@ var d = (e, t, n = {}, i = {}) => {
|
|
|
53
53
|
definition: f,
|
|
54
54
|
elementState: {
|
|
55
55
|
...f.initialState,
|
|
56
|
-
...
|
|
56
|
+
...a
|
|
57
57
|
},
|
|
58
|
-
style:
|
|
58
|
+
style: c
|
|
59
59
|
};
|
|
60
|
-
}, f = ({ children: r, internalProps:
|
|
61
|
-
let { useStore:
|
|
62
|
-
if (!p) throw Error(`Element ${f} not found, Page ${
|
|
60
|
+
}, f = ({ children: r, internalProps: i, previewMode: o = !1, baseElementId: l }) => {
|
|
61
|
+
let { useStore: u } = c(), { id: f } = i, [p] = u(`schema.flat.${f}`);
|
|
62
|
+
if (!p) throw Error(`Element ${f} not found, Page ${l}`);
|
|
63
63
|
let { state: m, setElementState: h } = t({
|
|
64
64
|
bindings: p.definition.bindings,
|
|
65
|
-
previewMode:
|
|
65
|
+
previewMode: o
|
|
66
66
|
}), g = e({
|
|
67
|
-
id: f,
|
|
68
67
|
bindings: p.definition.bindings,
|
|
69
68
|
sources: ["variables"]
|
|
70
|
-
}), _ =
|
|
71
|
-
...d(p,
|
|
69
|
+
}), _ = a(() => ({
|
|
70
|
+
...d(p, i, g, m),
|
|
72
71
|
setElementState: h
|
|
73
72
|
}), [
|
|
74
73
|
p,
|
|
75
|
-
|
|
74
|
+
i,
|
|
76
75
|
g,
|
|
77
76
|
m,
|
|
78
77
|
h
|
|
79
78
|
]);
|
|
80
79
|
return {
|
|
81
80
|
internalProps: _,
|
|
82
|
-
customProps:
|
|
81
|
+
customProps: s(_, [
|
|
83
82
|
"id",
|
|
84
83
|
"rootId",
|
|
85
84
|
"plitziElementLayout",
|
|
@@ -94,7 +93,7 @@ var d = (e, t, n = {}, i = {}) => {
|
|
|
94
93
|
definition: _.definition,
|
|
95
94
|
plitziElementLayout: _.plitziElementLayout,
|
|
96
95
|
children: r,
|
|
97
|
-
previewMode:
|
|
96
|
+
previewMode: o
|
|
98
97
|
})
|
|
99
98
|
};
|
|
100
99
|
};
|
|
@@ -2,7 +2,7 @@ import e from "../helpers/pluginSelector.mjs";
|
|
|
2
2
|
import t from "../ServerStaticShell.mjs";
|
|
3
3
|
import { isValidElement as n, use as r, useMemo as i, useSyncExternalStore as a } from "react";
|
|
4
4
|
import { get as o } from "@plitzi/plitzi-ui/helpers";
|
|
5
|
-
import { createStoreHook as s } from "@plitzi/
|
|
5
|
+
import { createStoreHook as s } from "@plitzi/nexus/createStore";
|
|
6
6
|
import { usePlitziServiceContext as c } from "@plitzi/sdk-shared";
|
|
7
7
|
import l from "@plitzi/sdk-shared/elements/ComponentContext";
|
|
8
8
|
import { jsx as u } from "react/jsx-runtime";
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { use as e, useCallback as t, useMemo as n } from "react";
|
|
2
|
+
import { get as r } from "@plitzi/plitzi-ui/helpers";
|
|
3
|
+
import { createStoreHook as i } from "@plitzi/nexus/createStore";
|
|
4
|
+
import { getPathsFromObeject as a } from "@plitzi/sdk-shared/helpers/utils";
|
|
5
|
+
import o from "@plitzi/sdk-shared/dataSource/hooks/useRegisterSource";
|
|
6
|
+
import { QueryBuilderEvaluator as s } from "@plitzi/plitzi-ui/QueryBuilder";
|
|
7
|
+
import c from "@plitzi/sdk-navigation/NavigationContext";
|
|
8
|
+
import l from "@plitzi/sdk-auth/AuthContext";
|
|
9
|
+
import u from "@plitzi/sdk-state/StateManagerContext";
|
|
10
|
+
//#region src/dataSource/GlobalSources.tsx
|
|
11
|
+
var d = ({ children: d, environment: f = "main" }) => {
|
|
12
|
+
let { useStore: p, useStoreSync: m } = i(), { routeParams: h, queryParams: g, hostname: _, currentPageId: v } = e(c), [y] = p("schema.variables"), b = n(() => y ? y.reduce((e, t) => {
|
|
13
|
+
let { name: n, value: r, subValues: i } = t;
|
|
14
|
+
if (!Array.isArray(i) || i.length === 0) return {
|
|
15
|
+
...e,
|
|
16
|
+
[n]: r
|
|
17
|
+
};
|
|
18
|
+
let a = {
|
|
19
|
+
routeParams: h,
|
|
20
|
+
queryParams: g,
|
|
21
|
+
hostname: _,
|
|
22
|
+
environment: f
|
|
23
|
+
}, o = i.find((e) => s(e.when, a));
|
|
24
|
+
return {
|
|
25
|
+
...e,
|
|
26
|
+
[n]: o ? o.value : r
|
|
27
|
+
};
|
|
28
|
+
}, {}) : {}, [
|
|
29
|
+
f,
|
|
30
|
+
_,
|
|
31
|
+
g,
|
|
32
|
+
h,
|
|
33
|
+
y
|
|
34
|
+
]);
|
|
35
|
+
o({
|
|
36
|
+
id: "global",
|
|
37
|
+
source: "variables",
|
|
38
|
+
name: "Variables",
|
|
39
|
+
fields: t(() => a(b).map((e) => ({
|
|
40
|
+
path: e,
|
|
41
|
+
name: `variables.${e}`
|
|
42
|
+
})), [b])
|
|
43
|
+
}), m("runtime.sources.variables", b);
|
|
44
|
+
let x = n(() => ({
|
|
45
|
+
routeParams: h,
|
|
46
|
+
queryParams: g
|
|
47
|
+
}), [h, g]);
|
|
48
|
+
o({
|
|
49
|
+
id: "global",
|
|
50
|
+
source: "navigation",
|
|
51
|
+
name: "Navigation",
|
|
52
|
+
fields: t(() => a({
|
|
53
|
+
routeParams: h,
|
|
54
|
+
queryParams: g
|
|
55
|
+
}).map((e) => ({
|
|
56
|
+
path: e,
|
|
57
|
+
name: `navigation.${e}`
|
|
58
|
+
})), [h, g])
|
|
59
|
+
}), m("runtime.sources.navigation", x);
|
|
60
|
+
let { user: S, authenticated: C } = e(l), [w = "basic"] = p("schema.settings.userProvider"), T = n(() => {
|
|
61
|
+
switch (w) {
|
|
62
|
+
case "auth0": return {
|
|
63
|
+
isAuthenticated: C,
|
|
64
|
+
user: {
|
|
65
|
+
given_name: "",
|
|
66
|
+
family_name: "",
|
|
67
|
+
nickname: "",
|
|
68
|
+
name: "",
|
|
69
|
+
picture: "",
|
|
70
|
+
locale: "",
|
|
71
|
+
updated_at: "",
|
|
72
|
+
email: "",
|
|
73
|
+
email_verified: !1,
|
|
74
|
+
sub: "",
|
|
75
|
+
...S
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
case "basic": return {
|
|
79
|
+
isAuthenticated: C,
|
|
80
|
+
accessToken: S?.accessToken ?? "",
|
|
81
|
+
details: {
|
|
82
|
+
username: "",
|
|
83
|
+
email: "",
|
|
84
|
+
roles: "",
|
|
85
|
+
permissions: "",
|
|
86
|
+
verified: "",
|
|
87
|
+
...S?.details ?? {}
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
default: return {};
|
|
91
|
+
}
|
|
92
|
+
}, [
|
|
93
|
+
w,
|
|
94
|
+
S,
|
|
95
|
+
C
|
|
96
|
+
]);
|
|
97
|
+
o({
|
|
98
|
+
id: "global",
|
|
99
|
+
source: "auth",
|
|
100
|
+
name: "Auth State",
|
|
101
|
+
fields: t(() => a(T).map((e) => ({
|
|
102
|
+
path: e,
|
|
103
|
+
name: `user.${e}`
|
|
104
|
+
})), [T])
|
|
105
|
+
}), m("runtime.sources.auth", T);
|
|
106
|
+
let { state: E } = e(u), [D = {}] = p("pageDefinitions"), O = n(() => Object.values(D).map((e) => ({
|
|
107
|
+
value: e.id,
|
|
108
|
+
label: r(e, "attributes.name", e.id)
|
|
109
|
+
})), [D]), k = n(() => ({
|
|
110
|
+
...E,
|
|
111
|
+
currentPageId: v
|
|
112
|
+
}), [E, v]);
|
|
113
|
+
return o({
|
|
114
|
+
id: "global",
|
|
115
|
+
source: "page",
|
|
116
|
+
name: "Page",
|
|
117
|
+
fields: t(() => {
|
|
118
|
+
let e = a(E).map((e) => ({
|
|
119
|
+
path: e,
|
|
120
|
+
name: `page.${e}`
|
|
121
|
+
})), t = O.length > 0 ? {
|
|
122
|
+
path: "currentPageId",
|
|
123
|
+
name: "Current Page",
|
|
124
|
+
inputType: "select",
|
|
125
|
+
values: O
|
|
126
|
+
} : {
|
|
127
|
+
path: "currentPageId",
|
|
128
|
+
name: "Current Page"
|
|
129
|
+
};
|
|
130
|
+
return [...e, t];
|
|
131
|
+
}, [E, O])
|
|
132
|
+
}), m("runtime.sources.page", k), d;
|
|
133
|
+
};
|
|
134
|
+
//#endregion
|
|
135
|
+
export { d as default };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { RuleValue } from '@plitzi/plitzi-ui/QueryBuilder';
|
|
2
|
+
import { Element } from '@plitzi/sdk-shared';
|
|
3
|
+
declare const getBindingsDetails: (dataSource: Record<string, RuleValue>, element: Element, style?: Record<string, string>) => {
|
|
4
|
+
attributes: Record<string, unknown> & {
|
|
5
|
+
subType?: string;
|
|
6
|
+
};
|
|
7
|
+
style: Record<string, string>;
|
|
8
|
+
definition: import('@plitzi/sdk-shared').ElementDefinition;
|
|
9
|
+
};
|
|
10
|
+
export default getBindingsDetails;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import e from "./utility/index.mjs";
|
|
2
|
+
import { produce as t } from "immer";
|
|
3
|
+
import { camelCase as n, get as r, set as i } from "@plitzi/plitzi-ui";
|
|
4
|
+
import { QueryBuilderEvaluator as a } from "@plitzi/plitzi-ui/QueryBuilder";
|
|
5
|
+
//#region src/dataSource/getBindingsDetails.ts
|
|
6
|
+
var o = (e, t, n, i, a, o) => {
|
|
7
|
+
let s = n && t ? `${t}.${n}` : void 0, c = a === "initialState" ? `definition.${a}.${o}` : `${a}.${o}`;
|
|
8
|
+
return {
|
|
9
|
+
fromValue: s ? r(e, s, r(i, c)) : void 0,
|
|
10
|
+
toValue: r(i, c, s ? r(e, s) : void 0)
|
|
11
|
+
};
|
|
12
|
+
}, s = (s, c, l = {}) => {
|
|
13
|
+
let { attributes: u, definition: d } = c, { bindings: f } = d;
|
|
14
|
+
return !f || typeof f == "object" && !Object.keys(f).length ? {
|
|
15
|
+
attributes: u,
|
|
16
|
+
style: {},
|
|
17
|
+
definition: d
|
|
18
|
+
} : t({
|
|
19
|
+
attributes: u,
|
|
20
|
+
style: l,
|
|
21
|
+
definition: d
|
|
22
|
+
}, (t) => {
|
|
23
|
+
Object.keys(f).forEach((c) => {
|
|
24
|
+
!f[c] || !Array.isArray(f[c]) || !f[c].length || f[c].forEach((l) => {
|
|
25
|
+
let { source: u, fromPath: d, transformers: f, when: p, enabled: m = !0 } = l, { toPath: h } = l;
|
|
26
|
+
if (!h || p && !a(p, s, !1, !0) || !m) return;
|
|
27
|
+
c === "style" && (h = n(h));
|
|
28
|
+
let { fromValue: g, toValue: _ } = o(s, u, d, t, c, h), v = g;
|
|
29
|
+
f && Array.isArray(f) && f.length > 0 && f.forEach((n) => {
|
|
30
|
+
let { type: i, action: a, params: o } = n;
|
|
31
|
+
switch (i) {
|
|
32
|
+
case "utility": {
|
|
33
|
+
let n = r(e, `${a}.callback`);
|
|
34
|
+
if (typeof n != "function") break;
|
|
35
|
+
v = n(v, o, t, {
|
|
36
|
+
...s,
|
|
37
|
+
sourceTo: _
|
|
38
|
+
});
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
default:
|
|
42
|
+
}
|
|
43
|
+
}), (typeof v == "boolean" || typeof v == "number" || v) && (c === "initialState" ? i(t, `definition.${c}.${h}`, v) : i(t, `${c}.${h}`, v));
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
//#endregion
|
|
49
|
+
export { s as default };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import e from "@plitzi/sdk-schema/helpers/FlatMap";
|
|
2
|
+
//#region src/dataSource/getSourcesByElementId.ts
|
|
3
|
+
var t = (t = {}, n, r) => {
|
|
4
|
+
if (!r || !n) return {};
|
|
5
|
+
let i = e.parentTree(n, r);
|
|
6
|
+
return Object.values(t).filter((e) => e.meta.id && i.includes(e.meta.id) || e.meta.id === "global").reduce((e, t) => ({
|
|
7
|
+
...e,
|
|
8
|
+
[t.id]: t
|
|
9
|
+
}), {});
|
|
10
|
+
};
|
|
11
|
+
//#endregion
|
|
12
|
+
export { t as default };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { default as GlobalSources } from './GlobalSources';
|
|
2
|
+
export { default as getBindingsDetails } from './getBindingsDetails';
|
|
3
|
+
export { default as getSourcesByElementId } from './getSourcesByElementId';
|
|
4
|
+
export { default as utility, utilityOptions } from './utility';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import e, { utilityOptions as t } from "./utility/index.mjs";
|
|
2
|
+
import n from "./getBindingsDetails.mjs";
|
|
3
|
+
import r from "./GlobalSources.mjs";
|
|
4
|
+
import i from "./getSourcesByElementId.mjs";
|
|
5
|
+
export { r as GlobalSources, n as getBindingsDetails, i as getSourcesByElementId, e as utility, t as utilityOptions };
|