@alpaca-headless/alpaca-headless-nextjs 1.0.27 → 1.0.129

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 (238) hide show
  1. package/dist/cjs/client-components/ClientLink.js +36 -0
  2. package/dist/cjs/client-components/MultiComponentEditor.js +26 -0
  3. package/dist/cjs/client-components/index.js +19 -0
  4. package/dist/cjs/components/Link.js +1 -1
  5. package/dist/cjs/components/LinkEditor.js +47 -1
  6. package/dist/cjs/components/Picture.js +14 -12
  7. package/dist/cjs/components/PictureEditor.js +20 -39
  8. package/dist/cjs/components/Placeholder.js +51 -9
  9. package/dist/cjs/components/RichText.js +1 -1
  10. package/dist/cjs/components/RichTextEditor.js +17 -2
  11. package/dist/cjs/components/TextEditor.js +15 -3
  12. package/dist/cjs/components/Translate.js +1 -1
  13. package/dist/cjs/{editor → components}/TranslateEditor.js +5 -2
  14. package/dist/cjs/editor/AiPopup.js +33 -0
  15. package/dist/cjs/editor/AiTerminal.js +42 -18
  16. package/dist/cjs/editor/ComponentInfo.js +4 -3
  17. package/dist/cjs/editor/ComponentPalette.js +12 -68
  18. package/dist/cjs/editor/ComponentTree.js +76 -59
  19. package/dist/cjs/editor/ConfirmationDialog.js +31 -0
  20. package/dist/cjs/editor/ContentTree.js +144 -49
  21. package/dist/cjs/editor/Debug.js +12 -2
  22. package/dist/cjs/editor/DialogButtons.js +7 -0
  23. package/dist/cjs/editor/DictionaryEditor.js +14 -8
  24. package/dist/cjs/editor/EditFrame.js +88 -20
  25. package/dist/cjs/editor/EditHistory.js +17 -4
  26. package/dist/cjs/editor/Editor.js +1 -1
  27. package/dist/cjs/editor/EditorClient.js +506 -237
  28. package/dist/cjs/editor/EditorClientHost.js +2 -2
  29. package/dist/cjs/editor/FieldList.js +30 -43
  30. package/dist/cjs/editor/FieldListField.js +75 -0
  31. package/dist/cjs/editor/FloatingToolbar.js +92 -0
  32. package/dist/cjs/editor/GraphQL.js +4 -6
  33. package/dist/cjs/editor/ItemEditor.js +9 -0
  34. package/dist/cjs/editor/ItemInfo.js +17 -0
  35. package/dist/cjs/editor/ItemNameDialog.js +37 -0
  36. package/dist/cjs/editor/LanguageSelector.js +1 -1
  37. package/dist/cjs/editor/LinkEditorDialog.js +67 -0
  38. package/dist/cjs/editor/MainLayout.js +24 -0
  39. package/dist/cjs/editor/MediaSelector.js +35 -10
  40. package/dist/cjs/editor/PictureEditorDialog.js +93 -0
  41. package/dist/cjs/editor/PlaceholderDropZone.js +48 -9
  42. package/dist/cjs/editor/SidebarTabs.js +47 -0
  43. package/dist/cjs/editor/Terminal.js +21 -11
  44. package/dist/cjs/editor/Utils.js +43 -0
  45. package/dist/cjs/editor/VersionSelector.js +1 -1
  46. package/dist/cjs/editor/Workbox.js +41 -0
  47. package/dist/cjs/editor/componentCommands.js +141 -0
  48. package/dist/cjs/editor/contentService.js +45 -3
  49. package/dist/cjs/editor/editContext.js +9 -4
  50. package/dist/cjs/editor/editService.js +187 -3
  51. package/dist/cjs/editor/fieldTypes/CheckboxEditor.js +21 -0
  52. package/dist/cjs/editor/fieldTypes/InternalLinkFieldEditor.js +46 -0
  53. package/dist/cjs/editor/fieldTypes/LinkFieldEditor.js +55 -0
  54. package/dist/cjs/editor/fieldTypes/MultiLineText.js +25 -0
  55. package/dist/cjs/editor/fieldTypes/PictureFieldEditor.js +19 -0
  56. package/dist/cjs/editor/fieldTypes/RichTextEditor.js +9 -4
  57. package/dist/cjs/editor/fieldTypes/SingleLineText.js +12 -4
  58. package/dist/cjs/editor/fieldTypes/TreeListEditor.js +59 -0
  59. package/dist/cjs/editor/ui/Section.js +8 -0
  60. package/dist/cjs/loadRouteData.js +24 -14
  61. package/dist/cjs/middleware/authorization.js +52 -0
  62. package/dist/cjs/middleware/index.js +17 -0
  63. package/dist/editor.css +530 -72
  64. package/dist/primereact/resources/themes/arya-blue/theme.css +103 -91
  65. package/dist/primereact/resources/themes/arya-green/theme.css +103 -91
  66. package/dist/primereact/resources/themes/arya-orange/theme.css +103 -91
  67. package/dist/primereact/resources/themes/arya-purple/theme.css +103 -91
  68. package/dist/primereact/resources/themes/bootstrap4-dark-blue/theme.css +103 -91
  69. package/dist/primereact/resources/themes/bootstrap4-dark-purple/theme.css +103 -91
  70. package/dist/primereact/resources/themes/bootstrap4-light-blue/theme.css +102 -90
  71. package/dist/primereact/resources/themes/bootstrap4-light-purple/theme.css +102 -90
  72. package/dist/primereact/resources/themes/fluent-light/theme.css +103 -91
  73. package/dist/primereact/resources/themes/lara-dark-amber/fonts/Inter-italic.var.woff2 +0 -0
  74. package/dist/primereact/resources/themes/lara-dark-amber/fonts/Inter-roman.var.woff2 +0 -0
  75. package/dist/primereact/resources/themes/lara-dark-amber/theme.css +6049 -0
  76. package/dist/primereact/resources/themes/lara-dark-blue/theme.css +1006 -955
  77. package/dist/primereact/resources/themes/lara-dark-cyan/fonts/Inter-italic.var.woff2 +0 -0
  78. package/dist/primereact/resources/themes/lara-dark-cyan/fonts/Inter-roman.var.woff2 +0 -0
  79. package/dist/primereact/resources/themes/lara-dark-cyan/theme.css +6049 -0
  80. package/dist/primereact/resources/themes/lara-dark-green/fonts/Inter-italic.var.woff2 +0 -0
  81. package/dist/primereact/resources/themes/lara-dark-green/fonts/Inter-roman.var.woff2 +0 -0
  82. package/dist/primereact/resources/themes/lara-dark-green/theme.css +6049 -0
  83. package/dist/primereact/resources/themes/lara-dark-indigo/theme.css +1006 -955
  84. package/dist/primereact/resources/themes/lara-dark-pink/fonts/Inter-italic.var.woff2 +0 -0
  85. package/dist/primereact/resources/themes/lara-dark-pink/fonts/Inter-roman.var.woff2 +0 -0
  86. package/dist/primereact/resources/themes/lara-dark-pink/theme.css +6049 -0
  87. package/dist/primereact/resources/themes/lara-dark-purple/theme.css +1006 -955
  88. package/dist/primereact/resources/themes/lara-dark-teal/theme.css +1006 -955
  89. package/dist/primereact/resources/themes/lara-light-amber/fonts/Inter-italic.var.woff2 +0 -0
  90. package/dist/primereact/resources/themes/lara-light-amber/fonts/Inter-roman.var.woff2 +0 -0
  91. package/dist/primereact/resources/themes/lara-light-amber/theme.css +6041 -0
  92. package/dist/primereact/resources/themes/lara-light-blue/theme.css +842 -799
  93. package/dist/primereact/resources/themes/lara-light-cyan/fonts/Inter-italic.var.woff2 +0 -0
  94. package/dist/primereact/resources/themes/lara-light-cyan/fonts/Inter-roman.var.woff2 +0 -0
  95. package/dist/primereact/resources/themes/lara-light-cyan/theme.css +6041 -0
  96. package/dist/primereact/resources/themes/lara-light-green/fonts/Inter-italic.var.woff2 +0 -0
  97. package/dist/primereact/resources/themes/lara-light-green/fonts/Inter-roman.var.woff2 +0 -0
  98. package/dist/primereact/resources/themes/lara-light-green/theme.css +6041 -0
  99. package/dist/primereact/resources/themes/lara-light-indigo/theme.css +842 -799
  100. package/dist/primereact/resources/themes/lara-light-pink/fonts/Inter-italic.var.woff2 +0 -0
  101. package/dist/primereact/resources/themes/lara-light-pink/fonts/Inter-roman.var.woff2 +0 -0
  102. package/dist/primereact/resources/themes/lara-light-pink/theme.css +6041 -0
  103. package/dist/primereact/resources/themes/lara-light-purple/theme.css +842 -799
  104. package/dist/primereact/resources/themes/lara-light-teal/theme.css +1115 -1072
  105. package/dist/primereact/resources/themes/luna-amber/theme.css +103 -91
  106. package/dist/primereact/resources/themes/luna-blue/theme.css +103 -91
  107. package/dist/primereact/resources/themes/luna-green/theme.css +103 -91
  108. package/dist/primereact/resources/themes/luna-pink/theme.css +103 -91
  109. package/dist/primereact/resources/themes/md-dark-deeppurple/theme.css +147 -135
  110. package/dist/primereact/resources/themes/md-dark-indigo/theme.css +147 -135
  111. package/dist/primereact/resources/themes/md-light-deeppurple/theme.css +147 -135
  112. package/dist/primereact/resources/themes/md-light-indigo/theme.css +147 -135
  113. package/dist/primereact/resources/themes/mdc-dark-deeppurple/theme.css +147 -135
  114. package/dist/primereact/resources/themes/mdc-dark-indigo/theme.css +147 -135
  115. package/dist/primereact/resources/themes/mdc-light-deeppurple/theme.css +147 -135
  116. package/dist/primereact/resources/themes/mdc-light-indigo/theme.css +147 -135
  117. package/dist/primereact/resources/themes/mira/theme.css +108 -91
  118. package/dist/primereact/resources/themes/nano/theme.css +107 -91
  119. package/dist/primereact/resources/themes/nova/theme.css +103 -91
  120. package/dist/primereact/resources/themes/nova-accent/theme.css +103 -91
  121. package/dist/primereact/resources/themes/nova-alt/theme.css +103 -91
  122. package/dist/primereact/resources/themes/rhea/theme.css +103 -91
  123. package/dist/primereact/resources/themes/saga-blue/theme.css +103 -91
  124. package/dist/primereact/resources/themes/saga-green/theme.css +103 -91
  125. package/dist/primereact/resources/themes/saga-orange/theme.css +103 -91
  126. package/dist/primereact/resources/themes/saga-purple/theme.css +103 -91
  127. package/dist/primereact/resources/themes/soho-dark/theme.css +108 -91
  128. package/dist/primereact/resources/themes/soho-light/theme.css +108 -91
  129. package/dist/primereact/resources/themes/vela-blue/theme.css +103 -91
  130. package/dist/primereact/resources/themes/vela-green/theme.css +103 -91
  131. package/dist/primereact/resources/themes/vela-orange/theme.css +103 -91
  132. package/dist/primereact/resources/themes/vela-purple/theme.css +103 -91
  133. package/dist/primereact/resources/themes/viva-dark/theme.css +103 -91
  134. package/dist/primereact/resources/themes/viva-light/theme.css +103 -91
  135. package/package.json +29 -16
  136. package/tailwind.config.js +9 -2
  137. package/types/client-components/ClientLink.d.ts +6 -0
  138. package/types/client-components/MultiComponentEditor.d.ts +10 -0
  139. package/types/client-components/index.d.ts +2 -0
  140. package/types/components/Picture.d.ts +1 -0
  141. package/types/components/Placeholder.d.ts +16 -2
  142. package/types/components/RichTextEditor.d.ts +55 -55
  143. package/types/components/TextEditor.d.ts +54 -54
  144. package/types/editor/AiPopup.d.ts +10 -0
  145. package/types/editor/AiTerminal.d.ts +4 -3
  146. package/types/editor/ComponentPalette.d.ts +3 -4
  147. package/types/editor/ComponentTree.d.ts +1 -1
  148. package/types/editor/ConfirmationDialog.d.ts +19 -0
  149. package/types/editor/ContentTree.d.ts +7 -3
  150. package/types/editor/Debug.d.ts +1 -1
  151. package/types/editor/DialogButtons.d.ts +4 -0
  152. package/types/editor/DictionaryEditor.d.ts +3 -2
  153. package/types/editor/EditFrame.d.ts +4 -3
  154. package/types/editor/EditorClient.d.ts +4 -4
  155. package/types/editor/EditorClientHost.d.ts +4 -3
  156. package/types/editor/FieldListField.d.ts +4 -0
  157. package/types/editor/FloatingToolbar.d.ts +7 -0
  158. package/types/editor/ItemEditor.d.ts +4 -0
  159. package/types/editor/ItemInfo.d.ts +4 -0
  160. package/types/editor/ItemNameDialog.d.ts +10 -0
  161. package/types/editor/LinkEditorDialog.d.ts +15 -0
  162. package/types/editor/MainLayout.d.ts +6 -0
  163. package/types/editor/MediaSelector.d.ts +2 -1
  164. package/types/editor/PictureEditorDialog.d.ts +6 -0
  165. package/types/editor/SidebarTabs.d.ts +8 -0
  166. package/types/editor/Terminal.d.ts +3 -1
  167. package/types/editor/Utils.d.ts +3 -0
  168. package/types/editor/Workbox.d.ts +6 -0
  169. package/types/editor/componentCommands.d.ts +4 -0
  170. package/types/editor/contentService.d.ts +7 -1
  171. package/types/editor/editContext.d.ts +90 -19
  172. package/types/editor/editService.d.ts +9 -1
  173. package/types/editor/fieldTypes/CheckboxEditor.d.ts +4 -0
  174. package/types/editor/fieldTypes/InternalLinkFieldEditor.d.ts +4 -0
  175. package/types/editor/fieldTypes/LinkFieldEditor.d.ts +4 -0
  176. package/types/editor/fieldTypes/MultiLineText.d.ts +4 -0
  177. package/types/editor/fieldTypes/PictureFieldEditor.d.ts +4 -0
  178. package/types/editor/fieldTypes/TreeListEditor.d.ts +4 -0
  179. package/types/editor/ui/Section.d.ts +5 -0
  180. package/types/fieldTypes.d.ts +30 -15
  181. package/types/layoutData.d.ts +34 -9
  182. package/types/loadRouteData.d.ts +34 -5
  183. package/types/mediaProtection.d.ts +1 -0
  184. package/types/middleware/authorization.d.ts +2 -0
  185. package/types/middleware/index.d.ts +1 -0
  186. package/dist/cjs/editor/PageInfo.js +0 -12
  187. package/dist/esm/alpacaContext.js +0 -8
  188. package/dist/esm/components/Error.js +0 -10
  189. package/dist/esm/components/Image.js +0 -32
  190. package/dist/esm/components/Link.js +0 -29
  191. package/dist/esm/components/LinkEditor.js +0 -19
  192. package/dist/esm/components/Picture.js +0 -118
  193. package/dist/esm/components/PictureEditor.js +0 -64
  194. package/dist/esm/components/Placeholder.js +0 -69
  195. package/dist/esm/components/RichText.js +0 -40
  196. package/dist/esm/components/RichTextEditor.js +0 -52
  197. package/dist/esm/components/Slot.js +0 -5
  198. package/dist/esm/components/Text.js +0 -39
  199. package/dist/esm/components/TextEditor.js +0 -38
  200. package/dist/esm/components/Translate.js +0 -10
  201. package/dist/esm/components/index.js +0 -7
  202. package/dist/esm/editor/AiTerminal.js +0 -157
  203. package/dist/esm/editor/ComponentInfo.js +0 -10
  204. package/dist/esm/editor/ComponentPalette.js +0 -72
  205. package/dist/esm/editor/ComponentTree.js +0 -196
  206. package/dist/esm/editor/ContentTree.js +0 -117
  207. package/dist/esm/editor/Debug.js +0 -9
  208. package/dist/esm/editor/DictionaryEditor.js +0 -31
  209. package/dist/esm/editor/EditFrame.js +0 -57
  210. package/dist/esm/editor/EditHistory.js +0 -26
  211. package/dist/esm/editor/Editor.js +0 -23
  212. package/dist/esm/editor/EditorClient.js +0 -477
  213. package/dist/esm/editor/EditorClientHost.js +0 -7
  214. package/dist/esm/editor/FieldList.js +0 -60
  215. package/dist/esm/editor/GraphQL.js +0 -82
  216. package/dist/esm/editor/LanguageSelector.js +0 -17
  217. package/dist/esm/editor/MediaSelector.js +0 -60
  218. package/dist/esm/editor/PageInfo.js +0 -8
  219. package/dist/esm/editor/PlaceholderDropZone.js +0 -50
  220. package/dist/esm/editor/PlaceholderDropZoneHost.js +0 -7
  221. package/dist/esm/editor/Terminal.js +0 -47
  222. package/dist/esm/editor/TranslateEditor.js +0 -21
  223. package/dist/esm/editor/VersionSelector.js +0 -17
  224. package/dist/esm/editor/componentTreeHelper.js +0 -14
  225. package/dist/esm/editor/contentService.js +0 -31
  226. package/dist/esm/editor/editContext.js +0 -5
  227. package/dist/esm/editor/editService.js +0 -139
  228. package/dist/esm/editor/fieldTypes/RichTextEditor.js +0 -15
  229. package/dist/esm/editor/fieldTypes/SingleLineText.js +0 -13
  230. package/dist/esm/editor/index.js +0 -2
  231. package/dist/esm/fieldTypes.js +0 -1
  232. package/dist/esm/graphQLTypes.js +0 -1
  233. package/dist/esm/index.js +0 -7
  234. package/dist/esm/layoutData.js +0 -1
  235. package/dist/esm/loadRouteData.js +0 -123
  236. package/dist/esm/mediaProtection.js +0 -49
  237. package/types/editor/PageInfo.d.ts +0 -4
  238. /package/types/{editor → components}/TranslateEditor.d.ts +0 -0
@@ -1,29 +0,0 @@
1
- var __rest = (this && this.__rest) || function (s, e) {
2
- var t = {};
3
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
- t[p] = s[p];
5
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
- t[p[i]] = s[p[i]];
9
- }
10
- return t;
11
- };
12
- import { jsx as _jsx } from "react/jsx-runtime";
13
- import { useAlpacaContext } from "..";
14
- import LinkEditor from "./LinkEditor";
15
- export function Link(_a) {
16
- var _b;
17
- var { field, children } = _a, props = __rest(_a, ["field", "children"]);
18
- if (!field)
19
- return;
20
- if (field.jsonValue) {
21
- field = field.jsonValue;
22
- }
23
- if (!field.value)
24
- return;
25
- const editing = (_b = useAlpacaContext().pageContext) === null || _b === void 0 ? void 0 : _b.pageEditing;
26
- if (editing)
27
- return (_jsx(LinkEditor, Object.assign({ field: field, children: children }, props)));
28
- return (_jsx("a", Object.assign({ href: field.value.url }, props, { children: children })));
29
- }
@@ -1,19 +0,0 @@
1
- "use client";
2
- var __rest = (this && this.__rest) || function (s, e) {
3
- var t = {};
4
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
- t[p] = s[p];
6
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
- t[p[i]] = s[p[i]];
10
- }
11
- return t;
12
- };
13
- import { jsx as _jsx } from "react/jsx-runtime";
14
- export default function LinkEditor(_a) {
15
- var { field, children } = _a, props = __rest(_a, ["field", "children"]);
16
- if (!field)
17
- return;
18
- return (_jsx("a", Object.assign({ href: field.value.url }, props, { onClick: (e) => e.preventDefault(), children: children })));
19
- }
@@ -1,118 +0,0 @@
1
- var __rest = (this && this.__rest) || function (s, e) {
2
- var t = {};
3
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
- t[p] = s[p];
5
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
- t[p[i]] = s[p[i]];
9
- }
10
- return t;
11
- };
12
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
13
- import { hashImageUrl } from "../mediaProtection";
14
- import { useAlpacaContext } from "..";
15
- import { PictureEditor } from "./PictureEditor";
16
- // const addClassName = (otherAttrs: { [key: string]: unknown }): void => {
17
- // if (otherAttrs.class) {
18
- // // if any classes are defined properly already
19
- // if (otherAttrs.className) {
20
- // let className: string = otherAttrs.className as string;
21
- // className += ` ${otherAttrs.class}`;
22
- // otherAttrs.className = className;
23
- // } else {
24
- // otherAttrs.className = otherAttrs.class;
25
- // }
26
- // delete otherAttrs.class;
27
- // }
28
- // };
29
- export const Picture = (_a) => {
30
- var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
31
- var { field, imageParams, sources, defaultVariant, renderJsonLinkedData } = _a, otherProps = __rest(_a, ["field", "imageParams", "sources", "defaultVariant", "renderJsonLinkedData"]);
32
- if (!field)
33
- return null;
34
- if (field.jsonValue) {
35
- field = field.jsonValue;
36
- }
37
- if ((_b = useAlpacaContext().pageContext) === null || _b === void 0 ? void 0 : _b.pageEditing)
38
- return _jsx(PictureEditor, Object.assign({ field: field }, otherProps));
39
- const variants = (_c = field.value) === null || _c === void 0 ? void 0 : _c.variants;
40
- const img = (_e = (_d = field.value) === null || _d === void 0 ? void 0 : _d.variants.find((x) => x.name.toUpperCase() == (defaultVariant === null || defaultVariant === void 0 ? void 0 : defaultVariant.toUpperCase()))) !== null && _e !== void 0 ? _e : (_f = field.value) === null || _f === void 0 ? void 0 : _f.variants[0];
41
- const attrs = Object.assign({ src: img === null || img === void 0 ? void 0 : img.src }, otherProps);
42
- const video = img === null || img === void 0 ? void 0 : img.videoUrl;
43
- const videoAttr = Object.assign({ src: video }, otherProps);
44
- if (!(sources === null || sources === void 0 ? void 0 : sources.length)) {
45
- return _jsx("img", Object.assign({}, attrs, { alt: (_g = field.value) === null || _g === void 0 ? void 0 : _g.alt }));
46
- }
47
- else {
48
- return (_jsxs(_Fragment, { children: [_jsxs("picture", { children: [sources === null || sources === void 0 ? void 0 : sources.map((source) => {
49
- const variant = variants === null || variants === void 0 ? void 0 : variants.find((v) => v.name.toLowerCase() == source.variant.toLowerCase());
50
- if (!(variant === null || variant === void 0 ? void 0 : variant.src))
51
- return;
52
- let srcSet = hashImageUrl(variant.src);
53
- const getScaledImage = (variant, width) => {
54
- if (width > variant.width)
55
- return { src: variant.src, width: 0 };
56
- else
57
- return {
58
- src: variant.src +
59
- `${variant.src.includes("?") ? "&" : "?"}mw=` +
60
- width,
61
- width: width,
62
- };
63
- };
64
- if (source.widths && source.widths.length) {
65
- let scaledImages = source.widths.map((x) => getScaledImage(variant, x));
66
- srcSet = "";
67
- for (let w = 0; w < scaledImages.length; w++) {
68
- if (srcSet.length)
69
- srcSet = srcSet + ", ";
70
- srcSet +=
71
- hashImageUrl(scaledImages[w].src) +
72
- " " +
73
- source.widths[w] +
74
- "w";
75
- if (scaledImages[w].width === 0)
76
- break;
77
- }
78
- }
79
- else {
80
- if (source.width) {
81
- srcSet = hashImageUrl(getScaledImage(variant, source.width).src);
82
- if (source.scales) {
83
- let scaledImages = source.scales.map((x) => { var _a; return getScaledImage(variant, ((_a = source.width) !== null && _a !== void 0 ? _a : 0) * x); });
84
- srcSet = "";
85
- for (let w = 0; w < scaledImages.length; w++) {
86
- if (srcSet.length)
87
- srcSet = srcSet + ", ";
88
- srcSet +=
89
- hashImageUrl(scaledImages[w].src) +
90
- " " +
91
- source.scales[w] +
92
- "x";
93
- if (scaledImages[w].width === 0)
94
- break;
95
- }
96
- }
97
- }
98
- }
99
- return (_jsx("source", { srcSet: srcSet, media: source.media }, source.variant + source.media));
100
- }), _jsx("img", Object.assign({}, attrs, { alt: (_h = field.value) === null || _h === void 0 ? void 0 : _h.alt }))] }), renderJsonLinkedData && !video ? (_jsx("script", { type: "application/ld+json", dangerouslySetInnerHTML: {
101
- __html: JSON.stringify({
102
- "@context": "http://schema.org",
103
- "@type": "ImageObject",
104
- image: img === null || img === void 0 ? void 0 : img.src,
105
- description: (_j = field.value) === null || _j === void 0 ? void 0 : _j.alt,
106
- name: (_k = field.value) === null || _k === void 0 ? void 0 : _k.name,
107
- }),
108
- } })) : null, video && _jsx("video", Object.assign({}, videoAttr)), renderJsonLinkedData && video ? (_jsx("script", { type: "application/ld+json", dangerouslySetInnerHTML: {
109
- __html: JSON.stringify({
110
- "@context": "http://schema.org",
111
- "@type": "VideoObject",
112
- contentUrl: img === null || img === void 0 ? void 0 : img.src,
113
- description: (_l = field.value) === null || _l === void 0 ? void 0 : _l.alt,
114
- name: (_m = field.value) === null || _m === void 0 ? void 0 : _m.name,
115
- }),
116
- } })) : null] }));
117
- }
118
- };
@@ -1,64 +0,0 @@
1
- "use client";
2
- var __rest = (this && this.__rest) || function (s, e) {
3
- var t = {};
4
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
- t[p] = s[p];
6
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
- t[p[i]] = s[p[i]];
10
- }
11
- return t;
12
- };
13
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
14
- import { useEffect, useState } from "react";
15
- import { Picture } from "./Picture";
16
- import { useEditContext } from "..";
17
- import { MediaSelector } from "../editor/MediaSelector";
18
- import { Dialog } from "primereact/dialog";
19
- import { Button } from "primereact/button";
20
- export const PictureEditor = (_a) => {
21
- var _b, _c;
22
- var { field, imageParams, sources, defaultVariant, renderJsonLinkedData } = _a, otherProps = __rest(_a, ["field", "imageParams", "sources", "defaultVariant", "renderJsonLinkedData"]);
23
- const editContext = useEditContext();
24
- const [mediaSelectorVisible, setMediaSelectorVisible] = useState(false);
25
- const [editorVisible, setEditorVisible] = useState(false);
26
- const [selectedVariant, setSelectedVariant] = useState();
27
- if (!editContext)
28
- return;
29
- function imageSelected(imageId) {
30
- if (!selectedVariant)
31
- return;
32
- const value = (field === null || field === void 0 ? void 0 : field.rawValue)
33
- ? JSON.parse(field === null || field === void 0 ? void 0 : field.rawValue)
34
- : { variants: [] };
35
- const selected = value.variants.find((x) => x.name == selectedVariant.name);
36
- if (!selected) {
37
- value.variants.push({
38
- name: selectedVariant.name,
39
- mediaId: imageId,
40
- });
41
- }
42
- else {
43
- selected.mediaId = imageId;
44
- }
45
- console.log(imageId);
46
- console.log(JSON.stringify(value));
47
- if (field) {
48
- editContext === null || editContext === void 0 ? void 0 : editContext.editField(field, JSON.stringify(value), false);
49
- editContext === null || editContext === void 0 ? void 0 : editContext.requestRefresh("immediate");
50
- }
51
- }
52
- useEffect(() => {
53
- var _a;
54
- setSelectedVariant((_a = field === null || field === void 0 ? void 0 : field.value) === null || _a === void 0 ? void 0 : _a.variants[0]);
55
- }, []);
56
- console.log("Picture Field: " + JSON.stringify(field));
57
- return (_jsxs(_Fragment, { children: [_jsx(MediaSelector, { visible: mediaSelectorVisible, onHide: () => setMediaSelectorVisible(false), onMediaSelected: imageSelected }), _jsx(Dialog, { header: "Edit picture", visible: editorVisible, style: { width: "50vw", height: "50vh" }, onHide: () => setEditorVisible(false), children: _jsxs("div", { className: "a-flex a-gap-1 a-flex-col a-justify a-h-full", children: [_jsxs("div", { className: "a-flex-1 a-flex a-gap-1", children: [_jsx("div", { className: "a-flex a-flex-col a-gap-1 a-h-full a-border-r", children: (_c = (_b = field === null || field === void 0 ? void 0 : field.value) === null || _b === void 0 ? void 0 : _b.variants) === null || _c === void 0 ? void 0 : _c.map((variant) => (_jsxs("div", { onClick: () => setSelectedVariant(variant), children: [_jsxs("div", { className: "a-h-24 a-w-24 a-border a-relative" +
58
- (selectedVariant == variant ? " a-shadow-xl " : ""), children: [variant.src && _jsx("img", { src: variant.thumbSrc }), _jsx("div", { className: "a-absolute a-top-0 a-right-0 ", children: _jsx("i", { className: "pi pi-pencil a-m-1 a-cursor-pointer", onClick: () => setMediaSelectorVisible(true) }) })] }, variant.name), _jsx("div", { children: variant.name }), _jsx("div", { children: variant.aspectRatioText })] }))) }), _jsx("div", { className: "a-flex-1 a-relative", children: _jsx("div", { className: "a-absolute a-inset-0 a-overflow-auto", children: selectedVariant && _jsx("img", { src: selectedVariant.src }) }) })] }), _jsxs("div", { className: "a-flex a-justify-end a-gap-3 a-mt-3", children: [_jsx(Button, { onClick: () => {
59
- setEditorVisible(false);
60
- }, children: "Ok" }), _jsx(Button, { onClick: () => {
61
- setEditorVisible(false);
62
- editContext === null || editContext === void 0 ? void 0 : editContext.requestRefresh("immediate");
63
- }, children: "Cancel" })] })] }) }), _jsx("span", Object.assign({}, otherProps, { onClick: () => setEditorVisible(true), className: "a-cursor-pointer", children: _jsx(Picture, { field: field, imageParams: imageParams, sources: sources }) }))] }));
64
- };
@@ -1,69 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
11
- import { EditFrame } from "../editor/EditFrame";
12
- import { useAlpacaContext, } from "..";
13
- import { PlaceholderDropZoneHost } from "../editor/PlaceholderDropZoneHost";
14
- import Slot from "./Slot";
15
- import { ErrorBoundary } from "react-error-boundary";
16
- import { ErrorFallbackWithDetails, ErrorFallback } from "./Error";
17
- export function Placeholder({ name, content, }) {
18
- return __awaiter(this, void 0, void 0, function* () {
19
- const data = yield content;
20
- if (!data || !("placeholders" in data))
21
- return;
22
- const placeholderData = data.placeholders.find((x) => x.name == name);
23
- if (!placeholderData)
24
- return;
25
- const context = useAlpacaContext();
26
- const loader = context.componentModuleLoader;
27
- const promises = placeholderData === null || placeholderData === void 0 ? void 0 : placeholderData.components.map((component) => __awaiter(this, void 0, void 0, function* () {
28
- if (component.componentType == "Slot")
29
- return { Component: Slot, data: component, parent: data };
30
- let module = null;
31
- try {
32
- module = yield loader(component.componentType);
33
- }
34
- catch (e) {
35
- console.log(e);
36
- }
37
- if (!module) {
38
- console.log("Could not find module " + component.componentType);
39
- return {
40
- data: { name: component.componentType, id: "0" },
41
- Component: ComponentNotFound,
42
- };
43
- }
44
- return { parent: data, data: component, Component: module.default };
45
- }));
46
- const components = yield Promise.all(promises);
47
- if (context.pageContext.pageEditing) {
48
- return (_jsxs(_Fragment, { children: [components.map(({ Component, data, parent }, index) => {
49
- try {
50
- return (_jsxs(_Fragment, { children: [_jsx(PlaceholderDropZoneHost, { parentName: parent === null || parent === void 0 ? void 0 : parent.name, placeholder: placeholderData, index: index + 1 }), _jsx(EditFrame, { componentId: data.id, children: _jsx(ErrorBoundary, { FallbackComponent: ErrorFallbackWithDetails, children: _jsx(Component, { component: data }) }) }, data.id)] }));
51
- }
52
- catch (e) {
53
- return (_jsxs("div", { children: ["Error rendering component ", data.name, ": ", e.message] }));
54
- }
55
- }), _jsx(PlaceholderDropZoneHost, { parentName: data === null || data === void 0 ? void 0 : data.name, placeholder: placeholderData, index: components.length + 1 })] }));
56
- }
57
- else
58
- return (_jsx(_Fragment, { children: components.map(({ Component, data }) => (_jsx(_Fragment, { children: _jsx(ErrorBoundary, { FallbackComponent: ErrorFallback, children: _jsx(Component, { component: data }) }) }))) }));
59
- });
60
- }
61
- function ComponentNotFound({ component }) {
62
- return (_jsxs("div", { style: {
63
- backgroundColor: "orange",
64
- color: "red",
65
- fontSize: 18,
66
- padding: 10,
67
- border: "3px solid red",
68
- }, children: ["Component not found: ", component.name, " "] }));
69
- }
@@ -1,40 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- var __rest = (this && this.__rest) || function (s, e) {
11
- var t = {};
12
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
13
- t[p] = s[p];
14
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
15
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
16
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
17
- t[p[i]] = s[p[i]];
18
- }
19
- return t;
20
- };
21
- import { jsx as _jsx } from "react/jsx-runtime";
22
- import React from "react";
23
- import { RichTextEditor } from "./RichTextEditor";
24
- import { useAlpacaContext } from "..";
25
- export function RichText(_a) {
26
- var { field, tag, editable } = _a, props = __rest(_a, ["field", "tag", "editable"]);
27
- return __awaiter(this, void 0, void 0, function* () {
28
- if (!field)
29
- return;
30
- if (field.jsonValue) {
31
- field = field.jsonValue;
32
- }
33
- const internalProps = Object.assign(Object.assign({}, props), { dangerouslySetInnerHTML: {
34
- __html: field.value,
35
- }, editable: editable, contentEditable: true, "data-test": "test", placeholder: "[" + field.name + "]" });
36
- if (useAlpacaContext().pageContext.pageEditing)
37
- return _jsx(RichTextEditor, Object.assign({ field: field, tag: tag }, props));
38
- return React.createElement(tag || "div", Object.assign(props, internalProps));
39
- });
40
- }
@@ -1,52 +0,0 @@
1
- "use client";
2
- var __rest = (this && this.__rest) || function (s, e) {
3
- var t = {};
4
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
- t[p] = s[p];
6
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
- t[p[i]] = s[p[i]];
10
- }
11
- return t;
12
- };
13
- import React, { useEffect, useState, useMemo, useCallback } from "react";
14
- import { useEditContext } from "../editor/editContext";
15
- export function RichTextEditor(_a) {
16
- var { field, tag } = _a, props = __rest(_a, ["field", "tag"]);
17
- const editContext = useEditContext();
18
- const [value, setValue] = useState("");
19
- const [editedValue, setEditedValue] = useState();
20
- if (!editContext)
21
- return;
22
- const { updateContentEditingFields } = editContext;
23
- const liveField = editContext.getLiveField(field);
24
- useEffect(() => {
25
- if (editedValue != liveField.value &&
26
- "<p>" + editedValue + "</p>" != liveField.value) {
27
- // console.log(
28
- // "editedValue:" + editedValue + " liveField.value " + liveField.value
29
- // );
30
- setValue(liveField.value);
31
- }
32
- }, [liveField.value]);
33
- useEffect(() => {
34
- setValue(liveField.value); // Otherwise react would not update the field after the refresh
35
- }, [updateContentEditingFields]);
36
- const setFieldValue = (val) => {
37
- if (val != editedValue) {
38
- setEditedValue(val);
39
- if (editContext)
40
- editContext.editField(field, val, true);
41
- }
42
- };
43
- const eventHandler = useCallback((e) => {
44
- setFieldValue(e.currentTarget.innerHTML);
45
- }, [editContext.editField]);
46
- return useMemo(() => {
47
- const properies = Object.assign(Object.assign({}, props), { contentEditable: true, suppressContentEditableWarning: true, onInput: eventHandler, placeholder: "[" + field.name + "]", dangerouslySetInnerHTML: {
48
- __html: value,
49
- } });
50
- return React.createElement(tag || "div", properies);
51
- }, [value]);
52
- }
@@ -1,5 +0,0 @@
1
- import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { Placeholder } from "..";
3
- export default function Section({ component }) {
4
- return (_jsx(_Fragment, { children: _jsx(Placeholder, { name: "ph-slot-content", content: component }) }));
5
- }
@@ -1,39 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- var __rest = (this && this.__rest) || function (s, e) {
11
- var t = {};
12
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
13
- t[p] = s[p];
14
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
15
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
16
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
17
- t[p[i]] = s[p[i]];
18
- }
19
- return t;
20
- };
21
- import { jsx as _jsx } from "react/jsx-runtime";
22
- import React from "react";
23
- import { TextEditor } from "./TextEditor";
24
- import { useAlpacaContext } from "..";
25
- export function Text(_a) {
26
- var { field, tag, editable } = _a, props = __rest(_a, ["field", "tag", "editable"]);
27
- return __awaiter(this, void 0, void 0, function* () {
28
- if (!field)
29
- return;
30
- if (field.jsonValue) {
31
- field = field.jsonValue;
32
- }
33
- if (useAlpacaContext().pageContext.pageEditing) {
34
- return (_jsx("div", { children: _jsx(TextEditor, Object.assign({ field: field, tag: tag }, props)) }));
35
- }
36
- else
37
- return React.createElement(tag || "div", props, field.value);
38
- });
39
- }
@@ -1,38 +0,0 @@
1
- "use client";
2
- var __rest = (this && this.__rest) || function (s, e) {
3
- var t = {};
4
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
- t[p] = s[p];
6
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
- t[p[i]] = s[p[i]];
10
- }
11
- return t;
12
- };
13
- import React, { useEffect, useState } from "react";
14
- import { useEditContext } from "../editor/editContext";
15
- export function TextEditor(_a) {
16
- var { field, tag } = _a, props = __rest(_a, ["field", "tag"]);
17
- const editContext = useEditContext();
18
- const [value, setValue] = useState("");
19
- const [editedValue, setEditedValue] = useState();
20
- if (!editContext)
21
- return;
22
- const { updateContentEditingFields } = editContext;
23
- const liveField = editContext.getLiveField(field);
24
- useEffect(() => {
25
- if (editedValue != liveField.value)
26
- setValue(liveField.value);
27
- }, [liveField.value]);
28
- useEffect(() => {
29
- setValue(liveField.value); // Otherwise react would not update the field after the refresh
30
- }, [updateContentEditingFields]);
31
- const properies = Object.assign(Object.assign({}, props), { contentEditable: true, suppressContentEditableWarning: true, onInput: (e) => setFieldValue(e.currentTarget.textContent), placeholder: "[" + field.name + "]" });
32
- const setFieldValue = (val) => {
33
- setEditedValue(val);
34
- if (editContext)
35
- editContext.editField(field, val, true);
36
- };
37
- return React.createElement(tag || "div", properies, value);
38
- }
@@ -1,10 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { useAlpacaContext } from "..";
3
- import { TranslateEditor } from "../editor/TranslateEditor";
4
- export function Translate({ text }) {
5
- const context = useAlpacaContext();
6
- const dictionary = context.dictionary;
7
- if (context.pageContext.pageEditing)
8
- return _jsx(TranslateEditor, { text: text });
9
- return dictionary[text] || text;
10
- }
@@ -1,7 +0,0 @@
1
- export * from "./Placeholder";
2
- export * from "./Text";
3
- export * from "./Picture";
4
- export * from "./RichText";
5
- export * from "./Image";
6
- export * from "./Link";
7
- export * from "./Translate";