runeforge 0.0.61 → 0.0.63
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/LICENSE +21 -21
- package/README.md +1410 -1407
- package/dist/components/Avatar.svelte +31 -31
- package/dist/components/IconRenderer.svelte +73 -73
- package/dist/components/Modal.svelte +75 -75
- package/dist/components/common/Header.svelte +40 -40
- package/dist/components/crud/EmbeddedField.svelte +203 -203
- package/dist/components/crud/Field.svelte +122 -122
- package/dist/components/crud/GenericCRUD.svelte +426 -426
- package/dist/components/crud/SearchInput.svelte +53 -53
- package/dist/components/crud/columns/Avatar.svelte +15 -15
- package/dist/components/crud/columns/Icon.svelte +8 -8
- package/dist/components/crud/fields/BooleanField.svelte +38 -38
- package/dist/components/crud/fields/DatetimeField.svelte +250 -250
- package/dist/components/crud/fields/DefaultField.svelte +67 -67
- package/dist/components/crud/fields/FileField.svelte +70 -70
- package/dist/components/crud/fields/MultiSelectField.svelte +70 -70
- package/dist/components/crud/fields/SelectField.svelte +67 -67
- package/dist/components/crud/fields/TextareaField.svelte +55 -55
- package/dist/components/crud/fields/TreeField.svelte +1 -0
- package/dist/components/crud/utils/resolution.js +1 -0
- package/dist/components/crud/utils/tree.d.ts +5 -0
- package/dist/components/crud/utils/tree.js +29 -0
- package/dist/components/crud/views/Create.svelte +239 -239
- package/dist/components/crud/views/Read.svelte +131 -131
- package/dist/components/crud/views/Update.svelte +215 -215
- package/dist/components/crud/views/list/List.svelte +291 -291
- package/dist/components/crud/views/list/Modals.svelte +56 -56
- package/dist/components/crud/views/list/Table.svelte +173 -173
- package/dist/components/crud/views/list/Toolbar.svelte +340 -340
- package/dist/components/form/Button.svelte +27 -27
- package/dist/components/form/Label.svelte +37 -37
- package/dist/components/form/MultiSelect.svelte +248 -248
- package/dist/components/form/PasswordInput.svelte +68 -68
- package/dist/components/form/Required.svelte +1 -1
- package/dist/components/form/Select.svelte +209 -209
- package/dist/components/form/Tree.svelte +43 -4
- package/dist/components/form/Tree.svelte.d.ts +1 -0
- package/dist/components/form/TreeNode.svelte +31 -2
- package/dist/components/form/TreeNode.svelte.d.ts +2 -0
- package/dist/components/navigation/Breadcrumbs.svelte +111 -111
- package/dist/components/table/ColumnFilter.svelte +168 -168
- package/dist/components/table/PaginatedTable.svelte +542 -542
- package/dist/components/table/Paginator.svelte +113 -113
- package/dist/components/table/SortHeader.svelte +43 -43
- package/dist/components/table/TableBody.svelte +150 -150
- package/dist/components/table/TableHeader.svelte +88 -88
- package/dist/components/table/state.svelte.js +7 -2
- package/dist/icons/defaults/Clear.svelte +6 -6
- package/dist/icons/defaults/Create.svelte +6 -6
- package/dist/icons/defaults/Delete.svelte +6 -6
- package/dist/icons/defaults/Download.svelte +7 -7
- package/dist/icons/defaults/Edit.svelte +7 -7
- package/dist/icons/defaults/Filter.svelte +6 -6
- package/dist/icons/defaults/FilterActive.svelte +6 -6
- package/dist/icons/defaults/Folder.svelte +6 -6
- package/dist/icons/defaults/Grip.svelte +7 -7
- package/dist/icons/defaults/Home.svelte +6 -6
- package/dist/icons/defaults/PasswordHide.svelte +9 -9
- package/dist/icons/defaults/PasswordShow.svelte +7 -7
- package/dist/icons/defaults/SortAsc.svelte +6 -6
- package/dist/icons/defaults/SortDesc.svelte +6 -6
- package/dist/icons/defaults/SortNone.svelte +6 -6
- package/dist/icons/defaults/View.svelte +7 -7
- package/dist/types/attribute.d.ts +3 -0
- package/dist/types/crud/fields.d.ts +3 -0
- package/package.json +1 -1
|
@@ -1,215 +1,215 @@
|
|
|
1
|
-
<script lang="ts" generics="T extends object = Record<string, unknown>">
|
|
2
|
-
import { untrack } from 'svelte';
|
|
3
|
-
import { enhance } from '$app/forms';
|
|
4
|
-
import Field from '../Field.svelte';
|
|
5
|
-
import Button from '../../form/Button.svelte';
|
|
6
|
-
import Header from '../../common/Header.svelte';
|
|
7
|
-
import { getIconSet } from '../../../icons/context.js';
|
|
8
|
-
import { defaultIconSet } from '../../../icons/sets/default.js';
|
|
9
|
-
import { validateAll } from '../utils/validation.js';
|
|
10
|
-
import { groupFields } from '../utils/grouping.js';
|
|
11
|
-
import { applyDuplicateOmit, seedRecord } from '../utils/embedded.js';
|
|
12
|
-
import type { ActionConfiguration } from '../../../types/crud/actions.js';
|
|
13
|
-
import type { FieldDefinition } from '../../../types/crud/fields.js';
|
|
14
|
-
import { getStrings } from '../../../i18n/context.js';
|
|
15
|
-
|
|
16
|
-
const strings = getStrings();
|
|
17
|
-
|
|
18
|
-
let {
|
|
19
|
-
labelOne = '',
|
|
20
|
-
labelMany = '',
|
|
21
|
-
icon,
|
|
22
|
-
idKey = '_id',
|
|
23
|
-
fields = [] as FieldDefinition<T>[],
|
|
24
|
-
instance = {} as T,
|
|
25
|
-
update = {} as ActionConfiguration<T>,
|
|
26
|
-
serverError = '',
|
|
27
|
-
onCancel,
|
|
28
|
-
onSuccess,
|
|
29
|
-
onContinue,
|
|
30
|
-
onDuplicate,
|
|
31
|
-
}: {
|
|
32
|
-
labelOne?: string;
|
|
33
|
-
labelMany?: string;
|
|
34
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
35
|
-
icon?: any;
|
|
36
|
-
idKey?: string;
|
|
37
|
-
fields?: FieldDefinition<T>[];
|
|
38
|
-
instance?: T;
|
|
39
|
-
update?: ActionConfiguration<T>;
|
|
40
|
-
serverError?: string;
|
|
41
|
-
onCancel?: () => void;
|
|
42
|
-
onSuccess?: () => void;
|
|
43
|
-
onContinue?: () => void;
|
|
44
|
-
onDuplicate?: (record: Record<string, unknown>) => void;
|
|
45
|
-
} = $props();
|
|
46
|
-
|
|
47
|
-
const icons = $derived(getIconSet() ?? defaultIconSet);
|
|
48
|
-
const entityIcon = $derived(icon ?? icons.folder);
|
|
49
|
-
|
|
50
|
-
let fieldErrors = $state<Record<string, string>>({});
|
|
51
|
-
let internalError = $state('');
|
|
52
|
-
let continuing = $state(false);
|
|
53
|
-
let duplicating = $state(false);
|
|
54
|
-
|
|
55
|
-
let record = $state<Record<string, unknown>>(
|
|
56
|
-
untrack(() => seedRecord(fields, instance as Record<string, unknown>))
|
|
57
|
-
);
|
|
58
|
-
|
|
59
|
-
$effect(() => {
|
|
60
|
-
const id = (instance as Record<string, unknown>)[idKey];
|
|
61
|
-
if (!id) return;
|
|
62
|
-
untrack(() => { record = seedRecord(fields, instance as Record<string, unknown>); });
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
const groups = $derived(groupFields(fields));
|
|
66
|
-
const hasFileField = $derived(fields.some((f) => f.type === 'file'));
|
|
67
|
-
|
|
68
|
-
const continueEnabled = $derived(update.continue?.enabled ?? false);
|
|
69
|
-
const continueLabel = $derived(update.continue?.label ?? strings.saveAndContinue);
|
|
70
|
-
const continueClass = $derived(update.continue?.class ?? '');
|
|
71
|
-
|
|
72
|
-
const duplicationEnabled = $derived(update.duplication?.enabled ?? false);
|
|
73
|
-
const duplicationLabel = $derived(update.duplication?.label ?? strings.duplicate);
|
|
74
|
-
const duplicationClass = $derived(update.duplication?.class ?? '');
|
|
75
|
-
|
|
76
|
-
const errorEntries = $derived([
|
|
77
|
-
...((serverError || internalError) ? [['_global', internalError || serverError] as [string, string]] : []),
|
|
78
|
-
...Object.entries(fieldErrors),
|
|
79
|
-
]);
|
|
80
|
-
</script>
|
|
81
|
-
|
|
82
|
-
<div class="flex flex-col gap-6">
|
|
83
|
-
|
|
84
|
-
<div class="sticky-header sticky z-10 flex flex-col gap-6 bg-base-100 pb-2">
|
|
85
|
-
<Header
|
|
86
|
-
title={labelMany}
|
|
87
|
-
breadcrumbs={[
|
|
88
|
-
{ label: labelMany, icon: entityIcon, link: { href: '#', onclick: (e) => { e.preventDefault(); onCancel?.(); } }, prominent: true },
|
|
89
|
-
{ label: update.label ?? labelOne, icon: icons.edit },
|
|
90
|
-
]}
|
|
91
|
-
/>
|
|
92
|
-
|
|
93
|
-
{#if errorEntries.length > 0}
|
|
94
|
-
<div role="alert" class="alert alert-error">
|
|
95
|
-
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 shrink-0" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
96
|
-
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z" />
|
|
97
|
-
</svg>
|
|
98
|
-
<ul class="list-disc list-inside text-sm">
|
|
99
|
-
{#each errorEntries as [key, msg] (key)}
|
|
100
|
-
<li>{msg}</li>
|
|
101
|
-
{/each}
|
|
102
|
-
</ul>
|
|
103
|
-
</div>
|
|
104
|
-
{/if}
|
|
105
|
-
</div>
|
|
106
|
-
|
|
107
|
-
<form
|
|
108
|
-
method="POST"
|
|
109
|
-
action={update.endpoint ?? '?/update'}
|
|
110
|
-
enctype={hasFileField ? 'multipart/form-data' : undefined}
|
|
111
|
-
class="mx-auto flex w-full flex-col gap-4 px-4"
|
|
112
|
-
use:enhance={({ formData, cancel }) => {
|
|
113
|
-
fieldErrors = {};
|
|
114
|
-
internalError = '';
|
|
115
|
-
const errs = validateAll(fields, formData, strings);
|
|
116
|
-
if (Object.keys(errs).length > 0) {
|
|
117
|
-
fieldErrors = errs;
|
|
118
|
-
cancel();
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
return async ({ result, update: updateForm }) => {
|
|
122
|
-
if (result.type === 'success' || result.type === 'redirect') {
|
|
123
|
-
await updateForm({ reset: false });
|
|
124
|
-
if (continuing) {
|
|
125
|
-
continuing = false;
|
|
126
|
-
onContinue?.();
|
|
127
|
-
} else if (duplicating) {
|
|
128
|
-
duplicating = false;
|
|
129
|
-
onDuplicate?.(applyDuplicateOmit(fields, record, update.duplication?.omit));
|
|
130
|
-
} else {
|
|
131
|
-
onSuccess?.();
|
|
132
|
-
}
|
|
133
|
-
} else if (result.type === 'error') {
|
|
134
|
-
internalError = result.error?.message ?? strings.serverError;
|
|
135
|
-
} else {
|
|
136
|
-
await updateForm({ reset: false });
|
|
137
|
-
}
|
|
138
|
-
};
|
|
139
|
-
}}
|
|
140
|
-
>
|
|
141
|
-
<input type="hidden" name="id" value={String(record[idKey] ?? '')} />
|
|
142
|
-
|
|
143
|
-
{#each groups as group, i (group.title ?? `_ungrouped_${i}`)}
|
|
144
|
-
{#if group.title}
|
|
145
|
-
<fieldset class="fieldset border border-base-300 rounded-box p-4">
|
|
146
|
-
<legend class="fieldset-legend px-2">{group.title}</legend>
|
|
147
|
-
<div class="flex flex-col gap-4">
|
|
148
|
-
{#each group.rows as row (row.map((f) => f.attribute).join('|'))}
|
|
149
|
-
{#if row.length > 1}
|
|
150
|
-
<div class="flex flex-col gap-4 md:flex-row">
|
|
151
|
-
{#each row as field (field.attribute)}
|
|
152
|
-
<Field {field} bind:record error={fieldErrors[field.attribute] ?? ''} class="md:min-w-0 md:flex-1" />
|
|
153
|
-
{/each}
|
|
154
|
-
</div>
|
|
155
|
-
{:else}
|
|
156
|
-
<Field field={row[0]} bind:record error={fieldErrors[row[0].attribute] ?? ''} />
|
|
157
|
-
{/if}
|
|
158
|
-
{/each}
|
|
159
|
-
</div>
|
|
160
|
-
</fieldset>
|
|
161
|
-
{:else}
|
|
162
|
-
{#each group.rows as row (row.map((f) => f.attribute).join('|'))}
|
|
163
|
-
{#if row.length > 1}
|
|
164
|
-
<div class="flex flex-col gap-4 md:flex-row">
|
|
165
|
-
{#each row as field (field.attribute)}
|
|
166
|
-
<Field {field} bind:record error={fieldErrors[field.attribute] ?? ''} class="md:min-w-0 md:flex-1" />
|
|
167
|
-
{/each}
|
|
168
|
-
</div>
|
|
169
|
-
{:else}
|
|
170
|
-
<Field field={row[0]} bind:record error={fieldErrors[row[0].attribute] ?? ''} />
|
|
171
|
-
{/if}
|
|
172
|
-
{/each}
|
|
173
|
-
{/if}
|
|
174
|
-
{/each}
|
|
175
|
-
|
|
176
|
-
<div class="flex flex-col-reverse gap-2 pt-2 sm:flex-row sm:justify-end">
|
|
177
|
-
<Button variant="ghost" onclick={() => onCancel?.()}>
|
|
178
|
-
{strings.cancel}
|
|
179
|
-
</Button>
|
|
180
|
-
{#if duplicationEnabled}
|
|
181
|
-
<Button
|
|
182
|
-
type="submit"
|
|
183
|
-
variant="warning"
|
|
184
|
-
class={duplicationClass}
|
|
185
|
-
onclick={() => { continuing = false; duplicating = true; }}
|
|
186
|
-
>
|
|
187
|
-
{duplicationLabel}
|
|
188
|
-
</Button>
|
|
189
|
-
{/if}
|
|
190
|
-
{#if continueEnabled}
|
|
191
|
-
<Button
|
|
192
|
-
type="submit"
|
|
193
|
-
variant="secondary"
|
|
194
|
-
class={continueClass}
|
|
195
|
-
onclick={() => { continuing = true; duplicating = false; }}
|
|
196
|
-
>
|
|
197
|
-
{continueLabel}
|
|
198
|
-
</Button>
|
|
199
|
-
{/if}
|
|
200
|
-
<Button type="submit" variant="primary" onclick={() => { continuing = false; duplicating = false; }}>
|
|
201
|
-
{strings.save}
|
|
202
|
-
</Button>
|
|
203
|
-
</div>
|
|
204
|
-
</form>
|
|
205
|
-
</div>
|
|
206
|
-
|
|
207
|
-
<style>
|
|
208
|
-
form {
|
|
209
|
-
max-width: var(--runeforge-form-max-width, 32rem);
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
.sticky-header {
|
|
213
|
-
top: var(--runeforge-sticky-header-top, 0);
|
|
214
|
-
}
|
|
215
|
-
</style>
|
|
1
|
+
<script lang="ts" generics="T extends object = Record<string, unknown>">
|
|
2
|
+
import { untrack } from 'svelte';
|
|
3
|
+
import { enhance } from '$app/forms';
|
|
4
|
+
import Field from '../Field.svelte';
|
|
5
|
+
import Button from '../../form/Button.svelte';
|
|
6
|
+
import Header from '../../common/Header.svelte';
|
|
7
|
+
import { getIconSet } from '../../../icons/context.js';
|
|
8
|
+
import { defaultIconSet } from '../../../icons/sets/default.js';
|
|
9
|
+
import { validateAll } from '../utils/validation.js';
|
|
10
|
+
import { groupFields } from '../utils/grouping.js';
|
|
11
|
+
import { applyDuplicateOmit, seedRecord } from '../utils/embedded.js';
|
|
12
|
+
import type { ActionConfiguration } from '../../../types/crud/actions.js';
|
|
13
|
+
import type { FieldDefinition } from '../../../types/crud/fields.js';
|
|
14
|
+
import { getStrings } from '../../../i18n/context.js';
|
|
15
|
+
|
|
16
|
+
const strings = getStrings();
|
|
17
|
+
|
|
18
|
+
let {
|
|
19
|
+
labelOne = '',
|
|
20
|
+
labelMany = '',
|
|
21
|
+
icon,
|
|
22
|
+
idKey = '_id',
|
|
23
|
+
fields = [] as FieldDefinition<T>[],
|
|
24
|
+
instance = {} as T,
|
|
25
|
+
update = {} as ActionConfiguration<T>,
|
|
26
|
+
serverError = '',
|
|
27
|
+
onCancel,
|
|
28
|
+
onSuccess,
|
|
29
|
+
onContinue,
|
|
30
|
+
onDuplicate,
|
|
31
|
+
}: {
|
|
32
|
+
labelOne?: string;
|
|
33
|
+
labelMany?: string;
|
|
34
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
35
|
+
icon?: any;
|
|
36
|
+
idKey?: string;
|
|
37
|
+
fields?: FieldDefinition<T>[];
|
|
38
|
+
instance?: T;
|
|
39
|
+
update?: ActionConfiguration<T>;
|
|
40
|
+
serverError?: string;
|
|
41
|
+
onCancel?: () => void;
|
|
42
|
+
onSuccess?: () => void;
|
|
43
|
+
onContinue?: () => void;
|
|
44
|
+
onDuplicate?: (record: Record<string, unknown>) => void;
|
|
45
|
+
} = $props();
|
|
46
|
+
|
|
47
|
+
const icons = $derived(getIconSet() ?? defaultIconSet);
|
|
48
|
+
const entityIcon = $derived(icon ?? icons.folder);
|
|
49
|
+
|
|
50
|
+
let fieldErrors = $state<Record<string, string>>({});
|
|
51
|
+
let internalError = $state('');
|
|
52
|
+
let continuing = $state(false);
|
|
53
|
+
let duplicating = $state(false);
|
|
54
|
+
|
|
55
|
+
let record = $state<Record<string, unknown>>(
|
|
56
|
+
untrack(() => seedRecord(fields, instance as Record<string, unknown>))
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
$effect(() => {
|
|
60
|
+
const id = (instance as Record<string, unknown>)[idKey];
|
|
61
|
+
if (!id) return;
|
|
62
|
+
untrack(() => { record = seedRecord(fields, instance as Record<string, unknown>); });
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
const groups = $derived(groupFields(fields));
|
|
66
|
+
const hasFileField = $derived(fields.some((f) => f.type === 'file'));
|
|
67
|
+
|
|
68
|
+
const continueEnabled = $derived(update.continue?.enabled ?? false);
|
|
69
|
+
const continueLabel = $derived(update.continue?.label ?? strings.saveAndContinue);
|
|
70
|
+
const continueClass = $derived(update.continue?.class ?? '');
|
|
71
|
+
|
|
72
|
+
const duplicationEnabled = $derived(update.duplication?.enabled ?? false);
|
|
73
|
+
const duplicationLabel = $derived(update.duplication?.label ?? strings.duplicate);
|
|
74
|
+
const duplicationClass = $derived(update.duplication?.class ?? '');
|
|
75
|
+
|
|
76
|
+
const errorEntries = $derived([
|
|
77
|
+
...((serverError || internalError) ? [['_global', internalError || serverError] as [string, string]] : []),
|
|
78
|
+
...Object.entries(fieldErrors),
|
|
79
|
+
]);
|
|
80
|
+
</script>
|
|
81
|
+
|
|
82
|
+
<div class="flex flex-col gap-6">
|
|
83
|
+
|
|
84
|
+
<div class="sticky-header sticky z-10 flex flex-col gap-6 bg-base-100 pb-2">
|
|
85
|
+
<Header
|
|
86
|
+
title={labelMany}
|
|
87
|
+
breadcrumbs={[
|
|
88
|
+
{ label: labelMany, icon: entityIcon, link: { href: '#', onclick: (e) => { e.preventDefault(); onCancel?.(); } }, prominent: true },
|
|
89
|
+
{ label: update.label ?? labelOne, icon: icons.edit },
|
|
90
|
+
]}
|
|
91
|
+
/>
|
|
92
|
+
|
|
93
|
+
{#if errorEntries.length > 0}
|
|
94
|
+
<div role="alert" class="alert alert-error">
|
|
95
|
+
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 shrink-0" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
96
|
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z" />
|
|
97
|
+
</svg>
|
|
98
|
+
<ul class="list-disc list-inside text-sm">
|
|
99
|
+
{#each errorEntries as [key, msg] (key)}
|
|
100
|
+
<li>{msg}</li>
|
|
101
|
+
{/each}
|
|
102
|
+
</ul>
|
|
103
|
+
</div>
|
|
104
|
+
{/if}
|
|
105
|
+
</div>
|
|
106
|
+
|
|
107
|
+
<form
|
|
108
|
+
method="POST"
|
|
109
|
+
action={update.endpoint ?? '?/update'}
|
|
110
|
+
enctype={hasFileField ? 'multipart/form-data' : undefined}
|
|
111
|
+
class="mx-auto flex w-full flex-col gap-4 px-4"
|
|
112
|
+
use:enhance={({ formData, cancel }) => {
|
|
113
|
+
fieldErrors = {};
|
|
114
|
+
internalError = '';
|
|
115
|
+
const errs = validateAll(fields, formData, strings);
|
|
116
|
+
if (Object.keys(errs).length > 0) {
|
|
117
|
+
fieldErrors = errs;
|
|
118
|
+
cancel();
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
return async ({ result, update: updateForm }) => {
|
|
122
|
+
if (result.type === 'success' || result.type === 'redirect') {
|
|
123
|
+
await updateForm({ reset: false });
|
|
124
|
+
if (continuing) {
|
|
125
|
+
continuing = false;
|
|
126
|
+
onContinue?.();
|
|
127
|
+
} else if (duplicating) {
|
|
128
|
+
duplicating = false;
|
|
129
|
+
onDuplicate?.(applyDuplicateOmit(fields, record, update.duplication?.omit));
|
|
130
|
+
} else {
|
|
131
|
+
onSuccess?.();
|
|
132
|
+
}
|
|
133
|
+
} else if (result.type === 'error') {
|
|
134
|
+
internalError = result.error?.message ?? strings.serverError;
|
|
135
|
+
} else {
|
|
136
|
+
await updateForm({ reset: false });
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
}}
|
|
140
|
+
>
|
|
141
|
+
<input type="hidden" name="id" value={String(record[idKey] ?? '')} />
|
|
142
|
+
|
|
143
|
+
{#each groups as group, i (group.title ?? `_ungrouped_${i}`)}
|
|
144
|
+
{#if group.title}
|
|
145
|
+
<fieldset class="fieldset border border-base-300 rounded-box p-4">
|
|
146
|
+
<legend class="fieldset-legend px-2">{group.title}</legend>
|
|
147
|
+
<div class="flex flex-col gap-4">
|
|
148
|
+
{#each group.rows as row (row.map((f) => f.attribute).join('|'))}
|
|
149
|
+
{#if row.length > 1}
|
|
150
|
+
<div class="flex flex-col gap-4 md:flex-row">
|
|
151
|
+
{#each row as field (field.attribute)}
|
|
152
|
+
<Field {field} bind:record error={fieldErrors[field.attribute] ?? ''} class="md:min-w-0 md:flex-1" />
|
|
153
|
+
{/each}
|
|
154
|
+
</div>
|
|
155
|
+
{:else}
|
|
156
|
+
<Field field={row[0]} bind:record error={fieldErrors[row[0].attribute] ?? ''} />
|
|
157
|
+
{/if}
|
|
158
|
+
{/each}
|
|
159
|
+
</div>
|
|
160
|
+
</fieldset>
|
|
161
|
+
{:else}
|
|
162
|
+
{#each group.rows as row (row.map((f) => f.attribute).join('|'))}
|
|
163
|
+
{#if row.length > 1}
|
|
164
|
+
<div class="flex flex-col gap-4 md:flex-row">
|
|
165
|
+
{#each row as field (field.attribute)}
|
|
166
|
+
<Field {field} bind:record error={fieldErrors[field.attribute] ?? ''} class="md:min-w-0 md:flex-1" />
|
|
167
|
+
{/each}
|
|
168
|
+
</div>
|
|
169
|
+
{:else}
|
|
170
|
+
<Field field={row[0]} bind:record error={fieldErrors[row[0].attribute] ?? ''} />
|
|
171
|
+
{/if}
|
|
172
|
+
{/each}
|
|
173
|
+
{/if}
|
|
174
|
+
{/each}
|
|
175
|
+
|
|
176
|
+
<div class="flex flex-col-reverse gap-2 pt-2 sm:flex-row sm:justify-end">
|
|
177
|
+
<Button variant="ghost" onclick={() => onCancel?.()}>
|
|
178
|
+
{strings.cancel}
|
|
179
|
+
</Button>
|
|
180
|
+
{#if duplicationEnabled}
|
|
181
|
+
<Button
|
|
182
|
+
type="submit"
|
|
183
|
+
variant="warning"
|
|
184
|
+
class={duplicationClass}
|
|
185
|
+
onclick={() => { continuing = false; duplicating = true; }}
|
|
186
|
+
>
|
|
187
|
+
{duplicationLabel}
|
|
188
|
+
</Button>
|
|
189
|
+
{/if}
|
|
190
|
+
{#if continueEnabled}
|
|
191
|
+
<Button
|
|
192
|
+
type="submit"
|
|
193
|
+
variant="secondary"
|
|
194
|
+
class={continueClass}
|
|
195
|
+
onclick={() => { continuing = true; duplicating = false; }}
|
|
196
|
+
>
|
|
197
|
+
{continueLabel}
|
|
198
|
+
</Button>
|
|
199
|
+
{/if}
|
|
200
|
+
<Button type="submit" variant="primary" onclick={() => { continuing = false; duplicating = false; }}>
|
|
201
|
+
{strings.save}
|
|
202
|
+
</Button>
|
|
203
|
+
</div>
|
|
204
|
+
</form>
|
|
205
|
+
</div>
|
|
206
|
+
|
|
207
|
+
<style>
|
|
208
|
+
form {
|
|
209
|
+
max-width: var(--runeforge-form-max-width, 32rem);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
.sticky-header {
|
|
213
|
+
top: var(--runeforge-sticky-header-top, 0);
|
|
214
|
+
}
|
|
215
|
+
</style>
|