@greatapps/common 1.1.776 → 1.1.778

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,7 +1,8 @@
1
1
  'use client';
2
2
 
3
- import { ComponentType } from 'react';
3
+ import { ComponentType, useContext } from 'react';
4
4
  import { useModalManager } from '../../store/useModalManager';
5
+ import { DialogDepthContext } from '../ui/overlay/layers';
5
6
 
6
7
  interface ModalManagerProps {
7
8
  registry: Record<string, ComponentType>;
@@ -9,12 +10,17 @@ interface ModalManagerProps {
9
10
 
10
11
  export function ModalManager({ registry }: ModalManagerProps) {
11
12
  const { modalStack } = useModalManager();
13
+ const depth = useContext(DialogDepthContext);
12
14
 
13
15
  if (modalStack.length === 0) return null;
14
16
 
17
+ // Modais da pilha nascem irmaos na arvore React: sem isso, todos cairiam na
18
+ // mesma profundidade e na mesma faixa de z-index (ver layers.tsx). A
19
+ // posicao na pilha vira a profundidade, relativa a onde o ModalManager
20
+ // esta montado.
15
21
  return (
16
22
  <>
17
- {modalStack.map((modal) => {
23
+ {modalStack.map((modal, index) => {
18
24
  const ModalComponent = registry[modal.key];
19
25
 
20
26
  if (!ModalComponent) {
@@ -22,7 +28,11 @@ export function ModalManager({ registry }: ModalManagerProps) {
22
28
  return null;
23
29
  }
24
30
 
25
- return <ModalComponent key={modal.key} />;
31
+ return (
32
+ <DialogDepthContext.Provider value={depth + index} key={modal.key}>
33
+ <ModalComponent />
34
+ </DialogDepthContext.Provider>
35
+ );
26
36
  })}
27
37
  </>
28
38
  );
@@ -8,6 +8,7 @@ import {
8
8
  DialogHeader,
9
9
  DialogTitle,
10
10
  } from '../../ui/overlay/Dialog'
11
+ import { DialogLayer } from '../../ui/overlay/layers'
11
12
  import { Button } from '../../ui/buttons/Button'
12
13
 
13
14
  interface ImageTooSmallModalProps {
@@ -33,30 +34,30 @@ export function ImageTooSmallModal({
33
34
  const dimensionText = `${minWidth}x${minHeight}px`
34
35
 
35
36
  return (
36
- <Dialog open={open} onOpenChange={onOpenChange}>
37
- <DialogContent
38
- className="w-full md:w-[480px]! lg:w-[480px]! max-w-[480px]! max-[480px]:w-[calc(100%-32px)] p-0 gap-0 z-[1003]"
39
- overlayClassName="z-[1002]"
40
- >
41
- <DialogHeader className="p-5">
42
- <DialogTitle className="text-center text-[16px]!">
43
- {translate('common.imageUpload.tooSmallTitleWithDimension', { dimensionText })}
44
- </DialogTitle>
45
- </DialogHeader>
37
+ // Abre por cima do modal/uploader que a disparou.
38
+ <DialogLayer>
39
+ <Dialog open={open} onOpenChange={onOpenChange}>
40
+ <DialogContent className="w-full md:w-[480px]! lg:w-[480px]! max-w-[480px]! max-[480px]:w-[calc(100%-32px)] p-0 gap-0">
41
+ <DialogHeader className="p-5">
42
+ <DialogTitle className="text-center text-[16px]!">
43
+ {translate('common.imageUpload.tooSmallTitleWithDimension', { dimensionText })}
44
+ </DialogTitle>
45
+ </DialogHeader>
46
46
 
47
- <div className="px-5 pb-5">
48
- <p className="paragraph-small-regular text-zinc-600 text-center">
49
- {translate('common.imageUpload.tooSmallBodyFileWithDimension', { fileName, dimensionText })}
50
- </p>
51
- </div>
47
+ <div className="px-5 pb-5">
48
+ <p className="paragraph-small-regular text-zinc-600 text-center">
49
+ {translate('common.imageUpload.tooSmallBodyFileWithDimension', { fileName, dimensionText })}
50
+ </p>
51
+ </div>
52
52
 
53
- <DialogFooter className="flex-row! items-center justify-start! gap-3 p-5 border-t border-zinc-200">
54
- <Button onClick={onSelectAnother}>{translate('common.imageUpload.sendAnother')}</Button>
55
- <Button variant="secondary" onClick={onCancel}>
56
- {translate('common.actions.cancel')}
57
- </Button>
58
- </DialogFooter>
59
- </DialogContent>
60
- </Dialog>
53
+ <DialogFooter className="flex-row! items-center justify-start! gap-3 p-5 border-t border-zinc-200">
54
+ <Button onClick={onSelectAnother}>{translate('common.imageUpload.sendAnother')}</Button>
55
+ <Button variant="secondary" onClick={onCancel}>
56
+ {translate('common.actions.cancel')}
57
+ </Button>
58
+ </DialogFooter>
59
+ </DialogContent>
60
+ </Dialog>
61
+ </DialogLayer>
61
62
  )
62
63
  }