@plitzi/sdk-elements 0.36.1 → 0.37.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/CHANGELOG.md +80 -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/useElementDataSource.mjs +1 -1
- 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/Custom/declaration.d.ts +7 -9
- package/dist/elements/advanced/Custom/index.d.ts +1 -7
- 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/basic/Button/Button.d.ts +9 -1
- package/dist/elements/basic/Button/Button.mjs +19 -20
- package/dist/elements/basic/Button/Settings.d.ts +2 -1
- package/dist/elements/basic/Button/Settings.mjs +13 -6
- package/dist/elements/basic/Button/declaration.d.ts +1 -0
- package/dist/elements/basic/Button/index.d.ts +1 -0
- package/dist/elements/declarations/index.d.ts +6 -9
- package/dist/elements/form/FormControl/declaration.d.ts +2 -0
- 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/Container/Container.d.ts +1 -1
- package/dist/elements/structure/Container/Settings.d.ts +1 -1
- package/dist/elements/structure/Container/Settings.mjs +4 -0
- package/dist/elements/structure/Container/declaration.d.ts +1 -1
- package/dist/elements/structure/Container/index.d.ts +1 -1
- package/dist/elements/structure/DialogContainer/DialogContainer.mjs +17 -25
- package/dist/elements/structure/ModalContainer/ModalContainer.mjs +15 -23
- package/dist/index.d.ts +6 -9
- package/package.json +38 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,85 @@
|
|
|
1
1
|
# @plitzi/sdk-elements
|
|
2
2
|
|
|
3
|
+
## 0.37.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- - A `button` takes a `title`: shown as a tooltip, and its accessible name when it has no text of its own — an
|
|
8
|
+
icon-only button without one was announced as nothing. The builder's settings offer it as "Tooltip". The JSON export
|
|
9
|
+
is two files, `schema.json` and `style.json`, shown as tabs; each group of changes in the export folds away.
|
|
10
|
+
|
|
11
|
+
- `BindingTransformer.params` is `Record<string, string | number | boolean>`: a param the builder draws as a checkbox
|
|
12
|
+
(`styleVariant`'s `append`) is stored as the boolean it is and read as one, so the type now says so. The MCP compares
|
|
13
|
+
such a param with its catalog options as text. A `container` may be an `li`, for the rows of a list. The export
|
|
14
|
+
keeps every element id with `keepIds`, and the header's Publish dialog opens wider.
|
|
15
|
+
|
|
16
|
+
- **The builder exports the space on screen — on paid plans.** **Export** in the header opens a wide dialog: the
|
|
17
|
+
format as tabs (TypeScript in one file, TypeScript with a file per page as a `.zip`, or JSON), generated as soon as
|
|
18
|
+
it is picked, shown read-only in CodeMirror — beside a file list when there are several — with one row of actions,
|
|
19
|
+
**Copy** and **Download**. What the export tidied is a one-line note that unfolds into readable groups. On the free
|
|
20
|
+
plan the dialog explains what export is instead; the server refuses the code with a 402 (`limit: 'spaceExport'`)
|
|
21
|
+
whatever the builder shows. `useSpaceExport` is the one way into it, for anything else that needs the space as files.
|
|
22
|
+
|
|
23
|
+
- **A space document can be read back into code.** `specFromSpace(documents)` turns a `{ schema, style }` pair — a
|
|
24
|
+
builder export, a seed checked in as JSON — into the `SpaceSpec` that authors it, and `specToSource(spec, { exportName })`
|
|
25
|
+
writes that spec out as the TypeScript a person would write: one factory call per element, the attributes a type
|
|
26
|
+
already defaults to left out, the longhands the document stores written back as `padding: 10px 20px`, and every class
|
|
27
|
+
something names as a `styles()` declaration held in a variable. `split: true` writes one file per page and per layout.
|
|
28
|
+
`compareSpaces(expected, actual)` proves the round trip: it lists every way two pairs render differently — the tree,
|
|
29
|
+
the attributes, the rules that apply to each element whatever its selector is called, bindings, flows, pages, layouts
|
|
30
|
+
and settings — and nothing else. A selector used by one element becomes that element's own `css`; one shared, or
|
|
31
|
+
spelled out anywhere in the document (a `customCss` rule, a template), stays a class under its own name; an element id
|
|
32
|
+
nothing refers to is left out and derived again.
|
|
33
|
+
|
|
34
|
+
What an older builder left behind is repaired on the way, and every repair is reported in `corrections` rather than
|
|
35
|
+
made silently: element types that no longer exist (`navbar` → a `list` laid out in a row, `navbarItem` → `listItem`),
|
|
36
|
+
a hover stored as a class of its own (`card:hover`) folded into the class, fields and attributes no component reads,
|
|
37
|
+
a setting nothing reads, a link `target` of `_blank` (the component adds the underscore, so it rendered as `__blank`),
|
|
38
|
+
`null` or an empty list where an attribute is unset, a binding to a source nothing publishes, a flow with a step that
|
|
39
|
+
runs nothing, and a global callback registered on the wrong module. A CSS property the style editor cannot hold is
|
|
40
|
+
kept in `customCss` under the same selector, so the page still renders it.
|
|
41
|
+
|
|
42
|
+
- **What a spec can say grew to what a document holds.** A selector carries its states and variants beside its rules —
|
|
43
|
+
`styles('card', { css, states: { hover }, variants: { active } })`, and `states` on an element's own `css` — and the
|
|
44
|
+
selector cache is now written by `processSelector`, the function the style editor writes it with. An element type's
|
|
45
|
+
defaults (`elements`) take states, variants, per-breakpoint rules and `slots` for its other selectors (a modal's
|
|
46
|
+
`rootContainer`). A space declares `layouts` — shells that pages render inside, named by `layout: { id, slot }` on a
|
|
47
|
+
page or on another layout, with the slot checked to be inside the shell — and a page takes `keepState` and
|
|
48
|
+
`stateStorage`. `visible: false` starts an element hidden for a flow to reveal, and `loadStrategy` is carried through.
|
|
49
|
+
An element's own selector never takes the name of a declared class any more, however that class happens to be called.
|
|
50
|
+
|
|
51
|
+
- `elementAttributeNames` lists, as data, the attributes each built-in element can be authored with — `null` for one
|
|
52
|
+
that takes any. It is generated from the elements' attribute types (`yarn generate:attribute-names`) and a type test
|
|
53
|
+
fails when the two disagree. `defaultAttributes(type)` and `defaultLabel(type)` expose what a factory fills in.
|
|
54
|
+
|
|
55
|
+
- `CustomAttributes` accepts any attribute, because the component a custom element's `renderType` names reads its own
|
|
56
|
+
attributes off it; and `FormControlAttributes` declares `previewError`, which `withFieldValue` reads.
|
|
57
|
+
|
|
58
|
+
### Patch Changes
|
|
59
|
+
|
|
60
|
+
- Updated dependencies
|
|
61
|
+
- @plitzi/sdk-auth@0.37.0
|
|
62
|
+
- @plitzi/sdk-dev-tools@0.37.0
|
|
63
|
+
- @plitzi/sdk-event-bridge@0.37.0
|
|
64
|
+
- @plitzi/sdk-interactions@0.37.0
|
|
65
|
+
- @plitzi/sdk-navigation@0.37.0
|
|
66
|
+
- @plitzi/sdk-schema@0.37.0
|
|
67
|
+
- @plitzi/sdk-shared@0.37.0
|
|
68
|
+
|
|
69
|
+
## 0.36.2
|
|
70
|
+
|
|
71
|
+
### Patch Changes
|
|
72
|
+
|
|
73
|
+
- v0.36.2
|
|
74
|
+
- Updated dependencies
|
|
75
|
+
- @plitzi/sdk-auth@0.36.2
|
|
76
|
+
- @plitzi/sdk-dev-tools@0.36.2
|
|
77
|
+
- @plitzi/sdk-event-bridge@0.36.2
|
|
78
|
+
- @plitzi/sdk-interactions@0.36.2
|
|
79
|
+
- @plitzi/sdk-navigation@0.36.2
|
|
80
|
+
- @plitzi/sdk-schema@0.36.2
|
|
81
|
+
- @plitzi/sdk-shared@0.36.2
|
|
82
|
+
|
|
3
83
|
## 0.36.1
|
|
4
84
|
|
|
5
85
|
### Patch 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 };
|
|
@@ -8,7 +8,7 @@ var r = ({ source: e, transformers: t }) => {
|
|
|
8
8
|
let t = e.indexOf(".");
|
|
9
9
|
r.push(t > -1 ? e.substring(0, t) : e);
|
|
10
10
|
}
|
|
11
|
-
for (let { action: e, params: i } of t ?? []) e === "twigTemplate" && i.template && r.push(...n(i.template));
|
|
11
|
+
for (let { action: e, params: i } of t ?? []) e === "twigTemplate" && typeof i.template == "string" && i.template && r.push(...n(i.template));
|
|
12
12
|
return r;
|
|
13
13
|
}, i = ({ bindings: n, sources: i }) => {
|
|
14
14
|
let a = e(() => {
|
|
@@ -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 };
|