@plitzi/sdk-elements 0.36.0 → 0.36.2
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 +28 -0
- package/dist/Element/ElementParentContext.d.ts +13 -0
- package/dist/Element/ElementParentContext.mjs +6 -0
- package/dist/Element/LayoutBody.d.ts +21 -0
- package/dist/Element/LayoutBody.mjs +24 -0
- package/dist/Element/hocs/withElement.mjs +104 -87
- package/dist/Element/hooks/useElementInternal.mjs +24 -24
- package/dist/Element/hooks/useInternalItems.mjs +42 -39
- package/dist/Element/hooks/useLayoutChain.d.ts +10 -0
- package/dist/Element/hooks/useLayoutChain.mjs +20 -0
- package/dist/Element/hooks/useRootElementInteractions.mjs +45 -44
- package/dist/dataSource/GlobalSources.mjs +60 -59
- package/dist/dataSource/pathFields.d.ts +7 -0
- package/dist/dataSource/pathFields.mjs +8 -0
- package/dist/elements/advanced/Reference/Reference.mjs +93 -89
- package/dist/elements/advanced/Reference/declaration.d.ts +1 -1
- package/dist/elements/advanced/Reference/index.d.ts +1 -1
- package/dist/elements/declarations/index.d.ts +3 -1
- package/dist/elements/internal/LayoutContainer/LayoutContainer.d.ts +6 -0
- package/dist/elements/internal/LayoutContainer/LayoutContainer.mjs +31 -23
- package/dist/elements/internal/LayoutContainer/Settings.d.ts +4 -1
- package/dist/elements/internal/LayoutContainer/Settings.mjs +78 -64
- package/dist/elements/internal/LayoutContainer/declaration.d.ts +2 -0
- package/dist/elements/internal/LayoutContainer/index.d.ts +2 -0
- package/dist/elements/internal/LayoutPicker/LayoutPicker.d.ts +10 -0
- package/dist/elements/internal/LayoutPicker/LayoutPicker.mjs +35 -0
- package/dist/elements/internal/LayoutPicker/index.d.ts +3 -0
- package/dist/elements/internal/LayoutPicker/index.mjs +5 -0
- package/dist/elements/internal/Page/Page.mjs +49 -48
- package/dist/elements/internal/Page/Settings.mjs +101 -119
- package/dist/elements/provider/ApiContainer/ApiContainer.mjs +58 -66
- package/dist/elements/provider/ApiContainer/declaration.mjs +1 -1
- package/dist/elements/provider/ApiContainer/hooks/useApi.d.ts +8 -0
- package/dist/elements/provider/ApiContainer/hooks/useApi.mjs +52 -48
- package/dist/elements/structure/DialogContainer/DialogContainer.mjs +17 -25
- package/dist/elements/structure/ModalContainer/ModalContainer.mjs +15 -23
- package/dist/index.d.ts +3 -1
- package/package.json +38 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# @plitzi/sdk-elements
|
|
2
2
|
|
|
3
|
+
## 0.36.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- v0.36.2
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @plitzi/sdk-auth@0.36.2
|
|
10
|
+
- @plitzi/sdk-dev-tools@0.36.2
|
|
11
|
+
- @plitzi/sdk-event-bridge@0.36.2
|
|
12
|
+
- @plitzi/sdk-interactions@0.36.2
|
|
13
|
+
- @plitzi/sdk-navigation@0.36.2
|
|
14
|
+
- @plitzi/sdk-schema@0.36.2
|
|
15
|
+
- @plitzi/sdk-shared@0.36.2
|
|
16
|
+
|
|
17
|
+
## 0.36.1
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- v0.36.1
|
|
22
|
+
- Updated dependencies
|
|
23
|
+
- @plitzi/sdk-auth@0.36.1
|
|
24
|
+
- @plitzi/sdk-dev-tools@0.36.1
|
|
25
|
+
- @plitzi/sdk-event-bridge@0.36.1
|
|
26
|
+
- @plitzi/sdk-interactions@0.36.1
|
|
27
|
+
- @plitzi/sdk-navigation@0.36.1
|
|
28
|
+
- @plitzi/sdk-schema@0.36.1
|
|
29
|
+
- @plitzi/sdk-shared@0.36.1
|
|
30
|
+
|
|
3
31
|
## 0.36.0
|
|
4
32
|
|
|
5
33
|
### Minor Changes
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What an element needs from the element around it: whether that one is on screen, and its tracing identity.
|
|
3
|
+
*
|
|
4
|
+
* Kept apart from `ElementContext` on purpose. That context carries the whole element — its attributes, its state,
|
|
5
|
+
* its style — so a parent whose state changed (a nav item lighting up on a navigation) re-rendered every child
|
|
6
|
+
* reading it, for two values that had not moved. Children read this; only the element itself reads the full one.
|
|
7
|
+
*/
|
|
8
|
+
export type ElementParentContextValue = {
|
|
9
|
+
visible: boolean;
|
|
10
|
+
traceId: string;
|
|
11
|
+
};
|
|
12
|
+
declare const ElementParentContext: import('react').Context<ElementParentContextValue | undefined>;
|
|
13
|
+
export default ElementParentContext;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
export type LayoutBodyProps = {
|
|
3
|
+
/** What the slot of the shell below renders: the page's content, or the shell nested inside this one. */
|
|
4
|
+
body: ReactNode;
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Hands a shell's slot its body without handing it to every element of the shell.
|
|
9
|
+
*
|
|
10
|
+
* The body used to travel inside `plitziElementLayout`, which every element of the shell receives as a prop. The body
|
|
11
|
+
* is a new node on every navigation — it IS the page — so the whole shell rendered again each time, sidebar and all,
|
|
12
|
+
* to show the one container that holds the page. Here the value every element reads never changes; only the slot
|
|
13
|
+
* subscribes to what it holds.
|
|
14
|
+
*
|
|
15
|
+
* `current` is the body as of the first render, which is what the server renders and what hydration reads. Later
|
|
16
|
+
* bodies are announced after the commit, and the slot renders them before the browser paints.
|
|
17
|
+
*/
|
|
18
|
+
declare const LayoutBody: ({ body, children }: LayoutBodyProps) => import("react").JSX.Element;
|
|
19
|
+
/** The body of the nearest shell, for the element that is its slot; nothing, and no subscription, for any other. */
|
|
20
|
+
export declare const useLayoutBody: (isSlot: boolean) => ReactNode;
|
|
21
|
+
export default LayoutBody;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { createContext as e, use as t, useCallback as n, useLayoutEffect as r, useState as i, useSyncExternalStore as a } from "react";
|
|
2
|
+
import { jsx as o } from "react/jsx-runtime";
|
|
3
|
+
//#region src/Element/LayoutBody.tsx
|
|
4
|
+
var s = e(void 0);
|
|
5
|
+
s.displayName = "LayoutBodyContext";
|
|
6
|
+
var c = () => void 0, l = ({ body: e, children: t }) => {
|
|
7
|
+
let [n] = i(() => ({
|
|
8
|
+
current: e,
|
|
9
|
+
listeners: /* @__PURE__ */ new Set()
|
|
10
|
+
}));
|
|
11
|
+
return r(() => {
|
|
12
|
+
n.current !== e && (n.current = e, n.listeners.forEach((e) => e()));
|
|
13
|
+
}, [e, n]), /* @__PURE__ */ o(s, {
|
|
14
|
+
value: n,
|
|
15
|
+
children: t
|
|
16
|
+
});
|
|
17
|
+
}, u = (e) => {
|
|
18
|
+
let r = t(s), i = n((t) => !e || !r ? c : (r.listeners.add(t), () => {
|
|
19
|
+
r.listeners.delete(t);
|
|
20
|
+
}), [e, r]), o = n(() => e && r ? r.current : void 0, [e, r]);
|
|
21
|
+
return a(i, o, o);
|
|
22
|
+
};
|
|
23
|
+
//#endregion
|
|
24
|
+
export { l as default, u as useLayoutBody };
|
|
@@ -1,71 +1,85 @@
|
|
|
1
1
|
import e from "../ElementContext.mjs";
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import r from "../
|
|
5
|
-
import i from "
|
|
6
|
-
import
|
|
7
|
-
import u from "
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
2
|
+
import t from "../ElementParentContext.mjs";
|
|
3
|
+
import { isVisible as n } from "../helpers/isVisible.mjs";
|
|
4
|
+
import { omitKeys as r } from "../helpers/omitKeys.mjs";
|
|
5
|
+
import i from "../hooks/useElementInternal.mjs";
|
|
6
|
+
import a from "@plitzi/plitzi-ui/ErrorBoundary";
|
|
7
|
+
import { Profiler as o, use as s, useEffect as c, useId as l, useMemo as u, useRef as d } from "react";
|
|
8
|
+
import f from "@plitzi/sdk-event-bridge/hooks/useEventBridge";
|
|
9
|
+
import p from "@plitzi/sdk-shared/hooks/usePlitziServiceContext";
|
|
10
|
+
import { useCommonStore as m } from "@plitzi/sdk-shared/store";
|
|
11
|
+
import { diffProps as h, tracingCollector as g } from "@plitzi/sdk-shared/store/tracing";
|
|
12
|
+
import { jsx as _ } from "react/jsx-runtime";
|
|
12
13
|
//#region src/Element/hocs/withElement.tsx
|
|
13
|
-
var
|
|
14
|
-
let
|
|
15
|
-
let
|
|
16
|
-
id:
|
|
17
|
-
rootId:
|
|
18
|
-
visible:
|
|
19
|
-
traceId:
|
|
14
|
+
var v = (v) => {
|
|
15
|
+
let y = v.displayName || v.name, b = (y) => {
|
|
16
|
+
let b = d(void 0), x = d(void 0), { id: S, rootId: C } = y.internalProps, w = s(t), T = w?.visible ?? !0, E = `${S}${l()}`, D = w?.traceId ?? E, O = u(() => ({
|
|
17
|
+
id: S,
|
|
18
|
+
rootId: C,
|
|
19
|
+
visible: T,
|
|
20
|
+
traceId: D,
|
|
20
21
|
plitziJsxSkipHOC: !0
|
|
21
22
|
}), [
|
|
22
|
-
|
|
23
|
-
x,
|
|
23
|
+
S,
|
|
24
24
|
C,
|
|
25
|
-
T
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
T,
|
|
26
|
+
D
|
|
27
|
+
]), k = u(() => ({
|
|
28
|
+
visible: T,
|
|
29
|
+
traceId: D
|
|
30
|
+
}), [T, D]);
|
|
31
|
+
if (y.plitziJsxSkipHOC) return /* @__PURE__ */ _(t, {
|
|
32
|
+
value: k,
|
|
33
|
+
children: /* @__PURE__ */ _(e, {
|
|
34
|
+
value: O,
|
|
35
|
+
children: /* @__PURE__ */ _(v, { ...y })
|
|
36
|
+
})
|
|
30
37
|
});
|
|
31
|
-
let { settings: { previewMode:
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
38
|
+
let { settings: { previewMode: A, debugMode: j }, root: { baseElementId: M } } = p();
|
|
39
|
+
c(() => {
|
|
40
|
+
if (j) return g.markMounted(E), () => g.markUnmounted(E);
|
|
41
|
+
}, [j, E]);
|
|
42
|
+
let [N] = m(`schema.flat.${S}`);
|
|
43
|
+
if (!N) throw Error(`Element ${S} not found, Page ${M}`);
|
|
44
|
+
let { internalProps: P, customProps: F, children: I } = i({
|
|
45
|
+
element: N,
|
|
46
|
+
internalProps: y.internalProps,
|
|
47
|
+
children: y.children,
|
|
48
|
+
previewMode: A,
|
|
49
|
+
parentVisible: T
|
|
50
|
+
}), { attributes: L, definition: R, style: z, plitziElementLayout: B, elementState: V, setElementState: H } = P, U = u(() => ({ [`${S}_setState`]: H }), [S, H]);
|
|
51
|
+
f("element", U);
|
|
52
|
+
let W = T && n(V.visibility), G = u(() => ({
|
|
53
|
+
id: S,
|
|
54
|
+
rootId: C,
|
|
55
|
+
visible: W,
|
|
56
|
+
traceId: E,
|
|
57
|
+
attributes: L,
|
|
58
|
+
definition: R,
|
|
59
|
+
plitziElementLayout: B,
|
|
60
|
+
style: z,
|
|
61
|
+
elementState: V,
|
|
62
|
+
setElementState: H
|
|
52
63
|
}), [
|
|
53
|
-
P,
|
|
54
|
-
F,
|
|
55
|
-
R,
|
|
56
|
-
b,
|
|
57
64
|
L,
|
|
58
|
-
|
|
59
|
-
I,
|
|
60
|
-
z,
|
|
65
|
+
R,
|
|
61
66
|
V,
|
|
62
|
-
|
|
63
|
-
|
|
67
|
+
S,
|
|
68
|
+
B,
|
|
69
|
+
C,
|
|
70
|
+
z,
|
|
71
|
+
H,
|
|
72
|
+
W,
|
|
73
|
+
E
|
|
74
|
+
]), K = u(() => ({
|
|
75
|
+
visible: W,
|
|
76
|
+
traceId: E
|
|
77
|
+
}), [W, E]), q = u(() => {
|
|
64
78
|
let e = {
|
|
65
|
-
...
|
|
66
|
-
...
|
|
67
|
-
...
|
|
68
|
-
...
|
|
79
|
+
...P.attributes,
|
|
80
|
+
...y.extraProps,
|
|
81
|
+
...F,
|
|
82
|
+
...r(y, [
|
|
69
83
|
"plitziJsxSkipHOC",
|
|
70
84
|
"internalProps",
|
|
71
85
|
"className",
|
|
@@ -73,34 +87,37 @@ var g = (g) => {
|
|
|
73
87
|
"extraProps"
|
|
74
88
|
])
|
|
75
89
|
};
|
|
76
|
-
return
|
|
90
|
+
return I && (e = {
|
|
77
91
|
...e,
|
|
78
|
-
children:
|
|
79
|
-
}), /* @__PURE__ */
|
|
92
|
+
children: I
|
|
93
|
+
}), /* @__PURE__ */ _(a, { children: /* @__PURE__ */ _(v, {
|
|
80
94
|
...e,
|
|
81
|
-
ref:
|
|
95
|
+
ref: b
|
|
82
96
|
}) });
|
|
83
97
|
}, [
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
]),
|
|
89
|
-
value:
|
|
90
|
-
children:
|
|
98
|
+
P.attributes,
|
|
99
|
+
y,
|
|
100
|
+
F,
|
|
101
|
+
I
|
|
102
|
+
]), J = /* @__PURE__ */ _(t, {
|
|
103
|
+
value: K,
|
|
104
|
+
children: /* @__PURE__ */ _(e, {
|
|
105
|
+
value: G,
|
|
106
|
+
children: q
|
|
107
|
+
})
|
|
91
108
|
});
|
|
92
|
-
if (
|
|
93
|
-
|
|
109
|
+
if (j) {
|
|
110
|
+
g.linkParent(E, w?.traceId, S);
|
|
94
111
|
let e = {
|
|
95
|
-
attributes:
|
|
96
|
-
definition:
|
|
97
|
-
style:
|
|
98
|
-
elementState:
|
|
99
|
-
plitziElementLayout:
|
|
100
|
-
children:
|
|
101
|
-
...
|
|
102
|
-
...
|
|
103
|
-
...
|
|
112
|
+
attributes: L,
|
|
113
|
+
definition: R,
|
|
114
|
+
style: z,
|
|
115
|
+
elementState: V,
|
|
116
|
+
plitziElementLayout: B,
|
|
117
|
+
children: I,
|
|
118
|
+
...F,
|
|
119
|
+
...y.extraProps,
|
|
120
|
+
...r(y, [
|
|
104
121
|
"plitziJsxSkipHOC",
|
|
105
122
|
"internalProps",
|
|
106
123
|
"className",
|
|
@@ -108,15 +125,15 @@ var g = (g) => {
|
|
|
108
125
|
"extraProps"
|
|
109
126
|
])
|
|
110
127
|
};
|
|
111
|
-
return
|
|
112
|
-
id:
|
|
113
|
-
onRender:
|
|
114
|
-
children:
|
|
128
|
+
return g.recordProps(E, h(x.current, e)), x.current = e, /* @__PURE__ */ _(o, {
|
|
129
|
+
id: E,
|
|
130
|
+
onRender: g.onRender,
|
|
131
|
+
children: J
|
|
115
132
|
});
|
|
116
133
|
}
|
|
117
|
-
return
|
|
134
|
+
return J;
|
|
118
135
|
};
|
|
119
|
-
return
|
|
136
|
+
return b.displayName = `withElement(${y})`, b;
|
|
120
137
|
};
|
|
121
138
|
//#endregion
|
|
122
|
-
export {
|
|
139
|
+
export { v as default };
|
|
@@ -70,39 +70,39 @@ var f = (e, n, r = {}, i = {}) => {
|
|
|
70
70
|
},
|
|
71
71
|
style: o
|
|
72
72
|
};
|
|
73
|
-
}, p = ({ element: a, children: c, internalProps: l, previewMode: u = !1, parentVisible: d = !0 }) => {
|
|
74
|
-
let { id:
|
|
75
|
-
id:
|
|
73
|
+
}, p = ["variables"], m = (e) => Object.values(e ?? {}).some((e) => typeof e == "string" && u(e)), h = ({ element: a, children: c, internalProps: l, previewMode: u = !1, parentVisible: d = !0 }) => {
|
|
74
|
+
let { id: h } = l, { state: g, setElementState: _ } = r({
|
|
75
|
+
id: h,
|
|
76
76
|
bindings: a.definition.bindings,
|
|
77
77
|
previewMode: u
|
|
78
|
-
}), [[
|
|
78
|
+
}), v = o(() => m(a.attributes) || m(l.attributes), [a.attributes, l.attributes]), [[y, b, x]] = s([
|
|
79
79
|
"navigation.routeParams",
|
|
80
80
|
"navigation.queryParams",
|
|
81
81
|
"navigation.origin"
|
|
82
|
-
]),
|
|
82
|
+
], { enabled: v }), S = n({
|
|
83
83
|
bindings: a.definition.bindings,
|
|
84
|
-
sources:
|
|
85
|
-
}),
|
|
84
|
+
sources: v ? p : void 0
|
|
85
|
+
}), C = o(() => ({
|
|
86
86
|
...f(a, l, {
|
|
87
|
-
...
|
|
88
|
-
routeParams:
|
|
89
|
-
queryParams:
|
|
90
|
-
origin:
|
|
91
|
-
},
|
|
92
|
-
setElementState:
|
|
87
|
+
...S,
|
|
88
|
+
routeParams: y,
|
|
89
|
+
queryParams: b,
|
|
90
|
+
origin: x
|
|
91
|
+
}, g),
|
|
92
|
+
setElementState: _
|
|
93
93
|
}), [
|
|
94
94
|
a,
|
|
95
95
|
l,
|
|
96
|
+
S,
|
|
96
97
|
y,
|
|
98
|
+
b,
|
|
99
|
+
x,
|
|
97
100
|
g,
|
|
98
|
-
_
|
|
99
|
-
v,
|
|
100
|
-
m,
|
|
101
|
-
h
|
|
101
|
+
_
|
|
102
102
|
]);
|
|
103
103
|
return {
|
|
104
|
-
internalProps:
|
|
105
|
-
customProps: t(
|
|
104
|
+
internalProps: C,
|
|
105
|
+
customProps: t(C, [
|
|
106
106
|
"id",
|
|
107
107
|
"rootId",
|
|
108
108
|
"plitziElementLayout",
|
|
@@ -113,14 +113,14 @@ var f = (e, n, r = {}, i = {}) => {
|
|
|
113
113
|
"setElementState"
|
|
114
114
|
]),
|
|
115
115
|
children: i({
|
|
116
|
-
id:
|
|
117
|
-
definition:
|
|
118
|
-
plitziElementLayout:
|
|
116
|
+
id: h,
|
|
117
|
+
definition: C.definition,
|
|
118
|
+
plitziElementLayout: C.plitziElementLayout,
|
|
119
119
|
children: c,
|
|
120
120
|
previewMode: u,
|
|
121
|
-
visible: d && e(
|
|
121
|
+
visible: d && e(C.elementState.visibility)
|
|
122
122
|
})
|
|
123
123
|
};
|
|
124
124
|
};
|
|
125
125
|
//#endregion
|
|
126
|
-
export {
|
|
126
|
+
export { h as default, f as getProps };
|
|
@@ -1,60 +1,63 @@
|
|
|
1
1
|
import e, { getRemoteSettings as t } from "../helpers/pluginSelector.mjs";
|
|
2
|
-
import n from "../
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import f from "@plitzi/sdk-shared
|
|
8
|
-
import
|
|
2
|
+
import { useLayoutBody as n } from "../LayoutBody.mjs";
|
|
3
|
+
import r from "../ServerStaticShell.mjs";
|
|
4
|
+
import { Fragment as i, isValidElement as a, use as o, useMemo as s, useRef as c, useSyncExternalStore as l } from "react";
|
|
5
|
+
import { useCommonStore as u } from "@plitzi/sdk-shared/store";
|
|
6
|
+
import { get as d } from "@plitzi/plitzi-ui/helpers";
|
|
7
|
+
import { usePlitziServiceContext as f } from "@plitzi/sdk-shared";
|
|
8
|
+
import p from "@plitzi/sdk-shared/elements/ComponentContext";
|
|
9
|
+
import { jsx as m } from "react/jsx-runtime";
|
|
9
10
|
//#region src/Element/hooks/useInternalItems.tsx
|
|
10
|
-
var
|
|
11
|
-
let [[
|
|
12
|
-
|
|
13
|
-
let
|
|
14
|
-
return
|
|
15
|
-
if (!
|
|
16
|
-
let
|
|
17
|
-
let t =
|
|
11
|
+
var h = typeof window > "u", g = "#layout-body", _ = "#children", v = () => () => {}, y = () => !0, b = () => !1, x = ({ id: x, definition: S, plitziElementLayout: C, children: w, previewMode: T, visible: E = !0 }) => {
|
|
12
|
+
let [[D, O]] = u(["schema.flat", "rsc.enabled"], { mode: "mount" }), { components: k, componentDefinitions: A } = o(p), { contexts: { PluginsContext: j } } = f(), { plugins: M } = o(j), { items: N } = S, P = A.current[S.type], F = S.loadStrategy ?? P?.definition.loadStrategy ?? "eager", I = C || w || N?.length, L = c(!1);
|
|
13
|
+
E && (L.current = !0);
|
|
14
|
+
let R = !T || F === "eager" || E || F === "lazy" && L.current, z = C ? `${C.type}:${C.rootId}:${C.containerId}` : "", B = l(v, y, b), V = C?.containerId === x, H = n(V);
|
|
15
|
+
return s(() => {
|
|
16
|
+
if (!I || !R) return;
|
|
17
|
+
let n = (N ?? []).filter((e) => {
|
|
18
|
+
let t = D[e];
|
|
18
19
|
if (!t) return !1;
|
|
19
|
-
if (!
|
|
20
|
+
if (!T || !O) return !0;
|
|
20
21
|
let n = t.definition.runtime ?? "shared";
|
|
21
|
-
return !(!
|
|
22
|
-
}).map((
|
|
23
|
-
let { rootId: i, type: a, runtime: o } =
|
|
22
|
+
return !(!B && n === "client");
|
|
23
|
+
}).map((n) => {
|
|
24
|
+
let { rootId: i, type: a, runtime: o } = d(D, `${n}.definition`, {}), s = d(C, "rootId", i), c = a in k.current || !!t({
|
|
24
25
|
type: a,
|
|
25
|
-
plugins:
|
|
26
|
+
plugins: M
|
|
26
27
|
}), l = e({
|
|
27
|
-
key: !
|
|
28
|
-
plitziElementLayout:
|
|
28
|
+
key: !T && C ? `${n}_${z}` : n,
|
|
29
|
+
plitziElementLayout: C,
|
|
29
30
|
type: a,
|
|
30
31
|
internalProps: {
|
|
31
|
-
id:
|
|
32
|
+
id: n,
|
|
32
33
|
rootId: s
|
|
33
34
|
},
|
|
34
|
-
components:
|
|
35
|
-
plugins:
|
|
35
|
+
components: k.current,
|
|
36
|
+
plugins: M
|
|
36
37
|
});
|
|
37
|
-
return
|
|
38
|
-
id:
|
|
38
|
+
return O && o === "server" && !h && T && !(B && c) ? /* @__PURE__ */ m(r, {
|
|
39
|
+
id: n,
|
|
39
40
|
children: l
|
|
40
|
-
},
|
|
41
|
+
}, n) : l;
|
|
41
42
|
});
|
|
42
|
-
if (
|
|
43
|
+
if (V && n.push(/* @__PURE__ */ m(i, { children: H }, g)), Array.isArray(w) ? n.push(...w.filter(a)) : a(w) && n.push(/* @__PURE__ */ m(i, { children: w }, _)), N) return n.length === 1 ? n[0] : n;
|
|
43
44
|
}, [
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
S,
|
|
45
|
+
I,
|
|
46
|
+
R,
|
|
47
|
+
N,
|
|
48
48
|
C,
|
|
49
|
-
E,
|
|
50
49
|
w,
|
|
51
50
|
D,
|
|
52
|
-
|
|
53
|
-
R,
|
|
51
|
+
T,
|
|
54
52
|
O,
|
|
55
|
-
|
|
56
|
-
|
|
53
|
+
B,
|
|
54
|
+
z,
|
|
55
|
+
k,
|
|
56
|
+
M,
|
|
57
|
+
x,
|
|
58
|
+
V,
|
|
59
|
+
H
|
|
57
60
|
]);
|
|
58
61
|
};
|
|
59
62
|
//#endregion
|
|
60
|
-
export {
|
|
63
|
+
export { x as default };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { LayoutLink } from '@plitzi/sdk-shared/schema/layoutChain';
|
|
2
|
+
/**
|
|
3
|
+
* The shells around a page, innermost first — see `resolveLayoutChain`.
|
|
4
|
+
*
|
|
5
|
+
* Read from the store rather than from a subscription to the whole schema's value: a page re-rendered on every edit
|
|
6
|
+
* anywhere in the document would be the builder rebuilding the page on each keystroke. The chain is compared with the
|
|
7
|
+
* previous one, so the page renders again only when a shell in it changes which shell it sits in.
|
|
8
|
+
*/
|
|
9
|
+
declare const useLayoutChain: (layout: string, layoutContainer: string) => LayoutLink[];
|
|
10
|
+
export default useLayoutChain;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { useCallback as e, useContext as t, useRef as n, useSyncExternalStore as r } from "react";
|
|
2
|
+
import { StoreContext as i } from "@plitzi/nexus/react";
|
|
3
|
+
import { resolveLayoutChain as a } from "@plitzi/sdk-shared/schema/layoutChain";
|
|
4
|
+
//#region src/Element/hooks/useLayoutChain.ts
|
|
5
|
+
var o = [], s = (e, t) => e.length === t.length && e.every((e, n) => e.layout === t[n].layout && e.slot === t[n].slot), c = (e) => typeof e == "object" && !!e && "definition" in e && "attributes" in e, l = (e) => (t) => {
|
|
6
|
+
let n = e(`schema.flat.${t}`);
|
|
7
|
+
return c(n) ? n : void 0;
|
|
8
|
+
}, u = (c, u) => {
|
|
9
|
+
let d = t(i), f = n(o), p = e((e) => d ? d.subscribePath("schema.flat", e) : () => void 0, [d]), m = e(() => {
|
|
10
|
+
let e = c && d ? a(l((e) => d.getPath(e)), c, u) : o;
|
|
11
|
+
return s(f.current, e) || (f.current = e), f.current;
|
|
12
|
+
}, [
|
|
13
|
+
d,
|
|
14
|
+
c,
|
|
15
|
+
u
|
|
16
|
+
]);
|
|
17
|
+
return r(p, m, m);
|
|
18
|
+
};
|
|
19
|
+
//#endregion
|
|
20
|
+
export { u as default };
|