@ukhomeoffice/cop-react-form-renderer 5.89.0 → 5.90.0
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/dist/components/FormComponent/Collection.scss +1 -1
- package/dist/components/FormComponent/Container.js +2 -0
- package/dist/components/FormComponent/Container.scss +15 -0
- package/dist/utils/Validate/additional/conditionallyPermittedChange.js +25 -0
- package/dist/utils/Validate/additional/conditionallyPermittedChange.test.js +33 -0
- package/dist/utils/Validate/additional/index.js +2 -0
- package/package.json +1 -1
|
@@ -12,8 +12,10 @@ var _models = require("../../models");
|
|
|
12
12
|
var _utils = _interopRequireDefault(require("../../utils"));
|
|
13
13
|
var _FormComponent = _interopRequireDefault(require("./FormComponent"));
|
|
14
14
|
var _getSourceData = _interopRequireDefault(require("../../utils/Data/getSourceData"));
|
|
15
|
+
require("./Container.scss");
|
|
15
16
|
var _excluded = ["container", "value", "formData", "onChange", "wrap", "onTopLevelChange"]; // Global imports
|
|
16
17
|
// Local imports
|
|
18
|
+
// Styles
|
|
17
19
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
20
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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); }
|
|
19
21
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
.horizonal {
|
|
2
|
+
flex-direction: row;
|
|
3
|
+
display: flex;
|
|
4
|
+
justify-content: space-between;
|
|
5
|
+
gap: 2rem;
|
|
6
|
+
.horizonal{
|
|
7
|
+
justify-content: space-around;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
@media screen and (max-width: 640px) {
|
|
11
|
+
.horizonal {
|
|
12
|
+
flex-direction: column;
|
|
13
|
+
gap:0;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* Additional validator to not permit a value change if a specified item exists in formData.
|
|
9
|
+
* @param {object} data the changed value
|
|
10
|
+
* @param {object} config the config for the validation must contain
|
|
11
|
+
* a property 'base' holding the value for checking
|
|
12
|
+
* a property 'check' holding the formData item name to check if exists
|
|
13
|
+
* @param {object} formData the form data
|
|
14
|
+
* @returns false if:
|
|
15
|
+
* the 'base' value is not the same as the changed value AND
|
|
16
|
+
* the 'check' value exists in formData as an item
|
|
17
|
+
* otherwise returns true
|
|
18
|
+
*/
|
|
19
|
+
var conditionallyPermittedChange = function conditionallyPermittedChange(data, config, _, formData) {
|
|
20
|
+
if (data !== config.base && formData[config.check]) {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
return true;
|
|
24
|
+
};
|
|
25
|
+
var _default = exports.default = conditionallyPermittedChange;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _conditionallyPermittedChange = _interopRequireDefault(require("./conditionallyPermittedChange"));
|
|
4
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
5
|
+
describe('utils', function () {
|
|
6
|
+
describe('Validate', function () {
|
|
7
|
+
describe('additional', function () {
|
|
8
|
+
describe('conditionallyPermittedChange', function () {
|
|
9
|
+
var CONFIG = {
|
|
10
|
+
base: 'Value1',
|
|
11
|
+
check: 'Item1'
|
|
12
|
+
};
|
|
13
|
+
test('should pass if the base value has same value as data parameter', function () {
|
|
14
|
+
var DATA = 'Value1';
|
|
15
|
+
var FORMDATA = {};
|
|
16
|
+
expect((0, _conditionallyPermittedChange.default)(DATA, CONFIG, null, FORMDATA)).toEqual(true);
|
|
17
|
+
});
|
|
18
|
+
test('should fail if the base value is different to data parameter and check item exists in form data', function () {
|
|
19
|
+
var DATA = 'Value2';
|
|
20
|
+
var FORMDATA = {
|
|
21
|
+
Item1: "any"
|
|
22
|
+
};
|
|
23
|
+
expect((0, _conditionallyPermittedChange.default)(DATA, CONFIG, null, FORMDATA)).toEqual(false);
|
|
24
|
+
});
|
|
25
|
+
test('should pass if the base value is different to data parameter and check item not exists in form data', function () {
|
|
26
|
+
var DATA = 'Value2';
|
|
27
|
+
var FORMDATA = {};
|
|
28
|
+
expect((0, _conditionallyPermittedChange.default)(DATA, CONFIG, null, FORMDATA)).toEqual(true);
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
});
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
+
var _conditionallyPermittedChange = _interopRequireDefault(require("./conditionallyPermittedChange"));
|
|
7
8
|
var _conditionallyRequired = _interopRequireDefault(require("./conditionallyRequired"));
|
|
8
9
|
var _mustBeAfter = _interopRequireDefault(require("./mustBeAfter"));
|
|
9
10
|
var _mustBeBefore = _interopRequireDefault(require("./mustBeBefore"));
|
|
@@ -25,6 +26,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
25
26
|
// Local imports
|
|
26
27
|
|
|
27
28
|
var functions = {
|
|
29
|
+
conditionallyPermittedChange: _conditionallyPermittedChange.default,
|
|
28
30
|
conditionallyRequired: _conditionallyRequired.default,
|
|
29
31
|
mustBeAfter: _mustBeAfter.default,
|
|
30
32
|
mustBeBefore: _mustBeBefore.default,
|