@luscii-healthtech/web-ui 2.16.0 → 2.16.2

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.
@@ -1415,7 +1415,7 @@ var Input = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
1415
1415
  });
1416
1416
  };
1417
1417
 
1418
- var isClearIconVisible = clearable && value;
1418
+ var isClearIconVisible = clearable && innerValue;
1419
1419
  return /*#__PURE__*/React__default.createElement(FlexRow, {
1420
1420
  spacing: "none",
1421
1421
  "data-test-id": "input-component-container",
@@ -2693,13 +2693,9 @@ var RadioGroupV2 = /*#__PURE__*/React__default.forwardRef(function (props, ref)
2693
2693
  });
2694
2694
 
2695
2695
  var ConfirmationDialogChoices = function ConfirmationDialogChoices(props) {
2696
- var choices = props.choices;
2697
-
2698
- var _useState = useState(choices == null ? void 0 : choices.options.find(function (choice) {
2699
- return choice.value === choices.defaultChoice;
2700
- })),
2701
- selectedChoice = _useState[0],
2702
- setSelectedChoice = _useState[1];
2696
+ var choices = props.choices,
2697
+ onChoiceChangeCallback = props.onChoiceChangeCallback,
2698
+ selectedChoice = props.selectedChoice;
2703
2699
 
2704
2700
  if (!choices) {
2705
2701
  return null;
@@ -2712,10 +2708,7 @@ var ConfirmationDialogChoices = function ConfirmationDialogChoices(props) {
2712
2708
  value: choice.value,
2713
2709
  info: choice.description,
2714
2710
  onChange: function onChange() {
2715
- var _props$choices;
2716
-
2717
- (_props$choices = props.choices) == null ? void 0 : _props$choices.onChoiceChange(choice);
2718
- setSelectedChoice(choice);
2711
+ onChoiceChangeCallback == null ? void 0 : onChoiceChangeCallback(choice);
2719
2712
  }
2720
2713
  };
2721
2714
  });
@@ -2730,12 +2723,34 @@ var ConfirmationDialogChoices = function ConfirmationDialogChoices(props) {
2730
2723
  };
2731
2724
 
2732
2725
  var ConfirmationDialog = function ConfirmationDialog(props) {
2726
+ var choices = props.choices;
2727
+
2728
+ var _useState = useState(choices == null ? void 0 : choices.options.find(function (choice) {
2729
+ return choice.value === choices.defaultChoice;
2730
+ })),
2731
+ selectedChoice = _useState[0],
2732
+ setSelectedChoice = _useState[1];
2733
+
2733
2734
  var handleOnCloseClick = function handleOnCloseClick() {
2734
2735
  if (!props.isProcessing) {
2735
2736
  props.onCancel();
2736
2737
  }
2737
2738
  };
2738
2739
 
2740
+ var onChoiceChange = function onChoiceChange(choice) {
2741
+ setSelectedChoice(choice);
2742
+
2743
+ if (choice) {
2744
+ var _props$choices;
2745
+
2746
+ (_props$choices = props.choices) == null ? void 0 : _props$choices.onChoiceChange(choice);
2747
+ }
2748
+ };
2749
+
2750
+ var onConfirmHandler = function onConfirmHandler() {
2751
+ props.onConfirm(selectedChoice);
2752
+ };
2753
+
2739
2754
  var modalButtons = [/*#__PURE__*/React__default.createElement(SecondaryButton, {
2740
2755
  key: "confirmation-dialog-button-cancel",
2741
2756
  "data-test-id": "button-cancel",
@@ -2747,7 +2762,7 @@ var ConfirmationDialog = function ConfirmationDialog(props) {
2747
2762
  className: "ml-2.5",
2748
2763
  "data-test-id": "button-confirm",
2749
2764
  text: props.texts.confirmLabel,
2750
- onClick: props.onConfirm,
2765
+ onClick: onConfirmHandler,
2751
2766
  isPending: props.isProcessing
2752
2767
  })];
2753
2768
  return /*#__PURE__*/React__default.createElement(ModalWithButtons, {
@@ -2766,7 +2781,9 @@ var ConfirmationDialog = function ConfirmationDialog(props) {
2766
2781
  text: props.texts.message,
2767
2782
  containsDangerousHtml: true
2768
2783
  }), /*#__PURE__*/React__default.createElement(ConfirmationDialogChoices, {
2769
- choices: props.choices
2784
+ choices: props.choices,
2785
+ onChoiceChangeCallback: onChoiceChange,
2786
+ selectedChoice: selectedChoice
2770
2787
  })));
2771
2788
  };
2772
2789
 
@@ -6175,13 +6192,15 @@ var isRequired = function isRequired(options) {
6175
6192
  return !!(options && "required" in options);
6176
6193
  };
6177
6194
 
6178
- var _excluded$n = ["name", "fieldErrors", "fieldRequired", "label", "info", "decoratorClassname"];
6195
+ var _excluded$n = ["control", "name", "rules", "fieldErrors", "fieldRequired", "label", "info", "decoratorClassname"];
6179
6196
  /**
6180
6197
  * Input field that can be used in any react-hook-form context.
6181
6198
  */
6182
6199
 
6183
- var FormInput = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
6184
- var name = _ref.name,
6200
+ var FormInput = /*#__PURE__*/React__default.forwardRef(function (_ref, innerRef) {
6201
+ var control = _ref.control,
6202
+ name = _ref.name,
6203
+ rules = _ref.rules,
6185
6204
  fieldErrors = _ref.fieldErrors,
6186
6205
  fieldRequired = _ref.fieldRequired,
6187
6206
  label = _ref.label,
@@ -6196,11 +6215,18 @@ var FormInput = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
6196
6215
  label: label,
6197
6216
  info: info,
6198
6217
  decoratorClassname: decoratorClassname
6199
- }, /*#__PURE__*/React__default.createElement(Input, _extends({}, fieldProps, {
6200
- isError: hasError(name, fieldErrors),
6201
- ref: ref,
6202
- name: name
6203
- })));
6218
+ }, /*#__PURE__*/React__default.createElement(Controller, {
6219
+ name: name,
6220
+ control: control,
6221
+ rules: rules,
6222
+ render: function render(_ref2) {
6223
+ var field = _ref2.field;
6224
+ return /*#__PURE__*/React__default.createElement(Input, _extends({}, fieldProps, field, {
6225
+ isError: hasError(name, fieldErrors),
6226
+ ref: innerRef
6227
+ }));
6228
+ }
6229
+ }));
6204
6230
  });
6205
6231
 
6206
6232
  var _excluded$o = ["name", "fieldErrors", "fieldRequired", "label", "info", "decoratorClassname"];
@@ -6724,12 +6750,15 @@ function FormFieldMapper(formFieldProps, useFormReturn) {
6724
6750
  case "email":
6725
6751
  case "password":
6726
6752
  return /*#__PURE__*/React__default.createElement(FormInput, _extends({
6727
- key: name
6753
+ key: name,
6754
+ name: name
6728
6755
  }, decoratorProps, {
6729
6756
  fieldRequired: isRequired(options),
6730
6757
  fieldErrors: errors
6731
- }, fieldProps, register(name, options), {
6732
- type: type || "text"
6758
+ }, fieldProps, {
6759
+ control: control,
6760
+ rules: options,
6761
+ type: type
6733
6762
  }));
6734
6763
 
6735
6764
  case "select":