@mantine/modals 7.2.2 → 7.3.0-alpha.0
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/cjs/ConfirmModal.cjs +36 -0
- package/cjs/ConfirmModal.cjs.map +1 -0
- package/cjs/ModalsProvider.cjs +182 -0
- package/cjs/ModalsProvider.cjs.map +1 -0
- package/cjs/{context.js → context.cjs} +1 -3
- package/cjs/context.cjs.map +1 -0
- package/cjs/{events.js → events.cjs} +1 -3
- package/cjs/events.cjs.map +1 -0
- package/cjs/{index.js → index.cjs} +4 -6
- package/cjs/index.cjs.map +1 -0
- package/cjs/{reducer.js → reducer.cjs} +3 -6
- package/cjs/reducer.cjs.map +1 -0
- package/cjs/use-modals/{use-modals.js → use-modals.cjs} +2 -4
- package/cjs/use-modals/use-modals.cjs.map +1 -0
- package/esm/ConfirmModal.mjs +3 -22
- package/esm/ConfirmModal.mjs.map +1 -1
- package/esm/ModalsProvider.mjs +23 -67
- package/esm/ModalsProvider.mjs.map +1 -1
- package/esm/context.mjs.map +1 -1
- package/esm/events.mjs.map +1 -1
- package/esm/reducer.mjs +2 -3
- package/esm/reducer.mjs.map +1 -1
- package/esm/use-modals/use-modals.mjs.map +1 -1
- package/package.json +24 -26
- package/cjs/ConfirmModal.js +0 -61
- package/cjs/ConfirmModal.js.map +0 -1
- package/cjs/ModalsProvider.js +0 -232
- package/cjs/ModalsProvider.js.map +0 -1
- package/cjs/context.js.map +0 -1
- package/cjs/events.js.map +0 -1
- package/cjs/index.js.map +0 -1
- package/cjs/reducer.js.map +0 -1
- package/cjs/use-modals/use-modals.js.map +0 -1
package/cjs/ModalsProvider.js
DELETED
|
@@ -1,232 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
-
|
|
6
|
-
var React = require('react');
|
|
7
|
-
var core = require('@mantine/core');
|
|
8
|
-
var hooks = require('@mantine/hooks');
|
|
9
|
-
var context = require('./context.js');
|
|
10
|
-
var ConfirmModal = require('./ConfirmModal.js');
|
|
11
|
-
var reducer = require('./reducer.js');
|
|
12
|
-
var events = require('./events.js');
|
|
13
|
-
|
|
14
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e['default'] : e; }
|
|
15
|
-
|
|
16
|
-
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
17
|
-
|
|
18
|
-
var __defProp = Object.defineProperty;
|
|
19
|
-
var __defProps = Object.defineProperties;
|
|
20
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
21
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
22
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
23
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
24
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
25
|
-
var __spreadValues = (a, b) => {
|
|
26
|
-
for (var prop in b || (b = {}))
|
|
27
|
-
if (__hasOwnProp.call(b, prop))
|
|
28
|
-
__defNormalProp(a, prop, b[prop]);
|
|
29
|
-
if (__getOwnPropSymbols)
|
|
30
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
31
|
-
if (__propIsEnum.call(b, prop))
|
|
32
|
-
__defNormalProp(a, prop, b[prop]);
|
|
33
|
-
}
|
|
34
|
-
return a;
|
|
35
|
-
};
|
|
36
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
37
|
-
var __objRest = (source, exclude) => {
|
|
38
|
-
var target = {};
|
|
39
|
-
for (var prop in source)
|
|
40
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
41
|
-
target[prop] = source[prop];
|
|
42
|
-
if (source != null && __getOwnPropSymbols)
|
|
43
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
44
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
45
|
-
target[prop] = source[prop];
|
|
46
|
-
}
|
|
47
|
-
return target;
|
|
48
|
-
};
|
|
49
|
-
function separateConfirmModalProps(props) {
|
|
50
|
-
if (!props) {
|
|
51
|
-
return { confirmProps: {}, modalProps: {} };
|
|
52
|
-
}
|
|
53
|
-
const _a = props, {
|
|
54
|
-
id,
|
|
55
|
-
children,
|
|
56
|
-
onCancel,
|
|
57
|
-
onConfirm,
|
|
58
|
-
closeOnConfirm,
|
|
59
|
-
closeOnCancel,
|
|
60
|
-
cancelProps,
|
|
61
|
-
confirmProps,
|
|
62
|
-
groupProps,
|
|
63
|
-
labels
|
|
64
|
-
} = _a, others = __objRest(_a, [
|
|
65
|
-
"id",
|
|
66
|
-
"children",
|
|
67
|
-
"onCancel",
|
|
68
|
-
"onConfirm",
|
|
69
|
-
"closeOnConfirm",
|
|
70
|
-
"closeOnCancel",
|
|
71
|
-
"cancelProps",
|
|
72
|
-
"confirmProps",
|
|
73
|
-
"groupProps",
|
|
74
|
-
"labels"
|
|
75
|
-
]);
|
|
76
|
-
return {
|
|
77
|
-
confirmProps: {
|
|
78
|
-
id,
|
|
79
|
-
children,
|
|
80
|
-
onCancel,
|
|
81
|
-
onConfirm,
|
|
82
|
-
closeOnConfirm,
|
|
83
|
-
closeOnCancel,
|
|
84
|
-
cancelProps,
|
|
85
|
-
confirmProps,
|
|
86
|
-
groupProps,
|
|
87
|
-
labels
|
|
88
|
-
},
|
|
89
|
-
modalProps: __spreadValues({
|
|
90
|
-
id
|
|
91
|
-
}, others)
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
function ModalsProvider({ children, modalProps, labels, modals }) {
|
|
95
|
-
const [state, dispatch] = React.useReducer(reducer.modalsReducer, { modals: [], current: null });
|
|
96
|
-
const stateRef = React.useRef(state);
|
|
97
|
-
stateRef.current = state;
|
|
98
|
-
const closeAll = React.useCallback(
|
|
99
|
-
(canceled) => {
|
|
100
|
-
dispatch({ type: "CLOSE_ALL", canceled });
|
|
101
|
-
},
|
|
102
|
-
[stateRef, dispatch]
|
|
103
|
-
);
|
|
104
|
-
const openModal = React.useCallback(
|
|
105
|
-
(_a) => {
|
|
106
|
-
var _b = _a, { modalId } = _b, props = __objRest(_b, ["modalId"]);
|
|
107
|
-
const id = modalId || hooks.randomId();
|
|
108
|
-
dispatch({
|
|
109
|
-
type: "OPEN",
|
|
110
|
-
modal: {
|
|
111
|
-
id,
|
|
112
|
-
type: "content",
|
|
113
|
-
props
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
return id;
|
|
117
|
-
},
|
|
118
|
-
[dispatch]
|
|
119
|
-
);
|
|
120
|
-
const openConfirmModal = React.useCallback(
|
|
121
|
-
(_c) => {
|
|
122
|
-
var _d = _c, { modalId } = _d, props = __objRest(_d, ["modalId"]);
|
|
123
|
-
const id = modalId || hooks.randomId();
|
|
124
|
-
dispatch({
|
|
125
|
-
type: "OPEN",
|
|
126
|
-
modal: {
|
|
127
|
-
id,
|
|
128
|
-
type: "confirm",
|
|
129
|
-
props
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
|
-
return id;
|
|
133
|
-
},
|
|
134
|
-
[dispatch]
|
|
135
|
-
);
|
|
136
|
-
const openContextModal = React.useCallback(
|
|
137
|
-
(modal, _e) => {
|
|
138
|
-
var _f = _e, { modalId } = _f, props = __objRest(_f, ["modalId"]);
|
|
139
|
-
const id = modalId || hooks.randomId();
|
|
140
|
-
dispatch({
|
|
141
|
-
type: "OPEN",
|
|
142
|
-
modal: {
|
|
143
|
-
id,
|
|
144
|
-
type: "context",
|
|
145
|
-
props,
|
|
146
|
-
ctx: modal
|
|
147
|
-
}
|
|
148
|
-
});
|
|
149
|
-
return id;
|
|
150
|
-
},
|
|
151
|
-
[dispatch]
|
|
152
|
-
);
|
|
153
|
-
const closeModal = React.useCallback(
|
|
154
|
-
(id, canceled) => {
|
|
155
|
-
dispatch({ type: "CLOSE", modalId: id, canceled });
|
|
156
|
-
},
|
|
157
|
-
[stateRef, dispatch]
|
|
158
|
-
);
|
|
159
|
-
events.useModalsEvents({
|
|
160
|
-
openModal,
|
|
161
|
-
openConfirmModal,
|
|
162
|
-
openContextModal: (_g) => {
|
|
163
|
-
var _h = _g, { modal } = _h, payload = __objRest(_h, ["modal"]);
|
|
164
|
-
return openContextModal(modal, payload);
|
|
165
|
-
},
|
|
166
|
-
closeModal,
|
|
167
|
-
closeContextModal: closeModal,
|
|
168
|
-
closeAllModals: closeAll
|
|
169
|
-
});
|
|
170
|
-
const ctx = {
|
|
171
|
-
modals: state.modals,
|
|
172
|
-
openModal,
|
|
173
|
-
openConfirmModal,
|
|
174
|
-
openContextModal,
|
|
175
|
-
closeModal,
|
|
176
|
-
closeContextModal: closeModal,
|
|
177
|
-
closeAll
|
|
178
|
-
};
|
|
179
|
-
const getCurrentModal = () => {
|
|
180
|
-
const currentModal = stateRef.current.current;
|
|
181
|
-
switch (currentModal == null ? void 0 : currentModal.type) {
|
|
182
|
-
case "context": {
|
|
183
|
-
const _a = currentModal.props, { innerProps } = _a, rest = __objRest(_a, ["innerProps"]);
|
|
184
|
-
const ContextModal = modals[currentModal.ctx];
|
|
185
|
-
return {
|
|
186
|
-
modalProps: rest,
|
|
187
|
-
content: /* @__PURE__ */ React__default.createElement(ContextModal, { innerProps, context: ctx, id: currentModal.id })
|
|
188
|
-
};
|
|
189
|
-
}
|
|
190
|
-
case "confirm": {
|
|
191
|
-
const { modalProps: separatedModalProps, confirmProps: separatedConfirmProps } = separateConfirmModalProps(currentModal.props);
|
|
192
|
-
return {
|
|
193
|
-
modalProps: separatedModalProps,
|
|
194
|
-
content: /* @__PURE__ */ React__default.createElement(
|
|
195
|
-
ConfirmModal.ConfirmModal,
|
|
196
|
-
__spreadProps(__spreadValues({}, separatedConfirmProps), {
|
|
197
|
-
id: currentModal.id,
|
|
198
|
-
labels: currentModal.props.labels || labels
|
|
199
|
-
})
|
|
200
|
-
)
|
|
201
|
-
};
|
|
202
|
-
}
|
|
203
|
-
case "content": {
|
|
204
|
-
const _b = currentModal.props, { children: currentModalChildren } = _b, rest = __objRest(_b, ["children"]);
|
|
205
|
-
return {
|
|
206
|
-
modalProps: rest,
|
|
207
|
-
content: /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, currentModalChildren)
|
|
208
|
-
};
|
|
209
|
-
}
|
|
210
|
-
default: {
|
|
211
|
-
return {
|
|
212
|
-
modalProps: {},
|
|
213
|
-
content: null
|
|
214
|
-
};
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
};
|
|
218
|
-
const { modalProps: currentModalProps, content } = getCurrentModal();
|
|
219
|
-
return /* @__PURE__ */ React__default.createElement(context.ModalsContext.Provider, { value: ctx }, /* @__PURE__ */ React__default.createElement(
|
|
220
|
-
core.Modal,
|
|
221
|
-
__spreadProps(__spreadValues(__spreadValues({
|
|
222
|
-
zIndex: core.getDefaultZIndex("modal") + 1
|
|
223
|
-
}, modalProps), currentModalProps), {
|
|
224
|
-
opened: state.modals.length > 0,
|
|
225
|
-
onClose: () => closeModal(state.current.id)
|
|
226
|
-
}),
|
|
227
|
-
content
|
|
228
|
-
), children);
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
exports.ModalsProvider = ModalsProvider;
|
|
232
|
-
//# sourceMappingURL=ModalsProvider.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ModalsProvider.js","sources":["../src/ModalsProvider.tsx"],"sourcesContent":["import React, { useCallback, useReducer, useRef } from 'react';\nimport { Modal, getDefaultZIndex } from '@mantine/core';\nimport { randomId } from '@mantine/hooks';\nimport {\n ModalsContext,\n ModalSettings,\n ConfirmLabels,\n OpenConfirmModal,\n OpenContextModal,\n ContextModalProps,\n ModalsContextProps,\n} from './context';\nimport { ConfirmModal } from './ConfirmModal';\nimport { modalsReducer } from './reducer';\nimport { useModalsEvents } from './events';\n\nexport interface ModalsProviderProps {\n /** Your app */\n children: React.ReactNode;\n\n /** Predefined modals */\n modals?: Record<string, React.FC<ContextModalProps<any>>>;\n\n /** Shared Modal component props, applied for every modal */\n modalProps?: ModalSettings;\n\n /** Confirm modal labels */\n labels?: ConfirmLabels;\n}\n\nfunction separateConfirmModalProps(props: OpenConfirmModal) {\n if (!props) {\n return { confirmProps: {}, modalProps: {} };\n }\n\n const {\n id,\n children,\n onCancel,\n onConfirm,\n closeOnConfirm,\n closeOnCancel,\n cancelProps,\n confirmProps,\n groupProps,\n labels,\n ...others\n } = props;\n\n return {\n confirmProps: {\n id,\n children,\n onCancel,\n onConfirm,\n closeOnConfirm,\n closeOnCancel,\n cancelProps,\n confirmProps,\n groupProps,\n labels,\n },\n modalProps: {\n id,\n ...others,\n },\n };\n}\n\nexport function ModalsProvider({ children, modalProps, labels, modals }: ModalsProviderProps) {\n const [state, dispatch] = useReducer(modalsReducer, { modals: [], current: null });\n const stateRef = useRef(state);\n stateRef.current = state;\n\n const closeAll = useCallback(\n (canceled?: boolean) => {\n dispatch({ type: 'CLOSE_ALL', canceled });\n },\n [stateRef, dispatch]\n );\n\n const openModal = useCallback(\n ({ modalId, ...props }: ModalSettings) => {\n const id = modalId || randomId();\n\n dispatch({\n type: 'OPEN',\n modal: {\n id,\n type: 'content',\n props,\n },\n });\n return id;\n },\n [dispatch]\n );\n\n const openConfirmModal = useCallback(\n ({ modalId, ...props }: OpenConfirmModal) => {\n const id = modalId || randomId();\n dispatch({\n type: 'OPEN',\n modal: {\n id,\n type: 'confirm',\n props,\n },\n });\n return id;\n },\n [dispatch]\n );\n\n const openContextModal = useCallback(\n (modal: string, { modalId, ...props }: OpenContextModal) => {\n const id = modalId || randomId();\n dispatch({\n type: 'OPEN',\n modal: {\n id,\n type: 'context',\n props,\n ctx: modal,\n },\n });\n return id;\n },\n [dispatch]\n );\n\n const closeModal = useCallback(\n (id: string, canceled?: boolean) => {\n dispatch({ type: 'CLOSE', modalId: id, canceled });\n },\n [stateRef, dispatch]\n );\n\n useModalsEvents({\n openModal,\n openConfirmModal,\n openContextModal: ({ modal, ...payload }: any) => openContextModal(modal, payload),\n closeModal,\n closeContextModal: closeModal,\n closeAllModals: closeAll,\n });\n\n const ctx: ModalsContextProps = {\n modals: state.modals,\n openModal,\n openConfirmModal,\n openContextModal,\n closeModal,\n closeContextModal: closeModal,\n closeAll,\n };\n\n const getCurrentModal = () => {\n const currentModal = stateRef.current.current;\n switch (currentModal?.type) {\n case 'context': {\n const { innerProps, ...rest } = currentModal.props;\n const ContextModal = modals![currentModal.ctx];\n\n return {\n modalProps: rest,\n content: <ContextModal innerProps={innerProps} context={ctx} id={currentModal.id} />,\n };\n }\n case 'confirm': {\n const { modalProps: separatedModalProps, confirmProps: separatedConfirmProps } =\n separateConfirmModalProps(currentModal.props);\n\n return {\n modalProps: separatedModalProps,\n content: (\n <ConfirmModal\n {...separatedConfirmProps}\n id={currentModal.id}\n labels={currentModal.props.labels || labels}\n />\n ),\n };\n }\n case 'content': {\n const { children: currentModalChildren, ...rest } = currentModal.props;\n\n return {\n modalProps: rest,\n content: <>{currentModalChildren}</>,\n };\n }\n default: {\n return {\n modalProps: {},\n content: null,\n };\n }\n }\n };\n\n const { modalProps: currentModalProps, content } = getCurrentModal();\n\n return (\n <ModalsContext.Provider value={ctx}>\n <Modal\n zIndex={getDefaultZIndex('modal') + 1}\n {...modalProps}\n {...currentModalProps}\n opened={state.modals.length > 0}\n onClose={() => closeModal(state.current!.id)}\n >\n {content}\n </Modal>\n\n {children}\n </ModalsContext.Provider>\n );\n}\n"],"names":["useReducer","modalsReducer","useRef","useCallback","randomId","useModalsEvents","React","ConfirmModal","ModalsContext","Modal","getDefaultZIndex"],"mappings":";;;;;;;;;;;;;;;;;AAAA,IAAI,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC;AACtC,IAAI,UAAU,GAAG,MAAM,CAAC,gBAAgB,CAAC;AACzC,IAAI,iBAAiB,GAAG,MAAM,CAAC,yBAAyB,CAAC;AACzD,IAAI,mBAAmB,GA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AAU,EAAE,IAAI;AAC1B,UAAU,OAAO,kBAAkBD,cAAK,CAAC,aAAa,CAACA,cAAK,CAAC,QAAQ,EAAE,IAAI,EAAE,oBAAoB,CAAC;AAClG,SAAS,CAAC;AACV,OAAO;AACP,MAAM,SAAS;AACf,QAAQ,OAAO;AACf,UAAU,UAAU,EAAE,EAAE;AACxB,UAAU,OAAO,EAAE,IAAI;AACvB,SAAS,CAAC;AACV,OAAO;AACP,KAAK;AACL,GAAG,CAAC;AACJ,EAAE,MAAM,EAAE,UAAU,EAAE,iBAAiB,EAAE,OAAO,EAAE,GAAG,eAAe,EAAE,CAAC;AACvE,EAAE,uBAAuBA,cAAK,CAAC,aAAa,CAACE,qBAAa,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,kBAAkBF,cAAK,CAAC,aAAa;AACxH,IAAIG,UAAK;AACT,IAAI,aAAa,CAAC,cAAc,CAAC,cAAc,CAAC;AAChD,MAAM,MAAM,EAAEC,qBAAgB,CAAC,OAAO,CAAC,GAAG,CAAC;AAC3C,KAAK,EAAE,UAAU,CAAC,EAAE,iBAAiB,CAAC,EAAE;AACxC,MAAM,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC;AACrC,MAAM,OAAO,EAAE,MAAM,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;AACjD,KAAK,CAAC;AACN,IAAI,OAAO;AACX,GAAG,EAAE,QAAQ,CAAC,CAAC;AACf;;"}
|
package/cjs/context.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sources":["../src/context.ts"],"sourcesContent":["import { createContext, ReactNode } from 'react';\nimport { ModalProps } from '@mantine/core';\nimport type { ConfirmModalProps } from './ConfirmModal';\n\nexport type ModalSettings = Partial<Omit<ModalProps, 'opened'>> & { modalId?: string };\n\nexport type ConfirmLabels = Record<'confirm' | 'cancel', ReactNode>;\n\nexport interface OpenConfirmModal extends ModalSettings, ConfirmModalProps {}\nexport interface OpenContextModal<CustomProps extends Record<string, any> = {}>\n extends ModalSettings {\n innerProps: CustomProps;\n}\n\nexport interface ContextModalProps<T extends Record<string, any> = {}> {\n context: ModalsContextProps;\n innerProps: T;\n id: string;\n}\n\nexport type ModalState =\n | { id: string; props: ModalSettings; type: 'content' }\n | { id: string; props: OpenConfirmModal; type: 'confirm' }\n | { id: string; props: OpenContextModal; type: 'context'; ctx: string };\n\nexport interface ModalsContextProps {\n modals: ModalState[];\n openModal: (props: ModalSettings) => string;\n openConfirmModal: (props: OpenConfirmModal) => string;\n openContextModal: <TKey extends MantineModal>(\n modal: TKey,\n props: OpenContextModal<Parameters<MantineModals[TKey]>[0]['innerProps']>\n ) => string;\n closeModal: (id: string, canceled?: boolean) => void;\n closeContextModal: <TKey extends MantineModal>(id: TKey, canceled?: boolean) => void;\n closeAll: () => void;\n}\n\nexport type MantineModalsOverride = {};\n\nexport type MantineModalsOverwritten = MantineModalsOverride extends {\n modals: Record<string, React.FC<ContextModalProps<any>>>;\n}\n ? MantineModalsOverride\n : {\n modals: Record<string, React.FC<ContextModalProps<any>>>;\n };\n\nexport type MantineModals = MantineModalsOverwritten['modals'];\n\nexport type MantineModal = keyof MantineModals;\n\nexport const ModalsContext = createContext<ModalsContextProps>(null as any);\nModalsContext.displayName = '@mantine/modals/ModalsContext';\n"],"names":["createContext"],"mappings":";;;;;;;AACY,MAAC,aAAa,GAAGA,mBAAa,CAAC,IAAI,EAAE;AACjD,aAAa,CAAC,WAAW,GAAG,+BAA+B;;"}
|
package/cjs/events.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"events.js","sources":["../src/events.ts"],"sourcesContent":["import { createUseExternalEvents } from '@mantine/core';\nimport {\n MantineModal,\n MantineModals,\n ModalSettings,\n OpenConfirmModal,\n OpenContextModal,\n} from './context';\n\ntype ModalsEvents = {\n openModal: (payload: ModalSettings) => void;\n closeModal: (id: string) => void;\n closeContextModal: <TKey extends MantineModal>(id: TKey) => void;\n closeAllModals: () => void;\n openConfirmModal: (payload: OpenConfirmModal) => void;\n openContextModal: <TKey extends MantineModal>(\n payload: OpenContextModal<Parameters<MantineModals[TKey]>[0]['innerProps']> & { modal: TKey }\n ) => void;\n};\n\nexport const [useModalsEvents, createEvent] =\n createUseExternalEvents<ModalsEvents>('mantine-modals');\n\nexport const openModal = createEvent('openModal');\nexport const closeModal = createEvent('closeModal');\nexport const closeContextModal: ModalsEvents['closeContextModal'] = <TKey extends MantineModal>(\n id: TKey\n) => createEvent('closeContextModal')(id);\nexport const closeAllModals = createEvent('closeAllModals');\nexport const openConfirmModal = createEvent('openConfirmModal');\nexport const openContextModal: ModalsEvents['openContextModal'] = <TKey extends MantineModal>(\n payload: OpenContextModal<Parameters<MantineModals[TKey]>[0]['innerProps']> & { modal: TKey }\n) => createEvent('openContextModal')(payload);\n\nexport const modals = {\n open: openModal,\n close: closeModal,\n closeAll: closeAllModals,\n openConfirmModal,\n openContextModal,\n};\n"],"names":["createUseExternalEvents"],"mappings":";;;;;;;AACY,MAAC,CAAC,eAAe,EAAE,WAAW,CAAC,GAAGA,4BAAuB,CAAC,gBAAgB,EAAE;AAC5E,MAAC,SAAS,GAAG,WAAW,CAAC,WAAW,EAAE;AACtC,MAAC,UAAU,GAAG,WAAW,CAAC,YAAY,EAAE;AAExC,MAAC,cAAc,GAAG,WAAW,CAAC,gBAAgB,EAAE;AAChD,MAAC,gBAAgB,GAAG,WAAW,CAAC,kBAAkB,EAAE;AACpD,MAAC,gBAAgB,GAAG,CAAC,OAAO,KAAK,WAAW,CAAC,kBAAkB,CAAC,CAAC,OAAO,EAAE;AAC1E,MAAC,MAAM,GAAG;AACtB,EAAE,IAAI,EAAE,SAAS;AACjB,EAAE,KAAK,EAAE,UAAU;AACnB,EAAE,QAAQ,EAAE,cAAc;AAC1B,EAAE,gBAAgB;AAClB,EAAE,gBAAgB;AAClB;;;;;;;;;"}
|
package/cjs/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;"}
|
package/cjs/reducer.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"reducer.js","sources":["../src/reducer.ts"],"sourcesContent":["import { ModalState } from './context';\n\ninterface ModalsState {\n modals: ModalState[];\n\n /**\n * Modal that is currently open or was the last open one.\n * Keeping the last one is necessary for providing a clean exit transition.\n */\n current: ModalState | null;\n}\n\ninterface OpenAction {\n type: 'OPEN';\n modal: ModalState;\n}\n\ninterface CloseAction {\n type: 'CLOSE';\n modalId: string;\n canceled?: boolean;\n}\n\ninterface CloseAllAction {\n type: 'CLOSE_ALL';\n canceled?: boolean;\n}\n\nfunction handleCloseModal(modal: ModalState, canceled?: boolean) {\n if (canceled && modal.type === 'confirm') {\n modal.props.onCancel?.();\n }\n\n modal.props.onClose?.();\n}\n\nexport function modalsReducer(\n state: ModalsState,\n action: OpenAction | CloseAction | CloseAllAction\n): ModalsState {\n switch (action.type) {\n case 'OPEN': {\n return {\n current: action.modal,\n modals: [...state.modals, action.modal],\n };\n }\n case 'CLOSE': {\n const modal = state.modals.find((m) => m.id === action.modalId);\n if (!modal) {\n return state;\n }\n\n handleCloseModal(modal, action.canceled);\n\n const remainingModals = state.modals.filter((m) => m.id !== action.modalId);\n\n return {\n current: remainingModals[remainingModals.length - 1] || state.current,\n modals: remainingModals,\n };\n }\n case 'CLOSE_ALL': {\n if (!state.modals.length) {\n return state;\n }\n\n // Resolve modal stack from top to bottom\n state.modals\n .concat()\n .reverse()\n .forEach((modal) => {\n handleCloseModal(modal, action.canceled);\n });\n\n return {\n current: state.current,\n modals: [],\n };\n }\n default: {\n return state;\n }\n }\n}\n"],"names":[],"mappings":";;;;;AAAA,SAAS,gBAAgB,CAAC,KAAK,EAAE,QAAQ,EAAE;AAC3C,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,E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AM,GAAG,CAAC,CAAC,IAAI,KAAK,CAAC,OAAO;AAC7E,QAAQ,MAAM,EAAE,eAAe;AAC/B,OAAO,CAAC;AACR,KAAK;AACL,IAAI,KAAK,WAAW,EAAE;AACtB,MAAM,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE;AAChC,QAAQ,OAAO,KAAK,CAAC;AACrB,OAAO;AACP,MAAM,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,CAAC,KAAK,KAAK;AACzD,QAAQ,gBAAgB,CAAC,KAAK,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;AACjD,OAAO,CAAC,CAAC;AACT,MAAM,OAAO;AACb,QAAQ,OAAO,EAAE,KAAK,CAAC,OAAO;AAC9B,QAAQ,MAAM,EAAE,EAAE;AAClB,OAAO,CAAC;AACR,KAAK;AACL,IAAI,SAAS;AACb,MAAM,OAAO,KAAK,CAAC;AACnB,KAAK;AACL,GAAG;AACH;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"use-modals.js","sources":["../../src/use-modals/use-modals.ts"],"sourcesContent":["import { useContext } from 'react';\nimport { ModalsContext } from '../context';\n\nexport function useModals() {\n const ctx = useContext(ModalsContext);\n\n if (!ctx) {\n throw new Error(\n '[@mantine/modals] useModals hook was called outside of context, wrap your app with ModalsProvider component'\n );\n }\n\n return ctx;\n}\n"],"names":["useContext","ModalsContext"],"mappings":";;;;;;;;AAEO,SAAS,SAAS,GAAG;AAC5B,EAAE,MAAM,GAAG,GAAGA,gBAAU,CAACC,qBAAa,CAAC,CAAC;AACxC,EAAE,IAAI,CAAC,GAAG,EAAE;AACZ,IAAI,MAAM,IAAI,KAAK;AACnB,MAAM,6GAA6G;AACnH,KAAK,CAAC;AACN,GAAG;AACH,EAAE,OAAO,GAAG,CAAC;AACb;;"}
|