@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.
Files changed (53) hide show
  1. package/CHANGELOG.md +80 -0
  2. package/dist/Element/ElementParentContext.d.ts +13 -0
  3. package/dist/Element/ElementParentContext.mjs +6 -0
  4. package/dist/Element/LayoutBody.d.ts +21 -0
  5. package/dist/Element/LayoutBody.mjs +24 -0
  6. package/dist/Element/hocs/withElement.mjs +104 -87
  7. package/dist/Element/hooks/useElementDataSource.mjs +1 -1
  8. package/dist/Element/hooks/useElementInternal.mjs +24 -24
  9. package/dist/Element/hooks/useInternalItems.mjs +42 -39
  10. package/dist/Element/hooks/useLayoutChain.d.ts +10 -0
  11. package/dist/Element/hooks/useLayoutChain.mjs +20 -0
  12. package/dist/Element/hooks/useRootElementInteractions.mjs +45 -44
  13. package/dist/dataSource/GlobalSources.mjs +60 -59
  14. package/dist/dataSource/pathFields.d.ts +7 -0
  15. package/dist/dataSource/pathFields.mjs +8 -0
  16. package/dist/elements/advanced/Custom/declaration.d.ts +7 -9
  17. package/dist/elements/advanced/Custom/index.d.ts +1 -7
  18. package/dist/elements/advanced/Reference/Reference.mjs +93 -89
  19. package/dist/elements/advanced/Reference/declaration.d.ts +1 -1
  20. package/dist/elements/advanced/Reference/index.d.ts +1 -1
  21. package/dist/elements/basic/Button/Button.d.ts +9 -1
  22. package/dist/elements/basic/Button/Button.mjs +19 -20
  23. package/dist/elements/basic/Button/Settings.d.ts +2 -1
  24. package/dist/elements/basic/Button/Settings.mjs +13 -6
  25. package/dist/elements/basic/Button/declaration.d.ts +1 -0
  26. package/dist/elements/basic/Button/index.d.ts +1 -0
  27. package/dist/elements/declarations/index.d.ts +6 -9
  28. package/dist/elements/form/FormControl/declaration.d.ts +2 -0
  29. package/dist/elements/internal/LayoutContainer/LayoutContainer.d.ts +6 -0
  30. package/dist/elements/internal/LayoutContainer/LayoutContainer.mjs +31 -23
  31. package/dist/elements/internal/LayoutContainer/Settings.d.ts +4 -1
  32. package/dist/elements/internal/LayoutContainer/Settings.mjs +78 -64
  33. package/dist/elements/internal/LayoutContainer/declaration.d.ts +2 -0
  34. package/dist/elements/internal/LayoutContainer/index.d.ts +2 -0
  35. package/dist/elements/internal/LayoutPicker/LayoutPicker.d.ts +10 -0
  36. package/dist/elements/internal/LayoutPicker/LayoutPicker.mjs +35 -0
  37. package/dist/elements/internal/LayoutPicker/index.d.ts +3 -0
  38. package/dist/elements/internal/LayoutPicker/index.mjs +5 -0
  39. package/dist/elements/internal/Page/Page.mjs +49 -48
  40. package/dist/elements/internal/Page/Settings.mjs +101 -119
  41. package/dist/elements/provider/ApiContainer/ApiContainer.mjs +58 -66
  42. package/dist/elements/provider/ApiContainer/declaration.mjs +1 -1
  43. package/dist/elements/provider/ApiContainer/hooks/useApi.d.ts +8 -0
  44. package/dist/elements/provider/ApiContainer/hooks/useApi.mjs +52 -48
  45. package/dist/elements/structure/Container/Container.d.ts +1 -1
  46. package/dist/elements/structure/Container/Settings.d.ts +1 -1
  47. package/dist/elements/structure/Container/Settings.mjs +4 -0
  48. package/dist/elements/structure/Container/declaration.d.ts +1 -1
  49. package/dist/elements/structure/Container/index.d.ts +1 -1
  50. package/dist/elements/structure/DialogContainer/DialogContainer.mjs +17 -25
  51. package/dist/elements/structure/ModalContainer/ModalContainer.mjs +15 -23
  52. package/dist/index.d.ts +6 -9
  53. package/package.json +38 -10
@@ -1,28 +1,27 @@
1
1
  import e from "../../../Element/hocs/withElement.mjs";
2
- import t from "../../../Element/hooks/useElement.mjs";
3
- import { RootElement as n } from "../../../Element/RootElement.mjs";
4
- import { useMemo as r } from "react";
5
- import i from "@plitzi/sdk-shared/hooks/usePlitziServiceContext";
6
- import { jsxs as a } from "react/jsx-runtime";
7
- import o from "clsx";
2
+ import { RootElement as t } from "../../../Element/RootElement.mjs";
3
+ import n from "@plitzi/sdk-shared/hooks/usePlitziServiceContext";
4
+ import { jsxs as r } from "react/jsx-runtime";
5
+ import i from "clsx";
8
6
  //#region src/elements/basic/Button/Button.tsx
9
- var s = ({ ref: e, className: s = "", children: c, contentPlacement: l = "after", content: u = "Button", subType: d = "button", disabled: f = !1, ariaExpanded: p, ariaPressed: m }) => {
10
- let { definition: { label: h } } = t(), { settings: { previewMode: g } } = i(), _ = r(() => typeof u == "string" ? u : h, [u, h]);
11
- return /* @__PURE__ */ a(n, {
7
+ var a = ({ ref: e, className: a = "", children: o, contentPlacement: s = "after", content: c = "Button", subType: l = "button", disabled: u = !1, ariaExpanded: d, ariaPressed: f, title: p }) => {
8
+ let { settings: { previewMode: m } } = n();
9
+ return /* @__PURE__ */ r(t, {
12
10
  ref: e,
13
11
  tag: "button",
14
- type: g ? d : "button",
15
- className: o("plitzi-component__button", s, { "container--empty--skip": !g && !c && u }),
16
- disabled: f,
17
- "aria-label": _,
18
- "aria-expanded": p,
19
- "aria-pressed": m,
12
+ type: m ? l : "button",
13
+ className: i("plitzi-component__button", a, { "container--empty--skip": !m && !o && c }),
14
+ disabled: u,
15
+ "aria-label": c || void 0,
16
+ title: p || void 0,
17
+ "aria-expanded": d,
18
+ "aria-pressed": f,
20
19
  children: [
21
- l === "before" && u,
22
- c,
23
- l === "after" && u
20
+ s === "before" && c,
21
+ o,
22
+ s === "after" && c
24
23
  ]
25
24
  });
26
- }, c = e(s);
25
+ }, o = e(a);
27
26
  //#endregion
28
- export { s as Button, c as default };
27
+ export { a as Button, o as default };
@@ -3,7 +3,8 @@ type SettingsProps = {
3
3
  contentPlacement?: 'before' | 'after' | 'elements';
4
4
  subType?: 'button' | 'reset' | 'submit';
5
5
  disabled?: boolean;
6
+ title?: string;
6
7
  onUpdate?: (key: string, value: string | number | boolean) => void;
7
8
  };
8
- declare const Settings: ({ content, contentPlacement, subType, disabled, onUpdate }: SettingsProps) => import("react").JSX.Element;
9
+ declare const Settings: ({ content, contentPlacement, subType, disabled, title, onUpdate }: SettingsProps) => import("react").JSX.Element;
9
10
  export default Settings;
@@ -4,21 +4,28 @@ import r from "@plitzi/plitzi-ui/Checkbox";
4
4
  import i from "@plitzi/plitzi-ui/Input";
5
5
  import a from "@plitzi/plitzi-ui/Select";
6
6
  //#region src/elements/basic/Button/Settings.tsx
7
- var o = ({ content: o = "Button", contentPlacement: s = "after", subType: c = "button", disabled: l = !1, onUpdate: u }) => {
8
- let d = e((e) => u?.("content", e), [u]), f = e((e) => u?.("contentPlacement", e), [u]), p = e((e) => u?.("subType", e), [u]), m = e((e) => u?.("disabled", e.target.checked), [u]);
7
+ var o = ({ content: o = "Button", contentPlacement: s = "after", subType: c = "button", disabled: l = !1, title: u = "", onUpdate: d }) => {
8
+ let f = e((e) => d?.("content", e), [d]), p = e((e) => d?.("contentPlacement", e), [d]), m = e((e) => d?.("subType", e), [d]), h = e((e) => d?.("title", e), [d]), g = e((e) => d?.("disabled", e.target.checked), [d]);
9
9
  return /* @__PURE__ */ n("div", {
10
10
  className: "flex h-full flex-col gap-4 py-2",
11
11
  children: [
12
12
  /* @__PURE__ */ t(i, {
13
13
  value: o,
14
14
  label: "Content",
15
- onChange: d,
15
+ onChange: f,
16
+ size: "xs"
17
+ }),
18
+ /* @__PURE__ */ t(i, {
19
+ value: u,
20
+ label: "Tooltip",
21
+ placeholder: "What the button does, for an icon-only one",
22
+ onChange: h,
16
23
  size: "xs"
17
24
  }),
18
25
  /* @__PURE__ */ n(a, {
19
26
  value: s,
20
27
  label: "Mode",
21
- onChange: f,
28
+ onChange: p,
22
29
  size: "xs",
23
30
  children: [
24
31
  /* @__PURE__ */ t("option", {
@@ -38,7 +45,7 @@ var o = ({ content: o = "Button", contentPlacement: s = "after", subType: c = "b
38
45
  /* @__PURE__ */ n(a, {
39
46
  value: c,
40
47
  label: "Button Type",
41
- onChange: p,
48
+ onChange: m,
42
49
  size: "xs",
43
50
  children: [
44
51
  /* @__PURE__ */ t("option", {
@@ -58,7 +65,7 @@ var o = ({ content: o = "Button", contentPlacement: s = "after", subType: c = "b
58
65
  /* @__PURE__ */ t(r, {
59
66
  checked: l,
60
67
  label: "Is Disabled",
61
- onChange: m,
68
+ onChange: g,
62
69
  size: "xs"
63
70
  })
64
71
  ]
@@ -119,6 +119,7 @@ declare const declaration: {
119
119
  readonly settings: {};
120
120
  };
121
121
  } & import('@plitzi/sdk-shared/authoring/declare').ElementAttributesBrand<Partial<{
122
+ title?: string | undefined;
122
123
  content?: string | undefined;
123
124
  disabled?: boolean | undefined;
124
125
  subType?: "button" | "submit" | "reset" | undefined;
@@ -118,6 +118,7 @@ declare const Button: {
118
118
  readonly settings: {};
119
119
  };
120
120
  } & import('@plitzi/sdk-shared/authoring/declare').ElementAttributesBrand<Partial<{
121
+ title?: string | undefined;
121
122
  content?: string | undefined;
122
123
  disabled?: boolean | undefined;
123
124
  subType?: "button" | "submit" | "reset" | undefined;
@@ -319,6 +319,7 @@ export declare const elementDeclarations: {
319
319
  readonly settings: {};
320
320
  };
321
321
  } & import('@plitzi/sdk-shared/authoring/declare').ElementAttributesBrand<Partial<{
322
+ title?: string | undefined;
322
323
  content?: string | undefined;
323
324
  disabled?: boolean | undefined;
324
325
  subType?: "button" | "submit" | "reset" | undefined;
@@ -376,7 +377,7 @@ export declare const elementDeclarations: {
376
377
  readonly settings: {};
377
378
  };
378
379
  } & import('@plitzi/sdk-shared/authoring/declare').ElementAttributesBrand<Partial<{
379
- subType?: "div" | "header" | "footer" | "nav" | "main" | "section" | "article" | "aside" | "address" | "figure" | "dl" | "dt" | "dd" | undefined;
380
+ subType?: "div" | "header" | "footer" | "nav" | "main" | "section" | "article" | "aside" | "address" | "figure" | "dl" | "dt" | "dd" | "li" | undefined;
380
381
  }>>;
381
382
  readonly Custom: {
382
383
  readonly type: "custom";
@@ -429,13 +430,7 @@ export declare const elementDeclarations: {
429
430
  };
430
431
  readonly settings: {};
431
432
  };
432
- } & import('@plitzi/sdk-shared/authoring/declare').ElementAttributesBrand<Partial<{
433
- settings?: string | undefined;
434
- assets?: string | undefined;
435
- renderType?: string | undefined;
436
- isPlugin?: boolean | undefined;
437
- scriptUrl?: string | undefined;
438
- }>>;
433
+ } & import('@plitzi/sdk-shared/authoring/declare').ElementAttributesBrand<import('../advanced/Custom/declaration').CustomAttributes>;
439
434
  readonly DialogContainer: {
440
435
  readonly type: "dialogContainer";
441
436
  readonly sourceType: "dialogContainer";
@@ -1595,7 +1590,9 @@ export declare const elementDeclarations: {
1595
1590
  readonly settings: {};
1596
1591
  };
1597
1592
  } & import('@plitzi/sdk-shared/authoring/declare').ElementAttributesBrand<Partial<{
1593
+ layout?: string | undefined;
1598
1594
  subType?: "div" | "header" | "footer" | "nav" | "main" | "section" | "article" | "aside" | "address" | "figure" | undefined;
1595
+ layoutContainer?: string | undefined;
1599
1596
  }>>;
1600
1597
  readonly Link: {
1601
1598
  readonly type: "link";
@@ -2667,8 +2664,8 @@ export declare const elementDeclarations: {
2667
2664
  readonly settings: {};
2668
2665
  };
2669
2666
  } & import('@plitzi/sdk-shared/authoring/declare').ElementAttributesBrand<Partial<{
2670
- referenceId: string;
2671
2667
  referenceType: import('@plitzi/sdk-shared').ElementLayoutType;
2668
+ referenceId: string;
2672
2669
  referenceContainer: string;
2673
2670
  }>>;
2674
2671
  readonly RichText: {
@@ -3,6 +3,8 @@ import { AuthorableAttributes } from '@plitzi/sdk-shared/authoring/declare';
3
3
  /** What this element can be authored with — its component's own props, minus what the runtime supplies. */
4
4
  export type FormControlAttributes = AuthorableAttributes<FormControlProps, 'value' | 'error' | 'handleChange' | 'handleValidate'> & {
5
5
  defaultValue?: string;
6
+ /** Read by `withFieldValue`, not by the component: shows the control in its error state while editing. */
7
+ previewError?: boolean;
6
8
  };
7
9
  declare const declaration: {
8
10
  readonly type: "formControl";
@@ -1,6 +1,12 @@
1
1
  import { ReactNode, RefObject } from 'react';
2
2
  export type LayoutContainerProps = {
3
3
  ref?: RefObject<HTMLElement>;
4
+ /**
5
+ * The layout this one is shown inside, and the container in it that takes this one — the same pair a page names.
6
+ * Read by the page that renders the chain (`useLayoutChain`), not here.
7
+ */
8
+ layout?: string;
9
+ layoutContainer?: string;
4
10
  className?: string;
5
11
  children?: ReactNode;
6
12
  subType?: 'div' | 'header' | 'footer' | 'nav' | 'main' | 'section' | 'article' | 'aside' | 'address' | 'figure';
@@ -7,41 +7,49 @@ import { throttle as o } from "@plitzi/plitzi-ui/helpers";
7
7
  import { jsx as s } from "react/jsx-runtime";
8
8
  import c from "clsx";
9
9
  //#region src/elements/internal/LayoutContainer/LayoutContainer.tsx
10
- var l = ({ ref: e, className: l = "", children: u, subType: d = "div" }) => {
11
- let { plitziElementLayout: f } = t(), { settings: { previewMode: p } } = a(), m = r((e, t) => {
12
- if (!e || !t) return;
13
- let n = t.getBoundingClientRect(), r = n.top - 0, i = n.left - 0, a = i + n.width + 0, o = r + n.height + 0, s = `
10
+ var l = ".plitzi-component__layout-container", u = ".plitzi-component--layout-body", d = (e) => [...e.querySelectorAll(u)].find((e) => !e.querySelector(u)) ?? null, f = ({ ref: e, className: u = "", children: f, subType: p = "div" }) => {
11
+ let { plitziElementLayout: m } = t(), { settings: { previewMode: h } } = a(), g = r((e, t) => {
12
+ if (!e) return;
13
+ if (!t) {
14
+ e.style.removeProperty("--child-clip");
15
+ return;
16
+ }
17
+ let n = e.getBoundingClientRect(), r = t.getBoundingClientRect(), i = e.offsetWidth > 0 ? n.width / e.offsetWidth : 1, a = (r.top - n.top) / i, o = (r.left - n.left) / i, s = o + r.width / i, c = a + r.height / i, l = `
14
18
  polygon(
15
19
  evenodd,
16
20
  /* outer rect */
17
21
  0 0, 100% 0, 100% 100%, 0% 100%, 0 0,
18
22
  /* inner rect */
19
- ${i}px ${r}px, ${a}px ${r}px, ${a}px ${o}px, ${i}px ${o}px, ${i}px ${r}px
23
+ ${o}px ${a}px, ${s}px ${a}px, ${s}px ${c}px, ${o}px ${c}px, ${o}px ${a}px
20
24
  )`;
21
- e.style.setProperty("--child-clip", s);
25
+ e.style.setProperty("--child-clip", l);
22
26
  }, []);
23
27
  return i(() => {
24
- if (!f || !e?.current || p) return;
25
- let t = o(() => {
26
- let t = e.current, n = t.querySelector(".plitzi-component--layout-body");
27
- m(t, n);
28
- }, 150), n = new ResizeObserver(t);
29
- n.observe(e.current);
30
- let r = e.current.querySelector(".plitzi-component--layout-body");
31
- return r && n.observe(r), () => {
32
- t.cancel(), n.disconnect();
28
+ let t = e?.current;
29
+ if (!m || !t || h || t.parentElement?.closest(l)) return;
30
+ let n = null, r = o(() => {
31
+ let e = d(t);
32
+ e !== n && (n && i.unobserve(n), e && i.observe(e), n = e), g(t, e);
33
+ }, 50), i = new ResizeObserver(r);
34
+ i.observe(t);
35
+ let a = new MutationObserver(r);
36
+ return a.observe(t, {
37
+ childList: !0,
38
+ subtree: !0
39
+ }), t.addEventListener("scroll", r, !0), r(), () => {
40
+ r.cancel(), i.disconnect(), a.disconnect(), t.removeEventListener("scroll", r, !0);
33
41
  };
34
42
  }, [
35
- f,
36
- p,
43
+ m,
44
+ h,
37
45
  e,
38
- m
46
+ g
39
47
  ]), /* @__PURE__ */ s(n, {
40
48
  ref: e,
41
- tag: d,
42
- className: c("plitzi-component__layout-container", l),
43
- children: u
49
+ tag: p,
50
+ className: c("plitzi-component__layout-container", u),
51
+ children: f
44
52
  });
45
- }, u = e(l);
53
+ }, p = e(f);
46
54
  //#endregion
47
- export { l as LayoutContainer, u as default };
55
+ export { f as LayoutContainer, p as default };
@@ -1,7 +1,10 @@
1
1
  type SettingsProps = {
2
+ id?: string;
3
+ layout?: string;
4
+ layoutContainer?: string;
2
5
  subType?: 'div' | 'header' | 'footer' | 'nav' | 'main' | 'section' | 'article' | 'aside' | 'address' | 'figure';
3
6
  folder?: string;
4
7
  onUpdate?: (key: string, value: string | boolean | number) => void;
5
8
  };
6
- declare const Settings: ({ subType, folder, onUpdate }: SettingsProps) => import("react").JSX.Element;
9
+ declare const Settings: ({ id, layout, layoutContainer, subType, folder, onUpdate }: SettingsProps) => import("react").JSX.Element;
7
10
  export default Settings;
@@ -1,73 +1,87 @@
1
- import { useCallback as e, useMemo as t } from "react";
2
- import { useCommonStore as n } from "@plitzi/sdk-shared/store";
3
- import { jsx as r, jsxs as i } from "react/jsx-runtime";
4
- import a from "@plitzi/plitzi-ui/Select";
5
- import o from "@plitzi/plitzi-ui/Select2";
1
+ import e from "../LayoutPicker/index.mjs";
2
+ import { useCallback as t, useMemo as n } from "react";
3
+ import { useCommonStore as r } from "@plitzi/sdk-shared/store";
4
+ import { jsx as i, jsxs as a } from "react/jsx-runtime";
5
+ import o from "@plitzi/plitzi-ui/Select";
6
+ import s from "@plitzi/plitzi-ui/Select2";
6
7
  //#region src/elements/internal/LayoutContainer/Settings.tsx
7
- var s = ({ subType: s = "div", folder: c = "", onUpdate: l }) => {
8
- let [u] = n("schema.pageFolders"), d = e((e) => l?.("subType", e), [l]), f = e((e) => l?.("folder", e?.value ?? ""), [l]), p = t(() => [{
8
+ var c = ({ id: c, layout: l = "", layoutContainer: u = "", subType: d = "div", folder: f = "", onUpdate: p }) => {
9
+ let [m] = r("schema.pageFolders"), h = t((e) => p?.("subType", e), [p]), g = t((e) => p?.("folder", e?.value ?? ""), [p]), _ = n(() => [{
9
10
  value: "",
10
11
  label: "None"
11
- }, ...u.map(({ id: e, name: t }) => ({
12
+ }, ...m.map(({ id: e, name: t }) => ({
12
13
  value: e,
13
14
  label: t
14
- }))], [u]);
15
- return /* @__PURE__ */ i("div", {
15
+ }))], [m]);
16
+ return /* @__PURE__ */ a("div", {
16
17
  className: "flex flex-col gap-4 py-2",
17
- children: [/* @__PURE__ */ i(a, {
18
- value: s,
19
- label: "Container Tag",
20
- onChange: d,
21
- children: [
22
- /* @__PURE__ */ r("option", {
23
- value: "div",
24
- children: "Div"
25
- }),
26
- /* @__PURE__ */ r("option", {
27
- value: "header",
28
- children: "Header"
29
- }),
30
- /* @__PURE__ */ r("option", {
31
- value: "footer",
32
- children: "Footer"
33
- }),
34
- /* @__PURE__ */ r("option", {
35
- value: "nav",
36
- children: "Nav"
37
- }),
38
- /* @__PURE__ */ r("option", {
39
- value: "main",
40
- children: "Main"
41
- }),
42
- /* @__PURE__ */ r("option", {
43
- value: "section",
44
- children: "Section"
45
- }),
46
- /* @__PURE__ */ r("option", {
47
- value: "article",
48
- children: "Article"
49
- }),
50
- /* @__PURE__ */ r("option", {
51
- value: "aside",
52
- children: "Aside"
53
- }),
54
- /* @__PURE__ */ r("option", {
55
- value: "address",
56
- children: "Address"
57
- }),
58
- /* @__PURE__ */ r("option", {
59
- value: "figure",
60
- children: "Figure"
61
- })
62
- ]
63
- }), /* @__PURE__ */ r(o, {
64
- label: "Folder",
65
- value: c,
66
- options: p,
67
- placeholder: "None",
68
- onChange: f
69
- })]
18
+ children: [
19
+ /* @__PURE__ */ a(o, {
20
+ value: d,
21
+ label: "Container Tag",
22
+ onChange: h,
23
+ children: [
24
+ /* @__PURE__ */ i("option", {
25
+ value: "div",
26
+ children: "Div"
27
+ }),
28
+ /* @__PURE__ */ i("option", {
29
+ value: "header",
30
+ children: "Header"
31
+ }),
32
+ /* @__PURE__ */ i("option", {
33
+ value: "footer",
34
+ children: "Footer"
35
+ }),
36
+ /* @__PURE__ */ i("option", {
37
+ value: "nav",
38
+ children: "Nav"
39
+ }),
40
+ /* @__PURE__ */ i("option", {
41
+ value: "main",
42
+ children: "Main"
43
+ }),
44
+ /* @__PURE__ */ i("option", {
45
+ value: "section",
46
+ children: "Section"
47
+ }),
48
+ /* @__PURE__ */ i("option", {
49
+ value: "article",
50
+ children: "Article"
51
+ }),
52
+ /* @__PURE__ */ i("option", {
53
+ value: "aside",
54
+ children: "Aside"
55
+ }),
56
+ /* @__PURE__ */ i("option", {
57
+ value: "address",
58
+ children: "Address"
59
+ }),
60
+ /* @__PURE__ */ i("option", {
61
+ value: "figure",
62
+ children: "Figure"
63
+ })
64
+ ]
65
+ }),
66
+ /* @__PURE__ */ i(s, {
67
+ label: "Folder",
68
+ value: f,
69
+ options: _,
70
+ placeholder: "None",
71
+ onChange: g
72
+ }),
73
+ /* @__PURE__ */ i(e, {
74
+ layout: l,
75
+ layoutContainer: u,
76
+ ownLayoutId: c,
77
+ onUpdate: p
78
+ }),
79
+ /* @__PURE__ */ i("span", {
80
+ className: "text-xs text-gray-500 dark:text-zinc-400",
81
+ children: "A layout can sit inside another one: pages using this layout are shown inside it, and it inside the one picked here — the outer shell stays mounted while moving between pages that share it."
82
+ })
83
+ ]
70
84
  });
71
85
  };
72
86
  //#endregion
73
- export { s as default };
87
+ export { c as default };
@@ -52,6 +52,8 @@ declare const declaration: {
52
52
  readonly settings: {};
53
53
  };
54
54
  } & import('@plitzi/sdk-shared/authoring/declare').ElementAttributesBrand<Partial<{
55
+ layout?: string | undefined;
55
56
  subType?: "div" | "header" | "footer" | "nav" | "main" | "section" | "article" | "aside" | "address" | "figure" | undefined;
57
+ layoutContainer?: string | undefined;
56
58
  }>>;
57
59
  export default declaration;
@@ -51,6 +51,8 @@ declare const LayoutContainer: {
51
51
  readonly settings: {};
52
52
  };
53
53
  } & import('@plitzi/sdk-shared/authoring/declare').ElementAttributesBrand<Partial<{
54
+ layout?: string | undefined;
54
55
  subType?: "div" | "header" | "footer" | "nav" | "main" | "section" | "article" | "aside" | "address" | "figure" | undefined;
56
+ layoutContainer?: string | undefined;
55
57
  }>>;
56
58
  export default LayoutContainer;
@@ -0,0 +1,10 @@
1
+ export type LayoutPickerProps = {
2
+ layout?: string;
3
+ layoutContainer?: string;
4
+ /** The layout being edited, when it is one: it cannot sit in itself, nor in a shell that already sits in it. */
5
+ ownLayoutId?: string;
6
+ onUpdate?: (key: string, value: string) => void;
7
+ };
8
+ /** Which shell something is rendered inside, and the container in that shell its content goes into. */
9
+ declare const LayoutPicker: ({ layout, layoutContainer, ownLayoutId, onUpdate }: LayoutPickerProps) => import("react").JSX.Element;
10
+ export default LayoutPicker;
@@ -0,0 +1,35 @@
1
+ import { useCallback as e, useMemo as t } from "react";
2
+ import { useCommonStore as n } from "@plitzi/sdk-shared/store";
3
+ import { get as r } from "@plitzi/plitzi-ui/helpers";
4
+ import { Fragment as i, jsx as a, jsxs as o } from "react/jsx-runtime";
5
+ import { resolveLayoutChain as s } from "@plitzi/sdk-shared/schema/layoutChain";
6
+ import c from "@plitzi/plitzi-ui/Select";
7
+ //#region src/elements/internal/LayoutPicker/LayoutPicker.tsx
8
+ var l = ({ layout: l = "", layoutContainer: u = "", ownLayoutId: d, onUpdate: f }) => {
9
+ let [p] = n("schema.flat"), m = t(() => Object.values(p).filter((e) => r(e, "definition.type", "") === "layoutContainer" && (!d || !s((e) => p[e], e.id, "").some((e) => e.layout === d))), [p, d]), h = t(() => l ? Object.values(p).filter((e) => r(e, "definition.type", "") === "container" && r(e, "definition.rootId", "") === l) : [], [p, l]), g = e((e) => {
10
+ f?.("layout", e), f?.("layoutContainer", "");
11
+ }, [f]), _ = e((e) => f?.("layoutContainer", e), [f]);
12
+ return /* @__PURE__ */ o(i, { children: [/* @__PURE__ */ a(c, {
13
+ value: l,
14
+ placeholder: "None",
15
+ label: "Layout",
16
+ onChange: g,
17
+ size: "xs",
18
+ children: m.map(({ id: e, definition: { label: t } }) => /* @__PURE__ */ a("option", {
19
+ value: e,
20
+ children: t
21
+ }, e))
22
+ }), l && /* @__PURE__ */ a(c, {
23
+ value: u,
24
+ placeholder: "None",
25
+ label: "Layout Container Body",
26
+ onChange: _,
27
+ size: "xs",
28
+ children: h.map(({ id: e, definition: { label: t } }) => /* @__PURE__ */ a("option", {
29
+ value: e,
30
+ children: t
31
+ }, e))
32
+ })] });
33
+ };
34
+ //#endregion
35
+ export { l as default };
@@ -0,0 +1,3 @@
1
+ import { default as LayoutPicker } from './LayoutPicker';
2
+ export * from './LayoutPicker';
3
+ export default LayoutPicker;
@@ -0,0 +1,5 @@
1
+ import e from "./LayoutPicker.mjs";
2
+ //#region src/elements/internal/LayoutPicker/index.ts
3
+ var t = e;
4
+ //#endregion
5
+ export { t as default };