diff --git a/.env b/.env deleted file mode 100644 index 5cd1aca5..00000000 --- a/.env +++ /dev/null @@ -1,3 +0,0 @@ -# This env file should be checked into source control -# This is the place for default values for all environments -# Values in `.env.local` and `.env.production` will override these values diff --git a/.gitignore b/.gitignore index 26da9023..2d69ad6f 100644 --- a/.gitignore +++ b/.gitignore @@ -26,6 +26,7 @@ blitz-log.log .env.local .env.*.local .envrc +.env # Logs logs diff --git a/package-lock.json b/package-lock.json index 949bea27..643e143a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -24,14 +24,10 @@ "@lexical/rich-text": "0.34.0", "@prisma/client": "4.16.2", "@reach/auto-id": "0.18.0", - "@rjsf/bootstrap-4": "5.13.4", - "@rjsf/core": "5.13.4", - "@rjsf/material-ui": "5.13.4", - "@rjsf/mui": "5.13.4", "@rjsf/utils": "5.13.4", "@rjsf/validator-ajv8": "5.13.4", - "@staple-verse/form-studio": "github:STAPLE-verse/form-studio#v0.2.0-rc.4", - "@staple-verse/marker-template-runtime": "https://github.com/STAPLE-verse/marker-template-spec/releases/download/v1.0.0-rc.3/staple-verse-marker-template-runtime-1.0.0-rc.3.tgz", + "@staple-verse/form-studio": "github:STAPLE-verse/form-studio#v1.0.0", + "@staple-verse/marker-template-runtime": "https://github.com/STAPLE-verse/marker-template-spec/releases/download/v1.0.0/staple-verse-marker-template-runtime-1.0.0.tgz", "@tanstack/react-table": "8.20.5", "@wamra/gantt-task-react": "0.6.17", "archiver": "7.0.1", @@ -3666,14 +3662,6 @@ "react-dom": "^18.2.0" } }, - "node_modules/@react-icons/all-files": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/@react-icons/all-files/-/all-files-4.1.0.tgz", - "integrity": "sha512-hxBI2UOuVaI3O/BhQfhtb4kcGn9ft12RWAFVMUeNjqqhLsHvFtzIkFaptBJpFDANTKoDfdVoHTKZDlwKCACbMQ==", - "peerDependencies": { - "react": "*" - } - }, "node_modules/@reactflow/background": { "version": "11.3.2", "resolved": "https://registry.npmjs.org/@reactflow/background/-/background-11.3.2.tgz", @@ -3781,91 +3769,6 @@ "react": ">=16.8.0" } }, - "node_modules/@rjsf/bootstrap-4": { - "version": "5.13.4", - "resolved": "https://registry.npmjs.org/@rjsf/bootstrap-4/-/bootstrap-4-5.13.4.tgz", - "integrity": "sha512-l1ngF0dQtkuXv0kiG7p8xaKmaSucjSt1bR8L41Xprszv/QttfrOlrWTmiYsfhRJOp5YwrvCP+YORfZpC2zXjcQ==", - "dependencies": { - "@react-icons/all-files": "^4.1.0" - }, - "engines": { - "node": ">=14" - }, - "peerDependencies": { - "@rjsf/core": "^5.12.x", - "@rjsf/utils": "^5.12.x", - "react": "^16.14.0 || >=17", - "react-bootstrap": "^1.6.5" - } - }, - "node_modules/@rjsf/core": { - "version": "5.13.4", - "resolved": "https://registry.npmjs.org/@rjsf/core/-/core-5.13.4.tgz", - "integrity": "sha512-EhT9JMBbs8ELIWY9f2G4HaY3e+IPBy6LgmhAEDjovNNwILOnNEiwXtEest6m2golrRaPJwSSTIh3EHUUIsDxJw==", - "dependencies": { - "lodash": "^4.17.21", - "lodash-es": "^4.17.21", - "markdown-to-jsx": "^7.3.2", - "nanoid": "^3.3.6", - "prop-types": "^15.8.1" - }, - "engines": { - "node": ">=14" - }, - "peerDependencies": { - "@rjsf/utils": "^5.12.x", - "react": "^16.14.0 || >=17" - } - }, - "node_modules/@rjsf/core/node_modules/nanoid": { - "version": "3.3.11", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.11.tgz", - "integrity": "sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/ai" - } - ], - "bin": { - "nanoid": "bin/nanoid.cjs" - }, - "engines": { - "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" - } - }, - "node_modules/@rjsf/material-ui": { - "version": "5.13.4", - "resolved": "https://registry.npmjs.org/@rjsf/material-ui/-/material-ui-5.13.4.tgz", - "integrity": "sha512-dIaFQ1ypK6u9i97jUF1QcF1flnOX5NkXnavETQ2F7DZHWDwVVtXFe4cftOWh62XucoDBiXsV0HmcgIN+dEuzpg==", - "engines": { - "node": ">=14" - }, - "peerDependencies": { - "@material-ui/core": "^4.12.3", - "@material-ui/icons": "^4.11.2", - "@rjsf/core": "^5.12.x", - "@rjsf/utils": "^5.12.x", - "react": "^16.14.0 || >=17" - } - }, - "node_modules/@rjsf/mui": { - "version": "5.13.4", - "resolved": "https://registry.npmjs.org/@rjsf/mui/-/mui-5.13.4.tgz", - "integrity": "sha512-2FiqqCiFqGZ0NcEQeoWqsx7EI7R1ZXB9ywlwIeiEtNtUxTYd5gZxjc+l65HOjYr3zrnaupSEUleK0wz9Rm7Mhw==", - "engines": { - "node": ">=14" - }, - "peerDependencies": { - "@emotion/react": "^11.7.0", - "@emotion/styled": "^11.6.0", - "@mui/icons-material": "^5.2.0", - "@mui/material": "^5.2.2", - "@rjsf/core": "^5.12.x", - "@rjsf/utils": "^5.12.x", - "react": ">=17" - } - }, "node_modules/@rjsf/utils": { "version": "5.13.4", "resolved": "https://registry.npmjs.org/@rjsf/utils/-/utils-5.13.4.tgz", @@ -4487,14 +4390,14 @@ "integrity": "sha512-XExJS3cLqgrmNBIP3bBw6+1oQ1ksGjFh0+oClDKFYpCCqx/hlqwWO5KO/S63fzUo67SxI9dMrF0y5T/Ey7h8Zw==" }, "node_modules/@staple-verse/form-studio": { - "version": "0.2.0-rc.4", - "resolved": "git+ssh://git@github.com/STAPLE-verse/form-studio.git#98dd47fd515ea54638617106dd6cdc3ccdd793a7", + "version": "1.0.0", + "resolved": "git+ssh://git@github.com/STAPLE-verse/form-studio.git#dc88a963aafadce50bcd7d7fe515b0c195be4bfb", "license": "MIT", "dependencies": { "@hello-pangea/dnd": "^18.0.1", "@heroicons/react": "^2.2.0", "@monaco-editor/react": "^4.7.0", - "@staple-verse/marker-template-runtime": "https://github.com/STAPLE-verse/marker-template-spec/releases/download/v1.0.0-rc.3/staple-verse-marker-template-runtime-1.0.0-rc.3.tgz", + "@staple-verse/marker-template-runtime": "https://github.com/STAPLE-verse/marker-template-spec/releases/download/v1.0.0/staple-verse-marker-template-runtime-1.0.0.tgz", "react-markdown": "^10.1.0", "remark-breaks": "^4.0.0", "remark-gfm": "^4.0.1" @@ -4519,9 +4422,9 @@ } }, "node_modules/@staple-verse/marker-template-runtime": { - "version": "1.0.0-rc.3", - "resolved": "https://github.com/STAPLE-verse/marker-template-spec/releases/download/v1.0.0-rc.3/staple-verse-marker-template-runtime-1.0.0-rc.3.tgz", - "integrity": "sha512-6bSfz84SSUIrChwfL7d1lJ6pEFxrwWNxfgwh8O3NfJ5tpzGksZmUZIaFU5hgx+YplMJCQiV2Lgb8A5rPEiko9w==", + "version": "1.0.0", + "resolved": "https://github.com/STAPLE-verse/marker-template-spec/releases/download/v1.0.0/staple-verse-marker-template-runtime-1.0.0.tgz", + "integrity": "sha512-IXYWq7sNKekN3sqx6yxJikWN5eUKLWNGNjqxRZA5Yw+hB/vd/DNT8Jv6Mp7uJWEpwn0s5kyYWA30kctoOuGolQ==", "dependencies": { "ajv": "^8.17.1", "ajv-formats": "^3.0.1" @@ -14864,17 +14767,6 @@ "url": "https://github.com/sponsors/wooorm" } }, - "node_modules/markdown-to-jsx": { - "version": "7.7.6", - "resolved": "https://registry.npmjs.org/markdown-to-jsx/-/markdown-to-jsx-7.7.6.tgz", - "integrity": "sha512-/PWFFoKKMidk4Ut06F5hs5sluq1aJ0CGvUJWsnCK6hx/LPM8vlhvKAxtGHJ+U+V2Il2wmnfO6r81ICD3xZRVaw==", - "engines": { - "node": ">= 10" - }, - "peerDependencies": { - "react": ">= 0.14.0" - } - }, "node_modules/matcher": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/matcher/-/matcher-3.0.0.tgz", diff --git a/package.json b/package.json index 34fe5a54..630c5d7d 100644 --- a/package.json +++ b/package.json @@ -43,14 +43,10 @@ "@lexical/rich-text": "0.34.0", "@prisma/client": "4.16.2", "@reach/auto-id": "0.18.0", - "@rjsf/bootstrap-4": "5.13.4", - "@rjsf/core": "5.13.4", - "@rjsf/material-ui": "5.13.4", - "@rjsf/mui": "5.13.4", "@rjsf/utils": "5.13.4", "@rjsf/validator-ajv8": "5.13.4", - "@staple-verse/form-studio": "github:STAPLE-verse/form-studio#v0.2.0-rc.4", - "@staple-verse/marker-template-runtime": "https://github.com/STAPLE-verse/marker-template-spec/releases/download/v1.0.0-rc.3/staple-verse-marker-template-runtime-1.0.0-rc.3.tgz", + "@staple-verse/form-studio": "github:STAPLE-verse/form-studio#v1.0.0", + "@staple-verse/marker-template-runtime": "https://github.com/STAPLE-verse/marker-template-spec/releases/download/v1.0.0/staple-verse-marker-template-runtime-1.0.0.tgz", "@tanstack/react-table": "8.20.5", "@wamra/gantt-task-react": "0.6.17", "archiver": "7.0.1", diff --git a/src/core/components/DaisyTheme.tsx b/src/core/components/DaisyTheme.tsx deleted file mode 100644 index f5533986..00000000 --- a/src/core/components/DaisyTheme.tsx +++ /dev/null @@ -1,355 +0,0 @@ -// eslint-disable-next-line @typescript-eslint/ban-ts-comment -// @ts-nocheck - -import { - WidgetProps, - RegistryWidgetsType, - TemplatesType, - FieldTemplateProps, - FormContextType, - TitleFieldProps, - RJSFSchema, - StrictRJSFSchema, - DescriptionFieldProps, - getTemplate, - getUiOptions, - getSubmitButtonOptions, - SubmitButtonProps, - schemaRequiresTrueValue, - descriptionId, - ariaDescribedByIds, - enumOptionsIsSelected, - enumOptionsSelectValue, - enumOptionsDeselectValue, - enumOptionsValueForIndex, - optionId, -} from "@rjsf/utils" -import ReactMarkdown from "react-markdown" -import remarkGfm from "remark-gfm" -import remarkBreaks from "remark-breaks" - -import { ThemeProps } from "@rjsf/core" - -// required information symbol -const REQUIRED_FIELD_SYMBOL = " *" - -// required label information -type LabelProps = { - /** The label for the field */ - label?: string - /** A boolean value stating if the field is required */ - required?: boolean - /** The id of the input field being labeled */ - id?: string -} - -function Label(props: LabelProps) { - const { label, required, id } = props - if (!label) { - return null - } - return ( - - ) -} - -// template updates - -// title field template the top template -function MyTitleField< - T = any, - S extends StrictRJSFSchema = RJSFSchema, - F extends FormContextType = any ->(props: TitleFieldProps) { - const { id, title, required } = props - return ( - - {title} - {required && {REQUIRED_FIELD_SYMBOL}} - - ) -} - -// description field template -function MyDescriptionField< - T = any, - S extends StrictRJSFSchema = RJSFSchema, - F extends FormContextType = any ->(props: DescriptionFieldProps) { - const { id, description } = props - if (!description) { - return null - } - if (typeof description === "string") { - return ( -
- {description} -
- ) - } else { - return ( -
- {description} -
- ) - } -} - -// field template -function MyFieldTemplate< - T = any, - S extends StrictRJSFSchema = RJSFSchema, - F extends FormContextType = any ->(props: FieldTemplateProps) { - const { - id, - label, - children, - errors, - help, - description, - hidden, - required, - displayLabel, - registry, - uiSchema, - } = props - const uiOptions = getUiOptions(uiSchema) - const WrapIfAdditionalTemplate = getTemplate<"WrapIfAdditionalTemplate", T, S, F>( - "WrapIfAdditionalTemplate", - registry, - uiOptions - ) - if (hidden) { - return
{children}
- } - return ( - - {displayLabel && - ) -} - -// button templates -function MySubmitButton< - T = any, - S extends StrictRJSFSchema = RJSFSchema, - F extends FormContextType = any ->({ uiSchema }: SubmitButtonProps) { - const { - submitText, - norender, - props: submitButtonProps = {}, - } = getSubmitButtonOptions(uiSchema) - if (norender) { - return null - } - return ( -
- -
- ) -} - -// here's the custom widgets - -// text input field -const MyTextWidget = (props: WidgetProps) => { - return ( -
- props.onChange(event.target.value)} - /> -
- ) -} - -const MyEmailWidget = (props: WidgetProps) => { - return ( -
- props.onChange(event.target.value)} - /> -
- ) -} - -const MyCheckboxWidget = (props: WidgetProps) => { - const { - id, - value, - disabled, - readonly, - label, - hideLabel, - onChange, - onBlur, - onFocus, - options, - schema, - uiSchema, - registry, - } = props - const DescriptionFieldTemplate = getTemplate("DescriptionFieldTemplate", registry, options) - const description = options.description ?? schema.description - const required = schemaRequiresTrueValue(schema) - - return ( -
- {!hideLabel && label && ( - - )} - {!hideLabel && !!description && ( - - )} - -
- ) -} - -const MyCheckboxesWidget = (props: WidgetProps) => { - const { - id, - disabled, - options, - value, - readonly, - onChange, - onBlur, - onFocus, - autofocus = false, - } = props - const { enumOptions, enumDisabled, emptyValue } = options - const checkboxesValues = Array.isArray(value) ? value : [value] - - return ( -
- {Array.isArray(enumOptions) && - enumOptions.map((option, index) => { - const checked = enumOptionsIsSelected(option.value, checkboxesValues) - const itemDisabled = - Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1 - const disabledCls = disabled || itemDisabled || readonly ? "disabled" : "" - - return ( - - ) - })} -
- ) -} - -// create Registry information -// templates -const myTemplates: Partial = { - TitleFieldTemplate: MyTitleField, - DescriptionFieldTemplate: MyDescriptionField, - FieldTemplate: MyFieldTemplate, - ButtonTemplates: { - SubmitButton: MySubmitButton, - // AddButton: DefaultTemplate, - // CopyButton: DefaultTemplate, - // MoveDownButton: DefaultTemplate, - // MoveUpButton: DefaultTemplate, - // RemoveButton: DefaultTemplate, - }, - // ArrayFieldTemplate: DefaultTemplate, - // ArrayFieldDescriptionTemplate: DefaultTemplate, - // ArrayFieldItemTemplate: DefaultTemplate, - // ArrayFieldTitleTemplate: DefaultTemplate, - // ObjectFieldTemplate: DefaultTemplate, - // ErrorListTemplate: DefaultTemplate, - // BaseInputTemplate: DefaultTemplate, - // UnsupportedFieldTemplate: DefaultTemplate, - // FieldErrorTemplate: DefaultTemplate, - // FieldHelpTemplate: DefaultTemplate, - // WrapIfAdditionalTemplate: DefaultTemplate, -} - -// templates -const myWidgets: RegistryWidgetsType = { - TextWidget: MyTextWidget, - EmailWidget: MyEmailWidget, - CheckboxWidget: MyCheckboxWidget, - CheckboxesWidget: MyCheckboxesWidget, -} - -// create the overall theme to use on the other page -const DaisyTheme: ThemeProps = { - widgets: myWidgets, - templates: myTemplates, -} -export default DaisyTheme diff --git a/src/core/components/JsonForm.tsx b/src/core/components/JsonForm.tsx deleted file mode 100644 index 44c7edae..00000000 --- a/src/core/components/JsonForm.tsx +++ /dev/null @@ -1,12 +0,0 @@ -import React from "react" -import validator from "@rjsf/validator-ajv8" -import { withTheme } from "@rjsf/core" -import DaisyTheme from "src/core/components/DaisyTheme" - -const ThemedForm = withTheme(DaisyTheme) - -const JsonForm = ({ schema, ...rest }) => { - return
{}
-} - -export default JsonForm diff --git a/src/core/components/JsonFormModal.tsx b/src/core/components/JsonFormModal.tsx index c9f0f07d..01ded17f 100644 --- a/src/core/components/JsonFormModal.tsx +++ b/src/core/components/JsonFormModal.tsx @@ -1,6 +1,6 @@ import { useState } from "react" import Modal from "./Modal" -import JsonForm from "src/core/components/JsonForm" +import { JsonSchemaForm } from "@staple-verse/form-studio" import { Prisma } from "@prisma/client" import { noSubmitButton } from "src/forms/utils/extendSchema" @@ -54,10 +54,10 @@ export const JsonFormModal = ({
- } + uiSchema={extendedUiSchema as Record} + formData={metadata as Record} onSubmit={submittable ? onSubmit : undefined} onError={onError} /> diff --git a/src/forms/utils/defaultSchemaList.test.tsx b/src/forms/utils/defaultSchemaList.test.tsx index 0dfa7dd2..6d7495ed 100644 --- a/src/forms/utils/defaultSchemaList.test.tsx +++ b/src/forms/utils/defaultSchemaList.test.tsx @@ -3,15 +3,13 @@ */ import { cleanup, render } from "@testing-library/react" -import { withTheme } from "@rjsf/core" +import { JsonSchemaForm } from "@staple-verse/form-studio" import validator from "@rjsf/validator-ajv8" import { afterEach, describe, expect, test, vi } from "vitest" -import DaisyTheme from "src/core/components/DaisyTheme" import { getDefaultSchemaLists } from "./getDefaultSchemaList" import getJsonSchema from "./getJsonSchema" const activeValidator = "rawValidation" in validator ? validator : (validator as any).default -const DeployedForm = withTheme(DaisyTheme) const builtInExamples = [ { @@ -89,12 +87,7 @@ describe("STAPLE built-in form deployment", () => { expect(activeValidator.rawValidation(schema, {}).errors?.length ?? 0).toBeGreaterThan(0) const { container } = render( - + ) expect(container.querySelector("form")).not.toBeNull() }) @@ -109,11 +102,7 @@ describe("STAPLE built-in form deployment", () => { expect(template!.uiSchema.description).toEqual({ "ui:widget": "textarea" }) const { container } = render( - + ) expect(container.querySelector("textarea")).not.toBeNull() } diff --git a/src/forms/utils/markerTemplateCapabilityFixtures.test.tsx b/src/forms/utils/markerTemplateCapabilityFixtures.test.tsx index f0641957..759927c7 100644 --- a/src/forms/utils/markerTemplateCapabilityFixtures.test.tsx +++ b/src/forms/utils/markerTemplateCapabilityFixtures.test.tsx @@ -5,14 +5,12 @@ import { readdirSync, readFileSync } from "node:fs" import path from "node:path" import { cleanup, render } from "@testing-library/react" -import { withTheme } from "@rjsf/core" +import { JsonSchemaForm } from "@staple-verse/form-studio" import validator from "@rjsf/validator-ajv8" import { afterEach, describe, expect, test, vi } from "vitest" -import DaisyTheme from "src/core/components/DaisyTheme" import getJsonSchema from "./getJsonSchema" const activeValidator = "rawValidation" in validator ? validator : (validator as any).default -const DeployedForm = withTheme(DaisyTheme) type Status = "pass" | "lossy" | "unsupported" | "blocked" | "unverified" @@ -66,18 +64,6 @@ afterEach(() => { vi.restoreAllMocks() }) -test("STAPLE deployment test coordinates match the recorded current stack", () => { - const readVersion = (packageName: string) => - JSON.parse( - readFileSync(path.join(process.cwd(), "node_modules", packageName, "package.json"), "utf8") - ).version - - expect(readVersion("@rjsf/core")).toBe("5.13.4") - expect(readVersion("@rjsf/validator-ajv8")).toBe("5.13.4") - expect(readVersion("ajv")).toBe("8.17.1") - expect(readVersion("ajv-formats")).toBe("2.1.1") -}) - describe("current STAPLE deployment integration", () => { test.each(loadFixtures())("classifies $id", (fixture) => { vi.spyOn(console, "error").mockImplementation(() => undefined) @@ -88,11 +74,10 @@ describe("current STAPLE deployment integration", () => { const validationPreserved = hasExpectedValidationBehavior(deployedSchema, fixture) const { container } = render( - ) expect(container.querySelector("form")).not.toBeNull()