@bluemarble/bm-components 2.5.2 → 2.5.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.
- package/dist/index.cjs +114 -91
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +18 -3
- package/dist/index.d.ts +18 -3
- package/dist/index.js +142 -119
- package/dist/index.js.map +1 -1
- package/package.json +9 -5
package/dist/index.d.cts
CHANGED
|
@@ -404,16 +404,31 @@ interface IDialogChildrenProps {
|
|
|
404
404
|
onConfirm: (fn: (...params: any[]) => Promise<void>) => (...params: any[]) => Promise<void>;
|
|
405
405
|
onCancel: () => void;
|
|
406
406
|
}
|
|
407
|
+
type TDialogConfirmColor = Exclude<NonNullable<ButtonProps['color']>, 'inherit'>;
|
|
408
|
+
type TDialogConfirmVariant = Extract<NonNullable<ButtonProps['variant']>, 'outlined' | 'contained'>;
|
|
407
409
|
interface IDialogConfirmProps {
|
|
408
410
|
icon?: IconType;
|
|
409
411
|
title?: string;
|
|
410
412
|
body?: string;
|
|
413
|
+
/**
|
|
414
|
+
* Cor da paleta aplicada ao ícone e ao botão de confirmação.
|
|
415
|
+
* Sem valor, o ícone usa `warning` e o botão usa `primary`.
|
|
416
|
+
*/
|
|
417
|
+
color?: TDialogConfirmColor;
|
|
418
|
+
/** Estilo do botão de confirmação. */
|
|
419
|
+
variant?: TDialogConfirmVariant;
|
|
411
420
|
children: (props: IDialogChildrenProps) => ReactNode;
|
|
412
421
|
confirmButtonText?: string;
|
|
413
422
|
cancelButtonText?: string;
|
|
414
423
|
}
|
|
415
424
|
type TUseDialogConfirm = ReturnType<typeof UseDialogConfirm>;
|
|
416
|
-
|
|
425
|
+
/**
|
|
426
|
+
* Deve ser usado dentro de um `BaseDialog.Provider`.
|
|
427
|
+
* Recebe o `name` de um `BaseDialog.Create()` para controlar o diálogo,
|
|
428
|
+
* ou cria um nome próprio quando nenhum for informado.
|
|
429
|
+
*/
|
|
430
|
+
declare function UseDialogConfirm(dialogName?: symbol): {
|
|
431
|
+
name: symbol;
|
|
417
432
|
isLoading: boolean;
|
|
418
433
|
opened: boolean;
|
|
419
434
|
onConfirm: (fn: (...params: any) => Promise<any>) => (...params: any[]) => Promise<void>;
|
|
@@ -451,7 +466,7 @@ interface IBaseDialogInstanceProviderProps {
|
|
|
451
466
|
name: symbol;
|
|
452
467
|
}
|
|
453
468
|
|
|
454
|
-
interface IBaseDialogContainerProps {
|
|
469
|
+
interface IBaseDialogContainerProps extends Omit<Partial<ModalProps>, 'open' | 'children'> {
|
|
455
470
|
BoxProps?: BoxProps;
|
|
456
471
|
children: React__default.ReactNode | ((props: {
|
|
457
472
|
close: () => void;
|
|
@@ -772,4 +787,4 @@ declare function useFormHelper(): {
|
|
|
772
787
|
createAlert(message: string, type: _mui_material.AlertColor): void;
|
|
773
788
|
};
|
|
774
789
|
|
|
775
|
-
export { AlertContext, AlertProvider, ApiHelper, type AuthContextProps, AuthHelper, Autocomplete, BaseDialog, BaseDialogBody, BaseDialogContainer, BaseDialogCreate, BaseDialogTrigger, BaseGrid, BaseGridAutoRows, type BaseRequest, type BaseResponse, Checkbox, type ColumnTitleProps, type ColumnsProps, CreateAuthProvider, Dialog, DialogConfirm, DomainError, EditableTableCell, type FilterCompareType, type FilterProps, FormHelperContext, FormHelperProvider, GetInputLabel, Grid, type HandlerProps, type HelperRequest, type HelperResponse, HttpError, type IBaseDialogBodyProps, type IBaseDialogContainerProps, type IBaseDialogTriggerProps, type IDialogConfirmProps, type IFilter, Input, InputMask, LargeButton, type MethodProps, type MiddlewaresProps, Modal, type NextHandlerApiRequest, type NookiesRequest, type NookiesResponse, Radio, Select, type ServerSidePropsContext, type SortedByProps$1 as SortedByProps, Switch, type TApiHelperProps, type TApiOptions, type TUseDialogConfirm, TabPanel, type TabPanelProps, Td, Tr, UseDialogConfirm, createApiHelper, createAuthContext, createFilter, destroyCookie, filterData, getTabProps, nookies, parseCookies, setCookie, useAlert, useAsyncGrid, useBaseDialog, useBaseDialogInstance, useEvent, useFilter, useFormHelper, useGrid, useLoading };
|
|
790
|
+
export { AlertContext, AlertProvider, ApiHelper, type AuthContextProps, AuthHelper, Autocomplete, BaseDialog, BaseDialogBody, BaseDialogContainer, BaseDialogCreate, BaseDialogTrigger, BaseGrid, BaseGridAutoRows, type BaseRequest, type BaseResponse, Checkbox, type ColumnTitleProps, type ColumnsProps, CreateAuthProvider, Dialog, DialogConfirm, DomainError, EditableTableCell, type FilterCompareType, type FilterProps, FormHelperContext, FormHelperProvider, GetInputLabel, Grid, type HandlerProps, type HelperRequest, type HelperResponse, HttpError, type IBaseDialogBodyProps, type IBaseDialogContainerProps, type IBaseDialogTriggerProps, type IDialogConfirmProps, type IFilter, Input, InputMask, LargeButton, type MethodProps, type MiddlewaresProps, Modal, type NextHandlerApiRequest, type NookiesRequest, type NookiesResponse, Radio, Select, type ServerSidePropsContext, type SortedByProps$1 as SortedByProps, Switch, type TApiHelperProps, type TApiOptions, type TDialogConfirmColor, type TDialogConfirmVariant, type TUseDialogConfirm, TabPanel, type TabPanelProps, Td, Tr, UseDialogConfirm, createApiHelper, createAuthContext, createFilter, destroyCookie, filterData, getTabProps, nookies, parseCookies, setCookie, useAlert, useAsyncGrid, useBaseDialog, useBaseDialogInstance, useEvent, useFilter, useFormHelper, useGrid, useLoading };
|
package/dist/index.d.ts
CHANGED
|
@@ -404,16 +404,31 @@ interface IDialogChildrenProps {
|
|
|
404
404
|
onConfirm: (fn: (...params: any[]) => Promise<void>) => (...params: any[]) => Promise<void>;
|
|
405
405
|
onCancel: () => void;
|
|
406
406
|
}
|
|
407
|
+
type TDialogConfirmColor = Exclude<NonNullable<ButtonProps['color']>, 'inherit'>;
|
|
408
|
+
type TDialogConfirmVariant = Extract<NonNullable<ButtonProps['variant']>, 'outlined' | 'contained'>;
|
|
407
409
|
interface IDialogConfirmProps {
|
|
408
410
|
icon?: IconType;
|
|
409
411
|
title?: string;
|
|
410
412
|
body?: string;
|
|
413
|
+
/**
|
|
414
|
+
* Cor da paleta aplicada ao ícone e ao botão de confirmação.
|
|
415
|
+
* Sem valor, o ícone usa `warning` e o botão usa `primary`.
|
|
416
|
+
*/
|
|
417
|
+
color?: TDialogConfirmColor;
|
|
418
|
+
/** Estilo do botão de confirmação. */
|
|
419
|
+
variant?: TDialogConfirmVariant;
|
|
411
420
|
children: (props: IDialogChildrenProps) => ReactNode;
|
|
412
421
|
confirmButtonText?: string;
|
|
413
422
|
cancelButtonText?: string;
|
|
414
423
|
}
|
|
415
424
|
type TUseDialogConfirm = ReturnType<typeof UseDialogConfirm>;
|
|
416
|
-
|
|
425
|
+
/**
|
|
426
|
+
* Deve ser usado dentro de um `BaseDialog.Provider`.
|
|
427
|
+
* Recebe o `name` de um `BaseDialog.Create()` para controlar o diálogo,
|
|
428
|
+
* ou cria um nome próprio quando nenhum for informado.
|
|
429
|
+
*/
|
|
430
|
+
declare function UseDialogConfirm(dialogName?: symbol): {
|
|
431
|
+
name: symbol;
|
|
417
432
|
isLoading: boolean;
|
|
418
433
|
opened: boolean;
|
|
419
434
|
onConfirm: (fn: (...params: any) => Promise<any>) => (...params: any[]) => Promise<void>;
|
|
@@ -451,7 +466,7 @@ interface IBaseDialogInstanceProviderProps {
|
|
|
451
466
|
name: symbol;
|
|
452
467
|
}
|
|
453
468
|
|
|
454
|
-
interface IBaseDialogContainerProps {
|
|
469
|
+
interface IBaseDialogContainerProps extends Omit<Partial<ModalProps>, 'open' | 'children'> {
|
|
455
470
|
BoxProps?: BoxProps;
|
|
456
471
|
children: React__default.ReactNode | ((props: {
|
|
457
472
|
close: () => void;
|
|
@@ -772,4 +787,4 @@ declare function useFormHelper(): {
|
|
|
772
787
|
createAlert(message: string, type: _mui_material.AlertColor): void;
|
|
773
788
|
};
|
|
774
789
|
|
|
775
|
-
export { AlertContext, AlertProvider, ApiHelper, type AuthContextProps, AuthHelper, Autocomplete, BaseDialog, BaseDialogBody, BaseDialogContainer, BaseDialogCreate, BaseDialogTrigger, BaseGrid, BaseGridAutoRows, type BaseRequest, type BaseResponse, Checkbox, type ColumnTitleProps, type ColumnsProps, CreateAuthProvider, Dialog, DialogConfirm, DomainError, EditableTableCell, type FilterCompareType, type FilterProps, FormHelperContext, FormHelperProvider, GetInputLabel, Grid, type HandlerProps, type HelperRequest, type HelperResponse, HttpError, type IBaseDialogBodyProps, type IBaseDialogContainerProps, type IBaseDialogTriggerProps, type IDialogConfirmProps, type IFilter, Input, InputMask, LargeButton, type MethodProps, type MiddlewaresProps, Modal, type NextHandlerApiRequest, type NookiesRequest, type NookiesResponse, Radio, Select, type ServerSidePropsContext, type SortedByProps$1 as SortedByProps, Switch, type TApiHelperProps, type TApiOptions, type TUseDialogConfirm, TabPanel, type TabPanelProps, Td, Tr, UseDialogConfirm, createApiHelper, createAuthContext, createFilter, destroyCookie, filterData, getTabProps, nookies, parseCookies, setCookie, useAlert, useAsyncGrid, useBaseDialog, useBaseDialogInstance, useEvent, useFilter, useFormHelper, useGrid, useLoading };
|
|
790
|
+
export { AlertContext, AlertProvider, ApiHelper, type AuthContextProps, AuthHelper, Autocomplete, BaseDialog, BaseDialogBody, BaseDialogContainer, BaseDialogCreate, BaseDialogTrigger, BaseGrid, BaseGridAutoRows, type BaseRequest, type BaseResponse, Checkbox, type ColumnTitleProps, type ColumnsProps, CreateAuthProvider, Dialog, DialogConfirm, DomainError, EditableTableCell, type FilterCompareType, type FilterProps, FormHelperContext, FormHelperProvider, GetInputLabel, Grid, type HandlerProps, type HelperRequest, type HelperResponse, HttpError, type IBaseDialogBodyProps, type IBaseDialogContainerProps, type IBaseDialogTriggerProps, type IDialogConfirmProps, type IFilter, Input, InputMask, LargeButton, type MethodProps, type MiddlewaresProps, Modal, type NextHandlerApiRequest, type NookiesRequest, type NookiesResponse, Radio, Select, type ServerSidePropsContext, type SortedByProps$1 as SortedByProps, Switch, type TApiHelperProps, type TApiOptions, type TDialogConfirmColor, type TDialogConfirmVariant, type TUseDialogConfirm, TabPanel, type TabPanelProps, Td, Tr, UseDialogConfirm, createApiHelper, createAuthContext, createFilter, destroyCookie, filterData, getTabProps, nookies, parseCookies, setCookie, useAlert, useAsyncGrid, useBaseDialog, useBaseDialogInstance, useEvent, useFilter, useFormHelper, useGrid, useLoading };
|
package/dist/index.js
CHANGED
|
@@ -209,7 +209,7 @@ var require_react_is_development = __commonJS({
|
|
|
209
209
|
var Fragment3 = REACT_FRAGMENT_TYPE;
|
|
210
210
|
var Lazy = REACT_LAZY_TYPE;
|
|
211
211
|
var Memo = REACT_MEMO_TYPE;
|
|
212
|
-
var
|
|
212
|
+
var Portal = REACT_PORTAL_TYPE;
|
|
213
213
|
var Profiler = REACT_PROFILER_TYPE;
|
|
214
214
|
var StrictMode = REACT_STRICT_MODE_TYPE;
|
|
215
215
|
var Suspense = REACT_SUSPENSE_TYPE;
|
|
@@ -268,7 +268,7 @@ var require_react_is_development = __commonJS({
|
|
|
268
268
|
exports.Fragment = Fragment3;
|
|
269
269
|
exports.Lazy = Lazy;
|
|
270
270
|
exports.Memo = Memo;
|
|
271
|
-
exports.Portal =
|
|
271
|
+
exports.Portal = Portal;
|
|
272
272
|
exports.Profiler = Profiler;
|
|
273
273
|
exports.StrictMode = StrictMode;
|
|
274
274
|
exports.Suspense = Suspense;
|
|
@@ -2760,7 +2760,7 @@ function createBox(options = {}) {
|
|
|
2760
2760
|
const BoxRoot = styled("div", {
|
|
2761
2761
|
shouldForwardProp: (prop) => prop !== "theme" && prop !== "sx" && prop !== "as"
|
|
2762
2762
|
})(styleFunctionSx_default);
|
|
2763
|
-
const
|
|
2763
|
+
const Box8 = /* @__PURE__ */ React4.forwardRef(function Box9(inProps, ref) {
|
|
2764
2764
|
const theme = useTheme_default(defaultTheme);
|
|
2765
2765
|
const {
|
|
2766
2766
|
className,
|
|
@@ -2775,7 +2775,7 @@ function createBox(options = {}) {
|
|
|
2775
2775
|
...other
|
|
2776
2776
|
});
|
|
2777
2777
|
});
|
|
2778
|
-
return
|
|
2778
|
+
return Box8;
|
|
2779
2779
|
}
|
|
2780
2780
|
|
|
2781
2781
|
// node_modules/@mui/utils/esm/generateUtilityClass/generateUtilityClass.js
|
|
@@ -4335,111 +4335,25 @@ var Dialog = ({
|
|
|
4335
4335
|
};
|
|
4336
4336
|
|
|
4337
4337
|
// src/components/DialogConfirm/DialogConfirm.view.tsx
|
|
4338
|
-
import
|
|
4339
|
-
import {
|
|
4340
|
-
import { grey, orange } from "@mui/material/colors";
|
|
4338
|
+
import React29 from "react";
|
|
4339
|
+
import { alpha, Stack as Stack3, Typography as Typography4 } from "@mui/material";
|
|
4341
4340
|
import { MdOutlineWarningAmber } from "react-icons/md";
|
|
4342
4341
|
|
|
4343
4342
|
// src/components/DialogConfirm/DialogConfirm.model.ts
|
|
4344
|
-
import { useRef as useRef3, useState as
|
|
4345
|
-
function UseDialogConfirm() {
|
|
4346
|
-
const [opened, setOpened] = useState4(false);
|
|
4347
|
-
const [isLoading, setLoading] = useState4(false);
|
|
4348
|
-
const onConfirmFn = useRef3(async () => {
|
|
4349
|
-
});
|
|
4350
|
-
const paramsFn = useRef3([]);
|
|
4351
|
-
const onConfirm = (fn) => {
|
|
4352
|
-
onConfirmFn.current = fn;
|
|
4353
|
-
return async (...params) => {
|
|
4354
|
-
paramsFn.current = params;
|
|
4355
|
-
setOpened(true);
|
|
4356
|
-
};
|
|
4357
|
-
};
|
|
4358
|
-
const onProceed = async (event) => {
|
|
4359
|
-
event?.preventDefault();
|
|
4360
|
-
event?.stopPropagation();
|
|
4361
|
-
setLoading(true);
|
|
4362
|
-
try {
|
|
4363
|
-
if (!onConfirmFn.current) return;
|
|
4364
|
-
await onConfirmFn.current(...paramsFn.current);
|
|
4365
|
-
} finally {
|
|
4366
|
-
setOpened(false);
|
|
4367
|
-
setLoading(false);
|
|
4368
|
-
}
|
|
4369
|
-
};
|
|
4370
|
-
const onCancel = (event) => {
|
|
4371
|
-
event?.preventDefault();
|
|
4372
|
-
event?.stopPropagation();
|
|
4373
|
-
setOpened(false);
|
|
4374
|
-
};
|
|
4375
|
-
const onCloseModal = () => {
|
|
4376
|
-
if (isLoading) return;
|
|
4377
|
-
setOpened(false);
|
|
4378
|
-
};
|
|
4379
|
-
return {
|
|
4380
|
-
isLoading,
|
|
4381
|
-
opened,
|
|
4382
|
-
onConfirm,
|
|
4383
|
-
onCloseModal,
|
|
4384
|
-
onCancel,
|
|
4385
|
-
onProceed
|
|
4386
|
-
};
|
|
4387
|
-
}
|
|
4388
|
-
|
|
4389
|
-
// src/components/DialogConfirm/DialogConfirm.view.tsx
|
|
4390
|
-
var DEFAULT_ICON = MdOutlineWarningAmber;
|
|
4391
|
-
var DialogConfirm = (props) => {
|
|
4392
|
-
const model = UseDialogConfirm();
|
|
4393
|
-
const Icon = props.icon || DEFAULT_ICON;
|
|
4394
|
-
return /* @__PURE__ */ React25.createElement(React25.Fragment, null, props.children({
|
|
4395
|
-
onConfirm: model.onConfirm,
|
|
4396
|
-
onCancel: model.onCancel
|
|
4397
|
-
}), /* @__PURE__ */ React25.createElement(Portal, null, /* @__PURE__ */ React25.createElement(Modal, { open: model.opened, onClose: model.onCloseModal }, /* @__PURE__ */ React25.createElement(Box7, { sx: { p: 2, maxWidth: 400, textAlign: "center" } }, /* @__PURE__ */ React25.createElement(
|
|
4398
|
-
Stack2,
|
|
4399
|
-
{
|
|
4400
|
-
mx: "auto",
|
|
4401
|
-
color: orange[800],
|
|
4402
|
-
bgcolor: orange[50],
|
|
4403
|
-
borderRadius: "50%",
|
|
4404
|
-
height: 8 * 5,
|
|
4405
|
-
width: 8 * 5,
|
|
4406
|
-
direction: "row",
|
|
4407
|
-
justifyContent: "center",
|
|
4408
|
-
alignItems: "center"
|
|
4409
|
-
},
|
|
4410
|
-
/* @__PURE__ */ React25.createElement(Icon, { size: 8 * 3 })
|
|
4411
|
-
), /* @__PURE__ */ React25.createElement(Typography3, { fontWeight: "bold", variant: "h6", mt: 1 }, props.title || "Aten\xE7\xE3o"), /* @__PURE__ */ React25.createElement(Typography3, { my: 1 }, props.body || "Tem certeza que deseja realizar essa a\xE7\xE3o?"), /* @__PURE__ */ React25.createElement(Stack2, { gap: 1, mt: 3, color: grey[600] }, /* @__PURE__ */ React25.createElement(
|
|
4412
|
-
LargeButton,
|
|
4413
|
-
{
|
|
4414
|
-
color: "warning",
|
|
4415
|
-
loading: model.isLoading,
|
|
4416
|
-
onClick: model.onProceed
|
|
4417
|
-
},
|
|
4418
|
-
props.confirmButtonText || "Confirmar"
|
|
4419
|
-
), /* @__PURE__ */ React25.createElement(
|
|
4420
|
-
LargeButton,
|
|
4421
|
-
{
|
|
4422
|
-
variant: "outlined",
|
|
4423
|
-
disabled: model.isLoading,
|
|
4424
|
-
onClick: model.onCancel,
|
|
4425
|
-
color: "inherit"
|
|
4426
|
-
},
|
|
4427
|
-
props.cancelButtonText || "Cancelar"
|
|
4428
|
-
))))));
|
|
4429
|
-
};
|
|
4343
|
+
import { useMemo as useMemo3, useRef as useRef3, useState as useState5 } from "react";
|
|
4430
4344
|
|
|
4431
4345
|
// src/components/BaseDialog/BaseDialog.tsx
|
|
4432
|
-
import
|
|
4346
|
+
import React28 from "react";
|
|
4433
4347
|
|
|
4434
4348
|
// src/components/BaseDialog/BaseDialogHook.ts
|
|
4435
4349
|
import { useContext as useContext2 } from "react";
|
|
4436
4350
|
|
|
4437
4351
|
// src/components/BaseDialog/BaseDialogContext.tsx
|
|
4438
|
-
import
|
|
4439
|
-
import { createContext, useCallback, useState as
|
|
4352
|
+
import React25 from "react";
|
|
4353
|
+
import { createContext, useCallback, useState as useState4 } from "react";
|
|
4440
4354
|
var BaseDialogContext = createContext({});
|
|
4441
4355
|
var BaseDialogProvider = (props) => {
|
|
4442
|
-
const [openedDialogs, setOpenedDialogs] =
|
|
4356
|
+
const [openedDialogs, setOpenedDialogs] = useState4([]);
|
|
4443
4357
|
const isOpened = useCallback(
|
|
4444
4358
|
(dialog) => {
|
|
4445
4359
|
return openedDialogs.includes(dialog);
|
|
@@ -4464,7 +4378,7 @@ var BaseDialogProvider = (props) => {
|
|
|
4464
4378
|
const closeAllDialogs = useCallback(() => {
|
|
4465
4379
|
return setOpenedDialogs([]);
|
|
4466
4380
|
}, [openedDialogs]);
|
|
4467
|
-
return /* @__PURE__ */
|
|
4381
|
+
return /* @__PURE__ */ React25.createElement(
|
|
4468
4382
|
BaseDialogContext.Provider,
|
|
4469
4383
|
{
|
|
4470
4384
|
value: {
|
|
@@ -4481,14 +4395,14 @@ var BaseDialogProvider = (props) => {
|
|
|
4481
4395
|
};
|
|
4482
4396
|
|
|
4483
4397
|
// src/components/BaseDialog/BaseDialogInstanceContext.tsx
|
|
4484
|
-
import
|
|
4398
|
+
import React26 from "react";
|
|
4485
4399
|
import { createContext as createContext2 } from "react";
|
|
4486
4400
|
var BaseDialogInstanceContext = createContext2(
|
|
4487
4401
|
{}
|
|
4488
4402
|
);
|
|
4489
4403
|
var BaseDialogInstanceProvider = (props) => {
|
|
4490
4404
|
const actions = useBaseDialog();
|
|
4491
|
-
return /* @__PURE__ */
|
|
4405
|
+
return /* @__PURE__ */ React26.createElement(BaseDialogInstanceContext.Provider, { value: { name: props.name, actions } }, props.children);
|
|
4492
4406
|
};
|
|
4493
4407
|
|
|
4494
4408
|
// src/components/BaseDialog/BaseDialogHook.ts
|
|
@@ -4500,14 +4414,18 @@ function useBaseDialogInstance() {
|
|
|
4500
4414
|
}
|
|
4501
4415
|
|
|
4502
4416
|
// src/components/BaseDialog/BaseDialog.tsx
|
|
4503
|
-
import {
|
|
4417
|
+
import {
|
|
4418
|
+
Box as Box7,
|
|
4419
|
+
Button as Button4,
|
|
4420
|
+
Modal as Modal2
|
|
4421
|
+
} from "@mui/material";
|
|
4504
4422
|
|
|
4505
4423
|
// src/components/BaseDialog/BaseDialogHeader.tsx
|
|
4506
|
-
import
|
|
4424
|
+
import React27 from "react";
|
|
4507
4425
|
import {
|
|
4508
4426
|
IconButton as IconButton4,
|
|
4509
|
-
Stack as
|
|
4510
|
-
Typography as
|
|
4427
|
+
Stack as Stack2,
|
|
4428
|
+
Typography as Typography3
|
|
4511
4429
|
} from "@mui/material";
|
|
4512
4430
|
import { MdClose as MdClose2 } from "react-icons/md";
|
|
4513
4431
|
var BaseDialogHeader = ({
|
|
@@ -4523,8 +4441,8 @@ var BaseDialogHeader = ({
|
|
|
4523
4441
|
if (onClose) return onClose();
|
|
4524
4442
|
closeDialog(name);
|
|
4525
4443
|
}
|
|
4526
|
-
return /* @__PURE__ */
|
|
4527
|
-
|
|
4444
|
+
return /* @__PURE__ */ React27.createElement(
|
|
4445
|
+
Stack2,
|
|
4528
4446
|
{
|
|
4529
4447
|
direction: "row",
|
|
4530
4448
|
alignItems: "center",
|
|
@@ -4533,8 +4451,8 @@ var BaseDialogHeader = ({
|
|
|
4533
4451
|
my: 1,
|
|
4534
4452
|
...props
|
|
4535
4453
|
},
|
|
4536
|
-
/* @__PURE__ */
|
|
4537
|
-
/* @__PURE__ */
|
|
4454
|
+
/* @__PURE__ */ React27.createElement(Typography3, { variant: "h6", fontWeight: "bold", ...TypographyProps2 }, title),
|
|
4455
|
+
/* @__PURE__ */ React27.createElement(IconButton4, { ...IconButtonProps, onClick: handleClose }, /* @__PURE__ */ React27.createElement(MdClose2, null))
|
|
4538
4456
|
);
|
|
4539
4457
|
};
|
|
4540
4458
|
|
|
@@ -4546,9 +4464,9 @@ var BaseDialogContainer = ({
|
|
|
4546
4464
|
}) => {
|
|
4547
4465
|
const { name } = useBaseDialogInstance();
|
|
4548
4466
|
const { isOpened, close: closeDialog } = useBaseDialog();
|
|
4549
|
-
const close =
|
|
4550
|
-
return /* @__PURE__ */
|
|
4551
|
-
|
|
4467
|
+
const close = React28.useCallback(() => closeDialog(name), [closeDialog, name]);
|
|
4468
|
+
return /* @__PURE__ */ React28.createElement(Modal2, { open: isOpened(name), onClose: close, ...rest }, /* @__PURE__ */ React28.createElement(
|
|
4469
|
+
Box7,
|
|
4552
4470
|
{
|
|
4553
4471
|
...BoxProps3,
|
|
4554
4472
|
sx: {
|
|
@@ -4566,7 +4484,7 @@ var BaseDialogContainer = ({
|
|
|
4566
4484
|
));
|
|
4567
4485
|
};
|
|
4568
4486
|
var BaseDialogBody = (props) => {
|
|
4569
|
-
return /* @__PURE__ */
|
|
4487
|
+
return /* @__PURE__ */ React28.createElement(Box7, { px: 2, pb: 2, width: "100vw", maxWidth: 650, ...props }, props.children);
|
|
4570
4488
|
};
|
|
4571
4489
|
var BaseDialogTrigger = ({
|
|
4572
4490
|
name,
|
|
@@ -4574,7 +4492,7 @@ var BaseDialogTrigger = ({
|
|
|
4574
4492
|
...props
|
|
4575
4493
|
}) => {
|
|
4576
4494
|
const { open } = useBaseDialog();
|
|
4577
|
-
return /* @__PURE__ */
|
|
4495
|
+
return /* @__PURE__ */ React28.createElement(
|
|
4578
4496
|
Button4,
|
|
4579
4497
|
{
|
|
4580
4498
|
...props,
|
|
@@ -4589,8 +4507,8 @@ var BaseDialogTrigger = ({
|
|
|
4589
4507
|
var BaseDialogCreate = (name = /* @__PURE__ */ Symbol()) => {
|
|
4590
4508
|
return {
|
|
4591
4509
|
name,
|
|
4592
|
-
Trigger: (props) => /* @__PURE__ */
|
|
4593
|
-
Root: (props) => /* @__PURE__ */
|
|
4510
|
+
Trigger: (props) => /* @__PURE__ */ React28.createElement(BaseDialogTrigger, { name, ...props }),
|
|
4511
|
+
Root: (props) => /* @__PURE__ */ React28.createElement(BaseDialogInstanceProvider, { name, ...props }),
|
|
4594
4512
|
Container: BaseDialogContainer,
|
|
4595
4513
|
Header: BaseDialogHeader,
|
|
4596
4514
|
Body: BaseDialogBody
|
|
@@ -4606,6 +4524,111 @@ var BaseDialog = {
|
|
|
4606
4524
|
Body: BaseDialogBody
|
|
4607
4525
|
};
|
|
4608
4526
|
|
|
4527
|
+
// src/components/DialogConfirm/DialogConfirm.model.ts
|
|
4528
|
+
function UseDialogConfirm(dialogName) {
|
|
4529
|
+
const { isOpened, open, close } = useBaseDialog();
|
|
4530
|
+
const name = useMemo3(
|
|
4531
|
+
() => dialogName || /* @__PURE__ */ Symbol("DialogConfirm"),
|
|
4532
|
+
[dialogName]
|
|
4533
|
+
);
|
|
4534
|
+
const [isLoading, setLoading] = useState5(false);
|
|
4535
|
+
const onConfirmFn = useRef3(async () => {
|
|
4536
|
+
});
|
|
4537
|
+
const paramsFn = useRef3([]);
|
|
4538
|
+
const onConfirm = (fn) => {
|
|
4539
|
+
onConfirmFn.current = fn;
|
|
4540
|
+
return async (...params) => {
|
|
4541
|
+
paramsFn.current = params;
|
|
4542
|
+
open(name);
|
|
4543
|
+
};
|
|
4544
|
+
};
|
|
4545
|
+
const onProceed = async (event) => {
|
|
4546
|
+
event?.preventDefault();
|
|
4547
|
+
event?.stopPropagation();
|
|
4548
|
+
setLoading(true);
|
|
4549
|
+
try {
|
|
4550
|
+
if (!onConfirmFn.current) return;
|
|
4551
|
+
await onConfirmFn.current(...paramsFn.current);
|
|
4552
|
+
} finally {
|
|
4553
|
+
close(name);
|
|
4554
|
+
setLoading(false);
|
|
4555
|
+
}
|
|
4556
|
+
};
|
|
4557
|
+
const onCancel = (event) => {
|
|
4558
|
+
event?.preventDefault();
|
|
4559
|
+
event?.stopPropagation();
|
|
4560
|
+
close(name);
|
|
4561
|
+
};
|
|
4562
|
+
const onCloseModal = () => {
|
|
4563
|
+
if (isLoading) return;
|
|
4564
|
+
close(name);
|
|
4565
|
+
};
|
|
4566
|
+
return {
|
|
4567
|
+
name,
|
|
4568
|
+
isLoading,
|
|
4569
|
+
opened: isOpened(name),
|
|
4570
|
+
onConfirm,
|
|
4571
|
+
onCloseModal,
|
|
4572
|
+
onCancel,
|
|
4573
|
+
onProceed
|
|
4574
|
+
};
|
|
4575
|
+
}
|
|
4576
|
+
|
|
4577
|
+
// src/components/DialogConfirm/DialogConfirm.view.tsx
|
|
4578
|
+
var DEFAULT_ICON = MdOutlineWarningAmber;
|
|
4579
|
+
var DEFAULT_ICON_COLOR = "warning";
|
|
4580
|
+
var DEFAULT_BUTTON_COLOR = "primary";
|
|
4581
|
+
var DEFAULT_VARIANT = "contained";
|
|
4582
|
+
var DialogConfirmContent = (props) => {
|
|
4583
|
+
const dialog = React29.useMemo(() => BaseDialog.Create(), []);
|
|
4584
|
+
const model = UseDialogConfirm(dialog.name);
|
|
4585
|
+
const Icon = props.icon || DEFAULT_ICON;
|
|
4586
|
+
const iconColor = props.color || DEFAULT_ICON_COLOR;
|
|
4587
|
+
const buttonColor = props.color || DEFAULT_BUTTON_COLOR;
|
|
4588
|
+
const variant = props.variant || DEFAULT_VARIANT;
|
|
4589
|
+
return /* @__PURE__ */ React29.createElement(React29.Fragment, null, props.children({
|
|
4590
|
+
onConfirm: model.onConfirm,
|
|
4591
|
+
onCancel: model.onCancel
|
|
4592
|
+
}), /* @__PURE__ */ React29.createElement(dialog.Root, null, /* @__PURE__ */ React29.createElement(dialog.Container, { onClose: model.onCloseModal }, /* @__PURE__ */ React29.createElement(dialog.Body, { pt: 2, maxWidth: 400, textAlign: "center" }, /* @__PURE__ */ React29.createElement(
|
|
4593
|
+
Stack3,
|
|
4594
|
+
{
|
|
4595
|
+
mx: "auto",
|
|
4596
|
+
borderRadius: "50%",
|
|
4597
|
+
height: 8 * 5,
|
|
4598
|
+
width: 8 * 5,
|
|
4599
|
+
direction: "row",
|
|
4600
|
+
justifyContent: "center",
|
|
4601
|
+
alignItems: "center",
|
|
4602
|
+
sx: (theme) => {
|
|
4603
|
+
const { main } = theme.palette[iconColor];
|
|
4604
|
+
return { color: main, bgcolor: alpha(main, 0.12) };
|
|
4605
|
+
}
|
|
4606
|
+
},
|
|
4607
|
+
/* @__PURE__ */ React29.createElement(Icon, { size: 8 * 3 })
|
|
4608
|
+
), /* @__PURE__ */ React29.createElement(Typography4, { fontWeight: "bold", variant: "h6", mt: 1 }, props.title || "Aten\xE7\xE3o"), /* @__PURE__ */ React29.createElement(Typography4, { my: 1 }, props.body || "Tem certeza que deseja realizar essa a\xE7\xE3o?"), /* @__PURE__ */ React29.createElement(Stack3, { gap: 1, mt: 3, color: "text.secondary" }, /* @__PURE__ */ React29.createElement(
|
|
4609
|
+
LargeButton,
|
|
4610
|
+
{
|
|
4611
|
+
color: buttonColor,
|
|
4612
|
+
variant,
|
|
4613
|
+
loading: model.isLoading,
|
|
4614
|
+
onClick: model.onProceed
|
|
4615
|
+
},
|
|
4616
|
+
props.confirmButtonText || "Confirmar"
|
|
4617
|
+
), /* @__PURE__ */ React29.createElement(
|
|
4618
|
+
LargeButton,
|
|
4619
|
+
{
|
|
4620
|
+
variant: "outlined",
|
|
4621
|
+
disabled: model.isLoading,
|
|
4622
|
+
onClick: model.onCancel,
|
|
4623
|
+
color: "inherit"
|
|
4624
|
+
},
|
|
4625
|
+
props.cancelButtonText || "Cancelar"
|
|
4626
|
+
))))));
|
|
4627
|
+
};
|
|
4628
|
+
var DialogConfirm = (props) => {
|
|
4629
|
+
return /* @__PURE__ */ React29.createElement(BaseDialog.Provider, null, /* @__PURE__ */ React29.createElement(DialogConfirmContent, { ...props }));
|
|
4630
|
+
};
|
|
4631
|
+
|
|
4609
4632
|
// src/contexts/FormHelperProvider.tsx
|
|
4610
4633
|
import React30 from "react";
|
|
4611
4634
|
import { createContext as createContext3 } from "react";
|
|
@@ -4690,7 +4713,7 @@ import {
|
|
|
4690
4713
|
} from "react";
|
|
4691
4714
|
|
|
4692
4715
|
// src/hooks/useGrid.ts
|
|
4693
|
-
import { useCallback as useCallback4, useEffect as useEffect4, useMemo as
|
|
4716
|
+
import { useCallback as useCallback4, useEffect as useEffect4, useMemo as useMemo4, useState as useState8 } from "react";
|
|
4694
4717
|
|
|
4695
4718
|
// src/hooks/useFilter.ts
|
|
4696
4719
|
import { useCallback as useCallback3, useState as useState7 } from "react";
|
|
@@ -4893,13 +4916,13 @@ function useGrid({
|
|
|
4893
4916
|
},
|
|
4894
4917
|
[currentPage]
|
|
4895
4918
|
);
|
|
4896
|
-
const orderedData =
|
|
4919
|
+
const orderedData = useMemo4(() => {
|
|
4897
4920
|
if (sortedBy.length === 0) return defaultData;
|
|
4898
4921
|
const newData = defaultData.slice(0);
|
|
4899
4922
|
const sortedData = sortData(newData);
|
|
4900
4923
|
return sortedData;
|
|
4901
4924
|
}, [defaultData, sortData, sortedBy]);
|
|
4902
|
-
const filteredData =
|
|
4925
|
+
const filteredData = useMemo4(() => {
|
|
4903
4926
|
let newData = orderedData.slice(0);
|
|
4904
4927
|
if (search && search.value !== "") {
|
|
4905
4928
|
const searchBy = createSearch(search);
|
|
@@ -4909,7 +4932,7 @@ function useGrid({
|
|
|
4909
4932
|
const newFilter = createFilter(filters);
|
|
4910
4933
|
return newData.filter(newFilter.apply);
|
|
4911
4934
|
}, [orderedData, search, filters]);
|
|
4912
|
-
const paginatedData =
|
|
4935
|
+
const paginatedData = useMemo4(() => {
|
|
4913
4936
|
const startPage = currentPage * rowsPerPage;
|
|
4914
4937
|
const endPage = startPage + rowsPerPage;
|
|
4915
4938
|
return filteredData.slice(startPage, endPage);
|