chore: update prettier configuration for print width (#519)
* feat: update prettier configuration for print width * chore: apply code formatting to entire repository * fix: remove build files * fix: format issue --------- Co-authored-by: Meier Lukas <meierschlumpf@gmail.com>
This commit is contained in:
@@ -1,15 +1,7 @@
|
||||
"use client";
|
||||
|
||||
import type { PropsWithChildren } from "react";
|
||||
import {
|
||||
createContext,
|
||||
useCallback,
|
||||
useContext,
|
||||
useEffect,
|
||||
useReducer,
|
||||
useRef,
|
||||
useState,
|
||||
} from "react";
|
||||
import { createContext, useCallback, useContext, useEffect, useReducer, useRef, useState } from "react";
|
||||
import { getDefaultZIndex, Modal } from "@mantine/core";
|
||||
import { randomId } from "@mantine/hooks";
|
||||
|
||||
@@ -76,19 +68,12 @@ export const ModalProvider = ({ children }: PropsWithChildren) => {
|
||||
[closeModal, state.current?.id],
|
||||
);
|
||||
|
||||
const activeModals = state.modals.filter(
|
||||
(modal) => modal.id === state.current?.id || modal.props.keepMounted,
|
||||
);
|
||||
const activeModals = state.modals.filter((modal) => modal.id === state.current?.id || modal.props.keepMounted);
|
||||
|
||||
return (
|
||||
<ModalContext.Provider value={{ openModalInner, closeModal }}>
|
||||
{activeModals.map((modal) => (
|
||||
<ActiveModal
|
||||
key={modal.id}
|
||||
modal={modal}
|
||||
state={state}
|
||||
handleCloseModal={handleCloseModal}
|
||||
/>
|
||||
<ActiveModal key={modal.id} modal={modal} state={state} handleCloseModal={handleCloseModal} />
|
||||
))}
|
||||
|
||||
{children}
|
||||
@@ -112,8 +97,7 @@ const ActiveModal = ({ modal, state, handleCloseModal }: ActiveModalProps) => {
|
||||
setTimeout(() => setOpened(true), 0);
|
||||
}, []);
|
||||
|
||||
const { defaultTitle: _ignored, ...otherModalProps } =
|
||||
modal.reference.modalProps;
|
||||
const { defaultTitle: _ignored, ...otherModalProps } = modal.reference.modalProps;
|
||||
|
||||
return (
|
||||
<Modal
|
||||
@@ -145,18 +129,13 @@ interface OpenModalOptions {
|
||||
title?: stringOrTranslation;
|
||||
}
|
||||
|
||||
export const useModalAction = <TModal extends ModalDefinition>(
|
||||
modal: TModal,
|
||||
) => {
|
||||
export const useModalAction = <TModal extends ModalDefinition>(modal: TModal) => {
|
||||
const context = useContext(ModalContext);
|
||||
|
||||
if (!context) throw new Error("ModalContext is not provided");
|
||||
|
||||
return {
|
||||
openModal: (
|
||||
innerProps: inferInnerProps<TModal>,
|
||||
options: OpenModalOptions | void,
|
||||
) => {
|
||||
openModal: (innerProps: inferInnerProps<TModal>, options: OpenModalOptions | void) => {
|
||||
context.openModalInner({ modal, innerProps, options: options ?? {} });
|
||||
},
|
||||
};
|
||||
@@ -166,7 +145,6 @@ export const useConfirmModal = () => {
|
||||
const { openModal } = useModalAction(ConfirmModal);
|
||||
|
||||
return {
|
||||
openConfirmModal: (props: ConfirmModalProps) =>
|
||||
openModal(props, { title: props.title }),
|
||||
openConfirmModal: (props: ConfirmModalProps) => openModal(props, { title: props.title }),
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user