@chaibuilder/sdk 1.2.107 → 1.2.109
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-LVy_BVMp.cjs → CodeEditor-heJvLZrQ.cjs} +1 -1
- package/dist/{CodeEditor-U9ErQEW3.js → CodeEditor-lKbkdWrD.js} +1 -1
- package/dist/{Topbar-XucHTo33.js → Topbar-lJgYu8sz.js} +1 -1
- package/dist/{Topbar-WRaqBwCJ.cjs → Topbar-mnYBenY0.cjs} +1 -1
- package/dist/{UnsplashImages-9axJ7VXj.cjs → UnsplashImages-8r1JNyap.cjs} +1 -1
- package/dist/{UnsplashImages-B5Dq7OwG.js → UnsplashImages-nAe1gyu9.js} +1 -1
- package/dist/{UploadImages-nEQCD1rK.js → UploadImages-PygaZXFU.js} +1 -1
- package/dist/{UploadImages--0pLZkUI.cjs → UploadImages-Vws49f38.cjs} +1 -1
- package/dist/core.cjs +1 -1
- package/dist/core.d.ts +1 -0
- package/dist/core.js +1 -1
- package/dist/{index-VJfL6eA2.cjs → index-0rfWW4hY.cjs} +5 -5
- package/dist/{index--gUeScPk.js → index-OhF0-tfj.js} +1299 -1263
- package/package.json +1 -1
|
@@ -89,278 +89,278 @@ 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 = (f) => o.get(f), d = (f, v) => {
|
|
93
|
+
(define_import_meta_env_default$2 ? "production" : void 0) !== "production" && Object.freeze(v);
|
|
94
|
+
const C = o.get(f);
|
|
95
|
+
if (o.set(f, v), r.has(f) || r.set(f, C), C && hasPromiseAtomValue(C)) {
|
|
96
|
+
const w = "v" in v ? v.v instanceof Promise ? v.v : Promise.resolve(v.v) : Promise.reject(v.e);
|
|
97
|
+
cancelPromise(C.v, w);
|
|
98
98
|
}
|
|
99
|
-
},
|
|
100
|
-
const
|
|
101
|
-
let
|
|
102
|
-
|
|
103
|
-
!
|
|
104
|
-
}), (
|
|
105
|
-
},
|
|
106
|
-
const
|
|
107
|
-
d: (
|
|
108
|
-
v
|
|
99
|
+
}, u = (f, v, C) => {
|
|
100
|
+
const w = /* @__PURE__ */ new Map();
|
|
101
|
+
let I = !1;
|
|
102
|
+
C.forEach((N, D) => {
|
|
103
|
+
!N && D === f && (N = v), N ? (w.set(D, N), v.d.get(D) !== N && (I = !0)) : (define_import_meta_env_default$2 ? "production" : void 0) !== "production" && console.warn("[Bug] atom state not found");
|
|
104
|
+
}), (I || v.d.size !== w.size) && (v.d = w);
|
|
105
|
+
}, p = (f, v, C) => {
|
|
106
|
+
const w = c(f), I = {
|
|
107
|
+
d: (w == null ? void 0 : w.d) || /* @__PURE__ */ new Map(),
|
|
108
|
+
v
|
|
109
109
|
};
|
|
110
|
-
if (
|
|
111
|
-
return
|
|
112
|
-
if (
|
|
113
|
-
if (
|
|
114
|
-
return
|
|
115
|
-
|
|
110
|
+
if (C && u(f, I, C), w && isEqualAtomValue(w, I) && w.d === I.d)
|
|
111
|
+
return w;
|
|
112
|
+
if (w && hasPromiseAtomValue(w) && hasPromiseAtomValue(I) && isEqualPromiseAtomValue(w, I)) {
|
|
113
|
+
if (w.d === I.d)
|
|
114
|
+
return w;
|
|
115
|
+
I.v = w.v;
|
|
116
116
|
}
|
|
117
|
-
return d(
|
|
118
|
-
}, m = (
|
|
119
|
-
if (isPromiseLike$2(
|
|
120
|
-
let
|
|
121
|
-
const
|
|
117
|
+
return d(f, I), I;
|
|
118
|
+
}, m = (f, v, C, w) => {
|
|
119
|
+
if (isPromiseLike$2(v)) {
|
|
120
|
+
let I;
|
|
121
|
+
const N = new Promise((D, 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
|
-
|
|
129
|
-
|
|
130
|
-
|
|
127
|
+
const $ = c(f), H = p(
|
|
128
|
+
f,
|
|
129
|
+
N,
|
|
130
|
+
C
|
|
131
131
|
);
|
|
132
|
-
resolvePromise(
|
|
132
|
+
resolvePromise(N, O), D(O), ($ == null ? void 0 : $.d) !== H.d && T(f, H, $ == null ? void 0 : $.d);
|
|
133
133
|
}
|
|
134
134
|
},
|
|
135
135
|
(O) => {
|
|
136
136
|
if (!M) {
|
|
137
137
|
M = !0;
|
|
138
|
-
const $ = c(
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
138
|
+
const $ = c(f), H = p(
|
|
139
|
+
f,
|
|
140
|
+
N,
|
|
141
|
+
C
|
|
142
142
|
);
|
|
143
|
-
rejectPromise(
|
|
143
|
+
rejectPromise(N, O), V(O), ($ == null ? void 0 : $.d) !== H.d && T(f, H, $ == null ? void 0 : $.d);
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
|
-
),
|
|
146
|
+
), I = (O) => {
|
|
147
147
|
M || (M = !0, O.then(
|
|
148
|
-
($) => resolvePromise(
|
|
149
|
-
($) => rejectPromise(
|
|
150
|
-
),
|
|
148
|
+
($) => resolvePromise(N, $),
|
|
149
|
+
($) => rejectPromise(N, $)
|
|
150
|
+
), D(O));
|
|
151
151
|
};
|
|
152
152
|
});
|
|
153
|
-
return
|
|
154
|
-
|
|
155
|
-
}),
|
|
153
|
+
return N.orig = v, N.status = "pending", registerCancelPromise(N, (D) => {
|
|
154
|
+
D && I(D), w == null || w();
|
|
155
|
+
}), p(f, N, C);
|
|
156
156
|
}
|
|
157
|
-
return
|
|
158
|
-
},
|
|
159
|
-
const
|
|
160
|
-
d: (
|
|
161
|
-
e:
|
|
157
|
+
return p(f, v, C);
|
|
158
|
+
}, g = (f, v, C) => {
|
|
159
|
+
const w = c(f), I = {
|
|
160
|
+
d: (w == null ? void 0 : w.d) || /* @__PURE__ */ new Map(),
|
|
161
|
+
e: v
|
|
162
162
|
};
|
|
163
|
-
return
|
|
164
|
-
},
|
|
165
|
-
const
|
|
166
|
-
if (
|
|
167
|
-
O !==
|
|
168
|
-
}), Array.from(
|
|
163
|
+
return C && u(f, I, C), w && isEqualAtomError(w, I) && w.d === I.d ? w : (d(f, I), I);
|
|
164
|
+
}, x = (f) => {
|
|
165
|
+
const v = c(f);
|
|
166
|
+
if (v && (v.d.forEach((M, O) => {
|
|
167
|
+
O !== f && !n.has(O) && x(O);
|
|
168
|
+
}), Array.from(v.d).every(([M, O]) => {
|
|
169
169
|
const $ = c(M);
|
|
170
|
-
return M ===
|
|
170
|
+
return M === f || $ === 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 C = /* @__PURE__ */ new Map();
|
|
175
|
+
let w = !0;
|
|
176
|
+
const I = (M) => {
|
|
177
|
+
if (M === f) {
|
|
178
178
|
const $ = c(M);
|
|
179
179
|
if ($)
|
|
180
|
-
return
|
|
180
|
+
return C.set(M, $), returnAtomValue($);
|
|
181
181
|
if (hasInitialValue(M))
|
|
182
|
-
return
|
|
182
|
+
return C.set(M, void 0), M.init;
|
|
183
183
|
throw new Error("no atom init");
|
|
184
184
|
}
|
|
185
|
-
const O =
|
|
186
|
-
return
|
|
185
|
+
const O = x(M);
|
|
186
|
+
return C.set(M, O), returnAtomValue(O);
|
|
187
187
|
};
|
|
188
|
-
let
|
|
188
|
+
let N, D;
|
|
189
189
|
const V = {
|
|
190
190
|
get signal() {
|
|
191
|
-
return
|
|
191
|
+
return N || (N = new AbortController()), N.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(
|
|
197
|
-
}),
|
|
194
|
+
return (define_import_meta_env_default$2 ? "production" : void 0) !== "production" && !isActuallyWritableAtom(f) && console.warn("setSelf function cannot be used with read-only atom"), !D && isActuallyWritableAtom(f) && (D = (...M) => {
|
|
195
|
+
if ((define_import_meta_env_default$2 ? "production" : void 0) !== "production" && w && console.warn("setSelf function cannot be called in sync"), !w)
|
|
196
|
+
return B(f, ...M);
|
|
197
|
+
}), D;
|
|
198
198
|
}
|
|
199
199
|
};
|
|
200
200
|
try {
|
|
201
|
-
const M =
|
|
201
|
+
const M = f.read(I, V);
|
|
202
202
|
return m(
|
|
203
|
-
|
|
203
|
+
f,
|
|
204
204
|
M,
|
|
205
|
-
|
|
206
|
-
() =>
|
|
205
|
+
C,
|
|
206
|
+
() => N == null ? void 0 : N.abort()
|
|
207
207
|
);
|
|
208
208
|
} catch (M) {
|
|
209
|
-
return
|
|
209
|
+
return g(f, M, C);
|
|
210
210
|
} finally {
|
|
211
|
-
|
|
211
|
+
w = !1;
|
|
212
212
|
}
|
|
213
|
-
},
|
|
214
|
-
let
|
|
215
|
-
return
|
|
216
|
-
},
|
|
217
|
-
const
|
|
218
|
-
|
|
219
|
-
}, _ = (
|
|
220
|
-
const
|
|
221
|
-
const
|
|
222
|
-
|
|
223
|
-
V !==
|
|
213
|
+
}, j = (f) => returnAtomValue(x(f)), E = (f) => {
|
|
214
|
+
let v = n.get(f);
|
|
215
|
+
return v || (v = R(f)), v;
|
|
216
|
+
}, b = (f, v) => !v.l.size && (!v.t.size || v.t.size === 1 && v.t.has(f)), k = (f) => {
|
|
217
|
+
const v = n.get(f);
|
|
218
|
+
v && b(f, v) && A(f);
|
|
219
|
+
}, _ = (f) => {
|
|
220
|
+
const v = /* @__PURE__ */ new Map(), C = /* @__PURE__ */ new WeakMap(), w = (N) => {
|
|
221
|
+
const D = n.get(N);
|
|
222
|
+
D == null || D.t.forEach((V) => {
|
|
223
|
+
V !== N && (v.set(
|
|
224
224
|
V,
|
|
225
|
-
(
|
|
226
|
-
),
|
|
225
|
+
(v.get(V) || /* @__PURE__ */ new Set()).add(N)
|
|
226
|
+
), C.set(V, (C.get(V) || 0) + 1), w(V));
|
|
227
227
|
});
|
|
228
228
|
};
|
|
229
|
-
|
|
230
|
-
const
|
|
231
|
-
const
|
|
232
|
-
|
|
229
|
+
w(f);
|
|
230
|
+
const I = (N) => {
|
|
231
|
+
const D = n.get(N);
|
|
232
|
+
D == null || D.t.forEach((V) => {
|
|
233
233
|
var M;
|
|
234
|
-
if (V !==
|
|
235
|
-
let O =
|
|
236
|
-
if (O &&
|
|
237
|
-
let $ = !!((M =
|
|
234
|
+
if (V !== N) {
|
|
235
|
+
let O = C.get(V);
|
|
236
|
+
if (O && C.set(V, --O), !O) {
|
|
237
|
+
let $ = !!((M = v.get(V)) != null && M.size);
|
|
238
238
|
if ($) {
|
|
239
|
-
const H = c(V), F =
|
|
239
|
+
const H = c(V), F = x(V);
|
|
240
240
|
$ = !H || !isEqualAtomValue(H, F);
|
|
241
241
|
}
|
|
242
|
-
$ ||
|
|
242
|
+
$ || v.forEach((H) => H.delete(V));
|
|
243
243
|
}
|
|
244
|
-
|
|
244
|
+
I(V);
|
|
245
245
|
}
|
|
246
246
|
});
|
|
247
247
|
};
|
|
248
|
-
|
|
249
|
-
},
|
|
250
|
-
let
|
|
251
|
-
const
|
|
248
|
+
I(f);
|
|
249
|
+
}, S = (f, ...v) => {
|
|
250
|
+
let C = !0;
|
|
251
|
+
const w = (D) => returnAtomValue(x(D)), I = (D, ...V) => {
|
|
252
252
|
let M;
|
|
253
|
-
if (
|
|
254
|
-
if (!hasInitialValue(
|
|
253
|
+
if (D === f) {
|
|
254
|
+
if (!hasInitialValue(D))
|
|
255
255
|
throw new Error("atom not writable");
|
|
256
|
-
const O = c(
|
|
257
|
-
(!O || !isEqualAtomValue(O, $)) && _(
|
|
256
|
+
const O = c(D), $ = m(D, V[0]);
|
|
257
|
+
(!O || !isEqualAtomValue(O, $)) && _(D);
|
|
258
258
|
} else
|
|
259
|
-
M =
|
|
260
|
-
if (!
|
|
261
|
-
const O =
|
|
259
|
+
M = S(D, ...V);
|
|
260
|
+
if (!C) {
|
|
261
|
+
const O = L();
|
|
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
|
-
},
|
|
268
|
-
return
|
|
269
|
-
}, B = (
|
|
270
|
-
const
|
|
267
|
+
}, N = f.write(w, I, ...v);
|
|
268
|
+
return C = !1, N;
|
|
269
|
+
}, B = (f, ...v) => {
|
|
270
|
+
const C = S(f, ...v), w = L();
|
|
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
|
+
(I) => I({ type: "write", flushed: w })
|
|
273
|
+
), C;
|
|
274
|
+
}, R = (f, v) => {
|
|
275
|
+
const C = {
|
|
276
|
+
t: new Set(v && [v]),
|
|
277
277
|
l: /* @__PURE__ */ new Set()
|
|
278
278
|
};
|
|
279
|
-
if (n.set(
|
|
280
|
-
const
|
|
281
|
-
|
|
282
|
-
}),
|
|
283
|
-
const
|
|
284
|
-
|
|
279
|
+
if (n.set(f, C), (define_import_meta_env_default$2 ? "production" : void 0) !== "production" && i.add(f), x(f).d.forEach((w, I) => {
|
|
280
|
+
const N = n.get(I);
|
|
281
|
+
N ? N.t.add(f) : I !== f && R(I, f);
|
|
282
|
+
}), x(f), isActuallyWritableAtom(f) && f.onMount) {
|
|
283
|
+
const w = f.onMount((...I) => B(f, ...I));
|
|
284
|
+
w && (C.u = w);
|
|
285
285
|
}
|
|
286
|
-
return
|
|
287
|
-
}, A = (
|
|
288
|
-
var
|
|
289
|
-
const
|
|
290
|
-
|
|
291
|
-
const
|
|
292
|
-
|
|
293
|
-
if (
|
|
294
|
-
const
|
|
295
|
-
|
|
286
|
+
return C;
|
|
287
|
+
}, A = (f) => {
|
|
288
|
+
var v;
|
|
289
|
+
const C = (v = n.get(f)) == null ? void 0 : v.u;
|
|
290
|
+
C && C(), n.delete(f), (define_import_meta_env_default$2 ? "production" : void 0) !== "production" && i.delete(f);
|
|
291
|
+
const w = c(f);
|
|
292
|
+
w ? (hasPromiseAtomValue(w) && cancelPromise(w.v), w.d.forEach((I, N) => {
|
|
293
|
+
if (N !== f) {
|
|
294
|
+
const D = n.get(N);
|
|
295
|
+
D && (D.t.delete(f), b(N, D) && A(N));
|
|
296
296
|
}
|
|
297
|
-
})) : (define_import_meta_env_default$2 ? "production" : void 0) !== "production" && console.warn("[Bug] could not find atom state to unmount",
|
|
298
|
-
},
|
|
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", f);
|
|
298
|
+
}, T = (f, v, C) => {
|
|
299
|
+
const w = new Set(v.d.keys());
|
|
300
|
+
C == null || C.forEach((I, N) => {
|
|
301
|
+
if (w.has(N)) {
|
|
302
|
+
w.delete(N);
|
|
303
303
|
return;
|
|
304
304
|
}
|
|
305
|
-
const
|
|
306
|
-
|
|
307
|
-
}),
|
|
308
|
-
const
|
|
309
|
-
|
|
305
|
+
const D = n.get(N);
|
|
306
|
+
D && (D.t.delete(f), b(N, D) && A(N));
|
|
307
|
+
}), w.forEach((I) => {
|
|
308
|
+
const N = n.get(I);
|
|
309
|
+
N ? N.t.add(f) : n.has(f) && R(I, f);
|
|
310
310
|
});
|
|
311
|
-
},
|
|
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
|
|
320
|
-
|
|
311
|
+
}, L = () => {
|
|
312
|
+
let f;
|
|
313
|
+
for ((define_import_meta_env_default$2 ? "production" : void 0) !== "production" && (f = /* @__PURE__ */ new Set()); r.size; ) {
|
|
314
|
+
const v = Array.from(r);
|
|
315
|
+
r.clear(), v.forEach(([C, w]) => {
|
|
316
|
+
const I = c(C);
|
|
317
|
+
if (I) {
|
|
318
|
+
I.d !== (w == null ? void 0 : w.d) && T(C, I, w == null ? void 0 : w.d);
|
|
319
|
+
const N = n.get(C);
|
|
320
|
+
N && !// TODO This seems pretty hacky. Hope to fix it.
|
|
321
321
|
// Maybe we could `mountDependencies` in `setAtomState`?
|
|
322
|
-
(
|
|
322
|
+
(w && !hasPromiseAtomValue(w) && (isEqualAtomValue(w, I) || isEqualAtomError(w, I))) && (N.l.forEach((D) => D()), (define_import_meta_env_default$2 ? "production" : void 0) !== "production" && f.add(C));
|
|
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
|
-
(
|
|
328
|
+
return a.forEach((v) => v("state")), f;
|
|
329
|
+
}, P = (f, v) => {
|
|
330
|
+
const C = E(f), w = L(), I = C.l;
|
|
331
|
+
return I.add(v), (define_import_meta_env_default$2 ? "production" : void 0) !== "production" && (a.forEach((N) => N("sub")), l.forEach(
|
|
332
|
+
(N) => N({ type: "sub", flushed: w })
|
|
333
333
|
)), () => {
|
|
334
|
-
|
|
334
|
+
I.delete(v), k(f), (define_import_meta_env_default$2 ? "production" : void 0) !== "production" && (a.forEach((N) => N("unsub")), l.forEach((N) => N({ type: "unsub" })));
|
|
335
335
|
};
|
|
336
336
|
};
|
|
337
337
|
return (define_import_meta_env_default$2 ? "production" : void 0) !== "production" ? {
|
|
338
|
-
get:
|
|
338
|
+
get: j,
|
|
339
339
|
set: B,
|
|
340
|
-
sub:
|
|
340
|
+
sub: P,
|
|
341
341
|
// store dev methods (these are tentative and subject to change without notice)
|
|
342
|
-
dev_subscribe_store: (
|
|
342
|
+
dev_subscribe_store: (f, 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(f), () => {
|
|
345
|
+
a.delete(f);
|
|
346
|
+
}) : (l.add(f), () => {
|
|
347
|
+
l.delete(f);
|
|
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: (f) => o.get(f),
|
|
351
|
+
dev_get_mounted: (f) => n.get(f),
|
|
352
|
+
dev_restore_atoms: (f) => {
|
|
353
|
+
for (const [C, w] of f)
|
|
354
|
+
hasInitialValue(C) && (m(C, w), _(C));
|
|
355
|
+
const v = L();
|
|
356
356
|
l.forEach(
|
|
357
|
-
(
|
|
357
|
+
(C) => C({ type: "restore", flushed: v })
|
|
358
358
|
);
|
|
359
359
|
}
|
|
360
360
|
} : {
|
|
361
|
-
get:
|
|
361
|
+
get: j,
|
|
362
362
|
set: B,
|
|
363
|
-
sub:
|
|
363
|
+
sub: P
|
|
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
|
|
381
|
-
return c.forEach((
|
|
382
|
-
const
|
|
383
|
-
|
|
384
|
-
const
|
|
385
|
-
if (
|
|
386
|
-
m[
|
|
377
|
+
let u = r.get(c);
|
|
378
|
+
if (u)
|
|
379
|
+
return u;
|
|
380
|
+
const p = d && r.get(d), m = [], g = [];
|
|
381
|
+
return c.forEach((x, j) => {
|
|
382
|
+
const E = n ? n(x) : j;
|
|
383
|
+
g[j] = E;
|
|
384
|
+
const b = p && p.atomList[p.keyList.indexOf(E)];
|
|
385
|
+
if (b) {
|
|
386
|
+
m[j] = b;
|
|
387
387
|
return;
|
|
388
388
|
}
|
|
389
|
-
const
|
|
390
|
-
const B =
|
|
391
|
-
if (
|
|
392
|
-
const
|
|
393
|
-
if (
|
|
394
|
-
return
|
|
389
|
+
const k = (S) => {
|
|
390
|
+
const B = S(l), R = S(o), T = a(R, B == null ? void 0 : B.arr).keyList.indexOf(E);
|
|
391
|
+
if (T < 0 || T >= R.length) {
|
|
392
|
+
const L = c[a(c).keyList.indexOf(E)];
|
|
393
|
+
if (L)
|
|
394
|
+
return L;
|
|
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[T];
|
|
398
|
+
}, _ = (S, B, R) => {
|
|
399
|
+
const A = S(l), T = S(o), P = a(T, A == null ? void 0 : A.arr).keyList.indexOf(E);
|
|
400
|
+
if (P < 0 || P >= T.length)
|
|
401
401
|
throw new Error("splitAtom: index out of bounds for write");
|
|
402
|
-
const
|
|
402
|
+
const f = isFunction(R) ? R(T[P]) : R;
|
|
403
403
|
B(o, [
|
|
404
|
-
...
|
|
405
|
-
|
|
406
|
-
...
|
|
404
|
+
...T.slice(0, P),
|
|
405
|
+
f,
|
|
406
|
+
...T.slice(P + 1)
|
|
407
407
|
]);
|
|
408
408
|
};
|
|
409
|
-
m[
|
|
410
|
-
}),
|
|
409
|
+
m[j] = isWritable(o) ? atom(k, _) : atom(k);
|
|
410
|
+
}), p && p.keyList.length === g.length && p.keyList.every((x, j) => x === g[j]) ? u = p : u = { arr: c, atomList: m, keyList: g }, r.set(c, u), u;
|
|
411
411
|
}, l = atom((c) => {
|
|
412
|
-
const d = c(l),
|
|
413
|
-
return a(
|
|
412
|
+
const d = c(l), u = c(o);
|
|
413
|
+
return a(u, 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, u) => {
|
|
419
|
+
switch (u.type) {
|
|
420
420
|
case "remove": {
|
|
421
|
-
const
|
|
422
|
-
if (
|
|
421
|
+
const p = c(i).indexOf(u.atom);
|
|
422
|
+
if (p >= 0) {
|
|
423
423
|
const m = c(o);
|
|
424
424
|
d(o, [
|
|
425
|
-
...m.slice(0,
|
|
426
|
-
...m.slice(
|
|
425
|
+
...m.slice(0, p),
|
|
426
|
+
...m.slice(p + 1)
|
|
427
427
|
]);
|
|
428
428
|
}
|
|
429
429
|
break;
|
|
430
430
|
}
|
|
431
431
|
case "insert": {
|
|
432
|
-
const
|
|
433
|
-
if (
|
|
432
|
+
const p = u.before ? c(i).indexOf(u.before) : c(i).length;
|
|
433
|
+
if (p >= 0) {
|
|
434
434
|
const m = c(o);
|
|
435
435
|
d(o, [
|
|
436
|
-
...m.slice(0,
|
|
437
|
-
|
|
438
|
-
...m.slice(
|
|
436
|
+
...m.slice(0, p),
|
|
437
|
+
u.value,
|
|
438
|
+
...m.slice(p)
|
|
439
439
|
]);
|
|
440
440
|
}
|
|
441
441
|
break;
|
|
442
442
|
}
|
|
443
443
|
case "move": {
|
|
444
|
-
const
|
|
445
|
-
if (
|
|
446
|
-
const
|
|
447
|
-
|
|
448
|
-
...
|
|
449
|
-
...
|
|
450
|
-
|
|
451
|
-
...
|
|
444
|
+
const p = c(i).indexOf(u.atom), m = u.before ? c(i).indexOf(u.before) : c(i).length;
|
|
445
|
+
if (p >= 0 && m >= 0) {
|
|
446
|
+
const g = c(o);
|
|
447
|
+
p < m ? d(o, [
|
|
448
|
+
...g.slice(0, p),
|
|
449
|
+
...g.slice(p + 1, m),
|
|
450
|
+
g[p],
|
|
451
|
+
...g.slice(m)
|
|
452
452
|
]) : d(o, [
|
|
453
|
-
...
|
|
454
|
-
|
|
455
|
-
...
|
|
456
|
-
...
|
|
453
|
+
...g.slice(0, m),
|
|
454
|
+
g[p],
|
|
455
|
+
...g.slice(m, p),
|
|
456
|
+
...g.slice(p + 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 u = (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
|
+
}, p = (d = (c = o()) == null ? void 0 : c.getItem(l)) != null ? d : null;
|
|
487
|
+
return isPromiseLike$1(p) ? p.then(u) : u(p);
|
|
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 = (u) => {
|
|
503
|
+
if (u.storageArea === o() && u.key === l) {
|
|
504
|
+
let p;
|
|
505
505
|
try {
|
|
506
|
-
|
|
506
|
+
p = JSON.parse(u.newValue || "");
|
|
507
507
|
} catch {
|
|
508
|
-
|
|
508
|
+
p = c;
|
|
509
509
|
}
|
|
510
|
-
i(
|
|
510
|
+
i(p);
|
|
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 u;
|
|
528
|
+
return r.subscribe && (u = r.subscribe(o, d, n)), u;
|
|
529
529
|
}, atom(
|
|
530
530
|
(d) => d(i),
|
|
531
|
-
(d,
|
|
532
|
-
const m = typeof
|
|
533
|
-
return m === RESET ? (
|
|
531
|
+
(d, u, p) => {
|
|
532
|
+
const m = typeof p == "function" ? p(d(i)) : p;
|
|
533
|
+
return m === RESET ? (u(i, n), r.removeItem(o)) : m instanceof Promise ? m.then((g) => (u(i, g), r.setItem(o, g))) : (u(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
|
+
(p) => {
|
|
558
558
|
const m = r.get(o);
|
|
559
|
-
return Object.is(
|
|
559
|
+
return Object.is(p[0], m) && p[1] === r && p[2] === o ? p : [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 u = n == null ? void 0 : n.delay;
|
|
567
567
|
return useEffect(() => {
|
|
568
|
-
const
|
|
569
|
-
if (typeof
|
|
570
|
-
setTimeout(c,
|
|
568
|
+
const p = r.sub(o, () => {
|
|
569
|
+
if (typeof u == "number") {
|
|
570
|
+
setTimeout(c, u);
|
|
571
571
|
return;
|
|
572
572
|
}
|
|
573
573
|
c();
|
|
574
574
|
});
|
|
575
|
-
return c(),
|
|
576
|
-
}, [r, o,
|
|
575
|
+
return c(), p;
|
|
576
|
+
}, [r, o, u]), 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: p
|
|
644
|
-
d[
|
|
641
|
+
const d = c, u = getSlots(d);
|
|
642
|
+
return Object.keys(u).length > 0 && Object.keys(u).forEach((p) => {
|
|
643
|
+
const m = find(i, { oldId: u[p].replace("slot:", "") });
|
|
644
|
+
d[p] = `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 p = o.schema;
|
|
750
|
+
return p.title && (p.title = titleWithLang(n(p.title), r, get(o, "i18n"))), p.oneOf && Array.isArray(p.oneOf) && (p.oneOf = p.oneOf.map((m) => (m.title && (m.title = n(m.title)), m))), p;
|
|
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((p) => {
|
|
759
|
+
const m = a[p];
|
|
760
760
|
if (includes(["slot", "styles"], m.type))
|
|
761
761
|
return;
|
|
762
|
-
const
|
|
763
|
-
i.properties[
|
|
762
|
+
const g = p;
|
|
763
|
+
i.properties[g] = 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, u = {
|
|
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((p) => {
|
|
775
|
+
const m = c[p];
|
|
776
776
|
if (includes(["slot", "styles"], m.type))
|
|
777
777
|
return;
|
|
778
|
-
const
|
|
779
|
-
|
|
780
|
-
|
|
778
|
+
const g = p;
|
|
779
|
+
u.items.properties[g] = getBlockJSONFromSchemas(m, n, r), set(
|
|
780
|
+
u.items,
|
|
781
781
|
"title",
|
|
782
782
|
titleWithLang(get(m, "itemTitle", `${n(d)} item`), r, get(m, "i18n"))
|
|
783
783
|
);
|
|
784
|
-
}),
|
|
784
|
+
}), u;
|
|
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 p
|
|
837
|
-
return !
|
|
836
|
+
function u(p, m) {
|
|
837
|
+
return !p || typeof p[m] != "function" ? this : (c = !0, p[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(p) {
|
|
848
|
+
return c ? this : (a.splice(l + 1, a.length - l), a.push(p), 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(p) {
|
|
855
|
+
d = p;
|
|
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 p = a[l];
|
|
862
|
+
if (!p)
|
|
863
863
|
return this;
|
|
864
|
-
const m =
|
|
865
|
-
for (;
|
|
864
|
+
const m = p.groupId;
|
|
865
|
+
for (; p.groupId === m && (u(p, "undo"), l -= 1, p = a[l], !(!p || !p.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 p = a[l + 1];
|
|
874
|
+
if (!p)
|
|
875
875
|
return this;
|
|
876
|
-
const m =
|
|
877
|
-
for (;
|
|
876
|
+
const m = p.groupId;
|
|
877
|
+
for (; p.groupId === m && (u(p, "redo"), l += 1, p = a[l + 1], !(!p || !p.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 p = a.length;
|
|
886
|
+
a = [], l = -1, d && p > 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(p) {
|
|
908
|
+
return p ? a.filter((m) => m.groupId === p) : 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(p) {
|
|
922
|
+
i = p;
|
|
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 (u) => {
|
|
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 u = l();
|
|
1072
|
+
return await r({ blocks: u.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, u = 0; d < o.length; d++)
|
|
1116
1116
|
if (o[d]._parent === r) {
|
|
1117
|
-
if (
|
|
1117
|
+
if (u === i) {
|
|
1118
1118
|
c = d;
|
|
1119
1119
|
break;
|
|
1120
1120
|
}
|
|
1121
|
-
|
|
1121
|
+
u++;
|
|
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((u) => u._id === n);
|
|
1152
1152
|
return d && (d._parent = r === "root" ? null : r), c.shift(), c;
|
|
1153
1153
|
}
|
|
1154
1154
|
return o;
|
|
@@ -1195,114 +1195,114 @@ const useBlocksStoreManager = () => {
|
|
|
1195
1195
|
updateBlocksProps: c
|
|
1196
1196
|
} = useBlocksStoreManager();
|
|
1197
1197
|
return {
|
|
1198
|
-
moveBlocks: (
|
|
1199
|
-
const _ = map(
|
|
1200
|
-
const A = n.find((
|
|
1201
|
-
return { _id: B, oldParent: A, oldPosition:
|
|
1202
|
-
}),
|
|
1203
|
-
|
|
1204
|
-
undo: () => each(_, ({ _id: B, oldParent:
|
|
1205
|
-
i([B],
|
|
1198
|
+
moveBlocks: (E, b, k) => {
|
|
1199
|
+
const _ = map(E, (B) => {
|
|
1200
|
+
const A = n.find((P) => P._id === B)._parent || null, L = n.filter((P) => A ? P._parent === A : !P._parent).map((P) => P._id).indexOf(B);
|
|
1201
|
+
return { _id: B, oldParent: A, oldPosition: L };
|
|
1202
|
+
}), S = _.find(({ _id: B }) => B === E[0]);
|
|
1203
|
+
S && S.oldParent === b && S.oldPosition === k || (i(E, b, k), o({
|
|
1204
|
+
undo: () => each(_, ({ _id: B, oldParent: R, oldPosition: A }) => {
|
|
1205
|
+
i([B], R, A);
|
|
1206
1206
|
}),
|
|
1207
|
-
redo: () => i(
|
|
1207
|
+
redo: () => i(E, b, k)
|
|
1208
1208
|
}));
|
|
1209
1209
|
},
|
|
1210
|
-
addBlocks: (
|
|
1211
|
-
a(
|
|
1212
|
-
undo: () => l(map(
|
|
1213
|
-
redo: () => a(
|
|
1210
|
+
addBlocks: (E, b, k) => {
|
|
1211
|
+
a(E, b, k), o({
|
|
1212
|
+
undo: () => l(map(E, "_id")),
|
|
1213
|
+
redo: () => a(E, b, k)
|
|
1214
1214
|
});
|
|
1215
1215
|
},
|
|
1216
|
-
removeBlocks: (
|
|
1217
|
-
var
|
|
1218
|
-
const
|
|
1219
|
-
l(map(
|
|
1220
|
-
undo: () => a(
|
|
1221
|
-
redo: () => l(map(
|
|
1216
|
+
removeBlocks: (E) => {
|
|
1217
|
+
var S;
|
|
1218
|
+
const b = (S = first(E)) == null ? void 0 : S._parent, _ = n.filter((B) => b ? B._parent === b : !B._parent).indexOf(first(E));
|
|
1219
|
+
l(map(E, "_id")), o({
|
|
1220
|
+
undo: () => a(E, b, _),
|
|
1221
|
+
redo: () => l(map(E, "_id"))
|
|
1222
1222
|
});
|
|
1223
1223
|
},
|
|
1224
|
-
updateBlocks: (
|
|
1224
|
+
updateBlocks: (E, b, k) => {
|
|
1225
1225
|
let _ = [];
|
|
1226
|
-
if (
|
|
1227
|
-
_ = map(
|
|
1226
|
+
if (k)
|
|
1227
|
+
_ = map(E, (S) => ({ _id: S, ...k }));
|
|
1228
1228
|
else {
|
|
1229
|
-
const
|
|
1230
|
-
_ = map(
|
|
1231
|
-
const
|
|
1232
|
-
return each(
|
|
1229
|
+
const S = keys(b);
|
|
1230
|
+
_ = map(E, (B) => {
|
|
1231
|
+
const R = n.find((T) => T._id === B), A = { _id: B };
|
|
1232
|
+
return each(S, (T) => A[T] = R[T]), A;
|
|
1233
1233
|
});
|
|
1234
1234
|
}
|
|
1235
|
-
c(map(
|
|
1235
|
+
c(map(E, (S) => ({ _id: S, ...b }))), o({
|
|
1236
1236
|
undo: () => c(_),
|
|
1237
|
-
redo: () => c(map(
|
|
1237
|
+
redo: () => c(map(E, (S) => ({ _id: S, ...b })))
|
|
1238
1238
|
});
|
|
1239
1239
|
},
|
|
1240
|
-
updateBlocksRuntime: (
|
|
1241
|
-
c(map(
|
|
1240
|
+
updateBlocksRuntime: (E, b) => {
|
|
1241
|
+
c(map(E, (k) => ({ _id: k, ...b })));
|
|
1242
1242
|
},
|
|
1243
|
-
setNewBlocks: (
|
|
1244
|
-
r(
|
|
1243
|
+
setNewBlocks: (E) => {
|
|
1244
|
+
r(E), o({
|
|
1245
1245
|
undo: () => r(n),
|
|
1246
|
-
redo: () => r(
|
|
1246
|
+
redo: () => r(E)
|
|
1247
1247
|
});
|
|
1248
1248
|
},
|
|
1249
|
-
updateMultipleBlocksProps: (
|
|
1250
|
-
let
|
|
1251
|
-
|
|
1252
|
-
const _ = keys(
|
|
1253
|
-
return each(_, (
|
|
1254
|
-
}), c(
|
|
1255
|
-
undo: () => c(
|
|
1256
|
-
redo: () => c(
|
|
1249
|
+
updateMultipleBlocksProps: (E) => {
|
|
1250
|
+
let b = [];
|
|
1251
|
+
b = map(E, (k) => {
|
|
1252
|
+
const _ = keys(k), S = n.find((R) => R._id === k._id), B = {};
|
|
1253
|
+
return each(_, (R) => B[R] = S[R]), B;
|
|
1254
|
+
}), c(E), o({
|
|
1255
|
+
undo: () => c(b),
|
|
1256
|
+
redo: () => c(E)
|
|
1257
1257
|
});
|
|
1258
1258
|
}
|
|
1259
1259
|
};
|
|
1260
1260
|
}, useAddBlock = () => {
|
|
1261
1261
|
const [o] = useBlocksStore(), [, n] = useSelectedBlockIds(), { addBlocks: r } = useBlocksStoreUndoableActions(), a = useCallback(
|
|
1262
1262
|
(i, c, d) => {
|
|
1263
|
-
var
|
|
1264
|
-
for (let
|
|
1265
|
-
const { _id:
|
|
1266
|
-
i[
|
|
1267
|
-
const
|
|
1268
|
-
for (let
|
|
1269
|
-
|
|
1263
|
+
var x;
|
|
1264
|
+
for (let j = 0; j < i.length; j++) {
|
|
1265
|
+
const { _id: E } = i[j];
|
|
1266
|
+
i[j]._id = generateUUID();
|
|
1267
|
+
const b = filter(i, { _parent: E });
|
|
1268
|
+
for (let k = 0; k < b.length; k++)
|
|
1269
|
+
b[k]._parent = i[j]._id;
|
|
1270
1270
|
}
|
|
1271
|
-
const
|
|
1272
|
-
let
|
|
1273
|
-
return c && (
|
|
1271
|
+
const u = first(i);
|
|
1272
|
+
let p, m;
|
|
1273
|
+
return c && (p = find(o, { _id: c }), i[0]._parent = c, m = c), !(p ? canAcceptChildBlock(p == null ? void 0 : p._type, u._type) : !0) && p && (i[0]._parent = p._parent, m = p._parent), r(i, m, d), n([(x = first(i)) == null ? void 0 : x._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 u = generateUUID(), p = getBlockDefaultProps(i.props), m = [];
|
|
1284
|
+
forIn(p, (k, _) => {
|
|
1285
|
+
if (startsWith(k, SLOT_KEY)) {
|
|
1286
|
+
const S = k.replace(SLOT_KEY, "");
|
|
1287
1287
|
m.push({
|
|
1288
|
-
_id:
|
|
1288
|
+
_id: S,
|
|
1289
1289
|
_type: "Slot",
|
|
1290
|
-
_parent:
|
|
1290
|
+
_parent: u,
|
|
1291
1291
|
_name: i.props[_].name,
|
|
1292
1292
|
_styles: i.props[_].styles,
|
|
1293
1293
|
_emptyStyles: i.props[_].emptyStyles
|
|
1294
1294
|
});
|
|
1295
1295
|
}
|
|
1296
1296
|
});
|
|
1297
|
-
const
|
|
1297
|
+
const g = {
|
|
1298
1298
|
_type: i.type,
|
|
1299
|
-
_id:
|
|
1300
|
-
...
|
|
1299
|
+
_id: u,
|
|
1300
|
+
...p
|
|
1301
1301
|
};
|
|
1302
|
-
let
|
|
1303
|
-
c && (
|
|
1304
|
-
const
|
|
1305
|
-
return r(
|
|
1302
|
+
let x, j;
|
|
1303
|
+
c && (x = find(o, { _id: c }), g._parent = c, j = c), !canAcceptChildBlock(x == null ? void 0 : x._type, g._type) && x && (g._parent = x._parent, j = x._parent);
|
|
1304
|
+
const b = [g, ...m];
|
|
1305
|
+
return r(b, j, d), n([g._id]), g;
|
|
1306
1306
|
},
|
|
1307
1307
|
[a, o, n]
|
|
1308
1308
|
), addPredefinedBlock: a };
|
|
@@ -2402,23 +2402,23 @@ 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
|
+
(p) => !isNull(p)
|
|
2406
|
+
), l = filter(map(n.split(" "), constructClassObject), (p) => !isNull(p));
|
|
2407
2407
|
l = filter(
|
|
2408
2408
|
l,
|
|
2409
|
-
(
|
|
2409
|
+
(p) => !includes(IGNORED_BASES_CLASSES_PROPERTIES, p.property)
|
|
2410
2410
|
);
|
|
2411
2411
|
const i = [], c = [];
|
|
2412
|
-
each(r, (
|
|
2413
|
-
const m = constructClassObject(
|
|
2414
|
-
if (
|
|
2412
|
+
each(r, (p) => {
|
|
2413
|
+
const m = constructClassObject(p), g = find(a, pick(m, ["dark", "mq", "mod", "property"]));
|
|
2414
|
+
if (g && (a = filter(
|
|
2415
2415
|
a,
|
|
2416
|
-
(
|
|
2417
|
-
)), i.push(m), m.mq === "xs" && !m.dark && m.mod === "" && (l = filter(l, (
|
|
2418
|
-
const
|
|
2419
|
-
|
|
2416
|
+
(x) => x.fullCls !== (g == null ? void 0 : g.fullCls)
|
|
2417
|
+
)), i.push(m), m.mq === "xs" && !m.dark && m.mod === "" && (l = filter(l, (x) => x.property !== m.property)), getBelongsToForClass(a, m) === "baseClasses" && !includes(IGNORED_BASES_CLASSES_PROPERTIES, m.property)) {
|
|
2418
|
+
const x = find(l, pick(m, ["property"]));
|
|
2419
|
+
g && (l = filter(
|
|
2420
2420
|
l,
|
|
2421
|
-
(
|
|
2421
|
+
(j) => j.fullCls !== (x == null ? void 0 : x.fullCls)
|
|
2422
2422
|
)), c.push({
|
|
2423
2423
|
...m,
|
|
2424
2424
|
fullCls: m.cls,
|
|
@@ -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], (p) => MEDIA_QUERIES[p.mq]),
|
|
2431
2431
|
"fullCls"
|
|
2432
2432
|
).join(" ");
|
|
2433
2433
|
return `${map(
|
|
2434
|
-
sortBy([...l, ...c], (
|
|
2434
|
+
sortBy([...l, ...c], (p) => MEDIA_QUERIES[p.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), u = get(d, i.prop, `${STYLES_KEY},`), { baseClasses: p, classes: m } = getSplitClasses$1(u);
|
|
2453
2453
|
return {
|
|
2454
2454
|
ids: [d._id],
|
|
2455
|
-
props: { [i.prop]: `${STYLES_KEY}${getNewClasses(m,
|
|
2455
|
+
props: { [i.prop]: `${STYLES_KEY}${getNewClasses(m, p, a)}` }
|
|
2456
2456
|
};
|
|
2457
2457
|
});
|
|
2458
2458
|
}), useAddClassesToBlocks = () => {
|
|
@@ -2501,13 +2501,13 @@ const useSelectedStylingBlocks = () => useAtom$1(selectedStylingBlocksAtom), get
|
|
|
2501
2501
|
(a, l = null) => {
|
|
2502
2502
|
const i = [];
|
|
2503
2503
|
each(a, (c) => {
|
|
2504
|
-
const d = o.find((
|
|
2504
|
+
const d = o.find((x) => x._id === c);
|
|
2505
2505
|
l || (l = d._parent);
|
|
2506
2506
|
const m = filter(
|
|
2507
2507
|
o,
|
|
2508
|
-
(
|
|
2509
|
-
).indexOf(d) + 1,
|
|
2510
|
-
r(
|
|
2508
|
+
(x) => isString$1(l) ? x._parent === l : !d._parent
|
|
2509
|
+
).indexOf(d) + 1, g = getDuplicatedBlocks(o, c, l);
|
|
2510
|
+
r(g, l, m), i.push(get(g, "0._id", ""));
|
|
2511
2511
|
}), n(i);
|
|
2512
2512
|
},
|
|
2513
2513
|
[o, n]
|
|
@@ -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 u = Array.isArray(d) ? d[0] : d;
|
|
2552
|
+
isEmpty(o) ? l(n, d) : a(o, u), 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(
|
|
2575
|
-
const
|
|
2576
|
-
|
|
2577
|
-
const
|
|
2578
|
-
includes(["2xl", "xl", "lg", "md", "sm"],
|
|
2579
|
-
}), each(
|
|
2580
|
-
const
|
|
2581
|
-
m = m.replace(
|
|
2572
|
+
const d = o(c), u = a;
|
|
2573
|
+
let { classes: p, baseClasses: m } = getSplitClasses(get(d, l.prop, "styles:,"));
|
|
2574
|
+
return each(u, (g) => {
|
|
2575
|
+
const x = g.replace(/[\[\]\/\\{}()*+?.^$|]/g, "\\$&"), j = new RegExp(`(^| )${x}($| )`, "g");
|
|
2576
|
+
p = p.replace(j, " ").replace(/ +/g, " ").trim();
|
|
2577
|
+
const E = first(g.split(":"));
|
|
2578
|
+
includes(["2xl", "xl", "lg", "md", "sm"], E) && u.push(g.split(":").pop().trim());
|
|
2579
|
+
}), each(u, (g) => {
|
|
2580
|
+
const x = new RegExp(`(^| )${g.replace("[", "\\[").replace("]", "\\]")}($| )`, "g");
|
|
2581
|
+
m = m.replace(x, " ").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},${p}`
|
|
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 u = "";
|
|
2684
2684
|
o([n], { [i]: "" });
|
|
2685
|
-
for (let
|
|
2686
|
-
|
|
2685
|
+
for (let p = 0; p < d.length; p++)
|
|
2686
|
+
u += d[p].join(""), o([n], { [i]: u }), await new Promise((m) => setTimeout(m, a));
|
|
2687
2687
|
}
|
|
2688
2688
|
}
|
|
2689
2689
|
},
|
|
@@ -2748,18 +2748,18 @@ const xShowBlocksAtom = atom$1([]);
|
|
|
2748
2748
|
xShowBlocksAtom.debugLabel = "xShowBlocksAtom";
|
|
2749
2749
|
const selectedLibraryAtom = atomWithStorage("_selectedLibrary", null);
|
|
2750
2750
|
selectedLibraryAtom.debugLabel = "selectedLibraryAtom";
|
|
2751
|
-
let lastHighlighted
|
|
2751
|
+
let lastHighlighted = null;
|
|
2752
2752
|
const useBlockHighlight = () => {
|
|
2753
2753
|
const [o] = useAtom$1(canvasIframeAtom);
|
|
2754
2754
|
return { highlightBlock: (a) => {
|
|
2755
2755
|
var c;
|
|
2756
2756
|
const l = o.contentDocument || ((c = o.contentWindow) == null ? void 0 : c.document);
|
|
2757
|
-
lastHighlighted
|
|
2757
|
+
lastHighlighted && lastHighlighted.removeAttribute("data-highlighted");
|
|
2758
2758
|
const i = l.querySelector(`[data-block-id="${a}"]`);
|
|
2759
|
-
i ? (i.setAttribute("data-highlighted", "true"), lastHighlighted
|
|
2759
|
+
i ? (i.setAttribute("data-highlighted", "true"), lastHighlighted = i) : lastHighlighted = null;
|
|
2760
2760
|
}, clearHighlight: () => {
|
|
2761
|
-
lastHighlighted
|
|
2762
|
-
} };
|
|
2761
|
+
lastHighlighted && (lastHighlighted.removeAttribute("data-highlighted"), lastHighlighted = null);
|
|
2762
|
+
}, lastHighlighted };
|
|
2763
2763
|
}, globalBlocksStoreAtom = atom({}), globalBlocksLoadingStateAtom = atom({}), useGlobalBlocksStore = () => {
|
|
2764
2764
|
const [o, n] = useAtom(globalBlocksStoreAtom), r = useCallback(
|
|
2765
2765
|
(l) => get(o, l == null ? void 0 : l.globalBlock, []),
|
|
@@ -2769,18 +2769,18 @@ const useBlockHighlight = () => {
|
|
|
2769
2769
|
}, [n]);
|
|
2770
2770
|
return { getGlobalBlocks: r, reset: a };
|
|
2771
2771
|
}, useWatchGlobalBlocks = () => {
|
|
2772
|
-
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((u) => u._type === "GlobalBlock").filter((u) => u._type === "GlobalBlock").map((u) => u.globalBlock), [o]);
|
|
2773
2773
|
useEffect(() => {
|
|
2774
2774
|
forEach(c, (d) => {
|
|
2775
|
-
has(n, d) || get(a, `${d}.loading`, !1) || (l((
|
|
2776
|
-
r((
|
|
2777
|
-
...
|
|
2775
|
+
has(n, d) || get(a, `${d}.loading`, !1) || (l((u) => ({ ...u, [d]: { loading: !0, error: null } })), i(d).then((u) => {
|
|
2776
|
+
r((p) => ({ ...p, [d]: u })), l((p) => ({
|
|
2777
|
+
...p,
|
|
2778
2778
|
[d]: { loading: !1, error: null }
|
|
2779
2779
|
}));
|
|
2780
|
-
}).catch((
|
|
2781
|
-
l((
|
|
2782
|
-
...
|
|
2783
|
-
[d]: { loading: !1, error:
|
|
2780
|
+
}).catch((u) => {
|
|
2781
|
+
l((p) => ({
|
|
2782
|
+
...p,
|
|
2783
|
+
[d]: { loading: !1, error: u.message }
|
|
2784
2784
|
}));
|
|
2785
2785
|
}));
|
|
2786
2786
|
});
|
|
@@ -2878,24 +2878,24 @@ const useBlockHighlight = () => {
|
|
|
2878
2878
|
</body>
|
|
2879
2879
|
</html>`, useCanvasScale = (o) => {
|
|
2880
2880
|
const [n] = useCanvasWidth(), [, r] = useCanvasZoom(), a = useBuilderProp("htmlDir", "ltr"), [l, i] = useState({}), c = useCallback(() => {
|
|
2881
|
-
const { width: d, height:
|
|
2881
|
+
const { width: d, height: u } = o;
|
|
2882
2882
|
if (d < n) {
|
|
2883
|
-
const
|
|
2883
|
+
const p = parseFloat((d / n).toFixed(2).toString());
|
|
2884
2884
|
let m = {};
|
|
2885
|
-
const
|
|
2886
|
-
|
|
2885
|
+
const g = u * p, x = d * p;
|
|
2886
|
+
u && (m = {
|
|
2887
2887
|
// Eureka! This is the formula to calculate the height of the scaled element. Thank you ChatGPT 4
|
|
2888
|
-
height: 100 + (
|
|
2889
|
-
width: 100 + (d -
|
|
2888
|
+
height: 100 + (u - g) / g * 100 + "%",
|
|
2889
|
+
width: 100 + (d - x) / x * 100 + "%"
|
|
2890
2890
|
}), i({
|
|
2891
2891
|
position: "relative",
|
|
2892
2892
|
top: 0,
|
|
2893
|
-
transform: `scale(${
|
|
2893
|
+
transform: `scale(${p})`,
|
|
2894
2894
|
transformOrigin: a === "rtl" ? "top right" : "top left",
|
|
2895
2895
|
...m,
|
|
2896
2896
|
maxWidth: "none"
|
|
2897
2897
|
// TODO: Add max-width to the wrapper
|
|
2898
|
-
}), r(
|
|
2898
|
+
}), r(p * 100);
|
|
2899
2899
|
} else
|
|
2900
2900
|
i({}), r(100);
|
|
2901
2901
|
}, [n, o, a, r]);
|
|
@@ -3016,8 +3016,8 @@ let iframeDocument = null, possiblePositions = [], dropTarget = null, dropIndex
|
|
|
3016
3016
|
const positionPlaceholder = (o, n, r) => {
|
|
3017
3017
|
if (!iframeDocument || !o)
|
|
3018
3018
|
return;
|
|
3019
|
-
const a = iframeDocument == null ? void 0 : iframeDocument.getElementById("placeholder"), l = possiblePositions.map(([
|
|
3020
|
-
(
|
|
3019
|
+
const a = iframeDocument == null ? void 0 : iframeDocument.getElementById("placeholder"), l = possiblePositions.map(([u]) => u), i = l.reduce(
|
|
3020
|
+
(u, p) => Math.abs(p - r) < Math.abs(u - r) ? p : u,
|
|
3021
3021
|
0
|
|
3022
3022
|
), c = l.indexOf(i);
|
|
3023
3023
|
if (!possiblePositions[c])
|
|
@@ -3062,41 +3062,41 @@ function removeDataDrop() {
|
|
|
3062
3062
|
o && o.removeAttribute("data-drop");
|
|
3063
3063
|
}
|
|
3064
3064
|
const useDnd = () => {
|
|
3065
|
-
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, u] = useAtom$1(draggedBlockAtom), [, p] = useAtom$1(dropTargetBlockIdAtom);
|
|
3066
3066
|
if (!useFeature("dnd"))
|
|
3067
3067
|
return {};
|
|
3068
|
-
const
|
|
3069
|
-
removePlaceholder(), r(!1),
|
|
3068
|
+
const g = () => {
|
|
3069
|
+
removePlaceholder(), r(!1), u(null), p(null), possiblePositions = [];
|
|
3070
3070
|
};
|
|
3071
3071
|
return iframeDocument = o, {
|
|
3072
3072
|
isDragging: n,
|
|
3073
|
-
onDragOver: (
|
|
3074
|
-
|
|
3073
|
+
onDragOver: (x) => {
|
|
3074
|
+
x.preventDefault(), x.stopPropagation(), throttledDragOver(x);
|
|
3075
3075
|
},
|
|
3076
|
-
onDrop: (
|
|
3077
|
-
var
|
|
3078
|
-
const
|
|
3079
|
-
dropIndex = calculateDropIndex(
|
|
3080
|
-
const
|
|
3081
|
-
if ((
|
|
3082
|
-
|
|
3076
|
+
onDrop: (x) => {
|
|
3077
|
+
var R;
|
|
3078
|
+
const j = dropTarget, b = getOrientation(j) === "vertical" ? x.clientY + ((R = iframeDocument == null ? void 0 : iframeDocument.defaultView) == null ? void 0 : R.scrollY) : x.clientX;
|
|
3079
|
+
dropIndex = calculateDropIndex(b, possiblePositions);
|
|
3080
|
+
const k = d, _ = j.getAttribute("data-block-id"), S = dropTarget.getAttribute("data-dnd-dragged") !== "yes";
|
|
3081
|
+
if ((k == null ? void 0 : k._id) === _ || !S) {
|
|
3082
|
+
g();
|
|
3083
3083
|
return;
|
|
3084
3084
|
}
|
|
3085
|
-
if (!has(
|
|
3086
|
-
a(
|
|
3085
|
+
if (!has(k, "_id")) {
|
|
3086
|
+
a(k, _ === "canvas" ? null : _, dropIndex), setTimeout(g, 300);
|
|
3087
3087
|
return;
|
|
3088
3088
|
}
|
|
3089
|
-
let B =
|
|
3090
|
-
B === null && (B =
|
|
3089
|
+
let B = j.getAttribute("data-block-id");
|
|
3090
|
+
B === null && (B = x.target.parentElement.getAttribute("data-block-id")), c([k._id], B === "canvas" ? null : B, dropIndex), g(), setTimeout(removePlaceholder, 300);
|
|
3091
3091
|
},
|
|
3092
|
-
onDragEnter: (
|
|
3093
|
-
const
|
|
3094
|
-
dropTarget =
|
|
3095
|
-
const
|
|
3096
|
-
|
|
3092
|
+
onDragEnter: (x) => {
|
|
3093
|
+
const j = x, E = j.target;
|
|
3094
|
+
dropTarget = E;
|
|
3095
|
+
const b = E.getAttribute("data-block-id"), k = E.getAttribute("data-dnd-dragged") !== "yes";
|
|
3096
|
+
p(b), j.stopPropagation(), j.preventDefault(), possiblePositions = [], k && calculatePossiblePositions(E), r(!0), l(""), i([]);
|
|
3097
3097
|
},
|
|
3098
|
-
onDragLeave: (
|
|
3099
|
-
|
|
3098
|
+
onDragLeave: (x) => {
|
|
3099
|
+
x.target.getAttribute("data-block-id") === "canvas" && (p(null), r(!1), removePlaceholder(), possiblePositions = []);
|
|
3100
3100
|
}
|
|
3101
3101
|
};
|
|
3102
3102
|
};
|
|
@@ -3114,113 +3114,109 @@ function destroyQuill(o) {
|
|
|
3114
3114
|
n && n.parentNode.removeChild(n), o = null;
|
|
3115
3115
|
}
|
|
3116
3116
|
const useHandleCanvasDblClick = () => {
|
|
3117
|
-
const o = ["Heading", "Paragraph", "Text", "Link", "Span", "Button"], n = useUpdateBlocksProps(), [r, a] = useAtom$1(inlineEditingActiveAtom);
|
|
3118
|
-
return (
|
|
3119
|
-
var
|
|
3117
|
+
const o = ["Heading", "Paragraph", "Text", "Link", "Span", "Button"], n = useUpdateBlocksProps(), [r, a] = useAtom$1(inlineEditingActiveAtom), { clearHighlight: l } = useBlockHighlight();
|
|
3118
|
+
return (i) => {
|
|
3119
|
+
var g;
|
|
3120
3120
|
if (r)
|
|
3121
3121
|
return;
|
|
3122
|
-
const
|
|
3123
|
-
if (!
|
|
3122
|
+
const c = getTargetedBlock(i.target), d = c.getAttribute("data-block-type");
|
|
3123
|
+
if (!d || !o.includes(d))
|
|
3124
3124
|
return;
|
|
3125
|
-
const
|
|
3126
|
-
|
|
3127
|
-
x.name !== "class" &&
|
|
3128
|
-
}),
|
|
3129
|
-
const p = new Quill(
|
|
3130
|
-
function
|
|
3125
|
+
const u = c.cloneNode(!0);
|
|
3126
|
+
c.style.display = "none", Array.from(u.attributes).forEach((x) => {
|
|
3127
|
+
x.name !== "class" && u.removeAttribute(x.name);
|
|
3128
|
+
}), d === "Text" && (u.style.display = "inline-block"), c.parentNode.insertBefore(u, c.nextSibling);
|
|
3129
|
+
const p = new Quill(u, { placeholder: "Type here..." });
|
|
3130
|
+
function m() {
|
|
3131
3131
|
const x = p.getText(0, p.getLength());
|
|
3132
|
-
n([
|
|
3132
|
+
n([c.getAttribute("data-block-id")], { content: x }), c.removeAttribute("style"), u.removeEventListener("blur", m, !0), destroyQuill(p), a(""), l();
|
|
3133
3133
|
}
|
|
3134
|
-
|
|
3135
|
-
(x.key === "Enter" || x.key === "Escape") &&
|
|
3136
|
-
}), p.focus(), (
|
|
3134
|
+
u.addEventListener("blur", m, !0), u.addEventListener("keydown", (x) => {
|
|
3135
|
+
(x.key === "Enter" || x.key === "Escape") && m();
|
|
3136
|
+
}), p.focus(), (g = u.querySelector(".ql-clipboard")) == null || g.remove(), a(c.getAttribute("data-block-id"));
|
|
3137
3137
|
};
|
|
3138
3138
|
}, useHandleCanvasClick = () => {
|
|
3139
|
-
const [, o] = useSelectedStylingBlocks(), [n, r] = useSelectedBlockIds(), [a] = useAtom$1(inlineEditingActiveAtom), [l] = useAtom$1(treeRefAtom);
|
|
3140
|
-
return (
|
|
3139
|
+
const [, o] = useSelectedStylingBlocks(), [n, r] = useSelectedBlockIds(), [a] = useAtom$1(inlineEditingActiveAtom), [l] = useAtom$1(treeRefAtom), { clearHighlight: i } = useBlockHighlight();
|
|
3140
|
+
return (c) => {
|
|
3141
3141
|
if (a)
|
|
3142
3142
|
return;
|
|
3143
|
-
|
|
3144
|
-
const
|
|
3145
|
-
if (
|
|
3146
|
-
r([]), o([]),
|
|
3143
|
+
c.stopPropagation();
|
|
3144
|
+
const d = getTargetedBlock(c.target);
|
|
3145
|
+
if (d != null && d.getAttribute("data-block-id") && (d == null ? void 0 : d.getAttribute("data-block-id")) === "container") {
|
|
3146
|
+
r([]), o([]), i();
|
|
3147
3147
|
return;
|
|
3148
3148
|
}
|
|
3149
|
-
if (
|
|
3150
|
-
const
|
|
3151
|
-
n.includes(
|
|
3152
|
-
} else if (
|
|
3153
|
-
const
|
|
3154
|
-
n.includes(
|
|
3149
|
+
if (d != null && d.getAttribute("data-block-parent")) {
|
|
3150
|
+
const u = d.getAttribute("data-style-prop"), p = d.getAttribute("data-style-id"), m = d.getAttribute("data-block-parent");
|
|
3151
|
+
n.includes(m) || l == null || l.closeAll(), o([{ id: p, prop: u, blockId: m }]), r([m]);
|
|
3152
|
+
} else if (d != null && d.getAttribute("data-block-id")) {
|
|
3153
|
+
const u = d.getAttribute("data-block-id");
|
|
3154
|
+
n.includes(u) || l == null || l.closeAll(), o([]), r(u === "canvas" ? [] : [u]);
|
|
3155
3155
|
}
|
|
3156
|
-
|
|
3157
|
-
};
|
|
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);
|
|
3156
|
+
i();
|
|
3168
3157
|
};
|
|
3169
|
-
},
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
3158
|
+
}, useHandleMouseMove = () => {
|
|
3159
|
+
const [o] = useAtom$1(inlineEditingActiveAtom), { highlightBlock: n } = useBlockHighlight();
|
|
3160
|
+
return throttle((r) => {
|
|
3161
|
+
if (o)
|
|
3162
|
+
return;
|
|
3163
|
+
const a = getTargetedBlock(r.target);
|
|
3164
|
+
a && n(a.getAttribute("data-block-id"));
|
|
3165
|
+
}, 16);
|
|
3166
|
+
}, useHandleMouseLeave = () => {
|
|
3167
|
+
const { clearHighlight: o } = useBlockHighlight();
|
|
3168
|
+
return o;
|
|
3169
|
+
}, Canvas = ({ children: o }) => {
|
|
3170
|
+
const { document: n } = useFrame(), [r] = useSelectedBlockIds(), [a, l] = useSelectedStylingBlocks(), { clearHighlight: i } = useBlockHighlight();
|
|
3171
|
+
useEffect(() => i, [i]), useEffect(() => {
|
|
3176
3172
|
setTimeout(() => {
|
|
3177
3173
|
if (!isEmpty(a))
|
|
3178
3174
|
return;
|
|
3179
|
-
const
|
|
3180
|
-
if (
|
|
3181
|
-
const x =
|
|
3175
|
+
const g = getElementByDataBlockId(n, first(r));
|
|
3176
|
+
if (g) {
|
|
3177
|
+
const x = g.getAttribute("data-style-prop");
|
|
3182
3178
|
if (x) {
|
|
3183
|
-
const
|
|
3184
|
-
l([{ id:
|
|
3179
|
+
const j = g.getAttribute("data-style-id"), E = g.getAttribute("data-block-parent");
|
|
3180
|
+
l([{ id: j, prop: x, blockId: E }]);
|
|
3185
3181
|
}
|
|
3186
3182
|
}
|
|
3187
3183
|
}, 100);
|
|
3188
3184
|
}, [n, r, l, a]);
|
|
3189
|
-
const
|
|
3185
|
+
const c = useHandleCanvasDblClick(), d = useHandleCanvasClick(), u = useHandleMouseMove(), p = useHandleMouseLeave(), m = useDnd();
|
|
3190
3186
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
3191
3187
|
"div",
|
|
3192
3188
|
{
|
|
3193
3189
|
"data-block-id": "canvas",
|
|
3194
3190
|
id: "canvas",
|
|
3195
|
-
onClick:
|
|
3196
|
-
onDoubleClick:
|
|
3197
|
-
onMouseMove:
|
|
3191
|
+
onClick: d,
|
|
3192
|
+
onDoubleClick: c,
|
|
3193
|
+
onMouseMove: u,
|
|
3198
3194
|
onMouseLeave: p,
|
|
3199
|
-
...omit(
|
|
3200
|
-
className: "relative h-full max-w-full p-px " + (
|
|
3195
|
+
...omit(m, "isDragging"),
|
|
3196
|
+
className: "relative h-full max-w-full p-px " + (m.isDragging ? "dragging" : ""),
|
|
3201
3197
|
children: o
|
|
3202
3198
|
}
|
|
3203
3199
|
);
|
|
3204
3200
|
}, getElementByDataBlockId = (o, n) => o.querySelector(`[data-block-id="${n}"]`), useKeyEventWatcher = (o) => {
|
|
3205
|
-
const [n, r] = useSelectedBlockIds(), a = useRemoveBlocks(), l = useDuplicateBlocks(), { undo: i, redo: c } = useUndoManager(), [, d] = useCutBlockIds(), [,
|
|
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", () =>
|
|
3201
|
+
const [n, r] = useSelectedBlockIds(), a = useRemoveBlocks(), l = useDuplicateBlocks(), { undo: i, redo: c } = useUndoManager(), [, d] = useCutBlockIds(), [, u] = useCopyBlockIds(), { canPaste: p, pasteBlocks: m } = usePasteBlocks();
|
|
3202
|
+
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", () => u(n), {}, [n, u]), useHotkeys(
|
|
3207
3203
|
"ctrl+v,command+v",
|
|
3208
3204
|
() => {
|
|
3209
|
-
|
|
3205
|
+
p(n[0]) && m(n);
|
|
3210
3206
|
},
|
|
3211
3207
|
{},
|
|
3212
|
-
[n,
|
|
3208
|
+
[n, p, m]
|
|
3213
3209
|
);
|
|
3214
|
-
const
|
|
3215
|
-
useHotkeys("esc", () => r([]),
|
|
3210
|
+
const g = o ? { document: o } : {};
|
|
3211
|
+
useHotkeys("esc", () => r([]), g, [r]), useHotkeys("ctrl+d,command+d", () => l(n), { ...g, preventDefault: !0 }, [
|
|
3216
3212
|
n,
|
|
3217
3213
|
l
|
|
3218
3214
|
]), useHotkeys(
|
|
3219
3215
|
"del, backspace",
|
|
3220
|
-
(
|
|
3221
|
-
|
|
3216
|
+
(x) => {
|
|
3217
|
+
x.preventDefault(), a(n);
|
|
3222
3218
|
},
|
|
3223
|
-
|
|
3219
|
+
g,
|
|
3224
3220
|
[n, a]
|
|
3225
3221
|
);
|
|
3226
3222
|
}, KeyboardHandler = () => {
|
|
@@ -3249,7 +3245,7 @@ const handleMouseMove = throttle((o) => {
|
|
|
3249
3245
|
}
|
|
3250
3246
|
);
|
|
3251
3247
|
}, BlockActionsStatic = ({ selectedBlockElement: o, block: n }) => {
|
|
3252
|
-
const r = useRemoveBlocks(), a = useDuplicateBlocks(), [, l] = useSelectedBlockIds(), [, i] = useHighlightBlockId(), [, c] = useSelectedStylingBlocks(), [d] = useAtom$1(inlineEditingActiveAtom), { floatingStyles:
|
|
3248
|
+
const r = useRemoveBlocks(), a = useDuplicateBlocks(), [, l] = useSelectedBlockIds(), [, i] = useHighlightBlockId(), [, c] = useSelectedStylingBlocks(), [d] = useAtom$1(inlineEditingActiveAtom), { floatingStyles: u, refs: p, update: m } = useFloating({
|
|
3253
3249
|
placement: "top-start",
|
|
3254
3250
|
middleware: [shift(), flip()],
|
|
3255
3251
|
elements: {
|
|
@@ -3257,33 +3253,33 @@ const handleMouseMove = throttle((o) => {
|
|
|
3257
3253
|
}
|
|
3258
3254
|
});
|
|
3259
3255
|
useResizeObserver(o, () => m(), o !== null);
|
|
3260
|
-
const
|
|
3256
|
+
const g = get(n, "_parent", null), x = isEmpty(get(n, "_name", "")) ? get(n, "_type", "") : get(n, "_name", "");
|
|
3261
3257
|
return !o || !n || d ? null : /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
3262
3258
|
"div",
|
|
3263
3259
|
{
|
|
3264
3260
|
role: "button",
|
|
3265
3261
|
tabIndex: 0,
|
|
3266
|
-
ref:
|
|
3267
|
-
style:
|
|
3268
|
-
onClick: (
|
|
3269
|
-
|
|
3262
|
+
ref: p.setFloating,
|
|
3263
|
+
style: u,
|
|
3264
|
+
onClick: (j) => {
|
|
3265
|
+
j.stopPropagation(), j.preventDefault();
|
|
3270
3266
|
},
|
|
3271
|
-
onMouseEnter: (
|
|
3272
|
-
|
|
3267
|
+
onMouseEnter: (j) => {
|
|
3268
|
+
j.stopPropagation(), i(null);
|
|
3273
3269
|
},
|
|
3274
|
-
onKeyDown: (
|
|
3270
|
+
onKeyDown: (j) => j.stopPropagation(),
|
|
3275
3271
|
className: "isolate z-[999] flex h-6 items-center bg-blue-500 py-2 text-xs text-white",
|
|
3276
3272
|
children: [
|
|
3277
|
-
|
|
3273
|
+
g && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
3278
3274
|
ArrowUpIcon,
|
|
3279
3275
|
{
|
|
3280
3276
|
className: "hover:scale-105",
|
|
3281
3277
|
onClick: () => {
|
|
3282
|
-
c([]), l([
|
|
3278
|
+
c([]), l([g]);
|
|
3283
3279
|
}
|
|
3284
3280
|
}
|
|
3285
3281
|
),
|
|
3286
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(BlockActionLabel, { label:
|
|
3282
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(BlockActionLabel, { label: x, block: n }),
|
|
3287
3283
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex gap-2 px-1", children: [
|
|
3288
3284
|
canAddChildBlock(get(n, "_type", "")) && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
3289
3285
|
PlusIcon,
|
|
@@ -3306,29 +3302,29 @@ const handleMouseMove = throttle((o) => {
|
|
|
3306
3302
|
}
|
|
3307
3303
|
) });
|
|
3308
3304
|
}, HeadTags = () => {
|
|
3309
|
-
const [o] = useBrandingOptions(), [n] = useSelectedBlockIds(), [r] = useDarkMode(), [a] = useSelectedStylingBlocks(), [l] = useAtom$1(draggedBlockAtom), [i] = useAtom$1(dropTargetBlockIdAtom), { document: c, window: d } = useFrame(), [
|
|
3305
|
+
const [o] = useBrandingOptions(), [n] = useSelectedBlockIds(), [r] = useDarkMode(), [a] = useSelectedStylingBlocks(), [l] = useAtom$1(draggedBlockAtom), [i] = useAtom$1(dropTargetBlockIdAtom), { document: c, window: d } = useFrame(), [u] = useState(c == null ? void 0 : c.getElementById("highlighted-block")), [p] = useState(
|
|
3310
3306
|
c == null ? void 0 : c.getElementById("selected-block")
|
|
3311
3307
|
), [m] = useState(
|
|
3312
3308
|
c == null ? void 0 : c.getElementById("selected-styling-block")
|
|
3313
|
-
), [
|
|
3309
|
+
), [g] = useState(
|
|
3314
3310
|
c == null ? void 0 : c.getElementById("dragged-block")
|
|
3315
3311
|
);
|
|
3316
3312
|
useEffect(() => {
|
|
3317
3313
|
r ? c == null || c.documentElement.classList.add("dark") : c == null || c.documentElement.classList.remove("dark");
|
|
3318
3314
|
}, [r, c]);
|
|
3319
|
-
const
|
|
3315
|
+
const x = get(o, "headingFont", "DM Sans"), j = get(o, "bodyFont", "DM Sans");
|
|
3320
3316
|
return useEffect(() => {
|
|
3321
|
-
const
|
|
3322
|
-
colors: [
|
|
3317
|
+
const E = get(o, "primaryColor", "#000"), b = get(o, "secondaryColor", "#FFF"), k = get(o, "bodyBgLightColor", "#fff"), _ = get(o, "bodyBgDarkColor", "#000"), S = get(o, "bodyTextDarkColor", "#000"), B = get(o, "bodyTextLightColor", "#fff"), R = s({
|
|
3318
|
+
colors: [E, b],
|
|
3323
3319
|
names: ["primary", "secondary"]
|
|
3324
3320
|
});
|
|
3325
|
-
set(
|
|
3321
|
+
set(R, "primary.DEFAULT", E), set(R, "secondary.DEFAULT", b);
|
|
3326
3322
|
const A = {
|
|
3327
|
-
"bg-light":
|
|
3323
|
+
"bg-light": k,
|
|
3328
3324
|
"bg-dark": _,
|
|
3329
|
-
"text-dark":
|
|
3325
|
+
"text-dark": S,
|
|
3330
3326
|
"text-light": B
|
|
3331
|
-
},
|
|
3327
|
+
}, T = get(o, "roundedCorners", "0");
|
|
3332
3328
|
!d || !d.tailwind || (d.tailwind.config = {
|
|
3333
3329
|
darkMode: "class",
|
|
3334
3330
|
theme: {
|
|
@@ -3341,73 +3337,73 @@ const handleMouseMove = throttle((o) => {
|
|
|
3341
3337
|
}
|
|
3342
3338
|
},
|
|
3343
3339
|
fontFamily: {
|
|
3344
|
-
heading: [
|
|
3345
|
-
body: [
|
|
3340
|
+
heading: [x],
|
|
3341
|
+
body: [j]
|
|
3346
3342
|
},
|
|
3347
3343
|
borderRadius: {
|
|
3348
|
-
DEFAULT: `${
|
|
3344
|
+
DEFAULT: `${T || "0"}px`
|
|
3349
3345
|
},
|
|
3350
|
-
colors: { ...A, ...
|
|
3346
|
+
colors: { ...A, ...R }
|
|
3351
3347
|
}
|
|
3352
3348
|
},
|
|
3353
3349
|
plugins: [
|
|
3354
3350
|
typography$1,
|
|
3355
3351
|
forms,
|
|
3356
3352
|
aspectRatio,
|
|
3357
|
-
plugin(function({ addBase:
|
|
3358
|
-
|
|
3353
|
+
plugin(function({ addBase: L, theme: P }) {
|
|
3354
|
+
L({
|
|
3359
3355
|
"h1,h2,h3,h4,h5,h6": {
|
|
3360
|
-
fontFamily:
|
|
3356
|
+
fontFamily: P("fontFamily.heading")
|
|
3361
3357
|
},
|
|
3362
3358
|
body: {
|
|
3363
|
-
fontFamily:
|
|
3364
|
-
color:
|
|
3365
|
-
backgroundColor:
|
|
3359
|
+
fontFamily: P("fontFamily.body"),
|
|
3360
|
+
color: P("colors.text-light"),
|
|
3361
|
+
backgroundColor: P("colors.bg-light")
|
|
3366
3362
|
},
|
|
3367
3363
|
".dark body": {
|
|
3368
|
-
color:
|
|
3369
|
-
backgroundColor:
|
|
3364
|
+
color: P("colors.text-dark"),
|
|
3365
|
+
backgroundColor: P("colors.bg-dark")
|
|
3370
3366
|
}
|
|
3371
3367
|
});
|
|
3372
3368
|
})
|
|
3373
3369
|
]
|
|
3374
3370
|
});
|
|
3375
|
-
}, [o, d,
|
|
3376
|
-
|
|
3371
|
+
}, [o, d, x, j]), useEffect(() => {
|
|
3372
|
+
p && (p.textContent = `${map(n, (E) => `[data-block-id="${E}"]`).join(",")}{
|
|
3377
3373
|
outline: 1px solid ${n.length === 1 ? "#42a1fc" : "orange"} !important; outline-offset: -1px;
|
|
3378
3374
|
}`);
|
|
3379
|
-
}, [n,
|
|
3380
|
-
|
|
3381
|
-
}, [l,
|
|
3382
|
-
|
|
3383
|
-
}, [
|
|
3384
|
-
m && (m.textContent = `${map(a, ({ id:
|
|
3375
|
+
}, [n, p]), useEffect(() => {
|
|
3376
|
+
g.textContent = l ? `[data-block-id="${l._id}"], [data-block-id="${l._id}"] > * { pointer-events: none !important; opacity: 0.6 !important}` : "";
|
|
3377
|
+
}, [l, g]), useEffect(() => {
|
|
3378
|
+
u && (u.textContent = '[data-highlighted="true"]{ outline: 1px solid #42a1fc !important; outline-offset: -1px;}');
|
|
3379
|
+
}, [u]), useEffect(() => {
|
|
3380
|
+
m && (m.textContent = `${map(a, ({ id: E }) => `[data-style-id="${E}"]`).join(",")}{
|
|
3385
3381
|
outline: 1px solid #42a1fc !important; outline-offset: -1px;
|
|
3386
3382
|
}`);
|
|
3387
3383
|
}, [a, m]), useEffect(() => {
|
|
3388
3384
|
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: (
|
|
3385
|
+
}, [i]), /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: (x || j) && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
3390
3386
|
"link",
|
|
3391
3387
|
{
|
|
3392
3388
|
rel: "stylesheet",
|
|
3393
|
-
href: `https://fonts.googleapis.com/css2?family=${
|
|
3389
|
+
href: `https://fonts.googleapis.com/css2?family=${x ? `${x.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` : ""}${x && j && x !== j ? "&" : ""}${j && j !== x ? `family=${j.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`
|
|
3394
3390
|
}
|
|
3395
3391
|
) });
|
|
3396
3392
|
}, useChaiExternalData = () => useAtom$1(chaiExternalDataAtom), useCanvasSettings = () => useAtom$1(canvasSettingsAtom), isVisibleAtBreakpoint = (o, n) => {
|
|
3397
3393
|
const r = ["xs", "sm", "md", "lg", "xl", "2xl"], a = r.indexOf(n), l = o.split(" ");
|
|
3398
3394
|
let i = new Array(r.length).fill(!1);
|
|
3399
3395
|
for (const c of l) {
|
|
3400
|
-
let [d,
|
|
3401
|
-
|
|
3402
|
-
const
|
|
3403
|
-
if (
|
|
3404
|
-
const m = ["block", "flex", "inline", "inline-block", "inline-flex", "grid", "table"],
|
|
3405
|
-
if (m.includes(
|
|
3406
|
-
for (let
|
|
3407
|
-
i[
|
|
3408
|
-
else if (
|
|
3409
|
-
for (let
|
|
3410
|
-
i[
|
|
3396
|
+
let [d, u] = c.split(":");
|
|
3397
|
+
u || (u = d, d = "xs");
|
|
3398
|
+
const p = r.indexOf(d);
|
|
3399
|
+
if (p <= a) {
|
|
3400
|
+
const m = ["block", "flex", "inline", "inline-block", "inline-flex", "grid", "table"], g = ["hidden"];
|
|
3401
|
+
if (m.includes(u))
|
|
3402
|
+
for (let x = p; x < r.length; x++)
|
|
3403
|
+
i[x] = !0;
|
|
3404
|
+
else if (g.includes(u))
|
|
3405
|
+
for (let x = p; x < r.length; x++)
|
|
3406
|
+
i[x] = !1;
|
|
3411
3407
|
}
|
|
3412
3408
|
}
|
|
3413
3409
|
return i[a];
|
|
@@ -3426,24 +3422,24 @@ const handleMouseMove = throttle((o) => {
|
|
|
3426
3422
|
);
|
|
3427
3423
|
return { getRSCBlockMarkup: a, getRSCBlockState: l, reset: i };
|
|
3428
3424
|
}, useWatchRSCBlocks = () => {
|
|
3429
|
-
const [o] = useBlocksStore(), [n, r] = useAtom(rscBlocksStoreAtom), [a, l] = useAtom(rscBlocksLoadingStateAtom), i = useChaiBlocks(), c = useBuilderProp("getRSCBlock", async (
|
|
3430
|
-
var
|
|
3431
|
-
return (
|
|
3432
|
-
}).map((
|
|
3425
|
+
const [o] = useBlocksStore(), [n, r] = useAtom(rscBlocksStoreAtom), [a, l] = useAtom(rscBlocksLoadingStateAtom), i = useChaiBlocks(), c = useBuilderProp("getRSCBlock", async (u) => ""), d = useMemo(() => o.filter((p) => {
|
|
3426
|
+
var g;
|
|
3427
|
+
return (g = get(i, p._type)) == null ? void 0 : g.server;
|
|
3428
|
+
}).map((p) => p._id), [i, o]);
|
|
3433
3429
|
useEffect(() => {
|
|
3434
|
-
forEach(d, (
|
|
3435
|
-
if (get(n,
|
|
3430
|
+
forEach(d, (u) => {
|
|
3431
|
+
if (get(n, u, "") || get(a, `${u}.loading`, !1))
|
|
3436
3432
|
return;
|
|
3437
|
-
const
|
|
3438
|
-
l((m) => ({ ...m, [
|
|
3439
|
-
r((
|
|
3440
|
-
...
|
|
3441
|
-
[
|
|
3433
|
+
const p = o.find((m) => m._id === u);
|
|
3434
|
+
l((m) => ({ ...m, [u]: { loading: !0, error: null } })), c(p).then((m) => {
|
|
3435
|
+
r((g) => ({ ...g, [u]: m })), l((g) => ({
|
|
3436
|
+
...g,
|
|
3437
|
+
[u]: { loading: !1, error: null }
|
|
3442
3438
|
}));
|
|
3443
3439
|
}).catch((m) => {
|
|
3444
|
-
l((
|
|
3445
|
-
...
|
|
3446
|
-
[
|
|
3440
|
+
l((g) => ({
|
|
3441
|
+
...g,
|
|
3442
|
+
[u]: { loading: !1, error: m.message }
|
|
3447
3443
|
}));
|
|
3448
3444
|
});
|
|
3449
3445
|
});
|
|
@@ -3508,50 +3504,50 @@ function applyLanguage(o, n, r) {
|
|
|
3508
3504
|
}), a;
|
|
3509
3505
|
}
|
|
3510
3506
|
function BlocksRendererStatic({ blocks: o, allBlocks: n }) {
|
|
3511
|
-
const { selectedLang: r } = useLanguages(), [a] = useAtom$1(xShowBlocksAtom), [l] = useCutBlockIds(), [i] = useAtom$1(draggedBlockAtom), [c] = useAtom$1(dropTargetBlockIdAtom), [, d] = useCanvasWidth(), [
|
|
3512
|
-
(
|
|
3513
|
-
const
|
|
3514
|
-
return { ...
|
|
3507
|
+
const { selectedLang: r } = useLanguages(), [a] = useAtom$1(xShowBlocksAtom), [l] = useCutBlockIds(), [i] = useAtom$1(draggedBlockAtom), [c] = useAtom$1(dropTargetBlockIdAtom), [, d] = useCanvasWidth(), [u] = useCanvasSettings(), [p] = useHiddenBlockIds(), { getGlobalBlocks: m } = useGlobalBlocksStore(), g = useCallback((b) => getStyleAttrs(b, d), [d]), [x] = useChaiExternalData(), [j] = useAtom$1(inlineEditingActiveAtom), E = useCallback(
|
|
3508
|
+
(b) => b.reduce((k, _) => {
|
|
3509
|
+
const S = get(u, _, {});
|
|
3510
|
+
return { ...k, ...S };
|
|
3515
3511
|
}, {}),
|
|
3516
|
-
[
|
|
3512
|
+
[u]
|
|
3517
3513
|
);
|
|
3518
3514
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: React__default.Children.toArray(
|
|
3519
|
-
o.map((
|
|
3520
|
-
if (
|
|
3515
|
+
o.map((b, k) => {
|
|
3516
|
+
if (j === b._id || p.includes(b._id))
|
|
3521
3517
|
return null;
|
|
3522
|
-
const _ = {},
|
|
3523
|
-
if (_.children =
|
|
3524
|
-
const
|
|
3525
|
-
_.children = /* @__PURE__ */ jsxRuntimeExports.jsx(RenderGlobalBlock, { blocks: filter(
|
|
3518
|
+
const _ = {}, S = filter(n, { _parent: b._id });
|
|
3519
|
+
if (_.children = S.length > 0 ? /* @__PURE__ */ jsxRuntimeExports.jsx(BlocksRendererStatic, { allBlocks: n, blocks: S }) : null, b._type === "GlobalBlock") {
|
|
3520
|
+
const C = m(b);
|
|
3521
|
+
_.children = /* @__PURE__ */ jsxRuntimeExports.jsx(RenderGlobalBlock, { blocks: filter(C, (w) => !w._parent), allBlocks: C });
|
|
3526
3522
|
}
|
|
3527
|
-
const B = getBlockComponent(
|
|
3523
|
+
const B = getBlockComponent(b._type), R = get(B, "server", !1), A = R ? RSCBlock : get(B, "builderComponent", get(B, "component", null));
|
|
3528
3524
|
if (isNull(A))
|
|
3529
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx("noscript", { children: `<!-- ${
|
|
3530
|
-
const
|
|
3531
|
-
if (get(
|
|
3525
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("noscript", { children: `<!-- ${b == null ? void 0 : b._type} not registered -->` });
|
|
3526
|
+
const T = has(B, "getBlockStateFrom") ? B == null ? void 0 : B.getBlockStateFrom(b, n) : [], L = E(T), P = g(b);
|
|
3527
|
+
if (get(P, "__isHidden", !1) && !includes(a, b._id))
|
|
3532
3528
|
return null;
|
|
3533
|
-
const
|
|
3534
|
-
...includes(a,
|
|
3535
|
-
"data-block-id":
|
|
3536
|
-
"data-block-type":
|
|
3529
|
+
const f = i && isDescendant(i._id, b._id, n), v = {
|
|
3530
|
+
...includes(a, b._id) ? { "force-show": "" } : {},
|
|
3531
|
+
"data-block-id": b._id,
|
|
3532
|
+
"data-block-type": b._type,
|
|
3537
3533
|
...i ? (
|
|
3538
3534
|
// @ts-ignore
|
|
3539
3535
|
{
|
|
3540
|
-
"data-dnd": canAcceptChildBlock(
|
|
3541
|
-
"data-dnd-dragged": i._id ===
|
|
3536
|
+
"data-dnd": canAcceptChildBlock(b._type, i == null ? void 0 : i._type) ? "yes" : "no",
|
|
3537
|
+
"data-dnd-dragged": i._id === b._id || f ? "yes" : "no"
|
|
3542
3538
|
}
|
|
3543
3539
|
) : {},
|
|
3544
|
-
...c ===
|
|
3545
|
-
...includes(l,
|
|
3540
|
+
...c === b._id && !f ? { "data-drop": "yes" } : {},
|
|
3541
|
+
...includes(l, b._id) ? { "data-cut-block": "yes" } : {}
|
|
3546
3542
|
};
|
|
3547
|
-
return
|
|
3548
|
-
blockProps:
|
|
3549
|
-
index:
|
|
3550
|
-
...applyBindings(applyLanguage(
|
|
3551
|
-
...omit(
|
|
3543
|
+
return R ? /* @__PURE__ */ jsxRuntimeExports.jsx(RSCBlock, { block: b, blockProps: v }) : /* @__PURE__ */ jsxRuntimeExports.jsx(Suspense, { children: React__default.createElement(A, {
|
|
3544
|
+
blockProps: v,
|
|
3545
|
+
index: k,
|
|
3546
|
+
...applyBindings(applyLanguage(b, r, B), x),
|
|
3547
|
+
...omit(P, ["__isHidden"]),
|
|
3552
3548
|
..._,
|
|
3553
3549
|
inBuilder: !0,
|
|
3554
|
-
blockState:
|
|
3550
|
+
blockState: L
|
|
3555
3551
|
}) });
|
|
3556
3552
|
})
|
|
3557
3553
|
) });
|
|
@@ -3563,7 +3559,7 @@ const useAllDataProviders = () => useMemo(() => getChaiDataProviders(), []), Blo
|
|
|
3563
3559
|
if (i) {
|
|
3564
3560
|
const c = (i == null ? void 0 : i.mockFn) || (i == null ? void 0 : i.dataFn);
|
|
3565
3561
|
c && c(l.args).then(
|
|
3566
|
-
(d) => n((
|
|
3562
|
+
(d) => n((u) => ({ ...u, [l.providerKey]: d }))
|
|
3567
3563
|
);
|
|
3568
3564
|
}
|
|
3569
3565
|
}), () => {
|
|
@@ -3601,47 +3597,47 @@ const useAllDataProviders = () => useMemo(() => getChaiDataProviders(), []), Blo
|
|
|
3601
3597
|
n(i);
|
|
3602
3598
|
}, []), /* @__PURE__ */ jsxRuntimeExports.jsx("div", { id: "main-content", className: "h-full w-full p-8 pb-0", ref: a, children: o });
|
|
3603
3599
|
}, getElementByStyleId = (o, n) => o.querySelector(`[data-style-id="${n}"]`), StaticCanvas = () => {
|
|
3604
|
-
const [o] = useAtom$1(networkModeAtom), [n] = useCanvasWidth(), [, r] = useSelectedBlockIds(), a = useSelectedBlock(), [, l] = useHighlightBlockId(), i = useRef(null), c = useRef(null), [d,
|
|
3605
|
-
|
|
3600
|
+
const [o] = useAtom$1(networkModeAtom), [n] = useCanvasWidth(), [, r] = useSelectedBlockIds(), a = useSelectedBlock(), [, l] = useHighlightBlockId(), i = useRef(null), c = useRef(null), [d, u] = useState({ width: 0, height: 0 }), p = useCanvasScale(d), [m, g] = useState([]), [, x] = useState([]), [, j] = useAtom$1(canvasIframeAtom), [E, b] = useSelectedStylingBlocks(), k = useBuilderProp("loading", !1), _ = useBuilderProp("htmlDir", "ltr"), S = (A) => {
|
|
3601
|
+
u((T) => ({ ...T, width: A }));
|
|
3606
3602
|
};
|
|
3607
3603
|
useEffect(() => {
|
|
3608
3604
|
if (!c.current)
|
|
3609
3605
|
return;
|
|
3610
|
-
const { clientWidth: A, clientHeight:
|
|
3611
|
-
|
|
3606
|
+
const { clientWidth: A, clientHeight: T } = c.current;
|
|
3607
|
+
u({ width: A, height: T });
|
|
3612
3608
|
}, [c, n]);
|
|
3613
|
-
const B = (A,
|
|
3614
|
-
const { top:
|
|
3615
|
-
return
|
|
3609
|
+
const B = (A, T = 0) => {
|
|
3610
|
+
const { top: L } = A.getBoundingClientRect();
|
|
3611
|
+
return L + T >= 0 && L - T <= window.innerHeight;
|
|
3616
3612
|
};
|
|
3617
3613
|
useEffect(() => {
|
|
3618
|
-
var A,
|
|
3614
|
+
var A, T;
|
|
3619
3615
|
if (a && a.type !== "Multiple" && i.current) {
|
|
3620
|
-
const
|
|
3621
|
-
|
|
3616
|
+
const L = getElementByDataBlockId(i.current.contentDocument, a._id);
|
|
3617
|
+
L && (B(L) || (T = (A = i.current) == null ? void 0 : A.contentWindow) == null || T.scrollTo({ top: L.offsetTop, behavior: "smooth" }), g([L]));
|
|
3622
3618
|
}
|
|
3623
3619
|
}, [a]), useEffect(() => {
|
|
3624
|
-
if (!isEmpty(
|
|
3620
|
+
if (!isEmpty(E) && i.current) {
|
|
3625
3621
|
const A = getElementByStyleId(
|
|
3626
3622
|
i.current.contentDocument,
|
|
3627
|
-
first(
|
|
3623
|
+
first(E).id
|
|
3628
3624
|
);
|
|
3629
|
-
|
|
3625
|
+
x(A ? [A] : [null]);
|
|
3630
3626
|
} else
|
|
3631
|
-
|
|
3632
|
-
}, [
|
|
3633
|
-
const
|
|
3627
|
+
x([null]);
|
|
3628
|
+
}, [E]);
|
|
3629
|
+
const R = useMemo(() => {
|
|
3634
3630
|
let A = IframeInitialContent;
|
|
3635
3631
|
return A = A.replace("__HTML_DIR__", _), o === "offline" && (A = A.replace(
|
|
3636
3632
|
"https://old.chaibuilder.com/offline/tailwind.cdn.js",
|
|
3637
3633
|
"/offline/tailwind.cdn.js"
|
|
3638
3634
|
), 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;
|
|
3639
3635
|
}, [o, _]);
|
|
3640
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(ResizableCanvasWrapper, { onMount:
|
|
3636
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(ResizableCanvasWrapper, { onMount: S, onResize: S, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
3641
3637
|
"div",
|
|
3642
3638
|
{
|
|
3643
3639
|
onClick: () => {
|
|
3644
|
-
r([]),
|
|
3640
|
+
r([]), b([]);
|
|
3645
3641
|
},
|
|
3646
3642
|
onMouseLeave: () => setTimeout(() => l(""), 300),
|
|
3647
3643
|
className: "relative mx-auto h-full w-full overflow-hidden",
|
|
@@ -3649,12 +3645,12 @@ const useAllDataProviders = () => useMemo(() => getChaiDataProviders(), []), Blo
|
|
|
3649
3645
|
children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
3650
3646
|
ChaiFrame,
|
|
3651
3647
|
{
|
|
3652
|
-
contentDidMount: () =>
|
|
3648
|
+
contentDidMount: () => j(i.current),
|
|
3653
3649
|
ref: i,
|
|
3654
3650
|
id: "canvas-iframe",
|
|
3655
|
-
style: { ...
|
|
3651
|
+
style: { ...p, ...isEmpty(p) ? { width: `${n}px` } : {} },
|
|
3656
3652
|
className: "relative mx-auto box-content h-full w-full max-w-full shadow-lg transition-all duration-300 ease-linear",
|
|
3657
|
-
initialContent:
|
|
3653
|
+
initialContent: R,
|
|
3658
3654
|
children: [
|
|
3659
3655
|
/* @__PURE__ */ jsxRuntimeExports.jsx(KeyboardHandler, {}),
|
|
3660
3656
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
@@ -3666,7 +3662,7 @@ const useAllDataProviders = () => useMemo(() => getChaiDataProviders(), []), Blo
|
|
|
3666
3662
|
),
|
|
3667
3663
|
/* @__PURE__ */ jsxRuntimeExports.jsx(HeadTags, {}),
|
|
3668
3664
|
/* @__PURE__ */ jsxRuntimeExports.jsx(Provider, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(Canvas, { children: [
|
|
3669
|
-
|
|
3665
|
+
k ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-full p-4", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-full" }) }) : /* @__PURE__ */ jsxRuntimeExports.jsx(StaticBlocksRenderer, {}),
|
|
3670
3666
|
/* @__PURE__ */ jsxRuntimeExports.jsx(AddBlockAtBottom, {}),
|
|
3671
3667
|
/* @__PURE__ */ jsxRuntimeExports.jsx("br", {}),
|
|
3672
3668
|
/* @__PURE__ */ jsxRuntimeExports.jsx("br", {}),
|
|
@@ -3777,7 +3773,7 @@ const useAllDataProviders = () => useMemo(() => getChaiDataProviders(), []), Blo
|
|
|
3777
3773
|
l !== o.length - 1 && /* @__PURE__ */ jsxRuntimeExports.jsx(ChevronRight, { className: "rtl:rotate-180", size: 16 })
|
|
3778
3774
|
] }, l))
|
|
3779
3775
|
] }) });
|
|
3780
|
-
}, CodeEditor$1 = React__default.lazy(() => import("./CodeEditor-
|
|
3776
|
+
}, CodeEditor$1 = React__default.lazy(() => import("./CodeEditor-lKbkdWrD.js")), CanvasArea = () => {
|
|
3781
3777
|
const [o] = useCodeEditor(), n = useBuilderProp("onError", noop);
|
|
3782
3778
|
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: [
|
|
3783
3779
|
/* @__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, {}) }) }),
|
|
@@ -3852,63 +3848,63 @@ const useAllDataProviders = () => useMemo(() => getChaiDataProviders(), []), Blo
|
|
|
3852
3848
|
showHeading: o = !0,
|
|
3853
3849
|
className: n = ""
|
|
3854
3850
|
}) => {
|
|
3855
|
-
const [r, a] = useBrandingOptions(), [l] = useBlocksContainer(), i = React.useRef(r), { t: c } = useTranslation(), d = ({ formData:
|
|
3856
|
-
A && (a(
|
|
3851
|
+
const [r, a] = useBrandingOptions(), [l] = useBlocksContainer(), i = React.useRef(r), { t: c } = useTranslation(), d = ({ formData: R }, A) => {
|
|
3852
|
+
A && (a(R), i.current = R);
|
|
3857
3853
|
}, {
|
|
3858
|
-
bodyFont:
|
|
3859
|
-
headingFont:
|
|
3854
|
+
bodyFont: u,
|
|
3855
|
+
headingFont: p,
|
|
3860
3856
|
primaryColor: m,
|
|
3861
|
-
bodyTextDarkColor:
|
|
3862
|
-
bodyTextLightColor:
|
|
3863
|
-
bodyBgDarkColor:
|
|
3864
|
-
secondaryColor:
|
|
3865
|
-
bodyBgLightColor:
|
|
3866
|
-
roundedCorners:
|
|
3857
|
+
bodyTextDarkColor: g,
|
|
3858
|
+
bodyTextLightColor: x,
|
|
3859
|
+
bodyBgDarkColor: j,
|
|
3860
|
+
secondaryColor: E,
|
|
3861
|
+
bodyBgLightColor: b,
|
|
3862
|
+
roundedCorners: k
|
|
3867
3863
|
} = r;
|
|
3868
3864
|
let _ = {
|
|
3869
3865
|
headingFont: y({
|
|
3870
3866
|
title: c("theme_config.heading_font"),
|
|
3871
|
-
default:
|
|
3867
|
+
default: p,
|
|
3872
3868
|
options: FONTS
|
|
3873
3869
|
}),
|
|
3874
3870
|
bodyFont: y({
|
|
3875
3871
|
title: c("theme_config.body_font"),
|
|
3876
|
-
default:
|
|
3872
|
+
default: u,
|
|
3877
3873
|
options: FONTS
|
|
3878
3874
|
}),
|
|
3879
3875
|
roundedCorners: s$1({
|
|
3880
3876
|
title: c("theme_config.rounded_corner"),
|
|
3881
|
-
default: parseInt(
|
|
3877
|
+
default: parseInt(k || 5, 10)
|
|
3882
3878
|
}),
|
|
3883
3879
|
primaryColor: h({ title: c("theme_config.primary"), default: m }),
|
|
3884
|
-
secondaryColor: h({ title: c("theme_config.secondary"), default:
|
|
3880
|
+
secondaryColor: h({ title: c("theme_config.secondary"), default: E })
|
|
3885
3881
|
};
|
|
3886
3882
|
l || (_ = {
|
|
3887
3883
|
..._,
|
|
3888
3884
|
bodyBgLightColor: h({
|
|
3889
3885
|
title: c("theme_config.background"),
|
|
3890
|
-
default:
|
|
3886
|
+
default: b
|
|
3891
3887
|
}),
|
|
3892
3888
|
bodyTextLightColor: h({
|
|
3893
3889
|
title: c("theme_config.text_color"),
|
|
3894
|
-
default:
|
|
3890
|
+
default: g
|
|
3895
3891
|
}),
|
|
3896
3892
|
bodyBgDarkColor: h({
|
|
3897
3893
|
title: c("theme_config.background_dark_mode"),
|
|
3898
|
-
default:
|
|
3894
|
+
default: j
|
|
3899
3895
|
}),
|
|
3900
3896
|
bodyTextDarkColor: h({
|
|
3901
3897
|
title: c("theme_config.text_color_dark_mode"),
|
|
3902
|
-
default:
|
|
3898
|
+
default: x
|
|
3903
3899
|
})
|
|
3904
3900
|
});
|
|
3905
|
-
const
|
|
3901
|
+
const S = {
|
|
3906
3902
|
type: "object",
|
|
3907
3903
|
properties: {}
|
|
3908
3904
|
}, B = {};
|
|
3909
|
-
return Object.keys(_).forEach((
|
|
3910
|
-
const A = _[
|
|
3911
|
-
return
|
|
3905
|
+
return Object.keys(_).forEach((R) => {
|
|
3906
|
+
const A = _[R];
|
|
3907
|
+
return S.properties || (S.properties = {}), S.properties[R] = A.schema, B[R] = A.uiSchema, !0;
|
|
3912
3908
|
}), /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: cn("flex h-full w-full select-none flex-col", n), children: [
|
|
3913
3909
|
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,
|
|
3914
3910
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
@@ -3921,7 +3917,7 @@ const useAllDataProviders = () => useMemo(() => getChaiDataProviders(), []), Blo
|
|
|
3921
3917
|
liveOmit: !0,
|
|
3922
3918
|
liveValidate: !0,
|
|
3923
3919
|
uiSchema: B,
|
|
3924
|
-
schema:
|
|
3920
|
+
schema: S,
|
|
3925
3921
|
formData: r,
|
|
3926
3922
|
validator,
|
|
3927
3923
|
onChange: d
|
|
@@ -4103,35 +4099,35 @@ function BiExpandVertical(o) {
|
|
|
4103
4099
|
}
|
|
4104
4100
|
const Node = memo(({ node: o, style: n, dragHandle: r }) => {
|
|
4105
4101
|
const a = useBuilderProp("outlineMenuItems", []), { t: l } = useTranslation(), [i, , c] = useHiddenBlockIds(), [d] = useAtom$1(canvasIframeAtom);
|
|
4106
|
-
let
|
|
4107
|
-
const
|
|
4108
|
-
|
|
4109
|
-
},
|
|
4110
|
-
|
|
4111
|
-
},
|
|
4112
|
-
|
|
4113
|
-
},
|
|
4114
|
-
|
|
4102
|
+
let u = null;
|
|
4103
|
+
const p = o.children.length > 0, { highlightBlock: m, clearHighlight: g } = useBlockHighlight(), { id: x, data: j, isSelected: E, willReceiveDrop: b, isDragging: k, isEditing: _, handleClick: S } = o, B = (f) => {
|
|
4104
|
+
f.stopPropagation(), !i.includes(x) && o.toggle();
|
|
4105
|
+
}, R = (f) => {
|
|
4106
|
+
f.isInternal && (u = f.isOpen, f.isOpen && f.close());
|
|
4107
|
+
}, A = (f) => {
|
|
4108
|
+
f.isInternal && u !== null && (u ? f.open() : f.close(), u = null);
|
|
4109
|
+
}, T = (f) => {
|
|
4110
|
+
f.stopPropagation(), !o.isOpen && !i.includes(x) && o.toggle(), S(f);
|
|
4115
4111
|
};
|
|
4116
4112
|
useEffect(() => {
|
|
4117
|
-
const
|
|
4118
|
-
b && !o.isOpen && !
|
|
4113
|
+
const f = setTimeout(() => {
|
|
4114
|
+
b && !o.isOpen && !k && !i.includes(x) && o.toggle();
|
|
4119
4115
|
}, 500);
|
|
4120
|
-
return () => clearTimeout(
|
|
4121
|
-
}, [b, o,
|
|
4122
|
-
const
|
|
4123
|
-
const
|
|
4124
|
-
for (let
|
|
4125
|
-
if (
|
|
4126
|
-
const w =
|
|
4127
|
-
|
|
4116
|
+
return () => clearTimeout(f);
|
|
4117
|
+
}, [b, o, k]);
|
|
4118
|
+
const L = useMemo(() => {
|
|
4119
|
+
const f = Object.keys(j), v = [];
|
|
4120
|
+
for (let C = 0; C < f.length; C++)
|
|
4121
|
+
if (f[C].endsWith("_attrs")) {
|
|
4122
|
+
const w = j[f[C]], I = Object.keys(w).join("|");
|
|
4123
|
+
I.match(/x-data/) && v.push("data"), I.match(/x-on/) && v.push("event"), I.match(/x-show|x-if/) && v.push("show");
|
|
4128
4124
|
}
|
|
4129
|
-
return
|
|
4130
|
-
}, [
|
|
4131
|
-
const
|
|
4132
|
-
w && w.setAttribute("data-drop",
|
|
4133
|
-
const
|
|
4134
|
-
|
|
4125
|
+
return v;
|
|
4126
|
+
}, [j]), P = (f, v) => {
|
|
4127
|
+
const C = d.contentDocument || d.contentWindow.document, w = C.querySelector(`[data-block-id=${f}]`);
|
|
4128
|
+
w && w.setAttribute("data-drop", v);
|
|
4129
|
+
const I = w.getBoundingClientRect(), N = d.getBoundingClientRect();
|
|
4130
|
+
I.top >= N.top && I.left >= N.left && I.bottom <= N.bottom && I.right <= N.right || (C.documentElement.scrollTop = w.offsetTop - N.top);
|
|
4135
4131
|
};
|
|
4136
4132
|
return x === ROOT_TEMP_KEY ? /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
4137
4133
|
"button",
|
|
@@ -4147,26 +4143,27 @@ const Node = memo(({ node: o, style: n, dragHandle: r }) => {
|
|
|
4147
4143
|
"div",
|
|
4148
4144
|
{
|
|
4149
4145
|
onMouseEnter: () => m(x),
|
|
4150
|
-
|
|
4146
|
+
onMouseLeave: () => g(),
|
|
4147
|
+
onClick: T,
|
|
4151
4148
|
style: n,
|
|
4152
4149
|
"data-node-id": x,
|
|
4153
4150
|
ref: i.includes(x) ? null : r,
|
|
4154
|
-
onDragStart: () =>
|
|
4155
|
-
onDragEnd: () =>
|
|
4156
|
-
onDragOver: (
|
|
4157
|
-
|
|
4151
|
+
onDragStart: () => R(o),
|
|
4152
|
+
onDragEnd: () => A(o),
|
|
4153
|
+
onDragOver: (f) => {
|
|
4154
|
+
f.preventDefault(), P(x, "yes");
|
|
4158
4155
|
},
|
|
4159
|
-
onDragLeave: (
|
|
4160
|
-
|
|
4156
|
+
onDragLeave: (f) => {
|
|
4157
|
+
f.preventDefault(), P(x, "no");
|
|
4161
4158
|
},
|
|
4162
|
-
onDrop: (
|
|
4163
|
-
|
|
4159
|
+
onDrop: (f) => {
|
|
4160
|
+
f.preventDefault(), P(x, "no");
|
|
4164
4161
|
},
|
|
4165
4162
|
className: cn(
|
|
4166
4163
|
"group flex !h-full w-full items-center justify-between space-x-px !rounded py-px text-foreground/80 outline-none",
|
|
4167
4164
|
E ? "bg-blue-500 text-white" : "hover:bg-gray-200 dark:hover:bg-gray-800",
|
|
4168
|
-
b && canAcceptChildBlock(
|
|
4169
|
-
|
|
4165
|
+
b && canAcceptChildBlock(j._type, "Icon") ? "bg-green-200" : "",
|
|
4166
|
+
k && "opacity-20",
|
|
4170
4167
|
i.includes(x) ? "opacity-50" : ""
|
|
4171
4168
|
),
|
|
4172
4169
|
children: [
|
|
@@ -4175,41 +4172,41 @@ const Node = memo(({ node: o, style: n, dragHandle: r }) => {
|
|
|
4175
4172
|
"div",
|
|
4176
4173
|
{
|
|
4177
4174
|
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" : ""}`,
|
|
4178
|
-
children:
|
|
4175
|
+
children: p && /* @__PURE__ */ jsxRuntimeExports.jsx("button", { onClick: B, type: "button", children: /* @__PURE__ */ jsxRuntimeExports.jsx(TriangleRightIcon, {}) })
|
|
4179
4176
|
}
|
|
4180
4177
|
),
|
|
4181
4178
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center", children: [
|
|
4182
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "-mt-0.5 h-3 w-3", children: /* @__PURE__ */ jsxRuntimeExports.jsx(TypeIcon, { type:
|
|
4183
|
-
|
|
4179
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "-mt-0.5 h-3 w-3", children: /* @__PURE__ */ jsxRuntimeExports.jsx(TypeIcon, { type: j == null ? void 0 : j._type }) }),
|
|
4180
|
+
_ ? /* @__PURE__ */ jsxRuntimeExports.jsx(Input, { node: o }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
4184
4181
|
"div",
|
|
4185
4182
|
{
|
|
4186
4183
|
className: "ml-2 flex items-center gap-x-1 truncate text-[11px]",
|
|
4187
|
-
onDoubleClick: (
|
|
4188
|
-
|
|
4184
|
+
onDoubleClick: (f) => {
|
|
4185
|
+
f.stopPropagation(), o.edit(), o.deselect();
|
|
4189
4186
|
},
|
|
4190
4187
|
children: [
|
|
4191
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: (
|
|
4192
|
-
|
|
4193
|
-
|
|
4194
|
-
|
|
4188
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: (j == null ? void 0 : j._name) || (j == null ? void 0 : j._type.split("/").pop()) }),
|
|
4189
|
+
L.includes("data") && /* @__PURE__ */ jsxRuntimeExports.jsx(VscJson, { className: "h-3 w-3 text-orange-600" }),
|
|
4190
|
+
L.includes("event") && /* @__PURE__ */ jsxRuntimeExports.jsx(BsLightningFill, { className: "h-3 w-3 text-yellow-500" }),
|
|
4191
|
+
L.includes("show") && /* @__PURE__ */ jsxRuntimeExports.jsx(TbEyeDown, { className: "h-3 w-3 text-orange-600" })
|
|
4195
4192
|
]
|
|
4196
4193
|
}
|
|
4197
4194
|
)
|
|
4198
4195
|
] })
|
|
4199
4196
|
] }),
|
|
4200
4197
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "invisible flex items-center space-x-1 pr-2 group-hover:visible", children: [
|
|
4201
|
-
!i.includes(x) && a.map((
|
|
4198
|
+
!i.includes(x) && a.map((f) => /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
|
|
4202
4199
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
4203
4200
|
TooltipTrigger,
|
|
4204
4201
|
{
|
|
4205
4202
|
className: "cursor-pointer rounded bg-transparent hover:bg-white hover:text-blue-500",
|
|
4206
4203
|
asChild: !0,
|
|
4207
|
-
children: React__default.createElement(
|
|
4204
|
+
children: React__default.createElement(f.item, { blockId: x })
|
|
4208
4205
|
}
|
|
4209
4206
|
),
|
|
4210
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { className: "isolate z-10", children:
|
|
4207
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { className: "isolate z-10", children: f.tooltip })
|
|
4211
4208
|
] })),
|
|
4212
|
-
canAddChildBlock(
|
|
4209
|
+
canAddChildBlock(j == null ? void 0 : j._type) && !i.includes(x) ? /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
|
|
4213
4210
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
4214
4211
|
TooltipTrigger,
|
|
4215
4212
|
{
|
|
@@ -4225,8 +4222,8 @@ const Node = memo(({ node: o, style: n, dragHandle: r }) => {
|
|
|
4225
4222
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
4226
4223
|
TooltipTrigger,
|
|
4227
4224
|
{
|
|
4228
|
-
onClick: (
|
|
4229
|
-
|
|
4225
|
+
onClick: (f) => {
|
|
4226
|
+
f.stopPropagation(), c(x), o.isOpen && o.toggle();
|
|
4230
4227
|
},
|
|
4231
4228
|
className: "cursor-pointer rounded bg-transparent hover:bg-white hover:text-black",
|
|
4232
4229
|
asChild: !0,
|
|
@@ -4454,7 +4451,10 @@ const Node = memo(({ node: o, style: n, dragHandle: r }) => {
|
|
|
4454
4451
|
multiple: "multiple",
|
|
4455
4452
|
name: "fieldName"
|
|
4456
4453
|
}
|
|
4457
|
-
}, shouldAddText = (o, n) => o.children.length === 1 && includes(
|
|
4454
|
+
}, shouldAddText = (o, n) => o.children.length === 1 && includes(
|
|
4455
|
+
["Heading", "Paragraph", "Span", "ListItem", "Button", "Label", "TableCell", "Link", "RichText"],
|
|
4456
|
+
n._type
|
|
4457
|
+
), 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) => {
|
|
4458
4458
|
if (o.tagName === "svg")
|
|
4459
4459
|
return {};
|
|
4460
4460
|
const n = {}, r = ATTRIBUTE_MAP[o.tagName] || {}, a = o.attributes;
|
|
@@ -4479,6 +4479,11 @@ const Node = memo(({ node: o, style: n, dragHandle: r }) => {
|
|
|
4479
4479
|
}
|
|
4480
4480
|
return { [n]: `${STYLES_KEY},` };
|
|
4481
4481
|
}, getBlockProps = (o) => {
|
|
4482
|
+
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");
|
|
4483
|
+
if (r)
|
|
4484
|
+
return { _type: "RichText" };
|
|
4485
|
+
if (a)
|
|
4486
|
+
return { _type: "LightBoxLink" };
|
|
4482
4487
|
switch (o.tagName) {
|
|
4483
4488
|
case "img":
|
|
4484
4489
|
return { _type: "Image" };
|
|
@@ -4550,46 +4555,77 @@ const Node = memo(({ node: o, style: n, dragHandle: r }) => {
|
|
|
4550
4555
|
return { _type: "TableBody" };
|
|
4551
4556
|
case "tfoot":
|
|
4552
4557
|
return { _type: "TableFooter" };
|
|
4553
|
-
default:
|
|
4554
|
-
const
|
|
4558
|
+
default: {
|
|
4559
|
+
const l = get(o, "children", []).length > 0 ? "Box" : "EmptyBox";
|
|
4555
4560
|
return {
|
|
4556
|
-
_type:
|
|
4561
|
+
_type: l,
|
|
4557
4562
|
tag: o.tagName,
|
|
4558
|
-
_name:
|
|
4563
|
+
_name: l == "EmptyBox" || o.tagName === "div" ? l : capitalize(o.tagName)
|
|
4559
4564
|
};
|
|
4565
|
+
}
|
|
4560
4566
|
}
|
|
4561
4567
|
}, traverseNodes = (o, n = null) => flatMapDeep(o, (r) => {
|
|
4562
|
-
var
|
|
4568
|
+
var u, p, m, g, x, j, E, b;
|
|
4563
4569
|
if (r.type === "comment")
|
|
4564
4570
|
return [];
|
|
4565
4571
|
let a = { _id: generateUUID() };
|
|
4566
4572
|
if (n && (a._parent = n.block._id), r.type === "text")
|
|
4567
4573
|
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", "") };
|
|
4574
|
+
const l = get(r, "attributes", []), i = l.find(
|
|
4575
|
+
(k) => k.key === "data-chai-richtext" || k.key === "chai-richtext"
|
|
4576
|
+
), c = l.find(
|
|
4577
|
+
(k) => k.key === "data-chai-lightbox" || k.key === "chai-lightbox"
|
|
4578
|
+
);
|
|
4568
4579
|
if (a = {
|
|
4569
4580
|
...a,
|
|
4570
4581
|
...getBlockProps(r),
|
|
4571
4582
|
...getAttrs(r),
|
|
4572
4583
|
...getStyles(r)
|
|
4573
4584
|
}, r.attributes) {
|
|
4574
|
-
const
|
|
4575
|
-
|
|
4585
|
+
const k = r.attributes.find((_) => _.key === NAME_ATTRIBUTE);
|
|
4586
|
+
k && (a._name = k.value);
|
|
4587
|
+
}
|
|
4588
|
+
if (i)
|
|
4589
|
+
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];
|
|
4590
|
+
if (c) {
|
|
4591
|
+
const k = [
|
|
4592
|
+
"data-chai-lightbox",
|
|
4593
|
+
"chai-lightbox",
|
|
4594
|
+
"data-vbtype",
|
|
4595
|
+
"data-autoplay",
|
|
4596
|
+
"data-maxwidth",
|
|
4597
|
+
"data-overlay",
|
|
4598
|
+
"data-gall",
|
|
4599
|
+
"href"
|
|
4600
|
+
];
|
|
4601
|
+
a = {
|
|
4602
|
+
...a,
|
|
4603
|
+
href: ((u = l.find((_) => _.key === "href")) == null ? void 0 : u.value) || "",
|
|
4604
|
+
hrefType: ((p = l.find((_) => _.key === "data-vbtype")) == null ? void 0 : p.value) || "video",
|
|
4605
|
+
autoplay: ((m = l.find((_) => _.key === "data-autoplay")) == null ? void 0 : m.value) === "true",
|
|
4606
|
+
maxWidth: ((x = (g = l.find((_) => _.key === "data-maxwidth")) == null ? void 0 : g.value) == null ? void 0 : x.replace("px", "")) || "",
|
|
4607
|
+
backdropColor: ((j = l.find((_) => _.key === "data-overlay")) == null ? void 0 : j.value) || "",
|
|
4608
|
+
galleryName: ((E = l.find((_) => _.key === "data-gall")) == null ? void 0 : E.value) || ""
|
|
4609
|
+
}, forEach(k, (_) => {
|
|
4610
|
+
has(a, `styles_attrs.${_}`) && delete a.styles_attrs[_];
|
|
4611
|
+
});
|
|
4576
4612
|
}
|
|
4577
4613
|
if (a._type === "Input") {
|
|
4578
|
-
const
|
|
4579
|
-
|
|
4614
|
+
const k = a.inputType || "text";
|
|
4615
|
+
k === "checkbox" ? set(a, "_type", "Checkbox") : k === "radio" && set(a, "_type", "Radio");
|
|
4580
4616
|
} else if (r.tagName === "video" || r.tagName === "iframe") {
|
|
4581
|
-
const
|
|
4582
|
-
return hasVideoEmbed(
|
|
4617
|
+
const k = stringify([r]);
|
|
4618
|
+
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];
|
|
4583
4619
|
} else if (r.tagName === "svg") {
|
|
4584
|
-
const
|
|
4585
|
-
return a.styles = `${STYLES_KEY}, ${cn(`w-${
|
|
4586
|
-
} else if (r.tagName == "option" && n && ((
|
|
4620
|
+
const k = find(r.attributes, { key: "height" }), _ = find(r.attributes, { key: "width" }), S = 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");
|
|
4621
|
+
return a.styles = `${STYLES_KEY}, ${cn(`w-${B} h-${S}`, R)}`.trim(), r.attributes = filter(r.attributes, (A) => !includes(["style", "width", "height", "class"], A.key)), a.icon = stringify([r]), [a];
|
|
4622
|
+
} else if (r.tagName == "option" && n && ((b = n.block) == null ? void 0 : b._type) === "Select")
|
|
4587
4623
|
return n.block.options.push({
|
|
4588
4624
|
label: getTextContent(r.children),
|
|
4589
4625
|
...getAttrs(r)
|
|
4590
4626
|
}), [];
|
|
4591
|
-
const
|
|
4592
|
-
return [a, ...
|
|
4627
|
+
const d = traverseNodes(r.children, { block: a, node: r });
|
|
4628
|
+
return [a, ...d];
|
|
4593
4629
|
}), getSanitizedHTML = (o) => {
|
|
4594
4630
|
const n = o.match(/<body[^>]*>[\s\S]*?<\/body>/);
|
|
4595
4631
|
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();
|
|
@@ -4641,63 +4677,63 @@ function ExpandableObject(o) {
|
|
|
4641
4677
|
openBracket: i,
|
|
4642
4678
|
closeBracket: c,
|
|
4643
4679
|
level: d,
|
|
4644
|
-
style:
|
|
4645
|
-
shouldExpandNode:
|
|
4680
|
+
style: u,
|
|
4681
|
+
shouldExpandNode: p,
|
|
4646
4682
|
clickToExpandNode: m
|
|
4647
4683
|
} = o;
|
|
4648
|
-
const
|
|
4684
|
+
const g = useRef(!1), [x, j, E] = useBool(() => p(d, r, n));
|
|
4649
4685
|
useEffect(() => {
|
|
4650
|
-
|
|
4651
|
-
}, [
|
|
4652
|
-
const
|
|
4653
|
-
A.key === " " && (A.preventDefault(),
|
|
4686
|
+
g.current ? E(p(d, r, n)) : g.current = !0;
|
|
4687
|
+
}, [p]);
|
|
4688
|
+
const b = x ? u.collapseIcon : u.expandIcon, k = x ? "collapse JSON" : "expand JSON", _ = useComponentId(), S = d + 1, B = a.length - 1, R = (A) => {
|
|
4689
|
+
A.key === " " && (A.preventDefault(), j());
|
|
4654
4690
|
};
|
|
4655
4691
|
return /* @__PURE__ */ createElement("div", {
|
|
4656
|
-
className:
|
|
4692
|
+
className: u.basicChildStyle,
|
|
4657
4693
|
role: "list"
|
|
4658
4694
|
}, /* @__PURE__ */ createElement("span", {
|
|
4659
|
-
className:
|
|
4660
|
-
onClick:
|
|
4661
|
-
onKeyDown:
|
|
4695
|
+
className: b,
|
|
4696
|
+
onClick: j,
|
|
4697
|
+
onKeyDown: R,
|
|
4662
4698
|
role: "button",
|
|
4663
4699
|
tabIndex: 0,
|
|
4664
|
-
"aria-label":
|
|
4665
|
-
"aria-expanded":
|
|
4666
|
-
"aria-controls":
|
|
4700
|
+
"aria-label": k,
|
|
4701
|
+
"aria-expanded": x,
|
|
4702
|
+
"aria-controls": x ? _ : void 0
|
|
4667
4703
|
}), n && (m ? /* @__PURE__ */ createElement("span", {
|
|
4668
|
-
className:
|
|
4669
|
-
onClick:
|
|
4670
|
-
onKeyDown:
|
|
4704
|
+
className: u.clickableLabel,
|
|
4705
|
+
onClick: j,
|
|
4706
|
+
onKeyDown: R,
|
|
4671
4707
|
role: "button",
|
|
4672
4708
|
tabIndex: -1
|
|
4673
4709
|
}, n, ":") : /* @__PURE__ */ createElement("span", {
|
|
4674
|
-
className:
|
|
4710
|
+
className: u.label
|
|
4675
4711
|
}, n, ":")), /* @__PURE__ */ createElement("span", {
|
|
4676
|
-
className:
|
|
4677
|
-
}, i),
|
|
4712
|
+
className: u.punctuation
|
|
4713
|
+
}, i), x ? /* @__PURE__ */ createElement("div", {
|
|
4678
4714
|
id: _
|
|
4679
|
-
}, a.map((A,
|
|
4680
|
-
key: A[0] ||
|
|
4715
|
+
}, a.map((A, T) => /* @__PURE__ */ createElement(DataRender, {
|
|
4716
|
+
key: A[0] || T,
|
|
4681
4717
|
field: A[0],
|
|
4682
4718
|
value: A[1],
|
|
4683
|
-
style:
|
|
4684
|
-
lastElement:
|
|
4685
|
-
level:
|
|
4686
|
-
shouldExpandNode:
|
|
4719
|
+
style: u,
|
|
4720
|
+
lastElement: T === B,
|
|
4721
|
+
level: S,
|
|
4722
|
+
shouldExpandNode: p,
|
|
4687
4723
|
clickToExpandNode: m
|
|
4688
4724
|
}))) : /* @__PURE__ */ createElement("span", {
|
|
4689
|
-
className:
|
|
4690
|
-
onClick:
|
|
4691
|
-
onKeyDown:
|
|
4725
|
+
className: u.collapsedContent,
|
|
4726
|
+
onClick: j,
|
|
4727
|
+
onKeyDown: R,
|
|
4692
4728
|
role: "button",
|
|
4693
4729
|
tabIndex: -1,
|
|
4694
4730
|
"aria-hidden": !0,
|
|
4695
|
-
"aria-label":
|
|
4696
|
-
"aria-expanded":
|
|
4731
|
+
"aria-label": k,
|
|
4732
|
+
"aria-expanded": x
|
|
4697
4733
|
}), /* @__PURE__ */ createElement("span", {
|
|
4698
|
-
className:
|
|
4734
|
+
className: u.punctuation
|
|
4699
4735
|
}, c), !l && /* @__PURE__ */ createElement("span", {
|
|
4700
|
-
className:
|
|
4736
|
+
className: u.punctuation
|
|
4701
4737
|
}, ","));
|
|
4702
4738
|
}
|
|
4703
4739
|
function JsonObject(o) {
|
|
@@ -4720,7 +4756,7 @@ function JsonObject(o) {
|
|
|
4720
4756
|
style: a,
|
|
4721
4757
|
shouldExpandNode: i,
|
|
4722
4758
|
clickToExpandNode: c,
|
|
4723
|
-
data: Object.keys(r).map((
|
|
4759
|
+
data: Object.keys(r).map((u) => [u, r[u]])
|
|
4724
4760
|
});
|
|
4725
4761
|
}
|
|
4726
4762
|
function JsonArray(o) {
|
|
@@ -4743,7 +4779,7 @@ function JsonArray(o) {
|
|
|
4743
4779
|
style: a,
|
|
4744
4780
|
shouldExpandNode: c,
|
|
4745
4781
|
clickToExpandNode: d,
|
|
4746
|
-
data: r.map((
|
|
4782
|
+
data: r.map((u) => [void 0, u])
|
|
4747
4783
|
});
|
|
4748
4784
|
}
|
|
4749
4785
|
function JsonPrimitiveValue(o) {
|
|
@@ -4807,8 +4843,8 @@ function getPathAndTypes(o) {
|
|
|
4807
4843
|
const n = [], r = {};
|
|
4808
4844
|
function a(l, i) {
|
|
4809
4845
|
forEach(i, (c, d) => {
|
|
4810
|
-
const
|
|
4811
|
-
n.push(
|
|
4846
|
+
const u = l ? `${l}.${d}` : d, p = isArray$1(c) ? "list" : typeof c;
|
|
4847
|
+
n.push(u), r[u] = p === "string" ? "text" : p === "object" ? "model" : p, p === "object" && !isArray$1(c) && a(u, c);
|
|
4812
4848
|
});
|
|
4813
4849
|
}
|
|
4814
4850
|
return a("", omit(o, ["styles", "_type", "_id", "_name", "_bindings"])), { paths: n, pathsType: r };
|
|
@@ -4846,15 +4882,15 @@ const ViewData = ({ data: o, fullView: n }) => {
|
|
|
4846
4882
|
dataType: i,
|
|
4847
4883
|
appliedBindings: c
|
|
4848
4884
|
}) => {
|
|
4849
|
-
const { paths: d, pathsType:
|
|
4850
|
-
(
|
|
4851
|
-
) : d.filter((
|
|
4885
|
+
const { paths: d, pathsType: u } = getPathAndTypes(a), p = o === "PROP" ? getBlockComponent(a == null ? void 0 : a._type) : {}, m = o === "PROP", [g, x] = useState(!1), j = useMemo(() => o === "PROP" ? d.filter(
|
|
4886
|
+
(E) => !includes(c, E) && get(p, `props.${first(split(E, "."))}.binding`)
|
|
4887
|
+
) : d.filter((E) => i === get(u, E, "")), [o, d, c, i, p]);
|
|
4852
4888
|
return useEffect(() => {
|
|
4853
4889
|
n && l(n);
|
|
4854
4890
|
}, [n, o]), /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
4855
4891
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center space-x-4", children: [
|
|
4856
4892
|
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-muted-foreground", children: startCase(toLower(o)) }),
|
|
4857
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs(Popover, { open:
|
|
4893
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(Popover, { open: g, onOpenChange: x, children: [
|
|
4858
4894
|
/* @__PURE__ */ jsxRuntimeExports.jsx(PopoverTrigger, { asChild: !0, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
4859
4895
|
Button,
|
|
4860
4896
|
{
|
|
@@ -4877,23 +4913,23 @@ const ViewData = ({ data: o, fullView: n }) => {
|
|
|
4877
4913
|
/* @__PURE__ */ jsxRuntimeExports.jsx(CommandInput, { placeholder: `Choose ${toLower(o)}...` }),
|
|
4878
4914
|
/* @__PURE__ */ jsxRuntimeExports.jsxs(CommandList, { children: [
|
|
4879
4915
|
/* @__PURE__ */ jsxRuntimeExports.jsx(CommandEmpty, { children: "No results found." }),
|
|
4880
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(CommandGroup, { children: map(
|
|
4916
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(CommandGroup, { children: map(j, (E) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
4881
4917
|
CommandItem,
|
|
4882
4918
|
{
|
|
4883
|
-
value:
|
|
4919
|
+
value: E,
|
|
4884
4920
|
className: `cursor-pointer ${m ? "flex items-center justify-between" : "flex flex-col items-start justify-start"}`,
|
|
4885
|
-
onSelect: (
|
|
4886
|
-
r(find(
|
|
4921
|
+
onSelect: (b) => {
|
|
4922
|
+
r(find(j, (k) => k === b) || null), x(!1);
|
|
4887
4923
|
},
|
|
4888
4924
|
children: [
|
|
4889
4925
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-x-2", children: [
|
|
4890
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(Check, { className: `h-4 w-4 text-green-500 ${n ===
|
|
4891
|
-
|
|
4926
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Check, { className: `h-4 w-4 text-green-500 ${n === E ? "" : "opacity-0"}` }),
|
|
4927
|
+
E
|
|
4892
4928
|
] }),
|
|
4893
|
-
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(
|
|
4929
|
+
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(u, E, "")) }) }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "pl-6", children: /* @__PURE__ */ jsxRuntimeExports.jsx(ViewData, { data: get(a, E) }) })
|
|
4894
4930
|
]
|
|
4895
4931
|
},
|
|
4896
|
-
|
|
4932
|
+
E
|
|
4897
4933
|
)) })
|
|
4898
4934
|
] })
|
|
4899
4935
|
] }) })
|
|
@@ -4907,20 +4943,20 @@ const ViewData = ({ data: o, fullView: n }) => {
|
|
|
4907
4943
|
editMode: r,
|
|
4908
4944
|
item: a
|
|
4909
4945
|
}) => {
|
|
4910
|
-
const [l, i] = useState(r ? a.key : ""), [c, d] = useState(r ? a.value : ""),
|
|
4911
|
-
(
|
|
4912
|
-
if (isEmpty(
|
|
4946
|
+
const [l, i] = useState(r ? a.key : ""), [c, d] = useState(r ? a.value : ""), u = useSelectedBlock(), [p] = useChaiExternalData(), m = useCallback(
|
|
4947
|
+
(j, E) => {
|
|
4948
|
+
if (isEmpty(j))
|
|
4913
4949
|
return "";
|
|
4914
4950
|
{
|
|
4915
|
-
const
|
|
4916
|
-
if (isArray$1(
|
|
4951
|
+
const b = get(E === "PROP" ? u : p, j, "");
|
|
4952
|
+
if (isArray$1(b))
|
|
4917
4953
|
return "list";
|
|
4918
|
-
const
|
|
4919
|
-
return
|
|
4954
|
+
const k = typeof b;
|
|
4955
|
+
return k === "string" ? "text" : k === "object" ? "model" : k;
|
|
4920
4956
|
}
|
|
4921
4957
|
},
|
|
4922
|
-
[
|
|
4923
|
-
), [
|
|
4958
|
+
[u, p]
|
|
4959
|
+
), [g, x] = useState(r ? m(a.key, "PROP") : "");
|
|
4924
4960
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
4925
4961
|
/* @__PURE__ */ jsxRuntimeExports.jsxs(DialogHeader, { children: [
|
|
4926
4962
|
/* @__PURE__ */ jsxRuntimeExports.jsx(DialogTitle, { children: "Add Data Binding" }),
|
|
@@ -4935,12 +4971,12 @@ const ViewData = ({ data: o, fullView: n }) => {
|
|
|
4935
4971
|
placeholder: "Enter prop key",
|
|
4936
4972
|
value: l,
|
|
4937
4973
|
setValue: i,
|
|
4938
|
-
onChange: (
|
|
4939
|
-
const
|
|
4940
|
-
i(
|
|
4974
|
+
onChange: (j) => {
|
|
4975
|
+
const E = m(j, "PROP");
|
|
4976
|
+
i(j), g !== E && d(""), x(E);
|
|
4941
4977
|
},
|
|
4942
|
-
data:
|
|
4943
|
-
dataType:
|
|
4978
|
+
data: u,
|
|
4979
|
+
dataType: g,
|
|
4944
4980
|
appliedBindings: o
|
|
4945
4981
|
}
|
|
4946
4982
|
),
|
|
@@ -4953,12 +4989,12 @@ const ViewData = ({ data: o, fullView: n }) => {
|
|
|
4953
4989
|
placeholder: "Enter data path",
|
|
4954
4990
|
value: c,
|
|
4955
4991
|
setValue: d,
|
|
4956
|
-
onChange: (
|
|
4957
|
-
const
|
|
4958
|
-
d(
|
|
4992
|
+
onChange: (j) => {
|
|
4993
|
+
const E = m(j, "PATH");
|
|
4994
|
+
d(g === E ? j : "");
|
|
4959
4995
|
},
|
|
4960
|
-
data:
|
|
4961
|
-
dataType:
|
|
4996
|
+
data: p,
|
|
4997
|
+
dataType: g,
|
|
4962
4998
|
appliedBindings: o
|
|
4963
4999
|
}
|
|
4964
5000
|
)
|
|
@@ -4984,8 +5020,8 @@ const ViewData = ({ data: o, fullView: n }) => {
|
|
|
4984
5020
|
item: i,
|
|
4985
5021
|
editMode: l,
|
|
4986
5022
|
appliedBindings: a,
|
|
4987
|
-
onAddBinding: (
|
|
4988
|
-
r(
|
|
5023
|
+
onAddBinding: (u) => {
|
|
5024
|
+
r(u), d(!1);
|
|
4989
5025
|
}
|
|
4990
5026
|
}
|
|
4991
5027
|
) })
|
|
@@ -4998,18 +5034,18 @@ const ViewData = ({ data: o, fullView: n }) => {
|
|
|
4998
5034
|
dataProvider: l,
|
|
4999
5035
|
appliedBindings: i
|
|
5000
5036
|
}) => {
|
|
5001
|
-
const [c, d] = useState("string"),
|
|
5002
|
-
if (isEmpty(
|
|
5037
|
+
const [c, d] = useState("string"), u = (p, m) => {
|
|
5038
|
+
if (isEmpty(p))
|
|
5003
5039
|
return "";
|
|
5004
5040
|
{
|
|
5005
|
-
const
|
|
5006
|
-
if (isArray$1(
|
|
5041
|
+
const g = get(m === "PROP" ? a : l, p, "");
|
|
5042
|
+
if (isArray$1(g))
|
|
5007
5043
|
return "list";
|
|
5008
|
-
const
|
|
5009
|
-
return
|
|
5044
|
+
const x = typeof g;
|
|
5045
|
+
return x === "string" ? "text" : x === "object" ? "model" : x;
|
|
5010
5046
|
}
|
|
5011
5047
|
};
|
|
5012
|
-
return useEffect(() => d(() =>
|
|
5048
|
+
return useEffect(() => d(() => u(o.key, "PROP")), [o.key]), /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "relative flex flex-col rounded-md border border-border p-2", children: [
|
|
5013
5049
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-sm font-normal text-gray-500", children: o.key }),
|
|
5014
5050
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "font-medium leading-5", children: o.value }),
|
|
5015
5051
|
/* @__PURE__ */ jsxRuntimeExports.jsx(ViewData, { data: get(l, o.value, "") }),
|
|
@@ -5027,34 +5063,34 @@ const ViewData = ({ data: o, fullView: n }) => {
|
|
|
5027
5063
|
] });
|
|
5028
5064
|
}, DataBindingSetting = ({ bindingData: o, onChange: n }) => {
|
|
5029
5065
|
const r = useSelectedBlock(), [a] = useChaiExternalData(), l = getChaiDataProviders(), [i, c] = useState(
|
|
5030
|
-
map(o, (
|
|
5066
|
+
map(o, (g, x) => ({ key: x, value: g }))
|
|
5031
5067
|
);
|
|
5032
5068
|
useEffect(() => {
|
|
5033
|
-
c(map(o, (
|
|
5069
|
+
c(map(o, (g, x) => ({ key: x, value: g })));
|
|
5034
5070
|
}, [r == null ? void 0 : r._id, o]);
|
|
5035
5071
|
const d = useMemo(() => {
|
|
5036
5072
|
if (isEmpty(a))
|
|
5037
5073
|
return !0;
|
|
5038
5074
|
if (isEmpty(i))
|
|
5039
5075
|
return !1;
|
|
5040
|
-
const
|
|
5041
|
-
return isEmpty(
|
|
5042
|
-
}, [a, i]),
|
|
5043
|
-
const
|
|
5044
|
-
c([...
|
|
5045
|
-
},
|
|
5046
|
-
const
|
|
5047
|
-
m([...
|
|
5076
|
+
const g = last(i);
|
|
5077
|
+
return isEmpty(g == null ? void 0 : g.key) || isEmpty(g == null ? void 0 : g.value);
|
|
5078
|
+
}, [a, i]), u = (g) => {
|
|
5079
|
+
const x = filter(i, (j) => j.key !== g.key);
|
|
5080
|
+
c([...x, g]), m([...x, g]);
|
|
5081
|
+
}, p = (g) => {
|
|
5082
|
+
const x = filter(i, (j, E) => g !== E);
|
|
5083
|
+
m([...x]);
|
|
5048
5084
|
}, m = useCallback(
|
|
5049
|
-
(
|
|
5050
|
-
if (c(
|
|
5085
|
+
(g = []) => {
|
|
5086
|
+
if (c(g), isEmpty(g)) {
|
|
5051
5087
|
n({});
|
|
5052
5088
|
return;
|
|
5053
5089
|
}
|
|
5054
|
-
const
|
|
5055
|
-
forEach(
|
|
5056
|
-
!isEmpty(
|
|
5057
|
-
}), n(
|
|
5090
|
+
const x = {};
|
|
5091
|
+
forEach(g, (j) => {
|
|
5092
|
+
!isEmpty(j == null ? void 0 : j.key) && !isEmpty(j == null ? void 0 : j.value) && set(x, j.key, j.value);
|
|
5093
|
+
}), n(x);
|
|
5058
5094
|
},
|
|
5059
5095
|
[n]
|
|
5060
5096
|
);
|
|
@@ -5063,17 +5099,17 @@ const ViewData = ({ data: o, fullView: n }) => {
|
|
|
5063
5099
|
/* @__PURE__ */ jsxRuntimeExports.jsx("br", {}),
|
|
5064
5100
|
/* @__PURE__ */ jsxRuntimeExports.jsx("a", { className: "text-blue-500", href: "https://chaibuilder.com/docs/registering-data-providers", target: "_blank", children: "Learn more" })
|
|
5065
5101
|
] }) }) : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [
|
|
5066
|
-
map(i, (
|
|
5102
|
+
map(i, (g, x) => /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
5067
5103
|
NewDataBindingPair,
|
|
5068
5104
|
{
|
|
5069
|
-
item:
|
|
5070
|
-
onAddBinding:
|
|
5071
|
-
onRemove: () =>
|
|
5105
|
+
item: g,
|
|
5106
|
+
onAddBinding: u,
|
|
5107
|
+
onRemove: () => p(x),
|
|
5072
5108
|
selectedBlock: r,
|
|
5073
5109
|
dataProvider: a,
|
|
5074
5110
|
appliedBindings: map(i, "key")
|
|
5075
5111
|
},
|
|
5076
|
-
|
|
5112
|
+
g.key
|
|
5077
5113
|
)),
|
|
5078
5114
|
/* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { delayDuration: 200, children: [
|
|
5079
5115
|
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { disabled: isEmpty(a), className: "w-full", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
@@ -5081,7 +5117,7 @@ const ViewData = ({ data: o, fullView: n }) => {
|
|
|
5081
5117
|
{
|
|
5082
5118
|
disabled: d,
|
|
5083
5119
|
appliedBindings: map(i, "key"),
|
|
5084
|
-
onAddBinding:
|
|
5120
|
+
onAddBinding: u,
|
|
5085
5121
|
children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
5086
5122
|
"span",
|
|
5087
5123
|
{
|
|
@@ -5162,7 +5198,7 @@ const ViewData = ({ data: o, fullView: n }) => {
|
|
|
5162
5198
|
}
|
|
5163
5199
|
)
|
|
5164
5200
|
] });
|
|
5165
|
-
}, UnsplashImages = React__default.lazy(() => import("./UnsplashImages-
|
|
5201
|
+
}, UnsplashImages = React__default.lazy(() => import("./UnsplashImages-nAe1gyu9.js")), UploadImages = React__default.lazy(() => import("./UploadImages-PygaZXFU.js")), ImagesPanel = ({
|
|
5166
5202
|
isModalView: o = !1,
|
|
5167
5203
|
onSelect: n = () => {
|
|
5168
5204
|
}
|
|
@@ -5172,7 +5208,7 @@ const ViewData = ({ data: o, fullView: n }) => {
|
|
|
5172
5208
|
);
|
|
5173
5209
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex h-full flex-col", children: [
|
|
5174
5210
|
/* @__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" }) }),
|
|
5175
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs(Tabs, { value: c, onValueChange: (
|
|
5211
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(Tabs, { value: c, onValueChange: (u) => d(u), className: "flex h-full w-full flex-col py-2", children: [
|
|
5176
5212
|
!(l || i) && /* @__PURE__ */ jsxRuntimeExports.jsxs(TabsList, { className: "w-full", children: [
|
|
5177
5213
|
/* @__PURE__ */ jsxRuntimeExports.jsx(TabsTrigger, { value: "upload", className: "w-full", children: "Upload" }),
|
|
5178
5214
|
/* @__PURE__ */ jsxRuntimeExports.jsx(TabsTrigger, { value: "unsplash", className: "w-full", children: "Unsplash" })
|
|
@@ -5209,8 +5245,8 @@ const ImagePickerModal$1 = ImagePickerModal, ImagePickerField = ({ value: o, onC
|
|
|
5209
5245
|
className: "text-xs",
|
|
5210
5246
|
placeholder: c("enter_image_url"),
|
|
5211
5247
|
value: o,
|
|
5212
|
-
onBlur: ({ target: { value:
|
|
5213
|
-
onChange: (
|
|
5248
|
+
onBlur: ({ target: { value: u } }) => a(r, u),
|
|
5249
|
+
onChange: (u) => n(u.target.value)
|
|
5214
5250
|
}
|
|
5215
5251
|
)
|
|
5216
5252
|
] })
|
|
@@ -5252,25 +5288,25 @@ const ImagePickerModal$1 = ImagePickerModal, ImagePickerField = ({ value: o, onC
|
|
|
5252
5288
|
}
|
|
5253
5289
|
);
|
|
5254
5290
|
}, LinkField = ({ schema: o, formData: n, onChange: r }) => {
|
|
5255
|
-
const [a, l] = useState([]), i = useBuilderProp("getPages", () => []), { type: c = "page", href: d = "", target:
|
|
5291
|
+
const [a, l] = useState([]), i = useBuilderProp("getPages", () => []), { type: c = "page", href: d = "", target: u = "self" } = n;
|
|
5256
5292
|
return useEffect(() => {
|
|
5257
5293
|
(async () => {
|
|
5258
|
-
const
|
|
5259
|
-
l(
|
|
5294
|
+
const p = await i();
|
|
5295
|
+
l(p || []);
|
|
5260
5296
|
})();
|
|
5261
5297
|
}, []), /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
|
|
5262
5298
|
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-xs font-medium", children: (o == null ? void 0 : o.title) ?? "Link" }),
|
|
5263
5299
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-y-1.5", children: [
|
|
5264
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("select", { name: "type", value: c, onChange: (
|
|
5300
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("select", { name: "type", value: c, onChange: (p) => r({ ...n, type: p.target.value }), children: [
|
|
5265
5301
|
{ const: "page", title: "Open Page" },
|
|
5266
5302
|
{ const: "url", title: "Open URL" },
|
|
5267
5303
|
{ const: "email", title: "Compose Email" },
|
|
5268
5304
|
{ const: "telephone", title: "Call Phone" },
|
|
5269
5305
|
{ const: "scroll", title: "Scroll to element" }
|
|
5270
|
-
].map((
|
|
5271
|
-
c === "page" ? /* @__PURE__ */ jsxRuntimeExports.jsxs("select", { name: "href", value: d, onChange: (
|
|
5306
|
+
].map((p) => /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: p.const, children: p.title }, p.const)) }),
|
|
5307
|
+
c === "page" ? /* @__PURE__ */ jsxRuntimeExports.jsxs("select", { name: "href", value: d, onChange: (p) => r({ ...n, href: p.target.value || "#" }), children: [
|
|
5272
5308
|
/* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "", children: "Choose page" }),
|
|
5273
|
-
map(a, (
|
|
5309
|
+
map(a, (p) => /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: p.slug, children: p.name }, p.uuid))
|
|
5274
5310
|
] }) : /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
5275
5311
|
"input",
|
|
5276
5312
|
{
|
|
@@ -5280,7 +5316,7 @@ const ImagePickerModal$1 = ImagePickerModal, ImagePickerField = ({ value: o, onC
|
|
|
5280
5316
|
name: "href",
|
|
5281
5317
|
type: "text",
|
|
5282
5318
|
value: d,
|
|
5283
|
-
onChange: (
|
|
5319
|
+
onChange: (p) => r({ ...n, href: p.target.value || "#" }),
|
|
5284
5320
|
placeholder: c === "page" || c === "url" ? "Enter URL" : c === "scroll" ? "#ElementID" : "Enter detail"
|
|
5285
5321
|
}
|
|
5286
5322
|
),
|
|
@@ -5292,9 +5328,9 @@ const ImagePickerModal$1 = ImagePickerModal, ImagePickerField = ({ value: o, onC
|
|
|
5292
5328
|
autoCorrect: "off",
|
|
5293
5329
|
spellCheck: "false",
|
|
5294
5330
|
type: "checkbox",
|
|
5295
|
-
defaultChecked:
|
|
5331
|
+
defaultChecked: u === "_blank",
|
|
5296
5332
|
className: "!w-fit cursor-pointer rounded-md border border-border",
|
|
5297
|
-
onChange: () => r({ ...n, target:
|
|
5333
|
+
onChange: () => r({ ...n, target: u === "_blank" ? "_self" : "_blank" })
|
|
5298
5334
|
}
|
|
5299
5335
|
),
|
|
5300
5336
|
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "pt-1 text-xs", children: "Open in new tab" })
|
|
@@ -5306,8 +5342,8 @@ const ImagePickerModal$1 = ImagePickerModal, ImagePickerField = ({ value: o, onC
|
|
|
5306
5342
|
if (typeof window > "u")
|
|
5307
5343
|
return null;
|
|
5308
5344
|
const i = o.replace("root.", ""), c = get(l, i, ""), d = () => {
|
|
5309
|
-
const
|
|
5310
|
-
a({ blockId:
|
|
5345
|
+
const u = l == null ? void 0 : l._id;
|
|
5346
|
+
a({ blockId: u, blockProp: i, placeholder: n, initialCode: get(l, i, c) });
|
|
5311
5347
|
};
|
|
5312
5348
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mt-2 flex flex-col gap-y-1", children: [
|
|
5313
5349
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
@@ -5321,19 +5357,19 @@ const ImagePickerModal$1 = ImagePickerModal, ImagePickerField = ({ value: o, onC
|
|
|
5321
5357
|
/* @__PURE__ */ jsxRuntimeExports.jsx(Button, { onClick: d, size: "sm", variant: "outline", className: "w-fit", children: r("Open code editor") })
|
|
5322
5358
|
] });
|
|
5323
5359
|
}, JSONForm = memo(({ id: o, properties: n, formData: r, onChange: a }) => {
|
|
5324
|
-
const [l, i] = useState(r), c = { type: "object", properties: {} }, d = {}, { t:
|
|
5325
|
-
Object.keys(n).forEach((
|
|
5326
|
-
const
|
|
5327
|
-
if (includes(["slot", "styles"],
|
|
5360
|
+
const [l, i] = useState(r), c = { type: "object", properties: {} }, d = {}, { t: u } = useTranslation(), { selectedLang: p, fallbackLang: m, languages: g } = useLanguages(), x = g.length === 0 ? "" : p.length ? p : m;
|
|
5361
|
+
Object.keys(n).forEach((E) => {
|
|
5362
|
+
const b = n[E];
|
|
5363
|
+
if (includes(["slot", "styles"], b.type))
|
|
5328
5364
|
return;
|
|
5329
|
-
const
|
|
5330
|
-
c.properties[
|
|
5365
|
+
const k = E;
|
|
5366
|
+
c.properties[k] = getBlockJSONFromSchemas(b, u, x), d[k] = getBlockJSONFromUISchemas(b);
|
|
5331
5367
|
}), useEffect(() => {
|
|
5332
5368
|
i(r);
|
|
5333
|
-
}, [o,
|
|
5334
|
-
const
|
|
5335
|
-
async ({ formData:
|
|
5336
|
-
a({ formData:
|
|
5369
|
+
}, [o, p]);
|
|
5370
|
+
const j = useThrottledCallback(
|
|
5371
|
+
async ({ formData: E }, b) => {
|
|
5372
|
+
a({ formData: E }, b);
|
|
5337
5373
|
},
|
|
5338
5374
|
[a],
|
|
5339
5375
|
1e3
|
|
@@ -5359,8 +5395,8 @@ const ImagePickerModal$1 = ImagePickerModal, ImagePickerField = ({ value: o, onC
|
|
|
5359
5395
|
uiSchema: d,
|
|
5360
5396
|
schema: c,
|
|
5361
5397
|
formData: l,
|
|
5362
|
-
onChange: ({ formData:
|
|
5363
|
-
|
|
5398
|
+
onChange: ({ formData: E }, b) => {
|
|
5399
|
+
b && (i(E), j({ formData: E }, b));
|
|
5364
5400
|
}
|
|
5365
5401
|
}
|
|
5366
5402
|
);
|
|
@@ -5382,7 +5418,7 @@ const ImagePickerModal$1 = ImagePickerModal, ImagePickerField = ({ value: o, onC
|
|
|
5382
5418
|
id: "show-on-canvas",
|
|
5383
5419
|
checked: c,
|
|
5384
5420
|
onCheckedChange: (d) => {
|
|
5385
|
-
d ? (n((
|
|
5421
|
+
d ? (n((u) => [...u, r._id]), a([r._id])) : n((u) => u.filter((p) => p !== r._id));
|
|
5386
5422
|
}
|
|
5387
5423
|
}
|
|
5388
5424
|
),
|
|
@@ -5429,32 +5465,32 @@ const ImagePickerModal$1 = ImagePickerModal, ImagePickerField = ({ value: o, onC
|
|
|
5429
5465
|
}), a;
|
|
5430
5466
|
};
|
|
5431
5467
|
function BlockSettings() {
|
|
5432
|
-
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),
|
|
5433
|
-
if (
|
|
5434
|
-
const
|
|
5435
|
-
a([n._id], { [
|
|
5468
|
+
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), u = useBuilderProp("dataBindingSupport", !1), p = ({ formData: b }, k, _) => {
|
|
5469
|
+
if (k && (c == null ? void 0 : c._id) === n._id) {
|
|
5470
|
+
const S = k.replace("root.", "");
|
|
5471
|
+
a([n._id], { [S]: get(b, S) }, _);
|
|
5436
5472
|
}
|
|
5437
5473
|
}, m = useCallback(
|
|
5438
|
-
debounce(({ formData:
|
|
5439
|
-
|
|
5474
|
+
debounce(({ formData: b }, k, _) => {
|
|
5475
|
+
p({ formData: b }, k, _), d(b);
|
|
5440
5476
|
}, 1500),
|
|
5441
5477
|
[n == null ? void 0 : n._id, o]
|
|
5442
|
-
),
|
|
5443
|
-
if (
|
|
5444
|
-
const _ =
|
|
5478
|
+
), g = ({ formData: b }, k) => {
|
|
5479
|
+
if (k) {
|
|
5480
|
+
const _ = k.replace("root.", "");
|
|
5445
5481
|
r(
|
|
5446
5482
|
[n._id],
|
|
5447
|
-
convertDotNotationToObject(_, get(
|
|
5448
|
-
), m({ formData:
|
|
5483
|
+
convertDotNotationToObject(_, get(b, _.split(".")))
|
|
5484
|
+
), m({ formData: b }, k, { [_]: get(c, _) });
|
|
5449
5485
|
}
|
|
5450
|
-
},
|
|
5451
|
-
const
|
|
5452
|
-
return each(
|
|
5453
|
-
get(
|
|
5454
|
-
}),
|
|
5455
|
-
}, [l,
|
|
5486
|
+
}, x = keys(get(i, "_bindings", {})), j = useMemo(() => {
|
|
5487
|
+
const b = cloneDeep(get(l, "props", {}));
|
|
5488
|
+
return each(b, (k, _) => {
|
|
5489
|
+
get(k, "hidden", !1) && delete b[_];
|
|
5490
|
+
}), u && each(x, (k) => delete b[k]), b;
|
|
5491
|
+
}, [l, x, u]), E = get(l, "server", !1);
|
|
5456
5492
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "overflow-x-hidden px-px", children: [
|
|
5457
|
-
|
|
5493
|
+
u ? /* @__PURE__ */ jsxRuntimeExports.jsxs(Accordion, { type: "multiple", defaultValue: ["STATIC", "BINDING"], className: "mt-4 h-full w-full", children: [
|
|
5458
5494
|
/* @__PURE__ */ jsxRuntimeExports.jsxs(AccordionItem, { value: "BINDING", children: [
|
|
5459
5495
|
/* @__PURE__ */ jsxRuntimeExports.jsx(AccordionTrigger, { className: "py-2", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-x-2", children: [
|
|
5460
5496
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
@@ -5469,8 +5505,8 @@ function BlockSettings() {
|
|
|
5469
5505
|
DataBindingSetting$1,
|
|
5470
5506
|
{
|
|
5471
5507
|
bindingData: get(n, "_bindings", {}),
|
|
5472
|
-
onChange: (
|
|
5473
|
-
|
|
5508
|
+
onChange: (b) => {
|
|
5509
|
+
p({ formData: { _bindings: b } }, "root._bindings");
|
|
5474
5510
|
}
|
|
5475
5511
|
}
|
|
5476
5512
|
) })
|
|
@@ -5481,35 +5517,35 @@ function BlockSettings() {
|
|
|
5481
5517
|
"Static Content"
|
|
5482
5518
|
] }) }),
|
|
5483
5519
|
/* @__PURE__ */ jsxRuntimeExports.jsxs(AccordionContent, { className: "pt-4", children: [
|
|
5484
|
-
isEmpty(
|
|
5520
|
+
isEmpty(x) ? null : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mb-1 mt-0 rounded-sm border border-orange-500 bg-orange-100 p-1 text-xs text-orange-500", children: [
|
|
5485
5521
|
"Data binding is set for ",
|
|
5486
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("b", { children: map(
|
|
5522
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("b", { children: map(x, capitalize).join(", ") }),
|
|
5487
5523
|
" ",
|
|
5488
|
-
|
|
5524
|
+
x.length === 1 ? "property" : "properties",
|
|
5489
5525
|
". Remove data binding to edit static content."
|
|
5490
5526
|
] }),
|
|
5491
5527
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
5492
5528
|
JSONForm,
|
|
5493
5529
|
{
|
|
5494
5530
|
id: n == null ? void 0 : n._id,
|
|
5495
|
-
onChange:
|
|
5531
|
+
onChange: g,
|
|
5496
5532
|
formData: i,
|
|
5497
|
-
properties:
|
|
5533
|
+
properties: j
|
|
5498
5534
|
}
|
|
5499
5535
|
)
|
|
5500
5536
|
] })
|
|
5501
5537
|
] })
|
|
5502
|
-
] }) : isEmpty(
|
|
5538
|
+
] }) : isEmpty(j) ? null : /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
5503
5539
|
JSONForm,
|
|
5504
5540
|
{
|
|
5505
5541
|
id: n == null ? void 0 : n._id,
|
|
5506
|
-
onChange:
|
|
5542
|
+
onChange: g,
|
|
5507
5543
|
formData: i,
|
|
5508
|
-
properties:
|
|
5544
|
+
properties: j
|
|
5509
5545
|
}
|
|
5510
5546
|
),
|
|
5511
5547
|
(n == null ? void 0 : n._type) === "GlobalBlock" ? /* @__PURE__ */ jsxRuntimeExports.jsx(GlobalBlockSettings, {}) : null,
|
|
5512
|
-
|
|
5548
|
+
E ? /* @__PURE__ */ jsxRuntimeExports.jsx(ResetRSCBlockButton, { blockId: n == null ? void 0 : n._id }) : null,
|
|
5513
5549
|
/* @__PURE__ */ jsxRuntimeExports.jsx(CanvasSettings, {})
|
|
5514
5550
|
] });
|
|
5515
5551
|
}
|
|
@@ -5533,25 +5569,25 @@ function promptWithLanguage(o, n, r) {
|
|
|
5533
5569
|
${a}`;
|
|
5534
5570
|
}
|
|
5535
5571
|
const askAiProcessingAtom = atom$1(!1), useAskAi = () => {
|
|
5536
|
-
const [o, n] = useAtom$1(askAiProcessingAtom), [r, a] = useState(null), l = useBuilderProp("askAiCallBack", null), i = useStreamMultipleBlocksProps(), c = useUpdateMultipleBlocksProps(), [d] = useBlocksStore(), { selectedLang:
|
|
5572
|
+
const [o, n] = useAtom$1(askAiProcessingAtom), [r, a] = useState(null), l = useBuilderProp("askAiCallBack", null), i = useStreamMultipleBlocksProps(), c = useUpdateMultipleBlocksProps(), [d] = useBlocksStore(), { selectedLang: u, fallbackLang: p } = useLanguages(), m = u.length ? u : p;
|
|
5537
5573
|
return {
|
|
5538
5574
|
askAi: useCallback(
|
|
5539
|
-
async (x,
|
|
5575
|
+
async (g, x, j, E) => {
|
|
5540
5576
|
if (l) {
|
|
5541
5577
|
n(!0), a(null);
|
|
5542
5578
|
try {
|
|
5543
|
-
const
|
|
5544
|
-
set(
|
|
5545
|
-
const
|
|
5579
|
+
const b = g === "content" ? cloneDeep(getBlockWithChildren(x, d)) : [cloneDeep(d.find((R) => R._id === x))];
|
|
5580
|
+
set(b, "0._parent", null);
|
|
5581
|
+
const k = u === p ? "" : u, _ = await l(g, promptWithLanguage(j, m, g), b, k), { blocks: S, error: B } = _;
|
|
5546
5582
|
if (B) {
|
|
5547
5583
|
a(B);
|
|
5548
5584
|
return;
|
|
5549
5585
|
}
|
|
5550
|
-
|
|
5551
|
-
} catch (
|
|
5552
|
-
a(
|
|
5586
|
+
g === "styles" ? c(S) : i(S), E && E(_);
|
|
5587
|
+
} catch (b) {
|
|
5588
|
+
a(b);
|
|
5553
5589
|
} finally {
|
|
5554
|
-
n(!1),
|
|
5590
|
+
n(!1), E && E();
|
|
5555
5591
|
}
|
|
5556
5592
|
}
|
|
5557
5593
|
},
|
|
@@ -5559,8 +5595,8 @@ const askAiProcessingAtom = atom$1(!1), useAskAi = () => {
|
|
|
5559
5595
|
l,
|
|
5560
5596
|
n,
|
|
5561
5597
|
d,
|
|
5562
|
-
p,
|
|
5563
5598
|
u,
|
|
5599
|
+
p,
|
|
5564
5600
|
m,
|
|
5565
5601
|
c,
|
|
5566
5602
|
i
|
|
@@ -5587,10 +5623,10 @@ function Countdown() {
|
|
|
5587
5623
|
const [o, n] = useState(SECONDS), [r, a] = useState(!1);
|
|
5588
5624
|
useEffect(() => {
|
|
5589
5625
|
if (r && o > 0) {
|
|
5590
|
-
const
|
|
5626
|
+
const u = setTimeout(() => {
|
|
5591
5627
|
n(o - 0.1);
|
|
5592
5628
|
}, 100);
|
|
5593
|
-
return () => clearTimeout(
|
|
5629
|
+
return () => clearTimeout(u);
|
|
5594
5630
|
} else
|
|
5595
5631
|
o <= 0 && (a(!1), n(SECONDS));
|
|
5596
5632
|
}, [r, o]);
|
|
@@ -5635,14 +5671,14 @@ function Countdown() {
|
|
|
5635
5671
|
] });
|
|
5636
5672
|
}
|
|
5637
5673
|
const AskAIStyles = ({ blockId: o }) => {
|
|
5638
|
-
const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, c] = useState(""), d = useRef(null),
|
|
5674
|
+
const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, c] = useState(""), d = useRef(null), u = useRef(null), [p, m] = useState();
|
|
5639
5675
|
useEffect(() => {
|
|
5640
|
-
var
|
|
5641
|
-
(
|
|
5676
|
+
var x;
|
|
5677
|
+
(x = d.current) == null || x.focus();
|
|
5642
5678
|
}, []);
|
|
5643
|
-
const
|
|
5644
|
-
const { usage:
|
|
5645
|
-
!l &&
|
|
5679
|
+
const g = (x) => {
|
|
5680
|
+
const { usage: j } = x || {};
|
|
5681
|
+
!l && j && m(j), u.current = setTimeout(() => m(void 0), 1e4), l || c("");
|
|
5646
5682
|
};
|
|
5647
5683
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "", children: [
|
|
5648
5684
|
/* @__PURE__ */ jsxRuntimeExports.jsx("h2", { className: "mb-1 text-sm font-semibold leading-none tracking-tight", children: n("ask_ai") }),
|
|
@@ -5651,12 +5687,12 @@ const AskAIStyles = ({ blockId: o }) => {
|
|
|
5651
5687
|
{
|
|
5652
5688
|
ref: d,
|
|
5653
5689
|
value: i,
|
|
5654
|
-
onChange: (
|
|
5690
|
+
onChange: (x) => c(x.target.value),
|
|
5655
5691
|
placeholder: n("ask_ai_to_edit_styles"),
|
|
5656
5692
|
className: "w-full border border-border focus:border-0",
|
|
5657
5693
|
rows: 3,
|
|
5658
|
-
onKeyDown: (
|
|
5659
|
-
|
|
5694
|
+
onKeyDown: (x) => {
|
|
5695
|
+
x.key === "Enter" && (x.preventDefault(), u.current && clearTimeout(u.current), m(void 0), r("styles", o, i, g));
|
|
5660
5696
|
}
|
|
5661
5697
|
}
|
|
5662
5698
|
),
|
|
@@ -5666,7 +5702,7 @@ const AskAIStyles = ({ blockId: o }) => {
|
|
|
5666
5702
|
{
|
|
5667
5703
|
disabled: i.trim().length < 5 || a,
|
|
5668
5704
|
onClick: () => {
|
|
5669
|
-
|
|
5705
|
+
u.current && clearTimeout(u.current), m(void 0), r("styles", o, i, g);
|
|
5670
5706
|
},
|
|
5671
5707
|
variant: "default",
|
|
5672
5708
|
className: "w-fit",
|
|
@@ -5685,11 +5721,11 @@ const AskAIStyles = ({ blockId: o }) => {
|
|
|
5685
5721
|
/* @__PURE__ */ jsxRuntimeExports.jsx(Button, { variant: "destructive", onClick: () => stop(), className: "hidden w-fit", size: "sm", children: n("stop") })
|
|
5686
5722
|
] }) : null
|
|
5687
5723
|
] }),
|
|
5688
|
-
|
|
5724
|
+
p ? /* @__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: [
|
|
5689
5725
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("span", { children: [
|
|
5690
5726
|
n("Total tokens used"),
|
|
5691
5727
|
": ",
|
|
5692
|
-
|
|
5728
|
+
p.totalTokens
|
|
5693
5729
|
] }),
|
|
5694
5730
|
/* @__PURE__ */ jsxRuntimeExports.jsx(Countdown, {})
|
|
5695
5731
|
] }) }) : null,
|
|
@@ -5703,45 +5739,45 @@ const AskAIStyles = ({ blockId: o }) => {
|
|
|
5703
5739
|
});
|
|
5704
5740
|
function ManualClasses() {
|
|
5705
5741
|
var A;
|
|
5706
|
-
const { t: o } = useTranslation(), [n] = useSelectedStylingBlocks(), r = useSelectedBlock(), a = useAddClassesToBlocks(), l = useRemoveClassesFromBlocks(), [i] = useSelectedBlockIds(), c = useBuilderProp("askAiCallBack", null), [d,
|
|
5707
|
-
const
|
|
5708
|
-
a(i,
|
|
5709
|
-
}, [
|
|
5710
|
-
const
|
|
5711
|
-
let
|
|
5712
|
-
if (
|
|
5713
|
-
const [
|
|
5714
|
-
|
|
5715
|
-
...
|
|
5716
|
-
item: { ...
|
|
5742
|
+
const { t: o } = useTranslation(), [n] = useSelectedStylingBlocks(), r = useSelectedBlock(), a = useAddClassesToBlocks(), l = useRemoveClassesFromBlocks(), [i] = useSelectedBlockIds(), c = useBuilderProp("askAiCallBack", null), [d, u] = useState(""), { toast: p } = useToast(), m = (A = first(n)) == null ? void 0 : A.prop, g = reject((get(r, m, "").replace(STYLES_KEY, "").split(",").pop() || "").split(" "), isEmpty), x = () => {
|
|
5743
|
+
const T = d.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
|
|
5744
|
+
a(i, T, !0), u("");
|
|
5745
|
+
}, [j, E] = useState([]), b = ({ value: T }) => {
|
|
5746
|
+
const L = T.trim().toLowerCase(), P = L.match(/.+:/g);
|
|
5747
|
+
let f = [];
|
|
5748
|
+
if (P && P.length > 0) {
|
|
5749
|
+
const [v] = P, C = L.replace(v, "");
|
|
5750
|
+
f = fuse.search(C).map((I) => ({
|
|
5751
|
+
...I,
|
|
5752
|
+
item: { ...I.item, name: v + I.item.name }
|
|
5717
5753
|
}));
|
|
5718
5754
|
} else
|
|
5719
|
-
|
|
5720
|
-
return
|
|
5721
|
-
},
|
|
5722
|
-
|
|
5723
|
-
}, _ = (
|
|
5755
|
+
f = fuse.search(L);
|
|
5756
|
+
return E(map(f, "item"));
|
|
5757
|
+
}, k = () => {
|
|
5758
|
+
E([]);
|
|
5759
|
+
}, _ = (T) => T.name, S = (T) => /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "rounded-md p-1", children: T.name }), B = {
|
|
5724
5760
|
autoComplete: "off",
|
|
5725
5761
|
autoCorrect: "off",
|
|
5726
5762
|
autoCapitalize: "off",
|
|
5727
5763
|
spellCheck: !1,
|
|
5728
5764
|
placeholder: o("enter_classes_separated_by_space"),
|
|
5729
5765
|
value: d,
|
|
5730
|
-
onKeyDown: (
|
|
5731
|
-
|
|
5766
|
+
onKeyDown: (T) => {
|
|
5767
|
+
T.key === "Enter" && d.trim() !== "" && x();
|
|
5732
5768
|
},
|
|
5733
|
-
onChange: (
|
|
5769
|
+
onChange: (T, { newValue: L }) => u(L),
|
|
5734
5770
|
className: "w-full rounded-md text-xs px-2 hover:outline-0 bg-background border-border py-1"
|
|
5735
|
-
},
|
|
5771
|
+
}, R = () => {
|
|
5736
5772
|
if (navigator.clipboard === void 0) {
|
|
5737
|
-
|
|
5773
|
+
p({
|
|
5738
5774
|
title: o("clipboard_not_supported"),
|
|
5739
5775
|
description: o("please_use_chrome_firefox_or_safari"),
|
|
5740
5776
|
variant: "destructive"
|
|
5741
5777
|
});
|
|
5742
5778
|
return;
|
|
5743
5779
|
}
|
|
5744
|
-
navigator.clipboard.writeText(
|
|
5780
|
+
navigator.clipboard.writeText(g.join(" ")), p({
|
|
5745
5781
|
title: o("copied"),
|
|
5746
5782
|
description: o("classes_copied_to_clipboard")
|
|
5747
5783
|
});
|
|
@@ -5749,13 +5785,13 @@ function ManualClasses() {
|
|
|
5749
5785
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
5750
5786
|
"div",
|
|
5751
5787
|
{
|
|
5752
|
-
className: `flex ${
|
|
5788
|
+
className: `flex ${j.length > 0 ? "min-h-[300px]" : "min-h-max"} w-full flex-col gap-y-1.5 overflow-y-auto pb-4`,
|
|
5753
5789
|
children: [
|
|
5754
5790
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between gap-x-2", children: [
|
|
5755
5791
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-x-2 text-muted-foreground", children: [
|
|
5756
5792
|
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: o("classes") }),
|
|
5757
5793
|
/* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
|
|
5758
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxRuntimeExports.jsx(CopyIcon, { onClick:
|
|
5794
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxRuntimeExports.jsx(CopyIcon, { onClick: R, className: "cursor-pointer" }) }),
|
|
5759
5795
|
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { children: o("copy_classes_to_clipboard") }) })
|
|
5760
5796
|
] })
|
|
5761
5797
|
] }),
|
|
@@ -5771,11 +5807,11 @@ function ManualClasses() {
|
|
|
5771
5807
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "relative flex w-full items-center gap-x-3", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
5772
5808
|
Autosuggest,
|
|
5773
5809
|
{
|
|
5774
|
-
suggestions:
|
|
5775
|
-
onSuggestionsFetchRequested:
|
|
5776
|
-
onSuggestionsClearRequested:
|
|
5810
|
+
suggestions: j,
|
|
5811
|
+
onSuggestionsFetchRequested: b,
|
|
5812
|
+
onSuggestionsClearRequested: k,
|
|
5777
5813
|
getSuggestionValue: _,
|
|
5778
|
-
renderSuggestion:
|
|
5814
|
+
renderSuggestion: S,
|
|
5779
5815
|
inputProps: B,
|
|
5780
5816
|
containerProps: {
|
|
5781
5817
|
className: "relative h-8 w-full gap-y-1 py-1 border-border"
|
|
@@ -5792,7 +5828,7 @@ function ManualClasses() {
|
|
|
5792
5828
|
{
|
|
5793
5829
|
variant: "outline",
|
|
5794
5830
|
className: "h-6 border-border",
|
|
5795
|
-
onClick:
|
|
5831
|
+
onClick: x,
|
|
5796
5832
|
disabled: d.trim() === "",
|
|
5797
5833
|
size: "sm",
|
|
5798
5834
|
children: /* @__PURE__ */ jsxRuntimeExports.jsx(PlusIcon, {})
|
|
@@ -5800,22 +5836,22 @@ function ManualClasses() {
|
|
|
5800
5836
|
)
|
|
5801
5837
|
] }),
|
|
5802
5838
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex w-full flex-wrap gap-2 overflow-x-hidden", children: React.Children.toArray(
|
|
5803
|
-
|
|
5839
|
+
g.map((T) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
5804
5840
|
"div",
|
|
5805
5841
|
{
|
|
5806
5842
|
className: "group relative flex max-w-[260px] cursor-default items-center gap-x-1 truncate rounded border border-border bg-gray-200 p-px px-1.5 text-[11px] text-gray-600 hover:border-gray-300 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-300",
|
|
5807
5843
|
children: [
|
|
5808
|
-
|
|
5844
|
+
T,
|
|
5809
5845
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
5810
5846
|
Cross2Icon,
|
|
5811
5847
|
{
|
|
5812
|
-
onClick: () => l(i, [
|
|
5848
|
+
onClick: () => l(i, [T]),
|
|
5813
5849
|
className: "invisible absolute right-1 rounded-full bg-red-400 hover:text-white group-hover:visible group-hover:cursor-pointer"
|
|
5814
5850
|
}
|
|
5815
5851
|
)
|
|
5816
5852
|
]
|
|
5817
5853
|
},
|
|
5818
|
-
|
|
5854
|
+
T
|
|
5819
5855
|
))
|
|
5820
5856
|
) })
|
|
5821
5857
|
]
|
|
@@ -6115,7 +6151,7 @@ const EDITOR_ICONS = {
|
|
|
6115
6151
|
DropDown,
|
|
6116
6152
|
{
|
|
6117
6153
|
rounded: o,
|
|
6118
|
-
onChange: (
|
|
6154
|
+
onChange: (u) => r(u, n),
|
|
6119
6155
|
selected: i,
|
|
6120
6156
|
options: a,
|
|
6121
6157
|
disabled: !c
|
|
@@ -6129,23 +6165,23 @@ function DropDown({ selected: o, onChange: n, rounded: r = !1, options: a, disab
|
|
|
6129
6165
|
{
|
|
6130
6166
|
disabled: !a.length || l,
|
|
6131
6167
|
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`,
|
|
6132
|
-
onChange: (
|
|
6133
|
-
onKeyDown: (
|
|
6134
|
-
|
|
6168
|
+
onChange: (u) => n(u.target.value),
|
|
6169
|
+
onKeyDown: (u) => {
|
|
6170
|
+
u.ctrlKey && (u.key === "z" && c(), u.key === "y" && d());
|
|
6135
6171
|
},
|
|
6136
6172
|
value: i,
|
|
6137
6173
|
children: [
|
|
6138
6174
|
/* @__PURE__ */ jsxRuntimeExports.jsx("option", { className: "bg-transparent", value: "" }),
|
|
6139
6175
|
React__default.Children.toArray(
|
|
6140
|
-
a.map((
|
|
6176
|
+
a.map((u) => /* @__PURE__ */ jsxRuntimeExports.jsx("option", { className: "bg-transparent", value: u, children: u }))
|
|
6141
6177
|
)
|
|
6142
6178
|
]
|
|
6143
6179
|
}
|
|
6144
6180
|
);
|
|
6145
6181
|
}
|
|
6146
6182
|
const RangeChoices = ({ property: o, onChange: n }) => {
|
|
6147
|
-
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,
|
|
6148
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-row divide-x divide-solid divide-border rounded border border-border text-xs", children:
|
|
6183
|
+
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, u = /\[.*\]/g.test(i);
|
|
6184
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-row divide-x divide-solid divide-border rounded border border-border text-xs", children: u ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "py-[5px] px-2", children: i }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
6149
6185
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
6150
6186
|
"button",
|
|
6151
6187
|
{
|
|
@@ -6206,30 +6242,30 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
6206
6242
|
ringColor: "ring",
|
|
6207
6243
|
ringOffsetColor: "ring-offset"
|
|
6208
6244
|
}, ColorChoice = ({ property: o, onChange: n }) => {
|
|
6209
|
-
const r = useCurrentClassByProperty(o), a = useMemo(() => get(r, "cls", ""), [r]), { canChange: l } = useContext(StyleContext), [i, c] = useState([]), [d,
|
|
6245
|
+
const r = useCurrentClassByProperty(o), a = useMemo(() => get(r, "cls", ""), [r]), { canChange: l } = useContext(StyleContext), [i, c] = useState([]), [d, u] = useState({ color: "", shade: "" }), p = a.split("-"), m = get(p, "1", ""), g = get(p, "2", ""), x = useCallback(
|
|
6210
6246
|
// eslint-disable-next-line no-shadow
|
|
6211
|
-
(
|
|
6212
|
-
["current", "inherit", "transparent", "black", "white"].includes(
|
|
6247
|
+
(E) => {
|
|
6248
|
+
["current", "inherit", "transparent", "black", "white"].includes(E) ? (c([]), u({ color: E })) : (c(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]), u((b) => ({ ...b, color: E, shade: b.shade ? b.shade : "500" })));
|
|
6213
6249
|
},
|
|
6214
|
-
[c,
|
|
6250
|
+
[c, u]
|
|
6215
6251
|
);
|
|
6216
6252
|
useEffect(() => {
|
|
6217
6253
|
if (["current", "inherit", "transparent", "black", "white"].includes(m))
|
|
6218
6254
|
return c([]);
|
|
6219
6255
|
c(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]);
|
|
6220
6256
|
}, [m]);
|
|
6221
|
-
const
|
|
6257
|
+
const j = useCallback(
|
|
6222
6258
|
// eslint-disable-next-line no-shadow
|
|
6223
|
-
(
|
|
6224
|
-
|
|
6259
|
+
(E) => {
|
|
6260
|
+
u({ color: m, shade: E });
|
|
6225
6261
|
},
|
|
6226
6262
|
[m]
|
|
6227
6263
|
);
|
|
6228
6264
|
return useEffect(() => {
|
|
6229
|
-
|
|
6265
|
+
u({ color: "", shade: "" });
|
|
6230
6266
|
}, [r]), useEffect(() => {
|
|
6231
|
-
const
|
|
6232
|
-
|
|
6267
|
+
const b = `${get(COLOR_PROP, o, "")}-${d.color}${d.shade ? `-${d.shade}` : ""}`;
|
|
6268
|
+
b.match(new RegExp(get(CLASSES_LIST, `${o}.regExp`, ""))) && n(b, o);
|
|
6233
6269
|
}, [d, n, o]), /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-row divide-x divide-solid divide-border rounded-lg border border-transparent text-xs", children: [
|
|
6234
6270
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "grow text-center", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
6235
6271
|
DropDown,
|
|
@@ -6237,7 +6273,7 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
6237
6273
|
disabled: !l,
|
|
6238
6274
|
rounded: !0,
|
|
6239
6275
|
selected: m,
|
|
6240
|
-
onChange:
|
|
6276
|
+
onChange: x,
|
|
6241
6277
|
options: [
|
|
6242
6278
|
"current",
|
|
6243
6279
|
"transparent",
|
|
@@ -6270,7 +6306,7 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
6270
6306
|
]
|
|
6271
6307
|
}
|
|
6272
6308
|
) }),
|
|
6273
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("button", { type: "button", className: "grow text-center", children: /* @__PURE__ */ jsxRuntimeExports.jsx(DropDown, { rounded: !0, selected:
|
|
6309
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("button", { type: "button", className: "grow text-center", children: /* @__PURE__ */ jsxRuntimeExports.jsx(DropDown, { rounded: !0, selected: g, disabled: !m || !l, onChange: j, options: i }) })
|
|
6274
6310
|
] });
|
|
6275
6311
|
}, getUserInputValues = (o, n) => {
|
|
6276
6312
|
o = o.toLowerCase();
|
|
@@ -6434,18 +6470,18 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
6434
6470
|
"button",
|
|
6435
6471
|
{
|
|
6436
6472
|
type: "button",
|
|
6437
|
-
onMouseDown: (
|
|
6438
|
-
const
|
|
6473
|
+
onMouseDown: (u) => {
|
|
6474
|
+
const p = {
|
|
6439
6475
|
onDrag: r,
|
|
6440
6476
|
onDragEnd: a,
|
|
6441
6477
|
dragging: !0,
|
|
6442
|
-
dragStartY:
|
|
6478
|
+
dragStartY: u.pageY,
|
|
6443
6479
|
dragStartValue: `${n}`,
|
|
6444
6480
|
dragUnit: o,
|
|
6445
6481
|
negative: i,
|
|
6446
6482
|
cssProperty: c
|
|
6447
6483
|
};
|
|
6448
|
-
l(
|
|
6484
|
+
l(p), d(p);
|
|
6449
6485
|
},
|
|
6450
6486
|
color: void 0,
|
|
6451
6487
|
className: "relative z-50 ml-1 hidden h-6 cursor-row-resize rounded bg-background/70 px-2 group-hover:inline",
|
|
@@ -6465,52 +6501,52 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
6465
6501
|
},
|
|
6466
6502
|
a
|
|
6467
6503
|
)) }), THROTTLE_TIME = 50, AdvanceChoices = (o) => {
|
|
6468
|
-
const [n, r] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty:
|
|
6504
|
+
const [n, r] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: u, units: p, negative: m } = o, [g, x] = useState(u != null && u.toLowerCase().includes("width") ? "%" : p[0]), [j, E] = useState(!1), [b, k] = useState(""), [_, S] = useState(!1), [B, R] = useState(!1);
|
|
6469
6505
|
useEffect(() => {
|
|
6470
|
-
const { value:
|
|
6471
|
-
if (
|
|
6472
|
-
l(
|
|
6506
|
+
const { value: f, unit: v } = getClassValueAndUnit(i);
|
|
6507
|
+
if (v === "") {
|
|
6508
|
+
l(f), x(u != null && u.toLowerCase().includes("width") ? "%" : first(p));
|
|
6473
6509
|
return;
|
|
6474
6510
|
}
|
|
6475
|
-
|
|
6476
|
-
}, [i,
|
|
6477
|
-
const A = useThrottledCallback((
|
|
6478
|
-
(
|
|
6479
|
-
const
|
|
6480
|
-
if (get(
|
|
6481
|
-
|
|
6511
|
+
x(v), l(v === "class" || isEmpty(f) ? "" : f);
|
|
6512
|
+
}, [i, u, p]);
|
|
6513
|
+
const A = useThrottledCallback((f) => c(f), [c], THROTTLE_TIME), T = useThrottledCallback((f) => c(f, !1), [c], THROTTLE_TIME), L = useCallback(
|
|
6514
|
+
(f = !1) => {
|
|
6515
|
+
const v = getUserInputValues(`${a}`, p);
|
|
6516
|
+
if (get(v, "error", !1)) {
|
|
6517
|
+
E(!0);
|
|
6482
6518
|
return;
|
|
6483
6519
|
}
|
|
6484
|
-
const
|
|
6485
|
-
if (
|
|
6486
|
-
A(`${d}${
|
|
6520
|
+
const C = get(v, "unit") !== "" ? get(v, "unit") : g;
|
|
6521
|
+
if (C === "auto" || C === "none") {
|
|
6522
|
+
A(`${d}${C}`);
|
|
6487
6523
|
return;
|
|
6488
6524
|
}
|
|
6489
|
-
if (get(
|
|
6525
|
+
if (get(v, "value") === "")
|
|
6490
6526
|
return;
|
|
6491
|
-
const
|
|
6492
|
-
|
|
6527
|
+
const I = `${get(v, "value", "").startsWith("-") ? "-" : ""}${d}[${get(v, "value", "").replace("-", "")}${C === "-" ? "" : C}]`;
|
|
6528
|
+
f ? T(I) : A(I);
|
|
6493
6529
|
},
|
|
6494
|
-
[A,
|
|
6495
|
-
),
|
|
6496
|
-
(
|
|
6497
|
-
const
|
|
6498
|
-
if (get(
|
|
6499
|
-
|
|
6530
|
+
[A, T, a, g, d, p]
|
|
6531
|
+
), P = useCallback(
|
|
6532
|
+
(f) => {
|
|
6533
|
+
const v = getUserInputValues(`${a}`, p);
|
|
6534
|
+
if (get(v, "error", !1)) {
|
|
6535
|
+
E(!0);
|
|
6500
6536
|
return;
|
|
6501
6537
|
}
|
|
6502
|
-
if (
|
|
6503
|
-
A(`${d}${
|
|
6538
|
+
if (f === "auto" || f === "none") {
|
|
6539
|
+
A(`${d}${f}`);
|
|
6504
6540
|
return;
|
|
6505
6541
|
}
|
|
6506
|
-
if (get(
|
|
6542
|
+
if (get(v, "value") === "")
|
|
6507
6543
|
return;
|
|
6508
|
-
const
|
|
6509
|
-
A(
|
|
6544
|
+
const C = get(v, "unit") !== "" ? get(v, "unit") : f, I = `${get(v, "value", "").startsWith("-") ? "-" : ""}${d}[${get(v, "value", "").replace("-", "")}${C === "-" ? "" : C}]`;
|
|
6545
|
+
A(I);
|
|
6510
6546
|
},
|
|
6511
|
-
[A, a, d,
|
|
6547
|
+
[A, a, d, p]
|
|
6512
6548
|
);
|
|
6513
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex w-full flex-col", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-start", children:
|
|
6549
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex w-full flex-col", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-start", children: g === "class" ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
6514
6550
|
/* @__PURE__ */ jsxRuntimeExports.jsx("input", { className: "w-20 rounded py-1", readOnly: !0, value: i }),
|
|
6515
6551
|
/* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
|
|
6516
6552
|
/* @__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, {}) }) }),
|
|
@@ -6518,38 +6554,38 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
6518
6554
|
] })
|
|
6519
6555
|
] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: `group relative flex items-center ${_ ? "z-auto" : ""}`, children: [
|
|
6520
6556
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center rounded-md border border-border", children: [
|
|
6521
|
-
["none", "auto"].indexOf(
|
|
6557
|
+
["none", "auto"].indexOf(g) !== -1 ? null : /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
6522
6558
|
"input",
|
|
6523
6559
|
{
|
|
6524
|
-
readOnly:
|
|
6525
|
-
onKeyPress: (
|
|
6526
|
-
|
|
6560
|
+
readOnly: g === "class",
|
|
6561
|
+
onKeyPress: (f) => {
|
|
6562
|
+
f.key === "Enter" && L();
|
|
6527
6563
|
},
|
|
6528
|
-
onKeyDown: (
|
|
6529
|
-
if (
|
|
6564
|
+
onKeyDown: (f) => {
|
|
6565
|
+
if (f.keyCode !== 38 && f.keyCode !== 40)
|
|
6530
6566
|
return;
|
|
6531
|
-
|
|
6532
|
-
const
|
|
6533
|
-
let
|
|
6534
|
-
|
|
6535
|
-
const
|
|
6536
|
-
N
|
|
6567
|
+
f.preventDefault(), R(!0);
|
|
6568
|
+
const v = parseInt$1(f.target.value);
|
|
6569
|
+
let C = isNaN$1(v) ? 0 : v;
|
|
6570
|
+
f.keyCode === 38 && (C += 1), f.keyCode === 40 && (C -= 1);
|
|
6571
|
+
const w = `${C}`, N = `${w.startsWith("-") ? "-" : ""}${d}[${w.replace("-", "")}${g === "-" ? "" : g}]`;
|
|
6572
|
+
T(N);
|
|
6537
6573
|
},
|
|
6538
|
-
onKeyUp: (
|
|
6539
|
-
B && (
|
|
6574
|
+
onKeyUp: (f) => {
|
|
6575
|
+
B && (f.preventDefault(), R(!1));
|
|
6540
6576
|
},
|
|
6541
|
-
onBlur: () =>
|
|
6542
|
-
onChange: (
|
|
6543
|
-
|
|
6577
|
+
onBlur: () => L(),
|
|
6578
|
+
onChange: (f) => {
|
|
6579
|
+
E(!1), l(f.target.value);
|
|
6544
6580
|
},
|
|
6545
|
-
onClick: (
|
|
6546
|
-
var
|
|
6547
|
-
(
|
|
6581
|
+
onClick: (f) => {
|
|
6582
|
+
var v;
|
|
6583
|
+
(v = f == null ? void 0 : f.target) == null || v.select(), r(!1);
|
|
6548
6584
|
},
|
|
6549
|
-
value: _ ?
|
|
6585
|
+
value: _ ? b : a,
|
|
6550
6586
|
className: "h-6 w-14 rounded rounded-r-none border border-transparent bg-background pl-2 text-sm focus-visible:outline-0".concat(
|
|
6551
6587
|
" ",
|
|
6552
|
-
|
|
6588
|
+
j ? "border-red-500 text-red-500" : "border-foreground/20"
|
|
6553
6589
|
)
|
|
6554
6590
|
}
|
|
6555
6591
|
),
|
|
@@ -6561,44 +6597,44 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
6561
6597
|
onClick: () => r(!n),
|
|
6562
6598
|
className: "flex h-6 cursor-pointer items-center gap-x-1 rounded rounded-l-none bg-background p-px px-1 text-[11px] uppercase",
|
|
6563
6599
|
children: [
|
|
6564
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: `inline-block ${
|
|
6565
|
-
|
|
6600
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: `inline-block ${p.length === 1 ? "px-2 font-semibold" : ""}`, children: g }),
|
|
6601
|
+
p.length > 1 ? /* @__PURE__ */ jsxRuntimeExports.jsx(TriangleDownIcon, {}) : null
|
|
6566
6602
|
]
|
|
6567
6603
|
}
|
|
6568
6604
|
) }),
|
|
6569
6605
|
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipPortal, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { className: "bg-background", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
6570
6606
|
UnitSelection,
|
|
6571
6607
|
{
|
|
6572
|
-
units:
|
|
6573
|
-
current:
|
|
6574
|
-
onSelect: (
|
|
6575
|
-
r(!1),
|
|
6608
|
+
units: p,
|
|
6609
|
+
current: g,
|
|
6610
|
+
onSelect: (f) => {
|
|
6611
|
+
r(!1), x(f), P(f);
|
|
6576
6612
|
}
|
|
6577
6613
|
}
|
|
6578
6614
|
) }) })
|
|
6579
6615
|
] })
|
|
6580
6616
|
] }),
|
|
6581
|
-
["none", "auto"].indexOf(
|
|
6617
|
+
["none", "auto"].indexOf(g) !== -1 || _ ? null : /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
6582
6618
|
DragStyleButton,
|
|
6583
6619
|
{
|
|
6584
|
-
onDragStart: () =>
|
|
6585
|
-
onDragEnd: (
|
|
6586
|
-
if (
|
|
6620
|
+
onDragStart: () => S(!0),
|
|
6621
|
+
onDragEnd: (f) => {
|
|
6622
|
+
if (k(() => ""), S(!1), isEmpty(f))
|
|
6587
6623
|
return;
|
|
6588
|
-
const
|
|
6589
|
-
A(
|
|
6624
|
+
const v = `${f}`, w = `${v.startsWith("-") ? "-" : ""}${d}[${v.replace("-", "")}${g === "-" ? "" : g}]`;
|
|
6625
|
+
A(w);
|
|
6590
6626
|
},
|
|
6591
|
-
onDrag: (
|
|
6592
|
-
if (isEmpty(
|
|
6627
|
+
onDrag: (f) => {
|
|
6628
|
+
if (isEmpty(f))
|
|
6593
6629
|
return;
|
|
6594
|
-
|
|
6595
|
-
const
|
|
6596
|
-
|
|
6630
|
+
k(f);
|
|
6631
|
+
const v = `${f}`, w = `${v.startsWith("-") ? "-" : ""}${d}[${v.replace("-", "")}${g === "-" ? "" : g}]`;
|
|
6632
|
+
T(w);
|
|
6597
6633
|
},
|
|
6598
6634
|
currentValue: a,
|
|
6599
|
-
unit:
|
|
6635
|
+
unit: g,
|
|
6600
6636
|
negative: m,
|
|
6601
|
-
cssProperty:
|
|
6637
|
+
cssProperty: u
|
|
6602
6638
|
}
|
|
6603
6639
|
)
|
|
6604
6640
|
] }) }) });
|
|
@@ -6690,22 +6726,22 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
6690
6726
|
"2xl": "1536px"
|
|
6691
6727
|
}, getBreakpoint = (o) => `${o.toUpperCase()} ${BREAKPOINTS[o] ? `(${BREAKPOINTS[o]} & up)` : ""}`, BlockStyle = (o) => {
|
|
6692
6728
|
const { t: n } = useTranslation(), { type: r = "icons", label: a, property: l, onEmitChange: i = () => {
|
|
6693
|
-
}, units: c, negative: d = !1 } = o, [
|
|
6694
|
-
(
|
|
6695
|
-
const
|
|
6696
|
-
(
|
|
6697
|
-
const
|
|
6698
|
-
|
|
6729
|
+
}, units: c, negative: d = !1 } = o, [u] = useDarkMode(), [p] = useStylingState(), [, m] = useCanvasWidth(), g = useCurrentClassByProperty(l), x = useAddClassesToBlocks(), j = useRemoveClassesFromBlocks(), [E] = useSelectedBlockIds(), b = useMemo(() => get(g, "fullCls", ""), [g]), k = useCallback(
|
|
6730
|
+
(T, L = !0) => {
|
|
6731
|
+
const P = { dark: u, mq: m, mod: p, cls: T, property: l, fullCls: "" };
|
|
6732
|
+
(u || p !== "") && (P.mq = "xs");
|
|
6733
|
+
const f = generateFullClsName(P);
|
|
6734
|
+
x(E, [f], L);
|
|
6699
6735
|
},
|
|
6700
|
-
[
|
|
6736
|
+
[E, u, m, p, l, x]
|
|
6701
6737
|
), _ = useCallback(() => {
|
|
6702
|
-
E
|
|
6703
|
-
}, [
|
|
6738
|
+
j(E, [b]);
|
|
6739
|
+
}, [E, b, j]), S = useMemo(() => canChangeClass(g, m), [g, m]);
|
|
6704
6740
|
useEffect(() => {
|
|
6705
|
-
i(
|
|
6706
|
-
}, [
|
|
6707
|
-
const [, , B] = useCanvasWidth(),
|
|
6708
|
-
(
|
|
6741
|
+
i(S, g);
|
|
6742
|
+
}, [S, i, g]);
|
|
6743
|
+
const [, , B] = useCanvasWidth(), R = useCallback(
|
|
6744
|
+
(T) => {
|
|
6709
6745
|
B({
|
|
6710
6746
|
xs: 400,
|
|
6711
6747
|
sm: 640,
|
|
@@ -6713,31 +6749,31 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
6713
6749
|
lg: 1024,
|
|
6714
6750
|
xl: 1420,
|
|
6715
6751
|
"2xl": 1920
|
|
6716
|
-
}[
|
|
6752
|
+
}[T]);
|
|
6717
6753
|
},
|
|
6718
6754
|
[B]
|
|
6719
|
-
), A = get(
|
|
6720
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(BlockStyleProvider, { canChange:
|
|
6721
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: `text-[11px] ${
|
|
6755
|
+
), A = get(g, "dark", null) === u && get(g, "mod", null) === p && get(g, "mq", null) === m;
|
|
6756
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(BlockStyleProvider, { canChange: S, canReset: g && A, children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "group flex flex-row items-center py-2 first:pt-0 last:pb-0", children: [
|
|
6757
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: `text-[11px] ${g && !A ? "text-foreground" : ""}`, children: n(a) }) }),
|
|
6722
6758
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-row items-center", children: [
|
|
6723
6759
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "w-[150px]", children: [
|
|
6724
6760
|
r === "arbitrary" ? /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
6725
6761
|
AdvanceChoices,
|
|
6726
6762
|
{
|
|
6727
|
-
currentClass: get(
|
|
6763
|
+
currentClass: get(g, "cls", ""),
|
|
6728
6764
|
classPrefix: get(CLASS_PREFIXES, l, ""),
|
|
6729
6765
|
units: c || [],
|
|
6730
|
-
onChange:
|
|
6766
|
+
onChange: k,
|
|
6731
6767
|
negative: d,
|
|
6732
6768
|
cssProperty: l
|
|
6733
6769
|
}
|
|
6734
6770
|
) : null,
|
|
6735
|
-
r === "icons" && /* @__PURE__ */ jsxRuntimeExports.jsx(IconChoices, { property: l, onChange:
|
|
6736
|
-
r === "range" && /* @__PURE__ */ jsxRuntimeExports.jsx(RangeChoices, { property: l, onChange:
|
|
6737
|
-
r === "color" && /* @__PURE__ */ jsxRuntimeExports.jsx(ColorChoice, { property: l, onChange:
|
|
6738
|
-
r === "dropdown" && /* @__PURE__ */ jsxRuntimeExports.jsx(DropDownChoices, { label: a, property: l, onChange:
|
|
6771
|
+
r === "icons" && /* @__PURE__ */ jsxRuntimeExports.jsx(IconChoices, { property: l, onChange: k }),
|
|
6772
|
+
r === "range" && /* @__PURE__ */ jsxRuntimeExports.jsx(RangeChoices, { property: l, onChange: k }),
|
|
6773
|
+
r === "color" && /* @__PURE__ */ jsxRuntimeExports.jsx(ColorChoice, { property: l, onChange: k }),
|
|
6774
|
+
r === "dropdown" && /* @__PURE__ */ jsxRuntimeExports.jsx(DropDownChoices, { label: a, property: l, onChange: k })
|
|
6739
6775
|
] }),
|
|
6740
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `w-[30px] cursor-pointer ${
|
|
6776
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `w-[30px] cursor-pointer ${b ? "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" }) }) : S && g ? /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { delayDuration: 100, children: [
|
|
6741
6777
|
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
6742
6778
|
"button",
|
|
6743
6779
|
{
|
|
@@ -6749,19 +6785,19 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
6749
6785
|
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-right", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
|
|
6750
6786
|
"Current style is set at ",
|
|
6751
6787
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "font-bold", children: [
|
|
6752
|
-
getBreakpoint(get(
|
|
6753
|
-
|
|
6788
|
+
getBreakpoint(get(g, "mq")),
|
|
6789
|
+
u && !g.dark ? "(Light mode)" : ""
|
|
6754
6790
|
] }),
|
|
6755
6791
|
/* @__PURE__ */ jsxRuntimeExports.jsx("br", {}),
|
|
6756
6792
|
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
6757
6793
|
"button",
|
|
6758
6794
|
{
|
|
6759
6795
|
type: "button",
|
|
6760
|
-
onClick: () =>
|
|
6796
|
+
onClick: () => R(get(g, "mq")),
|
|
6761
6797
|
className: "block w-full cursor-default text-right font-semibold text-blue-500",
|
|
6762
6798
|
children: [
|
|
6763
6799
|
"Switch to ",
|
|
6764
|
-
get(
|
|
6800
|
+
get(g, "mq").toUpperCase()
|
|
6765
6801
|
]
|
|
6766
6802
|
}
|
|
6767
6803
|
)
|
|
@@ -6778,7 +6814,7 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
6778
6814
|
units: i = basicUnits,
|
|
6779
6815
|
negative: c = !1
|
|
6780
6816
|
}) => {
|
|
6781
|
-
const { t: d } = useTranslation(), [
|
|
6817
|
+
const { t: d } = useTranslation(), [u, p] = useState(n[0].key), m = useSelectedBlockCurrentClasses(), g = useCallback((x) => map(m, "property").includes(x), [m]);
|
|
6782
6818
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
6783
6819
|
"div",
|
|
6784
6820
|
{
|
|
@@ -6787,22 +6823,22 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
6787
6823
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-row text-xs", children: [
|
|
6788
6824
|
o && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "relative w-[70px] flex-none text-xs text-foreground", children: d(o) }),
|
|
6789
6825
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mb-3 flex grow flex-row flex-wrap gap-x-px", children: React__default.Children.toArray(
|
|
6790
|
-
n.map(({ label:
|
|
6826
|
+
n.map(({ label: x, key: j }) => /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "first:rounded-l last:rounded-r", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
|
|
6791
6827
|
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
6792
6828
|
"button",
|
|
6793
6829
|
{
|
|
6794
6830
|
type: "button",
|
|
6795
|
-
onClick: () =>
|
|
6796
|
-
className: `relative cursor-pointer rounded-full p-1 text-[8px] ${
|
|
6831
|
+
onClick: () => p(j),
|
|
6832
|
+
className: `relative cursor-pointer rounded-full p-1 text-[8px] ${j === u ? "bg-[#3E57F0] text-white" : "text-gray-600 dark:text-gray-300"}`,
|
|
6797
6833
|
children: [
|
|
6798
6834
|
React__default.createElement("div", {
|
|
6799
|
-
className:
|
|
6835
|
+
className: g(j) ? "-bottom-1.5 absolute bg-[#3E57F0] h-[2px] left-0 w-full" : ""
|
|
6800
6836
|
}),
|
|
6801
|
-
React__default.createElement(get(EDITOR_ICONS,
|
|
6837
|
+
React__default.createElement(get(EDITOR_ICONS, j, BoxIcon), { className: "text-inherit w-3 h-3" })
|
|
6802
6838
|
]
|
|
6803
6839
|
}
|
|
6804
6840
|
) }),
|
|
6805
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { children: startCase(toLower(
|
|
6841
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { children: startCase(toLower(x)) })
|
|
6806
6842
|
] }) }))
|
|
6807
6843
|
) })
|
|
6808
6844
|
] }),
|
|
@@ -6812,7 +6848,7 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
6812
6848
|
type: l,
|
|
6813
6849
|
units: [...i],
|
|
6814
6850
|
label: "",
|
|
6815
|
-
property:
|
|
6851
|
+
property: u,
|
|
6816
6852
|
negative: c
|
|
6817
6853
|
}
|
|
6818
6854
|
) })
|
|
@@ -6821,10 +6857,10 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
6821
6857
|
);
|
|
6822
6858
|
}, NestedOptions = ({ heading: o, items: n }) => {
|
|
6823
6859
|
const { t: r } = useTranslation(), a = useSelectedBlockCurrentClasses(), l = useMemo(() => {
|
|
6824
|
-
const i = (
|
|
6825
|
-
|
|
6860
|
+
const i = (u) => flatten(
|
|
6861
|
+
u.map((p) => p.styleType === "multiple" ? map(p.options, "key") : p.property)
|
|
6826
6862
|
), c = flatten(
|
|
6827
|
-
n.map((
|
|
6863
|
+
n.map((u) => u.styleType === "accordion" ? i(u.items) : u.styleType === "multiple" ? map(u.options, "key") : u.property)
|
|
6828
6864
|
), d = map(a, "property");
|
|
6829
6865
|
return intersection(c, d).length > 0;
|
|
6830
6866
|
}, [a, n]);
|
|
@@ -6844,11 +6880,11 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
6844
6880
|
const { t: n } = useTranslation(), r = useSelectedBlockCurrentClasses(), a = useCallback(
|
|
6845
6881
|
(i = []) => {
|
|
6846
6882
|
const c = {};
|
|
6847
|
-
for (let
|
|
6848
|
-
c[r[
|
|
6883
|
+
for (let u = 0; u < r.length; u++)
|
|
6884
|
+
c[r[u].property] = r[u].cls;
|
|
6849
6885
|
let d = !0;
|
|
6850
|
-
for (const
|
|
6851
|
-
if (!has(c,
|
|
6886
|
+
for (const u in i)
|
|
6887
|
+
if (!has(c, u) || c[u] !== i[u]) {
|
|
6852
6888
|
d = !1;
|
|
6853
6889
|
break;
|
|
6854
6890
|
}
|
|
@@ -6866,8 +6902,8 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
6866
6902
|
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`, {});
|
|
6867
6903
|
if (isEmpty(a) && (!has(i, "props") || isEmpty(d)))
|
|
6868
6904
|
return null;
|
|
6869
|
-
const
|
|
6870
|
-
const m =
|
|
6905
|
+
const u = (p) => {
|
|
6906
|
+
const m = p.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
|
|
6871
6907
|
l([o._id], m, !0);
|
|
6872
6908
|
};
|
|
6873
6909
|
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-10", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(DropdownMenu, { children: [
|
|
@@ -6883,16 +6919,16 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
6883
6919
|
r("presets")
|
|
6884
6920
|
] }),
|
|
6885
6921
|
/* @__PURE__ */ jsxRuntimeExports.jsx(DropdownMenuSeparator, {}),
|
|
6886
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(DropdownMenuGroup, { children: keys(d).map((
|
|
6887
|
-
capitalize(startCase(r(
|
|
6922
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(DropdownMenuGroup, { children: keys(d).map((p) => /* @__PURE__ */ jsxRuntimeExports.jsxs(DropdownMenuItem, { className: "group text-xs", onClick: () => u(d[p]), children: [
|
|
6923
|
+
capitalize(startCase(r(p))),
|
|
6888
6924
|
/* @__PURE__ */ jsxRuntimeExports.jsx(DropdownMenuShortcut, { className: "invisible hover:font-bold hover:text-blue-600 group-hover:visible", children: r("apply") })
|
|
6889
6925
|
] })) })
|
|
6890
6926
|
] }),
|
|
6891
6927
|
isEmpty(a) ? null : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
6892
6928
|
/* @__PURE__ */ jsxRuntimeExports.jsx(DropdownMenuLabel, { children: r("Global presets") }),
|
|
6893
6929
|
/* @__PURE__ */ jsxRuntimeExports.jsx(DropdownMenuSeparator, {}),
|
|
6894
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(DropdownMenuGroup, { children: keys(a).map((
|
|
6895
|
-
capitalize(startCase(r(
|
|
6930
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(DropdownMenuGroup, { children: keys(a).map((p) => /* @__PURE__ */ jsxRuntimeExports.jsxs(DropdownMenuItem, { className: "group text-xs", onClick: () => u(a[p]), children: [
|
|
6931
|
+
capitalize(startCase(r(p))),
|
|
6896
6932
|
/* @__PURE__ */ jsxRuntimeExports.jsx(DropdownMenuShortcut, { className: "invisible hover:font-bold hover:text-blue-600 group-hover:visible", children: r("apply") })
|
|
6897
6933
|
] })) })
|
|
6898
6934
|
] })
|
|
@@ -6912,8 +6948,8 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
6912
6948
|
};
|
|
6913
6949
|
function BlockStyling() {
|
|
6914
6950
|
const { flexChild: o, gridChild: n } = useSelectedBlocksDisplayChild(), [r] = useSelectedStylingBlocks(), [a, l] = React__default.useState(""), [i, c] = React__default.useState({
|
|
6915
|
-
onDrag: (
|
|
6916
|
-
onDragEnd: (
|
|
6951
|
+
onDrag: (p) => p,
|
|
6952
|
+
onDragEnd: (p) => p,
|
|
6917
6953
|
dragStartY: 0,
|
|
6918
6954
|
dragging: !1,
|
|
6919
6955
|
dragStartValue: 0,
|
|
@@ -6921,21 +6957,21 @@ function BlockStyling() {
|
|
|
6921
6957
|
negative: !1,
|
|
6922
6958
|
cssProperty: ""
|
|
6923
6959
|
}), d = useThrottledCallback(
|
|
6924
|
-
(
|
|
6925
|
-
const m = !get(i, "negative", !1),
|
|
6926
|
-
let
|
|
6927
|
-
|
|
6928
|
-
let
|
|
6929
|
-
(startsWith(
|
|
6930
|
-
let
|
|
6931
|
-
m &&
|
|
6960
|
+
(p) => {
|
|
6961
|
+
const m = !get(i, "negative", !1), g = get(i, "cssProperty", "");
|
|
6962
|
+
let x = parseFloat(i.dragStartValue);
|
|
6963
|
+
x = isNaN(x) ? 0 : x;
|
|
6964
|
+
let j = MAPPER[i.dragUnit];
|
|
6965
|
+
(startsWith(g, "scale") || g === "opacity") && (j = 10);
|
|
6966
|
+
let b = (i.dragStartY - p.pageY) / j + x;
|
|
6967
|
+
m && b < 0 && (b = 0), g === "opacity" && b > 1 && (b = 1), i.onDrag(`${b}`), l(`${b}`);
|
|
6932
6968
|
},
|
|
6933
6969
|
[i],
|
|
6934
6970
|
50
|
|
6935
|
-
),
|
|
6971
|
+
), u = useCallback(() => {
|
|
6936
6972
|
setTimeout(() => i.onDragEnd(`${a}`), 100), c({
|
|
6937
|
-
onDrag: (
|
|
6938
|
-
onDragEnd: (
|
|
6973
|
+
onDrag: (p) => p,
|
|
6974
|
+
onDragEnd: (p) => p,
|
|
6939
6975
|
dragStartY: 0,
|
|
6940
6976
|
dragging: !1,
|
|
6941
6977
|
dragStartValue: 0,
|
|
@@ -6949,7 +6985,7 @@ function BlockStyling() {
|
|
|
6949
6985
|
"div",
|
|
6950
6986
|
{
|
|
6951
6987
|
onMouseMove: d,
|
|
6952
|
-
onMouseUp: () =>
|
|
6988
|
+
onMouseUp: () => u(),
|
|
6953
6989
|
className: "absolute inset-0 z-30 cursor-row-resize bg-gray-300/10"
|
|
6954
6990
|
}
|
|
6955
6991
|
) : null,
|
|
@@ -6958,7 +6994,7 @@ function BlockStyling() {
|
|
|
6958
6994
|
/* @__PURE__ */ jsxRuntimeExports.jsxs(Accordion, { defaultValue: ["Styles"], type: "multiple", className: "w-full", children: [
|
|
6959
6995
|
o && /* @__PURE__ */ jsxRuntimeExports.jsx(StylingGroup, { section: FLEX_CHILD_SECTION }),
|
|
6960
6996
|
n ? /* @__PURE__ */ jsxRuntimeExports.jsx(StylingGroup, { section: GRID_CHILD_SECTION }) : null,
|
|
6961
|
-
SETTINGS_SECTIONS.map((
|
|
6997
|
+
SETTINGS_SECTIONS.map((p) => /* @__PURE__ */ jsxRuntimeExports.jsx(StylingGroup, { section: p }, p.heading))
|
|
6962
6998
|
] })
|
|
6963
6999
|
] })
|
|
6964
7000
|
] });
|
|
@@ -6970,9 +7006,9 @@ const ChaiSelect = ({
|
|
|
6970
7006
|
placeholder: a = "Select",
|
|
6971
7007
|
className: l = ""
|
|
6972
7008
|
}) => {
|
|
6973
|
-
const [i, c] = useState(o), d = (
|
|
6974
|
-
const
|
|
6975
|
-
c(
|
|
7009
|
+
const [i, c] = useState(o), d = (u) => {
|
|
7010
|
+
const p = u.target.value;
|
|
7011
|
+
c(p), n(p);
|
|
6976
7012
|
};
|
|
6977
7013
|
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: cn("relative inline-block w-full", l), children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
6978
7014
|
"select",
|
|
@@ -6982,7 +7018,7 @@ const ChaiSelect = ({
|
|
|
6982
7018
|
onChange: d,
|
|
6983
7019
|
children: [
|
|
6984
7020
|
/* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "", disabled: !0, children: a }),
|
|
6985
|
-
r.map((
|
|
7021
|
+
r.map((u) => /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: u.value, children: u.label }, u.value))
|
|
6986
7022
|
]
|
|
6987
7023
|
}
|
|
6988
7024
|
) });
|
|
@@ -7014,12 +7050,12 @@ const BlockCard = ({
|
|
|
7014
7050
|
library: n,
|
|
7015
7051
|
parentId: r = void 0
|
|
7016
7052
|
}) => {
|
|
7017
|
-
const [a, l] = useState(!1), i = useBuilderProp("getUILibraryBlock", noop), { addCoreBlock: c, addPredefinedBlock: d } = useAddBlock(), [,
|
|
7018
|
-
const _ = has(
|
|
7019
|
-
return
|
|
7020
|
-
},
|
|
7021
|
-
async (
|
|
7022
|
-
if (
|
|
7053
|
+
const [a, l] = useState(!1), i = useBuilderProp("getUILibraryBlock", noop), { addCoreBlock: c, addPredefinedBlock: d } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: p } = useBlockHighlight(), m = get(o, "name", get(o, "label")), g = useFeature("dnd"), [, x] = useAtom$1(draggedBlockAtom), j = (k) => {
|
|
7054
|
+
const _ = has(k, "styles_attrs.data-page-section");
|
|
7055
|
+
return k._type === "Box" && _;
|
|
7056
|
+
}, E = useCallback(
|
|
7057
|
+
async (k) => {
|
|
7058
|
+
if (k.stopPropagation(), has(o, "component")) {
|
|
7023
7059
|
c(o, r), emitChaiBuilderMsg({ name: CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK });
|
|
7024
7060
|
return;
|
|
7025
7061
|
}
|
|
@@ -7028,20 +7064,20 @@ const BlockCard = ({
|
|
|
7028
7064
|
isEmpty(_) || d(syncBlocksWithDefaults(_), r), emitChaiBuilderMsg({ name: CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK });
|
|
7029
7065
|
},
|
|
7030
7066
|
[o]
|
|
7031
|
-
),
|
|
7067
|
+
), b = async (k) => {
|
|
7032
7068
|
const _ = await i(n, o);
|
|
7033
|
-
let
|
|
7034
|
-
if (
|
|
7035
|
-
const B = { blocks: _, uiLibrary: !0, parent:
|
|
7036
|
-
if (
|
|
7037
|
-
const
|
|
7038
|
-
|
|
7039
|
-
|
|
7069
|
+
let S = r;
|
|
7070
|
+
if (j(first(_)) && (S = null), !isEmpty(_)) {
|
|
7071
|
+
const B = { blocks: _, uiLibrary: !0, parent: S };
|
|
7072
|
+
if (k.dataTransfer.setData("text/plain", JSON.stringify(B)), o.preview) {
|
|
7073
|
+
const R = new Image();
|
|
7074
|
+
R.src = o.preview, R.onload = () => {
|
|
7075
|
+
k.dataTransfer.setDragImage(R, 0, 0);
|
|
7040
7076
|
};
|
|
7041
7077
|
} else
|
|
7042
|
-
|
|
7043
|
-
|
|
7044
|
-
|
|
7078
|
+
k.dataTransfer.setDragImage(new Image(), 0, 0);
|
|
7079
|
+
x(B), setTimeout(() => {
|
|
7080
|
+
u([]), p(), emitChaiBuilderMsg({ name: CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK });
|
|
7045
7081
|
}, 200);
|
|
7046
7082
|
}
|
|
7047
7083
|
};
|
|
@@ -7050,9 +7086,9 @@ const BlockCard = ({
|
|
|
7050
7086
|
"div",
|
|
7051
7087
|
{
|
|
7052
7088
|
onClick: a ? () => {
|
|
7053
|
-
} :
|
|
7054
|
-
draggable:
|
|
7055
|
-
onDragStart:
|
|
7089
|
+
} : E,
|
|
7090
|
+
draggable: g ? "true" : "false",
|
|
7091
|
+
onDragStart: b,
|
|
7056
7092
|
className: clsx(
|
|
7057
7093
|
"relative mt-2 cursor-pointer overflow-hidden rounded-md border border-border bg-white duration-200 hover:border-blue-500 hover:shadow-xl"
|
|
7058
7094
|
),
|
|
@@ -7075,42 +7111,42 @@ const BlockCard = ({
|
|
|
7075
7111
|
(async () => {
|
|
7076
7112
|
if (i === "complete" || c.current === "loading")
|
|
7077
7113
|
return;
|
|
7078
|
-
c.current = "loading", r((
|
|
7114
|
+
c.current = "loading", r((u) => ({ ...u, [o == null ? void 0 : o.uuid]: { loading: "loading", blocks: [] } }));
|
|
7079
7115
|
const d = await a(o);
|
|
7080
|
-
c.current = "idle", r((
|
|
7116
|
+
c.current = "idle", r((u) => ({ ...u, [o == null ? void 0 : o.uuid]: { loading: "complete", blocks: d || [] } }));
|
|
7081
7117
|
})();
|
|
7082
7118
|
}, [o, l, i, c]), { data: l || [], isLoading: i === "loading" };
|
|
7083
7119
|
}, UILibrarySection = ({ parentId: o }) => {
|
|
7084
|
-
const [n, r] = useAtom$1(selectedLibraryAtom), a = useBuilderProp("uiLibraries", []), l = useChaiBlocks(), i = values(l).filter((
|
|
7085
|
-
|
|
7086
|
-
|
|
7120
|
+
const [n, r] = useAtom$1(selectedLibraryAtom), a = useBuilderProp("uiLibraries", []), l = useChaiBlocks(), i = values(l).filter((S) => S.category === "custom"), c = a.find((S) => S.uuid === n) || first(a), { data: d, isLoading: u } = useLibraryBlocks(c), p = groupBy([...d, ...i], "group"), [m, g] = useState("Hero"), x = get(p, m, []), j = useRef(null), { t: E } = useTranslation(), b = (S) => {
|
|
7121
|
+
j.current && (clearTimeout(j.current), j.current = null), j.current = setTimeout(() => {
|
|
7122
|
+
j.current && g(S);
|
|
7087
7123
|
}, 300);
|
|
7088
7124
|
};
|
|
7089
|
-
if (
|
|
7125
|
+
if (u)
|
|
7090
7126
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mt-4 grid h-full w-full grid-cols-12 gap-2", children: [
|
|
7091
7127
|
/* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "col-span-3 h-full" }),
|
|
7092
7128
|
/* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "col-span-9 h-full" })
|
|
7093
7129
|
] });
|
|
7094
|
-
const
|
|
7130
|
+
const k = filter(x, (S, B) => B % 2 === 0), _ = filter(x, (S, B) => B % 2 === 1);
|
|
7095
7131
|
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: [
|
|
7096
7132
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex h-full max-h-full w-60 flex-col gap-1 px-1 pr-2", children: [
|
|
7097
7133
|
/* @__PURE__ */ jsxRuntimeExports.jsx(UILibrariesSelect, { library: c == null ? void 0 : c.uuid, setLibrary: r, uiLibraries: a }),
|
|
7098
7134
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mt-2 flex h-full max-h-full w-full flex-1 flex-col", children: [
|
|
7099
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-xs font-bold text-gray-500", children:
|
|
7135
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-xs font-bold text-gray-500", children: E("groups") }),
|
|
7100
7136
|
/* @__PURE__ */ jsxRuntimeExports.jsx("hr", { className: "mt-1 border-border" }),
|
|
7101
7137
|
/* @__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(
|
|
7102
|
-
map(
|
|
7138
|
+
map(p, (S, B) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
7103
7139
|
"div",
|
|
7104
7140
|
{
|
|
7105
|
-
onMouseEnter: () =>
|
|
7106
|
-
onMouseLeave: () => clearTimeout(
|
|
7107
|
-
onClick: () =>
|
|
7141
|
+
onMouseEnter: () => b(B),
|
|
7142
|
+
onMouseLeave: () => clearTimeout(j.current),
|
|
7143
|
+
onClick: () => g(B),
|
|
7108
7144
|
className: cn(
|
|
7109
7145
|
"flex w-full cursor-pointer items-center justify-between rounded-md p-2 text-sm text-foreground transition-all ease-in-out hover:bg-gray-200 dark:hover:bg-gray-800",
|
|
7110
7146
|
B === m ? "bg-blue-500 text-white hover:bg-blue-600" : ""
|
|
7111
7147
|
),
|
|
7112
7148
|
children: [
|
|
7113
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: capitalize(
|
|
7149
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: capitalize(E(B.toLowerCase())) }),
|
|
7114
7150
|
/* @__PURE__ */ jsxRuntimeExports.jsx(CaretRightIcon, { className: "ml-2 h-5 w-5" })
|
|
7115
7151
|
]
|
|
7116
7152
|
},
|
|
@@ -7122,15 +7158,15 @@ const BlockCard = ({
|
|
|
7122
7158
|
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
7123
7159
|
ScrollArea,
|
|
7124
7160
|
{
|
|
7125
|
-
onMouseEnter: () =>
|
|
7161
|
+
onMouseEnter: () => j.current ? clearTimeout(j.current) : null,
|
|
7126
7162
|
className: "z-10 -mt-2 flex h-full max-h-full w-full flex-col gap-2 border-l border-border transition-all ease-linear",
|
|
7127
7163
|
children: [
|
|
7128
7164
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-2 gap-2 px-2", children: [
|
|
7129
7165
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-col gap-1", children: React__default.Children.toArray(
|
|
7130
|
-
|
|
7166
|
+
k.map((S) => /* @__PURE__ */ jsxRuntimeExports.jsx(BlockCard, { parentId: o, block: S, library: c }))
|
|
7131
7167
|
) }),
|
|
7132
7168
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-col gap-1", children: React__default.Children.toArray(
|
|
7133
|
-
_.map((
|
|
7169
|
+
_.map((S) => /* @__PURE__ */ jsxRuntimeExports.jsx(BlockCard, { parentId: o, block: S, library: c }))
|
|
7134
7170
|
) })
|
|
7135
7171
|
] }),
|
|
7136
7172
|
/* @__PURE__ */ jsxRuntimeExports.jsx("br", {}),
|
|
@@ -7575,54 +7611,54 @@ i18n.use(initReactI18next).init({
|
|
|
7575
7611
|
}
|
|
7576
7612
|
});
|
|
7577
7613
|
const CoreBlock = ({ block: o, disabled: n, parentId: r }) => {
|
|
7578
|
-
const [, a] = useAtom$1(draggedBlockAtom), { type: l, icon: i, label: c } = o, { addCoreBlock: d, addPredefinedBlock:
|
|
7614
|
+
const [, a] = useAtom$1(draggedBlockAtom), { type: l, icon: i, label: c } = o, { addCoreBlock: d, addPredefinedBlock: u } = useAddBlock(), [, p] = useSelectedBlockIds(), { clearHighlight: m } = useBlockHighlight(), g = () => {
|
|
7579
7615
|
if (has(o, "blocks")) {
|
|
7580
|
-
const
|
|
7581
|
-
|
|
7616
|
+
const E = isFunction$1(o.blocks) ? o.blocks() : o.blocks;
|
|
7617
|
+
u(syncBlocksWithDefaults(E), r || null);
|
|
7582
7618
|
} else
|
|
7583
7619
|
d(o, r || null);
|
|
7584
7620
|
emitChaiBuilderMsg({ name: CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK });
|
|
7585
|
-
},
|
|
7621
|
+
}, x = useFeature("dnd"), { t: j } = useTranslation();
|
|
7586
7622
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
|
|
7587
7623
|
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
7588
7624
|
"button",
|
|
7589
7625
|
{
|
|
7590
7626
|
disabled: n,
|
|
7591
|
-
onClick:
|
|
7627
|
+
onClick: g,
|
|
7592
7628
|
type: "button",
|
|
7593
|
-
onDragStart: (
|
|
7594
|
-
|
|
7595
|
-
|
|
7629
|
+
onDragStart: (E) => {
|
|
7630
|
+
E.dataTransfer.setData("text/plain", JSON.stringify(omit(o, ["component", "icon"]))), E.dataTransfer.setDragImage(new Image(), 0, 0), a(omit(o, ["component", "icon"])), setTimeout(() => {
|
|
7631
|
+
p([]), m();
|
|
7596
7632
|
}, 200);
|
|
7597
7633
|
},
|
|
7598
|
-
draggable:
|
|
7634
|
+
draggable: x ? "true" : "false",
|
|
7599
7635
|
className: "cursor-pointer space-y-2 rounded-lg border border-border p-3 text-center hover:bg-slate-300/50 disabled:cursor-not-allowed disabled:bg-gray-100 disabled:text-gray-400 dark:border-gray-700 dark:text-white dark:hover:bg-slate-800/50 dark:disabled:bg-gray-900 dark:disabled:text-foreground",
|
|
7600
7636
|
children: [
|
|
7601
7637
|
createElement(i || BoxIcon, { className: "w-4 h-4 mx-auto" }),
|
|
7602
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "truncate text-xs", children: capitalize(
|
|
7638
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "truncate text-xs", children: capitalize(j(c || l)) })
|
|
7603
7639
|
]
|
|
7604
7640
|
}
|
|
7605
7641
|
) }),
|
|
7606
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { children:
|
|
7642
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { children: j(c || l) }) })
|
|
7607
7643
|
] }) });
|
|
7608
7644
|
}, DefaultChaiBlocks = ({ parentId: o, gridCols: n = "grid-cols-2" }) => {
|
|
7609
7645
|
const r = useChaiBlocks(), a = useBuilderProp("filterChaiBlock", () => !0), l = filter(r, a), i = groupBy(l, "category"), c = uniq(map(i.core, "group"));
|
|
7610
7646
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(ChaiBuilderBlocks, { gridCols: n, parentId: o, groups: c, blocks: i.core });
|
|
7611
7647
|
}, CORE_GROUPS = ["basic", "typography", "media", "layout", "form", "advanced", "other"], ChaiBuilderBlocks = ({ groups: o, blocks: n, parentId: r, gridCols: a = "grid-cols-4" }) => {
|
|
7612
7648
|
var d;
|
|
7613
|
-
const { t: l } = useTranslation(), [i] = useBlocksStore(), c = (d = find(i, (
|
|
7649
|
+
const { t: l } = useTranslation(), [i] = useBlocksStore(), c = (d = find(i, (u) => u._id === r)) == null ? void 0 : d._type;
|
|
7614
7650
|
return React__default.Children.toArray(
|
|
7615
7651
|
map(
|
|
7616
|
-
sortBy(o, (
|
|
7617
|
-
(
|
|
7618
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(AccordionTrigger, { className: "rounded-md bg-background px-4 py-2 capitalize text-foreground hover:no-underline", children: capitalize(l(
|
|
7652
|
+
sortBy(o, (u) => CORE_GROUPS.indexOf(u) === -1 ? 99 : CORE_GROUPS.indexOf(u)),
|
|
7653
|
+
(u) => reject(filter(values(n), { group: u }), { hidden: !0 }).length ? /* @__PURE__ */ jsxRuntimeExports.jsx(Accordion, { type: "single", value: u, collapsible: !0, className: "w-full", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(AccordionItem, { value: u, className: "border-border", children: [
|
|
7654
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(AccordionTrigger, { className: "rounded-md bg-background px-4 py-2 capitalize text-foreground hover:no-underline", children: capitalize(l(u.toLowerCase())) }),
|
|
7619
7655
|
/* @__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(
|
|
7620
|
-
reject(filter(values(n), { group:
|
|
7656
|
+
reject(filter(values(n), { group: u }), { hidden: !0 }).map((p) => /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
7621
7657
|
CoreBlock,
|
|
7622
7658
|
{
|
|
7623
7659
|
parentId: r,
|
|
7624
|
-
block:
|
|
7625
|
-
disabled: !canAcceptChildBlock(c,
|
|
7660
|
+
block: p,
|
|
7661
|
+
disabled: !canAcceptChildBlock(c, p.type) || !canBeNestedInside(c, p.type)
|
|
7626
7662
|
}
|
|
7627
7663
|
))
|
|
7628
7664
|
) }) })
|
|
@@ -7643,8 +7679,8 @@ const CoreBlock = ({ block: o, disabled: n, parentId: r }) => {
|
|
|
7643
7679
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
7644
7680
|
Tabs,
|
|
7645
7681
|
{
|
|
7646
|
-
onValueChange: (
|
|
7647
|
-
c(""), i(
|
|
7682
|
+
onValueChange: (u) => {
|
|
7683
|
+
c(""), i(u);
|
|
7648
7684
|
},
|
|
7649
7685
|
value: l,
|
|
7650
7686
|
className: cn("h-max"),
|
|
@@ -7929,7 +7965,7 @@ function QuickPrompts({ onClick: o }) {
|
|
|
7929
7965
|
icon: FaLanguage$1,
|
|
7930
7966
|
prompt: `Translate the content to ${get(LANGUAGES, a, a)}. Maintain same tone, style and length.`
|
|
7931
7967
|
}), /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: n ? "pointer-events-none opacity-50" : "", children: /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { className: "space-y-2", children: i.map(
|
|
7932
|
-
({ name: c, icon: d, subMenus:
|
|
7968
|
+
({ name: c, icon: d, subMenus: u, prompt: p }) => u ? /* @__PURE__ */ jsxRuntimeExports.jsxs(Popover, { children: [
|
|
7933
7969
|
/* @__PURE__ */ jsxRuntimeExports.jsx(PopoverTrigger, { asChild: !0, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
7934
7970
|
"li",
|
|
7935
7971
|
{
|
|
@@ -7945,7 +7981,7 @@ function QuickPrompts({ onClick: o }) {
|
|
|
7945
7981
|
] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
7946
7982
|
"li",
|
|
7947
7983
|
{
|
|
7948
|
-
onClick: () => o(
|
|
7984
|
+
onClick: () => o(p),
|
|
7949
7985
|
className: "flex cursor-pointer items-center space-x-2 rounded p-1 text-sm hover:bg-gray-100 dark:hover:bg-gray-800",
|
|
7950
7986
|
children: [
|
|
7951
7987
|
/* @__PURE__ */ jsxRuntimeExports.jsx(d, { className: "h-4 w-4" }),
|
|
@@ -7957,20 +7993,20 @@ function QuickPrompts({ onClick: o }) {
|
|
|
7957
7993
|
) }) });
|
|
7958
7994
|
}
|
|
7959
7995
|
const AIUserPrompt = ({ blockId: o }) => {
|
|
7960
|
-
const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, c] = useState(""), [d,
|
|
7996
|
+
const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, c] = useState(""), [d, u] = useState(!0), [p, m] = useState(), g = useRef(null), x = useRef(null);
|
|
7961
7997
|
useEffect(() => {
|
|
7962
|
-
var
|
|
7963
|
-
(
|
|
7998
|
+
var E;
|
|
7999
|
+
(E = g.current) == null || E.focus();
|
|
7964
8000
|
}, []);
|
|
7965
|
-
const
|
|
7966
|
-
const { usage:
|
|
7967
|
-
!l &&
|
|
8001
|
+
const j = (E) => {
|
|
8002
|
+
const { usage: b } = E || {};
|
|
8003
|
+
!l && b && m(b), x.current = setTimeout(() => m(void 0), 1e4), l || c("");
|
|
7968
8004
|
};
|
|
7969
8005
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "", children: [
|
|
7970
8006
|
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
7971
8007
|
"div",
|
|
7972
8008
|
{
|
|
7973
|
-
onClick: () =>
|
|
8009
|
+
onClick: () => u(!d),
|
|
7974
8010
|
className: "flex cursor-pointer items-center justify-between border-b border-border py-2 text-sm font-bold text-muted-foreground hover:underline",
|
|
7975
8011
|
children: [
|
|
7976
8012
|
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: n("Ask AI") }),
|
|
@@ -7982,14 +8018,14 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
7982
8018
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
7983
8019
|
Textarea,
|
|
7984
8020
|
{
|
|
7985
|
-
ref:
|
|
8021
|
+
ref: g,
|
|
7986
8022
|
value: i,
|
|
7987
|
-
onChange: (
|
|
8023
|
+
onChange: (E) => c(E.target.value),
|
|
7988
8024
|
placeholder: n("Ask AI to edit content"),
|
|
7989
8025
|
className: "w-full",
|
|
7990
8026
|
rows: 3,
|
|
7991
|
-
onKeyDown: (
|
|
7992
|
-
|
|
8027
|
+
onKeyDown: (E) => {
|
|
8028
|
+
E.key === "Enter" && (E.preventDefault(), x.current && clearTimeout(x.current), m(void 0), r("content", o, i, j));
|
|
7993
8029
|
}
|
|
7994
8030
|
}
|
|
7995
8031
|
),
|
|
@@ -7999,7 +8035,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
7999
8035
|
{
|
|
8000
8036
|
disabled: i.trim().length < 5 || a,
|
|
8001
8037
|
onClick: () => {
|
|
8002
|
-
|
|
8038
|
+
x.current && clearTimeout(x.current), m(void 0), r("content", o, i, j);
|
|
8003
8039
|
},
|
|
8004
8040
|
variant: "default",
|
|
8005
8041
|
className: "w-fit",
|
|
@@ -8018,11 +8054,11 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8018
8054
|
/* @__PURE__ */ jsxRuntimeExports.jsx(Button, { variant: "destructive", onClick: () => stop(), className: "hidden w-fit", size: "sm", children: n("Stop") })
|
|
8019
8055
|
] }) : null
|
|
8020
8056
|
] }),
|
|
8021
|
-
|
|
8057
|
+
p ? /* @__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: [
|
|
8022
8058
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("span", { children: [
|
|
8023
8059
|
n("Total tokens used"),
|
|
8024
8060
|
": ",
|
|
8025
|
-
|
|
8061
|
+
p.totalTokens
|
|
8026
8062
|
] }),
|
|
8027
8063
|
/* @__PURE__ */ jsxRuntimeExports.jsx(Countdown, {})
|
|
8028
8064
|
] }) }) : null,
|
|
@@ -8031,8 +8067,8 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8031
8067
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
8032
8068
|
QuickPrompts,
|
|
8033
8069
|
{
|
|
8034
|
-
onClick: (
|
|
8035
|
-
|
|
8070
|
+
onClick: (E) => {
|
|
8071
|
+
x.current && clearTimeout(x.current), m(void 0), r("content", o, E, j);
|
|
8036
8072
|
}
|
|
8037
8073
|
}
|
|
8038
8074
|
)
|
|
@@ -8042,19 +8078,19 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8042
8078
|
] }) }) : null
|
|
8043
8079
|
] });
|
|
8044
8080
|
}, AISetContext = () => {
|
|
8045
|
-
const { t: o } = useTranslation(), n = useBuilderProp("aiContext", ""), [r, a] = useState(n), l = useRef(null), i = useBuilderProp("saveAiContextCallback", noop), [c, d] = useState(!1), [
|
|
8081
|
+
const { t: o } = useTranslation(), n = useBuilderProp("aiContext", ""), [r, a] = useState(n), l = useRef(null), i = useBuilderProp("saveAiContextCallback", noop), [c, d] = useState(!1), [u, p] = useState(null), [, m] = useState(!1), { toast: g } = useToast(), x = useRef(null);
|
|
8046
8082
|
useEffect(() => {
|
|
8047
8083
|
n && a(n);
|
|
8048
8084
|
}, [n]);
|
|
8049
|
-
const
|
|
8085
|
+
const j = async () => {
|
|
8050
8086
|
try {
|
|
8051
|
-
d(!0),
|
|
8087
|
+
d(!0), p(null), await i(r), g({
|
|
8052
8088
|
title: o("Updated AI Context"),
|
|
8053
8089
|
description: o("You can now Ask AI to edit your content"),
|
|
8054
8090
|
variant: "default"
|
|
8055
|
-
}),
|
|
8056
|
-
} catch (
|
|
8057
|
-
|
|
8091
|
+
}), x.current.click();
|
|
8092
|
+
} catch (E) {
|
|
8093
|
+
p(E);
|
|
8058
8094
|
} finally {
|
|
8059
8095
|
d(!1);
|
|
8060
8096
|
}
|
|
@@ -8062,25 +8098,25 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8062
8098
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
8063
8099
|
Accordion,
|
|
8064
8100
|
{
|
|
8065
|
-
onValueChange: (
|
|
8066
|
-
m(
|
|
8101
|
+
onValueChange: (E) => {
|
|
8102
|
+
m(E !== "");
|
|
8067
8103
|
},
|
|
8068
8104
|
type: "single",
|
|
8069
8105
|
collapsible: !0,
|
|
8070
8106
|
children: /* @__PURE__ */ jsxRuntimeExports.jsxs(AccordionItem, { value: "set-context", className: "border-none", children: [
|
|
8071
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(AccordionTrigger, { ref:
|
|
8107
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(AccordionTrigger, { ref: x, className: "border-b border-border py-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex w-full items-center justify-between", children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "font-bold text-muted-foreground", children: o("AI Context") }) }) }),
|
|
8072
8108
|
/* @__PURE__ */ jsxRuntimeExports.jsxs(AccordionContent, { children: [
|
|
8073
8109
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
8074
8110
|
Textarea,
|
|
8075
8111
|
{
|
|
8076
8112
|
ref: l,
|
|
8077
8113
|
value: r,
|
|
8078
|
-
onChange: (
|
|
8114
|
+
onChange: (E) => a(E.target.value),
|
|
8079
8115
|
placeholder: o("Tell about this page eg this page is about"),
|
|
8080
8116
|
className: "mt-1 w-full",
|
|
8081
8117
|
rows: 10,
|
|
8082
|
-
onKeyDown: (
|
|
8083
|
-
|
|
8118
|
+
onKeyDown: (E) => {
|
|
8119
|
+
E.key === "Enter" && (E.preventDefault(), j());
|
|
8084
8120
|
}
|
|
8085
8121
|
}
|
|
8086
8122
|
),
|
|
@@ -8092,7 +8128,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8092
8128
|
Button,
|
|
8093
8129
|
{
|
|
8094
8130
|
disabled: r.trim().length < 5,
|
|
8095
|
-
onClick: () =>
|
|
8131
|
+
onClick: () => j(),
|
|
8096
8132
|
variant: "default",
|
|
8097
8133
|
className: "w-fit",
|
|
8098
8134
|
size: "sm",
|
|
@@ -8121,7 +8157,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8121
8157
|
AlertDialogAction,
|
|
8122
8158
|
{
|
|
8123
8159
|
onClick: () => {
|
|
8124
|
-
a(""),
|
|
8160
|
+
a(""), j();
|
|
8125
8161
|
},
|
|
8126
8162
|
children: o("Yes, Delete")
|
|
8127
8163
|
}
|
|
@@ -8130,7 +8166,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8130
8166
|
] })
|
|
8131
8167
|
] }) : null
|
|
8132
8168
|
] }),
|
|
8133
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mt-2 max-w-full", children:
|
|
8169
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mt-2 max-w-full", children: u && /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "break-words rounded border border-red-500 bg-red-100 p-1 text-xs text-red-500", children: u.message }) })
|
|
8134
8170
|
] })
|
|
8135
8171
|
] })
|
|
8136
8172
|
}
|
|
@@ -8142,42 +8178,42 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8142
8178
|
/* @__PURE__ */ jsxRuntimeExports.jsx(AIUserPrompt, { blockId: first(o) })
|
|
8143
8179
|
] });
|
|
8144
8180
|
}, AttrsEditor = React__default.memo(function o({ preloadedAttributes: n = [], onAttributesChange: r }) {
|
|
8145
|
-
const [a, l] = useState([]), [i, c] = useState(""), [d,
|
|
8181
|
+
const [a, l] = useState([]), [i, c] = useState(""), [d, u] = useState(""), [p, m] = useState(null), [g, x] = useState(""), j = useRef(null), E = useRef(null);
|
|
8146
8182
|
useEffect(() => {
|
|
8147
8183
|
l(n);
|
|
8148
8184
|
}, [n]);
|
|
8149
|
-
const
|
|
8185
|
+
const b = () => {
|
|
8150
8186
|
if (i.startsWith("@")) {
|
|
8151
|
-
|
|
8187
|
+
x("Attribute keys cannot start with '@'");
|
|
8152
8188
|
return;
|
|
8153
8189
|
}
|
|
8154
8190
|
if (i) {
|
|
8155
|
-
const
|
|
8156
|
-
r(
|
|
8191
|
+
const R = [...a, { key: i, value: d }];
|
|
8192
|
+
r(R), l(a), c(""), u(""), x("");
|
|
8157
8193
|
}
|
|
8158
|
-
},
|
|
8159
|
-
const A = a.filter((
|
|
8194
|
+
}, k = (R) => {
|
|
8195
|
+
const A = a.filter((T, L) => L !== R);
|
|
8160
8196
|
r(A), l(A);
|
|
8161
|
-
}, _ = (
|
|
8162
|
-
m(
|
|
8163
|
-
},
|
|
8197
|
+
}, _ = (R) => {
|
|
8198
|
+
m(R), c(a[R].key), u(a[R].value);
|
|
8199
|
+
}, S = () => {
|
|
8164
8200
|
if (i.startsWith("@")) {
|
|
8165
|
-
|
|
8201
|
+
x("Attribute keys cannot start with '@'");
|
|
8166
8202
|
return;
|
|
8167
8203
|
}
|
|
8168
|
-
if (
|
|
8169
|
-
const
|
|
8170
|
-
|
|
8204
|
+
if (p !== null && i) {
|
|
8205
|
+
const R = [...a];
|
|
8206
|
+
R[p] = { key: i, value: d }, r(R), l(R), m(null), c(""), u(""), x("");
|
|
8171
8207
|
}
|
|
8172
|
-
}, B = (
|
|
8173
|
-
|
|
8208
|
+
}, B = (R) => {
|
|
8209
|
+
R.key === "Enter" && !R.shiftKey && (R.preventDefault(), p !== null ? S() : b());
|
|
8174
8210
|
};
|
|
8175
8211
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "max-w-full", children: [
|
|
8176
8212
|
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
8177
8213
|
"form",
|
|
8178
8214
|
{
|
|
8179
|
-
onSubmit: (
|
|
8180
|
-
|
|
8215
|
+
onSubmit: (R) => {
|
|
8216
|
+
R.preventDefault(), p !== null ? S() : b();
|
|
8181
8217
|
},
|
|
8182
8218
|
className: "space-y-3",
|
|
8183
8219
|
children: [
|
|
@@ -8191,9 +8227,9 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8191
8227
|
autoCorrect: "off",
|
|
8192
8228
|
spellCheck: "false",
|
|
8193
8229
|
id: "attrKey",
|
|
8194
|
-
ref:
|
|
8230
|
+
ref: j,
|
|
8195
8231
|
value: i,
|
|
8196
|
-
onChange: (
|
|
8232
|
+
onChange: (R) => c(R.target.value),
|
|
8197
8233
|
placeholder: "Key",
|
|
8198
8234
|
className: "h-8 text-sm"
|
|
8199
8235
|
}
|
|
@@ -8209,9 +8245,9 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8209
8245
|
spellCheck: "false",
|
|
8210
8246
|
id: "attrValue",
|
|
8211
8247
|
rows: 2,
|
|
8212
|
-
ref:
|
|
8248
|
+
ref: E,
|
|
8213
8249
|
value: d,
|
|
8214
|
-
onChange: (
|
|
8250
|
+
onChange: (R) => u(R.target.value),
|
|
8215
8251
|
onKeyDown: B,
|
|
8216
8252
|
placeholder: "Value",
|
|
8217
8253
|
className: "bg-background text-sm"
|
|
@@ -8219,22 +8255,22 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8219
8255
|
)
|
|
8220
8256
|
] })
|
|
8221
8257
|
] }),
|
|
8222
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(Button, { type: "submit", variant: "secondary", className: "h-8 w-fit text-sm", children:
|
|
8223
|
-
|
|
8258
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Button, { type: "submit", variant: "secondary", className: "h-8 w-fit text-sm", children: p !== null ? "Save" : "Add" }),
|
|
8259
|
+
g && /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-red-500", children: g })
|
|
8224
8260
|
]
|
|
8225
8261
|
}
|
|
8226
8262
|
),
|
|
8227
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mt-4 space-y-1 overflow-y-auto", children: a.map((
|
|
8263
|
+
/* @__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: [
|
|
8228
8264
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mr-2 flex flex-col", children: [
|
|
8229
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "truncate font-semibold", children:
|
|
8230
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-wrap max-w-[200px] text-muted-foreground", children:
|
|
8265
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "truncate font-semibold", children: R.key }),
|
|
8266
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-wrap max-w-[200px] text-muted-foreground", children: R.value.toString() })
|
|
8231
8267
|
] }),
|
|
8232
8268
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-shrink-0", children: [
|
|
8233
8269
|
/* @__PURE__ */ jsxRuntimeExports.jsxs(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => _(A), children: [
|
|
8234
8270
|
/* @__PURE__ */ jsxRuntimeExports.jsx(Edit2, { className: "h-3 w-3" }),
|
|
8235
8271
|
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "sr-only", children: "Edit attribute" })
|
|
8236
8272
|
] }),
|
|
8237
|
-
/* @__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: () => k(A), children: [
|
|
8238
8274
|
/* @__PURE__ */ jsxRuntimeExports.jsx(X, { className: "h-3 w-3" }),
|
|
8239
8275
|
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "sr-only", children: "Remove attribute" })
|
|
8240
8276
|
] })
|
|
@@ -8244,15 +8280,15 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8244
8280
|
}), BlockAttributesEditor = React.memo(() => {
|
|
8245
8281
|
const o = useSelectedBlock(), [n, r] = useState([]), [a] = useSelectedStylingBlocks(), l = useUpdateBlocksProps(), i = `${get(a, "0.prop")}_attrs`;
|
|
8246
8282
|
React.useEffect(() => {
|
|
8247
|
-
const d = map(get(o, i), (
|
|
8283
|
+
const d = map(get(o, i), (u, p) => ({ key: p, value: u }));
|
|
8248
8284
|
isEmpty(d) ? r([]) : r(d);
|
|
8249
8285
|
}, [get(o, i)]);
|
|
8250
8286
|
const c = React.useCallback(
|
|
8251
8287
|
(d = []) => {
|
|
8252
|
-
const
|
|
8253
|
-
forEach(d, (
|
|
8254
|
-
isEmpty(
|
|
8255
|
-
}), l([get(o, "_id")], { [i]:
|
|
8288
|
+
const u = {};
|
|
8289
|
+
forEach(d, (p) => {
|
|
8290
|
+
isEmpty(p.key) || set(u, p.key, p.value);
|
|
8291
|
+
}), l([get(o, "_id")], { [i]: u });
|
|
8256
8292
|
},
|
|
8257
8293
|
[o, l, i]
|
|
8258
8294
|
);
|
|
@@ -8378,7 +8414,7 @@ const TabletIcon = ({ landscape: o = !1 }) => /* @__PURE__ */ jsxRuntimeExports.
|
|
|
8378
8414
|
] });
|
|
8379
8415
|
}, Breakpoints = () => {
|
|
8380
8416
|
const [, o, n] = useCanvasWidth(), [r, a] = useSelectedBreakpoints(), { t: l } = useTranslation(), i = useBuilderProp("breakpoints", WEB_BREAKPOINTS), c = (d) => {
|
|
8381
|
-
r.includes(d) ? r.length > 2 && a(r.filter((
|
|
8417
|
+
r.includes(d) ? r.length > 2 && a(r.filter((u) => u !== d)) : a((u) => [...u, d]);
|
|
8382
8418
|
};
|
|
8383
8419
|
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: [
|
|
8384
8420
|
map(
|
|
@@ -8428,8 +8464,8 @@ const TabletIcon = ({ landscape: o = !1 }) => /* @__PURE__ */ jsxRuntimeExports.
|
|
|
8428
8464
|
const { fallbackLang: o, languages: n, selectedLang: r, setSelectedLang: a } = useLanguages(), l = (r == null ? void 0 : r.length) > 0 ? r : o, i = useMemo(() => {
|
|
8429
8465
|
const c = [];
|
|
8430
8466
|
return forEach(uniq([o, ...n]), (d) => {
|
|
8431
|
-
const
|
|
8432
|
-
|
|
8467
|
+
const u = get(LANGUAGES, d);
|
|
8468
|
+
u && c.push({ key: d, value: u, default: d === o });
|
|
8433
8469
|
}), c;
|
|
8434
8470
|
}, [o, n]);
|
|
8435
8471
|
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: [
|
|
@@ -8696,16 +8732,16 @@ function RemoveProviderConfirmation({
|
|
|
8696
8732
|
}
|
|
8697
8733
|
const PageDataProviders = () => {
|
|
8698
8734
|
const { t: o } = useTranslation(), n = useMemo(() => getChaiDataProviders(), []), [r, a] = usePageDataProviders(), [, l] = useAtom$1(builderSaveStateAtom), [i, c] = useState(
|
|
8699
|
-
filter(n, (
|
|
8700
|
-
), [d,
|
|
8701
|
-
n.map((
|
|
8702
|
-
(
|
|
8703
|
-
),
|
|
8704
|
-
const
|
|
8705
|
-
c((_) => [..._,
|
|
8706
|
-
},
|
|
8707
|
-
c((
|
|
8708
|
-
},
|
|
8735
|
+
filter(n, (b) => map(r, "providerKey").includes(b.providerKey))
|
|
8736
|
+
), [d, u] = useState(""), [p, m] = useState(null), g = filter(
|
|
8737
|
+
n.map((b) => map(i, "providerKey").includes(b.providerKey) ? null : { value: b.providerKey, label: b.name }),
|
|
8738
|
+
(b) => !isNull(b)
|
|
8739
|
+
), x = (b) => {
|
|
8740
|
+
const k = find(n, { providerKey: b });
|
|
8741
|
+
c((_) => [..._, k]), a((_) => [..._, { providerKey: k.providerKey, args: {} }]), u(""), l("UNSAVED");
|
|
8742
|
+
}, j = (b) => {
|
|
8743
|
+
c((k) => filter(k, (_) => _.providerKey !== b.providerKey)), a((k) => filter(k, (_) => _.providerKey !== b.providerKey)), l("UNSAVED");
|
|
8744
|
+
}, E = (b) => m(b);
|
|
8709
8745
|
return isEmpty(n) ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "mb-1.5 p-4 text-xs text-gray-500", children: [
|
|
8710
8746
|
o("no_data_providers"),
|
|
8711
8747
|
/* @__PURE__ */ jsxRuntimeExports.jsx("br", {}),
|
|
@@ -8713,11 +8749,11 @@ const PageDataProviders = () => {
|
|
|
8713
8749
|
] }) }) : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "px-1", children: [
|
|
8714
8750
|
/* @__PURE__ */ jsxRuntimeExports.jsx("br", {}),
|
|
8715
8751
|
/* @__PURE__ */ jsxRuntimeExports.jsx("label", { children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "mb-1.5 text-xs text-gray-500", children: o("add_data_providers") }) }),
|
|
8716
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center space-x-1", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(Select, { value: d, onValueChange: (
|
|
8752
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center space-x-1", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(Select, { value: d, onValueChange: (b) => x(b), children: [
|
|
8717
8753
|
/* @__PURE__ */ jsxRuntimeExports.jsx(SelectTrigger, { className: "w-full", children: /* @__PURE__ */ jsxRuntimeExports.jsx(SelectValue, { placeholder: o("select_provider") }) }),
|
|
8718
8754
|
/* @__PURE__ */ jsxRuntimeExports.jsxs(SelectContent, { children: [
|
|
8719
8755
|
/* @__PURE__ */ jsxRuntimeExports.jsx(SelectItem, { value: "", children: o("choose") }),
|
|
8720
|
-
|
|
8756
|
+
g.map((b) => /* @__PURE__ */ jsxRuntimeExports.jsx(SelectItem, { value: b.value, children: b.label }, b.value))
|
|
8721
8757
|
] })
|
|
8722
8758
|
] }) }),
|
|
8723
8759
|
/* @__PURE__ */ jsxRuntimeExports.jsx("br", {}),
|
|
@@ -8726,21 +8762,21 @@ const PageDataProviders = () => {
|
|
|
8726
8762
|
o("page_data_providers"),
|
|
8727
8763
|
":"
|
|
8728
8764
|
] }),
|
|
8729
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "space-y-2", children: i.map((
|
|
8765
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "space-y-2", children: i.map((b) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
8730
8766
|
"div",
|
|
8731
8767
|
{
|
|
8732
8768
|
className: "w-full rounded-lg border border-border bg-card text-card-foreground shadow-sm",
|
|
8733
8769
|
"data-v0-t": "card",
|
|
8734
8770
|
children: [
|
|
8735
8771
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-col space-y-1.5 px-4 pt-4", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-between", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
|
|
8736
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "font-medium leading-4", children:
|
|
8737
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "pt-1 text-xs text-gray-400", children:
|
|
8772
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "font-medium leading-4", children: b.name }),
|
|
8773
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "pt-1 text-xs text-gray-400", children: b.description })
|
|
8738
8774
|
] }) }) }),
|
|
8739
8775
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between p-2 py-2", children: [
|
|
8740
8776
|
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
8741
8777
|
"button",
|
|
8742
8778
|
{
|
|
8743
|
-
onClick: () => b
|
|
8779
|
+
onClick: () => E(b),
|
|
8744
8780
|
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",
|
|
8745
8781
|
children: [
|
|
8746
8782
|
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
@@ -8766,7 +8802,7 @@ const PageDataProviders = () => {
|
|
|
8766
8802
|
]
|
|
8767
8803
|
}
|
|
8768
8804
|
),
|
|
8769
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(RemoveProviderConfirmation, { onRemove: () =>
|
|
8805
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(RemoveProviderConfirmation, { onRemove: () => j(b), name: b.name, children: /* @__PURE__ */ jsxRuntimeExports.jsxs("button", { className: "inline-flex h-9 items-center justify-center rounded-md px-3 text-xs font-medium text-red-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", children: [
|
|
8770
8806
|
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
8771
8807
|
"svg",
|
|
8772
8808
|
{
|
|
@@ -8792,16 +8828,16 @@ const PageDataProviders = () => {
|
|
|
8792
8828
|
] })
|
|
8793
8829
|
]
|
|
8794
8830
|
},
|
|
8795
|
-
|
|
8831
|
+
b.providerKey
|
|
8796
8832
|
)) }),
|
|
8797
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(ViewProviderData, { onClose: () => m(null), provider:
|
|
8833
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(ViewProviderData, { onClose: () => m(null), provider: p })
|
|
8798
8834
|
] })
|
|
8799
8835
|
] });
|
|
8800
8836
|
};
|
|
8801
8837
|
function AiFillDatabase(o) {
|
|
8802
8838
|
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);
|
|
8803
8839
|
}
|
|
8804
|
-
const TopBar = lazy(() => import("./Topbar-
|
|
8840
|
+
const TopBar = lazy(() => import("./Topbar-lJgYu8sz.js"));
|
|
8805
8841
|
function useSidebarMenuItems(o) {
|
|
8806
8842
|
const n = o === "SINGLE_SIDE_PANEL", { t: r } = useTranslation(), a = useBuilderProp("dataBindingSupport", !1), l = useBuilderProp("askAiCallBack", null);
|
|
8807
8843
|
return useMemo(() => {
|
|
@@ -8828,15 +8864,15 @@ function isDualLayout(o) {
|
|
|
8828
8864
|
}
|
|
8829
8865
|
const RootLayout = () => {
|
|
8830
8866
|
const [o, n] = useState(0), [r] = useLayoutVariant(), [a, l] = useState(!1);
|
|
8831
|
-
useChaiBuilderMsgListener(({ name:
|
|
8832
|
-
|
|
8867
|
+
useChaiBuilderMsgListener(({ name: x }) => {
|
|
8868
|
+
x === CHAI_BUILDER_EVENTS.SHOW_BLOCK_SETTINGS && n(1);
|
|
8833
8869
|
});
|
|
8834
|
-
const i = useBuilderProp("sideBarComponents.top", []), c = (
|
|
8835
|
-
|
|
8836
|
-
}, d = (
|
|
8837
|
-
n(o ===
|
|
8838
|
-
},
|
|
8839
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { dir:
|
|
8870
|
+
const i = useBuilderProp("sideBarComponents.top", []), c = (x) => {
|
|
8871
|
+
x.preventDefault();
|
|
8872
|
+
}, d = (x) => {
|
|
8873
|
+
n(o === x ? null : x);
|
|
8874
|
+
}, u = useSidebarMenuItems(r), { t: p } = useTranslation(), m = [...u, ...i], g = useBuilderProp("htmlDir", "ltr");
|
|
8875
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { dir: g, className: "h-screen max-h-full w-screen overflow-x-hidden bg-background text-foreground", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(TooltipProvider, { children: [
|
|
8840
8876
|
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
8841
8877
|
"div",
|
|
8842
8878
|
{
|
|
@@ -8846,23 +8882,23 @@ const RootLayout = () => {
|
|
|
8846
8882
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-14 w-screen shrink-0 border-b border-border", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Suspense, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(TopBar, {}) }) }),
|
|
8847
8883
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("main", { className: "relative flex h-[calc(100vh-56px)] max-w-full flex-1 flex-row", children: [
|
|
8848
8884
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex w-12 flex-col items-center justify-between border-r border-border py-2", children: [
|
|
8849
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-col", children: m.map((
|
|
8885
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-col", children: m.map((x, j) => /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
|
|
8850
8886
|
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
8851
8887
|
Button,
|
|
8852
8888
|
{
|
|
8853
|
-
variant: o ===
|
|
8889
|
+
variant: o === j ? "default" : "ghost",
|
|
8854
8890
|
className: "mb-2 rounded-lg p-2 transition-colors",
|
|
8855
|
-
onClick: () => d(
|
|
8856
|
-
children: get(
|
|
8891
|
+
onClick: () => d(j),
|
|
8892
|
+
children: get(x, "icon", null)
|
|
8857
8893
|
},
|
|
8858
|
-
|
|
8894
|
+
j
|
|
8859
8895
|
) }),
|
|
8860
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { children:
|
|
8861
|
-
] }, "button" +
|
|
8896
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { children: p(x.label) }) })
|
|
8897
|
+
] }, "button" + j)) }),
|
|
8862
8898
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col space-y-1", children: [
|
|
8863
8899
|
/* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
|
|
8864
8900
|
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { variant: "ghost", onClick: () => l(!0), children: /* @__PURE__ */ jsxRuntimeExports.jsx(LayoutTemplate, { size: 20 }) }) }),
|
|
8865
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { children:
|
|
8901
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { children: p("Choose Builder Layout") }) })
|
|
8866
8902
|
] }),
|
|
8867
8903
|
/* @__PURE__ */ jsxRuntimeExports.jsx(HotKeys, {})
|
|
8868
8904
|
] })
|
|
@@ -8877,7 +8913,7 @@ const RootLayout = () => {
|
|
|
8877
8913
|
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: [
|
|
8878
8914
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("h2", { className: "-mt-1 flex h-10 items-center space-x-1 text-base font-bold", children: [
|
|
8879
8915
|
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "rtl:ml-2 rtl:inline-block", children: get(m, `${o}.icon`, null) }),
|
|
8880
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children:
|
|
8916
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: p(m[o].label) })
|
|
8881
8917
|
] }),
|
|
8882
8918
|
/* @__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), {}) }) })
|
|
8883
8919
|
] }) })
|
|
@@ -8897,7 +8933,7 @@ const RootLayout = () => {
|
|
|
8897
8933
|
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: [
|
|
8898
8934
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("h2", { className: "-mt-1 flex h-10 items-center space-x-1 text-base font-bold", children: [
|
|
8899
8935
|
/* @__PURE__ */ jsxRuntimeExports.jsx(EditIcon, { size: "16", className: "rtl:ml-2" }),
|
|
8900
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children:
|
|
8936
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: p("Block Settings") })
|
|
8901
8937
|
] }),
|
|
8902
8938
|
/* @__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, {}) }) })
|
|
8903
8939
|
] }) })
|