diff --git a/src/components/formio/columns/columns.component.tsx b/src/components/formio/columns/columns.component.tsx deleted file mode 100644 index 90e1cc4..0000000 --- a/src/components/formio/columns/columns.component.tsx +++ /dev/null @@ -1,60 +0,0 @@ -import {Component} from '@components/utils'; -import {IComponentProps} from '@types'; -import clsx from 'clsx'; -import {ComponentSchema} from 'formiojs'; -import React from 'react'; - -export interface IColumnsComponent extends ComponentSchema { - type: 'columns'; - columns: IFormioColumn[]; -} - -export interface IColumnsProps extends IComponentProps { - component: IColumnsComponent; -} - -/** - * This component can be used for grouping other components, like Text Field, Text Area, Checkbox - * etc., into configurable columns. It might be useful if you want to display more than one - * component in one line. - */ -export const Columns = (componentProps: IColumnsProps): React.ReactElement => { - const {children} = componentProps; - const className = clsx(`of-${componentProps.component.type}`); - - return ( - -
{children}
-
- ); -}; - -type ColumnSize = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12; - -export interface IFormioColumn { - components: ComponentSchema[]; - size: ColumnSize; - sizeMobile?: ColumnSize; -} - -type IFormioColumnComponentSchema = IFormioColumn & ComponentSchema; - -export interface IColumnComponent extends IFormioColumnComponentSchema { - type: 'column'; -} - -export interface IColumnProps extends IComponentProps { - component: IColumnComponent; -} - -/** - * Not actually a component but an extension of `IFormioColumn` with a fixed type "column" allowing - * it to be picked up by the renderer. This component is automatically generated for each `columns` - * entry in a Form.io component. - */ -export const Column = (columnProps: IColumnProps): React.ReactElement => { - const {children} = columnProps; - const className = clsx(`of-column`); - - return
{children}
; -}; diff --git a/src/components/formio/columns/columns.stories.tsx b/src/components/formio/columns/columns.stories.tsx deleted file mode 100644 index c1ef0bd..0000000 --- a/src/components/formio/columns/columns.stories.tsx +++ /dev/null @@ -1,45 +0,0 @@ -import {Columns} from '@components'; -import {RenderComponent} from '@lib/renderer'; -import {expect} from '@storybook/jest'; -import type {ComponentStory, Meta} from '@storybook/react'; -import {within} from '@storybook/testing-library'; - -import {FormikDecorator} from '../../../tests/utils/decorators'; - -const meta: Meta = { - title: 'Components / Formio / Columns', - component: Columns, - decorators: [], - parameters: {}, -}; -export default meta; - -export const columns: ComponentStory = args => ( - -); -columns.args = { - component: { - key: 'foo', - type: 'columns', - columns: [ - { - key: 'foo.foo', - type: 'column', - size: 9, - components: [{key: 'foo.foo.foo', type: 'content', html: 'Left column.'}], - }, - { - key: 'foo.bar', - type: 'column', - size: 3, - components: [{key: 'foo.bar.bar', type: 'content', html: 'Right column.'}], - }, - ], - }, -}; -columns.play = async ({canvasElement}) => { - const canvas = within(canvasElement); - expect(await canvas.findByText('Left column.')).toBeVisible(); - expect(await canvas.findByText('Right column.')).toBeVisible(); -}; -columns.decorators = [FormikDecorator]; diff --git a/src/components/formio/columns/index.ts b/src/components/formio/columns/index.ts deleted file mode 100644 index 19684bc..0000000 --- a/src/components/formio/columns/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './columns.component'; diff --git a/src/components/formio/content/content.component.tsx b/src/components/formio/content/content.component.tsx deleted file mode 100644 index 2b73bba..0000000 --- a/src/components/formio/content/content.component.tsx +++ /dev/null @@ -1,31 +0,0 @@ -import {IComponentProps} from '@types'; -import clsx from 'clsx'; -import {ComponentSchema} from 'formiojs'; -import React from 'react'; - -export interface IContentComponent extends ComponentSchema { - html: string; - type: 'content'; -} - -export interface IContentProps extends IComponentProps { - component: IContentComponent; -} - -/** - * A Content component may be added to a form to provide non-field information. For example, if you - * need instructions at the top of a form that are for display only, use the Content component. The - * Content component value is not submitted back to the server. - * WARNING: HTML is passed into dangerouslySetInnerHTML prop. - */ -export const Content = (contentProps: IContentProps): React.ReactElement => { - const {component, children} = contentProps; - const className = clsx(`of-${contentProps.component.type}`); - - return ( -
-
- {children} -
- ); -}; diff --git a/src/components/formio/content/content.stories.tsx b/src/components/formio/content/content.stories.tsx deleted file mode 100644 index 0266961..0000000 --- a/src/components/formio/content/content.stories.tsx +++ /dev/null @@ -1,31 +0,0 @@ -import {Content} from '@components'; -import {RenderComponent} from '@lib/renderer'; -import {expect} from '@storybook/jest'; -import type {ComponentStory, Meta} from '@storybook/react'; -import {within} from '@storybook/testing-library'; - -import {FormikDecorator} from '../../../tests/utils/decorators'; - -const meta: Meta = { - title: 'Components / Formio / Content', - component: Content, - decorators: [], - parameters: {}, -}; -export default meta; - -export const content: ComponentStory = args => ( - -); -content.args = { - component: { - key: 'foo', - type: 'content', - html: 'The quick brown fox jumps over the lazy dog.', - }, -}; -content.play = async ({canvasElement}) => { - const canvas = within(canvasElement); - expect(await canvas.findByText('quick')).toBeVisible(); -}; -content.decorators = [FormikDecorator]; diff --git a/src/components/formio/content/index.ts b/src/components/formio/content/index.ts deleted file mode 100644 index f35e396..0000000 --- a/src/components/formio/content/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './content.component'; diff --git a/src/components/formio/index.ts b/src/components/formio/index.ts deleted file mode 100644 index 7da67a3..0000000 --- a/src/components/formio/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './columns'; -export * from './content'; -export * from './textfield'; diff --git a/src/components/formio/textfield/index.ts b/src/components/formio/textfield/index.ts deleted file mode 100644 index bb6c156..0000000 --- a/src/components/formio/textfield/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './textfield.component'; diff --git a/src/components/formio/textfield/textfield.component.tsx b/src/components/formio/textfield/textfield.component.tsx deleted file mode 100644 index 0bdd46e..0000000 --- a/src/components/formio/textfield/textfield.component.tsx +++ /dev/null @@ -1,70 +0,0 @@ -import {CharCount, Component, Description, Errors, Label} from '@components/utils'; -import {IComponentProps} from '@types'; -import clsx from 'clsx'; -import {ComponentSchema} from 'formiojs'; -import React, {useState} from 'react'; - -export interface ITextFieldComponent extends ComponentSchema { - id: string; - inputMask: string; - key: string; - label: string; - mask: string; - showCharCount: boolean; - type: 'textfield'; -} - -// TODO: replace with @open-formulieren/open-forms-types TextFieldSchema type when its available -export interface ITextFieldProps extends IComponentProps { - component: ITextFieldComponent; - value: string; -} - -/** - * A Text Field can be used for short and general text input. There are options to define input - * masks and validations, allowing users to mold information into desired formats. - */ -export const TextField: React.FC = ({callbacks, component, value, errors}) => { - const {onChange, ..._callbacks} = callbacks; - const [pristineState, setPristineState] = useState(true); - const inputClassName = clsx(`of-${component.type}`); - const componentId = `${component.id}-${component.key}`; - - const inputAttrs = { - disabled: component.disabled, - id: componentId, - multiple: component.multiple, - name: component.key, - pattern: component.validate?.pattern || undefined, - placeholder: component.placeholder || component.mask || component.inputMask || undefined, - required: component.validate?.required, - ...component.widget, // TODO: Check if component.hidden should be used manually or even component.inputType. - }; - - /** - * @param {React.FormEvent} event - */ - const _onChange = (event: React.FormEvent) => { - setPristineState(false); - onChange && onChange(event); - }; - - return ( - - - ); -}; diff --git a/src/components/formio/textfield/textfield.stories.tsx b/src/components/formio/textfield/textfield.stories.tsx deleted file mode 100644 index 5d6090c..0000000 --- a/src/components/formio/textfield/textfield.stories.tsx +++ /dev/null @@ -1,40 +0,0 @@ -import {TextField} from '@components'; -import {RenderComponent} from '@lib/renderer'; -import {expect} from '@storybook/jest'; -import type {ComponentStory, Meta} from '@storybook/react'; -import {userEvent, within} from '@storybook/testing-library'; - -import {FormikDecorator} from '../../../tests/utils/decorators'; - -const meta: Meta = { - title: 'Components / Formio / Textfield', - component: TextField, - decorators: [], - parameters: {}, -}; -export default meta; - -export const textfield: ComponentStory = args => ( - -); -textfield.args = { - component: { - description: 'Enter your first name', - id: 'id', - inputMask: '', - key: 'firstName', - label: 'first name', - mask: '', - showCharCount: true, - type: 'textfield', - }, -}; -textfield.play = async ({canvasElement}) => { - const canvas = within(canvasElement); - const input = canvas.getByLabelText('first name'); - expect(await canvas.findByText('Enter your first name')).toBeVisible(); - expect(canvas.queryByText('0 characters')).toBeNull(); - await userEvent.type(input, 'The quick brown fox jumps over the lazy dog.', {delay: 10}); - expect(await canvas.findByText('44 characters')).toBeVisible(); -}; -textfield.decorators = [FormikDecorator]; diff --git a/src/components/index.ts b/src/components/index.ts deleted file mode 100644 index 13bcead..0000000 --- a/src/components/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './formio'; -export * from './utils'; diff --git a/src/components/utils/charcount/charcount.component.tsx b/src/components/utils/charcount/charcount.component.tsx deleted file mode 100644 index 2836c70..0000000 --- a/src/components/utils/charcount/charcount.component.tsx +++ /dev/null @@ -1,14 +0,0 @@ -import clsx from 'clsx'; -import React from 'react'; - -export interface ICharCountProps { - value: string; -} - -/** - * Reusable component showing `count` as number of characters typed into the component. - */ -export const CharCount: React.FC = ({value}) => { - const className = clsx(`of-charcount`); - return {value.length} characters; -}; diff --git a/src/components/utils/charcount/charcount.stories.tsx b/src/components/utils/charcount/charcount.stories.tsx deleted file mode 100644 index 1c2723f..0000000 --- a/src/components/utils/charcount/charcount.stories.tsx +++ /dev/null @@ -1,21 +0,0 @@ -import {CharCount} from '@components'; -import {expect} from '@storybook/jest'; -import type {ComponentStory, Meta} from '@storybook/react'; -import {within} from '@storybook/testing-library'; - -const meta: Meta = { - title: 'Components / Utils / Charcount', - component: CharCount, - decorators: [], - parameters: {}, -}; -export default meta; - -export const charcount: ComponentStory = args => ; -charcount.args = { - value: 'foo', -}; -charcount.play = async ({canvasElement}) => { - const canvas = within(canvasElement); - expect(await canvas.findByText('3 characters')).toBeVisible(); -}; diff --git a/src/components/utils/charcount/index.ts b/src/components/utils/charcount/index.ts deleted file mode 100644 index e616e12..0000000 --- a/src/components/utils/charcount/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './charcount.component'; diff --git a/src/components/utils/component/component.component.tsx b/src/components/utils/component/component.component.tsx deleted file mode 100644 index f71dde1..0000000 --- a/src/components/utils/component/component.component.tsx +++ /dev/null @@ -1,11 +0,0 @@ -import clsx from 'clsx'; -import React from 'react'; - -/** - * Structural wrapper for the component. A component's implementation should be placed in `children` - * prop. - */ -export const Component: React.FC = ({children}) => { - const className = clsx(`of-component`); - return
{children}
; -}; diff --git a/src/components/utils/component/component.stories.tsx b/src/components/utils/component/component.stories.tsx deleted file mode 100644 index 722fcc9..0000000 --- a/src/components/utils/component/component.stories.tsx +++ /dev/null @@ -1,21 +0,0 @@ -import {Component} from '@components'; -import {expect} from '@storybook/jest'; -import type {ComponentStory, Meta} from '@storybook/react'; -import {within} from '@storybook/testing-library'; - -const meta: Meta = { - title: 'Components / Utils / Component', - component: Component, - decorators: [], - parameters: {}, -}; -export default meta; - -export const component: ComponentStory = args => ; -component.args = { - children: 'The quick brown fox jumps over the lazy dog.', -}; -component.play = async ({canvasElement}) => { - const canvas = within(canvasElement); - expect(await canvas.findByText('The quick brown fox jumps over the lazy dog.')).toBeVisible(); -}; diff --git a/src/components/utils/component/index.ts b/src/components/utils/component/index.ts deleted file mode 100644 index c2d056f..0000000 --- a/src/components/utils/component/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './component.component'; diff --git a/src/components/utils/description/description.component.tsx b/src/components/utils/description/description.component.tsx deleted file mode 100644 index 6ebda7d..0000000 --- a/src/components/utils/description/description.component.tsx +++ /dev/null @@ -1,14 +0,0 @@ -import clsx from 'clsx'; -import React from 'react'; - -interface IDescriptionProps { - description: string; -} - -/** - * Description/help text section of a component. - */ -export const Description: React.FC = ({description}) => { - const className = clsx(`of-description`); - return
{description}
; -}; diff --git a/src/components/utils/description/description.stories.tsx b/src/components/utils/description/description.stories.tsx deleted file mode 100644 index 6e824e4..0000000 --- a/src/components/utils/description/description.stories.tsx +++ /dev/null @@ -1,21 +0,0 @@ -import {Description} from '@components'; -import {expect} from '@storybook/jest'; -import type {ComponentStory, Meta} from '@storybook/react'; -import {within} from '@storybook/testing-library'; - -const meta: Meta = { - title: 'Components / Utils / Description', - component: Description, - decorators: [], - parameters: {}, -}; -export default meta; - -export const description: ComponentStory = args => ; -description.args = { - description: 'The quick brown fox jumps over the lazy dog.', -}; -description.play = async ({canvasElement}) => { - const canvas = within(canvasElement); - expect(await canvas.findByText('The quick brown fox jumps over the lazy dog.')).toBeVisible(); -}; diff --git a/src/components/utils/description/index.ts b/src/components/utils/description/index.ts deleted file mode 100644 index 97ae638..0000000 --- a/src/components/utils/description/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './description.component'; diff --git a/src/components/utils/errors/errors.component.tsx b/src/components/utils/errors/errors.component.tsx deleted file mode 100644 index 2d940ae..0000000 --- a/src/components/utils/errors/errors.component.tsx +++ /dev/null @@ -1,30 +0,0 @@ -import clsx from 'clsx'; -import React from 'react'; - -export interface IErrorsProps { - componentId: string; - errors: string[]; -} - -/** - * Reusable component showing `errors` as list of error messages for the component. - */ -export const Errors: React.FC = ({componentId, errors}) => { - const className = clsx(`of-error-list`); - const listItemClassName = clsx(`of-error-list__item`); - const labelClassName = clsx(`of-error-list__message`); - - return ( -
    - {errors?.map((error: string, index: number) => { - return ( -
  • - -
  • - ); - })} -
- ); -}; diff --git a/src/components/utils/errors/errors.stories.tsx b/src/components/utils/errors/errors.stories.tsx deleted file mode 100644 index fa951d8..0000000 --- a/src/components/utils/errors/errors.stories.tsx +++ /dev/null @@ -1,24 +0,0 @@ -import {Errors} from '@components'; -import {expect} from '@storybook/jest'; -import type {ComponentStory, Meta} from '@storybook/react'; -import {within} from '@storybook/testing-library'; - -const meta: Meta = { - title: 'Components / Utils / Errors', - component: Errors, - decorators: [], - parameters: {}, -}; -export default meta; - -export const errors: ComponentStory = args => ; -errors.args = { - errors: ['Postcode is required', 'Postcode does not match the pattern ^\\d{4}\\s?[a-zA-Z]{2}$'], -}; -errors.play = async ({canvasElement}) => { - const canvas = within(canvasElement); - expect(await canvas.findByText('Postcode is required')).toBeVisible(); - expect( - await canvas.findByText('Postcode does not match the pattern ^\\d{4}\\s?[a-zA-Z]{2}$') - ).toBeVisible(); -}; diff --git a/src/components/utils/errors/index.ts b/src/components/utils/errors/index.ts deleted file mode 100644 index 1bf4f09..0000000 --- a/src/components/utils/errors/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './errors.component'; diff --git a/src/components/utils/index.ts b/src/components/utils/index.ts deleted file mode 100644 index cd0a43f..0000000 --- a/src/components/utils/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -export * from './charcount'; -export * from './component'; -export * from './description'; -export * from './errors'; -export * from './label'; diff --git a/src/components/utils/label/index.ts b/src/components/utils/label/index.ts deleted file mode 100644 index abbc12d..0000000 --- a/src/components/utils/label/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './label.component'; diff --git a/src/components/utils/label/label.component.tsx b/src/components/utils/label/label.component.tsx deleted file mode 100644 index d887bd4..0000000 --- a/src/components/utils/label/label.component.tsx +++ /dev/null @@ -1,20 +0,0 @@ -import clsx from 'clsx'; -import React from 'react'; - -interface ILabelProps { - componentId: string; - label: string; -} - -/** - * Label component. - */ -export const Label: React.FC = ({componentId, label}) => { - const className = clsx(); - - return ( - - ); -}; diff --git a/src/components/utils/label/label.stories.tsx b/src/components/utils/label/label.stories.tsx deleted file mode 100644 index 3ca7819..0000000 --- a/src/components/utils/label/label.stories.tsx +++ /dev/null @@ -1,21 +0,0 @@ -import {Label} from '@components'; -import {expect} from '@storybook/jest'; -import type {ComponentStory, Meta} from '@storybook/react'; -import {within} from '@storybook/testing-library'; - -const meta: Meta = { - title: 'Components / Utils / Label', - component: Label, - decorators: [], - parameters: {}, -}; -export default meta; - -export const label: ComponentStory = args =>