@aphexcms/cms-core 0.1.10 → 0.1.12
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.
|
@@ -13,12 +13,13 @@
|
|
|
13
13
|
import DocumentEditor from './admin/DocumentEditor.svelte';
|
|
14
14
|
import type { DocumentType } from '../types/index';
|
|
15
15
|
import { documents } from '../api/index';
|
|
16
|
+
import { FileText } from 'lucide-svelte';
|
|
16
17
|
|
|
17
|
-
type InitDocumentType = Pick<DocumentType, 'name' | 'title' | 'description'>;
|
|
18
|
+
type InitDocumentType = Pick<DocumentType, 'name' | 'title' | 'description' | 'icon'>;
|
|
18
19
|
|
|
19
20
|
interface Props {
|
|
20
21
|
schemas: SchemaType[];
|
|
21
|
-
documentTypes:
|
|
22
|
+
documentTypes: Array<{ name: string; title: string; description?: string }>;
|
|
22
23
|
schemaError?: { message: string } | null;
|
|
23
24
|
title?: string;
|
|
24
25
|
graphqlSettings?: { endpoint: string; enableGraphiQL: boolean } | null;
|
|
@@ -29,7 +30,7 @@
|
|
|
29
30
|
|
|
30
31
|
let {
|
|
31
32
|
schemas,
|
|
32
|
-
documentTypes,
|
|
33
|
+
documentTypes: documentTypesFromServer,
|
|
33
34
|
schemaError = null,
|
|
34
35
|
title = 'Aphex CMS',
|
|
35
36
|
graphqlSettings = null,
|
|
@@ -38,7 +39,16 @@
|
|
|
38
39
|
handleTabChange = () => {}
|
|
39
40
|
}: Props = $props();
|
|
40
41
|
|
|
41
|
-
//
|
|
42
|
+
// Merge document types with schema icons (schemas have icons, server data doesn't)
|
|
43
|
+
const documentTypes = $derived(
|
|
44
|
+
documentTypesFromServer.map((docType) => {
|
|
45
|
+
const schema = schemas.find((s) => s.name === docType.name);
|
|
46
|
+
return {
|
|
47
|
+
...docType,
|
|
48
|
+
icon: schema?.icon
|
|
49
|
+
};
|
|
50
|
+
})
|
|
51
|
+
);
|
|
42
52
|
|
|
43
53
|
const hasDocumentTypes = $derived(documentTypes.length > 0);
|
|
44
54
|
|
|
@@ -730,7 +740,12 @@
|
|
|
730
740
|
>
|
|
731
741
|
<div class="flex items-center gap-3">
|
|
732
742
|
<div class="flex h-6 w-6 items-center justify-center">
|
|
733
|
-
|
|
743
|
+
{#if docType.icon}
|
|
744
|
+
{@const Icon = docType.icon}
|
|
745
|
+
<Icon class="text-muted-foreground h-4 w-4" />
|
|
746
|
+
{:else}
|
|
747
|
+
<FileText class="text-muted-foreground h-4 w-4" />
|
|
748
|
+
{/if}
|
|
734
749
|
</div>
|
|
735
750
|
<div>
|
|
736
751
|
<h3 class="text-sm font-medium">{docType.title}s</h3>
|
|
@@ -763,7 +778,7 @@
|
|
|
763
778
|
<div
|
|
764
779
|
class="bg-muted/50 mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-full"
|
|
765
780
|
>
|
|
766
|
-
<
|
|
781
|
+
<FileText class="text-muted-foreground h-8 w-8" />
|
|
767
782
|
</div>
|
|
768
783
|
<h3 class="mb-2 font-medium">No content types found</h3>
|
|
769
784
|
<p class="text-muted-foreground mb-4 text-sm">
|
|
@@ -806,19 +821,26 @@
|
|
|
806
821
|
</div>
|
|
807
822
|
</button>
|
|
808
823
|
{:else}
|
|
824
|
+
{@const currentDocType = documentTypes.find(
|
|
825
|
+
(t) => t.name === selectedDocumentType
|
|
826
|
+
)}
|
|
809
827
|
<div class="border-border bg-muted/20 border-b p-3">
|
|
810
828
|
<div class="flex items-center justify-between">
|
|
811
829
|
<div class="flex items-center gap-3">
|
|
812
830
|
{#if windowWidth > 620}
|
|
813
831
|
<!-- Desktop: Icon -->
|
|
814
832
|
<div class="flex h-6 w-6 items-center justify-center">
|
|
815
|
-
|
|
833
|
+
{#if currentDocType?.icon}
|
|
834
|
+
{@const Icon = currentDocType.icon}
|
|
835
|
+
<Icon class="text-muted-foreground h-4 w-4" />
|
|
836
|
+
{:else}
|
|
837
|
+
<FileText class="text-muted-foreground h-4 w-4" />
|
|
838
|
+
{/if}
|
|
816
839
|
</div>
|
|
817
840
|
{/if}
|
|
818
841
|
<div>
|
|
819
842
|
<h3 class="text-sm font-medium">
|
|
820
|
-
{(
|
|
821
|
-
selectedDocumentType) + 's'}
|
|
843
|
+
{(currentDocType?.title || selectedDocumentType) + 's'}
|
|
822
844
|
</h3>
|
|
823
845
|
<p class="text-muted-foreground text-xs">
|
|
824
846
|
{documentsList.length} document{documentsList.length !== 1 ? 's' : ''}
|
|
@@ -870,7 +892,12 @@
|
|
|
870
892
|
>
|
|
871
893
|
<div class="flex min-w-0 flex-1 items-center gap-3">
|
|
872
894
|
<div class="flex h-6 w-6 items-center justify-center">
|
|
873
|
-
|
|
895
|
+
{#if currentDocType?.icon}
|
|
896
|
+
{@const Icon = currentDocType.icon}
|
|
897
|
+
<Icon class="text-muted-foreground h-4 w-4" />
|
|
898
|
+
{:else}
|
|
899
|
+
<FileText class="text-muted-foreground h-4 w-4" />
|
|
900
|
+
{/if}
|
|
874
901
|
</div>
|
|
875
902
|
<div class="min-w-0 flex-1">
|
|
876
903
|
<h3 class="truncate text-sm font-medium">{doc.title}</h3>
|
|
@@ -895,7 +922,12 @@
|
|
|
895
922
|
<div
|
|
896
923
|
class="bg-muted/50 mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-full"
|
|
897
924
|
>
|
|
898
|
-
|
|
925
|
+
{#if currentDocType?.icon}
|
|
926
|
+
{@const Icon = currentDocType.icon}
|
|
927
|
+
<Icon class="text-muted-foreground h-8 w-8" />
|
|
928
|
+
{:else}
|
|
929
|
+
<FileText class="text-muted-foreground h-8 w-8" />
|
|
930
|
+
{/if}
|
|
899
931
|
</div>
|
|
900
932
|
<h3 class="mb-2 font-medium">No documents found</h3>
|
|
901
933
|
<p class="text-muted-foreground text-sm">
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { SchemaType } from '../types/index.js';
|
|
2
|
-
import type { DocumentType } from '../types/index.js';
|
|
3
|
-
type InitDocumentType = Pick<DocumentType, 'name' | 'title' | 'description'>;
|
|
4
2
|
interface Props {
|
|
5
3
|
schemas: SchemaType[];
|
|
6
|
-
documentTypes:
|
|
4
|
+
documentTypes: Array<{
|
|
5
|
+
name: string;
|
|
6
|
+
title: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
}>;
|
|
7
9
|
schemaError?: {
|
|
8
10
|
message: string;
|
|
9
11
|
} | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AdminApp.svelte.d.ts","sourceRoot":"","sources":["../../src/lib/components/AdminApp.svelte.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"AdminApp.svelte.d.ts","sourceRoot":"","sources":["../../src/lib/components/AdminApp.svelte.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAShD,UAAU,KAAK;IACd,OAAO,EAAE,UAAU,EAAE,CAAC;IACtB,aAAa,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC5E,WAAW,CAAC,EAAE;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IACzC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,eAAe,CAAC,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,cAAc,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI,CAAC;IACvE,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,SAAS,CAAC,EAAE;QAAE,KAAK,EAAE,WAAW,GAAG,QAAQ,CAAA;KAAE,CAAC;IAC9C,eAAe,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACzC;AAg8BF,QAAA,MAAM,QAAQ,2CAAwC,CAAC;AACvD,KAAK,QAAQ,GAAG,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAC;AAC5C,eAAe,QAAQ,CAAC"}
|
package/dist/types/schemas.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Rule } from '../field-validation/rule.js';
|
|
2
|
+
import type { Icon as LucideIcon } from 'lucide-svelte';
|
|
2
3
|
export type FieldType = 'string' | 'text' | 'number' | 'boolean' | 'slug' | 'image' | 'array' | 'object' | 'reference';
|
|
3
4
|
export interface BaseField {
|
|
4
5
|
name: string;
|
|
@@ -73,6 +74,7 @@ export interface DocumentType {
|
|
|
73
74
|
name: string;
|
|
74
75
|
title: string;
|
|
75
76
|
description?: string;
|
|
77
|
+
icon?: typeof LucideIcon;
|
|
76
78
|
fields: Field[];
|
|
77
79
|
preview?: PreviewConfig;
|
|
78
80
|
createdAt: Date | null;
|
|
@@ -83,6 +85,7 @@ export interface ObjectType {
|
|
|
83
85
|
name: string;
|
|
84
86
|
title: string;
|
|
85
87
|
description?: string;
|
|
88
|
+
icon?: typeof LucideIcon;
|
|
86
89
|
fields: Field[];
|
|
87
90
|
preview?: PreviewConfig;
|
|
88
91
|
}
|
|
@@ -95,6 +98,7 @@ export interface SchemaType {
|
|
|
95
98
|
name: string;
|
|
96
99
|
title: string;
|
|
97
100
|
description?: string;
|
|
101
|
+
icon?: typeof LucideIcon;
|
|
98
102
|
fields: Field[];
|
|
99
103
|
preview?: PreviewConfig;
|
|
100
104
|
createdAt?: Date | null;
|
|
@@ -106,6 +110,7 @@ export interface NewSchemaType {
|
|
|
106
110
|
name: string;
|
|
107
111
|
title: string;
|
|
108
112
|
description?: string;
|
|
113
|
+
icon?: typeof LucideIcon;
|
|
109
114
|
fields: Field[];
|
|
110
115
|
preview?: PreviewConfig;
|
|
111
116
|
createdAt?: Date | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../src/lib/types/schemas.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MA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