diff --git a/apps/climatemappedafrica/package.json b/apps/climatemappedafrica/package.json index e5a2e3fd2..460c2aa51 100644 --- a/apps/climatemappedafrica/package.json +++ b/apps/climatemappedafrica/package.json @@ -36,6 +36,7 @@ "@apollo/client": "catalog:", "@commons-ui/core": "catalog:", "@commons-ui/next": "workspace:*", + "@commons-ui/payload": "workspace:*", "@emotion/react": "catalog:", "@emotion/styled": "catalog:", "@hurumap/core": "workspace:*", diff --git a/apps/climatemappedafrica/src/components/Footer/index.js b/apps/climatemappedafrica/src/components/Footer/index.js index 47705f72c..eff78692f 100644 --- a/apps/climatemappedafrica/src/components/Footer/index.js +++ b/apps/climatemappedafrica/src/components/Footer/index.js @@ -1,5 +1,6 @@ import { QuickLinks, LogoButton, Copyright } from "@commons-ui/core"; -import { Link, RichText, StayInTouch } from "@commons-ui/next"; +import { Link, StayInTouch } from "@commons-ui/next"; +import { RichText } from "@commons-ui/payload"; import { Grid } from "@mui/material"; import React from "react"; diff --git a/packages/commons-ui-next/src/index.js b/packages/commons-ui-next/src/index.js index 049ca3c32..c37bd3e41 100644 --- a/packages/commons-ui-next/src/index.js +++ b/packages/commons-ui-next/src/index.js @@ -4,5 +4,4 @@ export { default as Link } from "./Link"; export * from "./Link"; export { default as RichTypography } from "./RichTypography"; -export { default as RichText } from "./RichText"; export { default as StayInTouch } from "./StayInTouch"; diff --git a/packages/commons-ui-payload/.eslintignore b/packages/commons-ui-payload/.eslintignore new file mode 100644 index 000000000..c0e426719 --- /dev/null +++ b/packages/commons-ui-payload/.eslintignore @@ -0,0 +1,29 @@ +# dependencies +node_modules +.pnp +.pnp.js +.pnpm-debug.log + +# testing +coverage + +# next.js +.next/ +out/ +build + +# misc +.DS_Store +*.pem + +# debug +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# Vercel +.vercel +.now + +# turbo +.turbo diff --git a/packages/commons-ui-payload/.eslintrc.js b/packages/commons-ui-payload/.eslintrc.js new file mode 100644 index 000000000..a728847a6 --- /dev/null +++ b/packages/commons-ui-payload/.eslintrc.js @@ -0,0 +1,4 @@ +module.exports = { + root: true, + extends: ["eslint-config-commons-ui"], +}; diff --git a/packages/commons-ui-payload/.lintstagedrc.js b/packages/commons-ui-payload/.lintstagedrc.js new file mode 100644 index 000000000..bce8a3fb3 --- /dev/null +++ b/packages/commons-ui-payload/.lintstagedrc.js @@ -0,0 +1 @@ +module.exports = require("eslint-config-commons-ui/.lintstagedrc"); diff --git a/packages/commons-ui-payload/jest.config.js b/packages/commons-ui-payload/jest.config.js new file mode 100644 index 000000000..5dcb2b586 --- /dev/null +++ b/packages/commons-ui-payload/jest.config.js @@ -0,0 +1,14 @@ +const defaultConfig = require("jest-config-commons-ui"); + +const { moduleNameMapper } = defaultConfig; + +module.exports = { + ...defaultConfig, + moduleNameMapper: { + ...moduleNameMapper, + // Handle module aliases + "^@/commons-ui/core/(.*)$": "/../commons-ui-core/src/$1", + "^@/commons-ui/next/(.*)$": "/../commons-ui-next/src/$1", + "^@/commons-ui/payload/(.*)$": "/src/$1", + }, +}; diff --git a/packages/commons-ui-payload/jest.setup.js b/packages/commons-ui-payload/jest.setup.js new file mode 100644 index 000000000..6f6929f58 --- /dev/null +++ b/packages/commons-ui-payload/jest.setup.js @@ -0,0 +1,12 @@ +/* eslint-env jest */ + +jest.mock("next/router", () => ({ + useRouter: jest.fn().mockImplementation(() => ({ + asPath: "", + isReady: true, + push: jest.fn(), + query: {}, + })), +})); + +module.exports = require("@commons-ui/testing-library/jest.setup"); diff --git a/packages/commons-ui-payload/jsconfig.json b/packages/commons-ui-payload/jsconfig.json new file mode 100644 index 000000000..2b74ff6a9 --- /dev/null +++ b/packages/commons-ui-payload/jsconfig.json @@ -0,0 +1,9 @@ +{ + "compilerOptions": { + "baseUrl": ".", + "paths": { + "@/commons-ui/payload/*": ["./src/*"] + } + }, + "exclude": ["node_modules"] +} diff --git a/packages/commons-ui-payload/package.json b/packages/commons-ui-payload/package.json new file mode 100644 index 000000000..c93cb6d71 --- /dev/null +++ b/packages/commons-ui-payload/package.json @@ -0,0 +1,66 @@ +{ + "name": "@commons-ui/payload", + "version": "0.0.1", + "private": false, + "author": "Code for Africa ", + "description": "", + "main": "src/index.js", + "keywords": [ + "react", + "react-component", + "mui", + "material-ui", + "material design" + ], + "repository": { + "type": "git", + "url": "https://github.com/codeforafrica/ui.git", + "directory": "packages/commons-ui-core" + }, + "license": "MIT", + "bugs": { + "url": "https://github.com/codeforafrica/ui/issues" + }, + "scripts": { + "jest": "jest", + "lint-check": "TIMING=1 eslint './'", + "lint": "TIMING=1 eslint --fix './'", + "clean": "rm -rf .turbo node_modules dist" + }, + "devDependencies": { + "@babel/core": "catalog:", + "@babel/preset-react": "catalog:", + "@commons-ui/testing-library": "workspace:*", + "@emotion/react": "catalog:", + "@emotion/styled": "catalog:", + "@mui/material": "catalog:", + "@mui/utils": "catalog:", + "@types/react": "catalog:", + "babel-loader": "catalog:", + "eslint": "catalog:", + "eslint-config-commons-ui": "workspace:*", + "identity-obj-proxy": "catalog:", + "jest": "catalog:", + "jest-config-commons-ui": "workspace:*", + "prettier": "catalog:", + "react": "catalog:", + "react-dom": "catalog:", + "react-test-renderer": "catalog:", + "require-from-string": "catalog:", + "typescript": "catalog:", + "webpack": "catalog:" + }, + "peerDependencies": { + "@babel/core": "catalog:", + "@commons-ui/core": "workspace:*", + "@commons-ui/next": "workspace:*", + "@mui/material": "catalog:", + "clsx": "catalog:", + "next": "catalog:", + "prop-types": "catalog:", + "react": "catalog:", + "react-dom": "catalog:", + "slate": "catalog:" + }, + "dependencies": {} +} diff --git a/packages/commons-ui-next/src/RichText/RichText.js b/packages/commons-ui-payload/src/RichText/RichText.js similarity index 96% rename from packages/commons-ui-next/src/RichText/RichText.js rename to packages/commons-ui-payload/src/RichText/RichText.js index 6f1ea3ae0..dd1c236bd 100644 --- a/packages/commons-ui-next/src/RichText/RichText.js +++ b/packages/commons-ui-payload/src/RichText/RichText.js @@ -1,11 +1,9 @@ /* eslint-disable react/no-array-index-key */ +import { Link, RichTypography } from "@commons-ui/next"; import { Box } from "@mui/material"; import React, { Fragment } from "react"; import { Text } from "slate"; -import Link from "@/commons-ui/next/Link"; -import RichTypography from "@/commons-ui/next/RichTypography"; - const DEFAULT_PROPS = { html: false, }; diff --git a/packages/commons-ui-next/src/RichText/RichText.snap.js b/packages/commons-ui-payload/src/RichText/RichText.snap.js similarity index 100% rename from packages/commons-ui-next/src/RichText/RichText.snap.js rename to packages/commons-ui-payload/src/RichText/RichText.snap.js diff --git a/packages/commons-ui-next/src/RichText/RichText.test.js b/packages/commons-ui-payload/src/RichText/RichText.test.js similarity index 100% rename from packages/commons-ui-next/src/RichText/RichText.test.js rename to packages/commons-ui-payload/src/RichText/RichText.test.js diff --git a/packages/commons-ui-next/src/RichText/index.js b/packages/commons-ui-payload/src/RichText/index.js similarity index 100% rename from packages/commons-ui-next/src/RichText/index.js rename to packages/commons-ui-payload/src/RichText/index.js diff --git a/packages/commons-ui-payload/src/index.js b/packages/commons-ui-payload/src/index.js new file mode 100644 index 000000000..ace4dbf6b --- /dev/null +++ b/packages/commons-ui-payload/src/index.js @@ -0,0 +1,3 @@ +/* eslint-disable import/prefer-default-export */ + +export { default as RichText } from "./RichText"; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 6ccb664b1..b1c903e82 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1049,6 +1049,9 @@ importers: '@commons-ui/next': specifier: workspace:* version: link:../../packages/commons-ui-next + '@commons-ui/payload': + specifier: workspace:* + version: link:../../packages/commons-ui-payload '@emotion/react': specifier: 'catalog:' version: 11.13.3(@types/react@18.3.10)(react@18.3.1) @@ -2569,6 +2572,91 @@ importers: specifier: 'catalog:' version: 5.95.0(@swc/core@1.7.26(@swc/helpers@0.5.5))(webpack-cli@4.10.0(webpack-bundle-analyzer@4.10.2)(webpack@5.95.0(@swc/core@1.7.26(@swc/helpers@0.5.5)))) + packages/commons-ui-payload: + dependencies: + '@commons-ui/core': + specifier: workspace:* + version: link:../commons-ui-core + '@commons-ui/next': + specifier: workspace:* + version: link:../commons-ui-next + clsx: + specifier: 'catalog:' + version: 2.1.1 + next: + specifier: 'catalog:' + version: 14.2.13(@babel/core@7.25.2)(@opentelemetry/api@1.9.0)(@playwright/test@1.47.2)(babel-plugin-macros@3.1.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.69.4) + prop-types: + specifier: 'catalog:' + version: 15.8.1 + slate: + specifier: 'catalog:' + version: 0.103.0 + devDependencies: + '@babel/core': + specifier: 'catalog:' + version: 7.25.2 + '@babel/preset-react': + specifier: 'catalog:' + version: 7.24.7(@babel/core@7.25.2) + '@commons-ui/testing-library': + specifier: workspace:* + version: link:../commons-ui-testing-library + '@emotion/react': + specifier: 'catalog:' + version: 11.13.3(@types/react@18.3.10)(react@18.3.1) + '@emotion/styled': + specifier: 'catalog:' + version: 11.13.0(@emotion/react@11.13.3(@types/react@18.3.10)(react@18.3.1))(@types/react@18.3.10)(react@18.3.1) + '@mui/material': + specifier: 'catalog:' + version: 5.16.7(@emotion/react@11.13.3(@types/react@18.3.10)(react@18.3.1))(@emotion/styled@11.13.0(@emotion/react@11.13.3(@types/react@18.3.10)(react@18.3.1))(@types/react@18.3.10)(react@18.3.1))(@types/react@18.3.10)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) + '@mui/utils': + specifier: 'catalog:' + version: 5.16.6(@types/react@18.3.10)(react@18.3.1) + '@types/react': + specifier: 'catalog:' + version: 18.3.10 + babel-loader: + specifier: 'catalog:' + version: 9.2.1(@babel/core@7.25.2)(webpack@5.95.0(@swc/core@1.7.26(@swc/helpers@0.5.5))) + eslint: + specifier: 'catalog:' + version: 8.57.1 + eslint-config-commons-ui: + specifier: workspace:* + version: link:../eslint-config-commons-ui + identity-obj-proxy: + specifier: 'catalog:' + version: 3.0.0 + jest: + specifier: 'catalog:' + version: 29.7.0(@types/node@22.7.4)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@swc/core@1.7.26(@swc/helpers@0.5.5))(@types/node@22.7.4)(typescript@5.6.2)) + jest-config-commons-ui: + specifier: workspace:* + version: link:../jest-config-commons-ui + prettier: + specifier: 'catalog:' + version: 3.3.3 + react: + specifier: 'catalog:' + version: 18.3.1 + react-dom: + specifier: 'catalog:' + version: 18.3.1(react@18.3.1) + react-test-renderer: + specifier: 'catalog:' + version: 18.3.1(react@18.3.1) + require-from-string: + specifier: 'catalog:' + version: 2.0.2 + typescript: + specifier: 'catalog:' + version: 5.6.2 + webpack: + specifier: 'catalog:' + version: 5.95.0(@swc/core@1.7.26(@swc/helpers@0.5.5))(webpack-cli@4.10.0(webpack-bundle-analyzer@4.10.2)(webpack@5.95.0(@swc/core@1.7.26(@swc/helpers@0.5.5)))) + packages/commons-ui-testing-library: dependencies: '@testing-library/jest-dom':