@aphexcms/cms-core 0.1.9 → 0.1.11
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/package.json
CHANGED
|
@@ -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">
|
package/src/lib/types/schemas.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// types/schemas.ts
|
|
2
2
|
import type { Rule } from '../field-validation/rule';
|
|
3
|
+
import type { Icon as LucideIcon } from 'lucide-svelte';
|
|
3
4
|
|
|
4
5
|
// From root types.ts
|
|
5
6
|
export type FieldType =
|
|
@@ -106,6 +107,7 @@ export interface DocumentType {
|
|
|
106
107
|
name: string;
|
|
107
108
|
title: string;
|
|
108
109
|
description?: string;
|
|
110
|
+
icon?: typeof LucideIcon;
|
|
109
111
|
fields: Field[];
|
|
110
112
|
preview?: PreviewConfig;
|
|
111
113
|
createdAt: Date | null;
|
|
@@ -117,6 +119,7 @@ export interface ObjectType {
|
|
|
117
119
|
name: string;
|
|
118
120
|
title: string;
|
|
119
121
|
description?: string;
|
|
122
|
+
icon?: typeof LucideIcon;
|
|
120
123
|
fields: Field[];
|
|
121
124
|
preview?: PreviewConfig;
|
|
122
125
|
}
|
|
@@ -132,6 +135,7 @@ export interface SchemaType {
|
|
|
132
135
|
name: string;
|
|
133
136
|
title: string;
|
|
134
137
|
description?: string;
|
|
138
|
+
icon?: typeof LucideIcon;
|
|
135
139
|
fields: Field[];
|
|
136
140
|
preview?: PreviewConfig;
|
|
137
141
|
createdAt?: Date | null;
|
|
@@ -144,6 +148,7 @@ export interface NewSchemaType {
|
|
|
144
148
|
name: string;
|
|
145
149
|
title: string;
|
|
146
150
|
description?: string;
|
|
151
|
+
icon?: typeof LucideIcon;
|
|
147
152
|
fields: Field[];
|
|
148
153
|
preview?: PreviewConfig;
|
|
149
154
|
createdAt?: Date | null;
|