@chaibuilder/sdk 1.2.92 → 1.2.93-beta.1
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/dist/{CodeEditor-orTEdw7a.js → CodeEditor-_pniWL9A.js} +20 -20
- package/dist/CodeEditor-hbpcHA6a.cjs +1 -0
- package/dist/GlobalBlockSettings-1Ix883dP.cjs +1 -0
- package/dist/GlobalBlockSettings-eytCBAHr.js +44 -0
- package/dist/Topbar-0dGbwmC_.cjs +1 -0
- package/dist/{Topbar-OPlOc1Ha.js → Topbar-AzDg5F6n.js} +12 -12
- package/dist/{UnsplashImages-WaGyNL1z.js → UnsplashImages-Gdm78EC5.js} +36 -36
- package/dist/UnsplashImages-etSQzJ6J.cjs +1 -0
- package/dist/{UploadImages-GiKofaXX.js → UploadImages-2XWy9JHd.js} +10 -10
- package/dist/UploadImages-lyC-Th50.cjs +1 -0
- package/dist/{context-menu-yLeOsx9j.js → context-menu-9cWJcKdh.js} +463 -427
- package/dist/context-menu-sQn7ryJ6.cjs +1 -0
- package/dist/core.cjs +1 -1
- package/dist/core.js +52 -52
- package/dist/iconBase-HBZkvN04.js +330 -0
- package/dist/iconBase-kuD_VwQx.cjs +1 -0
- package/dist/index-lynOzeB3.cjs +223 -0
- package/dist/{index-yJ1H6b2C.js → index-zgy8mVKm.js} +28 -35
- package/dist/ui.cjs +1 -1
- package/dist/ui.js +112 -113
- package/dist/useGlobalBlocksStore-1wJUEOl4.cjs +1 -0
- package/dist/useGlobalBlocksStore-HlGhDxuV.js +1258 -0
- package/dist/web-blocks.cjs +1 -1
- package/dist/web-blocks.js +245 -272
- package/package.json +1 -1
- package/dist/CodeEditor-awVVPqel.cjs +0 -1
- package/dist/Topbar--KOfsR94.cjs +0 -1
- package/dist/UnsplashImages-g-8MvB9W.cjs +0 -1
- package/dist/UploadImages-Ic_iZgWY.cjs +0 -1
- package/dist/button-9Duvj2dH.js +0 -42
- package/dist/button-oQgWN0j0.cjs +0 -1
- package/dist/context-menu-8MWP_Ikf.cjs +0 -1
- package/dist/iconBase-BnEC5_qG.js +0 -1583
- package/dist/iconBase-_bgMuxa5.cjs +0 -1
- package/dist/index-Hj8wMhx_.cjs +0 -223
|
@@ -1,25 +1,17 @@
|
|
|
1
1
|
import { j as t } from "./jsx-runtime-Sp0orL4X.js";
|
|
2
2
|
import k from "@monaco-editor/react";
|
|
3
|
-
import { B as C } from "./
|
|
3
|
+
import { B as C } from "./context-menu-9cWJcKdh.js";
|
|
4
4
|
import { useTranslation as j } from "react-i18next";
|
|
5
5
|
import { useState as l, useCallback as v, useEffect as g } from "react";
|
|
6
|
-
import { a as y,
|
|
7
|
-
import { u as E } from "./index-
|
|
6
|
+
import { a as y, l as N, x as T } from "./useGlobalBlocksStore-HlGhDxuV.js";
|
|
7
|
+
import { u as E } from "./index-zgy8mVKm.js";
|
|
8
8
|
import { Cross2Icon as w } from "@radix-ui/react-icons";
|
|
9
9
|
import { useThrottledCallback as B } from "@react-hookz/web";
|
|
10
|
-
import "@radix-ui/react-slot";
|
|
11
|
-
import "class-variance-authority";
|
|
12
|
-
import "clsx";
|
|
13
|
-
import "tailwind-merge";
|
|
14
|
-
import "lodash-es";
|
|
15
|
-
import "jotai";
|
|
16
|
-
import "./_commonjsHelpers-f3sTPFkQ.js";
|
|
17
|
-
import "@chaibuilder/runtime";
|
|
18
|
-
import "tree-model";
|
|
19
|
-
import "./context-menu-yLeOsx9j.js";
|
|
20
10
|
import "@radix-ui/react-switch";
|
|
21
11
|
import "@radix-ui/react-accordion";
|
|
12
|
+
import "class-variance-authority";
|
|
22
13
|
import "@radix-ui/react-alert-dialog";
|
|
14
|
+
import "@radix-ui/react-slot";
|
|
23
15
|
import "@radix-ui/react-label";
|
|
24
16
|
import "@radix-ui/react-scroll-area";
|
|
25
17
|
import "@radix-ui/react-tabs";
|
|
@@ -33,6 +25,14 @@ import "@radix-ui/react-toast";
|
|
|
33
25
|
import "cmdk";
|
|
34
26
|
import "@radix-ui/react-dialog";
|
|
35
27
|
import "@radix-ui/react-context-menu";
|
|
28
|
+
import "clsx";
|
|
29
|
+
import "tailwind-merge";
|
|
30
|
+
import "lodash-es";
|
|
31
|
+
import "jotai";
|
|
32
|
+
import "./iconBase-HBZkvN04.js";
|
|
33
|
+
import "./_commonjsHelpers-f3sTPFkQ.js";
|
|
34
|
+
import "@chaibuilder/runtime";
|
|
35
|
+
import "tree-model";
|
|
36
36
|
import "react-quill";
|
|
37
37
|
import "./STRINGS-TDN5UhWi.js";
|
|
38
38
|
import "flagged";
|
|
@@ -60,21 +60,21 @@ import "react-autosuggest";
|
|
|
60
60
|
import "fuse.js";
|
|
61
61
|
import "i18next";
|
|
62
62
|
import "framer-motion";
|
|
63
|
-
const
|
|
63
|
+
const a = (r) => {
|
|
64
64
|
const e = document.createElement("div");
|
|
65
65
|
return e.innerHTML = r, e.innerHTML;
|
|
66
66
|
};
|
|
67
|
-
function
|
|
68
|
-
const { t: r } = j(), [e,
|
|
67
|
+
function Ut() {
|
|
68
|
+
const { t: r } = j(), [e, n] = l(!1), [m, c] = l(""), [o, s] = E(), [p] = y(), d = N(), u = T(), f = B(
|
|
69
69
|
(i) => {
|
|
70
|
-
const b =
|
|
70
|
+
const b = a(i);
|
|
71
71
|
u([o.blockId], { [o.blockProp]: b });
|
|
72
72
|
},
|
|
73
73
|
[],
|
|
74
74
|
300
|
|
75
75
|
), x = v(() => {
|
|
76
76
|
if (e) {
|
|
77
|
-
const i =
|
|
77
|
+
const i = a(m);
|
|
78
78
|
d([o.blockId], { [o.blockProp]: i });
|
|
79
79
|
}
|
|
80
80
|
}, [e, m]);
|
|
@@ -110,7 +110,7 @@ function Dt() {
|
|
|
110
110
|
i.setValue(o.initialCode);
|
|
111
111
|
},
|
|
112
112
|
onChange: (i) => {
|
|
113
|
-
|
|
113
|
+
n(!0), c(i), f(i);
|
|
114
114
|
},
|
|
115
115
|
height: "100%",
|
|
116
116
|
defaultLanguage: "html",
|
|
@@ -127,5 +127,5 @@ function Dt() {
|
|
|
127
127
|
] });
|
|
128
128
|
}
|
|
129
129
|
export {
|
|
130
|
-
|
|
130
|
+
Ut as default
|
|
131
131
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./jsx-runtime-JYMCiFoE.cjs"),h=require("@monaco-editor/react"),k=require("./context-menu-sQn7ryJ6.cjs"),C=require("react-i18next"),u=require("react"),n=require("./useGlobalBlocksStore-1wJUEOl4.cjs"),E=require("./index-lynOzeB3.cjs"),R=require("@radix-ui/react-icons"),g=require("@react-hookz/web");require("@radix-ui/react-switch");require("@radix-ui/react-accordion");require("class-variance-authority");require("@radix-ui/react-alert-dialog");require("@radix-ui/react-slot");require("@radix-ui/react-label");require("@radix-ui/react-scroll-area");require("@radix-ui/react-tabs");require("@radix-ui/react-tooltip");require("@radix-ui/react-popover");require("@radix-ui/react-hover-card");require("@radix-ui/react-select");require("@radix-ui/react-dropdown-menu");require("@radix-ui/react-separator");require("@radix-ui/react-toast");require("cmdk");require("@radix-ui/react-dialog");require("@radix-ui/react-context-menu");require("clsx");require("tailwind-merge");require("lodash-es");require("jotai");require("./iconBase-kuD_VwQx.cjs");require("./_commonjsHelpers-f52AuuUj.cjs");require("@chaibuilder/runtime");require("tree-model");require("react-quill");require("./STRINGS-Yl7cSWDc.cjs");require("flagged");require("react-hotkeys-hook");require("@floating-ui/dom");require("@floating-ui/react-dom");require("react-event-hook");require("@tailwindcss/typography");require("@tailwindcss/forms");require("@tailwindcss/aspect-ratio");require("tailwindcss-palette-generator");require("./plugin-02QsHeBE.cjs");require("react-wrap-balancer");require("react-dom");require("prop-types");require("react-error-boundary");require("re-resizable");require("lucide-react");require("@rjsf/validator-ajv8");require("@rjsf/core");require("react-arborist");require("himalaya");require("react-icons-picker");require("react-autosuggest");require("fuse.js");require("i18next");require("framer-motion");const a=s=>{const i=document.createElement("div");return i.innerHTML=s,i.innerHTML};function v(){const{t:s}=C.useTranslation(),[i,q]=u.useState(!1),[l,d]=u.useState(""),[r,o]=E.useCodeEditor(),[c]=n.useSelectedBlockIds(),x=n.useUpdateBlocksProps(),m=n.useUpdateBlocksPropsRealtime(),p=g.useThrottledCallback(t=>{const f=a(t);m([r.blockId],{[r.blockProp]:f})},[],300),j=u.useCallback(()=>{if(i){const t=a(l);x([r.blockId],{[r.blockProp]:t})}},[i,l]);u.useEffect(()=>{c.includes(r==null?void 0:r.blockId)||(j(),o(null))},[c]);const b=()=>{o(null)};return e.jsxRuntimeExports.jsxs("div",{className:"h-full rounded-t-lg border-t-4 border-black bg-black text-white",children:[e.jsxRuntimeExports.jsx("button",{onClick:b,className:"fixed inset-0 z-[100000] cursor-default bg-gray-400/20"}),e.jsxRuntimeExports.jsxs("div",{className:"relative z-[100001] h-full w-full flex-col gap-y-1",children:[e.jsxRuntimeExports.jsxs("div",{className:"-mt-1 flex items-center justify-between px-2 py-2",children:[e.jsxRuntimeExports.jsxs("h3",{className:"space-x-3 text-sm font-semibold",children:[e.jsxRuntimeExports.jsx("span",{children:s("HTML Code Editor |")}),e.jsxRuntimeExports.jsx("span",{className:"text-xs text-gray-400",children:s("Scripts will be only executed in preview and live mode.")})]}),e.jsxRuntimeExports.jsx("div",{className:"flex gap-x-2",children:e.jsxRuntimeExports.jsx(k.Button,{onClick:()=>o(null),size:"sm",variant:"destructive",className:"h-6 w-fit",children:e.jsxRuntimeExports.jsx(R.Cross2Icon,{})})})]}),e.jsxRuntimeExports.jsx(h,{onMount:t=>{t.setValue(r.initialCode)},onChange:t=>{q(!0),d(t),p(t)},height:"100%",defaultLanguage:"html",theme:"vs-dark",defaultValue:"",options:{minimap:{enabled:!1}}})]})]})}exports.default=v;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./jsx-runtime-JYMCiFoE.cjs"),t=require("./useGlobalBlocksStore-1wJUEOl4.cjs");require("react-i18next");require("react");require("lodash-es");require("jotai");require("./iconBase-kuD_VwQx.cjs");require("clsx");require("tailwind-merge");require("./_commonjsHelpers-f52AuuUj.cjs");require("@react-hookz/web");require("@chaibuilder/runtime");require("tree-model");const u=()=>{const s=t.useSelectedBlock(),{data:o,refetch:l,isLoading:a}=t.useGlobalBlocksList(),i=t.useUpdateBlocksProps();return e.jsxRuntimeExports.jsxs("div",{children:[e.jsxRuntimeExports.jsx("label",{className:"text-sm",children:"Choose a global block"}),e.jsxRuntimeExports.jsxs("select",{className:"h-8 w-full rounded-md border border-border bg-gray-50 p-0 px-2 text-xs dark:bg-gray-800",value:(s==null?void 0:s.globalBlock)||"",onChange:r=>{i([s._id],{globalBlock:r.target.value})},children:[e.jsxRuntimeExports.jsx("option",{value:"",children:"Select a global block"}),Object.keys(o).map(r=>e.jsxRuntimeExports.jsx("option",{value:r,children:o[r].name||r},r))]}),e.jsxRuntimeExports.jsx("div",{className:"mt-2 text-xs",children:e.jsxRuntimeExports.jsx("button",{onClick:l,className:"rounded-md bg-gray-100 p-1 px-2 text-xs hover:bg-gray-200 dark:bg-gray-800 dark:hover:bg-gray-700",children:a?"Loading...":"Refresh List"})})]})};exports.default=u;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { j as o } from "./jsx-runtime-Sp0orL4X.js";
|
|
2
|
+
import { r as i, N as c, l as d } from "./useGlobalBlocksStore-HlGhDxuV.js";
|
|
3
|
+
import "react-i18next";
|
|
4
|
+
import "react";
|
|
5
|
+
import "lodash-es";
|
|
6
|
+
import "jotai";
|
|
7
|
+
import "./iconBase-HBZkvN04.js";
|
|
8
|
+
import "clsx";
|
|
9
|
+
import "tailwind-merge";
|
|
10
|
+
import "./_commonjsHelpers-f3sTPFkQ.js";
|
|
11
|
+
import "@react-hookz/web";
|
|
12
|
+
import "@chaibuilder/runtime";
|
|
13
|
+
import "tree-model";
|
|
14
|
+
const N = () => {
|
|
15
|
+
const t = i(), { data: e, refetch: s, isLoading: a } = c(), l = d();
|
|
16
|
+
return /* @__PURE__ */ o.jsxs("div", { children: [
|
|
17
|
+
/* @__PURE__ */ o.jsx("label", { className: "text-sm", children: "Choose a global block" }),
|
|
18
|
+
/* @__PURE__ */ o.jsxs(
|
|
19
|
+
"select",
|
|
20
|
+
{
|
|
21
|
+
className: "h-8 w-full rounded-md border border-border bg-gray-50 p-0 px-2 text-xs dark:bg-gray-800",
|
|
22
|
+
value: (t == null ? void 0 : t.globalBlock) || "",
|
|
23
|
+
onChange: (r) => {
|
|
24
|
+
l([t._id], { globalBlock: r.target.value });
|
|
25
|
+
},
|
|
26
|
+
children: [
|
|
27
|
+
/* @__PURE__ */ o.jsx("option", { value: "", children: "Select a global block" }),
|
|
28
|
+
Object.keys(e).map((r) => /* @__PURE__ */ o.jsx("option", { value: r, children: e[r].name || r }, r))
|
|
29
|
+
]
|
|
30
|
+
}
|
|
31
|
+
),
|
|
32
|
+
/* @__PURE__ */ o.jsx("div", { className: "mt-2 text-xs", children: /* @__PURE__ */ o.jsx(
|
|
33
|
+
"button",
|
|
34
|
+
{
|
|
35
|
+
onClick: s,
|
|
36
|
+
className: "rounded-md bg-gray-100 p-1 px-2 text-xs hover:bg-gray-200 dark:bg-gray-800 dark:hover:bg-gray-700",
|
|
37
|
+
children: a ? "Loading..." : "Refresh List"
|
|
38
|
+
}
|
|
39
|
+
) })
|
|
40
|
+
] });
|
|
41
|
+
};
|
|
42
|
+
export {
|
|
43
|
+
N as default
|
|
44
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./jsx-runtime-JYMCiFoE.cjs"),i=require("react"),n=require("./context-menu-sQn7ryJ6.cjs"),u=require("./useGlobalBlocksStore-1wJUEOl4.cjs"),x=require("react-i18next"),c=require("./index-lynOzeB3.cjs"),l=require("./iconBase-kuD_VwQx.cjs"),p=require("@radix-ui/react-icons");require("@radix-ui/react-switch");require("@radix-ui/react-accordion");require("class-variance-authority");require("@radix-ui/react-alert-dialog");require("@radix-ui/react-slot");require("@radix-ui/react-label");require("@radix-ui/react-scroll-area");require("@radix-ui/react-tabs");require("@radix-ui/react-tooltip");require("@radix-ui/react-popover");require("@radix-ui/react-hover-card");require("@radix-ui/react-select");require("@radix-ui/react-dropdown-menu");require("@radix-ui/react-separator");require("@radix-ui/react-toast");require("cmdk");require("@radix-ui/react-dialog");require("@radix-ui/react-context-menu");require("clsx");require("tailwind-merge");require("lodash-es");require("jotai");require("./_commonjsHelpers-f52AuuUj.cjs");require("@react-hookz/web");require("@chaibuilder/runtime");require("tree-model");require("react-quill");require("./STRINGS-Yl7cSWDc.cjs");require("flagged");require("react-hotkeys-hook");require("@floating-ui/dom");require("@floating-ui/react-dom");require("react-event-hook");require("@tailwindcss/typography");require("@tailwindcss/forms");require("@tailwindcss/aspect-ratio");require("tailwindcss-palette-generator");require("./plugin-02QsHeBE.cjs");require("react-wrap-balancer");require("react-dom");require("prop-types");require("react-error-boundary");require("re-resizable");require("lucide-react");require("@rjsf/validator-ajv8");require("@rjsf/core");require("react-arborist");require("himalaya");require("react-icons-picker");require("react-autosuggest");require("fuse.js");require("i18next");require("framer-motion");const m=()=>{const{savePage:a,saveState:r}=u.useSavePage(),{t:s}=x.useTranslation(),o=e.jsxRuntimeExports.jsxs(n.Button,{disabled:r==="SAVING",onClick:t=>{t.preventDefault(),a()},className:l.cn("flex h-auto w-fit items-center gap-x-2 p-1 px-2","bg-gray-200 text-gray-500 hover:bg-gray-100 dark:bg-gray-800 dark:text-gray-400",{"animate-pulse bg-gray-300 text-gray-900":r==="SAVING","bg-green-500 text-white hover:bg-green-600 hover:text-white dark:bg-green-600 dark:text-white":r==="SAVED"}),size:"sm",variant:"outline",children:[e.jsxRuntimeExports.jsx(c.FaCheck,{className:"text-sm text-white"}),e.jsxRuntimeExports.jsx("span",{className:"text-sm",children:s(r==="SAVING"?"saving":r==="SAVED"?"saved":"unsaved")})]});return e.jsxRuntimeExports.jsx("div",{className:"flex items-center",children:o})},q=function(){const r=u.useBuilderProp("previewComponent"),[,s]=c.usePreviewMode(),{t:o}=x.useTranslation();return r?e.jsxRuntimeExports.jsxs(n.Button,{onClick:t=>{t.preventDefault(),s(!0)},className:"flex h-auto w-fit items-center gap-x-2 p-1 px-2",size:"sm",variant:"outline",children:[e.jsxRuntimeExports.jsx(p.EyeOpenIcon,{className:"text-xs"}),e.jsxRuntimeExports.jsx("span",{className:"text-sm",children:o("preview")})]}):null},j=()=>{const a=u.useBuilderProp("topBarComponents.left",[]),r=u.useBuilderProp("topBarComponents.center",[]),s=u.useBuilderProp("topBarComponents.right",[]),o=u.useBuilderProp("editable",!0);return e.jsxRuntimeExports.jsxs("div",{className:"flex h-14 items-center justify-between px-2",children:[e.jsxRuntimeExports.jsx("div",{className:"flex items-center space-x-2",children:e.jsxRuntimeExports.jsx("div",{className:"flex items-center space-x-2 font-bold",children:i.Children.toArray(a.map(t=>e.jsxRuntimeExports.jsx(i.Suspense,{fallback:e.jsxRuntimeExports.jsx(n.Skeleton,{className:"h-10"}),children:e.jsxRuntimeExports.jsx(t,{})})))})}),e.jsxRuntimeExports.jsx("div",{className:"flex items-center space-x-2",children:i.Children.toArray(r.map(t=>e.jsxRuntimeExports.jsx(i.Suspense,{fallback:e.jsxRuntimeExports.jsx(n.Skeleton,{className:"h-10"}),children:e.jsxRuntimeExports.jsx(t,{})})))}),e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-1",children:[e.jsxRuntimeExports.jsx(q,{}),e.jsxRuntimeExports.jsx(n.Separator,{orientation:"vertical"}),o?e.jsxRuntimeExports.jsx(m,{}):null,i.Children.toArray(s.map(t=>e.jsxRuntimeExports.jsx(i.Suspense,{fallback:e.jsxRuntimeExports.jsx(n.Skeleton,{className:"h-10"}),children:e.jsxRuntimeExports.jsx(t,{})})))]})]})};exports.default=j;
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { j as t } from "./jsx-runtime-Sp0orL4X.js";
|
|
2
2
|
import m, { Suspense as p } from "react";
|
|
3
|
-
import { S as n,
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
3
|
+
import { B as c, S as n, ac as x } from "./context-menu-9cWJcKdh.js";
|
|
4
|
+
import { L as d, k as s } from "./useGlobalBlocksStore-HlGhDxuV.js";
|
|
5
|
+
import { useTranslation as l } from "react-i18next";
|
|
6
|
+
import { F as h, a as f } from "./index-zgy8mVKm.js";
|
|
7
|
+
import { c as u } from "./iconBase-HBZkvN04.js";
|
|
8
8
|
import { EyeOpenIcon as v } from "@radix-ui/react-icons";
|
|
9
9
|
import "@radix-ui/react-switch";
|
|
10
10
|
import "@radix-ui/react-accordion";
|
|
11
11
|
import "class-variance-authority";
|
|
12
12
|
import "@radix-ui/react-alert-dialog";
|
|
13
|
+
import "@radix-ui/react-slot";
|
|
13
14
|
import "@radix-ui/react-label";
|
|
14
15
|
import "@radix-ui/react-scroll-area";
|
|
15
16
|
import "@radix-ui/react-tabs";
|
|
@@ -23,7 +24,6 @@ import "@radix-ui/react-toast";
|
|
|
23
24
|
import "cmdk";
|
|
24
25
|
import "@radix-ui/react-dialog";
|
|
25
26
|
import "@radix-ui/react-context-menu";
|
|
26
|
-
import "@radix-ui/react-slot";
|
|
27
27
|
import "clsx";
|
|
28
28
|
import "tailwind-merge";
|
|
29
29
|
import "lodash-es";
|
|
@@ -60,14 +60,14 @@ import "fuse.js";
|
|
|
60
60
|
import "i18next";
|
|
61
61
|
import "framer-motion";
|
|
62
62
|
const j = () => {
|
|
63
|
-
const { savePage: a, saveState: e } = d(), { t: o } =
|
|
64
|
-
|
|
63
|
+
const { savePage: a, saveState: e } = d(), { t: o } = l(), i = /* @__PURE__ */ t.jsxs(
|
|
64
|
+
c,
|
|
65
65
|
{
|
|
66
66
|
disabled: e === "SAVING",
|
|
67
67
|
onClick: (r) => {
|
|
68
68
|
r.preventDefault(), a();
|
|
69
69
|
},
|
|
70
|
-
className:
|
|
70
|
+
className: u(
|
|
71
71
|
"flex h-auto w-fit items-center gap-x-2 p-1 px-2",
|
|
72
72
|
// UNSAVED sate
|
|
73
73
|
"bg-gray-200 text-gray-500 hover:bg-gray-100 dark:bg-gray-800 dark:text-gray-400",
|
|
@@ -79,16 +79,16 @@ const j = () => {
|
|
|
79
79
|
size: "sm",
|
|
80
80
|
variant: "outline",
|
|
81
81
|
children: [
|
|
82
|
-
/* @__PURE__ */ t.jsx(
|
|
82
|
+
/* @__PURE__ */ t.jsx(h, { className: "text-sm text-white" }),
|
|
83
83
|
/* @__PURE__ */ t.jsx("span", { className: "text-sm", children: o(e === "SAVING" ? "saving" : e === "SAVED" ? "saved" : "unsaved") })
|
|
84
84
|
]
|
|
85
85
|
}
|
|
86
86
|
);
|
|
87
87
|
return /* @__PURE__ */ t.jsx("div", { className: "flex items-center", children: i });
|
|
88
88
|
}, g = function() {
|
|
89
|
-
const e = s("previewComponent"), [, o] =
|
|
89
|
+
const e = s("previewComponent"), [, o] = f(), { t: i } = l();
|
|
90
90
|
return e ? /* @__PURE__ */ t.jsxs(
|
|
91
|
-
|
|
91
|
+
c,
|
|
92
92
|
{
|
|
93
93
|
onClick: (r) => {
|
|
94
94
|
r.preventDefault(), o(!0);
|
|
@@ -2,21 +2,18 @@ import { j as e } from "./jsx-runtime-Sp0orL4X.js";
|
|
|
2
2
|
import { useState as c, useEffect as S } from "react";
|
|
3
3
|
import { isEmpty as d } from "lodash-es";
|
|
4
4
|
import { createApi as B } from "unsplash-js";
|
|
5
|
-
import {
|
|
6
|
-
import { M as E, U as L } from "./context-menu-yLeOsx9j.js";
|
|
5
|
+
import { N as D, V as E, B as L } from "./context-menu-9cWJcKdh.js";
|
|
7
6
|
import { useTranslation as T } from "react-i18next";
|
|
8
|
-
import {
|
|
7
|
+
import { k as V } from "./useGlobalBlocksStore-HlGhDxuV.js";
|
|
9
8
|
import { useDebouncedState as F } from "@react-hookz/web";
|
|
10
9
|
import { Loader as K } from "lucide-react";
|
|
11
|
-
import { C as
|
|
12
|
-
import "@radix-ui/react-slot";
|
|
13
|
-
import "class-variance-authority";
|
|
14
|
-
import "clsx";
|
|
15
|
-
import "tailwind-merge";
|
|
10
|
+
import { C as w } from "./index-zgy8mVKm.js";
|
|
16
11
|
import "@radix-ui/react-switch";
|
|
17
12
|
import "@radix-ui/react-accordion";
|
|
18
13
|
import "@radix-ui/react-icons";
|
|
14
|
+
import "class-variance-authority";
|
|
19
15
|
import "@radix-ui/react-alert-dialog";
|
|
16
|
+
import "@radix-ui/react-slot";
|
|
20
17
|
import "@radix-ui/react-label";
|
|
21
18
|
import "@radix-ui/react-scroll-area";
|
|
22
19
|
import "@radix-ui/react-tabs";
|
|
@@ -30,7 +27,10 @@ import "@radix-ui/react-toast";
|
|
|
30
27
|
import "cmdk";
|
|
31
28
|
import "@radix-ui/react-dialog";
|
|
32
29
|
import "@radix-ui/react-context-menu";
|
|
30
|
+
import "clsx";
|
|
31
|
+
import "tailwind-merge";
|
|
33
32
|
import "jotai";
|
|
33
|
+
import "./iconBase-HBZkvN04.js";
|
|
34
34
|
import "./_commonjsHelpers-f3sTPFkQ.js";
|
|
35
35
|
import "@chaibuilder/runtime";
|
|
36
36
|
import "tree-model";
|
|
@@ -64,16 +64,16 @@ const C = async (f, g) => new Promise((s, r) => {
|
|
|
64
64
|
B({ accessKey: g }).search.getPhotos(f).then((i) => {
|
|
65
65
|
s(i);
|
|
66
66
|
}).catch((i) => r(i));
|
|
67
|
-
}),
|
|
68
|
-
const s =
|
|
67
|
+
}), He = ({ isModalView: f, onSelect: g }) => {
|
|
68
|
+
const s = V("unsplashAccessKey", ""), [r, x] = c([]), [i, v] = c(0), [l, P] = c(), [n, A] = c(), [_, b] = c(0), [h, q] = F("", 1e3), [u, m] = c(!1), { t: j } = T(), I = async (a) => {
|
|
69
69
|
if (d(h))
|
|
70
70
|
return;
|
|
71
71
|
let t = i + 1;
|
|
72
|
-
|
|
72
|
+
a && (a.preventDefault(), t = 1), m(!0), v(t);
|
|
73
73
|
const p = { query: h, page: t };
|
|
74
|
-
l && (p.orientation = l), n && (p.color = n), C(p, s).then((
|
|
75
|
-
var y, N,
|
|
76
|
-
x(t === 1 ? ((y =
|
|
74
|
+
l && (p.orientation = l), n && (p.color = n), C(p, s).then((o) => {
|
|
75
|
+
var y, N, k;
|
|
76
|
+
x(t === 1 ? ((y = o == null ? void 0 : o.response) == null ? void 0 : y.results) || [] : [...r, ...((N = o == null ? void 0 : o.response) == null ? void 0 : N.results) || []]), b((k = o == null ? void 0 : o.response) == null ? void 0 : k.total_pages), m(!1);
|
|
77
77
|
}).catch(() => {
|
|
78
78
|
m(!1);
|
|
79
79
|
});
|
|
@@ -81,10 +81,10 @@ const C = async (f, g) => new Promise((s, r) => {
|
|
|
81
81
|
return S(() => {
|
|
82
82
|
if (!d(h) && s) {
|
|
83
83
|
m(!0);
|
|
84
|
-
const
|
|
85
|
-
l && (
|
|
86
|
-
var p,
|
|
87
|
-
x(((p = t == null ? void 0 : t.response) == null ? void 0 : p.results) || []), b((
|
|
84
|
+
const a = { query: h, page: 1 };
|
|
85
|
+
l && (a.orientation = l), n && (a.color = n), v(1), C(a, s).then((t) => {
|
|
86
|
+
var p, o;
|
|
87
|
+
x(((p = t == null ? void 0 : t.response) == null ? void 0 : p.results) || []), b((o = t == null ? void 0 : t.response) == null ? void 0 : o.total_pages), m(!1);
|
|
88
88
|
}).catch(() => {
|
|
89
89
|
m(!1);
|
|
90
90
|
});
|
|
@@ -104,17 +104,17 @@ const C = async (f, g) => new Promise((s, r) => {
|
|
|
104
104
|
] }) }) : /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
|
|
105
105
|
/* @__PURE__ */ e.jsxs("form", { className: "flex items-center gap-x-2 rounded-md border border-border bg-background p-px", children: [
|
|
106
106
|
/* @__PURE__ */ e.jsx(
|
|
107
|
-
|
|
107
|
+
D,
|
|
108
108
|
{
|
|
109
109
|
type: "text",
|
|
110
110
|
name: "query",
|
|
111
111
|
className: "text-foreground",
|
|
112
112
|
placeholder: 'Try "dog" or "apple"',
|
|
113
|
-
onChange: (
|
|
113
|
+
onChange: (a) => q(a.target.value)
|
|
114
114
|
}
|
|
115
115
|
),
|
|
116
116
|
/* @__PURE__ */ e.jsx("div", { children: /* @__PURE__ */ e.jsx(
|
|
117
|
-
|
|
117
|
+
w,
|
|
118
118
|
{
|
|
119
119
|
className: "w-40",
|
|
120
120
|
placeholder: j("Orientation"),
|
|
@@ -137,11 +137,11 @@ const C = async (f, g) => new Promise((s, r) => {
|
|
|
137
137
|
}
|
|
138
138
|
],
|
|
139
139
|
defaultValue: l,
|
|
140
|
-
onValueChange: (
|
|
140
|
+
onValueChange: (a) => P(a)
|
|
141
141
|
}
|
|
142
142
|
) }),
|
|
143
143
|
/* @__PURE__ */ e.jsx("div", { children: /* @__PURE__ */ e.jsx(
|
|
144
|
-
|
|
144
|
+
w,
|
|
145
145
|
{
|
|
146
146
|
placeholder: j("Color"),
|
|
147
147
|
options: [
|
|
@@ -179,12 +179,12 @@ const C = async (f, g) => new Promise((s, r) => {
|
|
|
179
179
|
}
|
|
180
180
|
],
|
|
181
181
|
defaultValue: n,
|
|
182
|
-
onValueChange: (
|
|
182
|
+
onValueChange: (a) => A(a)
|
|
183
183
|
}
|
|
184
184
|
) })
|
|
185
185
|
] }),
|
|
186
186
|
/* @__PURE__ */ e.jsxs(
|
|
187
|
-
|
|
187
|
+
E,
|
|
188
188
|
{
|
|
189
189
|
className: `h-full ${f && !d(r) ? "-mx-2 flex flex-wrap px-2" : "-mx-2 flex flex-col pb-8 pt-2"}`,
|
|
190
190
|
children: [
|
|
@@ -192,40 +192,40 @@ const C = async (f, g) => new Promise((s, r) => {
|
|
|
192
192
|
/* @__PURE__ */ e.jsx("div", { className: "font-medium", children: "No Data" }),
|
|
193
193
|
/* @__PURE__ */ e.jsx("div", { className: "text-sm text-gray-500", children: "Enter query and press enter" })
|
|
194
194
|
] }),
|
|
195
|
-
f ? /* @__PURE__ */ e.jsx("div", { className: "h-full columns-5 py-2", children: r.map((
|
|
195
|
+
f ? /* @__PURE__ */ e.jsx("div", { className: "h-full columns-5 py-2", children: r.map((a) => /* @__PURE__ */ e.jsx(
|
|
196
196
|
"div",
|
|
197
197
|
{
|
|
198
198
|
role: "button",
|
|
199
199
|
tabIndex: 0,
|
|
200
200
|
className: "my-1 flex",
|
|
201
|
-
onClick: () => g(
|
|
201
|
+
onClick: () => g(a.urls.regular),
|
|
202
202
|
children: /* @__PURE__ */ e.jsx("div", { className: "relative overflow-hidden rounded-md bg-cover bg-no-repeat", children: /* @__PURE__ */ e.jsx(
|
|
203
203
|
"img",
|
|
204
204
|
{
|
|
205
205
|
className: "h-auto flex-1 cursor-pointer rounded-md transition duration-300 ease-in-out hover:scale-105",
|
|
206
|
-
alt:
|
|
207
|
-
src:
|
|
206
|
+
alt: a.alt_description,
|
|
207
|
+
src: a.urls.small
|
|
208
208
|
}
|
|
209
209
|
) })
|
|
210
210
|
},
|
|
211
|
-
|
|
212
|
-
)) }) : r.map((
|
|
211
|
+
a.id
|
|
212
|
+
)) }) : r.map((a) => (
|
|
213
213
|
// TODO: Drag and Drop Image to Canvas from Here use `pic.urls.[small, regular, full]` for image quality
|
|
214
214
|
/* @__PURE__ */ e.jsx("div", { className: "w-full px-2 py-1", children: /* @__PURE__ */ e.jsx("div", { className: "relative overflow-hidden rounded-md bg-cover bg-no-repeat", children: /* @__PURE__ */ e.jsx(
|
|
215
215
|
"img",
|
|
216
216
|
{
|
|
217
217
|
className: "h-auto cursor-pointer transition duration-300 ease-in-out hover:scale-105",
|
|
218
|
-
alt:
|
|
219
|
-
src:
|
|
218
|
+
alt: a.alt_description,
|
|
219
|
+
src: a.urls.small
|
|
220
220
|
}
|
|
221
|
-
) }) },
|
|
221
|
+
) }) }, a.id)
|
|
222
222
|
)),
|
|
223
223
|
u && /* @__PURE__ */ e.jsxs("div", { className: "flex items-center justify-center py-8", children: [
|
|
224
224
|
/* @__PURE__ */ e.jsx(K, { className: "h-6 w-6 animate-spin" }),
|
|
225
225
|
" Loading..."
|
|
226
226
|
] }),
|
|
227
227
|
!d(r) && i < _ && !u && /* @__PURE__ */ e.jsx(
|
|
228
|
-
|
|
228
|
+
L,
|
|
229
229
|
{
|
|
230
230
|
size: "sm",
|
|
231
231
|
variant: "link",
|
|
@@ -241,6 +241,6 @@ const C = async (f, g) => new Promise((s, r) => {
|
|
|
241
241
|
] });
|
|
242
242
|
};
|
|
243
243
|
export {
|
|
244
|
-
|
|
244
|
+
He as default,
|
|
245
245
|
C as fetchImage
|
|
246
246
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./jsx-runtime-JYMCiFoE.cjs"),n=require("react"),p=require("lodash-es"),A=require("unsplash-js"),f=require("./context-menu-sQn7ryJ6.cjs"),_=require("react-i18next"),B=require("./useGlobalBlocksStore-1wJUEOl4.cjs"),T=require("@react-hookz/web"),D=require("lucide-react"),S=require("./index-lynOzeB3.cjs");require("@radix-ui/react-switch");require("@radix-ui/react-accordion");require("@radix-ui/react-icons");require("class-variance-authority");require("@radix-ui/react-alert-dialog");require("@radix-ui/react-slot");require("@radix-ui/react-label");require("@radix-ui/react-scroll-area");require("@radix-ui/react-tabs");require("@radix-ui/react-tooltip");require("@radix-ui/react-popover");require("@radix-ui/react-hover-card");require("@radix-ui/react-select");require("@radix-ui/react-dropdown-menu");require("@radix-ui/react-separator");require("@radix-ui/react-toast");require("cmdk");require("@radix-ui/react-dialog");require("@radix-ui/react-context-menu");require("clsx");require("tailwind-merge");require("jotai");require("./iconBase-kuD_VwQx.cjs");require("./_commonjsHelpers-f52AuuUj.cjs");require("@chaibuilder/runtime");require("tree-model");require("react-quill");require("./STRINGS-Yl7cSWDc.cjs");require("flagged");require("react-hotkeys-hook");require("@floating-ui/dom");require("@floating-ui/react-dom");require("react-event-hook");require("@tailwindcss/typography");require("@tailwindcss/forms");require("@tailwindcss/aspect-ratio");require("tailwindcss-palette-generator");require("./plugin-02QsHeBE.cjs");require("react-wrap-balancer");require("react-dom");require("prop-types");require("react-error-boundary");require("re-resizable");require("@rjsf/validator-ajv8");require("@rjsf/core");require("react-arborist");require("himalaya");require("react-icons-picker");require("react-autosuggest");require("fuse.js");require("i18next");require("framer-motion");const g=async(h,j)=>new Promise((i,a)=>{A.createApi({accessKey:j}).search.getPhotos(h).then(o=>{i(o)}).catch(o=>a(o))}),L=({isModalView:h,onSelect:j})=>{const i=B.useBuilderProp("unsplashAccessKey",""),[a,q]=n.useState([]),[o,b]=n.useState(0),[l,w]=n.useState(),[u,k]=n.useState(),[C,v]=n.useState(0),[d,P]=T.useDebouncedState("",1e3),[m,c]=n.useState(!1),{t:y}=_.useTranslation(),I=async r=>{if(p.isEmpty(d))return;let t=o+1;r&&(r.preventDefault(),t=1),c(!0),b(t);const x={query:d,page:t};l&&(x.orientation=l),u&&(x.color=u),g(x,i).then(s=>{var E,R,N;q(t===1?((E=s==null?void 0:s.response)==null?void 0:E.results)||[]:[...a,...((R=s==null?void 0:s.response)==null?void 0:R.results)||[]]),v((N=s==null?void 0:s.response)==null?void 0:N.total_pages),c(!1)}).catch(()=>{c(!1)})};return n.useEffect(()=>{if(!p.isEmpty(d)&&i){c(!0);const r={query:d,page:1};l&&(r.orientation=l),u&&(r.color=u),b(1),g(r,i).then(t=>{var x,s;q(((x=t==null?void 0:t.response)==null?void 0:x.results)||[]),v((s=t==null?void 0:t.response)==null?void 0:s.total_pages),c(!1)}).catch(()=>{c(!1)})}},[l,u,d,i]),p.isEmpty(i)?e.jsxRuntimeExports.jsx("div",{className:"flex h-full flex-col items-center justify-center",children:e.jsxRuntimeExports.jsxs("p",{className:"max-w-3xl text-center text-gray-500",children:["To enable Unsplash, kindly provide your",e.jsxRuntimeExports.jsx("a",{href:"https://unsplash.com/documentation#public-authentication",className:"px-1 underline hover:text-blue-400",target:"_blank",rel:"noopener noreferrer",children:"Unsplash Access Key"})]})}):e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs("form",{className:"flex items-center gap-x-2 rounded-md border border-border bg-background p-px",children:[e.jsxRuntimeExports.jsx(f.Input,{type:"text",name:"query",className:"text-foreground",placeholder:'Try "dog" or "apple"',onChange:r=>P(r.target.value)}),e.jsxRuntimeExports.jsx("div",{children:e.jsxRuntimeExports.jsx(S.ChaiSelect,{className:"w-40",placeholder:y("Orientation"),options:[{value:"",label:"All"},{value:"landscape",label:"Landscape"},{value:"portrait",label:"Portrait"},{value:"squarish",label:"Square"}],defaultValue:l,onValueChange:r=>w(r)})}),e.jsxRuntimeExports.jsx("div",{children:e.jsxRuntimeExports.jsx(S.ChaiSelect,{placeholder:y("Color"),options:[{value:"",label:"All"},{value:"black_and_white",label:"Black and White"},{value:"black",label:"Black"},{value:"white",label:"White"},{value:"night",label:"Night"},{value:"warm",label:"Warm"},{value:"cool",label:"Cool"},{value:"sepia",label:"Sepia"}],defaultValue:u,onValueChange:r=>k(r)})})]}),e.jsxRuntimeExports.jsxs(f.ScrollArea,{className:`h-full ${h&&!p.isEmpty(a)?"-mx-2 flex flex-wrap px-2":"-mx-2 flex flex-col pb-8 pt-2"}`,children:[p.isEmpty(a)&&!m&&e.jsxRuntimeExports.jsxs("div",{className:"flex flex-col items-center justify-center py-6",children:[e.jsxRuntimeExports.jsx("div",{className:"font-medium",children:"No Data"}),e.jsxRuntimeExports.jsx("div",{className:"text-sm text-gray-500",children:"Enter query and press enter"})]}),h?e.jsxRuntimeExports.jsx("div",{className:"h-full columns-5 py-2",children:a.map(r=>e.jsxRuntimeExports.jsx("div",{role:"button",tabIndex:0,className:"my-1 flex",onClick:()=>j(r.urls.regular),children:e.jsxRuntimeExports.jsx("div",{className:"relative overflow-hidden rounded-md bg-cover bg-no-repeat",children:e.jsxRuntimeExports.jsx("img",{className:"h-auto flex-1 cursor-pointer rounded-md transition duration-300 ease-in-out hover:scale-105",alt:r.alt_description,src:r.urls.small})})},r.id))}):a.map(r=>e.jsxRuntimeExports.jsx("div",{className:"w-full px-2 py-1",children:e.jsxRuntimeExports.jsx("div",{className:"relative overflow-hidden rounded-md bg-cover bg-no-repeat",children:e.jsxRuntimeExports.jsx("img",{className:"h-auto cursor-pointer transition duration-300 ease-in-out hover:scale-105",alt:r.alt_description,src:r.urls.small})})},r.id)),m&&e.jsxRuntimeExports.jsxs("div",{className:"flex items-center justify-center py-8",children:[e.jsxRuntimeExports.jsx(D.Loader,{className:"h-6 w-6 animate-spin"})," Loading..."]}),!p.isEmpty(a)&&o<C&&!m&&e.jsxRuntimeExports.jsx(f.Button,{size:"sm",variant:"link",className:"w-full",onClick:()=>I(void 0),disabled:m,children:m?"":"Load More"})]})]})};exports.default=L;exports.fetchImage=g;
|
|
@@ -1,20 +1,17 @@
|
|
|
1
1
|
import { j as e } from "./jsx-runtime-Sp0orL4X.js";
|
|
2
2
|
import { useState as i, useEffect as k } from "react";
|
|
3
3
|
import { isEmpty as j, map as b } from "lodash-es";
|
|
4
|
-
import { atom as
|
|
5
|
-
import {
|
|
4
|
+
import { atom as F, useAtom as U } from "jotai";
|
|
5
|
+
import { V as C } from "./context-menu-9cWJcKdh.js";
|
|
6
6
|
import { useTranslation as E } from "react-i18next";
|
|
7
|
-
import {
|
|
7
|
+
import { k as N } from "./useGlobalBlocksStore-HlGhDxuV.js";
|
|
8
8
|
import { Upload as G, Loader as P } from "lucide-react";
|
|
9
9
|
import "@radix-ui/react-switch";
|
|
10
|
-
import "./button-9Duvj2dH.js";
|
|
11
|
-
import "@radix-ui/react-slot";
|
|
12
|
-
import "class-variance-authority";
|
|
13
|
-
import "clsx";
|
|
14
|
-
import "tailwind-merge";
|
|
15
10
|
import "@radix-ui/react-accordion";
|
|
16
11
|
import "@radix-ui/react-icons";
|
|
12
|
+
import "class-variance-authority";
|
|
17
13
|
import "@radix-ui/react-alert-dialog";
|
|
14
|
+
import "@radix-ui/react-slot";
|
|
18
15
|
import "@radix-ui/react-label";
|
|
19
16
|
import "@radix-ui/react-scroll-area";
|
|
20
17
|
import "@radix-ui/react-tabs";
|
|
@@ -28,12 +25,15 @@ import "@radix-ui/react-toast";
|
|
|
28
25
|
import "cmdk";
|
|
29
26
|
import "@radix-ui/react-dialog";
|
|
30
27
|
import "@radix-ui/react-context-menu";
|
|
28
|
+
import "clsx";
|
|
29
|
+
import "tailwind-merge";
|
|
30
|
+
import "./iconBase-HBZkvN04.js";
|
|
31
31
|
import "./_commonjsHelpers-f3sTPFkQ.js";
|
|
32
32
|
import "@react-hookz/web";
|
|
33
33
|
import "@chaibuilder/runtime";
|
|
34
34
|
import "tree-model";
|
|
35
|
-
const S =
|
|
36
|
-
const { t: s } = E(), p = N("uploadMediaCallback"), n = N("fetchMediaCallback"), [l, d] =
|
|
35
|
+
const S = F([]), ue = ({ isModalView: r, onSelect: m }) => {
|
|
36
|
+
const { t: s } = E(), p = N("uploadMediaCallback"), n = N("fetchMediaCallback"), [l, d] = U(S), [y, u] = i(!1), [x, f] = i(!1), [, v] = i(), [h, c] = i("");
|
|
37
37
|
k(() => {
|
|
38
38
|
(async () => {
|
|
39
39
|
if (!n)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./jsx-runtime-JYMCiFoE.cjs"),i=require("react"),o=require("lodash-es"),E=require("jotai"),I=require("./context-menu-sQn7ryJ6.cjs"),w=require("react-i18next"),b=require("./useGlobalBlocksStore-1wJUEOl4.cjs"),q=require("lucide-react");require("@radix-ui/react-switch");require("@radix-ui/react-accordion");require("@radix-ui/react-icons");require("class-variance-authority");require("@radix-ui/react-alert-dialog");require("@radix-ui/react-slot");require("@radix-ui/react-label");require("@radix-ui/react-scroll-area");require("@radix-ui/react-tabs");require("@radix-ui/react-tooltip");require("@radix-ui/react-popover");require("@radix-ui/react-hover-card");require("@radix-ui/react-select");require("@radix-ui/react-dropdown-menu");require("@radix-ui/react-separator");require("@radix-ui/react-toast");require("cmdk");require("@radix-ui/react-dialog");require("@radix-ui/react-context-menu");require("clsx");require("tailwind-merge");require("./iconBase-kuD_VwQx.cjs");require("./_commonjsHelpers-f52AuuUj.cjs");require("@react-hookz/web");require("@chaibuilder/runtime");require("tree-model");const k=E.atom([]),S=({isModalView:a,onSelect:u})=>{const{t}=w.useTranslation(),d=b.useBuilderProp("uploadMediaCallback"),x=b.useBuilderProp("fetchMediaCallback"),[l,c]=E.useAtom(k),[R,p]=i.useState(!1),[j,h]=i.useState(!1),[,y]=i.useState(),[f,m]=i.useState("");i.useEffect(()=>{(async()=>{if(!x)return;h(!0);const s=await x();c(s||[]),h(!1)})()},[]);const N=s=>{var r,n;if(m(""),s&&((n=(r=s==null?void 0:s.target)==null?void 0:r.files)==null?void 0:n.length)>0){const g=s.target.files[0];g.type.startsWith("image")?v(g):m(t("Please select an image"))}},v=async s=>{if(d){p(!0);try{const{url:r}=await d(s);u(r),y(void 0);const n=await x();c(n)}catch(r){c([]),m((r==null?void 0:r.message)||"Something went wrong.")}p(!1)}};return e.jsxRuntimeExports.jsxs("div",{children:[e.jsxRuntimeExports.jsxs("label",{htmlFor:a?"upload-in-modal":"upload-in-panel",children:[e.jsxRuntimeExports.jsx("div",{className:"flex flex-col items-center rounded-lg",children:e.jsxRuntimeExports.jsxs("label",{htmlFor:"image-upload",className:"flex w-full cursor-pointer flex-col items-center justify-center rounded-lg border-2 border-dashed border-border",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex flex-col items-center justify-center pb-6 pt-5",children:[e.jsxRuntimeExports.jsx(q.Upload,{className:"mb-3 h-10 w-10 text-gray-400"}),e.jsxRuntimeExports.jsx("p",{className:"mb-2 text-sm text-gray-500 dark:text-gray-400",children:e.jsxRuntimeExports.jsx("span",{className:"font-semibold",children:t("Click to upload")})}),e.jsxRuntimeExports.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:t("SVG, PNG, JPG or GIF (Max. 2mb)")})]}),R?e.jsxRuntimeExports.jsxs("div",{className:"flex h-full w-full items-center justify-center",children:[e.jsxRuntimeExports.jsx(q.Loader,{className:"h-6 w-6 animate-spin"}),e.jsxRuntimeExports.jsx("span",{className:"ml-2 text-sm text-gray-500",children:t("Uploading...")})]}):null,f&&e.jsxRuntimeExports.jsx("p",{className:"pb-2 text-xs text-red-500",children:f||t("Something went wrong")})]})}),e.jsxRuntimeExports.jsx("input",{type:"file",id:"image-upload",accept:"image/*",hidden:!0,onChange:N})]}),e.jsxRuntimeExports.jsxs(I.ScrollArea,{className:`-mx-2 flex h-full flex-col pb-8 pt-2 ${a?"px-2":""} pt-2`,children:[o.isEmpty(l)&&j&&e.jsxRuntimeExports.jsx("div",{className:"flex flex-col items-center justify-center py-6",children:e.jsxRuntimeExports.jsx("div",{className:"animate-pulse font-medium",children:t("Fetching...")})}),o.isEmpty(l)&&!j&&e.jsxRuntimeExports.jsxs("div",{className:"flex h-full flex-col items-center justify-center text-center",children:[e.jsxRuntimeExports.jsx("div",{className:"mb-4 h-12 rounded-full p-6"}),e.jsxRuntimeExports.jsx("h3",{className:"mb-2 text-sm font-semibold",children:t("No images found")}),e.jsxRuntimeExports.jsx("p",{className:"mb-4 max-w-sm text-muted-foreground",children:t("It looks like you haven't uploaded any images yet. Start by clicking the upload button above.")})]}),a?e.jsxRuntimeExports.jsx("div",{className:"h-full columns-5 py-2",children:o.map(l,s=>e.jsxRuntimeExports.jsx("div",{role:"button",tabIndex:0,className:"my-1 flex",onClick:()=>u(s.url),children:e.jsxRuntimeExports.jsx("div",{className:"relative overflow-hidden rounded-md bg-cover bg-no-repeat",children:e.jsxRuntimeExports.jsx("img",{className:"h-auto flex-1 cursor-pointer rounded-md transition duration-300 ease-in-out hover:scale-105",alt:s.name,src:s.thumbUrl})})},s.id))}):o.map(l,s=>e.jsxRuntimeExports.jsx("div",{role:"button",tabIndex:0,className:"px-2 py-1",onClick:()=>u(s.url),children:e.jsxRuntimeExports.jsx("div",{className:"relative overflow-hidden rounded-md bg-cover bg-no-repeat",children:e.jsxRuntimeExports.jsx("img",{className:"h-auto w-full cursor-pointer transition duration-300 ease-in-out hover:scale-105",alt:s.name,src:s.url})})},s.id))]})]})};exports.default=S;
|