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