@g4rcez/components 2.2.4 → 2.2.5
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/components/floating/modal.d.ts +4 -55
- package/dist/components/floating/modal.d.ts.map +1 -1
- package/dist/components/floating/modal.jsx +5 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4147 -4148
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +10 -10
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
|
@@ -38,6 +38,10 @@ export type ModalRef = {
|
|
|
38
38
|
context: any;
|
|
39
39
|
floating: HTMLElement | null;
|
|
40
40
|
};
|
|
41
|
+
type ModalComponent = React.FC<ModalProps> & {
|
|
42
|
+
confirm: <T>(options: ConfirmOptions) => Promise<T>;
|
|
43
|
+
};
|
|
44
|
+
export declare const Modal: ModalComponent;
|
|
41
45
|
type ButtonConfirmationAction = {
|
|
42
46
|
value?: any;
|
|
43
47
|
text?: Label;
|
|
@@ -49,61 +53,6 @@ export type ConfirmOptions = {
|
|
|
49
53
|
cancel?: ButtonConfirmationAction;
|
|
50
54
|
confirm?: ButtonConfirmationAction;
|
|
51
55
|
};
|
|
52
|
-
export declare const Modal: React.ForwardRefExoticComponent<(Omit<Omit<HTMLMotionProps<"div">, "footer" | "title" | "className" | "role" | "onChange" | "position" | "open" | "resizer" | "type" | "layoutId" | "animated" | "asChild" | "closable" | "forceType" | "bodyClassName" | "overlayClassName" | "overlayClickClose" | "closeOnFocusOut" | "interactions" | "trigger" | "ariaTitle"> & {
|
|
53
|
-
title: Label;
|
|
54
|
-
ariaTitle?: string;
|
|
55
|
-
} & {
|
|
56
|
-
open: boolean;
|
|
57
|
-
onChange: (nextState: boolean) => void;
|
|
58
|
-
} & Partial<{
|
|
59
|
-
footer: Label;
|
|
60
|
-
type: ModalType;
|
|
61
|
-
animated: boolean;
|
|
62
|
-
asChild: boolean;
|
|
63
|
-
layoutId: string;
|
|
64
|
-
resizer: boolean;
|
|
65
|
-
className: string;
|
|
66
|
-
closable: boolean;
|
|
67
|
-
forceType: boolean;
|
|
68
|
-
bodyClassName: string;
|
|
69
|
-
overlayClassName: string;
|
|
70
|
-
position: DrawerPosition;
|
|
71
|
-
overlayClickClose: boolean;
|
|
72
|
-
closeOnFocusOut: boolean;
|
|
73
|
-
role: "dialog";
|
|
74
|
-
interactions: ElementProps[];
|
|
75
|
-
trigger: Label | React.FC<any>;
|
|
76
|
-
}> & {
|
|
77
|
-
children?: React.ReactNode | undefined;
|
|
78
|
-
}, "ref"> | Omit<Omit<HTMLMotionProps<"div">, "footer" | "title" | "className" | "role" | "onChange" | "position" | "open" | "resizer" | "type" | "layoutId" | "animated" | "asChild" | "closable" | "forceType" | "bodyClassName" | "overlayClassName" | "overlayClickClose" | "closeOnFocusOut" | "interactions" | "trigger" | "ariaTitle"> & {
|
|
79
|
-
ariaTitle: string;
|
|
80
|
-
title?: Label;
|
|
81
|
-
} & {
|
|
82
|
-
open: boolean;
|
|
83
|
-
onChange: (nextState: boolean) => void;
|
|
84
|
-
} & Partial<{
|
|
85
|
-
footer: Label;
|
|
86
|
-
type: ModalType;
|
|
87
|
-
animated: boolean;
|
|
88
|
-
asChild: boolean;
|
|
89
|
-
layoutId: string;
|
|
90
|
-
resizer: boolean;
|
|
91
|
-
className: string;
|
|
92
|
-
closable: boolean;
|
|
93
|
-
forceType: boolean;
|
|
94
|
-
bodyClassName: string;
|
|
95
|
-
overlayClassName: string;
|
|
96
|
-
position: DrawerPosition;
|
|
97
|
-
overlayClickClose: boolean;
|
|
98
|
-
closeOnFocusOut: boolean;
|
|
99
|
-
role: "dialog";
|
|
100
|
-
interactions: ElementProps[];
|
|
101
|
-
trigger: Label | React.FC<any>;
|
|
102
|
-
}> & {
|
|
103
|
-
children?: React.ReactNode | undefined;
|
|
104
|
-
}, "ref">) & React.RefAttributes<ModalRef>> & {
|
|
105
|
-
confirm: (options: ConfirmOptions) => Promise<boolean>;
|
|
106
|
-
};
|
|
107
56
|
export declare const ModalConfirmProvider: ({ children }: {
|
|
108
57
|
children: React.ReactNode;
|
|
109
58
|
}) => React.JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modal.d.ts","sourceRoot":"","sources":["../../../src/components/floating/modal.tsx"],"names":[],"mappings":"AACA,OAAO,EASL,KAAK,YAAY,EAClB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAmB,eAAe,EAA4F,MAAM,cAAc,CAAC;AAE1J,OAAO,KAAsI,MAAM,OAAO,CAAC;AAG3J,OAAO,EAAE,KAAK,EAAO,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEnD,OAAO,EAAU,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAMrD,eAAO,MAAM,UAAU,kBAF8B,cAAc,KAAK,OAAO,CAAC,OAAO,CAEvB,CAAC;AAEjE,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,QAAQ,GAAG,OAAO,CAAC;AAEtD,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,OAAO,CAAC;AAuD9C,MAAM,MAAM,UAAU,GAAG,QAAQ,CAC/B,eAAe,CAAC,KAAK,CAAC,EACtB,CAAC;IAAE,KAAK,EAAE,KAAK,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,KAAK,CAAA;CAAE,CAAC,GAAG;IAC9E,IAAI,EAAE,OAAO,CAAC;IACd,QAAQ,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;CACxC,GAAG,OAAO,CAAC;IACV,MAAM,EAAE,KAAK,CAAC;IACd,IAAI,EAAE,SAAS,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;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AAO,CAAC,CAAA;CAC7B,CAAA;AAED,MAAM,MAAM,cAAc,GAAG;IAC3B,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,WAAW,CAAC,EAAE,KAAK,CAAC;IACpB,MAAM,CAAC,EAAE,wBAAwB,CAAC;IAClC,OAAO,CAAC,EAAE,wBAAwB,CAAC;CACpC,CAAC;AAaF,eAAO,MAAM,oBAAoB,GAAI,cAAc;IAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,sBAuD/E,CAAC"}
|
|
@@ -95,7 +95,7 @@ const fetchPosition = (isDesktop, forceType, propsType, propsPosition) => {
|
|
|
95
95
|
return forceType ? positions[type] : positions.sheet;
|
|
96
96
|
};
|
|
97
97
|
const noop = [];
|
|
98
|
-
const
|
|
98
|
+
export const Modal = forwardRef(({ open, title, footer, asChild, trigger, children, onChange, ariaTitle, className, bodyClassName, resizer = true, animated = true, closable = true, forceType = false, layoutId = undefined, overlayClassName = "", type: _type = "dialog", position: propsPosition, overlayClickClose = false, closeOnFocusOut = false, interactions: outInteractions = noop, ...props }, externalRef) => {
|
|
99
99
|
const root = useFloatingRef();
|
|
100
100
|
const innerContent = useRef(null);
|
|
101
101
|
const removeScrollRef = useRef(null);
|
|
@@ -246,15 +246,13 @@ const InternalModal = forwardRef(({ open, title, footer, asChild, trigger, child
|
|
|
246
246
|
</MotionConfig>
|
|
247
247
|
</Fragment>);
|
|
248
248
|
});
|
|
249
|
-
let confirmGlobal = async () => {
|
|
249
|
+
let confirmGlobal = async (options) => {
|
|
250
250
|
if (typeof window !== "undefined") {
|
|
251
251
|
console.warn("ConfirmationProvider is not mounted");
|
|
252
252
|
}
|
|
253
253
|
return false;
|
|
254
254
|
};
|
|
255
|
-
|
|
256
|
-
confirm: (options) => confirmGlobal(options),
|
|
257
|
-
});
|
|
255
|
+
Modal.confirm = (options) => confirmGlobal(options);
|
|
258
256
|
export const ModalConfirmProvider = ({ children }) => {
|
|
259
257
|
const [open, setOpen] = useState(false);
|
|
260
258
|
const [options, setOptions] = useState({});
|
|
@@ -281,7 +279,7 @@ export const ModalConfirmProvider = ({ children }) => {
|
|
|
281
279
|
};
|
|
282
280
|
return (<ConfirmContext.Provider value={confirmAction}>
|
|
283
281
|
{children}
|
|
284
|
-
<
|
|
282
|
+
<Modal open={open} type="dialog" closable={false} onChange={setOpen} overlayClickClose={false} title={options.title || "Confirmation"} className="container max-w-dialog lg:max-w-96" footer={<div className="flex gap-2 justify-end">
|
|
285
283
|
<Button theme={options.cancel?.theme || "ghost-muted"} onClick={onCancel}>
|
|
286
284
|
{options.cancel?.text || "Cancel"}
|
|
287
285
|
</Button>
|
|
@@ -290,6 +288,6 @@ export const ModalConfirmProvider = ({ children }) => {
|
|
|
290
288
|
</Button>
|
|
291
289
|
</div>}>
|
|
292
290
|
<div className="py-2 text-foreground">{options.description}</div>
|
|
293
|
-
</
|
|
291
|
+
</Modal>
|
|
294
292
|
</ConfirmContext.Provider>);
|
|
295
293
|
};
|