@thebes/cadmea 1.2.0 → 1.4.0
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/RichTextEditor-CPQTvhQD.js +190 -0
- package/dist/RichTextEditor-CPQTvhQD.js.map +1 -0
- package/dist/RichTextEditor-ComcBFfl.js +334 -0
- package/dist/RichTextEditor-ComcBFfl.js.map +1 -0
- package/dist/index/index.d.ts +9 -0
- package/dist/index/index.js +228 -182
- package/dist/index/index.js.map +1 -1
- package/dist/index/server.js +99 -52
- package/dist/index/server.js.map +1 -1
- package/dist/tanstack-start/index.d.ts +9 -0
- package/dist/tanstack-start/index.js +229 -183
- package/dist/tanstack-start/index.js.map +1 -1
- package/dist/tanstack-start/server.js +100 -53
- package/dist/tanstack-start/server.js.map +1 -1
- package/package.json +2 -1
- package/dist/RichTextEditor-BPilh7Pw.js +0 -36
- package/dist/RichTextEditor-BPilh7Pw.js.map +0 -1
- package/dist/RichTextEditor-DcLqdFY7.js +0 -15
- package/dist/RichTextEditor-DcLqdFY7.js.map +0 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { className, createComponent, delegateEvents, effect, insert, memo, setAttribute, template } from "solid-js/web";
|
|
2
2
|
import { createMutation, createQuery, useQueryClient } from "@tanstack/solid-query";
|
|
3
|
-
import { For, Index, Show, Suspense, createEffect, createSignal, lazy } from "solid-js";
|
|
3
|
+
import { For, Index, Show, Suspense, createEffect, createSignal, lazy, onCleanup } from "solid-js";
|
|
4
4
|
import { createForm } from "@tanstack/solid-form";
|
|
5
5
|
import { validateDocument } from "@thebes/cadmus/cms";
|
|
6
6
|
import { Link, useBlocker } from "@tanstack/solid-router";
|
|
7
7
|
import { createSolidTable, flexRender, getCoreRowModel } from "@tanstack/solid-table";
|
|
8
8
|
//#region src/CollectionEdit.tsx
|
|
9
|
-
var _tmpl$$4 = /*#__PURE__*/ template(`<p class="text-sm text-error"role=alert>`), _tmpl$2$3 = /*#__PURE__*/ template(`<span class="loading loading-spinner loading-sm">`), _tmpl$3$1 = /*#__PURE__*/ template(`<button type=button class="btn flex-1">`), _tmpl$4$1 = /*#__PURE__*/ template(`<button type=button class="btn btn-primary flex-1">`), _tmpl$5$1 = /*#__PURE__*/ template(`<button type=button class="btn btn-outline flex-1">`), _tmpl$6$1 = /*#__PURE__*/ template(`<form class="flex flex-col gap-4"><div class="bg-base-100 sticky bottom-0 flex gap-2 border-t py-3">`), _tmpl$
|
|
10
|
-
const RichTextEditor = lazy(() => import("../RichTextEditor-
|
|
9
|
+
var _tmpl$$4 = /*#__PURE__*/ template(`<p class="text-sm text-error"role=alert>`), _tmpl$2$3 = /*#__PURE__*/ template(`<span class="loading loading-spinner loading-sm">`), _tmpl$3$1 = /*#__PURE__*/ template(`<button type=button class="btn flex-1">`), _tmpl$4$1 = /*#__PURE__*/ template(`<button type=button class="btn btn-primary flex-1">`), _tmpl$5$1 = /*#__PURE__*/ template(`<button type=button class="btn btn-outline flex-1">`), _tmpl$6$1 = /*#__PURE__*/ template(`<span class="text-base-content/60 self-center px-1 text-xs"aria-live=polite>`), _tmpl$7$1 = /*#__PURE__*/ template(`<form class="flex flex-col gap-4"><div class="bg-base-100 sticky bottom-0 flex gap-2 border-t py-3">`), _tmpl$8$1 = /*#__PURE__*/ template(`<fieldset class="border-base-300 rounded-box border p-4"><legend class="px-2 text-sm font-semibold">`), _tmpl$9$1 = /*#__PURE__*/ template(`<div class="grid grid-cols-1 gap-4 md:grid-cols-2">`), _tmpl$0$1 = /*#__PURE__*/ template(`<span class=text-error> *`), _tmpl$1$1 = /*#__PURE__*/ template(`<p class="text-base-content/60 mb-1 text-xs">`), _tmpl$10$1 = /*#__PURE__*/ template(`<p class="text-error mt-1 text-sm"role=alert>`), _tmpl$11$1 = /*#__PURE__*/ template(`<div><label class=label>`), _tmpl$12$1 = /*#__PURE__*/ template(`<input class=input type=text>`), _tmpl$13$1 = /*#__PURE__*/ template(`<select class=select>`), _tmpl$14 = /*#__PURE__*/ template(`<option>`), _tmpl$15 = /*#__PURE__*/ template(`<input class=input type=number>`), _tmpl$16 = /*#__PURE__*/ template(`<input class=input type=text readonly>`), _tmpl$17 = /*#__PURE__*/ template(`<input class=checkbox type=checkbox>`), _tmpl$18 = /*#__PURE__*/ template(`<p class="text-sm opacity-70 break-all">`), _tmpl$19 = /*#__PURE__*/ template(`<p class="text-sm text-error">`), _tmpl$20 = /*#__PURE__*/ template(`<div class="flex flex-col gap-2"><input class=file-input type=file>`), _tmpl$21 = /*#__PURE__*/ template(`<div class="mb-1 flex flex-wrap gap-1">`), _tmpl$22 = /*#__PURE__*/ template(`<button type=button aria-label=Clear class="absolute top-2 right-2 cursor-pointer opacity-60">×`), _tmpl$23 = /*#__PURE__*/ template(`<div role=listbox class="bg-base-100 border-base-300 rounded-box absolute z-10 mt-1 flex max-h-56 w-full flex-col overflow-auto border p-1 shadow">`), _tmpl$24 = /*#__PURE__*/ template(`<div class=relative><input type=text role=combobox autocomplete=off class=input>`), _tmpl$25 = /*#__PURE__*/ template(`<span class="badge badge-primary gap-1"><button type=button class=cursor-pointer>×`), _tmpl$26 = /*#__PURE__*/ template(`<button type=button role=option class="rounded px-3 py-2 text-left">`), _tmpl$27 = /*#__PURE__*/ template(`<div role=menu class="bg-base-100 border-base-300 rounded-box absolute z-10 mt-1 flex flex-col border p-1 shadow">`), _tmpl$28 = /*#__PURE__*/ template(`<div class="relative self-start"><button type=button class="btn btn-outline btn-sm"aria-haspopup=menu>Add block`), _tmpl$29 = /*#__PURE__*/ template(`<div class="form-control md:col-span-2"><div class="label font-medium"></div><div class="flex flex-col gap-3">`), _tmpl$30 = /*#__PURE__*/ template(`<span class="text-base-content/60 truncate text-sm">`), _tmpl$31 = /*#__PURE__*/ template(`<div class="flex flex-col gap-2">`), _tmpl$32 = /*#__PURE__*/ template(`<div class="card bg-base-200 flex flex-col gap-2 p-3"><div class="flex items-center gap-2"><button type=button class="btn btn-ghost btn-sm gap-2"><span aria-hidden=true></span><span class=font-semibold></span></button><div class="ml-auto flex gap-1"><button type=button class="btn btn-ghost btn-xs"aria-label="Move up">↑</button><button type=button class="btn btn-ghost btn-xs"aria-label="Move down">↓</button><button type=button class="btn btn-ghost btn-xs"aria-label=Duplicate>⧉</button><button type=button class="btn btn-ghost btn-xs text-error"aria-label=Remove>Remove`), _tmpl$33 = /*#__PURE__*/ template(`<button type=button class="btn btn-outline btn-sm self-start">Add `), _tmpl$34 = /*#__PURE__*/ template(`<i aria-hidden=true>`), _tmpl$35 = /*#__PURE__*/ template(`<button type=button role=menuitem class="flex items-center gap-2 rounded px-3 py-2 text-left">`);
|
|
10
|
+
const RichTextEditor = lazy(() => import("../RichTextEditor-ComcBFfl.js").then((mod) => ({ default: mod.RichTextEditor })));
|
|
11
11
|
function editableFields(config) {
|
|
12
12
|
return Object.entries(config.fields).filter(([key]) => key !== "id");
|
|
13
13
|
}
|
|
@@ -70,8 +70,30 @@ function CollectionEdit(props) {
|
|
|
70
70
|
};
|
|
71
71
|
const fieldGroups = groupFields(editableFields(props.config));
|
|
72
72
|
const versioned = () => props.config.versions?.drafts && props.draftActions;
|
|
73
|
+
const [autosaveStatus, setAutosaveStatus] = createSignal("idle");
|
|
74
|
+
let autosaveTimer;
|
|
75
|
+
createEffect(() => {
|
|
76
|
+
const dirty = !isDefaultValue();
|
|
77
|
+
const values = formValues();
|
|
78
|
+
if (!versioned() || !props.draftActions?.autosave) return;
|
|
79
|
+
if (!dirty) {
|
|
80
|
+
setAutosaveStatus("idle");
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
clearTimeout(autosaveTimer);
|
|
84
|
+
autosaveTimer = setTimeout(async () => {
|
|
85
|
+
setAutosaveStatus("saving");
|
|
86
|
+
try {
|
|
87
|
+
await props.draftActions?.onSaveDraft(editablePayload(values));
|
|
88
|
+
setAutosaveStatus("saved");
|
|
89
|
+
} catch {
|
|
90
|
+
setAutosaveStatus("idle");
|
|
91
|
+
}
|
|
92
|
+
}, props.draftActions?.autosaveMs ?? 1500);
|
|
93
|
+
});
|
|
94
|
+
onCleanup(() => clearTimeout(autosaveTimer));
|
|
73
95
|
return (() => {
|
|
74
|
-
var _el$ = _tmpl$
|
|
96
|
+
var _el$ = _tmpl$7$1(), _el$3 = _el$.firstChild;
|
|
75
97
|
_el$.addEventListener("submit", (event) => {
|
|
76
98
|
event.preventDefault();
|
|
77
99
|
form.handleSubmit();
|
|
@@ -103,9 +125,9 @@ function CollectionEdit(props) {
|
|
|
103
125
|
});
|
|
104
126
|
},
|
|
105
127
|
get children() {
|
|
106
|
-
var _el$
|
|
107
|
-
insert(_el$
|
|
108
|
-
insert(_el$
|
|
128
|
+
var _el$1 = _tmpl$8$1(), _el$10 = _el$1.firstChild;
|
|
129
|
+
insert(_el$10, () => group.name);
|
|
130
|
+
insert(_el$1, createComponent(FieldsGrid, {
|
|
109
131
|
form,
|
|
110
132
|
ctx,
|
|
111
133
|
get fields() {
|
|
@@ -113,7 +135,7 @@ function CollectionEdit(props) {
|
|
|
113
135
|
},
|
|
114
136
|
values: formValues
|
|
115
137
|
}), null);
|
|
116
|
-
return _el$
|
|
138
|
+
return _el$1;
|
|
117
139
|
}
|
|
118
140
|
})
|
|
119
141
|
}), _el$3);
|
|
@@ -127,9 +149,9 @@ function CollectionEdit(props) {
|
|
|
127
149
|
return props.capabilities?.canUpdate !== false;
|
|
128
150
|
},
|
|
129
151
|
get children() {
|
|
130
|
-
var _el$
|
|
131
|
-
_el$
|
|
132
|
-
insert(_el$
|
|
152
|
+
var _el$11 = _tmpl$4$1();
|
|
153
|
+
_el$11.$$click = () => void form.handleSubmit();
|
|
154
|
+
insert(_el$11, createComponent(Show, {
|
|
133
155
|
get when() {
|
|
134
156
|
return props.saving;
|
|
135
157
|
},
|
|
@@ -140,8 +162,8 @@ function CollectionEdit(props) {
|
|
|
140
162
|
return _tmpl$2$3();
|
|
141
163
|
}
|
|
142
164
|
}));
|
|
143
|
-
effect(() => _el$
|
|
144
|
-
return _el$
|
|
165
|
+
effect(() => _el$11.disabled = props.saving);
|
|
166
|
+
return _el$11;
|
|
145
167
|
}
|
|
146
168
|
});
|
|
147
169
|
},
|
|
@@ -202,6 +224,27 @@ function CollectionEdit(props) {
|
|
|
202
224
|
effect(() => _el$8.disabled = !props.draftActions?.canPreview || props.draftActions?.previewing);
|
|
203
225
|
return _el$8;
|
|
204
226
|
}
|
|
227
|
+
}),
|
|
228
|
+
createComponent(Show, {
|
|
229
|
+
get when() {
|
|
230
|
+
return props.draftActions?.autosave;
|
|
231
|
+
},
|
|
232
|
+
get children() {
|
|
233
|
+
var _el$0 = _tmpl$6$1();
|
|
234
|
+
insert(_el$0, createComponent(Show, {
|
|
235
|
+
get when() {
|
|
236
|
+
return autosaveStatus() === "saving";
|
|
237
|
+
},
|
|
238
|
+
children: "Saving…"
|
|
239
|
+
}), null);
|
|
240
|
+
insert(_el$0, createComponent(Show, {
|
|
241
|
+
get when() {
|
|
242
|
+
return autosaveStatus() === "saved";
|
|
243
|
+
},
|
|
244
|
+
children: "Saved"
|
|
245
|
+
}), null);
|
|
246
|
+
return _el$0;
|
|
247
|
+
}
|
|
205
248
|
})
|
|
206
249
|
];
|
|
207
250
|
}
|
|
@@ -211,8 +254,8 @@ function CollectionEdit(props) {
|
|
|
211
254
|
}
|
|
212
255
|
function FieldsGrid(props) {
|
|
213
256
|
return (() => {
|
|
214
|
-
var _el$
|
|
215
|
-
insert(_el$
|
|
257
|
+
var _el$13 = _tmpl$9$1();
|
|
258
|
+
insert(_el$13, createComponent(For, {
|
|
216
259
|
get each() {
|
|
217
260
|
return props.fields;
|
|
218
261
|
},
|
|
@@ -225,7 +268,7 @@ function FieldsGrid(props) {
|
|
|
225
268
|
}
|
|
226
269
|
})
|
|
227
270
|
}));
|
|
228
|
-
return _el$
|
|
271
|
+
return _el$13;
|
|
229
272
|
})();
|
|
230
273
|
}
|
|
231
274
|
function renderField(form, ctx, name, field, label) {
|
|
@@ -234,40 +277,40 @@ function renderField(form, ctx, name, field, label) {
|
|
|
234
277
|
return createComponent(form.Field, {
|
|
235
278
|
name,
|
|
236
279
|
children: (fieldApi) => (() => {
|
|
237
|
-
var _el$
|
|
238
|
-
className(_el$
|
|
239
|
-
setAttribute(_el$
|
|
240
|
-
insert(_el$
|
|
241
|
-
insert(_el$
|
|
280
|
+
var _el$14 = _tmpl$11$1(), _el$15 = _el$14.firstChild;
|
|
281
|
+
className(_el$14, `form-control ${spanClass}`);
|
|
282
|
+
setAttribute(_el$15, "for", name);
|
|
283
|
+
insert(_el$15, label, null);
|
|
284
|
+
insert(_el$15, createComponent(Show, {
|
|
242
285
|
get when() {
|
|
243
286
|
return field.required;
|
|
244
287
|
},
|
|
245
288
|
get children() {
|
|
246
|
-
return _tmpl$
|
|
289
|
+
return _tmpl$0$1();
|
|
247
290
|
}
|
|
248
291
|
}), null);
|
|
249
|
-
insert(_el$
|
|
292
|
+
insert(_el$14, createComponent(Show, {
|
|
250
293
|
get when() {
|
|
251
294
|
return field.admin?.description;
|
|
252
295
|
},
|
|
253
296
|
get children() {
|
|
254
|
-
var _el$
|
|
255
|
-
insert(_el$
|
|
256
|
-
return _el$
|
|
297
|
+
var _el$17 = _tmpl$1$1();
|
|
298
|
+
insert(_el$17, () => field.admin?.description);
|
|
299
|
+
return _el$17;
|
|
257
300
|
}
|
|
258
301
|
}), null);
|
|
259
|
-
insert(_el$
|
|
260
|
-
insert(_el$
|
|
302
|
+
insert(_el$14, () => renderControl(ctx, name, field, fieldApi), null);
|
|
303
|
+
insert(_el$14, createComponent(Show, {
|
|
261
304
|
get when() {
|
|
262
305
|
return (fieldApi().state.meta.errors?.length ?? 0) > 0;
|
|
263
306
|
},
|
|
264
307
|
get children() {
|
|
265
|
-
var _el$
|
|
266
|
-
insert(_el$
|
|
267
|
-
return _el$
|
|
308
|
+
var _el$18 = _tmpl$10$1();
|
|
309
|
+
insert(_el$18, () => fieldApi().state.meta.errors.filter(Boolean).join(", "));
|
|
310
|
+
return _el$18;
|
|
268
311
|
}
|
|
269
312
|
}), null);
|
|
270
|
-
return _el$
|
|
313
|
+
return _el$14;
|
|
271
314
|
})()
|
|
272
315
|
});
|
|
273
316
|
}
|
|
@@ -287,76 +330,76 @@ function renderControl(ctx, name, field, fieldApi) {
|
|
|
287
330
|
const change = (v) => fieldApi().handleChange(v);
|
|
288
331
|
switch (field.type) {
|
|
289
332
|
case "text": return (() => {
|
|
290
|
-
var _el$
|
|
291
|
-
_el$
|
|
292
|
-
_el$
|
|
293
|
-
setAttribute(_el$
|
|
294
|
-
_el$
|
|
333
|
+
var _el$19 = _tmpl$12$1();
|
|
334
|
+
_el$19.addEventListener("blur", () => fieldApi().handleBlur());
|
|
335
|
+
_el$19.$$input = (e) => change(e.currentTarget.value);
|
|
336
|
+
setAttribute(_el$19, "id", name);
|
|
337
|
+
_el$19.readOnly = readOnly;
|
|
295
338
|
effect((_p$) => {
|
|
296
339
|
var _v$ = field.admin?.placeholder, _v$2 = field.required;
|
|
297
|
-
_v$ !== _p$.e && setAttribute(_el$
|
|
298
|
-
_v$2 !== _p$.t && (_el$
|
|
340
|
+
_v$ !== _p$.e && setAttribute(_el$19, "placeholder", _p$.e = _v$);
|
|
341
|
+
_v$2 !== _p$.t && (_el$19.required = _p$.t = _v$2);
|
|
299
342
|
return _p$;
|
|
300
343
|
}, {
|
|
301
344
|
e: void 0,
|
|
302
345
|
t: void 0
|
|
303
346
|
});
|
|
304
|
-
effect(() => _el$
|
|
305
|
-
return _el$
|
|
347
|
+
effect(() => _el$19.value = fieldApi().state.value ?? "");
|
|
348
|
+
return _el$19;
|
|
306
349
|
})();
|
|
307
350
|
case "select": return (() => {
|
|
308
|
-
var _el$
|
|
309
|
-
_el$
|
|
310
|
-
_el$
|
|
311
|
-
setAttribute(_el$
|
|
312
|
-
_el$
|
|
313
|
-
insert(_el$
|
|
351
|
+
var _el$20 = _tmpl$13$1();
|
|
352
|
+
_el$20.addEventListener("blur", () => fieldApi().handleBlur());
|
|
353
|
+
_el$20.addEventListener("change", (e) => change(e.currentTarget.value));
|
|
354
|
+
setAttribute(_el$20, "id", name);
|
|
355
|
+
_el$20.disabled = readOnly;
|
|
356
|
+
insert(_el$20, createComponent(For, {
|
|
314
357
|
get each() {
|
|
315
358
|
return field.options;
|
|
316
359
|
},
|
|
317
360
|
children: (option) => (() => {
|
|
318
|
-
var _el$
|
|
319
|
-
_el$
|
|
320
|
-
insert(_el$
|
|
321
|
-
return _el$
|
|
361
|
+
var _el$21 = _tmpl$14();
|
|
362
|
+
_el$21.value = option;
|
|
363
|
+
insert(_el$21, option);
|
|
364
|
+
return _el$21;
|
|
322
365
|
})()
|
|
323
366
|
}));
|
|
324
|
-
effect(() => _el$
|
|
325
|
-
effect(() => _el$
|
|
326
|
-
return _el$
|
|
367
|
+
effect(() => _el$20.required = field.required);
|
|
368
|
+
effect(() => _el$20.value = fieldApi().state.value ?? "");
|
|
369
|
+
return _el$20;
|
|
327
370
|
})();
|
|
328
371
|
case "number": return (() => {
|
|
329
|
-
var _el$
|
|
330
|
-
_el$
|
|
331
|
-
_el$
|
|
332
|
-
setAttribute(_el$
|
|
333
|
-
_el$
|
|
372
|
+
var _el$22 = _tmpl$15();
|
|
373
|
+
_el$22.addEventListener("blur", () => fieldApi().handleBlur());
|
|
374
|
+
_el$22.$$input = (e) => change(e.currentTarget.valueAsNumber);
|
|
375
|
+
setAttribute(_el$22, "id", name);
|
|
376
|
+
_el$22.readOnly = readOnly;
|
|
334
377
|
effect((_p$) => {
|
|
335
378
|
var _v$3 = field.admin?.placeholder, _v$4 = field.required;
|
|
336
|
-
_v$3 !== _p$.e && setAttribute(_el$
|
|
337
|
-
_v$4 !== _p$.t && (_el$
|
|
379
|
+
_v$3 !== _p$.e && setAttribute(_el$22, "placeholder", _p$.e = _v$3);
|
|
380
|
+
_v$4 !== _p$.t && (_el$22.required = _p$.t = _v$4);
|
|
338
381
|
return _p$;
|
|
339
382
|
}, {
|
|
340
383
|
e: void 0,
|
|
341
384
|
t: void 0
|
|
342
385
|
});
|
|
343
|
-
effect(() => _el$
|
|
344
|
-
return _el$21;
|
|
345
|
-
})();
|
|
346
|
-
case "date": return (() => {
|
|
347
|
-
var _el$22 = _tmpl$15();
|
|
348
|
-
setAttribute(_el$22, "id", name);
|
|
349
|
-
effect(() => _el$22.value = formatDateValue(fieldApi().state.value));
|
|
386
|
+
effect(() => _el$22.value = fieldApi().state.value ?? "");
|
|
350
387
|
return _el$22;
|
|
351
388
|
})();
|
|
352
|
-
case "
|
|
389
|
+
case "date": return (() => {
|
|
353
390
|
var _el$23 = _tmpl$16();
|
|
354
|
-
_el$23.addEventListener("change", (e) => change(e.currentTarget.checked));
|
|
355
391
|
setAttribute(_el$23, "id", name);
|
|
356
|
-
_el$23.
|
|
357
|
-
effect(() => _el$23.checked = fieldApi().state.value ?? false);
|
|
392
|
+
effect(() => _el$23.value = formatDateValue(fieldApi().state.value));
|
|
358
393
|
return _el$23;
|
|
359
394
|
})();
|
|
395
|
+
case "checkbox": return (() => {
|
|
396
|
+
var _el$24 = _tmpl$17();
|
|
397
|
+
_el$24.addEventListener("change", (e) => change(e.currentTarget.checked));
|
|
398
|
+
setAttribute(_el$24, "id", name);
|
|
399
|
+
_el$24.disabled = readOnly;
|
|
400
|
+
effect(() => _el$24.checked = fieldApi().state.value ?? false);
|
|
401
|
+
return _el$24;
|
|
402
|
+
})();
|
|
360
403
|
case "upload": return createComponent(UploadControl, {
|
|
361
404
|
name,
|
|
362
405
|
field,
|
|
@@ -381,7 +424,10 @@ function renderControl(ctx, name, field, fieldApi) {
|
|
|
381
424
|
get content() {
|
|
382
425
|
return fieldApi().state.value;
|
|
383
426
|
},
|
|
384
|
-
onChange: (doc) => change(doc)
|
|
427
|
+
onChange: (doc) => change(doc),
|
|
428
|
+
get onUploadFile() {
|
|
429
|
+
return ctx.onUploadFile;
|
|
430
|
+
}
|
|
385
431
|
});
|
|
386
432
|
}
|
|
387
433
|
});
|
|
@@ -411,19 +457,19 @@ function UploadControl(props) {
|
|
|
411
457
|
}
|
|
412
458
|
}
|
|
413
459
|
return (() => {
|
|
414
|
-
var _el$
|
|
415
|
-
insert(_el$
|
|
460
|
+
var _el$26 = _tmpl$20(), _el$28 = _el$26.firstChild;
|
|
461
|
+
insert(_el$26, createComponent(Show, {
|
|
416
462
|
get when() {
|
|
417
463
|
return value();
|
|
418
464
|
},
|
|
419
465
|
get children() {
|
|
420
|
-
var _el$
|
|
421
|
-
insert(_el$
|
|
422
|
-
return _el$
|
|
466
|
+
var _el$27 = _tmpl$18();
|
|
467
|
+
insert(_el$27, value);
|
|
468
|
+
return _el$27;
|
|
423
469
|
}
|
|
424
|
-
}), _el$
|
|
425
|
-
_el$
|
|
426
|
-
insert(_el$
|
|
470
|
+
}), _el$28);
|
|
471
|
+
_el$28.addEventListener("change", handleFileChange);
|
|
472
|
+
insert(_el$26, createComponent(Show, {
|
|
427
473
|
get when() {
|
|
428
474
|
return uploading();
|
|
429
475
|
},
|
|
@@ -431,28 +477,28 @@ function UploadControl(props) {
|
|
|
431
477
|
return _tmpl$2$3();
|
|
432
478
|
}
|
|
433
479
|
}), null);
|
|
434
|
-
insert(_el$
|
|
480
|
+
insert(_el$26, createComponent(Show, {
|
|
435
481
|
get when() {
|
|
436
482
|
return uploadError();
|
|
437
483
|
},
|
|
438
484
|
get children() {
|
|
439
|
-
var _el$
|
|
440
|
-
insert(_el$
|
|
441
|
-
return _el$
|
|
485
|
+
var _el$30 = _tmpl$19();
|
|
486
|
+
insert(_el$30, uploadError);
|
|
487
|
+
return _el$30;
|
|
442
488
|
}
|
|
443
489
|
}), null);
|
|
444
490
|
effect((_p$) => {
|
|
445
491
|
var _v$5 = props.name, _v$6 = props.field.required && !value(), _v$7 = uploading() || props.field.admin?.readOnly;
|
|
446
|
-
_v$5 !== _p$.e && setAttribute(_el$
|
|
447
|
-
_v$6 !== _p$.t && (_el$
|
|
448
|
-
_v$7 !== _p$.a && (_el$
|
|
492
|
+
_v$5 !== _p$.e && setAttribute(_el$28, "id", _p$.e = _v$5);
|
|
493
|
+
_v$6 !== _p$.t && (_el$28.required = _p$.t = _v$6);
|
|
494
|
+
_v$7 !== _p$.a && (_el$28.disabled = _p$.a = _v$7);
|
|
449
495
|
return _p$;
|
|
450
496
|
}, {
|
|
451
497
|
e: void 0,
|
|
452
498
|
t: void 0,
|
|
453
499
|
a: void 0
|
|
454
500
|
});
|
|
455
|
-
return _el$
|
|
501
|
+
return _el$26;
|
|
456
502
|
})();
|
|
457
503
|
}
|
|
458
504
|
function RelationshipField(props) {
|
|
@@ -507,86 +553,86 @@ function RelationshipField(props) {
|
|
|
507
553
|
}
|
|
508
554
|
}
|
|
509
555
|
return (() => {
|
|
510
|
-
var _el$
|
|
511
|
-
insert(_el$
|
|
556
|
+
var _el$31 = _tmpl$24(), _el$33 = _el$31.firstChild;
|
|
557
|
+
insert(_el$31, createComponent(Show, {
|
|
512
558
|
get when() {
|
|
513
559
|
return memo(() => !!isMulti())() && selectedOptions().length > 0;
|
|
514
560
|
},
|
|
515
561
|
get children() {
|
|
516
|
-
var _el$
|
|
517
|
-
insert(_el$
|
|
562
|
+
var _el$32 = _tmpl$21();
|
|
563
|
+
insert(_el$32, createComponent(For, {
|
|
518
564
|
get each() {
|
|
519
565
|
return selectedOptions();
|
|
520
566
|
},
|
|
521
567
|
children: (option) => (() => {
|
|
522
|
-
var _el$
|
|
523
|
-
insert(_el$
|
|
524
|
-
_el$
|
|
525
|
-
effect(() => setAttribute(_el$
|
|
526
|
-
return _el$
|
|
568
|
+
var _el$36 = _tmpl$25(), _el$37 = _el$36.firstChild;
|
|
569
|
+
insert(_el$36, () => option.label, _el$37);
|
|
570
|
+
_el$37.$$click = () => removeId(option.id);
|
|
571
|
+
effect(() => setAttribute(_el$37, "aria-label", `Remove ${option.label}`));
|
|
572
|
+
return _el$36;
|
|
527
573
|
})()
|
|
528
574
|
}));
|
|
529
|
-
return _el$
|
|
575
|
+
return _el$32;
|
|
530
576
|
}
|
|
531
|
-
}), _el$
|
|
532
|
-
_el$
|
|
533
|
-
_el$
|
|
534
|
-
_el$
|
|
535
|
-
_el$
|
|
577
|
+
}), _el$33);
|
|
578
|
+
_el$33.$$keydown = onKeyDown;
|
|
579
|
+
_el$33.addEventListener("blur", () => setTimeout(() => setOpen(false), 120));
|
|
580
|
+
_el$33.addEventListener("focus", () => setOpen(true));
|
|
581
|
+
_el$33.$$input = (e) => {
|
|
536
582
|
setQuery(e.currentTarget.value);
|
|
537
583
|
setOpen(true);
|
|
538
584
|
setActive(0);
|
|
539
585
|
};
|
|
540
|
-
setAttribute(_el$
|
|
541
|
-
insert(_el$
|
|
586
|
+
setAttribute(_el$33, "aria-controls", listId);
|
|
587
|
+
insert(_el$31, createComponent(Show, {
|
|
542
588
|
get when() {
|
|
543
589
|
return memo(() => !!(!isMulti() && value() != null))() && !props.field.required;
|
|
544
590
|
},
|
|
545
591
|
get children() {
|
|
546
|
-
var _el$
|
|
547
|
-
_el$
|
|
548
|
-
_el$
|
|
549
|
-
return _el$
|
|
592
|
+
var _el$34 = _tmpl$22();
|
|
593
|
+
_el$34.$$click = () => removeId(value());
|
|
594
|
+
_el$34.$$mousedown = (e) => e.preventDefault();
|
|
595
|
+
return _el$34;
|
|
550
596
|
}
|
|
551
597
|
}), null);
|
|
552
|
-
insert(_el$
|
|
598
|
+
insert(_el$31, createComponent(Show, {
|
|
553
599
|
get when() {
|
|
554
600
|
return memo(() => !!open())() && filtered().length > 0;
|
|
555
601
|
},
|
|
556
602
|
get children() {
|
|
557
|
-
var _el$
|
|
558
|
-
setAttribute(_el$
|
|
559
|
-
insert(_el$
|
|
603
|
+
var _el$35 = _tmpl$23();
|
|
604
|
+
setAttribute(_el$35, "id", listId);
|
|
605
|
+
insert(_el$35, createComponent(For, {
|
|
560
606
|
get each() {
|
|
561
607
|
return filtered();
|
|
562
608
|
},
|
|
563
609
|
children: (option, i) => (() => {
|
|
564
|
-
var _el$
|
|
565
|
-
_el$
|
|
566
|
-
_el$
|
|
567
|
-
insert(_el$
|
|
610
|
+
var _el$38 = _tmpl$26();
|
|
611
|
+
_el$38.$$click = () => choose(option);
|
|
612
|
+
_el$38.$$mousedown = (e) => e.preventDefault();
|
|
613
|
+
insert(_el$38, () => option.label);
|
|
568
614
|
effect((_p$) => {
|
|
569
615
|
var _v$11 = selectedIds().includes(option.id), _v$12 = !!(i() === active());
|
|
570
|
-
_v$11 !== _p$.e && setAttribute(_el$
|
|
571
|
-
_v$12 !== _p$.t && _el$
|
|
616
|
+
_v$11 !== _p$.e && setAttribute(_el$38, "aria-selected", _p$.e = _v$11);
|
|
617
|
+
_v$12 !== _p$.t && _el$38.classList.toggle("bg-base-200", _p$.t = _v$12);
|
|
572
618
|
return _p$;
|
|
573
619
|
}, {
|
|
574
620
|
e: void 0,
|
|
575
621
|
t: void 0
|
|
576
622
|
});
|
|
577
|
-
return _el$
|
|
623
|
+
return _el$38;
|
|
578
624
|
})()
|
|
579
625
|
}));
|
|
580
|
-
return _el$
|
|
626
|
+
return _el$35;
|
|
581
627
|
}
|
|
582
628
|
}), null);
|
|
583
629
|
effect((_p$) => {
|
|
584
630
|
var _v$8 = props.name, _v$9 = open(), _v$0 = props.field.required && selectedIds().length === 0, _v$1 = props.field.admin?.readOnly, _v$10 = props.field.admin?.placeholder ?? "Search…";
|
|
585
|
-
_v$8 !== _p$.e && setAttribute(_el$
|
|
586
|
-
_v$9 !== _p$.t && setAttribute(_el$
|
|
587
|
-
_v$0 !== _p$.a && (_el$
|
|
588
|
-
_v$1 !== _p$.o && (_el$
|
|
589
|
-
_v$10 !== _p$.i && setAttribute(_el$
|
|
631
|
+
_v$8 !== _p$.e && setAttribute(_el$33, "id", _p$.e = _v$8);
|
|
632
|
+
_v$9 !== _p$.t && setAttribute(_el$33, "aria-expanded", _p$.t = _v$9);
|
|
633
|
+
_v$0 !== _p$.a && (_el$33.required = _p$.a = _v$0);
|
|
634
|
+
_v$1 !== _p$.o && (_el$33.disabled = _p$.o = _v$1);
|
|
635
|
+
_v$10 !== _p$.i && setAttribute(_el$33, "placeholder", _p$.i = _v$10);
|
|
590
636
|
return _p$;
|
|
591
637
|
}, {
|
|
592
638
|
e: void 0,
|
|
@@ -595,8 +641,8 @@ function RelationshipField(props) {
|
|
|
595
641
|
o: void 0,
|
|
596
642
|
i: void 0
|
|
597
643
|
});
|
|
598
|
-
effect(() => _el$
|
|
599
|
-
return _el$
|
|
644
|
+
effect(() => _el$33.value = open() || isMulti() ? query() : singleLabel());
|
|
645
|
+
return _el$31;
|
|
600
646
|
})();
|
|
601
647
|
}
|
|
602
648
|
function renderArray(form, ctx, name, field, label) {
|
|
@@ -657,129 +703,129 @@ function BlockEditor(props) {
|
|
|
657
703
|
return "";
|
|
658
704
|
}
|
|
659
705
|
return (() => {
|
|
660
|
-
var _el$
|
|
661
|
-
insert(_el$
|
|
662
|
-
insert(_el$
|
|
706
|
+
var _el$39 = _tmpl$29(), _el$40 = _el$39.firstChild, _el$43 = _el$40.nextSibling;
|
|
707
|
+
insert(_el$40, () => props.label, null);
|
|
708
|
+
insert(_el$40, createComponent(Show, {
|
|
663
709
|
get when() {
|
|
664
710
|
return props.field.required;
|
|
665
711
|
},
|
|
666
712
|
get children() {
|
|
667
|
-
return _tmpl$
|
|
713
|
+
return _tmpl$0$1();
|
|
668
714
|
}
|
|
669
715
|
}), null);
|
|
670
|
-
insert(_el$
|
|
716
|
+
insert(_el$39, createComponent(Show, {
|
|
671
717
|
get when() {
|
|
672
718
|
return props.field.admin?.description;
|
|
673
719
|
},
|
|
674
720
|
get children() {
|
|
675
|
-
var _el$
|
|
676
|
-
insert(_el$
|
|
677
|
-
return _el$
|
|
721
|
+
var _el$42 = _tmpl$1$1();
|
|
722
|
+
insert(_el$42, () => props.field.admin?.description);
|
|
723
|
+
return _el$42;
|
|
678
724
|
}
|
|
679
|
-
}), _el$
|
|
680
|
-
insert(_el$
|
|
725
|
+
}), _el$43);
|
|
726
|
+
insert(_el$43, createComponent(Index, {
|
|
681
727
|
get each() {
|
|
682
728
|
return items();
|
|
683
729
|
},
|
|
684
730
|
children: (item, index) => {
|
|
685
731
|
const isCollapsed = () => collapsed().has(index);
|
|
686
732
|
return (() => {
|
|
687
|
-
var _el$
|
|
688
|
-
_el$
|
|
689
|
-
insert(_el$
|
|
690
|
-
insert(_el$
|
|
691
|
-
insert(_el$
|
|
733
|
+
var _el$47 = _tmpl$32(), _el$48 = _el$47.firstChild, _el$49 = _el$48.firstChild, _el$50 = _el$49.firstChild, _el$51 = _el$50.nextSibling, _el$53 = _el$49.nextSibling, _el$54 = _el$53.firstChild, _el$55 = _el$54.nextSibling, _el$56 = _el$55.nextSibling, _el$57 = _el$56.nextSibling;
|
|
734
|
+
_el$49.$$click = () => toggleCollapse(index);
|
|
735
|
+
insert(_el$50, () => isCollapsed() ? "▸" : "▾");
|
|
736
|
+
insert(_el$51, () => blockTitle(item()));
|
|
737
|
+
insert(_el$48, createComponent(Show, {
|
|
692
738
|
get when() {
|
|
693
739
|
return memo(() => !!isCollapsed())() && blockSummary(item());
|
|
694
740
|
},
|
|
695
741
|
get children() {
|
|
696
|
-
var _el$
|
|
697
|
-
insert(_el$
|
|
698
|
-
return _el$
|
|
742
|
+
var _el$52 = _tmpl$30();
|
|
743
|
+
insert(_el$52, () => blockSummary(item()));
|
|
744
|
+
return _el$52;
|
|
699
745
|
}
|
|
700
|
-
}), _el$
|
|
701
|
-
_el$
|
|
702
|
-
_el$
|
|
703
|
-
_el$
|
|
704
|
-
_el$
|
|
705
|
-
_el$
|
|
706
|
-
insert(_el$
|
|
746
|
+
}), _el$53);
|
|
747
|
+
_el$54.$$click = () => move(index, index - 1);
|
|
748
|
+
_el$54.disabled = index === 0;
|
|
749
|
+
_el$55.$$click = () => move(index, index + 1);
|
|
750
|
+
_el$56.$$click = () => duplicate(index);
|
|
751
|
+
_el$57.$$click = () => props.fieldApi().removeValue(index);
|
|
752
|
+
insert(_el$47, createComponent(Show, {
|
|
707
753
|
get when() {
|
|
708
754
|
return !isCollapsed();
|
|
709
755
|
},
|
|
710
756
|
get children() {
|
|
711
|
-
var _el$
|
|
712
|
-
insert(_el$
|
|
757
|
+
var _el$58 = _tmpl$31();
|
|
758
|
+
insert(_el$58, createComponent(For, {
|
|
713
759
|
get each() {
|
|
714
760
|
return fieldsForItem(props.field, item());
|
|
715
761
|
},
|
|
716
762
|
children: ([itemKey, itemField]) => renderField(props.form, props.ctx, `${props.name}[${index}].${itemKey}`, itemField, labelFor(itemKey, itemField))
|
|
717
763
|
}));
|
|
718
|
-
return _el$
|
|
764
|
+
return _el$58;
|
|
719
765
|
}
|
|
720
766
|
}), null);
|
|
721
767
|
effect((_p$) => {
|
|
722
768
|
var _v$13 = !isCollapsed(), _v$14 = index === items().length - 1;
|
|
723
|
-
_v$13 !== _p$.e && setAttribute(_el$
|
|
724
|
-
_v$14 !== _p$.t && (_el$
|
|
769
|
+
_v$13 !== _p$.e && setAttribute(_el$49, "aria-expanded", _p$.e = _v$13);
|
|
770
|
+
_v$14 !== _p$.t && (_el$55.disabled = _p$.t = _v$14);
|
|
725
771
|
return _p$;
|
|
726
772
|
}, {
|
|
727
773
|
e: void 0,
|
|
728
774
|
t: void 0
|
|
729
775
|
});
|
|
730
|
-
return _el$
|
|
776
|
+
return _el$47;
|
|
731
777
|
})();
|
|
732
778
|
}
|
|
733
779
|
}), null);
|
|
734
|
-
insert(_el$
|
|
780
|
+
insert(_el$43, createComponent(Show, {
|
|
735
781
|
get when() {
|
|
736
782
|
return disc && variants.length > 0;
|
|
737
783
|
},
|
|
738
784
|
get fallback() {
|
|
739
785
|
return (() => {
|
|
740
|
-
var _el$
|
|
741
|
-
_el$
|
|
742
|
-
_el$
|
|
743
|
-
insert(_el$
|
|
744
|
-
return _el$
|
|
786
|
+
var _el$59 = _tmpl$33();
|
|
787
|
+
_el$59.firstChild;
|
|
788
|
+
_el$59.$$click = () => addBlock();
|
|
789
|
+
insert(_el$59, () => props.label, null);
|
|
790
|
+
return _el$59;
|
|
745
791
|
})();
|
|
746
792
|
},
|
|
747
793
|
get children() {
|
|
748
|
-
var _el$
|
|
749
|
-
_el$
|
|
750
|
-
insert(_el$
|
|
794
|
+
var _el$44 = _tmpl$28(), _el$45 = _el$44.firstChild;
|
|
795
|
+
_el$45.$$click = () => setMenuOpen((o) => !o);
|
|
796
|
+
insert(_el$44, createComponent(Show, {
|
|
751
797
|
get when() {
|
|
752
798
|
return menuOpen();
|
|
753
799
|
},
|
|
754
800
|
get children() {
|
|
755
|
-
var _el$
|
|
756
|
-
insert(_el$
|
|
801
|
+
var _el$46 = _tmpl$27();
|
|
802
|
+
insert(_el$46, createComponent(For, {
|
|
757
803
|
each: variants,
|
|
758
804
|
children: (variant) => (() => {
|
|
759
|
-
var _el$
|
|
760
|
-
_el$
|
|
761
|
-
insert(_el$
|
|
805
|
+
var _el$61 = _tmpl$35();
|
|
806
|
+
_el$61.$$click = () => addBlock(variant);
|
|
807
|
+
insert(_el$61, createComponent(Show, {
|
|
762
808
|
get when() {
|
|
763
809
|
return disc?.variantsAdmin?.[variant]?.icon;
|
|
764
810
|
},
|
|
765
811
|
get children() {
|
|
766
|
-
var _el$
|
|
767
|
-
effect(() => className(_el$
|
|
768
|
-
return _el$
|
|
812
|
+
var _el$62 = _tmpl$34();
|
|
813
|
+
effect(() => className(_el$62, disc?.variantsAdmin?.[variant]?.icon));
|
|
814
|
+
return _el$62;
|
|
769
815
|
}
|
|
770
816
|
}), null);
|
|
771
|
-
insert(_el$
|
|
772
|
-
return _el$
|
|
817
|
+
insert(_el$61, () => variantLabel(disc, variant), null);
|
|
818
|
+
return _el$61;
|
|
773
819
|
})()
|
|
774
820
|
}));
|
|
775
|
-
return _el$
|
|
821
|
+
return _el$46;
|
|
776
822
|
}
|
|
777
823
|
}), null);
|
|
778
|
-
effect(() => setAttribute(_el$
|
|
779
|
-
return _el$
|
|
824
|
+
effect(() => setAttribute(_el$45, "aria-expanded", menuOpen()));
|
|
825
|
+
return _el$44;
|
|
780
826
|
}
|
|
781
827
|
}), null);
|
|
782
|
-
return _el$
|
|
828
|
+
return _el$39;
|
|
783
829
|
})();
|
|
784
830
|
}
|
|
785
831
|
function fieldsForItem(field, item) {
|