@mantine/modals 6.0.18 → 7.0.0-alpha.22
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.js +1 -11
- package/cjs/ConfirmModal.js.map +1 -1
- package/cjs/ModalsProvider.js +79 -63
- package/cjs/ModalsProvider.js.map +1 -1
- package/cjs/context.js.map +1 -1
- package/cjs/events.js +2 -2
- package/cjs/events.js.map +1 -1
- package/cjs/index.js +1 -0
- package/cjs/index.js.map +1 -1
- package/cjs/use-modals/use-modals.js +3 -1
- package/cjs/use-modals/use-modals.js.map +1 -1
- package/esm/ConfirmModal.js +1 -11
- package/esm/ConfirmModal.js.map +1 -1
- package/esm/ModalsProvider.js +79 -63
- package/esm/ModalsProvider.js.map +1 -1
- package/esm/context.js.map +1 -1
- package/esm/events.js +1 -1
- package/esm/events.js.map +1 -1
- package/esm/index.js +1 -0
- package/esm/index.js.map +1 -1
- package/esm/use-modals/use-modals.js +3 -1
- package/esm/use-modals/use-modals.js.map +1 -1
- package/lib/ConfirmModal.d.ts +1 -1
- package/lib/ConfirmModal.d.ts.map +1 -1
- package/lib/Modals.story.d.ts +4 -4
- package/lib/Modals.story.d.ts.map +1 -1
- package/lib/ModalsProvider.d.ts +1 -1
- package/lib/ModalsProvider.d.ts.map +1 -1
- package/lib/context.d.ts.map +1 -1
- package/package.json +16 -12
package/cjs/ConfirmModal.js
CHANGED
|
@@ -53,17 +53,7 @@ function ConfirmModal({
|
|
|
53
53
|
typeof onConfirm === "function" && onConfirm();
|
|
54
54
|
closeOnConfirm && ctx.closeModal(id);
|
|
55
55
|
};
|
|
56
|
-
return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, children && /* @__PURE__ */ React__default.createElement(core.Box, {
|
|
57
|
-
mb: "md"
|
|
58
|
-
}, children), /* @__PURE__ */ React__default.createElement(core.Group, __spreadValues({
|
|
59
|
-
position: "right"
|
|
60
|
-
}, groupProps), /* @__PURE__ */ React__default.createElement(core.Button, __spreadProps(__spreadValues({
|
|
61
|
-
variant: "default"
|
|
62
|
-
}, cancelProps), {
|
|
63
|
-
onClick: handleCancel
|
|
64
|
-
}), (cancelProps == null ? void 0 : cancelProps.children) || cancelLabel), /* @__PURE__ */ React__default.createElement(core.Button, __spreadProps(__spreadValues({}, confirmProps), {
|
|
65
|
-
onClick: handleConfirm
|
|
66
|
-
}), (confirmProps == null ? void 0 : confirmProps.children) || confirmLabel)));
|
|
56
|
+
return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, children && /* @__PURE__ */ React__default.createElement(core.Box, { mb: "md" }, children), /* @__PURE__ */ React__default.createElement(core.Group, __spreadValues({ justify: "flex-end" }, groupProps), /* @__PURE__ */ React__default.createElement(core.Button, __spreadProps(__spreadValues({ variant: "default" }, cancelProps), { onClick: handleCancel }), (cancelProps == null ? void 0 : cancelProps.children) || cancelLabel), /* @__PURE__ */ React__default.createElement(core.Button, __spreadProps(__spreadValues({}, confirmProps), { onClick: handleConfirm }), (confirmProps == null ? void 0 : confirmProps.children) || confirmLabel)));
|
|
67
57
|
}
|
|
68
58
|
|
|
69
59
|
exports.ConfirmModal = ConfirmModal;
|
package/cjs/ConfirmModal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfirmModal.js","sources":["../src/ConfirmModal.tsx"],"sourcesContent":["import React from 'react';\nimport { Button, Group, Box, ButtonProps, GroupProps } from '@mantine/core';\nimport { ConfirmLabels } from './context';\nimport { useModals } from './use-modals/use-modals';\n\nexport interface ConfirmModalProps {\n id?: string;\n children?: React.ReactNode;\n onCancel?(): void;\n onConfirm?(): void;\n closeOnConfirm?: boolean;\n closeOnCancel?: boolean;\n cancelProps?: ButtonProps & React.ComponentPropsWithoutRef<'button'>;\n confirmProps?: ButtonProps & React.ComponentPropsWithoutRef<'button'>;\n groupProps?: GroupProps;\n labels?: ConfirmLabels;\n}\n\nexport function ConfirmModal({\n id,\n cancelProps,\n confirmProps,\n labels = { cancel: '', confirm: '' },\n closeOnConfirm = true,\n closeOnCancel = true,\n groupProps,\n onCancel,\n onConfirm,\n children,\n}: ConfirmModalProps) {\n const { cancel: cancelLabel, confirm: confirmLabel } = labels;\n const ctx = useModals();\n\n const handleCancel = (event: React.MouseEvent<HTMLButtonElement>) => {\n typeof cancelProps?.onClick === 'function' && cancelProps?.onClick(event);\n typeof onCancel === 'function' && onCancel();\n closeOnCancel && ctx.closeModal(id);\n };\n\n const handleConfirm = (event: React.MouseEvent<HTMLButtonElement>) => {\n typeof confirmProps?.onClick === 'function' && confirmProps?.onClick(event);\n typeof onConfirm === 'function' && onConfirm();\n closeOnConfirm && ctx.closeModal(id);\n };\n\n return (\n <>\n {children && <Box mb=\"md\">{children}</Box>}\n\n <Group
|
|
1
|
+
{"version":3,"file":"ConfirmModal.js","sources":["../src/ConfirmModal.tsx"],"sourcesContent":["import React from 'react';\nimport { Button, Group, Box, ButtonProps, GroupProps } from '@mantine/core';\nimport { ConfirmLabels } from './context';\nimport { useModals } from './use-modals/use-modals';\n\nexport interface ConfirmModalProps {\n id?: string;\n children?: React.ReactNode;\n onCancel?(): void;\n onConfirm?(): void;\n closeOnConfirm?: boolean;\n closeOnCancel?: boolean;\n cancelProps?: ButtonProps & React.ComponentPropsWithoutRef<'button'>;\n confirmProps?: ButtonProps & React.ComponentPropsWithoutRef<'button'>;\n groupProps?: GroupProps;\n labels?: ConfirmLabels;\n}\n\nexport function ConfirmModal({\n id,\n cancelProps,\n confirmProps,\n labels = { cancel: '', confirm: '' },\n closeOnConfirm = true,\n closeOnCancel = true,\n groupProps,\n onCancel,\n onConfirm,\n children,\n}: ConfirmModalProps) {\n const { cancel: cancelLabel, confirm: confirmLabel } = labels;\n const ctx = useModals();\n\n const handleCancel = (event: React.MouseEvent<HTMLButtonElement>) => {\n typeof cancelProps?.onClick === 'function' && cancelProps?.onClick(event);\n typeof onCancel === 'function' && onCancel();\n closeOnCancel && ctx.closeModal(id!);\n };\n\n const handleConfirm = (event: React.MouseEvent<HTMLButtonElement>) => {\n typeof confirmProps?.onClick === 'function' && confirmProps?.onClick(event);\n typeof onConfirm === 'function' && onConfirm();\n closeOnConfirm && ctx.closeModal(id!);\n };\n\n return (\n <>\n {children && <Box mb=\"md\">{children}</Box>}\n\n <Group justify=\"flex-end\" {...groupProps}>\n <Button variant=\"default\" {...cancelProps} onClick={handleCancel}>\n {cancelProps?.children || cancelLabel}\n </Button>\n\n <Button {...confirmProps} onClick={handleConfirm}>\n {confirmProps?.children || confirmLabel}\n </Button>\n </Group>\n </>\n );\n}\n"],"names":["useModals","React","Box","Group","Button"],"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,GAAG,MAAM,CAAC,qBAAqB,CAAC;AACvD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC;AACnD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,oBAAoB,CAAC;AACzD,IAAI,eAAe,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,KAAK,GAAG,IAAI,GAAG,GAAG,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAChK,IAAI,cAAc,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK;AAC/B,EAAE,KAAK,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;AAChC,IAAI,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC;AAClC,MAAM,eAAe,CAAC,CAAC,EAAE,IA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AC,CAAC,CAAC;AACvoB;;;;"}
|
package/cjs/ModalsProvider.js
CHANGED
|
@@ -94,52 +94,67 @@ function ModalsProvider({ children, modalProps, labels, modals }) {
|
|
|
94
94
|
const [state, dispatch] = React.useReducer(reducer.modalsReducer, { modals: [], current: null });
|
|
95
95
|
const stateRef = React.useRef(state);
|
|
96
96
|
stateRef.current = state;
|
|
97
|
-
const closeAll = React.useCallback(
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
97
|
+
const closeAll = React.useCallback(
|
|
98
|
+
(canceled) => {
|
|
99
|
+
dispatch({ type: "CLOSE_ALL", canceled });
|
|
100
|
+
},
|
|
101
|
+
[stateRef, dispatch]
|
|
102
|
+
);
|
|
103
|
+
const openModal = React.useCallback(
|
|
104
|
+
(_a) => {
|
|
105
|
+
var _b = _a, { modalId } = _b, props = __objRest(_b, ["modalId"]);
|
|
106
|
+
const id = modalId || hooks.randomId();
|
|
107
|
+
dispatch({
|
|
108
|
+
type: "OPEN",
|
|
109
|
+
modal: {
|
|
110
|
+
id,
|
|
111
|
+
type: "content",
|
|
112
|
+
props
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
return id;
|
|
116
|
+
},
|
|
117
|
+
[dispatch]
|
|
118
|
+
);
|
|
119
|
+
const openConfirmModal = React.useCallback(
|
|
120
|
+
(_c) => {
|
|
121
|
+
var _d = _c, { modalId } = _d, props = __objRest(_d, ["modalId"]);
|
|
122
|
+
const id = modalId || hooks.randomId();
|
|
123
|
+
dispatch({
|
|
124
|
+
type: "OPEN",
|
|
125
|
+
modal: {
|
|
126
|
+
id,
|
|
127
|
+
type: "confirm",
|
|
128
|
+
props
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
return id;
|
|
132
|
+
},
|
|
133
|
+
[dispatch]
|
|
134
|
+
);
|
|
135
|
+
const openContextModal = React.useCallback(
|
|
136
|
+
(modal, _e) => {
|
|
137
|
+
var _f = _e, { modalId } = _f, props = __objRest(_f, ["modalId"]);
|
|
138
|
+
const id = modalId || hooks.randomId();
|
|
139
|
+
dispatch({
|
|
140
|
+
type: "OPEN",
|
|
141
|
+
modal: {
|
|
142
|
+
id,
|
|
143
|
+
type: "context",
|
|
144
|
+
props,
|
|
145
|
+
ctx: modal
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
return id;
|
|
149
|
+
},
|
|
150
|
+
[dispatch]
|
|
151
|
+
);
|
|
152
|
+
const closeModal = React.useCallback(
|
|
153
|
+
(id, canceled) => {
|
|
154
|
+
dispatch({ type: "CLOSE", modalId: id, canceled });
|
|
155
|
+
},
|
|
156
|
+
[stateRef, dispatch]
|
|
157
|
+
);
|
|
143
158
|
events.useModalsEvents({
|
|
144
159
|
openModal,
|
|
145
160
|
openConfirmModal,
|
|
@@ -168,21 +183,20 @@ function ModalsProvider({ children, modalProps, labels, modals }) {
|
|
|
168
183
|
const ContextModal = modals[currentModal.ctx];
|
|
169
184
|
return {
|
|
170
185
|
modalProps: rest,
|
|
171
|
-
content: /* @__PURE__ */ React__default.createElement(ContextModal, {
|
|
172
|
-
innerProps,
|
|
173
|
-
context: ctx,
|
|
174
|
-
id: currentModal.id
|
|
175
|
-
})
|
|
186
|
+
content: /* @__PURE__ */ React__default.createElement(ContextModal, { innerProps, context: ctx, id: currentModal.id })
|
|
176
187
|
};
|
|
177
188
|
}
|
|
178
189
|
case "confirm": {
|
|
179
190
|
const { modalProps: separatedModalProps, confirmProps: separatedConfirmProps } = separateConfirmModalProps(currentModal.props);
|
|
180
191
|
return {
|
|
181
192
|
modalProps: separatedModalProps,
|
|
182
|
-
content: /* @__PURE__ */ React__default.createElement(
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
193
|
+
content: /* @__PURE__ */ React__default.createElement(
|
|
194
|
+
ConfirmModal.ConfirmModal,
|
|
195
|
+
__spreadProps(__spreadValues({}, separatedConfirmProps), {
|
|
196
|
+
id: currentModal.id,
|
|
197
|
+
labels: currentModal.props.labels || labels
|
|
198
|
+
})
|
|
199
|
+
)
|
|
186
200
|
};
|
|
187
201
|
}
|
|
188
202
|
case "content": {
|
|
@@ -201,14 +215,16 @@ function ModalsProvider({ children, modalProps, labels, modals }) {
|
|
|
201
215
|
}
|
|
202
216
|
};
|
|
203
217
|
const { modalProps: currentModalProps, content } = getCurrentModal();
|
|
204
|
-
return /* @__PURE__ */ React__default.createElement(context.ModalsContext.Provider, {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
218
|
+
return /* @__PURE__ */ React__default.createElement(context.ModalsContext.Provider, { value: ctx }, /* @__PURE__ */ React__default.createElement(
|
|
219
|
+
core.Modal,
|
|
220
|
+
__spreadProps(__spreadValues(__spreadValues({
|
|
221
|
+
zIndex: core.getDefaultZIndex("modal") + 1
|
|
222
|
+
}, modalProps), currentModalProps), {
|
|
223
|
+
opened: state.modals.length > 0,
|
|
224
|
+
onClose: () => closeModal(state.current.id)
|
|
225
|
+
}),
|
|
226
|
+
content
|
|
227
|
+
), children);
|
|
212
228
|
}
|
|
213
229
|
|
|
214
230
|
exports.ModalsProvider = ModalsProvider;
|
|
@@ -1 +1 @@
|
|
|
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 }) => 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,GAAG,MAAM,CAAC,qBAAqB,CAAC;AACvD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC;AACnD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,oBAAoB,CAAC;AACzD,IAAI,eAAe,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,KAAK,GAAG,IAAI,GAAG,GAAG,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAChK,IAAI,cAAc,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK;AAC/B,EAAE,KAAK,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;AAChC,IAAI,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC;AAClC,MAAM,eAAe,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;AACxC,EAAE,IAAI,mBAAmB;AACzB,IAAI,KAAK,IAAI,IAAI,IAAI,mBAAmB,CAAC,CAAC,CAAC,EAAE;AAC7C,MAAM,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,CA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
|
+
{"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,GAAG,MAAM,CAAC,qBAAqB,CAAC;AACvD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC;AACnD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,oBAAoB,CAAC;AACzD,IAAI,eAAe,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,KAAK,GAAG,IAAI,GAAG,GAAG,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAChK,IAAI,cAAc,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK;AAC/B,EAAE,KAAK,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;AAChC,IAAI,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC;AAClC,MAAM,eAAe,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;AACxC,EAAE,IAAI,mBAAmB;AACzB,IAAI,KAAK,IAAI,IAAI,IAAI,mBAAmB,CAAC,CAAC,CAAC,EAAE;AAC7C,MAAM,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC;AACpC,QAAQ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,OAAO;AACX,GAAG,EAAE,QAAQ,CAAC,CAAC;AACf;;;;"}
|
package/cjs/context.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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);\nModalsContext.displayName = '@mantine/modals/ModalsContext';\n"],"names":["createContext"],"mappings":";;;;;;AACY,MAAC,aAAa,GAAGA,mBAAa,CAAC,IAAI,EAAE;AACjD,aAAa,CAAC,WAAW,GAAG,+BAA+B;;;;"}
|
|
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
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var core = require('@mantine/core');
|
|
6
6
|
|
|
7
|
-
const [useModalsEvents, createEvent] =
|
|
7
|
+
const [useModalsEvents, createEvent] = core.createUseExternalEvents("mantine-modals");
|
|
8
8
|
const openModal = createEvent("openModal");
|
|
9
9
|
const closeModal = createEvent("closeModal");
|
|
10
10
|
const closeAllModals = createEvent("closeAllModals");
|
package/cjs/events.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.js","sources":["../src/events.ts"],"sourcesContent":["import { createUseExternalEvents } from '@mantine/
|
|
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
CHANGED
package/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;"}
|
|
@@ -8,7 +8,9 @@ var context = require('../context.js');
|
|
|
8
8
|
function useModals() {
|
|
9
9
|
const ctx = React.useContext(context.ModalsContext);
|
|
10
10
|
if (!ctx) {
|
|
11
|
-
throw new Error(
|
|
11
|
+
throw new Error(
|
|
12
|
+
"[@mantine/modals] useModals hook was called outside of context, wrap your app with ModalsProvider component"
|
|
13
|
+
);
|
|
12
14
|
}
|
|
13
15
|
return ctx;
|
|
14
16
|
}
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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;;;;"}
|
package/esm/ConfirmModal.js
CHANGED
|
@@ -45,17 +45,7 @@ function ConfirmModal({
|
|
|
45
45
|
typeof onConfirm === "function" && onConfirm();
|
|
46
46
|
closeOnConfirm && ctx.closeModal(id);
|
|
47
47
|
};
|
|
48
|
-
return /* @__PURE__ */ React.createElement(React.Fragment, null, children && /* @__PURE__ */ React.createElement(Box, {
|
|
49
|
-
mb: "md"
|
|
50
|
-
}, children), /* @__PURE__ */ React.createElement(Group, __spreadValues({
|
|
51
|
-
position: "right"
|
|
52
|
-
}, groupProps), /* @__PURE__ */ React.createElement(Button, __spreadProps(__spreadValues({
|
|
53
|
-
variant: "default"
|
|
54
|
-
}, cancelProps), {
|
|
55
|
-
onClick: handleCancel
|
|
56
|
-
}), (cancelProps == null ? void 0 : cancelProps.children) || cancelLabel), /* @__PURE__ */ React.createElement(Button, __spreadProps(__spreadValues({}, confirmProps), {
|
|
57
|
-
onClick: handleConfirm
|
|
58
|
-
}), (confirmProps == null ? void 0 : confirmProps.children) || confirmLabel)));
|
|
48
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, children && /* @__PURE__ */ React.createElement(Box, { mb: "md" }, children), /* @__PURE__ */ React.createElement(Group, __spreadValues({ justify: "flex-end" }, groupProps), /* @__PURE__ */ React.createElement(Button, __spreadProps(__spreadValues({ variant: "default" }, cancelProps), { onClick: handleCancel }), (cancelProps == null ? void 0 : cancelProps.children) || cancelLabel), /* @__PURE__ */ React.createElement(Button, __spreadProps(__spreadValues({}, confirmProps), { onClick: handleConfirm }), (confirmProps == null ? void 0 : confirmProps.children) || confirmLabel)));
|
|
59
49
|
}
|
|
60
50
|
|
|
61
51
|
export { ConfirmModal };
|
package/esm/ConfirmModal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfirmModal.js","sources":["../src/ConfirmModal.tsx"],"sourcesContent":["import React from 'react';\nimport { Button, Group, Box, ButtonProps, GroupProps } from '@mantine/core';\nimport { ConfirmLabels } from './context';\nimport { useModals } from './use-modals/use-modals';\n\nexport interface ConfirmModalProps {\n id?: string;\n children?: React.ReactNode;\n onCancel?(): void;\n onConfirm?(): void;\n closeOnConfirm?: boolean;\n closeOnCancel?: boolean;\n cancelProps?: ButtonProps & React.ComponentPropsWithoutRef<'button'>;\n confirmProps?: ButtonProps & React.ComponentPropsWithoutRef<'button'>;\n groupProps?: GroupProps;\n labels?: ConfirmLabels;\n}\n\nexport function ConfirmModal({\n id,\n cancelProps,\n confirmProps,\n labels = { cancel: '', confirm: '' },\n closeOnConfirm = true,\n closeOnCancel = true,\n groupProps,\n onCancel,\n onConfirm,\n children,\n}: ConfirmModalProps) {\n const { cancel: cancelLabel, confirm: confirmLabel } = labels;\n const ctx = useModals();\n\n const handleCancel = (event: React.MouseEvent<HTMLButtonElement>) => {\n typeof cancelProps?.onClick === 'function' && cancelProps?.onClick(event);\n typeof onCancel === 'function' && onCancel();\n closeOnCancel && ctx.closeModal(id);\n };\n\n const handleConfirm = (event: React.MouseEvent<HTMLButtonElement>) => {\n typeof confirmProps?.onClick === 'function' && confirmProps?.onClick(event);\n typeof onConfirm === 'function' && onConfirm();\n closeOnConfirm && ctx.closeModal(id);\n };\n\n return (\n <>\n {children && <Box mb=\"md\">{children}</Box>}\n\n <Group
|
|
1
|
+
{"version":3,"file":"ConfirmModal.js","sources":["../src/ConfirmModal.tsx"],"sourcesContent":["import React from 'react';\nimport { Button, Group, Box, ButtonProps, GroupProps } from '@mantine/core';\nimport { ConfirmLabels } from './context';\nimport { useModals } from './use-modals/use-modals';\n\nexport interface ConfirmModalProps {\n id?: string;\n children?: React.ReactNode;\n onCancel?(): void;\n onConfirm?(): void;\n closeOnConfirm?: boolean;\n closeOnCancel?: boolean;\n cancelProps?: ButtonProps & React.ComponentPropsWithoutRef<'button'>;\n confirmProps?: ButtonProps & React.ComponentPropsWithoutRef<'button'>;\n groupProps?: GroupProps;\n labels?: ConfirmLabels;\n}\n\nexport function ConfirmModal({\n id,\n cancelProps,\n confirmProps,\n labels = { cancel: '', confirm: '' },\n closeOnConfirm = true,\n closeOnCancel = true,\n groupProps,\n onCancel,\n onConfirm,\n children,\n}: ConfirmModalProps) {\n const { cancel: cancelLabel, confirm: confirmLabel } = labels;\n const ctx = useModals();\n\n const handleCancel = (event: React.MouseEvent<HTMLButtonElement>) => {\n typeof cancelProps?.onClick === 'function' && cancelProps?.onClick(event);\n typeof onCancel === 'function' && onCancel();\n closeOnCancel && ctx.closeModal(id!);\n };\n\n const handleConfirm = (event: React.MouseEvent<HTMLButtonElement>) => {\n typeof confirmProps?.onClick === 'function' && confirmProps?.onClick(event);\n typeof onConfirm === 'function' && onConfirm();\n closeOnConfirm && ctx.closeModal(id!);\n };\n\n return (\n <>\n {children && <Box mb=\"md\">{children}</Box>}\n\n <Group justify=\"flex-end\" {...groupProps}>\n <Button variant=\"default\" {...cancelProps} onClick={handleCancel}>\n {cancelProps?.children || cancelLabel}\n </Button>\n\n <Button {...confirmProps} onClick={handleConfirm}>\n {confirmProps?.children || confirmLabel}\n </Button>\n </Group>\n </>\n );\n}\n"],"names":[],"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,GAAG,MAAM,CAAC,qBAAqB,CAAC;AACvD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC;AACnD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,oBAAoB,CAAC;AACzD,IAAI,eAAe,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,KAAK,GAAG,IAAI,GAAG,GAAG,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAChK,IAAI,cAAc,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK;AAC/B,EAAE,KAAK,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;AAChC,IAAI,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC;AAClC,MAAM,eAAe,CAAC,CAAC,EAAE,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AC,CAAC;AACvoB;;;;"}
|
package/esm/ModalsProvider.js
CHANGED
|
@@ -86,52 +86,67 @@ function ModalsProvider({ children, modalProps, labels, modals }) {
|
|
|
86
86
|
const [state, dispatch] = useReducer(modalsReducer, { modals: [], current: null });
|
|
87
87
|
const stateRef = useRef(state);
|
|
88
88
|
stateRef.current = state;
|
|
89
|
-
const closeAll = useCallback(
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
89
|
+
const closeAll = useCallback(
|
|
90
|
+
(canceled) => {
|
|
91
|
+
dispatch({ type: "CLOSE_ALL", canceled });
|
|
92
|
+
},
|
|
93
|
+
[stateRef, dispatch]
|
|
94
|
+
);
|
|
95
|
+
const openModal = useCallback(
|
|
96
|
+
(_a) => {
|
|
97
|
+
var _b = _a, { modalId } = _b, props = __objRest(_b, ["modalId"]);
|
|
98
|
+
const id = modalId || randomId();
|
|
99
|
+
dispatch({
|
|
100
|
+
type: "OPEN",
|
|
101
|
+
modal: {
|
|
102
|
+
id,
|
|
103
|
+
type: "content",
|
|
104
|
+
props
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
return id;
|
|
108
|
+
},
|
|
109
|
+
[dispatch]
|
|
110
|
+
);
|
|
111
|
+
const openConfirmModal = useCallback(
|
|
112
|
+
(_c) => {
|
|
113
|
+
var _d = _c, { modalId } = _d, props = __objRest(_d, ["modalId"]);
|
|
114
|
+
const id = modalId || randomId();
|
|
115
|
+
dispatch({
|
|
116
|
+
type: "OPEN",
|
|
117
|
+
modal: {
|
|
118
|
+
id,
|
|
119
|
+
type: "confirm",
|
|
120
|
+
props
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
return id;
|
|
124
|
+
},
|
|
125
|
+
[dispatch]
|
|
126
|
+
);
|
|
127
|
+
const openContextModal = useCallback(
|
|
128
|
+
(modal, _e) => {
|
|
129
|
+
var _f = _e, { modalId } = _f, props = __objRest(_f, ["modalId"]);
|
|
130
|
+
const id = modalId || randomId();
|
|
131
|
+
dispatch({
|
|
132
|
+
type: "OPEN",
|
|
133
|
+
modal: {
|
|
134
|
+
id,
|
|
135
|
+
type: "context",
|
|
136
|
+
props,
|
|
137
|
+
ctx: modal
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
return id;
|
|
141
|
+
},
|
|
142
|
+
[dispatch]
|
|
143
|
+
);
|
|
144
|
+
const closeModal = useCallback(
|
|
145
|
+
(id, canceled) => {
|
|
146
|
+
dispatch({ type: "CLOSE", modalId: id, canceled });
|
|
147
|
+
},
|
|
148
|
+
[stateRef, dispatch]
|
|
149
|
+
);
|
|
135
150
|
useModalsEvents({
|
|
136
151
|
openModal,
|
|
137
152
|
openConfirmModal,
|
|
@@ -160,21 +175,20 @@ function ModalsProvider({ children, modalProps, labels, modals }) {
|
|
|
160
175
|
const ContextModal = modals[currentModal.ctx];
|
|
161
176
|
return {
|
|
162
177
|
modalProps: rest,
|
|
163
|
-
content: /* @__PURE__ */ React.createElement(ContextModal, {
|
|
164
|
-
innerProps,
|
|
165
|
-
context: ctx,
|
|
166
|
-
id: currentModal.id
|
|
167
|
-
})
|
|
178
|
+
content: /* @__PURE__ */ React.createElement(ContextModal, { innerProps, context: ctx, id: currentModal.id })
|
|
168
179
|
};
|
|
169
180
|
}
|
|
170
181
|
case "confirm": {
|
|
171
182
|
const { modalProps: separatedModalProps, confirmProps: separatedConfirmProps } = separateConfirmModalProps(currentModal.props);
|
|
172
183
|
return {
|
|
173
184
|
modalProps: separatedModalProps,
|
|
174
|
-
content: /* @__PURE__ */ React.createElement(
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
185
|
+
content: /* @__PURE__ */ React.createElement(
|
|
186
|
+
ConfirmModal,
|
|
187
|
+
__spreadProps(__spreadValues({}, separatedConfirmProps), {
|
|
188
|
+
id: currentModal.id,
|
|
189
|
+
labels: currentModal.props.labels || labels
|
|
190
|
+
})
|
|
191
|
+
)
|
|
178
192
|
};
|
|
179
193
|
}
|
|
180
194
|
case "content": {
|
|
@@ -193,14 +207,16 @@ function ModalsProvider({ children, modalProps, labels, modals }) {
|
|
|
193
207
|
}
|
|
194
208
|
};
|
|
195
209
|
const { modalProps: currentModalProps, content } = getCurrentModal();
|
|
196
|
-
return /* @__PURE__ */ React.createElement(ModalsContext.Provider, {
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
210
|
+
return /* @__PURE__ */ React.createElement(ModalsContext.Provider, { value: ctx }, /* @__PURE__ */ React.createElement(
|
|
211
|
+
Modal,
|
|
212
|
+
__spreadProps(__spreadValues(__spreadValues({
|
|
213
|
+
zIndex: getDefaultZIndex("modal") + 1
|
|
214
|
+
}, modalProps), currentModalProps), {
|
|
215
|
+
opened: state.modals.length > 0,
|
|
216
|
+
onClose: () => closeModal(state.current.id)
|
|
217
|
+
}),
|
|
218
|
+
content
|
|
219
|
+
), children);
|
|
204
220
|
}
|
|
205
221
|
|
|
206
222
|
export { ModalsProvider };
|
|
@@ -1 +1 @@
|
|
|
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 }) => 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":[],"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,GAAG,SAAS,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;AACnH,QAAQ,OAAO;AACf,UAAU,UAAU,EAAE,IAAI;AAC1B,UAAU,OAAO,kBAAkB,KAAK,CAAC,aAAa,CAAC,KAAK,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,uBAAuB,KAAK,CAAC,aAAa,CAAC,aAAa,CAAC,QAAQ,EAAE;AACrE,IAAI,KAAK,EAAE,GAAG;AACd,GAAG,kBAAkB,KAAK,CAAC,aAAa,CAAC,KAAK,EAAE,aAAa,CAAC,cAAc,CAAC,cAAc,CAAC;AAC5F,IAAI,MAAM,EAAE,gBAAgB,CAAC,OAAO,CAAC,GAAG,CAAC;AACzC,GAAG,EAAE,UAAU,CAAC,EAAE,iBAAiB,CAAC,EAAE;AACtC,IAAI,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC;AACnC,IAAI,OAAO,EAAE,MAAM,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;AAC/C,GAAG,CAAC,EAAE,OAAO,CAAC,EAAE,QAAQ,CAAC,CAAC;AAC1B;;;;"}
|
|
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":[],"mappings":";;;;;;;;AAAA,IAAI,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC;AACtC,IAAI,UAAU,GAAG,MAAM,CAAC,gBAAgB,CAAC;AACzC,IAAI,iBAAiB,G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,QAAQ,OAAO;AACf,UAAU,UAAU,EAAE,IAAI;AAC1B,UAAU,OAAO,kBAAkB,KAAK,CAAC,aAAa,CAAC,KAAK,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,uBAAuB,KAAK,CAAC,aAAa,CAAC,aAAa,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,kBAAkB,KAAK,CAAC,aAAa;AACxH,IAAI,KAAK;AACT,IAAI,aAAa,CAAC,cAAc,CAAC,cAAc,CAAC;AAChD,MAAM,MAAM,EAAE,gBAAgB,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/esm/context.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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);\nModalsContext.displayName = '@mantine/modals/ModalsContext';\n"],"names":[],"mappings":";;AACY,MAAC,aAAa,GAAG,aAAa,CAAC,IAAI,EAAE;AACjD,aAAa,CAAC,WAAW,GAAG,+BAA+B;;;;"}
|
|
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":[],"mappings":";;AACY,MAAC,aAAa,GAAG,aAAa,CAAC,IAAI,EAAE;AACjD,aAAa,CAAC,WAAW,GAAG,+BAA+B;;;;"}
|
package/esm/events.js
CHANGED
package/esm/events.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.js","sources":["../src/events.ts"],"sourcesContent":["import { createUseExternalEvents } from '@mantine/
|
|
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":[],"mappings":";;AACY,MAAC,CAAC,eAAe,EAAE,WAAW,CAAC,GAAG,uBAAuB,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/esm/index.js
CHANGED
package/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
|
|
@@ -4,7 +4,9 @@ import { ModalsContext } from '../context.js';
|
|
|
4
4
|
function useModals() {
|
|
5
5
|
const ctx = useContext(ModalsContext);
|
|
6
6
|
if (!ctx) {
|
|
7
|
-
throw new Error(
|
|
7
|
+
throw new Error(
|
|
8
|
+
"[@mantine/modals] useModals hook was called outside of context, wrap your app with ModalsProvider component"
|
|
9
|
+
);
|
|
8
10
|
}
|
|
9
11
|
return ctx;
|
|
10
12
|
}
|
|
@@ -1 +1 @@
|
|
|
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":[],"mappings":";;;AAEO,SAAS,SAAS,GAAG;AAC5B,EAAE,MAAM,GAAG,GAAG,UAAU,CAAC,aAAa,CAAC,CAAC;AACxC,EAAE,IAAI,CAAC,GAAG,EAAE;AACZ,IAAI,MAAM,IAAI,KAAK,
|
|
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":[],"mappings":";;;AAEO,SAAS,SAAS,GAAG;AAC5B,EAAE,MAAM,GAAG,GAAG,UAAU,CAAC,aAAa,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;;;;"}
|
package/lib/ConfirmModal.d.ts
CHANGED
|
@@ -13,5 +13,5 @@ export interface ConfirmModalProps {
|
|
|
13
13
|
groupProps?: GroupProps;
|
|
14
14
|
labels?: ConfirmLabels;
|
|
15
15
|
}
|
|
16
|
-
export declare function ConfirmModal({ id, cancelProps, confirmProps, labels, closeOnConfirm, closeOnCancel, groupProps, onCancel, onConfirm, children, }: ConfirmModalProps): JSX.Element;
|
|
16
|
+
export declare function ConfirmModal({ id, cancelProps, confirmProps, labels, closeOnConfirm, closeOnCancel, groupProps, onCancel, onConfirm, children, }: ConfirmModalProps): React.JSX.Element;
|
|
17
17
|
//# sourceMappingURL=ConfirmModal.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfirmModal.d.ts","sourceRoot":"","sources":["../src/ConfirmModal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAsB,WAAW,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC5E,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAG1C,MAAM,WAAW,iBAAiB;IAChC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,QAAQ,CAAC,IAAI,IAAI,CAAC;IAClB,SAAS,CAAC,IAAI,IAAI,CAAC;IACnB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,WAAW,CAAC,EAAE,WAAW,GAAG,KAAK,CAAC,wBAAwB,CAAC,QAAQ,CAAC,CAAC;IACrE,YAAY,CAAC,EAAE,WAAW,GAAG,KAAK,CA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 -1,9 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import React from 'react';
|
|
2
2
|
declare const _default: {
|
|
3
3
|
title: string;
|
|
4
4
|
};
|
|
5
5
|
export default _default;
|
|
6
|
-
export declare function Usage(): JSX.Element;
|
|
7
|
-
export declare function NestedInsideModal(): JSX.Element;
|
|
8
|
-
export declare function closeAll(): JSX.Element;
|
|
6
|
+
export declare function Usage(): React.JSX.Element;
|
|
7
|
+
export declare function NestedInsideModal(): React.JSX.Element;
|
|
8
|
+
export declare function closeAll(): React.JSX.Element;
|
|
9
9
|
//# sourceMappingURL=Modals.story.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Modals.story.d.ts","sourceRoot":"","sources":["../src/Modals.story.tsx"],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"Modals.story.d.ts","sourceRoot":"","sources":["../src/Modals.story.tsx"],"names":[],"mappings":"AACA,OAAO,KAAmB,MAAM,OAAO,CAAC;;;;AAaxC,wBAA2C;AAE3C,wBAAgB,KAAK,sBAwFpB;AAED,wBAAgB,iBAAiB,sBAmChC;AA4BD,wBAAgB,QAAQ,sBAMvB"}
|
package/lib/ModalsProvider.d.ts
CHANGED
|
@@ -10,5 +10,5 @@ export interface ModalsProviderProps {
|
|
|
10
10
|
/** Confirm modal labels */
|
|
11
11
|
labels?: ConfirmLabels;
|
|
12
12
|
}
|
|
13
|
-
export declare function ModalsProvider({ children, modalProps, labels, modals }: ModalsProviderProps): JSX.Element;
|
|
13
|
+
export declare function ModalsProvider({ children, modalProps, labels, modals }: ModalsProviderProps): React.JSX.Element;
|
|
14
14
|
//# sourceMappingURL=ModalsProvider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModalsProvider.d.ts","sourceRoot":"","sources":["../src/ModalsProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA0C,MAAM,OAAO,CAAC;AAG/D,OAAO,EAEL,aAAa,EACb,aAAa,EAGb,iBAAiB,EAElB,MAAM,WAAW,CAAC;AAKnB,MAAM,WAAW,mBAAmB;IAClC,eAAe;IACf,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAE1B,wBAAwB;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAE1D,4DAA4D;IAC5D,UAAU,CAAC,EAAE,aAAa,CAAC;IAE3B,2BAA2B;IAC3B,MAAM,CAAC,EAAE,aAAa,CAAC;CACxB;AAyCD,wBAAgB,cAAc,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,mBAAmB,
|
|
1
|
+
{"version":3,"file":"ModalsProvider.d.ts","sourceRoot":"","sources":["../src/ModalsProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA0C,MAAM,OAAO,CAAC;AAG/D,OAAO,EAEL,aAAa,EACb,aAAa,EAGb,iBAAiB,EAElB,MAAM,WAAW,CAAC;AAKnB,MAAM,WAAW,mBAAmB;IAClC,eAAe;IACf,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAE1B,wBAAwB;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAE1D,4DAA4D;IAC5D,UAAU,CAAC,EAAE,aAAa,CAAC;IAE3B,2BAA2B;IAC3B,MAAM,CAAC,EAAE,aAAa,CAAC;CACxB;AAyCD,wBAAgB,cAAc,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,mBAAmB,qBAqJ3F"}
|
package/lib/context.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAi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ACtD,gBAAgB,EAAE,CAAC,IAAI,SAAS,YAAY,EAC1C,KAAK,EAAE,IAAI,EACX,KAAK,EAAE,gBAAgB,CAAC,UAAU,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,KACtE,MAAM,CAAC;IACZ,UAAU,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IACrD,iBAAiB,EAAE,CAAC,IAAI,SAAS,YAAY,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IACrF,QAAQ,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,MAAM,MAAM,qBAAqB,GAAG,EAAE,CAAC;AAEvC,MAAM,MAAM,wBAAwB,GAAG,qBAAqB,SAAS;IACnE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAC1D,GACG,qBAAqB,GACrB;IACE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAC1D,CAAC;AAEN,MAAM,MAAM,aAAa,GAAG,wBAAwB,CAAC,QAAQ,CAAC,CAAC;AAE/D,MAAM,MAAM,YAAY,GAAG,MAAM,aAAa,CAAC;AAE/C,eAAO,MAAM,aAAa,6CAAiD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mantine/modals",
|
|
3
3
|
"description": "Modals manager based on Mantine components",
|
|
4
|
-
"version": "
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
|
|
4
|
+
"version": "7.0.0-alpha.22",
|
|
5
|
+
"types": "./lib/index.d.ts",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"import": "./esm/index.js",
|
|
9
|
+
"require": "./cjs/index.js",
|
|
10
|
+
"types": "./lib/index.d.ts"
|
|
11
|
+
},
|
|
12
|
+
"./styles.css": "./esm/index.css"
|
|
13
|
+
},
|
|
14
|
+
"sideEffects": false,
|
|
8
15
|
"license": "MIT",
|
|
9
16
|
"author": "Vitaly Rtishchev <rtivital@gmail.com>",
|
|
10
|
-
"sideEffects": false,
|
|
11
17
|
"homepage": "https://mantine.dev/others/modals/",
|
|
12
18
|
"repository": {
|
|
13
19
|
"url": "https://github.com/mantinedev/mantine.git",
|
|
@@ -27,13 +33,11 @@
|
|
|
27
33
|
"confirm"
|
|
28
34
|
],
|
|
29
35
|
"peerDependencies": {
|
|
30
|
-
"@mantine/core": "
|
|
31
|
-
"@mantine/hooks": "
|
|
32
|
-
"react": "
|
|
33
|
-
"react-dom": "
|
|
34
|
-
},
|
|
35
|
-
"dependencies": {
|
|
36
|
-
"@mantine/utils": "6.0.18"
|
|
36
|
+
"@mantine/core": "7.0.0-alpha.22",
|
|
37
|
+
"@mantine/hooks": "7.0.0-alpha.22",
|
|
38
|
+
"react": "^18.2.0",
|
|
39
|
+
"react-dom": "^18.2.0"
|
|
37
40
|
},
|
|
41
|
+
"dependencies": {},
|
|
38
42
|
"devDependencies": {}
|
|
39
43
|
}
|