@bigbinary/neeto-rules-frontend 2.5.15-beta-5 → 2.5.15-beta-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/dist/NeetoRulesForm.js
CHANGED
|
@@ -5,7 +5,7 @@ import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
|
5
5
|
import { shallow } from 'zustand/shallow';
|
|
6
6
|
import { useRef, useEffect, createElement, forwardRef, useState, useMemo, memo, Fragment as Fragment$1 } from 'react';
|
|
7
7
|
import { useFormikContext, useField, FieldArray, ErrorMessage, Formik, Form as Form$1 } from 'formik';
|
|
8
|
-
import { findBy, isNotEmpty, isPresent, hyphenate, renameKeys, nullSafe,
|
|
8
|
+
import { findBy, noop, isNotEmpty, isPresent, hyphenate, renameKeys, nullSafe, toLabelAndValue, removeBy, isNotPresent } from '@bigbinary/neeto-cist';
|
|
9
9
|
import Plus from '@bigbinary/neeto-icons/Plus';
|
|
10
10
|
import Delete from '@bigbinary/neeto-icons/Delete';
|
|
11
11
|
import Refresh from '@bigbinary/neeto-icons/Refresh';
|
|
@@ -510,15 +510,20 @@ var DEFAULT_LONG_TEXT_ROWS = 8;
|
|
|
510
510
|
var Target$j = function Target(_ref) {
|
|
511
511
|
var _errors$actions, _touched$actions, _selectedField$separa;
|
|
512
512
|
var index = _ref.index,
|
|
513
|
+
name = _ref.name,
|
|
513
514
|
_ref$selectedField = _ref.selectedField,
|
|
514
515
|
selectedField = _ref$selectedField === void 0 ? {} : _ref$selectedField,
|
|
515
516
|
defaultLabel = _ref.defaultLabel,
|
|
516
517
|
defaultSeparator = _ref.defaultSeparator,
|
|
517
|
-
|
|
518
|
+
_ref$onClick = _ref.onClick,
|
|
519
|
+
_onClick = _ref$onClick === void 0 ? noop : _ref$onClick;
|
|
518
520
|
var _useFormikContext = useFormikContext(),
|
|
519
521
|
errors = _useFormikContext.errors,
|
|
520
522
|
touched = _useFormikContext.touched;
|
|
521
|
-
var
|
|
523
|
+
var _useActiveField = useActiveField(name),
|
|
524
|
+
isFieldActive = _useActiveField.isFieldActive,
|
|
525
|
+
setFieldActive = _useActiveField.setFieldActive;
|
|
526
|
+
var isFieldInvalid = errors.actions && isNotNil((_errors$actions = errors.actions) === null || _errors$actions === void 0 || (_errors$actions = _errors$actions.value) === null || _errors$actions === void 0 ? void 0 : _errors$actions[index]) && isNotNil((_touched$actions = touched.actions) === null || _touched$actions === void 0 || (_touched$actions = _touched$actions.value) === null || _touched$actions === void 0 ? void 0 : _touched$actions[index]);
|
|
522
527
|
var separator = (selectedField === null || selectedField === void 0 || (_selectedField$separa = selectedField.separator) === null || _selectedField$separa === void 0 ? void 0 : _selectedField$separa.toLowerCase()) || defaultSeparator;
|
|
523
528
|
var label = (selectedField === null || selectedField === void 0 ? void 0 : selectedField.placeholder) || defaultLabel;
|
|
524
529
|
return /*#__PURE__*/jsxs(Fragment, {
|
|
@@ -533,27 +538,35 @@ var Target$j = function Target(_ref) {
|
|
|
533
538
|
label: label.toLowerCase(),
|
|
534
539
|
style: "link",
|
|
535
540
|
className: classNames("neeto-ui-text-gray-800 neeto-ui-font-semibold underline", {
|
|
536
|
-
"neeto-ui-text-
|
|
541
|
+
"neeto-ui-text-accent-800": isFieldActive,
|
|
542
|
+
"neeto-ui-text-error-500": isFieldInvalid && !isFieldActive
|
|
537
543
|
}),
|
|
538
544
|
onClick: function onClick() {
|
|
539
|
-
|
|
545
|
+
_onClick();
|
|
546
|
+
setFieldActive();
|
|
540
547
|
}
|
|
541
548
|
})]
|
|
542
549
|
});
|
|
543
550
|
};
|
|
544
551
|
var LongTextField = function LongTextField(_ref2) {
|
|
545
552
|
var name = _ref2.name,
|
|
546
|
-
_ref2$value = _ref2.value,
|
|
547
|
-
value = _ref2$value === void 0 ? "" : _ref2$value,
|
|
548
553
|
_ref2$selectedField = _ref2.selectedField,
|
|
549
|
-
selectedField = _ref2$selectedField === void 0 ? {} : _ref2$selectedField
|
|
554
|
+
selectedField = _ref2$selectedField === void 0 ? {} : _ref2$selectedField,
|
|
555
|
+
_ref2$shouldAutoFocus = _ref2.shouldAutoFocus,
|
|
556
|
+
shouldAutoFocus = _ref2$shouldAutoFocus === void 0 ? false : _ref2$shouldAutoFocus;
|
|
557
|
+
var _useActiveField2 = useActiveField(name, {
|
|
558
|
+
shouldAutoFocus: shouldAutoFocus
|
|
559
|
+
}),
|
|
560
|
+
ref = _useActiveField2.ref,
|
|
561
|
+
setFieldActive = _useActiveField2.setFieldActive;
|
|
550
562
|
var rows = (selectedField === null || selectedField === void 0 ? void 0 : selectedField.rows) || DEFAULT_LONG_TEXT_ROWS;
|
|
551
563
|
return /*#__PURE__*/jsx(Textarea, {
|
|
552
564
|
name: name,
|
|
565
|
+
ref: ref,
|
|
553
566
|
rows: rows,
|
|
554
|
-
value: value,
|
|
555
567
|
required: true,
|
|
556
|
-
className: "w-full"
|
|
568
|
+
className: "w-full",
|
|
569
|
+
onFocus: setFieldActive
|
|
557
570
|
});
|
|
558
571
|
};
|
|
559
572
|
LongTextField.Target = Target$j;
|
|
@@ -2833,7 +2846,6 @@ var ActionSubItem = function ActionSubItem(_ref) {
|
|
|
2833
2846
|
});
|
|
2834
2847
|
}
|
|
2835
2848
|
if ((selectedField === null || selectedField === void 0 ? void 0 : selectedField.type) === ACTION_TYPES.longText || (selectedField === null || selectedField === void 0 ? void 0 : selectedField.type) === ACTION_TYPES.textarea) {
|
|
2836
|
-
var _action$metadata6, _action$metadata7;
|
|
2837
2849
|
return isTarget ? /*#__PURE__*/jsx(LongTextField.Target, {
|
|
2838
2850
|
hasError: hasError,
|
|
2839
2851
|
index: index,
|
|
@@ -2841,7 +2853,6 @@ var ActionSubItem = function ActionSubItem(_ref) {
|
|
|
2841
2853
|
defaultLabel: t("neetoRules.labels.body"),
|
|
2842
2854
|
defaultSeparator: t("neetoRules.common.as"),
|
|
2843
2855
|
name: "".concat(name, ".value"),
|
|
2844
|
-
value: (_action$metadata6 = action.metadata) === null || _action$metadata6 === void 0 ? void 0 : _action$metadata6.value,
|
|
2845
2856
|
onClick: function onClick() {
|
|
2846
2857
|
return openPanel("large");
|
|
2847
2858
|
}
|
|
@@ -2851,8 +2862,7 @@ var ActionSubItem = function ActionSubItem(_ref) {
|
|
|
2851
2862
|
shouldAutoFocus: true,
|
|
2852
2863
|
defaultLabel: t("neetoRules.labels.body"),
|
|
2853
2864
|
defaultSeparator: t("neetoRules.common.as"),
|
|
2854
|
-
name: "".concat(name, ".value")
|
|
2855
|
-
value: (_action$metadata7 = action.metadata) === null || _action$metadata7 === void 0 ? void 0 : _action$metadata7.value
|
|
2865
|
+
name: "".concat(name, ".value")
|
|
2856
2866
|
});
|
|
2857
2867
|
}
|
|
2858
2868
|
if (selectedField !== null && selectedField !== void 0 && selectedField.component) {
|
|
@@ -3754,18 +3764,15 @@ var ValueField = function ValueField(_ref) {
|
|
|
3754
3764
|
});
|
|
3755
3765
|
}
|
|
3756
3766
|
if (fieldType === CONDITION_VALUE_TYPES.textarea) {
|
|
3757
|
-
var _condition$metadata, _condition$metadata2;
|
|
3758
3767
|
return isTarget ? /*#__PURE__*/jsx(LongTextField.Target, {
|
|
3759
3768
|
index: index,
|
|
3760
3769
|
onClick: onClick,
|
|
3761
3770
|
defaultLabel: t("neetoRules.labels.text"),
|
|
3762
|
-
name: "".concat(name, ".value")
|
|
3763
|
-
value: (_condition$metadata = condition.metadata) === null || _condition$metadata === void 0 ? void 0 : _condition$metadata.value
|
|
3771
|
+
name: "".concat(name, ".value")
|
|
3764
3772
|
}) : /*#__PURE__*/jsx(LongTextField, {
|
|
3765
3773
|
index: index,
|
|
3766
3774
|
defaultLabel: t("neetoRules.labels.text"),
|
|
3767
|
-
name: "".concat(name, ".value")
|
|
3768
|
-
value: (_condition$metadata2 = condition.metadata) === null || _condition$metadata2 === void 0 ? void 0 : _condition$metadata2.value
|
|
3775
|
+
name: "".concat(name, ".value")
|
|
3769
3776
|
});
|
|
3770
3777
|
}
|
|
3771
3778
|
if (fieldType === CONDITION_VALUE_TYPES.radio) {
|