@luscii-healthtech/web-ui 2.16.1 → 2.16.3

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.
@@ -1,5 +1,7 @@
1
1
  import React from "react";
2
- import { ConfirmationDialogProps } from "./types/ConfirmationDialog.types";
2
+ import { ConfirmationDialogChoice, ConfirmationDialogProps } from "./types/ConfirmationDialog.types";
3
3
  export declare const ConfirmationDialogChoices: React.FC<{
4
4
  choices: ConfirmationDialogProps["choices"];
5
+ onChoiceChangeCallback?: (choice: ConfirmationDialogChoice) => void;
6
+ selectedChoice?: ConfirmationDialogChoice;
5
7
  }>;
@@ -19,7 +19,7 @@ export interface ConfirmationDialogProps {
19
19
  texts: ConfirmationDialogTexts;
20
20
  isOpen: boolean;
21
21
  onCancel: () => void;
22
- onConfirm: () => void;
22
+ onConfirm: (choice?: ConfirmationDialogChoice) => void;
23
23
  isProcessing?: boolean;
24
24
  withTitle?: {
25
25
  title: string;
@@ -25,12 +25,17 @@ export interface FormFieldDecoratorProps {
25
25
  info?: string;
26
26
  decoratorClassname?: string;
27
27
  }
28
- export declare type FormFieldProps<TFieldValues> = FormFieldInputProps<TFieldValues> | FormFieldSelectProps<TFieldValues> | FormFieldImagePickerProps<TFieldValues> | FormFieldRadioGroupProps<TFieldValues> | FormFieldRowProps<TFieldValues>;
28
+ export declare type FormFieldProps<TFieldValues> = FormFieldInputProps<TFieldValues> | FormFieldSelectProps<TFieldValues> | FormFieldImagePickerProps<TFieldValues> | FormFieldRadioGroupProps<TFieldValues> | FormFieldRowProps<TFieldValues> | FormFieldSeparatorProps<TFieldValues>;
29
29
  export interface FormFieldRowProps<TFieldValues> extends Record<keyof FormFieldGenericProps<never, TFieldValues>, never> {
30
30
  type: "row";
31
31
  key: string;
32
32
  fields: FormFieldProps<TFieldValues>[];
33
33
  }
34
+ export interface FormFieldSeparatorProps<TFieldValues> extends Record<keyof FormFieldGenericProps<never, TFieldValues>, never> {
35
+ type: "separator";
36
+ key: string;
37
+ text: string;
38
+ }
34
39
  export interface FormFieldInputProps<TFieldValues> extends FormFieldGenericProps<Omit<InputProps, "name">, TFieldValues> {
35
40
  type: AllowedTextInputTypes;
36
41
  }
@@ -2701,13 +2701,9 @@ var RadioGroupV2 = /*#__PURE__*/React__default.forwardRef(function (props, ref)
2701
2701
  });
2702
2702
 
2703
2703
  var ConfirmationDialogChoices = function ConfirmationDialogChoices(props) {
2704
- var choices = props.choices;
2705
-
2706
- var _useState = React.useState(choices == null ? void 0 : choices.options.find(function (choice) {
2707
- return choice.value === choices.defaultChoice;
2708
- })),
2709
- selectedChoice = _useState[0],
2710
- setSelectedChoice = _useState[1];
2704
+ var choices = props.choices,
2705
+ onChoiceChangeCallback = props.onChoiceChangeCallback,
2706
+ selectedChoice = props.selectedChoice;
2711
2707
 
2712
2708
  if (!choices) {
2713
2709
  return null;
@@ -2720,10 +2716,7 @@ var ConfirmationDialogChoices = function ConfirmationDialogChoices(props) {
2720
2716
  value: choice.value,
2721
2717
  info: choice.description,
2722
2718
  onChange: function onChange() {
2723
- var _props$choices;
2724
-
2725
- (_props$choices = props.choices) == null ? void 0 : _props$choices.onChoiceChange(choice);
2726
- setSelectedChoice(choice);
2719
+ onChoiceChangeCallback == null ? void 0 : onChoiceChangeCallback(choice);
2727
2720
  }
2728
2721
  };
2729
2722
  });
@@ -2738,12 +2731,34 @@ var ConfirmationDialogChoices = function ConfirmationDialogChoices(props) {
2738
2731
  };
2739
2732
 
2740
2733
  var ConfirmationDialog = function ConfirmationDialog(props) {
2734
+ var choices = props.choices;
2735
+
2736
+ var _useState = React.useState(choices == null ? void 0 : choices.options.find(function (choice) {
2737
+ return choice.value === choices.defaultChoice;
2738
+ })),
2739
+ selectedChoice = _useState[0],
2740
+ setSelectedChoice = _useState[1];
2741
+
2741
2742
  var handleOnCloseClick = function handleOnCloseClick() {
2742
2743
  if (!props.isProcessing) {
2743
2744
  props.onCancel();
2744
2745
  }
2745
2746
  };
2746
2747
 
2748
+ var onChoiceChange = function onChoiceChange(choice) {
2749
+ setSelectedChoice(choice);
2750
+
2751
+ if (choice) {
2752
+ var _props$choices;
2753
+
2754
+ (_props$choices = props.choices) == null ? void 0 : _props$choices.onChoiceChange(choice);
2755
+ }
2756
+ };
2757
+
2758
+ var onConfirmHandler = function onConfirmHandler() {
2759
+ props.onConfirm(selectedChoice);
2760
+ };
2761
+
2747
2762
  var modalButtons = [/*#__PURE__*/React__default.createElement(SecondaryButton, {
2748
2763
  key: "confirmation-dialog-button-cancel",
2749
2764
  "data-test-id": "button-cancel",
@@ -2755,7 +2770,7 @@ var ConfirmationDialog = function ConfirmationDialog(props) {
2755
2770
  className: "ml-2.5",
2756
2771
  "data-test-id": "button-confirm",
2757
2772
  text: props.texts.confirmLabel,
2758
- onClick: props.onConfirm,
2773
+ onClick: onConfirmHandler,
2759
2774
  isPending: props.isProcessing
2760
2775
  })];
2761
2776
  return /*#__PURE__*/React__default.createElement(ModalWithButtons, {
@@ -2774,7 +2789,9 @@ var ConfirmationDialog = function ConfirmationDialog(props) {
2774
2789
  text: props.texts.message,
2775
2790
  containsDangerousHtml: true
2776
2791
  }), /*#__PURE__*/React__default.createElement(ConfirmationDialogChoices, {
2777
- choices: props.choices
2792
+ choices: props.choices,
2793
+ onChoiceChangeCallback: onChoiceChange,
2794
+ selectedChoice: selectedChoice
2778
2795
  })));
2779
2796
  };
2780
2797
 
@@ -6126,6 +6143,12 @@ function ViewItem(_ref) {
6126
6143
  })));
6127
6144
  }
6128
6145
 
6146
+ var Divider = function Divider() {
6147
+ return /*#__PURE__*/React__default.createElement("div", {
6148
+ className: "block w-full border-b last:border-b-0 border-solid border-color border-color-divider"
6149
+ });
6150
+ };
6151
+
6129
6152
  /**
6130
6153
  * Decorator for any input component. Adds a label and additional information to be shown.
6131
6154
  *
@@ -6727,6 +6750,11 @@ function FormFieldMapper(formFieldProps, useFormReturn) {
6727
6750
  errors = useFormReturn.formState.errors;
6728
6751
 
6729
6752
  switch (type) {
6753
+ case "separator":
6754
+ return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Divider, null), /*#__PURE__*/React__default.createElement(Title, {
6755
+ text: formFieldProps.text
6756
+ }));
6757
+
6730
6758
  case "row":
6731
6759
  return /*#__PURE__*/React__default.createElement(FlexRow, {
6732
6760
  key: formFieldProps.key
@@ -7542,12 +7570,6 @@ var SearchCancelIcon = function SearchCancelIcon(props) {
7542
7570
  }));
7543
7571
  };
7544
7572
 
7545
- var Divider = function Divider() {
7546
- return /*#__PURE__*/React__default.createElement("div", {
7547
- className: "block w-full border-b last:border-b-0 border-solid border-color border-color-divider"
7548
- });
7549
- };
7550
-
7551
7573
  exports.AccordionList = AccordionList;
7552
7574
  exports.AddIcon = AddIcon;
7553
7575
  exports.AlertsIcon = AlertsIcon;