@chaibuilder/sdk 2.0.0-beta.24 → 2.0.0-beta.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core.cjs +3 -3
- package/dist/core.d.ts +2 -0
- package/dist/core.js +660 -595
- package/dist/web-blocks.cjs +1 -1
- package/dist/web-blocks.js +1 -0
- package/package.json +1 -1
package/dist/core.js
CHANGED
|
@@ -108,99 +108,99 @@ const hasInitialValue = (o) => "init" in o, isActuallyWritableAtom = (o) => !!o.
|
|
|
108
108
|
(define_import_meta_env_default$2 ? "production" : void 0) !== "production" && (a = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set());
|
|
109
109
|
const c = (m) => o.get(m), d = (m, E) => {
|
|
110
110
|
(define_import_meta_env_default$2 ? "production" : void 0) !== "production" && Object.freeze(E);
|
|
111
|
-
const
|
|
112
|
-
if (o.set(m, E), n.has(m) || n.set(m,
|
|
113
|
-
const
|
|
114
|
-
cancelPromise(
|
|
111
|
+
const R = o.get(m);
|
|
112
|
+
if (o.set(m, E), n.has(m) || n.set(m, R), R && hasPromiseAtomValue(R)) {
|
|
113
|
+
const w = "v" in E ? E.v instanceof Promise ? E.v : Promise.resolve(E.v) : Promise.reject(E.e);
|
|
114
|
+
cancelPromise(R.v, w);
|
|
115
115
|
}
|
|
116
|
-
}, p = (m, E,
|
|
117
|
-
const
|
|
118
|
-
let
|
|
119
|
-
|
|
120
|
-
!k && N === m && (k = E), k ? (
|
|
121
|
-
}), (
|
|
122
|
-
}, u = (m, E,
|
|
123
|
-
const
|
|
124
|
-
d: (
|
|
116
|
+
}, p = (m, E, R) => {
|
|
117
|
+
const w = /* @__PURE__ */ new Map();
|
|
118
|
+
let T = !1;
|
|
119
|
+
R.forEach((k, N) => {
|
|
120
|
+
!k && N === m && (k = E), k ? (w.set(N, k), E.d.get(N) !== k && (T = !0)) : (define_import_meta_env_default$2 ? "production" : void 0) !== "production" && console.warn("[Bug] atom state not found");
|
|
121
|
+
}), (T || E.d.size !== w.size) && (E.d = w);
|
|
122
|
+
}, u = (m, E, R) => {
|
|
123
|
+
const w = c(m), T = {
|
|
124
|
+
d: (w == null ? void 0 : w.d) || /* @__PURE__ */ new Map(),
|
|
125
125
|
v: E
|
|
126
126
|
};
|
|
127
|
-
if (
|
|
128
|
-
return
|
|
129
|
-
if (
|
|
130
|
-
if (
|
|
131
|
-
return
|
|
132
|
-
|
|
127
|
+
if (R && p(m, T, R), w && isEqualAtomValue(w, T) && w.d === T.d)
|
|
128
|
+
return w;
|
|
129
|
+
if (w && hasPromiseAtomValue(w) && hasPromiseAtomValue(T) && isEqualPromiseAtomValue(w, T)) {
|
|
130
|
+
if (w.d === T.d)
|
|
131
|
+
return w;
|
|
132
|
+
T.v = w.v;
|
|
133
133
|
}
|
|
134
|
-
return d(m,
|
|
135
|
-
}, x = (m, E,
|
|
134
|
+
return d(m, T), T;
|
|
135
|
+
}, x = (m, E, R, w) => {
|
|
136
136
|
if (isPromiseLike$2(E)) {
|
|
137
|
-
let
|
|
137
|
+
let T;
|
|
138
138
|
const k = new Promise((N, $) => {
|
|
139
139
|
let L = !1;
|
|
140
140
|
E.then(
|
|
141
|
-
(
|
|
141
|
+
(P) => {
|
|
142
142
|
if (!L) {
|
|
143
143
|
L = !0;
|
|
144
|
-
const
|
|
144
|
+
const M = c(m), O = u(
|
|
145
145
|
m,
|
|
146
146
|
k,
|
|
147
|
-
|
|
147
|
+
R
|
|
148
148
|
);
|
|
149
|
-
resolvePromise(k,
|
|
149
|
+
resolvePromise(k, P), N(P), (M == null ? void 0 : M.d) !== O.d && _(m, O, M == null ? void 0 : M.d);
|
|
150
150
|
}
|
|
151
151
|
},
|
|
152
|
-
(
|
|
152
|
+
(P) => {
|
|
153
153
|
if (!L) {
|
|
154
154
|
L = !0;
|
|
155
|
-
const
|
|
155
|
+
const M = c(m), O = u(
|
|
156
156
|
m,
|
|
157
157
|
k,
|
|
158
|
-
|
|
158
|
+
R
|
|
159
159
|
);
|
|
160
|
-
rejectPromise(k,
|
|
160
|
+
rejectPromise(k, P), $(P), (M == null ? void 0 : M.d) !== O.d && _(m, O, M == null ? void 0 : M.d);
|
|
161
161
|
}
|
|
162
162
|
}
|
|
163
|
-
),
|
|
164
|
-
L || (L = !0,
|
|
165
|
-
(
|
|
166
|
-
(
|
|
167
|
-
), N(
|
|
163
|
+
), T = (P) => {
|
|
164
|
+
L || (L = !0, P.then(
|
|
165
|
+
(M) => resolvePromise(k, M),
|
|
166
|
+
(M) => rejectPromise(k, M)
|
|
167
|
+
), N(P));
|
|
168
168
|
};
|
|
169
169
|
});
|
|
170
170
|
return k.orig = E, k.status = "pending", registerCancelPromise(k, (N) => {
|
|
171
|
-
N &&
|
|
172
|
-
}), u(m, k,
|
|
171
|
+
N && T(N), w == null || w();
|
|
172
|
+
}), u(m, k, R);
|
|
173
173
|
}
|
|
174
|
-
return u(m, E,
|
|
175
|
-
}, f = (m, E,
|
|
176
|
-
const
|
|
177
|
-
d: (
|
|
174
|
+
return u(m, E, R);
|
|
175
|
+
}, f = (m, E, R) => {
|
|
176
|
+
const w = c(m), T = {
|
|
177
|
+
d: (w == null ? void 0 : w.d) || /* @__PURE__ */ new Map(),
|
|
178
178
|
e: E
|
|
179
179
|
};
|
|
180
|
-
return
|
|
180
|
+
return R && p(m, T, R), w && isEqualAtomError(w, T) && w.d === T.d ? w : (d(m, T), T);
|
|
181
181
|
}, g = (m) => {
|
|
182
182
|
const E = c(m);
|
|
183
|
-
if (E && (E.d.forEach((L,
|
|
184
|
-
|
|
185
|
-
}), Array.from(E.d).every(([L,
|
|
186
|
-
const
|
|
187
|
-
return L === m ||
|
|
188
|
-
|
|
183
|
+
if (E && (E.d.forEach((L, P) => {
|
|
184
|
+
P !== m && !r.has(P) && g(P);
|
|
185
|
+
}), Array.from(E.d).every(([L, P]) => {
|
|
186
|
+
const M = c(L);
|
|
187
|
+
return L === m || M === P || // TODO This is a hack, we should find a better solution.
|
|
188
|
+
M && !hasPromiseAtomValue(M) && isEqualAtomValue(M, P);
|
|
189
189
|
})))
|
|
190
190
|
return E;
|
|
191
|
-
const
|
|
192
|
-
let
|
|
193
|
-
const
|
|
191
|
+
const R = /* @__PURE__ */ new Map();
|
|
192
|
+
let w = !0;
|
|
193
|
+
const T = (L) => {
|
|
194
194
|
if (L === m) {
|
|
195
|
-
const
|
|
196
|
-
if (
|
|
197
|
-
return
|
|
195
|
+
const M = c(L);
|
|
196
|
+
if (M)
|
|
197
|
+
return R.set(L, M), returnAtomValue(M);
|
|
198
198
|
if (hasInitialValue(L))
|
|
199
|
-
return
|
|
199
|
+
return R.set(L, void 0), L.init;
|
|
200
200
|
throw new Error("no atom init");
|
|
201
201
|
}
|
|
202
|
-
const
|
|
203
|
-
return
|
|
202
|
+
const P = g(L);
|
|
203
|
+
return R.set(L, P), returnAtomValue(P);
|
|
204
204
|
};
|
|
205
205
|
let k, N;
|
|
206
206
|
const $ = {
|
|
@@ -209,152 +209,152 @@ const hasInitialValue = (o) => "init" in o, isActuallyWritableAtom = (o) => !!o.
|
|
|
209
209
|
},
|
|
210
210
|
get setSelf() {
|
|
211
211
|
return (define_import_meta_env_default$2 ? "production" : void 0) !== "production" && !isActuallyWritableAtom(m) && console.warn("setSelf function cannot be used with read-only atom"), !N && isActuallyWritableAtom(m) && (N = (...L) => {
|
|
212
|
-
if ((define_import_meta_env_default$2 ? "production" : void 0) !== "production" &&
|
|
213
|
-
return
|
|
212
|
+
if ((define_import_meta_env_default$2 ? "production" : void 0) !== "production" && w && console.warn("setSelf function cannot be called in sync"), !w)
|
|
213
|
+
return A(m, ...L);
|
|
214
214
|
}), N;
|
|
215
215
|
}
|
|
216
216
|
};
|
|
217
217
|
try {
|
|
218
|
-
const L = m.read(
|
|
218
|
+
const L = m.read(T, $);
|
|
219
219
|
return x(
|
|
220
220
|
m,
|
|
221
221
|
L,
|
|
222
|
-
|
|
222
|
+
R,
|
|
223
223
|
() => k == null ? void 0 : k.abort()
|
|
224
224
|
);
|
|
225
225
|
} catch (L) {
|
|
226
|
-
return f(m, L,
|
|
226
|
+
return f(m, L, R);
|
|
227
227
|
} finally {
|
|
228
|
-
|
|
228
|
+
w = !1;
|
|
229
229
|
}
|
|
230
|
-
},
|
|
230
|
+
}, j = (m) => returnAtomValue(g(m)), b = (m) => {
|
|
231
231
|
let E = r.get(m);
|
|
232
|
-
return E || (E =
|
|
233
|
-
}, h = (m, E) => !E.l.size && (!E.t.size || E.t.size === 1 && E.t.has(m)),
|
|
232
|
+
return E || (E = C(m)), E;
|
|
233
|
+
}, h = (m, E) => !E.l.size && (!E.t.size || E.t.size === 1 && E.t.has(m)), y = (m) => {
|
|
234
234
|
const E = r.get(m);
|
|
235
|
-
E && h(m, E) &&
|
|
236
|
-
},
|
|
237
|
-
const E = /* @__PURE__ */ new Map(),
|
|
235
|
+
E && h(m, E) && v(m);
|
|
236
|
+
}, S = (m) => {
|
|
237
|
+
const E = /* @__PURE__ */ new Map(), R = /* @__PURE__ */ new WeakMap(), w = (k) => {
|
|
238
238
|
const N = r.get(k);
|
|
239
239
|
N == null || N.t.forEach(($) => {
|
|
240
240
|
$ !== k && (E.set(
|
|
241
241
|
$,
|
|
242
242
|
(E.get($) || /* @__PURE__ */ new Set()).add(k)
|
|
243
|
-
),
|
|
243
|
+
), R.set($, (R.get($) || 0) + 1), w($));
|
|
244
244
|
});
|
|
245
245
|
};
|
|
246
|
-
|
|
247
|
-
const
|
|
246
|
+
w(m);
|
|
247
|
+
const T = (k) => {
|
|
248
248
|
const N = r.get(k);
|
|
249
249
|
N == null || N.t.forEach(($) => {
|
|
250
250
|
var L;
|
|
251
251
|
if ($ !== k) {
|
|
252
|
-
let
|
|
253
|
-
if (
|
|
254
|
-
let
|
|
255
|
-
if (
|
|
252
|
+
let P = R.get($);
|
|
253
|
+
if (P && R.set($, --P), !P) {
|
|
254
|
+
let M = !!((L = E.get($)) != null && L.size);
|
|
255
|
+
if (M) {
|
|
256
256
|
const O = c($), V = g($);
|
|
257
|
-
|
|
257
|
+
M = !O || !isEqualAtomValue(O, V);
|
|
258
258
|
}
|
|
259
|
-
|
|
259
|
+
M || E.forEach((O) => O.delete($));
|
|
260
260
|
}
|
|
261
|
-
|
|
261
|
+
T($);
|
|
262
262
|
}
|
|
263
263
|
});
|
|
264
264
|
};
|
|
265
|
-
|
|
266
|
-
},
|
|
267
|
-
let
|
|
268
|
-
const
|
|
265
|
+
T(m);
|
|
266
|
+
}, B = (m, ...E) => {
|
|
267
|
+
let R = !0;
|
|
268
|
+
const w = (N) => returnAtomValue(g(N)), T = (N, ...$) => {
|
|
269
269
|
let L;
|
|
270
270
|
if (N === m) {
|
|
271
271
|
if (!hasInitialValue(N))
|
|
272
272
|
throw new Error("atom not writable");
|
|
273
|
-
const
|
|
274
|
-
(!
|
|
273
|
+
const P = c(N), M = x(N, $[0]);
|
|
274
|
+
(!P || !isEqualAtomValue(P, M)) && S(N);
|
|
275
275
|
} else
|
|
276
|
-
L =
|
|
277
|
-
if (!
|
|
278
|
-
const
|
|
276
|
+
L = B(N, ...$);
|
|
277
|
+
if (!R) {
|
|
278
|
+
const P = I();
|
|
279
279
|
(define_import_meta_env_default$2 ? "production" : void 0) !== "production" && l.forEach(
|
|
280
|
-
(
|
|
280
|
+
(M) => M({ type: "async-write", flushed: P })
|
|
281
281
|
);
|
|
282
282
|
}
|
|
283
283
|
return L;
|
|
284
|
-
}, k = m.write(
|
|
285
|
-
return
|
|
286
|
-
},
|
|
287
|
-
const
|
|
284
|
+
}, k = m.write(w, T, ...E);
|
|
285
|
+
return R = !1, k;
|
|
286
|
+
}, A = (m, ...E) => {
|
|
287
|
+
const R = B(m, ...E), w = I();
|
|
288
288
|
return (define_import_meta_env_default$2 ? "production" : void 0) !== "production" && l.forEach(
|
|
289
|
-
(
|
|
290
|
-
),
|
|
291
|
-
},
|
|
292
|
-
const
|
|
289
|
+
(T) => T({ type: "write", flushed: w })
|
|
290
|
+
), R;
|
|
291
|
+
}, C = (m, E) => {
|
|
292
|
+
const R = {
|
|
293
293
|
t: new Set(E && [E]),
|
|
294
294
|
l: /* @__PURE__ */ new Set()
|
|
295
295
|
};
|
|
296
|
-
if (r.set(m,
|
|
297
|
-
const k = r.get(
|
|
298
|
-
k ? k.t.add(m) :
|
|
296
|
+
if (r.set(m, R), (define_import_meta_env_default$2 ? "production" : void 0) !== "production" && i.add(m), g(m).d.forEach((w, T) => {
|
|
297
|
+
const k = r.get(T);
|
|
298
|
+
k ? k.t.add(m) : T !== m && C(T, m);
|
|
299
299
|
}), g(m), isActuallyWritableAtom(m) && m.onMount) {
|
|
300
|
-
const
|
|
301
|
-
|
|
300
|
+
const w = m.onMount((...T) => A(m, ...T));
|
|
301
|
+
w && (R.u = w);
|
|
302
302
|
}
|
|
303
|
-
return
|
|
304
|
-
},
|
|
303
|
+
return R;
|
|
304
|
+
}, v = (m) => {
|
|
305
305
|
var E;
|
|
306
|
-
const
|
|
307
|
-
|
|
308
|
-
const
|
|
309
|
-
|
|
306
|
+
const R = (E = r.get(m)) == null ? void 0 : E.u;
|
|
307
|
+
R && R(), r.delete(m), (define_import_meta_env_default$2 ? "production" : void 0) !== "production" && i.delete(m);
|
|
308
|
+
const w = c(m);
|
|
309
|
+
w ? (hasPromiseAtomValue(w) && cancelPromise(w.v), w.d.forEach((T, k) => {
|
|
310
310
|
if (k !== m) {
|
|
311
311
|
const N = r.get(k);
|
|
312
|
-
N && (N.t.delete(m), h(k, N) &&
|
|
312
|
+
N && (N.t.delete(m), h(k, N) && v(k));
|
|
313
313
|
}
|
|
314
314
|
})) : (define_import_meta_env_default$2 ? "production" : void 0) !== "production" && console.warn("[Bug] could not find atom state to unmount", m);
|
|
315
|
-
},
|
|
316
|
-
const
|
|
317
|
-
|
|
318
|
-
if (
|
|
319
|
-
|
|
315
|
+
}, _ = (m, E, R) => {
|
|
316
|
+
const w = new Set(E.d.keys());
|
|
317
|
+
R == null || R.forEach((T, k) => {
|
|
318
|
+
if (w.has(k)) {
|
|
319
|
+
w.delete(k);
|
|
320
320
|
return;
|
|
321
321
|
}
|
|
322
322
|
const N = r.get(k);
|
|
323
|
-
N && (N.t.delete(m), h(k, N) &&
|
|
324
|
-
}),
|
|
325
|
-
const k = r.get(
|
|
326
|
-
k ? k.t.add(m) : r.has(m) &&
|
|
323
|
+
N && (N.t.delete(m), h(k, N) && v(k));
|
|
324
|
+
}), w.forEach((T) => {
|
|
325
|
+
const k = r.get(T);
|
|
326
|
+
k ? k.t.add(m) : r.has(m) && C(T, m);
|
|
327
327
|
});
|
|
328
|
-
},
|
|
328
|
+
}, I = () => {
|
|
329
329
|
let m;
|
|
330
330
|
for ((define_import_meta_env_default$2 ? "production" : void 0) !== "production" && (m = /* @__PURE__ */ new Set()); n.size; ) {
|
|
331
331
|
const E = Array.from(n);
|
|
332
|
-
n.clear(), E.forEach(([
|
|
333
|
-
const
|
|
334
|
-
if (
|
|
335
|
-
|
|
336
|
-
const k = r.get(
|
|
332
|
+
n.clear(), E.forEach(([R, w]) => {
|
|
333
|
+
const T = c(R);
|
|
334
|
+
if (T) {
|
|
335
|
+
T.d !== (w == null ? void 0 : w.d) && _(R, T, w == null ? void 0 : w.d);
|
|
336
|
+
const k = r.get(R);
|
|
337
337
|
k && !// TODO This seems pretty hacky. Hope to fix it.
|
|
338
338
|
// Maybe we could `mountDependencies` in `setAtomState`?
|
|
339
|
-
(
|
|
339
|
+
(w && !hasPromiseAtomValue(w) && (isEqualAtomValue(w, T) || isEqualAtomError(w, T))) && (k.l.forEach((N) => N()), (define_import_meta_env_default$2 ? "production" : void 0) !== "production" && m.add(R));
|
|
340
340
|
} else
|
|
341
341
|
(define_import_meta_env_default$2 ? "production" : void 0) !== "production" && console.warn("[Bug] no atom state to flush");
|
|
342
342
|
});
|
|
343
343
|
}
|
|
344
344
|
if ((define_import_meta_env_default$2 ? "production" : void 0) !== "production")
|
|
345
345
|
return a.forEach((E) => E("state")), m;
|
|
346
|
-
},
|
|
347
|
-
const
|
|
348
|
-
return
|
|
349
|
-
(k) => k({ type: "sub", flushed:
|
|
346
|
+
}, D = (m, E) => {
|
|
347
|
+
const R = b(m), w = I(), T = R.l;
|
|
348
|
+
return T.add(E), (define_import_meta_env_default$2 ? "production" : void 0) !== "production" && (a.forEach((k) => k("sub")), l.forEach(
|
|
349
|
+
(k) => k({ type: "sub", flushed: w })
|
|
350
350
|
)), () => {
|
|
351
|
-
|
|
351
|
+
T.delete(E), y(m), (define_import_meta_env_default$2 ? "production" : void 0) !== "production" && (a.forEach((k) => k("unsub")), l.forEach((k) => k({ type: "unsub" })));
|
|
352
352
|
};
|
|
353
353
|
};
|
|
354
354
|
return (define_import_meta_env_default$2 ? "production" : void 0) !== "production" ? {
|
|
355
|
-
get:
|
|
356
|
-
set:
|
|
357
|
-
sub:
|
|
355
|
+
get: j,
|
|
356
|
+
set: A,
|
|
357
|
+
sub: D,
|
|
358
358
|
// store dev methods (these are tentative and subject to change without notice)
|
|
359
359
|
dev_subscribe_store: (m, E) => E !== 2 ? (console.warn(
|
|
360
360
|
"The current StoreListener revision is 2. The older ones are deprecated."
|
|
@@ -367,17 +367,17 @@ const hasInitialValue = (o) => "init" in o, isActuallyWritableAtom = (o) => !!o.
|
|
|
367
367
|
dev_get_atom_state: (m) => o.get(m),
|
|
368
368
|
dev_get_mounted: (m) => r.get(m),
|
|
369
369
|
dev_restore_atoms: (m) => {
|
|
370
|
-
for (const [
|
|
371
|
-
hasInitialValue(
|
|
372
|
-
const E =
|
|
370
|
+
for (const [R, w] of m)
|
|
371
|
+
hasInitialValue(R) && (x(R, w), S(R));
|
|
372
|
+
const E = I();
|
|
373
373
|
l.forEach(
|
|
374
|
-
(
|
|
374
|
+
(R) => R({ type: "restore", flushed: E })
|
|
375
375
|
);
|
|
376
376
|
}
|
|
377
377
|
} : {
|
|
378
|
-
get:
|
|
379
|
-
set:
|
|
380
|
-
sub:
|
|
378
|
+
get: j,
|
|
379
|
+
set: A,
|
|
380
|
+
sub: D
|
|
381
381
|
};
|
|
382
382
|
};
|
|
383
383
|
let defaultStore;
|
|
@@ -395,36 +395,36 @@ function splitAtom(o, r) {
|
|
|
395
395
|
if (p)
|
|
396
396
|
return p;
|
|
397
397
|
const u = d && n.get(d), x = [], f = [];
|
|
398
|
-
return c.forEach((g,
|
|
399
|
-
const b = r ? r(g) :
|
|
400
|
-
f[
|
|
398
|
+
return c.forEach((g, j) => {
|
|
399
|
+
const b = r ? r(g) : j;
|
|
400
|
+
f[j] = b;
|
|
401
401
|
const h = u && u.atomList[u.keyList.indexOf(b)];
|
|
402
402
|
if (h) {
|
|
403
|
-
x[
|
|
403
|
+
x[j] = h;
|
|
404
404
|
return;
|
|
405
405
|
}
|
|
406
|
-
const
|
|
407
|
-
const
|
|
408
|
-
if (
|
|
409
|
-
const
|
|
410
|
-
if (
|
|
411
|
-
return
|
|
406
|
+
const y = (B) => {
|
|
407
|
+
const A = B(l), C = B(o), _ = a(C, A == null ? void 0 : A.arr).keyList.indexOf(b);
|
|
408
|
+
if (_ < 0 || _ >= C.length) {
|
|
409
|
+
const I = c[a(c).keyList.indexOf(b)];
|
|
410
|
+
if (I)
|
|
411
|
+
return I;
|
|
412
412
|
throw new Error("splitAtom: index out of bounds for read");
|
|
413
413
|
}
|
|
414
|
-
return
|
|
415
|
-
},
|
|
416
|
-
const
|
|
417
|
-
if (
|
|
414
|
+
return C[_];
|
|
415
|
+
}, S = (B, A, C) => {
|
|
416
|
+
const v = B(l), _ = B(o), D = a(_, v == null ? void 0 : v.arr).keyList.indexOf(b);
|
|
417
|
+
if (D < 0 || D >= _.length)
|
|
418
418
|
throw new Error("splitAtom: index out of bounds for write");
|
|
419
|
-
const m = isFunction(
|
|
420
|
-
|
|
421
|
-
...
|
|
419
|
+
const m = isFunction(C) ? C(_[D]) : C;
|
|
420
|
+
A(o, [
|
|
421
|
+
..._.slice(0, D),
|
|
422
422
|
m,
|
|
423
|
-
...
|
|
423
|
+
..._.slice(D + 1)
|
|
424
424
|
]);
|
|
425
425
|
};
|
|
426
|
-
x[
|
|
427
|
-
}), u && u.keyList.length === f.length && u.keyList.every((g,
|
|
426
|
+
x[j] = isWritable(o) ? atom(y, S) : atom(y);
|
|
427
|
+
}), u && u.keyList.length === f.length && u.keyList.every((g, j) => g === f[j]) ? p = u : p = { arr: c, atomList: x, keyList: f }, n.set(c, p), p;
|
|
428
428
|
}, l = atom((c) => {
|
|
429
429
|
const d = c(l), p = c(o);
|
|
430
430
|
return a(p, d == null ? void 0 : d.arr);
|
|
@@ -1134,50 +1134,50 @@ const useBlocksStoreManager = () => {
|
|
|
1134
1134
|
updateBlocksProps: c
|
|
1135
1135
|
} = useBlocksStoreManager();
|
|
1136
1136
|
return {
|
|
1137
|
-
moveBlocks: (b, h,
|
|
1138
|
-
const
|
|
1139
|
-
const
|
|
1140
|
-
return { _id:
|
|
1141
|
-
}),
|
|
1142
|
-
|
|
1143
|
-
undo: () => each(
|
|
1144
|
-
i([
|
|
1137
|
+
moveBlocks: (b, h, y) => {
|
|
1138
|
+
const S = map(b, (A) => {
|
|
1139
|
+
const v = r.find((D) => D._id === A)._parent || null, I = r.filter((D) => v ? D._parent === v : !D._parent).map((D) => D._id).indexOf(A);
|
|
1140
|
+
return { _id: A, oldParent: v, oldPosition: I };
|
|
1141
|
+
}), B = S.find(({ _id: A }) => A === b[0]);
|
|
1142
|
+
B && B.oldParent === h && B.oldPosition === y || (i(b, h, y), o({
|
|
1143
|
+
undo: () => each(S, ({ _id: A, oldParent: C, oldPosition: v }) => {
|
|
1144
|
+
i([A], C, v);
|
|
1145
1145
|
}),
|
|
1146
|
-
redo: () => i(b, h,
|
|
1146
|
+
redo: () => i(b, h, y)
|
|
1147
1147
|
}));
|
|
1148
1148
|
},
|
|
1149
|
-
addBlocks: (b, h,
|
|
1150
|
-
a(b, h,
|
|
1149
|
+
addBlocks: (b, h, y) => {
|
|
1150
|
+
a(b, h, y), o({
|
|
1151
1151
|
undo: () => l(map(b, "_id")),
|
|
1152
|
-
redo: () => a(b, h,
|
|
1152
|
+
redo: () => a(b, h, y)
|
|
1153
1153
|
});
|
|
1154
1154
|
},
|
|
1155
1155
|
removeBlocks: (b) => {
|
|
1156
|
-
var
|
|
1157
|
-
const h = (
|
|
1156
|
+
var B;
|
|
1157
|
+
const h = (B = first(b)) == null ? void 0 : B._parent, S = r.filter((A) => h ? A._parent === h : !A._parent).indexOf(first(b));
|
|
1158
1158
|
l(map(b, "_id")), o({
|
|
1159
|
-
undo: () => a(b, h,
|
|
1159
|
+
undo: () => a(b, h, S),
|
|
1160
1160
|
redo: () => l(map(b, "_id"))
|
|
1161
1161
|
});
|
|
1162
1162
|
},
|
|
1163
|
-
updateBlocks: (b, h,
|
|
1164
|
-
let
|
|
1165
|
-
if (
|
|
1166
|
-
|
|
1163
|
+
updateBlocks: (b, h, y) => {
|
|
1164
|
+
let S = [];
|
|
1165
|
+
if (y)
|
|
1166
|
+
S = map(b, (B) => ({ _id: B, ...y }));
|
|
1167
1167
|
else {
|
|
1168
|
-
const
|
|
1169
|
-
|
|
1170
|
-
const
|
|
1171
|
-
return each(
|
|
1168
|
+
const B = keys(h);
|
|
1169
|
+
S = map(b, (A) => {
|
|
1170
|
+
const C = r.find((_) => _._id === A), v = { _id: A };
|
|
1171
|
+
return each(B, (_) => v[_] = C[_]), v;
|
|
1172
1172
|
});
|
|
1173
1173
|
}
|
|
1174
|
-
c(map(b, (
|
|
1175
|
-
undo: () => c(
|
|
1176
|
-
redo: () => c(map(b, (
|
|
1174
|
+
c(map(b, (B) => ({ _id: B, ...h }))), o({
|
|
1175
|
+
undo: () => c(S),
|
|
1176
|
+
redo: () => c(map(b, (B) => ({ _id: B, ...h })))
|
|
1177
1177
|
});
|
|
1178
1178
|
},
|
|
1179
1179
|
updateBlocksRuntime: (b, h) => {
|
|
1180
|
-
c(map(b, (
|
|
1180
|
+
c(map(b, (y) => ({ _id: y, ...h })));
|
|
1181
1181
|
},
|
|
1182
1182
|
setNewBlocks: (b) => {
|
|
1183
1183
|
n(b), o({
|
|
@@ -1187,9 +1187,9 @@ const useBlocksStoreManager = () => {
|
|
|
1187
1187
|
},
|
|
1188
1188
|
updateMultipleBlocksProps: (b) => {
|
|
1189
1189
|
let h = [];
|
|
1190
|
-
h = map(b, (
|
|
1191
|
-
const
|
|
1192
|
-
return each(
|
|
1190
|
+
h = map(b, (y) => {
|
|
1191
|
+
const S = keys(y), B = r.find((C) => C._id === y._id), A = {};
|
|
1192
|
+
return each(S, (C) => A[C] = B[C]), A;
|
|
1193
1193
|
}), c(b), o({
|
|
1194
1194
|
undo: () => c(h),
|
|
1195
1195
|
redo: () => c(b)
|
|
@@ -1200,12 +1200,12 @@ const useBlocksStoreManager = () => {
|
|
|
1200
1200
|
const [o] = useBlocksStore(), [, r] = useSelectedBlockIds(), { addBlocks: n } = useBlocksStoreUndoableActions(), a = useCallback(
|
|
1201
1201
|
(i, c, d) => {
|
|
1202
1202
|
var g;
|
|
1203
|
-
for (let
|
|
1204
|
-
const { _id: b } = i[
|
|
1205
|
-
i[
|
|
1203
|
+
for (let j = 0; j < i.length; j++) {
|
|
1204
|
+
const { _id: b } = i[j];
|
|
1205
|
+
i[j]._id = generateUUID();
|
|
1206
1206
|
const h = filter(i, { _parent: b });
|
|
1207
|
-
for (let
|
|
1208
|
-
h[
|
|
1207
|
+
for (let y = 0; y < h.length; y++)
|
|
1208
|
+
h[y]._parent = i[j]._id;
|
|
1209
1209
|
}
|
|
1210
1210
|
const p = first(i);
|
|
1211
1211
|
let u, x;
|
|
@@ -2375,7 +2375,7 @@ function getNewClasses(o = "", r = "", n = []) {
|
|
|
2375
2375
|
const g = find(l, pick(x, ["property"]));
|
|
2376
2376
|
f && (l = filter(
|
|
2377
2377
|
l,
|
|
2378
|
-
(
|
|
2378
|
+
(j) => j.fullCls !== (g == null ? void 0 : g.fullCls)
|
|
2379
2379
|
)), c.push({
|
|
2380
2380
|
...x,
|
|
2381
2381
|
fullCls: x.cls,
|
|
@@ -2564,8 +2564,8 @@ const useSelectedStylingBlocks = () => useAtom$1(selectedStylingBlocksAtom), get
|
|
|
2564
2564
|
const d = o(c), p = a;
|
|
2565
2565
|
let { classes: u, baseClasses: x } = getSplitClasses(get(d, l.prop, "styles:,"));
|
|
2566
2566
|
return each(p, (f) => {
|
|
2567
|
-
const g = f.replace(/[\[\]\/\\{}()*+?.^$|]/g, "\\$&"),
|
|
2568
|
-
u = u.replace(
|
|
2567
|
+
const g = f.replace(/[\[\]\/\\{}()*+?.^$|]/g, "\\$&"), j = new RegExp(`(^| )${g}($| )`, "g");
|
|
2568
|
+
u = u.replace(j, " ").replace(/ +/g, " ").trim();
|
|
2569
2569
|
const b = first(f.split(":"));
|
|
2570
2570
|
includes(["2xl", "xl", "lg", "md", "sm"], b) && p.push(f.split(":").pop().trim());
|
|
2571
2571
|
}), each(p, (f) => {
|
|
@@ -3021,37 +3021,37 @@ const getBlockWithChildren = (o, r) => {
|
|
|
3021
3021
|
return isEmpty(c) ? !1 : (has(l, "_parent") && isEmpty(l._parent) && delete l._parent, { ...l, ...c });
|
|
3022
3022
|
})
|
|
3023
3023
|
), addLangToPrompt = (o, r, n) => !r || n !== "content" ? o : `${o}. Generate content in ${get(LANGUAGES, r, r)} language.`, askAiProcessingAtom = atom$1(!1), useAskAi = () => {
|
|
3024
|
-
const [o, r] = useAtom$1(askAiProcessingAtom), [n, a] = useState(null), l = useBuilderProp("askAiCallBack", null), i = useStreamMultipleBlocksProps(), c = useUpdateMultipleBlocksProps(), [d] = useBlocksStore(), { selectedLang: p, fallbackLang: u } = useLanguages(), x = p.length ? p : u, f = (g,
|
|
3025
|
-
const b = cloneDeep(
|
|
3024
|
+
const [o, r] = useAtom$1(askAiProcessingAtom), [n, a] = useState(null), l = useBuilderProp("askAiCallBack", null), i = useStreamMultipleBlocksProps(), c = useUpdateMultipleBlocksProps(), [d] = useBlocksStore(), { selectedLang: p, fallbackLang: u } = useLanguages(), x = p.length ? p : u, f = (g, j) => {
|
|
3025
|
+
const b = cloneDeep(j.find((h) => h._id === g));
|
|
3026
3026
|
for (const h in b) {
|
|
3027
|
-
const
|
|
3028
|
-
typeof
|
|
3027
|
+
const y = b[h];
|
|
3028
|
+
typeof y == "string" && startsWith(y, STYLES_KEY) ? b[h] = compact(flattenDeep(y.replace(STYLES_KEY, "").split(","))).join(" ") : h !== "_id" && delete b[h];
|
|
3029
3029
|
}
|
|
3030
3030
|
return b;
|
|
3031
3031
|
};
|
|
3032
3032
|
return {
|
|
3033
3033
|
askAi: useCallback(
|
|
3034
|
-
async (g,
|
|
3034
|
+
async (g, j, b, h) => {
|
|
3035
3035
|
if (l) {
|
|
3036
3036
|
r(!0), a(null);
|
|
3037
3037
|
try {
|
|
3038
|
-
const
|
|
3039
|
-
if (
|
|
3040
|
-
a(
|
|
3038
|
+
const y = p === u ? "" : p, S = g === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(j, d)), p) : [f(j, d)], B = await l(g, addLangToPrompt(b, x, g), S, y), { blocks: A, error: C } = B;
|
|
3039
|
+
if (C) {
|
|
3040
|
+
a(C);
|
|
3041
3041
|
return;
|
|
3042
3042
|
}
|
|
3043
3043
|
if (g === "styles") {
|
|
3044
|
-
const
|
|
3045
|
-
for (const
|
|
3046
|
-
|
|
3047
|
-
return
|
|
3044
|
+
const v = A.map((_) => {
|
|
3045
|
+
for (const I in _)
|
|
3046
|
+
I !== "_id" && (_[I] = `${STYLES_KEY},${_[I]}`);
|
|
3047
|
+
return _;
|
|
3048
3048
|
});
|
|
3049
|
-
c(
|
|
3049
|
+
c(v);
|
|
3050
3050
|
} else
|
|
3051
|
-
i(
|
|
3052
|
-
h && h(
|
|
3053
|
-
} catch (
|
|
3054
|
-
a(
|
|
3051
|
+
i(A);
|
|
3052
|
+
h && h(B);
|
|
3053
|
+
} catch (y) {
|
|
3054
|
+
a(y);
|
|
3055
3055
|
} finally {
|
|
3056
3056
|
r(!1), h && h();
|
|
3057
3057
|
}
|
|
@@ -3079,7 +3079,27 @@ const getBlockWithChildren = (o, r) => {
|
|
|
3079
3079
|
},
|
|
3080
3080
|
[o]
|
|
3081
3081
|
);
|
|
3082
|
-
},
|
|
3082
|
+
}, wrapperBlockAtom = atom$1((o) => {
|
|
3083
|
+
var c;
|
|
3084
|
+
const r = o(presentBlocksAtom), n = o(selectedBlockIdsAtom), a = n.length === 1 ? n[0] : null;
|
|
3085
|
+
if (!a)
|
|
3086
|
+
return null;
|
|
3087
|
+
const l = find(r, { _id: a });
|
|
3088
|
+
if (!l)
|
|
3089
|
+
return null;
|
|
3090
|
+
let i = l._parent;
|
|
3091
|
+
for (; i; ) {
|
|
3092
|
+
const d = find(r, { _id: i });
|
|
3093
|
+
if (!d)
|
|
3094
|
+
return null;
|
|
3095
|
+
if ((c = getRegisteredChaiBlock(d._type)) != null && c.wrapper)
|
|
3096
|
+
return d;
|
|
3097
|
+
i = d._parent;
|
|
3098
|
+
}
|
|
3099
|
+
return null;
|
|
3100
|
+
});
|
|
3101
|
+
wrapperBlockAtom.debugLabel = "wrapperBlockAtom";
|
|
3102
|
+
const useWrapperBlock = () => useAtomValue$1(wrapperBlockAtom), layoutVariantAtom = atomWithStorage("_layout_variant_mode", "DUAL_SIDE_PANEL"), useLayoutVariant = () => {
|
|
3083
3103
|
const [o, r] = useAtom$1(layoutVariantAtom), n = useBuilderProp("layoutVariant", "DUAL_SIDE_PANEL");
|
|
3084
3104
|
return [o || n, r];
|
|
3085
3105
|
}, IframeInitialContent = `<!doctype html>
|
|
@@ -3336,26 +3356,26 @@ const useDnd = () => {
|
|
|
3336
3356
|
g.preventDefault(), g.stopPropagation(), throttledDragOver(g);
|
|
3337
3357
|
},
|
|
3338
3358
|
onDrop: (g) => {
|
|
3339
|
-
var
|
|
3340
|
-
const
|
|
3359
|
+
var C;
|
|
3360
|
+
const j = dropTarget, h = getOrientation(j) === "vertical" ? g.clientY + ((C = iframeDocument == null ? void 0 : iframeDocument.defaultView) == null ? void 0 : C.scrollY) : g.clientX;
|
|
3341
3361
|
dropIndex = calculateDropIndex(h, possiblePositions);
|
|
3342
|
-
const
|
|
3343
|
-
if ((
|
|
3362
|
+
const y = d, S = j.getAttribute("data-block-id"), B = dropTarget.getAttribute("data-dnd-dragged") !== "yes";
|
|
3363
|
+
if ((y == null ? void 0 : y._id) === S || !B) {
|
|
3344
3364
|
f();
|
|
3345
3365
|
return;
|
|
3346
3366
|
}
|
|
3347
|
-
if (!has(
|
|
3348
|
-
a(
|
|
3367
|
+
if (!has(y, "_id")) {
|
|
3368
|
+
a(y, S === "canvas" ? null : S, dropIndex), setTimeout(f, 300);
|
|
3349
3369
|
return;
|
|
3350
3370
|
}
|
|
3351
|
-
let
|
|
3352
|
-
|
|
3371
|
+
let A = j.getAttribute("data-block-id");
|
|
3372
|
+
A === null && (A = g.target.parentElement.getAttribute("data-block-id")), c([y._id], A === "canvas" ? null : A, dropIndex), f(), setTimeout(removePlaceholder, 300);
|
|
3353
3373
|
},
|
|
3354
3374
|
onDragEnter: (g) => {
|
|
3355
|
-
const
|
|
3375
|
+
const j = g, b = j.target;
|
|
3356
3376
|
dropTarget = b;
|
|
3357
|
-
const h = b.getAttribute("data-block-id"),
|
|
3358
|
-
u(h),
|
|
3377
|
+
const h = b.getAttribute("data-block-id"), y = b.getAttribute("data-dnd-dragged") !== "yes";
|
|
3378
|
+
u(h), j.stopPropagation(), j.preventDefault(), possiblePositions = [], y && calculatePossiblePositions(b), n(!0), l(""), i([]);
|
|
3359
3379
|
},
|
|
3360
3380
|
onDragLeave: (g) => {
|
|
3361
3381
|
g.target.getAttribute("data-block-id") === "canvas" && (u(null), n(!1), removePlaceholder(), possiblePositions = []);
|
|
@@ -3440,8 +3460,8 @@ const useHandleCanvasDblClick = () => {
|
|
|
3440
3460
|
if (f) {
|
|
3441
3461
|
const g = f.getAttribute("data-style-prop");
|
|
3442
3462
|
if (g) {
|
|
3443
|
-
const
|
|
3444
|
-
l([{ id:
|
|
3463
|
+
const j = f.getAttribute("data-style-id"), b = f.getAttribute("data-block-parent");
|
|
3464
|
+
l([{ id: j, prop: g, blockId: b }]);
|
|
3445
3465
|
}
|
|
3446
3466
|
}
|
|
3447
3467
|
}, 100);
|
|
@@ -3477,8 +3497,8 @@ const useHandleCanvasDblClick = () => {
|
|
|
3477
3497
|
i
|
|
3478
3498
|
]), useHotkeys(
|
|
3479
3499
|
"del, backspace",
|
|
3480
|
-
(
|
|
3481
|
-
|
|
3500
|
+
(j) => {
|
|
3501
|
+
j.preventDefault(), canDeleteBlock(get(a, "_type", "")) && l(r);
|
|
3482
3502
|
},
|
|
3483
3503
|
g,
|
|
3484
3504
|
[r, l]
|
|
@@ -3541,13 +3561,13 @@ const pubsub = new PubSub(), BlockActionLabel = ({ block: o, label: r }) => {
|
|
|
3541
3561
|
tabIndex: 0,
|
|
3542
3562
|
ref: u.setFloating,
|
|
3543
3563
|
style: p,
|
|
3544
|
-
onClick: (
|
|
3545
|
-
|
|
3564
|
+
onClick: (j) => {
|
|
3565
|
+
j.stopPropagation(), j.preventDefault();
|
|
3546
3566
|
},
|
|
3547
|
-
onMouseEnter: (
|
|
3548
|
-
|
|
3567
|
+
onMouseEnter: (j) => {
|
|
3568
|
+
j.stopPropagation(), i(null);
|
|
3549
3569
|
},
|
|
3550
|
-
onKeyDown: (
|
|
3570
|
+
onKeyDown: (j) => j.stopPropagation(),
|
|
3551
3571
|
className: "isolate z-[999] flex h-6 items-center bg-blue-500 py-2 text-xs text-white",
|
|
3552
3572
|
children: [
|
|
3553
3573
|
f && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
@@ -3603,15 +3623,15 @@ const pubsub = new PubSub(), BlockActionLabel = ({ block: o, label: r }) => {
|
|
|
3603
3623
|
typography,
|
|
3604
3624
|
forms,
|
|
3605
3625
|
aspectRatio,
|
|
3606
|
-
plugin(function({ addBase: h, theme:
|
|
3626
|
+
plugin(function({ addBase: h, theme: y }) {
|
|
3607
3627
|
h({
|
|
3608
3628
|
"h1,h2,h3,h4,h5,h6": {
|
|
3609
|
-
fontFamily:
|
|
3629
|
+
fontFamily: y("fontFamily.heading")
|
|
3610
3630
|
},
|
|
3611
3631
|
body: {
|
|
3612
|
-
fontFamily:
|
|
3613
|
-
color:
|
|
3614
|
-
backgroundColor:
|
|
3632
|
+
fontFamily: y("fontFamily.body"),
|
|
3633
|
+
color: y("colors.foreground"),
|
|
3634
|
+
backgroundColor: y("colors.background")
|
|
3615
3635
|
}
|
|
3616
3636
|
});
|
|
3617
3637
|
})
|
|
@@ -3632,12 +3652,12 @@ const pubsub = new PubSub(), BlockActionLabel = ({ block: o, label: r }) => {
|
|
|
3632
3652
|
}, [l, f]), useEffect(() => {
|
|
3633
3653
|
d.querySelector("#drop-target-block").innerHTML = c ? `[data-block-id="${c}"]{ outline: 1px dashed orange !important; outline-offset: -1px;}` : "";
|
|
3634
3654
|
}, [c, d]);
|
|
3635
|
-
const
|
|
3655
|
+
const j = useMemo(
|
|
3636
3656
|
() => getChaiThemeCssVariables(o),
|
|
3637
3657
|
[o]
|
|
3638
3658
|
), b = useMemo(() => getThemeFontsLinkMarkup(pick(o, ["fontFamily"])), [o]);
|
|
3639
3659
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
3640
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("style", { id: "chai-theme", children:
|
|
3660
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("style", { id: "chai-theme", children: j }),
|
|
3641
3661
|
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { id: "chai-fonts", dangerouslySetInnerHTML: { __html: b } })
|
|
3642
3662
|
] });
|
|
3643
3663
|
}, useChaiExternalData = () => useAtom$1(chaiExternalDataAtom), useCanvasSettings = () => useAtom$1(canvasSettingsAtom), isVisibleAtBreakpoint = (o, r) => {
|
|
@@ -3720,29 +3740,29 @@ function applyLanguage(o, r, n) {
|
|
|
3720
3740
|
}), a;
|
|
3721
3741
|
}
|
|
3722
3742
|
function BlocksRendererStatic({ blocks: o, allBlocks: r }) {
|
|
3723
|
-
const { selectedLang: n } = useLanguages(), [a] = useAtom$1(xShowBlocksAtom), [l] = useCutBlockIds(), [i] = useAtom$1(draggedBlockAtom), [c] = useAtom$1(dropTargetBlockIdAtom), [, d] = useCanvasWidth(), [p] = useCanvasSettings(), [u] = useHiddenBlockIds(), { getGlobalBlocks: x } = useGlobalBlocksStore(), f = useCallback((h) => getStyleAttrs(h, d), [d]), [g] = useChaiExternalData(), [
|
|
3724
|
-
(h) => h.reduce((
|
|
3725
|
-
const
|
|
3726
|
-
return { ...
|
|
3743
|
+
const { selectedLang: n } = useLanguages(), [a] = useAtom$1(xShowBlocksAtom), [l] = useCutBlockIds(), [i] = useAtom$1(draggedBlockAtom), [c] = useAtom$1(dropTargetBlockIdAtom), [, d] = useCanvasWidth(), [p] = useCanvasSettings(), [u] = useHiddenBlockIds(), { getGlobalBlocks: x } = useGlobalBlocksStore(), f = useCallback((h) => getStyleAttrs(h, d), [d]), [g] = useChaiExternalData(), [j] = useAtom$1(inlineEditingActiveAtom), b = useCallback(
|
|
3744
|
+
(h) => h.reduce((y, S) => {
|
|
3745
|
+
const B = get(p, S, {});
|
|
3746
|
+
return { ...y, ...B };
|
|
3727
3747
|
}, {}),
|
|
3728
3748
|
[p]
|
|
3729
3749
|
);
|
|
3730
3750
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: React__default.Children.toArray(
|
|
3731
|
-
o.map((h,
|
|
3732
|
-
if (
|
|
3751
|
+
o.map((h, y) => {
|
|
3752
|
+
if (j === h._id || u.includes(h._id))
|
|
3733
3753
|
return null;
|
|
3734
|
-
const
|
|
3735
|
-
if (
|
|
3736
|
-
const
|
|
3737
|
-
|
|
3754
|
+
const S = {}, B = filter(r, { _parent: h._id });
|
|
3755
|
+
if (S.children = B.length > 0 ? /* @__PURE__ */ jsxRuntimeExports.jsx(BlocksRendererStatic, { allBlocks: r, blocks: B }) : null, h._type === "GlobalBlock") {
|
|
3756
|
+
const w = x(h);
|
|
3757
|
+
S.children = /* @__PURE__ */ jsxRuntimeExports.jsx(RenderGlobalBlock, { blocks: filter(w, (T) => !T._parent), allBlocks: w });
|
|
3738
3758
|
}
|
|
3739
|
-
const
|
|
3740
|
-
if (isNull(
|
|
3759
|
+
const A = getRegisteredChaiBlock(h._type), C = get(A, "component", null);
|
|
3760
|
+
if (isNull(C))
|
|
3741
3761
|
return /* @__PURE__ */ jsxRuntimeExports.jsx("noscript", { children: `<!-- ${h == null ? void 0 : h._type} not registered -->` });
|
|
3742
|
-
const
|
|
3743
|
-
if (get(
|
|
3762
|
+
const v = has(A, "getBlockStateFrom") ? A == null ? void 0 : A.getBlockStateFrom(h, r) : [], _ = b(v), I = f(h);
|
|
3763
|
+
if (get(I, "__isHidden", !1) && !includes(a, h._id))
|
|
3744
3764
|
return null;
|
|
3745
|
-
const
|
|
3765
|
+
const D = i && isDescendant(i._id, h._id, r), E = {
|
|
3746
3766
|
blockProps: {
|
|
3747
3767
|
...includes(a, h._id) ? { "force-show": "" } : {},
|
|
3748
3768
|
"data-block-id": h._id,
|
|
@@ -3751,31 +3771,31 @@ function BlocksRendererStatic({ blocks: o, allBlocks: r }) {
|
|
|
3751
3771
|
// @ts-ignore
|
|
3752
3772
|
{
|
|
3753
3773
|
"data-dnd": canAcceptChildBlock(h._type, i == null ? void 0 : i._type) ? "yes" : "no",
|
|
3754
|
-
"data-dnd-dragged": i._id === h._id ||
|
|
3774
|
+
"data-dnd-dragged": i._id === h._id || D ? "yes" : "no"
|
|
3755
3775
|
}
|
|
3756
3776
|
) : {},
|
|
3757
|
-
...c === h._id && !
|
|
3777
|
+
...c === h._id && !D ? { "data-drop": "yes" } : {},
|
|
3758
3778
|
...includes(l, h._id) ? { "data-cut-block": "yes" } : {}
|
|
3759
3779
|
},
|
|
3760
|
-
index:
|
|
3761
|
-
...applyBindings(applyLanguage(h, n,
|
|
3762
|
-
...omit(
|
|
3763
|
-
...
|
|
3780
|
+
index: y,
|
|
3781
|
+
...applyBindings(applyLanguage(h, n, A), g),
|
|
3782
|
+
...omit(I, ["__isHidden"]),
|
|
3783
|
+
...S,
|
|
3764
3784
|
inBuilder: !0,
|
|
3765
|
-
blockState:
|
|
3785
|
+
blockState: _
|
|
3766
3786
|
};
|
|
3767
|
-
if (has(
|
|
3787
|
+
if (has(A, "dataProvider"))
|
|
3768
3788
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(Suspense, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
3769
3789
|
AsyncPropsBlock,
|
|
3770
3790
|
{
|
|
3771
|
-
dataProvider:
|
|
3791
|
+
dataProvider: A.dataProvider,
|
|
3772
3792
|
block: h,
|
|
3773
|
-
component:
|
|
3793
|
+
component: C,
|
|
3774
3794
|
props: E
|
|
3775
3795
|
}
|
|
3776
3796
|
) });
|
|
3777
|
-
const
|
|
3778
|
-
return
|
|
3797
|
+
const R = getRuntimeProps(h._type);
|
|
3798
|
+
return R ? /* @__PURE__ */ jsxRuntimeExports.jsx(RuntimePropsBlock, { runtimeProps: R, block: h, component: C, props: E }) : /* @__PURE__ */ jsxRuntimeExports.jsx(Suspense, { children: React__default.createElement(C, E) });
|
|
3779
3799
|
})
|
|
3780
3800
|
) });
|
|
3781
3801
|
}
|
|
@@ -3830,43 +3850,43 @@ const usePageDataProviders = () => useAtom$1(dataProvidersAtom), useAllDataProvi
|
|
|
3830
3850
|
};
|
|
3831
3851
|
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { id: "main-content", onClick: d, className: "h-full w-full p-8 pb-0", ref: i, children: o });
|
|
3832
3852
|
}, getElementByStyleId = (o, r) => o.querySelector(`[data-style-id="${r}"]`), StaticCanvas = () => {
|
|
3833
|
-
const [o] = useAtom$1(networkModeAtom), [r] = useCanvasWidth(), [, n] = useSelectedBlockIds(), a = useSelectedBlock(), [, l] = useHighlightBlockId(), i = useRef(null), c = useRef(null), [d, p] = useState({ width: 0, height: 0 }), u = useCanvasScale(d), [x, f] = useState([]), [, g] = useState([]), [,
|
|
3834
|
-
p((
|
|
3853
|
+
const [o] = useAtom$1(networkModeAtom), [r] = useCanvasWidth(), [, n] = useSelectedBlockIds(), a = useSelectedBlock(), [, l] = useHighlightBlockId(), i = useRef(null), c = useRef(null), [d, p] = useState({ width: 0, height: 0 }), u = useCanvasScale(d), [x, f] = useState([]), [, g] = useState([]), [, j] = useAtom$1(canvasIframeAtom), [b, h] = useSelectedStylingBlocks(), y = useBuilderProp("loading", !1), S = useBuilderProp("htmlDir", "ltr"), B = (v) => {
|
|
3854
|
+
p((_) => ({ ..._, width: v }));
|
|
3835
3855
|
};
|
|
3836
3856
|
useEffect(() => {
|
|
3837
3857
|
if (!c.current)
|
|
3838
3858
|
return;
|
|
3839
|
-
const { clientWidth:
|
|
3840
|
-
p({ width:
|
|
3859
|
+
const { clientWidth: v, clientHeight: _ } = c.current;
|
|
3860
|
+
p({ width: v, height: _ });
|
|
3841
3861
|
}, [c, r]);
|
|
3842
|
-
const
|
|
3843
|
-
const { top:
|
|
3844
|
-
return
|
|
3862
|
+
const A = (v, _ = 0) => {
|
|
3863
|
+
const { top: I } = v.getBoundingClientRect();
|
|
3864
|
+
return I + _ >= 0 && I - _ <= window.innerHeight;
|
|
3845
3865
|
};
|
|
3846
3866
|
useEffect(() => {
|
|
3847
|
-
var
|
|
3867
|
+
var v, _;
|
|
3848
3868
|
if (a && a.type !== "Multiple" && i.current) {
|
|
3849
|
-
const
|
|
3850
|
-
|
|
3869
|
+
const I = getElementByDataBlockId(i.current.contentDocument, a._id);
|
|
3870
|
+
I && (A(I) || (_ = (v = i.current) == null ? void 0 : v.contentWindow) == null || _.scrollTo({ top: I.offsetTop, behavior: "smooth" }), f([I]));
|
|
3851
3871
|
}
|
|
3852
3872
|
}, [a]), useEffect(() => {
|
|
3853
3873
|
if (!isEmpty(b) && i.current) {
|
|
3854
|
-
const
|
|
3874
|
+
const v = getElementByStyleId(
|
|
3855
3875
|
i.current.contentDocument,
|
|
3856
3876
|
first(b).id
|
|
3857
3877
|
);
|
|
3858
|
-
g(
|
|
3878
|
+
g(v ? [v] : [null]);
|
|
3859
3879
|
} else
|
|
3860
3880
|
g([null]);
|
|
3861
3881
|
}, [b]);
|
|
3862
|
-
const
|
|
3863
|
-
let
|
|
3864
|
-
return
|
|
3882
|
+
const C = useMemo(() => {
|
|
3883
|
+
let v = IframeInitialContent;
|
|
3884
|
+
return v = v.replace("__HTML_DIR__", S), o === "offline" && (v = v.replace(
|
|
3865
3885
|
"https://old.chaibuilder.com/offline/tailwind.cdn.js",
|
|
3866
3886
|
"/offline/tailwind.cdn.js"
|
|
3867
|
-
),
|
|
3868
|
-
}, [o,
|
|
3869
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(ResizableCanvasWrapper, { onMount:
|
|
3887
|
+
), v = v.replace("https://unpkg.com/aos@next/dist/aos.css", "/offline/aos.css"), v = v.replace("https://unpkg.com/aos@next/dist/aos.js", "/offline/aos.js")), v;
|
|
3888
|
+
}, [o, S]);
|
|
3889
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(ResizableCanvasWrapper, { onMount: B, onResize: B, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
3870
3890
|
"div",
|
|
3871
3891
|
{
|
|
3872
3892
|
onClick: () => {
|
|
@@ -3878,12 +3898,12 @@ const usePageDataProviders = () => useAtom$1(dataProvidersAtom), useAllDataProvi
|
|
|
3878
3898
|
children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
3879
3899
|
ChaiFrame,
|
|
3880
3900
|
{
|
|
3881
|
-
contentDidMount: () =>
|
|
3901
|
+
contentDidMount: () => j(i.current),
|
|
3882
3902
|
ref: i,
|
|
3883
3903
|
id: "canvas-iframe",
|
|
3884
3904
|
style: { ...u, ...isEmpty(u) ? { width: `${r}px` } : {} },
|
|
3885
3905
|
className: "relative mx-auto box-content h-full w-full max-w-full shadow-lg transition-all duration-300 ease-linear",
|
|
3886
|
-
initialContent:
|
|
3906
|
+
initialContent: C,
|
|
3887
3907
|
children: [
|
|
3888
3908
|
/* @__PURE__ */ jsxRuntimeExports.jsx(KeyboardHandler, {}),
|
|
3889
3909
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
@@ -3895,7 +3915,7 @@ const usePageDataProviders = () => useAtom$1(dataProvidersAtom), useAllDataProvi
|
|
|
3895
3915
|
),
|
|
3896
3916
|
/* @__PURE__ */ jsxRuntimeExports.jsx(HeadTags, {}),
|
|
3897
3917
|
/* @__PURE__ */ jsxRuntimeExports.jsx(Provider, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(Canvas, { children: [
|
|
3898
|
-
|
|
3918
|
+
y ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-full p-4", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-full" }) }) : /* @__PURE__ */ jsxRuntimeExports.jsx(StaticBlocksRenderer, {}),
|
|
3899
3919
|
/* @__PURE__ */ jsxRuntimeExports.jsx(AddBlockAtBottom, {}),
|
|
3900
3920
|
/* @__PURE__ */ jsxRuntimeExports.jsx("br", {}),
|
|
3901
3921
|
/* @__PURE__ */ jsxRuntimeExports.jsx("br", {}),
|
|
@@ -4125,19 +4145,19 @@ const usePageDataProviders = () => useAtom$1(dataProvidersAtom), useAllDataProvi
|
|
|
4125
4145
|
const [r] = useDarkMode(), [n, a] = React.useState(""), l = useBuilderProp("themePresets", []), [i, c] = useTheme(), d = useThemeOptions(), { t: p } = useTranslation(), u = (h) => {
|
|
4126
4146
|
a(h);
|
|
4127
4147
|
}, x = () => {
|
|
4128
|
-
const h = l.find((
|
|
4148
|
+
const h = l.find((y) => Object.keys(y)[0] === n);
|
|
4129
4149
|
if (h) {
|
|
4130
|
-
const
|
|
4131
|
-
|
|
4150
|
+
const y = Object.values(h)[0];
|
|
4151
|
+
y && typeof y == "object" && "fontFamily" in y && "borderRadius" in y && "colors" in y ? c(y) : console.error("Invalid preset structure:", y);
|
|
4132
4152
|
} else
|
|
4133
4153
|
console.error("Preset not found:", n);
|
|
4134
4154
|
}, f = useDebouncedCallback(
|
|
4135
|
-
(h,
|
|
4155
|
+
(h, y) => {
|
|
4136
4156
|
c(() => ({
|
|
4137
4157
|
...i,
|
|
4138
4158
|
fontFamily: {
|
|
4139
4159
|
...i.fontFamily,
|
|
4140
|
-
[h.replace(/font-/g, "")]:
|
|
4160
|
+
[h.replace(/font-/g, "")]: y
|
|
4141
4161
|
}
|
|
4142
4162
|
}));
|
|
4143
4163
|
},
|
|
@@ -4152,33 +4172,33 @@ const usePageDataProviders = () => useAtom$1(dataProvidersAtom), useAllDataProvi
|
|
|
4152
4172
|
},
|
|
4153
4173
|
[i],
|
|
4154
4174
|
200
|
|
4155
|
-
),
|
|
4156
|
-
(h,
|
|
4175
|
+
), j = useDebouncedCallback(
|
|
4176
|
+
(h, y) => {
|
|
4157
4177
|
c(() => {
|
|
4158
|
-
const
|
|
4159
|
-
return r ? set(
|
|
4178
|
+
const S = get(i, `colors.${h}`);
|
|
4179
|
+
return r ? set(S, 1, y) : set(S, 0, y), {
|
|
4160
4180
|
...i,
|
|
4161
4181
|
colors: {
|
|
4162
4182
|
...i.colors,
|
|
4163
|
-
[h]:
|
|
4183
|
+
[h]: S
|
|
4164
4184
|
}
|
|
4165
4185
|
};
|
|
4166
4186
|
});
|
|
4167
4187
|
},
|
|
4168
4188
|
[i],
|
|
4169
4189
|
200
|
|
4170
|
-
), b = (h) => /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "grid grid-cols-1", children: Object.entries(h.items).map(([
|
|
4171
|
-
const
|
|
4190
|
+
), b = (h) => /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "grid grid-cols-1", children: Object.entries(h.items).map(([y]) => {
|
|
4191
|
+
const S = get(i, `colors.${y}.${r ? 1 : 0}`);
|
|
4172
4192
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mt-1 flex items-center gap-x-2", children: [
|
|
4173
4193
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
4174
4194
|
ColorPickerInput$1,
|
|
4175
4195
|
{
|
|
4176
|
-
value:
|
|
4177
|
-
onChange: (
|
|
4196
|
+
value: S,
|
|
4197
|
+
onChange: (B) => j(y, B)
|
|
4178
4198
|
}
|
|
4179
4199
|
),
|
|
4180
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(Label, { className: "text-xs font-normal leading-tight text-slate-600", children:
|
|
4181
|
-
] },
|
|
4200
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Label, { className: "text-xs font-normal leading-tight text-slate-600", children: y.split(/(?=[A-Z])/).join(" ").replace(/-/g, " ").split(" ").map((B) => B.charAt(0).toUpperCase() + B.slice(1)).join(" ") + (!y.toLowerCase().includes("foreground") && !y.toLowerCase().includes("border") && !y.toLowerCase().includes("input") && !y.toLowerCase().includes("ring") && !y.toLowerCase().includes("background") ? " Background" : "") })
|
|
4201
|
+
] }, y);
|
|
4182
4202
|
}) });
|
|
4183
4203
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: cn("no-scrollbar h-full w-full overflow-y-auto", o), children: [
|
|
4184
4204
|
l.length > 0 && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex gap-2 py-2", children: [
|
|
@@ -4200,12 +4220,12 @@ const usePageDataProviders = () => useAtom$1(dataProvidersAtom), useAllDataProvi
|
|
|
4200
4220
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex w-[30%] items-end", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { className: "w-full text-sm", disabled: n === "", variant: "default", onClick: x, children: p("Apply") }) })
|
|
4201
4221
|
] }),
|
|
4202
4222
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: cn("space-y-2", o), children: [
|
|
4203
|
-
(d == null ? void 0 : d.fontFamily) && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "grid gap-4", children: Object.entries(d.fontFamily).map(([h,
|
|
4223
|
+
(d == null ? void 0 : d.fontFamily) && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "grid gap-4", children: Object.entries(d.fontFamily).map(([h, y]) => /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
4204
4224
|
FontSelector$1,
|
|
4205
4225
|
{
|
|
4206
4226
|
label: h,
|
|
4207
|
-
value: i.fontFamily[h.replace(/font-/g, "")] ||
|
|
4208
|
-
onChange: (
|
|
4227
|
+
value: i.fontFamily[h.replace(/font-/g, "")] || y[Object.keys(y)[0]],
|
|
4228
|
+
onChange: (S) => f(h, S)
|
|
4209
4229
|
},
|
|
4210
4230
|
h
|
|
4211
4231
|
)) }),
|
|
@@ -4415,40 +4435,40 @@ function BiExpandVertical(o) {
|
|
|
4415
4435
|
const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: r, dragHandle: n }) => {
|
|
4416
4436
|
const a = useBuilderProp("outlineMenuItems", []), { t: l } = useTranslation(), [i, , c] = useHiddenBlockIds(), [d] = useAtom$1(canvasIframeAtom);
|
|
4417
4437
|
let p = null;
|
|
4418
|
-
const u = o.children.length > 0, { highlightBlock: x, clearHighlight: f } = useBlockHighlight(), { id: g, data:
|
|
4438
|
+
const u = o.children.length > 0, { highlightBlock: x, clearHighlight: f } = useBlockHighlight(), { id: g, data: j, isSelected: b, willReceiveDrop: h, isDragging: y, isEditing: S, handleClick: B } = o, A = (k) => {
|
|
4419
4439
|
k.stopPropagation(), !i.includes(g) && o.toggle();
|
|
4420
|
-
},
|
|
4440
|
+
}, C = (k) => {
|
|
4421
4441
|
k.isInternal && (p = k.isOpen, k.isOpen && k.close());
|
|
4422
|
-
},
|
|
4442
|
+
}, v = (k) => {
|
|
4423
4443
|
k.isInternal && p !== null && (p ? k.open() : k.close(), p = null);
|
|
4424
|
-
}, [
|
|
4444
|
+
}, [_, I] = useAtom$1(currentAddSelection), D = () => {
|
|
4425
4445
|
var N, $;
|
|
4426
|
-
m(), document.getElementById(`tree-node-${(N = o == null ? void 0 : o.parent) == null ? void 0 : N.id}`) && !o.parent.isSelected &&
|
|
4446
|
+
m(), document.getElementById(`tree-node-${(N = o == null ? void 0 : o.parent) == null ? void 0 : N.id}`) && !o.parent.isSelected && I(($ = o == null ? void 0 : o.parent) == null ? void 0 : $.id);
|
|
4427
4447
|
}, m = () => {
|
|
4428
|
-
|
|
4448
|
+
I(null);
|
|
4429
4449
|
}, E = (k) => {
|
|
4430
|
-
m(), k.stopPropagation(), !o.isOpen && !i.includes(g) && o.toggle(),
|
|
4450
|
+
m(), k.stopPropagation(), !o.isOpen && !i.includes(g) && o.toggle(), B(k);
|
|
4431
4451
|
};
|
|
4432
4452
|
useEffect(() => {
|
|
4433
4453
|
const k = setTimeout(() => {
|
|
4434
|
-
h && !o.isOpen && !
|
|
4454
|
+
h && !o.isOpen && !y && !i.includes(g) && o.toggle();
|
|
4435
4455
|
}, 500);
|
|
4436
4456
|
return () => clearTimeout(k);
|
|
4437
|
-
}, [h, o,
|
|
4438
|
-
const
|
|
4439
|
-
const k = Object.keys(
|
|
4457
|
+
}, [h, o, y]);
|
|
4458
|
+
const R = useMemo(() => {
|
|
4459
|
+
const k = Object.keys(j), N = [];
|
|
4440
4460
|
for (let $ = 0; $ < k.length; $++)
|
|
4441
4461
|
if (k[$].endsWith("_attrs")) {
|
|
4442
|
-
const L =
|
|
4443
|
-
|
|
4462
|
+
const L = j[k[$]], P = Object.keys(L).join("|");
|
|
4463
|
+
P.match(/x-data/) && N.push("data"), P.match(/x-on/) && N.push("event"), P.match(/x-show|x-if/) && N.push("show");
|
|
4444
4464
|
}
|
|
4445
4465
|
return N;
|
|
4446
|
-
}, [
|
|
4466
|
+
}, [j]), w = (k, N) => {
|
|
4447
4467
|
const $ = d.contentDocument || d.contentWindow.document, L = $.querySelector(`[data-block-id=${k}]`);
|
|
4448
4468
|
L && L.setAttribute("data-drop", N);
|
|
4449
|
-
const
|
|
4450
|
-
|
|
4451
|
-
},
|
|
4469
|
+
const P = L.getBoundingClientRect(), M = d.getBoundingClientRect();
|
|
4470
|
+
P.top >= M.top && P.left >= M.left && P.bottom <= M.bottom && P.right <= M.right || ($.documentElement.scrollTop = L.offsetTop - M.top);
|
|
4471
|
+
}, T = (k) => {
|
|
4452
4472
|
m();
|
|
4453
4473
|
const N = get(o, "parent.id");
|
|
4454
4474
|
N !== "__REACT_ARBORIST_INTERNAL_ROOT__" ? pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: N, position: k }) : pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK);
|
|
@@ -4458,7 +4478,7 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: r, drag
|
|
|
4458
4478
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
4459
4479
|
"div",
|
|
4460
4480
|
{
|
|
4461
|
-
onClick: () =>
|
|
4481
|
+
onClick: () => T(-1),
|
|
4462
4482
|
className: "h-1 rounded bg-purple-500 opacity-0 duration-200 group-hover:opacity-100",
|
|
4463
4483
|
children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "absolute left-1/2 top-1/2 flex -translate-x-1/2 -translate-y-1/2 transform items-center gap-x-1 rounded-full bg-purple-500 px-3 py-1 text-[9px] leading-tight text-white hover:bg-purple-500", children: [
|
|
4464
4484
|
/* @__PURE__ */ jsxRuntimeExports.jsx(PlusIcon$1, { className: "h-2 w-2 stroke-[3]" }),
|
|
@@ -4477,23 +4497,23 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: r, drag
|
|
|
4477
4497
|
style: r,
|
|
4478
4498
|
"data-node-id": g,
|
|
4479
4499
|
ref: i.includes(g) ? null : n,
|
|
4480
|
-
onDragStart: () =>
|
|
4481
|
-
onDragEnd: () =>
|
|
4500
|
+
onDragStart: () => C(o),
|
|
4501
|
+
onDragEnd: () => v(o),
|
|
4482
4502
|
onDragOver: (k) => {
|
|
4483
|
-
k.preventDefault(),
|
|
4503
|
+
k.preventDefault(), w(g, "yes");
|
|
4484
4504
|
},
|
|
4485
4505
|
onDragLeave: (k) => {
|
|
4486
|
-
k.preventDefault(),
|
|
4506
|
+
k.preventDefault(), w(g, "no");
|
|
4487
4507
|
},
|
|
4488
4508
|
onDrop: (k) => {
|
|
4489
|
-
k.preventDefault(),
|
|
4509
|
+
k.preventDefault(), w(g, "no");
|
|
4490
4510
|
},
|
|
4491
4511
|
children: [
|
|
4492
4512
|
(o == null ? void 0 : o.rowIndex) > 0 && o.parent.isOpen && canAddChildBlock(get(o, "parent.data._type")) && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "group relative ml-5 h-full w-full cursor-pointer", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
4493
4513
|
"div",
|
|
4494
4514
|
{
|
|
4495
|
-
onClick: () =>
|
|
4496
|
-
onMouseEnter:
|
|
4515
|
+
onClick: () => T(o.childIndex),
|
|
4516
|
+
onMouseEnter: D,
|
|
4497
4517
|
onMouseLeave: m,
|
|
4498
4518
|
className: "absolute -top-0.5 h-1 w-[90%] rounded bg-purple-500 opacity-0 delay-200 duration-200 group-hover:opacity-100",
|
|
4499
4519
|
children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "absolute left-1/2 top-1/2 flex h-5 w-5 -translate-x-1/2 -translate-y-1/2 transform items-center justify-center rounded-full bg-purple-500 p-1 outline outline-2 outline-white hover:bg-purple-500", children: /* @__PURE__ */ jsxRuntimeExports.jsx(PlusIcon$1, { className: "h-4 w-4 stroke-[3] text-white" }) })
|
|
@@ -4506,9 +4526,9 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: r, drag
|
|
|
4506
4526
|
className: cn(
|
|
4507
4527
|
"group flex w-full cursor-pointer items-center justify-between space-x-px !rounded p-1 text-foreground/80 outline-none",
|
|
4508
4528
|
b ? "bg-blue-500 text-white" : "hover:bg-slate-200 dark:hover:bg-gray-800",
|
|
4509
|
-
h && canAcceptChildBlock(
|
|
4510
|
-
(o == null ? void 0 : o.id) ===
|
|
4511
|
-
|
|
4529
|
+
h && canAcceptChildBlock(j._type, "Icon") ? "bg-green-200" : "",
|
|
4530
|
+
(o == null ? void 0 : o.id) === _ ? "bg-purple-50" : "",
|
|
4531
|
+
y && "opacity-20",
|
|
4512
4532
|
i.includes(g) ? "opacity-50" : ""
|
|
4513
4533
|
),
|
|
4514
4534
|
children: [
|
|
@@ -4517,7 +4537,7 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: r, drag
|
|
|
4517
4537
|
"div",
|
|
4518
4538
|
{
|
|
4519
4539
|
className: `flex h-4 w-4 rotate-0 transform cursor-pointer items-center justify-center transition-transform duration-100 ${o.isOpen ? "rotate-90" : ""}`,
|
|
4520
|
-
children: u && /* @__PURE__ */ jsxRuntimeExports.jsx("button", { onClick:
|
|
4540
|
+
children: u && /* @__PURE__ */ jsxRuntimeExports.jsx("button", { onClick: A, type: "button", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
4521
4541
|
ChevronRight,
|
|
4522
4542
|
{
|
|
4523
4543
|
className: `h-3 w-3 stroke-[3] ${b ? "text-slate-200" : "text-slate-400"}`
|
|
@@ -4526,8 +4546,8 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: r, drag
|
|
|
4526
4546
|
}
|
|
4527
4547
|
),
|
|
4528
4548
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "leading-1 flex items-center", children: [
|
|
4529
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(TypeIcon, { type:
|
|
4530
|
-
|
|
4549
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(TypeIcon, { type: j == null ? void 0 : j._type }),
|
|
4550
|
+
S ? /* @__PURE__ */ jsxRuntimeExports.jsx(Input, { node: o }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
4531
4551
|
"div",
|
|
4532
4552
|
{
|
|
4533
4553
|
className: "ml-1.5 flex items-center gap-x-1 truncate text-[13px]",
|
|
@@ -4535,10 +4555,10 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: r, drag
|
|
|
4535
4555
|
k.stopPropagation(), o.edit(), o.deselect();
|
|
4536
4556
|
},
|
|
4537
4557
|
children: [
|
|
4538
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: (
|
|
4539
|
-
|
|
4540
|
-
|
|
4541
|
-
|
|
4558
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: (j == null ? void 0 : j._name) || (j == null ? void 0 : j._type.split("/").pop()) }),
|
|
4559
|
+
R.includes("data") && /* @__PURE__ */ jsxRuntimeExports.jsx(VscJson, { className: "h-3 w-3 text-orange-600" }),
|
|
4560
|
+
R.includes("event") && /* @__PURE__ */ jsxRuntimeExports.jsx(BsLightningFill, { className: "h-3 w-3 text-yellow-500" }),
|
|
4561
|
+
R.includes("show") && /* @__PURE__ */ jsxRuntimeExports.jsx(TbEyeDown, { className: "h-3 w-3 text-orange-600" })
|
|
4542
4562
|
]
|
|
4543
4563
|
}
|
|
4544
4564
|
)
|
|
@@ -4556,7 +4576,7 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: r, drag
|
|
|
4556
4576
|
),
|
|
4557
4577
|
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { className: "isolate z-10", children: k.tooltip })
|
|
4558
4578
|
] })),
|
|
4559
|
-
canAddChildBlock(
|
|
4579
|
+
canAddChildBlock(j == null ? void 0 : j._type) && !i.includes(g) ? /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
|
|
4560
4580
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
4561
4581
|
TooltipTrigger,
|
|
4562
4582
|
{
|
|
@@ -4926,16 +4946,16 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: r, drag
|
|
|
4926
4946
|
}
|
|
4927
4947
|
}
|
|
4928
4948
|
}, traverseNodes = (o, r = null) => flatMapDeep(o, (n) => {
|
|
4929
|
-
var p, u, x, f, g,
|
|
4949
|
+
var p, u, x, f, g, j, b, h;
|
|
4930
4950
|
if (n.type === "comment")
|
|
4931
4951
|
return [];
|
|
4932
4952
|
let a = { _id: generateUUID() };
|
|
4933
4953
|
if (r && (a._parent = r.block._id), n.type === "text")
|
|
4934
4954
|
return isEmpty(get(n, "content", "")) ? [] : r && shouldAddText(r.node, r.block) ? (set(r, "block.content", get(n, "content", "")), []) : { ...a, _type: "Text", content: get(n, "content", "") };
|
|
4935
4955
|
const l = get(n, "attributes", []), i = l.find(
|
|
4936
|
-
(
|
|
4956
|
+
(y) => y.key === "data-chai-richtext" || y.key === "chai-richtext"
|
|
4937
4957
|
), c = l.find(
|
|
4938
|
-
(
|
|
4958
|
+
(y) => y.key === "data-chai-lightbox" || y.key === "chai-lightbox"
|
|
4939
4959
|
);
|
|
4940
4960
|
if (a = {
|
|
4941
4961
|
...a,
|
|
@@ -4943,13 +4963,13 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: r, drag
|
|
|
4943
4963
|
...getAttrs(n),
|
|
4944
4964
|
...getStyles(n)
|
|
4945
4965
|
}, n.attributes) {
|
|
4946
|
-
const
|
|
4947
|
-
|
|
4966
|
+
const y = n.attributes.find((S) => includes(NAME_ATTRIBUTES, S.key));
|
|
4967
|
+
y && (a._name = y.value);
|
|
4948
4968
|
}
|
|
4949
4969
|
if (i)
|
|
4950
4970
|
return a.content = stringify(n.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];
|
|
4951
4971
|
if (c) {
|
|
4952
|
-
const
|
|
4972
|
+
const y = [
|
|
4953
4973
|
"data-chai-lightbox",
|
|
4954
4974
|
"chai-lightbox",
|
|
4955
4975
|
"data-vbtype",
|
|
@@ -4961,25 +4981,25 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: r, drag
|
|
|
4961
4981
|
];
|
|
4962
4982
|
a = {
|
|
4963
4983
|
...a,
|
|
4964
|
-
href: ((p = l.find((
|
|
4965
|
-
hrefType: ((u = l.find((
|
|
4966
|
-
autoplay: ((x = l.find((
|
|
4967
|
-
maxWidth: ((g = (f = l.find((
|
|
4968
|
-
backdropColor: ((
|
|
4969
|
-
galleryName: ((b = l.find((
|
|
4970
|
-
}, forEach(
|
|
4971
|
-
has(a, `styles_attrs.${
|
|
4984
|
+
href: ((p = l.find((S) => S.key === "href")) == null ? void 0 : p.value) || "",
|
|
4985
|
+
hrefType: ((u = l.find((S) => S.key === "data-vbtype")) == null ? void 0 : u.value) || "video",
|
|
4986
|
+
autoplay: ((x = l.find((S) => S.key === "data-autoplay")) == null ? void 0 : x.value) === "true" ? "true" : "false",
|
|
4987
|
+
maxWidth: ((g = (f = l.find((S) => S.key === "data-maxwidth")) == null ? void 0 : f.value) == null ? void 0 : g.replace("px", "")) || "",
|
|
4988
|
+
backdropColor: ((j = l.find((S) => S.key === "data-overlay")) == null ? void 0 : j.value) || "",
|
|
4989
|
+
galleryName: ((b = l.find((S) => S.key === "data-gall")) == null ? void 0 : b.value) || ""
|
|
4990
|
+
}, forEach(y, (S) => {
|
|
4991
|
+
has(a, `styles_attrs.${S}`) && delete a.styles_attrs[S];
|
|
4972
4992
|
});
|
|
4973
4993
|
}
|
|
4974
4994
|
if (a._type === "Input") {
|
|
4975
|
-
const
|
|
4976
|
-
|
|
4995
|
+
const y = a.inputType || "text";
|
|
4996
|
+
y === "checkbox" ? set(a, "_type", "Checkbox") : y === "radio" && set(a, "_type", "Radio");
|
|
4977
4997
|
} else if (n.tagName === "video" || n.tagName === "iframe") {
|
|
4978
|
-
const
|
|
4979
|
-
return hasVideoEmbed(
|
|
4998
|
+
const y = stringify([n]);
|
|
4999
|
+
return hasVideoEmbed(y) && (set(a, "_type", "Video"), set(a, "url", getVideoURLFromHTML(y)), set(a, "styles", `${STYLES_KEY},`), set(a, "controls", { autoPlay: !1, muted: !0, loop: !1, controls: !1 })), a.content = y, [a];
|
|
4980
5000
|
} else if (n.tagName === "svg") {
|
|
4981
|
-
const
|
|
4982
|
-
return a.styles = `${STYLES_KEY}, ${cn(`w-${
|
|
5001
|
+
const y = find(n.attributes, { key: "height" }), S = find(n.attributes, { key: "width" }), B = get(y, "value") ? `[${get(y, "value")}px]` : "24px", A = get(S, "value") ? `[${get(S, "value")}px]` : "24px", C = get(find(n.attributes, { key: "class" }), "value", "w-full h-full");
|
|
5002
|
+
return a.styles = `${STYLES_KEY}, ${cn(`w-${A} h-${B}`, C)}`.trim(), n.attributes = filter(n.attributes, (v) => !includes(["style", "width", "height", "class"], v.key)), a.icon = stringify([n]), [a];
|
|
4983
5003
|
} else if (n.tagName == "option" && r && ((h = r.block) == null ? void 0 : h._type) === "Select")
|
|
4984
5004
|
return r.block.options.push({
|
|
4985
5005
|
label: getTextContent(n.children),
|
|
@@ -5165,18 +5185,18 @@ const MediaManagerModal$1 = MediaManagerModal, ImagePickerField = ({ value: o, o
|
|
|
5165
5185
|
collections: r,
|
|
5166
5186
|
onChange: n
|
|
5167
5187
|
}) => {
|
|
5168
|
-
var
|
|
5169
|
-
const { t: a } = useTranslation(), l = useBuilderProp("searchCollectionItems", (m, E) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, x] = useState("page"), [f, g] = useState(""), [
|
|
5188
|
+
var D;
|
|
5189
|
+
const { t: a } = useTranslation(), l = useBuilderProp("searchCollectionItems", (m, E) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, x] = useState("page"), [f, g] = useState(""), [j, b] = useState([]), [h, y] = useState(-1), S = useRef(null), B = (D = r == null ? void 0 : r.find((m) => m.key === u)) == null ? void 0 : D.name;
|
|
5170
5190
|
useEffect(() => {
|
|
5171
|
-
if (g(""), b([]),
|
|
5191
|
+
if (g(""), b([]), y(-1), p(!1), !o || i || !startsWith(o, "collection:"))
|
|
5172
5192
|
return;
|
|
5173
5193
|
const m = split(o, ":"), E = get(m, 1, "page") || "page";
|
|
5174
5194
|
x(E), (async () => {
|
|
5175
|
-
const
|
|
5176
|
-
|
|
5195
|
+
const R = await l(E, [get(m, 2, "page")]);
|
|
5196
|
+
R && Array.isArray(R) && g(get(R, [0, "name"], ""));
|
|
5177
5197
|
})();
|
|
5178
5198
|
}, [o]);
|
|
5179
|
-
const
|
|
5199
|
+
const A = useDebouncedCallback(
|
|
5180
5200
|
async (m) => {
|
|
5181
5201
|
if (isEmpty(m))
|
|
5182
5202
|
b([]);
|
|
@@ -5184,41 +5204,41 @@ const MediaManagerModal$1 = MediaManagerModal, ImagePickerField = ({ value: o, o
|
|
|
5184
5204
|
const E = await l(u, m);
|
|
5185
5205
|
b(E);
|
|
5186
5206
|
}
|
|
5187
|
-
c(!1),
|
|
5207
|
+
c(!1), y(-1);
|
|
5188
5208
|
},
|
|
5189
5209
|
[u],
|
|
5190
5210
|
300
|
|
5191
|
-
),
|
|
5211
|
+
), C = (m) => {
|
|
5192
5212
|
const E = ["collection", u, m.id];
|
|
5193
|
-
E[1] && (n(E.join(":")), g(m.name), p(!1), b([]),
|
|
5194
|
-
},
|
|
5213
|
+
E[1] && (n(E.join(":")), g(m.name), p(!1), b([]), y(-1));
|
|
5214
|
+
}, v = (m) => {
|
|
5195
5215
|
switch (m.key) {
|
|
5196
5216
|
case "ArrowDown":
|
|
5197
|
-
m.preventDefault(),
|
|
5217
|
+
m.preventDefault(), y((E) => E < j.length - 1 ? E + 1 : E);
|
|
5198
5218
|
break;
|
|
5199
5219
|
case "ArrowUp":
|
|
5200
|
-
m.preventDefault(),
|
|
5220
|
+
m.preventDefault(), y((E) => E > 0 ? E - 1 : E);
|
|
5201
5221
|
break;
|
|
5202
5222
|
case "Enter":
|
|
5203
|
-
if (m.preventDefault(),
|
|
5223
|
+
if (m.preventDefault(), j.length === 0)
|
|
5204
5224
|
return;
|
|
5205
|
-
h >= 0 &&
|
|
5225
|
+
h >= 0 && C(j[h]);
|
|
5206
5226
|
break;
|
|
5207
5227
|
case "Escape":
|
|
5208
|
-
m.preventDefault(),
|
|
5228
|
+
m.preventDefault(), _();
|
|
5209
5229
|
break;
|
|
5210
5230
|
}
|
|
5211
5231
|
};
|
|
5212
5232
|
useEffect(() => {
|
|
5213
|
-
if (h >= 0 &&
|
|
5214
|
-
const m =
|
|
5233
|
+
if (h >= 0 && S.current) {
|
|
5234
|
+
const m = S.current.children[h];
|
|
5215
5235
|
m == null || m.scrollIntoView({ block: "nearest" });
|
|
5216
5236
|
}
|
|
5217
5237
|
}, [h]);
|
|
5218
|
-
const
|
|
5219
|
-
g(""), b([]),
|
|
5220
|
-
},
|
|
5221
|
-
g(m), p(!isEmpty(m)), c(!0),
|
|
5238
|
+
const _ = () => {
|
|
5239
|
+
g(""), b([]), y(-1), p(!1), n("");
|
|
5240
|
+
}, I = (m) => {
|
|
5241
|
+
g(m), p(!isEmpty(m)), c(!0), A(m);
|
|
5222
5242
|
};
|
|
5223
5243
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
|
|
5224
5244
|
/* @__PURE__ */ jsxRuntimeExports.jsx("select", { name: "collection", value: u, onChange: (m) => x(m.target.value), children: map(r, (m) => /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: m.key, children: m.name }, m.key)) }),
|
|
@@ -5228,26 +5248,26 @@ const MediaManagerModal$1 = MediaManagerModal, ImagePickerField = ({ value: o, o
|
|
|
5228
5248
|
{
|
|
5229
5249
|
type: "text",
|
|
5230
5250
|
value: f,
|
|
5231
|
-
onChange: (m) =>
|
|
5232
|
-
onKeyDown:
|
|
5233
|
-
placeholder: a(`Search ${
|
|
5251
|
+
onChange: (m) => I(m.target.value),
|
|
5252
|
+
onKeyDown: v,
|
|
5253
|
+
placeholder: a(`Search ${B}`),
|
|
5234
5254
|
className: "w-full rounded-md border border-gray-300 p-2 pr-16"
|
|
5235
5255
|
}
|
|
5236
5256
|
),
|
|
5237
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children: f && /* @__PURE__ */ jsxRuntimeExports.jsx("button", { onClick:
|
|
5257
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children: f && /* @__PURE__ */ jsxRuntimeExports.jsx("button", { onClick: _, className: "text-gray-400 hover:text-gray-600", title: a("Clear search"), children: /* @__PURE__ */ jsxRuntimeExports.jsx(X, { className: "h-4 w-4" }) }) })
|
|
5238
5258
|
] }),
|
|
5239
|
-
(i || !isEmpty(
|
|
5259
|
+
(i || !isEmpty(j) || d && isEmpty(j)) && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "absolute z-40 mt-2 max-h-40 w-full overflow-y-auto rounded-md border border-border bg-background shadow-lg", children: i ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-1 p-2", children: [
|
|
5240
5260
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" }),
|
|
5241
5261
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" })
|
|
5242
|
-
] }) : d && isEmpty(
|
|
5262
|
+
] }) : d && isEmpty(j) ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-center p-4 text-sm text-gray-500", children: [
|
|
5243
5263
|
a("No results found for"),
|
|
5244
5264
|
' "',
|
|
5245
5265
|
f,
|
|
5246
5266
|
'"'
|
|
5247
|
-
] }) : /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { ref:
|
|
5267
|
+
] }) : /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { ref: S, children: map(j == null ? void 0 : j.slice(0, 20), (m, E) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
5248
5268
|
"li",
|
|
5249
5269
|
{
|
|
5250
|
-
onClick: () =>
|
|
5270
|
+
onClick: () => C(m),
|
|
5251
5271
|
className: `cursor-pointer p-2 text-xs ${o != null && o.includes(m.id) ? "bg-blue-200" : E === h ? "bg-gray-100" : "hover:bg-gray-100"}`,
|
|
5252
5272
|
children: [
|
|
5253
5273
|
m.name,
|
|
@@ -5345,27 +5365,27 @@ const MediaManagerModal$1 = MediaManagerModal, ImagePickerField = ({ value: o, o
|
|
|
5345
5365
|
required: p,
|
|
5346
5366
|
schema: u
|
|
5347
5367
|
}) => {
|
|
5348
|
-
const { selectedLang: x, fallbackLang: f, languages: g } = useLanguages(),
|
|
5368
|
+
const { selectedLang: x, fallbackLang: f, languages: g } = useLanguages(), j = isEmpty(g) ? "" : isEmpty(x) ? f : x, b = get(LANGUAGES, j, j), h = useSelectedBlock(), y = useRegisteredChaiBlocks(), S = get(y, [h == null ? void 0 : h._type, "i18nProps"], []) || [], [B, A] = useState(null);
|
|
5349
5369
|
if (d)
|
|
5350
5370
|
return null;
|
|
5351
5371
|
if (u.type === "boolean")
|
|
5352
5372
|
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: r, children: a });
|
|
5353
|
-
const
|
|
5373
|
+
const v = S == null ? void 0 : S.includes(o.replace("root.", ""));
|
|
5354
5374
|
return u.type === "array" ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: `${r} relative`, children: [
|
|
5355
5375
|
u.title && /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
5356
5376
|
"label",
|
|
5357
5377
|
{
|
|
5358
5378
|
htmlFor: o,
|
|
5359
|
-
onClick: () =>
|
|
5379
|
+
onClick: () => A(B ? null : o),
|
|
5360
5380
|
className: "flex cursor-pointer items-center gap-x-1 py-1 leading-tight duration-200 hover:bg-slate-100",
|
|
5361
5381
|
children: [
|
|
5362
|
-
|
|
5382
|
+
B ? /* @__PURE__ */ jsxRuntimeExports.jsx(ChevronDown, { className: "h-3 w-3" }) : /* @__PURE__ */ jsxRuntimeExports.jsx(ChevronRight, { className: "h-3 w-3" }),
|
|
5363
5383
|
/* @__PURE__ */ jsxRuntimeExports.jsx(List, { className: "h-3 w-3" }),
|
|
5364
5384
|
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "leading-tight", children: n })
|
|
5365
5385
|
]
|
|
5366
5386
|
}
|
|
5367
5387
|
),
|
|
5368
|
-
|
|
5388
|
+
B && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "p-2", children: [
|
|
5369
5389
|
c,
|
|
5370
5390
|
a,
|
|
5371
5391
|
l,
|
|
@@ -5375,7 +5395,7 @@ const MediaManagerModal$1 = MediaManagerModal, ImagePickerField = ({ value: o, o
|
|
|
5375
5395
|
u.title && /* @__PURE__ */ jsxRuntimeExports.jsxs("label", { htmlFor: o, className: u.type === "object" ? "pb-2" : "", children: [
|
|
5376
5396
|
n,
|
|
5377
5397
|
" ",
|
|
5378
|
-
|
|
5398
|
+
v && /* @__PURE__ */ jsxRuntimeExports.jsxs("small", { className: "text-[9px] text-zinc-400", children: [
|
|
5379
5399
|
" ",
|
|
5380
5400
|
b
|
|
5381
5401
|
] }),
|
|
@@ -5503,39 +5523,83 @@ const MediaManagerModal$1 = MediaManagerModal, ImagePickerField = ({ value: o, o
|
|
|
5503
5523
|
return set(n, o, r), n;
|
|
5504
5524
|
};
|
|
5505
5525
|
function BlockSettings() {
|
|
5506
|
-
const { selectedLang: o } = useLanguages(), r = useSelectedBlock(), n = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), l = getRegisteredChaiBlock(r == null ? void 0 : r._type), i = formDataWithSelectedLang(r, o, l), [c, d] = useState(i), p = ({ formData:
|
|
5507
|
-
if (
|
|
5508
|
-
const
|
|
5509
|
-
a([r._id], { [
|
|
5526
|
+
const { selectedLang: o } = useLanguages(), r = useSelectedBlock(), n = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), l = getRegisteredChaiBlock(r == null ? void 0 : r._type), i = formDataWithSelectedLang(r, o, l), [c, d] = useState(i), [p, u] = useState(!1), x = useWrapperBlock(), f = getRegisteredChaiBlock(x == null ? void 0 : x._type), g = formDataWithSelectedLang(x, o, f), j = ({ formData: v }, _, I) => {
|
|
5527
|
+
if (_ && (c == null ? void 0 : c._id) === r._id) {
|
|
5528
|
+
const D = _.replace("root.", "");
|
|
5529
|
+
a([r._id], { [D]: get(v, D) }, I);
|
|
5510
5530
|
}
|
|
5511
|
-
},
|
|
5512
|
-
debounce(({ formData:
|
|
5513
|
-
|
|
5531
|
+
}, b = useCallback(
|
|
5532
|
+
debounce(({ formData: v }, _, I) => {
|
|
5533
|
+
j({ formData: v }, _, I), d(v);
|
|
5514
5534
|
}, 1500),
|
|
5515
5535
|
[r == null ? void 0 : r._id, o]
|
|
5516
|
-
),
|
|
5517
|
-
if (
|
|
5518
|
-
const
|
|
5536
|
+
), h = ({ formData: v }, _) => {
|
|
5537
|
+
if (_) {
|
|
5538
|
+
const I = _.replace("root.", "");
|
|
5519
5539
|
n(
|
|
5520
5540
|
[r._id],
|
|
5521
|
-
convertDotNotationToObject(
|
|
5522
|
-
),
|
|
5541
|
+
convertDotNotationToObject(I, get(v, I.split(".")))
|
|
5542
|
+
), b({ formData: v }, _, { [I]: get(c, I) });
|
|
5543
|
+
}
|
|
5544
|
+
}, y = ({ formData: v }, _) => {
|
|
5545
|
+
if (_) {
|
|
5546
|
+
const I = _.replace("root.", "");
|
|
5547
|
+
n(
|
|
5548
|
+
[x._id],
|
|
5549
|
+
convertDotNotationToObject(I, get(v, I.split(".")))
|
|
5550
|
+
), b({ formData: v }, _, { [I]: get(c, I) });
|
|
5523
5551
|
}
|
|
5524
5552
|
};
|
|
5525
5553
|
keys(get(i, "_bindings", {}));
|
|
5526
|
-
const { schema:
|
|
5527
|
-
const
|
|
5528
|
-
|
|
5529
|
-
|
|
5554
|
+
const { schema: S, uiSchema: B } = useMemo(() => {
|
|
5555
|
+
const v = r == null ? void 0 : r._type;
|
|
5556
|
+
if (v)
|
|
5557
|
+
return getBlockFormSchemas(v);
|
|
5558
|
+
}, [r]), { wrapperSchema: A, wrapperUiSchema: C } = useMemo(() => {
|
|
5559
|
+
if (!x || !(x != null && x._type))
|
|
5560
|
+
return { wrapperSchema: {}, wrapperUiSchema: {} };
|
|
5561
|
+
const v = x == null ? void 0 : x._type, { schema: _ = {}, uiSchema: I = {} } = getBlockFormSchemas(v);
|
|
5562
|
+
return { wrapperSchema: _, wrapperUiSchema: I };
|
|
5563
|
+
}, [x]);
|
|
5530
5564
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "overflow-x-hidden px-px", children: [
|
|
5531
|
-
isEmpty(
|
|
5565
|
+
!isEmpty(x) && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mb-4 rounded border bg-zinc-100 px-1", children: [
|
|
5566
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
5567
|
+
"div",
|
|
5568
|
+
{
|
|
5569
|
+
onClick: () => u((v) => !v),
|
|
5570
|
+
className: "flex cursor-pointer items-center gap-x-1 py-2 text-xs font-medium leading-tight hover:bg-slate-100",
|
|
5571
|
+
children: [
|
|
5572
|
+
p ? /* @__PURE__ */ jsxRuntimeExports.jsx(ChevronDown, { className: "h-4 w-4 stroke-[3] text-slate-400" }) : /* @__PURE__ */ jsxRuntimeExports.jsx(ChevronRight, { className: "h-4 w-4 stroke-[3] text-slate-400" }),
|
|
5573
|
+
startCase(x._type),
|
|
5574
|
+
" settings",
|
|
5575
|
+
" ",
|
|
5576
|
+
x._name && /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "text-[11px] font-light text-slate-400", children: [
|
|
5577
|
+
"(",
|
|
5578
|
+
x._name,
|
|
5579
|
+
")"
|
|
5580
|
+
] })
|
|
5581
|
+
]
|
|
5582
|
+
}
|
|
5583
|
+
),
|
|
5584
|
+
p && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
5585
|
+
JSONForm,
|
|
5586
|
+
{
|
|
5587
|
+
id: x == null ? void 0 : x._id,
|
|
5588
|
+
onChange: y,
|
|
5589
|
+
formData: g,
|
|
5590
|
+
schema: A,
|
|
5591
|
+
uiSchema: C
|
|
5592
|
+
}
|
|
5593
|
+
)
|
|
5594
|
+
] }),
|
|
5595
|
+
isEmpty(S) ? null : /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
5532
5596
|
JSONForm,
|
|
5533
5597
|
{
|
|
5534
5598
|
id: r == null ? void 0 : r._id,
|
|
5535
|
-
onChange:
|
|
5599
|
+
onChange: h,
|
|
5536
5600
|
formData: i,
|
|
5537
|
-
schema:
|
|
5538
|
-
uiSchema:
|
|
5601
|
+
schema: S,
|
|
5602
|
+
uiSchema: B
|
|
5539
5603
|
}
|
|
5540
5604
|
),
|
|
5541
5605
|
(r == null ? void 0 : r._type) === "GlobalBlock" ? /* @__PURE__ */ jsxRuntimeExports.jsx(GlobalBlockSettings, {}) : null,
|
|
@@ -5613,8 +5677,8 @@ const AskAIStyles = ({ blockId: o }) => {
|
|
|
5613
5677
|
(g = d.current) == null || g.focus();
|
|
5614
5678
|
}, []);
|
|
5615
5679
|
const f = (g) => {
|
|
5616
|
-
const { usage:
|
|
5617
|
-
!l &&
|
|
5680
|
+
const { usage: j } = g || {};
|
|
5681
|
+
!l && j && x(j), p.current = setTimeout(() => x(void 0), 1e4), l || c("");
|
|
5618
5682
|
};
|
|
5619
5683
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "", children: [
|
|
5620
5684
|
/* @__PURE__ */ jsxRuntimeExports.jsx("h2", { className: "mb-1 text-sm font-semibold leading-none tracking-tight", children: r("Ask AI") }),
|
|
@@ -5669,37 +5733,37 @@ const AskAIStyles = ({ blockId: o }) => {
|
|
|
5669
5733
|
] });
|
|
5670
5734
|
};
|
|
5671
5735
|
function ManualClasses() {
|
|
5672
|
-
var
|
|
5673
|
-
const o = useFuseSearch(), { t: r } = useTranslation(), [n] = useSelectedStylingBlocks(), a = useSelectedBlock(), l = useAddClassesToBlocks(), i = useRemoveClassesFromBlocks(), [c] = useSelectedBlockIds(), d = useBuilderProp("askAiCallBack", null), [p, u] = useState(""), { toast: x } = useToast(), f = (
|
|
5674
|
-
const
|
|
5675
|
-
l(c,
|
|
5676
|
-
}, [b, h] = useState([]),
|
|
5677
|
-
const
|
|
5736
|
+
var _;
|
|
5737
|
+
const o = useFuseSearch(), { t: r } = useTranslation(), [n] = useSelectedStylingBlocks(), a = useSelectedBlock(), l = useAddClassesToBlocks(), i = useRemoveClassesFromBlocks(), [c] = useSelectedBlockIds(), d = useBuilderProp("askAiCallBack", null), [p, u] = useState(""), { toast: x } = useToast(), f = (_ = first(n)) == null ? void 0 : _.prop, g = reject((get(a, f, "").replace(STYLES_KEY, "").split(",").pop() || "").split(" "), isEmpty), j = () => {
|
|
5738
|
+
const I = p.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
|
|
5739
|
+
l(c, I, !0), u("");
|
|
5740
|
+
}, [b, h] = useState([]), y = ({ value: I }) => {
|
|
5741
|
+
const D = I.trim().toLowerCase(), m = D.match(/.+:/g);
|
|
5678
5742
|
let E = [];
|
|
5679
5743
|
if (m && m.length > 0) {
|
|
5680
|
-
const [
|
|
5681
|
-
E = o.search(
|
|
5744
|
+
const [R] = m, w = D.replace(R, "");
|
|
5745
|
+
E = o.search(w).map((k) => ({
|
|
5682
5746
|
...k,
|
|
5683
|
-
item: { ...k.item, name:
|
|
5747
|
+
item: { ...k.item, name: R + k.item.name }
|
|
5684
5748
|
}));
|
|
5685
5749
|
} else
|
|
5686
|
-
E = o.search(
|
|
5750
|
+
E = o.search(D);
|
|
5687
5751
|
return h(map(E, "item"));
|
|
5688
|
-
},
|
|
5752
|
+
}, S = () => {
|
|
5689
5753
|
h([]);
|
|
5690
|
-
},
|
|
5754
|
+
}, B = (I) => I.name, A = (I) => /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "rounded-md p-1", children: I.name }), C = {
|
|
5691
5755
|
autoComplete: "off",
|
|
5692
5756
|
autoCorrect: "off",
|
|
5693
5757
|
autoCapitalize: "off",
|
|
5694
5758
|
spellCheck: !1,
|
|
5695
5759
|
placeholder: r("Enter classes separated by space"),
|
|
5696
5760
|
value: p,
|
|
5697
|
-
onKeyDown: (
|
|
5698
|
-
|
|
5761
|
+
onKeyDown: (I) => {
|
|
5762
|
+
I.key === "Enter" && p.trim() !== "" && j();
|
|
5699
5763
|
},
|
|
5700
|
-
onChange: (
|
|
5764
|
+
onChange: (I, { newValue: D }) => u(D),
|
|
5701
5765
|
className: "w-full rounded-md text-xs px-2 hover:outline-0 bg-background border-border py-1"
|
|
5702
|
-
},
|
|
5766
|
+
}, v = () => {
|
|
5703
5767
|
if (navigator.clipboard === void 0) {
|
|
5704
5768
|
x({
|
|
5705
5769
|
title: r("Clipboard not supported"),
|
|
@@ -5722,7 +5786,7 @@ function ManualClasses() {
|
|
|
5722
5786
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-x-2 text-muted-foreground", children: [
|
|
5723
5787
|
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: r("Classes") }),
|
|
5724
5788
|
/* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
|
|
5725
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxRuntimeExports.jsx(CopyIcon, { onClick:
|
|
5789
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxRuntimeExports.jsx(CopyIcon, { onClick: v, className: "cursor-pointer" }) }),
|
|
5726
5790
|
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { children: r("Copy classes to clipboard") }) })
|
|
5727
5791
|
] })
|
|
5728
5792
|
] }),
|
|
@@ -5739,11 +5803,11 @@ function ManualClasses() {
|
|
|
5739
5803
|
Autosuggest,
|
|
5740
5804
|
{
|
|
5741
5805
|
suggestions: b,
|
|
5742
|
-
onSuggestionsFetchRequested:
|
|
5743
|
-
onSuggestionsClearRequested:
|
|
5744
|
-
getSuggestionValue:
|
|
5745
|
-
renderSuggestion:
|
|
5746
|
-
inputProps:
|
|
5806
|
+
onSuggestionsFetchRequested: y,
|
|
5807
|
+
onSuggestionsClearRequested: S,
|
|
5808
|
+
getSuggestionValue: B,
|
|
5809
|
+
renderSuggestion: A,
|
|
5810
|
+
inputProps: C,
|
|
5747
5811
|
containerProps: {
|
|
5748
5812
|
className: "relative h-8 w-full gap-y-1 py-1 border-border text-xs"
|
|
5749
5813
|
},
|
|
@@ -5759,7 +5823,7 @@ function ManualClasses() {
|
|
|
5759
5823
|
{
|
|
5760
5824
|
variant: "outline",
|
|
5761
5825
|
className: "h-6 border-border",
|
|
5762
|
-
onClick:
|
|
5826
|
+
onClick: j,
|
|
5763
5827
|
disabled: p.trim() === "",
|
|
5764
5828
|
size: "sm",
|
|
5765
5829
|
children: /* @__PURE__ */ jsxRuntimeExports.jsx(PlusIcon, {})
|
|
@@ -5767,22 +5831,22 @@ function ManualClasses() {
|
|
|
5767
5831
|
)
|
|
5768
5832
|
] }),
|
|
5769
5833
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex w-full flex-wrap gap-2 overflow-x-hidden", children: React.Children.toArray(
|
|
5770
|
-
g.map((
|
|
5834
|
+
g.map((I) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
5771
5835
|
"div",
|
|
5772
5836
|
{
|
|
5773
5837
|
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",
|
|
5774
5838
|
children: [
|
|
5775
|
-
|
|
5839
|
+
I,
|
|
5776
5840
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
5777
5841
|
Cross2Icon,
|
|
5778
5842
|
{
|
|
5779
|
-
onClick: () => i(c, [
|
|
5843
|
+
onClick: () => i(c, [I]),
|
|
5780
5844
|
className: "invisible absolute right-1 rounded-full bg-red-400 hover:text-white group-hover:visible group-hover:cursor-pointer"
|
|
5781
5845
|
}
|
|
5782
5846
|
)
|
|
5783
5847
|
]
|
|
5784
5848
|
},
|
|
5785
|
-
|
|
5849
|
+
I
|
|
5786
5850
|
))
|
|
5787
5851
|
) })
|
|
5788
5852
|
]
|
|
@@ -6176,7 +6240,7 @@ const RangeChoices = ({ property: o, onChange: r }) => {
|
|
|
6176
6240
|
const n = useCurrentClassByProperty(o), a = useMemo(() => get(n, "cls", ""), [n]), { canChange: l } = useContext(StyleContext), [i, c] = useState([]), [d, p] = useState({ color: "", shade: "" }), u = a.split("-"), x = get(u, "1", ""), f = get(u, "2", ""), g = useCallback(
|
|
6177
6241
|
// eslint-disable-next-line no-shadow
|
|
6178
6242
|
(h) => {
|
|
6179
|
-
["current", "inherit", "transparent", "black", "white"].includes(h) ? (c([]), p({ color: h })) : (c(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]), p((
|
|
6243
|
+
["current", "inherit", "transparent", "black", "white"].includes(h) ? (c([]), p({ color: h })) : (c(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]), p((y) => ({ ...y, color: h, shade: y.shade ? y.shade : "500" })));
|
|
6180
6244
|
},
|
|
6181
6245
|
[c, p]
|
|
6182
6246
|
);
|
|
@@ -6185,7 +6249,7 @@ const RangeChoices = ({ property: o, onChange: r }) => {
|
|
|
6185
6249
|
return c([]);
|
|
6186
6250
|
c(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]);
|
|
6187
6251
|
}, [x]);
|
|
6188
|
-
const
|
|
6252
|
+
const j = useCallback(
|
|
6189
6253
|
// eslint-disable-next-line no-shadow
|
|
6190
6254
|
(h) => {
|
|
6191
6255
|
p({ color: x, shade: h });
|
|
@@ -6197,8 +6261,8 @@ const RangeChoices = ({ property: o, onChange: r }) => {
|
|
|
6197
6261
|
}, [n]);
|
|
6198
6262
|
const { match: b } = useTailwindClassList();
|
|
6199
6263
|
return useEffect(() => {
|
|
6200
|
-
const
|
|
6201
|
-
b(o,
|
|
6264
|
+
const y = `${get(COLOR_PROP, o, "")}-${d.color}${d.shade ? `-${d.shade}` : ""}`;
|
|
6265
|
+
b(o, y) && r(y, o);
|
|
6202
6266
|
}, [b, d, r, o]), /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-row divide-x divide-solid divide-border rounded-lg border border-transparent text-xs", children: [
|
|
6203
6267
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "grow text-center", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
6204
6268
|
DropDown,
|
|
@@ -6239,7 +6303,7 @@ const RangeChoices = ({ property: o, onChange: r }) => {
|
|
|
6239
6303
|
]
|
|
6240
6304
|
}
|
|
6241
6305
|
) }),
|
|
6242
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("button", { type: "button", className: "grow text-center", children: /* @__PURE__ */ jsxRuntimeExports.jsx(DropDown, { rounded: !0, selected: f, disabled: !x || !l, onChange:
|
|
6306
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("button", { type: "button", className: "grow text-center", children: /* @__PURE__ */ jsxRuntimeExports.jsx(DropDown, { rounded: !0, selected: f, disabled: !x || !l, onChange: j, options: i }) })
|
|
6243
6307
|
] });
|
|
6244
6308
|
}, getUserInputValues = (o, r) => {
|
|
6245
6309
|
o = o.toLowerCase();
|
|
@@ -6434,7 +6498,7 @@ const RangeChoices = ({ property: o, onChange: r }) => {
|
|
|
6434
6498
|
},
|
|
6435
6499
|
a
|
|
6436
6500
|
)) }), THROTTLE_TIME = 50, AdvanceChoices = (o) => {
|
|
6437
|
-
const [r, n] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: x } = o, [f, g] = useState(p != null && p.toLowerCase().includes("width") ? "%" : u[0]), [
|
|
6501
|
+
const [r, n] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: x } = o, [f, g] = useState(p != null && p.toLowerCase().includes("width") ? "%" : u[0]), [j, b] = useState(!1), [h, y] = useState(""), [S, B] = useState(!1), [A, C] = useState(!1);
|
|
6438
6502
|
useEffect(() => {
|
|
6439
6503
|
const { value: m, unit: E } = getClassValueAndUnit(i);
|
|
6440
6504
|
if (E === "") {
|
|
@@ -6443,25 +6507,25 @@ const RangeChoices = ({ property: o, onChange: r }) => {
|
|
|
6443
6507
|
}
|
|
6444
6508
|
g(E), l(E === "class" || isEmpty(m) ? "" : m);
|
|
6445
6509
|
}, [i, p, u]);
|
|
6446
|
-
const
|
|
6510
|
+
const v = useThrottledCallback((m) => c(m), [c], THROTTLE_TIME), _ = useThrottledCallback((m) => c(m, !1), [c], THROTTLE_TIME), I = useCallback(
|
|
6447
6511
|
(m = !1) => {
|
|
6448
6512
|
const E = getUserInputValues(`${a}`, u);
|
|
6449
6513
|
if (get(E, "error", !1)) {
|
|
6450
6514
|
b(!0);
|
|
6451
6515
|
return;
|
|
6452
6516
|
}
|
|
6453
|
-
const
|
|
6454
|
-
if (
|
|
6455
|
-
|
|
6517
|
+
const R = get(E, "unit") !== "" ? get(E, "unit") : f;
|
|
6518
|
+
if (R === "auto" || R === "none") {
|
|
6519
|
+
v(`${d}${R}`);
|
|
6456
6520
|
return;
|
|
6457
6521
|
}
|
|
6458
6522
|
if (get(E, "value") === "")
|
|
6459
6523
|
return;
|
|
6460
|
-
const
|
|
6461
|
-
m ?
|
|
6524
|
+
const T = `${get(E, "value", "").startsWith("-") ? "-" : ""}${d}[${get(E, "value", "").replace("-", "")}${R === "-" ? "" : R}]`;
|
|
6525
|
+
m ? _(T) : v(T);
|
|
6462
6526
|
},
|
|
6463
|
-
[
|
|
6464
|
-
),
|
|
6527
|
+
[v, _, a, f, d, u]
|
|
6528
|
+
), D = useCallback(
|
|
6465
6529
|
(m) => {
|
|
6466
6530
|
const E = getUserInputValues(`${a}`, u);
|
|
6467
6531
|
if (get(E, "error", !1)) {
|
|
@@ -6469,15 +6533,15 @@ const RangeChoices = ({ property: o, onChange: r }) => {
|
|
|
6469
6533
|
return;
|
|
6470
6534
|
}
|
|
6471
6535
|
if (m === "auto" || m === "none") {
|
|
6472
|
-
|
|
6536
|
+
v(`${d}${m}`);
|
|
6473
6537
|
return;
|
|
6474
6538
|
}
|
|
6475
6539
|
if (get(E, "value") === "")
|
|
6476
6540
|
return;
|
|
6477
|
-
const
|
|
6478
|
-
|
|
6541
|
+
const R = get(E, "unit") !== "" ? get(E, "unit") : m, T = `${get(E, "value", "").startsWith("-") ? "-" : ""}${d}[${get(E, "value", "").replace("-", "")}${R === "-" ? "" : R}]`;
|
|
6542
|
+
v(T);
|
|
6479
6543
|
},
|
|
6480
|
-
[
|
|
6544
|
+
[v, a, d, u]
|
|
6481
6545
|
);
|
|
6482
6546
|
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex w-full flex-col", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-start", children: f === "class" ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
6483
6547
|
/* @__PURE__ */ jsxRuntimeExports.jsx("input", { className: "w-20 rounded py-1", readOnly: !0, value: i }),
|
|
@@ -6485,29 +6549,29 @@ const RangeChoices = ({ property: o, onChange: r }) => {
|
|
|
6485
6549
|
/* @__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, {}) }) }),
|
|
6486
6550
|
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { children: "Current value is using a Tailwind preset class." })
|
|
6487
6551
|
] })
|
|
6488
|
-
] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: `group relative flex items-center ${
|
|
6552
|
+
] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: `group relative flex items-center ${S ? "z-auto" : ""}`, children: [
|
|
6489
6553
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center rounded-md border border-border", children: [
|
|
6490
6554
|
["none", "auto"].indexOf(f) !== -1 ? null : /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
6491
6555
|
"input",
|
|
6492
6556
|
{
|
|
6493
6557
|
readOnly: f === "class",
|
|
6494
6558
|
onKeyPress: (m) => {
|
|
6495
|
-
m.key === "Enter" &&
|
|
6559
|
+
m.key === "Enter" && I();
|
|
6496
6560
|
},
|
|
6497
6561
|
onKeyDown: (m) => {
|
|
6498
6562
|
if (m.keyCode !== 38 && m.keyCode !== 40)
|
|
6499
6563
|
return;
|
|
6500
|
-
m.preventDefault(),
|
|
6564
|
+
m.preventDefault(), C(!0);
|
|
6501
6565
|
const E = parseInt$1(m.target.value);
|
|
6502
|
-
let
|
|
6503
|
-
m.keyCode === 38 && (
|
|
6504
|
-
const
|
|
6505
|
-
|
|
6566
|
+
let R = isNaN$1(E) ? 0 : E;
|
|
6567
|
+
m.keyCode === 38 && (R += 1), m.keyCode === 40 && (R -= 1);
|
|
6568
|
+
const w = `${R}`, k = `${w.startsWith("-") ? "-" : ""}${d}[${w.replace("-", "")}${f === "-" ? "" : f}]`;
|
|
6569
|
+
_(k);
|
|
6506
6570
|
},
|
|
6507
6571
|
onKeyUp: (m) => {
|
|
6508
|
-
|
|
6572
|
+
A && (m.preventDefault(), C(!1));
|
|
6509
6573
|
},
|
|
6510
|
-
onBlur: () =>
|
|
6574
|
+
onBlur: () => I(),
|
|
6511
6575
|
onChange: (m) => {
|
|
6512
6576
|
b(!1), l(m.target.value);
|
|
6513
6577
|
},
|
|
@@ -6515,10 +6579,10 @@ const RangeChoices = ({ property: o, onChange: r }) => {
|
|
|
6515
6579
|
var E;
|
|
6516
6580
|
(E = m == null ? void 0 : m.target) == null || E.select(), n(!1);
|
|
6517
6581
|
},
|
|
6518
|
-
value:
|
|
6582
|
+
value: S ? h : a,
|
|
6519
6583
|
className: "h-6 w-14 rounded rounded-r-none border border-transparent bg-background pl-2 text-sm focus-visible:outline-0".concat(
|
|
6520
6584
|
" ",
|
|
6521
|
-
|
|
6585
|
+
j ? "border-red-500 text-red-500" : "border-foreground/20"
|
|
6522
6586
|
)
|
|
6523
6587
|
}
|
|
6524
6588
|
),
|
|
@@ -6541,28 +6605,28 @@ const RangeChoices = ({ property: o, onChange: r }) => {
|
|
|
6541
6605
|
units: u,
|
|
6542
6606
|
current: f,
|
|
6543
6607
|
onSelect: (m) => {
|
|
6544
|
-
n(!1), g(m),
|
|
6608
|
+
n(!1), g(m), D(m);
|
|
6545
6609
|
}
|
|
6546
6610
|
}
|
|
6547
6611
|
) }) })
|
|
6548
6612
|
] })
|
|
6549
6613
|
] }),
|
|
6550
|
-
["none", "auto"].indexOf(f) !== -1 ||
|
|
6614
|
+
["none", "auto"].indexOf(f) !== -1 || S ? null : /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
6551
6615
|
DragStyleButton,
|
|
6552
6616
|
{
|
|
6553
|
-
onDragStart: () =>
|
|
6617
|
+
onDragStart: () => B(!0),
|
|
6554
6618
|
onDragEnd: (m) => {
|
|
6555
|
-
if (
|
|
6619
|
+
if (y(() => ""), B(!1), isEmpty(m))
|
|
6556
6620
|
return;
|
|
6557
|
-
const E = `${m}`,
|
|
6558
|
-
|
|
6621
|
+
const E = `${m}`, w = `${E.startsWith("-") ? "-" : ""}${d}[${E.replace("-", "")}${f === "-" ? "" : f}]`;
|
|
6622
|
+
v(w);
|
|
6559
6623
|
},
|
|
6560
6624
|
onDrag: (m) => {
|
|
6561
6625
|
if (isEmpty(m))
|
|
6562
6626
|
return;
|
|
6563
|
-
|
|
6564
|
-
const E = `${m}`,
|
|
6565
|
-
|
|
6627
|
+
y(m);
|
|
6628
|
+
const E = `${m}`, w = `${E.startsWith("-") ? "-" : ""}${d}[${E.replace("-", "")}${f === "-" ? "" : f}]`;
|
|
6629
|
+
_(w);
|
|
6566
6630
|
},
|
|
6567
6631
|
currentValue: a,
|
|
6568
6632
|
unit: f,
|
|
@@ -6659,35 +6723,35 @@ const RangeChoices = ({ property: o, onChange: r }) => {
|
|
|
6659
6723
|
"2xl": "1536px"
|
|
6660
6724
|
}, getBreakpoint = (o) => `${o.toUpperCase()} ${BREAKPOINTS[o] ? `(${BREAKPOINTS[o]} & up)` : ""}`, BlockStyle = (o) => {
|
|
6661
6725
|
const { t: r } = useTranslation(), { type: n = "icons", label: a, property: l, onEmitChange: i = () => {
|
|
6662
|
-
}, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, x] = useCanvasWidth(), f = useCurrentClassByProperty(l), g = useAddClassesToBlocks(),
|
|
6663
|
-
(
|
|
6664
|
-
const
|
|
6665
|
-
(p || u !== "") && (
|
|
6666
|
-
const m = generateFullClsName(
|
|
6667
|
-
g(b, [m],
|
|
6726
|
+
}, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, x] = useCanvasWidth(), f = useCurrentClassByProperty(l), g = useAddClassesToBlocks(), j = useRemoveClassesFromBlocks(), [b] = useSelectedBlockIds(), h = useMemo(() => get(f, "fullCls", ""), [f]), y = useCallback(
|
|
6727
|
+
(_, I = !0) => {
|
|
6728
|
+
const D = { dark: p, mq: x, mod: u, cls: _, property: l, fullCls: "" };
|
|
6729
|
+
(p || u !== "") && (D.mq = "xs");
|
|
6730
|
+
const m = generateFullClsName(D);
|
|
6731
|
+
g(b, [m], I);
|
|
6668
6732
|
},
|
|
6669
6733
|
[b, p, x, u, l, g]
|
|
6670
|
-
),
|
|
6671
|
-
|
|
6672
|
-
}, [b, h,
|
|
6734
|
+
), S = useCallback(() => {
|
|
6735
|
+
j(b, [h]);
|
|
6736
|
+
}, [b, h, j]), B = useMemo(() => canChangeClass(f, x), [f, x]);
|
|
6673
6737
|
useEffect(() => {
|
|
6674
|
-
i(
|
|
6675
|
-
}, [
|
|
6676
|
-
const [, ,
|
|
6677
|
-
(
|
|
6678
|
-
|
|
6738
|
+
i(B, f);
|
|
6739
|
+
}, [B, i, f]);
|
|
6740
|
+
const [, , A] = useCanvasWidth(), C = useCallback(
|
|
6741
|
+
(_) => {
|
|
6742
|
+
A({
|
|
6679
6743
|
xs: 400,
|
|
6680
6744
|
sm: 640,
|
|
6681
6745
|
md: 800,
|
|
6682
6746
|
lg: 1024,
|
|
6683
6747
|
xl: 1420,
|
|
6684
6748
|
"2xl": 1920
|
|
6685
|
-
}[
|
|
6749
|
+
}[_]);
|
|
6686
6750
|
},
|
|
6687
|
-
[
|
|
6688
|
-
),
|
|
6689
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(BlockStyleProvider, { canChange:
|
|
6690
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: `text-[11px] ${f && !
|
|
6751
|
+
[A]
|
|
6752
|
+
), v = get(f, "dark", null) === p && get(f, "mod", null) === u && get(f, "mq", null) === x;
|
|
6753
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(BlockStyleProvider, { canChange: B, canReset: f && v, children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "group flex flex-row items-center py-2 first:pt-0 last:pb-0", children: [
|
|
6754
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: `text-[11px] ${f && !v ? "text-foreground" : ""}`, children: r(a) }) }),
|
|
6691
6755
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-row items-center", children: [
|
|
6692
6756
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "w-[150px]", children: [
|
|
6693
6757
|
n === "arbitrary" ? /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
@@ -6696,17 +6760,17 @@ const RangeChoices = ({ property: o, onChange: r }) => {
|
|
|
6696
6760
|
currentClass: get(f, "cls", ""),
|
|
6697
6761
|
classPrefix: get(CLASS_PREFIXES, l, ""),
|
|
6698
6762
|
units: c || [],
|
|
6699
|
-
onChange:
|
|
6763
|
+
onChange: y,
|
|
6700
6764
|
negative: d,
|
|
6701
6765
|
cssProperty: l
|
|
6702
6766
|
}
|
|
6703
6767
|
) : null,
|
|
6704
|
-
n === "icons" && /* @__PURE__ */ jsxRuntimeExports.jsx(IconChoices, { property: l, onChange:
|
|
6705
|
-
n === "range" && /* @__PURE__ */ jsxRuntimeExports.jsx(RangeChoices, { property: l, onChange:
|
|
6706
|
-
n === "color" && /* @__PURE__ */ jsxRuntimeExports.jsx(ColorChoice, { property: l, onChange:
|
|
6707
|
-
n === "dropdown" && /* @__PURE__ */ jsxRuntimeExports.jsx(DropDownChoices, { label: a, property: l, onChange:
|
|
6768
|
+
n === "icons" && /* @__PURE__ */ jsxRuntimeExports.jsx(IconChoices, { property: l, onChange: y }),
|
|
6769
|
+
n === "range" && /* @__PURE__ */ jsxRuntimeExports.jsx(RangeChoices, { property: l, onChange: y }),
|
|
6770
|
+
n === "color" && /* @__PURE__ */ jsxRuntimeExports.jsx(ColorChoice, { property: l, onChange: y }),
|
|
6771
|
+
n === "dropdown" && /* @__PURE__ */ jsxRuntimeExports.jsx(DropDownChoices, { label: a, property: l, onChange: y })
|
|
6708
6772
|
] }),
|
|
6709
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `w-[30px] cursor-pointer ${h ? "visible" : "invisible"}`, children:
|
|
6773
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `w-[30px] cursor-pointer ${h ? "visible" : "invisible"}`, children: v ? /* @__PURE__ */ jsxRuntimeExports.jsx("button", { type: "button", onClick: () => S(), 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" }) }) : B && f ? /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { delayDuration: 100, children: [
|
|
6710
6774
|
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
6711
6775
|
"button",
|
|
6712
6776
|
{
|
|
@@ -6726,7 +6790,7 @@ const RangeChoices = ({ property: o, onChange: r }) => {
|
|
|
6726
6790
|
"button",
|
|
6727
6791
|
{
|
|
6728
6792
|
type: "button",
|
|
6729
|
-
onClick: () =>
|
|
6793
|
+
onClick: () => C(get(f, "mq")),
|
|
6730
6794
|
className: "block w-full cursor-default text-right font-semibold text-blue-500",
|
|
6731
6795
|
children: [
|
|
6732
6796
|
"Switch to ",
|
|
@@ -6756,18 +6820,18 @@ const RangeChoices = ({ property: o, onChange: r }) => {
|
|
|
6756
6820
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-row text-xs", children: [
|
|
6757
6821
|
o && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "relative w-[70px] flex-none text-xs text-foreground", children: d(o) }),
|
|
6758
6822
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mb-3 flex grow flex-row flex-wrap gap-x-px", children: React__default.Children.toArray(
|
|
6759
|
-
r.map(({ label: g, key:
|
|
6823
|
+
r.map(({ label: g, key: j }) => /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "first:rounded-l last:rounded-r", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
|
|
6760
6824
|
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
6761
6825
|
"button",
|
|
6762
6826
|
{
|
|
6763
6827
|
type: "button",
|
|
6764
|
-
onClick: () => u(
|
|
6765
|
-
className: `relative cursor-pointer rounded-full p-1 text-[8px] ${
|
|
6828
|
+
onClick: () => u(j),
|
|
6829
|
+
className: `relative cursor-pointer rounded-full p-1 text-[8px] ${j === p ? "bg-[#3E57F0] text-white" : "text-gray-600 dark:text-gray-300"}`,
|
|
6766
6830
|
children: [
|
|
6767
6831
|
React__default.createElement("div", {
|
|
6768
|
-
className: f(
|
|
6832
|
+
className: f(j) ? "-bottom-1.5 absolute bg-[#3E57F0] h-[2px] left-0 w-full" : ""
|
|
6769
6833
|
}),
|
|
6770
|
-
React__default.createElement(get(EDITOR_ICONS,
|
|
6834
|
+
React__default.createElement(get(EDITOR_ICONS, j, BoxIcon), { className: "text-inherit w-3 h-3" })
|
|
6771
6835
|
]
|
|
6772
6836
|
}
|
|
6773
6837
|
) }),
|
|
@@ -6915,9 +6979,9 @@ function BlockStyling() {
|
|
|
6915
6979
|
const x = !get(i, "negative", !1), f = get(i, "cssProperty", "");
|
|
6916
6980
|
let g = parseFloat(i.dragStartValue);
|
|
6917
6981
|
g = isNaN(g) ? 0 : g;
|
|
6918
|
-
let
|
|
6919
|
-
(startsWith(f, "scale") || f === "opacity") && (
|
|
6920
|
-
let h = (i.dragStartY - u.pageY) /
|
|
6982
|
+
let j = MAPPER[i.dragUnit];
|
|
6983
|
+
(startsWith(f, "scale") || f === "opacity") && (j = 10);
|
|
6984
|
+
let h = (i.dragStartY - u.pageY) / j + g;
|
|
6921
6985
|
x && h < 0 && (h = 0), f === "opacity" && h > 1 && (h = 1), i.onDrag(`${h}`), l(`${h}`);
|
|
6922
6986
|
},
|
|
6923
6987
|
[i],
|
|
@@ -7006,33 +7070,33 @@ const BlockCard = ({
|
|
|
7006
7070
|
parentId: n = void 0,
|
|
7007
7071
|
position: a = -1
|
|
7008
7072
|
}) => {
|
|
7009
|
-
const [l, i] = useState(!1), c = useBuilderProp("getUILibraryBlock", noop), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: x } = useBlockHighlight(), f = get(o, "name", get(o, "label")), g = useFeature("dnd"), [,
|
|
7010
|
-
const
|
|
7011
|
-
return
|
|
7073
|
+
const [l, i] = useState(!1), c = useBuilderProp("getUILibraryBlock", noop), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: x } = useBlockHighlight(), f = get(o, "name", get(o, "label")), g = useFeature("dnd"), [, j] = useAtom$1(draggedBlockAtom), b = (S) => {
|
|
7074
|
+
const B = has(S, "styles_attrs.data-page-section");
|
|
7075
|
+
return S._type === "Box" && B;
|
|
7012
7076
|
}, h = useCallback(
|
|
7013
|
-
async (
|
|
7014
|
-
if (
|
|
7077
|
+
async (S) => {
|
|
7078
|
+
if (S.stopPropagation(), has(o, "component")) {
|
|
7015
7079
|
d(o, n, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
7016
7080
|
return;
|
|
7017
7081
|
}
|
|
7018
7082
|
i(!0);
|
|
7019
|
-
const
|
|
7020
|
-
isEmpty(
|
|
7083
|
+
const B = await c(r, o);
|
|
7084
|
+
isEmpty(B) || p(syncBlocksWithDefaults(B), n, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
7021
7085
|
},
|
|
7022
7086
|
[d, p, o, c, r, n, a]
|
|
7023
|
-
),
|
|
7024
|
-
const
|
|
7025
|
-
let
|
|
7026
|
-
if (b(first(
|
|
7027
|
-
const
|
|
7028
|
-
if (
|
|
7029
|
-
const
|
|
7030
|
-
|
|
7031
|
-
|
|
7087
|
+
), y = async (S) => {
|
|
7088
|
+
const B = await c(r, o);
|
|
7089
|
+
let A = n;
|
|
7090
|
+
if (b(first(B)) && (A = null), !isEmpty(B)) {
|
|
7091
|
+
const C = { blocks: B, uiLibrary: !0, parent: A };
|
|
7092
|
+
if (S.dataTransfer.setData("text/plain", JSON.stringify(C)), o.preview) {
|
|
7093
|
+
const v = new Image();
|
|
7094
|
+
v.src = o.preview, v.onload = () => {
|
|
7095
|
+
S.dataTransfer.setDragImage(v, 0, 0);
|
|
7032
7096
|
};
|
|
7033
7097
|
} else
|
|
7034
|
-
|
|
7035
|
-
|
|
7098
|
+
S.dataTransfer.setDragImage(new Image(), 0, 0);
|
|
7099
|
+
j(C), setTimeout(() => {
|
|
7036
7100
|
u([]), x(), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
7037
7101
|
}, 200);
|
|
7038
7102
|
}
|
|
@@ -7044,7 +7108,7 @@ const BlockCard = ({
|
|
|
7044
7108
|
onClick: l ? () => {
|
|
7045
7109
|
} : h,
|
|
7046
7110
|
draggable: g ? "true" : "false",
|
|
7047
|
-
onDragStart:
|
|
7111
|
+
onDragStart: y,
|
|
7048
7112
|
className: clsx(
|
|
7049
7113
|
"relative mt-2 cursor-pointer overflow-hidden rounded-md border border-border bg-white duration-200 hover:border-blue-500 hover:shadow-xl"
|
|
7050
7114
|
),
|
|
@@ -7073,9 +7137,9 @@ const BlockCard = ({
|
|
|
7073
7137
|
})();
|
|
7074
7138
|
}, [o, l, i, c, n, a]), { data: l || [], isLoading: i === "loading" };
|
|
7075
7139
|
}, UILibrarySection = ({ parentId: o, position: r }) => {
|
|
7076
|
-
const [n, a] = useAtom$1(selectedLibraryAtom), l = useBuilderProp("uiLibraries", []), i = useRegisteredChaiBlocks(), c = values(i).filter((
|
|
7140
|
+
const [n, a] = useAtom$1(selectedLibraryAtom), l = useBuilderProp("uiLibraries", []), i = useRegisteredChaiBlocks(), c = values(i).filter((A) => A.category === "custom"), d = l.find((A) => A.uuid === n) || first(l), { data: p, isLoading: u } = useLibraryBlocks(d), x = groupBy([...p, ...c], "group"), [f, g] = useState("Hero"), j = get(x, f, []), b = useRef(null), { t: h } = useTranslation(), y = (A) => {
|
|
7077
7141
|
b.current && (clearTimeout(b.current), b.current = null), b.current = setTimeout(() => {
|
|
7078
|
-
b.current && g(
|
|
7142
|
+
b.current && g(A);
|
|
7079
7143
|
}, 300);
|
|
7080
7144
|
};
|
|
7081
7145
|
if (u)
|
|
@@ -7083,7 +7147,7 @@ const BlockCard = ({
|
|
|
7083
7147
|
/* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "col-span-3 h-full" }),
|
|
7084
7148
|
/* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "col-span-9 h-full" })
|
|
7085
7149
|
] });
|
|
7086
|
-
const
|
|
7150
|
+
const S = filter(j, (A, C) => C % 2 === 0), B = filter(j, (A, C) => C % 2 === 1);
|
|
7087
7151
|
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: [
|
|
7088
7152
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex h-full max-h-full w-60 flex-col gap-1 px-1 pr-2", children: [
|
|
7089
7153
|
/* @__PURE__ */ jsxRuntimeExports.jsx(UILibrariesSelect, { library: d == null ? void 0 : d.uuid, setLibrary: a, uiLibraries: l }),
|
|
@@ -7091,22 +7155,22 @@ const BlockCard = ({
|
|
|
7091
7155
|
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-xs font-bold text-gray-500", children: h("Groups") }),
|
|
7092
7156
|
/* @__PURE__ */ jsxRuntimeExports.jsx("hr", { className: "mt-1 border-border" }),
|
|
7093
7157
|
/* @__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(
|
|
7094
|
-
map(x, (
|
|
7158
|
+
map(x, (A, C) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
7095
7159
|
"div",
|
|
7096
7160
|
{
|
|
7097
|
-
onMouseEnter: () =>
|
|
7161
|
+
onMouseEnter: () => y(C),
|
|
7098
7162
|
onMouseLeave: () => clearTimeout(b.current),
|
|
7099
|
-
onClick: () => g(
|
|
7163
|
+
onClick: () => g(C),
|
|
7100
7164
|
className: cn(
|
|
7101
7165
|
"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",
|
|
7102
|
-
|
|
7166
|
+
C === f ? "bg-blue-500 text-white hover:bg-blue-600" : ""
|
|
7103
7167
|
),
|
|
7104
7168
|
children: [
|
|
7105
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: capitalize(h(
|
|
7169
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: capitalize(h(C.toLowerCase())) }),
|
|
7106
7170
|
/* @__PURE__ */ jsxRuntimeExports.jsx(CaretRightIcon, { className: "ml-2 h-5 w-5" })
|
|
7107
7171
|
]
|
|
7108
7172
|
},
|
|
7109
|
-
|
|
7173
|
+
C
|
|
7110
7174
|
))
|
|
7111
7175
|
) })
|
|
7112
7176
|
] })
|
|
@@ -7119,10 +7183,10 @@ const BlockCard = ({
|
|
|
7119
7183
|
children: [
|
|
7120
7184
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-2 gap-2 px-2", children: [
|
|
7121
7185
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-col gap-1", children: React__default.Children.toArray(
|
|
7122
|
-
|
|
7186
|
+
S.map((A) => /* @__PURE__ */ jsxRuntimeExports.jsx(BlockCard, { parentId: o, position: r, block: A, library: d }))
|
|
7123
7187
|
) }),
|
|
7124
7188
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-col gap-1", children: React__default.Children.toArray(
|
|
7125
|
-
|
|
7189
|
+
B.map((A) => /* @__PURE__ */ jsxRuntimeExports.jsx(BlockCard, { parentId: o, position: r, block: A, library: d }))
|
|
7126
7190
|
) })
|
|
7127
7191
|
] }),
|
|
7128
7192
|
/* @__PURE__ */ jsxRuntimeExports.jsx("br", {}),
|
|
@@ -7638,7 +7702,7 @@ const CoreBlock = ({
|
|
|
7638
7702
|
} else
|
|
7639
7703
|
p(o, n || null, a);
|
|
7640
7704
|
pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
7641
|
-
},
|
|
7705
|
+
}, j = useFeature("dnd"), { t: b } = useTranslation();
|
|
7642
7706
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
|
|
7643
7707
|
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
7644
7708
|
"button",
|
|
@@ -7651,7 +7715,7 @@ const CoreBlock = ({
|
|
|
7651
7715
|
x([]), f();
|
|
7652
7716
|
}, 200);
|
|
7653
7717
|
},
|
|
7654
|
-
draggable:
|
|
7718
|
+
draggable: j ? "true" : "false",
|
|
7655
7719
|
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",
|
|
7656
7720
|
children: [
|
|
7657
7721
|
createElement(c || BoxIcon, { className: "w-4 h-4 mx-auto" }),
|
|
@@ -7849,7 +7913,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
7849
7913
|
var b;
|
|
7850
7914
|
(b = f.current) == null || b.focus();
|
|
7851
7915
|
}, []);
|
|
7852
|
-
const
|
|
7916
|
+
const j = (b) => {
|
|
7853
7917
|
const { usage: h } = b || {};
|
|
7854
7918
|
!l && h && x(h), g.current = setTimeout(() => x(void 0), 1e4), l || c("");
|
|
7855
7919
|
};
|
|
@@ -7876,7 +7940,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
7876
7940
|
className: "w-full",
|
|
7877
7941
|
rows: 3,
|
|
7878
7942
|
onKeyDown: (b) => {
|
|
7879
|
-
b.key === "Enter" && (b.preventDefault(), g.current && clearTimeout(g.current), x(void 0), n("content", o, i,
|
|
7943
|
+
b.key === "Enter" && (b.preventDefault(), g.current && clearTimeout(g.current), x(void 0), n("content", o, i, j));
|
|
7880
7944
|
}
|
|
7881
7945
|
}
|
|
7882
7946
|
),
|
|
@@ -7886,7 +7950,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
7886
7950
|
{
|
|
7887
7951
|
disabled: i.trim().length < 5 || a,
|
|
7888
7952
|
onClick: () => {
|
|
7889
|
-
g.current && clearTimeout(g.current), x(void 0), n("content", o, i,
|
|
7953
|
+
g.current && clearTimeout(g.current), x(void 0), n("content", o, i, j);
|
|
7890
7954
|
},
|
|
7891
7955
|
variant: "default",
|
|
7892
7956
|
className: "w-fit",
|
|
@@ -7919,7 +7983,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
7919
7983
|
QuickPrompts,
|
|
7920
7984
|
{
|
|
7921
7985
|
onClick: (b) => {
|
|
7922
|
-
g.current && clearTimeout(g.current), x(void 0), n("content", o, b,
|
|
7986
|
+
g.current && clearTimeout(g.current), x(void 0), n("content", o, b, j);
|
|
7923
7987
|
}
|
|
7924
7988
|
}
|
|
7925
7989
|
)
|
|
@@ -7933,7 +7997,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
7933
7997
|
useEffect(() => {
|
|
7934
7998
|
r && a(r);
|
|
7935
7999
|
}, [r]);
|
|
7936
|
-
const
|
|
8000
|
+
const j = async () => {
|
|
7937
8001
|
try {
|
|
7938
8002
|
d(!0), u(null), await i(n), f({
|
|
7939
8003
|
title: o("Updated AI Context"),
|
|
@@ -7967,7 +8031,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
7967
8031
|
className: "mt-1 w-full",
|
|
7968
8032
|
rows: 10,
|
|
7969
8033
|
onKeyDown: (b) => {
|
|
7970
|
-
b.key === "Enter" && (b.preventDefault(),
|
|
8034
|
+
b.key === "Enter" && (b.preventDefault(), j());
|
|
7971
8035
|
}
|
|
7972
8036
|
}
|
|
7973
8037
|
),
|
|
@@ -7979,7 +8043,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
7979
8043
|
Button,
|
|
7980
8044
|
{
|
|
7981
8045
|
disabled: n.trim().length < 5,
|
|
7982
|
-
onClick: () =>
|
|
8046
|
+
onClick: () => j(),
|
|
7983
8047
|
variant: "default",
|
|
7984
8048
|
className: "w-fit",
|
|
7985
8049
|
size: "sm",
|
|
@@ -8008,7 +8072,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8008
8072
|
AlertDialogAction,
|
|
8009
8073
|
{
|
|
8010
8074
|
onClick: () => {
|
|
8011
|
-
a(""),
|
|
8075
|
+
a(""), j();
|
|
8012
8076
|
},
|
|
8013
8077
|
children: o("Yes, Delete")
|
|
8014
8078
|
}
|
|
@@ -8029,7 +8093,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8029
8093
|
/* @__PURE__ */ jsxRuntimeExports.jsx(AIUserPrompt, { blockId: first(o) })
|
|
8030
8094
|
] });
|
|
8031
8095
|
}, AttrsEditor = React__default.memo(function o({ preloadedAttributes: r = [], onAttributesChange: n }) {
|
|
8032
|
-
const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, x] = useState(null), [f, g] = useState(""),
|
|
8096
|
+
const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, x] = useState(null), [f, g] = useState(""), j = useRef(null), b = useRef(null);
|
|
8033
8097
|
useEffect(() => {
|
|
8034
8098
|
l(r);
|
|
8035
8099
|
}, [r]);
|
|
@@ -8039,32 +8103,32 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8039
8103
|
return;
|
|
8040
8104
|
}
|
|
8041
8105
|
if (i) {
|
|
8042
|
-
const
|
|
8043
|
-
n(
|
|
8106
|
+
const C = [...a, { key: i, value: d }];
|
|
8107
|
+
n(C), l(a), c(""), p(""), g("");
|
|
8044
8108
|
}
|
|
8045
|
-
},
|
|
8046
|
-
const
|
|
8047
|
-
n(
|
|
8048
|
-
},
|
|
8049
|
-
x(
|
|
8050
|
-
},
|
|
8109
|
+
}, y = (C) => {
|
|
8110
|
+
const v = a.filter((_, I) => I !== C);
|
|
8111
|
+
n(v), l(v);
|
|
8112
|
+
}, S = (C) => {
|
|
8113
|
+
x(C), c(a[C].key), p(a[C].value);
|
|
8114
|
+
}, B = () => {
|
|
8051
8115
|
if (i.startsWith("@")) {
|
|
8052
8116
|
g("Attribute keys cannot start with '@'");
|
|
8053
8117
|
return;
|
|
8054
8118
|
}
|
|
8055
8119
|
if (u !== null && i) {
|
|
8056
|
-
const
|
|
8057
|
-
|
|
8120
|
+
const C = [...a];
|
|
8121
|
+
C[u] = { key: i, value: d }, n(C), l(C), x(null), c(""), p(""), g("");
|
|
8058
8122
|
}
|
|
8059
|
-
},
|
|
8060
|
-
|
|
8123
|
+
}, A = (C) => {
|
|
8124
|
+
C.key === "Enter" && !C.shiftKey && (C.preventDefault(), u !== null ? B() : h());
|
|
8061
8125
|
};
|
|
8062
8126
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex max-h-full flex-1 flex-col", children: [
|
|
8063
8127
|
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
8064
8128
|
"form",
|
|
8065
8129
|
{
|
|
8066
|
-
onSubmit: (
|
|
8067
|
-
|
|
8130
|
+
onSubmit: (C) => {
|
|
8131
|
+
C.preventDefault(), u !== null ? B() : h();
|
|
8068
8132
|
},
|
|
8069
8133
|
className: "space-y-3",
|
|
8070
8134
|
children: [
|
|
@@ -8078,9 +8142,9 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8078
8142
|
autoCorrect: "off",
|
|
8079
8143
|
spellCheck: "false",
|
|
8080
8144
|
id: "attrKey",
|
|
8081
|
-
ref:
|
|
8145
|
+
ref: j,
|
|
8082
8146
|
value: i,
|
|
8083
|
-
onChange: (
|
|
8147
|
+
onChange: (C) => c(C.target.value),
|
|
8084
8148
|
placeholder: "Enter Key",
|
|
8085
8149
|
className: "py-0 text-xs font-normal leading-tight placeholder:text-slate-400"
|
|
8086
8150
|
}
|
|
@@ -8098,8 +8162,8 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8098
8162
|
rows: 2,
|
|
8099
8163
|
ref: b,
|
|
8100
8164
|
value: d,
|
|
8101
|
-
onChange: (
|
|
8102
|
-
onKeyDown:
|
|
8165
|
+
onChange: (C) => p(C.target.value),
|
|
8166
|
+
onKeyDown: A,
|
|
8103
8167
|
placeholder: "Enter Value",
|
|
8104
8168
|
className: "text-xs font-normal leading-tight placeholder:text-slate-400"
|
|
8105
8169
|
}
|
|
@@ -8111,16 +8175,16 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8111
8175
|
]
|
|
8112
8176
|
}
|
|
8113
8177
|
),
|
|
8114
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "space-y-1 py-4", children: a.map((
|
|
8178
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "space-y-1 py-4", children: a.map((C, v) => /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between rounded border p-2 text-sm", children: [
|
|
8115
8179
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col text-xs leading-tight", children: [
|
|
8116
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "truncate text-[12px] font-light text-muted-foreground", children:
|
|
8117
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-wrap max-w-[200px] font-normal", children:
|
|
8180
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "truncate text-[12px] font-light text-muted-foreground", children: C.key }),
|
|
8181
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-wrap max-w-[200px] font-normal", children: C.value.toString() })
|
|
8118
8182
|
] }),
|
|
8119
8183
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-shrink-0 text-slate-400", children: [
|
|
8120
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => v
|
|
8121
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () =>
|
|
8184
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => S(v), children: /* @__PURE__ */ jsxRuntimeExports.jsx(Edit2, { className: "h-3 w-3" }) }),
|
|
8185
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => y(v), children: /* @__PURE__ */ jsxRuntimeExports.jsx(X, { className: "h-3 w-3" }) })
|
|
8122
8186
|
] })
|
|
8123
|
-
] },
|
|
8187
|
+
] }, v)) })
|
|
8124
8188
|
] });
|
|
8125
8189
|
}), BlockAttributesEditor = React.memo(() => {
|
|
8126
8190
|
const o = useSelectedBlock(), [r, n] = useState([]), [a] = useSelectedStylingBlocks(), l = useUpdateBlocksProps(), i = `${get(a, "0.prop")}_attrs`;
|
|
@@ -8505,10 +8569,10 @@ const RootLayout = () => {
|
|
|
8505
8569
|
usePubSub(CHAI_BUILDER_EVENTS.SHOW_BLOCK_SETTINGS, () => {
|
|
8506
8570
|
r(1);
|
|
8507
8571
|
});
|
|
8508
|
-
const c = useBuilderProp("sideBarComponents.top", []), d = (
|
|
8509
|
-
|
|
8510
|
-
}, p = (
|
|
8511
|
-
r(o ===
|
|
8572
|
+
const c = useBuilderProp("sideBarComponents.top", []), d = (j) => {
|
|
8573
|
+
j.preventDefault();
|
|
8574
|
+
}, p = (j) => {
|
|
8575
|
+
r(o === j ? null : j);
|
|
8512
8576
|
}, u = useSidebarMenuItems(), { t: x } = useTranslation(), f = [...u, ...c], g = useBuilderProp("htmlDir", "ltr");
|
|
8513
8577
|
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: [
|
|
8514
8578
|
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
@@ -8520,18 +8584,18 @@ const RootLayout = () => {
|
|
|
8520
8584
|
/* @__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, {}) }) }),
|
|
8521
8585
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("main", { className: "relative flex h-[calc(100vh-56px)] max-w-full flex-1 flex-row", children: [
|
|
8522
8586
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex w-12 flex-col items-center justify-between border-r border-border py-2", children: [
|
|
8523
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-col", children: f.map((
|
|
8587
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-col", children: f.map((j, b) => /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
|
|
8524
8588
|
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
8525
8589
|
Button,
|
|
8526
8590
|
{
|
|
8527
8591
|
variant: o === b ? "default" : "ghost",
|
|
8528
8592
|
className: "mb-2 rounded-lg p-2 transition-colors",
|
|
8529
8593
|
onClick: () => p(b),
|
|
8530
|
-
children: get(
|
|
8594
|
+
children: get(j, "icon", null)
|
|
8531
8595
|
},
|
|
8532
8596
|
b
|
|
8533
8597
|
) }),
|
|
8534
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { children: x(
|
|
8598
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { children: x(j.label) }) })
|
|
8535
8599
|
] }, "button" + b)) }),
|
|
8536
8600
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-col space-y-1" })
|
|
8537
8601
|
] }),
|
|
@@ -8734,5 +8798,6 @@ export {
|
|
|
8734
8798
|
useUILibraryBlocks,
|
|
8735
8799
|
useUndoManager,
|
|
8736
8800
|
useUpdateBlocksProps,
|
|
8737
|
-
useUpdateBlocksPropsRealtime
|
|
8801
|
+
useUpdateBlocksPropsRealtime,
|
|
8802
|
+
useWrapperBlock
|
|
8738
8803
|
};
|