@mantine/modals 9.0.1 → 9.1.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/ModalsProvider.cjs
CHANGED
|
@@ -40,10 +40,15 @@ function ModalsProvider({ children, modalProps, labels, modals }) {
|
|
|
40
40
|
});
|
|
41
41
|
const stateRef = (0, react.useRef)(state);
|
|
42
42
|
stateRef.current = state;
|
|
43
|
+
const closingRef = (0, react.useRef)(false);
|
|
43
44
|
const closeAll = (0, react.useCallback)((canceled) => {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
if (!closingRef.current) {
|
|
46
|
+
closingRef.current = true;
|
|
47
|
+
stateRef.current.modals.concat().reverse().forEach((modal) => {
|
|
48
|
+
require_reducer.handleCloseModal(modal, canceled);
|
|
49
|
+
});
|
|
50
|
+
closingRef.current = false;
|
|
51
|
+
}
|
|
47
52
|
dispatch({
|
|
48
53
|
type: "CLOSE_ALL",
|
|
49
54
|
canceled
|
|
@@ -87,8 +92,14 @@ function ModalsProvider({ children, modalProps, labels, modals }) {
|
|
|
87
92
|
return id;
|
|
88
93
|
}, [dispatch]);
|
|
89
94
|
const closeModal = (0, react.useCallback)((id, canceled) => {
|
|
90
|
-
|
|
91
|
-
|
|
95
|
+
if (!closingRef.current) {
|
|
96
|
+
const modal = stateRef.current.modals.find((m) => m.id === id);
|
|
97
|
+
if (modal) {
|
|
98
|
+
closingRef.current = true;
|
|
99
|
+
require_reducer.handleCloseModal(modal, canceled);
|
|
100
|
+
closingRef.current = false;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
92
103
|
dispatch({
|
|
93
104
|
type: "CLOSE",
|
|
94
105
|
modalId: id,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModalsProvider.cjs","names":["modalsReducer","ConfirmModal","ModalsContext","Modal"],"sources":["../src/ModalsProvider.tsx"],"sourcesContent":["import { useCallback, useReducer, useRef } from 'react';\nimport { getDefaultZIndex, Modal } from '@mantine/core';\nimport { randomId } from '@mantine/hooks';\nimport { ConfirmModal } from './ConfirmModal';\nimport {\n ConfirmLabels,\n ContextModalProps,\n ModalsContext,\n ModalsContextProps,\n ModalSettings,\n OpenConfirmModal,\n OpenContextModal,\n} from './context';\nimport { useModalsEvents } from './events';\nimport { handleCloseModal, modalsReducer } from './reducer';\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 stateRef.current.modals\n
|
|
1
|
+
{"version":3,"file":"ModalsProvider.cjs","names":["modalsReducer","ConfirmModal","ModalsContext","Modal"],"sources":["../src/ModalsProvider.tsx"],"sourcesContent":["import { useCallback, useReducer, useRef } from 'react';\nimport { getDefaultZIndex, Modal } from '@mantine/core';\nimport { randomId } from '@mantine/hooks';\nimport { ConfirmModal } from './ConfirmModal';\nimport {\n ConfirmLabels,\n ContextModalProps,\n ModalsContext,\n ModalsContextProps,\n ModalSettings,\n OpenConfirmModal,\n OpenContextModal,\n} from './context';\nimport { useModalsEvents } from './events';\nimport { handleCloseModal, modalsReducer } from './reducer';\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 const closingRef = useRef(false);\n\n const closeAll = useCallback(\n (canceled?: boolean) => {\n if (!closingRef.current) {\n closingRef.current = true;\n stateRef.current.modals\n .concat()\n .reverse()\n .forEach((modal) => {\n handleCloseModal(modal, canceled);\n });\n closingRef.current = false;\n }\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 if (!closingRef.current) {\n const modal = stateRef.current.modals.find((m) => m.id === id);\n if (modal) {\n closingRef.current = true;\n handleCloseModal(modal, canceled);\n closingRef.current = false;\n }\n }\n dispatch({ type: 'CLOSE', modalId: id, canceled });\n },\n [stateRef, dispatch]\n );\n\n const updateModal = useCallback(\n ({ modalId, ...newProps }: Partial<ModalSettings> & { modalId: string }) => {\n dispatch({\n type: 'UPDATE',\n modalId,\n newProps,\n });\n },\n [dispatch]\n );\n\n const updateContextModal = useCallback(\n ({ modalId, ...newProps }: { modalId: string } & Partial<OpenContextModal<any>>) => {\n dispatch({ type: 'UPDATE', modalId, newProps });\n },\n [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 updateModal,\n updateContextModal,\n });\n\n const ctx: ModalsContextProps = {\n modalProps: modalProps || {},\n modals: state.modals,\n openModal,\n openConfirmModal,\n openContextModal,\n closeModal,\n closeContextModal: closeModal,\n closeAll,\n updateModal,\n updateContextModal,\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 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 as any)}\n >\n {content}\n </Modal>\n\n {children}\n </ModalsContext>\n );\n}\n"],"mappings":";;;;;;;;;;AA8BA,SAAS,0BAA0B,OAAyB;AAC1D,KAAI,CAAC,MACH,QAAO;EAAE,cAAc,EAAE;EAAE,YAAY,EAAE;EAAE;CAG7C,MAAM,EACJ,IACA,UACA,UACA,WACA,gBACA,eACA,aACA,cACA,YACA,QACA,GAAG,WACD;AAEJ,QAAO;EACL,cAAc;GACZ;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACD;EACD,YAAY;GACV;GACA,GAAG;GACJ;EACF;;AAGH,SAAgB,eAAe,EAAE,UAAU,YAAY,QAAQ,UAA+B;CAC5F,MAAM,CAAC,OAAO,aAAA,GAAA,MAAA,YAAuBA,gBAAAA,eAAe;EAAE,QAAQ,EAAE;EAAE,SAAS;EAAM,CAAC;CAClF,MAAM,YAAA,GAAA,MAAA,QAAkB,MAAM;AAC9B,UAAS,UAAU;CACnB,MAAM,cAAA,GAAA,MAAA,QAAoB,MAAM;CAEhC,MAAM,YAAA,GAAA,MAAA,cACH,aAAuB;AACtB,MAAI,CAAC,WAAW,SAAS;AACvB,cAAW,UAAU;AACrB,YAAS,QAAQ,OACd,QAAQ,CACR,SAAS,CACT,SAAS,UAAU;AAClB,oBAAA,iBAAiB,OAAO,SAAS;KACjC;AACJ,cAAW,UAAU;;AAEvB,WAAS;GAAE,MAAM;GAAa;GAAU,CAAC;IAE3C,CAAC,UAAU,SAAS,CACrB;CAED,MAAM,aAAA,GAAA,MAAA,cACH,EAAE,S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
|
package/esm/ModalsProvider.mjs
CHANGED
|
@@ -40,10 +40,15 @@ function ModalsProvider({ children, modalProps, labels, modals }) {
|
|
|
40
40
|
});
|
|
41
41
|
const stateRef = useRef(state);
|
|
42
42
|
stateRef.current = state;
|
|
43
|
+
const closingRef = useRef(false);
|
|
43
44
|
const closeAll = useCallback((canceled) => {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
if (!closingRef.current) {
|
|
46
|
+
closingRef.current = true;
|
|
47
|
+
stateRef.current.modals.concat().reverse().forEach((modal) => {
|
|
48
|
+
handleCloseModal(modal, canceled);
|
|
49
|
+
});
|
|
50
|
+
closingRef.current = false;
|
|
51
|
+
}
|
|
47
52
|
dispatch({
|
|
48
53
|
type: "CLOSE_ALL",
|
|
49
54
|
canceled
|
|
@@ -87,8 +92,14 @@ function ModalsProvider({ children, modalProps, labels, modals }) {
|
|
|
87
92
|
return id;
|
|
88
93
|
}, [dispatch]);
|
|
89
94
|
const closeModal = useCallback((id, canceled) => {
|
|
90
|
-
|
|
91
|
-
|
|
95
|
+
if (!closingRef.current) {
|
|
96
|
+
const modal = stateRef.current.modals.find((m) => m.id === id);
|
|
97
|
+
if (modal) {
|
|
98
|
+
closingRef.current = true;
|
|
99
|
+
handleCloseModal(modal, canceled);
|
|
100
|
+
closingRef.current = false;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
92
103
|
dispatch({
|
|
93
104
|
type: "CLOSE",
|
|
94
105
|
modalId: id,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModalsProvider.mjs","names":[],"sources":["../src/ModalsProvider.tsx"],"sourcesContent":["import { useCallback, useReducer, useRef } from 'react';\nimport { getDefaultZIndex, Modal } from '@mantine/core';\nimport { randomId } from '@mantine/hooks';\nimport { ConfirmModal } from './ConfirmModal';\nimport {\n ConfirmLabels,\n ContextModalProps,\n ModalsContext,\n ModalsContextProps,\n ModalSettings,\n OpenConfirmModal,\n OpenContextModal,\n} from './context';\nimport { useModalsEvents } from './events';\nimport { handleCloseModal, modalsReducer } from './reducer';\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 stateRef.current.modals\n
|
|
1
|
+
{"version":3,"file":"ModalsProvider.mjs","names":[],"sources":["../src/ModalsProvider.tsx"],"sourcesContent":["import { useCallback, useReducer, useRef } from 'react';\nimport { getDefaultZIndex, Modal } from '@mantine/core';\nimport { randomId } from '@mantine/hooks';\nimport { ConfirmModal } from './ConfirmModal';\nimport {\n ConfirmLabels,\n ContextModalProps,\n ModalsContext,\n ModalsContextProps,\n ModalSettings,\n OpenConfirmModal,\n OpenContextModal,\n} from './context';\nimport { useModalsEvents } from './events';\nimport { handleCloseModal, modalsReducer } from './reducer';\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 const closingRef = useRef(false);\n\n const closeAll = useCallback(\n (canceled?: boolean) => {\n if (!closingRef.current) {\n closingRef.current = true;\n stateRef.current.modals\n .concat()\n .reverse()\n .forEach((modal) => {\n handleCloseModal(modal, canceled);\n });\n closingRef.current = false;\n }\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 if (!closingRef.current) {\n const modal = stateRef.current.modals.find((m) => m.id === id);\n if (modal) {\n closingRef.current = true;\n handleCloseModal(modal, canceled);\n closingRef.current = false;\n }\n }\n dispatch({ type: 'CLOSE', modalId: id, canceled });\n },\n [stateRef, dispatch]\n );\n\n const updateModal = useCallback(\n ({ modalId, ...newProps }: Partial<ModalSettings> & { modalId: string }) => {\n dispatch({\n type: 'UPDATE',\n modalId,\n newProps,\n });\n },\n [dispatch]\n );\n\n const updateContextModal = useCallback(\n ({ modalId, ...newProps }: { modalId: string } & Partial<OpenContextModal<any>>) => {\n dispatch({ type: 'UPDATE', modalId, newProps });\n },\n [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 updateModal,\n updateContextModal,\n });\n\n const ctx: ModalsContextProps = {\n modalProps: modalProps || {},\n modals: state.modals,\n openModal,\n openConfirmModal,\n openContextModal,\n closeModal,\n closeContextModal: closeModal,\n closeAll,\n updateModal,\n updateContextModal,\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 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 as any)}\n >\n {content}\n </Modal>\n\n {children}\n </ModalsContext>\n );\n}\n"],"mappings":";;;;;;;;;;AA8BA,SAAS,0BAA0B,OAAyB;AAC1D,KAAI,CAAC,MACH,QAAO;EAAE,cAAc,EAAE;EAAE,YAAY,EAAE;EAAE;CAG7C,MAAM,EACJ,IACA,UACA,UACA,WACA,gBACA,eACA,aACA,cACA,YACA,QACA,GAAG,WACD;AAEJ,QAAO;EACL,cAAc;GACZ;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACD;EACD,YAAY;GACV;GACA,GAAG;GACJ;EACF;;AAGH,SAAgB,eAAe,EAAE,UAAU,YAAY,QAAQ,UAA+B;CAC5F,MAAM,CAAC,OAAO,YAAY,WAAW,eAAe;EAAE,QAAQ,EAAE;EAAE,SAAS;EAAM,CAAC;CAClF,MAAM,WAAW,OAAO,MAAM;AAC9B,UAAS,UAAU;CACnB,MAAM,aAAa,OAAO,MAAM;CAEhC,MAAM,WAAW,aACd,aAAuB;AACtB,MAAI,CAAC,WAAW,SAAS;AACvB,cAAW,UAAU;AACrB,YAAS,QAAQ,OACd,QAAQ,CACR,SAAS,CACT,SAAS,UAAU;AAClB,qBAAiB,OAAO,SAAS;KACjC;AACJ,cAAW,UAAU;;AAEvB,WAAS;GAAE,MAAM;GAAa;GAAU,CAAC;IAE3C,CAAC,UAAU,SAAS,CACrB;CAED,MAAM,YAAY,aACf,EAAE,SAAS,GAAG,YAA2B;EACxC,MAAM,KAAK,WAAW,UAAU;AAEhC,WAAS;GACP,MAAM;GACN,OAAO;IACL;IACA,MAAM;IACN;IACD;GACF,CAAC;AACF,SAAO;IAET,CAAC,SAAS,CACX;CAED,MAAM,mBAAmB,aACtB,EAAE,SAAS,GAAG,YAA8B;EAC3C,MAAM,KAAK,WAAW,UAAU;AAChC,WAAS;GACP,MAAM;GACN,OAAO;IACL;IACA,MAAM;IACN;IACD;G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AY;KACZ,SAAS,oBAAC,cAAD;MAA0B;MAAY,SAAS;MAAK,IAAI,aAAa;MAAM,CAAA;KACrF;;GAEH,KAAK,WAAW;IACd,MAAM,EAAE,YAAY,qBAAqB,cAAc,0BACrD,0BAA0B,aAAa,MAAM;AAE/C,WAAO;KACL,YAAY;KACZ,SACE,oBAAC,cAAD;MACE,GAAI;MACJ,IAAI,aAAa;MACjB,QAAQ,aAAa,MAAM,UAAU;MACrC,CAAA;KAEL;;GAEH,KAAK,WAAW;IACd,MAAM,EAAE,UAAU,sBAAsB,GAAG,SAAS,aAAa;AAEjE,WAAO;KACL,YAAY;KACZ,SAAS;KACV;;GAEH,QACE,QAAO;IACL,YAAY,EAAE;IACd,SAAS;IACV;;;CAKP,MAAM,EAAE,YAAY,mBAAmB,YAAY,iBAAiB;AAEpE,QACE,qBAAC,eAAD;EAAe,OAAO;YAAtB,CACE,oBAAC,OAAD;GACE,QAAQ,iBAAiB,QAAQ,GAAG;GACpC,GAAI;GACJ,GAAI;GACJ,QAAQ,MAAM,OAAO,SAAS;GAC9B,eAAe,WAAW,MAAM,SAAS,GAAU;aAElD;GACK,CAAA,EAEP,SACa"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mantine/modals",
|
|
3
|
-
"version": "9.0
|
|
3
|
+
"version": "9.1.0",
|
|
4
4
|
"description": "Modals manager based on Mantine components",
|
|
5
5
|
"homepage": "https://mantine.dev/x/modals/",
|
|
6
6
|
"license": "MIT",
|
|
@@ -39,15 +39,15 @@
|
|
|
39
39
|
"directory": "packages/@mantine/modals"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
|
-
"@mantine/core": "9.0
|
|
43
|
-
"@mantine/hooks": "9.0
|
|
42
|
+
"@mantine/core": "9.1.0",
|
|
43
|
+
"@mantine/hooks": "9.1.0",
|
|
44
44
|
"react": "^19.2.0",
|
|
45
45
|
"react-dom": "^19.2.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@mantine/core": "workspace:*",
|
|
49
49
|
"@mantine/hooks": "workspace:*",
|
|
50
|
-
"react": "19.2.
|
|
51
|
-
"react-dom": "19.2.
|
|
50
|
+
"react": "19.2.5",
|
|
51
|
+
"react-dom": "19.2.5"
|
|
52
52
|
}
|
|
53
53
|
}
|