@mantine/modals 6.0.0-alpha.2 → 6.0.0-alpha.4
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.js +2 -0
- package/cjs/ModalsProvider.js.map +1 -1
- package/cjs/context.js.map +1 -1
- package/cjs/events.js +1 -1
- package/cjs/events.js.map +1 -1
- package/esm/ModalsProvider.js +2 -0
- 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/lib/ModalsProvider.d.ts.map +1 -1
- package/lib/context.d.ts +12 -3
- package/lib/context.d.ts.map +1 -1
- package/lib/events.d.ts +8 -8
- package/lib/events.d.ts.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/package.json +4 -4
package/cjs/ModalsProvider.js
CHANGED
|
@@ -163,6 +163,7 @@ function ModalsProvider({ children, modalProps, labels, modals }) {
|
|
|
163
163
|
return openContextModal(modal, payload);
|
|
164
164
|
},
|
|
165
165
|
closeModal,
|
|
166
|
+
closeContextModal: closeModal,
|
|
166
167
|
closeAllModals: closeAll
|
|
167
168
|
});
|
|
168
169
|
const ctx = {
|
|
@@ -171,6 +172,7 @@ function ModalsProvider({ children, modalProps, labels, modals }) {
|
|
|
171
172
|
openConfirmModal,
|
|
172
173
|
openContextModal,
|
|
173
174
|
closeModal,
|
|
175
|
+
closeContextModal: closeModal,
|
|
174
176
|
closeAll
|
|
175
177
|
};
|
|
176
178
|
const getCurrentModal = () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModalsProvider.js","sources":["../src/ModalsProvider.tsx"],"sourcesContent":["import React, { useReducer } 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 closeAll = (canceled?: boolean) => {\n state.modals.forEach((modal) => {\n if (modal.type === 'confirm' && canceled) {\n modal.props?.onCancel?.();\n }\n\n modal.props?.onClose?.();\n });\n dispatch({ type: 'CLOSE_ALL' });\n };\n\n const openModal = ({ modalId, ...props }: ModalSettings) => {\n const id = modalId || randomId();\n\n dispatch({\n type: 'OPEN',\n payload: {\n id,\n type: 'content',\n props,\n },\n });\n return id;\n };\n\n const openConfirmModal = ({ modalId, ...props }: OpenConfirmModal) => {\n const id = modalId || randomId();\n dispatch({\n type: 'OPEN',\n payload: {\n id,\n type: 'confirm',\n props,\n },\n });\n return id;\n };\n\n const openContextModal = (modal: string, { modalId, ...props }: OpenContextModal) => {\n const id = modalId || randomId();\n dispatch({\n type: 'OPEN',\n payload: {\n id,\n type: 'context',\n props,\n ctx: modal,\n },\n });\n return id;\n };\n\n const closeModal = (id: string, canceled?: boolean) => {\n if (state.modals.length <= 1) {\n closeAll(canceled);\n return;\n }\n\n const modal = state.modals.find((item) => item.id === id);\n if (modal?.type === 'confirm' && canceled) {\n modal.props?.onCancel?.();\n }\n modal?.props?.onClose?.();\n dispatch({ type: 'CLOSE', payload: modal.id });\n };\n\n useModalsEvents({\n openModal,\n openConfirmModal,\n openContextModal: ({ modal, ...payload }) => openContextModal(modal, payload),\n closeModal,\n closeAllModals: closeAll,\n });\n\n const ctx: ModalsContextProps = {\n modals: state.modals,\n openModal,\n openConfirmModal,\n openContextModal,\n closeModal,\n closeAll,\n };\n\n const getCurrentModal = () => {\n switch (state.current?.type) {\n case 'context': {\n const { innerProps, ...rest } = state.current.props;\n const ContextModal = modals[state.current.ctx];\n\n return {\n modalProps: rest,\n content: <ContextModal innerProps={innerProps} context={ctx} id={state.current.id} />,\n };\n }\n case 'confirm': {\n const { modalProps: separatedModalProps, confirmProps: separatedConfirmProps } =\n separateConfirmModalProps(state.current.props);\n\n return {\n modalProps: separatedModalProps,\n content: (\n <ConfirmModal\n {...separatedConfirmProps}\n id={state.current.id}\n labels={state.current.props.labels || labels}\n />\n ),\n };\n }\n case 'content': {\n const { children: currentModalChildren, ...rest } = state.current.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","randomId","useModalsEvents","React","ConfirmModal","ModalsContext","Modal","getDefaultZIndex"],"mappings":";;;;;;;;;;;;;;;;AAAA,IAAI,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC;AACtC,IAAI,UAAU,GA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AkBD,cAAK,CAAC,aAAa,CAACA,cAAK,CAAC,QAAQ,EAAE,IAAI,EAAE,oBAAoB,CAAC;AAClG,SAAS,CAAC;AACV,OAAO;AACP,MAAM,SAAS;AACf,QAAQ,OAAO;AACf,UAAU,UAAU,EAAE,EAAE;AACxB,UAAU,OAAO,EAAE,IAAI;AACvB,SAAS,CAAC;AACV,OAAO;AACP,KAAK;AACL,GAAG,CAAC;AACJ,EAAE,MAAM,EAAE,UAAU,EAAE,iBAAiB,EAAE,OAAO,EAAE,GAAG,eAAe,EAAE,CAAC;AACvE,EAAE,uBAAuBA,cAAK,CAAC,aAAa,CAACE,qBAAa,CAAC,QAAQ,EAAE;AACrE,IAAI,KAAK,EAAE,GAAG;AACd,GAAG,kBAAkBF,cAAK,CAAC,aAAa,CAACG,UAAK,EAAE,aAAa,CAAC,cAAc,CAAC,cAAc,CAAC;AAC5F,IAAI,MAAM,EAAEC,qBAAgB,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, { useReducer } 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 closeAll = (canceled?: boolean) => {\n state.modals.forEach((modal) => {\n if (modal.type === 'confirm' && canceled) {\n modal.props?.onCancel?.();\n }\n\n modal.props?.onClose?.();\n });\n dispatch({ type: 'CLOSE_ALL' });\n };\n\n const openModal = ({ modalId, ...props }: ModalSettings) => {\n const id = modalId || randomId();\n\n dispatch({\n type: 'OPEN',\n payload: {\n id,\n type: 'content',\n props,\n },\n });\n return id;\n };\n\n const openConfirmModal = ({ modalId, ...props }: OpenConfirmModal) => {\n const id = modalId || randomId();\n dispatch({\n type: 'OPEN',\n payload: {\n id,\n type: 'confirm',\n props,\n },\n });\n return id;\n };\n\n const openContextModal = (modal: string, { modalId, ...props }: OpenContextModal) => {\n const id = modalId || randomId();\n dispatch({\n type: 'OPEN',\n payload: {\n id,\n type: 'context',\n props,\n ctx: modal,\n },\n });\n return id;\n };\n\n const closeModal = (id: string, canceled?: boolean) => {\n if (state.modals.length <= 1) {\n closeAll(canceled);\n return;\n }\n\n const modal = state.modals.find((item) => item.id === id);\n if (modal?.type === 'confirm' && canceled) {\n modal.props?.onCancel?.();\n }\n modal?.props?.onClose?.();\n dispatch({ type: 'CLOSE', payload: modal.id });\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 switch (state.current?.type) {\n case 'context': {\n const { innerProps, ...rest } = state.current.props;\n const ContextModal = modals[state.current.ctx];\n\n return {\n modalProps: rest,\n content: <ContextModal innerProps={innerProps} context={ctx} id={state.current.id} />,\n };\n }\n case 'confirm': {\n const { modalProps: separatedModalProps, confirmProps: separatedConfirmProps } =\n separateConfirmModalProps(state.current.props);\n\n return {\n modalProps: separatedModalProps,\n content: (\n <ConfirmModal\n {...separatedConfirmProps}\n id={state.current.id}\n labels={state.current.props.labels || labels}\n />\n ),\n };\n }\n case 'content': {\n const { children: currentModalChildren, ...rest } = state.current.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","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,CAA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C,aAAa,CAACA,cAAK,CAAC,QAAQ,EAAE,IAAI,EAAE,oBAAoB,CAAC;AAClG,SAAS,CAAC;AACV,OAAO;AACP,MAAM,SAAS;AACf,QAAQ,OAAO;AACf,UAAU,UAAU,EAAE,EAAE;AACxB,UAAU,OAAO,EAAE,IAAI;AACvB,SAAS,CAAC;AACV,OAAO;AACP,KAAK;AACL,GAAG,CAAC;AACJ,EAAE,MAAM,EAAE,UAAU,EAAE,iBAAiB,EAAE,OAAO,EAAE,GAAG,eAAe,EAAE,CAAC;AACvE,EAAE,uBAAuBA,cAAK,CAAC,aAAa,CAACE,qBAAa,CAAC,QAAQ,EAAE;AACrE,IAAI,KAAK,EAAE,GAAG;AACd,GAAG,kBAAkBF,cAAK,CAAC,aAAa,CAACG,UAAK,EAAE,aAAa,CAAC,cAAc,CAAC,cAAc,CAAC;AAC5F,IAAI,MAAM,EAAEC,qBAAgB,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;;;;"}
|
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,
|
|
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;;;;"}
|
package/cjs/events.js
CHANGED
|
@@ -9,7 +9,7 @@ const openModal = createEvent("openModal");
|
|
|
9
9
|
const closeModal = createEvent("closeModal");
|
|
10
10
|
const closeAllModals = createEvent("closeAllModals");
|
|
11
11
|
const openConfirmModal = createEvent("openConfirmModal");
|
|
12
|
-
const openContextModal = createEvent("openContextModal");
|
|
12
|
+
const openContextModal = (payload) => createEvent("openContextModal")(payload);
|
|
13
13
|
const modals = {
|
|
14
14
|
open: openModal,
|
|
15
15
|
close: closeModal,
|
package/cjs/events.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.js","sources":["../src/events.ts"],"sourcesContent":["import { createUseExternalEvents } from '@mantine/utils';\nimport {
|
|
1
|
+
{"version":3,"file":"events.js","sources":["../src/events.ts"],"sourcesContent":["import { createUseExternalEvents } from '@mantine/utils';\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,6BAAuB,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/ModalsProvider.js
CHANGED
|
@@ -155,6 +155,7 @@ function ModalsProvider({ children, modalProps, labels, modals }) {
|
|
|
155
155
|
return openContextModal(modal, payload);
|
|
156
156
|
},
|
|
157
157
|
closeModal,
|
|
158
|
+
closeContextModal: closeModal,
|
|
158
159
|
closeAllModals: closeAll
|
|
159
160
|
});
|
|
160
161
|
const ctx = {
|
|
@@ -163,6 +164,7 @@ function ModalsProvider({ children, modalProps, labels, modals }) {
|
|
|
163
164
|
openConfirmModal,
|
|
164
165
|
openContextModal,
|
|
165
166
|
closeModal,
|
|
167
|
+
closeContextModal: closeModal,
|
|
166
168
|
closeAll
|
|
167
169
|
};
|
|
168
170
|
const getCurrentModal = () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModalsProvider.js","sources":["../src/ModalsProvider.tsx"],"sourcesContent":["import React, { useReducer } 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 closeAll = (canceled?: boolean) => {\n state.modals.forEach((modal) => {\n if (modal.type === 'confirm' && canceled) {\n modal.props?.onCancel?.();\n }\n\n modal.props?.onClose?.();\n });\n dispatch({ type: 'CLOSE_ALL' });\n };\n\n const openModal = ({ modalId, ...props }: ModalSettings) => {\n const id = modalId || randomId();\n\n dispatch({\n type: 'OPEN',\n payload: {\n id,\n type: 'content',\n props,\n },\n });\n return id;\n };\n\n const openConfirmModal = ({ modalId, ...props }: OpenConfirmModal) => {\n const id = modalId || randomId();\n dispatch({\n type: 'OPEN',\n payload: {\n id,\n type: 'confirm',\n props,\n },\n });\n return id;\n };\n\n const openContextModal = (modal: string, { modalId, ...props }: OpenContextModal) => {\n const id = modalId || randomId();\n dispatch({\n type: 'OPEN',\n payload: {\n id,\n type: 'context',\n props,\n ctx: modal,\n },\n });\n return id;\n };\n\n const closeModal = (id: string, canceled?: boolean) => {\n if (state.modals.length <= 1) {\n closeAll(canceled);\n return;\n }\n\n const modal = state.modals.find((item) => item.id === id);\n if (modal?.type === 'confirm' && canceled) {\n modal.props?.onCancel?.();\n }\n modal?.props?.onClose?.();\n dispatch({ type: 'CLOSE', payload: modal.id });\n };\n\n useModalsEvents({\n openModal,\n openConfirmModal,\n openContextModal: ({ modal, ...payload }) => openContextModal(modal, payload),\n closeModal,\n closeAllModals: closeAll,\n });\n\n const ctx: ModalsContextProps = {\n modals: state.modals,\n openModal,\n openConfirmModal,\n openContextModal,\n closeModal,\n closeAll,\n };\n\n const getCurrentModal = () => {\n switch (state.current?.type) {\n case 'context': {\n const { innerProps, ...rest } = state.current.props;\n const ContextModal = modals[state.current.ctx];\n\n return {\n modalProps: rest,\n content: <ContextModal innerProps={innerProps} context={ctx} id={state.current.id} />,\n };\n }\n case 'confirm': {\n const { modalProps: separatedModalProps, confirmProps: separatedConfirmProps } =\n separateConfirmModalProps(state.current.props);\n\n return {\n modalProps: separatedModalProps,\n content: (\n <ConfirmModal\n {...separatedConfirmProps}\n id={state.current.id}\n labels={state.current.props.labels || labels}\n />\n ),\n };\n }\n case 'content': {\n const { children: currentModalChildren, ...rest } = state.current.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,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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, { useReducer } 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 closeAll = (canceled?: boolean) => {\n state.modals.forEach((modal) => {\n if (modal.type === 'confirm' && canceled) {\n modal.props?.onCancel?.();\n }\n\n modal.props?.onClose?.();\n });\n dispatch({ type: 'CLOSE_ALL' });\n };\n\n const openModal = ({ modalId, ...props }: ModalSettings) => {\n const id = modalId || randomId();\n\n dispatch({\n type: 'OPEN',\n payload: {\n id,\n type: 'content',\n props,\n },\n });\n return id;\n };\n\n const openConfirmModal = ({ modalId, ...props }: OpenConfirmModal) => {\n const id = modalId || randomId();\n dispatch({\n type: 'OPEN',\n payload: {\n id,\n type: 'confirm',\n props,\n },\n });\n return id;\n };\n\n const openContextModal = (modal: string, { modalId, ...props }: OpenContextModal) => {\n const id = modalId || randomId();\n dispatch({\n type: 'OPEN',\n payload: {\n id,\n type: 'context',\n props,\n ctx: modal,\n },\n });\n return id;\n };\n\n const closeModal = (id: string, canceled?: boolean) => {\n if (state.modals.length <= 1) {\n closeAll(canceled);\n return;\n }\n\n const modal = state.modals.find((item) => item.id === id);\n if (modal?.type === 'confirm' && canceled) {\n modal.props?.onCancel?.();\n }\n modal?.props?.onClose?.();\n dispatch({ type: 'CLOSE', payload: modal.id });\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 switch (state.current?.type) {\n case 'context': {\n const { innerProps, ...rest } = state.current.props;\n const ContextModal = modals[state.current.ctx];\n\n return {\n modalProps: rest,\n content: <ContextModal innerProps={innerProps} context={ctx} id={state.current.id} />,\n };\n }\n case 'confirm': {\n const { modalProps: separatedModalProps, confirmProps: separatedConfirmProps } =\n separateConfirmModalProps(state.current.props);\n\n return {\n modalProps: separatedModalProps,\n content: (\n <ConfirmModal\n {...separatedConfirmProps}\n id={state.current.id}\n labels={state.current.props.labels || labels}\n />\n ),\n };\n }\n case 'content': {\n const { children: currentModalChildren, ...rest } = state.current.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,GAAG,MAAM,CAAC,yBAAyB,CAAC;AACzD,IAAI,mBAAmB,GAAG,MAAM,CAAC,qBAAqB,CAAC;AACvD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,C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ACf,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;;;;"}
|
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,
|
|
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;;;;"}
|
package/esm/events.js
CHANGED
|
@@ -5,7 +5,7 @@ const openModal = createEvent("openModal");
|
|
|
5
5
|
const closeModal = createEvent("closeModal");
|
|
6
6
|
const closeAllModals = createEvent("closeAllModals");
|
|
7
7
|
const openConfirmModal = createEvent("openConfirmModal");
|
|
8
|
-
const openContextModal = createEvent("openContextModal");
|
|
8
|
+
const openContextModal = (payload) => createEvent("openContextModal")(payload);
|
|
9
9
|
const modals = {
|
|
10
10
|
open: openModal,
|
|
11
11
|
close: closeModal,
|
package/esm/events.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.js","sources":["../src/events.ts"],"sourcesContent":["import { createUseExternalEvents } from '@mantine/utils';\nimport {
|
|
1
|
+
{"version":3,"file":"events.js","sources":["../src/events.ts"],"sourcesContent":["import { createUseExternalEvents } from '@mantine/utils';\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;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModalsProvider.d.ts","sourceRoot":"","sources":["../src/ModalsProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAG1C,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,KAAqB,MAAM,OAAO,CAAC;AAG1C,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,eAmJ3F"}
|
package/lib/context.d.ts
CHANGED
|
@@ -7,10 +7,10 @@ export type ModalSettings = Partial<Omit<ModalProps, 'opened'>> & {
|
|
|
7
7
|
export type ConfirmLabels = Record<'confirm' | 'cancel', ReactNode>;
|
|
8
8
|
export interface OpenConfirmModal extends ModalSettings, ConfirmModalProps {
|
|
9
9
|
}
|
|
10
|
-
export interface OpenContextModal<CustomProps extends Record<string,
|
|
10
|
+
export interface OpenContextModal<CustomProps extends Record<string, any> = {}> extends ModalSettings {
|
|
11
11
|
innerProps: CustomProps;
|
|
12
12
|
}
|
|
13
|
-
export interface ContextModalProps<T extends Record<string,
|
|
13
|
+
export interface ContextModalProps<T extends Record<string, any> = {}> {
|
|
14
14
|
context: ModalsContextProps;
|
|
15
15
|
innerProps: T;
|
|
16
16
|
id: string;
|
|
@@ -33,9 +33,18 @@ export interface ModalsContextProps {
|
|
|
33
33
|
modals: ModalState[];
|
|
34
34
|
openModal: (props: ModalSettings) => string;
|
|
35
35
|
openConfirmModal: (props: OpenConfirmModal) => string;
|
|
36
|
-
openContextModal: <
|
|
36
|
+
openContextModal: <TKey extends MantineModal>(modal: TKey, props: OpenContextModal<Parameters<MantineModals[TKey]>[0]['innerProps']>) => string;
|
|
37
37
|
closeModal: (id: string, canceled?: boolean) => void;
|
|
38
|
+
closeContextModal: <TKey extends MantineModal>(id: TKey, canceled?: boolean) => void;
|
|
38
39
|
closeAll: () => void;
|
|
39
40
|
}
|
|
41
|
+
export type MantineModalsOverride = {};
|
|
42
|
+
export type MantineModalsOverwritten = MantineModalsOverride extends {
|
|
43
|
+
modals: Record<string, React.FC<ContextModalProps<any>>>;
|
|
44
|
+
} ? MantineModalsOverride : {
|
|
45
|
+
modals: Record<string, React.FC<ContextModalProps<any>>>;
|
|
46
|
+
};
|
|
47
|
+
export type MantineModals = MantineModalsOverwritten['modals'];
|
|
48
|
+
export type MantineModal = keyof MantineModals;
|
|
40
49
|
export declare const ModalsContext: import("react").Context<ModalsContextProps>;
|
|
41
50
|
//# sourceMappingURL=context.d.ts.map
|
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,EAAiB,SAAS,EAAE,MAAM,OAAO,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAExD,MAAM,MAAM,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC,GAAG;IAAE,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAEvF,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,SAAS,GAAG,QAAQ,EAAE,SAAS,CAAC,CAAC;AAEpE,MAAM,WAAW,gBAAiB,SAAQ,aAAa,EAAE,iBAAiB;CAAG;AAC7E,MAAM,WAAW,gBAAgB,CAAC,WAAW,SAAS,MAAM,CAAC,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,O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AAC,KAAK,EAAE,aAAa,KAAK,MAAM,CAAC;IAC5C,gBAAgB,EAAE,CAAC,KAAK,EAAE,gBAAgB,KAAK,MAAM,CAAC;IACtD,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,6CAA0C,CAAC"}
|
package/lib/events.d.ts
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import { ModalSettings, OpenConfirmModal, OpenContextModal } from './context';
|
|
1
|
+
import { MantineModal, MantineModals, ModalSettings, OpenConfirmModal, OpenContextModal } from './context';
|
|
2
2
|
type ModalsEvents = {
|
|
3
3
|
openModal(payload: ModalSettings): void;
|
|
4
4
|
closeModal(id: string): void;
|
|
5
|
+
closeContextModal<TKey extends MantineModal>(id: TKey): void;
|
|
5
6
|
closeAllModals(): void;
|
|
6
7
|
openConfirmModal(payload: OpenConfirmModal): void;
|
|
7
|
-
openContextModal(payload: OpenContextModal & {
|
|
8
|
-
modal:
|
|
8
|
+
openContextModal<TKey extends MantineModal>(payload: OpenContextModal<Parameters<MantineModals[TKey]>[0]['innerProps']> & {
|
|
9
|
+
modal: TKey;
|
|
9
10
|
}): void;
|
|
10
11
|
};
|
|
11
12
|
export declare const useModalsEvents: (events: ModalsEvents) => void, createEvent: <EventKey extends keyof ModalsEvents>(event: EventKey) => (...payload: Parameters<ModalsEvents[EventKey]>[0] extends undefined ? [undefined?] : [Parameters<ModalsEvents[EventKey]>[0]]) => void;
|
|
12
13
|
export declare const openModal: (payload_0: ModalSettings) => void;
|
|
13
14
|
export declare const closeModal: (payload_0: string) => void;
|
|
15
|
+
export declare const closeContextModal: ModalsEvents['closeContextModal'];
|
|
14
16
|
export declare const closeAllModals: (payload_0?: undefined) => void;
|
|
15
17
|
export declare const openConfirmModal: (payload_0: OpenConfirmModal) => void;
|
|
16
|
-
export declare const openContextModal:
|
|
17
|
-
modal: string;
|
|
18
|
-
}) => void;
|
|
18
|
+
export declare const openContextModal: ModalsEvents['openContextModal'];
|
|
19
19
|
export declare const modals: {
|
|
20
20
|
open: (payload_0: ModalSettings) => void;
|
|
21
21
|
close: (payload_0: string) => void;
|
|
22
22
|
closeAll: (payload_0?: undefined) => void;
|
|
23
23
|
openConfirmModal: (payload_0: OpenConfirmModal) => void;
|
|
24
|
-
openContextModal: (
|
|
25
|
-
modal:
|
|
24
|
+
openContextModal: <TKey extends string>(payload: OpenContextModal<any> & {
|
|
25
|
+
modal: TKey;
|
|
26
26
|
}) => void;
|
|
27
27
|
};
|
|
28
28
|
export {};
|
package/lib/events.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AACA,OAAO,EACL,YAAY,EACZ,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,gBAAgB,EACjB,MAAM,WAAW,CAAC;AAEnB,KAAK,YAAY,GAAG;IAClB,SAAS,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI,CAAC;IACxC,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,iBAAiB,CAAC,IAAI,SAAS,YAAY,EAAE,EAAE,EAAE,IAAI,GAAG,IAAI,CAAC;IAC7D,cAAc,IAAI,IAAI,CAAC;IACvB,gBAAgB,CAAC,OAAO,EAAE,gBAAgB,GAAG,IAAI,CAAC;IAClD,gBAAgB,CAAC,IAAI,SAAS,YAAY,EACxC,OAAO,EAAE,gBAAgB,CAAC,UAAU,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,GAAG;QAAE,KAAK,EAAE,IAAI,CAAA;KAAE,GAC5F,IAAI,CAAC;CACT,CAAC;AAEF,eAAO,MAAO,eAAe,kCAAE,WAAW,kMACe,CAAC;AAE1D,eAAO,MAAM,SAAS,oCAA2B,CAAC;AAClD,eAAO,MAAM,UAAU,6BAA4B,CAAC;AACpD,eAAO,MAAM,iBAAiB,EAAE,YAAY,CAAC,mBAAmB,CAEvB,CAAC;AAC1C,eAAO,MAAM,cAAc,iCAAgC,CAAC;AAC5D,eAAO,MAAM,gBAAgB,uCAAkC,CAAC;AAChE,eAAO,MAAM,gBAAgB,EAAE,YAAY,CAAC,kBAAkB,CAEjB,CAAC;AAE9C,eAAO,MAAM,MAAM;;;;;;;UAjBd,IAAI;CAuBR,CAAC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -2,5 +2,5 @@ export { ModalsProvider } from './ModalsProvider';
|
|
|
2
2
|
export { useModals } from './use-modals/use-modals';
|
|
3
3
|
export { openModal, closeModal, closeAllModals, openConfirmModal, openContextModal, modals, } from './events';
|
|
4
4
|
export type { ModalsProviderProps } from './ModalsProvider';
|
|
5
|
-
export type { ContextModalProps } from './context';
|
|
5
|
+
export type { ContextModalProps, MantineModalsOverride, MantineModals, MantineModal, } from './context';
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EACL,SAAS,EACT,UAAU,EACV,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAChB,MAAM,GACP,MAAM,UAAU,CAAC;AAElB,YAAY,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EACL,SAAS,EACT,UAAU,EACV,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAChB,MAAM,GACP,MAAM,UAAU,CAAC;AAElB,YAAY,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,YAAY,EACV,iBAAiB,EACjB,qBAAqB,EACrB,aAAa,EACb,YAAY,GACb,MAAM,WAAW,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": "6.0.0-alpha.
|
|
4
|
+
"version": "6.0.0-alpha.4",
|
|
5
5
|
"main": "cjs/index.js",
|
|
6
6
|
"module": "esm/index.js",
|
|
7
7
|
"types": "lib/index.d.ts",
|
|
@@ -27,13 +27,13 @@
|
|
|
27
27
|
"confirm"
|
|
28
28
|
],
|
|
29
29
|
"peerDependencies": {
|
|
30
|
-
"@mantine/core": "6.0.0-alpha.
|
|
31
|
-
"@mantine/hooks": "6.0.0-alpha.
|
|
30
|
+
"@mantine/core": "6.0.0-alpha.4",
|
|
31
|
+
"@mantine/hooks": "6.0.0-alpha.4",
|
|
32
32
|
"react": ">=16.8.0",
|
|
33
33
|
"react-dom": ">=16.8.0"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@mantine/utils": "6.0.0-alpha.
|
|
36
|
+
"@mantine/utils": "6.0.0-alpha.4"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {}
|
|
39
39
|
}
|