@atlaskit/link-create 0.5.6 → 0.5.7
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/CHANGELOG.md +6 -0
- package/dist/cjs/common/utils/form/index.js +15 -0
- package/dist/cjs/ui/create-form/async-select/main.js +8 -1
- package/dist/cjs/ui/create-form/textfield/main.js +8 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/common/utils/form/index.js +8 -0
- package/dist/es2019/ui/create-form/async-select/main.js +10 -1
- package/dist/es2019/ui/create-form/textfield/main.js +8 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/common/utils/form/index.js +8 -0
- package/dist/esm/ui/create-form/async-select/main.js +8 -1
- package/dist/esm/ui/create-form/textfield/main.js +8 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/common/utils/form/index.d.ts +7 -0
- package/dist/types-ts4.5/common/utils/form/index.d.ts +7 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.validateSubmitErrors = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* This function checks if there have been changes since last submit
|
|
9
|
+
* to let a Field know if it should hide the error message until
|
|
10
|
+
* the next submit, or if it returns to the previous error state
|
|
11
|
+
*/
|
|
12
|
+
var validateSubmitErrors = function validateSubmitErrors(meta) {
|
|
13
|
+
return !!(meta.touched && (meta.error || meta.submitError && !meta.dirtySinceLastSubmit));
|
|
14
|
+
};
|
|
15
|
+
exports.validateSubmitErrors = validateSubmitErrors;
|
|
@@ -11,6 +11,7 @@ var _react = require("react");
|
|
|
11
11
|
var _react2 = require("@emotion/react");
|
|
12
12
|
var _form = require("@atlaskit/form");
|
|
13
13
|
var _select = require("@atlaskit/select");
|
|
14
|
+
var _form2 = require("../../../common/utils/form");
|
|
14
15
|
var _formContext = require("../../../controllers/form-context");
|
|
15
16
|
var _excluded = ["label", "name", "validationHelpText", "isRequired", "testId", "validators", "defaultValue"];
|
|
16
17
|
/** @jsx jsx */
|
|
@@ -45,7 +46,13 @@ function AsyncSelect(_ref) {
|
|
|
45
46
|
defaultValue: defaultValue
|
|
46
47
|
}, function (_ref2) {
|
|
47
48
|
var fieldProps = _ref2.fieldProps,
|
|
49
|
+
meta = _ref2.meta,
|
|
48
50
|
error = _ref2.error;
|
|
49
|
-
|
|
51
|
+
var isInvalid = (0, _form2.validateSubmitErrors)(meta);
|
|
52
|
+
return (0, _react2.jsx)(_react.Fragment, null, (0, _react2.jsx)(_select.AsyncSelect, (0, _extends2.default)({}, fieldProps, rest, {
|
|
53
|
+
isInvalid: isInvalid
|
|
54
|
+
})), !error && validationHelpText && (0, _react2.jsx)(_form.HelperMessage, null, validationHelpText), isInvalid && (0, _react2.jsx)(_form.ErrorMessage, {
|
|
55
|
+
testId: "".concat(testId, "-error-message")
|
|
56
|
+
}, error));
|
|
50
57
|
}));
|
|
51
58
|
}
|
|
@@ -11,6 +11,7 @@ var _react = require("react");
|
|
|
11
11
|
var _react2 = require("@emotion/react");
|
|
12
12
|
var _form = require("@atlaskit/form");
|
|
13
13
|
var _textfield = _interopRequireDefault(require("@atlaskit/textfield"));
|
|
14
|
+
var _form2 = require("../../../common/utils/form");
|
|
14
15
|
var _formContext = require("../../../controllers/form-context");
|
|
15
16
|
var _excluded = ["label", "name", "validationHelpText", "validators", "defaultValue"];
|
|
16
17
|
/** @jsx jsx */
|
|
@@ -49,8 +50,14 @@ function TextField(_ref) {
|
|
|
49
50
|
defaultValue: defaultValue !== null && defaultValue !== void 0 ? defaultValue : ''
|
|
50
51
|
}, function (_ref2) {
|
|
51
52
|
var fieldProps = _ref2.fieldProps,
|
|
53
|
+
meta = _ref2.meta,
|
|
52
54
|
error = _ref2.error;
|
|
53
|
-
|
|
55
|
+
var isInvalid = (0, _form2.validateSubmitErrors)(meta);
|
|
56
|
+
return (0, _react2.jsx)(_react.Fragment, null, (0, _react2.jsx)(_textfield.default, (0, _extends2.default)({}, fieldProps, restProps, {
|
|
57
|
+
isInvalid: isInvalid
|
|
58
|
+
})), !error && validationHelpText && (0, _react2.jsx)(_form.HelperMessage, null, validationHelpText), error && isInvalid && (0, _react2.jsx)(_form.ErrorMessage, {
|
|
59
|
+
testId: "".concat(restProps.testId, "-error-message")
|
|
60
|
+
}, error));
|
|
54
61
|
})
|
|
55
62
|
);
|
|
56
63
|
}
|
package/dist/cjs/version.json
CHANGED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This function checks if there have been changes since last submit
|
|
3
|
+
* to let a Field know if it should hide the error message until
|
|
4
|
+
* the next submit, or if it returns to the previous error state
|
|
5
|
+
*/
|
|
6
|
+
export const validateSubmitErrors = meta => {
|
|
7
|
+
return !!(meta.touched && (meta.error || meta.submitError && !meta.dirtySinceLastSubmit));
|
|
8
|
+
};
|
|
@@ -4,6 +4,7 @@ import { Fragment, useEffect } from 'react';
|
|
|
4
4
|
import { jsx } from '@emotion/react';
|
|
5
5
|
import { ErrorMessage, Field, HelperMessage } from '@atlaskit/form';
|
|
6
6
|
import { AsyncSelect as AkAsyncSelect } from '@atlaskit/select';
|
|
7
|
+
import { validateSubmitErrors } from '../../../common/utils/form';
|
|
7
8
|
import { useFormContext } from '../../../controllers/form-context';
|
|
8
9
|
/**
|
|
9
10
|
* An async select utilising the Atlaskit AsyncSelect and Field objects from `@atlaskit/form`.
|
|
@@ -38,6 +39,14 @@ export function AsyncSelect({
|
|
|
38
39
|
defaultValue: defaultValue
|
|
39
40
|
}, ({
|
|
40
41
|
fieldProps,
|
|
42
|
+
meta,
|
|
41
43
|
error
|
|
42
|
-
}) =>
|
|
44
|
+
}) => {
|
|
45
|
+
const isInvalid = validateSubmitErrors(meta);
|
|
46
|
+
return jsx(Fragment, null, jsx(AkAsyncSelect, _extends({}, fieldProps, rest, {
|
|
47
|
+
isInvalid: isInvalid
|
|
48
|
+
})), !error && validationHelpText && jsx(HelperMessage, null, validationHelpText), isInvalid && jsx(ErrorMessage, {
|
|
49
|
+
testId: `${testId}-error-message`
|
|
50
|
+
}, error));
|
|
51
|
+
}));
|
|
43
52
|
}
|
|
@@ -4,6 +4,7 @@ import { Fragment, useEffect } from 'react';
|
|
|
4
4
|
import { jsx } from '@emotion/react';
|
|
5
5
|
import { ErrorMessage, Field, HelperMessage } from '@atlaskit/form';
|
|
6
6
|
import AkTextfield from '@atlaskit/textfield';
|
|
7
|
+
import { validateSubmitErrors } from '../../../common/utils/form';
|
|
7
8
|
import { useFormContext } from '../../../controllers/form-context';
|
|
8
9
|
/**
|
|
9
10
|
* A text field utilising the Atlaskit Textfield and Field objects from `@atlaskit/form`.
|
|
@@ -42,9 +43,15 @@ export function TextField({
|
|
|
42
43
|
defaultValue: defaultValue !== null && defaultValue !== void 0 ? defaultValue : ''
|
|
43
44
|
}, ({
|
|
44
45
|
fieldProps,
|
|
46
|
+
meta,
|
|
45
47
|
error
|
|
46
48
|
}) => {
|
|
47
|
-
|
|
49
|
+
const isInvalid = validateSubmitErrors(meta);
|
|
50
|
+
return jsx(Fragment, null, jsx(AkTextfield, _extends({}, fieldProps, restProps, {
|
|
51
|
+
isInvalid: isInvalid
|
|
52
|
+
})), !error && validationHelpText && jsx(HelperMessage, null, validationHelpText), error && isInvalid && jsx(ErrorMessage, {
|
|
53
|
+
testId: `${restProps.testId}-error-message`
|
|
54
|
+
}, error));
|
|
48
55
|
})
|
|
49
56
|
);
|
|
50
57
|
}
|
package/dist/es2019/version.json
CHANGED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This function checks if there have been changes since last submit
|
|
3
|
+
* to let a Field know if it should hide the error message until
|
|
4
|
+
* the next submit, or if it returns to the previous error state
|
|
5
|
+
*/
|
|
6
|
+
export var validateSubmitErrors = function validateSubmitErrors(meta) {
|
|
7
|
+
return !!(meta.touched && (meta.error || meta.submitError && !meta.dirtySinceLastSubmit));
|
|
8
|
+
};
|
|
@@ -6,6 +6,7 @@ import { Fragment, useEffect } from 'react';
|
|
|
6
6
|
import { jsx } from '@emotion/react';
|
|
7
7
|
import { ErrorMessage, Field, HelperMessage } from '@atlaskit/form';
|
|
8
8
|
import { AsyncSelect as AkAsyncSelect } from '@atlaskit/select';
|
|
9
|
+
import { validateSubmitErrors } from '../../../common/utils/form';
|
|
9
10
|
import { useFormContext } from '../../../controllers/form-context';
|
|
10
11
|
/**
|
|
11
12
|
* An async select utilising the Atlaskit AsyncSelect and Field objects from `@atlaskit/form`.
|
|
@@ -38,7 +39,13 @@ export function AsyncSelect(_ref) {
|
|
|
38
39
|
defaultValue: defaultValue
|
|
39
40
|
}, function (_ref2) {
|
|
40
41
|
var fieldProps = _ref2.fieldProps,
|
|
42
|
+
meta = _ref2.meta,
|
|
41
43
|
error = _ref2.error;
|
|
42
|
-
|
|
44
|
+
var isInvalid = validateSubmitErrors(meta);
|
|
45
|
+
return jsx(Fragment, null, jsx(AkAsyncSelect, _extends({}, fieldProps, rest, {
|
|
46
|
+
isInvalid: isInvalid
|
|
47
|
+
})), !error && validationHelpText && jsx(HelperMessage, null, validationHelpText), isInvalid && jsx(ErrorMessage, {
|
|
48
|
+
testId: "".concat(testId, "-error-message")
|
|
49
|
+
}, error));
|
|
43
50
|
}));
|
|
44
51
|
}
|
|
@@ -6,6 +6,7 @@ import { Fragment, useEffect } from 'react';
|
|
|
6
6
|
import { jsx } from '@emotion/react';
|
|
7
7
|
import { ErrorMessage, Field, HelperMessage } from '@atlaskit/form';
|
|
8
8
|
import AkTextfield from '@atlaskit/textfield';
|
|
9
|
+
import { validateSubmitErrors } from '../../../common/utils/form';
|
|
9
10
|
import { useFormContext } from '../../../controllers/form-context';
|
|
10
11
|
/**
|
|
11
12
|
* A text field utilising the Atlaskit Textfield and Field objects from `@atlaskit/form`.
|
|
@@ -42,8 +43,14 @@ export function TextField(_ref) {
|
|
|
42
43
|
defaultValue: defaultValue !== null && defaultValue !== void 0 ? defaultValue : ''
|
|
43
44
|
}, function (_ref2) {
|
|
44
45
|
var fieldProps = _ref2.fieldProps,
|
|
46
|
+
meta = _ref2.meta,
|
|
45
47
|
error = _ref2.error;
|
|
46
|
-
|
|
48
|
+
var isInvalid = validateSubmitErrors(meta);
|
|
49
|
+
return jsx(Fragment, null, jsx(AkTextfield, _extends({}, fieldProps, restProps, {
|
|
50
|
+
isInvalid: isInvalid
|
|
51
|
+
})), !error && validationHelpText && jsx(HelperMessage, null, validationHelpText), error && isInvalid && jsx(ErrorMessage, {
|
|
52
|
+
testId: "".concat(restProps.testId, "-error-message")
|
|
53
|
+
}, error));
|
|
47
54
|
})
|
|
48
55
|
);
|
|
49
56
|
}
|
package/dist/esm/version.json
CHANGED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Meta } from '@atlaskit/form/Field';
|
|
2
|
+
/**
|
|
3
|
+
* This function checks if there have been changes since last submit
|
|
4
|
+
* to let a Field know if it should hide the error message until
|
|
5
|
+
* the next submit, or if it returns to the previous error state
|
|
6
|
+
*/
|
|
7
|
+
export declare const validateSubmitErrors: (meta: Meta) => boolean;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Meta } from '@atlaskit/form/Field';
|
|
2
|
+
/**
|
|
3
|
+
* This function checks if there have been changes since last submit
|
|
4
|
+
* to let a Field know if it should hide the error message until
|
|
5
|
+
* the next submit, or if it returns to the previous error state
|
|
6
|
+
*/
|
|
7
|
+
export declare const validateSubmitErrors: (meta: Meta) => boolean;
|