diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5f3f0172..c2e8ce3d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,7 +14,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - node-version: [16.x] + node-version: [18.x] steps: - uses: actions/checkout@v2 @@ -33,7 +33,7 @@ jobs: strategy: matrix: os: [ubuntu-latest] - node-version: [16.x] + node-version: [18.x] steps: - uses: actions/checkout@v2 @@ -53,7 +53,7 @@ jobs: strategy: matrix: - node-version: [16.x] + node-version: [18.x] steps: - uses: actions/checkout@v2 @@ -84,7 +84,7 @@ jobs: strategy: matrix: - node-version: [14.x] + node-version: [18.x] steps: - uses: actions/checkout@v2 diff --git a/.github/workflows/website.yml b/.github/workflows/website.yml new file mode 100644 index 00000000..2755afa6 --- /dev/null +++ b/.github/workflows/website.yml @@ -0,0 +1,32 @@ +# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions + +name: Website + +on: + workflow_dispatch: + +jobs: + publish-pages: + runs-on: ubuntu-latest + needs: deploy-packages + if: ${{ github.event_name != 'pull_request' && (contains(github.ref, 'master') || contains(github.ref, 'alpha') || contains(github.ref, 'beta') || contains(github.ref, 'rc')) }} + + strategy: + matrix: + node-version: [18.x] + + steps: + - uses: actions/checkout@v2 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + - name: Install dependencies + run: yarn install --frozen-lockfile + - name: Release packages + env: + CI: true + GH_TOKEN: ${{ secrets.GH_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + run: yarn publish:storybook diff --git a/package.json b/package.json index d04b9426..40cbb14a 100644 --- a/package.json +++ b/package.json @@ -65,7 +65,7 @@ "@testing-library/jest-dom": "^5.16.4", "@testing-library/react": "^12.1.5", "@testing-library/user-event": "^14.2.1", - "@tsed/monorepo-utils": "1.17.8", + "@tsed/monorepo-utils": "^1.22.6", "@types/ejs": "^3.0.5", "@types/jest": "27.0.2", "@types/lodash": "4.14.168", @@ -106,7 +106,7 @@ "rimraf": "^3.0.2", "semantic-release": "19.0.3", "semantic-release-slack-bot": "3.5.3", - "typescript": "5.1.3", + "typescript": "4.9.5", "webpack": "4.44.2" }, "workspaces": { @@ -118,11 +118,13 @@ "productionBranch": "master", "developBranch": "master", "npmAccess": "public", - "ghpages": { - "dir": "./packages/tailwind-formio/.out", - "url": "https://github.com/TypedProject/tsed-formio.git", - "branch": "gh-pages", - "cname": "formio.tsed.io" - } + "ghpages": [ + { + "dir": "./packages/storybook/.out", + "url": "https://github.com/tsedio/tsed-formio.git", + "branch": "gh-pages", + "cname": "formio.tsed.io" + } + ] } } diff --git a/packages/react-formio-container/coverage.json b/packages/react-formio-container/coverage.json index 53759ed1..f85b5b63 100644 --- a/packages/react-formio-container/coverage.json +++ b/packages/react-formio-container/coverage.json @@ -1,6 +1,6 @@ { "statements": 2.29, "branches": 0.44, - "functions": 3.17, + "functions": 2.56, "lines": 2.43 } diff --git a/packages/react-formio/coverage.json b/packages/react-formio/coverage.json index f6f62516..ea4d998f 100644 --- a/packages/react-formio/coverage.json +++ b/packages/react-formio/coverage.json @@ -1,6 +1,6 @@ { - "statements": 56.11, - "branches": 46.65, - "functions": 51.31, - "lines": 56.1 + "statements": 56.02, + "branches": 46.56, + "functions": 48.33, + "lines": 56.04 } diff --git a/packages/react-formio/package.json b/packages/react-formio/package.json index d7951bae..a911ff1f 100644 --- a/packages/react-formio/package.json +++ b/packages/react-formio/package.json @@ -16,7 +16,8 @@ }, "dependencies": { "eventemitter2": "^6.4.3", - "prop-types": "^15.7.2" + "prop-types": "^15.7.2", + "classnames": "^2.3.1" }, "peerDependencies": { "@formio/choices.js": ">=9.0.1", @@ -34,4 +35,4 @@ "@tsed/tailwind": "2.1.2", "@tsed/tailwind-formio": "2.1.2" } -} \ No newline at end of file +} diff --git a/packages/react-formio/readme.md b/packages/react-formio/readme.md index e1da804e..702b406c 100644 --- a/packages/react-formio/readme.md +++ b/packages/react-formio/readme.md @@ -31,24 +31,25 @@ platform. This module is based on the original [react-formio](https://github.com/formio/react-formio) and add extra features listed above. -See our [storybook](https://formio.tsed.io/) to see all available components. +See our [storybook](https://formio.tsed.io/?path=/docs/getting-started--docs) to see all available components. ## Features -- Many components are provided to build your own backoffice based on Formio.js API: - - [ActionsTable](https://formio.tsed.io/?path=/story/reactformio-actionstable--sandbox), - - [FormAccess](https://formio.tsed.io/?path=/story/reactformio-formaccess--sandbox), - - [FormAction](https://formio.tsed.io/?path=/story/reactformio-formaction--sandbox), - - [Form](https://formio.tsed.io/?path=/story/reactformio-form--sandbox), - - [FormBuilder](https://formio.tsed.io/?path=/story/reactformio-formbuilder--sandbox), - - [FormEdit](https://formio.tsed.io/?path=/story/reactformio-formedit--sandbox), - - [FormsTable](https://formio.tsed.io/?path=/story/reactformio-formstable--sandbox), - - [InputTags](https://formio.tsed.io/?path=/story/reactformio-inputtags--sandbox), - - [InputText](https://formio.tsed.io/?path=/story/reactformio-inputtext--sandbox), - - [Pagination](https://formio.tsed.io/?path=/story/reactformio-pagination--sandbox), - - [Select](https://formio.tsed.io/?path=/story/reactformio-select--sandbox), - - [SubmissionsTable](https://formio.tsed.io/?path=/story/reactformio-subssionsstable--sandbox). - - [Table](https://formio.tsed.io/?path=/story/reactformio-table--sandbox), +Many components are provided to build your own backoffice based on Formio.js API: + +- [ActionsTable](https://formio.tsed.io/?path=story/reactformio-actionstable--sandbox), +- [FormAccess](https://formio.tsed.io/?path=story/reactformio-formaccess--sandbox), +- [FormAction](https://formio.tsed.io/?path=story/reactformio-formaction--sandbox), +- [Form](https://formio.tsed.io/?path=docs/documentation-form--docs), +- [FormBuilder](https://formio.tsed.io/?path=docs/documentation-formbuilder--docs), +- [FormEdit](https://formio.tsed.io/?path=docs/documentation-formedit--docs), +- [FormsTable](https://formio.tsed.io/?path=docs/documentation-formstable--docs), +- [InputTags](https://formio.tsed.io/?path=story/reactformio-inputtags--sandbox), +- [InputText](https://formio.tsed.io/?path=story/reactformio-inputtext--sandbox), +- [Pagination](https://formio.tsed.io/?path=story/reactformio-pagination--sandbox), +- [Select](https://formio.tsed.io/?path=/story/reactformio-select--sandbox), +- [SubmissionsTable](https://formio.tsed.io/?path=/docs/documentation-submissionstable--docs). +- [Table](https://formio.tsed.io/?path=/story/reactformio-table--sandbox), - Predefined Reducers for Actions, Action, Form, Forms, Submission, Submissions, etc..., - TypeScript support. - Tailwind support. @@ -90,186 +91,7 @@ function App() { export default App; ``` -## Components - -### Form - -The form component is the primary component of the system. It is what takes the form definition (json) and renders the -form into html. There are multiple ways to send the form to the Form component. The two main ways are to pass the `src` -prop with a url to the form definition, usually a form.io server. The other is to pass the `form` prop with the json -definition and optionally a `url` prop with the location of the form. - -#### Props - -| Name | Type | Default | Description | -| ------------ | ------ | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `src` | url | | The url of the form definition. This is commonly from a form.io server. When using src, the form will automatically submit the data to that url as well. | -| `url` | url | | The url of the form definition. The form will not be loaded from this url and the submission will not be saved here either. This is used for file upload, oauth and other components or actions that need to know where the server is. Use this in connection with `form` | -| `form` | object | | Instead of loading a form from the `src` url, you can preload the form definition and pass it in with the `form` prop. You should also set `url` if you are using any advanced components like file upload or oauth. | -| `submission` | object | | Submission data to fill the form. You can either load a previous submission or create a submission with some pre-filled data. If you do not provide a submissions the form will initialize an empty submission using default values from the form. | -| `options` | object | | an options object that can pass options to the formio.js Form that is rendered. You can set options such as `readOnly`, `noAlerts` or `hide`. There are [many options to be found in the formio.js library](https://github.com/formio/formio.js/wiki/Form-Renderer#options). | - -#### Event Props - -You can respond to various events in the form. Simply pass in a prop with a function for one of these events. - -| Name | Parameters | Description | -| --------------- | --------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- | -| `onAsyncSubmit` | `submission`: object | When the submit button is pressed and the submission has started. Use this event if you submit data to external service. | -| `onSubmit` | `submission`: object | When the submit button is pressed and the submission has started. If `src` is not provided, this will be the final submit event. | -| `onSubmitDone` | `submission`: object | When the submission has successfully been made to the server. This will only fire if `src` is set. | -| `onChange` | `submission`: object, `submission.changed`: object of what changed, `submission.isValid`: boolean - if the submission passes validations. | A value in the submission has changed. | -| `onError` | `errors`: array or string or boolean | Called when an error occurs during submission such as a validation issue. | -| `onRender` | | Triggers when the form is finished rendering. | -| `onCustomEvent` | { `type`: string - event type, `component`: object - triggering component, `data`: object - data for component, `event`: string - raw event } | Event that is triggered from a button configured with "Event" type. | -| `onPrevPage` | { `page`: integer - new page number, `submission`: object - submission data } | Triggered for wizards when "Previous" button is pressed | -| `onNextPage` | { `page`: integer - new page number, `submission`: object - submission data } | Triggered for wizards when "Next" button is pressed | -| `onFormReady` | `formInstance`: Webform/Wizard - form class instance | Called when the form gets ready state | - -#### Example - -##### With src/url - -Give `Form` a `src` property and render: - -```tsx -import React from "react"; -import ReactDOM from "react-dom"; -import { Form } from "@tsed/react-formio"; - -ReactDOM.render(
, document.getElementById("example")); -``` - -##### With form - -Give `Form` a `src` property and render: - -```tsx -import React from "react"; -import ReactDOM from "react-dom"; -import { Form } from "@tsed/react-formio"; - -interface MyFormData { - title: string; -} - -const form = { - display: "form", - components: [ - { - key: "title", - type: "textfield" - } - ] -}; - -ReactDOM.render( -