@chaibuilder/sdk 1.2.73 → 1.2.75

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.
@@ -1,252 +0,0 @@
1
- import { j as e } from "./jsx-runtime-Sp0orL4X.js";
2
- import { useState as c, useEffect as q } from "react";
3
- import { isEmpty as d } from "lodash-es";
4
- import { MixerHorizontalIcon as S } from "@radix-ui/react-icons";
5
- import { createApi as B } from "unsplash-js";
6
- import { N as D, P as E, r as L, s as T, V as z, B as F } from "./context-menu-zu6r7B6f.js";
7
- import "react-i18next";
8
- import { d as K, C as P } from "./index-pjWMG6LC.js";
9
- import { useDebouncedState as U } from "@react-hookz/web";
10
- import { Loader as V } from "lucide-react";
11
- import "@radix-ui/react-switch";
12
- import "@radix-ui/react-accordion";
13
- import "@radix-ui/react-alert-dialog";
14
- import "@radix-ui/react-slot";
15
- import "class-variance-authority";
16
- import "@radix-ui/react-label";
17
- import "@radix-ui/react-scroll-area";
18
- import "@radix-ui/react-tabs";
19
- import "@radix-ui/react-tooltip";
20
- import "@radix-ui/react-popover";
21
- import "@radix-ui/react-hover-card";
22
- import "@radix-ui/react-dropdown-menu";
23
- import "@radix-ui/react-separator";
24
- import "@radix-ui/react-toast";
25
- import "cmdk";
26
- import "@radix-ui/react-dialog";
27
- import "@radix-ui/react-context-menu";
28
- import "clsx";
29
- import "tailwind-merge";
30
- import "jotai";
31
- import "./iconBase-zweRWSz0.js";
32
- import "@chaibuilder/runtime";
33
- import "./plugin-sJ3Hzvpv.js";
34
- import "tree-model";
35
- import "react-quill";
36
- import "./STRINGS-rPGH65PW.js";
37
- import "react-hotkeys-hook";
38
- import "@floating-ui/dom";
39
- import "@floating-ui/react-dom";
40
- import "flagged";
41
- import "@tailwindcss/typography";
42
- import "@tailwindcss/forms";
43
- import "@tailwindcss/aspect-ratio";
44
- import "tailwindcss-palette-generator";
45
- import "react-wrap-balancer";
46
- import "react-dom";
47
- import "prop-types";
48
- import "re-resizable";
49
- import "@rjsf/validator-ajv8";
50
- import "@rjsf/core";
51
- import "react-arborist";
52
- import "himalaya";
53
- import "react-icons-picker";
54
- import "react-autosuggest";
55
- import "fuse.js";
56
- import "i18next";
57
- import "framer-motion";
58
- const C = async (h, v) => new Promise((s, r) => {
59
- B({ accessKey: v }).search.getPhotos(h).then((i) => {
60
- s(i);
61
- }).catch((i) => r(i));
62
- }), He = ({ isModalView: h, onSelect: v }) => {
63
- const s = K("unsplashAccessKey", ""), [r, f] = c([]), [i, g] = c(0), [l, w] = c(), [n, k] = c(), [A, j] = c(0), [u, I] = U("", 1e3), [x, m] = c(!1), _ = async (t) => {
64
- if (d(u))
65
- return;
66
- let o = i + 1;
67
- t && (t.preventDefault(), o = 1), m(!0), g(o);
68
- const p = { query: u, page: o };
69
- l && (p.orientation = l), n && (p.color = n), C(p, s).then((a) => {
70
- var b, y, N;
71
- f(o === 1 ? ((b = a == null ? void 0 : a.response) == null ? void 0 : b.results) || [] : [...r, ...((y = a == null ? void 0 : a.response) == null ? void 0 : y.results) || []]), j((N = a == null ? void 0 : a.response) == null ? void 0 : N.total_pages), m(!1);
72
- }).catch(() => {
73
- m(!1);
74
- });
75
- };
76
- return q(() => {
77
- if (!d(u) && s) {
78
- m(!0);
79
- const t = { query: u, page: 1 };
80
- l && (t.orientation = l), n && (t.color = n), g(1), C(t, s).then((o) => {
81
- var p, a;
82
- f(((p = o == null ? void 0 : o.response) == null ? void 0 : p.results) || []), j((a = o == null ? void 0 : o.response) == null ? void 0 : a.total_pages), m(!1);
83
- }).catch(() => {
84
- m(!1);
85
- });
86
- }
87
- }, [l, n, u, s]), d(s) ? /* @__PURE__ */ e.jsx("div", { className: "flex h-full flex-col items-center justify-center", children: /* @__PURE__ */ e.jsxs("p", { className: "max-w-3xl text-center text-gray-500", children: [
88
- "To enable Unsplash, kindly provide your",
89
- /* @__PURE__ */ e.jsx(
90
- "a",
91
- {
92
- href: "https://unsplash.com/documentation#public-authentication",
93
- className: "px-1 underline hover:text-blue-400",
94
- target: "_blank",
95
- rel: "noopener noreferrer",
96
- children: "Unsplash Access Key"
97
- }
98
- )
99
- ] }) }) : /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
100
- /* @__PURE__ */ e.jsxs("form", { className: "flex items-center rounded-md border bg-gray-100 p-px", children: [
101
- /* @__PURE__ */ e.jsx(
102
- D,
103
- {
104
- type: "text",
105
- name: "query",
106
- className: "input",
107
- placeholder: 'Try "dog" or "apple"',
108
- onChange: (t) => I(t.target.value)
109
- }
110
- ),
111
- /* @__PURE__ */ e.jsxs(E, { children: [
112
- /* @__PURE__ */ e.jsx(L, { asChild: !0, className: "h-full w-10 cursor-pointer p-2.5 hover:bg-slate-200", children: /* @__PURE__ */ e.jsx(S, {}) }),
113
- /* @__PURE__ */ e.jsx(
114
- T,
115
- {
116
- side: h ? "bottom" : "right",
117
- className: "z-[9999] flex w-max items-center justify-center",
118
- children: /* @__PURE__ */ e.jsxs("div", { children: [
119
- /* @__PURE__ */ e.jsx("div", { className: "py-1 text-sm font-medium", children: "Orientation" }),
120
- /* @__PURE__ */ e.jsx(
121
- P,
122
- {
123
- options: [
124
- {
125
- value: "",
126
- label: "All"
127
- },
128
- {
129
- value: "landscape",
130
- label: "Landscape"
131
- },
132
- {
133
- value: "portrait",
134
- label: "Portrait"
135
- },
136
- {
137
- value: "squarish",
138
- label: "Square"
139
- }
140
- ],
141
- defaultValue: l,
142
- onValueChange: (t) => w(t)
143
- }
144
- ),
145
- /* @__PURE__ */ e.jsx("div", { className: "pb-1 pt-2 text-sm font-medium", children: "Color" }),
146
- /* @__PURE__ */ e.jsx(
147
- P,
148
- {
149
- options: [
150
- {
151
- value: "",
152
- label: "All"
153
- },
154
- {
155
- value: "black_and_white",
156
- label: "Black and White"
157
- },
158
- {
159
- value: "black",
160
- label: "Black"
161
- },
162
- {
163
- value: "white",
164
- label: "White"
165
- },
166
- {
167
- value: "night",
168
- label: "Night"
169
- },
170
- {
171
- value: "warm",
172
- label: "Warm"
173
- },
174
- {
175
- value: "cool",
176
- label: "Cool"
177
- },
178
- {
179
- value: "sepia",
180
- label: "Sepia"
181
- }
182
- ],
183
- defaultValue: n,
184
- onValueChange: (t) => k(t)
185
- }
186
- )
187
- ] })
188
- }
189
- )
190
- ] })
191
- ] }),
192
- /* @__PURE__ */ e.jsxs(
193
- z,
194
- {
195
- className: `h-full ${h && !d(r) ? "-mx-2 flex flex-wrap px-2" : "-mx-2 flex flex-col pb-8 pt-2"}`,
196
- children: [
197
- d(r) && !x && /* @__PURE__ */ e.jsxs("div", { className: "flex flex-col items-center justify-center py-6", children: [
198
- /* @__PURE__ */ e.jsx("div", { className: "font-medium", children: "No Data" }),
199
- /* @__PURE__ */ e.jsx("div", { className: "text-sm text-gray-500", children: "Enter query and press enter" })
200
- ] }),
201
- h ? /* @__PURE__ */ e.jsx("div", { className: "h-full columns-5 py-2", children: r.map((t) => /* @__PURE__ */ e.jsx(
202
- "div",
203
- {
204
- role: "button",
205
- tabIndex: 0,
206
- className: "my-1 flex",
207
- onClick: () => v(t.urls.regular),
208
- children: /* @__PURE__ */ e.jsx("div", { className: "relative overflow-hidden rounded-md bg-cover bg-no-repeat", children: /* @__PURE__ */ e.jsx(
209
- "img",
210
- {
211
- className: "h-auto flex-1 cursor-pointer rounded-md transition duration-300 ease-in-out hover:scale-105",
212
- alt: t.alt_description,
213
- src: t.urls.small
214
- }
215
- ) })
216
- },
217
- t.id
218
- )) }) : r.map((t) => (
219
- // TODO: Drag and Drop Image to Canvas from Here use `pic.urls.[small, regular, full]` for image quality
220
- /* @__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(
221
- "img",
222
- {
223
- className: "h-auto cursor-pointer transition duration-300 ease-in-out hover:scale-105",
224
- alt: t.alt_description,
225
- src: t.urls.small
226
- }
227
- ) }) }, t.id)
228
- )),
229
- x && /* @__PURE__ */ e.jsxs("div", { className: "flex items-center justify-center py-8", children: [
230
- /* @__PURE__ */ e.jsx(V, { className: "h-6 w-6 animate-spin" }),
231
- "  Loading..."
232
- ] }),
233
- !d(r) && i < A && !x && /* @__PURE__ */ e.jsx(
234
- F,
235
- {
236
- size: "sm",
237
- variant: "link",
238
- className: "w-full",
239
- onClick: () => _(void 0),
240
- disabled: x,
241
- children: x ? "" : "Load More"
242
- }
243
- )
244
- ]
245
- }
246
- )
247
- ] });
248
- };
249
- export {
250
- He as default,
251
- C as fetchImage
252
- };
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./jsx-runtime-JYMCiFoE.cjs"),i=require("react"),n=require("lodash-es"),E=require("jotai"),I=require("./context-menu-Lx_MAqsu.cjs"),w=require("react-i18next"),g=require("./index-tHeU8jPk.cjs"),b=require("lucide-react");require("@radix-ui/react-switch");require("@radix-ui/react-accordion");require("@radix-ui/react-icons");require("@radix-ui/react-alert-dialog");require("@radix-ui/react-slot");require("class-variance-authority");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-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-vJD0OXxU.cjs");require("@chaibuilder/runtime");require("./plugin-_F-KZp1i.cjs");require("@react-hookz/web");require("tree-model");require("react-quill");require("./STRINGS-hZpwIZMT.cjs");require("react-hotkeys-hook");require("@floating-ui/dom");require("@floating-ui/react-dom");require("flagged");require("@tailwindcss/typography");require("@tailwindcss/forms");require("@tailwindcss/aspect-ratio");require("tailwindcss-palette-generator");require("react-wrap-balancer");require("react-dom");require("prop-types");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 k=E.atom([]),S=({isModalView:a,onSelect:o})=>{const{t:s}=w.useTranslation(),d=g.useBuilderProp("uploadMediaCallback"),x=g.useBuilderProp("fetchMediaCallback"),[u,c]=E.useAtom(k),[y,p]=i.useState(!1),[j,h]=i.useState(!1),[,R]=i.useState(),[q,m]=i.useState("");i.useEffect(()=>{(async()=>{if(!x)return;h(!0);const r=await x();c(r||[]),h(!1)})()},[]);const N=r=>{var t,l;if(m(""),r&&((l=(t=r==null?void 0:r.target)==null?void 0:t.files)==null?void 0:l.length)>0){const f=r.target.files[0];f.type.startsWith("image")?v(f):m(s("Please select an image"))}},v=async r=>{if(d){p(!0);try{const{url:t}=await d(r);o(t),R(void 0);const l=await x();c(l)}catch(t){c([]),m((t==null?void 0:t.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-gray-300 bg-gray-50 hover:bg-gray-100",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex flex-col items-center justify-center pb-6 pt-5",children:[e.jsxRuntimeExports.jsx(b.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:s("Click to upload")})}),e.jsxRuntimeExports.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:s("SVG, PNG, JPG or GIF (Max. 2mb)")})]}),y?e.jsxRuntimeExports.jsxs("div",{className:"flex h-full w-full items-center justify-center",children:[e.jsxRuntimeExports.jsx(b.Loader,{className:"h-6 w-6 animate-spin"}),e.jsxRuntimeExports.jsx("span",{className:"ml-2 text-sm text-gray-500",children:s("Uploading...")})]}):null,q&&e.jsxRuntimeExports.jsx("p",{className:"pb-2 text-xs text-red-500",children:q||s("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:[n.isEmpty(u)&&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:s("Fetching...")})}),n.isEmpty(u)&&!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:s("No images found")}),e.jsxRuntimeExports.jsx("p",{className:"mb-4 max-w-sm text-muted-foreground",children:s("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:n.map(u,r=>e.jsxRuntimeExports.jsx("div",{role:"button",tabIndex:0,className:"my-1 flex",onClick:()=>o(r.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:r.name,src:r.thumbUrl})})},r.id))}):n.map(u,r=>e.jsxRuntimeExports.jsx("div",{role:"button",tabIndex:0,className:"px-2 py-1",onClick:()=>o(r.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:r.name,src:r.url})})},r.id))]})]})};exports.default=S;