@bigbinary/neeto-rules-frontend 2.5.15-beta-5 → 2.5.15-beta-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.
@@ -531,15 +531,20 @@ var DEFAULT_LONG_TEXT_ROWS = 8;
531
531
  var Target$j = function Target(_ref) {
532
532
  var _errors$actions, _touched$actions, _selectedField$separa;
533
533
  var index = _ref.index,
534
+ name = _ref.name,
534
535
  _ref$selectedField = _ref.selectedField,
535
536
  selectedField = _ref$selectedField === void 0 ? {} : _ref$selectedField,
536
537
  defaultLabel = _ref.defaultLabel,
537
538
  defaultSeparator = _ref.defaultSeparator,
538
- _onClick = _ref.onClick;
539
+ _ref$onClick = _ref.onClick,
540
+ _onClick = _ref$onClick === void 0 ? neetoCist.noop : _ref$onClick;
539
541
  var _useFormikContext = formik.useFormikContext(),
540
542
  errors = _useFormikContext.errors,
541
543
  touched = _useFormikContext.touched;
542
- var isValid = errors.actions && ramda.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]) && ramda.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]);
544
+ var _useActiveField = useActiveField(name),
545
+ isFieldActive = _useActiveField.isFieldActive,
546
+ setFieldActive = _useActiveField.setFieldActive;
547
+ var isFieldInvalid = errors.actions && ramda.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]) && ramda.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]);
543
548
  var separator = (selectedField === null || selectedField === void 0 || (_selectedField$separa = selectedField.separator) === null || _selectedField$separa === void 0 ? void 0 : _selectedField$separa.toLowerCase()) || defaultSeparator;
544
549
  var label = (selectedField === null || selectedField === void 0 ? void 0 : selectedField.placeholder) || defaultLabel;
545
550
  return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
@@ -554,27 +559,35 @@ var Target$j = function Target(_ref) {
554
559
  label: label.toLowerCase(),
555
560
  style: "link",
556
561
  className: classNames("neeto-ui-text-gray-800 neeto-ui-font-semibold underline", {
557
- "neeto-ui-text-error-500": isValid
562
+ "neeto-ui-text-accent-800": isFieldActive,
563
+ "neeto-ui-text-error-500": isFieldInvalid && !isFieldActive
558
564
  }),
559
565
  onClick: function onClick() {
560
- return _onClick === null || _onClick === void 0 ? void 0 : _onClick();
566
+ _onClick();
567
+ setFieldActive();
561
568
  }
562
569
  })]
563
570
  });
564
571
  };
565
572
  var LongTextField = function LongTextField(_ref2) {
566
573
  var name = _ref2.name,
567
- _ref2$value = _ref2.value,
568
- value = _ref2$value === void 0 ? "" : _ref2$value,
569
574
  _ref2$selectedField = _ref2.selectedField,
570
- selectedField = _ref2$selectedField === void 0 ? {} : _ref2$selectedField;
575
+ selectedField = _ref2$selectedField === void 0 ? {} : _ref2$selectedField,
576
+ _ref2$shouldAutoFocus = _ref2.shouldAutoFocus,
577
+ shouldAutoFocus = _ref2$shouldAutoFocus === void 0 ? false : _ref2$shouldAutoFocus;
578
+ var _useActiveField2 = useActiveField(name, {
579
+ shouldAutoFocus: shouldAutoFocus
580
+ }),
581
+ ref = _useActiveField2.ref,
582
+ setFieldActive = _useActiveField2.setFieldActive;
571
583
  var rows = (selectedField === null || selectedField === void 0 ? void 0 : selectedField.rows) || DEFAULT_LONG_TEXT_ROWS;
572
584
  return /*#__PURE__*/jsxRuntime.jsx(Textarea, {
573
585
  name: name,
586
+ ref: ref,
574
587
  rows: rows,
575
- value: value,
576
588
  required: true,
577
- className: "w-full"
589
+ className: "w-full",
590
+ onFocus: setFieldActive
578
591
  });
579
592
  };
580
593
  LongTextField.Target = Target$j;
@@ -2854,7 +2867,6 @@ var ActionSubItem = function ActionSubItem(_ref) {
2854
2867
  });
2855
2868
  }
2856
2869
  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) {
2857
- var _action$metadata6, _action$metadata7;
2858
2870
  return isTarget ? /*#__PURE__*/jsxRuntime.jsx(LongTextField.Target, {
2859
2871
  hasError: hasError,
2860
2872
  index: index,
@@ -2862,7 +2874,6 @@ var ActionSubItem = function ActionSubItem(_ref) {
2862
2874
  defaultLabel: t("neetoRules.labels.body"),
2863
2875
  defaultSeparator: t("neetoRules.common.as"),
2864
2876
  name: "".concat(name, ".value"),
2865
- value: (_action$metadata6 = action.metadata) === null || _action$metadata6 === void 0 ? void 0 : _action$metadata6.value,
2866
2877
  onClick: function onClick() {
2867
2878
  return openPanel("large");
2868
2879
  }
@@ -2872,8 +2883,7 @@ var ActionSubItem = function ActionSubItem(_ref) {
2872
2883
  shouldAutoFocus: true,
2873
2884
  defaultLabel: t("neetoRules.labels.body"),
2874
2885
  defaultSeparator: t("neetoRules.common.as"),
2875
- name: "".concat(name, ".value"),
2876
- value: (_action$metadata7 = action.metadata) === null || _action$metadata7 === void 0 ? void 0 : _action$metadata7.value
2886
+ name: "".concat(name, ".value")
2877
2887
  });
2878
2888
  }
2879
2889
  if (selectedField !== null && selectedField !== void 0 && selectedField.component) {
@@ -3775,18 +3785,15 @@ var ValueField = function ValueField(_ref) {
3775
3785
  });
3776
3786
  }
3777
3787
  if (fieldType === constants.CONDITION_VALUE_TYPES.textarea) {
3778
- var _condition$metadata, _condition$metadata2;
3779
3788
  return isTarget ? /*#__PURE__*/jsxRuntime.jsx(LongTextField.Target, {
3780
3789
  index: index,
3781
3790
  onClick: onClick,
3782
3791
  defaultLabel: t("neetoRules.labels.text"),
3783
- name: "".concat(name, ".value"),
3784
- value: (_condition$metadata = condition.metadata) === null || _condition$metadata === void 0 ? void 0 : _condition$metadata.value
3792
+ name: "".concat(name, ".value")
3785
3793
  }) : /*#__PURE__*/jsxRuntime.jsx(LongTextField, {
3786
3794
  index: index,
3787
3795
  defaultLabel: t("neetoRules.labels.text"),
3788
- name: "".concat(name, ".value"),
3789
- value: (_condition$metadata2 = condition.metadata) === null || _condition$metadata2 === void 0 ? void 0 : _condition$metadata2.value
3796
+ name: "".concat(name, ".value")
3790
3797
  });
3791
3798
  }
3792
3799
  if (fieldType === constants.CONDITION_VALUE_TYPES.radio) {
@@ -6042,6 +6049,7 @@ var Form = function Form(_ref) {
6042
6049
  resetPanelState = _useUtilityStore.resetPanelState;
6043
6050
  var submitForm = function submitForm(values, formikBag) {
6044
6051
  var payload = buildPayload(data, values);
6052
+ resetPanelState();
6045
6053
  handleSubmit(payload, formikBag);
6046
6054
  };
6047
6055
  var initialValues = react.useMemo(function () {