@dhis2/ui-forms 8.2.0 → 8.2.1
Sign up to get free protection for your applications and to get access to all the features.
- package/build/cjs/CheckboxFieldFF/CheckboxFieldFF.js +24 -21
- package/build/cjs/CheckboxFieldFF/CheckboxFieldFF.stories.js +3 -27
- package/build/cjs/FieldGroupFF/FieldGroupFF.js +7 -6
- package/build/cjs/FieldGroupFF/FieldGroupFF.stories.js +3 -13
- package/build/cjs/FileInputFieldFF/FileInputFieldFF.js +17 -18
- package/build/cjs/FileInputFieldFF/FileInputFieldFF.stories.e2e.js +12 -8
- package/build/cjs/FileInputFieldFF/FileInputFieldFF.stories.js +3 -27
- package/build/cjs/InputFieldFF/InputFieldFF.js +27 -24
- package/build/cjs/InputFieldFF/InputFieldFF.stories.js +3 -27
- package/build/cjs/MultiSelectFieldFF/MultiSelectFieldFF.js +15 -14
- package/build/cjs/MultiSelectFieldFF/MultiSelectFieldFF.stories.e2e.js +13 -10
- package/build/cjs/MultiSelectFieldFF/MultiSelectFieldFF.stories.js +3 -29
- package/build/cjs/RadioFieldFF/RadioFieldFF.js +24 -21
- package/build/cjs/RadioFieldFF/RadioFieldFF.stories.js +3 -27
- package/build/cjs/SingleSelectFieldFF/SingleSelectFieldFF.js +15 -14
- package/build/cjs/SingleSelectFieldFF/SingleSelectFieldFF.stories.e2e.js +13 -10
- package/build/cjs/SingleSelectFieldFF/SingleSelectFieldFF.stories.js +3 -29
- package/build/cjs/SwitchFieldFF/SwitchFieldFF.js +24 -21
- package/build/cjs/SwitchFieldFF/SwitchFieldFF.stories.js +3 -27
- package/build/cjs/TextAreaFieldFF/TextAreaFieldFF.js +26 -23
- package/build/cjs/TextAreaFieldFF/TextAreaFieldFF.stories.js +3 -27
- package/build/cjs/formDecorator.js +6 -5
- package/build/cjs/index.js +12 -11
- package/build/cjs/locales/en/translations.json +0 -1
- package/build/cjs/shared/helpers/createChangeHandler.js +19 -16
- package/build/cjs/shared/helpers/createSelectChangeHandler.js +10 -6
- package/build/cjs/shared/propTypes.js +1 -1
- package/build/cjs/transformers/arrayWithIdObjects.js +6 -3
- package/build/cjs/validators/__tests__/createPattern.test.js +1 -1
- package/build/cjs/validators/composeValidators.js +10 -2
- package/build/cjs/validators/helpers/index.js +1 -1
- package/build/cjs/validators/number.js +1 -1
- package/build/cjs/validators/string.js +1 -1
- package/build/cjs/validators/test-helpers/index.js +2 -2
- package/build/cjs/validators/url.js +1 -1
- package/build/es/CheckboxFieldFF/CheckboxFieldFF.js +24 -21
- package/build/es/CheckboxFieldFF/CheckboxFieldFF.stories.js +2 -26
- package/build/es/FieldGroupFF/FieldGroupFF.js +7 -6
- package/build/es/FieldGroupFF/FieldGroupFF.stories.js +2 -12
- package/build/es/FileInputFieldFF/FileInputFieldFF.js +17 -18
- package/build/es/FileInputFieldFF/FileInputFieldFF.stories.e2e.js +12 -8
- package/build/es/FileInputFieldFF/FileInputFieldFF.stories.js +2 -26
- package/build/es/InputFieldFF/InputFieldFF.js +27 -24
- package/build/es/InputFieldFF/InputFieldFF.stories.js +2 -26
- package/build/es/MultiSelectFieldFF/MultiSelectFieldFF.js +15 -14
- package/build/es/MultiSelectFieldFF/MultiSelectFieldFF.stories.e2e.js +13 -10
- package/build/es/MultiSelectFieldFF/MultiSelectFieldFF.stories.js +2 -28
- package/build/es/RadioFieldFF/RadioFieldFF.js +24 -21
- package/build/es/RadioFieldFF/RadioFieldFF.stories.js +2 -26
- package/build/es/SingleSelectFieldFF/SingleSelectFieldFF.js +15 -14
- package/build/es/SingleSelectFieldFF/SingleSelectFieldFF.stories.e2e.js +13 -10
- package/build/es/SingleSelectFieldFF/SingleSelectFieldFF.stories.js +2 -28
- package/build/es/SwitchFieldFF/SwitchFieldFF.js +24 -21
- package/build/es/SwitchFieldFF/SwitchFieldFF.stories.js +2 -26
- package/build/es/TextAreaFieldFF/TextAreaFieldFF.js +26 -23
- package/build/es/TextAreaFieldFF/TextAreaFieldFF.stories.js +2 -26
- package/build/es/formDecorator.js +6 -5
- package/build/es/locales/en/translations.json +0 -1
- package/build/es/shared/helpers/createChangeHandler.js +19 -16
- package/build/es/shared/helpers/createSelectChangeHandler.js +10 -6
- package/build/es/transformers/arrayWithIdObjects.js +6 -3
- package/build/es/validators/__tests__/createPattern.test.js +1 -1
- package/build/es/validators/composeValidators.js +10 -2
- package/build/es/validators/test-helpers/index.js +1 -1
- package/package.json +10 -10
@@ -19,27 +19,30 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
19
19
|
|
20
20
|
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
21
21
|
|
22
|
-
const CheckboxFieldFF =
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
22
|
+
const CheckboxFieldFF = _ref => {
|
23
|
+
let {
|
24
|
+
error,
|
25
|
+
input,
|
26
|
+
meta,
|
27
|
+
showValidStatus,
|
28
|
+
valid,
|
29
|
+
validationText,
|
30
|
+
onBlur,
|
31
|
+
onFocus,
|
32
|
+
...rest
|
33
|
+
} = _ref;
|
34
|
+
return /*#__PURE__*/_react.default.createElement(_checkbox.CheckboxField, _extends({}, rest, {
|
35
|
+
name: input.name,
|
36
|
+
checked: input.checked,
|
37
|
+
value: input.value,
|
38
|
+
error: (0, _helpers.hasError)(meta, error),
|
39
|
+
valid: (0, _helpers.isValid)(meta, valid, showValidStatus),
|
40
|
+
validationText: (0, _helpers.getValidationText)(meta, validationText, error),
|
41
|
+
onFocus: (0, _helpers.createFocusHandler)(input, onFocus),
|
42
|
+
onChange: (0, _helpers.createToggleChangeHandler)(input),
|
43
|
+
onBlur: (0, _helpers.createBlurHandler)(input, onBlur)
|
44
|
+
}));
|
45
|
+
};
|
43
46
|
|
44
47
|
exports.CheckboxFieldFF = CheckboxFieldFF;
|
45
48
|
CheckboxFieldFF.propTypes = {
|
@@ -3,7 +3,7 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.
|
6
|
+
exports.default = exports.ValueWhenChecked = exports.Statuses = exports.RequiredWithValidate = exports.HelpText = exports.Disabled = exports.Default = void 0;
|
7
7
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
9
9
|
|
@@ -19,33 +19,9 @@ var _CheckboxFieldFF = require("./CheckboxFieldFF.js");
|
|
19
19
|
|
20
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
21
21
|
|
22
|
-
const description = `
|
23
|
-
The \`CheckboxFieldFF\` is a wrapper around a \`CheckboxField\` that enables it to work with Final Form, the preferred library for form validation and utilities in DHIS 2 apps.
|
24
|
-
|
25
|
-
#### Final Form
|
26
|
-
|
27
|
-
See how to use Final Form at [Final Form - Getting Started](https://final-form.org/docs/react-final-form/getting-started).
|
28
|
-
|
29
|
-
Inside a Final Form \`<Form>\` component, these 'FF' UI components are intended to be used in the \`component\` prop of the [Final Form \`<Field>\` components](https://final-form.org/docs/react-final-form/api/Field) where they will receive some props from the Field, e.g. \`<Field component={CheckboxFieldFF} />\`. See the code samples below for examples.
|
30
|
-
|
31
|
-
#### Props
|
32
|
-
|
33
|
-
The props shown in the table below are generally provided to the \`CheckboxFieldFF\` wrapper by the Final Form \`Field\`.
|
34
|
-
|
35
|
-
Note that any props beyond the API of the \`Field\` component will be spread to the \`CheckboxFieldFF\`, which passes any extra props to the underlying \`CheckboxField\` using \`{...rest}\`.
|
36
|
-
|
37
|
-
Therefore, to add any props to the \`CheckboxFieldFF\` or \`CheckboxField\`, add those props to the parent Final Form \`Field\` component.
|
38
|
-
|
39
|
-
Also see \`Checkbox\` and \`CheckboxField\` for notes about props and implementation.
|
40
|
-
|
41
|
-
\`\`\`js
|
42
|
-
import { CheckboxFieldFF } from '@dhis2/ui'
|
43
|
-
\`\`\`
|
44
|
-
|
45
|
-
Press **Submit** to see the form values logged to the console.
|
46
|
-
`;
|
22
|
+
const description = "\nThe `CheckboxFieldFF` is a wrapper around a `CheckboxField` that enables it to work with Final Form, the preferred library for form validation and utilities in DHIS 2 apps.\n\n#### Final Form\n\nSee how to use Final Form at [Final Form - Getting Started](https://final-form.org/docs/react-final-form/getting-started).\n\nInside a Final Form `<Form>` component, these 'FF' UI components are intended to be used in the `component` prop of the [Final Form `<Field>` components](https://final-form.org/docs/react-final-form/api/Field) where they will receive some props from the Field, e.g. `<Field component={CheckboxFieldFF} />`. See the code samples below for examples.\n\n#### Props\n\nThe props shown in the table below are generally provided to the `CheckboxFieldFF` wrapper by the Final Form `Field`.\n\nNote that any props beyond the API of the `Field` component will be spread to the `CheckboxFieldFF`, which passes any extra props to the underlying `CheckboxField` using `{...rest}`.\n\nTherefore, to add any props to the `CheckboxFieldFF` or `CheckboxField`, add those props to the parent Final Form `Field` component.\n\nAlso see `Checkbox` and `CheckboxField` for notes about props and implementation.\n\n```js\nimport { CheckboxFieldFF } from '@dhis2/ui'\n```\n\nPress **Submit** to see the form values logged to the console.\n";
|
47
23
|
var _default = {
|
48
|
-
title: '
|
24
|
+
title: 'Checkbox Field (Final Form)',
|
49
25
|
component: _CheckboxFieldFF.CheckboxFieldFF,
|
50
26
|
decorators: [_formDecorator.formDecorator],
|
51
27
|
parameters: {
|
@@ -15,12 +15,13 @@ var _reactFinalForm = require("react-final-form");
|
|
15
15
|
|
16
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
17
17
|
|
18
|
-
const FieldGroupFF =
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
18
|
+
const FieldGroupFF = _ref => {
|
19
|
+
let {
|
20
|
+
name,
|
21
|
+
label,
|
22
|
+
children,
|
23
|
+
required
|
24
|
+
} = _ref;
|
24
25
|
const {
|
25
26
|
meta: {
|
26
27
|
error,
|
@@ -3,7 +3,7 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.
|
6
|
+
exports.default = exports.Default = void 0;
|
7
7
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
9
9
|
|
@@ -19,19 +19,9 @@ var _FieldGroupFF = require("./FieldGroupFF.js");
|
|
19
19
|
|
20
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
21
21
|
|
22
|
-
const description = `
|
23
|
-
This component is intended for use with [Final Form](https://final-form.org/docs/react-final-form/getting-started), the preferred library for form validation and utilities in DHIS 2 apps.
|
24
|
-
|
25
|
-
\`FieldGroupFF\` groups related fields (using the Final Form \`<Field>\`), like checkboxes, and adds a label and name.
|
26
|
-
|
27
|
-
\`\`\`js
|
28
|
-
import { FieldGroupFF } from '@dhis2/ui'
|
29
|
-
\`\`\`
|
30
|
-
|
31
|
-
Press **Submit** to see the form values logged to the console.
|
32
|
-
`;
|
22
|
+
const description = "\nThis component is intended for use with [Final Form](https://final-form.org/docs/react-final-form/getting-started), the preferred library for form validation and utilities in DHIS 2 apps.\n\n`FieldGroupFF` groups related fields (using the Final Form `<Field>`), like checkboxes, and adds a label and name.\n\n```js\nimport { FieldGroupFF } from '@dhis2/ui'\n```\n\nPress **Submit** to see the form values logged to the console.\n";
|
33
23
|
var _default = {
|
34
|
-
title: '
|
24
|
+
title: 'Field Group (Final Form)',
|
35
25
|
component: _FieldGroupFF.FieldGroupFF,
|
36
26
|
decorators: [_formDecorator.formDecorator],
|
37
27
|
parameters: {
|
@@ -39,9 +39,10 @@ const dedupeAndConcat = (currentFiles, newFileList) => {
|
|
39
39
|
}).files;
|
40
40
|
};
|
41
41
|
|
42
|
-
const createChangeHandler = (input, multifile) =>
|
43
|
-
|
44
|
-
|
42
|
+
const createChangeHandler = (input, multifile) => _ref => {
|
43
|
+
let {
|
44
|
+
files
|
45
|
+
} = _ref;
|
45
46
|
// A JavaScript FileList instance is read-only, so we cannot add files to it
|
46
47
|
// FileList also doesn't have a .map method so by destructuring the FileList
|
47
48
|
// instance into an array we can add, remove and map
|
@@ -56,18 +57,19 @@ const createRemoveHandler = (input, fileToDelete) => () => {
|
|
56
57
|
input.onChange(value);
|
57
58
|
};
|
58
59
|
|
59
|
-
const FileInputFieldFF =
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
60
|
+
const FileInputFieldFF = _ref2 => {
|
61
|
+
let {
|
62
|
+
buttonLabel,
|
63
|
+
disabled,
|
64
|
+
error,
|
65
|
+
input,
|
66
|
+
meta,
|
67
|
+
multifile,
|
68
|
+
showValidStatus,
|
69
|
+
valid,
|
70
|
+
validationText,
|
71
|
+
...rest
|
72
|
+
} = _ref2;
|
71
73
|
const files = input.value || [];
|
72
74
|
return /*#__PURE__*/_react.default.createElement(_fileInput.FileInputField, _extends({}, rest, {
|
73
75
|
onChange: createChangeHandler(input, multifile),
|
@@ -87,9 +89,6 @@ const FileInputFieldFF = ({
|
|
87
89
|
};
|
88
90
|
|
89
91
|
exports.FileInputFieldFF = FileInputFieldFF;
|
90
|
-
FileInputFieldFF.defaultProps = {
|
91
|
-
placeholder: _index.default.t('No file(s) selected yet')
|
92
|
-
};
|
93
92
|
FileInputFieldFF.propTypes = {
|
94
93
|
/** `input` props provided by Final Form `Field` */
|
95
94
|
input: _propTypes2.inputPropType.isRequired,
|
@@ -30,9 +30,10 @@ var _FileInputFieldFF = require("./FileInputFieldFF.js");
|
|
30
30
|
|
31
31
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
32
32
|
|
33
|
-
const StandardForm =
|
34
|
-
|
35
|
-
|
33
|
+
const StandardForm = _ref => {
|
34
|
+
let {
|
35
|
+
values
|
36
|
+
} = _ref;
|
36
37
|
return /*#__PURE__*/_react2.default.createElement("div", {
|
37
38
|
style: {
|
38
39
|
maxWidth: 830
|
@@ -214,7 +215,7 @@ const StandardForm = ({
|
|
214
215
|
const [file] = files;
|
215
216
|
|
216
217
|
if (file.type !== 'text/plain') {
|
217
|
-
return
|
218
|
+
return "The file you provided is not a txt file, received \"".concat(file.type, "\"");
|
218
219
|
}
|
219
220
|
},
|
220
221
|
component: _FileInputFieldFF.FileInputFieldFF
|
@@ -234,7 +235,7 @@ const StandardForm = ({
|
|
234
235
|
}
|
235
236
|
|
236
237
|
if (file.type !== 'application/jpg') {
|
237
|
-
return
|
238
|
+
return "One of the files is not a jpg, received \"".concat(file.type, "\"");
|
238
239
|
}
|
239
240
|
}, undefined);
|
240
241
|
},
|
@@ -254,6 +255,9 @@ const StandardForm = ({
|
|
254
255
|
options: {
|
255
256
|
showPanel: false
|
256
257
|
}
|
257
|
-
}).add('Standard form', (_, {
|
258
|
-
|
259
|
-
|
258
|
+
}).add('Standard form', (_, _ref2) => {
|
259
|
+
let {
|
260
|
+
formRenderProps
|
261
|
+
} = _ref2;
|
262
|
+
return /*#__PURE__*/_react2.default.createElement(StandardForm, formRenderProps);
|
263
|
+
});
|
@@ -3,7 +3,7 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.
|
6
|
+
exports.default = exports.WithValues = exports.Required = exports.PreventPlaceholder = exports.Multifile = exports.Default = void 0;
|
7
7
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
9
9
|
|
@@ -19,34 +19,10 @@ var _FileInputFieldFF = require("./FileInputFieldFF.js");
|
|
19
19
|
|
20
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
21
21
|
|
22
|
-
const description = `
|
23
|
-
The \`FileInputFieldFF\` is a wrapper around a \`FileInputField\` that enables it to work with Final Form, the preferred library in DHIS 2 apps for form validation and utilities.
|
24
|
-
|
25
|
-
#### Final Form
|
26
|
-
|
27
|
-
See how to use Final Form at [Final Form - Getting Started](https://final-form.org/docs/react-final-form/getting-started).
|
28
|
-
|
29
|
-
Inside a Final Form \`<Form>\` component, these 'FF' UI components are intended to be used in the \`component\` prop of the [Final Form \`<Field>\` components](https://final-form.org/docs/react-final-form/api/Field) where they will receive some props from the Field, e.g. \`<Field component={FileInputFieldFF} />\`. See the code samples below for examples.
|
30
|
-
|
31
|
-
#### Props
|
32
|
-
|
33
|
-
The props shown in the table below are generally provided to the \`FileInputFieldFF\` wrapper by the Final Form \`Field\`.
|
34
|
-
|
35
|
-
Note that any props beyond the API of the \`Field\` component will be spread to the \`FileInputFieldFF\`, which passes any extra props to the underlying \`FileInputField\` using \`{...rest}\`.
|
36
|
-
|
37
|
-
Therefore, to add any props to the \`FileInputFieldFF\` or \`FileInputField\`, add those props to the parent Final Form \`Field\` component.
|
38
|
-
|
39
|
-
Also see \`FileInput\` and \`FileInputField\` for notes about props and implementation.
|
40
|
-
|
41
|
-
\`\`\`js
|
42
|
-
import { FileInputFieldFF } from '@dhis2/ui'
|
43
|
-
\`\`\`
|
44
|
-
|
45
|
-
Press **Submit** to see the form values logged to the console.
|
46
|
-
`;
|
22
|
+
const description = "\nThe `FileInputFieldFF` is a wrapper around a `FileInputField` that enables it to work with Final Form, the preferred library in DHIS 2 apps for form validation and utilities.\n\n#### Final Form\n\nSee how to use Final Form at [Final Form - Getting Started](https://final-form.org/docs/react-final-form/getting-started).\n\nInside a Final Form `<Form>` component, these 'FF' UI components are intended to be used in the `component` prop of the [Final Form `<Field>` components](https://final-form.org/docs/react-final-form/api/Field) where they will receive some props from the Field, e.g. `<Field component={FileInputFieldFF} />`. See the code samples below for examples.\n\n#### Props\n\nThe props shown in the table below are generally provided to the `FileInputFieldFF` wrapper by the Final Form `Field`.\n\nNote that any props beyond the API of the `Field` component will be spread to the `FileInputFieldFF`, which passes any extra props to the underlying `FileInputField` using `{...rest}`.\n\nTherefore, to add any props to the `FileInputFieldFF` or `FileInputField`, add those props to the parent Final Form `Field` component.\n\nAlso see `FileInput` and `FileInputField` for notes about props and implementation.\n\n```js\nimport { FileInputFieldFF } from '@dhis2/ui'\n```\n\nPress **Submit** to see the form values logged to the console.\n";
|
47
23
|
const files = [new File([], 'file1.txt'), new File([], 'file2.txt')];
|
48
24
|
var _default = {
|
49
|
-
title: '
|
25
|
+
title: 'File Input Field (Final Form)',
|
50
26
|
component: _FileInputFieldFF.FileInputFieldFF,
|
51
27
|
decorators: [_formDecorator.formDecorator],
|
52
28
|
parameters: {
|
@@ -19,30 +19,33 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
19
19
|
|
20
20
|
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
21
21
|
|
22
|
-
const InputFieldFF =
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
22
|
+
const InputFieldFF = _ref => {
|
23
|
+
let {
|
24
|
+
input,
|
25
|
+
meta,
|
26
|
+
error,
|
27
|
+
showValidStatus,
|
28
|
+
valid,
|
29
|
+
validationText,
|
30
|
+
onBlur,
|
31
|
+
onFocus,
|
32
|
+
loading,
|
33
|
+
showLoadingStatus,
|
34
|
+
...rest
|
35
|
+
} = _ref;
|
36
|
+
return /*#__PURE__*/_react.default.createElement(_input.InputField, _extends({}, rest, {
|
37
|
+
name: input.name,
|
38
|
+
type: input.type,
|
39
|
+
error: (0, _helpers.hasError)(meta, error),
|
40
|
+
valid: (0, _helpers.isValid)(meta, valid, showValidStatus),
|
41
|
+
loading: (0, _helpers.isLoading)(meta, loading, showLoadingStatus),
|
42
|
+
validationText: (0, _helpers.getValidationText)(meta, validationText, error),
|
43
|
+
onFocus: (0, _helpers.createFocusHandler)(input, onFocus),
|
44
|
+
onChange: (0, _helpers.createChangeHandler)(input),
|
45
|
+
onBlur: (0, _helpers.createBlurHandler)(input, onBlur),
|
46
|
+
value: input.value
|
47
|
+
}));
|
48
|
+
};
|
46
49
|
|
47
50
|
exports.InputFieldFF = InputFieldFF;
|
48
51
|
InputFieldFF.propTypes = {
|
@@ -3,7 +3,7 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.
|
6
|
+
exports.default = exports.Statuses = exports.Required = exports.HelpText = exports.Disabled = exports.Default = void 0;
|
7
7
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
9
9
|
|
@@ -19,33 +19,9 @@ var _InputFieldFF = require("./InputFieldFF.js");
|
|
19
19
|
|
20
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
21
21
|
|
22
|
-
const description = `
|
23
|
-
The \`InputFieldFF\` is a wrapper around a \`InputField\` that enables it to work with Final Form, the preferred library for form validation and utilities in DHIS 2 apps.
|
24
|
-
|
25
|
-
#### Final Form
|
26
|
-
|
27
|
-
See how to use Final Form at [Final Form - Getting Started](https://final-form.org/docs/react-final-form/getting-started).
|
28
|
-
|
29
|
-
Inside a Final Form \`<Form>\` component, these 'FF' UI components are intended to be used in the \`component\` prop of the [Final Form \`<Field>\` components](https://final-form.org/docs/react-final-form/api/Field) where they will receive some props from the Field, e.g. \`<Field component={InputFieldFF} />\`. See the code samples below for examples.
|
30
|
-
|
31
|
-
#### Props
|
32
|
-
|
33
|
-
The props shown in the table below are generally provided to the \`InputFieldFF\` wrapper by the Final Form \`Field\`.
|
34
|
-
|
35
|
-
Note that any props beyond the API of the \`Field\` component will be spread to the \`InputFieldFF\`, which passes any extra props to the underlying \`InputField\` using \`{...rest}\`.
|
36
|
-
|
37
|
-
Therefore, to add any props to the \`InputFieldFF\` or \`InputField\`, add those props to the parent Final Form \`Field\` component.
|
38
|
-
|
39
|
-
Also see \`InputField\` for notes about props and implementation.
|
40
|
-
|
41
|
-
\`\`\`js
|
42
|
-
import { InputFieldFF } from '@dhis2/ui'
|
43
|
-
\`\`\`
|
44
|
-
|
45
|
-
Press **Submit** to see the form values logged to the console.
|
46
|
-
`;
|
22
|
+
const description = "\nThe `InputFieldFF` is a wrapper around a `InputField` that enables it to work with Final Form, the preferred library for form validation and utilities in DHIS 2 apps.\n\n#### Final Form\n\nSee how to use Final Form at [Final Form - Getting Started](https://final-form.org/docs/react-final-form/getting-started).\n\nInside a Final Form `<Form>` component, these 'FF' UI components are intended to be used in the `component` prop of the [Final Form `<Field>` components](https://final-form.org/docs/react-final-form/api/Field) where they will receive some props from the Field, e.g. `<Field component={InputFieldFF} />`. See the code samples below for examples.\n\n#### Props\n\nThe props shown in the table below are generally provided to the `InputFieldFF` wrapper by the Final Form `Field`.\n\nNote that any props beyond the API of the `Field` component will be spread to the `InputFieldFF`, which passes any extra props to the underlying `InputField` using `{...rest}`.\n\nTherefore, to add any props to the `InputFieldFF` or `InputField`, add those props to the parent Final Form `Field` component.\n\nAlso see `InputField` for notes about props and implementation.\n\n```js\nimport { InputFieldFF } from '@dhis2/ui'\n```\n\nPress **Submit** to see the form values logged to the console.\n";
|
47
23
|
var _default = {
|
48
|
-
title: '
|
24
|
+
title: 'Input Field (Final Form)',
|
49
25
|
component: _InputFieldFF.InputFieldFF,
|
50
26
|
decorators: [_formDecorator.formDecorator],
|
51
27
|
parameters: {
|
@@ -19,20 +19,21 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
19
19
|
|
20
20
|
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
21
21
|
|
22
|
-
const MultiSelectFieldFF =
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
22
|
+
const MultiSelectFieldFF = _ref => {
|
23
|
+
let {
|
24
|
+
error,
|
25
|
+
input,
|
26
|
+
loading,
|
27
|
+
meta,
|
28
|
+
onBlur,
|
29
|
+
onFocus,
|
30
|
+
options = [],
|
31
|
+
showLoadingStatus,
|
32
|
+
showValidStatus,
|
33
|
+
valid,
|
34
|
+
validationText,
|
35
|
+
...rest
|
36
|
+
} = _ref;
|
36
37
|
return /*#__PURE__*/_react.default.createElement(_select.MultiSelectField, _extends({}, rest, {
|
37
38
|
name: input.name,
|
38
39
|
error: (0, _helpers.hasError)(meta, error),
|
@@ -25,13 +25,16 @@ const defaultOptions = [{
|
|
25
25
|
options: {
|
26
26
|
showPanel: false
|
27
27
|
}
|
28
|
-
}).add('Required', (_, {
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
28
|
+
}).add('Required', (_, _ref) => {
|
29
|
+
let {
|
30
|
+
cypressProps
|
31
|
+
} = _ref;
|
32
|
+
return /*#__PURE__*/_react2.default.createElement(_reactFinalForm.Field, {
|
33
|
+
required: true,
|
34
|
+
name: "multiSelect",
|
35
|
+
label: "Multi select",
|
36
|
+
component: _MultiSelectFieldFF.MultiSelectFieldFF,
|
37
|
+
validate: _index.hasValue,
|
38
|
+
options: cypressProps.options || defaultOptions
|
39
|
+
});
|
40
|
+
});
|
@@ -3,7 +3,7 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.
|
6
|
+
exports.default = exports.InitialValue = exports.Default = void 0;
|
7
7
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
9
9
|
|
@@ -17,33 +17,7 @@ var _MultiSelectFieldFF = require("./MultiSelectFieldFF.js");
|
|
17
17
|
|
18
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
19
19
|
|
20
|
-
const description = `
|
21
|
-
The \`MultiSelectFieldFF\` is a wrapper around a \`MultiSelectField\` that enables it to work with Final Form, the preferred library for form validation and utilities in DHIS 2 apps.
|
22
|
-
|
23
|
-
#### Final Form
|
24
|
-
|
25
|
-
See how to use Final Form at [Final Form - Getting Started](https://final-form.org/docs/react-final-form/getting-started).
|
26
|
-
|
27
|
-
Inside a Final Form \`<Form>\` component, these 'FF' UI components are intended to be used in the \`component\` prop of the [Final Form \`<Field>\` components](https://final-form.org/docs/react-final-form/api/Field) where they will receive some props from the Field, e.g. \`<Field component={MultiSelectFieldFF} />\`. See the code samples below for examples.
|
28
|
-
|
29
|
-
#### Props
|
30
|
-
|
31
|
-
The props shown in the table below are generally provided to the \`MultiSelectFieldFF\` wrapper by the Final Form \`Field\`.
|
32
|
-
|
33
|
-
Note that any props beyond the API of the \`Field\` component will be spread to the \`MultiSelectFieldFF\`, which passes any extra props to the underlying \`MultiSelectField\` using \`{...rest}\`.
|
34
|
-
|
35
|
-
Therefore, to add any props to the \`MultiSelectFieldFF\` or \`MultiSelectField\`, add those props to the parent Final Form \`Field\` component.
|
36
|
-
|
37
|
-
Also see \`MultiSelect\` and \`MultiSelectField\` for notes about props and implementation.
|
38
|
-
|
39
|
-
\`\`\`js
|
40
|
-
import { MultiSelectFieldFF } from '@dhis2/ui'
|
41
|
-
\`\`\`
|
42
|
-
|
43
|
-
Press **Submit** to see the form values logged to the console.
|
44
|
-
|
45
|
-
_**Note:** Dropdowns may not appear correctly on this page. See the affected demos in the 'Canvas' tab for propper dropdown placement._
|
46
|
-
`;
|
20
|
+
const description = "\nThe `MultiSelectFieldFF` is a wrapper around a `MultiSelectField` that enables it to work with Final Form, the preferred library for form validation and utilities in DHIS 2 apps.\n\n#### Final Form\n\nSee how to use Final Form at [Final Form - Getting Started](https://final-form.org/docs/react-final-form/getting-started).\n\nInside a Final Form `<Form>` component, these 'FF' UI components are intended to be used in the `component` prop of the [Final Form `<Field>` components](https://final-form.org/docs/react-final-form/api/Field) where they will receive some props from the Field, e.g. `<Field component={MultiSelectFieldFF} />`. See the code samples below for examples.\n\n#### Props\n\nThe props shown in the table below are generally provided to the `MultiSelectFieldFF` wrapper by the Final Form `Field`.\n\nNote that any props beyond the API of the `Field` component will be spread to the `MultiSelectFieldFF`, which passes any extra props to the underlying `MultiSelectField` using `{...rest}`.\n\nTherefore, to add any props to the `MultiSelectFieldFF` or `MultiSelectField`, add those props to the parent Final Form `Field` component.\n\nAlso see `MultiSelect` and `MultiSelectField` for notes about props and implementation.\n\n```js\nimport { MultiSelectFieldFF } from '@dhis2/ui'\n```\n\nPress **Submit** to see the form values logged to the console.\n\n_**Note:** Dropdowns may not appear correctly on this page. See the affected demos in the 'Canvas' tab for propper dropdown placement._\n";
|
47
21
|
const options = [{
|
48
22
|
value: '1',
|
49
23
|
label: 'one'
|
@@ -77,7 +51,7 @@ const options = [{
|
|
77
51
|
}];
|
78
52
|
const initialValue = ['3', '4', '9', '10'];
|
79
53
|
var _default = {
|
80
|
-
title: '
|
54
|
+
title: 'Multi Select Field (Final Form)',
|
81
55
|
component: _MultiSelectFieldFF.MultiSelectFieldFF,
|
82
56
|
decorators: [_formDecorator.formDecorator],
|
83
57
|
parameters: {
|
@@ -19,27 +19,30 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
19
19
|
|
20
20
|
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
21
21
|
|
22
|
-
const RadioFieldFF =
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
22
|
+
const RadioFieldFF = _ref => {
|
23
|
+
let {
|
24
|
+
error,
|
25
|
+
input,
|
26
|
+
meta,
|
27
|
+
showValidStatus,
|
28
|
+
valid,
|
29
|
+
validationText,
|
30
|
+
onBlur,
|
31
|
+
onFocus,
|
32
|
+
...rest
|
33
|
+
} = _ref;
|
34
|
+
return /*#__PURE__*/_react.default.createElement(_radio.Radio, _extends({}, rest, {
|
35
|
+
name: input.name,
|
36
|
+
checked: input.checked,
|
37
|
+
value: input.value,
|
38
|
+
error: (0, _helpers.hasError)(meta, error),
|
39
|
+
valid: (0, _helpers.isValid)(meta, valid, showValidStatus),
|
40
|
+
validationText: (0, _helpers.getValidationText)(meta, validationText, error),
|
41
|
+
onFocus: (0, _helpers.createFocusHandler)(input, onFocus),
|
42
|
+
onChange: (0, _helpers.createToggleChangeHandler)(input),
|
43
|
+
onBlur: (0, _helpers.createBlurHandler)(input, onBlur)
|
44
|
+
}));
|
45
|
+
};
|
43
46
|
|
44
47
|
exports.RadioFieldFF = RadioFieldFF;
|
45
48
|
RadioFieldFF.propTypes = {
|
@@ -3,7 +3,7 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.
|
6
|
+
exports.default = exports.Statuses = exports.Default = void 0;
|
7
7
|
|
8
8
|
var _field = require("@dhis2-ui/field");
|
9
9
|
|
@@ -19,33 +19,9 @@ var _RadioFieldFF = require("./RadioFieldFF.js");
|
|
19
19
|
|
20
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
21
21
|
|
22
|
-
const description = `
|
23
|
-
The \`RadioFieldFF\` is a wrapper around a \`Radio\` that enables it to work with Final Form, the preferred library for form validation and utilities in DHIS 2 apps.
|
24
|
-
|
25
|
-
#### Final Form
|
26
|
-
|
27
|
-
See how to use Final Form at [Final Form - Getting Started](https://final-form.org/docs/react-final-form/getting-started).
|
28
|
-
|
29
|
-
Inside a Final Form \`<Form>\` component, these 'FF' UI components are intended to be used in the \`component\` prop of the [Final Form \`<Field>\` components](https://final-form.org/docs/react-final-form/api/Field) where they will receive some props from the Field, e.g. \`<Field component={RadioFieldFF} />\`. See the code samples below for examples.
|
30
|
-
|
31
|
-
#### Props
|
32
|
-
|
33
|
-
The props shown in the table below are generally provided to the \`RadioFieldFF\` wrapper by the Final Form \`Field\`.
|
34
|
-
|
35
|
-
Note that any props beyond the API of the \`Field\` component will be spread to the \`RadioFieldFF\`, which passes any extra props to the underlying \`Radio\` using \`{...rest}\`.
|
36
|
-
|
37
|
-
Therefore, to add any props to the \`RadioFieldFF\` or \`Radio\`, add those props to the parent Final Form \`Field\` component.
|
38
|
-
|
39
|
-
Also see \`Radio\` for notes about props and implementation.
|
40
|
-
|
41
|
-
\`\`\`js
|
42
|
-
import { RadioFieldFF } from '@dhis2/ui'
|
43
|
-
\`\`\`
|
44
|
-
|
45
|
-
Press **Submit** to see the form values logged to the console.
|
46
|
-
`;
|
22
|
+
const description = "\nThe `RadioFieldFF` is a wrapper around a `Radio` that enables it to work with Final Form, the preferred library for form validation and utilities in DHIS 2 apps.\n\n#### Final Form\n\nSee how to use Final Form at [Final Form - Getting Started](https://final-form.org/docs/react-final-form/getting-started).\n\nInside a Final Form `<Form>` component, these 'FF' UI components are intended to be used in the `component` prop of the [Final Form `<Field>` components](https://final-form.org/docs/react-final-form/api/Field) where they will receive some props from the Field, e.g. `<Field component={RadioFieldFF} />`. See the code samples below for examples.\n\n#### Props\n\nThe props shown in the table below are generally provided to the `RadioFieldFF` wrapper by the Final Form `Field`.\n\nNote that any props beyond the API of the `Field` component will be spread to the `RadioFieldFF`, which passes any extra props to the underlying `Radio` using `{...rest}`.\n\nTherefore, to add any props to the `RadioFieldFF` or `Radio`, add those props to the parent Final Form `Field` component.\n\nAlso see `Radio` for notes about props and implementation.\n\n```js\nimport { RadioFieldFF } from '@dhis2/ui'\n```\n\nPress **Submit** to see the form values logged to the console.\n";
|
47
23
|
var _default = {
|
48
|
-
title: '
|
24
|
+
title: 'Radio Field (Final Form)',
|
49
25
|
component: _RadioFieldFF.RadioFieldFF,
|
50
26
|
decorators: [_formDecorator.formDecorator],
|
51
27
|
parameters: {
|