includio-cms 0.0.26 → 0.0.27
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/admin/assets/logo.svg +14 -0
- package/dist/admin/client/admin/admin-layout.svelte +1 -1
- package/dist/admin/client/collection/collection-page.svelte +2 -3
- package/dist/admin/client/form/columns.d.ts +7 -0
- package/dist/admin/client/form/columns.js +21 -0
- package/dist/admin/client/form/data-table.svelte +56 -0
- package/dist/admin/client/form/data-table.svelte.d.ts +29 -0
- package/dist/admin/client/form/form-page.svelte +35 -0
- package/dist/admin/client/form/form-page.svelte.d.ts +3 -0
- package/dist/admin/client/form/form-submission/form-submission-page.svelte +22 -0
- package/dist/admin/client/form/form-submission/form-submission-page.svelte.d.ts +3 -0
- package/dist/admin/client/form/form-submission/form-submission.svelte +44 -0
- package/dist/admin/client/form/form-submission/form-submission.svelte.d.ts +7 -0
- package/dist/admin/client/form/submission-link.svelte +12 -0
- package/dist/admin/client/form/submission-link.svelte.d.ts +7 -0
- package/dist/admin/client/index.d.ts +2 -0
- package/dist/admin/client/index.js +2 -0
- package/dist/admin/components/fields/array-field.svelte +30 -5
- package/dist/admin/components/fields/field-renderer.svelte +3 -0
- package/dist/admin/components/fields/relation-field.svelte +105 -0
- package/dist/admin/components/fields/relation-field.svelte.d.ts +30 -0
- package/dist/admin/components/fields/url-field.svelte +53 -61
- package/dist/admin/components/fields/url-field.svelte.d.ts +6 -6
- package/dist/admin/components/layout/app-sidebar.svelte +9 -3
- package/dist/admin/components/layout/nav-forms.svelte +24 -0
- package/dist/admin/components/layout/nav-forms.svelte.d.ts +9 -0
- package/dist/admin/components/layout/nav-main.svelte +1 -0
- package/dist/admin/components/layout/nav-singletons.svelte +4 -4
- package/dist/admin/components/layout/nav-singletons.svelte.d.ts +1 -1
- package/dist/admin/components/layout/nav-user.svelte +8 -0
- package/dist/admin/components/media/file-upload.svelte +16 -1
- package/dist/admin/components/media/media-library.svelte +145 -76
- package/dist/admin/remote/form.remote.d.ts +4 -0
- package/dist/admin/remote/form.remote.js +16 -0
- package/dist/admin/remote/index.d.ts +1 -0
- package/dist/admin/remote/index.js +1 -0
- package/dist/admin/styles/admin.css +15 -14
- package/dist/admin/utils/entryLabel.d.ts +3 -0
- package/dist/admin/utils/entryLabel.js +6 -0
- package/dist/components/ui/command/command-dialog.svelte +40 -0
- package/dist/components/ui/command/command-dialog.svelte.d.ts +12 -0
- package/dist/components/ui/command/command-empty.svelte +17 -0
- package/dist/components/ui/command/command-empty.svelte.d.ts +4 -0
- package/dist/components/ui/command/command-group.svelte +32 -0
- package/dist/components/ui/command/command-group.svelte.d.ts +7 -0
- package/dist/components/ui/command/command-input.svelte +26 -0
- package/dist/components/ui/command/command-input.svelte.d.ts +4 -0
- package/dist/components/ui/command/command-item.svelte +20 -0
- package/dist/components/ui/command/command-item.svelte.d.ts +4 -0
- package/dist/components/ui/command/command-link-item.svelte +20 -0
- package/dist/components/ui/command/command-link-item.svelte.d.ts +4 -0
- package/dist/components/ui/command/command-list.svelte +17 -0
- package/dist/components/ui/command/command-list.svelte.d.ts +4 -0
- package/dist/components/ui/command/command-separator.svelte +17 -0
- package/dist/components/ui/command/command-separator.svelte.d.ts +4 -0
- package/dist/components/ui/command/command-shortcut.svelte +20 -0
- package/dist/components/ui/command/command-shortcut.svelte.d.ts +5 -0
- package/dist/components/ui/command/command.svelte +28 -0
- package/dist/components/ui/command/command.svelte.d.ts +8 -0
- package/dist/components/ui/command/index.d.ts +13 -0
- package/dist/components/ui/command/index.js +15 -0
- package/dist/components/ui/dialog/dialog-content.svelte +1 -1
- package/dist/components/ui/sidebar/sidebar-input.svelte.d.ts +1 -1
- package/dist/core/cms.d.ts +3 -0
- package/dist/core/cms.js +10 -0
- package/dist/core/fields/fieldSchemaToTs.js +10 -9
- package/dist/core/fields/formFieldSchemaToTs.d.ts +4 -0
- package/dist/core/fields/formFieldSchemaToTs.js +33 -0
- package/dist/core/server/consentLogs/operations/create.d.ts +2 -0
- package/dist/core/server/consentLogs/operations/create.js +4 -0
- package/dist/core/server/entries/operations/get.js +24 -0
- package/dist/core/server/fields/populateEntry.js +4 -2
- package/dist/core/server/fields/resolveImageFields.js +11 -4
- package/dist/core/server/fields/resolveRelationFields.d.ts +3 -0
- package/dist/core/server/fields/resolveRelationFields.js +102 -0
- package/dist/core/server/fields/resolveUrlFields.d.ts +1 -1
- package/dist/core/server/fields/resolveUrlFields.js +13 -30
- package/dist/core/server/forms/submissions/operations/create.d.ts +1 -0
- package/dist/core/server/forms/submissions/operations/create.js +18 -0
- package/dist/core/server/forms/submissions/operations/get.d.ts +3 -0
- package/dist/core/server/forms/submissions/operations/get.js +7 -0
- package/dist/core/server/generator/fields.js +9 -3
- package/dist/core/server/generator/formFieldSchemaToString.d.ts +3 -0
- package/dist/core/server/generator/formFieldSchemaToString.js +32 -0
- package/dist/core/server/generator/formFields.d.ts +2 -0
- package/dist/core/server/generator/formFields.js +17 -0
- package/dist/core/server/generator/generator.js +64 -4
- package/dist/db-postgres/index.js +22 -0
- package/dist/db-postgres/schema/consentLog.d.ts +194 -0
- package/dist/db-postgres/schema/consentLog.js +14 -0
- package/dist/db-postgres/schema/formSubmission.d.ts +75 -0
- package/dist/db-postgres/schema/formSubmission.js +7 -0
- package/dist/db-postgres/schema/index.d.ts +2 -0
- package/dist/db-postgres/schema/index.js +2 -0
- package/dist/schemas/field/url.d.ts +21 -0
- package/dist/schemas/field/url.js +9 -0
- package/dist/sveltekit/config.d.ts +2 -0
- package/dist/sveltekit/config.js +3 -0
- package/dist/sveltekit/server/index.d.ts +2 -0
- package/dist/sveltekit/server/index.js +2 -0
- package/dist/types/adapters.d.ts +10 -0
- package/dist/types/cms.d.ts +3 -0
- package/dist/types/consent.d.ts +22 -0
- package/dist/types/consent.js +1 -0
- package/dist/types/fields.d.ts +2 -2
- package/dist/types/formFields.d.ts +25 -0
- package/dist/types/formFields.js +1 -0
- package/dist/types/forms.d.ts +12 -0
- package/dist/types/forms.js +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +1 -0
- package/package.json +4 -4
- /package/dist/core/server/generator/{fieldSchemaToString.d.ts → fieldSchemaToString copy.d.ts} +0 -0
- /package/dist/core/server/generator/{fieldSchemaToString.js → fieldSchemaToString copy.js} +0 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<svg width="144" height="32" viewBox="0 0 144 32" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path d="M4.06697 18.4123V31.7521H0V18.4123H4.06697ZM4.06697 13.2054V16.8998H0V13.2054H4.06697Z" fill="#263754"/>
|
|
3
|
+
<path d="M19.7916 23.2225V31.7521H15.7495V24.2639C15.7495 22.5035 15.0303 21.7596 13.9392 21.7596C12.9472 21.7596 11.5833 22.6275 11.0129 24.1152V31.7521H6.94598V18.4123H10.6162V20.6687C11.6329 19.0074 13.3688 18.1644 15.7991 18.1644C19.1965 18.1644 19.7916 20.9166 19.7916 23.2225Z" fill="#263754"/>
|
|
4
|
+
<path d="M28.9695 32C24.2826 32 21.8275 28.6031 21.8275 25.0822C21.8275 21.2637 24.5553 18.1644 28.9695 18.1644C31.9453 18.1644 34.1276 19.5033 35.2187 21.6853L31.2758 22.9002C30.755 22.0324 29.9614 21.6109 28.9447 21.6109C27.3328 21.6109 25.9937 22.8754 25.9937 25.0822C25.9937 27.2641 27.3576 28.5783 28.9447 28.5783C29.9614 28.5783 30.755 28.132 31.3006 27.2641L35.2435 28.4791C34.326 30.4875 32.2181 32 28.9695 32Z" fill="#263754"/>
|
|
5
|
+
<path d="M40.776 31.9752C38.4945 31.9752 37.1306 30.785 37.1306 28.4295L36.9995 17.6942H41.1976V27.0162C41.1976 28.0328 41.6191 28.5287 42.4871 28.5287C42.9087 28.5287 43.355 28.4047 43.851 28.1816L44.3718 31.2066C43.1567 31.7273 41.9415 31.9752 40.776 31.9752Z" fill="#263754"/>
|
|
6
|
+
<path d="M49.8299 32C47.0276 32 45.6637 30.2147 45.6637 26.9418V18.4123H49.7307V26.074C49.7307 27.7352 50.3506 28.5535 51.5906 28.5783C52.8057 28.5783 53.7728 27.9336 54.5168 26.6443V18.4123H58.559V27.1898C58.559 27.9584 58.8565 28.3303 59.4269 28.3303V31.7521C58.7573 31.876 58.187 31.9504 57.7158 31.9504C56.2527 31.9504 55.4343 31.3801 55.2111 30.2644L55.1368 29.4461C53.9216 31.157 52.1609 32 49.8299 32Z" fill="#263754"/>
|
|
7
|
+
<path d="M67.3648 32C65.5049 32 63.9922 31.3305 62.8267 30.0164C61.6612 28.6775 61.066 27.041 61.066 25.0822C61.066 23.1234 61.6116 21.4869 62.7027 20.1728C63.8186 18.8338 65.2322 18.1644 66.9433 18.1644C68.8031 18.1644 70.3903 19.1066 71.2086 20.5943V13.2054H75.2756V27.1898C75.2756 27.9584 75.5732 28.3303 76.1435 28.3303V31.7521C75.5236 31.876 74.9532 31.9504 74.4076 31.9504C72.9445 31.9504 72.1014 31.3801 71.9278 30.2396L71.8534 29.5453C70.8614 31.2314 69.1503 32 67.3648 32ZM68.456 28.5783C69.5471 28.5783 70.663 27.9088 71.2334 26.7186V23.9416C70.663 22.4787 69.3983 21.6109 68.2328 21.6109C67.5632 21.6109 66.9929 21.8092 66.5217 22.2307C65.6785 22.9498 65.257 23.9416 65.257 25.1566C65.257 27.3137 66.6705 28.5783 68.456 28.5783Z" fill="#263754"/>
|
|
8
|
+
<path d="M82.5935 18.4123V31.7521H78.5266V18.4123H82.5935ZM82.5935 13.2054V16.8998H78.5266V13.2054H82.5935Z" fill="#263754"/>
|
|
9
|
+
<path d="M91.821 32C87.1093 32 84.7038 28.6031 84.7038 25.107C84.7038 21.3877 87.3324 18.1644 91.821 18.1644C96.2847 18.1644 98.963 21.3877 98.963 25.107C98.963 28.7518 96.4583 32 91.821 32ZM91.821 28.5783C92.7137 28.5783 93.4329 28.2311 93.9537 27.5617C94.4992 26.8674 94.772 26.0492 94.772 25.107C94.772 22.9994 93.5073 21.6109 91.821 21.6109C91.0274 21.6109 90.3083 21.9332 89.6883 22.5779C89.1427 23.2721 88.87 24.1152 88.87 25.107C88.87 27.2145 90.0603 28.5783 91.821 28.5783Z" fill="#263754"/>
|
|
10
|
+
<path d="M110.502 31.7149C106.708 31.7706 103.918 28.1444 103.956 24.7413C103.956 23.5697 104.272 22.4168 104.904 21.2824C105.537 20.148 106.504 19.2554 107.806 18.6045C108.624 18.214 109.554 18.0095 110.614 18.0095C113.199 18.0095 115.003 19.2368 115.878 20.9662L113.85 22.3424C113.125 20.8733 111.823 20.334 110.54 20.334C108.01 20.334 106.615 22.5283 106.615 24.8157C106.615 26.0988 106.987 27.1774 107.75 28.07C108.512 28.944 109.442 29.3903 110.577 29.3903C111.916 29.3903 113.292 28.7395 113.906 27.3447L116.064 28.5721C115.599 29.5763 114.836 30.3573 113.739 30.8966C112.66 31.4359 111.581 31.7149 110.502 31.7149Z" fill="#263754"/>
|
|
11
|
+
<path d="M131.482 18.0838V31.6033H128.86V22.6585L125.363 29.3159H123.931L120.453 22.6585V31.6033H117.83V18.0838H120.639L124.638 25.7827L128.674 18.0838H131.482Z" fill="#263754"/>
|
|
12
|
+
<path d="M138.996 31.7521C136.932 31.7521 135.034 31.1756 133.323 30.004L134.476 27.7353C134.923 28.1816 136.894 29.3903 139.033 29.3903C140.465 29.3903 141.191 28.9254 141.191 27.9956C141.191 26.8984 139.945 26.5079 137.88 25.95L137.694 25.8942C135.239 25.2248 133.863 24.3694 133.863 22.2308C133.863 19.4971 136.057 17.9909 138.791 17.9909C140.521 17.9909 142.083 18.493 143.516 19.4971L142.362 21.6171C142.046 21.2638 140.41 20.2968 138.717 20.2968C137.285 20.2968 136.578 20.7803 136.578 21.7659C136.578 22.3424 136.839 22.7701 137.341 23.0118C137.861 23.2536 138.643 23.4953 139.666 23.7371C142.158 24.3694 143.999 25.1876 143.999 27.7353C144.055 30.7107 141.47 31.7149 138.996 31.7521Z" fill="#263754"/>
|
|
13
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M24.005 3.7459C31.2491 3.7459 36.9995 9.61754 36.9995 16.8606H41.2076C41.2076 7.43918 33.4278 0 24.005 0C14.5823 0 6.9436 7.43918 6.9436 16.8606H10.6138C10.6138 9.61754 16.7609 3.7459 24.005 3.7459Z" fill="#4975AE"/>
|
|
14
|
+
</svg>
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
import { getRemotes } from '../../context/remotes.js';
|
|
11
11
|
import { getContentLanguage } from '../../state/content-language.svelte.js';
|
|
12
12
|
import { getAtPath } from '../../utils/objectPath.js';
|
|
13
|
+
import { getCollectionEntryLabel } from '../../utils/entryLabel.js';
|
|
13
14
|
|
|
14
15
|
const remotes = getRemotes();
|
|
15
16
|
|
|
@@ -41,9 +42,7 @@
|
|
|
41
42
|
.map((entry) => ({
|
|
42
43
|
id: entry.id,
|
|
43
44
|
collection: entry.slug,
|
|
44
|
-
name: collection
|
|
45
|
-
? getAtPath(entry.data, collection.entryAdminTitle)[getContentLanguage()] || entry.id
|
|
46
|
-
: entry.id,
|
|
45
|
+
name: getCollectionEntryLabel(entry, collection, getContentLanguage()),
|
|
47
46
|
url: `/admin/entries/${entry.id}`,
|
|
48
47
|
status: entry.status,
|
|
49
48
|
createdAt: entry.createdAt,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { renderComponent } from '../../../components/ui/data-table/render-helpers.js';
|
|
2
|
+
import SubmissionLink from './submission-link.svelte';
|
|
3
|
+
export const columns = [
|
|
4
|
+
{
|
|
5
|
+
accessorKey: 'id',
|
|
6
|
+
header: 'ID',
|
|
7
|
+
cell: (info) => {
|
|
8
|
+
return renderComponent(SubmissionLink, {
|
|
9
|
+
name: info.row.original.id,
|
|
10
|
+
url: info.row.original.url
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
accessorKey: 'createdAt',
|
|
16
|
+
header: 'Created At',
|
|
17
|
+
cell: (info) => {
|
|
18
|
+
return new Date(info.row.original.createdAt).toLocaleString('pl');
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
];
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
<script lang="ts" generics="TData, TValue">
|
|
2
|
+
import { type ColumnDef, getCoreRowModel } from '@tanstack/table-core';
|
|
3
|
+
import { createSvelteTable, FlexRender } from '../../../components/ui/data-table/index.js';
|
|
4
|
+
import * as Table from '../../../components/ui/table/index.js';
|
|
5
|
+
|
|
6
|
+
type DataTableProps<TData, TValue> = {
|
|
7
|
+
columns: ColumnDef<TData, TValue>[];
|
|
8
|
+
data: TData[];
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
let { data, columns }: DataTableProps<TData, TValue> = $props();
|
|
12
|
+
|
|
13
|
+
const table = createSvelteTable({
|
|
14
|
+
get data() {
|
|
15
|
+
return data;
|
|
16
|
+
},
|
|
17
|
+
columns,
|
|
18
|
+
getCoreRowModel: getCoreRowModel()
|
|
19
|
+
});
|
|
20
|
+
</script>
|
|
21
|
+
|
|
22
|
+
<div class="rounded-md border">
|
|
23
|
+
<Table.Root>
|
|
24
|
+
<Table.Header>
|
|
25
|
+
{#each table.getHeaderGroups() as headerGroup (headerGroup.id)}
|
|
26
|
+
<Table.Row>
|
|
27
|
+
{#each headerGroup.headers as header (header.id)}
|
|
28
|
+
<Table.Head>
|
|
29
|
+
{#if !header.isPlaceholder}
|
|
30
|
+
<FlexRender
|
|
31
|
+
content={header.column.columnDef.header}
|
|
32
|
+
context={header.getContext()}
|
|
33
|
+
/>
|
|
34
|
+
{/if}
|
|
35
|
+
</Table.Head>
|
|
36
|
+
{/each}
|
|
37
|
+
</Table.Row>
|
|
38
|
+
{/each}
|
|
39
|
+
</Table.Header>
|
|
40
|
+
<Table.Body>
|
|
41
|
+
{#each table.getRowModel().rows as row (row.id)}
|
|
42
|
+
<Table.Row data-state={row.getIsSelected() && 'selected'}>
|
|
43
|
+
{#each row.getVisibleCells() as cell (cell.id)}
|
|
44
|
+
<Table.Cell>
|
|
45
|
+
<FlexRender content={cell.column.columnDef.cell} context={cell.getContext()} />
|
|
46
|
+
</Table.Cell>
|
|
47
|
+
{/each}
|
|
48
|
+
</Table.Row>
|
|
49
|
+
{:else}
|
|
50
|
+
<Table.Row>
|
|
51
|
+
<Table.Cell colspan={columns.length} class="h-24 text-center">No results.</Table.Cell>
|
|
52
|
+
</Table.Row>
|
|
53
|
+
{/each}
|
|
54
|
+
</Table.Body>
|
|
55
|
+
</Table.Root>
|
|
56
|
+
</div>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type ColumnDef } from '@tanstack/table-core';
|
|
2
|
+
type DataTableProps<TData, TValue> = {
|
|
3
|
+
columns: ColumnDef<TData, TValue>[];
|
|
4
|
+
data: TData[];
|
|
5
|
+
};
|
|
6
|
+
declare function $$render<TData, TValue>(): {
|
|
7
|
+
props: DataTableProps<TData, TValue>;
|
|
8
|
+
exports: {};
|
|
9
|
+
bindings: "";
|
|
10
|
+
slots: {};
|
|
11
|
+
events: {};
|
|
12
|
+
};
|
|
13
|
+
declare class __sveltets_Render<TData, TValue> {
|
|
14
|
+
props(): ReturnType<typeof $$render<TData, TValue>>['props'];
|
|
15
|
+
events(): ReturnType<typeof $$render<TData, TValue>>['events'];
|
|
16
|
+
slots(): ReturnType<typeof $$render<TData, TValue>>['slots'];
|
|
17
|
+
bindings(): "";
|
|
18
|
+
exports(): {};
|
|
19
|
+
}
|
|
20
|
+
interface $$IsomorphicComponent {
|
|
21
|
+
new <TData, TValue>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<TData, TValue>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<TData, TValue>['props']>, ReturnType<__sveltets_Render<TData, TValue>['events']>, ReturnType<__sveltets_Render<TData, TValue>['slots']>> & {
|
|
22
|
+
$$bindings?: ReturnType<__sveltets_Render<TData, TValue>['bindings']>;
|
|
23
|
+
} & ReturnType<__sveltets_Render<TData, TValue>['exports']>;
|
|
24
|
+
<TData, TValue>(internal: unknown, props: ReturnType<__sveltets_Render<TData, TValue>['props']> & {}): ReturnType<__sveltets_Render<TData, TValue>['exports']>;
|
|
25
|
+
z_$$bindings?: ReturnType<__sveltets_Render<any, any>['bindings']>;
|
|
26
|
+
}
|
|
27
|
+
declare const DataTable: $$IsomorphicComponent;
|
|
28
|
+
type DataTable<TData, TValue> = InstanceType<typeof DataTable<TData, TValue>>;
|
|
29
|
+
export default DataTable;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { page } from '$app/state';
|
|
3
|
+
import DataTable from './data-table.svelte';
|
|
4
|
+
import { columns } from './columns.js';
|
|
5
|
+
|
|
6
|
+
import { breadcrumbs } from '../../state/breadcrumbs.svelte';
|
|
7
|
+
import { getRemotes } from '../../context/remotes.js';
|
|
8
|
+
|
|
9
|
+
const remotes = getRemotes();
|
|
10
|
+
|
|
11
|
+
const formConfig = $derived(await remotes.getForm(page.params.form || ''));
|
|
12
|
+
|
|
13
|
+
const formSubmissionsQuery = $derived(remotes.getFormSubmissions(formConfig.slug));
|
|
14
|
+
|
|
15
|
+
$effect(() => {
|
|
16
|
+
breadcrumbs.state = [
|
|
17
|
+
{
|
|
18
|
+
label: formConfig.label || formConfig.slug
|
|
19
|
+
}
|
|
20
|
+
];
|
|
21
|
+
});
|
|
22
|
+
</script>
|
|
23
|
+
|
|
24
|
+
{#if formConfig}
|
|
25
|
+
<div class="p-4 md:p-6">
|
|
26
|
+
{#await formSubmissionsQuery then submissions}
|
|
27
|
+
{@const items = submissions.map((submission) => ({
|
|
28
|
+
id: submission.id,
|
|
29
|
+
createdAt: submission.createdAt,
|
|
30
|
+
url: `/admin/form-submissions/${submission.id}`
|
|
31
|
+
}))}
|
|
32
|
+
<DataTable data={items} {columns} />
|
|
33
|
+
{/await}
|
|
34
|
+
</div>
|
|
35
|
+
{/if}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { page } from '$app/state';
|
|
3
|
+
|
|
4
|
+
import { getRemotes } from '../../../context/remotes.js';
|
|
5
|
+
import FormSubmission from './form-submission.svelte';
|
|
6
|
+
|
|
7
|
+
const remotes = getRemotes();
|
|
8
|
+
|
|
9
|
+
let formSubmissionQuery = $derived(remotes.getFormSubmission(page.params.submissionId || ''));
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
{#key page.url}
|
|
13
|
+
{#await formSubmissionQuery}
|
|
14
|
+
Loading...
|
|
15
|
+
{:then submission}
|
|
16
|
+
{#if submission === null}
|
|
17
|
+
<p>Form submission not found.</p>
|
|
18
|
+
{:else}
|
|
19
|
+
<FormSubmission {submission} />
|
|
20
|
+
{/if}
|
|
21
|
+
{/await}
|
|
22
|
+
{/key}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { goto } from '$app/navigation';
|
|
3
|
+
import { PUBLIC_URL } from '$env/static/public';
|
|
4
|
+
import FieldsForm from '../../../components/fields/fields-form.svelte';
|
|
5
|
+
import slugify from '../../../imports/slugify.js';
|
|
6
|
+
import { breadcrumbs } from '../../../state/breadcrumbs.svelte';
|
|
7
|
+
import { isCollection } from '../../../utils/is-collection.js';
|
|
8
|
+
import Button from '../../../../components/ui/button/button.svelte';
|
|
9
|
+
import { generateZodSchemaFromFields } from '../../../../core/fields/fieldSchemaToTs.js';
|
|
10
|
+
import type { RawEntry } from '../../../../types/entries.js';
|
|
11
|
+
|
|
12
|
+
import { toast } from 'svelte-sonner';
|
|
13
|
+
import { defaults, superForm } from 'sveltekit-superforms';
|
|
14
|
+
import { zod, zodClient } from 'sveltekit-superforms/adapters';
|
|
15
|
+
|
|
16
|
+
import { getRemotes } from '../../../context/remotes.js';
|
|
17
|
+
import {
|
|
18
|
+
getContentLanguage,
|
|
19
|
+
setContentLanguage
|
|
20
|
+
} from '../../../state/content-language.svelte.js';
|
|
21
|
+
|
|
22
|
+
import * as DropdownMenu from '../../../../components/ui/dropdown-menu/index.js';
|
|
23
|
+
import * as ToggleGroup from '../../../../components/ui/toggle-group/index.js';
|
|
24
|
+
import DotsVerticalIcon from '@tabler/icons-svelte/icons/dots-vertical';
|
|
25
|
+
import { page } from '$app/state';
|
|
26
|
+
import { getAtPath } from '../../../utils/objectPath.js';
|
|
27
|
+
import type { FormSubmission } from '../../../../types/forms.js';
|
|
28
|
+
|
|
29
|
+
const remotes = getRemotes();
|
|
30
|
+
|
|
31
|
+
type Props = {
|
|
32
|
+
submission: FormSubmission;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
let { submission }: Props = $props();
|
|
36
|
+
|
|
37
|
+
let form = await remotes.getForm(submission.formSlug);
|
|
38
|
+
</script>
|
|
39
|
+
|
|
40
|
+
<div class="space-y-4">
|
|
41
|
+
{#each form.fields as field}
|
|
42
|
+
<p>{field.label}: {submission.data[field.slug]}</p>
|
|
43
|
+
{/each}
|
|
44
|
+
</div>
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { FormSubmission } from '../../../../types/forms.js';
|
|
2
|
+
type Props = {
|
|
3
|
+
submission: FormSubmission;
|
|
4
|
+
};
|
|
5
|
+
declare const FormSubmission: import("svelte").Component<Props, {}, "">;
|
|
6
|
+
type FormSubmission = ReturnType<typeof FormSubmission>;
|
|
7
|
+
export default FormSubmission;
|
|
@@ -5,3 +5,5 @@ export { default as CollectionPage } from './collection/collection-page.svelte';
|
|
|
5
5
|
export { default as DashboardPage } from './admin/dashboard-page.svelte';
|
|
6
6
|
export { default as LoginPage } from './login/login-page.svelte';
|
|
7
7
|
export { default as MediaPage } from './media/media-page.svelte';
|
|
8
|
+
export { default as FormPage } from './form/form-page.svelte';
|
|
9
|
+
export { default as FormSubmissionPage } from './form/form-submission/form-submission-page.svelte';
|
|
@@ -5,3 +5,5 @@ export { default as CollectionPage } from './collection/collection-page.svelte';
|
|
|
5
5
|
export { default as DashboardPage } from './admin/dashboard-page.svelte';
|
|
6
6
|
export { default as LoginPage } from './login/login-page.svelte';
|
|
7
7
|
export { default as MediaPage } from './media/media-page.svelte';
|
|
8
|
+
export { default as FormPage } from './form/form-page.svelte';
|
|
9
|
+
export { default as FormSubmissionPage } from './form/form-submission/form-submission-page.svelte';
|
|
@@ -77,6 +77,22 @@
|
|
|
77
77
|
openAndCloseOthers(index + 1);
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
+
function moveItemUp(index: number) {
|
|
81
|
+
if (!$value || index <= 0) return;
|
|
82
|
+
const newValue = [...$value];
|
|
83
|
+
[newValue[index - 1], newValue[index]] = [newValue[index], newValue[index - 1]];
|
|
84
|
+
$value = newValue;
|
|
85
|
+
openAndCloseOthers(index - 1);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function moveItemDown(index: number) {
|
|
89
|
+
if (!$value || index >= $value.length - 1) return;
|
|
90
|
+
const newValue = [...$value];
|
|
91
|
+
[newValue[index], newValue[index + 1]] = [newValue[index + 1], newValue[index]];
|
|
92
|
+
$value = newValue;
|
|
93
|
+
openAndCloseOthers(index + 1);
|
|
94
|
+
}
|
|
95
|
+
|
|
80
96
|
function removeItem(index: number) {
|
|
81
97
|
if (!$value) return;
|
|
82
98
|
|
|
@@ -169,12 +185,21 @@
|
|
|
169
185
|
{/snippet}
|
|
170
186
|
</DropdownMenu.Trigger>
|
|
171
187
|
<DropdownMenu.Content align="end" class="w-32">
|
|
172
|
-
<DropdownMenu.Item onclick={() => duplicateItem(index)}
|
|
173
|
-
|
|
174
|
-
>
|
|
175
|
-
<DropdownMenu.Item
|
|
176
|
-
|
|
188
|
+
<DropdownMenu.Item onclick={() => duplicateItem(index)}>
|
|
189
|
+
Duplicate
|
|
190
|
+
</DropdownMenu.Item>
|
|
191
|
+
<DropdownMenu.Item onclick={() => moveItemUp(index)} disabled={index === 0}>
|
|
192
|
+
Move up
|
|
193
|
+
</DropdownMenu.Item>
|
|
194
|
+
<DropdownMenu.Item
|
|
195
|
+
onclick={() => moveItemDown(index)}
|
|
196
|
+
disabled={$value && index === $value.length - 1}
|
|
177
197
|
>
|
|
198
|
+
Move down
|
|
199
|
+
</DropdownMenu.Item>
|
|
200
|
+
<DropdownMenu.Item variant="destructive" onclick={() => removeItem(index)}>
|
|
201
|
+
Delete
|
|
202
|
+
</DropdownMenu.Item>
|
|
178
203
|
</DropdownMenu.Content>
|
|
179
204
|
</DropdownMenu.Root>
|
|
180
205
|
</div>
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
import NumberField from './number-field.svelte';
|
|
15
15
|
import SeoField from './seo-field.svelte';
|
|
16
16
|
import UrlField from './url-field.svelte';
|
|
17
|
+
import RelationField from './relation-field.svelte';
|
|
17
18
|
|
|
18
19
|
type Props = {
|
|
19
20
|
objectFieldType?: 'default' | 'inline';
|
|
@@ -87,6 +88,8 @@
|
|
|
87
88
|
<SeoField {field} {form} {path} {...props} />
|
|
88
89
|
{:else if field.type === 'url'}
|
|
89
90
|
<UrlField {field} {form} {path} {...props} />
|
|
91
|
+
{:else if field.type === 'relation'}
|
|
92
|
+
<RelationField {field} {form} {path} {...props} />
|
|
90
93
|
{:else}
|
|
91
94
|
<p>Nieobsługiwany typ pola: {field.type}</p>
|
|
92
95
|
{/if}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
type T = Record<string, unknown>;
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<script lang="ts" generics="T extends Record<string, unknown>">
|
|
6
|
+
import type { RelationFieldData, RelationField } from '../../../types/fields.js';
|
|
7
|
+
import {
|
|
8
|
+
formFieldProxy,
|
|
9
|
+
type FormFieldProxy,
|
|
10
|
+
type FormPathLeaves,
|
|
11
|
+
type SuperForm
|
|
12
|
+
} from 'sveltekit-superforms';
|
|
13
|
+
import { getRemotes } from '../../../sveltekit/index.js';
|
|
14
|
+
import Button, { buttonVariants } from '../../../components/ui/button/button.svelte';
|
|
15
|
+
import { getCollectionEntryLabel } from '../../utils/entryLabel.js';
|
|
16
|
+
import { getContentLanguage } from '../../state/content-language.svelte.js';
|
|
17
|
+
import { tick } from 'svelte';
|
|
18
|
+
import { useId } from 'bits-ui';
|
|
19
|
+
import * as Popover from '../../../components/ui/popover/index.js';
|
|
20
|
+
import * as Command from '../../../components/ui/command/index.js';
|
|
21
|
+
import { cn } from '../../../utils.js';
|
|
22
|
+
import Selector from '@tabler/icons-svelte/icons/selector';
|
|
23
|
+
import Check from '@tabler/icons-svelte/icons/check';
|
|
24
|
+
|
|
25
|
+
const remotes = getRemotes();
|
|
26
|
+
|
|
27
|
+
type Props = {
|
|
28
|
+
field: RelationField;
|
|
29
|
+
form: SuperForm<T>;
|
|
30
|
+
path: FormPathLeaves<T, RelationFieldData>;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
let { field, form, path, ...props }: Props = $props();
|
|
34
|
+
|
|
35
|
+
let collectionConfig = await remotes.getCollection(field.collection);
|
|
36
|
+
|
|
37
|
+
const { value } = formFieldProxy(form, path) satisfies FormFieldProxy<RelationFieldData>;
|
|
38
|
+
|
|
39
|
+
async function getOptionsQuery(): Promise<{ label: string; value: string }[]> {
|
|
40
|
+
const entries = await remotes.getRawCollectionEntries(field.collection);
|
|
41
|
+
|
|
42
|
+
return entries.map((entry) => ({
|
|
43
|
+
label: getCollectionEntryLabel(entry, collectionConfig, getContentLanguage()),
|
|
44
|
+
value: entry.id
|
|
45
|
+
}));
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
let open = $state(false);
|
|
49
|
+
|
|
50
|
+
// We want to refocus the trigger button when the user selects
|
|
51
|
+
// an item from the list so users can continue navigating the
|
|
52
|
+
// rest of the form with the keyboard.
|
|
53
|
+
function closeAndFocusTrigger(triggerId: string) {
|
|
54
|
+
open = false;
|
|
55
|
+
tick().then(() => {
|
|
56
|
+
document.getElementById(triggerId)?.focus();
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
const triggerId = useId();
|
|
60
|
+
</script>
|
|
61
|
+
|
|
62
|
+
{#await getOptionsQuery() then options}
|
|
63
|
+
<Popover.Root bind:open>
|
|
64
|
+
<Popover.Trigger
|
|
65
|
+
id={triggerId}
|
|
66
|
+
class={cn(
|
|
67
|
+
buttonVariants({ variant: 'outline' }),
|
|
68
|
+
'w-[200px] justify-between',
|
|
69
|
+
!value && 'text-muted-foreground'
|
|
70
|
+
)}
|
|
71
|
+
role="combobox"
|
|
72
|
+
{...props}
|
|
73
|
+
>
|
|
74
|
+
{options.find((f) => f.value === $value)?.label ??
|
|
75
|
+
`Select ${collectionConfig.labels?.singular}`}
|
|
76
|
+
<Selector class="opacity-50" />
|
|
77
|
+
</Popover.Trigger>
|
|
78
|
+
<input hidden value={$value} name={path} />
|
|
79
|
+
|
|
80
|
+
<Popover.Content class="w-[200px] p-0">
|
|
81
|
+
<Command.Root>
|
|
82
|
+
<Command.Input
|
|
83
|
+
autofocus
|
|
84
|
+
placeholder="Search {collectionConfig.labels?.plural}..."
|
|
85
|
+
class="h-9"
|
|
86
|
+
/>
|
|
87
|
+
<Command.Empty>No {collectionConfig.labels?.plural} found.</Command.Empty>
|
|
88
|
+
<Command.Group value="options">
|
|
89
|
+
{#each options as option (option.value)}
|
|
90
|
+
<Command.Item
|
|
91
|
+
value={option.label}
|
|
92
|
+
onSelect={() => {
|
|
93
|
+
$value = option.value;
|
|
94
|
+
closeAndFocusTrigger(triggerId);
|
|
95
|
+
}}
|
|
96
|
+
>
|
|
97
|
+
{option.label}
|
|
98
|
+
<Check class={cn('ml-auto', option.value !== $value && 'text-transparent')} />
|
|
99
|
+
</Command.Item>
|
|
100
|
+
{/each}
|
|
101
|
+
</Command.Group>
|
|
102
|
+
</Command.Root>
|
|
103
|
+
</Popover.Content>
|
|
104
|
+
</Popover.Root>
|
|
105
|
+
{/await}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { RelationFieldData, RelationField } from '../../../types/fields.js';
|
|
2
|
+
import { type FormPathLeaves, type SuperForm } from 'sveltekit-superforms';
|
|
3
|
+
declare function $$render<T extends Record<string, unknown>>(): Promise<{
|
|
4
|
+
props: {
|
|
5
|
+
field: RelationField;
|
|
6
|
+
form: SuperForm<T>;
|
|
7
|
+
path: FormPathLeaves<T, RelationFieldData>;
|
|
8
|
+
};
|
|
9
|
+
exports: {};
|
|
10
|
+
bindings: "";
|
|
11
|
+
slots: {};
|
|
12
|
+
events: {};
|
|
13
|
+
}>;
|
|
14
|
+
declare class __sveltets_Render<T extends Record<string, unknown>> {
|
|
15
|
+
props(): Awaited<ReturnType<typeof $$render<T>>>['props'];
|
|
16
|
+
events(): Awaited<ReturnType<typeof $$render<T>>>['events'];
|
|
17
|
+
slots(): Awaited<ReturnType<typeof $$render<T>>>['slots'];
|
|
18
|
+
bindings(): "";
|
|
19
|
+
exports(): Promise<{}>;
|
|
20
|
+
}
|
|
21
|
+
interface $$IsomorphicComponent {
|
|
22
|
+
new <T extends Record<string, unknown>>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<T>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<T>['props']>, ReturnType<__sveltets_Render<T>['events']>, ReturnType<__sveltets_Render<T>['slots']>> & {
|
|
23
|
+
$$bindings?: ReturnType<__sveltets_Render<T>['bindings']>;
|
|
24
|
+
} & ReturnType<__sveltets_Render<T>['exports']>;
|
|
25
|
+
<T extends Record<string, unknown>>(internal: unknown, props: ReturnType<__sveltets_Render<T>['props']> & {}): ReturnType<__sveltets_Render<T>['exports']>;
|
|
26
|
+
z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
|
|
27
|
+
}
|
|
28
|
+
declare const RelationField: $$IsomorphicComponent;
|
|
29
|
+
type RelationField<T extends Record<string, unknown>> = InstanceType<typeof RelationField<T>>;
|
|
30
|
+
export default RelationField;
|