From bd5932b48190cb042414183c8f47401d2e06ebf0 Mon Sep 17 00:00:00 2001 From: Romain Lenzotti Date: Tue, 24 Dec 2024 16:09:59 +0100 Subject: [PATCH] chore: move storybook to root package --- .eslintrc.js => .eslintrc.cjs | 0 .github/workflows/build.yml | 4 +- .github/workflows/chromatic.yml | 6 +- .github/workflows/website.yml | 6 +- .gitignore | 2 +- .../.storybook => .storybook}/main.ts | 8 +- .../preview-head.html | 0 .../.storybook => .storybook}/preview.ts | 0 .../styles/fonts/bxicons/animations.css | 0 .../styles/fonts/bxicons/boxicons.css | 0 .../styles/fonts/bxicons/boxicons.eot | Bin .../styles/fonts/bxicons/boxicons.svg | 0 .../styles/fonts/bxicons/boxicons.ttf | Bin .../styles/fonts/bxicons/boxicons.woff | Bin .../styles/fonts/bxicons/boxicons.woff2 | Bin .../styles/fonts/bxicons/index.css | 0 .../styles/fonts/bxicons/transformations.css | 0 .../styles/fonts/inconsolata/index.css | 0 .../styles/fonts/index.css | 0 .../styles/fonts/source-sans-pro/index.css | 0 .storybook/styles/index.css | 6 ++ .../styles/tailwind.css | 0 .../styles/typography.css | 0 ...matic.config.json => chromatic.config.json | 0 commitlint.config.js => commitlint.config.cjs | 0 lint-staged.config.js | 4 - package.json | 68 +++++++++++++---- packages/config/package.json | 5 +- packages/react-formio-container/package.json | 3 +- packages/react-formio-stores/package.json | 2 +- packages/react-formio/package.json | 2 +- .../actions-table/__fixtures__/data.json | 12 +++ .../actionsTable.component.spec.tsx | 53 +++++++++++--- .../actions-table/actionsTable.stories.tsx | 14 +--- packages/redux-utils/package.json | 3 +- packages/storybook/.eslintignore | 14 ---- packages/storybook/.eslintrc.cjs | 7 -- .../storybook/.storybook/styles/index.css | 6 -- packages/storybook/package.json | 60 --------------- packages/storybook/tsconfig.json | 16 ---- packages/storybook/tsconfig.node.json | 8 -- packages/tailwind-formio/package.json | 5 +- packages/tailwind/package.json | 4 +- .../postcss.config.cjs => postcss.config.cjs | 0 .../storybook/stories => stories}/Form.mdx | 2 +- .../stories => stories}/FormBuilder.mdx | 2 +- .../stories => stories}/FormEdit.mdx | 2 +- .../stories => stories}/FormTable.mdx | 2 +- .../stories => stories}/Getting-started.mdx | 17 +---- .../stories => stories}/SubmissionsTable.mdx | 2 +- ...tailwind.config.cjs => tailwind.config.cjs | 0 tsconfig.json | 3 + tsconfig.node.json | 10 +++ .../vite.config.mts => vite.config.mts | 1 + yarn.lock | 69 +++++++----------- 55 files changed, 187 insertions(+), 241 deletions(-) rename .eslintrc.js => .eslintrc.cjs (100%) rename {packages/storybook/.storybook => .storybook}/main.ts (69%) rename {packages/storybook/.storybook => .storybook}/preview-head.html (100%) rename {packages/storybook/.storybook => .storybook}/preview.ts (100%) rename {packages/storybook/.storybook => .storybook}/styles/fonts/bxicons/animations.css (100%) rename {packages/storybook/.storybook => .storybook}/styles/fonts/bxicons/boxicons.css (100%) rename {packages/storybook/.storybook => .storybook}/styles/fonts/bxicons/boxicons.eot (100%) rename {packages/storybook/.storybook => .storybook}/styles/fonts/bxicons/boxicons.svg (100%) rename {packages/storybook/.storybook => .storybook}/styles/fonts/bxicons/boxicons.ttf (100%) rename {packages/storybook/.storybook => .storybook}/styles/fonts/bxicons/boxicons.woff (100%) rename {packages/storybook/.storybook => .storybook}/styles/fonts/bxicons/boxicons.woff2 (100%) rename {packages/storybook/.storybook => .storybook}/styles/fonts/bxicons/index.css (100%) rename {packages/storybook/.storybook => .storybook}/styles/fonts/bxicons/transformations.css (100%) rename {packages/storybook/.storybook => .storybook}/styles/fonts/inconsolata/index.css (100%) rename {packages/storybook/.storybook => .storybook}/styles/fonts/index.css (100%) rename {packages/storybook/.storybook => .storybook}/styles/fonts/source-sans-pro/index.css (100%) create mode 100644 .storybook/styles/index.css rename {packages/storybook/.storybook => .storybook}/styles/tailwind.css (100%) rename {packages/storybook/.storybook => .storybook}/styles/typography.css (100%) rename packages/storybook/chromatic.config.json => chromatic.config.json (100%) rename commitlint.config.js => commitlint.config.cjs (100%) delete mode 100644 lint-staged.config.js create mode 100644 packages/react-formio/src/components/actions-table/__fixtures__/data.json delete mode 100644 packages/storybook/.eslintignore delete mode 100644 packages/storybook/.eslintrc.cjs delete mode 100644 packages/storybook/.storybook/styles/index.css delete mode 100644 packages/storybook/package.json delete mode 100644 packages/storybook/tsconfig.json delete mode 100644 packages/storybook/tsconfig.node.json rename packages/storybook/postcss.config.cjs => postcss.config.cjs (100%) rename {packages/storybook/stories => stories}/Form.mdx (98%) rename {packages/storybook/stories => stories}/FormBuilder.mdx (96%) rename {packages/storybook/stories => stories}/FormEdit.mdx (93%) rename {packages/storybook/stories => stories}/FormTable.mdx (87%) rename {packages/storybook/stories => stories}/Getting-started.mdx (93%) rename {packages/storybook/stories => stories}/SubmissionsTable.mdx (88%) rename packages/storybook/tailwind.config.cjs => tailwind.config.cjs (100%) create mode 100644 tsconfig.node.json rename packages/storybook/vite.config.mts => vite.config.mts (94%) diff --git a/.eslintrc.js b/.eslintrc.cjs similarity index 100% rename from .eslintrc.js rename to .eslintrc.cjs diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3471ccc5..d69816e2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -52,13 +52,13 @@ jobs: - name: Install dependencies 🚀 run: yarn install --immutable - name: Install Playwright 🚀 - run: cd packages/storybook && yarn playwright install + run: yarn playwright install - name: Build Storybook run: yarn storybook:build --quiet - name: Serve Storybook and run tests 🔍 run: | npx concurrently -k -s first -n "SB,TEST" -c "magenta,blue" \ - "npx http-server packages/storybook/.out --port 6006 --silent" \ + "npx http-server storybook-static --port 6006 --silent" \ "npx wait-on tcp:6006 && yarn storybook:test:ci" deploy-packages: diff --git a/.github/workflows/chromatic.yml b/.github/workflows/chromatic.yml index 643f8193..6265843f 100644 --- a/.github/workflows/chromatic.yml +++ b/.github/workflows/chromatic.yml @@ -20,9 +20,13 @@ jobs: - name: Install dependencies run: yarn install --immutable + - name: Build tailwind + run: yarn tailwind:build + - name: Run Chromatic uses: chromaui/action@latest with: - workingDir: packages/storybook + storybookBaseDir: . + storybookConfigDir: ./.storybook # ⚠️ Make sure to configure a `CHROMATIC_PROJECT_TOKEN` repository secret projectToken: ${{ secrets.CHROMATIC_TOKEN }} diff --git a/.github/workflows/website.yml b/.github/workflows/website.yml index 81bafe9a..f1854956 100644 --- a/.github/workflows/website.yml +++ b/.github/workflows/website.yml @@ -44,12 +44,12 @@ jobs: - name: Build with Storybook run: | yarn storybook:build - touch packages/storybook/.out/.nojekyll - echo "formio.tsed.dev" > packages/storybook/.out/CNAME + touch ./storybook-static/.nojekyll + echo "formio.tsed.dev" > ./storybook-static/CNAME - name: Upload artifact uses: actions/upload-pages-artifact@v3 with: - path: packages/storybook/.out + path: ./storybook-static # Deployment job deploy: diff --git a/.gitignore b/.gitignore index 2de92d88..9eabc997 100644 --- a/.gitignore +++ b/.gitignore @@ -43,7 +43,7 @@ test/*.js.map lib dist build -.out +storybook-static /docs/api /docs/api/**/*.md diff --git a/packages/storybook/.storybook/main.ts b/.storybook/main.ts similarity index 69% rename from packages/storybook/.storybook/main.ts rename to .storybook/main.ts index 459df2db..083bcfa9 100644 --- a/packages/storybook/.storybook/main.ts +++ b/.storybook/main.ts @@ -1,14 +1,14 @@ import type {StorybookConfig} from "@storybook/react-vite"; const config: StorybookConfig = { - staticDirs: ["../../tailwind/build"], + staticDirs: ["../packages/tailwind/build"], stories: [ "../stories/Getting-started.mdx", "../stories/**/*.mdx", - "../../{tailwind-formio,react-formio}/src/**/*.mdx", - "../../{tailwind-formio,react-formio}/src/**/*.stories.@(js|jsx|ts|tsx)", - "../../{tailwind-formio,react-formio}/src/**/*.story.@(js|jsx|ts|tsx)" + "../packages/{tailwind-formio,react-formio}/src/**/*.mdx", + "../packages/{tailwind-formio,react-formio}/src/**/*.stories.@(js|jsx|ts|tsx)", + "../packages/{tailwind-formio,react-formio}/src/**/*.story.@(js|jsx|ts|tsx)" ], addons: [ diff --git a/packages/storybook/.storybook/preview-head.html b/.storybook/preview-head.html similarity index 100% rename from packages/storybook/.storybook/preview-head.html rename to .storybook/preview-head.html diff --git a/packages/storybook/.storybook/preview.ts b/.storybook/preview.ts similarity index 100% rename from packages/storybook/.storybook/preview.ts rename to .storybook/preview.ts diff --git a/packages/storybook/.storybook/styles/fonts/bxicons/animations.css b/.storybook/styles/fonts/bxicons/animations.css similarity index 100% rename from packages/storybook/.storybook/styles/fonts/bxicons/animations.css rename to .storybook/styles/fonts/bxicons/animations.css diff --git a/packages/storybook/.storybook/styles/fonts/bxicons/boxicons.css b/.storybook/styles/fonts/bxicons/boxicons.css similarity index 100% rename from packages/storybook/.storybook/styles/fonts/bxicons/boxicons.css rename to .storybook/styles/fonts/bxicons/boxicons.css diff --git a/packages/storybook/.storybook/styles/fonts/bxicons/boxicons.eot b/.storybook/styles/fonts/bxicons/boxicons.eot similarity index 100% rename from packages/storybook/.storybook/styles/fonts/bxicons/boxicons.eot rename to .storybook/styles/fonts/bxicons/boxicons.eot diff --git a/packages/storybook/.storybook/styles/fonts/bxicons/boxicons.svg b/.storybook/styles/fonts/bxicons/boxicons.svg similarity index 100% rename from packages/storybook/.storybook/styles/fonts/bxicons/boxicons.svg rename to .storybook/styles/fonts/bxicons/boxicons.svg diff --git a/packages/storybook/.storybook/styles/fonts/bxicons/boxicons.ttf b/.storybook/styles/fonts/bxicons/boxicons.ttf similarity index 100% rename from packages/storybook/.storybook/styles/fonts/bxicons/boxicons.ttf rename to .storybook/styles/fonts/bxicons/boxicons.ttf diff --git a/packages/storybook/.storybook/styles/fonts/bxicons/boxicons.woff b/.storybook/styles/fonts/bxicons/boxicons.woff similarity index 100% rename from packages/storybook/.storybook/styles/fonts/bxicons/boxicons.woff rename to .storybook/styles/fonts/bxicons/boxicons.woff diff --git a/packages/storybook/.storybook/styles/fonts/bxicons/boxicons.woff2 b/.storybook/styles/fonts/bxicons/boxicons.woff2 similarity index 100% rename from packages/storybook/.storybook/styles/fonts/bxicons/boxicons.woff2 rename to .storybook/styles/fonts/bxicons/boxicons.woff2 diff --git a/packages/storybook/.storybook/styles/fonts/bxicons/index.css b/.storybook/styles/fonts/bxicons/index.css similarity index 100% rename from packages/storybook/.storybook/styles/fonts/bxicons/index.css rename to .storybook/styles/fonts/bxicons/index.css diff --git a/packages/storybook/.storybook/styles/fonts/bxicons/transformations.css b/.storybook/styles/fonts/bxicons/transformations.css similarity index 100% rename from packages/storybook/.storybook/styles/fonts/bxicons/transformations.css rename to .storybook/styles/fonts/bxicons/transformations.css diff --git a/packages/storybook/.storybook/styles/fonts/inconsolata/index.css b/.storybook/styles/fonts/inconsolata/index.css similarity index 100% rename from packages/storybook/.storybook/styles/fonts/inconsolata/index.css rename to .storybook/styles/fonts/inconsolata/index.css diff --git a/packages/storybook/.storybook/styles/fonts/index.css b/.storybook/styles/fonts/index.css similarity index 100% rename from packages/storybook/.storybook/styles/fonts/index.css rename to .storybook/styles/fonts/index.css diff --git a/packages/storybook/.storybook/styles/fonts/source-sans-pro/index.css b/.storybook/styles/fonts/source-sans-pro/index.css similarity index 100% rename from packages/storybook/.storybook/styles/fonts/source-sans-pro/index.css rename to .storybook/styles/fonts/source-sans-pro/index.css diff --git a/.storybook/styles/index.css b/.storybook/styles/index.css new file mode 100644 index 00000000..acd912a5 --- /dev/null +++ b/.storybook/styles/index.css @@ -0,0 +1,6 @@ +@import "tailwind.css"; +@import "fonts/index.css"; +@import "typography.css"; +@import "../../node_modules/formiojs/dist/formio.full.css"; +@import "../../packages/tailwind-formio/styles/index.css"; + diff --git a/packages/storybook/.storybook/styles/tailwind.css b/.storybook/styles/tailwind.css similarity index 100% rename from packages/storybook/.storybook/styles/tailwind.css rename to .storybook/styles/tailwind.css diff --git a/packages/storybook/.storybook/styles/typography.css b/.storybook/styles/typography.css similarity index 100% rename from packages/storybook/.storybook/styles/typography.css rename to .storybook/styles/typography.css diff --git a/packages/storybook/chromatic.config.json b/chromatic.config.json similarity index 100% rename from packages/storybook/chromatic.config.json rename to chromatic.config.json diff --git a/commitlint.config.js b/commitlint.config.cjs similarity index 100% rename from commitlint.config.js rename to commitlint.config.cjs diff --git a/lint-staged.config.js b/lint-staged.config.js deleted file mode 100644 index c9a0582f..00000000 --- a/lint-staged.config.js +++ /dev/null @@ -1,4 +0,0 @@ -module.exports = { - "**/*.{ts,js}": ["eslint --fix"], - "**/*.{json,md,yml,yaml}": ["prettier --write"] -}; diff --git a/package.json b/package.json index 17ad1183..6340c587 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "description": "", "author": "Romain Lenzotti", "private": true, + "type": "module", "repository": { "type": "git", "url": "https://github.com/TypedProject/tsed-formio.git" @@ -23,13 +24,17 @@ "build": "monorepo build --verbose", "publish": "monorepo publish --dry-run", "start": "lerna run start --stream --parallel", - "storybook:start": "lerna run storybook:start --stream", - "storybook:build": "yarn tailwind:build && lerna run storybook:build --stream", "tailwind:build": "lerna run tailwind:build --stream --scope @tsed/tailwind", - "storybook:test": "yarn tailwind:build && lerna run storybook:test --stream", - "storybook:test:ci": "lerna run storybook:test:ci --stream", "release": "semantic-release", - "prepare": "is-ci || husky install" + "prepare": "is-ci || husky install", + "storybook:test": "yarn test-storybook", + "storybook:test:ci": "yarn test-storybook --maxWorkers=2", + "storybook:start": "storybook dev -p 6006", + "storybook:build": "yarn run tailwind:build && yarn run build-storybook", + "build-storybook": "storybook build -c .storybook", + "caniuse": "npx -y update-browserslist-db@latest", + "chromatic": "npx chromatic", + "watch": "nodemon --watch ./src --ext ts,js,ejs --exec \"yarn build\"" }, "dependencies": { "@formio/choices.js": "^9.0.1", @@ -57,8 +62,20 @@ "tooltip.js": "^1.3.3" }, "devDependencies": { + "@chromatic-com/storybook": "3.2.3", "@commitlint/cli": "^17.0.3", "@commitlint/config-conventional": "^17.0.3", + "@storybook/addon-a11y": "^8.4.7", + "@storybook/addon-essentials": "^8.4.7", + "@storybook/addon-interactions": "^8.4.7", + "@storybook/addon-links": "^8.4.7", + "@storybook/addon-mdx-gfm": "^8.4.7", + "@storybook/addon-viewport": "^8.4.7", + "@storybook/blocks": "^8.4.7", + "@storybook/react": "^8.4.7", + "@storybook/react-vite": "^8.4.7", + "@storybook/test": "^8.4.7", + "@storybook/test-runner": "0.21.0", "@swc/core": "^1.2.208", "@swc/jest": "^0.2.21", "@testing-library/dom": "^8.14.0", @@ -73,9 +90,11 @@ "@types/prop-types": "^15.7.5", "@types/react-dnd": "3.0.2", "@types/react-dnd-html5-backend": "3.0.2", + "@vitejs/plugin-react": "^4.3.4", "autoprefixer": "^10.4.7", "babel-eslint": "^10.1.0", "camelcase": "6.3.0", + "chromatic": "11.20.2", "cross-env": "7.0.3", "eslint": "^8.15.0", "eslint-config-prettier": "^8.5.0", @@ -95,6 +114,7 @@ "jest-watch-typeahead": "^1.1.0", "lint-staged": "13.0.3", "microbundle": "0.13.0", + "playwright": "1.49.1", "postcss": "^8.4.14", "postcss-flexbugs-fixes": "5.0.2", "postcss-nested": "^5.0.6", @@ -103,10 +123,18 @@ "postcss-safe-parser": "6.0.0", "prettier": "^2.6.2", "prettier-eslint": "^14.0.3", + "prop-types": "^15.8.1", + "react": "^18.2.0", + "react-dom": "^18.2.0", + "react-svg": "10.0.23", "rimraf": "^3.0.2", "semantic-release": "23.0.5", "semantic-release-slack-bot": "4.0.2", + "serve": "^13.0.4", + "storybook": "^8.4.7", "typescript": "4.9.5", + "vite": "5.1.8", + "vite-plugin-svgr": "^2.4.0", "webpack": "4.44.2" }, "workspaces": { @@ -117,15 +145,27 @@ "monorepo": { "productionBranch": "master", "developBranch": "master", - "npmAccess": "public", - "ghpages": [ - { - "dir": "./packages/storybook/.out", - "url": "https://github.com/tsedio/tsed-formio.git", - "branch": "gh-pages", - "cname": "formio.tsed.io" - } + "npmAccess": "public" + }, + "packageManager": "yarn@4.1.1", + "browserslist": { + "production": [ + ">0.2%", + "not dead", + "not op_mini all" + ], + "development": [ + "last 1 chrome version", + "last 1 firefox version", + "last 1 safari version" ] }, - "packageManager": "yarn@4.1.1" + "lint-staged": { + "**/*.{ts,js}": [ + "eslint --fix" + ], + "**/*.{json,md,yml,yaml}": [ + "prettier --write" + ] + } } diff --git a/packages/config/package.json b/packages/config/package.json index 5ebe3331..fc0904dd 100644 --- a/packages/config/package.json +++ b/packages/config/package.json @@ -7,6 +7,7 @@ "author": "Romain Lenzotti", "license": "MIT", "private": true, + "type": "commonjs", "scripts": { "lint": "eslint \"**/*.{js,jsx,ts,tsx}\"", "lint:fix": "yarn lint --fix" @@ -17,7 +18,5 @@ "devDependencies": { "@tsed/tailwind": "2.3.1", "@tsed/yarn-workspaces": "1.19.3" - }, - "dependencies": {}, - "peerDependencies": {} + } } diff --git a/packages/react-formio-container/package.json b/packages/react-formio-container/package.json index d28befb2..db352ff5 100644 --- a/packages/react-formio-container/package.json +++ b/packages/react-formio-container/package.json @@ -95,6 +95,5 @@ "tooltip.js": { "optional": false } - }, - "dependencies": {} + } } diff --git a/packages/react-formio-stores/package.json b/packages/react-formio-stores/package.json index 166f2821..2dba4348 100644 --- a/packages/react-formio-stores/package.json +++ b/packages/react-formio-stores/package.json @@ -24,7 +24,7 @@ "@tsed/react-formio": "workspace:*", "@tsed/redux-utils": "workspace:*", "eventemitter2": "^6.4.3", - "prop-types": "^15.7.2" + "prop-types": "15.8.1" }, "peerDependencies": { "@formio/choices.js": ">=9.0.1", diff --git a/packages/react-formio/package.json b/packages/react-formio/package.json index 5119a21a..b9500a6d 100644 --- a/packages/react-formio/package.json +++ b/packages/react-formio/package.json @@ -23,7 +23,7 @@ "dependencies": { "classnames": "^2.3.1", "eventemitter2": "^6.4.3", - "prop-types": "^15.7.2" + "prop-types": "15.8.1" }, "peerDependencies": { "@formio/choices.js": ">=9.0.1", diff --git a/packages/react-formio/src/components/actions-table/__fixtures__/data.json b/packages/react-formio/src/components/actions-table/__fixtures__/data.json new file mode 100644 index 00000000..6dfa14bd --- /dev/null +++ b/packages/react-formio/src/components/actions-table/__fixtures__/data.json @@ -0,0 +1,12 @@ +[ + { + "_id": "602967600685b2158b24e99a", + "handler": ["before"], + "method": ["create", "update"], + "priority": 10, + "name": "save", + "title": "Save Submission", + "form": "602967600685b24dbe24e999", + "machineName": "tcspjwhsevrzpcd:testForm:save" + } +] diff --git a/packages/react-formio/src/components/actions-table/actionsTable.component.spec.tsx b/packages/react-formio/src/components/actions-table/actionsTable.component.spec.tsx index 75e6cc61..2ba74e9f 100644 --- a/packages/react-formio/src/components/actions-table/actionsTable.component.spec.tsx +++ b/packages/react-formio/src/components/actions-table/actionsTable.component.spec.tsx @@ -2,32 +2,63 @@ import { fireEvent, render, screen } from "@testing-library/react"; import userEvent from "@testing-library/user-event"; import React from "react"; -import { Sandbox } from "./actionsTable.stories"; +import availableActions from "../__fixtures__/form-actions.json"; +import data from "./__fixtures__/data.json"; +import { ActionsTable } from "./actionsTable.component"; + +const args: any = { + data: data, + availableActions: availableActions.map(({ name, title }) => ({ + label: title, + value: name + })), + operations: [ + { + title: "Edit", + action: "edit", + alias: "row", + path: "/resources/:resourceId/submissions/:submissionId", + icon: "edit", + permissionsResolver() { + return true; + } + }, + { + action: "delete", + path: "/resources/:resourceId/submissions/:submissionId/delete", + icon: "trash", + buttonType: "danger", + permissionsResolver() { + return true; + } + } + ] +}; describe("ActionsTable", () => { it("should render the table actions", async () => { const onAddAction = jest.fn(); - render(); + render(); - const btn = screen.getByRole("button", { name: /add action/i }); + const btn = screen.getByTestId("action-table-add"); const cells = screen.getAllByRole("cell"); const options = screen.getAllByRole("option"); expect(btn).toHaveProperty("disabled"); expect(btn.innerHTML).toMatch("Add action"); expect(cells[0].innerHTML).toMatch("Save Submission"); - expect(options.length).toEqual(Sandbox.args.availableActions.length + 1); + expect(options.length).toEqual(availableActions.length + 1); expect(options[0].innerHTML).toMatch("Select an action"); - expect(options[1].innerHTML).toMatch("Email"); + expect(options[1].innerHTML).toMatch("Webhook (Premium)"); }); it("should not call addAction when the default item is selected", async () => { const onAddAction = jest.fn(); - render(); + render(); - const btn = screen.getByRole("button", { name: /add action/i }); + const btn = screen.getByTestId("action-table-add"); await fireEvent.click(btn); expect(onAddAction).not.toHaveBeenCalled(); @@ -35,16 +66,16 @@ describe("ActionsTable", () => { it("should call addAction with the selected action", async () => { const onAddAction = jest.fn(); - render(); + render(); - const btn = screen.getByRole("button", { name: /add action/i }); + const btn = screen.getByTestId("action-table-add"); const select = screen.getByRole("combobox"); - await userEvent.selectOptions(select, String(Sandbox.args.availableActions[1].value)); + await userEvent.selectOptions(select, String(args.availableActions[1].value)); await fireEvent.click(btn); expect(btn).not.toHaveProperty("disabled", true); - expect(onAddAction).toHaveBeenCalledWith("webhook"); + expect(onAddAction).toHaveBeenCalledWith("sql"); }); }); diff --git a/packages/react-formio/src/components/actions-table/actionsTable.stories.tsx b/packages/react-formio/src/components/actions-table/actionsTable.stories.tsx index 7e2eec9f..7574aaf4 100644 --- a/packages/react-formio/src/components/actions-table/actionsTable.stories.tsx +++ b/packages/react-formio/src/components/actions-table/actionsTable.stories.tsx @@ -2,6 +2,7 @@ import type { Meta, StoryObj } from "@storybook/react"; import { expect, fn, userEvent, within } from "@storybook/test"; import availableActions from "../__fixtures__/form-actions.json"; +import data from "./__fixtures__/data.json"; import { ActionsTable } from "./actionsTable.component"; export default { @@ -86,18 +87,7 @@ export const Sandbox: Story = { label: title, value: name })), - data: [ - { - _id: "602967600685b2158b24e99a", - handler: ["before"], - method: ["create", "update"], - priority: 10, - name: "save", - title: "Save Submission", - form: "602967600685b24dbe24e999", - machineName: "tcspjwhsevrzpcd:testForm:save" - } as never - ], + data: data as never, operations: [ { title: "Edit", diff --git a/packages/redux-utils/package.json b/packages/redux-utils/package.json index d67984bd..0aa710d9 100644 --- a/packages/redux-utils/package.json +++ b/packages/redux-utils/package.json @@ -27,6 +27,5 @@ "peerDependencies": { "react": "^18.2.0", "redux": "^4.0.5" - }, - "dependencies": {} + } } diff --git a/packages/storybook/.eslintignore b/packages/storybook/.eslintignore deleted file mode 100644 index 539ef9f9..00000000 --- a/packages/storybook/.eslintignore +++ /dev/null @@ -1,14 +0,0 @@ -**/node_modules -docs -docs-references -**/lib -**/build -**/dist -**/coverage -**/.nyc_output -**/node_modules -*-lock.json -*.lock -benchmarks.* -**/generated -src/**/*.ejs.js diff --git a/packages/storybook/.eslintrc.cjs b/packages/storybook/.eslintrc.cjs deleted file mode 100644 index 1b5dd069..00000000 --- a/packages/storybook/.eslintrc.cjs +++ /dev/null @@ -1,7 +0,0 @@ -module.exports = { - extends: [require.resolve("@tsed/config/eslint/node")], - rules: { - "import/no-anonymous-default-export": 0, - "jsx-a11y/anchor-is-valid": 0 - } -}; diff --git a/packages/storybook/.storybook/styles/index.css b/packages/storybook/.storybook/styles/index.css deleted file mode 100644 index 1654ef07..00000000 --- a/packages/storybook/.storybook/styles/index.css +++ /dev/null @@ -1,6 +0,0 @@ -@import "tailwind.css"; -@import "fonts/index.css"; -@import "typography.css"; -@import "formiojs/dist/formio.full.css"; -@import "../../../tailwind-formio/styles/index.css"; - diff --git a/packages/storybook/package.json b/packages/storybook/package.json deleted file mode 100644 index cdec553c..00000000 --- a/packages/storybook/package.json +++ /dev/null @@ -1,60 +0,0 @@ -{ - "name": "@tsed/storybook", - "version": "2.3.1", - "private": true, - "description": "storybook package", - "type": "module", - "scripts": { - "storybook:test": "yarn test-storybook", - "storybook:test:ci": "yarn test-storybook --maxWorkers=2", - "storybook:start": "storybook dev -p 6006", - "build-storybook": "storybook build -c ./.storybook -o .out", - "storybook:build": "yarn run build-storybook", - "serve": "serve .out", - "watch": "nodemon --watch ./src --ext ts,js,ejs --exec \"yarn build\"", - "deploy": "npx gh-pages -d ./.out -t true --history false" - }, - "dependencies": { - "@tsed/config": "workspace:*", - "@tsed/react-formio": "workspace:*", - "@tsed/tailwind-formio": "workspace:*" - }, - "devDependencies": { - "@chromatic-com/storybook": "^3", - "@storybook/addon-a11y": "^8.4.7", - "@storybook/addon-essentials": "^8.4.7", - "@storybook/addon-interactions": "^8.4.7", - "@storybook/addon-links": "^8.4.7", - "@storybook/addon-mdx-gfm": "^8.4.7", - "@storybook/addon-viewport": "^8.4.7", - "@storybook/blocks": "^8.4.7", - "@storybook/react": "^8.4.7", - "@storybook/react-vite": "^8.4.7", - "@storybook/test": "^8.4.7", - "@storybook/test-runner": "0.21.0", - "@vitejs/plugin-react": "^4.3.4", - "chromatic": "11.20.2", - "playwright": "1.49.1", - "prop-types": "^15.8.1", - "react": "^18.2.0", - "react-dom": "^18.2.0", - "react-svg": "10.0.23", - "serve": "^13.0.4", - "storybook": "^8.4.7", - "vite": "5.1.8", - "vite-plugin-svgr": "^2.4.0" - }, - "browserslist": { - "production": [ - ">0.2%", - "not dead", - "not op_mini all" - ], - "development": [ - "last 1 chrome version", - "last 1 firefox version", - "last 1 safari version" - ] - }, - "peerDependencies": {} -} diff --git a/packages/storybook/tsconfig.json b/packages/storybook/tsconfig.json deleted file mode 100644 index 7f62eac6..00000000 --- a/packages/storybook/tsconfig.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "extends": "@tsed/config/tsconfig.web.json", - "compilerOptions": { - "rootDir": "src", - "moduleResolution": "node" - }, - "include": ["src"], - "references": [ - { - "path": "./tsconfig.node.json" - }, - { - "path": "../redux-utils/tsconfig.json" - } - ] -} diff --git a/packages/storybook/tsconfig.node.json b/packages/storybook/tsconfig.node.json deleted file mode 100644 index de668915..00000000 --- a/packages/storybook/tsconfig.node.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "compilerOptions": { - "module": "esnext", - "moduleResolution": "node", - "noEmit": true - }, - "include": ["."] -} diff --git a/packages/tailwind-formio/package.json b/packages/tailwind-formio/package.json index 4dffef21..0aeddeea 100644 --- a/packages/tailwind-formio/package.json +++ b/packages/tailwind-formio/package.json @@ -5,6 +5,7 @@ "main": "dist/index.js", "module": "dist/index.modern.js", "source": "src/index.ts", + "type": "commonjs", "scripts": { "lint": "eslint \"**/*.{js,jsx,ts,tsx}\"", "lint:fix": "yarn lint --fix", @@ -34,7 +35,5 @@ "last 1 firefox version", "last 1 safari version" ] - }, - "dependencies": {}, - "peerDependencies": {} + } } diff --git a/packages/tailwind/package.json b/packages/tailwind/package.json index 1d26e84f..e7e17d58 100644 --- a/packages/tailwind/package.json +++ b/packages/tailwind/package.json @@ -33,7 +33,5 @@ "last 1 firefox version", "last 1 safari version" ] - }, - "dependencies": {}, - "peerDependencies": {} + } } diff --git a/packages/storybook/postcss.config.cjs b/postcss.config.cjs similarity index 100% rename from packages/storybook/postcss.config.cjs rename to postcss.config.cjs diff --git a/packages/storybook/stories/Form.mdx b/stories/Form.mdx similarity index 98% rename from packages/storybook/stories/Form.mdx rename to stories/Form.mdx index 65a07854..3442210c 100644 --- a/packages/storybook/stories/Form.mdx +++ b/stories/Form.mdx @@ -1,5 +1,5 @@ import {Canvas, Meta} from '@storybook/blocks' -import * as FormStories from '../../react-formio/src/components/form/form.stories' +import * as FormStories from '../packages/react-formio/src/components/form/form.stories' diff --git a/packages/storybook/stories/FormBuilder.mdx b/stories/FormBuilder.mdx similarity index 96% rename from packages/storybook/stories/FormBuilder.mdx rename to stories/FormBuilder.mdx index d9a49aaa..2b10290f 100644 --- a/packages/storybook/stories/FormBuilder.mdx +++ b/stories/FormBuilder.mdx @@ -1,5 +1,5 @@ import {Canvas, Meta} from '@storybook/blocks' -import * as FormBuilderStories from '../../react-formio/src/components/form-builder/formBuilder.stories' +import * as FormBuilderStories from '../packages/react-formio/src/components/form-builder/formBuilder.stories' diff --git a/packages/storybook/stories/FormEdit.mdx b/stories/FormEdit.mdx similarity index 93% rename from packages/storybook/stories/FormEdit.mdx rename to stories/FormEdit.mdx index c46e3318..e94c0ee6 100644 --- a/packages/storybook/stories/FormEdit.mdx +++ b/stories/FormEdit.mdx @@ -1,5 +1,5 @@ import {Canvas, Meta} from '@storybook/blocks' -import * as FormEditStories from '../../react-formio/src/components/form-edit/formEdit.stories' +import * as FormEditStories from '../packages/react-formio/src/components/form-edit/formEdit.stories' diff --git a/packages/storybook/stories/FormTable.mdx b/stories/FormTable.mdx similarity index 87% rename from packages/storybook/stories/FormTable.mdx rename to stories/FormTable.mdx index c0b56604..b11b5e6e 100644 --- a/packages/storybook/stories/FormTable.mdx +++ b/stories/FormTable.mdx @@ -1,5 +1,5 @@ import {Canvas, Meta} from '@storybook/blocks' -import * as FormsTableStories from '../../react-formio/src/components/forms-table/formsTable.stories' +import * as FormsTableStories from '../packages/react-formio/src/components/forms-table/formsTable.stories' diff --git a/packages/storybook/stories/Getting-started.mdx b/stories/Getting-started.mdx similarity index 93% rename from packages/storybook/stories/Getting-started.mdx rename to stories/Getting-started.mdx index 09ab3bed..2debf95e 100644 --- a/packages/storybook/stories/Getting-started.mdx +++ b/stories/Getting-started.mdx @@ -1,22 +1,11 @@ import {Canvas, Meta} from '@storybook/blocks' -import * as FormBuilderStories from '../../react-formio/src/components/form-builder/formBuilder.stories' +import * as FormBuilderStories from '../packages/react-formio/src/components/form-builder/formBuilder.stories' - -
- Ts.ED logo + Ts.ED logo
diff --git a/packages/storybook/stories/SubmissionsTable.mdx b/stories/SubmissionsTable.mdx similarity index 88% rename from packages/storybook/stories/SubmissionsTable.mdx rename to stories/SubmissionsTable.mdx index 509a0f41..8468c674 100644 --- a/packages/storybook/stories/SubmissionsTable.mdx +++ b/stories/SubmissionsTable.mdx @@ -1,5 +1,5 @@ import {Canvas, Meta} from '@storybook/blocks' -import * as SubmissionsTableStories from '../../react-formio/src/components/submissions-table/submissionsTable.stories' +import * as SubmissionsTableStories from '../packages/react-formio/src/components/submissions-table/submissionsTable.stories' diff --git a/packages/storybook/tailwind.config.cjs b/tailwind.config.cjs similarity index 100% rename from packages/storybook/tailwind.config.cjs rename to tailwind.config.cjs diff --git a/tsconfig.json b/tsconfig.json index fd1b2e5b..014f01cf 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,6 +4,9 @@ { "path": "./packages/react-formio" }, + { + "path": "./tsconfig.node.json" + }, { "path": "./packages/react-formio-container" }, diff --git a/tsconfig.node.json b/tsconfig.node.json new file mode 100644 index 00000000..3e4ca071 --- /dev/null +++ b/tsconfig.node.json @@ -0,0 +1,10 @@ +{ + "compilerOptions": { + "module": "esnext", + "moduleResolution": "nodenext", + "target": "esnext", + "esModuleInterop": true, + "noEmit": true + }, + "include": ["**/.storybook/**/*.ts", "vite.config.mts"] +} diff --git a/packages/storybook/vite.config.mts b/vite.config.mts similarity index 94% rename from packages/storybook/vite.config.mts rename to vite.config.mts index db5845a1..9f8d716f 100644 --- a/packages/storybook/vite.config.mts +++ b/vite.config.mts @@ -3,6 +3,7 @@ import { defineConfig } from "vite"; import svgr from "vite-plugin-svgr"; export default defineConfig({ + // @ts-ignore plugins: [react(), svgr()], base: "./", define: { diff --git a/yarn.lock b/yarn.lock index ba1855b7..063fc71f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1914,7 +1914,7 @@ __metadata: languageName: node linkType: hard -"@chromatic-com/storybook@npm:^3": +"@chromatic-com/storybook@npm:3.2.3": version: 3.2.3 resolution: "@chromatic-com/storybook@npm:3.2.3" dependencies: @@ -5925,7 +5925,7 @@ __metadata: "@tsed/tailwind": "workspace:*" "@tsed/tailwind-formio": "workspace:*" eventemitter2: "npm:^6.4.3" - prop-types: "npm:^15.7.2" + prop-types: "npm:15.8.1" peerDependencies: "@formio/choices.js": ">=9.0.1" formiojs: ">=4.0.0" @@ -5947,7 +5947,7 @@ __metadata: classnames: "npm:^2.3.1" eventemitter2: "npm:^6.4.3" microbundle: "npm:0.13.0" - prop-types: "npm:^15.7.2" + prop-types: "npm:15.8.1" peerDependencies: "@formio/choices.js": ">=9.0.1" formiojs: ">=4.0.0" @@ -5977,9 +5977,21 @@ __metadata: version: 0.0.0-use.local resolution: "@tsed/root@workspace:." dependencies: + "@chromatic-com/storybook": "npm:3.2.3" "@commitlint/cli": "npm:^17.0.3" "@commitlint/config-conventional": "npm:^17.0.3" "@formio/choices.js": "npm:^9.0.1" + "@storybook/addon-a11y": "npm:^8.4.7" + "@storybook/addon-essentials": "npm:^8.4.7" + "@storybook/addon-interactions": "npm:^8.4.7" + "@storybook/addon-links": "npm:^8.4.7" + "@storybook/addon-mdx-gfm": "npm:^8.4.7" + "@storybook/addon-viewport": "npm:^8.4.7" + "@storybook/blocks": "npm:^8.4.7" + "@storybook/react": "npm:^8.4.7" + "@storybook/react-vite": "npm:^8.4.7" + "@storybook/test": "npm:^8.4.7" + "@storybook/test-runner": "npm:0.21.0" "@swc/core": "npm:^1.2.208" "@swc/jest": "npm:^0.2.21" "@testing-library/dom": "npm:^8.14.0" @@ -6001,9 +6013,11 @@ __metadata: "@types/react-router": "npm:^5.1.20" "@types/react-router-dom": "npm:^5.3.3" "@types/react-table": "npm:^7.7.14" + "@vitejs/plugin-react": "npm:^4.3.4" autoprefixer: "npm:^10.4.7" babel-eslint: "npm:^10.1.0" camelcase: "npm:6.3.0" + chromatic: "npm:11.20.2" connected-react-router: "npm:6.9.1" cross-env: "npm:7.0.3" eslint: "npm:^8.15.0" @@ -6028,6 +6042,7 @@ __metadata: lint-staged: "npm:13.0.3" lodash: "npm:4.17.21" microbundle: "npm:0.13.0" + playwright: "npm:1.49.1" postcss: "npm:^8.4.14" postcss-flexbugs-fixes: "npm:5.0.2" postcss-nested: "npm:^5.0.6" @@ -6036,52 +6051,25 @@ __metadata: postcss-safe-parser: "npm:6.0.0" prettier: "npm:^2.6.2" prettier-eslint: "npm:^14.0.3" + prop-types: "npm:^15.8.1" react: "npm:^18.2.0" react-dom: "npm:^18.2.0" react-redux: "npm:7.2.6" react-router: "npm:5.2.1" react-router-dom: "npm:5.2.1" + react-svg: "npm:10.0.23" react-table: "npm:^7.8.0" redux-thunk: "npm:^2.4.1" rimraf: "npm:^3.0.2" semantic-release: "npm:23.0.5" semantic-release-slack-bot: "npm:4.0.2" - tooltip.js: "npm:^1.3.3" - typescript: "npm:4.9.5" - webpack: "npm:4.44.2" - languageName: unknown - linkType: soft - -"@tsed/storybook@workspace:packages/storybook": - version: 0.0.0-use.local - resolution: "@tsed/storybook@workspace:packages/storybook" - dependencies: - "@chromatic-com/storybook": "npm:^3" - "@storybook/addon-a11y": "npm:^8.4.7" - "@storybook/addon-essentials": "npm:^8.4.7" - "@storybook/addon-interactions": "npm:^8.4.7" - "@storybook/addon-links": "npm:^8.4.7" - "@storybook/addon-mdx-gfm": "npm:^8.4.7" - "@storybook/addon-viewport": "npm:^8.4.7" - "@storybook/blocks": "npm:^8.4.7" - "@storybook/react": "npm:^8.4.7" - "@storybook/react-vite": "npm:^8.4.7" - "@storybook/test": "npm:^8.4.7" - "@storybook/test-runner": "npm:0.21.0" - "@tsed/config": "workspace:*" - "@tsed/react-formio": "workspace:*" - "@tsed/tailwind-formio": "workspace:*" - "@vitejs/plugin-react": "npm:^4.3.4" - chromatic: "npm:11.20.2" - playwright: "npm:1.49.1" - prop-types: "npm:^15.8.1" - react: "npm:^18.2.0" - react-dom: "npm:^18.2.0" - react-svg: "npm:10.0.23" serve: "npm:^13.0.4" storybook: "npm:^8.4.7" + tooltip.js: "npm:^1.3.3" + typescript: "npm:4.9.5" vite: "npm:5.1.8" vite-plugin-svgr: "npm:^2.4.0" + webpack: "npm:4.44.2" languageName: unknown linkType: soft @@ -9065,14 +9053,7 @@ __metadata: languageName: node linkType: hard -"caniuse-lite@npm:^1.0.0, caniuse-lite@npm:^1.0.30001464, caniuse-lite@npm:^1.0.30001489": - version: 1.0.30001492 - resolution: "caniuse-lite@npm:1.0.30001492" - checksum: 10c0/df7ad55d2475ff6561e84e2f21c8da45fe02ba539d493d5a77214aeaf264632cf74084a8eb13bfd2cb0c9fbde0ff6af4acbd923b8590eb6b2920ba44fcac9b2d - languageName: node - linkType: hard - -"caniuse-lite@npm:^1.0.30001688": +"caniuse-lite@npm:^1.0.0, caniuse-lite@npm:^1.0.30001464, caniuse-lite@npm:^1.0.30001489, caniuse-lite@npm:^1.0.30001688": version: 1.0.30001690 resolution: "caniuse-lite@npm:1.0.30001690" checksum: 10c0/646bd469032afa90400a84dec30a2b00a6eda62c03ead358117e3f884cda8aacec02ec058a6dbee5eaf9714f83e483b9b0eb4fb42febb8076569f5ca40f1d347 @@ -22893,7 +22874,7 @@ __metadata: languageName: node linkType: hard -"prop-types@npm:^15.6.2, prop-types@npm:^15.7.2, prop-types@npm:^15.8.1": +"prop-types@npm:15.8.1, prop-types@npm:^15.6.2, prop-types@npm:^15.7.2, prop-types@npm:^15.8.1": version: 15.8.1 resolution: "prop-types@npm:15.8.1" dependencies: