@bigbinary/neeto-rules-frontend 0.6.4 → 0.6.6
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/app/javascript/src/translations/en.json +4 -2
- package/dist/index.cjs.js +34 -24
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +34 -24
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
|
@@ -180,7 +180,8 @@
|
|
|
180
180
|
"inValidEmail": "Email is invalid",
|
|
181
181
|
"inValidURL": "URL is invalid",
|
|
182
182
|
"noBlankSpaces": "Value should not contain blank spaces",
|
|
183
|
-
"
|
|
183
|
+
"positiveDecimal": "Value should be a positive decimal number.",
|
|
184
|
+
"decimal": "Value should be a decimal number.",
|
|
184
185
|
"atLeastOne": {
|
|
185
186
|
"option": "At least one option is required",
|
|
186
187
|
"email": "At least one email is required",
|
|
@@ -189,7 +190,8 @@
|
|
|
189
190
|
"atLeastOneValue": "At least one value is required",
|
|
190
191
|
"emailList": "Please make sure all emails are valid.",
|
|
191
192
|
"positiveInteger": "Value must be a positive integer.",
|
|
192
|
-
"positiveNumber": "Value must be a positive number.",
|
|
193
|
+
"positiveNumber": "Value must be a positive whole number.",
|
|
194
|
+
"number": "Value must be a whole number.",
|
|
193
195
|
"leadingSpace": "Can not have leading white space",
|
|
194
196
|
"slack": {
|
|
195
197
|
"invalidChannel": "Could not connect to the channel, please select other options.",
|
package/dist/index.cjs.js
CHANGED
|
@@ -415,15 +415,13 @@ var getConditionsSchema = function getConditionsSchema(element) {
|
|
|
415
415
|
field: yup__namespace.string().required(i18next.t("neetoRules.validations.required.condition")),
|
|
416
416
|
metadata: yup__namespace.mixed().when(["field", "verb"], function (field, verb, schema) {
|
|
417
417
|
var _selectedCondition$no;
|
|
418
|
-
var selectedCondition =
|
|
419
|
-
|
|
420
|
-
});
|
|
418
|
+
var selectedCondition = neetoCist.findBy({
|
|
419
|
+
value: field
|
|
420
|
+
}, conditionOptions);
|
|
421
421
|
var type = selectedCondition === null || selectedCondition === void 0 ? void 0 : selectedCondition.type;
|
|
422
422
|
if (selectedCondition !== null && selectedCondition !== void 0 && selectedCondition.additionalData) {
|
|
423
423
|
var value = selectedCondition === null || selectedCondition === void 0 ? void 0 : selectedCondition.additionalData[verb];
|
|
424
|
-
if (value)
|
|
425
|
-
type = value;
|
|
426
|
-
}
|
|
424
|
+
if (value) type = value;
|
|
427
425
|
}
|
|
428
426
|
if (selectedCondition !== null && selectedCondition !== void 0 && (_selectedCondition$no = selectedCondition.noValueForVerbs) !== null && _selectedCondition$no !== void 0 && _selectedCondition$no.includes(verb)) {
|
|
429
427
|
return yup__namespace.object();
|
|
@@ -454,9 +452,11 @@ var getConditionsSchema = function getConditionsSchema(element) {
|
|
|
454
452
|
}).required(i18next.t("neetoRules.validations.required.value"))
|
|
455
453
|
});
|
|
456
454
|
} else if ([CONDITION_VALUE_TYPES.number].includes(type)) {
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
455
|
+
var message = selectedCondition !== null && selectedCondition !== void 0 && selectedCondition.onlyPositive ? i18next.t("neetoRules.validations.positiveNumber") : i18next.t("neetoRules.validations.number");
|
|
456
|
+
var regex = selectedCondition !== null && selectedCondition !== void 0 && selectedCondition.onlyPositive ? POSITIVE_NUMBER_REGEX : NUMBER_REGEX;
|
|
457
|
+
return yup__namespace.object({
|
|
458
|
+
value: yup__namespace.string().test("are-all-number", message, function (value) {
|
|
459
|
+
return regex.test(value);
|
|
460
460
|
})
|
|
461
461
|
});
|
|
462
462
|
} else if ([CONDITION_VALUE_TYPES.url].includes(type)) {
|
|
@@ -471,9 +471,11 @@ var getConditionsSchema = function getConditionsSchema(element) {
|
|
|
471
471
|
}).required(i18next.t("neetoRules.validations.required.value"))
|
|
472
472
|
});
|
|
473
473
|
} else if ([CONDITION_VALUE_TYPES.decimal].includes(type)) {
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
474
|
+
var _message = selectedCondition !== null && selectedCondition !== void 0 && selectedCondition.onlyPositive ? i18next.t("neetoRules.validations.positiveDecimal") : i18next.t("neetoRules.validations.decimal");
|
|
475
|
+
var _regex = selectedCondition !== null && selectedCondition !== void 0 && selectedCondition.onlyPositive ? POSITIVE_DECIMAL_NUMBER_REGEX : DECIMAL_NUMBER_REGEX;
|
|
476
|
+
return yup__namespace.object({
|
|
477
|
+
value: yup__namespace.string().test("are-all-number", _message, function (value) {
|
|
478
|
+
return _regex.test(value);
|
|
477
479
|
}).required(i18next.t("neetoRules.validations.required.decimal"))
|
|
478
480
|
});
|
|
479
481
|
} else if ([CONDITION_VALUE_TYPES.textarea].includes(type)) {
|
|
@@ -557,15 +559,19 @@ var getActionsSchema = function getActionsSchema(element, customData) {
|
|
|
557
559
|
}).required(i18next.t("neetoRules.validations.required.value"))
|
|
558
560
|
});
|
|
559
561
|
} else if ((selectedAction === null || selectedAction === void 0 ? void 0 : selectedAction.type) === ACTION_TYPES.number) {
|
|
562
|
+
var message = selectedAction !== null && selectedAction !== void 0 && selectedAction.onlyPositive ? i18next.t("neetoRules.validations.positiveNumber") : i18next.t("neetoRules.validations.number");
|
|
563
|
+
var regex = selectedAction !== null && selectedAction !== void 0 && selectedAction.onlyPositive ? POSITIVE_NUMBER_REGEX : NUMBER_REGEX;
|
|
560
564
|
return yup__namespace.object({
|
|
561
|
-
value: yup__namespace.string().test("are-all-number",
|
|
562
|
-
return
|
|
565
|
+
value: yup__namespace.string().test("are-all-number", message, function (value) {
|
|
566
|
+
return regex.test(value);
|
|
563
567
|
})
|
|
564
568
|
});
|
|
565
569
|
} else if ((selectedAction === null || selectedAction === void 0 ? void 0 : selectedAction.type) === ACTION_TYPES.decimal) {
|
|
570
|
+
var _message2 = selectedAction !== null && selectedAction !== void 0 && selectedAction.onlyPositive ? i18next.t("neetoRules.validations.positiveDecimal") : i18next.t("neetoRules.validations.decimal");
|
|
571
|
+
var _regex2 = selectedAction !== null && selectedAction !== void 0 && selectedAction.onlyPositive ? POSITIVE_DECIMAL_NUMBER_REGEX : DECIMAL_NUMBER_REGEX;
|
|
566
572
|
return yup__namespace.object({
|
|
567
|
-
value: yup__namespace.string().test("are-all-number",
|
|
568
|
-
return
|
|
573
|
+
value: yup__namespace.string().test("are-all-number", _message2, function (value) {
|
|
574
|
+
return _regex2.test(value);
|
|
569
575
|
}).required(i18next.t("neetoRules.validations.required.decimal"))
|
|
570
576
|
});
|
|
571
577
|
} else if ((selectedAction === null || selectedAction === void 0 ? void 0 : selectedAction.type) === ACTION_TYPES.longText) {
|
|
@@ -617,8 +623,10 @@ var FIELD_TYPES = {
|
|
|
617
623
|
};
|
|
618
624
|
var MAXIMUM_OPTION_LENGTH$1 = 7;
|
|
619
625
|
var VALIDATION_SCHEMA = (_VALIDATION_SCHEMA = {}, _defineProperty$1(_VALIDATION_SCHEMA, FIELD_TYPES.text, getSchemaForStrings), _defineProperty$1(_VALIDATION_SCHEMA, FIELD_TYPES.longText, getSchemaForStrings), _defineProperty$1(_VALIDATION_SCHEMA, FIELD_TYPES.dropdown, getSchemaForStrings), _defineProperty$1(_VALIDATION_SCHEMA, FIELD_TYPES.radio, getSchemaForStrings), _defineProperty$1(_VALIDATION_SCHEMA, FIELD_TYPES.events, getEventsSchema), _defineProperty$1(_VALIDATION_SCHEMA, FIELD_TYPES.condition, getConditionsSchema), _defineProperty$1(_VALIDATION_SCHEMA, FIELD_TYPES.actions, getActionsSchema), _defineProperty$1(_VALIDATION_SCHEMA, FIELD_TYPES.multiSelect, getSchemaForArray), _VALIDATION_SCHEMA);
|
|
620
|
-
var DECIMAL_NUMBER_REGEX =
|
|
621
|
-
var
|
|
626
|
+
var DECIMAL_NUMBER_REGEX = /^-?\d*\.?\d+$/;
|
|
627
|
+
var NUMBER_REGEX = /^-?\d+$/;
|
|
628
|
+
var POSITIVE_DECIMAL_NUMBER_REGEX = /^\d*\.?\d+$/;
|
|
629
|
+
var POSITIVE_NUMBER_REGEX = /^\d+$/;
|
|
622
630
|
|
|
623
631
|
function ownKeys$a(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; }
|
|
624
632
|
function _objectSpread$9(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$a(Object(t), !0).forEach(function (r) { _defineProperty$1(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$a(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
@@ -12096,7 +12104,9 @@ var Conditions = function Conditions(_ref) {
|
|
|
12096
12104
|
isCallback = _ref$isCallback === void 0 ? false : _ref$isCallback,
|
|
12097
12105
|
previewCallback = _ref.previewCallback,
|
|
12098
12106
|
_ref$isWithEvents = _ref.isWithEvents,
|
|
12099
|
-
isWithEvents = _ref$isWithEvents === void 0 ? false : _ref$isWithEvents
|
|
12107
|
+
isWithEvents = _ref$isWithEvents === void 0 ? false : _ref$isWithEvents,
|
|
12108
|
+
_ref$allowEmpty = _ref.allowEmpty,
|
|
12109
|
+
allowEmpty = _ref$allowEmpty === void 0 ? true : _ref$allowEmpty;
|
|
12100
12110
|
var _useField = formik.useField(name),
|
|
12101
12111
|
_useField2 = _slicedToArray$1(_useField, 3),
|
|
12102
12112
|
field = _useField2[0],
|
|
@@ -12161,8 +12171,8 @@ var Conditions = function Conditions(_ref) {
|
|
|
12161
12171
|
}, index === conditions.length - 1 && /*#__PURE__*/React__default["default"].createElement(Button__default["default"], {
|
|
12162
12172
|
"data-cy": "add-condition-button",
|
|
12163
12173
|
icon: neetoIcons.Plus,
|
|
12164
|
-
size:
|
|
12165
|
-
style: "
|
|
12174
|
+
size: "small",
|
|
12175
|
+
style: "text",
|
|
12166
12176
|
tooltipProps: {
|
|
12167
12177
|
content: t("neetoRules.form.addCondition"),
|
|
12168
12178
|
position: "top"
|
|
@@ -12170,11 +12180,11 @@ var Conditions = function Conditions(_ref) {
|
|
|
12170
12180
|
onClick: function onClick() {
|
|
12171
12181
|
return handleAddCondition(arrayHelpers, condition.joinType);
|
|
12172
12182
|
}
|
|
12173
|
-
}), /*#__PURE__*/React__default["default"].createElement(Button__default["default"], {
|
|
12183
|
+
}), (allowEmpty || index !== 0) && /*#__PURE__*/React__default["default"].createElement(Button__default["default"], {
|
|
12174
12184
|
"data-cy": "delete-condition-button-".concat(index),
|
|
12175
12185
|
icon: neetoIcons.Delete,
|
|
12176
|
-
size:
|
|
12177
|
-
style: "
|
|
12186
|
+
size: "small",
|
|
12187
|
+
style: "text",
|
|
12178
12188
|
tooltipProps: {
|
|
12179
12189
|
content: t("neetoRules.common.delete"),
|
|
12180
12190
|
position: "top"
|