From f3bfb2736cedbf6ff9395ab8109f1dfa6659a0eb Mon Sep 17 00:00:00 2001 From: Drew Haven Date: Sat, 31 May 2025 22:39:53 -0700 Subject: [PATCH] Adds NPCs --- .../1748755724_updated_relationships.js | 48 +++++++++++ src/components/AutoSaveTextarea.tsx | 27 ++++-- src/components/documents/DocumentForm.tsx | 3 + src/components/documents/DocumentRow.tsx | 8 +- src/components/documents/npc/NpcForm.tsx | 84 +++++++++++++++++++ src/components/documents/npc/NpcRow.tsx | 46 ++++++++++ src/lib/types.ts | 16 ++++ .../_authenticated/document.$documentId.tsx | 1 + 8 files changed, 225 insertions(+), 8 deletions(-) create mode 100644 pb_migrations/1748755724_updated_relationships.js create mode 100644 src/components/documents/npc/NpcForm.tsx create mode 100644 src/components/documents/npc/NpcRow.tsx diff --git a/pb_migrations/1748755724_updated_relationships.js b/pb_migrations/1748755724_updated_relationships.js new file mode 100644 index 0000000..e48f0b8 --- /dev/null +++ b/pb_migrations/1748755724_updated_relationships.js @@ -0,0 +1,48 @@ +/// +migrate((app) => { + const collection = app.findCollectionByNameOrId("pbc_617371094") + + // update field + collection.fields.addAt(3, new Field({ + "hidden": false, + "id": "select2363381545", + "maxSelect": 1, + "name": "type", + "presentable": false, + "required": false, + "system": false, + "type": "select", + "values": [ + "discoveredIn", + "secrets", + "treasures", + "scenes", + "npcs", + "locations" + ] + })) + + return app.save(collection) +}, (app) => { + const collection = app.findCollectionByNameOrId("pbc_617371094") + + // update field + collection.fields.addAt(3, new Field({ + "hidden": false, + "id": "select2363381545", + "maxSelect": 1, + "name": "type", + "presentable": false, + "required": false, + "system": false, + "type": "select", + "values": [ + "discoveredIn", + "secrets", + "treasures", + "scenes" + ] + })) + + return app.save(collection) +}) diff --git a/src/components/AutoSaveTextarea.tsx b/src/components/AutoSaveTextarea.tsx index bdfb15c..0996c80 100644 --- a/src/components/AutoSaveTextarea.tsx +++ b/src/components/AutoSaveTextarea.tsx @@ -9,12 +9,14 @@ export function AutoSaveTextarea({ onSave, delay = 500, className = "", + multiline = true, ...props }: { value: string; onSave: (value: string) => Promise; delay?: number; className?: string; + multiline?: boolean; [key: string]: any; }) { const [value, setValue] = useState(initialValue || ""); @@ -35,7 +37,9 @@ export function AutoSaveTextarea({ }; }, []); - const handleChange = (e: React.ChangeEvent) => { + const handleChange = ( + e: React.ChangeEvent, + ) => { setValue(e.target.value); setSaved(false); setFlash(false); @@ -55,12 +59,21 @@ export function AutoSaveTextarea({ return (
-