From 323af7faf0f3fc00bb9bfb412f98f0eb0c8e1014 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dafydd=20Ll=C5=B7r=20Pearson?= Date: Fri, 3 May 2024 18:33:36 +0100 Subject: [PATCH] chore: Boilerplate for new component --- editor.planx.uk/package.json | 2 +- editor.planx.uk/pnpm-lock.yaml | 29 +++++-------------- .../src/@planx/components/List/Editor.tsx | 29 +++++++++++++++++++ .../@planx/components/List/Public.test.tsx | 10 +++++++ .../src/@planx/components/List/Public.tsx | 27 +++++++++++++++++ .../src/@planx/components/List/model.ts | 10 +++++++ .../components/shared/Preview/SummaryList.tsx | 1 + editor.planx.uk/src/@planx/components/ui.tsx | 2 ++ .../components/Flow/components/Node.tsx | 2 ++ .../FlowEditor/components/forms/FormModal.tsx | 4 +++ .../FlowEditor/components/forms/index.ts | 2 ++ .../src/pages/FlowEditor/data/types.ts | 1 + editor.planx.uk/src/pages/Preview/Node.tsx | 4 +++ 13 files changed, 100 insertions(+), 23 deletions(-) create mode 100644 editor.planx.uk/src/@planx/components/List/Editor.tsx create mode 100644 editor.planx.uk/src/@planx/components/List/Public.test.tsx create mode 100644 editor.planx.uk/src/@planx/components/List/Public.tsx create mode 100644 editor.planx.uk/src/@planx/components/List/model.ts diff --git a/editor.planx.uk/package.json b/editor.planx.uk/package.json index e87ab3859a..f660f9e01c 100644 --- a/editor.planx.uk/package.json +++ b/editor.planx.uk/package.json @@ -12,7 +12,7 @@ "@mui/material": "^5.15.2", "@mui/utils": "^5.15.2", "@opensystemslab/map": "^0.8.1", - "@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#722e1c7", + "@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#46a3ee4", "@tiptap/core": "^2.0.3", "@tiptap/extension-bold": "^2.0.3", "@tiptap/extension-bubble-menu": "^2.1.13", diff --git a/editor.planx.uk/pnpm-lock.yaml b/editor.planx.uk/pnpm-lock.yaml index 43d80a5258..cee5f4172a 100644 --- a/editor.planx.uk/pnpm-lock.yaml +++ b/editor.planx.uk/pnpm-lock.yaml @@ -38,8 +38,8 @@ dependencies: specifier: ^0.8.1 version: 0.8.1 '@opensystemslab/planx-core': - specifier: git+https://github.com/theopensystemslab/planx-core#722e1c7 - version: github.com/theopensystemslab/planx-core/722e1c7(@types/react@18.2.45) + specifier: git+https://github.com/theopensystemslab/planx-core#46a3ee4 + version: github.com/theopensystemslab/planx-core/46a3ee4(@types/react@18.2.45) '@tiptap/core': specifier: ^2.0.3 version: 2.0.3(@tiptap/pm@2.0.3) @@ -6216,7 +6216,7 @@ packages: '@storybook/preview-api': 7.6.7 '@storybook/theming': 7.6.7(react-dom@18.2.0)(react@18.2.0) '@storybook/types': 7.6.7 - '@types/lodash': 4.14.202 + '@types/lodash': 4.17.0 color-convert: 2.0.1 dequal: 2.0.3 lodash: 4.17.21 @@ -7150,20 +7150,6 @@ packages: pretty-format: 27.5.1 dev: true - /@testing-library/dom@8.20.1: - resolution: {integrity: sha512-/DiOQ5xBxgdYRC8LNk7U+RWat0S3qRLeIw3ZIkMQ9kkVlRmwD/Eg8k8CqIpD6GW7u20JIUOfMKbxtiLutpjQ4g==} - engines: {node: '>=12'} - dependencies: - '@babel/code-frame': 7.24.2 - '@babel/runtime': 7.24.5 - '@types/aria-query': 5.0.4 - aria-query: 5.1.3 - chalk: 4.1.2 - dom-accessibility-api: 0.5.16 - lz-string: 1.5.0 - pretty-format: 27.5.1 - dev: true - /@testing-library/dom@9.3.4: resolution: {integrity: sha512-FlS4ZWlp97iiNWig0Muq8p+3rVDjRiYE+YKGbAqXOu9nwJFFOdL00kFpz42M+4huzYi86vAK1sOOfyOG45muIQ==} engines: {node: '>=14'} @@ -7201,7 +7187,7 @@ packages: react-dom: ^18.0.0 dependencies: '@babel/runtime': 7.24.5 - '@testing-library/dom': 8.20.1 + '@testing-library/dom': 9.3.4 '@types/react-dom': 18.2.18 react: 18.2.0 react-dom: 18.2.0(react@18.2.0) @@ -7769,7 +7755,6 @@ packages: /@types/lodash@4.17.0: resolution: {integrity: sha512-t7dhREVv6dbNj0q17X12j7yDG4bD/DHYX7o5/DbDxobP0HnGPgpRz2Ej77aL7TZT3DSw13fqUTj8J4mMnqa7WA==} - dev: false /@types/mdast@3.0.15: resolution: {integrity: sha512-LnwD+mUEfxWMa1QpDraczIn6k0Ee3SMicuYSSzS6ZYl2gKS09EClnJYGd8Du6rfc5r/GZEk5o1mRb8TaTj03sQ==} @@ -21305,9 +21290,9 @@ packages: use-sync-external-store: 1.2.0(react@18.2.0) dev: false - github.com/theopensystemslab/planx-core/722e1c7(@types/react@18.2.45): - resolution: {tarball: https://codeload.github.com/theopensystemslab/planx-core/tar.gz/722e1c7} - id: github.com/theopensystemslab/planx-core/722e1c7 + github.com/theopensystemslab/planx-core/46a3ee4(@types/react@18.2.45): + resolution: {tarball: https://codeload.github.com/theopensystemslab/planx-core/tar.gz/46a3ee4} + id: github.com/theopensystemslab/planx-core/46a3ee4 name: '@opensystemslab/planx-core' version: 1.0.0 prepare: true diff --git a/editor.planx.uk/src/@planx/components/List/Editor.tsx b/editor.planx.uk/src/@planx/components/List/Editor.tsx new file mode 100644 index 0000000000..080e07a605 --- /dev/null +++ b/editor.planx.uk/src/@planx/components/List/Editor.tsx @@ -0,0 +1,29 @@ +import { ComponentType as TYPES } from "@opensystemslab/planx-core/types"; +import { useFormik } from "formik"; +import React from "react"; +import { FeaturePlaceholder } from "ui/editor/FeaturePlaceholder"; + +import { EditorProps } from "../ui"; +import { List, parseContent } from "./model"; + +type Props = EditorProps; + +function ListComponent(props: Props) { + const formik = useFormik({ + initialValues: parseContent(props.node?.data), + onSubmit: (newValues) => { + props.handleSubmit?.({ + type: TYPES.List, + data: newValues, + }); + }, + }); + + return ( +