@mantine/modals 3.3.2 → 3.4.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.
@@ -100,13 +100,16 @@ function ModalsProvider({ children, modalProps, labels, modals }) {
100
100
  return id;
101
101
  };
102
102
  const closeModal = (id) => {
103
- if (state.length <= 1) {
104
- closeAll();
105
- } else {
106
- const index = state.findIndex((item) => item.id === id);
107
- index !== -1 && handlers.remove(index);
108
- setCurrentModal(state[state.length - 2]);
109
- }
103
+ var _a2, _b;
104
+ const index = state.findIndex((item) => item.id === id);
105
+ const modal = state.find((item) => item.id === id);
106
+ (_b = (_a2 = modal == null ? void 0 : modal.props) == null ? void 0 : _a2.onClose) == null ? void 0 : _b.call(_a2);
107
+ index !== -1 && handlers.remove(index);
108
+ setCurrentModal(state[state.length - 2] || {
109
+ id: null,
110
+ props: null,
111
+ type: "content"
112
+ });
110
113
  };
111
114
  const ContextModal = (currentModal == null ? void 0 : currentModal.type) === "context" ? modals[currentModal == null ? void 0 : currentModal.ctx] : () => null;
112
115
  const ctx = {
@@ -126,10 +129,10 @@ function ModalsProvider({ children, modalProps, labels, modals }) {
126
129
  })) : (_a = currentModal == null ? void 0 : currentModal.props) == null ? void 0 : _a.children;
127
130
  return /* @__PURE__ */ React__default.createElement(context.modalsContext.Provider, {
128
131
  value: ctx
129
- }, /* @__PURE__ */ React__default.createElement(core.Modal, __spreadValues(__spreadValues({
132
+ }, /* @__PURE__ */ React__default.createElement(core.Modal, __spreadProps(__spreadValues(__spreadValues({}, modalProps), (currentModal == null ? void 0 : currentModal.type) === "confirm" ? extractConfirmModalProps(currentModal == null ? void 0 : currentModal.props) : currentModal == null ? void 0 : currentModal.props), {
130
133
  opened: state.length > 0,
131
134
  onClose: () => closeModal(currentModal == null ? void 0 : currentModal.id)
132
- }, modalProps), (currentModal == null ? void 0 : currentModal.type) === "confirm" ? extractConfirmModalProps(currentModal == null ? void 0 : currentModal.props) : currentModal == null ? void 0 : currentModal.props), content), children);
135
+ }), content), children);
133
136
  }
134
137
 
135
138
  exports.ModalsProvider = ModalsProvider;
@@ -1 +1 @@
1
- {"version":3,"file":"ModalsProvider.js","sources":["../src/ModalsProvider.tsx"],"sourcesContent":["import React, { useState } from 'react';\nimport { Modal } from '@mantine/core';\nimport { useListState, randomId } from '@mantine/hooks';\nimport {\n modalsContext,\n ModalsContext,\n ModalSettings,\n ConfirmLabels,\n OpenConfirmModal,\n ModalState,\n} from './context';\nimport { ConfirmModal } from './ConfirmModal';\n\nexport interface ContextModalProps {\n context: ModalsContext;\n id: string;\n}\n\nexport interface ModalsProviderProps {\n /** Your app */\n children: React.ReactNode;\n\n /** Predefined modals */\n modals?: Record<string, React.FC<ContextModalProps>>;\n\n /** Shared Modal component props, applied for every modal */\n modalProps?: ModalSettings;\n\n /** Confirm modal labels */\n labels?: ConfirmLabels;\n}\n\nfunction extractConfirmModalProps(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 { id, ...others };\n}\n\nexport function ModalsProvider({ children, modalProps, labels, modals }: ModalsProviderProps) {\n const [state, handlers] = useListState<ModalState>([]);\n const [currentModal, setCurrentModal] = useState<ModalState>({\n id: null,\n props: null,\n type: 'content',\n });\n const closeAll = () => handlers.setState([]);\n\n const openModal = (props: ModalSettings) => {\n const id = props.id || randomId();\n handlers.append({ id, props, type: 'content' });\n setCurrentModal({ id, props, type: 'content' });\n return id;\n };\n\n const openConfirmModal = (props: OpenConfirmModal) => {\n const id = props.id || randomId();\n handlers.append({ id, props, type: 'confirm' });\n setCurrentModal({ id, props, type: 'confirm' });\n return id;\n };\n\n const openContextModal = (modal: string, props: OpenConfirmModal) => {\n const id = props.id || randomId();\n handlers.append({ id, props, type: 'context', ctx: modal });\n setCurrentModal({ id, props, type: 'context', ctx: modal });\n return id;\n };\n\n const closeModal = (id: string) => {\n if (state.length <= 1) {\n closeAll();\n } else {\n const index = state.findIndex((item) => item.id === id);\n index !== -1 && handlers.remove(index);\n setCurrentModal(state[state.length - 2]);\n }\n };\n\n const ContextModal = currentModal?.type === 'context' ? modals[currentModal?.ctx] : () => null;\n\n const ctx = {\n modals: state,\n openModal,\n openConfirmModal,\n openContextModal,\n closeModal,\n closeAll,\n };\n\n const content =\n currentModal?.type === 'context' ? (\n <ContextModal context={ctx} id={currentModal?.id} />\n ) : currentModal?.type === 'confirm' ? (\n <ConfirmModal\n {...currentModal.props}\n id={currentModal.id}\n labels={currentModal.props.labels || labels}\n />\n ) : (\n currentModal?.props?.children\n );\n\n return (\n <modalsContext.Provider value={ctx}>\n <Modal\n opened={state.length > 0}\n onClose={() => closeModal(currentModal?.id)}\n {...modalProps}\n {...(currentModal?.type === 'confirm'\n ? extractConfirmModalProps(currentModal?.props)\n : currentModal?.props)}\n >\n {content}\n </Modal>\n\n {children}\n </modalsContext.Provider>\n );\n}\n"],"names":["useListState","useState","randomId","React","ConfirmModal","modalsContext","Modal"],"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,EA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ModalsProvider.js","sources":["../src/ModalsProvider.tsx"],"sourcesContent":["import React, { useState } from 'react';\nimport { Modal } from '@mantine/core';\nimport { useListState, randomId } from '@mantine/hooks';\nimport {\n modalsContext,\n ModalsContext,\n ModalSettings,\n ConfirmLabels,\n OpenConfirmModal,\n ModalState,\n} from './context';\nimport { ConfirmModal } from './ConfirmModal';\n\nexport interface ContextModalProps {\n context: ModalsContext;\n id: string;\n}\n\nexport interface ModalsProviderProps {\n /** Your app */\n children: React.ReactNode;\n\n /** Predefined modals */\n modals?: Record<string, React.FC<ContextModalProps>>;\n\n /** Shared Modal component props, applied for every modal */\n modalProps?: ModalSettings;\n\n /** Confirm modal labels */\n labels?: ConfirmLabels;\n}\n\nfunction extractConfirmModalProps(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 { id, ...others };\n}\n\nexport function ModalsProvider({ children, modalProps, labels, modals }: ModalsProviderProps) {\n const [state, handlers] = useListState<ModalState>([]);\n const [currentModal, setCurrentModal] = useState<ModalState>({\n id: null,\n props: null,\n type: 'content',\n });\n const closeAll = () => handlers.setState([]);\n\n const openModal = (props: ModalSettings) => {\n const id = props.id || randomId();\n handlers.append({ id, props, type: 'content' });\n setCurrentModal({ id, props, type: 'content' });\n return id;\n };\n\n const openConfirmModal = (props: OpenConfirmModal) => {\n const id = props.id || randomId();\n handlers.append({ id, props, type: 'confirm' });\n setCurrentModal({ id, props, type: 'confirm' });\n return id;\n };\n\n const openContextModal = (modal: string, props: OpenConfirmModal) => {\n const id = props.id || randomId();\n handlers.append({ id, props, type: 'context', ctx: modal });\n setCurrentModal({ id, props, type: 'context', ctx: modal });\n return id;\n };\n\n const closeModal = (id: string) => {\n const index = state.findIndex((item) => item.id === id);\n const modal = state.find((item) => item.id === id);\n modal?.props?.onClose?.();\n index !== -1 && handlers.remove(index);\n setCurrentModal(\n state[state.length - 2] || {\n id: null,\n props: null,\n type: 'content',\n }\n );\n };\n\n const ContextModal = currentModal?.type === 'context' ? modals[currentModal?.ctx] : () => null;\n\n const ctx = {\n modals: state,\n openModal,\n openConfirmModal,\n openContextModal,\n closeModal,\n closeAll,\n };\n\n const content =\n currentModal?.type === 'context' ? (\n <ContextModal context={ctx} id={currentModal?.id} />\n ) : currentModal?.type === 'confirm' ? (\n <ConfirmModal\n {...currentModal.props}\n id={currentModal.id}\n labels={currentModal.props.labels || labels}\n />\n ) : (\n currentModal?.props?.children\n );\n\n return (\n <modalsContext.Provider value={ctx}>\n <Modal\n {...modalProps}\n {...(currentModal?.type === 'confirm'\n ? extractConfirmModalProps(currentModal?.props)\n : currentModal?.props)}\n opened={state.length > 0}\n onClose={() => closeModal(currentModal?.id)}\n >\n {content}\n </Modal>\n\n {children}\n </modalsContext.Provider>\n );\n}\n"],"names":["useListState","useState","randomId","React","ConfirmModal","modalsContext","Modal"],"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,CAA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,CAAC,KAAK,CAAC,GAAG,YAAY,IAAI,IAAI,GAAG,KAAK,CAAC,GAAG,YAAY,CAAC,KAAK,CAAC,EAAE;AACrT,IAAI,MAAM,EAAE,KAAK,CAAC,MAAM,GAAG,CAAC;AAC5B,IAAI,OAAO,EAAE,MAAM,UAAU,CAAC,YAAY,IAAI,IAAI,GAAG,KAAK,CAAC,GAAG,YAAY,CAAC,EAAE,CAAC;AAC9E,GAAG,CAAC,EAAE,OAAO,CAAC,EAAE,QAAQ,CAAC,CAAC;AAC1B;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"context.js","sources":["../src/context.ts"],"sourcesContent":["import { createContext } from 'react';\nimport { ModalProps } from '@mantine/core';\nimport type { ConfirmModalProps } from './ConfirmModal';\n\nexport type ModalSettings = Omit<ModalProps, 'opened' | 'onClose'>;\n\nexport type ConfirmLabels = Record<'confirm' | 'cancel', string>;\n\nexport interface OpenConfirmModal extends ModalSettings, ConfirmModalProps {}\n\nexport type ModalState =\n | { id: string; props: ModalSettings; type: 'content' }\n | { id: string; props: OpenConfirmModal; type: 'confirm' }\n | { id: string; props: OpenConfirmModal; type: 'context'; ctx: string };\n\nexport interface ModalsContext {\n modals: ModalState[];\n openModal: (props: ModalSettings) => string;\n openConfirmModal: (props: OpenConfirmModal) => string;\n openContextModal: (modal: string, props: ModalSettings) => string;\n closeModal: (id: string) => void;\n closeAll: () => void;\n}\n\nexport const modalsContext = createContext<ModalsContext>({\n modals: [],\n openModal: () => null,\n openConfirmModal: () => null,\n openContextModal: () => null,\n closeAll: () => {},\n closeModal: () => {},\n});\n"],"names":["createContext"],"mappings":";;;;;;AACY,MAAC,aAAa,GAAGA,mBAAa,CAAC;AAC3C,EAAE,MAAM,EAAE,EAAE;AACZ,EAAE,SAAS,EAAE,MAAM,IAAI;AACvB,EAAE,gBAAgB,EAAE,MAAM,IAAI;AAC9B,EAAE,gBAAgB,EAAE,MAAM,IAAI;AAC9B,EAAE,QAAQ,EAAE,MAAM;AAClB,GAAG;AACH,EAAE,UAAU,EAAE,MAAM;AACpB,GAAG;AACH,CAAC;;;;"}
1
+ {"version":3,"file":"context.js","sources":["../src/context.ts"],"sourcesContent":["import { createContext } from 'react';\nimport { ModalProps } from '@mantine/core';\nimport type { ConfirmModalProps } from './ConfirmModal';\n\nexport type ModalSettings = Partial<Omit<ModalProps, 'opened'>>;\n\nexport type ConfirmLabels = Record<'confirm' | 'cancel', string>;\n\nexport interface OpenConfirmModal extends ModalSettings, ConfirmModalProps {}\n\nexport type ModalState =\n | { id: string; props: ModalSettings; type: 'content' }\n | { id: string; props: OpenConfirmModal; type: 'confirm' }\n | { id: string; props: OpenConfirmModal; type: 'context'; ctx: string };\n\nexport interface ModalsContext {\n modals: ModalState[];\n openModal: (props: ModalSettings) => string;\n openConfirmModal: (props: OpenConfirmModal) => string;\n openContextModal: (modal: string, props: ModalSettings) => string;\n closeModal: (id: string) => void;\n closeAll: () => void;\n}\n\nexport const modalsContext = createContext<ModalsContext>({\n modals: [],\n openModal: () => null,\n openConfirmModal: () => null,\n openContextModal: () => null,\n closeAll: () => {},\n closeModal: () => {},\n});\n"],"names":["createContext"],"mappings":";;;;;;AACY,MAAC,aAAa,GAAGA,mBAAa,CAAC;AAC3C,EAAE,MAAM,EAAE,EAAE;AACZ,EAAE,SAAS,EAAE,MAAM,IAAI;AACvB,EAAE,gBAAgB,EAAE,MAAM,IAAI;AAC9B,EAAE,gBAAgB,EAAE,MAAM,IAAI;AAC9B,EAAE,QAAQ,EAAE,MAAM;AAClB,GAAG;AACH,EAAE,UAAU,EAAE,MAAM;AACpB,GAAG;AACH,CAAC;;;;"}
@@ -92,13 +92,16 @@ function ModalsProvider({ children, modalProps, labels, modals }) {
92
92
  return id;
93
93
  };
94
94
  const closeModal = (id) => {
95
- if (state.length <= 1) {
96
- closeAll();
97
- } else {
98
- const index = state.findIndex((item) => item.id === id);
99
- index !== -1 && handlers.remove(index);
100
- setCurrentModal(state[state.length - 2]);
101
- }
95
+ var _a2, _b;
96
+ const index = state.findIndex((item) => item.id === id);
97
+ const modal = state.find((item) => item.id === id);
98
+ (_b = (_a2 = modal == null ? void 0 : modal.props) == null ? void 0 : _a2.onClose) == null ? void 0 : _b.call(_a2);
99
+ index !== -1 && handlers.remove(index);
100
+ setCurrentModal(state[state.length - 2] || {
101
+ id: null,
102
+ props: null,
103
+ type: "content"
104
+ });
102
105
  };
103
106
  const ContextModal = (currentModal == null ? void 0 : currentModal.type) === "context" ? modals[currentModal == null ? void 0 : currentModal.ctx] : () => null;
104
107
  const ctx = {
@@ -118,10 +121,10 @@ function ModalsProvider({ children, modalProps, labels, modals }) {
118
121
  })) : (_a = currentModal == null ? void 0 : currentModal.props) == null ? void 0 : _a.children;
119
122
  return /* @__PURE__ */ React.createElement(modalsContext.Provider, {
120
123
  value: ctx
121
- }, /* @__PURE__ */ React.createElement(Modal, __spreadValues(__spreadValues({
124
+ }, /* @__PURE__ */ React.createElement(Modal, __spreadProps(__spreadValues(__spreadValues({}, modalProps), (currentModal == null ? void 0 : currentModal.type) === "confirm" ? extractConfirmModalProps(currentModal == null ? void 0 : currentModal.props) : currentModal == null ? void 0 : currentModal.props), {
122
125
  opened: state.length > 0,
123
126
  onClose: () => closeModal(currentModal == null ? void 0 : currentModal.id)
124
- }, modalProps), (currentModal == null ? void 0 : currentModal.type) === "confirm" ? extractConfirmModalProps(currentModal == null ? void 0 : currentModal.props) : currentModal == null ? void 0 : currentModal.props), content), children);
127
+ }), content), children);
125
128
  }
126
129
 
127
130
  export { ModalsProvider };
@@ -1 +1 @@
1
- {"version":3,"file":"ModalsProvider.js","sources":["../src/ModalsProvider.tsx"],"sourcesContent":["import React, { useState } from 'react';\nimport { Modal } from '@mantine/core';\nimport { useListState, randomId } from '@mantine/hooks';\nimport {\n modalsContext,\n ModalsContext,\n ModalSettings,\n ConfirmLabels,\n OpenConfirmModal,\n ModalState,\n} from './context';\nimport { ConfirmModal } from './ConfirmModal';\n\nexport interface ContextModalProps {\n context: ModalsContext;\n id: string;\n}\n\nexport interface ModalsProviderProps {\n /** Your app */\n children: React.ReactNode;\n\n /** Predefined modals */\n modals?: Record<string, React.FC<ContextModalProps>>;\n\n /** Shared Modal component props, applied for every modal */\n modalProps?: ModalSettings;\n\n /** Confirm modal labels */\n labels?: ConfirmLabels;\n}\n\nfunction extractConfirmModalProps(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 { id, ...others };\n}\n\nexport function ModalsProvider({ children, modalProps, labels, modals }: ModalsProviderProps) {\n const [state, handlers] = useListState<ModalState>([]);\n const [currentModal, setCurrentModal] = useState<ModalState>({\n id: null,\n props: null,\n type: 'content',\n });\n const closeAll = () => handlers.setState([]);\n\n const openModal = (props: ModalSettings) => {\n const id = props.id || randomId();\n handlers.append({ id, props, type: 'content' });\n setCurrentModal({ id, props, type: 'content' });\n return id;\n };\n\n const openConfirmModal = (props: OpenConfirmModal) => {\n const id = props.id || randomId();\n handlers.append({ id, props, type: 'confirm' });\n setCurrentModal({ id, props, type: 'confirm' });\n return id;\n };\n\n const openContextModal = (modal: string, props: OpenConfirmModal) => {\n const id = props.id || randomId();\n handlers.append({ id, props, type: 'context', ctx: modal });\n setCurrentModal({ id, props, type: 'context', ctx: modal });\n return id;\n };\n\n const closeModal = (id: string) => {\n if (state.length <= 1) {\n closeAll();\n } else {\n const index = state.findIndex((item) => item.id === id);\n index !== -1 && handlers.remove(index);\n setCurrentModal(state[state.length - 2]);\n }\n };\n\n const ContextModal = currentModal?.type === 'context' ? modals[currentModal?.ctx] : () => null;\n\n const ctx = {\n modals: state,\n openModal,\n openConfirmModal,\n openContextModal,\n closeModal,\n closeAll,\n };\n\n const content =\n currentModal?.type === 'context' ? (\n <ContextModal context={ctx} id={currentModal?.id} />\n ) : currentModal?.type === 'confirm' ? (\n <ConfirmModal\n {...currentModal.props}\n id={currentModal.id}\n labels={currentModal.props.labels || labels}\n />\n ) : (\n currentModal?.props?.children\n );\n\n return (\n <modalsContext.Provider value={ctx}>\n <Modal\n opened={state.length > 0}\n onClose={() => closeModal(currentModal?.id)}\n {...modalProps}\n {...(currentModal?.type === 'confirm'\n ? extractConfirmModalProps(currentModal?.props)\n : currentModal?.props)}\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,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,IAA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IAAI,IAAI,GAAG,KAAK,CAAC,GAAG,YAAY,CAAC,KAAK,KAAK,IAAI,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC;AACjG,EAAE,uBAAuB,KAAK,CAAC,aAAa,CAAC,aAAa,CAAC,QAAQ,EAAE;AACrE,IAAI,KAAK,EAAE,GAAG;AACd,GAAG,kBAAkB,KAAK,CAAC,aAAa,CAAC,KAAK,EAAE,cAAc,CAAC,cAAc,CAAC;AAC9E,IAAI,MAAM,EAAE,KAAK,CAAC,MAAM,GAAG,CAAC;AAC5B,IAAI,OAAO,EAAE,MAAM,UAAU,CAAC,YAAY,IAAI,IAAI,GAAG,KAAK,CAAC,GAAG,YAAY,CAAC,EAAE,CAAC;AAC9E,GAAG,EAAE,UAAU,CAAC,EAAE,CAAC,YAAY,IAAI,IAAI,GAAG,KAAK,CAAC,GAAG,YAAY,CAAC,IAAI,MAAM,SAAS,GAAG,wBAAwB,CAAC,YAAY,IAAI,IAAI,GAAG,KAAK,CAAC,GAAG,YAAY,CAAC,KAAK,CAAC,GAAG,YAAY,IAAI,IAAI,GAAG,KAAK,CAAC,GAAG,YAAY,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,EAAE,QAAQ,CAAC,CAAC;AAC9O;;;;"}
1
+ {"version":3,"file":"ModalsProvider.js","sources":["../src/ModalsProvider.tsx"],"sourcesContent":["import React, { useState } from 'react';\nimport { Modal } from '@mantine/core';\nimport { useListState, randomId } from '@mantine/hooks';\nimport {\n modalsContext,\n ModalsContext,\n ModalSettings,\n ConfirmLabels,\n OpenConfirmModal,\n ModalState,\n} from './context';\nimport { ConfirmModal } from './ConfirmModal';\n\nexport interface ContextModalProps {\n context: ModalsContext;\n id: string;\n}\n\nexport interface ModalsProviderProps {\n /** Your app */\n children: React.ReactNode;\n\n /** Predefined modals */\n modals?: Record<string, React.FC<ContextModalProps>>;\n\n /** Shared Modal component props, applied for every modal */\n modalProps?: ModalSettings;\n\n /** Confirm modal labels */\n labels?: ConfirmLabels;\n}\n\nfunction extractConfirmModalProps(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 { id, ...others };\n}\n\nexport function ModalsProvider({ children, modalProps, labels, modals }: ModalsProviderProps) {\n const [state, handlers] = useListState<ModalState>([]);\n const [currentModal, setCurrentModal] = useState<ModalState>({\n id: null,\n props: null,\n type: 'content',\n });\n const closeAll = () => handlers.setState([]);\n\n const openModal = (props: ModalSettings) => {\n const id = props.id || randomId();\n handlers.append({ id, props, type: 'content' });\n setCurrentModal({ id, props, type: 'content' });\n return id;\n };\n\n const openConfirmModal = (props: OpenConfirmModal) => {\n const id = props.id || randomId();\n handlers.append({ id, props, type: 'confirm' });\n setCurrentModal({ id, props, type: 'confirm' });\n return id;\n };\n\n const openContextModal = (modal: string, props: OpenConfirmModal) => {\n const id = props.id || randomId();\n handlers.append({ id, props, type: 'context', ctx: modal });\n setCurrentModal({ id, props, type: 'context', ctx: modal });\n return id;\n };\n\n const closeModal = (id: string) => {\n const index = state.findIndex((item) => item.id === id);\n const modal = state.find((item) => item.id === id);\n modal?.props?.onClose?.();\n index !== -1 && handlers.remove(index);\n setCurrentModal(\n state[state.length - 2] || {\n id: null,\n props: null,\n type: 'content',\n }\n );\n };\n\n const ContextModal = currentModal?.type === 'context' ? modals[currentModal?.ctx] : () => null;\n\n const ctx = {\n modals: state,\n openModal,\n openConfirmModal,\n openContextModal,\n closeModal,\n closeAll,\n };\n\n const content =\n currentModal?.type === 'context' ? (\n <ContextModal context={ctx} id={currentModal?.id} />\n ) : currentModal?.type === 'confirm' ? (\n <ConfirmModal\n {...currentModal.props}\n id={currentModal.id}\n labels={currentModal.props.labels || labels}\n />\n ) : (\n currentModal?.props?.children\n );\n\n return (\n <modalsContext.Provider value={ctx}>\n <Modal\n {...modalProps}\n {...(currentModal?.type === 'confirm'\n ? extractConfirmModalProps(currentModal?.props)\n : currentModal?.props)}\n opened={state.length > 0}\n onClose={() => closeModal(currentModal?.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,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,QA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KAAK,CAAC,aAAa,CAAC,YAAY,EAAE,aAAa,CAAC,cAAc,CAAC,EAAE,EAAE,YAAY,CAAC,KAAK,CAAC,EAAE;AACnL,IAAI,EAAE,EAAE,YAAY,CAAC,EAAE;AACvB,IAAI,MAAM,EAAE,YAAY,CAAC,KAAK,CAAC,MAAM,IAAI,MAAM;AAC/C,GAAG,CAAC,CAAC,GAAG,CAAC,EAAE,GAAG,YAAY,IAAI,IAAI,GAAG,KAAK,CAAC,GAAG,YAAY,CAAC,KAAK,KAAK,IAAI,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC;AACjG,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,EAAE,EAAE,UAAU,CAAC,EAAE,CAAC,YAAY,IAAI,IAAI,GAAG,KAAK,CAAC,GAAG,YAAY,CAAC,IAAI,MAAM,SAAS,GAAG,wBAAwB,CAAC,YAAY,IAAI,IAAI,GAAG,KAAK,CAAC,GAAG,YAAY,CAAC,KAAK,CAAC,GAAG,YAAY,IAAI,IAAI,GAAG,KAAK,CAAC,GAAG,YAAY,CAAC,KAAK,CAAC,EAAE;AACrT,IAAI,MAAM,EAAE,KAAK,CAAC,MAAM,GAAG,CAAC;AAC5B,IAAI,OAAO,EAAE,MAAM,UAAU,CAAC,YAAY,IAAI,IAAI,GAAG,KAAK,CAAC,GAAG,YAAY,CAAC,EAAE,CAAC;AAC9E,GAAG,CAAC,EAAE,OAAO,CAAC,EAAE,QAAQ,CAAC,CAAC;AAC1B;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"context.js","sources":["../src/context.ts"],"sourcesContent":["import { createContext } from 'react';\nimport { ModalProps } from '@mantine/core';\nimport type { ConfirmModalProps } from './ConfirmModal';\n\nexport type ModalSettings = Omit<ModalProps, 'opened' | 'onClose'>;\n\nexport type ConfirmLabels = Record<'confirm' | 'cancel', string>;\n\nexport interface OpenConfirmModal extends ModalSettings, ConfirmModalProps {}\n\nexport type ModalState =\n | { id: string; props: ModalSettings; type: 'content' }\n | { id: string; props: OpenConfirmModal; type: 'confirm' }\n | { id: string; props: OpenConfirmModal; type: 'context'; ctx: string };\n\nexport interface ModalsContext {\n modals: ModalState[];\n openModal: (props: ModalSettings) => string;\n openConfirmModal: (props: OpenConfirmModal) => string;\n openContextModal: (modal: string, props: ModalSettings) => string;\n closeModal: (id: string) => void;\n closeAll: () => void;\n}\n\nexport const modalsContext = createContext<ModalsContext>({\n modals: [],\n openModal: () => null,\n openConfirmModal: () => null,\n openContextModal: () => null,\n closeAll: () => {},\n closeModal: () => {},\n});\n"],"names":[],"mappings":";;AACY,MAAC,aAAa,GAAG,aAAa,CAAC;AAC3C,EAAE,MAAM,EAAE,EAAE;AACZ,EAAE,SAAS,EAAE,MAAM,IAAI;AACvB,EAAE,gBAAgB,EAAE,MAAM,IAAI;AAC9B,EAAE,gBAAgB,EAAE,MAAM,IAAI;AAC9B,EAAE,QAAQ,EAAE,MAAM;AAClB,GAAG;AACH,EAAE,UAAU,EAAE,MAAM;AACpB,GAAG;AACH,CAAC;;;;"}
1
+ {"version":3,"file":"context.js","sources":["../src/context.ts"],"sourcesContent":["import { createContext } from 'react';\nimport { ModalProps } from '@mantine/core';\nimport type { ConfirmModalProps } from './ConfirmModal';\n\nexport type ModalSettings = Partial<Omit<ModalProps, 'opened'>>;\n\nexport type ConfirmLabels = Record<'confirm' | 'cancel', string>;\n\nexport interface OpenConfirmModal extends ModalSettings, ConfirmModalProps {}\n\nexport type ModalState =\n | { id: string; props: ModalSettings; type: 'content' }\n | { id: string; props: OpenConfirmModal; type: 'confirm' }\n | { id: string; props: OpenConfirmModal; type: 'context'; ctx: string };\n\nexport interface ModalsContext {\n modals: ModalState[];\n openModal: (props: ModalSettings) => string;\n openConfirmModal: (props: OpenConfirmModal) => string;\n openContextModal: (modal: string, props: ModalSettings) => string;\n closeModal: (id: string) => void;\n closeAll: () => void;\n}\n\nexport const modalsContext = createContext<ModalsContext>({\n modals: [],\n openModal: () => null,\n openConfirmModal: () => null,\n openContextModal: () => null,\n closeAll: () => {},\n closeModal: () => {},\n});\n"],"names":[],"mappings":";;AACY,MAAC,aAAa,GAAG,aAAa,CAAC;AAC3C,EAAE,MAAM,EAAE,EAAE;AACZ,EAAE,SAAS,EAAE,MAAM,IAAI;AACvB,EAAE,gBAAgB,EAAE,MAAM,IAAI;AAC9B,EAAE,gBAAgB,EAAE,MAAM,IAAI;AAC9B,EAAE,QAAQ,EAAE,MAAM;AAClB,GAAG;AACH,EAAE,UAAU,EAAE,MAAM;AACpB,GAAG;AACH,CAAC;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"ModalsProvider.d.ts","sourceRoot":"","sources":["../src/ModalsProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAGxC,OAAO,EAEL,aAAa,EACb,aAAa,EACb,aAAa,EAGd,MAAM,WAAW,CAAC;AAGnB,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,aAAa,CAAC;IACvB,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,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,CAAC,CAAC;IAErD,4DAA4D;IAC5D,UAAU,CAAC,EAAE,aAAa,CAAC;IAE3B,2BAA2B;IAC3B,MAAM,CAAC,EAAE,aAAa,CAAC;CACxB;AAwBD,wBAAgB,cAAc,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,mBAAmB,eAgF3F"}
1
+ {"version":3,"file":"ModalsProvider.d.ts","sourceRoot":"","sources":["../src/ModalsProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAGxC,OAAO,EAEL,aAAa,EACb,aAAa,EACb,aAAa,EAGd,MAAM,WAAW,CAAC;AAGnB,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,aAAa,CAAC;IACvB,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,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,CAAC,CAAC;IAErD,4DAA4D;IAC5D,UAAU,CAAC,EAAE,aAAa,CAAC;IAE3B,2BAA2B;IAC3B,MAAM,CAAC,EAAE,aAAa,CAAC;CACxB;AAwBD,wBAAgB,cAAc,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,mBAAmB,eAoF3F"}
package/lib/context.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import { ModalProps } from '@mantine/core';
3
3
  import type { ConfirmModalProps } from './ConfirmModal';
4
- export declare type ModalSettings = Omit<ModalProps, 'opened' | 'onClose'>;
4
+ export declare type ModalSettings = Partial<Omit<ModalProps, 'opened'>>;
5
5
  export declare type ConfirmLabels = Record<'confirm' | 'cancel', string>;
6
6
  export interface OpenConfirmModal extends ModalSettings, ConfirmModalProps {
7
7
  }
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAExD,oBAAY,aAAa,GAAG,IAAI,CAAC,UAAU,EAAE,QAAQ,GAAG,SA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AAM,CAAC,SAAS,GAAG,QAAQ,EAAE,MAAM,CAAC,CAAC;AAEjE,MAAM,WAAW,gBAAiB,SAAQ,aAAa,EAAE,iBAAiB;CAAG;AAE7E,oBAAY,UAAU,GAClB;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,aAAa,CAAC;IAAC,IAAI,EAAE,SAAS,CAAA;CAAE,GACrD;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,gBAAgB,CAAC;IAAC,IAAI,EAAE,SAAS,CAAA;CAAE,GACxD;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,gBAAgB,CAAC;IAAC,IAAI,EAAE,SAAS,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AAE1E,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,UAAU,EAAE,CAAC;IACrB,SAAS,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,MAAM,CAAC;IAC5C,gBAAgB,EAAE,CAAC,KAAK,EAAE,gBAAgB,KAAK,MAAM,CAAC;IACtD,gBAAgB,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,KAAK,MAAM,CAAC;IAClE,UAAU,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IACjC,QAAQ,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,eAAO,MAAM,aAAa,wCAOxB,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mantine/modals",
3
3
  "description": "Modals manager based on Mantine components",
4
- "version": "3.3.2",
4
+ "version": "3.4.0",
5
5
  "main": "cjs/index.js",
6
6
  "module": "esm/index.js",
7
7
  "types": "lib/index.d.ts",
@@ -15,8 +15,8 @@
15
15
  "directory": "src/mantine-modals"
16
16
  },
17
17
  "peerDependencies": {
18
- "@mantine/core": "3.3.2",
19
- "@mantine/hooks": "3.3.2",
18
+ "@mantine/core": "3.4.0",
19
+ "@mantine/hooks": "3.4.0",
20
20
  "react": ">=16.8.0",
21
21
  "react-dom": ">=16.8.0"
22
22
  },