@powerhousedao/codegen 4.1.0-dev.54 → 4.1.0-dev.55

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.
@@ -2,24 +2,35 @@
2
2
  to: "<%= rootDir %>/<%= h.changeCase.param(name) %>/components/CreateDocument.tsx"
3
3
  unless_exists: true
4
4
  ---
5
+ import { Button } from "@powerhousedao/design-system";
5
6
  import {
6
7
  addDocument,
7
8
  useDocumentModelModules,
8
9
  useSelectedDriveId,
9
10
  useSelectedFolder,
11
+ isDocumentTypeSupported,
10
12
  type VetraDocumentModelModule,
11
13
  } from "@powerhousedao/reactor-browser";
12
- import { Button } from "@powerhousedao/design-system";
14
+
15
+ interface CreateDocumentProps {
16
+ documentTypes?: string[];
17
+ }
13
18
 
14
19
  /**
15
20
  * Document creation UI component.
16
21
  * Displays available document types as clickable buttons.
17
22
  */
18
- export const CreateDocument = () => {
23
+ export const CreateDocument = (props: CreateDocumentProps) => {
24
+ const { documentTypes = [] } = props;
25
+
19
26
  const selectedDriveId = useSelectedDriveId();
20
27
  const selectedFolder = useSelectedFolder();
21
28
  const documentModelModules = useDocumentModelModules();
22
29
 
30
+ const filteredDocumentModelModules = documentModelModules?.filter((module) =>
31
+ isDocumentTypeSupported(module.documentModel.id, documentTypes),
32
+ );
33
+
23
34
  async function handleAddDocument(module: VetraDocumentModelModule) {
24
35
  if (!selectedDriveId) {
25
36
  return;
@@ -40,7 +51,7 @@ export const CreateDocument = () => {
40
51
  </h3>
41
52
  {/* Customize layout by changing flex-wrap, gap, or grid layout */}
42
53
  <div className="flex w-full flex-wrap gap-4">
43
- {documentModelModules?.map((documentModelModule) => {
54
+ {filteredDocumentModelModules?.map((documentModelModule) => {
44
55
  return (
45
56
  <Button
46
57
  key={documentModelModule.documentModel.id}
@@ -286,7 +286,7 @@ export function DriveExplorer(props: DriveEditorProps) {
286
286
 
287
287
  {/* === DOCUMENT CREATION SECTION === */}
288
288
  {/* Component for creating new documents */}
289
- <CreateDocument />
289
+ <CreateDocument documentTypes={props.editorConfig?.documentTypes} />
290
290
  </div>
291
291
  )}
292
292
  </div>
@@ -17,10 +17,14 @@ import { withDropZone } from "./utils/withDropZone.js";
17
17
  * Customize document opening behavior and drive-level actions here.
18
18
  */
19
19
  export function BaseEditor(props: DriveEditorProps) {
20
- const { context, document } = props;
20
+ const { context, document, editorConfig } = props;
21
21
  return (
22
22
  <div className="new-drive-explorer" style={{ height: "100%" }}>
23
- <DriveExplorer document={document} context={context} />
23
+ <DriveExplorer
24
+ document={document}
25
+ context={context}
26
+ editorConfig={editorConfig}
27
+ />
24
28
  </div>
25
29
  );
26
30
  }
@@ -7,15 +7,14 @@ import type {
7
7
  DriveEditorProps,
8
8
  FileUploadProgressCallback,
9
9
  } from "@powerhousedao/reactor-browser";
10
- import { setSelectedNode } from "@powerhousedao/reactor-browser";
10
+ import { setSelectedNode, useOnDropFile } from "@powerhousedao/reactor-browser";
11
11
  import type { ComponentType } from "react";
12
- import { useOnDropFile } from "../hooks/useOnDropFile.js";
13
12
 
14
13
  export function withDropZone<T extends DriveEditorProps>(
15
14
  WrappedComponent: ComponentType<T>,
16
15
  ): ComponentType<T> {
17
16
  const WithDropZoneComponent = (props: T) => {
18
- const onDropFile = useOnDropFile();
17
+ const onDropFile = useOnDropFile(props.editorConfig?.documentTypes);
19
18
 
20
19
  const onAddFile = async (
21
20
  file: File,