From 03ae693f55285916b4b56e90eee811962d8988d8 Mon Sep 17 00:00:00 2001 From: Daniel Naab Date: Fri, 9 Feb 2024 10:42:23 -0600 Subject: [PATCH 1/5] Add a FormConfig type to define injectable form field definitions. This is an overly large commit, but includes most of the refactoring necessary for this purpose. In the design package, we could use a better type and/or constructor for configuring the UI side of the form field configuration. --- .gitignore | 1 + .../src/components/AppFormManager.tsx | 8 +- .../src/components/AppFormRouter.tsx | 2 +- apps/spotlight/src/components/Footer.astro | 17 +-- apps/spotlight/src/context.ts | 5 + packages/design/src/Form/Form.stories.tsx | 3 +- packages/design/src/Form/index.tsx | 5 +- .../FormManager/DocumentImporter/index.tsx | 9 +- .../FormManager/FormEdit/FormEdit.stories.tsx | 3 +- .../FormEdit/FormElementEdit/RenderField.tsx | 76 ---------- .../FormElementEdit/SequenceElementEdit.tsx | 111 --------------- .../design/src/FormManager/FormEdit/index.tsx | 42 ++---- .../FormPreview/FormPreview.stories.tsx | 3 +- .../src/FormManager/FormPreview/index.tsx | 5 + packages/design/src/FormManager/index.tsx | 19 ++- packages/design/src/FormRouter/index.tsx | 4 + packages/design/src/test-form.ts | 26 ++-- packages/design/src/test-helper.ts | 6 +- packages/design/src/user/InputElementEdit.tsx | 61 ++++++++ .../design/src/user/SequenceElementEdit.tsx | 132 ++++++++++++++++++ packages/design/src/user/index.ts | 10 ++ packages/documents/src/document.ts | 38 +++-- packages/forms/src/config/config.ts | 13 ++ packages/forms/src/config/elements/input.ts | 35 +++++ .../forms/src/config/elements/sequence.ts | 27 ++++ packages/forms/src/config/index.ts | 26 ++-- packages/forms/src/elements.ts | 24 ++++ packages/forms/src/elements/index.ts | 20 --- packages/forms/src/elements/input.ts | 9 -- packages/forms/src/elements/sequence.ts | 7 - packages/forms/src/index.ts | 80 ++++------- .../src/{prompts/index.ts => prompts.ts} | 47 +++---- packages/forms/tests/two-field-form.test.ts | 25 ++-- 33 files changed, 496 insertions(+), 403 deletions(-) delete mode 100644 packages/design/src/FormManager/FormEdit/FormElementEdit/RenderField.tsx delete mode 100644 packages/design/src/FormManager/FormEdit/FormElementEdit/SequenceElementEdit.tsx create mode 100644 packages/design/src/user/InputElementEdit.tsx create mode 100644 packages/design/src/user/SequenceElementEdit.tsx create mode 100644 packages/design/src/user/index.ts create mode 100644 packages/forms/src/config/config.ts create mode 100644 packages/forms/src/config/elements/input.ts create mode 100644 packages/forms/src/config/elements/sequence.ts create mode 100644 packages/forms/src/elements.ts delete mode 100644 packages/forms/src/elements/index.ts delete mode 100644 packages/forms/src/elements/input.ts delete mode 100644 packages/forms/src/elements/sequence.ts rename packages/forms/src/{prompts/index.ts => prompts.ts} (55%) diff --git a/.gitignore b/.gitignore index b168fc06..7f174c0f 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ coverage/ html/ node_modules/ NOTES.md +tsconfig.tsbuildinfo diff --git a/apps/spotlight/src/components/AppFormManager.tsx b/apps/spotlight/src/components/AppFormManager.tsx index 020464bc..4a30f791 100644 --- a/apps/spotlight/src/components/AppFormManager.tsx +++ b/apps/spotlight/src/components/AppFormManager.tsx @@ -5,5 +5,11 @@ import { getAppContext } from '../context'; export default function () { const ctx = getAppContext(); - return ; + return ( + + ); } diff --git a/apps/spotlight/src/components/AppFormRouter.tsx b/apps/spotlight/src/components/AppFormRouter.tsx index 09cbc11d..9cff368f 100644 --- a/apps/spotlight/src/components/AppFormRouter.tsx +++ b/apps/spotlight/src/components/AppFormRouter.tsx @@ -5,5 +5,5 @@ import { getAppContext } from '../context'; export default function AppFormRouter() { const ctx = getAppContext(); - return ; + return ; } diff --git a/apps/spotlight/src/components/Footer.astro b/apps/spotlight/src/components/Footer.astro index 02a2d1c7..f11a3421 100644 --- a/apps/spotlight/src/components/Footer.astro +++ b/apps/spotlight/src/components/Footer.astro @@ -18,25 +18,14 @@ const { github } = Astro.props;