@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,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 SingleSelectFieldFF =
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
22
|
+
const SingleSelectFieldFF = _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.SingleSelectField, _extends({}, rest, {
|
37
38
|
name: input.name,
|
38
39
|
error: (0, _helpers.hasError)(meta, error),
|
@@ -22,13 +22,16 @@ const defaultOptions = [{
|
|
22
22
|
options: {
|
23
23
|
showPanel: false
|
24
24
|
}
|
25
|
-
}).add('Required', (_, {
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
25
|
+
}).add('Required', (_, _ref) => {
|
26
|
+
let {
|
27
|
+
cypressProps
|
28
|
+
} = _ref;
|
29
|
+
return /*#__PURE__*/_react2.default.createElement(_reactFinalForm.Field, {
|
30
|
+
required: true,
|
31
|
+
name: "singleSelect",
|
32
|
+
label: "Single select",
|
33
|
+
component: _SingleSelectFieldFF.SingleSelectFieldFF,
|
34
|
+
validate: _index.hasValue,
|
35
|
+
options: cypressProps.options || defaultOptions
|
36
|
+
});
|
37
|
+
});
|
@@ -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 _SingleSelectFieldFF = require("./SingleSelectFieldFF.js");
|
|
17
17
|
|
18
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
19
19
|
|
20
|
-
const description = `
|
21
|
-
The \`SingleSelectFieldFF\` is a wrapper around a \`SingleSelectField\` 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={SingleSelectFieldFF} />\`. See the code samples below for examples.
|
28
|
-
|
29
|
-
#### Props
|
30
|
-
|
31
|
-
The props shown in the table below are generally provided to the \`SingleSelectFieldFF\` wrapper by the Final Form \`Field\`.
|
32
|
-
|
33
|
-
Note that any props beyond the API of the \`Field\` component will be spread to the \`SingleSelectFieldFF\`, which passes any extra props to the underlying \`SingleSelectField\` using \`{...rest}\`.
|
34
|
-
|
35
|
-
Therefore, to add any props to the \`SingleSelectFieldFF\` or \`SingleSelectField\`, add those props to the parent Final Form \`Field\` component.
|
36
|
-
|
37
|
-
Also see \`SingleSelect\` and \`SingleSelectField\` for notes about props and implementation.
|
38
|
-
|
39
|
-
\`\`\`js
|
40
|
-
import { SingleSelectFieldFF } 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 `SingleSelectFieldFF` is a wrapper around a `SingleSelectField` 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={SingleSelectFieldFF} />`. See the code samples below for examples.\n\n#### Props\n\nThe props shown in the table below are generally provided to the `SingleSelectFieldFF` wrapper by the Final Form `Field`.\n\nNote that any props beyond the API of the `Field` component will be spread to the `SingleSelectFieldFF`, which passes any extra props to the underlying `SingleSelectField` using `{...rest}`.\n\nTherefore, to add any props to the `SingleSelectFieldFF` or `SingleSelectField`, add those props to the parent Final Form `Field` component.\n\nAlso see `SingleSelect` and `SingleSelectField` for notes about props and implementation.\n\n```js\nimport { SingleSelectFieldFF } 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'
|
@@ -76,7 +50,7 @@ const options = [{
|
|
76
50
|
label: 'ten'
|
77
51
|
}];
|
78
52
|
var _default = {
|
79
|
-
title: '
|
53
|
+
title: 'Single Select Field (Final Form)',
|
80
54
|
component: _SingleSelectFieldFF.SingleSelectFieldFF,
|
81
55
|
decorators: [_formDecorator.formDecorator],
|
82
56
|
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 SwitchFieldFF =
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
22
|
+
const SwitchFieldFF = _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(_switch.SwitchField, _extends({}, rest, {
|
35
|
+
checked: input.checked,
|
36
|
+
name: input.name,
|
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.SwitchFieldFF = SwitchFieldFF;
|
45
48
|
SwitchFieldFF.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.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 _SwitchFieldFF = require("./SwitchFieldFF.js");
|
|
19
19
|
|
20
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
21
21
|
|
22
|
-
const description = `
|
23
|
-
The \`SwitchFieldFF\` is a wrapper around a \`SwitchField\` 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={SwitchFieldFF} />\`. See the code samples below for examples.
|
30
|
-
|
31
|
-
#### Props
|
32
|
-
|
33
|
-
The props shown in the table below are generally provided to the \`SwitchFieldFF\` wrapper by the Final Form \`Field\`.
|
34
|
-
|
35
|
-
Note that any props beyond the API of the \`Field\` component will be spread to the \`SwitchFieldFF\`, which passes any extra props to the underlying \`SwitchField\` using \`{...rest}\`.
|
36
|
-
|
37
|
-
Therefore, to add any props to the \`SwitchFieldFF\` or \`SwitchField\`, add those props to the parent Final Form \`Field\` component.
|
38
|
-
|
39
|
-
Also see \`Switch\` and \`SwitchField\` for notes about props and implementation.
|
40
|
-
|
41
|
-
\`\`\`js
|
42
|
-
import { SwitchFieldFF } from '@dhis2/ui'
|
43
|
-
\`\`\`
|
44
|
-
|
45
|
-
Press **Submit** to see the form values logged to the console.
|
46
|
-
`;
|
22
|
+
const description = "\nThe `SwitchFieldFF` is a wrapper around a `SwitchField` 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={SwitchFieldFF} />`. See the code samples below for examples.\n\n#### Props\n\nThe props shown in the table below are generally provided to the `SwitchFieldFF` wrapper by the Final Form `Field`.\n\nNote that any props beyond the API of the `Field` component will be spread to the `SwitchFieldFF`, which passes any extra props to the underlying `SwitchField` using `{...rest}`.\n\nTherefore, to add any props to the `SwitchFieldFF` or `SwitchField`, add those props to the parent Final Form `Field` component.\n\nAlso see `Switch` and `SwitchField` for notes about props and implementation.\n\n```js\nimport { SwitchFieldFF } 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: 'Switch Field (Final Form)',
|
49
25
|
component: _SwitchFieldFF.SwitchFieldFF,
|
50
26
|
decorators: [_formDecorator.formDecorator],
|
51
27
|
parameters: {
|
@@ -19,29 +19,32 @@ 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 TextAreaFieldFF =
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
22
|
+
const TextAreaFieldFF = _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(_textArea.TextAreaField, _extends({}, rest, {
|
37
|
+
name: input.name,
|
38
|
+
error: (0, _helpers.hasError)(meta, error),
|
39
|
+
valid: (0, _helpers.isValid)(meta, valid, showValidStatus),
|
40
|
+
loading: (0, _helpers.isLoading)(meta, loading, showLoadingStatus),
|
41
|
+
validationText: (0, _helpers.getValidationText)(meta, validationText, error),
|
42
|
+
onFocus: (0, _helpers.createFocusHandler)(input, onFocus),
|
43
|
+
onChange: (0, _helpers.createChangeHandler)(input),
|
44
|
+
onBlur: (0, _helpers.createBlurHandler)(input, onBlur),
|
45
|
+
value: input.value
|
46
|
+
}));
|
47
|
+
};
|
45
48
|
|
46
49
|
exports.TextAreaFieldFF = TextAreaFieldFF;
|
47
50
|
TextAreaFieldFF.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 = exports.Autogrow = void 0;
|
7
7
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
9
9
|
|
@@ -19,33 +19,9 @@ var _TextAreaFieldFF = require("./TextAreaFieldFF.js");
|
|
19
19
|
|
20
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
21
21
|
|
22
|
-
const description = `
|
23
|
-
The \`TextAreaFieldFF\` is a wrapper around a \`TextAreaField\` 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={TextAreaFieldFF} />\`. See the code samples below for examples.
|
30
|
-
|
31
|
-
#### Props
|
32
|
-
|
33
|
-
The props shown in the table below are generally provided to the \`TextAreaFieldFF\` wrapper by the Final Form \`Field\`.
|
34
|
-
|
35
|
-
Note that any props beyond the API of the \`Field\` component will be spread to the \`TextAreaFieldFF\`, which passes any extra props to the underlying \`TextAreaField\` using \`{...rest}\`.
|
36
|
-
|
37
|
-
Therefore, to add any props to the \`TextAreaFieldFF\` or \`TextAreaField\`, add those props to the parent Final Form \`Field\` component.
|
38
|
-
|
39
|
-
Also see \`TextArea\` and \`TextAreaField\` for notes about props and implementation.
|
40
|
-
|
41
|
-
\`\`\`js
|
42
|
-
import { TextAreaFieldFF } from '@dhis2/ui'
|
43
|
-
\`\`\`
|
44
|
-
|
45
|
-
Press **Submit** to see the form values logged to the console.
|
46
|
-
`;
|
22
|
+
const description = "\nThe `TextAreaFieldFF` is a wrapper around a `TextAreaField` 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={TextAreaFieldFF} />`. See the code samples below for examples.\n\n#### Props\n\nThe props shown in the table below are generally provided to the `TextAreaFieldFF` wrapper by the Final Form `Field`.\n\nNote that any props beyond the API of the `Field` component will be spread to the `TextAreaFieldFF`, which passes any extra props to the underlying `TextAreaField` using `{...rest}`.\n\nTherefore, to add any props to the `TextAreaFieldFF` or `TextAreaField`, add those props to the parent Final Form `Field` component.\n\nAlso see `TextArea` and `TextAreaField` for notes about props and implementation.\n\n```js\nimport { TextAreaFieldFF } 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: 'Text Area Field (Final Form)',
|
49
25
|
component: _TextAreaFieldFF.TextAreaFieldFF,
|
50
26
|
decorators: [_formDecorator.formDecorator],
|
51
27
|
parameters: {
|
@@ -25,8 +25,8 @@ const formProps = {
|
|
25
25
|
};
|
26
26
|
|
27
27
|
class FormWithSpyAndSubmit extends _react.default.Component {
|
28
|
-
constructor(
|
29
|
-
super(...
|
28
|
+
constructor() {
|
29
|
+
super(...arguments);
|
30
30
|
|
31
31
|
_defineProperty(this, "state", {
|
32
32
|
cypressProps: {}
|
@@ -68,9 +68,10 @@ class FormWithSpyAndSubmit extends _react.default.Component {
|
|
68
68
|
}), /*#__PURE__*/_react.default.createElement(_button.Button, {
|
69
69
|
primary: true,
|
70
70
|
type: "submit"
|
71
|
-
}, "Submit"), /*#__PURE__*/_react.default.createElement(_reactFinalForm.FormSpy, null,
|
72
|
-
|
73
|
-
|
71
|
+
}, "Submit"), /*#__PURE__*/_react.default.createElement(_reactFinalForm.FormSpy, null, _ref => {
|
72
|
+
let {
|
73
|
+
values
|
74
|
+
} = _ref;
|
74
75
|
window.formValues = values;
|
75
76
|
return /*#__PURE__*/_react.default.createElement("span", {
|
76
77
|
className: "form-spy-internal"
|
package/build/cjs/index.js
CHANGED
@@ -22,12 +22,19 @@ Object.defineProperty(exports, "CheckboxFieldFF", {
|
|
22
22
|
return _CheckboxFieldFF.CheckboxFieldFF;
|
23
23
|
}
|
24
24
|
});
|
25
|
+
Object.defineProperty(exports, "FieldGroupFF", {
|
26
|
+
enumerable: true,
|
27
|
+
get: function () {
|
28
|
+
return _FieldGroupFF.FieldGroupFF;
|
29
|
+
}
|
30
|
+
});
|
25
31
|
Object.defineProperty(exports, "FileInputFieldFF", {
|
26
32
|
enumerable: true,
|
27
33
|
get: function () {
|
28
34
|
return _FileInputFieldFF.FileInputFieldFF;
|
29
35
|
}
|
30
36
|
});
|
37
|
+
exports.FinalForm = void 0;
|
31
38
|
Object.defineProperty(exports, "InputFieldFF", {
|
32
39
|
enumerable: true,
|
33
40
|
get: function () {
|
@@ -40,16 +47,17 @@ Object.defineProperty(exports, "MultiSelectFieldFF", {
|
|
40
47
|
return _MultiSelectFieldFF.MultiSelectFieldFF;
|
41
48
|
}
|
42
49
|
});
|
43
|
-
Object.defineProperty(exports, "
|
50
|
+
Object.defineProperty(exports, "RadioFieldFF", {
|
44
51
|
enumerable: true,
|
45
52
|
get: function () {
|
46
|
-
return
|
53
|
+
return _RadioFieldFF.RadioFieldFF;
|
47
54
|
}
|
48
55
|
});
|
49
|
-
|
56
|
+
exports.ReactFinalForm = void 0;
|
57
|
+
Object.defineProperty(exports, "SingleSelectFieldFF", {
|
50
58
|
enumerable: true,
|
51
59
|
get: function () {
|
52
|
-
return
|
60
|
+
return _SingleSelectFieldFF.SingleSelectFieldFF;
|
53
61
|
}
|
54
62
|
});
|
55
63
|
Object.defineProperty(exports, "SwitchFieldFF", {
|
@@ -64,13 +72,6 @@ Object.defineProperty(exports, "TextAreaFieldFF", {
|
|
64
72
|
return _TextAreaFieldFF.TextAreaFieldFF;
|
65
73
|
}
|
66
74
|
});
|
67
|
-
Object.defineProperty(exports, "FieldGroupFF", {
|
68
|
-
enumerable: true,
|
69
|
-
get: function () {
|
70
|
-
return _FieldGroupFF.FieldGroupFF;
|
71
|
-
}
|
72
|
-
});
|
73
|
-
exports.ReactFinalForm = exports.FinalForm = void 0;
|
74
75
|
|
75
76
|
var FinalForm = _interopRequireWildcard(require("final-form"));
|
76
77
|
|
@@ -2,7 +2,6 @@
|
|
2
2
|
"Upload file": "Upload file",
|
3
3
|
"Upload files": "Upload files",
|
4
4
|
"Remove": "Remove",
|
5
|
-
"No file(s) selected yet": "No file(s) selected yet",
|
6
5
|
"Please provide an alpha-numeric value": "Please provide an alpha-numeric value",
|
7
6
|
"Please provide a boolean value": "Please provide a boolean value",
|
8
7
|
"Please enter between {{lowerBound}} and {{upperBound}} characters": "Please enter between {{lowerBound}} and {{upperBound}} characters",
|
@@ -6,22 +6,25 @@ Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
exports.createChangeHandler = void 0;
|
7
7
|
const PRIMITIVE_TYPES = new Set(['string', 'number', 'boolean']);
|
8
8
|
|
9
|
-
const createChangeHandler =
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
9
|
+
const createChangeHandler = _ref => {
|
10
|
+
let {
|
11
|
+
onChange
|
12
|
+
} = _ref;
|
13
|
+
return payload => {
|
14
|
+
if (payload && 'value' in payload) {
|
15
|
+
// ui event signature
|
16
|
+
onChange(payload.value);
|
17
|
+
} else if (payload && payload.target && 'value' in payload.target) {
|
18
|
+
// synthetic event
|
19
|
+
onChange(payload.target.value);
|
20
|
+
} else if (PRIMITIVE_TYPES.has(typeof payload)) {
|
21
|
+
// directly usable value
|
22
|
+
onChange(payload);
|
23
|
+
} else {
|
24
|
+
// ¯\_(ツ)_/¯
|
25
|
+
throw new Error('Could not process event payload');
|
26
|
+
}
|
27
|
+
};
|
25
28
|
};
|
26
29
|
|
27
30
|
exports.createChangeHandler = createChangeHandler;
|
@@ -5,12 +5,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.createSelectChangeHandler = void 0;
|
7
7
|
|
8
|
-
const createSelectChangeHandler =
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
8
|
+
const createSelectChangeHandler = _ref => {
|
9
|
+
let {
|
10
|
+
onChange
|
11
|
+
} = _ref;
|
12
|
+
return _ref2 => {
|
13
|
+
let {
|
14
|
+
selected
|
15
|
+
} = _ref2;
|
16
|
+
onChange(selected);
|
17
|
+
};
|
14
18
|
};
|
15
19
|
|
16
20
|
exports.createSelectChangeHandler = createSelectChangeHandler;
|
@@ -3,7 +3,7 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.
|
6
|
+
exports.toggleGroupOptionsProp = exports.metaPropType = exports.metaArgType = exports.inputPropType = exports.inputArgType = void 0;
|
7
7
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
9
9
|
|
@@ -5,9 +5,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.arrayWithIdObjects = void 0;
|
7
7
|
|
8
|
-
const format = value => !value ? [] : value.map(
|
9
|
-
|
10
|
-
|
8
|
+
const format = value => !value ? [] : value.map(_ref => {
|
9
|
+
let {
|
10
|
+
id
|
11
|
+
} = _ref;
|
12
|
+
return id;
|
13
|
+
});
|
11
14
|
|
12
15
|
const parse = value => !value || Array.isArray(value) && value.length === 0 ? undefined : value.map(id => ({
|
13
16
|
id
|
@@ -24,7 +24,7 @@ describe('validator: createPattern', () => {
|
|
24
24
|
});
|
25
25
|
it('should return an error string when input does not match the pattern', () => {
|
26
26
|
const escapedRegexString = '/^test$/';
|
27
|
-
const invalidMsg =
|
27
|
+
const invalidMsg = "Please make sure the value of this input matches the pattern ".concat(escapedRegexString, ".");
|
28
28
|
expect(equalToTestPattern('bad input')).toEqual(invalidMsg);
|
29
29
|
});
|
30
30
|
it('should return an custon error string when one was provided and input does not match the pattern', () => {
|
@@ -5,8 +5,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.composeValidators = void 0;
|
7
7
|
|
8
|
-
const composeValidators = (
|
9
|
-
|
8
|
+
const composeValidators = function () {
|
9
|
+
for (var _len = arguments.length, validators = new Array(_len), _key = 0; _key < _len; _key++) {
|
10
|
+
validators[_key] = arguments[_key];
|
11
|
+
}
|
12
|
+
|
13
|
+
return function () {
|
14
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
15
|
+
args[_key2] = arguments[_key2];
|
16
|
+
}
|
17
|
+
|
10
18
|
return validators.reduce((error, validator) => error || validator(...args), undefined);
|
11
19
|
};
|
12
20
|
};
|
@@ -3,7 +3,7 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.
|
6
|
+
exports.toNumber = exports.requiredArgumentErrorMessage = exports.requireArgument = exports.isString = exports.isNumeric = exports.isNumber = exports.isInteger = exports.isInRange = exports.isEmpty = void 0;
|
7
7
|
|
8
8
|
const isEmpty = value => typeof value === 'undefined' || value === null || value === '';
|
9
9
|
|
@@ -3,7 +3,7 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.
|
6
|
+
exports.testValidatorValues = exports.allowsEmptyValues = void 0;
|
7
7
|
|
8
8
|
const testValidatorValues = (validator, returnValue, values) => {
|
9
9
|
const returnValueStr = returnValue === undefined ? 'undefined' : 'an error string';
|
@@ -11,7 +11,7 @@ const testValidatorValues = (validator, returnValue, values) => {
|
|
11
11
|
for (const value of values) {
|
12
12
|
const type = typeof value;
|
13
13
|
const valueStr = type === 'object' ? JSON.stringify(value) : value;
|
14
|
-
it(
|
14
|
+
it("should return ".concat(returnValueStr, " for value `").concat(valueStr, "` of type ").concat(type), () => {
|
15
15
|
expect(validator(value)).toBe(returnValue);
|
16
16
|
});
|
17
17
|
}
|