Skip to content
This repository has been archived by the owner on Aug 10, 2023. It is now read-only.

Sync fork with upstream #24

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .babelrc.esm-build
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"presets": [
[
"@babel/preset-env",
{
"modules": false
}
],
"@babel/react"
],
"plugins": [
[
"formatjs",
{
"idInterpolationPattern": "[sha512:contenthash:base64:6]",
"ast": true
}
],
[
"module-resolver",
{
"root": ["./src"],
"alias": {
"": "./src"
}
}
]
]
}
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[bumpversion]
commit = False
tag = False
current_version = 1.1.0-rc.0
current_version = 1.2.0-alpha.1
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(\-(?P<pre>[a-z]+)\.(?P<build>\d+))?
serialize =
{major}.{minor}.{patch}-{pre}.{build}
Expand Down
70 changes: 65 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,89 @@ env:
IMAGE_NAME: ${{ secrets.OTA_ACR_URL }}/openformulieren/open-forms-sdk

jobs:
tests:
name: Run Javascript tests
build:
name: Create 'production' build
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v3
with:
node-version: '16'
node-version-file: '.nvmrc'

- name: Build Javascript
run: |
yarn install
yarn build

- name: Store build artifact
uses: actions/upload-artifact@v2
with:
name: sdk-build
path: dist/
retention-days: 1

tests:
name: Run Javascript tests
runs-on: ubuntu-latest
needs: build

steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'

- name: Install dependencies
run: yarn install

- name: Download build artifact
uses: actions/download-artifact@v2
with:
name: sdk-build

- name: Run tests
run: |
yarn test
env:
CI: 'true'

# - name: Publish coverage report
# uses: codecov/codecov-action@v1
publish:
name: Publish the NPM package
runs-on: ubuntu-latest
needs:
- build
- tests

if: startsWith(github.ref, 'refs/tags/')

steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
registry-url: 'https://registry.npmjs.org'
scope: '@open-formulieren'

- name: Install dependencies
run: yarn

- name: Download build artifact
uses: actions/download-artifact@v2
with:
name: sdk-build

- name: Publish package to NPM
run: |
mv README.npm.md README.md
yarn prepare-package

# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')

yarn publish --access public --new-version=$VERSION
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

docker:
name: Build (and push) Docker image
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
.vscode/
/env/
.idea/
/venv/

# dependencies
/node_modules
Expand All @@ -16,6 +17,9 @@
# production
/build
/dist
/lib
/esm
*.tgz

# misc
.DS_Store
Expand Down
22 changes: 22 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,28 @@
Changelog
=========

1.1.1 (2022-07-25)
==================

Fixed a number of bugs

* [#1526] Fixed a situation where users could get "stuck" on a form step - backend logic
checks are now always performed, using the input data that validates client-side.
* [#1687] Fixed the SDK progressing to the next step even if the backend has validation
errors on step submission.
* Fixed displaying (generic) backend errors in a user-friendly way

1.0.4 (2022-07-25)
==================

Fixed a number of bugs

* [#1526] Fixed a situation where users could get "stuck" on a form step - backend logic
checks are now always performed, using the input data that validates client-side.
* [#1687] Fixed the SDK progressing to the next step even if the backend has validation
errors on step submission.
* Fixed displaying (generic) backend errors in a user-friendly way

1.1.0 (2022-05-24)
==================

Expand Down
4 changes: 2 additions & 2 deletions README.NL.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
Open Formulieren SDK
====================

:Version: 1.1.0-rc.0
:Source: https://github.com/maykinmedia/open-forms-sdk
:Version: 1.2.0-alpha.1
:Source: https://github.com/open-formulieren/open-forms-sdk
:Keywords: e-Formulieren, Common Ground, FormIO, API

|docs|
Expand Down
91 changes: 91 additions & 0 deletions README.npm.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# Open Forms SDK

[![NPM package](https://img.shields.io/npm/v/@open-formulieren/sdk.svg)](https://www.npmjs.com/package/@open-formulieren/sdk)

The Open Forms SDK is the frontend to the [Open Forms backend][backend]. We publish it
as both an NPM library of components and pre-built [Docker image][docker].

The documentation is available [online][docs]. Note that the SDK documentation is
currently lacking. We're planning to publish Storybook documentation soon.

## Audience

The target audience for this library is developers who want to compose their own version
of the SDK without forking the repository.

Open Forms is developed as a white-label application, including the SDK. While the
UI components are fairly generic, there are more organization/theme-specific layouts
possible, requiring significant markup changes.

Rather than exposing and maintaining complex options for UI-component
customization, we decided to publish the SDK as a library so that (experienced)
developers can replace components as they need.

## Usage

The package exports two ways to use the library:

1. Importing and composing the invididual modules (ESM)
2. Importing the library as a whole

The former approach allows more fine-grained control and should exclude code/dependencies
that aren't used and result in smaller builds, while the latter gives you the public API
as it would be available in the browser.

Given the target audience, we expect developers to use option 1.

### Using individual modules

The underlying React components are published and can serve as a basis for your own
components, or even completely replace them (TODO - this is on the roadmap!).

E.g. to re-use the card component:

```jsx
import Card from '@openformulieren/sdk/components/Card';

const MyCard = (props) => (<Card titleComponent="h3" {...props} />);

export default MyCard;
```

**NOTE**: the published components are semi-private API. We cannot provide guarantees
that it will be 100% backwards-compatible. If we know breaking changes are made, we will
bump the major version number, but you should probably do extensive testing even with
minor versions.

**Exposed API**

The `package.json` describes the module exports, at the time of writing these are:

* `@openformulieren/sdk/components/*`
* `@openformulieren/sdk/hooks/*`
* `@openformulieren/sdk/types/*`
* `@openformulieren/sdk/map/*`
* `@openformulieren/sdk/sdk`
* `@openformulieren/sdk/utils`

These will be documented with Storybook at some point.

### Using the library

If you decide that using the SDK itself is sufficient, then your usage comes down to:

```js
import OpenForm, {
ANALYTICS_PROVIDERS,
Formio,
Templates,
OFLibrary,
OpenFormsModule,
setCSRFToken
} from '@open-formulieren/sdk'; // JS API
import '@open-formulieren/sdk/styles.css'; // import the (default) stylesheet

const form = new OpenForm(targetNode, options);
form.init();
```

[backend]: https://github.com/open-formulieren/open-forms
[docker]: https://hub.docker.com/r/openformulieren/open-forms-sdk
[docs]: https://open-forms.readthedocs.io/en/latest/
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
Open Forms SDK
==============

:Version: 1.1.0-rc.0
:Source: https://github.com/maykinmedia/open-forms-sdk
:Version: 1.2.0-alpha.1
:Source: https://github.com/open-formulieren/open-forms-sdk
:Keywords: e-Formulieren, Common Ground, FormIO, API

|docs|
Expand Down
Loading