@chaibuilder/sdk 1.3.0-beta.8 → 1.3.0-beta.9

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 (63) hide show
  1. package/dist/CodeEditor-CTpbkvn0.cjs +1 -0
  2. package/dist/CodeEditor-ChxA5nBg.js +77 -0
  3. package/dist/STRINGS-eiGM83kj.js +7 -0
  4. package/dist/STRINGS-ew98weUe.cjs +1 -0
  5. package/dist/Topbar-QwR6PKnl.cjs +1 -0
  6. package/dist/Topbar-z1o2yz-v.js +113 -0
  7. package/dist/UnsplashImages-BZ4Uvn_u.cjs +1 -0
  8. package/dist/UnsplashImages-BiXwCeGg.js +189 -0
  9. package/dist/UploadImages-BeAGmTnm.js +101 -0
  10. package/dist/UploadImages-e9ItP1o-.cjs +1 -0
  11. package/dist/context-menu-BbqLeYFX.js +979 -0
  12. package/dist/context-menu-DfAXjmc8.cjs +1 -0
  13. package/dist/controls-C4n5ycp4.cjs +1 -0
  14. package/dist/controls-Com-zYCq.js +234 -0
  15. package/dist/core.cjs +1 -82
  16. package/dist/core.d.ts +8 -4
  17. package/dist/core.js +74 -74
  18. package/dist/iconBase-Cn2BsTrq.cjs +1 -0
  19. package/dist/iconBase-DHfFLkem.js +124 -0
  20. package/dist/index-Cu1kFTGh.cjs +63 -0
  21. package/dist/index-D1NbGHAC.js +9318 -0
  22. package/dist/jsx-runtime-BYECrxsp.cjs +30 -0
  23. package/dist/jsx-runtime-DGlMoOmv.js +630 -0
  24. package/dist/plugin-BOEoR5jk.js +44 -0
  25. package/dist/plugin-COMQcYlW.cjs +1 -0
  26. package/dist/plugin-Dw854zFv.js +107 -0
  27. package/dist/plugin-I9XxF65G.cjs +1 -0
  28. package/dist/render.cjs +2 -208
  29. package/dist/render.js +125 -171
  30. package/dist/runtime.cjs +1 -26
  31. package/dist/runtime.js +16 -16
  32. package/dist/style.css +2 -1529
  33. package/dist/tailwind.cjs +1 -78
  34. package/dist/tailwind.js +19 -21
  35. package/dist/ui.cjs +1 -392
  36. package/dist/ui.js +257 -268
  37. package/dist/web-blocks.cjs +3 -1241
  38. package/dist/web-blocks.js +555 -764
  39. package/package.json +1 -1
  40. package/dist/CodeEditor-1LboGb1I.cjs +0 -91
  41. package/dist/CodeEditor-BKgZeXwz.js +0 -91
  42. package/dist/STRINGS-3Sn_NeX1.cjs +0 -9
  43. package/dist/STRINGS-DdpfVlsV.js +0 -10
  44. package/dist/Topbar-B8IS6y4H.js +0 -135
  45. package/dist/Topbar-DXC7DFU1.cjs +0 -135
  46. package/dist/UnsplashImages-CjJ5szAy.cjs +0 -215
  47. package/dist/UnsplashImages-Ck9qpKR0.js +0 -215
  48. package/dist/UploadImages-DW1mj4MB.cjs +0 -117
  49. package/dist/UploadImages-DgAMZ8GR.js +0 -117
  50. package/dist/context-menu-BLbuduri.cjs +0 -1073
  51. package/dist/context-menu-BgtRnByf.js +0 -1042
  52. package/dist/controls-8EZmm0Ns.js +0 -234
  53. package/dist/controls-DaW52RjX.cjs +0 -233
  54. package/dist/iconBase-BSrIcOaG.cjs +0 -146
  55. package/dist/iconBase-CWgVxu0A.js +0 -147
  56. package/dist/index-Bjw2sUN2.cjs +0 -12139
  57. package/dist/index-D8_rAW8B.js +0 -12124
  58. package/dist/jsx-runtime-B6vEU3CM.cjs +0 -925
  59. package/dist/jsx-runtime-ClFauRgV.js +0 -926
  60. package/dist/plugin-BYwesM58.cjs +0 -54
  61. package/dist/plugin-BiDLHDo3.cjs +0 -114
  62. package/dist/plugin-BukD7GJR.js +0 -115
  63. package/dist/plugin-tVAEvXiS.js +0 -55
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "author": "Suraj Air",
6
6
  "license": "BSD-3-Clause",
7
7
  "homepage": "https://chaibuilder.com",
8
- "version": "1.3.0-beta.8",
8
+ "version": "1.3.0-beta.9",
9
9
  "type": "module",
10
10
  "repository": {
11
11
  "type": "git",
@@ -1,91 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const jsxRuntime = require("./jsx-runtime-B6vEU3CM.cjs");
4
- const Editor = require("@monaco-editor/react");
5
- const contextMenu = require("./context-menu-BLbuduri.cjs");
6
- const reactI18next = require("react-i18next");
7
- const React = require("react");
8
- const core = require("./index-Bjw2sUN2.cjs");
9
- const reactIcons = require("@radix-ui/react-icons");
10
- const web = require("@react-hookz/web");
11
- const sanitizeHTML = (html) => {
12
- const doc = document.createElement("div");
13
- doc.innerHTML = html;
14
- return doc.innerHTML;
15
- };
16
- function CodeEditor() {
17
- const { t } = reactI18next.useTranslation();
18
- const [dirty, setDirty] = React.useState(false);
19
- const [code, setCode] = React.useState("");
20
- const [codeEditor, setCodeEditor] = core.useCodeEditor();
21
- const [ids] = core.useSelectedBlockIds();
22
- const updateBlockProps = core.useUpdateBlocksProps();
23
- const updateRealTime = core.useUpdateBlocksPropsRealtime();
24
- const saveCodeContentRealTime = web.useThrottledCallback(
25
- (value) => {
26
- const html = sanitizeHTML(value);
27
- updateRealTime([codeEditor.blockId], { [codeEditor.blockProp]: html });
28
- },
29
- [],
30
- 300
31
- );
32
- const saveCodeContent = React.useCallback(() => {
33
- if (dirty) {
34
- const html = sanitizeHTML(code);
35
- updateBlockProps([codeEditor.blockId], { [codeEditor.blockProp]: html });
36
- }
37
- }, [dirty, code]);
38
- React.useEffect(() => {
39
- if (!ids.includes(codeEditor == null ? void 0 : codeEditor.blockId)) {
40
- saveCodeContent();
41
- setCodeEditor(null);
42
- }
43
- }, [ids]);
44
- const handleClickOutside = () => {
45
- setCodeEditor(null);
46
- };
47
- return /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsxs("div", { className: "h-full rounded-t-lg border-t-4 border-black bg-black text-white", children: [
48
- /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx("button", { onClick: handleClickOutside, className: "fixed inset-0 z-[100000] cursor-default bg-gray-400/20" }),
49
- /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsxs("div", { className: "relative z-[100001] h-full w-full flex-col gap-y-1", children: [
50
- /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsxs("div", { className: "-mt-1 flex items-center justify-between px-2 py-2", children: [
51
- /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsxs("h3", { className: "space-x-3 text-sm font-semibold", children: [
52
- /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx("span", { children: t("HTML Code Editor |") }),
53
- /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx("span", { className: "text-xs text-gray-400", children: t("Scripts will be only executed in preview and live mode.") })
54
- ] }),
55
- /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx("div", { className: "flex gap-x-2", children: /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(
56
- contextMenu.Button,
57
- {
58
- onClick: () => setCodeEditor(null),
59
- size: "sm",
60
- variant: "destructive",
61
- className: "h-6 w-fit",
62
- children: /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(reactIcons.Cross2Icon, {})
63
- }
64
- ) })
65
- ] }),
66
- /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(
67
- Editor,
68
- {
69
- onMount: (editor) => {
70
- editor.setValue(codeEditor.initialCode);
71
- },
72
- onChange: (value) => {
73
- setDirty(true);
74
- setCode(value);
75
- saveCodeContentRealTime(value);
76
- },
77
- height: "100%",
78
- defaultLanguage: "html",
79
- theme: "vs-dark",
80
- defaultValue: "",
81
- options: {
82
- minimap: {
83
- enabled: false
84
- }
85
- }
86
- }
87
- )
88
- ] })
89
- ] });
90
- }
91
- exports.default = CodeEditor;
@@ -1,91 +0,0 @@
1
- import { j as jsxRuntimeExports } from "./jsx-runtime-ClFauRgV.js";
2
- import Editor from "@monaco-editor/react";
3
- import { B as Button } from "./context-menu-BgtRnByf.js";
4
- import { useTranslation } from "react-i18next";
5
- import { useState, useCallback, useEffect } from "react";
6
- import { u as useCodeEditor, a as useSelectedBlockIds, b as useUpdateBlocksProps, c as useUpdateBlocksPropsRealtime } from "./index-D8_rAW8B.js";
7
- import { Cross2Icon } from "@radix-ui/react-icons";
8
- import { useThrottledCallback } from "@react-hookz/web";
9
- const sanitizeHTML = (html) => {
10
- const doc = document.createElement("div");
11
- doc.innerHTML = html;
12
- return doc.innerHTML;
13
- };
14
- function CodeEditor() {
15
- const { t } = useTranslation();
16
- const [dirty, setDirty] = useState(false);
17
- const [code, setCode] = useState("");
18
- const [codeEditor, setCodeEditor] = useCodeEditor();
19
- const [ids] = useSelectedBlockIds();
20
- const updateBlockProps = useUpdateBlocksProps();
21
- const updateRealTime = useUpdateBlocksPropsRealtime();
22
- const saveCodeContentRealTime = useThrottledCallback(
23
- (value) => {
24
- const html = sanitizeHTML(value);
25
- updateRealTime([codeEditor.blockId], { [codeEditor.blockProp]: html });
26
- },
27
- [],
28
- 300
29
- );
30
- const saveCodeContent = useCallback(() => {
31
- if (dirty) {
32
- const html = sanitizeHTML(code);
33
- updateBlockProps([codeEditor.blockId], { [codeEditor.blockProp]: html });
34
- }
35
- }, [dirty, code]);
36
- useEffect(() => {
37
- if (!ids.includes(codeEditor == null ? void 0 : codeEditor.blockId)) {
38
- saveCodeContent();
39
- setCodeEditor(null);
40
- }
41
- }, [ids]);
42
- const handleClickOutside = () => {
43
- setCodeEditor(null);
44
- };
45
- return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "h-full rounded-t-lg border-t-4 border-black bg-black text-white", children: [
46
- /* @__PURE__ */ jsxRuntimeExports.jsx("button", { onClick: handleClickOutside, className: "fixed inset-0 z-[100000] cursor-default bg-gray-400/20" }),
47
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "relative z-[100001] h-full w-full flex-col gap-y-1", children: [
48
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "-mt-1 flex items-center justify-between px-2 py-2", children: [
49
- /* @__PURE__ */ jsxRuntimeExports.jsxs("h3", { className: "space-x-3 text-sm font-semibold", children: [
50
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: t("HTML Code Editor |") }),
51
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-xs text-gray-400", children: t("Scripts will be only executed in preview and live mode.") })
52
- ] }),
53
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex gap-x-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
54
- Button,
55
- {
56
- onClick: () => setCodeEditor(null),
57
- size: "sm",
58
- variant: "destructive",
59
- className: "h-6 w-fit",
60
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(Cross2Icon, {})
61
- }
62
- ) })
63
- ] }),
64
- /* @__PURE__ */ jsxRuntimeExports.jsx(
65
- Editor,
66
- {
67
- onMount: (editor) => {
68
- editor.setValue(codeEditor.initialCode);
69
- },
70
- onChange: (value) => {
71
- setDirty(true);
72
- setCode(value);
73
- saveCodeContentRealTime(value);
74
- },
75
- height: "100%",
76
- defaultLanguage: "html",
77
- theme: "vs-dark",
78
- defaultValue: "",
79
- options: {
80
- minimap: {
81
- enabled: false
82
- }
83
- }
84
- }
85
- )
86
- ] })
87
- ] });
88
- }
89
- export {
90
- CodeEditor as default
91
- };
@@ -1,9 +0,0 @@
1
- "use strict";
2
- const STYLES_KEY = "#styles:";
3
- const SLOT_KEY = "#slots:";
4
- const I18N_KEY = "#i18n";
5
- const ROOT_TEMP_KEY = "__ADD_BLOCK_INTERNAL_ROOT";
6
- exports.I18N_KEY = I18N_KEY;
7
- exports.ROOT_TEMP_KEY = ROOT_TEMP_KEY;
8
- exports.SLOT_KEY = SLOT_KEY;
9
- exports.STYLES_KEY = STYLES_KEY;
@@ -1,10 +0,0 @@
1
- const STYLES_KEY = "#styles:";
2
- const SLOT_KEY = "#slots:";
3
- const I18N_KEY = "#i18n";
4
- const ROOT_TEMP_KEY = "__ADD_BLOCK_INTERNAL_ROOT";
5
- export {
6
- I18N_KEY as I,
7
- ROOT_TEMP_KEY as R,
8
- STYLES_KEY as S,
9
- SLOT_KEY as a
10
- };
@@ -1,135 +0,0 @@
1
- import { j as jsxRuntimeExports } from "./jsx-runtime-ClFauRgV.js";
2
- import React__default, { useMemo, Suspense } from "react";
3
- import { B as Button, a6 as DropdownMenu, a7 as DropdownMenuTrigger, a8 as DropdownMenuContent, a9 as DropdownMenuItem, aq as Skeleton, al as Separator } from "./context-menu-BgtRnByf.js";
4
- import { e as useSavePage, F as FaCheck, d as useBuilderProp, f as usePreviewMode, g as useLanguages, L as LANGUAGES, h as FaLanguage, i as FaStar } from "./index-D8_rAW8B.js";
5
- import { useTranslation } from "react-i18next";
6
- import { c as cn } from "./iconBase-CWgVxu0A.js";
7
- import { EyeOpenIcon, ChevronDownIcon } from "@radix-ui/react-icons";
8
- import { forEach, uniq, get, isEmpty, map } from "lodash-es";
9
- import "@chaibuilder/runtime";
10
- const SaveButton = () => {
11
- const { savePage, saveState } = useSavePage();
12
- const { t } = useTranslation();
13
- const button = /* @__PURE__ */ jsxRuntimeExports.jsxs(
14
- Button,
15
- {
16
- disabled: saveState === "SAVING",
17
- onClick: (e) => {
18
- e.preventDefault();
19
- savePage();
20
- },
21
- className: cn(
22
- "flex h-auto w-fit items-center gap-x-2 p-1 px-2",
23
- // UNSAVED sate
24
- "bg-gray-200 text-gray-500 hover:bg-gray-100 dark:bg-gray-800 dark:text-gray-400",
25
- {
26
- "animate-pulse bg-gray-300 text-gray-900": saveState === "SAVING",
27
- "bg-green-500 text-white hover:bg-green-600 hover:text-white dark:bg-green-600 dark:text-white": saveState === "SAVED"
28
- }
29
- ),
30
- size: "sm",
31
- variant: "outline",
32
- children: [
33
- /* @__PURE__ */ jsxRuntimeExports.jsx(FaCheck, { className: "text-sm text-white" }),
34
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-sm", children: saveState === "SAVING" ? t("Saving") : saveState === "SAVED" ? t("Saved") : t("Unsaved") })
35
- ]
36
- }
37
- );
38
- return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center", children: button });
39
- };
40
- const Preview = function Preview2() {
41
- const preview = useBuilderProp("previewComponent");
42
- const [, setPreviewMode] = usePreviewMode();
43
- const { t } = useTranslation();
44
- if (!preview) return null;
45
- return /* @__PURE__ */ jsxRuntimeExports.jsxs(
46
- Button,
47
- {
48
- onClick: (e) => {
49
- e.preventDefault();
50
- setPreviewMode(true);
51
- },
52
- className: `flex h-auto w-fit items-center gap-x-2 p-1 px-2`,
53
- size: "sm",
54
- variant: "outline",
55
- children: [
56
- /* @__PURE__ */ jsxRuntimeExports.jsx(EyeOpenIcon, { className: "text-xs" }),
57
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-sm", children: t("Preview") })
58
- ]
59
- }
60
- );
61
- };
62
- const LanguageSelector = () => {
63
- const { fallbackLang, languages, selectedLang, setSelectedLang } = useLanguages();
64
- const currentLang = (selectedLang == null ? void 0 : selectedLang.length) > 0 ? selectedLang : fallbackLang;
65
- const langOptions = useMemo(() => {
66
- const options = [];
67
- forEach(uniq([fallbackLang, ...languages]), (key) => {
68
- const value = get(LANGUAGES, key);
69
- if (value) options.push({ key, value, default: key === fallbackLang });
70
- });
71
- return options;
72
- }, [fallbackLang, languages]);
73
- if (isEmpty(languages) && currentLang === "en") {
74
- return null;
75
- }
76
- if (isEmpty(languages) && currentLang !== "en") {
77
- return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-x-1 text-sm text-blue-500 hover:text-blue-600", children: [
78
- /* @__PURE__ */ jsxRuntimeExports.jsx(FaLanguage, { className: "h-4 w-4" }),
79
- get(LANGUAGES, currentLang)
80
- ] });
81
- }
82
- return /* @__PURE__ */ jsxRuntimeExports.jsxs(DropdownMenu, { children: [
83
- /* @__PURE__ */ jsxRuntimeExports.jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(Button, { size: "sm", variant: "outline", className: "flex items-center gap-x-1 text-blue-500 hover:text-blue-600", children: [
84
- /* @__PURE__ */ jsxRuntimeExports.jsx(FaLanguage, { className: "h-4 w-4" }),
85
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center space-x-2", children: [
86
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
87
- " ",
88
- get(LANGUAGES, currentLang)
89
- ] }),
90
- /* @__PURE__ */ jsxRuntimeExports.jsx(ChevronDownIcon, { className: "h-4 w-4" })
91
- ] })
92
- ] }) }),
93
- /* @__PURE__ */ jsxRuntimeExports.jsx(DropdownMenuContent, { className: "border-border", children: map(langOptions, (option) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
94
- DropdownMenuItem,
95
- {
96
- className: cn(
97
- "flex cursor-pointer items-center text-sm",
98
- option.key === currentLang && "!bg-blue-500 text-white hover:!text-white"
99
- ),
100
- onClick: () => setSelectedLang(option.key),
101
- children: [
102
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: option.value }),
103
- option.key === fallbackLang ? /* @__PURE__ */ jsxRuntimeExports.jsx(FaStar, { className: "ml-2 h-4 w-4 text-yellow-400" }) : null
104
- ]
105
- }
106
- )) })
107
- ] });
108
- };
109
- const Topbar = () => {
110
- const leftComponents = useBuilderProp("topBarComponents.left", []);
111
- const centerComponents = useBuilderProp("topBarComponents.center", []);
112
- const rightComponents = useBuilderProp("topBarComponents.right", []);
113
- const editable = useBuilderProp("editable", true);
114
- return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex h-14 items-center justify-between px-2", children: [
115
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center space-x-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center space-x-2 font-bold", children: React__default.Children.toArray(
116
- leftComponents.map((Component) => /* @__PURE__ */ jsxRuntimeExports.jsx(Suspense, { fallback: /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-10" }), children: /* @__PURE__ */ jsxRuntimeExports.jsx(Component, {}) }))
117
- ) }) }),
118
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center space-x-2", children: React__default.Children.toArray(
119
- centerComponents.map((Component) => /* @__PURE__ */ jsxRuntimeExports.jsx(Suspense, { fallback: /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-10" }), children: /* @__PURE__ */ jsxRuntimeExports.jsx(Component, {}) }))
120
- ) }),
121
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center space-x-1", children: [
122
- /* @__PURE__ */ jsxRuntimeExports.jsx(LanguageSelector, {}),
123
- /* @__PURE__ */ jsxRuntimeExports.jsx(Separator, { orientation: "vertical" }),
124
- /* @__PURE__ */ jsxRuntimeExports.jsx(Preview, {}),
125
- /* @__PURE__ */ jsxRuntimeExports.jsx(Separator, { orientation: "vertical" }),
126
- editable ? /* @__PURE__ */ jsxRuntimeExports.jsx(SaveButton, {}) : null,
127
- React__default.Children.toArray(
128
- rightComponents.map((Component) => /* @__PURE__ */ jsxRuntimeExports.jsx(Suspense, { fallback: /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-10" }), children: /* @__PURE__ */ jsxRuntimeExports.jsx(Component, {}) }))
129
- )
130
- ] })
131
- ] });
132
- };
133
- export {
134
- Topbar as default
135
- };
@@ -1,135 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const jsxRuntime = require("./jsx-runtime-B6vEU3CM.cjs");
4
- const React = require("react");
5
- const contextMenu = require("./context-menu-BLbuduri.cjs");
6
- const core = require("./index-Bjw2sUN2.cjs");
7
- const reactI18next = require("react-i18next");
8
- const iconBase = require("./iconBase-BSrIcOaG.cjs");
9
- const reactIcons = require("@radix-ui/react-icons");
10
- const lodashEs = require("lodash-es");
11
- require("@chaibuilder/runtime");
12
- const SaveButton = () => {
13
- const { savePage, saveState } = core.useSavePage();
14
- const { t } = reactI18next.useTranslation();
15
- const button = /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsxs(
16
- contextMenu.Button,
17
- {
18
- disabled: saveState === "SAVING",
19
- onClick: (e) => {
20
- e.preventDefault();
21
- savePage();
22
- },
23
- className: iconBase.cn(
24
- "flex h-auto w-fit items-center gap-x-2 p-1 px-2",
25
- // UNSAVED sate
26
- "bg-gray-200 text-gray-500 hover:bg-gray-100 dark:bg-gray-800 dark:text-gray-400",
27
- {
28
- "animate-pulse bg-gray-300 text-gray-900": saveState === "SAVING",
29
- "bg-green-500 text-white hover:bg-green-600 hover:text-white dark:bg-green-600 dark:text-white": saveState === "SAVED"
30
- }
31
- ),
32
- size: "sm",
33
- variant: "outline",
34
- children: [
35
- /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(core.FaCheck, { className: "text-sm text-white" }),
36
- /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx("span", { className: "text-sm", children: saveState === "SAVING" ? t("Saving") : saveState === "SAVED" ? t("Saved") : t("Unsaved") })
37
- ]
38
- }
39
- );
40
- return /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx("div", { className: "flex items-center", children: button });
41
- };
42
- const Preview = function Preview2() {
43
- const preview = core.useBuilderProp("previewComponent");
44
- const [, setPreviewMode] = core.usePreviewMode();
45
- const { t } = reactI18next.useTranslation();
46
- if (!preview) return null;
47
- return /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsxs(
48
- contextMenu.Button,
49
- {
50
- onClick: (e) => {
51
- e.preventDefault();
52
- setPreviewMode(true);
53
- },
54
- className: `flex h-auto w-fit items-center gap-x-2 p-1 px-2`,
55
- size: "sm",
56
- variant: "outline",
57
- children: [
58
- /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(reactIcons.EyeOpenIcon, { className: "text-xs" }),
59
- /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx("span", { className: "text-sm", children: t("Preview") })
60
- ]
61
- }
62
- );
63
- };
64
- const LanguageSelector = () => {
65
- const { fallbackLang, languages, selectedLang, setSelectedLang } = core.useLanguages();
66
- const currentLang = (selectedLang == null ? void 0 : selectedLang.length) > 0 ? selectedLang : fallbackLang;
67
- const langOptions = React.useMemo(() => {
68
- const options = [];
69
- lodashEs.forEach(lodashEs.uniq([fallbackLang, ...languages]), (key) => {
70
- const value = lodashEs.get(core.LANGUAGES, key);
71
- if (value) options.push({ key, value, default: key === fallbackLang });
72
- });
73
- return options;
74
- }, [fallbackLang, languages]);
75
- if (lodashEs.isEmpty(languages) && currentLang === "en") {
76
- return null;
77
- }
78
- if (lodashEs.isEmpty(languages) && currentLang !== "en") {
79
- return /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-x-1 text-sm text-blue-500 hover:text-blue-600", children: [
80
- /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(core.FaLanguage, { className: "h-4 w-4" }),
81
- lodashEs.get(core.LANGUAGES, currentLang)
82
- ] });
83
- }
84
- return /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.DropdownMenu, { children: [
85
- /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(contextMenu.DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Button, { size: "sm", variant: "outline", className: "flex items-center gap-x-1 text-blue-500 hover:text-blue-600", children: [
86
- /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(core.FaLanguage, { className: "h-4 w-4" }),
87
- /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsxs("div", { className: "flex items-center space-x-2", children: [
88
- /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsxs("div", { children: [
89
- " ",
90
- lodashEs.get(core.LANGUAGES, currentLang)
91
- ] }),
92
- /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(reactIcons.ChevronDownIcon, { className: "h-4 w-4" })
93
- ] })
94
- ] }) }),
95
- /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(contextMenu.DropdownMenuContent, { className: "border-border", children: lodashEs.map(langOptions, (option) => /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsxs(
96
- contextMenu.DropdownMenuItem,
97
- {
98
- className: iconBase.cn(
99
- "flex cursor-pointer items-center text-sm",
100
- option.key === currentLang && "!bg-blue-500 text-white hover:!text-white"
101
- ),
102
- onClick: () => setSelectedLang(option.key),
103
- children: [
104
- /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx("div", { children: option.value }),
105
- option.key === fallbackLang ? /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(core.FaStar, { className: "ml-2 h-4 w-4 text-yellow-400" }) : null
106
- ]
107
- }
108
- )) })
109
- ] });
110
- };
111
- const Topbar = () => {
112
- const leftComponents = core.useBuilderProp("topBarComponents.left", []);
113
- const centerComponents = core.useBuilderProp("topBarComponents.center", []);
114
- const rightComponents = core.useBuilderProp("topBarComponents.right", []);
115
- const editable = core.useBuilderProp("editable", true);
116
- return /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsxs("div", { className: "flex h-14 items-center justify-between px-2", children: [
117
- /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx("div", { className: "flex items-center space-x-2", children: /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx("div", { className: "flex items-center space-x-2 font-bold", children: React.Children.toArray(
118
- leftComponents.map((Component) => /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(React.Suspense, { fallback: /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Skeleton, { className: "h-10" }), children: /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(Component, {}) }))
119
- ) }) }),
120
- /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx("div", { className: "flex items-center space-x-2", children: React.Children.toArray(
121
- centerComponents.map((Component) => /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(React.Suspense, { fallback: /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Skeleton, { className: "h-10" }), children: /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(Component, {}) }))
122
- ) }),
123
- /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsxs("div", { className: "flex items-center space-x-1", children: [
124
- /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(LanguageSelector, {}),
125
- /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Separator, { orientation: "vertical" }),
126
- /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(Preview, {}),
127
- /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Separator, { orientation: "vertical" }),
128
- editable ? /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(SaveButton, {}) : null,
129
- React.Children.toArray(
130
- rightComponents.map((Component) => /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(React.Suspense, { fallback: /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Skeleton, { className: "h-10" }), children: /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(Component, {}) }))
131
- )
132
- ] })
133
- ] });
134
- };
135
- exports.default = Topbar;