@bluecateng/pelagos-forms 5.3.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 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.
@@ -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
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bluecateng/pelagos-forms",
3
- "version": "5.3.0",
3
+ "version": "5.3.1",
4
4
  "description": "Form components",
5
5
  "license": "ISC",
6
6
  "sideEffects": false,
@@ -21,10 +21,16 @@
21
21
  "dist"
22
22
  ],
23
23
  "types": "./dist/index.d.ts",
24
- "exports": "./dist/index.js",
24
+ "exports": {
25
+ "types": "./dist/index.d.ts",
26
+ "default": "./dist/index.js"
27
+ },
28
+ "dependencies": {
29
+ "prop-types": "^15.8.1"
30
+ },
25
31
  "peerDependencies": {
26
- "@bluecateng/auto-forms": ">= 0",
27
- "@bluecateng/pelagos": ">= 10"
32
+ "@bluecateng/auto-forms": ">= 1",
33
+ "@bluecateng/pelagos": ">= 12.23"
28
34
  },
29
- "gitHead": "971bd581aada6d75b44bf488b0a87a19bb938683"
35
+ "gitHead": "e95b4cd0a8a299353aa602e0feb0334e7ae5e513"
30
36
  }