@bluemarble/bm-components 2.5.0 → 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 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 Portal2 = REACT_PORTAL_TYPE;
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 = Portal2;
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 Box9 = /* @__PURE__ */ React4.forwardRef(function Box10(inProps, ref) {
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 Box9;
2778
+ return Box8;
2779
2779
  }
2780
2780
 
2781
2781
  // node_modules/@mui/utils/esm/generateUtilityClass/generateUtilityClass.js
@@ -4337,96 +4337,10 @@ var Dialog = ({
4337
4337
  // src/components/DialogConfirm/DialogConfirm.view.tsx
4338
4338
 
4339
4339
 
4340
- var _colors = require('@mui/material/colors');
4341
4340
 
4342
4341
 
4343
4342
  // src/components/DialogConfirm/DialogConfirm.model.ts
4344
4343
 
4345
- function UseDialogConfirm() {
4346
- const [opened, setOpened] = _react.useState.call(void 0, false);
4347
- const [isLoading, setLoading] = _react.useState.call(void 0, false);
4348
- const onConfirmFn = _react.useRef.call(void 0, async () => {
4349
- });
4350
- const paramsFn = _react.useRef.call(void 0, []);
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
- _optionalChain([event, 'optionalAccess', _82 => _82.preventDefault, 'call', _83 => _83()]);
4360
- _optionalChain([event, 'optionalAccess', _84 => _84.stopPropagation, 'call', _85 => _85()]);
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
- _optionalChain([event, 'optionalAccess', _86 => _86.preventDefault, 'call', _87 => _87()]);
4372
- _optionalChain([event, 'optionalAccess', _88 => _88.stopPropagation, 'call', _89 => _89()]);
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 = _md.MdOutlineWarningAmber;
4391
- var DialogConfirm = (props) => {
4392
- const model = UseDialogConfirm();
4393
- const Icon = props.icon || DEFAULT_ICON;
4394
- return /* @__PURE__ */ React2.default.createElement(React2.default.Fragment, null, props.children({
4395
- onConfirm: model.onConfirm,
4396
- onCancel: model.onCancel
4397
- }), /* @__PURE__ */ React2.default.createElement(_material.Portal, null, /* @__PURE__ */ React2.default.createElement(Modal, { open: model.opened, onClose: model.onCloseModal }, /* @__PURE__ */ React2.default.createElement(_material.Box, { sx: { p: 2, maxWidth: 400, textAlign: "center" } }, /* @__PURE__ */ React2.default.createElement(
4398
- _material.Stack,
4399
- {
4400
- mx: "auto",
4401
- color: _colors.orange[800],
4402
- bgcolor: _colors.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__ */ React2.default.createElement(Icon, { size: 8 * 3 })
4411
- ), /* @__PURE__ */ React2.default.createElement(_material.Typography, { fontWeight: "bold", variant: "h6", mt: 1 }, props.title || "Aten\xE7\xE3o"), /* @__PURE__ */ React2.default.createElement(_material.Typography, { my: 1 }, props.body || "Tem certeza que deseja realizar essa a\xE7\xE3o?"), /* @__PURE__ */ React2.default.createElement(_material.Stack, { gap: 1, mt: 3, color: _colors.grey[600] }, /* @__PURE__ */ React2.default.createElement(
4412
- LargeButton,
4413
- {
4414
- color: "warning",
4415
- loading: model.isLoading,
4416
- onClick: model.onProceed
4417
- },
4418
- props.confirmButtonText || "Confirmar"
4419
- ), /* @__PURE__ */ React2.default.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
- };
4430
4344
 
4431
4345
  // src/components/BaseDialog/BaseDialog.tsx
4432
4346
 
@@ -4502,6 +4416,10 @@ function useBaseDialogInstance() {
4502
4416
  // src/components/BaseDialog/BaseDialog.tsx
4503
4417
 
4504
4418
 
4419
+
4420
+
4421
+
4422
+
4505
4423
  // src/components/BaseDialog/BaseDialogHeader.tsx
4506
4424
 
4507
4425
 
@@ -4546,7 +4464,8 @@ var BaseDialogContainer = ({
4546
4464
  }) => {
4547
4465
  const { name } = useBaseDialogInstance();
4548
4466
  const { isOpened, close: closeDialog } = useBaseDialog();
4549
- return /* @__PURE__ */ React2.default.createElement(_material.Modal, { open: isOpened(name), onClose: () => closeDialog(name), ...rest }, /* @__PURE__ */ React2.default.createElement(
4467
+ const close = React2.default.useCallback(() => closeDialog(name), [closeDialog, name]);
4468
+ return /* @__PURE__ */ React2.default.createElement(_material.Modal, { open: isOpened(name), onClose: close, ...rest }, /* @__PURE__ */ React2.default.createElement(
4550
4469
  _material.Box,
4551
4470
  {
4552
4471
  ...BoxProps3,
@@ -4558,10 +4477,10 @@ var BaseDialogContainer = ({
4558
4477
  left: "50%",
4559
4478
  transform: "translate(-50%, -50%)",
4560
4479
  borderRadius: 1,
4561
- ..._optionalChain([BoxProps3, 'optionalAccess', _90 => _90.sx])
4480
+ ..._optionalChain([BoxProps3, 'optionalAccess', _82 => _82.sx])
4562
4481
  }
4563
4482
  },
4564
- children
4483
+ typeof children === "function" ? children({ close }) : children
4565
4484
  ));
4566
4485
  };
4567
4486
  var BaseDialogBody = (props) => {
@@ -4605,6 +4524,111 @@ var BaseDialog = {
4605
4524
  Body: BaseDialogBody
4606
4525
  };
4607
4526
 
4527
+ // src/components/DialogConfirm/DialogConfirm.model.ts
4528
+ function UseDialogConfirm(dialogName) {
4529
+ const { isOpened, open, close } = useBaseDialog();
4530
+ const name = _react.useMemo.call(void 0,
4531
+ () => dialogName || /* @__PURE__ */ Symbol("DialogConfirm"),
4532
+ [dialogName]
4533
+ );
4534
+ const [isLoading, setLoading] = _react.useState.call(void 0, false);
4535
+ const onConfirmFn = _react.useRef.call(void 0, async () => {
4536
+ });
4537
+ const paramsFn = _react.useRef.call(void 0, []);
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
+ _optionalChain([event, 'optionalAccess', _83 => _83.preventDefault, 'call', _84 => _84()]);
4547
+ _optionalChain([event, 'optionalAccess', _85 => _85.stopPropagation, 'call', _86 => _86()]);
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
+ _optionalChain([event, 'optionalAccess', _87 => _87.preventDefault, 'call', _88 => _88()]);
4559
+ _optionalChain([event, 'optionalAccess', _89 => _89.stopPropagation, 'call', _90 => _90()]);
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 = _md.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 = React2.default.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__ */ React2.default.createElement(React2.default.Fragment, null, props.children({
4590
+ onConfirm: model.onConfirm,
4591
+ onCancel: model.onCancel
4592
+ }), /* @__PURE__ */ React2.default.createElement(dialog.Root, null, /* @__PURE__ */ React2.default.createElement(dialog.Container, { onClose: model.onCloseModal }, /* @__PURE__ */ React2.default.createElement(dialog.Body, { pt: 2, maxWidth: 400, textAlign: "center" }, /* @__PURE__ */ React2.default.createElement(
4593
+ _material.Stack,
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: _material.alpha.call(void 0, main, 0.12) };
4605
+ }
4606
+ },
4607
+ /* @__PURE__ */ React2.default.createElement(Icon, { size: 8 * 3 })
4608
+ ), /* @__PURE__ */ React2.default.createElement(_material.Typography, { fontWeight: "bold", variant: "h6", mt: 1 }, props.title || "Aten\xE7\xE3o"), /* @__PURE__ */ React2.default.createElement(_material.Typography, { my: 1 }, props.body || "Tem certeza que deseja realizar essa a\xE7\xE3o?"), /* @__PURE__ */ React2.default.createElement(_material.Stack, { gap: 1, mt: 3, color: "text.secondary" }, /* @__PURE__ */ React2.default.createElement(
4609
+ LargeButton,
4610
+ {
4611
+ color: buttonColor,
4612
+ variant,
4613
+ loading: model.isLoading,
4614
+ onClick: model.onProceed
4615
+ },
4616
+ props.confirmButtonText || "Confirmar"
4617
+ ), /* @__PURE__ */ React2.default.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__ */ React2.default.createElement(BaseDialog.Provider, null, /* @__PURE__ */ React2.default.createElement(DialogConfirmContent, { ...props }));
4630
+ };
4631
+
4608
4632
  // src/contexts/FormHelperProvider.tsx
4609
4633
 
4610
4634