@seeqdev/qomponents 0.0.80 → 0.0.82

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.
@@ -6,5 +6,4 @@ export default _default;
6
6
  export declare const AllModalsVariants: React.FunctionComponent;
7
7
  export declare const ModalsWithDisabledSubmit: React.FunctionComponent;
8
8
  export declare const ModalsWithEditableTitle: React.FunctionComponent;
9
- export declare const ModalsWithIcon: React.FunctionComponent;
10
9
  export declare const ModalsWithCustomButton: React.FunctionComponent;
package/dist/index.esm.js CHANGED
@@ -14058,16 +14058,17 @@ const DialogContent = React__default.forwardRef(({ className, children, ...props
14058
14058
  tw-gap-4 tw-border tw-bg-sq-white dark:tw-bg-sq-dark-background tw-p-6 tw-shadow-lg tw-duration-200
14059
14059
  tw-rounded-lg ${className}`, ...props }, children))));
14060
14060
  DialogContent.displayName = $5d3850c4d0b4e6c7$export$7c6e2c02157bb7d2.displayName;
14061
- const DialogHeader = ({ className, ...props }) => (React__default.createElement("div", { className: "tw-w-full tw-justify-between" },
14062
- React__default.createElement("div", { className: `flex flex-col space-y-1.5 text-center sm:text-left ${className}`, ...props })));
14061
+ const DialogHeader = (props) => (React__default.createElement("div", { className: "tw-w-full tw-justify-between" },
14062
+ React__default.createElement("div", { ...props })));
14063
14063
  DialogHeader.displayName = 'DialogHeader';
14064
- const DialogFooter = ({ className, ...props }) => (React__default.createElement("div", { className: `flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2 ${className}`, ...props }));
14064
+ const DialogFooter = (props) => React__default.createElement("div", { ...props });
14065
14065
  DialogFooter.displayName = 'DialogFooter';
14066
- const DialogTitle = React__default.forwardRef(({ className, ...props }, ref) => (React__default.createElement($5d3850c4d0b4e6c7$export$f99233281efd08a0, { ref: ref, className: `text-lg font-semibold leading-none tracking-tight ${className}`, ...props })));
14066
+ const DialogTitle = React__default.forwardRef((props, ref) => React__default.createElement($5d3850c4d0b4e6c7$export$f99233281efd08a0, { ref: ref, ...props }));
14067
14067
  DialogTitle.displayName = $5d3850c4d0b4e6c7$export$f99233281efd08a0.displayName;
14068
- const DialogDescription = React__default.forwardRef(({ className, ...props }, ref) => (React__default.createElement($5d3850c4d0b4e6c7$export$393edc798c47379d, { ref: ref, className: `text-sm text-muted-foreground ${className}`, ...props })));
14068
+ const DialogDescription = React__default.forwardRef((props, ref) => React__default.createElement($5d3850c4d0b4e6c7$export$393edc798c47379d, { ref: ref, ...props }));
14069
14069
  DialogDescription.displayName = $5d3850c4d0b4e6c7$export$393edc798c47379d.displayName;
14070
14070
  const Modal = ({ titleIcon, title = 'Modal title example', titleSuffixLabel, subtitle, children, open = false, onClose, customButton = false, customButtonLabel = 'Back', onClickCustomButton, submitButtonLabel = 'Submit', cancelButtonLabel = 'Cancel', disableSubmitButton = false, stopPropagationSubmitButton = false, onSubmit, isTitleEditable = false, onTitleChanged, inputExtraClassNames, hideCloseIcon = false, size = 'xl', titleIconPosition = 'left', hideFooterButtons = false, hideSubmitButton = false, hideCancelButton = false, testId = 'modal', modalFooter, dialogClassName, titlePlaceholder, titleRequired, titleError, submitButtonTooltip, cancelButtonTooltip, disableCustomButton, customHeader, middleFooterSection = React__default.createElement(React__default.Fragment, null), customButtonVariant = 'outline', keepFocusInsideModal = true, }) => {
14071
+ const [isLoading, setIsLoading] = useState(false);
14071
14072
  // the Dialog is adding pointerEvents: none to body and the dropdowns from the modal does not work anymore
14072
14073
  useEffect(() => {
14073
14074
  if (open) {
@@ -14081,6 +14082,17 @@ const Modal = ({ titleIcon, title = 'Modal title example', titleSuffixLabel, sub
14081
14082
  document.body.style.pointerEvents = 'auto';
14082
14083
  }
14083
14084
  }, [open]);
14085
+ const handleSubmit = async (e) => {
14086
+ if (!onSubmit)
14087
+ return;
14088
+ try {
14089
+ setIsLoading(true);
14090
+ await onSubmit(e);
14091
+ }
14092
+ finally {
14093
+ setIsLoading(false);
14094
+ }
14095
+ };
14084
14096
  const renderTitle = () => {
14085
14097
  let titleIconElement = React__default.createElement(React__default.Fragment, null);
14086
14098
  if (titleIcon) {
@@ -14126,7 +14138,7 @@ const Modal = ({ titleIcon, title = 'Modal title example', titleSuffixLabel, sub
14126
14138
  React__default.createElement("div", { className: "tw-flex tw-items-center" }, middleFooterSection),
14127
14139
  !hideCancelButton && (React__default.createElement(DialogClose, { asChild: true },
14128
14140
  React__default.createElement(Button, { label: cancelButtonLabel, extraClassNames: "tw-mr-5 tw-min-w-[100px]", tooltip: cancelButtonTooltip, variant: "outline", stopPropagation: false, testId: "cancelButton" }))),
14129
- !hideSubmitButton && (React__default.createElement(Button, { label: submitButtonLabel, onClick: onSubmit, disabled: disableSubmitButton, variant: "theme", stopPropagation: stopPropagationSubmitButton, tooltip: submitButtonTooltip, testId: "submitButton", extraClassNames: "tw-min-w-[100px]" })))))))))) : (React__default.createElement(React__default.Fragment, null));
14141
+ !hideSubmitButton && (React__default.createElement(Button, { label: submitButtonLabel, onClick: handleSubmit, disabled: disableSubmitButton || isLoading, variant: "theme", stopPropagation: stopPropagationSubmitButton, tooltip: submitButtonTooltip, icon: isLoading ? 'fc-loading-notch tw-animate-spin' : undefined, iconPosition: "left", testId: "submitButton", extraClassNames: "tw-min-w-[100px]" })))))))))) : (React__default.createElement(React__default.Fragment, null));
14130
14142
  };
14131
14143
 
14132
14144
  // We have resorted to returning slots directly rather than exposing primitives that can then