@bluecateng/pelagos-forms 5.2.0 → 5.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -0
- package/dist/components/FormCheckBox.d.ts +13 -0
- package/dist/components/FormDateInput.d.ts +13 -0
- package/dist/components/FormDropDown.d.ts +13 -0
- package/dist/components/FormFileUploader.d.ts +13 -0
- package/dist/components/FormListInput.d.ts +14 -0
- package/dist/components/FormRadioGroup.d.ts +13 -0
- package/dist/components/FormSubmit.d.ts +9 -0
- package/dist/components/FormSubmit.js +3 -3
- package/dist/components/FormTagComboBox.d.ts +14 -0
- package/dist/components/FormTagInput.d.ts +13 -0
- package/dist/components/FormTextArea.d.ts +13 -0
- package/dist/components/FormTextInput.d.ts +13 -0
- package/dist/components/FormToggle.d.ts +13 -0
- package/dist/index.d.ts +98 -0
- package/package.json +14 -6
package/README.md
CHANGED
|
@@ -2,8 +2,50 @@
|
|
|
2
2
|
|
|
3
3
|
Form components.
|
|
4
4
|
|
|
5
|
+
The components are [@bluecateng/pelagos](https://www.npmjs.com/package/@bluecateng/pelagos) fields connected to a [@bluecateng/auto-forms](https://www.npmjs.com/package/@bluecateng/auto-forms) `Form`. Each one takes a `name` prop with the name of the form field, plus the props of the component it wraps, except the ones which are provided by the form.
|
|
6
|
+
|
|
5
7
|
## Installation
|
|
6
8
|
|
|
7
9
|
```bash
|
|
8
10
|
npm i -S @bluecateng/pelagos-forms
|
|
9
11
|
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```javascript
|
|
16
|
+
import {Form, validateNotEmpty} from '@bluecateng/auto-forms';
|
|
17
|
+
import {FormSubmit, FormTextInput} from '@bluecateng/pelagos-forms';
|
|
18
|
+
|
|
19
|
+
const initialValues = {name: ''};
|
|
20
|
+
const rules = {name: validateNotEmpty('The name is required.')};
|
|
21
|
+
|
|
22
|
+
const Example = ({onSave}) => (
|
|
23
|
+
<Form initialValues={initialValues} rules={rules} onSubmit={onSave}>
|
|
24
|
+
<FormTextInput id="name" name="name" label="Name" />
|
|
25
|
+
<FormSubmit text="Save" />
|
|
26
|
+
</Form>
|
|
27
|
+
);
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Components
|
|
31
|
+
|
|
32
|
+
| Component | Wraps | Provided by the form |
|
|
33
|
+
| ------------------ | ------------------ | ---------------------------------------------------------------- |
|
|
34
|
+
| `FormCheckBox` | `CheckBox` | `checked`, `onChange` |
|
|
35
|
+
| `FormDateInput` | `DateInputField` | `value`, `error`, `onChange` |
|
|
36
|
+
| `FormDropDown` | `DropDownField` | `value`, `error`, `onChange` |
|
|
37
|
+
| `FormFileUploader` | `FileUploader` | `files`, `error`, `onChange` |
|
|
38
|
+
| `FormListInput` | `ListInput` | `list`, `error`, `onListChange`, `onTextChange`, `onErrorChange` |
|
|
39
|
+
| `FormRadioGroup` | `RadioGroup` | `value`, `onChange` |
|
|
40
|
+
| `FormTagComboBox` | `TagComboBoxField` | `tags`, `error`, `onChange`, `onError` |
|
|
41
|
+
| `FormTagInput` | `TagInputField` | `tags`, `error`, `onChange`, `onError` |
|
|
42
|
+
| `FormTextArea` | `TextAreaField` | `value`, `error`, `onChange` |
|
|
43
|
+
| `FormTextInput` | `TextInputField` | `value`, `error`, `onChange` |
|
|
44
|
+
| `FormToggle` | `ToggleField` | `value`, `onChange` |
|
|
45
|
+
| `FormSubmit` | `Button` | `type` |
|
|
46
|
+
|
|
47
|
+
`FormCheckBox`, `FormRadioGroup` and `FormToggle` do not receive the field error, so a validation rule on those fields is not displayed by the component. Show the error with `useFormField` if one is needed.
|
|
48
|
+
|
|
49
|
+
`FormListInput` stores in the form extras whether the input has text which was not added to the list, use it in `extraValidation` to reject the form in that case.
|
|
50
|
+
|
|
51
|
+
`FormSubmit` is a `Button` which is displayed as primary when the form values are different from the initial values, and as tertiary otherwise.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type {ComponentType} from 'react';
|
|
2
|
+
import type {CheckBoxProps} from '@bluecateng/pelagos';
|
|
3
|
+
|
|
4
|
+
export interface FormCheckBoxProps extends Omit<CheckBoxProps, 'checked' | 'onChange'> {
|
|
5
|
+
/** The form field name used by auto-forms connect HOC */
|
|
6
|
+
name: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* A form-connected CheckBox whose checked state is managed by auto-forms.
|
|
11
|
+
*/
|
|
12
|
+
declare const FormCheckBox: ComponentType<FormCheckBoxProps>;
|
|
13
|
+
export default FormCheckBox;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type {ComponentType} from 'react';
|
|
2
|
+
import type {DateInputFieldProps} from '@bluecateng/pelagos';
|
|
3
|
+
|
|
4
|
+
export interface FormDateInputProps extends Omit<DateInputFieldProps, 'value' | 'error' | 'onChange'> {
|
|
5
|
+
/** The form field name used by auto-forms connect HOC */
|
|
6
|
+
name: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* A form-connected DateInputField whose value is managed by auto-forms.
|
|
11
|
+
*/
|
|
12
|
+
declare const FormDateInput: ComponentType<FormDateInputProps>;
|
|
13
|
+
export default FormDateInput;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type {ReactElement} from 'react';
|
|
2
|
+
import type {DropDownFieldProps} from '@bluecateng/pelagos';
|
|
3
|
+
|
|
4
|
+
export interface FormDropDownProps<T> extends Omit<DropDownFieldProps<T>, 'value' | 'error' | 'onChange'> {
|
|
5
|
+
/** The form field name used by auto-forms connect HOC */
|
|
6
|
+
name: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* A form-connected DropDownField whose value is managed by auto-forms.
|
|
11
|
+
*/
|
|
12
|
+
declare const FormDropDown: <T>(props: FormDropDownProps<T>) => ReactElement;
|
|
13
|
+
export default FormDropDown;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type {ComponentType} from 'react';
|
|
2
|
+
import type {FileUploaderProps} from '@bluecateng/pelagos';
|
|
3
|
+
|
|
4
|
+
export interface FormFileUploaderProps extends Omit<FileUploaderProps, 'files' | 'error' | 'onChange'> {
|
|
5
|
+
/** The form field name used by auto-forms connect HOC */
|
|
6
|
+
name: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* A form-connected FileUploader whose value is managed by auto-forms.
|
|
11
|
+
*/
|
|
12
|
+
declare const FormFileUploader: ComponentType<FormFileUploaderProps>;
|
|
13
|
+
export default FormFileUploader;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type {ReactElement} from 'react';
|
|
2
|
+
import type {ListInputProps} from '@bluecateng/pelagos';
|
|
3
|
+
|
|
4
|
+
export interface FormListInputProps<T>
|
|
5
|
+
extends Omit<ListInputProps<T>, 'list' | 'error' | 'onListChange' | 'onTextChange' | 'onErrorChange'> {
|
|
6
|
+
/** The form field name used by auto-forms connect HOC */
|
|
7
|
+
name: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* A form-connected ListInput whose value is managed by auto-forms.
|
|
12
|
+
*/
|
|
13
|
+
declare const FormListInput: <T>(props: FormListInputProps<T>) => ReactElement;
|
|
14
|
+
export default FormListInput;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type {ComponentType} from 'react';
|
|
2
|
+
import type {RadioGroupProps} from '@bluecateng/pelagos';
|
|
3
|
+
|
|
4
|
+
export interface FormRadioGroupProps extends Omit<RadioGroupProps, 'value' | 'onChange'> {
|
|
5
|
+
/** The form field name used by auto-forms connect HOC */
|
|
6
|
+
name: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* A form-connected RadioGroup whose value is managed by auto-forms.
|
|
11
|
+
*/
|
|
12
|
+
declare const FormRadioGroup: ComponentType<FormRadioGroupProps>;
|
|
13
|
+
export default FormRadioGroup;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type {ComponentType} from 'react';
|
|
2
|
+
import type {ButtonProps} from '@bluecateng/pelagos';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A submit button that adapts its visual `type` based on form dirty state.
|
|
6
|
+
* The underlying Button's `type` prop is controlled internally.
|
|
7
|
+
*/
|
|
8
|
+
declare const FormSubmit: ComponentType<Omit<ButtonProps, 'type'>>;
|
|
9
|
+
export default FormSubmit;
|
|
@@ -2,9 +2,7 @@ import PropTypes from 'prop-types';
|
|
|
2
2
|
import { Button } from '@bluecateng/pelagos';
|
|
3
3
|
import { useFormState } from '@bluecateng/auto-forms';
|
|
4
4
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
-
const FormSubmit =
|
|
6
|
-
...props
|
|
7
|
-
}) => {
|
|
5
|
+
const FormSubmit = props => {
|
|
8
6
|
const {
|
|
9
7
|
isChanged
|
|
10
8
|
} = useFormState();
|
|
@@ -20,6 +18,8 @@ FormSubmit.propTypes = {
|
|
|
20
18
|
className: PropTypes.string,
|
|
21
19
|
tooltipText: PropTypes.string,
|
|
22
20
|
size: PropTypes.oneOf(['small', 'medium', 'large']),
|
|
21
|
+
disabled: PropTypes.bool,
|
|
22
|
+
onClick: PropTypes.func,
|
|
23
23
|
onFocus: PropTypes.func,
|
|
24
24
|
onBlur: PropTypes.func
|
|
25
25
|
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type {ReactElement} from 'react';
|
|
2
|
+
import type {TagComboBoxFieldProps} from '@bluecateng/pelagos';
|
|
3
|
+
|
|
4
|
+
export interface FormTagComboBoxProps<T>
|
|
5
|
+
extends Omit<TagComboBoxFieldProps<T>, 'tags' | 'error' | 'onChange' | 'onError'> {
|
|
6
|
+
/** The form field name used by auto-forms connect HOC */
|
|
7
|
+
name: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* A form-connected TagComboBoxField whose value is managed by auto-forms.
|
|
12
|
+
*/
|
|
13
|
+
declare const FormTagComboBox: <T>(props: FormTagComboBoxProps<T>) => ReactElement;
|
|
14
|
+
export default FormTagComboBox;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type {ComponentType} from 'react';
|
|
2
|
+
import type {TagInputFieldProps} from '@bluecateng/pelagos';
|
|
3
|
+
|
|
4
|
+
export interface FormTagInputProps extends Omit<TagInputFieldProps, 'tags' | 'error' | 'onChange' | 'onError'> {
|
|
5
|
+
/** The form field name used by auto-forms connect HOC */
|
|
6
|
+
name: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* A form-connected TagInputField whose value is managed by auto-forms.
|
|
11
|
+
*/
|
|
12
|
+
declare const FormTagInput: ComponentType<FormTagInputProps>;
|
|
13
|
+
export default FormTagInput;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type {ComponentType} from 'react';
|
|
2
|
+
import type {TextAreaFieldProps} from '@bluecateng/pelagos';
|
|
3
|
+
|
|
4
|
+
export interface FormTextAreaProps extends Omit<TextAreaFieldProps, 'value' | 'error' | 'onChange'> {
|
|
5
|
+
/** The form field name used by auto-forms connect HOC */
|
|
6
|
+
name: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* A form-connected TextAreaField whose value is managed by auto-forms.
|
|
11
|
+
*/
|
|
12
|
+
declare const FormTextArea: ComponentType<FormTextAreaProps>;
|
|
13
|
+
export default FormTextArea;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type {ComponentType} from 'react';
|
|
2
|
+
import type {TextInputFieldProps} from '@bluecateng/pelagos';
|
|
3
|
+
|
|
4
|
+
export interface FormTextInputProps extends Omit<TextInputFieldProps, 'value' | 'error' | 'onChange'> {
|
|
5
|
+
/** The form field name used by auto-forms connect HOC */
|
|
6
|
+
name: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* A form-connected TextInputField whose value is managed by auto-forms.
|
|
11
|
+
*/
|
|
12
|
+
declare const FormTextInput: ComponentType<FormTextInputProps>;
|
|
13
|
+
export default FormTextInput;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type {ComponentType} from 'react';
|
|
2
|
+
import type {ToggleFieldProps} from '@bluecateng/pelagos';
|
|
3
|
+
|
|
4
|
+
export interface FormToggleProps extends Omit<ToggleFieldProps, 'value' | 'onChange'> {
|
|
5
|
+
/** The form field name used by auto-forms connect HOC */
|
|
6
|
+
name: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* A form-connected ToggleField whose value is managed by auto-forms.
|
|
11
|
+
*/
|
|
12
|
+
declare const FormToggle: ComponentType<FormToggleProps>;
|
|
13
|
+
export default FormToggle;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { ButtonProps, CheckBoxProps, DateInputFieldProps, DropDownFieldProps, FileUploaderProps, ListInputProps, RadioGroupProps, TagComboBoxFieldProps, TagInputFieldProps, TextAreaFieldProps, TextInputFieldProps, ToggleFieldProps } from '@bluecateng/pelagos';
|
|
2
|
+
import { ComponentType, ReactElement } from 'react';
|
|
3
|
+
|
|
4
|
+
export interface FormCheckBoxProps extends Omit<CheckBoxProps, "checked" | "onChange"> {
|
|
5
|
+
/** The form field name used by auto-forms connect HOC */
|
|
6
|
+
name: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* A form-connected CheckBox whose checked state is managed by auto-forms.
|
|
10
|
+
*/
|
|
11
|
+
export declare const FormCheckBox: ComponentType<FormCheckBoxProps>;
|
|
12
|
+
export interface FormDateInputProps extends Omit<DateInputFieldProps, "value" | "error" | "onChange"> {
|
|
13
|
+
/** The form field name used by auto-forms connect HOC */
|
|
14
|
+
name: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* A form-connected DateInputField whose value is managed by auto-forms.
|
|
18
|
+
*/
|
|
19
|
+
export declare const FormDateInput: ComponentType<FormDateInputProps>;
|
|
20
|
+
export interface FormDropDownProps<T> extends Omit<DropDownFieldProps<T>, "value" | "error" | "onChange"> {
|
|
21
|
+
/** The form field name used by auto-forms connect HOC */
|
|
22
|
+
name: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* A form-connected DropDownField whose value is managed by auto-forms.
|
|
26
|
+
*/
|
|
27
|
+
export declare const FormDropDown: <T>(props: FormDropDownProps<T>) => ReactElement;
|
|
28
|
+
export interface FormFileUploaderProps extends Omit<FileUploaderProps, "files" | "error" | "onChange"> {
|
|
29
|
+
/** The form field name used by auto-forms connect HOC */
|
|
30
|
+
name: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* A form-connected FileUploader whose value is managed by auto-forms.
|
|
34
|
+
*/
|
|
35
|
+
export declare const FormFileUploader: ComponentType<FormFileUploaderProps>;
|
|
36
|
+
export interface FormTagComboBoxProps<T> extends Omit<TagComboBoxFieldProps<T>, "tags" | "error" | "onChange" | "onError"> {
|
|
37
|
+
/** The form field name used by auto-forms connect HOC */
|
|
38
|
+
name: string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* A form-connected TagComboBoxField whose value is managed by auto-forms.
|
|
42
|
+
*/
|
|
43
|
+
export declare const FormTagComboBox: <T>(props: FormTagComboBoxProps<T>) => ReactElement;
|
|
44
|
+
export interface FormTagInputProps extends Omit<TagInputFieldProps, "tags" | "error" | "onChange" | "onError"> {
|
|
45
|
+
/** The form field name used by auto-forms connect HOC */
|
|
46
|
+
name: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* A form-connected TagInputField whose value is managed by auto-forms.
|
|
50
|
+
*/
|
|
51
|
+
export declare const FormTagInput: ComponentType<FormTagInputProps>;
|
|
52
|
+
export interface FormTextAreaProps extends Omit<TextAreaFieldProps, "value" | "error" | "onChange"> {
|
|
53
|
+
/** The form field name used by auto-forms connect HOC */
|
|
54
|
+
name: string;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* A form-connected TextAreaField whose value is managed by auto-forms.
|
|
58
|
+
*/
|
|
59
|
+
export declare const FormTextArea: ComponentType<FormTextAreaProps>;
|
|
60
|
+
export interface FormTextInputProps extends Omit<TextInputFieldProps, "value" | "error" | "onChange"> {
|
|
61
|
+
/** The form field name used by auto-forms connect HOC */
|
|
62
|
+
name: string;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* A form-connected TextInputField whose value is managed by auto-forms.
|
|
66
|
+
*/
|
|
67
|
+
export declare const FormTextInput: ComponentType<FormTextInputProps>;
|
|
68
|
+
export interface FormToggleProps extends Omit<ToggleFieldProps, "value" | "onChange"> {
|
|
69
|
+
/** The form field name used by auto-forms connect HOC */
|
|
70
|
+
name: string;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* A form-connected ToggleField whose value is managed by auto-forms.
|
|
74
|
+
*/
|
|
75
|
+
export declare const FormToggle: ComponentType<FormToggleProps>;
|
|
76
|
+
export interface FormListInputProps<T> extends Omit<ListInputProps<T>, "list" | "error" | "onListChange" | "onTextChange" | "onErrorChange"> {
|
|
77
|
+
/** The form field name used by auto-forms connect HOC */
|
|
78
|
+
name: string;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* A form-connected ListInput whose value is managed by auto-forms.
|
|
82
|
+
*/
|
|
83
|
+
export declare const FormListInput: <T>(props: FormListInputProps<T>) => ReactElement;
|
|
84
|
+
export interface FormRadioGroupProps extends Omit<RadioGroupProps, "value" | "onChange"> {
|
|
85
|
+
/** The form field name used by auto-forms connect HOC */
|
|
86
|
+
name: string;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* A form-connected RadioGroup whose value is managed by auto-forms.
|
|
90
|
+
*/
|
|
91
|
+
export declare const FormRadioGroup: ComponentType<FormRadioGroupProps>;
|
|
92
|
+
/**
|
|
93
|
+
* A submit button that adapts its visual `type` based on form dirty state.
|
|
94
|
+
* The underlying Button's `type` prop is controlled internally.
|
|
95
|
+
*/
|
|
96
|
+
export declare const FormSubmit: ComponentType<Omit<ButtonProps, "type">>;
|
|
97
|
+
|
|
98
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bluecateng/pelagos-forms",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.3.1",
|
|
4
4
|
"description": "Form components",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"scripts": {
|
|
8
|
-
"build": "rm -rf dist && babel -D -d dist --env-name production --root-mode upward src",
|
|
8
|
+
"build": "rm -rf dist && babel -D -d dist --env-name production --root-mode upward src && npm run bundle-dts",
|
|
9
|
+
"bundle-dts": "dts-bundle-generator -o dist/index.d.ts --no-banner --silent --disable-symlinks-following src/index.d.ts",
|
|
9
10
|
"prepack": "npm run build"
|
|
10
11
|
},
|
|
11
12
|
"repository": {
|
|
@@ -19,10 +20,17 @@
|
|
|
19
20
|
"files": [
|
|
20
21
|
"dist"
|
|
21
22
|
],
|
|
22
|
-
"
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
24
|
+
"exports": {
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
26
|
+
"default": "./dist/index.js"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"prop-types": "^15.8.1"
|
|
30
|
+
},
|
|
23
31
|
"peerDependencies": {
|
|
24
|
-
"@bluecateng/auto-forms": ">=
|
|
25
|
-
"@bluecateng/pelagos": ">=
|
|
32
|
+
"@bluecateng/auto-forms": ">= 1",
|
|
33
|
+
"@bluecateng/pelagos": ">= 12.23"
|
|
26
34
|
},
|
|
27
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "e95b4cd0a8a299353aa602e0feb0334e7ae5e513"
|
|
28
36
|
}
|