Skip to content

Commit

Permalink
merge master and fix conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
brendanbond committed Apr 23, 2024
2 parents 9135ece + f603f34 commit 57e8617
Show file tree
Hide file tree
Showing 153 changed files with 5,773 additions and 6,127 deletions.
4 changes: 2 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
"parser": "@typescript-eslint/parser",
"extends": "formio",
"parserOptions": {
"ecmaVersion": 2015,
"ecmaVersion": 2020,
"sourceType": "module"
},
"plugins": ["@typescript-eslint"],
"env": {
"browser": true,
"es6": true,
"es2020": true,
"node": true,
"mocha": true
},
Expand Down
58 changes: 5 additions & 53 deletions .github/workflows/config.yml
Original file line number Diff line number Diff line change
@@ -1,60 +1,12 @@
# name: Build & Test

# on: push

# env:
# NODE_VERSION: 18.x

# jobs:
# test:
# runs-on: ubuntu-latest
# steps:
# - run: echo "Triggered by ${{ github.event_name }} event."

# - name: Check out repository code ${{ github.repository }} on ${{ github.ref }}
# uses: actions/checkout@v3

# - name: Set up Node.js ${{ env.NODE_VERSION }}
# uses: actions/setup-node@v3
# with:
# node-version: ${{ env.NODE_VERSION }}
# cache: 'npm'

# - name: Cache node modules
# uses: actions/cache@v3
# with:
# path: node_modules
# key: ${{ runner.os }}-node-${{ hashFiles('**/yarn.lock') }}
# restore-keys: |
# ${{ runner.os }}-node-

# - name: Installing dependencies
# if: steps.cache.outputs.cache-hit != 'true'
# uses: borales/actions-yarn@v4
# with:
# cmd: install --frozen-lockfile

# - name: Lint
# uses: borales/actions-yarn@v4
# with:
# cmd: lint

# - name: Build
# uses: borales/actions-yarn@v4
# with:
# cmd: build

# - name: Test
# uses: borales/actions-yarn@v4
# with:
# cmd: test

name: Build & Test

on: push
on:
push:
branches:
- '*' # This will make sure all push events on any branch triggers this workflow.

env:
NODE_VERSION: 18.x
NODE_VERSION: 20.x

jobs:
setup:
Expand Down
50 changes: 50 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Release

on:
push:
tags:
- '*' # This will make sure tag creations also trigger the workflow.

env:
NODE_VERSION: 20.x
AWS_DEFAULT_REGION: us-west-2
AWS_ACCESS_KEY_ID: ${{ vars.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

jobs:
deploy_to_test:
# if: false
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest

steps:
- run: echo "Triggered by ${{ github.event_name }} event."
- name: Check out repository code ${{ github.repository }} on ${{ github.ref }}
uses: actions/checkout@v3

- name: Setup Ruby and Install Jekyll
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.0'
bundler-cache: true

- name: Install Jekyll
run: gem install jekyll

- name: Restore node modules from cache
uses: actions/cache@v3
with:
path: node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install awscli
run: |
sudo apt-get update
sudo apt install -y awscli
- name: Release
uses: borales/actions-yarn@v4
with:
cmd: release
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@
"program": "${workspaceFolder}/node_modules/.bin/mocha",
"args": ["-b", "-t", "0", "'${file}'"],
"console": "integratedTerminal",
}
},
]
}
202 changes: 202 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,187 @@ All notable changes to this project will be documented in this file
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased: 5.0.0]

### New Features

#### New package name
The first thing that you will notice with the 5.x renderer is the package name has changed from **formiojs** to **@formio/js**. This is to be more consistent with the naming conventions that we are starting to use with all of our externally facing libraries. This change is as follows:

##### Before 5.x
```
npm install --save formiojs
```

##### After 5.x
```
npm install --save @formio/js
```

##### Before 5.x
```js
import { Formio } from 'formiojs';
```

##### After 5.x
```js
import { Formio } from '@formio/js';
```

All other libraries and modules within this package remain the same. The following still works as expected.

```js
// This still works as it did in < 5.x. The only thing that changes is @formio/js name.
import { Formio, Components } from '@formio/js';
```

#### Bootstrap 5 Support
The 5.x renderer now supports, and defaults to Bootstrap 5 for the base template. We have also moved the templates from the renderer to their own repository which can be found @ https://github.com/formio/bootstrap. If you wish to use the 5.x renderer with Bootstrap 4, that is also supported but the following code will need to be included within your application.

```js
import { Formio } from '@formio/js';
import bootstrap4 from '@formio/bootstrap/bootstrap4';
Formio.use(bootstrap4);
```

This is a **Breaking Change** so please see the section below for more information about this change.

#### New Validation Engine
The 5.x renderer incorporates our new Core validation engine found @ https://github.com/formio/core/tree/master/src/process. This process can be briefly described within the pull request notes @ https://github.com/formio/formio.js/pull/5317. This will also improve our Iso-morphic behavior for our renderer validation and significantly improve memory and processor consumption for server-side form validations. This feature does have a **Breaking Change** which is described below.

#### Improved render build sizes
With the 5.x version of the renderer/builder, there has been much effort into reducing the size of the build for the renderer. While the full renderer is still "large" and over the 1mb goal, we still have been able to trim a lot of size from the renderer/builder as follows.

- formio.form.min.js ~ 1.2mb => ~30% size reduction
- formio.form.min.js ~ 1.4mb => ~30% size reduction
- formio.min.js (SDK) ~ 235k => ~50% size reduction

#### New lazy-loading Embedding method.
One of the more exciting new additions to the 5.x renderer is the new lazy-loading process for adding the renderer to your application. There is a new file that is included with the 5.x renderer called "formio.embed.js". This file is tiny coming in at ~10kb. What this file does, however, is make it so that you can bundle a lazy-loading renderer within your application without increasing the build sizes of your application.

To use the new lazy-loading features, you will need to change your imports from the following to the new embed source as the following illustrates.

##### Before 5.x
```js
import { Formio } from 'formiojs';
```

##### After 5.x using Embed code.
```js
import { Formio } from '@formio/js/embed';
```

Anywhere you use the Formio.createForm or the Formio.builder methods, this functionality will then add a simple "loader" where the form will render, while then loading the full code to perform the rendering. All of the code that you are used to still functions as you would expect. For example, the following code still works.

```js
import { Formio } from '@formio/js/embed';

// Before, this would require a +1mb renderer to be bundled with your application to embed a form into a page. Now with the "embed" code, this will only incur a 10kb code penalty and show a loader symbol while the full renderer is lazy-loaded into the application. This improves usability so your application can quickly load and the form will show a loader while the user waits for the renderer to download and form to render.
Formio.createForm(document.getElementById('formio'), 'https://examples.form.io/example').then(function(form) {
form.submission = {
data: {
firstName: 'Joe',
lastName: 'Smith'
}
};
});
```

The following methods are able to be used within this embedded renderer.

- Formio.createForm
- Formio.builder
- Formio.use
- Formio.setBaseUrl
- Formio.setProjectUrl

If you wish to have code that is executed after the library has been lazy loaded, you can use the following code.

```js
import { Formio as FormioEmbed } from '@formio/js/embed';

FormioEmbed.formioReady.then(function(Formio) {
// This will be the TextField components.
console.log(Formio.Components.components.textfield);
});
```

#### "childComponents" and improved performance with getComponent method.
The 5.x renderer introduces a new "flat-map" of all component instances and their paths with the "childComponents" map. It can be used as follows.

```js
import { Formio } from '@formio/js';

Formio.createForm(document.getElementById('formio'), 'https://examples.form.io/example').then(function(form) {
// Prints out all child components and their data paths.
console.log(form.childComponents);
});
```

This map is also important to dramatically speed up the heavily used ```getComponent``` method.

```js
Formio.createForm(document.getElementById('formio'), 'https://examples.form.io/example').then(function(form) {
// Now returns the component from map lookup (quick search) vs O^n searching for the component.
const firstName = form.getComponent('firstName');
});
```

### Breaking Changes
- Bootstrap 5 Default Template - With the 5.x version of the renderer, the default template is now **Bootstrap 5** and is found @ https://github.com/formio/bootstrap repo.
- Bootstrap Icons - Now, instead of Font Awesome being the default icon set for our renderer, we are using Bootstrap Icons as the default icon set which is compatible with Bootstrap 5. Of course, you can always change out icon sets, but this is now the default.
- This version implements a new validation system. Within this, there are some changes that you should be aware of.
- In version 4.x, each component would have an error associated with that component as ```component.error```. This has changed
to ```component.errors``` which is an array of errors that are associated with the component. For example, if your custom logic references
the ```component.error.messages``` array, it will need to be changed as follows.

**4.x Renderer**
```js
const textField = form.getComponent('textField');
console.log(textField.error.messages[0]); // Legacy way of getting the text field error for the first error.
```

**5.x Renderer**
```js
const textField = form.getComponent('textField');
console.log(textField.errors[0].message); // 5.x way of getting the error message for the first error.
```
- EditGrid **validateRows** method now returns an array of errors instead of a boolean "true" or "false". If you wish to do the same thing as before 5.x, then you can use the following code.

```js
const isValid = form.getComponent('editgrid').validateRow().length === 0;
```

- In the 5.x renderer, the errors array will always be populated if there are errors in the form. They may not be displayed depending on the "pristine" state of the rendered form, but the error is always populated if there are form errors. This is different in 4.x where the error property would only contain and error if an error is VISIBLE on the form. This means that it is difficult to determine if a form has errors without executing the checkValidity() method with the dirty flag set to "true". You no longer need to do this in the 5.x renderer.

**4.x Renderer**
```js
const textField = form.getComponent('requiredField');
console.log(textField.error); // This would be null even if there was an error, but it was not visible.
```

**5.x Renderer**
```js
const textField = form.getComponent('requiredField');
console.log(textField.errors); // This will be populated with the errors of the textfield even if they are not displayed on the form.
```

- If you wish to show the "visibleErrors", then there is a new property on each component called "visibleComponents".

**4.x Renderer**
```js
const textField = form.getComponent('requiredField');
console.log(textField.errors);
```

**5.x Renderer**
```js
const textField = form.getComponent('textField');
console.log(textField.visibleErrors); // This is the equivalent of the 4.x renderer "errors" array.
```

- With the 5.x renderer, all templates are now stored within a separate repo, and are included as a dependency for this renderer.

## [Unreleased: 5.0.0-rc.40]
### Fixed
- FIO-7525: fixed an issue where new conditional logic based on select boxes does not work
Expand All @@ -27,7 +208,28 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- FIO-4871: fixed calculated value issues
- FIO 7603: fixed Edit Grid With Empty Rows Not Submitting Form
- FIO-7445: fixed an issue where the interpolated data does not show up on PDF
- FIO-7774: added validateWhenHidden option
- FIO-7421: Adds ReCaptcha error messages to the translations config
- FIO-7804: Added PKCE method for OIDC
- FIO-7675: Removed maps key from repo
- FIO-2453: Fixes an issue where custom disabled dates are not recalculated
- FIO-7395: Fixed the issue with loading nested form
- FIO-7996: refactor recaptcha validation
- FIO-7899: fixed an issue where saveDraft option does not work and added errors handling for the save draft and restore draft functionality
- FIO-7956: fixed an issue where simple condition based on stringified checkbox value is not executed correctly
- FIO-7933: added PDF Document Designer
- FIO-6632: update-formiojs-test-env-on-tag
- FIO-2453: Fixes an issue where custom disabled dates are bot recalculated after for valus is changed
- FIO-7395: Fixed the issue with loading nested form
- FIO-7807: added sanitizeConfig to global form settings
- FIO-7334: Fixes an issue where Radio values do not appear for Action Conditions settings
- FIO-8009: fixed display of the required asterisk
- FIO-8111: fixed saveDraft Trigger for nested forms
- FIO-8109: fixed save draft triggering for nested components
- FIO-8146 fixed saveDraft triggering for nested forms after submitting
- FIO-3703: Fixes an issue where NestedData components with modal view do not render values inside Layout components in modal preview table
- FIO-8091: added selectData calculation for url/resource select components
- FIO-8074: Added Storage Type to Radio Components

## 5.0.0-rc.37
### Fixed
Expand Down
9 changes: 8 additions & 1 deletion _layouts/default.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,14 @@
<script src="https://cdn.jsdelivr.net/npm/bootstrap/dist/js/bootstrap.min.js"></script>
{% if page.formioFull == nil %}
{% if page.noFormio == nil %}
<script src="{{ site.baseurl }}dist/formio.embed.js"></script>
<script src="{{ site.baseurl }}dist/formio.js"></script>
<script type="text/javascript">
Formio.config.cdnUrls = {
js: {
cdn: '{{ site.baseurl }}dist'
}
};
</script>
{% endif %}
{% endif %}
{% if page.lodash %}
Expand Down
1 change: 1 addition & 0 deletions embed.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './types/Embed';
Loading

0 comments on commit 57e8617

Please sign in to comment.