@chaibuilder/sdk 1.2.106 → 1.2.108
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/README.md +2 -2
- package/dist/{CodeEditor-IHn5dpOk.js → CodeEditor-kW6SrwIa.js} +1 -1
- package/dist/{CodeEditor-xvbde46w.cjs → CodeEditor-qrG-nsRa.cjs} +1 -1
- package/dist/{Topbar-21XY-_r9.js → Topbar-3h7dkWBH.js} +1 -1
- package/dist/{Topbar-N7Q15CNR.cjs → Topbar-GjOHwHud.cjs} +1 -1
- package/dist/{UnsplashImages-cgDgay1j.js → UnsplashImages-OH1oIK1z.js} +1 -1
- package/dist/{UnsplashImages-K0zYRuZY.cjs → UnsplashImages-_tnynHFB.cjs} +1 -1
- package/dist/{UploadImages-UnrnhGxR.cjs → UploadImages-6xXHWwiA.cjs} +1 -1
- package/dist/{UploadImages-mC_nhMam.js → UploadImages-Yom319eJ.js} +1 -1
- package/dist/core.cjs +1 -1
- package/dist/core.d.ts +5 -0
- package/dist/core.js +54 -53
- package/dist/{index-FXBj1MyA.js → index-e6K6XOp1.js} +1086 -1020
- package/dist/index-hP_tO2sg.cjs +63 -0
- package/package.json +1 -1
- package/dist/index-px4Uiw4o.cjs +0 -63
|
@@ -89,101 +89,101 @@ const hasInitialValue = (o) => "init" in o, isActuallyWritableAtom = (o) => !!o.
|
|
|
89
89
|
const o = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new WeakMap(), r = /* @__PURE__ */ new Map();
|
|
90
90
|
let a, l, i;
|
|
91
91
|
(define_import_meta_env_default$2 ? "production" : void 0) !== "production" && (a = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set());
|
|
92
|
-
const c = (
|
|
93
|
-
(define_import_meta_env_default$2 ? "production" : void 0) !== "production" && Object.freeze(
|
|
94
|
-
const
|
|
95
|
-
if (o.set(
|
|
96
|
-
const
|
|
97
|
-
cancelPromise(
|
|
92
|
+
const c = (j) => o.get(j), d = (j, v) => {
|
|
93
|
+
(define_import_meta_env_default$2 ? "production" : void 0) !== "production" && Object.freeze(v);
|
|
94
|
+
const w = o.get(j);
|
|
95
|
+
if (o.set(j, v), r.has(j) || r.set(j, w), w && hasPromiseAtomValue(w)) {
|
|
96
|
+
const S = "v" in v ? v.v instanceof Promise ? v.v : Promise.resolve(v.v) : Promise.reject(v.e);
|
|
97
|
+
cancelPromise(w.v, S);
|
|
98
98
|
}
|
|
99
|
-
},
|
|
100
|
-
const
|
|
101
|
-
let
|
|
102
|
-
|
|
103
|
-
!L && P ===
|
|
104
|
-
}), (
|
|
105
|
-
},
|
|
106
|
-
const
|
|
107
|
-
d: (
|
|
108
|
-
v
|
|
99
|
+
}, p = (j, v, w) => {
|
|
100
|
+
const S = /* @__PURE__ */ new Map();
|
|
101
|
+
let T = !1;
|
|
102
|
+
w.forEach((L, P) => {
|
|
103
|
+
!L && P === j && (L = v), L ? (S.set(P, L), v.d.get(P) !== L && (T = !0)) : (define_import_meta_env_default$2 ? "production" : void 0) !== "production" && console.warn("[Bug] atom state not found");
|
|
104
|
+
}), (T || v.d.size !== S.size) && (v.d = S);
|
|
105
|
+
}, u = (j, v, w) => {
|
|
106
|
+
const S = c(j), T = {
|
|
107
|
+
d: (S == null ? void 0 : S.d) || /* @__PURE__ */ new Map(),
|
|
108
|
+
v
|
|
109
109
|
};
|
|
110
|
-
if (
|
|
111
|
-
return
|
|
112
|
-
if (
|
|
113
|
-
if (
|
|
114
|
-
return
|
|
115
|
-
|
|
110
|
+
if (w && p(j, T, w), S && isEqualAtomValue(S, T) && S.d === T.d)
|
|
111
|
+
return S;
|
|
112
|
+
if (S && hasPromiseAtomValue(S) && hasPromiseAtomValue(T) && isEqualPromiseAtomValue(S, T)) {
|
|
113
|
+
if (S.d === T.d)
|
|
114
|
+
return S;
|
|
115
|
+
T.v = S.v;
|
|
116
116
|
}
|
|
117
|
-
return d(
|
|
118
|
-
}, m = (
|
|
119
|
-
if (isPromiseLike$2(
|
|
120
|
-
let
|
|
117
|
+
return d(j, T), T;
|
|
118
|
+
}, m = (j, v, w, S) => {
|
|
119
|
+
if (isPromiseLike$2(v)) {
|
|
120
|
+
let T;
|
|
121
121
|
const L = new Promise((P, V) => {
|
|
122
122
|
let M = !1;
|
|
123
|
-
|
|
123
|
+
v.then(
|
|
124
124
|
(O) => {
|
|
125
125
|
if (!M) {
|
|
126
126
|
M = !0;
|
|
127
|
-
const $ = c(
|
|
128
|
-
|
|
127
|
+
const $ = c(j), H = u(
|
|
128
|
+
j,
|
|
129
129
|
L,
|
|
130
|
-
|
|
130
|
+
w
|
|
131
131
|
);
|
|
132
|
-
resolvePromise(L, O), P(O), ($ == null ? void 0 : $.d) !== H.d && N(
|
|
132
|
+
resolvePromise(L, O), P(O), ($ == null ? void 0 : $.d) !== H.d && N(j, H, $ == null ? void 0 : $.d);
|
|
133
133
|
}
|
|
134
134
|
},
|
|
135
135
|
(O) => {
|
|
136
136
|
if (!M) {
|
|
137
137
|
M = !0;
|
|
138
|
-
const $ = c(
|
|
139
|
-
|
|
138
|
+
const $ = c(j), H = u(
|
|
139
|
+
j,
|
|
140
140
|
L,
|
|
141
|
-
|
|
141
|
+
w
|
|
142
142
|
);
|
|
143
|
-
rejectPromise(L, O), V(O), ($ == null ? void 0 : $.d) !== H.d && N(
|
|
143
|
+
rejectPromise(L, O), V(O), ($ == null ? void 0 : $.d) !== H.d && N(j, H, $ == null ? void 0 : $.d);
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
|
-
),
|
|
146
|
+
), T = (O) => {
|
|
147
147
|
M || (M = !0, O.then(
|
|
148
148
|
($) => resolvePromise(L, $),
|
|
149
149
|
($) => rejectPromise(L, $)
|
|
150
150
|
), P(O));
|
|
151
151
|
};
|
|
152
152
|
});
|
|
153
|
-
return L.orig =
|
|
154
|
-
P &&
|
|
155
|
-
}),
|
|
153
|
+
return L.orig = v, L.status = "pending", registerCancelPromise(L, (P) => {
|
|
154
|
+
P && T(P), S == null || S();
|
|
155
|
+
}), u(j, L, w);
|
|
156
156
|
}
|
|
157
|
-
return
|
|
158
|
-
}, x = (
|
|
159
|
-
const
|
|
160
|
-
d: (
|
|
161
|
-
e:
|
|
157
|
+
return u(j, v, w);
|
|
158
|
+
}, x = (j, v, w) => {
|
|
159
|
+
const S = c(j), T = {
|
|
160
|
+
d: (S == null ? void 0 : S.d) || /* @__PURE__ */ new Map(),
|
|
161
|
+
e: v
|
|
162
162
|
};
|
|
163
|
-
return
|
|
164
|
-
}, g = (
|
|
165
|
-
const
|
|
166
|
-
if (
|
|
167
|
-
O !==
|
|
168
|
-
}), Array.from(
|
|
163
|
+
return w && p(j, T, w), S && isEqualAtomError(S, T) && S.d === T.d ? S : (d(j, T), T);
|
|
164
|
+
}, g = (j) => {
|
|
165
|
+
const v = c(j);
|
|
166
|
+
if (v && (v.d.forEach((M, O) => {
|
|
167
|
+
O !== j && !n.has(O) && g(O);
|
|
168
|
+
}), Array.from(v.d).every(([M, O]) => {
|
|
169
169
|
const $ = c(M);
|
|
170
|
-
return M ===
|
|
170
|
+
return M === j || $ === O || // TODO This is a hack, we should find a better solution.
|
|
171
171
|
$ && !hasPromiseAtomValue($) && isEqualAtomValue($, O);
|
|
172
172
|
})))
|
|
173
|
-
return
|
|
174
|
-
const
|
|
175
|
-
let
|
|
176
|
-
const
|
|
177
|
-
if (M ===
|
|
173
|
+
return v;
|
|
174
|
+
const w = /* @__PURE__ */ new Map();
|
|
175
|
+
let S = !0;
|
|
176
|
+
const T = (M) => {
|
|
177
|
+
if (M === j) {
|
|
178
178
|
const $ = c(M);
|
|
179
179
|
if ($)
|
|
180
|
-
return
|
|
180
|
+
return w.set(M, $), returnAtomValue($);
|
|
181
181
|
if (hasInitialValue(M))
|
|
182
|
-
return
|
|
182
|
+
return w.set(M, void 0), M.init;
|
|
183
183
|
throw new Error("no atom init");
|
|
184
184
|
}
|
|
185
185
|
const O = g(M);
|
|
186
|
-
return
|
|
186
|
+
return w.set(M, O), returnAtomValue(O);
|
|
187
187
|
};
|
|
188
188
|
let L, P;
|
|
189
189
|
const V = {
|
|
@@ -191,176 +191,176 @@ const hasInitialValue = (o) => "init" in o, isActuallyWritableAtom = (o) => !!o.
|
|
|
191
191
|
return L || (L = new AbortController()), L.signal;
|
|
192
192
|
},
|
|
193
193
|
get setSelf() {
|
|
194
|
-
return (define_import_meta_env_default$2 ? "production" : void 0) !== "production" && !isActuallyWritableAtom(
|
|
195
|
-
if ((define_import_meta_env_default$2 ? "production" : void 0) !== "production" &&
|
|
196
|
-
return B(
|
|
194
|
+
return (define_import_meta_env_default$2 ? "production" : void 0) !== "production" && !isActuallyWritableAtom(j) && console.warn("setSelf function cannot be used with read-only atom"), !P && isActuallyWritableAtom(j) && (P = (...M) => {
|
|
195
|
+
if ((define_import_meta_env_default$2 ? "production" : void 0) !== "production" && S && console.warn("setSelf function cannot be called in sync"), !S)
|
|
196
|
+
return B(j, ...M);
|
|
197
197
|
}), P;
|
|
198
198
|
}
|
|
199
199
|
};
|
|
200
200
|
try {
|
|
201
|
-
const M =
|
|
201
|
+
const M = j.read(T, V);
|
|
202
202
|
return m(
|
|
203
|
-
|
|
203
|
+
j,
|
|
204
204
|
M,
|
|
205
|
-
|
|
205
|
+
w,
|
|
206
206
|
() => L == null ? void 0 : L.abort()
|
|
207
207
|
);
|
|
208
208
|
} catch (M) {
|
|
209
|
-
return x(
|
|
209
|
+
return x(j, M, w);
|
|
210
210
|
} finally {
|
|
211
|
-
|
|
211
|
+
S = !1;
|
|
212
212
|
}
|
|
213
|
-
}, E = (
|
|
214
|
-
let
|
|
215
|
-
return
|
|
216
|
-
}, f = (
|
|
217
|
-
const
|
|
218
|
-
|
|
219
|
-
},
|
|
220
|
-
const
|
|
213
|
+
}, E = (j) => returnAtomValue(g(j)), b = (j) => {
|
|
214
|
+
let v = n.get(j);
|
|
215
|
+
return v || (v = R(j)), v;
|
|
216
|
+
}, f = (j, v) => !v.l.size && (!v.t.size || v.t.size === 1 && v.t.has(j)), k = (j) => {
|
|
217
|
+
const v = n.get(j);
|
|
218
|
+
v && f(j, v) && A(j);
|
|
219
|
+
}, _ = (j) => {
|
|
220
|
+
const v = /* @__PURE__ */ new Map(), w = /* @__PURE__ */ new WeakMap(), S = (L) => {
|
|
221
221
|
const P = n.get(L);
|
|
222
222
|
P == null || P.t.forEach((V) => {
|
|
223
|
-
V !== L && (
|
|
223
|
+
V !== L && (v.set(
|
|
224
224
|
V,
|
|
225
|
-
(
|
|
226
|
-
),
|
|
225
|
+
(v.get(V) || /* @__PURE__ */ new Set()).add(L)
|
|
226
|
+
), w.set(V, (w.get(V) || 0) + 1), S(V));
|
|
227
227
|
});
|
|
228
228
|
};
|
|
229
|
-
|
|
230
|
-
const
|
|
229
|
+
S(j);
|
|
230
|
+
const T = (L) => {
|
|
231
231
|
const P = n.get(L);
|
|
232
232
|
P == null || P.t.forEach((V) => {
|
|
233
233
|
var M;
|
|
234
234
|
if (V !== L) {
|
|
235
|
-
let O =
|
|
236
|
-
if (O &&
|
|
237
|
-
let $ = !!((M =
|
|
235
|
+
let O = w.get(V);
|
|
236
|
+
if (O && w.set(V, --O), !O) {
|
|
237
|
+
let $ = !!((M = v.get(V)) != null && M.size);
|
|
238
238
|
if ($) {
|
|
239
239
|
const H = c(V), F = g(V);
|
|
240
240
|
$ = !H || !isEqualAtomValue(H, F);
|
|
241
241
|
}
|
|
242
|
-
$ ||
|
|
242
|
+
$ || v.forEach((H) => H.delete(V));
|
|
243
243
|
}
|
|
244
|
-
|
|
244
|
+
T(V);
|
|
245
245
|
}
|
|
246
246
|
});
|
|
247
247
|
};
|
|
248
|
-
|
|
249
|
-
},
|
|
250
|
-
let
|
|
251
|
-
const
|
|
248
|
+
T(j);
|
|
249
|
+
}, C = (j, ...v) => {
|
|
250
|
+
let w = !0;
|
|
251
|
+
const S = (P) => returnAtomValue(g(P)), T = (P, ...V) => {
|
|
252
252
|
let M;
|
|
253
|
-
if (P ===
|
|
253
|
+
if (P === j) {
|
|
254
254
|
if (!hasInitialValue(P))
|
|
255
255
|
throw new Error("atom not writable");
|
|
256
256
|
const O = c(P), $ = m(P, V[0]);
|
|
257
|
-
(!O || !isEqualAtomValue(O, $)) &&
|
|
257
|
+
(!O || !isEqualAtomValue(O, $)) && _(P);
|
|
258
258
|
} else
|
|
259
|
-
M =
|
|
260
|
-
if (!
|
|
259
|
+
M = C(P, ...V);
|
|
260
|
+
if (!w) {
|
|
261
261
|
const O = D();
|
|
262
262
|
(define_import_meta_env_default$2 ? "production" : void 0) !== "production" && l.forEach(
|
|
263
263
|
($) => $({ type: "async-write", flushed: O })
|
|
264
264
|
);
|
|
265
265
|
}
|
|
266
266
|
return M;
|
|
267
|
-
}, L =
|
|
268
|
-
return
|
|
269
|
-
}, B = (
|
|
270
|
-
const
|
|
267
|
+
}, L = j.write(S, T, ...v);
|
|
268
|
+
return w = !1, L;
|
|
269
|
+
}, B = (j, ...v) => {
|
|
270
|
+
const w = C(j, ...v), S = D();
|
|
271
271
|
return (define_import_meta_env_default$2 ? "production" : void 0) !== "production" && l.forEach(
|
|
272
|
-
(
|
|
273
|
-
),
|
|
274
|
-
},
|
|
275
|
-
const
|
|
276
|
-
t: new Set(
|
|
272
|
+
(T) => T({ type: "write", flushed: S })
|
|
273
|
+
), w;
|
|
274
|
+
}, R = (j, v) => {
|
|
275
|
+
const w = {
|
|
276
|
+
t: new Set(v && [v]),
|
|
277
277
|
l: /* @__PURE__ */ new Set()
|
|
278
278
|
};
|
|
279
|
-
if (n.set(
|
|
280
|
-
const L = n.get(
|
|
281
|
-
L ? L.t.add(
|
|
282
|
-
}), g(
|
|
283
|
-
const
|
|
284
|
-
|
|
279
|
+
if (n.set(j, w), (define_import_meta_env_default$2 ? "production" : void 0) !== "production" && i.add(j), g(j).d.forEach((S, T) => {
|
|
280
|
+
const L = n.get(T);
|
|
281
|
+
L ? L.t.add(j) : T !== j && R(T, j);
|
|
282
|
+
}), g(j), isActuallyWritableAtom(j) && j.onMount) {
|
|
283
|
+
const S = j.onMount((...T) => B(j, ...T));
|
|
284
|
+
S && (w.u = S);
|
|
285
285
|
}
|
|
286
|
-
return
|
|
287
|
-
}, A = (
|
|
288
|
-
var
|
|
289
|
-
const
|
|
290
|
-
|
|
291
|
-
const
|
|
292
|
-
|
|
293
|
-
if (L !==
|
|
286
|
+
return w;
|
|
287
|
+
}, A = (j) => {
|
|
288
|
+
var v;
|
|
289
|
+
const w = (v = n.get(j)) == null ? void 0 : v.u;
|
|
290
|
+
w && w(), n.delete(j), (define_import_meta_env_default$2 ? "production" : void 0) !== "production" && i.delete(j);
|
|
291
|
+
const S = c(j);
|
|
292
|
+
S ? (hasPromiseAtomValue(S) && cancelPromise(S.v), S.d.forEach((T, L) => {
|
|
293
|
+
if (L !== j) {
|
|
294
294
|
const P = n.get(L);
|
|
295
|
-
P && (P.t.delete(
|
|
295
|
+
P && (P.t.delete(j), f(L, P) && A(L));
|
|
296
296
|
}
|
|
297
|
-
})) : (define_import_meta_env_default$2 ? "production" : void 0) !== "production" && console.warn("[Bug] could not find atom state to unmount",
|
|
298
|
-
}, N = (
|
|
299
|
-
const
|
|
300
|
-
|
|
301
|
-
if (
|
|
302
|
-
|
|
297
|
+
})) : (define_import_meta_env_default$2 ? "production" : void 0) !== "production" && console.warn("[Bug] could not find atom state to unmount", j);
|
|
298
|
+
}, N = (j, v, w) => {
|
|
299
|
+
const S = new Set(v.d.keys());
|
|
300
|
+
w == null || w.forEach((T, L) => {
|
|
301
|
+
if (S.has(L)) {
|
|
302
|
+
S.delete(L);
|
|
303
303
|
return;
|
|
304
304
|
}
|
|
305
305
|
const P = n.get(L);
|
|
306
|
-
P && (P.t.delete(
|
|
307
|
-
}),
|
|
308
|
-
const L = n.get(
|
|
309
|
-
L ? L.t.add(
|
|
306
|
+
P && (P.t.delete(j), f(L, P) && A(L));
|
|
307
|
+
}), S.forEach((T) => {
|
|
308
|
+
const L = n.get(T);
|
|
309
|
+
L ? L.t.add(j) : n.has(j) && R(T, j);
|
|
310
310
|
});
|
|
311
311
|
}, D = () => {
|
|
312
|
-
let
|
|
313
|
-
for ((define_import_meta_env_default$2 ? "production" : void 0) !== "production" && (
|
|
314
|
-
const
|
|
315
|
-
r.clear(),
|
|
316
|
-
const
|
|
317
|
-
if (
|
|
318
|
-
|
|
319
|
-
const L = n.get(
|
|
312
|
+
let j;
|
|
313
|
+
for ((define_import_meta_env_default$2 ? "production" : void 0) !== "production" && (j = /* @__PURE__ */ new Set()); r.size; ) {
|
|
314
|
+
const v = Array.from(r);
|
|
315
|
+
r.clear(), v.forEach(([w, S]) => {
|
|
316
|
+
const T = c(w);
|
|
317
|
+
if (T) {
|
|
318
|
+
T.d !== (S == null ? void 0 : S.d) && N(w, T, S == null ? void 0 : S.d);
|
|
319
|
+
const L = n.get(w);
|
|
320
320
|
L && !// TODO This seems pretty hacky. Hope to fix it.
|
|
321
321
|
// Maybe we could `mountDependencies` in `setAtomState`?
|
|
322
|
-
(
|
|
322
|
+
(S && !hasPromiseAtomValue(S) && (isEqualAtomValue(S, T) || isEqualAtomError(S, T))) && (L.l.forEach((P) => P()), (define_import_meta_env_default$2 ? "production" : void 0) !== "production" && j.add(w));
|
|
323
323
|
} else
|
|
324
324
|
(define_import_meta_env_default$2 ? "production" : void 0) !== "production" && console.warn("[Bug] no atom state to flush");
|
|
325
325
|
});
|
|
326
326
|
}
|
|
327
327
|
if ((define_import_meta_env_default$2 ? "production" : void 0) !== "production")
|
|
328
|
-
return a.forEach((
|
|
329
|
-
},
|
|
330
|
-
const
|
|
331
|
-
return
|
|
332
|
-
(L) => L({ type: "sub", flushed:
|
|
328
|
+
return a.forEach((v) => v("state")), j;
|
|
329
|
+
}, I = (j, v) => {
|
|
330
|
+
const w = b(j), S = D(), T = w.l;
|
|
331
|
+
return T.add(v), (define_import_meta_env_default$2 ? "production" : void 0) !== "production" && (a.forEach((L) => L("sub")), l.forEach(
|
|
332
|
+
(L) => L({ type: "sub", flushed: S })
|
|
333
333
|
)), () => {
|
|
334
|
-
|
|
334
|
+
T.delete(v), k(j), (define_import_meta_env_default$2 ? "production" : void 0) !== "production" && (a.forEach((L) => L("unsub")), l.forEach((L) => L({ type: "unsub" })));
|
|
335
335
|
};
|
|
336
336
|
};
|
|
337
337
|
return (define_import_meta_env_default$2 ? "production" : void 0) !== "production" ? {
|
|
338
338
|
get: E,
|
|
339
339
|
set: B,
|
|
340
|
-
sub:
|
|
340
|
+
sub: I,
|
|
341
341
|
// store dev methods (these are tentative and subject to change without notice)
|
|
342
|
-
dev_subscribe_store: (
|
|
342
|
+
dev_subscribe_store: (j, v) => v !== 2 ? (console.warn(
|
|
343
343
|
"The current StoreListener revision is 2. The older ones are deprecated."
|
|
344
|
-
), a.add(
|
|
345
|
-
a.delete(
|
|
346
|
-
}) : (l.add(
|
|
347
|
-
l.delete(
|
|
344
|
+
), a.add(j), () => {
|
|
345
|
+
a.delete(j);
|
|
346
|
+
}) : (l.add(j), () => {
|
|
347
|
+
l.delete(j);
|
|
348
348
|
}),
|
|
349
349
|
dev_get_mounted_atoms: () => i.values(),
|
|
350
|
-
dev_get_atom_state: (
|
|
351
|
-
dev_get_mounted: (
|
|
352
|
-
dev_restore_atoms: (
|
|
353
|
-
for (const [
|
|
354
|
-
hasInitialValue(
|
|
355
|
-
const
|
|
350
|
+
dev_get_atom_state: (j) => o.get(j),
|
|
351
|
+
dev_get_mounted: (j) => n.get(j),
|
|
352
|
+
dev_restore_atoms: (j) => {
|
|
353
|
+
for (const [w, S] of j)
|
|
354
|
+
hasInitialValue(w) && (m(w, S), _(w));
|
|
355
|
+
const v = D();
|
|
356
356
|
l.forEach(
|
|
357
|
-
(
|
|
357
|
+
(w) => w({ type: "restore", flushed: v })
|
|
358
358
|
);
|
|
359
359
|
}
|
|
360
360
|
} : {
|
|
361
361
|
get: E,
|
|
362
362
|
set: B,
|
|
363
|
-
sub:
|
|
363
|
+
sub: I
|
|
364
364
|
};
|
|
365
365
|
};
|
|
366
366
|
let defaultStore;
|
|
@@ -374,86 +374,86 @@ function splitAtom(o, n) {
|
|
|
374
374
|
return memo2$1(
|
|
375
375
|
() => {
|
|
376
376
|
const r = /* @__PURE__ */ new WeakMap(), a = (c, d) => {
|
|
377
|
-
let
|
|
378
|
-
if (
|
|
379
|
-
return
|
|
380
|
-
const
|
|
377
|
+
let p = r.get(c);
|
|
378
|
+
if (p)
|
|
379
|
+
return p;
|
|
380
|
+
const u = d && r.get(d), m = [], x = [];
|
|
381
381
|
return c.forEach((g, E) => {
|
|
382
|
-
const
|
|
383
|
-
x[E] =
|
|
384
|
-
const f =
|
|
382
|
+
const b = n ? n(g) : E;
|
|
383
|
+
x[E] = b;
|
|
384
|
+
const f = u && u.atomList[u.keyList.indexOf(b)];
|
|
385
385
|
if (f) {
|
|
386
386
|
m[E] = f;
|
|
387
387
|
return;
|
|
388
388
|
}
|
|
389
|
-
const
|
|
390
|
-
const B =
|
|
391
|
-
if (N < 0 || N >=
|
|
392
|
-
const D = c[a(c).keyList.indexOf(
|
|
389
|
+
const k = (C) => {
|
|
390
|
+
const B = C(l), R = C(o), N = a(R, B == null ? void 0 : B.arr).keyList.indexOf(b);
|
|
391
|
+
if (N < 0 || N >= R.length) {
|
|
392
|
+
const D = c[a(c).keyList.indexOf(b)];
|
|
393
393
|
if (D)
|
|
394
394
|
return D;
|
|
395
395
|
throw new Error("splitAtom: index out of bounds for read");
|
|
396
396
|
}
|
|
397
|
-
return
|
|
398
|
-
},
|
|
399
|
-
const A =
|
|
400
|
-
if (
|
|
397
|
+
return R[N];
|
|
398
|
+
}, _ = (C, B, R) => {
|
|
399
|
+
const A = C(l), N = C(o), I = a(N, A == null ? void 0 : A.arr).keyList.indexOf(b);
|
|
400
|
+
if (I < 0 || I >= N.length)
|
|
401
401
|
throw new Error("splitAtom: index out of bounds for write");
|
|
402
|
-
const
|
|
402
|
+
const j = isFunction(R) ? R(N[I]) : R;
|
|
403
403
|
B(o, [
|
|
404
|
-
...N.slice(0,
|
|
405
|
-
|
|
406
|
-
...N.slice(
|
|
404
|
+
...N.slice(0, I),
|
|
405
|
+
j,
|
|
406
|
+
...N.slice(I + 1)
|
|
407
407
|
]);
|
|
408
408
|
};
|
|
409
|
-
m[E] = isWritable(o) ? atom(
|
|
410
|
-
}),
|
|
409
|
+
m[E] = isWritable(o) ? atom(k, _) : atom(k);
|
|
410
|
+
}), u && u.keyList.length === x.length && u.keyList.every((g, E) => g === x[E]) ? p = u : p = { arr: c, atomList: m, keyList: x }, r.set(c, p), p;
|
|
411
411
|
}, l = atom((c) => {
|
|
412
|
-
const d = c(l),
|
|
413
|
-
return a(
|
|
412
|
+
const d = c(l), p = c(o);
|
|
413
|
+
return a(p, d == null ? void 0 : d.arr);
|
|
414
414
|
});
|
|
415
415
|
(define_import_meta_env_default$1 ? "production" : void 0) !== "production" && (l.debugPrivate = !0), l.init = void 0;
|
|
416
416
|
const i = isWritable(o) ? atom(
|
|
417
417
|
(c) => c(l).atomList,
|
|
418
|
-
(c, d,
|
|
419
|
-
switch (
|
|
418
|
+
(c, d, p) => {
|
|
419
|
+
switch (p.type) {
|
|
420
420
|
case "remove": {
|
|
421
|
-
const
|
|
422
|
-
if (
|
|
421
|
+
const u = c(i).indexOf(p.atom);
|
|
422
|
+
if (u >= 0) {
|
|
423
423
|
const m = c(o);
|
|
424
424
|
d(o, [
|
|
425
|
-
...m.slice(0,
|
|
426
|
-
...m.slice(
|
|
425
|
+
...m.slice(0, u),
|
|
426
|
+
...m.slice(u + 1)
|
|
427
427
|
]);
|
|
428
428
|
}
|
|
429
429
|
break;
|
|
430
430
|
}
|
|
431
431
|
case "insert": {
|
|
432
|
-
const
|
|
433
|
-
if (
|
|
432
|
+
const u = p.before ? c(i).indexOf(p.before) : c(i).length;
|
|
433
|
+
if (u >= 0) {
|
|
434
434
|
const m = c(o);
|
|
435
435
|
d(o, [
|
|
436
|
-
...m.slice(0,
|
|
437
|
-
|
|
438
|
-
...m.slice(
|
|
436
|
+
...m.slice(0, u),
|
|
437
|
+
p.value,
|
|
438
|
+
...m.slice(u)
|
|
439
439
|
]);
|
|
440
440
|
}
|
|
441
441
|
break;
|
|
442
442
|
}
|
|
443
443
|
case "move": {
|
|
444
|
-
const
|
|
445
|
-
if (
|
|
444
|
+
const u = c(i).indexOf(p.atom), m = p.before ? c(i).indexOf(p.before) : c(i).length;
|
|
445
|
+
if (u >= 0 && m >= 0) {
|
|
446
446
|
const x = c(o);
|
|
447
|
-
|
|
448
|
-
...x.slice(0,
|
|
449
|
-
...x.slice(
|
|
450
|
-
x[
|
|
447
|
+
u < m ? d(o, [
|
|
448
|
+
...x.slice(0, u),
|
|
449
|
+
...x.slice(u + 1, m),
|
|
450
|
+
x[u],
|
|
451
451
|
...x.slice(m)
|
|
452
452
|
]) : d(o, [
|
|
453
453
|
...x.slice(0, m),
|
|
454
|
-
x[
|
|
455
|
-
...x.slice(m,
|
|
456
|
-
...x.slice(
|
|
454
|
+
x[u],
|
|
455
|
+
...x.slice(m, u),
|
|
456
|
+
...x.slice(u + 1)
|
|
457
457
|
]);
|
|
458
458
|
}
|
|
459
459
|
break;
|
|
@@ -473,7 +473,7 @@ function createJSONStorage(o) {
|
|
|
473
473
|
const a = {
|
|
474
474
|
getItem: (l, i) => {
|
|
475
475
|
var c, d;
|
|
476
|
-
const
|
|
476
|
+
const p = (m) => {
|
|
477
477
|
if (m = m || "", n !== m) {
|
|
478
478
|
try {
|
|
479
479
|
r = JSON.parse(m);
|
|
@@ -483,8 +483,8 @@ function createJSONStorage(o) {
|
|
|
483
483
|
n = m;
|
|
484
484
|
}
|
|
485
485
|
return r;
|
|
486
|
-
},
|
|
487
|
-
return isPromiseLike$1(
|
|
486
|
+
}, u = (d = (c = o()) == null ? void 0 : c.getItem(l)) != null ? d : null;
|
|
487
|
+
return isPromiseLike$1(u) ? u.then(p) : p(u);
|
|
488
488
|
},
|
|
489
489
|
setItem: (l, i) => {
|
|
490
490
|
var c;
|
|
@@ -499,15 +499,15 @@ function createJSONStorage(o) {
|
|
|
499
499
|
if (!(o() instanceof window.Storage))
|
|
500
500
|
return () => {
|
|
501
501
|
};
|
|
502
|
-
const d = (
|
|
503
|
-
if (
|
|
504
|
-
let
|
|
502
|
+
const d = (p) => {
|
|
503
|
+
if (p.storageArea === o() && p.key === l) {
|
|
504
|
+
let u;
|
|
505
505
|
try {
|
|
506
|
-
|
|
506
|
+
u = JSON.parse(p.newValue || "");
|
|
507
507
|
} catch {
|
|
508
|
-
|
|
508
|
+
u = c;
|
|
509
509
|
}
|
|
510
|
-
i(
|
|
510
|
+
i(u);
|
|
511
511
|
}
|
|
512
512
|
};
|
|
513
513
|
return window.addEventListener("storage", d), () => {
|
|
@@ -524,13 +524,13 @@ function atomWithStorage(o, n, r = defaultStorage, a) {
|
|
|
524
524
|
);
|
|
525
525
|
return (define_import_meta_env_default$1 ? "production" : void 0) !== "production" && (i.debugPrivate = !0), i.onMount = (d) => {
|
|
526
526
|
l || d(r.getItem(o, n));
|
|
527
|
-
let
|
|
528
|
-
return r.subscribe && (
|
|
527
|
+
let p;
|
|
528
|
+
return r.subscribe && (p = r.subscribe(o, d, n)), p;
|
|
529
529
|
}, atom(
|
|
530
530
|
(d) => d(i),
|
|
531
|
-
(d,
|
|
532
|
-
const m = typeof
|
|
533
|
-
return m === RESET ? (
|
|
531
|
+
(d, p, u) => {
|
|
532
|
+
const m = typeof u == "function" ? u(d(i)) : u;
|
|
533
|
+
return m === RESET ? (p(i, n), r.removeItem(o)) : m instanceof Promise ? m.then((x) => (p(i, x), r.setItem(o, x))) : (p(i, m), r.setItem(o, m));
|
|
534
534
|
}
|
|
535
535
|
);
|
|
536
536
|
}
|
|
@@ -554,26 +554,26 @@ const StoreContext = createContext(void 0), useStore = (o) => {
|
|
|
554
554
|
});
|
|
555
555
|
function useAtomValue(o, n) {
|
|
556
556
|
const r = useStore(n), [[a, l, i], c] = useReducer(
|
|
557
|
-
(
|
|
557
|
+
(u) => {
|
|
558
558
|
const m = r.get(o);
|
|
559
|
-
return Object.is(
|
|
559
|
+
return Object.is(u[0], m) && u[1] === r && u[2] === o ? u : [m, r, o];
|
|
560
560
|
},
|
|
561
561
|
void 0,
|
|
562
562
|
() => [r.get(o), r, o]
|
|
563
563
|
);
|
|
564
564
|
let d = a;
|
|
565
565
|
(l !== r || i !== o) && (c(), d = r.get(o));
|
|
566
|
-
const
|
|
566
|
+
const p = n == null ? void 0 : n.delay;
|
|
567
567
|
return useEffect(() => {
|
|
568
|
-
const
|
|
569
|
-
if (typeof
|
|
570
|
-
setTimeout(c,
|
|
568
|
+
const u = r.sub(o, () => {
|
|
569
|
+
if (typeof p == "number") {
|
|
570
|
+
setTimeout(c, p);
|
|
571
571
|
return;
|
|
572
572
|
}
|
|
573
573
|
c();
|
|
574
574
|
});
|
|
575
|
-
return c(),
|
|
576
|
-
}, [r, o,
|
|
575
|
+
return c(), u;
|
|
576
|
+
}, [r, o, p]), useDebugValue(d), isPromiseLike(d) ? use(d) : d;
|
|
577
577
|
}
|
|
578
578
|
function useSetAtom(o, n) {
|
|
579
579
|
const r = useStore(n);
|
|
@@ -638,10 +638,10 @@ const getSlots = (o) => {
|
|
|
638
638
|
filter(o, { _parent: n }).length > 0 && l.push(flatten(duplicateBlocks(o, n, a._id)));
|
|
639
639
|
const i = flatten(l);
|
|
640
640
|
return map(i, (c) => {
|
|
641
|
-
const d = c,
|
|
642
|
-
return Object.keys(
|
|
643
|
-
const m = find(i, { oldId: u
|
|
644
|
-
d[
|
|
641
|
+
const d = c, p = getSlots(d);
|
|
642
|
+
return Object.keys(p).length > 0 && Object.keys(p).forEach((u) => {
|
|
643
|
+
const m = find(i, { oldId: p[u].replace("slot:", "") });
|
|
644
|
+
d[u] = `slot:${m._id}`;
|
|
645
645
|
}), omit(d, ["global", "oldId"]);
|
|
646
646
|
});
|
|
647
647
|
}, presentBlocksAtom = atom$1([]);
|
|
@@ -746,8 +746,8 @@ const useSelectedBlocksDisplayChild = () => ({
|
|
|
746
746
|
}, getBlockJSONFromSchemas = (o, n, r) => {
|
|
747
747
|
switch (o.type) {
|
|
748
748
|
case "singular": {
|
|
749
|
-
const
|
|
750
|
-
return
|
|
749
|
+
const u = o.schema;
|
|
750
|
+
return u.title && (u.title = titleWithLang(n(u.title), r, get(o, "i18n"))), u.oneOf && Array.isArray(u.oneOf) && (u.oneOf = u.oneOf.map((m) => (m.title && (m.title = n(m.title)), m))), u;
|
|
751
751
|
}
|
|
752
752
|
case "model":
|
|
753
753
|
const { properties: a, title: l } = o, i = {
|
|
@@ -755,15 +755,15 @@ const useSelectedBlocksDisplayChild = () => ({
|
|
|
755
755
|
type: "object",
|
|
756
756
|
properties: {}
|
|
757
757
|
};
|
|
758
|
-
return Object.keys(a).forEach((
|
|
759
|
-
const m = a[
|
|
758
|
+
return Object.keys(a).forEach((u) => {
|
|
759
|
+
const m = a[u];
|
|
760
760
|
if (includes(["slot", "styles"], m.type))
|
|
761
761
|
return;
|
|
762
|
-
const x =
|
|
762
|
+
const x = u;
|
|
763
763
|
i.properties[x] = getBlockJSONFromSchemas(m, n, r);
|
|
764
764
|
}), i;
|
|
765
765
|
case "list":
|
|
766
|
-
const { itemProperties: c, title: d } = o,
|
|
766
|
+
const { itemProperties: c, title: d } = o, p = {
|
|
767
767
|
title: titleWithLang(n(d), r, get(o, "i18n")),
|
|
768
768
|
type: "array",
|
|
769
769
|
items: {
|
|
@@ -771,17 +771,17 @@ const useSelectedBlocksDisplayChild = () => ({
|
|
|
771
771
|
properties: {}
|
|
772
772
|
}
|
|
773
773
|
};
|
|
774
|
-
return Object.keys(c).forEach((
|
|
775
|
-
const m = c[
|
|
774
|
+
return Object.keys(c).forEach((u) => {
|
|
775
|
+
const m = c[u];
|
|
776
776
|
if (includes(["slot", "styles"], m.type))
|
|
777
777
|
return;
|
|
778
|
-
const x =
|
|
779
|
-
|
|
780
|
-
|
|
778
|
+
const x = u;
|
|
779
|
+
p.items.properties[x] = getBlockJSONFromSchemas(m, n, r), set(
|
|
780
|
+
p.items,
|
|
781
781
|
"title",
|
|
782
782
|
titleWithLang(get(m, "itemTitle", `${n(d)} item`), r, get(m, "i18n"))
|
|
783
783
|
);
|
|
784
|
-
}),
|
|
784
|
+
}), p;
|
|
785
785
|
default:
|
|
786
786
|
return {};
|
|
787
787
|
}
|
|
@@ -833,8 +833,8 @@ var undomanager = { exports: {} };
|
|
|
833
833
|
}
|
|
834
834
|
let r = function() {
|
|
835
835
|
let a = [], l = -1, i = 0, c = !1, d;
|
|
836
|
-
function u
|
|
837
|
-
return !
|
|
836
|
+
function p(u, m) {
|
|
837
|
+
return !u || typeof u[m] != "function" ? this : (c = !0, u[m](), c = !1, this);
|
|
838
838
|
}
|
|
839
839
|
return {
|
|
840
840
|
/**
|
|
@@ -844,25 +844,25 @@ var undomanager = { exports: {} };
|
|
|
844
844
|
* @property {function} command.redo - Redo function
|
|
845
845
|
* @property {string} [command.groupId] - Optional group id
|
|
846
846
|
*/
|
|
847
|
-
add: function(
|
|
848
|
-
return c ? this : (a.splice(l + 1, a.length - l), a.push(
|
|
847
|
+
add: function(u) {
|
|
848
|
+
return c ? this : (a.splice(l + 1, a.length - l), a.push(u), i && a.length > i && n(a, 0, -(i + 1)), l = a.length - 1, d && d(), this);
|
|
849
849
|
},
|
|
850
850
|
/**
|
|
851
851
|
* Pass a function to be called on undo and redo actions.
|
|
852
852
|
* @property {function} callbackFunc - Callback function
|
|
853
853
|
*/
|
|
854
|
-
setCallback: function(
|
|
855
|
-
d =
|
|
854
|
+
setCallback: function(u) {
|
|
855
|
+
d = u;
|
|
856
856
|
},
|
|
857
857
|
/**
|
|
858
858
|
* Performs undo: call the undo function at the current index and decrease the index by 1.
|
|
859
859
|
*/
|
|
860
860
|
undo: function() {
|
|
861
|
-
let
|
|
862
|
-
if (!
|
|
861
|
+
let u = a[l];
|
|
862
|
+
if (!u)
|
|
863
863
|
return this;
|
|
864
|
-
const m =
|
|
865
|
-
for (;
|
|
864
|
+
const m = u.groupId;
|
|
865
|
+
for (; u.groupId === m && (p(u, "undo"), l -= 1, u = a[l], !(!u || !u.groupId)); )
|
|
866
866
|
;
|
|
867
867
|
return d && d(), this;
|
|
868
868
|
},
|
|
@@ -870,11 +870,11 @@ var undomanager = { exports: {} };
|
|
|
870
870
|
* Performs redo: call the redo function at the next index and increase the index by 1.
|
|
871
871
|
*/
|
|
872
872
|
redo: function() {
|
|
873
|
-
let
|
|
874
|
-
if (!
|
|
873
|
+
let u = a[l + 1];
|
|
874
|
+
if (!u)
|
|
875
875
|
return this;
|
|
876
|
-
const m =
|
|
877
|
-
for (;
|
|
876
|
+
const m = u.groupId;
|
|
877
|
+
for (; u.groupId === m && (p(u, "redo"), l += 1, u = a[l + 1], !(!u || !u.groupId)); )
|
|
878
878
|
;
|
|
879
879
|
return d && d(), this;
|
|
880
880
|
},
|
|
@@ -882,8 +882,8 @@ var undomanager = { exports: {} };
|
|
|
882
882
|
* Clears the memory, losing all stored states. Resets the index.
|
|
883
883
|
*/
|
|
884
884
|
clear: function() {
|
|
885
|
-
let
|
|
886
|
-
a = [], l = -1, d &&
|
|
885
|
+
let u = a.length;
|
|
886
|
+
a = [], l = -1, d && u > 0 && d();
|
|
887
887
|
},
|
|
888
888
|
/**
|
|
889
889
|
* Tests if any undo actions exist.
|
|
@@ -904,8 +904,8 @@ var undomanager = { exports: {} };
|
|
|
904
904
|
* @param {string} [groupId] - Optionally filter commands by group ID
|
|
905
905
|
* @returns {array}
|
|
906
906
|
*/
|
|
907
|
-
getCommands: function(
|
|
908
|
-
return
|
|
907
|
+
getCommands: function(u) {
|
|
908
|
+
return u ? a.filter((m) => m.groupId === u) : a;
|
|
909
909
|
},
|
|
910
910
|
/**
|
|
911
911
|
* Returns the index of the actions list.
|
|
@@ -918,8 +918,8 @@ var undomanager = { exports: {} };
|
|
|
918
918
|
* Sets the maximum number of undo steps. Default: 0 (unlimited).
|
|
919
919
|
* @property {number} max - Maximum number of undo steps
|
|
920
920
|
*/
|
|
921
|
-
setLimit: function(
|
|
922
|
-
i =
|
|
921
|
+
setLimit: function(u) {
|
|
922
|
+
i = u;
|
|
923
923
|
}
|
|
924
924
|
};
|
|
925
925
|
};
|
|
@@ -1063,13 +1063,13 @@ dataProvidersAtom.debugLabel = "dataProvidersAtom";
|
|
|
1063
1063
|
const usePageDataProviders = () => useAtom$1(dataProvidersAtom), builderSaveStateAtom = atom$1("SAVED");
|
|
1064
1064
|
builderSaveStateAtom.debugLabel = "builderSaveStateAtom";
|
|
1065
1065
|
const useSavePage = () => {
|
|
1066
|
-
const [o, n] = useAtom$1(builderSaveStateAtom), r = useBuilderProp("onSave", async (
|
|
1066
|
+
const [o, n] = useAtom$1(builderSaveStateAtom), r = useBuilderProp("onSave", async (p) => {
|
|
1067
1067
|
}), a = useBuilderProp("onSaveStateChange", noop), l = useGetPageData(), [i] = usePageDataProviders(), [c] = useBrandingOptions();
|
|
1068
1068
|
return { savePage: useThrottledCallback(
|
|
1069
1069
|
async () => {
|
|
1070
1070
|
n("SAVING"), a("SAVING");
|
|
1071
|
-
const
|
|
1072
|
-
return await r({ blocks:
|
|
1071
|
+
const p = l();
|
|
1072
|
+
return await r({ blocks: p.blocks, providers: i, brandingOptions: c, themeConfiguration: c }), setTimeout(() => {
|
|
1073
1073
|
n("SAVED"), a("SAVED");
|
|
1074
1074
|
}, 100), !0;
|
|
1075
1075
|
},
|
|
@@ -1112,13 +1112,13 @@ function insertBlocksAtPosition(o, n, r, a) {
|
|
|
1112
1112
|
r && (l = o.filter((d) => d._parent === r));
|
|
1113
1113
|
const i = a !== void 0 ? a : l.length;
|
|
1114
1114
|
let c = o.length;
|
|
1115
|
-
for (let d = 0,
|
|
1115
|
+
for (let d = 0, p = 0; d < o.length; d++)
|
|
1116
1116
|
if (o[d]._parent === r) {
|
|
1117
|
-
if (
|
|
1117
|
+
if (p === i) {
|
|
1118
1118
|
c = d;
|
|
1119
1119
|
break;
|
|
1120
1120
|
}
|
|
1121
|
-
|
|
1121
|
+
p++;
|
|
1122
1122
|
}
|
|
1123
1123
|
return !r && a !== void 0 && a >= l.length && (c = o.length), [...o.slice(0, c), ...n, ...o.slice(c)];
|
|
1124
1124
|
}
|
|
@@ -1148,7 +1148,7 @@ function moveBlocksWithChildren(o, n, r, a) {
|
|
|
1148
1148
|
r = r || "root";
|
|
1149
1149
|
const i = new TreeModel().parse({ _id: "root", children: getBlocksTree(o) });
|
|
1150
1150
|
if (moveNode(i, n, r, a)) {
|
|
1151
|
-
const c = flattenTree(i), d = c.find((
|
|
1151
|
+
const c = flattenTree(i), d = c.find((p) => p._id === n);
|
|
1152
1152
|
return d && (d._parent = r === "root" ? null : r), c.shift(), c;
|
|
1153
1153
|
}
|
|
1154
1154
|
return o;
|
|
@@ -1195,65 +1195,65 @@ const useBlocksStoreManager = () => {
|
|
|
1195
1195
|
updateBlocksProps: c
|
|
1196
1196
|
} = useBlocksStoreManager();
|
|
1197
1197
|
return {
|
|
1198
|
-
moveBlocks: (
|
|
1199
|
-
const
|
|
1200
|
-
const A = n.find((
|
|
1198
|
+
moveBlocks: (b, f, k) => {
|
|
1199
|
+
const _ = map(b, (B) => {
|
|
1200
|
+
const A = n.find((I) => I._id === B)._parent || null, D = n.filter((I) => A ? I._parent === A : !I._parent).map((I) => I._id).indexOf(B);
|
|
1201
1201
|
return { _id: B, oldParent: A, oldPosition: D };
|
|
1202
|
-
}),
|
|
1203
|
-
|
|
1204
|
-
undo: () => each(
|
|
1205
|
-
i([B],
|
|
1202
|
+
}), C = _.find(({ _id: B }) => B === b[0]);
|
|
1203
|
+
C && C.oldParent === f && C.oldPosition === k || (i(b, f, k), o({
|
|
1204
|
+
undo: () => each(_, ({ _id: B, oldParent: R, oldPosition: A }) => {
|
|
1205
|
+
i([B], R, A);
|
|
1206
1206
|
}),
|
|
1207
|
-
redo: () => i(
|
|
1207
|
+
redo: () => i(b, f, k)
|
|
1208
1208
|
}));
|
|
1209
1209
|
},
|
|
1210
|
-
addBlocks: (
|
|
1211
|
-
a(
|
|
1212
|
-
undo: () => l(map(
|
|
1213
|
-
redo: () => a(
|
|
1210
|
+
addBlocks: (b, f, k) => {
|
|
1211
|
+
a(b, f, k), o({
|
|
1212
|
+
undo: () => l(map(b, "_id")),
|
|
1213
|
+
redo: () => a(b, f, k)
|
|
1214
1214
|
});
|
|
1215
1215
|
},
|
|
1216
|
-
removeBlocks: (
|
|
1217
|
-
var
|
|
1218
|
-
const f = (
|
|
1219
|
-
l(map(
|
|
1220
|
-
undo: () => a(
|
|
1221
|
-
redo: () => l(map(
|
|
1216
|
+
removeBlocks: (b) => {
|
|
1217
|
+
var C;
|
|
1218
|
+
const f = (C = first(b)) == null ? void 0 : C._parent, _ = n.filter((B) => f ? B._parent === f : !B._parent).indexOf(first(b));
|
|
1219
|
+
l(map(b, "_id")), o({
|
|
1220
|
+
undo: () => a(b, f, _),
|
|
1221
|
+
redo: () => l(map(b, "_id"))
|
|
1222
1222
|
});
|
|
1223
1223
|
},
|
|
1224
|
-
updateBlocks: (
|
|
1225
|
-
let
|
|
1226
|
-
if (
|
|
1227
|
-
|
|
1224
|
+
updateBlocks: (b, f, k) => {
|
|
1225
|
+
let _ = [];
|
|
1226
|
+
if (k)
|
|
1227
|
+
_ = map(b, (C) => ({ _id: C, ...k }));
|
|
1228
1228
|
else {
|
|
1229
|
-
const
|
|
1230
|
-
|
|
1231
|
-
const
|
|
1232
|
-
return each(
|
|
1229
|
+
const C = keys(f);
|
|
1230
|
+
_ = map(b, (B) => {
|
|
1231
|
+
const R = n.find((N) => N._id === B), A = { _id: B };
|
|
1232
|
+
return each(C, (N) => A[N] = R[N]), A;
|
|
1233
1233
|
});
|
|
1234
1234
|
}
|
|
1235
|
-
c(map(
|
|
1236
|
-
undo: () => c(
|
|
1237
|
-
redo: () => c(map(
|
|
1235
|
+
c(map(b, (C) => ({ _id: C, ...f }))), o({
|
|
1236
|
+
undo: () => c(_),
|
|
1237
|
+
redo: () => c(map(b, (C) => ({ _id: C, ...f })))
|
|
1238
1238
|
});
|
|
1239
1239
|
},
|
|
1240
|
-
updateBlocksRuntime: (
|
|
1241
|
-
c(map(
|
|
1240
|
+
updateBlocksRuntime: (b, f) => {
|
|
1241
|
+
c(map(b, (k) => ({ _id: k, ...f })));
|
|
1242
1242
|
},
|
|
1243
|
-
setNewBlocks: (
|
|
1244
|
-
r(
|
|
1243
|
+
setNewBlocks: (b) => {
|
|
1244
|
+
r(b), o({
|
|
1245
1245
|
undo: () => r(n),
|
|
1246
|
-
redo: () => r(
|
|
1246
|
+
redo: () => r(b)
|
|
1247
1247
|
});
|
|
1248
1248
|
},
|
|
1249
|
-
updateMultipleBlocksProps: (
|
|
1249
|
+
updateMultipleBlocksProps: (b) => {
|
|
1250
1250
|
let f = [];
|
|
1251
|
-
f = map(
|
|
1252
|
-
const
|
|
1253
|
-
return each(
|
|
1254
|
-
}), c(
|
|
1251
|
+
f = map(b, (k) => {
|
|
1252
|
+
const _ = keys(k), C = n.find((R) => R._id === k._id), B = {};
|
|
1253
|
+
return each(_, (R) => B[R] = C[R]), B;
|
|
1254
|
+
}), c(b), o({
|
|
1255
1255
|
undo: () => c(f),
|
|
1256
|
-
redo: () => c(
|
|
1256
|
+
redo: () => c(b)
|
|
1257
1257
|
});
|
|
1258
1258
|
}
|
|
1259
1259
|
};
|
|
@@ -1262,42 +1262,42 @@ const useBlocksStoreManager = () => {
|
|
|
1262
1262
|
(i, c, d) => {
|
|
1263
1263
|
var g;
|
|
1264
1264
|
for (let E = 0; E < i.length; E++) {
|
|
1265
|
-
const { _id:
|
|
1265
|
+
const { _id: b } = i[E];
|
|
1266
1266
|
i[E]._id = generateUUID();
|
|
1267
|
-
const f = filter(i, { _parent:
|
|
1268
|
-
for (let
|
|
1269
|
-
f[
|
|
1267
|
+
const f = filter(i, { _parent: b });
|
|
1268
|
+
for (let k = 0; k < f.length; k++)
|
|
1269
|
+
f[k]._parent = i[E]._id;
|
|
1270
1270
|
}
|
|
1271
|
-
const
|
|
1272
|
-
let
|
|
1273
|
-
return c && (
|
|
1271
|
+
const p = first(i);
|
|
1272
|
+
let u, m;
|
|
1273
|
+
return c && (u = find(o, { _id: c }), i[0]._parent = c, m = c), !(u ? canAcceptChildBlock(u == null ? void 0 : u._type, p._type) : !0) && u && (i[0]._parent = u._parent, m = u._parent), r(i, m, d), n([(g = first(i)) == null ? void 0 : g._id]), first(i);
|
|
1274
1274
|
},
|
|
1275
1275
|
[o, n]
|
|
1276
1276
|
);
|
|
1277
1277
|
return { addCoreBlock: useCallback(
|
|
1278
1278
|
(i, c, d) => {
|
|
1279
1279
|
if (has(i, "blocks")) {
|
|
1280
|
-
const
|
|
1281
|
-
return a(
|
|
1280
|
+
const k = i.blocks;
|
|
1281
|
+
return a(k, c, d);
|
|
1282
1282
|
}
|
|
1283
|
-
const
|
|
1284
|
-
forIn(
|
|
1285
|
-
if (startsWith(
|
|
1286
|
-
const
|
|
1283
|
+
const p = generateUUID(), u = getBlockDefaultProps(i.props), m = [];
|
|
1284
|
+
forIn(u, (k, _) => {
|
|
1285
|
+
if (startsWith(k, SLOT_KEY)) {
|
|
1286
|
+
const C = k.replace(SLOT_KEY, "");
|
|
1287
1287
|
m.push({
|
|
1288
|
-
_id:
|
|
1288
|
+
_id: C,
|
|
1289
1289
|
_type: "Slot",
|
|
1290
|
-
_parent:
|
|
1291
|
-
_name: i.props[
|
|
1292
|
-
_styles: i.props[
|
|
1293
|
-
_emptyStyles: i.props[
|
|
1290
|
+
_parent: p,
|
|
1291
|
+
_name: i.props[_].name,
|
|
1292
|
+
_styles: i.props[_].styles,
|
|
1293
|
+
_emptyStyles: i.props[_].emptyStyles
|
|
1294
1294
|
});
|
|
1295
1295
|
}
|
|
1296
1296
|
});
|
|
1297
1297
|
const x = {
|
|
1298
1298
|
_type: i.type,
|
|
1299
|
-
_id:
|
|
1300
|
-
...
|
|
1299
|
+
_id: p,
|
|
1300
|
+
...u
|
|
1301
1301
|
};
|
|
1302
1302
|
let g, E;
|
|
1303
1303
|
c && (g = find(o, { _id: c }), x._parent = c, E = c), !canAcceptChildBlock(g == null ? void 0 : g._type, x._type) && g && (x._parent = g._parent, E = g._parent);
|
|
@@ -2402,15 +2402,15 @@ function getNewClasses(o = "", n = "", r = []) {
|
|
|
2402
2402
|
o = o.trim().replace(/ +/g, "");
|
|
2403
2403
|
let a = filter(
|
|
2404
2404
|
map(o.split(" "), constructClassObject),
|
|
2405
|
-
(
|
|
2406
|
-
), l = filter(map(n.split(" "), constructClassObject), (
|
|
2405
|
+
(u) => !isNull(u)
|
|
2406
|
+
), l = filter(map(n.split(" "), constructClassObject), (u) => !isNull(u));
|
|
2407
2407
|
l = filter(
|
|
2408
2408
|
l,
|
|
2409
|
-
(
|
|
2409
|
+
(u) => !includes(IGNORED_BASES_CLASSES_PROPERTIES, u.property)
|
|
2410
2410
|
);
|
|
2411
2411
|
const i = [], c = [];
|
|
2412
|
-
each(r, (
|
|
2413
|
-
const m = constructClassObject(
|
|
2412
|
+
each(r, (u) => {
|
|
2413
|
+
const m = constructClassObject(u), x = find(a, pick(m, ["dark", "mq", "mod", "property"]));
|
|
2414
2414
|
if (x && (a = filter(
|
|
2415
2415
|
a,
|
|
2416
2416
|
(g) => g.fullCls !== (x == null ? void 0 : x.fullCls)
|
|
@@ -2427,11 +2427,11 @@ function getNewClasses(o = "", n = "", r = []) {
|
|
|
2427
2427
|
}
|
|
2428
2428
|
});
|
|
2429
2429
|
const d = map(
|
|
2430
|
-
sortBy([...a, ...i], (
|
|
2430
|
+
sortBy([...a, ...i], (u) => MEDIA_QUERIES[u.mq]),
|
|
2431
2431
|
"fullCls"
|
|
2432
2432
|
).join(" ");
|
|
2433
2433
|
return `${map(
|
|
2434
|
-
sortBy([...l, ...c], (
|
|
2434
|
+
sortBy([...l, ...c], (u) => MEDIA_QUERIES[u.mq]),
|
|
2435
2435
|
"fullCls"
|
|
2436
2436
|
).join(" ").trim()},${d.trim()}`.trim().replace(/ +/g, "");
|
|
2437
2437
|
}
|
|
@@ -2449,10 +2449,10 @@ const useSelectedStylingBlocks = () => useAtom$1(selectedStylingBlocksAtom), get
|
|
|
2449
2449
|
)
|
|
2450
2450
|
), i = first(o(selectedStylingBlocksAtom));
|
|
2451
2451
|
return map(l, (c) => {
|
|
2452
|
-
const d = o(c),
|
|
2452
|
+
const d = o(c), p = get(d, i.prop, `${STYLES_KEY},`), { baseClasses: u, classes: m } = getSplitClasses$1(p);
|
|
2453
2453
|
return {
|
|
2454
2454
|
ids: [d._id],
|
|
2455
|
-
props: { [i.prop]: `${STYLES_KEY}${getNewClasses(m,
|
|
2455
|
+
props: { [i.prop]: `${STYLES_KEY}${getNewClasses(m, u, a)}` }
|
|
2456
2456
|
};
|
|
2457
2457
|
});
|
|
2458
2458
|
}), useAddClassesToBlocks = () => {
|
|
@@ -2548,8 +2548,8 @@ const useSelectedStylingBlocks = () => useAtom$1(selectedStylingBlocksAtom), get
|
|
|
2548
2548
|
),
|
|
2549
2549
|
pasteBlocks: useCallback(
|
|
2550
2550
|
(d) => {
|
|
2551
|
-
const
|
|
2552
|
-
isEmpty(o) ? l(n, d) : a(o,
|
|
2551
|
+
const p = Array.isArray(d) ? d[0] : d;
|
|
2552
|
+
isEmpty(o) ? l(n, d) : a(o, p), r([]);
|
|
2553
2553
|
},
|
|
2554
2554
|
[n, o, a, l, r]
|
|
2555
2555
|
)
|
|
@@ -2569,20 +2569,20 @@ const useSelectedStylingBlocks = () => useAtom$1(selectedStylingBlocksAtom), get
|
|
|
2569
2569
|
)
|
|
2570
2570
|
);
|
|
2571
2571
|
return map(i, (c) => {
|
|
2572
|
-
const d = o(c),
|
|
2573
|
-
let { classes:
|
|
2574
|
-
return each(
|
|
2572
|
+
const d = o(c), p = a;
|
|
2573
|
+
let { classes: u, baseClasses: m } = getSplitClasses(get(d, l.prop, "styles:,"));
|
|
2574
|
+
return each(p, (x) => {
|
|
2575
2575
|
const g = x.replace(/[\[\]\/\\{}()*+?.^$|]/g, "\\$&"), E = new RegExp(`(^| )${g}($| )`, "g");
|
|
2576
|
-
|
|
2577
|
-
const
|
|
2578
|
-
includes(["2xl", "xl", "lg", "md", "sm"],
|
|
2579
|
-
}), each(
|
|
2576
|
+
u = u.replace(E, " ").replace(/ +/g, " ").trim();
|
|
2577
|
+
const b = first(x.split(":"));
|
|
2578
|
+
includes(["2xl", "xl", "lg", "md", "sm"], b) && p.push(x.split(":").pop().trim());
|
|
2579
|
+
}), each(p, (x) => {
|
|
2580
2580
|
const g = new RegExp(`(^| )${x.replace("[", "\\[").replace("]", "\\]")}($| )`, "g");
|
|
2581
2581
|
m = m.replace(g, " ").replace(/ +/g, " ").trim();
|
|
2582
2582
|
}), {
|
|
2583
2583
|
ids: [d._id],
|
|
2584
2584
|
props: {
|
|
2585
|
-
[l.prop]: `${STYLES_KEY}${m},${
|
|
2585
|
+
[l.prop]: `${STYLES_KEY}${m},${u}`
|
|
2586
2586
|
}
|
|
2587
2587
|
};
|
|
2588
2588
|
});
|
|
@@ -2680,10 +2680,10 @@ const useLanguages = () => {
|
|
|
2680
2680
|
const c = r[i];
|
|
2681
2681
|
if (isString$1(c)) {
|
|
2682
2682
|
const d = chunk(c.split(""), 12);
|
|
2683
|
-
let
|
|
2683
|
+
let p = "";
|
|
2684
2684
|
o([n], { [i]: "" });
|
|
2685
|
-
for (let
|
|
2686
|
-
|
|
2685
|
+
for (let u = 0; u < d.length; u++)
|
|
2686
|
+
p += d[u].join(""), o([n], { [i]: p }), await new Promise((m) => setTimeout(m, a));
|
|
2687
2687
|
}
|
|
2688
2688
|
}
|
|
2689
2689
|
},
|
|
@@ -2748,7 +2748,19 @@ const xShowBlocksAtom = atom$1([]);
|
|
|
2748
2748
|
xShowBlocksAtom.debugLabel = "xShowBlocksAtom";
|
|
2749
2749
|
const selectedLibraryAtom = atomWithStorage("_selectedLibrary", null);
|
|
2750
2750
|
selectedLibraryAtom.debugLabel = "selectedLibraryAtom";
|
|
2751
|
-
|
|
2751
|
+
let lastHighlighted$1 = null;
|
|
2752
|
+
const useBlockHighlight = () => {
|
|
2753
|
+
const [o] = useAtom$1(canvasIframeAtom);
|
|
2754
|
+
return { highlightBlock: (a) => {
|
|
2755
|
+
var c;
|
|
2756
|
+
const l = o.contentDocument || ((c = o.contentWindow) == null ? void 0 : c.document);
|
|
2757
|
+
lastHighlighted$1 && lastHighlighted$1.removeAttribute("data-highlighted");
|
|
2758
|
+
const i = l.querySelector(`[data-block-id="${a}"]`);
|
|
2759
|
+
i ? (i.setAttribute("data-highlighted", "true"), lastHighlighted$1 = i) : lastHighlighted$1 = null;
|
|
2760
|
+
}, clearHighlight: () => {
|
|
2761
|
+
lastHighlighted$1 && (lastHighlighted$1.removeAttribute("data-highlighted"), lastHighlighted$1 = null);
|
|
2762
|
+
} };
|
|
2763
|
+
}, globalBlocksStoreAtom = atom({}), globalBlocksLoadingStateAtom = atom({}), useGlobalBlocksStore = () => {
|
|
2752
2764
|
const [o, n] = useAtom(globalBlocksStoreAtom), r = useCallback(
|
|
2753
2765
|
(l) => get(o, l == null ? void 0 : l.globalBlock, []),
|
|
2754
2766
|
[o]
|
|
@@ -2757,18 +2769,18 @@ const globalBlocksStoreAtom = atom({}), globalBlocksLoadingStateAtom = atom({}),
|
|
|
2757
2769
|
}, [n]);
|
|
2758
2770
|
return { getGlobalBlocks: r, reset: a };
|
|
2759
2771
|
}, useWatchGlobalBlocks = () => {
|
|
2760
|
-
const [o] = useBlocksStore(), [n, r] = useAtom(globalBlocksStoreAtom), [a, l] = useAtom(globalBlocksLoadingStateAtom), i = useBuilderProp("getGlobalBlockBlocks", async (d) => []), c = useMemo(() => o.filter((
|
|
2772
|
+
const [o] = useBlocksStore(), [n, r] = useAtom(globalBlocksStoreAtom), [a, l] = useAtom(globalBlocksLoadingStateAtom), i = useBuilderProp("getGlobalBlockBlocks", async (d) => []), c = useMemo(() => o.filter((p) => p._type === "GlobalBlock").filter((p) => p._type === "GlobalBlock").map((p) => p.globalBlock), [o]);
|
|
2761
2773
|
useEffect(() => {
|
|
2762
2774
|
forEach(c, (d) => {
|
|
2763
|
-
has(n, d) || get(a, `${d}.loading`, !1) || (l((
|
|
2764
|
-
r((
|
|
2765
|
-
...
|
|
2775
|
+
has(n, d) || get(a, `${d}.loading`, !1) || (l((p) => ({ ...p, [d]: { loading: !0, error: null } })), i(d).then((p) => {
|
|
2776
|
+
r((u) => ({ ...u, [d]: p })), l((u) => ({
|
|
2777
|
+
...u,
|
|
2766
2778
|
[d]: { loading: !1, error: null }
|
|
2767
2779
|
}));
|
|
2768
|
-
}).catch((
|
|
2769
|
-
l((
|
|
2770
|
-
...
|
|
2771
|
-
[d]: { loading: !1, error:
|
|
2780
|
+
}).catch((p) => {
|
|
2781
|
+
l((u) => ({
|
|
2782
|
+
...u,
|
|
2783
|
+
[d]: { loading: !1, error: p.message }
|
|
2772
2784
|
}));
|
|
2773
2785
|
}));
|
|
2774
2786
|
});
|
|
@@ -2790,9 +2802,9 @@ const globalBlocksStoreAtom = atom({}), globalBlocksLoadingStateAtom = atom({}),
|
|
|
2790
2802
|
i();
|
|
2791
2803
|
}, []), { data: r, isLoading: o, refetch: i };
|
|
2792
2804
|
}, useBuilderReset = () => {
|
|
2793
|
-
const o = useSetAtom$1(historyStatesAtom), { clear: n } = useUndoManager(), [, r] = useSelectedBlockIds(),
|
|
2805
|
+
const o = useSetAtom$1(historyStatesAtom), { clear: n } = useUndoManager(), [, r] = useSelectedBlockIds(), { clearHighlight: a } = useBlockHighlight(), [, l] = useSelectedStylingBlocks(), [, i] = useAtom(aiAssistantActiveAtom), { reset: c } = useGlobalBlocksStore();
|
|
2794
2806
|
return () => {
|
|
2795
|
-
r([]), l([]), a(
|
|
2807
|
+
r([]), l([]), a(), n(), i(!1), o({ undoCount: 0, redoCount: 0 }), c();
|
|
2796
2808
|
};
|
|
2797
2809
|
}, useUILibraryBlocks = () => ({ data: useBuilderProp("uiLibraries", []), isLoading: !1 }), useCopyToClipboard = () => {
|
|
2798
2810
|
const [o, n] = useState(null), r = useCallback(async (a) => {
|
|
@@ -2866,24 +2878,24 @@ const globalBlocksStoreAtom = atom({}), globalBlocksLoadingStateAtom = atom({}),
|
|
|
2866
2878
|
</body>
|
|
2867
2879
|
</html>`, useCanvasScale = (o) => {
|
|
2868
2880
|
const [n] = useCanvasWidth(), [, r] = useCanvasZoom(), a = useBuilderProp("htmlDir", "ltr"), [l, i] = useState({}), c = useCallback(() => {
|
|
2869
|
-
const { width: d, height:
|
|
2881
|
+
const { width: d, height: p } = o;
|
|
2870
2882
|
if (d < n) {
|
|
2871
|
-
const
|
|
2883
|
+
const u = parseFloat((d / n).toFixed(2).toString());
|
|
2872
2884
|
let m = {};
|
|
2873
|
-
const x =
|
|
2874
|
-
|
|
2885
|
+
const x = p * u, g = d * u;
|
|
2886
|
+
p && (m = {
|
|
2875
2887
|
// Eureka! This is the formula to calculate the height of the scaled element. Thank you ChatGPT 4
|
|
2876
|
-
height: 100 + (
|
|
2888
|
+
height: 100 + (p - x) / x * 100 + "%",
|
|
2877
2889
|
width: 100 + (d - g) / g * 100 + "%"
|
|
2878
2890
|
}), i({
|
|
2879
2891
|
position: "relative",
|
|
2880
2892
|
top: 0,
|
|
2881
|
-
transform: `scale(${
|
|
2893
|
+
transform: `scale(${u})`,
|
|
2882
2894
|
transformOrigin: a === "rtl" ? "top right" : "top left",
|
|
2883
2895
|
...m,
|
|
2884
2896
|
maxWidth: "none"
|
|
2885
2897
|
// TODO: Add max-width to the wrapper
|
|
2886
|
-
}), r(
|
|
2898
|
+
}), r(u * 100);
|
|
2887
2899
|
} else
|
|
2888
2900
|
i({}), r(100);
|
|
2889
2901
|
}, [n, o, a, r]);
|
|
@@ -3004,8 +3016,8 @@ let iframeDocument = null, possiblePositions = [], dropTarget = null, dropIndex
|
|
|
3004
3016
|
const positionPlaceholder = (o, n, r) => {
|
|
3005
3017
|
if (!iframeDocument || !o)
|
|
3006
3018
|
return;
|
|
3007
|
-
const a = iframeDocument == null ? void 0 : iframeDocument.getElementById("placeholder"), l = possiblePositions.map(([
|
|
3008
|
-
(
|
|
3019
|
+
const a = iframeDocument == null ? void 0 : iframeDocument.getElementById("placeholder"), l = possiblePositions.map(([p]) => p), i = l.reduce(
|
|
3020
|
+
(p, u) => Math.abs(u - r) < Math.abs(p - r) ? u : p,
|
|
3009
3021
|
0
|
|
3010
3022
|
), c = l.indexOf(i);
|
|
3011
3023
|
if (!possiblePositions[c])
|
|
@@ -3050,11 +3062,11 @@ function removeDataDrop() {
|
|
|
3050
3062
|
o && o.removeAttribute("data-drop");
|
|
3051
3063
|
}
|
|
3052
3064
|
const useDnd = () => {
|
|
3053
|
-
const { document: o } = useFrame(), [n, r] = useAtom$1(draggingFlagAtom), { addCoreBlock: a } = useAddBlock(), [, l] = useHighlightBlockId(), [, i] = useSelectedBlockIds(), { moveBlocks: c } = useBlocksStoreUndoableActions(), [d,
|
|
3065
|
+
const { document: o } = useFrame(), [n, r] = useAtom$1(draggingFlagAtom), { addCoreBlock: a } = useAddBlock(), [, l] = useHighlightBlockId(), [, i] = useSelectedBlockIds(), { moveBlocks: c } = useBlocksStoreUndoableActions(), [d, p] = useAtom$1(draggedBlockAtom), [, u] = useAtom$1(dropTargetBlockIdAtom);
|
|
3054
3066
|
if (!useFeature("dnd"))
|
|
3055
3067
|
return {};
|
|
3056
3068
|
const x = () => {
|
|
3057
|
-
removePlaceholder(), r(!1),
|
|
3069
|
+
removePlaceholder(), r(!1), p(null), u(null), possiblePositions = [];
|
|
3058
3070
|
};
|
|
3059
3071
|
return iframeDocument = o, {
|
|
3060
3072
|
isDragging: n,
|
|
@@ -3062,34 +3074,39 @@ const useDnd = () => {
|
|
|
3062
3074
|
g.preventDefault(), g.stopPropagation(), throttledDragOver(g);
|
|
3063
3075
|
},
|
|
3064
3076
|
onDrop: (g) => {
|
|
3065
|
-
var
|
|
3066
|
-
const E = dropTarget, f = getOrientation(E) === "vertical" ? g.clientY + ((
|
|
3077
|
+
var R;
|
|
3078
|
+
const E = dropTarget, f = getOrientation(E) === "vertical" ? g.clientY + ((R = iframeDocument == null ? void 0 : iframeDocument.defaultView) == null ? void 0 : R.scrollY) : g.clientX;
|
|
3067
3079
|
dropIndex = calculateDropIndex(f, possiblePositions);
|
|
3068
|
-
const
|
|
3069
|
-
if ((
|
|
3080
|
+
const k = d, _ = E.getAttribute("data-block-id"), C = dropTarget.getAttribute("data-dnd-dragged") !== "yes";
|
|
3081
|
+
if ((k == null ? void 0 : k._id) === _ || !C) {
|
|
3070
3082
|
x();
|
|
3071
3083
|
return;
|
|
3072
3084
|
}
|
|
3073
|
-
if (!has(
|
|
3074
|
-
a(
|
|
3085
|
+
if (!has(k, "_id")) {
|
|
3086
|
+
a(k, _ === "canvas" ? null : _, dropIndex), setTimeout(x, 300);
|
|
3075
3087
|
return;
|
|
3076
3088
|
}
|
|
3077
3089
|
let B = E.getAttribute("data-block-id");
|
|
3078
|
-
B === null && (B = g.target.parentElement.getAttribute("data-block-id")), c([
|
|
3090
|
+
B === null && (B = g.target.parentElement.getAttribute("data-block-id")), c([k._id], B === "canvas" ? null : B, dropIndex), x(), setTimeout(removePlaceholder, 300);
|
|
3079
3091
|
},
|
|
3080
3092
|
onDragEnter: (g) => {
|
|
3081
|
-
const E = g,
|
|
3082
|
-
dropTarget =
|
|
3083
|
-
const f =
|
|
3084
|
-
|
|
3093
|
+
const E = g, b = E.target;
|
|
3094
|
+
dropTarget = b;
|
|
3095
|
+
const f = b.getAttribute("data-block-id"), k = b.getAttribute("data-dnd-dragged") !== "yes";
|
|
3096
|
+
u(f), E.stopPropagation(), E.preventDefault(), possiblePositions = [], k && calculatePossiblePositions(b), r(!0), l(""), i([]);
|
|
3085
3097
|
},
|
|
3086
3098
|
onDragLeave: (g) => {
|
|
3087
|
-
g.target.getAttribute("data-block-id") === "canvas" && (
|
|
3099
|
+
g.target.getAttribute("data-block-id") === "canvas" && (u(null), r(!1), removePlaceholder(), possiblePositions = []);
|
|
3088
3100
|
}
|
|
3089
3101
|
};
|
|
3090
3102
|
};
|
|
3091
3103
|
function getTargetedBlock(o) {
|
|
3092
|
-
|
|
3104
|
+
if (o.getAttribute("data-block-id") === "canvas")
|
|
3105
|
+
return null;
|
|
3106
|
+
if (o.getAttribute("data-block-id"))
|
|
3107
|
+
return o;
|
|
3108
|
+
const n = o.closest("[data-block-id]");
|
|
3109
|
+
return (n == null ? void 0 : n.getAttribute("data-block-id")) === "canvas" ? null : n;
|
|
3093
3110
|
}
|
|
3094
3111
|
function destroyQuill(o) {
|
|
3095
3112
|
o.container.innerHTML = "", o.container.parentNode.removeChild(o.container);
|
|
@@ -3097,72 +3114,79 @@ function destroyQuill(o) {
|
|
|
3097
3114
|
n && n.parentNode.removeChild(n), o = null;
|
|
3098
3115
|
}
|
|
3099
3116
|
const useHandleCanvasDblClick = () => {
|
|
3100
|
-
const o = ["Heading", "Paragraph", "Text", "Link", "Span", "Button"], n = useUpdateBlocksProps(), [
|
|
3101
|
-
return (
|
|
3102
|
-
var
|
|
3103
|
-
if (
|
|
3117
|
+
const o = ["Heading", "Paragraph", "Text", "Link", "Span", "Button"], n = useUpdateBlocksProps(), [r, a] = useAtom$1(inlineEditingActiveAtom);
|
|
3118
|
+
return (l) => {
|
|
3119
|
+
var m;
|
|
3120
|
+
if (r)
|
|
3104
3121
|
return;
|
|
3105
|
-
const
|
|
3106
|
-
if (!
|
|
3122
|
+
const i = getTargetedBlock(l.target), c = i.getAttribute("data-block-type");
|
|
3123
|
+
if (!c || !o.includes(c))
|
|
3107
3124
|
return;
|
|
3108
|
-
const
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
}),
|
|
3112
|
-
const p = new Quill(
|
|
3113
|
-
function
|
|
3114
|
-
const
|
|
3115
|
-
n([
|
|
3125
|
+
const d = i.cloneNode(!0);
|
|
3126
|
+
i.style.display = "none", Array.from(d.attributes).forEach((x) => {
|
|
3127
|
+
x.name !== "class" && d.removeAttribute(x.name);
|
|
3128
|
+
}), c === "Text" && (d.style.display = "inline-block"), i.parentNode.insertBefore(d, i.nextSibling);
|
|
3129
|
+
const p = new Quill(d, { placeholder: "Type here..." });
|
|
3130
|
+
function u() {
|
|
3131
|
+
const x = p.getText(0, p.getLength());
|
|
3132
|
+
n([i.getAttribute("data-block-id")], { content: x }), i.removeAttribute("style"), d.removeEventListener("blur", u, !0), destroyQuill(p), a(""), lastHighlighted && (lastHighlighted.removeAttribute("data-highlighted"), lastHighlighted = null);
|
|
3116
3133
|
}
|
|
3117
|
-
|
|
3118
|
-
(
|
|
3119
|
-
}), p.focus(), (
|
|
3134
|
+
d.addEventListener("blur", u, !0), d.addEventListener("keydown", (x) => {
|
|
3135
|
+
(x.key === "Enter" || x.key === "Escape") && u();
|
|
3136
|
+
}), p.focus(), (m = d.querySelector(".ql-clipboard")) == null || m.remove(), a(i.getAttribute("data-block-id"));
|
|
3120
3137
|
};
|
|
3121
3138
|
}, useHandleCanvasClick = () => {
|
|
3122
|
-
const [, o] = useSelectedStylingBlocks(), [n, r] = useSelectedBlockIds(), [
|
|
3123
|
-
return (
|
|
3124
|
-
if (
|
|
3139
|
+
const [, o] = useSelectedStylingBlocks(), [n, r] = useSelectedBlockIds(), [a] = useAtom$1(inlineEditingActiveAtom), [l] = useAtom$1(treeRefAtom);
|
|
3140
|
+
return (i) => {
|
|
3141
|
+
if (a)
|
|
3125
3142
|
return;
|
|
3126
|
-
|
|
3127
|
-
const
|
|
3128
|
-
if (
|
|
3129
|
-
r([]), o([]),
|
|
3143
|
+
i.stopPropagation();
|
|
3144
|
+
const c = getTargetedBlock(i.target);
|
|
3145
|
+
if (c != null && c.getAttribute("data-block-id") && (c == null ? void 0 : c.getAttribute("data-block-id")) === "container") {
|
|
3146
|
+
r([]), o([]), lastHighlighted && (lastHighlighted.removeAttribute("data-highlighted"), lastHighlighted = null);
|
|
3130
3147
|
return;
|
|
3131
3148
|
}
|
|
3132
|
-
if (
|
|
3133
|
-
const
|
|
3134
|
-
n.includes(
|
|
3135
|
-
} else if (
|
|
3136
|
-
const
|
|
3137
|
-
n.includes(
|
|
3149
|
+
if (c != null && c.getAttribute("data-block-parent")) {
|
|
3150
|
+
const d = c.getAttribute("data-style-prop"), p = c.getAttribute("data-style-id"), u = c.getAttribute("data-block-parent");
|
|
3151
|
+
n.includes(u) || l == null || l.closeAll(), o([{ id: p, prop: d, blockId: u }]), r([u]);
|
|
3152
|
+
} else if (c != null && c.getAttribute("data-block-id")) {
|
|
3153
|
+
const d = c.getAttribute("data-block-id");
|
|
3154
|
+
n.includes(d) || l == null || l.closeAll(), o([]), r(d === "canvas" ? [] : [d]);
|
|
3138
3155
|
}
|
|
3139
|
-
|
|
3156
|
+
lastHighlighted && (lastHighlighted.removeAttribute("data-highlighted"), lastHighlighted = null);
|
|
3140
3157
|
};
|
|
3141
|
-
}
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
const
|
|
3146
|
-
|
|
3147
|
-
|
|
3158
|
+
};
|
|
3159
|
+
let lastHighlighted = null;
|
|
3160
|
+
const handleMouseMove = throttle((o) => {
|
|
3161
|
+
lastHighlighted && lastHighlighted.removeAttribute("data-highlighted");
|
|
3162
|
+
const n = getTargetedBlock(o.target);
|
|
3163
|
+
n ? (n.setAttribute("data-highlighted", "true"), lastHighlighted = n) : lastHighlighted = null;
|
|
3164
|
+
}, 16), useHandleMouseMove = () => {
|
|
3165
|
+
const [o] = useAtom$1(inlineEditingActiveAtom);
|
|
3166
|
+
return (n) => {
|
|
3167
|
+
o || handleMouseMove(n);
|
|
3148
3168
|
};
|
|
3149
|
-
},
|
|
3169
|
+
}, clearHighlight = () => {
|
|
3170
|
+
lastHighlighted && (lastHighlighted.removeAttribute("data-highlighted"), lastHighlighted = null);
|
|
3171
|
+
}, useHandleMouseLeave = () => clearHighlight, Canvas = ({ children: o }) => {
|
|
3150
3172
|
const { document: n } = useFrame(), [r] = useSelectedBlockIds(), [a, l] = useSelectedStylingBlocks();
|
|
3151
|
-
useEffect(() => {
|
|
3173
|
+
useEffect(() => () => {
|
|
3174
|
+
clearHighlight();
|
|
3175
|
+
}, []), useEffect(() => {
|
|
3152
3176
|
setTimeout(() => {
|
|
3153
3177
|
if (!isEmpty(a))
|
|
3154
3178
|
return;
|
|
3155
|
-
const
|
|
3156
|
-
if (
|
|
3157
|
-
const
|
|
3158
|
-
if (
|
|
3159
|
-
const
|
|
3160
|
-
l([{ id:
|
|
3179
|
+
const m = getElementByDataBlockId(n, first(r));
|
|
3180
|
+
if (m) {
|
|
3181
|
+
const x = m.getAttribute("data-style-prop");
|
|
3182
|
+
if (x) {
|
|
3183
|
+
const g = m.getAttribute("data-style-id"), E = m.getAttribute("data-block-parent");
|
|
3184
|
+
l([{ id: g, prop: x, blockId: E }]);
|
|
3161
3185
|
}
|
|
3162
3186
|
}
|
|
3163
3187
|
}, 100);
|
|
3164
3188
|
}, [n, r, l, a]);
|
|
3165
|
-
const i = useHandleCanvasDblClick(), c = useHandleCanvasClick(), d = useHandleMouseMove(), u = useDnd();
|
|
3189
|
+
const i = useHandleCanvasDblClick(), c = useHandleCanvasClick(), d = useHandleMouseMove(), p = useHandleMouseLeave(), u = useDnd();
|
|
3166
3190
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
3167
3191
|
"div",
|
|
3168
3192
|
{
|
|
@@ -3171,20 +3195,21 @@ const useHandleCanvasDblClick = () => {
|
|
|
3171
3195
|
onClick: c,
|
|
3172
3196
|
onDoubleClick: i,
|
|
3173
3197
|
onMouseMove: d,
|
|
3198
|
+
onMouseLeave: p,
|
|
3174
3199
|
...omit(u, "isDragging"),
|
|
3175
3200
|
className: "relative h-full max-w-full p-px " + (u.isDragging ? "dragging" : ""),
|
|
3176
3201
|
children: o
|
|
3177
3202
|
}
|
|
3178
3203
|
);
|
|
3179
3204
|
}, getElementByDataBlockId = (o, n) => o.querySelector(`[data-block-id="${n}"]`), useKeyEventWatcher = (o) => {
|
|
3180
|
-
const [n, r] = useSelectedBlockIds(), a = useRemoveBlocks(), l = useDuplicateBlocks(), { undo: i, redo: c } = useUndoManager(), [, d] = useCutBlockIds(), [,
|
|
3181
|
-
useHotkeys("ctrl+z,command+z", () => i(), {}, [i]), useHotkeys("ctrl+y,command+y", () => c(), {}, [c]), useHotkeys("ctrl+x,command+x", () => d(n), {}, [n, d]), useHotkeys("ctrl+c,command+c", () =>
|
|
3205
|
+
const [n, r] = useSelectedBlockIds(), a = useRemoveBlocks(), l = useDuplicateBlocks(), { undo: i, redo: c } = useUndoManager(), [, d] = useCutBlockIds(), [, p] = useCopyBlockIds(), { canPaste: u, pasteBlocks: m } = usePasteBlocks();
|
|
3206
|
+
useHotkeys("ctrl+z,command+z", () => i(), {}, [i]), useHotkeys("ctrl+y,command+y", () => c(), {}, [c]), useHotkeys("ctrl+x,command+x", () => d(n), {}, [n, d]), useHotkeys("ctrl+c,command+c", () => p(n), {}, [n, p]), useHotkeys(
|
|
3182
3207
|
"ctrl+v,command+v",
|
|
3183
3208
|
() => {
|
|
3184
|
-
|
|
3209
|
+
u(n[0]) && m(n);
|
|
3185
3210
|
},
|
|
3186
3211
|
{},
|
|
3187
|
-
[n,
|
|
3212
|
+
[n, u, m]
|
|
3188
3213
|
);
|
|
3189
3214
|
const x = o ? { document: o } : {};
|
|
3190
3215
|
useHotkeys("esc", () => r([]), x, [r]), useHotkeys("ctrl+d,command+d", () => l(n), { ...x, preventDefault: !0 }, [
|
|
@@ -3224,7 +3249,7 @@ const useHandleCanvasDblClick = () => {
|
|
|
3224
3249
|
}
|
|
3225
3250
|
);
|
|
3226
3251
|
}, BlockActionsStatic = ({ selectedBlockElement: o, block: n }) => {
|
|
3227
|
-
const r = useRemoveBlocks(), a = useDuplicateBlocks(), [, l] = useSelectedBlockIds(), [, i] = useHighlightBlockId(), [, c] = useSelectedStylingBlocks(), [d] = useAtom$1(inlineEditingActiveAtom), { floatingStyles:
|
|
3252
|
+
const r = useRemoveBlocks(), a = useDuplicateBlocks(), [, l] = useSelectedBlockIds(), [, i] = useHighlightBlockId(), [, c] = useSelectedStylingBlocks(), [d] = useAtom$1(inlineEditingActiveAtom), { floatingStyles: p, refs: u, update: m } = useFloating({
|
|
3228
3253
|
placement: "top-start",
|
|
3229
3254
|
middleware: [shift(), flip()],
|
|
3230
3255
|
elements: {
|
|
@@ -3238,8 +3263,8 @@ const useHandleCanvasDblClick = () => {
|
|
|
3238
3263
|
{
|
|
3239
3264
|
role: "button",
|
|
3240
3265
|
tabIndex: 0,
|
|
3241
|
-
ref:
|
|
3242
|
-
style:
|
|
3266
|
+
ref: u.setFloating,
|
|
3267
|
+
style: p,
|
|
3243
3268
|
onClick: (E) => {
|
|
3244
3269
|
E.stopPropagation(), E.preventDefault();
|
|
3245
3270
|
},
|
|
@@ -3281,30 +3306,30 @@ const useHandleCanvasDblClick = () => {
|
|
|
3281
3306
|
}
|
|
3282
3307
|
) });
|
|
3283
3308
|
}, HeadTags = () => {
|
|
3284
|
-
const [o] = useBrandingOptions(), [n] = useSelectedBlockIds(), [r] = useDarkMode(), [a] =
|
|
3285
|
-
|
|
3309
|
+
const [o] = useBrandingOptions(), [n] = useSelectedBlockIds(), [r] = useDarkMode(), [a] = useSelectedStylingBlocks(), [l] = useAtom$1(draggedBlockAtom), [i] = useAtom$1(dropTargetBlockIdAtom), { document: c, window: d } = useFrame(), [p] = useState(c == null ? void 0 : c.getElementById("highlighted-block")), [u] = useState(
|
|
3310
|
+
c == null ? void 0 : c.getElementById("selected-block")
|
|
3311
|
+
), [m] = useState(
|
|
3312
|
+
c == null ? void 0 : c.getElementById("selected-styling-block")
|
|
3286
3313
|
), [x] = useState(
|
|
3287
|
-
|
|
3288
|
-
), [g] = useState(
|
|
3289
|
-
d == null ? void 0 : d.getElementById("dragged-block")
|
|
3314
|
+
c == null ? void 0 : c.getElementById("dragged-block")
|
|
3290
3315
|
);
|
|
3291
3316
|
useEffect(() => {
|
|
3292
|
-
r ?
|
|
3293
|
-
}, [r,
|
|
3294
|
-
const
|
|
3317
|
+
r ? c == null || c.documentElement.classList.add("dark") : c == null || c.documentElement.classList.remove("dark");
|
|
3318
|
+
}, [r, c]);
|
|
3319
|
+
const g = get(o, "headingFont", "DM Sans"), E = get(o, "bodyFont", "DM Sans");
|
|
3295
3320
|
return useEffect(() => {
|
|
3296
|
-
const
|
|
3297
|
-
colors: [
|
|
3321
|
+
const b = get(o, "primaryColor", "#000"), f = get(o, "secondaryColor", "#FFF"), k = get(o, "bodyBgLightColor", "#fff"), _ = get(o, "bodyBgDarkColor", "#000"), C = get(o, "bodyTextDarkColor", "#000"), B = get(o, "bodyTextLightColor", "#fff"), R = s({
|
|
3322
|
+
colors: [b, f],
|
|
3298
3323
|
names: ["primary", "secondary"]
|
|
3299
3324
|
});
|
|
3300
|
-
set(
|
|
3301
|
-
const
|
|
3302
|
-
"bg-light":
|
|
3303
|
-
"bg-dark":
|
|
3304
|
-
"text-dark":
|
|
3305
|
-
"text-light":
|
|
3306
|
-
},
|
|
3307
|
-
!
|
|
3325
|
+
set(R, "primary.DEFAULT", b), set(R, "secondary.DEFAULT", f);
|
|
3326
|
+
const A = {
|
|
3327
|
+
"bg-light": k,
|
|
3328
|
+
"bg-dark": _,
|
|
3329
|
+
"text-dark": C,
|
|
3330
|
+
"text-light": B
|
|
3331
|
+
}, N = get(o, "roundedCorners", "0");
|
|
3332
|
+
!d || !d.tailwind || (d.tailwind.config = {
|
|
3308
3333
|
darkMode: "class",
|
|
3309
3334
|
theme: {
|
|
3310
3335
|
extend: {
|
|
@@ -3316,72 +3341,72 @@ const useHandleCanvasDblClick = () => {
|
|
|
3316
3341
|
}
|
|
3317
3342
|
},
|
|
3318
3343
|
fontFamily: {
|
|
3319
|
-
heading: [
|
|
3320
|
-
body: [
|
|
3344
|
+
heading: [g],
|
|
3345
|
+
body: [E]
|
|
3321
3346
|
},
|
|
3322
3347
|
borderRadius: {
|
|
3323
|
-
DEFAULT: `${
|
|
3348
|
+
DEFAULT: `${N || "0"}px`
|
|
3324
3349
|
},
|
|
3325
|
-
colors: { ...
|
|
3350
|
+
colors: { ...A, ...R }
|
|
3326
3351
|
}
|
|
3327
3352
|
},
|
|
3328
3353
|
plugins: [
|
|
3329
3354
|
typography$1,
|
|
3330
3355
|
forms,
|
|
3331
3356
|
aspectRatio,
|
|
3332
|
-
plugin(function({ addBase:
|
|
3333
|
-
|
|
3357
|
+
plugin(function({ addBase: D, theme: I }) {
|
|
3358
|
+
D({
|
|
3334
3359
|
"h1,h2,h3,h4,h5,h6": {
|
|
3335
|
-
fontFamily:
|
|
3360
|
+
fontFamily: I("fontFamily.heading")
|
|
3336
3361
|
},
|
|
3337
3362
|
body: {
|
|
3338
|
-
fontFamily:
|
|
3339
|
-
color:
|
|
3340
|
-
backgroundColor:
|
|
3363
|
+
fontFamily: I("fontFamily.body"),
|
|
3364
|
+
color: I("colors.text-light"),
|
|
3365
|
+
backgroundColor: I("colors.bg-light")
|
|
3341
3366
|
},
|
|
3342
3367
|
".dark body": {
|
|
3343
|
-
color:
|
|
3344
|
-
backgroundColor:
|
|
3368
|
+
color: I("colors.text-dark"),
|
|
3369
|
+
backgroundColor: I("colors.bg-dark")
|
|
3345
3370
|
}
|
|
3346
3371
|
});
|
|
3347
3372
|
})
|
|
3348
3373
|
]
|
|
3349
3374
|
});
|
|
3350
|
-
}, [o,
|
|
3351
|
-
|
|
3375
|
+
}, [o, d, g, E]), useEffect(() => {
|
|
3376
|
+
u && (u.textContent = `${map(n, (b) => `[data-block-id="${b}"]`).join(",")}{
|
|
3352
3377
|
outline: 1px solid ${n.length === 1 ? "#42a1fc" : "orange"} !important; outline-offset: -1px;
|
|
3353
3378
|
}`);
|
|
3354
|
-
}, [n,
|
|
3355
|
-
|
|
3356
|
-
}, [
|
|
3357
|
-
p && (p.textContent =
|
|
3358
|
-
}, [
|
|
3359
|
-
|
|
3379
|
+
}, [n, u]), useEffect(() => {
|
|
3380
|
+
x.textContent = l ? `[data-block-id="${l._id}"], [data-block-id="${l._id}"] > * { pointer-events: none !important; opacity: 0.6 !important}` : "";
|
|
3381
|
+
}, [l, x]), useEffect(() => {
|
|
3382
|
+
p && (p.textContent = '[data-highlighted="true"]{ outline: 1px solid #42a1fc !important; outline-offset: -1px;}');
|
|
3383
|
+
}, [p]), useEffect(() => {
|
|
3384
|
+
m && (m.textContent = `${map(a, ({ id: b }) => `[data-style-id="${b}"]`).join(",")}{
|
|
3360
3385
|
outline: 1px solid #42a1fc !important; outline-offset: -1px;
|
|
3361
3386
|
}`);
|
|
3362
|
-
}, [
|
|
3363
|
-
|
|
3364
|
-
}, [
|
|
3387
|
+
}, [a, m]), useEffect(() => {
|
|
3388
|
+
c.querySelector("#drop-target-block").innerHTML = i ? `[data-block-id="${i}"]{ outline: 1px dashed orange !important; outline-offset: -1px;}` : "";
|
|
3389
|
+
}, [i]), /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: (g || E) && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
3365
3390
|
"link",
|
|
3366
3391
|
{
|
|
3367
3392
|
rel: "stylesheet",
|
|
3368
|
-
href: `https://fonts.googleapis.com/css2?family=${
|
|
3393
|
+
href: `https://fonts.googleapis.com/css2?family=${g ? `${g.replace(/ /g, "+")}:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,300;1,400;1,500;1,600;1,700;1,800;1,900` : ""}${g && E && g !== E ? "&" : ""}${E && E !== g ? `family=${E.replace(/ /g, "+")}:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,300;1,400;1,500;1,600;1,700;1,800;1,900` : ""}&display=swap`
|
|
3369
3394
|
}
|
|
3370
3395
|
) });
|
|
3371
3396
|
}, useChaiExternalData = () => useAtom$1(chaiExternalDataAtom), useCanvasSettings = () => useAtom$1(canvasSettingsAtom), isVisibleAtBreakpoint = (o, n) => {
|
|
3372
3397
|
const r = ["xs", "sm", "md", "lg", "xl", "2xl"], a = r.indexOf(n), l = o.split(" ");
|
|
3373
3398
|
let i = new Array(r.length).fill(!1);
|
|
3374
3399
|
for (const c of l) {
|
|
3375
|
-
let [d,
|
|
3376
|
-
|
|
3377
|
-
const
|
|
3378
|
-
if (
|
|
3400
|
+
let [d, p] = c.split(":");
|
|
3401
|
+
p || (p = d, d = "xs");
|
|
3402
|
+
const u = r.indexOf(d);
|
|
3403
|
+
if (u <= a) {
|
|
3379
3404
|
const m = ["block", "flex", "inline", "inline-block", "inline-flex", "grid", "table"], x = ["hidden"];
|
|
3380
|
-
if (m.includes(
|
|
3381
|
-
for (let g =
|
|
3405
|
+
if (m.includes(p))
|
|
3406
|
+
for (let g = u; g < r.length; g++)
|
|
3382
3407
|
i[g] = !0;
|
|
3383
|
-
else if (x.includes(
|
|
3384
|
-
for (let g =
|
|
3408
|
+
else if (x.includes(p))
|
|
3409
|
+
for (let g = u; g < r.length; g++)
|
|
3385
3410
|
i[g] = !1;
|
|
3386
3411
|
}
|
|
3387
3412
|
}
|
|
@@ -3401,24 +3426,24 @@ const useHandleCanvasDblClick = () => {
|
|
|
3401
3426
|
);
|
|
3402
3427
|
return { getRSCBlockMarkup: a, getRSCBlockState: l, reset: i };
|
|
3403
3428
|
}, useWatchRSCBlocks = () => {
|
|
3404
|
-
const [o] = useBlocksStore(), [n, r] = useAtom(rscBlocksStoreAtom), [a, l] = useAtom(rscBlocksLoadingStateAtom), i = useChaiBlocks(), c = useBuilderProp("getRSCBlock", async (
|
|
3429
|
+
const [o] = useBlocksStore(), [n, r] = useAtom(rscBlocksStoreAtom), [a, l] = useAtom(rscBlocksLoadingStateAtom), i = useChaiBlocks(), c = useBuilderProp("getRSCBlock", async (p) => ""), d = useMemo(() => o.filter((u) => {
|
|
3405
3430
|
var x;
|
|
3406
|
-
return (x = get(i,
|
|
3407
|
-
}).map((
|
|
3431
|
+
return (x = get(i, u._type)) == null ? void 0 : x.server;
|
|
3432
|
+
}).map((u) => u._id), [i, o]);
|
|
3408
3433
|
useEffect(() => {
|
|
3409
|
-
forEach(d, (
|
|
3410
|
-
if (get(n,
|
|
3434
|
+
forEach(d, (p) => {
|
|
3435
|
+
if (get(n, p, "") || get(a, `${p}.loading`, !1))
|
|
3411
3436
|
return;
|
|
3412
|
-
const
|
|
3413
|
-
l((m) => ({ ...m, [
|
|
3414
|
-
r((x) => ({ ...x, [
|
|
3437
|
+
const u = o.find((m) => m._id === p);
|
|
3438
|
+
l((m) => ({ ...m, [p]: { loading: !0, error: null } })), c(u).then((m) => {
|
|
3439
|
+
r((x) => ({ ...x, [p]: m })), l((x) => ({
|
|
3415
3440
|
...x,
|
|
3416
|
-
[
|
|
3441
|
+
[p]: { loading: !1, error: null }
|
|
3417
3442
|
}));
|
|
3418
3443
|
}).catch((m) => {
|
|
3419
3444
|
l((x) => ({
|
|
3420
3445
|
...x,
|
|
3421
|
-
[
|
|
3446
|
+
[p]: { loading: !1, error: m.message }
|
|
3422
3447
|
}));
|
|
3423
3448
|
});
|
|
3424
3449
|
});
|
|
@@ -3483,29 +3508,29 @@ function applyLanguage(o, n, r) {
|
|
|
3483
3508
|
}), a;
|
|
3484
3509
|
}
|
|
3485
3510
|
function BlocksRendererStatic({ blocks: o, allBlocks: n }) {
|
|
3486
|
-
const { selectedLang: r } = useLanguages(), [a] = useAtom$1(xShowBlocksAtom), [l] = useCutBlockIds(), [i] = useAtom$1(draggedBlockAtom), [c] = useAtom$1(dropTargetBlockIdAtom), [, d] = useCanvasWidth(), [
|
|
3487
|
-
(f) => f.reduce((
|
|
3488
|
-
const
|
|
3489
|
-
return { ...
|
|
3511
|
+
const { selectedLang: r } = useLanguages(), [a] = useAtom$1(xShowBlocksAtom), [l] = useCutBlockIds(), [i] = useAtom$1(draggedBlockAtom), [c] = useAtom$1(dropTargetBlockIdAtom), [, d] = useCanvasWidth(), [p] = useCanvasSettings(), [u] = useHiddenBlockIds(), { getGlobalBlocks: m } = useGlobalBlocksStore(), x = useCallback((f) => getStyleAttrs(f, d), [d]), [g] = useChaiExternalData(), [E] = useAtom$1(inlineEditingActiveAtom), b = useCallback(
|
|
3512
|
+
(f) => f.reduce((k, _) => {
|
|
3513
|
+
const C = get(p, _, {});
|
|
3514
|
+
return { ...k, ...C };
|
|
3490
3515
|
}, {}),
|
|
3491
|
-
[
|
|
3516
|
+
[p]
|
|
3492
3517
|
);
|
|
3493
3518
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: React__default.Children.toArray(
|
|
3494
|
-
o.map((f,
|
|
3495
|
-
if (E === f._id ||
|
|
3519
|
+
o.map((f, k) => {
|
|
3520
|
+
if (E === f._id || u.includes(f._id))
|
|
3496
3521
|
return null;
|
|
3497
|
-
const
|
|
3498
|
-
if (
|
|
3499
|
-
const
|
|
3500
|
-
|
|
3522
|
+
const _ = {}, C = filter(n, { _parent: f._id });
|
|
3523
|
+
if (_.children = C.length > 0 ? /* @__PURE__ */ jsxRuntimeExports.jsx(BlocksRendererStatic, { allBlocks: n, blocks: C }) : null, f._type === "GlobalBlock") {
|
|
3524
|
+
const w = m(f);
|
|
3525
|
+
_.children = /* @__PURE__ */ jsxRuntimeExports.jsx(RenderGlobalBlock, { blocks: filter(w, (S) => !S._parent), allBlocks: w });
|
|
3501
3526
|
}
|
|
3502
|
-
const B = getBlockComponent(f._type),
|
|
3527
|
+
const B = getBlockComponent(f._type), R = get(B, "server", !1), A = R ? RSCBlock : get(B, "builderComponent", get(B, "component", null));
|
|
3503
3528
|
if (isNull(A))
|
|
3504
3529
|
return /* @__PURE__ */ jsxRuntimeExports.jsx("noscript", { children: `<!-- ${f == null ? void 0 : f._type} not registered -->` });
|
|
3505
|
-
const N = has(B, "getBlockStateFrom") ? B == null ? void 0 : B.getBlockStateFrom(f, n) : [], D =
|
|
3506
|
-
if (get(
|
|
3530
|
+
const N = has(B, "getBlockStateFrom") ? B == null ? void 0 : B.getBlockStateFrom(f, n) : [], D = b(N), I = x(f);
|
|
3531
|
+
if (get(I, "__isHidden", !1) && !includes(a, f._id))
|
|
3507
3532
|
return null;
|
|
3508
|
-
const
|
|
3533
|
+
const j = i && isDescendant(i._id, f._id, n), v = {
|
|
3509
3534
|
...includes(a, f._id) ? { "force-show": "" } : {},
|
|
3510
3535
|
"data-block-id": f._id,
|
|
3511
3536
|
"data-block-type": f._type,
|
|
@@ -3513,18 +3538,18 @@ function BlocksRendererStatic({ blocks: o, allBlocks: n }) {
|
|
|
3513
3538
|
// @ts-ignore
|
|
3514
3539
|
{
|
|
3515
3540
|
"data-dnd": canAcceptChildBlock(f._type, i == null ? void 0 : i._type) ? "yes" : "no",
|
|
3516
|
-
"data-dnd-dragged": i._id === f._id ||
|
|
3541
|
+
"data-dnd-dragged": i._id === f._id || j ? "yes" : "no"
|
|
3517
3542
|
}
|
|
3518
3543
|
) : {},
|
|
3519
|
-
...c === f._id && !
|
|
3544
|
+
...c === f._id && !j ? { "data-drop": "yes" } : {},
|
|
3520
3545
|
...includes(l, f._id) ? { "data-cut-block": "yes" } : {}
|
|
3521
3546
|
};
|
|
3522
|
-
return
|
|
3523
|
-
blockProps:
|
|
3524
|
-
index:
|
|
3547
|
+
return R ? /* @__PURE__ */ jsxRuntimeExports.jsx(RSCBlock, { block: f, blockProps: v }) : /* @__PURE__ */ jsxRuntimeExports.jsx(Suspense, { children: React__default.createElement(A, {
|
|
3548
|
+
blockProps: v,
|
|
3549
|
+
index: k,
|
|
3525
3550
|
...applyBindings(applyLanguage(f, r, B), g),
|
|
3526
|
-
...omit(
|
|
3527
|
-
...
|
|
3551
|
+
...omit(I, ["__isHidden"]),
|
|
3552
|
+
..._,
|
|
3528
3553
|
inBuilder: !0,
|
|
3529
3554
|
blockState: D
|
|
3530
3555
|
}) });
|
|
@@ -3538,7 +3563,7 @@ const useAllDataProviders = () => useMemo(() => getChaiDataProviders(), []), Blo
|
|
|
3538
3563
|
if (i) {
|
|
3539
3564
|
const c = (i == null ? void 0 : i.mockFn) || (i == null ? void 0 : i.dataFn);
|
|
3540
3565
|
c && c(l.args).then(
|
|
3541
|
-
(d) => n((
|
|
3566
|
+
(d) => n((p) => ({ ...p, [l.providerKey]: d }))
|
|
3542
3567
|
);
|
|
3543
3568
|
}
|
|
3544
3569
|
}), () => {
|
|
@@ -3576,14 +3601,14 @@ const useAllDataProviders = () => useMemo(() => getChaiDataProviders(), []), Blo
|
|
|
3576
3601
|
n(i);
|
|
3577
3602
|
}, []), /* @__PURE__ */ jsxRuntimeExports.jsx("div", { id: "main-content", className: "h-full w-full p-8 pb-0", ref: a, children: o });
|
|
3578
3603
|
}, getElementByStyleId = (o, n) => o.querySelector(`[data-style-id="${n}"]`), StaticCanvas = () => {
|
|
3579
|
-
const [o] = useAtom$1(networkModeAtom), [n] = useCanvasWidth(), [, r] = useSelectedBlockIds(), a = useSelectedBlock(), [, l] = useHighlightBlockId(), i = useRef(null), c = useRef(null), [d,
|
|
3580
|
-
|
|
3604
|
+
const [o] = useAtom$1(networkModeAtom), [n] = useCanvasWidth(), [, r] = useSelectedBlockIds(), a = useSelectedBlock(), [, l] = useHighlightBlockId(), i = useRef(null), c = useRef(null), [d, p] = useState({ width: 0, height: 0 }), u = useCanvasScale(d), [m, x] = useState([]), [, g] = useState([]), [, E] = useAtom$1(canvasIframeAtom), [b, f] = useSelectedStylingBlocks(), k = useBuilderProp("loading", !1), _ = useBuilderProp("htmlDir", "ltr"), C = (A) => {
|
|
3605
|
+
p((N) => ({ ...N, width: A }));
|
|
3581
3606
|
};
|
|
3582
3607
|
useEffect(() => {
|
|
3583
3608
|
if (!c.current)
|
|
3584
3609
|
return;
|
|
3585
3610
|
const { clientWidth: A, clientHeight: N } = c.current;
|
|
3586
|
-
|
|
3611
|
+
p({ width: A, height: N });
|
|
3587
3612
|
}, [c, n]);
|
|
3588
3613
|
const B = (A, N = 0) => {
|
|
3589
3614
|
const { top: D } = A.getBoundingClientRect();
|
|
@@ -3596,23 +3621,23 @@ const useAllDataProviders = () => useMemo(() => getChaiDataProviders(), []), Blo
|
|
|
3596
3621
|
D && (B(D) || (N = (A = i.current) == null ? void 0 : A.contentWindow) == null || N.scrollTo({ top: D.offsetTop, behavior: "smooth" }), x([D]));
|
|
3597
3622
|
}
|
|
3598
3623
|
}, [a]), useEffect(() => {
|
|
3599
|
-
if (!isEmpty(
|
|
3624
|
+
if (!isEmpty(b) && i.current) {
|
|
3600
3625
|
const A = getElementByStyleId(
|
|
3601
3626
|
i.current.contentDocument,
|
|
3602
|
-
first(
|
|
3627
|
+
first(b).id
|
|
3603
3628
|
);
|
|
3604
3629
|
g(A ? [A] : [null]);
|
|
3605
3630
|
} else
|
|
3606
3631
|
g([null]);
|
|
3607
|
-
}, [
|
|
3608
|
-
const
|
|
3632
|
+
}, [b]);
|
|
3633
|
+
const R = useMemo(() => {
|
|
3609
3634
|
let A = IframeInitialContent;
|
|
3610
|
-
return A = A.replace("__HTML_DIR__",
|
|
3635
|
+
return A = A.replace("__HTML_DIR__", _), o === "offline" && (A = A.replace(
|
|
3611
3636
|
"https://old.chaibuilder.com/offline/tailwind.cdn.js",
|
|
3612
3637
|
"/offline/tailwind.cdn.js"
|
|
3613
3638
|
), A = A.replace("https://unpkg.com/aos@next/dist/aos.css", "/offline/aos.css"), A = A.replace("https://unpkg.com/aos@next/dist/aos.js", "/offline/aos.js")), A;
|
|
3614
|
-
}, [o,
|
|
3615
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(ResizableCanvasWrapper, { onMount:
|
|
3639
|
+
}, [o, _]);
|
|
3640
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(ResizableCanvasWrapper, { onMount: C, onResize: C, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
3616
3641
|
"div",
|
|
3617
3642
|
{
|
|
3618
3643
|
onClick: () => {
|
|
@@ -3627,9 +3652,9 @@ const useAllDataProviders = () => useMemo(() => getChaiDataProviders(), []), Blo
|
|
|
3627
3652
|
contentDidMount: () => E(i.current),
|
|
3628
3653
|
ref: i,
|
|
3629
3654
|
id: "canvas-iframe",
|
|
3630
|
-
style: { ...
|
|
3655
|
+
style: { ...u, ...isEmpty(u) ? { width: `${n}px` } : {} },
|
|
3631
3656
|
className: "relative mx-auto box-content h-full w-full max-w-full shadow-lg transition-all duration-300 ease-linear",
|
|
3632
|
-
initialContent:
|
|
3657
|
+
initialContent: R,
|
|
3633
3658
|
children: [
|
|
3634
3659
|
/* @__PURE__ */ jsxRuntimeExports.jsx(KeyboardHandler, {}),
|
|
3635
3660
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
@@ -3641,7 +3666,7 @@ const useAllDataProviders = () => useMemo(() => getChaiDataProviders(), []), Blo
|
|
|
3641
3666
|
),
|
|
3642
3667
|
/* @__PURE__ */ jsxRuntimeExports.jsx(HeadTags, {}),
|
|
3643
3668
|
/* @__PURE__ */ jsxRuntimeExports.jsx(Provider, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(Canvas, { children: [
|
|
3644
|
-
|
|
3669
|
+
k ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-full p-4", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-full" }) }) : /* @__PURE__ */ jsxRuntimeExports.jsx(StaticBlocksRenderer, {}),
|
|
3645
3670
|
/* @__PURE__ */ jsxRuntimeExports.jsx(AddBlockAtBottom, {}),
|
|
3646
3671
|
/* @__PURE__ */ jsxRuntimeExports.jsx("br", {}),
|
|
3647
3672
|
/* @__PURE__ */ jsxRuntimeExports.jsx("br", {}),
|
|
@@ -3727,7 +3752,7 @@ const useAllDataProviders = () => useMemo(() => getChaiDataProviders(), []), Blo
|
|
|
3727
3752
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(BoxModelIcon, {});
|
|
3728
3753
|
}
|
|
3729
3754
|
}, Breadcrumb = () => {
|
|
3730
|
-
const o = useSelectedBlockHierarchy(), [, n] = useSelectedBlockIds(),
|
|
3755
|
+
const o = useSelectedBlockHierarchy(), [, n] = useSelectedBlockIds(), { highlightBlock: r } = useBlockHighlight();
|
|
3731
3756
|
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "-mx-2 border-t border-border bg-background px-2 py-1 text-xs text-muted-foreground", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("ol", { className: "flex items-center whitespace-nowrap", children: [
|
|
3732
3757
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("li", { className: "inline-flex items-center", children: [
|
|
3733
3758
|
/* @__PURE__ */ jsxRuntimeExports.jsx(Button, { onClick: () => n([]), variant: "ghost", className: "h-fit p-1 text-xs font-normal", children: "Body" }),
|
|
@@ -3752,7 +3777,7 @@ const useAllDataProviders = () => useMemo(() => getChaiDataProviders(), []), Blo
|
|
|
3752
3777
|
l !== o.length - 1 && /* @__PURE__ */ jsxRuntimeExports.jsx(ChevronRight, { className: "rtl:rotate-180", size: 16 })
|
|
3753
3778
|
] }, l))
|
|
3754
3779
|
] }) });
|
|
3755
|
-
}, CodeEditor$1 = React__default.lazy(() => import("./CodeEditor-
|
|
3780
|
+
}, CodeEditor$1 = React__default.lazy(() => import("./CodeEditor-kW6SrwIa.js")), CanvasArea = () => {
|
|
3756
3781
|
const [o] = useCodeEditor(), n = useBuilderProp("onError", noop);
|
|
3757
3782
|
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex h-full max-h-full w-full flex-1 flex-col", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "relative flex h-full max-h-full flex-col overflow-hidden bg-gray-100/40 px-2", children: [
|
|
3758
3783
|
/* @__PURE__ */ jsxRuntimeExports.jsx(Suspense, { fallback: /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-full" }), children: /* @__PURE__ */ jsxRuntimeExports.jsx(ErrorBoundary, { fallback: /* @__PURE__ */ jsxRuntimeExports.jsx(FallbackError, {}), onError: n, children: /* @__PURE__ */ jsxRuntimeExports.jsx(StaticCanvas$1, {}) }) }),
|
|
@@ -3827,39 +3852,39 @@ const useAllDataProviders = () => useMemo(() => getChaiDataProviders(), []), Blo
|
|
|
3827
3852
|
showHeading: o = !0,
|
|
3828
3853
|
className: n = ""
|
|
3829
3854
|
}) => {
|
|
3830
|
-
const [r, a] = useBrandingOptions(), [l] = useBlocksContainer(), i = React.useRef(r), { t: c } = useTranslation(), d = ({ formData:
|
|
3831
|
-
A && (a(
|
|
3855
|
+
const [r, a] = useBrandingOptions(), [l] = useBlocksContainer(), i = React.useRef(r), { t: c } = useTranslation(), d = ({ formData: R }, A) => {
|
|
3856
|
+
A && (a(R), i.current = R);
|
|
3832
3857
|
}, {
|
|
3833
|
-
bodyFont:
|
|
3834
|
-
headingFont:
|
|
3858
|
+
bodyFont: p,
|
|
3859
|
+
headingFont: u,
|
|
3835
3860
|
primaryColor: m,
|
|
3836
3861
|
bodyTextDarkColor: x,
|
|
3837
3862
|
bodyTextLightColor: g,
|
|
3838
3863
|
bodyBgDarkColor: E,
|
|
3839
|
-
secondaryColor:
|
|
3864
|
+
secondaryColor: b,
|
|
3840
3865
|
bodyBgLightColor: f,
|
|
3841
|
-
roundedCorners:
|
|
3866
|
+
roundedCorners: k
|
|
3842
3867
|
} = r;
|
|
3843
|
-
let
|
|
3868
|
+
let _ = {
|
|
3844
3869
|
headingFont: y({
|
|
3845
3870
|
title: c("theme_config.heading_font"),
|
|
3846
|
-
default:
|
|
3871
|
+
default: u,
|
|
3847
3872
|
options: FONTS
|
|
3848
3873
|
}),
|
|
3849
3874
|
bodyFont: y({
|
|
3850
3875
|
title: c("theme_config.body_font"),
|
|
3851
|
-
default:
|
|
3876
|
+
default: p,
|
|
3852
3877
|
options: FONTS
|
|
3853
3878
|
}),
|
|
3854
3879
|
roundedCorners: s$1({
|
|
3855
3880
|
title: c("theme_config.rounded_corner"),
|
|
3856
|
-
default: parseInt(
|
|
3881
|
+
default: parseInt(k || 5, 10)
|
|
3857
3882
|
}),
|
|
3858
3883
|
primaryColor: h({ title: c("theme_config.primary"), default: m }),
|
|
3859
|
-
secondaryColor: h({ title: c("theme_config.secondary"), default:
|
|
3884
|
+
secondaryColor: h({ title: c("theme_config.secondary"), default: b })
|
|
3860
3885
|
};
|
|
3861
|
-
l || (
|
|
3862
|
-
...
|
|
3886
|
+
l || (_ = {
|
|
3887
|
+
..._,
|
|
3863
3888
|
bodyBgLightColor: h({
|
|
3864
3889
|
title: c("theme_config.background"),
|
|
3865
3890
|
default: f
|
|
@@ -3877,13 +3902,13 @@ const useAllDataProviders = () => useMemo(() => getChaiDataProviders(), []), Blo
|
|
|
3877
3902
|
default: g
|
|
3878
3903
|
})
|
|
3879
3904
|
});
|
|
3880
|
-
const
|
|
3905
|
+
const C = {
|
|
3881
3906
|
type: "object",
|
|
3882
3907
|
properties: {}
|
|
3883
3908
|
}, B = {};
|
|
3884
|
-
return Object.keys(
|
|
3885
|
-
const A =
|
|
3886
|
-
return
|
|
3909
|
+
return Object.keys(_).forEach((R) => {
|
|
3910
|
+
const A = _[R];
|
|
3911
|
+
return C.properties || (C.properties = {}), C.properties[R] = A.schema, B[R] = A.uiSchema, !0;
|
|
3887
3912
|
}), /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: cn("flex h-full w-full select-none flex-col", n), children: [
|
|
3888
3913
|
o ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "rounded-md bg-background/30 p-1", children: /* @__PURE__ */ jsxRuntimeExports.jsx("h1", { className: "px-1 font-semibold", children: c("Theme Configuration") }) }) : null,
|
|
3889
3914
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
@@ -3896,7 +3921,7 @@ const useAllDataProviders = () => useMemo(() => getChaiDataProviders(), []), Blo
|
|
|
3896
3921
|
liveOmit: !0,
|
|
3897
3922
|
liveValidate: !0,
|
|
3898
3923
|
uiSchema: B,
|
|
3899
|
-
schema:
|
|
3924
|
+
schema: C,
|
|
3900
3925
|
formData: r,
|
|
3901
3926
|
validator,
|
|
3902
3927
|
onChange: d
|
|
@@ -4077,36 +4102,36 @@ function BiExpandVertical(o) {
|
|
|
4077
4102
|
return GenIcon({ tag: "svg", attr: { viewBox: "0 0 24 24" }, child: [{ tag: "path", attr: { d: "m12 19.24-4.95-4.95-1.41 1.42L12 22.07l6.36-6.36-1.41-1.42L12 19.24zM5.64 8.29l1.41 1.42L12 4.76l4.95 4.95 1.41-1.42L12 1.93 5.64 8.29z" }, child: [] }] })(o);
|
|
4078
4103
|
}
|
|
4079
4104
|
const Node = memo(({ node: o, style: n, dragHandle: r }) => {
|
|
4080
|
-
const a = useBuilderProp("outlineMenuItems", []), { t: l } = useTranslation(), [i, , c] = useHiddenBlockIds(), [
|
|
4105
|
+
const a = useBuilderProp("outlineMenuItems", []), { t: l } = useTranslation(), [i, , c] = useHiddenBlockIds(), [d] = useAtom$1(canvasIframeAtom);
|
|
4081
4106
|
let p = null;
|
|
4082
|
-
const
|
|
4083
|
-
|
|
4084
|
-
}, B = (
|
|
4085
|
-
|
|
4086
|
-
},
|
|
4087
|
-
|
|
4088
|
-
}, A = (
|
|
4089
|
-
|
|
4107
|
+
const u = o.children.length > 0, { highlightBlock: m } = useBlockHighlight(), { id: x, data: g, isSelected: E, willReceiveDrop: b, isDragging: f, isEditing: k, handleClick: _ } = o, C = (I) => {
|
|
4108
|
+
I.stopPropagation(), !i.includes(x) && o.toggle();
|
|
4109
|
+
}, B = (I) => {
|
|
4110
|
+
I.isInternal && (p = I.isOpen, I.isOpen && I.close());
|
|
4111
|
+
}, R = (I) => {
|
|
4112
|
+
I.isInternal && p !== null && (p ? I.open() : I.close(), p = null);
|
|
4113
|
+
}, A = (I) => {
|
|
4114
|
+
I.stopPropagation(), !o.isOpen && !i.includes(x) && o.toggle(), _(I);
|
|
4090
4115
|
};
|
|
4091
4116
|
useEffect(() => {
|
|
4092
|
-
const
|
|
4093
|
-
|
|
4117
|
+
const I = setTimeout(() => {
|
|
4118
|
+
b && !o.isOpen && !f && !i.includes(x) && o.toggle();
|
|
4094
4119
|
}, 500);
|
|
4095
|
-
return () => clearTimeout(
|
|
4096
|
-
}, [
|
|
4120
|
+
return () => clearTimeout(I);
|
|
4121
|
+
}, [b, o, f]);
|
|
4097
4122
|
const N = useMemo(() => {
|
|
4098
|
-
const
|
|
4099
|
-
for (let
|
|
4100
|
-
if (
|
|
4101
|
-
const
|
|
4102
|
-
|
|
4123
|
+
const I = Object.keys(g), j = [];
|
|
4124
|
+
for (let v = 0; v < I.length; v++)
|
|
4125
|
+
if (I[v].endsWith("_attrs")) {
|
|
4126
|
+
const w = g[I[v]], S = Object.keys(w).join("|");
|
|
4127
|
+
S.match(/x-data/) && j.push("data"), S.match(/x-on/) && j.push("event"), S.match(/x-show|x-if/) && j.push("show");
|
|
4103
4128
|
}
|
|
4104
|
-
return
|
|
4105
|
-
}, [g]), D = (
|
|
4106
|
-
const
|
|
4107
|
-
|
|
4108
|
-
const
|
|
4109
|
-
|
|
4129
|
+
return j;
|
|
4130
|
+
}, [g]), D = (I, j) => {
|
|
4131
|
+
const v = d.contentDocument || d.contentWindow.document, w = v.querySelector(`[data-block-id=${I}]`);
|
|
4132
|
+
w && w.setAttribute("data-drop", j);
|
|
4133
|
+
const S = w.getBoundingClientRect(), T = d.getBoundingClientRect();
|
|
4134
|
+
S.top >= T.top && S.left >= T.left && S.bottom <= T.bottom && S.right <= T.right || (v.documentElement.scrollTop = w.offsetTop - T.top);
|
|
4110
4135
|
};
|
|
4111
4136
|
return x === ROOT_TEMP_KEY ? /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
4112
4137
|
"button",
|
|
@@ -4121,26 +4146,26 @@ const Node = memo(({ node: o, style: n, dragHandle: r }) => {
|
|
|
4121
4146
|
) : /* @__PURE__ */ jsxRuntimeExports.jsx(BlockContextMenu, { id: x, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
4122
4147
|
"div",
|
|
4123
4148
|
{
|
|
4124
|
-
onMouseEnter: () =>
|
|
4149
|
+
onMouseEnter: () => m(x),
|
|
4125
4150
|
onClick: A,
|
|
4126
4151
|
style: n,
|
|
4127
4152
|
"data-node-id": x,
|
|
4128
4153
|
ref: i.includes(x) ? null : r,
|
|
4129
4154
|
onDragStart: () => B(o),
|
|
4130
|
-
onDragEnd: () =>
|
|
4131
|
-
onDragOver: (
|
|
4132
|
-
|
|
4155
|
+
onDragEnd: () => R(o),
|
|
4156
|
+
onDragOver: (I) => {
|
|
4157
|
+
I.preventDefault(), D(x, "yes");
|
|
4133
4158
|
},
|
|
4134
|
-
onDragLeave: (
|
|
4135
|
-
|
|
4159
|
+
onDragLeave: (I) => {
|
|
4160
|
+
I.preventDefault(), D(x, "no");
|
|
4136
4161
|
},
|
|
4137
|
-
onDrop: (
|
|
4138
|
-
|
|
4162
|
+
onDrop: (I) => {
|
|
4163
|
+
I.preventDefault(), D(x, "no");
|
|
4139
4164
|
},
|
|
4140
4165
|
className: cn(
|
|
4141
4166
|
"group flex !h-full w-full items-center justify-between space-x-px !rounded py-px text-foreground/80 outline-none",
|
|
4142
4167
|
E ? "bg-blue-500 text-white" : "hover:bg-gray-200 dark:hover:bg-gray-800",
|
|
4143
|
-
|
|
4168
|
+
b && canAcceptChildBlock(g._type, "Icon") ? "bg-green-200" : "",
|
|
4144
4169
|
f && "opacity-20",
|
|
4145
4170
|
i.includes(x) ? "opacity-50" : ""
|
|
4146
4171
|
),
|
|
@@ -4150,17 +4175,17 @@ const Node = memo(({ node: o, style: n, dragHandle: r }) => {
|
|
|
4150
4175
|
"div",
|
|
4151
4176
|
{
|
|
4152
4177
|
className: `flex h-4 w-4 rotate-0 transform cursor-pointer items-center justify-center text-xs transition-transform duration-100 ${o.isOpen ? "rotate-90" : ""}`,
|
|
4153
|
-
children:
|
|
4178
|
+
children: u && /* @__PURE__ */ jsxRuntimeExports.jsx("button", { onClick: C, type: "button", children: /* @__PURE__ */ jsxRuntimeExports.jsx(TriangleRightIcon, {}) })
|
|
4154
4179
|
}
|
|
4155
4180
|
),
|
|
4156
4181
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center", children: [
|
|
4157
4182
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "-mt-0.5 h-3 w-3", children: /* @__PURE__ */ jsxRuntimeExports.jsx(TypeIcon, { type: g == null ? void 0 : g._type }) }),
|
|
4158
|
-
|
|
4183
|
+
k ? /* @__PURE__ */ jsxRuntimeExports.jsx(Input, { node: o }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
4159
4184
|
"div",
|
|
4160
4185
|
{
|
|
4161
4186
|
className: "ml-2 flex items-center gap-x-1 truncate text-[11px]",
|
|
4162
|
-
onDoubleClick: (
|
|
4163
|
-
|
|
4187
|
+
onDoubleClick: (I) => {
|
|
4188
|
+
I.stopPropagation(), o.edit(), o.deselect();
|
|
4164
4189
|
},
|
|
4165
4190
|
children: [
|
|
4166
4191
|
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: (g == null ? void 0 : g._name) || (g == null ? void 0 : g._type.split("/").pop()) }),
|
|
@@ -4173,16 +4198,16 @@ const Node = memo(({ node: o, style: n, dragHandle: r }) => {
|
|
|
4173
4198
|
] })
|
|
4174
4199
|
] }),
|
|
4175
4200
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "invisible flex items-center space-x-1 pr-2 group-hover:visible", children: [
|
|
4176
|
-
!i.includes(x) && a.map((
|
|
4201
|
+
!i.includes(x) && a.map((I) => /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
|
|
4177
4202
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
4178
4203
|
TooltipTrigger,
|
|
4179
4204
|
{
|
|
4180
4205
|
className: "cursor-pointer rounded bg-transparent hover:bg-white hover:text-blue-500",
|
|
4181
4206
|
asChild: !0,
|
|
4182
|
-
children: React__default.createElement(
|
|
4207
|
+
children: React__default.createElement(I.item, { blockId: x })
|
|
4183
4208
|
}
|
|
4184
4209
|
),
|
|
4185
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { className: "isolate z-10", children:
|
|
4210
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { className: "isolate z-10", children: I.tooltip })
|
|
4186
4211
|
] })),
|
|
4187
4212
|
canAddChildBlock(g == null ? void 0 : g._type) && !i.includes(x) ? /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
|
|
4188
4213
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
@@ -4200,8 +4225,8 @@ const Node = memo(({ node: o, style: n, dragHandle: r }) => {
|
|
|
4200
4225
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
4201
4226
|
TooltipTrigger,
|
|
4202
4227
|
{
|
|
4203
|
-
onClick: (
|
|
4204
|
-
|
|
4228
|
+
onClick: (I) => {
|
|
4229
|
+
I.stopPropagation(), c(x), o.isOpen && o.toggle();
|
|
4205
4230
|
},
|
|
4206
4231
|
className: "cursor-pointer rounded bg-transparent hover:bg-white hover:text-black",
|
|
4207
4232
|
asChild: !0,
|
|
@@ -4429,7 +4454,10 @@ const Node = memo(({ node: o, style: n, dragHandle: r }) => {
|
|
|
4429
4454
|
multiple: "multiple",
|
|
4430
4455
|
name: "fieldName"
|
|
4431
4456
|
}
|
|
4432
|
-
}, shouldAddText = (o, n) => o.children.length === 1 && includes(
|
|
4457
|
+
}, shouldAddText = (o, n) => o.children.length === 1 && includes(
|
|
4458
|
+
["Heading", "Paragraph", "Span", "ListItem", "Button", "Label", "TableCell", "Link", "RichText"],
|
|
4459
|
+
n._type
|
|
4460
|
+
), getTextContent = (o) => o.map((n) => n.type === "text" ? get(n, "content", "") : isEmpty(n.children) ? "" : getTextContent(n.children)).join(""), getSanitizedValue = (o) => o === null ? "" : o, getAttrs = (o) => {
|
|
4433
4461
|
if (o.tagName === "svg")
|
|
4434
4462
|
return {};
|
|
4435
4463
|
const n = {}, r = ATTRIBUTE_MAP[o.tagName] || {}, a = o.attributes;
|
|
@@ -4454,6 +4482,11 @@ const Node = memo(({ node: o, style: n, dragHandle: r }) => {
|
|
|
4454
4482
|
}
|
|
4455
4483
|
return { [n]: `${STYLES_KEY},` };
|
|
4456
4484
|
}, getBlockProps = (o) => {
|
|
4485
|
+
const n = get(o, "attributes", []), r = n.find((l) => l.key === "data-chai-richtext" || l.key === "chai-richtext"), a = n.find((l) => l.key === "data-chai-lightbox" || l.key === "chai-lightbox");
|
|
4486
|
+
if (r)
|
|
4487
|
+
return { _type: "RichText" };
|
|
4488
|
+
if (a)
|
|
4489
|
+
return { _type: "LightBoxLink" };
|
|
4457
4490
|
switch (o.tagName) {
|
|
4458
4491
|
case "img":
|
|
4459
4492
|
return { _type: "Image" };
|
|
@@ -4525,46 +4558,78 @@ const Node = memo(({ node: o, style: n, dragHandle: r }) => {
|
|
|
4525
4558
|
return { _type: "TableBody" };
|
|
4526
4559
|
case "tfoot":
|
|
4527
4560
|
return { _type: "TableFooter" };
|
|
4528
|
-
|
|
4529
|
-
const
|
|
4561
|
+
case "div": {
|
|
4562
|
+
const l = get(o, "children", []).length > 0 ? "Box" : "EmptyBox";
|
|
4530
4563
|
return {
|
|
4531
|
-
_type:
|
|
4564
|
+
_type: l,
|
|
4532
4565
|
tag: o.tagName,
|
|
4533
|
-
_name:
|
|
4566
|
+
_name: l == "EmptyBox" || o.tagName === "div" ? l : capitalize(o.tagName)
|
|
4534
4567
|
};
|
|
4568
|
+
}
|
|
4535
4569
|
}
|
|
4536
4570
|
}, traverseNodes = (o, n = null) => flatMapDeep(o, (r) => {
|
|
4537
|
-
var
|
|
4571
|
+
var p, u, m, x, g, E, b, f;
|
|
4538
4572
|
if (r.type === "comment")
|
|
4539
4573
|
return [];
|
|
4540
4574
|
let a = { _id: generateUUID() };
|
|
4541
4575
|
if (n && (a._parent = n.block._id), r.type === "text")
|
|
4542
4576
|
return isEmpty(get(r, "content", "")) ? [] : n && shouldAddText(n.node, n.block) ? (set(n, "block.content", get(r, "content", "")), []) : { ...a, _type: "Text", content: get(r, "content", "") };
|
|
4577
|
+
const l = get(r, "attributes", []), i = l.find(
|
|
4578
|
+
(k) => k.key === "data-chai-richtext" || k.key === "chai-richtext"
|
|
4579
|
+
), c = l.find(
|
|
4580
|
+
(k) => k.key === "data-chai-lightbox" || k.key === "chai-lightbox"
|
|
4581
|
+
);
|
|
4543
4582
|
if (a = {
|
|
4544
4583
|
...a,
|
|
4545
4584
|
...getBlockProps(r),
|
|
4546
4585
|
...getAttrs(r),
|
|
4547
4586
|
...getStyles(r)
|
|
4548
4587
|
}, r.attributes) {
|
|
4549
|
-
const
|
|
4550
|
-
|
|
4588
|
+
const k = r.attributes.find((_) => _.key === NAME_ATTRIBUTE);
|
|
4589
|
+
k && (a._name = k.value);
|
|
4590
|
+
}
|
|
4591
|
+
if (i)
|
|
4592
|
+
return a.content = stringify(r.children), has(a, "styles_attrs.data-chai-richtext") && delete a.styles_attrs["data-chai-richtext"], has(a, "styles_attrs.chai-richtext") && delete a.styles_attrs["chai-richtext"], [a];
|
|
4593
|
+
if (c) {
|
|
4594
|
+
const k = [
|
|
4595
|
+
"data-chai-lightbox",
|
|
4596
|
+
"chai-lightbox",
|
|
4597
|
+
"data-vbtype",
|
|
4598
|
+
"data-autoplay",
|
|
4599
|
+
"data-maxwidth",
|
|
4600
|
+
"data-overlay",
|
|
4601
|
+
"data-gall",
|
|
4602
|
+
"href"
|
|
4603
|
+
];
|
|
4604
|
+
a = {
|
|
4605
|
+
...a,
|
|
4606
|
+
href: ((p = l.find((_) => _.key === "href")) == null ? void 0 : p.value) || "",
|
|
4607
|
+
hrefType: ((u = l.find((_) => _.key === "data-vbtype")) == null ? void 0 : u.value) || "video",
|
|
4608
|
+
autoplay: ((m = l.find((_) => _.key === "data-autoplay")) == null ? void 0 : m.value) === "true",
|
|
4609
|
+
maxWidth: ((g = (x = l.find((_) => _.key === "data-maxwidth")) == null ? void 0 : x.value) == null ? void 0 : g.replace("px", "")) || "",
|
|
4610
|
+
backdropColor: ((E = l.find((_) => _.key === "data-overlay")) == null ? void 0 : E.value) || "",
|
|
4611
|
+
galleryName: ((b = l.find((_) => _.key === "data-gall")) == null ? void 0 : b.value) || ""
|
|
4612
|
+
}, forEach(k, (_) => {
|
|
4613
|
+
has(a, `styles_attrs.${_}`) && delete a.styles_attrs[_];
|
|
4614
|
+
});
|
|
4551
4615
|
}
|
|
4552
4616
|
if (a._type === "Input") {
|
|
4553
|
-
const
|
|
4554
|
-
|
|
4617
|
+
const k = a.inputType || "text";
|
|
4618
|
+
k === "checkbox" ? set(a, "_type", "Checkbox") : k === "radio" && set(a, "_type", "Radio");
|
|
4555
4619
|
} else if (r.tagName === "video" || r.tagName === "iframe") {
|
|
4556
|
-
const
|
|
4557
|
-
return hasVideoEmbed(
|
|
4620
|
+
const k = stringify([r]);
|
|
4621
|
+
return hasVideoEmbed(k) && (set(a, "_type", "Video"), set(a, "url", getVideoURLFromHTML(k)), set(a, "styles", `${STYLES_KEY},absolute top-0 left-0 w-full h-full`), set(a, "controls", { autoPlay: !1, muted: !0, loop: !1, controls: !1 })), a.content = k, [a];
|
|
4558
4622
|
} else if (r.tagName === "svg") {
|
|
4559
|
-
const
|
|
4560
|
-
return a.styles = `${STYLES_KEY}, ${cn(`w-${
|
|
4561
|
-
} else if (r.tagName == "option" && n && ((
|
|
4623
|
+
const k = find(r.attributes, { key: "height" }), _ = find(r.attributes, { key: "width" }), C = get(k, "value") ? `[${get(k, "value")}px]` : "24px", B = get(_, "value") ? `[${get(_, "value")}px]` : "24px", R = get(find(r.attributes, { key: "class" }), "value", "w-full h-full");
|
|
4624
|
+
return a.styles = `${STYLES_KEY}, ${cn(`w-${B} h-${C}`, R)}`.trim(), r.attributes = filter(r.attributes, (A) => !includes(["style", "width", "height", "class"], A.key)), a.icon = stringify([r]), [a];
|
|
4625
|
+
} else if (r.tagName == "option" && n && ((f = n.block) == null ? void 0 : f._type) === "Select")
|
|
4562
4626
|
return n.block.options.push({
|
|
4563
4627
|
label: getTextContent(r.children),
|
|
4564
4628
|
...getAttrs(r)
|
|
4565
4629
|
}), [];
|
|
4566
|
-
|
|
4567
|
-
|
|
4630
|
+
console.log(a);
|
|
4631
|
+
const d = traverseNodes(r.children, { block: a, node: r });
|
|
4632
|
+
return [a, ...d];
|
|
4568
4633
|
}), getSanitizedHTML = (o) => {
|
|
4569
4634
|
const n = o.match(/<body[^>]*>[\s\S]*?<\/body>/);
|
|
4570
4635
|
return (n && n.length > 0 ? n[0].replace(/<body/, "<div").replace(/<\/body>/, "</div>") : o).replace(/\s+/g, " ").replaceAll("> <", "><").replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, "").trim();
|
|
@@ -4616,63 +4681,63 @@ function ExpandableObject(o) {
|
|
|
4616
4681
|
openBracket: i,
|
|
4617
4682
|
closeBracket: c,
|
|
4618
4683
|
level: d,
|
|
4619
|
-
style:
|
|
4620
|
-
shouldExpandNode:
|
|
4684
|
+
style: p,
|
|
4685
|
+
shouldExpandNode: u,
|
|
4621
4686
|
clickToExpandNode: m
|
|
4622
4687
|
} = o;
|
|
4623
|
-
const x = useRef(!1), [g, E,
|
|
4688
|
+
const x = useRef(!1), [g, E, b] = useBool(() => u(d, r, n));
|
|
4624
4689
|
useEffect(() => {
|
|
4625
|
-
x.current ?
|
|
4626
|
-
}, [
|
|
4627
|
-
const f = g ?
|
|
4690
|
+
x.current ? b(u(d, r, n)) : x.current = !0;
|
|
4691
|
+
}, [u]);
|
|
4692
|
+
const f = g ? p.collapseIcon : p.expandIcon, k = g ? "collapse JSON" : "expand JSON", _ = useComponentId(), C = d + 1, B = a.length - 1, R = (A) => {
|
|
4628
4693
|
A.key === " " && (A.preventDefault(), E());
|
|
4629
4694
|
};
|
|
4630
4695
|
return /* @__PURE__ */ createElement("div", {
|
|
4631
|
-
className:
|
|
4696
|
+
className: p.basicChildStyle,
|
|
4632
4697
|
role: "list"
|
|
4633
4698
|
}, /* @__PURE__ */ createElement("span", {
|
|
4634
4699
|
className: f,
|
|
4635
4700
|
onClick: E,
|
|
4636
|
-
onKeyDown:
|
|
4701
|
+
onKeyDown: R,
|
|
4637
4702
|
role: "button",
|
|
4638
4703
|
tabIndex: 0,
|
|
4639
|
-
"aria-label":
|
|
4704
|
+
"aria-label": k,
|
|
4640
4705
|
"aria-expanded": g,
|
|
4641
|
-
"aria-controls": g ?
|
|
4706
|
+
"aria-controls": g ? _ : void 0
|
|
4642
4707
|
}), n && (m ? /* @__PURE__ */ createElement("span", {
|
|
4643
|
-
className:
|
|
4708
|
+
className: p.clickableLabel,
|
|
4644
4709
|
onClick: E,
|
|
4645
|
-
onKeyDown:
|
|
4710
|
+
onKeyDown: R,
|
|
4646
4711
|
role: "button",
|
|
4647
4712
|
tabIndex: -1
|
|
4648
4713
|
}, n, ":") : /* @__PURE__ */ createElement("span", {
|
|
4649
|
-
className:
|
|
4714
|
+
className: p.label
|
|
4650
4715
|
}, n, ":")), /* @__PURE__ */ createElement("span", {
|
|
4651
|
-
className:
|
|
4716
|
+
className: p.punctuation
|
|
4652
4717
|
}, i), g ? /* @__PURE__ */ createElement("div", {
|
|
4653
|
-
id:
|
|
4718
|
+
id: _
|
|
4654
4719
|
}, a.map((A, N) => /* @__PURE__ */ createElement(DataRender, {
|
|
4655
4720
|
key: A[0] || N,
|
|
4656
4721
|
field: A[0],
|
|
4657
4722
|
value: A[1],
|
|
4658
|
-
style:
|
|
4723
|
+
style: p,
|
|
4659
4724
|
lastElement: N === B,
|
|
4660
|
-
level:
|
|
4661
|
-
shouldExpandNode:
|
|
4725
|
+
level: C,
|
|
4726
|
+
shouldExpandNode: u,
|
|
4662
4727
|
clickToExpandNode: m
|
|
4663
4728
|
}))) : /* @__PURE__ */ createElement("span", {
|
|
4664
|
-
className:
|
|
4729
|
+
className: p.collapsedContent,
|
|
4665
4730
|
onClick: E,
|
|
4666
|
-
onKeyDown:
|
|
4731
|
+
onKeyDown: R,
|
|
4667
4732
|
role: "button",
|
|
4668
4733
|
tabIndex: -1,
|
|
4669
4734
|
"aria-hidden": !0,
|
|
4670
|
-
"aria-label":
|
|
4735
|
+
"aria-label": k,
|
|
4671
4736
|
"aria-expanded": g
|
|
4672
4737
|
}), /* @__PURE__ */ createElement("span", {
|
|
4673
|
-
className:
|
|
4738
|
+
className: p.punctuation
|
|
4674
4739
|
}, c), !l && /* @__PURE__ */ createElement("span", {
|
|
4675
|
-
className:
|
|
4740
|
+
className: p.punctuation
|
|
4676
4741
|
}, ","));
|
|
4677
4742
|
}
|
|
4678
4743
|
function JsonObject(o) {
|
|
@@ -4695,7 +4760,7 @@ function JsonObject(o) {
|
|
|
4695
4760
|
style: a,
|
|
4696
4761
|
shouldExpandNode: i,
|
|
4697
4762
|
clickToExpandNode: c,
|
|
4698
|
-
data: Object.keys(r).map((
|
|
4763
|
+
data: Object.keys(r).map((p) => [p, r[p]])
|
|
4699
4764
|
});
|
|
4700
4765
|
}
|
|
4701
4766
|
function JsonArray(o) {
|
|
@@ -4718,7 +4783,7 @@ function JsonArray(o) {
|
|
|
4718
4783
|
style: a,
|
|
4719
4784
|
shouldExpandNode: c,
|
|
4720
4785
|
clickToExpandNode: d,
|
|
4721
|
-
data: r.map((
|
|
4786
|
+
data: r.map((p) => [void 0, p])
|
|
4722
4787
|
});
|
|
4723
4788
|
}
|
|
4724
4789
|
function JsonPrimitiveValue(o) {
|
|
@@ -4782,8 +4847,8 @@ function getPathAndTypes(o) {
|
|
|
4782
4847
|
const n = [], r = {};
|
|
4783
4848
|
function a(l, i) {
|
|
4784
4849
|
forEach(i, (c, d) => {
|
|
4785
|
-
const
|
|
4786
|
-
n.push(
|
|
4850
|
+
const p = l ? `${l}.${d}` : d, u = isArray$1(c) ? "list" : typeof c;
|
|
4851
|
+
n.push(p), r[p] = u === "string" ? "text" : u === "object" ? "model" : u, u === "object" && !isArray$1(c) && a(p, c);
|
|
4787
4852
|
});
|
|
4788
4853
|
}
|
|
4789
4854
|
return a("", omit(o, ["styles", "_type", "_id", "_name", "_bindings"])), { paths: n, pathsType: r };
|
|
@@ -4821,9 +4886,9 @@ const ViewData = ({ data: o, fullView: n }) => {
|
|
|
4821
4886
|
dataType: i,
|
|
4822
4887
|
appliedBindings: c
|
|
4823
4888
|
}) => {
|
|
4824
|
-
const { paths: d, pathsType:
|
|
4825
|
-
(
|
|
4826
|
-
) : d.filter((
|
|
4889
|
+
const { paths: d, pathsType: p } = getPathAndTypes(a), u = o === "PROP" ? getBlockComponent(a == null ? void 0 : a._type) : {}, m = o === "PROP", [x, g] = useState(!1), E = useMemo(() => o === "PROP" ? d.filter(
|
|
4890
|
+
(b) => !includes(c, b) && get(u, `props.${first(split(b, "."))}.binding`)
|
|
4891
|
+
) : d.filter((b) => i === get(p, b, "")), [o, d, c, i, u]);
|
|
4827
4892
|
return useEffect(() => {
|
|
4828
4893
|
n && l(n);
|
|
4829
4894
|
}, [n, o]), /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
@@ -4852,23 +4917,23 @@ const ViewData = ({ data: o, fullView: n }) => {
|
|
|
4852
4917
|
/* @__PURE__ */ jsxRuntimeExports.jsx(CommandInput, { placeholder: `Choose ${toLower(o)}...` }),
|
|
4853
4918
|
/* @__PURE__ */ jsxRuntimeExports.jsxs(CommandList, { children: [
|
|
4854
4919
|
/* @__PURE__ */ jsxRuntimeExports.jsx(CommandEmpty, { children: "No results found." }),
|
|
4855
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(CommandGroup, { children: map(E, (
|
|
4920
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(CommandGroup, { children: map(E, (b) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
4856
4921
|
CommandItem,
|
|
4857
4922
|
{
|
|
4858
|
-
value:
|
|
4923
|
+
value: b,
|
|
4859
4924
|
className: `cursor-pointer ${m ? "flex items-center justify-between" : "flex flex-col items-start justify-start"}`,
|
|
4860
4925
|
onSelect: (f) => {
|
|
4861
|
-
r(find(E, (
|
|
4926
|
+
r(find(E, (k) => k === f) || null), g(!1);
|
|
4862
4927
|
},
|
|
4863
4928
|
children: [
|
|
4864
4929
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-x-2", children: [
|
|
4865
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(Check, { className: `h-4 w-4 text-green-500 ${n ===
|
|
4866
|
-
|
|
4930
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Check, { className: `h-4 w-4 text-green-500 ${n === b ? "" : "opacity-0"}` }),
|
|
4931
|
+
b
|
|
4867
4932
|
] }),
|
|
4868
|
-
m ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "rounded-full bg-purple-100 px-2 py-0.5 text-[10px] text-purple-500", children: startCase(get(
|
|
4933
|
+
m ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "rounded-full bg-purple-100 px-2 py-0.5 text-[10px] text-purple-500", children: startCase(get(p, b, "")) }) }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "pl-6", children: /* @__PURE__ */ jsxRuntimeExports.jsx(ViewData, { data: get(a, b) }) })
|
|
4869
4934
|
]
|
|
4870
4935
|
},
|
|
4871
|
-
|
|
4936
|
+
b
|
|
4872
4937
|
)) })
|
|
4873
4938
|
] })
|
|
4874
4939
|
] }) })
|
|
@@ -4882,19 +4947,19 @@ const ViewData = ({ data: o, fullView: n }) => {
|
|
|
4882
4947
|
editMode: r,
|
|
4883
4948
|
item: a
|
|
4884
4949
|
}) => {
|
|
4885
|
-
const [l, i] = useState(r ? a.key : ""), [c, d] = useState(r ? a.value : ""),
|
|
4886
|
-
(E,
|
|
4950
|
+
const [l, i] = useState(r ? a.key : ""), [c, d] = useState(r ? a.value : ""), p = useSelectedBlock(), [u] = useChaiExternalData(), m = useCallback(
|
|
4951
|
+
(E, b) => {
|
|
4887
4952
|
if (isEmpty(E))
|
|
4888
4953
|
return "";
|
|
4889
4954
|
{
|
|
4890
|
-
const f = get(
|
|
4955
|
+
const f = get(b === "PROP" ? p : u, E, "");
|
|
4891
4956
|
if (isArray$1(f))
|
|
4892
4957
|
return "list";
|
|
4893
|
-
const
|
|
4894
|
-
return
|
|
4958
|
+
const k = typeof f;
|
|
4959
|
+
return k === "string" ? "text" : k === "object" ? "model" : k;
|
|
4895
4960
|
}
|
|
4896
4961
|
},
|
|
4897
|
-
[
|
|
4962
|
+
[p, u]
|
|
4898
4963
|
), [x, g] = useState(r ? m(a.key, "PROP") : "");
|
|
4899
4964
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
4900
4965
|
/* @__PURE__ */ jsxRuntimeExports.jsxs(DialogHeader, { children: [
|
|
@@ -4911,10 +4976,10 @@ const ViewData = ({ data: o, fullView: n }) => {
|
|
|
4911
4976
|
value: l,
|
|
4912
4977
|
setValue: i,
|
|
4913
4978
|
onChange: (E) => {
|
|
4914
|
-
const
|
|
4915
|
-
i(E), x !==
|
|
4979
|
+
const b = m(E, "PROP");
|
|
4980
|
+
i(E), x !== b && d(""), g(b);
|
|
4916
4981
|
},
|
|
4917
|
-
data:
|
|
4982
|
+
data: p,
|
|
4918
4983
|
dataType: x,
|
|
4919
4984
|
appliedBindings: o
|
|
4920
4985
|
}
|
|
@@ -4929,10 +4994,10 @@ const ViewData = ({ data: o, fullView: n }) => {
|
|
|
4929
4994
|
value: c,
|
|
4930
4995
|
setValue: d,
|
|
4931
4996
|
onChange: (E) => {
|
|
4932
|
-
const
|
|
4933
|
-
d(x ===
|
|
4997
|
+
const b = m(E, "PATH");
|
|
4998
|
+
d(x === b ? E : "");
|
|
4934
4999
|
},
|
|
4935
|
-
data:
|
|
5000
|
+
data: u,
|
|
4936
5001
|
dataType: x,
|
|
4937
5002
|
appliedBindings: o
|
|
4938
5003
|
}
|
|
@@ -4959,8 +5024,8 @@ const ViewData = ({ data: o, fullView: n }) => {
|
|
|
4959
5024
|
item: i,
|
|
4960
5025
|
editMode: l,
|
|
4961
5026
|
appliedBindings: a,
|
|
4962
|
-
onAddBinding: (
|
|
4963
|
-
r(
|
|
5027
|
+
onAddBinding: (p) => {
|
|
5028
|
+
r(p), d(!1);
|
|
4964
5029
|
}
|
|
4965
5030
|
}
|
|
4966
5031
|
) })
|
|
@@ -4973,18 +5038,18 @@ const ViewData = ({ data: o, fullView: n }) => {
|
|
|
4973
5038
|
dataProvider: l,
|
|
4974
5039
|
appliedBindings: i
|
|
4975
5040
|
}) => {
|
|
4976
|
-
const [c, d] = useState("string"),
|
|
4977
|
-
if (isEmpty(
|
|
5041
|
+
const [c, d] = useState("string"), p = (u, m) => {
|
|
5042
|
+
if (isEmpty(u))
|
|
4978
5043
|
return "";
|
|
4979
5044
|
{
|
|
4980
|
-
const x = get(m === "PROP" ? a : l,
|
|
5045
|
+
const x = get(m === "PROP" ? a : l, u, "");
|
|
4981
5046
|
if (isArray$1(x))
|
|
4982
5047
|
return "list";
|
|
4983
5048
|
const g = typeof x;
|
|
4984
5049
|
return g === "string" ? "text" : g === "object" ? "model" : g;
|
|
4985
5050
|
}
|
|
4986
5051
|
};
|
|
4987
|
-
return useEffect(() => d(() =>
|
|
5052
|
+
return useEffect(() => d(() => p(o.key, "PROP")), [o.key]), /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "relative flex flex-col rounded-md border border-border p-2", children: [
|
|
4988
5053
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-sm font-normal text-gray-500", children: o.key }),
|
|
4989
5054
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "font-medium leading-5", children: o.value }),
|
|
4990
5055
|
/* @__PURE__ */ jsxRuntimeExports.jsx(ViewData, { data: get(l, o.value, "") }),
|
|
@@ -5014,11 +5079,11 @@ const ViewData = ({ data: o, fullView: n }) => {
|
|
|
5014
5079
|
return !1;
|
|
5015
5080
|
const x = last(i);
|
|
5016
5081
|
return isEmpty(x == null ? void 0 : x.key) || isEmpty(x == null ? void 0 : x.value);
|
|
5017
|
-
}, [a, i]),
|
|
5082
|
+
}, [a, i]), p = (x) => {
|
|
5018
5083
|
const g = filter(i, (E) => E.key !== x.key);
|
|
5019
5084
|
c([...g, x]), m([...g, x]);
|
|
5020
|
-
},
|
|
5021
|
-
const g = filter(i, (E,
|
|
5085
|
+
}, u = (x) => {
|
|
5086
|
+
const g = filter(i, (E, b) => x !== b);
|
|
5022
5087
|
m([...g]);
|
|
5023
5088
|
}, m = useCallback(
|
|
5024
5089
|
(x = []) => {
|
|
@@ -5042,8 +5107,8 @@ const ViewData = ({ data: o, fullView: n }) => {
|
|
|
5042
5107
|
NewDataBindingPair,
|
|
5043
5108
|
{
|
|
5044
5109
|
item: x,
|
|
5045
|
-
onAddBinding:
|
|
5046
|
-
onRemove: () =>
|
|
5110
|
+
onAddBinding: p,
|
|
5111
|
+
onRemove: () => u(g),
|
|
5047
5112
|
selectedBlock: r,
|
|
5048
5113
|
dataProvider: a,
|
|
5049
5114
|
appliedBindings: map(i, "key")
|
|
@@ -5056,7 +5121,7 @@ const ViewData = ({ data: o, fullView: n }) => {
|
|
|
5056
5121
|
{
|
|
5057
5122
|
disabled: d,
|
|
5058
5123
|
appliedBindings: map(i, "key"),
|
|
5059
|
-
onAddBinding:
|
|
5124
|
+
onAddBinding: p,
|
|
5060
5125
|
children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
5061
5126
|
"span",
|
|
5062
5127
|
{
|
|
@@ -5137,7 +5202,7 @@ const ViewData = ({ data: o, fullView: n }) => {
|
|
|
5137
5202
|
}
|
|
5138
5203
|
)
|
|
5139
5204
|
] });
|
|
5140
|
-
}, UnsplashImages = React__default.lazy(() => import("./UnsplashImages-
|
|
5205
|
+
}, UnsplashImages = React__default.lazy(() => import("./UnsplashImages-OH1oIK1z.js")), UploadImages = React__default.lazy(() => import("./UploadImages-Yom319eJ.js")), ImagesPanel = ({
|
|
5141
5206
|
isModalView: o = !1,
|
|
5142
5207
|
onSelect: n = () => {
|
|
5143
5208
|
}
|
|
@@ -5147,7 +5212,7 @@ const ViewData = ({ data: o, fullView: n }) => {
|
|
|
5147
5212
|
);
|
|
5148
5213
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex h-full flex-col", children: [
|
|
5149
5214
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-between rounded-md bg-background/30 p-1", children: /* @__PURE__ */ jsxRuntimeExports.jsx("h1", { className: "px-1 font-semibold", children: o && l ? "Unsplash images" : o ? "Select or upload images" : "Images" }) }),
|
|
5150
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs(Tabs, { value: c, onValueChange: (
|
|
5215
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(Tabs, { value: c, onValueChange: (p) => d(p), className: "flex h-full w-full flex-col py-2", children: [
|
|
5151
5216
|
!(l || i) && /* @__PURE__ */ jsxRuntimeExports.jsxs(TabsList, { className: "w-full", children: [
|
|
5152
5217
|
/* @__PURE__ */ jsxRuntimeExports.jsx(TabsTrigger, { value: "upload", className: "w-full", children: "Upload" }),
|
|
5153
5218
|
/* @__PURE__ */ jsxRuntimeExports.jsx(TabsTrigger, { value: "unsplash", className: "w-full", children: "Unsplash" })
|
|
@@ -5184,8 +5249,8 @@ const ImagePickerModal$1 = ImagePickerModal, ImagePickerField = ({ value: o, onC
|
|
|
5184
5249
|
className: "text-xs",
|
|
5185
5250
|
placeholder: c("enter_image_url"),
|
|
5186
5251
|
value: o,
|
|
5187
|
-
onBlur: ({ target: { value:
|
|
5188
|
-
onChange: (
|
|
5252
|
+
onBlur: ({ target: { value: p } }) => a(r, p),
|
|
5253
|
+
onChange: (p) => n(p.target.value)
|
|
5189
5254
|
}
|
|
5190
5255
|
)
|
|
5191
5256
|
] })
|
|
@@ -5227,25 +5292,25 @@ const ImagePickerModal$1 = ImagePickerModal, ImagePickerField = ({ value: o, onC
|
|
|
5227
5292
|
}
|
|
5228
5293
|
);
|
|
5229
5294
|
}, LinkField = ({ schema: o, formData: n, onChange: r }) => {
|
|
5230
|
-
const [a, l] = useState([]), i = useBuilderProp("getPages", () => []), { type: c = "page", href: d = "", target:
|
|
5295
|
+
const [a, l] = useState([]), i = useBuilderProp("getPages", () => []), { type: c = "page", href: d = "", target: p = "self" } = n;
|
|
5231
5296
|
return useEffect(() => {
|
|
5232
5297
|
(async () => {
|
|
5233
|
-
const
|
|
5234
|
-
l(
|
|
5298
|
+
const u = await i();
|
|
5299
|
+
l(u || []);
|
|
5235
5300
|
})();
|
|
5236
5301
|
}, []), /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
|
|
5237
5302
|
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-xs font-medium", children: (o == null ? void 0 : o.title) ?? "Link" }),
|
|
5238
5303
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-y-1.5", children: [
|
|
5239
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("select", { name: "type", value: c, onChange: (
|
|
5304
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("select", { name: "type", value: c, onChange: (u) => r({ ...n, type: u.target.value }), children: [
|
|
5240
5305
|
{ const: "page", title: "Open Page" },
|
|
5241
5306
|
{ const: "url", title: "Open URL" },
|
|
5242
5307
|
{ const: "email", title: "Compose Email" },
|
|
5243
5308
|
{ const: "telephone", title: "Call Phone" },
|
|
5244
5309
|
{ const: "scroll", title: "Scroll to element" }
|
|
5245
|
-
].map((
|
|
5246
|
-
c === "page" ? /* @__PURE__ */ jsxRuntimeExports.jsxs("select", { name: "href", value: d, onChange: (
|
|
5310
|
+
].map((u) => /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: u.const, children: u.title }, u.const)) }),
|
|
5311
|
+
c === "page" ? /* @__PURE__ */ jsxRuntimeExports.jsxs("select", { name: "href", value: d, onChange: (u) => r({ ...n, href: u.target.value || "#" }), children: [
|
|
5247
5312
|
/* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "", children: "Choose page" }),
|
|
5248
|
-
map(a, (
|
|
5313
|
+
map(a, (u) => /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: u.slug, children: u.name }, u.uuid))
|
|
5249
5314
|
] }) : /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
5250
5315
|
"input",
|
|
5251
5316
|
{
|
|
@@ -5255,7 +5320,7 @@ const ImagePickerModal$1 = ImagePickerModal, ImagePickerField = ({ value: o, onC
|
|
|
5255
5320
|
name: "href",
|
|
5256
5321
|
type: "text",
|
|
5257
5322
|
value: d,
|
|
5258
|
-
onChange: (
|
|
5323
|
+
onChange: (u) => r({ ...n, href: u.target.value || "#" }),
|
|
5259
5324
|
placeholder: c === "page" || c === "url" ? "Enter URL" : c === "scroll" ? "#ElementID" : "Enter detail"
|
|
5260
5325
|
}
|
|
5261
5326
|
),
|
|
@@ -5267,9 +5332,9 @@ const ImagePickerModal$1 = ImagePickerModal, ImagePickerField = ({ value: o, onC
|
|
|
5267
5332
|
autoCorrect: "off",
|
|
5268
5333
|
spellCheck: "false",
|
|
5269
5334
|
type: "checkbox",
|
|
5270
|
-
defaultChecked:
|
|
5335
|
+
defaultChecked: p === "_blank",
|
|
5271
5336
|
className: "!w-fit cursor-pointer rounded-md border border-border",
|
|
5272
|
-
onChange: () => r({ ...n, target:
|
|
5337
|
+
onChange: () => r({ ...n, target: p === "_blank" ? "_self" : "_blank" })
|
|
5273
5338
|
}
|
|
5274
5339
|
),
|
|
5275
5340
|
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "pt-1 text-xs", children: "Open in new tab" })
|
|
@@ -5281,8 +5346,8 @@ const ImagePickerModal$1 = ImagePickerModal, ImagePickerField = ({ value: o, onC
|
|
|
5281
5346
|
if (typeof window > "u")
|
|
5282
5347
|
return null;
|
|
5283
5348
|
const i = o.replace("root.", ""), c = get(l, i, ""), d = () => {
|
|
5284
|
-
const
|
|
5285
|
-
a({ blockId:
|
|
5349
|
+
const p = l == null ? void 0 : l._id;
|
|
5350
|
+
a({ blockId: p, blockProp: i, placeholder: n, initialCode: get(l, i, c) });
|
|
5286
5351
|
};
|
|
5287
5352
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mt-2 flex flex-col gap-y-1", children: [
|
|
5288
5353
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
@@ -5296,19 +5361,19 @@ const ImagePickerModal$1 = ImagePickerModal, ImagePickerField = ({ value: o, onC
|
|
|
5296
5361
|
/* @__PURE__ */ jsxRuntimeExports.jsx(Button, { onClick: d, size: "sm", variant: "outline", className: "w-fit", children: r("Open code editor") })
|
|
5297
5362
|
] });
|
|
5298
5363
|
}, JSONForm = memo(({ id: o, properties: n, formData: r, onChange: a }) => {
|
|
5299
|
-
const [l, i] = useState(r), c = { type: "object", properties: {} }, d = {}, { t:
|
|
5300
|
-
Object.keys(n).forEach((
|
|
5301
|
-
const f = n[
|
|
5364
|
+
const [l, i] = useState(r), c = { type: "object", properties: {} }, d = {}, { t: p } = useTranslation(), { selectedLang: u, fallbackLang: m, languages: x } = useLanguages(), g = x.length === 0 ? "" : u.length ? u : m;
|
|
5365
|
+
Object.keys(n).forEach((b) => {
|
|
5366
|
+
const f = n[b];
|
|
5302
5367
|
if (includes(["slot", "styles"], f.type))
|
|
5303
5368
|
return;
|
|
5304
|
-
const
|
|
5305
|
-
c.properties[
|
|
5369
|
+
const k = b;
|
|
5370
|
+
c.properties[k] = getBlockJSONFromSchemas(f, p, g), d[k] = getBlockJSONFromUISchemas(f);
|
|
5306
5371
|
}), useEffect(() => {
|
|
5307
5372
|
i(r);
|
|
5308
|
-
}, [o,
|
|
5373
|
+
}, [o, u]);
|
|
5309
5374
|
const E = useThrottledCallback(
|
|
5310
|
-
async ({ formData:
|
|
5311
|
-
a({ formData:
|
|
5375
|
+
async ({ formData: b }, f) => {
|
|
5376
|
+
a({ formData: b }, f);
|
|
5312
5377
|
},
|
|
5313
5378
|
[a],
|
|
5314
5379
|
1e3
|
|
@@ -5334,8 +5399,8 @@ const ImagePickerModal$1 = ImagePickerModal, ImagePickerField = ({ value: o, onC
|
|
|
5334
5399
|
uiSchema: d,
|
|
5335
5400
|
schema: c,
|
|
5336
5401
|
formData: l,
|
|
5337
|
-
onChange: ({ formData:
|
|
5338
|
-
f && (i(
|
|
5402
|
+
onChange: ({ formData: b }, f) => {
|
|
5403
|
+
f && (i(b), E({ formData: b }, f));
|
|
5339
5404
|
}
|
|
5340
5405
|
}
|
|
5341
5406
|
);
|
|
@@ -5357,7 +5422,7 @@ const ImagePickerModal$1 = ImagePickerModal, ImagePickerField = ({ value: o, onC
|
|
|
5357
5422
|
id: "show-on-canvas",
|
|
5358
5423
|
checked: c,
|
|
5359
5424
|
onCheckedChange: (d) => {
|
|
5360
|
-
d ? (n((
|
|
5425
|
+
d ? (n((p) => [...p, r._id]), a([r._id])) : n((p) => p.filter((u) => u !== r._id));
|
|
5361
5426
|
}
|
|
5362
5427
|
}
|
|
5363
5428
|
),
|
|
@@ -5404,32 +5469,32 @@ const ImagePickerModal$1 = ImagePickerModal, ImagePickerField = ({ value: o, onC
|
|
|
5404
5469
|
}), a;
|
|
5405
5470
|
};
|
|
5406
5471
|
function BlockSettings() {
|
|
5407
|
-
const { selectedLang: o } = useLanguages(), n = useSelectedBlock(), r = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), l = getBlockComponent(n == null ? void 0 : n._type), i = formDataWithSelectedLang(n, o, l), [c, d] = useState(i),
|
|
5408
|
-
if (
|
|
5409
|
-
const
|
|
5410
|
-
a([n._id], { [
|
|
5472
|
+
const { selectedLang: o } = useLanguages(), n = useSelectedBlock(), r = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), l = getBlockComponent(n == null ? void 0 : n._type), i = formDataWithSelectedLang(n, o, l), [c, d] = useState(i), p = useBuilderProp("dataBindingSupport", !1), u = ({ formData: f }, k, _) => {
|
|
5473
|
+
if (k && (c == null ? void 0 : c._id) === n._id) {
|
|
5474
|
+
const C = k.replace("root.", "");
|
|
5475
|
+
a([n._id], { [C]: get(f, C) }, _);
|
|
5411
5476
|
}
|
|
5412
5477
|
}, m = useCallback(
|
|
5413
|
-
debounce(({ formData: f },
|
|
5414
|
-
|
|
5478
|
+
debounce(({ formData: f }, k, _) => {
|
|
5479
|
+
u({ formData: f }, k, _), d(f);
|
|
5415
5480
|
}, 1500),
|
|
5416
5481
|
[n == null ? void 0 : n._id, o]
|
|
5417
|
-
), x = ({ formData: f },
|
|
5418
|
-
if (
|
|
5419
|
-
const
|
|
5482
|
+
), x = ({ formData: f }, k) => {
|
|
5483
|
+
if (k) {
|
|
5484
|
+
const _ = k.replace("root.", "");
|
|
5420
5485
|
r(
|
|
5421
5486
|
[n._id],
|
|
5422
|
-
convertDotNotationToObject(
|
|
5423
|
-
), m({ formData: f },
|
|
5487
|
+
convertDotNotationToObject(_, get(f, _.split(".")))
|
|
5488
|
+
), m({ formData: f }, k, { [_]: get(c, _) });
|
|
5424
5489
|
}
|
|
5425
5490
|
}, g = keys(get(i, "_bindings", {})), E = useMemo(() => {
|
|
5426
5491
|
const f = cloneDeep(get(l, "props", {}));
|
|
5427
|
-
return each(f, (
|
|
5428
|
-
get(
|
|
5429
|
-
}),
|
|
5430
|
-
}, [l, g,
|
|
5492
|
+
return each(f, (k, _) => {
|
|
5493
|
+
get(k, "hidden", !1) && delete f[_];
|
|
5494
|
+
}), p && each(g, (k) => delete f[k]), f;
|
|
5495
|
+
}, [l, g, p]), b = get(l, "server", !1);
|
|
5431
5496
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "overflow-x-hidden px-px", children: [
|
|
5432
|
-
|
|
5497
|
+
p ? /* @__PURE__ */ jsxRuntimeExports.jsxs(Accordion, { type: "multiple", defaultValue: ["STATIC", "BINDING"], className: "mt-4 h-full w-full", children: [
|
|
5433
5498
|
/* @__PURE__ */ jsxRuntimeExports.jsxs(AccordionItem, { value: "BINDING", children: [
|
|
5434
5499
|
/* @__PURE__ */ jsxRuntimeExports.jsx(AccordionTrigger, { className: "py-2", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-x-2", children: [
|
|
5435
5500
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
@@ -5445,7 +5510,7 @@ function BlockSettings() {
|
|
|
5445
5510
|
{
|
|
5446
5511
|
bindingData: get(n, "_bindings", {}),
|
|
5447
5512
|
onChange: (f) => {
|
|
5448
|
-
|
|
5513
|
+
u({ formData: { _bindings: f } }, "root._bindings");
|
|
5449
5514
|
}
|
|
5450
5515
|
}
|
|
5451
5516
|
) })
|
|
@@ -5484,7 +5549,7 @@ function BlockSettings() {
|
|
|
5484
5549
|
}
|
|
5485
5550
|
),
|
|
5486
5551
|
(n == null ? void 0 : n._type) === "GlobalBlock" ? /* @__PURE__ */ jsxRuntimeExports.jsx(GlobalBlockSettings, {}) : null,
|
|
5487
|
-
|
|
5552
|
+
b ? /* @__PURE__ */ jsxRuntimeExports.jsx(ResetRSCBlockButton, { blockId: n == null ? void 0 : n._id }) : null,
|
|
5488
5553
|
/* @__PURE__ */ jsxRuntimeExports.jsx(CanvasSettings, {})
|
|
5489
5554
|
] });
|
|
5490
5555
|
}
|
|
@@ -5508,25 +5573,25 @@ function promptWithLanguage(o, n, r) {
|
|
|
5508
5573
|
${a}`;
|
|
5509
5574
|
}
|
|
5510
5575
|
const askAiProcessingAtom = atom$1(!1), useAskAi = () => {
|
|
5511
|
-
const [o, n] = useAtom$1(askAiProcessingAtom), [r, a] = useState(null), l = useBuilderProp("askAiCallBack", null), i = useStreamMultipleBlocksProps(), c = useUpdateMultipleBlocksProps(), [d] = useBlocksStore(), { selectedLang:
|
|
5576
|
+
const [o, n] = useAtom$1(askAiProcessingAtom), [r, a] = useState(null), l = useBuilderProp("askAiCallBack", null), i = useStreamMultipleBlocksProps(), c = useUpdateMultipleBlocksProps(), [d] = useBlocksStore(), { selectedLang: p, fallbackLang: u } = useLanguages(), m = p.length ? p : u;
|
|
5512
5577
|
return {
|
|
5513
5578
|
askAi: useCallback(
|
|
5514
|
-
async (x, g, E,
|
|
5579
|
+
async (x, g, E, b) => {
|
|
5515
5580
|
if (l) {
|
|
5516
5581
|
n(!0), a(null);
|
|
5517
5582
|
try {
|
|
5518
|
-
const f = x === "content" ? cloneDeep(getBlockWithChildren(g, d)) : [cloneDeep(d.find((
|
|
5583
|
+
const f = x === "content" ? cloneDeep(getBlockWithChildren(g, d)) : [cloneDeep(d.find((R) => R._id === g))];
|
|
5519
5584
|
set(f, "0._parent", null);
|
|
5520
|
-
const
|
|
5585
|
+
const k = p === u ? "" : p, _ = await l(x, promptWithLanguage(E, m, x), f, k), { blocks: C, error: B } = _;
|
|
5521
5586
|
if (B) {
|
|
5522
5587
|
a(B);
|
|
5523
5588
|
return;
|
|
5524
5589
|
}
|
|
5525
|
-
x === "styles" ? c(
|
|
5590
|
+
x === "styles" ? c(C) : i(C), b && b(_);
|
|
5526
5591
|
} catch (f) {
|
|
5527
5592
|
a(f);
|
|
5528
5593
|
} finally {
|
|
5529
|
-
n(!1),
|
|
5594
|
+
n(!1), b && b();
|
|
5530
5595
|
}
|
|
5531
5596
|
}
|
|
5532
5597
|
},
|
|
@@ -5534,8 +5599,8 @@ const askAiProcessingAtom = atom$1(!1), useAskAi = () => {
|
|
|
5534
5599
|
l,
|
|
5535
5600
|
n,
|
|
5536
5601
|
d,
|
|
5537
|
-
u,
|
|
5538
5602
|
p,
|
|
5603
|
+
u,
|
|
5539
5604
|
m,
|
|
5540
5605
|
c,
|
|
5541
5606
|
i
|
|
@@ -5562,10 +5627,10 @@ function Countdown() {
|
|
|
5562
5627
|
const [o, n] = useState(SECONDS), [r, a] = useState(!1);
|
|
5563
5628
|
useEffect(() => {
|
|
5564
5629
|
if (r && o > 0) {
|
|
5565
|
-
const
|
|
5630
|
+
const p = setTimeout(() => {
|
|
5566
5631
|
n(o - 0.1);
|
|
5567
5632
|
}, 100);
|
|
5568
|
-
return () => clearTimeout(
|
|
5633
|
+
return () => clearTimeout(p);
|
|
5569
5634
|
} else
|
|
5570
5635
|
o <= 0 && (a(!1), n(SECONDS));
|
|
5571
5636
|
}, [r, o]);
|
|
@@ -5610,14 +5675,14 @@ function Countdown() {
|
|
|
5610
5675
|
] });
|
|
5611
5676
|
}
|
|
5612
5677
|
const AskAIStyles = ({ blockId: o }) => {
|
|
5613
|
-
const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, c] = useState(""), d = useRef(null),
|
|
5678
|
+
const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, c] = useState(""), d = useRef(null), p = useRef(null), [u, m] = useState();
|
|
5614
5679
|
useEffect(() => {
|
|
5615
5680
|
var g;
|
|
5616
5681
|
(g = d.current) == null || g.focus();
|
|
5617
5682
|
}, []);
|
|
5618
5683
|
const x = (g) => {
|
|
5619
5684
|
const { usage: E } = g || {};
|
|
5620
|
-
!l && E && m(E),
|
|
5685
|
+
!l && E && m(E), p.current = setTimeout(() => m(void 0), 1e4), l || c("");
|
|
5621
5686
|
};
|
|
5622
5687
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "", children: [
|
|
5623
5688
|
/* @__PURE__ */ jsxRuntimeExports.jsx("h2", { className: "mb-1 text-sm font-semibold leading-none tracking-tight", children: n("ask_ai") }),
|
|
@@ -5631,7 +5696,7 @@ const AskAIStyles = ({ blockId: o }) => {
|
|
|
5631
5696
|
className: "w-full border border-border focus:border-0",
|
|
5632
5697
|
rows: 3,
|
|
5633
5698
|
onKeyDown: (g) => {
|
|
5634
|
-
g.key === "Enter" && (g.preventDefault(),
|
|
5699
|
+
g.key === "Enter" && (g.preventDefault(), p.current && clearTimeout(p.current), m(void 0), r("styles", o, i, x));
|
|
5635
5700
|
}
|
|
5636
5701
|
}
|
|
5637
5702
|
),
|
|
@@ -5641,7 +5706,7 @@ const AskAIStyles = ({ blockId: o }) => {
|
|
|
5641
5706
|
{
|
|
5642
5707
|
disabled: i.trim().length < 5 || a,
|
|
5643
5708
|
onClick: () => {
|
|
5644
|
-
|
|
5709
|
+
p.current && clearTimeout(p.current), m(void 0), r("styles", o, i, x);
|
|
5645
5710
|
},
|
|
5646
5711
|
variant: "default",
|
|
5647
5712
|
className: "w-fit",
|
|
@@ -5660,11 +5725,11 @@ const AskAIStyles = ({ blockId: o }) => {
|
|
|
5660
5725
|
/* @__PURE__ */ jsxRuntimeExports.jsx(Button, { variant: "destructive", onClick: () => stop(), className: "hidden w-fit", size: "sm", children: n("stop") })
|
|
5661
5726
|
] }) : null
|
|
5662
5727
|
] }),
|
|
5663
|
-
|
|
5728
|
+
u ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "max-w-full", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "mb-1 flex justify-between break-words rounded border border-blue-500 bg-blue-100 p-1 text-xs text-blue-500", children: [
|
|
5664
5729
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("span", { children: [
|
|
5665
5730
|
n("Total tokens used"),
|
|
5666
5731
|
": ",
|
|
5667
|
-
|
|
5732
|
+
u.totalTokens
|
|
5668
5733
|
] }),
|
|
5669
5734
|
/* @__PURE__ */ jsxRuntimeExports.jsx(Countdown, {})
|
|
5670
5735
|
] }) }) : null,
|
|
@@ -5678,24 +5743,24 @@ const AskAIStyles = ({ blockId: o }) => {
|
|
|
5678
5743
|
});
|
|
5679
5744
|
function ManualClasses() {
|
|
5680
5745
|
var A;
|
|
5681
|
-
const { t: o } = useTranslation(), [n] = useSelectedStylingBlocks(), r = useSelectedBlock(), a = useAddClassesToBlocks(), l = useRemoveClassesFromBlocks(), [i] = useSelectedBlockIds(), c = useBuilderProp("askAiCallBack", null), [d,
|
|
5746
|
+
const { t: o } = useTranslation(), [n] = useSelectedStylingBlocks(), r = useSelectedBlock(), a = useAddClassesToBlocks(), l = useRemoveClassesFromBlocks(), [i] = useSelectedBlockIds(), c = useBuilderProp("askAiCallBack", null), [d, p] = useState(""), { toast: u } = useToast(), m = (A = first(n)) == null ? void 0 : A.prop, x = reject((get(r, m, "").replace(STYLES_KEY, "").split(",").pop() || "").split(" "), isEmpty), g = () => {
|
|
5682
5747
|
const N = d.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
|
|
5683
|
-
a(i, N, !0),
|
|
5684
|
-
}, [E,
|
|
5685
|
-
const D = N.trim().toLowerCase(),
|
|
5686
|
-
let
|
|
5687
|
-
if (
|
|
5688
|
-
const [
|
|
5689
|
-
|
|
5690
|
-
...
|
|
5691
|
-
item: { ...
|
|
5748
|
+
a(i, N, !0), p("");
|
|
5749
|
+
}, [E, b] = useState([]), f = ({ value: N }) => {
|
|
5750
|
+
const D = N.trim().toLowerCase(), I = D.match(/.+:/g);
|
|
5751
|
+
let j = [];
|
|
5752
|
+
if (I && I.length > 0) {
|
|
5753
|
+
const [v] = I, w = D.replace(v, "");
|
|
5754
|
+
j = fuse.search(w).map((T) => ({
|
|
5755
|
+
...T,
|
|
5756
|
+
item: { ...T.item, name: v + T.item.name }
|
|
5692
5757
|
}));
|
|
5693
5758
|
} else
|
|
5694
|
-
|
|
5695
|
-
return
|
|
5696
|
-
},
|
|
5697
|
-
|
|
5698
|
-
},
|
|
5759
|
+
j = fuse.search(D);
|
|
5760
|
+
return b(map(j, "item"));
|
|
5761
|
+
}, k = () => {
|
|
5762
|
+
b([]);
|
|
5763
|
+
}, _ = (N) => N.name, C = (N) => /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "rounded-md p-1", children: N.name }), B = {
|
|
5699
5764
|
autoComplete: "off",
|
|
5700
5765
|
autoCorrect: "off",
|
|
5701
5766
|
autoCapitalize: "off",
|
|
@@ -5705,18 +5770,18 @@ function ManualClasses() {
|
|
|
5705
5770
|
onKeyDown: (N) => {
|
|
5706
5771
|
N.key === "Enter" && d.trim() !== "" && g();
|
|
5707
5772
|
},
|
|
5708
|
-
onChange: (N, { newValue: D }) =>
|
|
5773
|
+
onChange: (N, { newValue: D }) => p(D),
|
|
5709
5774
|
className: "w-full rounded-md text-xs px-2 hover:outline-0 bg-background border-border py-1"
|
|
5710
|
-
},
|
|
5775
|
+
}, R = () => {
|
|
5711
5776
|
if (navigator.clipboard === void 0) {
|
|
5712
|
-
|
|
5777
|
+
u({
|
|
5713
5778
|
title: o("clipboard_not_supported"),
|
|
5714
5779
|
description: o("please_use_chrome_firefox_or_safari"),
|
|
5715
5780
|
variant: "destructive"
|
|
5716
5781
|
});
|
|
5717
5782
|
return;
|
|
5718
5783
|
}
|
|
5719
|
-
navigator.clipboard.writeText(x.join(" ")),
|
|
5784
|
+
navigator.clipboard.writeText(x.join(" ")), u({
|
|
5720
5785
|
title: o("copied"),
|
|
5721
5786
|
description: o("classes_copied_to_clipboard")
|
|
5722
5787
|
});
|
|
@@ -5730,7 +5795,7 @@ function ManualClasses() {
|
|
|
5730
5795
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-x-2 text-muted-foreground", children: [
|
|
5731
5796
|
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: o("classes") }),
|
|
5732
5797
|
/* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
|
|
5733
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxRuntimeExports.jsx(CopyIcon, { onClick:
|
|
5798
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxRuntimeExports.jsx(CopyIcon, { onClick: R, className: "cursor-pointer" }) }),
|
|
5734
5799
|
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { children: o("copy_classes_to_clipboard") }) })
|
|
5735
5800
|
] })
|
|
5736
5801
|
] }),
|
|
@@ -5748,9 +5813,9 @@ function ManualClasses() {
|
|
|
5748
5813
|
{
|
|
5749
5814
|
suggestions: E,
|
|
5750
5815
|
onSuggestionsFetchRequested: f,
|
|
5751
|
-
onSuggestionsClearRequested:
|
|
5752
|
-
getSuggestionValue:
|
|
5753
|
-
renderSuggestion:
|
|
5816
|
+
onSuggestionsClearRequested: k,
|
|
5817
|
+
getSuggestionValue: _,
|
|
5818
|
+
renderSuggestion: C,
|
|
5754
5819
|
inputProps: B,
|
|
5755
5820
|
containerProps: {
|
|
5756
5821
|
className: "relative h-8 w-full gap-y-1 py-1 border-border"
|
|
@@ -6090,7 +6155,7 @@ const EDITOR_ICONS = {
|
|
|
6090
6155
|
DropDown,
|
|
6091
6156
|
{
|
|
6092
6157
|
rounded: o,
|
|
6093
|
-
onChange: (
|
|
6158
|
+
onChange: (p) => r(p, n),
|
|
6094
6159
|
selected: i,
|
|
6095
6160
|
options: a,
|
|
6096
6161
|
disabled: !c
|
|
@@ -6104,23 +6169,23 @@ function DropDown({ selected: o, onChange: n, rounded: r = !1, options: a, disab
|
|
|
6104
6169
|
{
|
|
6105
6170
|
disabled: !a.length || l,
|
|
6106
6171
|
className: `${r ? "rounded-md border border-border" : "border-0"} disable:bg-gray-500 h-full w-full truncate rounded bg-background px-2 py-1 text-xs outline-none disabled:cursor-not-allowed`,
|
|
6107
|
-
onChange: (
|
|
6108
|
-
onKeyDown: (
|
|
6109
|
-
|
|
6172
|
+
onChange: (p) => n(p.target.value),
|
|
6173
|
+
onKeyDown: (p) => {
|
|
6174
|
+
p.ctrlKey && (p.key === "z" && c(), p.key === "y" && d());
|
|
6110
6175
|
},
|
|
6111
6176
|
value: i,
|
|
6112
6177
|
children: [
|
|
6113
6178
|
/* @__PURE__ */ jsxRuntimeExports.jsx("option", { className: "bg-transparent", value: "" }),
|
|
6114
6179
|
React__default.Children.toArray(
|
|
6115
|
-
a.map((
|
|
6180
|
+
a.map((p) => /* @__PURE__ */ jsxRuntimeExports.jsx("option", { className: "bg-transparent", value: p, children: p }))
|
|
6116
6181
|
)
|
|
6117
6182
|
]
|
|
6118
6183
|
}
|
|
6119
6184
|
);
|
|
6120
6185
|
}
|
|
6121
6186
|
const RangeChoices = ({ property: o, onChange: n }) => {
|
|
6122
|
-
const { canReset: r, canChange: a } = useContext(StyleContext), l = useCurrentClassByProperty(o), i = useMemo(() => get(l, "cls", ""), [l]), c = useMemo(() => get(CLASSES_LIST, `${o}.classes`, [""]), [o]), d = c.indexOf(i) > -1 ? c.indexOf(i) : 0,
|
|
6123
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-row divide-x divide-solid divide-border rounded border border-border text-xs", children:
|
|
6187
|
+
const { canReset: r, canChange: a } = useContext(StyleContext), l = useCurrentClassByProperty(o), i = useMemo(() => get(l, "cls", ""), [l]), c = useMemo(() => get(CLASSES_LIST, `${o}.classes`, [""]), [o]), d = c.indexOf(i) > -1 ? c.indexOf(i) : 0, p = /\[.*\]/g.test(i);
|
|
6188
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-row divide-x divide-solid divide-border rounded border border-border text-xs", children: p ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "py-[5px] px-2", children: i }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
6124
6189
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
6125
6190
|
"button",
|
|
6126
6191
|
{
|
|
@@ -6181,12 +6246,12 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
6181
6246
|
ringColor: "ring",
|
|
6182
6247
|
ringOffsetColor: "ring-offset"
|
|
6183
6248
|
}, ColorChoice = ({ property: o, onChange: n }) => {
|
|
6184
|
-
const r = useCurrentClassByProperty(o), a = useMemo(() => get(r, "cls", ""), [r]), { canChange: l } = useContext(StyleContext), [i, c] = useState([]), [d,
|
|
6249
|
+
const r = useCurrentClassByProperty(o), a = useMemo(() => get(r, "cls", ""), [r]), { canChange: l } = useContext(StyleContext), [i, c] = useState([]), [d, p] = useState({ color: "", shade: "" }), u = a.split("-"), m = get(u, "1", ""), x = get(u, "2", ""), g = useCallback(
|
|
6185
6250
|
// eslint-disable-next-line no-shadow
|
|
6186
|
-
(
|
|
6187
|
-
["current", "inherit", "transparent", "black", "white"].includes(
|
|
6251
|
+
(b) => {
|
|
6252
|
+
["current", "inherit", "transparent", "black", "white"].includes(b) ? (c([]), p({ color: b })) : (c(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]), p((f) => ({ ...f, color: b, shade: f.shade ? f.shade : "500" })));
|
|
6188
6253
|
},
|
|
6189
|
-
[c,
|
|
6254
|
+
[c, p]
|
|
6190
6255
|
);
|
|
6191
6256
|
useEffect(() => {
|
|
6192
6257
|
if (["current", "inherit", "transparent", "black", "white"].includes(m))
|
|
@@ -6195,13 +6260,13 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
6195
6260
|
}, [m]);
|
|
6196
6261
|
const E = useCallback(
|
|
6197
6262
|
// eslint-disable-next-line no-shadow
|
|
6198
|
-
(
|
|
6199
|
-
|
|
6263
|
+
(b) => {
|
|
6264
|
+
p({ color: m, shade: b });
|
|
6200
6265
|
},
|
|
6201
6266
|
[m]
|
|
6202
6267
|
);
|
|
6203
6268
|
return useEffect(() => {
|
|
6204
|
-
|
|
6269
|
+
p({ color: "", shade: "" });
|
|
6205
6270
|
}, [r]), useEffect(() => {
|
|
6206
6271
|
const f = `${get(COLOR_PROP, o, "")}-${d.color}${d.shade ? `-${d.shade}` : ""}`;
|
|
6207
6272
|
f.match(new RegExp(get(CLASSES_LIST, `${o}.regExp`, ""))) && n(f, o);
|
|
@@ -6409,18 +6474,18 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
6409
6474
|
"button",
|
|
6410
6475
|
{
|
|
6411
6476
|
type: "button",
|
|
6412
|
-
onMouseDown: (
|
|
6413
|
-
const
|
|
6477
|
+
onMouseDown: (p) => {
|
|
6478
|
+
const u = {
|
|
6414
6479
|
onDrag: r,
|
|
6415
6480
|
onDragEnd: a,
|
|
6416
6481
|
dragging: !0,
|
|
6417
|
-
dragStartY:
|
|
6482
|
+
dragStartY: p.pageY,
|
|
6418
6483
|
dragStartValue: `${n}`,
|
|
6419
6484
|
dragUnit: o,
|
|
6420
6485
|
negative: i,
|
|
6421
6486
|
cssProperty: c
|
|
6422
6487
|
};
|
|
6423
|
-
l(
|
|
6488
|
+
l(u), d(u);
|
|
6424
6489
|
},
|
|
6425
6490
|
color: void 0,
|
|
6426
6491
|
className: "relative z-50 ml-1 hidden h-6 cursor-row-resize rounded bg-background/70 px-2 group-hover:inline",
|
|
@@ -6440,50 +6505,50 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
6440
6505
|
},
|
|
6441
6506
|
a
|
|
6442
6507
|
)) }), THROTTLE_TIME = 50, AdvanceChoices = (o) => {
|
|
6443
|
-
const [n, r] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty:
|
|
6508
|
+
const [n, r] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: m } = o, [x, g] = useState(p != null && p.toLowerCase().includes("width") ? "%" : u[0]), [E, b] = useState(!1), [f, k] = useState(""), [_, C] = useState(!1), [B, R] = useState(!1);
|
|
6444
6509
|
useEffect(() => {
|
|
6445
|
-
const { value:
|
|
6446
|
-
if (
|
|
6447
|
-
l(
|
|
6510
|
+
const { value: j, unit: v } = getClassValueAndUnit(i);
|
|
6511
|
+
if (v === "") {
|
|
6512
|
+
l(j), g(p != null && p.toLowerCase().includes("width") ? "%" : first(u));
|
|
6448
6513
|
return;
|
|
6449
6514
|
}
|
|
6450
|
-
g(
|
|
6451
|
-
}, [i,
|
|
6452
|
-
const A = useThrottledCallback((
|
|
6453
|
-
(
|
|
6454
|
-
const
|
|
6455
|
-
if (get(
|
|
6456
|
-
|
|
6515
|
+
g(v), l(v === "class" || isEmpty(j) ? "" : j);
|
|
6516
|
+
}, [i, p, u]);
|
|
6517
|
+
const A = useThrottledCallback((j) => c(j), [c], THROTTLE_TIME), N = useThrottledCallback((j) => c(j, !1), [c], THROTTLE_TIME), D = useCallback(
|
|
6518
|
+
(j = !1) => {
|
|
6519
|
+
const v = getUserInputValues(`${a}`, u);
|
|
6520
|
+
if (get(v, "error", !1)) {
|
|
6521
|
+
b(!0);
|
|
6457
6522
|
return;
|
|
6458
6523
|
}
|
|
6459
|
-
const
|
|
6460
|
-
if (
|
|
6461
|
-
A(`${d}${
|
|
6524
|
+
const w = get(v, "unit") !== "" ? get(v, "unit") : x;
|
|
6525
|
+
if (w === "auto" || w === "none") {
|
|
6526
|
+
A(`${d}${w}`);
|
|
6462
6527
|
return;
|
|
6463
6528
|
}
|
|
6464
|
-
if (get(
|
|
6529
|
+
if (get(v, "value") === "")
|
|
6465
6530
|
return;
|
|
6466
|
-
const
|
|
6467
|
-
|
|
6531
|
+
const T = `${get(v, "value", "").startsWith("-") ? "-" : ""}${d}[${get(v, "value", "").replace("-", "")}${w === "-" ? "" : w}]`;
|
|
6532
|
+
j ? N(T) : A(T);
|
|
6468
6533
|
},
|
|
6469
|
-
[A, N, a, x, d,
|
|
6470
|
-
),
|
|
6471
|
-
(
|
|
6472
|
-
const
|
|
6473
|
-
if (get(
|
|
6474
|
-
|
|
6534
|
+
[A, N, a, x, d, u]
|
|
6535
|
+
), I = useCallback(
|
|
6536
|
+
(j) => {
|
|
6537
|
+
const v = getUserInputValues(`${a}`, u);
|
|
6538
|
+
if (get(v, "error", !1)) {
|
|
6539
|
+
b(!0);
|
|
6475
6540
|
return;
|
|
6476
6541
|
}
|
|
6477
|
-
if (
|
|
6478
|
-
A(`${d}${
|
|
6542
|
+
if (j === "auto" || j === "none") {
|
|
6543
|
+
A(`${d}${j}`);
|
|
6479
6544
|
return;
|
|
6480
6545
|
}
|
|
6481
|
-
if (get(
|
|
6546
|
+
if (get(v, "value") === "")
|
|
6482
6547
|
return;
|
|
6483
|
-
const
|
|
6484
|
-
A(
|
|
6548
|
+
const w = get(v, "unit") !== "" ? get(v, "unit") : j, T = `${get(v, "value", "").startsWith("-") ? "-" : ""}${d}[${get(v, "value", "").replace("-", "")}${w === "-" ? "" : w}]`;
|
|
6549
|
+
A(T);
|
|
6485
6550
|
},
|
|
6486
|
-
[A, a, d,
|
|
6551
|
+
[A, a, d, u]
|
|
6487
6552
|
);
|
|
6488
6553
|
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex w-full flex-col", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-start", children: x === "class" ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
6489
6554
|
/* @__PURE__ */ jsxRuntimeExports.jsx("input", { className: "w-20 rounded py-1", readOnly: !0, value: i }),
|
|
@@ -6491,37 +6556,37 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
6491
6556
|
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxRuntimeExports.jsx("button", { type: "button", className: "invisible ml-3 mt-1 text-blue-600 group-hover:visible", children: /* @__PURE__ */ jsxRuntimeExports.jsx(InfoCircledIcon, {}) }) }),
|
|
6492
6557
|
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { children: "Current value is using a Tailwind preset class." })
|
|
6493
6558
|
] })
|
|
6494
|
-
] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: `group relative flex items-center ${
|
|
6559
|
+
] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: `group relative flex items-center ${_ ? "z-auto" : ""}`, children: [
|
|
6495
6560
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center rounded-md border border-border", children: [
|
|
6496
6561
|
["none", "auto"].indexOf(x) !== -1 ? null : /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
6497
6562
|
"input",
|
|
6498
6563
|
{
|
|
6499
6564
|
readOnly: x === "class",
|
|
6500
|
-
onKeyPress: (
|
|
6501
|
-
|
|
6565
|
+
onKeyPress: (j) => {
|
|
6566
|
+
j.key === "Enter" && D();
|
|
6502
6567
|
},
|
|
6503
|
-
onKeyDown: (
|
|
6504
|
-
if (
|
|
6568
|
+
onKeyDown: (j) => {
|
|
6569
|
+
if (j.keyCode !== 38 && j.keyCode !== 40)
|
|
6505
6570
|
return;
|
|
6506
|
-
|
|
6507
|
-
const
|
|
6508
|
-
let
|
|
6509
|
-
|
|
6510
|
-
const
|
|
6571
|
+
j.preventDefault(), R(!0);
|
|
6572
|
+
const v = parseInt$1(j.target.value);
|
|
6573
|
+
let w = isNaN$1(v) ? 0 : v;
|
|
6574
|
+
j.keyCode === 38 && (w += 1), j.keyCode === 40 && (w -= 1);
|
|
6575
|
+
const S = `${w}`, L = `${S.startsWith("-") ? "-" : ""}${d}[${S.replace("-", "")}${x === "-" ? "" : x}]`;
|
|
6511
6576
|
N(L);
|
|
6512
6577
|
},
|
|
6513
|
-
onKeyUp: (
|
|
6514
|
-
B && (
|
|
6578
|
+
onKeyUp: (j) => {
|
|
6579
|
+
B && (j.preventDefault(), R(!1));
|
|
6515
6580
|
},
|
|
6516
6581
|
onBlur: () => D(),
|
|
6517
|
-
onChange: (
|
|
6518
|
-
|
|
6582
|
+
onChange: (j) => {
|
|
6583
|
+
b(!1), l(j.target.value);
|
|
6519
6584
|
},
|
|
6520
|
-
onClick: (
|
|
6521
|
-
var
|
|
6522
|
-
(
|
|
6585
|
+
onClick: (j) => {
|
|
6586
|
+
var v;
|
|
6587
|
+
(v = j == null ? void 0 : j.target) == null || v.select(), r(!1);
|
|
6523
6588
|
},
|
|
6524
|
-
value:
|
|
6589
|
+
value: _ ? f : a,
|
|
6525
6590
|
className: "h-6 w-14 rounded rounded-r-none border border-transparent bg-background pl-2 text-sm focus-visible:outline-0".concat(
|
|
6526
6591
|
" ",
|
|
6527
6592
|
E ? "border-red-500 text-red-500" : "border-foreground/20"
|
|
@@ -6536,44 +6601,44 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
6536
6601
|
onClick: () => r(!n),
|
|
6537
6602
|
className: "flex h-6 cursor-pointer items-center gap-x-1 rounded rounded-l-none bg-background p-px px-1 text-[11px] uppercase",
|
|
6538
6603
|
children: [
|
|
6539
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: `inline-block ${
|
|
6540
|
-
|
|
6604
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: `inline-block ${u.length === 1 ? "px-2 font-semibold" : ""}`, children: x }),
|
|
6605
|
+
u.length > 1 ? /* @__PURE__ */ jsxRuntimeExports.jsx(TriangleDownIcon, {}) : null
|
|
6541
6606
|
]
|
|
6542
6607
|
}
|
|
6543
6608
|
) }),
|
|
6544
6609
|
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipPortal, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { className: "bg-background", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
6545
6610
|
UnitSelection,
|
|
6546
6611
|
{
|
|
6547
|
-
units:
|
|
6612
|
+
units: u,
|
|
6548
6613
|
current: x,
|
|
6549
|
-
onSelect: (
|
|
6550
|
-
r(!1), g(
|
|
6614
|
+
onSelect: (j) => {
|
|
6615
|
+
r(!1), g(j), I(j);
|
|
6551
6616
|
}
|
|
6552
6617
|
}
|
|
6553
6618
|
) }) })
|
|
6554
6619
|
] })
|
|
6555
6620
|
] }),
|
|
6556
|
-
["none", "auto"].indexOf(x) !== -1 ||
|
|
6621
|
+
["none", "auto"].indexOf(x) !== -1 || _ ? null : /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
6557
6622
|
DragStyleButton,
|
|
6558
6623
|
{
|
|
6559
|
-
onDragStart: () =>
|
|
6560
|
-
onDragEnd: (
|
|
6561
|
-
if (
|
|
6624
|
+
onDragStart: () => C(!0),
|
|
6625
|
+
onDragEnd: (j) => {
|
|
6626
|
+
if (k(() => ""), C(!1), isEmpty(j))
|
|
6562
6627
|
return;
|
|
6563
|
-
const
|
|
6564
|
-
A(
|
|
6628
|
+
const v = `${j}`, S = `${v.startsWith("-") ? "-" : ""}${d}[${v.replace("-", "")}${x === "-" ? "" : x}]`;
|
|
6629
|
+
A(S);
|
|
6565
6630
|
},
|
|
6566
|
-
onDrag: (
|
|
6567
|
-
if (isEmpty(
|
|
6631
|
+
onDrag: (j) => {
|
|
6632
|
+
if (isEmpty(j))
|
|
6568
6633
|
return;
|
|
6569
|
-
|
|
6570
|
-
const
|
|
6571
|
-
N(
|
|
6634
|
+
k(j);
|
|
6635
|
+
const v = `${j}`, S = `${v.startsWith("-") ? "-" : ""}${d}[${v.replace("-", "")}${x === "-" ? "" : x}]`;
|
|
6636
|
+
N(S);
|
|
6572
6637
|
},
|
|
6573
6638
|
currentValue: a,
|
|
6574
6639
|
unit: x,
|
|
6575
6640
|
negative: m,
|
|
6576
|
-
cssProperty:
|
|
6641
|
+
cssProperty: p
|
|
6577
6642
|
}
|
|
6578
6643
|
)
|
|
6579
6644
|
] }) }) });
|
|
@@ -6665,21 +6730,21 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
6665
6730
|
"2xl": "1536px"
|
|
6666
6731
|
}, getBreakpoint = (o) => `${o.toUpperCase()} ${BREAKPOINTS[o] ? `(${BREAKPOINTS[o]} & up)` : ""}`, BlockStyle = (o) => {
|
|
6667
6732
|
const { t: n } = useTranslation(), { type: r = "icons", label: a, property: l, onEmitChange: i = () => {
|
|
6668
|
-
}, units: c, negative: d = !1 } = o, [
|
|
6733
|
+
}, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, m] = useCanvasWidth(), x = useCurrentClassByProperty(l), g = useAddClassesToBlocks(), E = useRemoveClassesFromBlocks(), [b] = useSelectedBlockIds(), f = useMemo(() => get(x, "fullCls", ""), [x]), k = useCallback(
|
|
6669
6734
|
(N, D = !0) => {
|
|
6670
|
-
const
|
|
6671
|
-
(
|
|
6672
|
-
const
|
|
6673
|
-
g(
|
|
6735
|
+
const I = { dark: p, mq: m, mod: u, cls: N, property: l, fullCls: "" };
|
|
6736
|
+
(p || u !== "") && (I.mq = "xs");
|
|
6737
|
+
const j = generateFullClsName(I);
|
|
6738
|
+
g(b, [j], D);
|
|
6674
6739
|
},
|
|
6675
|
-
[
|
|
6676
|
-
),
|
|
6677
|
-
E(
|
|
6678
|
-
}, [
|
|
6740
|
+
[b, p, m, u, l, g]
|
|
6741
|
+
), _ = useCallback(() => {
|
|
6742
|
+
E(b, [f]);
|
|
6743
|
+
}, [b, f, E]), C = useMemo(() => canChangeClass(x, m), [x, m]);
|
|
6679
6744
|
useEffect(() => {
|
|
6680
|
-
i(
|
|
6681
|
-
}, [
|
|
6682
|
-
const [, , B] = useCanvasWidth(),
|
|
6745
|
+
i(C, x);
|
|
6746
|
+
}, [C, i, x]);
|
|
6747
|
+
const [, , B] = useCanvasWidth(), R = useCallback(
|
|
6683
6748
|
(N) => {
|
|
6684
6749
|
B({
|
|
6685
6750
|
xs: 400,
|
|
@@ -6691,8 +6756,8 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
6691
6756
|
}[N]);
|
|
6692
6757
|
},
|
|
6693
6758
|
[B]
|
|
6694
|
-
), A = get(x, "dark", null) ===
|
|
6695
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(BlockStyleProvider, { canChange:
|
|
6759
|
+
), A = get(x, "dark", null) === p && get(x, "mod", null) === u && get(x, "mq", null) === m;
|
|
6760
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(BlockStyleProvider, { canChange: C, canReset: x && A, children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "group flex flex-row items-center py-2 first:pt-0 last:pb-0", children: [
|
|
6696
6761
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: `text-[11px] ${x && !A ? "text-foreground" : ""}`, children: n(a) }) }),
|
|
6697
6762
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-row items-center", children: [
|
|
6698
6763
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "w-[150px]", children: [
|
|
@@ -6702,17 +6767,17 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
6702
6767
|
currentClass: get(x, "cls", ""),
|
|
6703
6768
|
classPrefix: get(CLASS_PREFIXES, l, ""),
|
|
6704
6769
|
units: c || [],
|
|
6705
|
-
onChange:
|
|
6770
|
+
onChange: k,
|
|
6706
6771
|
negative: d,
|
|
6707
6772
|
cssProperty: l
|
|
6708
6773
|
}
|
|
6709
6774
|
) : null,
|
|
6710
|
-
r === "icons" && /* @__PURE__ */ jsxRuntimeExports.jsx(IconChoices, { property: l, onChange:
|
|
6711
|
-
r === "range" && /* @__PURE__ */ jsxRuntimeExports.jsx(RangeChoices, { property: l, onChange:
|
|
6712
|
-
r === "color" && /* @__PURE__ */ jsxRuntimeExports.jsx(ColorChoice, { property: l, onChange:
|
|
6713
|
-
r === "dropdown" && /* @__PURE__ */ jsxRuntimeExports.jsx(DropDownChoices, { label: a, property: l, onChange:
|
|
6775
|
+
r === "icons" && /* @__PURE__ */ jsxRuntimeExports.jsx(IconChoices, { property: l, onChange: k }),
|
|
6776
|
+
r === "range" && /* @__PURE__ */ jsxRuntimeExports.jsx(RangeChoices, { property: l, onChange: k }),
|
|
6777
|
+
r === "color" && /* @__PURE__ */ jsxRuntimeExports.jsx(ColorChoice, { property: l, onChange: k }),
|
|
6778
|
+
r === "dropdown" && /* @__PURE__ */ jsxRuntimeExports.jsx(DropDownChoices, { label: a, property: l, onChange: k })
|
|
6714
6779
|
] }),
|
|
6715
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `w-[30px] cursor-pointer ${f ? "visible" : "invisible"}`, children: A ? /* @__PURE__ */ jsxRuntimeExports.jsx("button", { type: "button", onClick: () =>
|
|
6780
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `w-[30px] cursor-pointer ${f ? "visible" : "invisible"}`, children: A ? /* @__PURE__ */ jsxRuntimeExports.jsx("button", { type: "button", onClick: () => _(), title: "Reset", className: "flex px-1.5 text-xs", children: /* @__PURE__ */ jsxRuntimeExports.jsx(CrossCircledIcon, { className: "h-5 w-5 text-blue-500 hover:opacity-80" }) }) : C && x ? /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { delayDuration: 100, children: [
|
|
6716
6781
|
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
6717
6782
|
"button",
|
|
6718
6783
|
{
|
|
@@ -6725,14 +6790,14 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
6725
6790
|
"Current style is set at ",
|
|
6726
6791
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "font-bold", children: [
|
|
6727
6792
|
getBreakpoint(get(x, "mq")),
|
|
6728
|
-
|
|
6793
|
+
p && !x.dark ? "(Light mode)" : ""
|
|
6729
6794
|
] }),
|
|
6730
6795
|
/* @__PURE__ */ jsxRuntimeExports.jsx("br", {}),
|
|
6731
6796
|
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
6732
6797
|
"button",
|
|
6733
6798
|
{
|
|
6734
6799
|
type: "button",
|
|
6735
|
-
onClick: () =>
|
|
6800
|
+
onClick: () => R(get(x, "mq")),
|
|
6736
6801
|
className: "block w-full cursor-default text-right font-semibold text-blue-500",
|
|
6737
6802
|
children: [
|
|
6738
6803
|
"Switch to ",
|
|
@@ -6753,7 +6818,7 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
6753
6818
|
units: i = basicUnits,
|
|
6754
6819
|
negative: c = !1
|
|
6755
6820
|
}) => {
|
|
6756
|
-
const { t: d } = useTranslation(), [
|
|
6821
|
+
const { t: d } = useTranslation(), [p, u] = useState(n[0].key), m = useSelectedBlockCurrentClasses(), x = useCallback((g) => map(m, "property").includes(g), [m]);
|
|
6757
6822
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
6758
6823
|
"div",
|
|
6759
6824
|
{
|
|
@@ -6767,8 +6832,8 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
6767
6832
|
"button",
|
|
6768
6833
|
{
|
|
6769
6834
|
type: "button",
|
|
6770
|
-
onClick: () =>
|
|
6771
|
-
className: `relative cursor-pointer rounded-full p-1 text-[8px] ${E ===
|
|
6835
|
+
onClick: () => u(E),
|
|
6836
|
+
className: `relative cursor-pointer rounded-full p-1 text-[8px] ${E === p ? "bg-[#3E57F0] text-white" : "text-gray-600 dark:text-gray-300"}`,
|
|
6772
6837
|
children: [
|
|
6773
6838
|
React__default.createElement("div", {
|
|
6774
6839
|
className: x(E) ? "-bottom-1.5 absolute bg-[#3E57F0] h-[2px] left-0 w-full" : ""
|
|
@@ -6787,7 +6852,7 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
6787
6852
|
type: l,
|
|
6788
6853
|
units: [...i],
|
|
6789
6854
|
label: "",
|
|
6790
|
-
property:
|
|
6855
|
+
property: p,
|
|
6791
6856
|
negative: c
|
|
6792
6857
|
}
|
|
6793
6858
|
) })
|
|
@@ -6796,10 +6861,10 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
6796
6861
|
);
|
|
6797
6862
|
}, NestedOptions = ({ heading: o, items: n }) => {
|
|
6798
6863
|
const { t: r } = useTranslation(), a = useSelectedBlockCurrentClasses(), l = useMemo(() => {
|
|
6799
|
-
const i = (
|
|
6800
|
-
|
|
6864
|
+
const i = (p) => flatten(
|
|
6865
|
+
p.map((u) => u.styleType === "multiple" ? map(u.options, "key") : u.property)
|
|
6801
6866
|
), c = flatten(
|
|
6802
|
-
n.map((
|
|
6867
|
+
n.map((p) => p.styleType === "accordion" ? i(p.items) : p.styleType === "multiple" ? map(p.options, "key") : p.property)
|
|
6803
6868
|
), d = map(a, "property");
|
|
6804
6869
|
return intersection(c, d).length > 0;
|
|
6805
6870
|
}, [a, n]);
|
|
@@ -6819,11 +6884,11 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
6819
6884
|
const { t: n } = useTranslation(), r = useSelectedBlockCurrentClasses(), a = useCallback(
|
|
6820
6885
|
(i = []) => {
|
|
6821
6886
|
const c = {};
|
|
6822
|
-
for (let
|
|
6823
|
-
c[r[
|
|
6887
|
+
for (let p = 0; p < r.length; p++)
|
|
6888
|
+
c[r[p].property] = r[p].cls;
|
|
6824
6889
|
let d = !0;
|
|
6825
|
-
for (const
|
|
6826
|
-
if (!has(c,
|
|
6890
|
+
for (const p in i)
|
|
6891
|
+
if (!has(c, p) || c[p] !== i[p]) {
|
|
6827
6892
|
d = !1;
|
|
6828
6893
|
break;
|
|
6829
6894
|
}
|
|
@@ -6841,8 +6906,8 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
6841
6906
|
const o = useSelectedBlock(), [n] = useSelectedStylingBlocks(), { t: r } = useTranslation(), a = useGlobalStylingPresets(), l = useAddClassesToBlocks(), i = getBlockComponent(o._type), c = get(first(n), "prop"), d = get(i.props, `${c}.presets`, {});
|
|
6842
6907
|
if (isEmpty(a) && (!has(i, "props") || isEmpty(d)))
|
|
6843
6908
|
return null;
|
|
6844
|
-
const
|
|
6845
|
-
const m =
|
|
6909
|
+
const p = (u) => {
|
|
6910
|
+
const m = u.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
|
|
6846
6911
|
l([o._id], m, !0);
|
|
6847
6912
|
};
|
|
6848
6913
|
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-10", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(DropdownMenu, { children: [
|
|
@@ -6858,16 +6923,16 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
6858
6923
|
r("presets")
|
|
6859
6924
|
] }),
|
|
6860
6925
|
/* @__PURE__ */ jsxRuntimeExports.jsx(DropdownMenuSeparator, {}),
|
|
6861
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(DropdownMenuGroup, { children: keys(d).map((
|
|
6862
|
-
capitalize(startCase(r(
|
|
6926
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(DropdownMenuGroup, { children: keys(d).map((u) => /* @__PURE__ */ jsxRuntimeExports.jsxs(DropdownMenuItem, { className: "group text-xs", onClick: () => p(d[u]), children: [
|
|
6927
|
+
capitalize(startCase(r(u))),
|
|
6863
6928
|
/* @__PURE__ */ jsxRuntimeExports.jsx(DropdownMenuShortcut, { className: "invisible hover:font-bold hover:text-blue-600 group-hover:visible", children: r("apply") })
|
|
6864
6929
|
] })) })
|
|
6865
6930
|
] }),
|
|
6866
6931
|
isEmpty(a) ? null : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
6867
6932
|
/* @__PURE__ */ jsxRuntimeExports.jsx(DropdownMenuLabel, { children: r("Global presets") }),
|
|
6868
6933
|
/* @__PURE__ */ jsxRuntimeExports.jsx(DropdownMenuSeparator, {}),
|
|
6869
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(DropdownMenuGroup, { children: keys(a).map((
|
|
6870
|
-
capitalize(startCase(r(
|
|
6934
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(DropdownMenuGroup, { children: keys(a).map((u) => /* @__PURE__ */ jsxRuntimeExports.jsxs(DropdownMenuItem, { className: "group text-xs", onClick: () => p(a[u]), children: [
|
|
6935
|
+
capitalize(startCase(r(u))),
|
|
6871
6936
|
/* @__PURE__ */ jsxRuntimeExports.jsx(DropdownMenuShortcut, { className: "invisible hover:font-bold hover:text-blue-600 group-hover:visible", children: r("apply") })
|
|
6872
6937
|
] })) })
|
|
6873
6938
|
] })
|
|
@@ -6887,8 +6952,8 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
6887
6952
|
};
|
|
6888
6953
|
function BlockStyling() {
|
|
6889
6954
|
const { flexChild: o, gridChild: n } = useSelectedBlocksDisplayChild(), [r] = useSelectedStylingBlocks(), [a, l] = React__default.useState(""), [i, c] = React__default.useState({
|
|
6890
|
-
onDrag: (
|
|
6891
|
-
onDragEnd: (
|
|
6955
|
+
onDrag: (u) => u,
|
|
6956
|
+
onDragEnd: (u) => u,
|
|
6892
6957
|
dragStartY: 0,
|
|
6893
6958
|
dragging: !1,
|
|
6894
6959
|
dragStartValue: 0,
|
|
@@ -6896,21 +6961,21 @@ function BlockStyling() {
|
|
|
6896
6961
|
negative: !1,
|
|
6897
6962
|
cssProperty: ""
|
|
6898
6963
|
}), d = useThrottledCallback(
|
|
6899
|
-
(
|
|
6964
|
+
(u) => {
|
|
6900
6965
|
const m = !get(i, "negative", !1), x = get(i, "cssProperty", "");
|
|
6901
6966
|
let g = parseFloat(i.dragStartValue);
|
|
6902
6967
|
g = isNaN(g) ? 0 : g;
|
|
6903
6968
|
let E = MAPPER[i.dragUnit];
|
|
6904
6969
|
(startsWith(x, "scale") || x === "opacity") && (E = 10);
|
|
6905
|
-
let f = (i.dragStartY -
|
|
6970
|
+
let f = (i.dragStartY - u.pageY) / E + g;
|
|
6906
6971
|
m && f < 0 && (f = 0), x === "opacity" && f > 1 && (f = 1), i.onDrag(`${f}`), l(`${f}`);
|
|
6907
6972
|
},
|
|
6908
6973
|
[i],
|
|
6909
6974
|
50
|
|
6910
|
-
),
|
|
6975
|
+
), p = useCallback(() => {
|
|
6911
6976
|
setTimeout(() => i.onDragEnd(`${a}`), 100), c({
|
|
6912
|
-
onDrag: (
|
|
6913
|
-
onDragEnd: (
|
|
6977
|
+
onDrag: (u) => u,
|
|
6978
|
+
onDragEnd: (u) => u,
|
|
6914
6979
|
dragStartY: 0,
|
|
6915
6980
|
dragging: !1,
|
|
6916
6981
|
dragStartValue: 0,
|
|
@@ -6924,7 +6989,7 @@ function BlockStyling() {
|
|
|
6924
6989
|
"div",
|
|
6925
6990
|
{
|
|
6926
6991
|
onMouseMove: d,
|
|
6927
|
-
onMouseUp: () =>
|
|
6992
|
+
onMouseUp: () => p(),
|
|
6928
6993
|
className: "absolute inset-0 z-30 cursor-row-resize bg-gray-300/10"
|
|
6929
6994
|
}
|
|
6930
6995
|
) : null,
|
|
@@ -6933,7 +6998,7 @@ function BlockStyling() {
|
|
|
6933
6998
|
/* @__PURE__ */ jsxRuntimeExports.jsxs(Accordion, { defaultValue: ["Styles"], type: "multiple", className: "w-full", children: [
|
|
6934
6999
|
o && /* @__PURE__ */ jsxRuntimeExports.jsx(StylingGroup, { section: FLEX_CHILD_SECTION }),
|
|
6935
7000
|
n ? /* @__PURE__ */ jsxRuntimeExports.jsx(StylingGroup, { section: GRID_CHILD_SECTION }) : null,
|
|
6936
|
-
SETTINGS_SECTIONS.map((
|
|
7001
|
+
SETTINGS_SECTIONS.map((u) => /* @__PURE__ */ jsxRuntimeExports.jsx(StylingGroup, { section: u }, u.heading))
|
|
6937
7002
|
] })
|
|
6938
7003
|
] })
|
|
6939
7004
|
] });
|
|
@@ -6945,9 +7010,9 @@ const ChaiSelect = ({
|
|
|
6945
7010
|
placeholder: a = "Select",
|
|
6946
7011
|
className: l = ""
|
|
6947
7012
|
}) => {
|
|
6948
|
-
const [i, c] = useState(o), d = (
|
|
6949
|
-
const
|
|
6950
|
-
c(
|
|
7013
|
+
const [i, c] = useState(o), d = (p) => {
|
|
7014
|
+
const u = p.target.value;
|
|
7015
|
+
c(u), n(u);
|
|
6951
7016
|
};
|
|
6952
7017
|
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: cn("relative inline-block w-full", l), children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
6953
7018
|
"select",
|
|
@@ -6957,7 +7022,7 @@ const ChaiSelect = ({
|
|
|
6957
7022
|
onChange: d,
|
|
6958
7023
|
children: [
|
|
6959
7024
|
/* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "", disabled: !0, children: a }),
|
|
6960
|
-
r.map((
|
|
7025
|
+
r.map((p) => /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: p.value, children: p.label }, p.value))
|
|
6961
7026
|
]
|
|
6962
7027
|
}
|
|
6963
7028
|
) });
|
|
@@ -6989,34 +7054,34 @@ const BlockCard = ({
|
|
|
6989
7054
|
library: n,
|
|
6990
7055
|
parentId: r = void 0
|
|
6991
7056
|
}) => {
|
|
6992
|
-
const [a, l] = useState(!1), i = useBuilderProp("getUILibraryBlock", noop), { addCoreBlock: c, addPredefinedBlock: d } = useAddBlock(), [,
|
|
6993
|
-
const
|
|
6994
|
-
return
|
|
6995
|
-
},
|
|
6996
|
-
async (
|
|
6997
|
-
if (
|
|
7057
|
+
const [a, l] = useState(!1), i = useBuilderProp("getUILibraryBlock", noop), { addCoreBlock: c, addPredefinedBlock: d } = useAddBlock(), [, p] = useSelectedBlockIds(), { clearHighlight: u } = useBlockHighlight(), m = get(o, "name", get(o, "label")), x = useFeature("dnd"), [, g] = useAtom$1(draggedBlockAtom), E = (k) => {
|
|
7058
|
+
const _ = has(k, "styles_attrs.data-page-section");
|
|
7059
|
+
return k._type === "Box" && _;
|
|
7060
|
+
}, b = useCallback(
|
|
7061
|
+
async (k) => {
|
|
7062
|
+
if (k.stopPropagation(), has(o, "component")) {
|
|
6998
7063
|
c(o, r), emitChaiBuilderMsg({ name: CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK });
|
|
6999
7064
|
return;
|
|
7000
7065
|
}
|
|
7001
7066
|
l(!0);
|
|
7002
|
-
const
|
|
7003
|
-
isEmpty(
|
|
7067
|
+
const _ = await i(n, o);
|
|
7068
|
+
isEmpty(_) || d(syncBlocksWithDefaults(_), r), emitChaiBuilderMsg({ name: CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK });
|
|
7004
7069
|
},
|
|
7005
7070
|
[o]
|
|
7006
|
-
), f = async (
|
|
7007
|
-
const
|
|
7008
|
-
let
|
|
7009
|
-
if (E(first(
|
|
7010
|
-
const B = { blocks:
|
|
7011
|
-
if (
|
|
7012
|
-
const
|
|
7013
|
-
|
|
7014
|
-
|
|
7071
|
+
), f = async (k) => {
|
|
7072
|
+
const _ = await i(n, o);
|
|
7073
|
+
let C = r;
|
|
7074
|
+
if (E(first(_)) && (C = null), !isEmpty(_)) {
|
|
7075
|
+
const B = { blocks: _, uiLibrary: !0, parent: C };
|
|
7076
|
+
if (k.dataTransfer.setData("text/plain", JSON.stringify(B)), o.preview) {
|
|
7077
|
+
const R = new Image();
|
|
7078
|
+
R.src = o.preview, R.onload = () => {
|
|
7079
|
+
k.dataTransfer.setDragImage(R, 0, 0);
|
|
7015
7080
|
};
|
|
7016
7081
|
} else
|
|
7017
|
-
|
|
7082
|
+
k.dataTransfer.setDragImage(new Image(), 0, 0);
|
|
7018
7083
|
g(B), setTimeout(() => {
|
|
7019
|
-
|
|
7084
|
+
p([]), u(), emitChaiBuilderMsg({ name: CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK });
|
|
7020
7085
|
}, 200);
|
|
7021
7086
|
}
|
|
7022
7087
|
};
|
|
@@ -7025,7 +7090,7 @@ const BlockCard = ({
|
|
|
7025
7090
|
"div",
|
|
7026
7091
|
{
|
|
7027
7092
|
onClick: a ? () => {
|
|
7028
|
-
} :
|
|
7093
|
+
} : b,
|
|
7029
7094
|
draggable: x ? "true" : "false",
|
|
7030
7095
|
onDragStart: f,
|
|
7031
7096
|
className: clsx(
|
|
@@ -7050,31 +7115,31 @@ const BlockCard = ({
|
|
|
7050
7115
|
(async () => {
|
|
7051
7116
|
if (i === "complete" || c.current === "loading")
|
|
7052
7117
|
return;
|
|
7053
|
-
c.current = "loading", r((
|
|
7118
|
+
c.current = "loading", r((p) => ({ ...p, [o == null ? void 0 : o.uuid]: { loading: "loading", blocks: [] } }));
|
|
7054
7119
|
const d = await a(o);
|
|
7055
|
-
c.current = "idle", r((
|
|
7120
|
+
c.current = "idle", r((p) => ({ ...p, [o == null ? void 0 : o.uuid]: { loading: "complete", blocks: d || [] } }));
|
|
7056
7121
|
})();
|
|
7057
7122
|
}, [o, l, i, c]), { data: l || [], isLoading: i === "loading" };
|
|
7058
7123
|
}, UILibrarySection = ({ parentId: o }) => {
|
|
7059
|
-
const [n, r] = useAtom$1(selectedLibraryAtom), a = useBuilderProp("uiLibraries", []), l = useChaiBlocks(), i = values(l).filter((
|
|
7124
|
+
const [n, r] = useAtom$1(selectedLibraryAtom), a = useBuilderProp("uiLibraries", []), l = useChaiBlocks(), i = values(l).filter((C) => C.category === "custom"), c = a.find((C) => C.uuid === n) || first(a), { data: d, isLoading: p } = useLibraryBlocks(c), u = groupBy([...d, ...i], "group"), [m, x] = useState("Hero"), g = get(u, m, []), E = useRef(null), { t: b } = useTranslation(), f = (C) => {
|
|
7060
7125
|
E.current && (clearTimeout(E.current), E.current = null), E.current = setTimeout(() => {
|
|
7061
|
-
E.current && x(
|
|
7126
|
+
E.current && x(C);
|
|
7062
7127
|
}, 300);
|
|
7063
7128
|
};
|
|
7064
|
-
if (
|
|
7129
|
+
if (p)
|
|
7065
7130
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mt-4 grid h-full w-full grid-cols-12 gap-2", children: [
|
|
7066
7131
|
/* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "col-span-3 h-full" }),
|
|
7067
7132
|
/* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "col-span-9 h-full" })
|
|
7068
7133
|
] });
|
|
7069
|
-
const
|
|
7134
|
+
const k = filter(g, (C, B) => B % 2 === 0), _ = filter(g, (C, B) => B % 2 === 1);
|
|
7070
7135
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "relative mt-2 flex h-full max-h-full overflow-hidden bg-background", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex h-full pt-2", children: [
|
|
7071
7136
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex h-full max-h-full w-60 flex-col gap-1 px-1 pr-2", children: [
|
|
7072
7137
|
/* @__PURE__ */ jsxRuntimeExports.jsx(UILibrariesSelect, { library: c == null ? void 0 : c.uuid, setLibrary: r, uiLibraries: a }),
|
|
7073
7138
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mt-2 flex h-full max-h-full w-full flex-1 flex-col", children: [
|
|
7074
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-xs font-bold text-gray-500", children:
|
|
7139
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-xs font-bold text-gray-500", children: b("groups") }),
|
|
7075
7140
|
/* @__PURE__ */ jsxRuntimeExports.jsx("hr", { className: "mt-1 border-border" }),
|
|
7076
7141
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "no-scrollbar mt-2 h-full max-h-full flex-1 overflow-y-auto pb-20", children: React__default.Children.toArray(
|
|
7077
|
-
map(
|
|
7142
|
+
map(u, (C, B) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
7078
7143
|
"div",
|
|
7079
7144
|
{
|
|
7080
7145
|
onMouseEnter: () => f(B),
|
|
@@ -7085,7 +7150,7 @@ const BlockCard = ({
|
|
|
7085
7150
|
B === m ? "bg-blue-500 text-white hover:bg-blue-600" : ""
|
|
7086
7151
|
),
|
|
7087
7152
|
children: [
|
|
7088
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: capitalize(
|
|
7153
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: capitalize(b(B.toLowerCase())) }),
|
|
7089
7154
|
/* @__PURE__ */ jsxRuntimeExports.jsx(CaretRightIcon, { className: "ml-2 h-5 w-5" })
|
|
7090
7155
|
]
|
|
7091
7156
|
},
|
|
@@ -7102,10 +7167,10 @@ const BlockCard = ({
|
|
|
7102
7167
|
children: [
|
|
7103
7168
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-2 gap-2 px-2", children: [
|
|
7104
7169
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-col gap-1", children: React__default.Children.toArray(
|
|
7105
|
-
|
|
7170
|
+
k.map((C) => /* @__PURE__ */ jsxRuntimeExports.jsx(BlockCard, { parentId: o, block: C, library: c }))
|
|
7106
7171
|
) }),
|
|
7107
7172
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-col gap-1", children: React__default.Children.toArray(
|
|
7108
|
-
|
|
7173
|
+
_.map((C) => /* @__PURE__ */ jsxRuntimeExports.jsx(BlockCard, { parentId: o, block: C, library: c }))
|
|
7109
7174
|
) })
|
|
7110
7175
|
] }),
|
|
7111
7176
|
/* @__PURE__ */ jsxRuntimeExports.jsx("br", {}),
|
|
@@ -7550,10 +7615,10 @@ i18n.use(initReactI18next).init({
|
|
|
7550
7615
|
}
|
|
7551
7616
|
});
|
|
7552
7617
|
const CoreBlock = ({ block: o, disabled: n, parentId: r }) => {
|
|
7553
|
-
const [, a] = useAtom$1(draggedBlockAtom), { type: l, icon: i, label: c } = o, { addCoreBlock: d, addPredefinedBlock:
|
|
7618
|
+
const [, a] = useAtom$1(draggedBlockAtom), { type: l, icon: i, label: c } = o, { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: m } = useBlockHighlight(), x = () => {
|
|
7554
7619
|
if (has(o, "blocks")) {
|
|
7555
|
-
const
|
|
7556
|
-
|
|
7620
|
+
const b = isFunction$1(o.blocks) ? o.blocks() : o.blocks;
|
|
7621
|
+
p(syncBlocksWithDefaults(b), r || null);
|
|
7557
7622
|
} else
|
|
7558
7623
|
d(o, r || null);
|
|
7559
7624
|
emitChaiBuilderMsg({ name: CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK });
|
|
@@ -7565,9 +7630,9 @@ const CoreBlock = ({ block: o, disabled: n, parentId: r }) => {
|
|
|
7565
7630
|
disabled: n,
|
|
7566
7631
|
onClick: x,
|
|
7567
7632
|
type: "button",
|
|
7568
|
-
onDragStart: (
|
|
7569
|
-
|
|
7570
|
-
|
|
7633
|
+
onDragStart: (b) => {
|
|
7634
|
+
b.dataTransfer.setData("text/plain", JSON.stringify(omit(o, ["component", "icon"]))), b.dataTransfer.setDragImage(new Image(), 0, 0), a(omit(o, ["component", "icon"])), setTimeout(() => {
|
|
7635
|
+
u([]), m();
|
|
7571
7636
|
}, 200);
|
|
7572
7637
|
},
|
|
7573
7638
|
draggable: g ? "true" : "false",
|
|
@@ -7585,19 +7650,19 @@ const CoreBlock = ({ block: o, disabled: n, parentId: r }) => {
|
|
|
7585
7650
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(ChaiBuilderBlocks, { gridCols: n, parentId: o, groups: c, blocks: i.core });
|
|
7586
7651
|
}, CORE_GROUPS = ["basic", "typography", "media", "layout", "form", "advanced", "other"], ChaiBuilderBlocks = ({ groups: o, blocks: n, parentId: r, gridCols: a = "grid-cols-4" }) => {
|
|
7587
7652
|
var d;
|
|
7588
|
-
const { t: l } = useTranslation(), [i] = useBlocksStore(), c = (d = find(i, (
|
|
7653
|
+
const { t: l } = useTranslation(), [i] = useBlocksStore(), c = (d = find(i, (p) => p._id === r)) == null ? void 0 : d._type;
|
|
7589
7654
|
return React__default.Children.toArray(
|
|
7590
7655
|
map(
|
|
7591
|
-
sortBy(o, (
|
|
7592
|
-
(
|
|
7593
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(AccordionTrigger, { className: "rounded-md bg-background px-4 py-2 capitalize text-foreground hover:no-underline", children: capitalize(l(
|
|
7656
|
+
sortBy(o, (p) => CORE_GROUPS.indexOf(p) === -1 ? 99 : CORE_GROUPS.indexOf(p)),
|
|
7657
|
+
(p) => reject(filter(values(n), { group: p }), { hidden: !0 }).length ? /* @__PURE__ */ jsxRuntimeExports.jsx(Accordion, { type: "single", value: p, collapsible: !0, className: "w-full", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(AccordionItem, { value: p, className: "border-border", children: [
|
|
7658
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(AccordionTrigger, { className: "rounded-md bg-background px-4 py-2 capitalize text-foreground hover:no-underline", children: capitalize(l(p.toLowerCase())) }),
|
|
7594
7659
|
/* @__PURE__ */ jsxRuntimeExports.jsx(AccordionContent, { className: "mx-auto max-w-xl p-3", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "grid gap-2 " + a, children: React__default.Children.toArray(
|
|
7595
|
-
reject(filter(values(n), { group:
|
|
7660
|
+
reject(filter(values(n), { group: p }), { hidden: !0 }).map((u) => /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
7596
7661
|
CoreBlock,
|
|
7597
7662
|
{
|
|
7598
7663
|
parentId: r,
|
|
7599
|
-
block:
|
|
7600
|
-
disabled: !canAcceptChildBlock(c,
|
|
7664
|
+
block: u,
|
|
7665
|
+
disabled: !canAcceptChildBlock(c, u.type) || !canBeNestedInside(c, u.type)
|
|
7601
7666
|
}
|
|
7602
7667
|
))
|
|
7603
7668
|
) }) })
|
|
@@ -7618,8 +7683,8 @@ const CoreBlock = ({ block: o, disabled: n, parentId: r }) => {
|
|
|
7618
7683
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
7619
7684
|
Tabs,
|
|
7620
7685
|
{
|
|
7621
|
-
onValueChange: (
|
|
7622
|
-
c(""), i(
|
|
7686
|
+
onValueChange: (p) => {
|
|
7687
|
+
c(""), i(p);
|
|
7623
7688
|
},
|
|
7624
7689
|
value: l,
|
|
7625
7690
|
className: cn("h-max"),
|
|
@@ -7904,7 +7969,7 @@ function QuickPrompts({ onClick: o }) {
|
|
|
7904
7969
|
icon: FaLanguage$1,
|
|
7905
7970
|
prompt: `Translate the content to ${get(LANGUAGES, a, a)}. Maintain same tone, style and length.`
|
|
7906
7971
|
}), /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: n ? "pointer-events-none opacity-50" : "", children: /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { className: "space-y-2", children: i.map(
|
|
7907
|
-
({ name: c, icon: d, subMenus:
|
|
7972
|
+
({ name: c, icon: d, subMenus: p, prompt: u }) => p ? /* @__PURE__ */ jsxRuntimeExports.jsxs(Popover, { children: [
|
|
7908
7973
|
/* @__PURE__ */ jsxRuntimeExports.jsx(PopoverTrigger, { asChild: !0, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
7909
7974
|
"li",
|
|
7910
7975
|
{
|
|
@@ -7920,7 +7985,7 @@ function QuickPrompts({ onClick: o }) {
|
|
|
7920
7985
|
] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
7921
7986
|
"li",
|
|
7922
7987
|
{
|
|
7923
|
-
onClick: () => o(
|
|
7988
|
+
onClick: () => o(u),
|
|
7924
7989
|
className: "flex cursor-pointer items-center space-x-2 rounded p-1 text-sm hover:bg-gray-100 dark:hover:bg-gray-800",
|
|
7925
7990
|
children: [
|
|
7926
7991
|
/* @__PURE__ */ jsxRuntimeExports.jsx(d, { className: "h-4 w-4" }),
|
|
@@ -7932,20 +7997,20 @@ function QuickPrompts({ onClick: o }) {
|
|
|
7932
7997
|
) }) });
|
|
7933
7998
|
}
|
|
7934
7999
|
const AIUserPrompt = ({ blockId: o }) => {
|
|
7935
|
-
const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, c] = useState(""), [d,
|
|
8000
|
+
const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, c] = useState(""), [d, p] = useState(!0), [u, m] = useState(), x = useRef(null), g = useRef(null);
|
|
7936
8001
|
useEffect(() => {
|
|
7937
|
-
var
|
|
7938
|
-
(
|
|
8002
|
+
var b;
|
|
8003
|
+
(b = x.current) == null || b.focus();
|
|
7939
8004
|
}, []);
|
|
7940
|
-
const E = (
|
|
7941
|
-
const { usage: f } =
|
|
8005
|
+
const E = (b) => {
|
|
8006
|
+
const { usage: f } = b || {};
|
|
7942
8007
|
!l && f && m(f), g.current = setTimeout(() => m(void 0), 1e4), l || c("");
|
|
7943
8008
|
};
|
|
7944
8009
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "", children: [
|
|
7945
8010
|
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
7946
8011
|
"div",
|
|
7947
8012
|
{
|
|
7948
|
-
onClick: () =>
|
|
8013
|
+
onClick: () => p(!d),
|
|
7949
8014
|
className: "flex cursor-pointer items-center justify-between border-b border-border py-2 text-sm font-bold text-muted-foreground hover:underline",
|
|
7950
8015
|
children: [
|
|
7951
8016
|
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: n("Ask AI") }),
|
|
@@ -7959,12 +8024,12 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
7959
8024
|
{
|
|
7960
8025
|
ref: x,
|
|
7961
8026
|
value: i,
|
|
7962
|
-
onChange: (
|
|
8027
|
+
onChange: (b) => c(b.target.value),
|
|
7963
8028
|
placeholder: n("Ask AI to edit content"),
|
|
7964
8029
|
className: "w-full",
|
|
7965
8030
|
rows: 3,
|
|
7966
|
-
onKeyDown: (
|
|
7967
|
-
|
|
8031
|
+
onKeyDown: (b) => {
|
|
8032
|
+
b.key === "Enter" && (b.preventDefault(), g.current && clearTimeout(g.current), m(void 0), r("content", o, i, E));
|
|
7968
8033
|
}
|
|
7969
8034
|
}
|
|
7970
8035
|
),
|
|
@@ -7993,11 +8058,11 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
7993
8058
|
/* @__PURE__ */ jsxRuntimeExports.jsx(Button, { variant: "destructive", onClick: () => stop(), className: "hidden w-fit", size: "sm", children: n("Stop") })
|
|
7994
8059
|
] }) : null
|
|
7995
8060
|
] }),
|
|
7996
|
-
|
|
8061
|
+
u ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "max-w-full", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "mb-1 flex justify-between break-words rounded border border-blue-500 bg-blue-100 p-1 text-xs text-blue-500", children: [
|
|
7997
8062
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("span", { children: [
|
|
7998
8063
|
n("Total tokens used"),
|
|
7999
8064
|
": ",
|
|
8000
|
-
|
|
8065
|
+
u.totalTokens
|
|
8001
8066
|
] }),
|
|
8002
8067
|
/* @__PURE__ */ jsxRuntimeExports.jsx(Countdown, {})
|
|
8003
8068
|
] }) }) : null,
|
|
@@ -8006,8 +8071,8 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8006
8071
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
8007
8072
|
QuickPrompts,
|
|
8008
8073
|
{
|
|
8009
|
-
onClick: (
|
|
8010
|
-
g.current && clearTimeout(g.current), m(void 0), r("content", o,
|
|
8074
|
+
onClick: (b) => {
|
|
8075
|
+
g.current && clearTimeout(g.current), m(void 0), r("content", o, b, E);
|
|
8011
8076
|
}
|
|
8012
8077
|
}
|
|
8013
8078
|
)
|
|
@@ -8017,19 +8082,19 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8017
8082
|
] }) }) : null
|
|
8018
8083
|
] });
|
|
8019
8084
|
}, AISetContext = () => {
|
|
8020
|
-
const { t: o } = useTranslation(), n = useBuilderProp("aiContext", ""), [r, a] = useState(n), l = useRef(null), i = useBuilderProp("saveAiContextCallback", noop), [c, d] = useState(!1), [
|
|
8085
|
+
const { t: o } = useTranslation(), n = useBuilderProp("aiContext", ""), [r, a] = useState(n), l = useRef(null), i = useBuilderProp("saveAiContextCallback", noop), [c, d] = useState(!1), [p, u] = useState(null), [, m] = useState(!1), { toast: x } = useToast(), g = useRef(null);
|
|
8021
8086
|
useEffect(() => {
|
|
8022
8087
|
n && a(n);
|
|
8023
8088
|
}, [n]);
|
|
8024
8089
|
const E = async () => {
|
|
8025
8090
|
try {
|
|
8026
|
-
d(!0),
|
|
8091
|
+
d(!0), u(null), await i(r), x({
|
|
8027
8092
|
title: o("Updated AI Context"),
|
|
8028
8093
|
description: o("You can now Ask AI to edit your content"),
|
|
8029
8094
|
variant: "default"
|
|
8030
8095
|
}), g.current.click();
|
|
8031
|
-
} catch (
|
|
8032
|
-
|
|
8096
|
+
} catch (b) {
|
|
8097
|
+
u(b);
|
|
8033
8098
|
} finally {
|
|
8034
8099
|
d(!1);
|
|
8035
8100
|
}
|
|
@@ -8037,8 +8102,8 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8037
8102
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
8038
8103
|
Accordion,
|
|
8039
8104
|
{
|
|
8040
|
-
onValueChange: (
|
|
8041
|
-
m(
|
|
8105
|
+
onValueChange: (b) => {
|
|
8106
|
+
m(b !== "");
|
|
8042
8107
|
},
|
|
8043
8108
|
type: "single",
|
|
8044
8109
|
collapsible: !0,
|
|
@@ -8050,12 +8115,12 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8050
8115
|
{
|
|
8051
8116
|
ref: l,
|
|
8052
8117
|
value: r,
|
|
8053
|
-
onChange: (
|
|
8118
|
+
onChange: (b) => a(b.target.value),
|
|
8054
8119
|
placeholder: o("Tell about this page eg this page is about"),
|
|
8055
8120
|
className: "mt-1 w-full",
|
|
8056
8121
|
rows: 10,
|
|
8057
|
-
onKeyDown: (
|
|
8058
|
-
|
|
8122
|
+
onKeyDown: (b) => {
|
|
8123
|
+
b.key === "Enter" && (b.preventDefault(), E());
|
|
8059
8124
|
}
|
|
8060
8125
|
}
|
|
8061
8126
|
),
|
|
@@ -8105,7 +8170,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8105
8170
|
] })
|
|
8106
8171
|
] }) : null
|
|
8107
8172
|
] }),
|
|
8108
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mt-2 max-w-full", children:
|
|
8173
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mt-2 max-w-full", children: p && /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "break-words rounded border border-red-500 bg-red-100 p-1 text-xs text-red-500", children: p.message }) })
|
|
8109
8174
|
] })
|
|
8110
8175
|
] })
|
|
8111
8176
|
}
|
|
@@ -8117,7 +8182,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8117
8182
|
/* @__PURE__ */ jsxRuntimeExports.jsx(AIUserPrompt, { blockId: first(o) })
|
|
8118
8183
|
] });
|
|
8119
8184
|
}, AttrsEditor = React__default.memo(function o({ preloadedAttributes: n = [], onAttributesChange: r }) {
|
|
8120
|
-
const [a, l] = useState([]), [i, c] = useState(""), [d,
|
|
8185
|
+
const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, m] = useState(null), [x, g] = useState(""), E = useRef(null), b = useRef(null);
|
|
8121
8186
|
useEffect(() => {
|
|
8122
8187
|
l(n);
|
|
8123
8188
|
}, [n]);
|
|
@@ -8127,32 +8192,32 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8127
8192
|
return;
|
|
8128
8193
|
}
|
|
8129
8194
|
if (i) {
|
|
8130
|
-
const
|
|
8131
|
-
r(
|
|
8195
|
+
const R = [...a, { key: i, value: d }];
|
|
8196
|
+
r(R), l(a), c(""), p(""), g("");
|
|
8132
8197
|
}
|
|
8133
|
-
},
|
|
8134
|
-
const A = a.filter((N, D) => D !==
|
|
8198
|
+
}, k = (R) => {
|
|
8199
|
+
const A = a.filter((N, D) => D !== R);
|
|
8135
8200
|
r(A), l(A);
|
|
8136
|
-
},
|
|
8137
|
-
m(
|
|
8138
|
-
},
|
|
8201
|
+
}, _ = (R) => {
|
|
8202
|
+
m(R), c(a[R].key), p(a[R].value);
|
|
8203
|
+
}, C = () => {
|
|
8139
8204
|
if (i.startsWith("@")) {
|
|
8140
8205
|
g("Attribute keys cannot start with '@'");
|
|
8141
8206
|
return;
|
|
8142
8207
|
}
|
|
8143
|
-
if (
|
|
8144
|
-
const
|
|
8145
|
-
|
|
8208
|
+
if (u !== null && i) {
|
|
8209
|
+
const R = [...a];
|
|
8210
|
+
R[u] = { key: i, value: d }, r(R), l(R), m(null), c(""), p(""), g("");
|
|
8146
8211
|
}
|
|
8147
|
-
}, B = (
|
|
8148
|
-
|
|
8212
|
+
}, B = (R) => {
|
|
8213
|
+
R.key === "Enter" && !R.shiftKey && (R.preventDefault(), u !== null ? C() : f());
|
|
8149
8214
|
};
|
|
8150
8215
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "max-w-full", children: [
|
|
8151
8216
|
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
8152
8217
|
"form",
|
|
8153
8218
|
{
|
|
8154
|
-
onSubmit: (
|
|
8155
|
-
|
|
8219
|
+
onSubmit: (R) => {
|
|
8220
|
+
R.preventDefault(), u !== null ? C() : f();
|
|
8156
8221
|
},
|
|
8157
8222
|
className: "space-y-3",
|
|
8158
8223
|
children: [
|
|
@@ -8168,7 +8233,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8168
8233
|
id: "attrKey",
|
|
8169
8234
|
ref: E,
|
|
8170
8235
|
value: i,
|
|
8171
|
-
onChange: (
|
|
8236
|
+
onChange: (R) => c(R.target.value),
|
|
8172
8237
|
placeholder: "Key",
|
|
8173
8238
|
className: "h-8 text-sm"
|
|
8174
8239
|
}
|
|
@@ -8184,9 +8249,9 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8184
8249
|
spellCheck: "false",
|
|
8185
8250
|
id: "attrValue",
|
|
8186
8251
|
rows: 2,
|
|
8187
|
-
ref:
|
|
8252
|
+
ref: b,
|
|
8188
8253
|
value: d,
|
|
8189
|
-
onChange: (
|
|
8254
|
+
onChange: (R) => p(R.target.value),
|
|
8190
8255
|
onKeyDown: B,
|
|
8191
8256
|
placeholder: "Value",
|
|
8192
8257
|
className: "bg-background text-sm"
|
|
@@ -8194,22 +8259,22 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8194
8259
|
)
|
|
8195
8260
|
] })
|
|
8196
8261
|
] }),
|
|
8197
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(Button, { type: "submit", variant: "secondary", className: "h-8 w-fit text-sm", children:
|
|
8262
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Button, { type: "submit", variant: "secondary", className: "h-8 w-fit text-sm", children: u !== null ? "Save" : "Add" }),
|
|
8198
8263
|
x && /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-red-500", children: x })
|
|
8199
8264
|
]
|
|
8200
8265
|
}
|
|
8201
8266
|
),
|
|
8202
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mt-4 space-y-1 overflow-y-auto", children: a.map((
|
|
8267
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mt-4 space-y-1 overflow-y-auto", children: a.map((R, A) => /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between rounded bg-muted p-1.5 text-sm", children: [
|
|
8203
8268
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mr-2 flex flex-col", children: [
|
|
8204
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "truncate font-semibold", children:
|
|
8205
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-wrap max-w-[200px] text-muted-foreground", children:
|
|
8269
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "truncate font-semibold", children: R.key }),
|
|
8270
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-wrap max-w-[200px] text-muted-foreground", children: R.value.toString() })
|
|
8206
8271
|
] }),
|
|
8207
8272
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-shrink-0", children: [
|
|
8208
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () =>
|
|
8273
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => _(A), children: [
|
|
8209
8274
|
/* @__PURE__ */ jsxRuntimeExports.jsx(Edit2, { className: "h-3 w-3" }),
|
|
8210
8275
|
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "sr-only", children: "Edit attribute" })
|
|
8211
8276
|
] }),
|
|
8212
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () =>
|
|
8277
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => k(A), children: [
|
|
8213
8278
|
/* @__PURE__ */ jsxRuntimeExports.jsx(X, { className: "h-3 w-3" }),
|
|
8214
8279
|
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "sr-only", children: "Remove attribute" })
|
|
8215
8280
|
] })
|
|
@@ -8219,15 +8284,15 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8219
8284
|
}), BlockAttributesEditor = React.memo(() => {
|
|
8220
8285
|
const o = useSelectedBlock(), [n, r] = useState([]), [a] = useSelectedStylingBlocks(), l = useUpdateBlocksProps(), i = `${get(a, "0.prop")}_attrs`;
|
|
8221
8286
|
React.useEffect(() => {
|
|
8222
|
-
const d = map(get(o, i), (
|
|
8287
|
+
const d = map(get(o, i), (p, u) => ({ key: u, value: p }));
|
|
8223
8288
|
isEmpty(d) ? r([]) : r(d);
|
|
8224
8289
|
}, [get(o, i)]);
|
|
8225
8290
|
const c = React.useCallback(
|
|
8226
8291
|
(d = []) => {
|
|
8227
|
-
const
|
|
8228
|
-
forEach(d, (
|
|
8229
|
-
isEmpty(
|
|
8230
|
-
}), l([get(o, "_id")], { [i]:
|
|
8292
|
+
const p = {};
|
|
8293
|
+
forEach(d, (u) => {
|
|
8294
|
+
isEmpty(u.key) || set(p, u.key, u.value);
|
|
8295
|
+
}), l([get(o, "_id")], { [i]: p });
|
|
8231
8296
|
},
|
|
8232
8297
|
[o, l, i]
|
|
8233
8298
|
);
|
|
@@ -8353,7 +8418,7 @@ const TabletIcon = ({ landscape: o = !1 }) => /* @__PURE__ */ jsxRuntimeExports.
|
|
|
8353
8418
|
] });
|
|
8354
8419
|
}, Breakpoints = () => {
|
|
8355
8420
|
const [, o, n] = useCanvasWidth(), [r, a] = useSelectedBreakpoints(), { t: l } = useTranslation(), i = useBuilderProp("breakpoints", WEB_BREAKPOINTS), c = (d) => {
|
|
8356
|
-
r.includes(d) ? r.length > 2 && a(r.filter((
|
|
8421
|
+
r.includes(d) ? r.length > 2 && a(r.filter((p) => p !== d)) : a((p) => [...p, d]);
|
|
8357
8422
|
};
|
|
8358
8423
|
return i.length < 4 ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center rounded-md", children: map(i, (d) => /* @__PURE__ */ createElement(BreakpointCard, { ...d, onClick: n, key: d.breakpoint, currentBreakpoint: o })) }) : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center rounded-md", children: [
|
|
8359
8424
|
map(
|
|
@@ -8403,8 +8468,8 @@ const TabletIcon = ({ landscape: o = !1 }) => /* @__PURE__ */ jsxRuntimeExports.
|
|
|
8403
8468
|
const { fallbackLang: o, languages: n, selectedLang: r, setSelectedLang: a } = useLanguages(), l = (r == null ? void 0 : r.length) > 0 ? r : o, i = useMemo(() => {
|
|
8404
8469
|
const c = [];
|
|
8405
8470
|
return forEach(uniq([o, ...n]), (d) => {
|
|
8406
|
-
const
|
|
8407
|
-
|
|
8471
|
+
const p = get(LANGUAGES, d);
|
|
8472
|
+
p && c.push({ key: d, value: p, default: d === o });
|
|
8408
8473
|
}), c;
|
|
8409
8474
|
}, [o, n]);
|
|
8410
8475
|
return isEmpty(n) && l === "en" ? null : isEmpty(n) && l !== "en" ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-x-1 text-sm text-blue-500 hover:text-blue-600", children: [
|
|
@@ -8672,15 +8737,15 @@ function RemoveProviderConfirmation({
|
|
|
8672
8737
|
const PageDataProviders = () => {
|
|
8673
8738
|
const { t: o } = useTranslation(), n = useMemo(() => getChaiDataProviders(), []), [r, a] = usePageDataProviders(), [, l] = useAtom$1(builderSaveStateAtom), [i, c] = useState(
|
|
8674
8739
|
filter(n, (f) => map(r, "providerKey").includes(f.providerKey))
|
|
8675
|
-
), [d,
|
|
8740
|
+
), [d, p] = useState(""), [u, m] = useState(null), x = filter(
|
|
8676
8741
|
n.map((f) => map(i, "providerKey").includes(f.providerKey) ? null : { value: f.providerKey, label: f.name }),
|
|
8677
8742
|
(f) => !isNull(f)
|
|
8678
8743
|
), g = (f) => {
|
|
8679
|
-
const
|
|
8680
|
-
c((
|
|
8744
|
+
const k = find(n, { providerKey: f });
|
|
8745
|
+
c((_) => [..._, k]), a((_) => [..._, { providerKey: k.providerKey, args: {} }]), p(""), l("UNSAVED");
|
|
8681
8746
|
}, E = (f) => {
|
|
8682
|
-
c((
|
|
8683
|
-
},
|
|
8747
|
+
c((k) => filter(k, (_) => _.providerKey !== f.providerKey)), a((k) => filter(k, (_) => _.providerKey !== f.providerKey)), l("UNSAVED");
|
|
8748
|
+
}, b = (f) => m(f);
|
|
8684
8749
|
return isEmpty(n) ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "mb-1.5 p-4 text-xs text-gray-500", children: [
|
|
8685
8750
|
o("no_data_providers"),
|
|
8686
8751
|
/* @__PURE__ */ jsxRuntimeExports.jsx("br", {}),
|
|
@@ -8715,7 +8780,7 @@ const PageDataProviders = () => {
|
|
|
8715
8780
|
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
8716
8781
|
"button",
|
|
8717
8782
|
{
|
|
8718
|
-
onClick: () =>
|
|
8783
|
+
onClick: () => b(f),
|
|
8719
8784
|
className: "inline-flex h-9 items-center justify-center rounded-md px-3 text-xs font-medium text-blue-500 underline-offset-4 ring-offset-background transition-colors hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",
|
|
8720
8785
|
children: [
|
|
8721
8786
|
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
@@ -8769,14 +8834,14 @@ const PageDataProviders = () => {
|
|
|
8769
8834
|
},
|
|
8770
8835
|
f.providerKey
|
|
8771
8836
|
)) }),
|
|
8772
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(ViewProviderData, { onClose: () => m(null), provider:
|
|
8837
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(ViewProviderData, { onClose: () => m(null), provider: u })
|
|
8773
8838
|
] })
|
|
8774
8839
|
] });
|
|
8775
8840
|
};
|
|
8776
8841
|
function AiFillDatabase(o) {
|
|
8777
8842
|
return GenIcon({ tag: "svg", attr: { viewBox: "0 0 1024 1024" }, child: [{ tag: "path", attr: { d: "M832 64H192c-17.7 0-32 14.3-32 32v224h704V96c0-17.7-14.3-32-32-32zM288 232c-22.1 0-40-17.9-40-40s17.9-40 40-40 40 17.9 40 40-17.9 40-40 40zM160 928c0 17.7 14.3 32 32 32h640c17.7 0 32-14.3 32-32V704H160v224zm128-136c22.1 0 40 17.9 40 40s-17.9 40-40 40-40-17.9-40-40 17.9-40 40-40zM160 640h704V384H160v256zm128-168c22.1 0 40 17.9 40 40s-17.9 40-40 40-40-17.9-40-40 17.9-40 40-40z" }, child: [] }] })(o);
|
|
8778
8843
|
}
|
|
8779
|
-
const TopBar = lazy(() => import("./Topbar-
|
|
8844
|
+
const TopBar = lazy(() => import("./Topbar-3h7dkWBH.js"));
|
|
8780
8845
|
function useSidebarMenuItems(o) {
|
|
8781
8846
|
const n = o === "SINGLE_SIDE_PANEL", { t: r } = useTranslation(), a = useBuilderProp("dataBindingSupport", !1), l = useBuilderProp("askAiCallBack", null);
|
|
8782
8847
|
return useMemo(() => {
|
|
@@ -8810,7 +8875,7 @@ const RootLayout = () => {
|
|
|
8810
8875
|
g.preventDefault();
|
|
8811
8876
|
}, d = (g) => {
|
|
8812
8877
|
n(o === g ? null : g);
|
|
8813
|
-
},
|
|
8878
|
+
}, p = useSidebarMenuItems(r), { t: u } = useTranslation(), m = [...p, ...i], x = useBuilderProp("htmlDir", "ltr");
|
|
8814
8879
|
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { dir: x, className: "h-screen max-h-full w-screen overflow-x-hidden bg-background text-foreground", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(TooltipProvider, { children: [
|
|
8815
8880
|
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
8816
8881
|
"div",
|
|
@@ -8832,12 +8897,12 @@ const RootLayout = () => {
|
|
|
8832
8897
|
},
|
|
8833
8898
|
E
|
|
8834
8899
|
) }),
|
|
8835
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { children:
|
|
8900
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { children: u(g.label) }) })
|
|
8836
8901
|
] }, "button" + E)) }),
|
|
8837
8902
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col space-y-1", children: [
|
|
8838
8903
|
/* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
|
|
8839
8904
|
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { variant: "ghost", onClick: () => l(!0), children: /* @__PURE__ */ jsxRuntimeExports.jsx(LayoutTemplate, { size: 20 }) }) }),
|
|
8840
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { children:
|
|
8905
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { children: u("Choose Builder Layout") }) })
|
|
8841
8906
|
] }),
|
|
8842
8907
|
/* @__PURE__ */ jsxRuntimeExports.jsx(HotKeys, {})
|
|
8843
8908
|
] })
|
|
@@ -8852,7 +8917,7 @@ const RootLayout = () => {
|
|
|
8852
8917
|
children: o !== null && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "no-scrollbar overflow h-full overflow-x-hidden", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col p-3", children: [
|
|
8853
8918
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("h2", { className: "-mt-1 flex h-10 items-center space-x-1 text-base font-bold", children: [
|
|
8854
8919
|
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "rtl:ml-2 rtl:inline-block", children: get(m, `${o}.icon`, null) }),
|
|
8855
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children:
|
|
8920
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: u(m[o].label) })
|
|
8856
8921
|
] }),
|
|
8857
8922
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Suspense, { fallback: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: "Loading..." }), children: React__default.createElement(get(m, `${o}.component`, null), {}) }) })
|
|
8858
8923
|
] }) })
|
|
@@ -8872,7 +8937,7 @@ const RootLayout = () => {
|
|
|
8872
8937
|
children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "no-scrollbar overflow h-full max-h-full overflow-x-hidden", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex max-h-full flex-col p-3", children: [
|
|
8873
8938
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("h2", { className: "-mt-1 flex h-10 items-center space-x-1 text-base font-bold", children: [
|
|
8874
8939
|
/* @__PURE__ */ jsxRuntimeExports.jsx(EditIcon, { size: "16", className: "rtl:ml-2" }),
|
|
8875
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children:
|
|
8940
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: u("Block Settings") })
|
|
8876
8941
|
] }),
|
|
8877
8942
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Suspense, { fallback: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: "Loading..." }), children: /* @__PURE__ */ jsxRuntimeExports.jsx(SettingsPanel$1, {}) }) })
|
|
8878
8943
|
] }) })
|
|
@@ -8960,7 +9025,7 @@ const RootLayout = () => {
|
|
|
8960
9025
|
] }) }) });
|
|
8961
9026
|
};
|
|
8962
9027
|
export {
|
|
8963
|
-
|
|
9028
|
+
useSelectedBlockCurrentClasses as $,
|
|
8964
9029
|
AddBlocksPanel$1 as A,
|
|
8965
9030
|
BlockSettings as B,
|
|
8966
9031
|
ChaiSelect$1 as C,
|
|
@@ -8983,22 +9048,23 @@ export {
|
|
|
8983
9048
|
ThemeOptions as T,
|
|
8984
9049
|
UILibraries as U,
|
|
8985
9050
|
useHighlightBlockId as V,
|
|
8986
|
-
|
|
8987
|
-
|
|
8988
|
-
|
|
8989
|
-
|
|
8990
|
-
|
|
9051
|
+
useBlockHighlight as W,
|
|
9052
|
+
usePasteBlocks as X,
|
|
9053
|
+
useBrandingOptions as Y,
|
|
9054
|
+
useRemoveBlocks as Z,
|
|
9055
|
+
useRemoveClassesFromBlocks as _,
|
|
8991
9056
|
useSelectedBlockIds as a,
|
|
8992
|
-
|
|
8993
|
-
|
|
8994
|
-
|
|
8995
|
-
|
|
8996
|
-
|
|
8997
|
-
|
|
8998
|
-
|
|
8999
|
-
|
|
9000
|
-
|
|
9001
|
-
|
|
9057
|
+
useSelectedBlockAllClasses as a0,
|
|
9058
|
+
useSelectedBlock as a1,
|
|
9059
|
+
useStylingBreakpoint as a2,
|
|
9060
|
+
useUILibraryBlocks as a3,
|
|
9061
|
+
useStylingState as a4,
|
|
9062
|
+
useSelectedBlocksDisplayChild as a5,
|
|
9063
|
+
useSelectedBreakpoints as a6,
|
|
9064
|
+
useSelectedStylingBlocks as a7,
|
|
9065
|
+
useLanguages as a8,
|
|
9066
|
+
useLayoutVariant as a9,
|
|
9067
|
+
useBlocksStoreUndoableActions as aa,
|
|
9002
9068
|
useUpdateBlocksProps as b,
|
|
9003
9069
|
useUpdateBlocksPropsRealtime as c,
|
|
9004
9070
|
useBuilderProp as d,
|