@thebes/cadmea 1.3.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/index/index.d.ts +9 -0
- package/dist/index/index.js +223 -180
- package/dist/index/index.js.map +1 -1
- package/dist/index/server.js +94 -50
- package/dist/index/server.js.map +1 -1
- package/dist/tanstack-start/index.d.ts +9 -0
- package/dist/tanstack-start/index.js +224 -181
- package/dist/tanstack-start/index.js.map +1 -1
- package/dist/tanstack-start/server.js +95 -51
- package/dist/tanstack-start/server.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,12 +1,12 @@
|
|
|
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$
|
|
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
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");
|
|
@@ -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,
|
|
@@ -414,19 +457,19 @@ function UploadControl(props) {
|
|
|
414
457
|
}
|
|
415
458
|
}
|
|
416
459
|
return (() => {
|
|
417
|
-
var _el$
|
|
418
|
-
insert(_el$
|
|
460
|
+
var _el$26 = _tmpl$20(), _el$28 = _el$26.firstChild;
|
|
461
|
+
insert(_el$26, createComponent(Show, {
|
|
419
462
|
get when() {
|
|
420
463
|
return value();
|
|
421
464
|
},
|
|
422
465
|
get children() {
|
|
423
|
-
var _el$
|
|
424
|
-
insert(_el$
|
|
425
|
-
return _el$
|
|
466
|
+
var _el$27 = _tmpl$18();
|
|
467
|
+
insert(_el$27, value);
|
|
468
|
+
return _el$27;
|
|
426
469
|
}
|
|
427
|
-
}), _el$
|
|
428
|
-
_el$
|
|
429
|
-
insert(_el$
|
|
470
|
+
}), _el$28);
|
|
471
|
+
_el$28.addEventListener("change", handleFileChange);
|
|
472
|
+
insert(_el$26, createComponent(Show, {
|
|
430
473
|
get when() {
|
|
431
474
|
return uploading();
|
|
432
475
|
},
|
|
@@ -434,28 +477,28 @@ function UploadControl(props) {
|
|
|
434
477
|
return _tmpl$2$3();
|
|
435
478
|
}
|
|
436
479
|
}), null);
|
|
437
|
-
insert(_el$
|
|
480
|
+
insert(_el$26, createComponent(Show, {
|
|
438
481
|
get when() {
|
|
439
482
|
return uploadError();
|
|
440
483
|
},
|
|
441
484
|
get children() {
|
|
442
|
-
var _el$
|
|
443
|
-
insert(_el$
|
|
444
|
-
return _el$
|
|
485
|
+
var _el$30 = _tmpl$19();
|
|
486
|
+
insert(_el$30, uploadError);
|
|
487
|
+
return _el$30;
|
|
445
488
|
}
|
|
446
489
|
}), null);
|
|
447
490
|
effect((_p$) => {
|
|
448
491
|
var _v$5 = props.name, _v$6 = props.field.required && !value(), _v$7 = uploading() || props.field.admin?.readOnly;
|
|
449
|
-
_v$5 !== _p$.e && setAttribute(_el$
|
|
450
|
-
_v$6 !== _p$.t && (_el$
|
|
451
|
-
_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);
|
|
452
495
|
return _p$;
|
|
453
496
|
}, {
|
|
454
497
|
e: void 0,
|
|
455
498
|
t: void 0,
|
|
456
499
|
a: void 0
|
|
457
500
|
});
|
|
458
|
-
return _el$
|
|
501
|
+
return _el$26;
|
|
459
502
|
})();
|
|
460
503
|
}
|
|
461
504
|
function RelationshipField(props) {
|
|
@@ -510,86 +553,86 @@ function RelationshipField(props) {
|
|
|
510
553
|
}
|
|
511
554
|
}
|
|
512
555
|
return (() => {
|
|
513
|
-
var _el$
|
|
514
|
-
insert(_el$
|
|
556
|
+
var _el$31 = _tmpl$24(), _el$33 = _el$31.firstChild;
|
|
557
|
+
insert(_el$31, createComponent(Show, {
|
|
515
558
|
get when() {
|
|
516
559
|
return memo(() => !!isMulti())() && selectedOptions().length > 0;
|
|
517
560
|
},
|
|
518
561
|
get children() {
|
|
519
|
-
var _el$
|
|
520
|
-
insert(_el$
|
|
562
|
+
var _el$32 = _tmpl$21();
|
|
563
|
+
insert(_el$32, createComponent(For, {
|
|
521
564
|
get each() {
|
|
522
565
|
return selectedOptions();
|
|
523
566
|
},
|
|
524
567
|
children: (option) => (() => {
|
|
525
|
-
var _el$
|
|
526
|
-
insert(_el$
|
|
527
|
-
_el$
|
|
528
|
-
effect(() => setAttribute(_el$
|
|
529
|
-
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;
|
|
530
573
|
})()
|
|
531
574
|
}));
|
|
532
|
-
return _el$
|
|
575
|
+
return _el$32;
|
|
533
576
|
}
|
|
534
|
-
}), _el$
|
|
535
|
-
_el$
|
|
536
|
-
_el$
|
|
537
|
-
_el$
|
|
538
|
-
_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) => {
|
|
539
582
|
setQuery(e.currentTarget.value);
|
|
540
583
|
setOpen(true);
|
|
541
584
|
setActive(0);
|
|
542
585
|
};
|
|
543
|
-
setAttribute(_el$
|
|
544
|
-
insert(_el$
|
|
586
|
+
setAttribute(_el$33, "aria-controls", listId);
|
|
587
|
+
insert(_el$31, createComponent(Show, {
|
|
545
588
|
get when() {
|
|
546
589
|
return memo(() => !!(!isMulti() && value() != null))() && !props.field.required;
|
|
547
590
|
},
|
|
548
591
|
get children() {
|
|
549
|
-
var _el$
|
|
550
|
-
_el$
|
|
551
|
-
_el$
|
|
552
|
-
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;
|
|
553
596
|
}
|
|
554
597
|
}), null);
|
|
555
|
-
insert(_el$
|
|
598
|
+
insert(_el$31, createComponent(Show, {
|
|
556
599
|
get when() {
|
|
557
600
|
return memo(() => !!open())() && filtered().length > 0;
|
|
558
601
|
},
|
|
559
602
|
get children() {
|
|
560
|
-
var _el$
|
|
561
|
-
setAttribute(_el$
|
|
562
|
-
insert(_el$
|
|
603
|
+
var _el$35 = _tmpl$23();
|
|
604
|
+
setAttribute(_el$35, "id", listId);
|
|
605
|
+
insert(_el$35, createComponent(For, {
|
|
563
606
|
get each() {
|
|
564
607
|
return filtered();
|
|
565
608
|
},
|
|
566
609
|
children: (option, i) => (() => {
|
|
567
|
-
var _el$
|
|
568
|
-
_el$
|
|
569
|
-
_el$
|
|
570
|
-
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);
|
|
571
614
|
effect((_p$) => {
|
|
572
615
|
var _v$11 = selectedIds().includes(option.id), _v$12 = !!(i() === active());
|
|
573
|
-
_v$11 !== _p$.e && setAttribute(_el$
|
|
574
|
-
_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);
|
|
575
618
|
return _p$;
|
|
576
619
|
}, {
|
|
577
620
|
e: void 0,
|
|
578
621
|
t: void 0
|
|
579
622
|
});
|
|
580
|
-
return _el$
|
|
623
|
+
return _el$38;
|
|
581
624
|
})()
|
|
582
625
|
}));
|
|
583
|
-
return _el$
|
|
626
|
+
return _el$35;
|
|
584
627
|
}
|
|
585
628
|
}), null);
|
|
586
629
|
effect((_p$) => {
|
|
587
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…";
|
|
588
|
-
_v$8 !== _p$.e && setAttribute(_el$
|
|
589
|
-
_v$9 !== _p$.t && setAttribute(_el$
|
|
590
|
-
_v$0 !== _p$.a && (_el$
|
|
591
|
-
_v$1 !== _p$.o && (_el$
|
|
592
|
-
_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);
|
|
593
636
|
return _p$;
|
|
594
637
|
}, {
|
|
595
638
|
e: void 0,
|
|
@@ -598,8 +641,8 @@ function RelationshipField(props) {
|
|
|
598
641
|
o: void 0,
|
|
599
642
|
i: void 0
|
|
600
643
|
});
|
|
601
|
-
effect(() => _el$
|
|
602
|
-
return _el$
|
|
644
|
+
effect(() => _el$33.value = open() || isMulti() ? query() : singleLabel());
|
|
645
|
+
return _el$31;
|
|
603
646
|
})();
|
|
604
647
|
}
|
|
605
648
|
function renderArray(form, ctx, name, field, label) {
|
|
@@ -660,129 +703,129 @@ function BlockEditor(props) {
|
|
|
660
703
|
return "";
|
|
661
704
|
}
|
|
662
705
|
return (() => {
|
|
663
|
-
var _el$
|
|
664
|
-
insert(_el$
|
|
665
|
-
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, {
|
|
666
709
|
get when() {
|
|
667
710
|
return props.field.required;
|
|
668
711
|
},
|
|
669
712
|
get children() {
|
|
670
|
-
return _tmpl$
|
|
713
|
+
return _tmpl$0$1();
|
|
671
714
|
}
|
|
672
715
|
}), null);
|
|
673
|
-
insert(_el$
|
|
716
|
+
insert(_el$39, createComponent(Show, {
|
|
674
717
|
get when() {
|
|
675
718
|
return props.field.admin?.description;
|
|
676
719
|
},
|
|
677
720
|
get children() {
|
|
678
|
-
var _el$
|
|
679
|
-
insert(_el$
|
|
680
|
-
return _el$
|
|
721
|
+
var _el$42 = _tmpl$1$1();
|
|
722
|
+
insert(_el$42, () => props.field.admin?.description);
|
|
723
|
+
return _el$42;
|
|
681
724
|
}
|
|
682
|
-
}), _el$
|
|
683
|
-
insert(_el$
|
|
725
|
+
}), _el$43);
|
|
726
|
+
insert(_el$43, createComponent(Index, {
|
|
684
727
|
get each() {
|
|
685
728
|
return items();
|
|
686
729
|
},
|
|
687
730
|
children: (item, index) => {
|
|
688
731
|
const isCollapsed = () => collapsed().has(index);
|
|
689
732
|
return (() => {
|
|
690
|
-
var _el$
|
|
691
|
-
_el$
|
|
692
|
-
insert(_el$
|
|
693
|
-
insert(_el$
|
|
694
|
-
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, {
|
|
695
738
|
get when() {
|
|
696
739
|
return memo(() => !!isCollapsed())() && blockSummary(item());
|
|
697
740
|
},
|
|
698
741
|
get children() {
|
|
699
|
-
var _el$
|
|
700
|
-
insert(_el$
|
|
701
|
-
return _el$
|
|
742
|
+
var _el$52 = _tmpl$30();
|
|
743
|
+
insert(_el$52, () => blockSummary(item()));
|
|
744
|
+
return _el$52;
|
|
702
745
|
}
|
|
703
|
-
}), _el$
|
|
704
|
-
_el$
|
|
705
|
-
_el$
|
|
706
|
-
_el$
|
|
707
|
-
_el$
|
|
708
|
-
_el$
|
|
709
|
-
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, {
|
|
710
753
|
get when() {
|
|
711
754
|
return !isCollapsed();
|
|
712
755
|
},
|
|
713
756
|
get children() {
|
|
714
|
-
var _el$
|
|
715
|
-
insert(_el$
|
|
757
|
+
var _el$58 = _tmpl$31();
|
|
758
|
+
insert(_el$58, createComponent(For, {
|
|
716
759
|
get each() {
|
|
717
760
|
return fieldsForItem(props.field, item());
|
|
718
761
|
},
|
|
719
762
|
children: ([itemKey, itemField]) => renderField(props.form, props.ctx, `${props.name}[${index}].${itemKey}`, itemField, labelFor(itemKey, itemField))
|
|
720
763
|
}));
|
|
721
|
-
return _el$
|
|
764
|
+
return _el$58;
|
|
722
765
|
}
|
|
723
766
|
}), null);
|
|
724
767
|
effect((_p$) => {
|
|
725
768
|
var _v$13 = !isCollapsed(), _v$14 = index === items().length - 1;
|
|
726
|
-
_v$13 !== _p$.e && setAttribute(_el$
|
|
727
|
-
_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);
|
|
728
771
|
return _p$;
|
|
729
772
|
}, {
|
|
730
773
|
e: void 0,
|
|
731
774
|
t: void 0
|
|
732
775
|
});
|
|
733
|
-
return _el$
|
|
776
|
+
return _el$47;
|
|
734
777
|
})();
|
|
735
778
|
}
|
|
736
779
|
}), null);
|
|
737
|
-
insert(_el$
|
|
780
|
+
insert(_el$43, createComponent(Show, {
|
|
738
781
|
get when() {
|
|
739
782
|
return disc && variants.length > 0;
|
|
740
783
|
},
|
|
741
784
|
get fallback() {
|
|
742
785
|
return (() => {
|
|
743
|
-
var _el$
|
|
744
|
-
_el$
|
|
745
|
-
_el$
|
|
746
|
-
insert(_el$
|
|
747
|
-
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;
|
|
748
791
|
})();
|
|
749
792
|
},
|
|
750
793
|
get children() {
|
|
751
|
-
var _el$
|
|
752
|
-
_el$
|
|
753
|
-
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, {
|
|
754
797
|
get when() {
|
|
755
798
|
return menuOpen();
|
|
756
799
|
},
|
|
757
800
|
get children() {
|
|
758
|
-
var _el$
|
|
759
|
-
insert(_el$
|
|
801
|
+
var _el$46 = _tmpl$27();
|
|
802
|
+
insert(_el$46, createComponent(For, {
|
|
760
803
|
each: variants,
|
|
761
804
|
children: (variant) => (() => {
|
|
762
|
-
var _el$
|
|
763
|
-
_el$
|
|
764
|
-
insert(_el$
|
|
805
|
+
var _el$61 = _tmpl$35();
|
|
806
|
+
_el$61.$$click = () => addBlock(variant);
|
|
807
|
+
insert(_el$61, createComponent(Show, {
|
|
765
808
|
get when() {
|
|
766
809
|
return disc?.variantsAdmin?.[variant]?.icon;
|
|
767
810
|
},
|
|
768
811
|
get children() {
|
|
769
|
-
var _el$
|
|
770
|
-
effect(() => className(_el$
|
|
771
|
-
return _el$
|
|
812
|
+
var _el$62 = _tmpl$34();
|
|
813
|
+
effect(() => className(_el$62, disc?.variantsAdmin?.[variant]?.icon));
|
|
814
|
+
return _el$62;
|
|
772
815
|
}
|
|
773
816
|
}), null);
|
|
774
|
-
insert(_el$
|
|
775
|
-
return _el$
|
|
817
|
+
insert(_el$61, () => variantLabel(disc, variant), null);
|
|
818
|
+
return _el$61;
|
|
776
819
|
})()
|
|
777
820
|
}));
|
|
778
|
-
return _el$
|
|
821
|
+
return _el$46;
|
|
779
822
|
}
|
|
780
823
|
}), null);
|
|
781
|
-
effect(() => setAttribute(_el$
|
|
782
|
-
return _el$
|
|
824
|
+
effect(() => setAttribute(_el$45, "aria-expanded", menuOpen()));
|
|
825
|
+
return _el$44;
|
|
783
826
|
}
|
|
784
827
|
}), null);
|
|
785
|
-
return _el$
|
|
828
|
+
return _el$39;
|
|
786
829
|
})();
|
|
787
830
|
}
|
|
788
831
|
function fieldsForItem(field, item) {
|