@inertiaui/modal-react 0.5.3 → 0.6.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/dist/inertiaui-modal.js +701 -697
- package/dist/inertiaui-modal.umd.cjs +17 -17
- package/package.json +2 -2
- package/src/HeadlessModal.jsx +13 -13
- package/src/Modal.jsx +7 -7
- package/src/ModalContent.jsx +17 -17
- package/src/ModalRenderer.jsx +1 -1
- package/src/ModalRoot.jsx +16 -19
- package/src/SlideoverContent.jsx +18 -18
- package/src/inertiauiModal.js +2 -1
- package/src/useModal.js +6 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inertiaui/modal-react",
|
|
3
3
|
"author": "Pascal Baljet <pascal@protone.media>",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.6.0",
|
|
5
5
|
"private": false,
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"type": "module",
|
|
@@ -49,4 +49,4 @@
|
|
|
49
49
|
"react": "^18.2.0",
|
|
50
50
|
"react-dom": "^18.2.0"
|
|
51
51
|
}
|
|
52
|
-
}
|
|
52
|
+
}
|
package/src/HeadlessModal.jsx
CHANGED
|
@@ -15,20 +15,20 @@ const HeadlessModal = forwardRef(({ name, children, ...props }, ref) => {
|
|
|
15
15
|
return stack.find((m) => m.shouldRender && m.index > modalContext?.index)?.index
|
|
16
16
|
}, [modalIndex, stack])
|
|
17
17
|
|
|
18
|
-
const
|
|
18
|
+
const configSlideover = useMemo(() => modalContext?.config.slideover ?? props.slideover ?? getConfig('type') === 'slideover', [props.slideover])
|
|
19
19
|
|
|
20
|
-
const
|
|
20
|
+
const config = useMemo(
|
|
21
21
|
() => ({
|
|
22
|
-
slideover:
|
|
23
|
-
closeButton: props.closeButton ?? getConfigByType(
|
|
24
|
-
closeExplicitly: props.closeExplicitly ?? getConfigByType(
|
|
25
|
-
maxWidth: props.maxWidth ?? getConfigByType(
|
|
26
|
-
paddingClasses: props.paddingClasses ?? getConfigByType(
|
|
27
|
-
panelClasses: props.panelClasses ?? getConfigByType(
|
|
28
|
-
position: props.position ?? getConfigByType(
|
|
29
|
-
...modalContext?.
|
|
22
|
+
slideover: configSlideover,
|
|
23
|
+
closeButton: props.closeButton ?? getConfigByType(configSlideover, 'closeButton'),
|
|
24
|
+
closeExplicitly: props.closeExplicitly ?? getConfigByType(configSlideover, 'closeExplicitly'),
|
|
25
|
+
maxWidth: props.maxWidth ?? getConfigByType(configSlideover, 'maxWidth'),
|
|
26
|
+
paddingClasses: props.paddingClasses ?? getConfigByType(configSlideover, 'paddingClasses'),
|
|
27
|
+
panelClasses: props.panelClasses ?? getConfigByType(configSlideover, 'panelClasses'),
|
|
28
|
+
position: props.position ?? getConfigByType(configSlideover, 'position'),
|
|
29
|
+
...modalContext?.config,
|
|
30
30
|
}),
|
|
31
|
-
[props, modalContext?.
|
|
31
|
+
[props, modalContext?.config],
|
|
32
32
|
)
|
|
33
33
|
|
|
34
34
|
useEffect(() => {
|
|
@@ -55,6 +55,7 @@ const HeadlessModal = forwardRef(({ name, children, ...props }, ref) => {
|
|
|
55
55
|
() => ({
|
|
56
56
|
afterLeave: () => modalContext.afterLeave(),
|
|
57
57
|
close: () => modalContext.close(),
|
|
58
|
+
config,
|
|
58
59
|
emit: (...args) => modalContext.emit(...args),
|
|
59
60
|
getChildModal: () => modalContext.getChildModal(),
|
|
60
61
|
getParentModal: () => modalContext.getParentModal(),
|
|
@@ -62,7 +63,6 @@ const HeadlessModal = forwardRef(({ name, children, ...props }, ref) => {
|
|
|
62
63
|
index: modalContext?.index,
|
|
63
64
|
isOpen: modalContext?.isOpen,
|
|
64
65
|
modalContext,
|
|
65
|
-
modalProps,
|
|
66
66
|
onTopOfStack: modalContext?.onTopOfStack,
|
|
67
67
|
reload: () => modalContext.reload(),
|
|
68
68
|
setOpen: () => modalContext.setOpen(),
|
|
@@ -78,6 +78,7 @@ const HeadlessModal = forwardRef(({ name, children, ...props }, ref) => {
|
|
|
78
78
|
? children({
|
|
79
79
|
afterLeave: modalContext.afterLeave,
|
|
80
80
|
close: modalContext.close,
|
|
81
|
+
config,
|
|
81
82
|
emit: modalContext.emit,
|
|
82
83
|
getChildModal: modalContext.getChildModal,
|
|
83
84
|
getParentModal: modalContext.getParentModal,
|
|
@@ -85,7 +86,6 @@ const HeadlessModal = forwardRef(({ name, children, ...props }, ref) => {
|
|
|
85
86
|
index: modalContext.index,
|
|
86
87
|
isOpen: modalContext.isOpen,
|
|
87
88
|
modalContext,
|
|
88
|
-
modalProps,
|
|
89
89
|
onTopOfStack: modalContext.onTopOfStack,
|
|
90
90
|
reload: modalContext.reload,
|
|
91
91
|
setOpen: modalContext.setOpen,
|
package/src/Modal.jsx
CHANGED
|
@@ -26,6 +26,7 @@ const Modal = forwardRef(({ name, children, ...props }, ref) => {
|
|
|
26
26
|
{({
|
|
27
27
|
afterLeave,
|
|
28
28
|
close,
|
|
29
|
+
config,
|
|
29
30
|
emit,
|
|
30
31
|
getChildModal,
|
|
31
32
|
getParentModal,
|
|
@@ -33,7 +34,6 @@ const Modal = forwardRef(({ name, children, ...props }, ref) => {
|
|
|
33
34
|
index,
|
|
34
35
|
isOpen,
|
|
35
36
|
modalContext,
|
|
36
|
-
modalProps,
|
|
37
37
|
onTopOfStack,
|
|
38
38
|
reload,
|
|
39
39
|
setOpen,
|
|
@@ -46,7 +46,7 @@ const Modal = forwardRef(({ name, children, ...props }, ref) => {
|
|
|
46
46
|
<Dialog
|
|
47
47
|
as="div"
|
|
48
48
|
className="im-dialog relative z-20"
|
|
49
|
-
onClose={() => (
|
|
49
|
+
onClose={() => (config.closeExplicitly ? null : close())}
|
|
50
50
|
data-inertiaui-modal-id={id}
|
|
51
51
|
data-inertiaui-modal-index={index}
|
|
52
52
|
>
|
|
@@ -75,14 +75,15 @@ const Modal = forwardRef(({ name, children, ...props }, ref) => {
|
|
|
75
75
|
{index > 0 && onTopOfStack ? <div className="im-backdrop fixed inset-0 z-30 bg-black/75" /> : null}
|
|
76
76
|
|
|
77
77
|
{/* The modal/slideover content itself */}
|
|
78
|
-
{
|
|
78
|
+
{config.slideover ? (
|
|
79
79
|
<SlideoverContent
|
|
80
80
|
modalContext={modalContext}
|
|
81
|
-
|
|
81
|
+
config={config}
|
|
82
82
|
>
|
|
83
83
|
{renderChildren({
|
|
84
84
|
afterLeave,
|
|
85
85
|
close,
|
|
86
|
+
config,
|
|
86
87
|
emit,
|
|
87
88
|
getChildModal,
|
|
88
89
|
getParentModal,
|
|
@@ -90,7 +91,6 @@ const Modal = forwardRef(({ name, children, ...props }, ref) => {
|
|
|
90
91
|
index,
|
|
91
92
|
isOpen,
|
|
92
93
|
modalContext,
|
|
93
|
-
modalProps,
|
|
94
94
|
onTopOfStack,
|
|
95
95
|
reload,
|
|
96
96
|
setOpen,
|
|
@@ -100,11 +100,12 @@ const Modal = forwardRef(({ name, children, ...props }, ref) => {
|
|
|
100
100
|
) : (
|
|
101
101
|
<ModalContent
|
|
102
102
|
modalContext={modalContext}
|
|
103
|
-
|
|
103
|
+
config={config}
|
|
104
104
|
>
|
|
105
105
|
{renderChildren({
|
|
106
106
|
afterLeave,
|
|
107
107
|
close,
|
|
108
|
+
config,
|
|
108
109
|
emit,
|
|
109
110
|
getChildModal,
|
|
110
111
|
getParentModal,
|
|
@@ -112,7 +113,6 @@ const Modal = forwardRef(({ name, children, ...props }, ref) => {
|
|
|
112
113
|
index,
|
|
113
114
|
isOpen,
|
|
114
115
|
modalContext,
|
|
115
|
-
modalProps,
|
|
116
116
|
onTopOfStack,
|
|
117
117
|
reload,
|
|
118
118
|
setOpen,
|
package/src/ModalContent.jsx
CHANGED
|
@@ -2,14 +2,14 @@ import { TransitionChild, DialogPanel } from '@headlessui/react'
|
|
|
2
2
|
import CloseButton from './CloseButton'
|
|
3
3
|
import clsx from 'clsx'
|
|
4
4
|
|
|
5
|
-
const ModalContent = ({ modalContext,
|
|
5
|
+
const ModalContent = ({ modalContext, config, children }) => {
|
|
6
6
|
return (
|
|
7
7
|
<div className="im-modal-container fixed inset-0 z-40 overflow-y-auto p-4">
|
|
8
8
|
<div
|
|
9
9
|
className={clsx('im-modal-positioner flex min-h-full justify-center', {
|
|
10
|
-
'items-start':
|
|
11
|
-
'items-center':
|
|
12
|
-
'items-end':
|
|
10
|
+
'items-start': config.position === 'top',
|
|
11
|
+
'items-center': config.position === 'center',
|
|
12
|
+
'items-end': config.position === 'bottom',
|
|
13
13
|
})}
|
|
14
14
|
>
|
|
15
15
|
<TransitionChild
|
|
@@ -19,25 +19,25 @@ const ModalContent = ({ modalContext, modalProps, children }) => {
|
|
|
19
19
|
leaveTo="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"
|
|
20
20
|
afterLeave={modalContext.afterLeave}
|
|
21
21
|
className={clsx('im-modal-wrapper w-full transition duration-300 ease-in-out', modalContext.onTopOfStack ? '' : 'blur-sm', {
|
|
22
|
-
'sm:max-w-sm':
|
|
23
|
-
'sm:max-w-md':
|
|
24
|
-
'sm:max-w-md md:max-w-lg':
|
|
25
|
-
'sm:max-w-md md:max-w-xl':
|
|
26
|
-
'sm:max-w-md md:max-w-xl lg:max-w-2xl':
|
|
27
|
-
'sm:max-w-md md:max-w-xl lg:max-w-3xl':
|
|
28
|
-
'sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-4xl':
|
|
29
|
-
'sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-5xl':
|
|
30
|
-
'sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-5xl 2xl:max-w-6xl':
|
|
31
|
-
'sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-5xl 2xl:max-w-7xl':
|
|
22
|
+
'sm:max-w-sm': config.maxWidth === 'sm',
|
|
23
|
+
'sm:max-w-md': config.maxWidth === 'md',
|
|
24
|
+
'sm:max-w-md md:max-w-lg': config.maxWidth === 'lg',
|
|
25
|
+
'sm:max-w-md md:max-w-xl': config.maxWidth === 'xl',
|
|
26
|
+
'sm:max-w-md md:max-w-xl lg:max-w-2xl': config.maxWidth === '2xl',
|
|
27
|
+
'sm:max-w-md md:max-w-xl lg:max-w-3xl': config.maxWidth === '3xl',
|
|
28
|
+
'sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-4xl': config.maxWidth === '4xl',
|
|
29
|
+
'sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-5xl': config.maxWidth === '5xl',
|
|
30
|
+
'sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-5xl 2xl:max-w-6xl': config.maxWidth === '6xl',
|
|
31
|
+
'sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-5xl 2xl:max-w-7xl': config.maxWidth === '7xl',
|
|
32
32
|
})}
|
|
33
33
|
>
|
|
34
|
-
<DialogPanel className={`im-modal-content relative ${
|
|
35
|
-
{
|
|
34
|
+
<DialogPanel className={`im-modal-content relative ${config.paddingClasses} ${config.panelClasses}`}>
|
|
35
|
+
{config.closeButton && (
|
|
36
36
|
<div className="absolute right-0 top-0 pr-3 pt-3">
|
|
37
37
|
<CloseButton onClick={modalContext.close} />
|
|
38
38
|
</div>
|
|
39
39
|
)}
|
|
40
|
-
{typeof children === 'function' ? children({ modalContext,
|
|
40
|
+
{typeof children === 'function' ? children({ modalContext, config }) : children}
|
|
41
41
|
</DialogPanel>
|
|
42
42
|
</TransitionChild>
|
|
43
43
|
</div>
|
package/src/ModalRenderer.jsx
CHANGED
|
@@ -23,7 +23,7 @@ const ModalRenderer = ({ index }) => {
|
|
|
23
23
|
modalContext?.component && (
|
|
24
24
|
<ModalIndexContext.Provider value={index}>
|
|
25
25
|
<modalContext.component
|
|
26
|
-
{...modalContext.
|
|
26
|
+
{...modalContext.props}
|
|
27
27
|
onModalEvent={(...args) => modalContext.emit(...args)}
|
|
28
28
|
/>
|
|
29
29
|
</ModalIndexContext.Provider>
|
package/src/ModalRoot.jsx
CHANGED
|
@@ -72,16 +72,16 @@ export const ModalStackProvider = ({ children }) => {
|
|
|
72
72
|
}, [stack])
|
|
73
73
|
|
|
74
74
|
class Modal {
|
|
75
|
-
constructor(component, response,
|
|
75
|
+
constructor(component, response, config, onClose, afterLeave) {
|
|
76
76
|
this.id = Modal.generateId()
|
|
77
77
|
this.isOpen = false
|
|
78
78
|
this.shouldRender = false
|
|
79
79
|
this.listeners = {}
|
|
80
80
|
|
|
81
81
|
this.component = component
|
|
82
|
-
this.
|
|
82
|
+
this.props = response.props
|
|
83
83
|
this.response = response
|
|
84
|
-
this.
|
|
84
|
+
this.config = config
|
|
85
85
|
this.onCloseCallback = onClose
|
|
86
86
|
this.afterLeaveCallback = afterLeave
|
|
87
87
|
|
|
@@ -99,11 +99,11 @@ export const ModalStackProvider = ({ children }) => {
|
|
|
99
99
|
return `inertiaui_modal_${Date.now().toString(36)}_${Math.random().toString(36).substr(2, 9)}`
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
update = (
|
|
102
|
+
update = (config, onClose, afterLeave) => {
|
|
103
103
|
updateStack((prevStack) =>
|
|
104
104
|
prevStack.map((modal) => {
|
|
105
105
|
if (modal.id === this.id) {
|
|
106
|
-
modal.
|
|
106
|
+
modal.config = config
|
|
107
107
|
modal.onCloseCallback = onClose
|
|
108
108
|
modal.afterLeaveCallback = afterLeave
|
|
109
109
|
}
|
|
@@ -129,7 +129,6 @@ export const ModalStackProvider = ({ children }) => {
|
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
close = () => {
|
|
132
|
-
console.log('Closing', this.id)
|
|
133
132
|
updateStack((prevStack) =>
|
|
134
133
|
prevStack.map((modal) => {
|
|
135
134
|
if (modal.id === this.id && modal.isOpen) {
|
|
@@ -146,7 +145,6 @@ export const ModalStackProvider = ({ children }) => {
|
|
|
146
145
|
}
|
|
147
146
|
|
|
148
147
|
afterLeave = () => {
|
|
149
|
-
console.log('After leave', this.id)
|
|
150
148
|
if (this.isOpen) {
|
|
151
149
|
return
|
|
152
150
|
}
|
|
@@ -228,18 +226,18 @@ export const ModalStackProvider = ({ children }) => {
|
|
|
228
226
|
'X-InertiaUI-Modal-Use-Router': 0,
|
|
229
227
|
},
|
|
230
228
|
}).then((response) => {
|
|
231
|
-
Object.assign(this.
|
|
229
|
+
Object.assign(this.props, response.data.props)
|
|
232
230
|
updateStack((prevStack) => prevStack) // Trigger re-render
|
|
233
231
|
})
|
|
234
232
|
}
|
|
235
233
|
}
|
|
236
234
|
|
|
237
|
-
const pushFromResponseData = (responseData,
|
|
238
|
-
return resolveComponent(responseData.component).then((component) => push(component, responseData,
|
|
235
|
+
const pushFromResponseData = (responseData, config = {}, onClose = null, onAfterLeave = null) => {
|
|
236
|
+
return resolveComponent(responseData.component).then((component) => push(component, responseData, config, onClose, onAfterLeave))
|
|
239
237
|
}
|
|
240
238
|
|
|
241
|
-
const push = (component, response,
|
|
242
|
-
const newModal = new Modal(component, response,
|
|
239
|
+
const push = (component, response, config, onClose, afterLeave) => {
|
|
240
|
+
const newModal = new Modal(component, response, config, onClose, afterLeave)
|
|
243
241
|
newModal.index = stack.length
|
|
244
242
|
|
|
245
243
|
updateStack((prevStack) => [...prevStack, newModal])
|
|
@@ -249,12 +247,12 @@ export const ModalStackProvider = ({ children }) => {
|
|
|
249
247
|
return newModal
|
|
250
248
|
}
|
|
251
249
|
|
|
252
|
-
function pushLocalModal(name,
|
|
250
|
+
function pushLocalModal(name, config, onClose, afterLeave) {
|
|
253
251
|
if (!localModals[name]) {
|
|
254
252
|
throw new Error(`The local modal "${name}" has not been registered.`)
|
|
255
253
|
}
|
|
256
254
|
|
|
257
|
-
const modal = push(null, {},
|
|
255
|
+
const modal = push(null, {}, config, onClose, afterLeave)
|
|
258
256
|
modal.name = name
|
|
259
257
|
localModals[name].callback(modal)
|
|
260
258
|
return modal
|
|
@@ -278,7 +276,7 @@ export const ModalStackProvider = ({ children }) => {
|
|
|
278
276
|
method,
|
|
279
277
|
payload = {},
|
|
280
278
|
headers = {},
|
|
281
|
-
|
|
279
|
+
config = {},
|
|
282
280
|
onClose = null,
|
|
283
281
|
onAfterLeave = null,
|
|
284
282
|
queryStringArrayFormat = 'brackets',
|
|
@@ -286,7 +284,7 @@ export const ModalStackProvider = ({ children }) => {
|
|
|
286
284
|
) => {
|
|
287
285
|
return new Promise((resolve, reject) => {
|
|
288
286
|
if (href.startsWith('#')) {
|
|
289
|
-
resolve(pushLocalModal(href.substring(1),
|
|
287
|
+
resolve(pushLocalModal(href.substring(1), config, onClose, onAfterLeave))
|
|
290
288
|
return
|
|
291
289
|
}
|
|
292
290
|
|
|
@@ -323,7 +321,7 @@ export const ModalStackProvider = ({ children }) => {
|
|
|
323
321
|
const originalAfterLeave = modal.afterLeaveCallback
|
|
324
322
|
|
|
325
323
|
modal.update(
|
|
326
|
-
|
|
324
|
+
config,
|
|
327
325
|
() => {
|
|
328
326
|
onClose?.()
|
|
329
327
|
originalOnClose?.()
|
|
@@ -349,7 +347,7 @@ export const ModalStackProvider = ({ children }) => {
|
|
|
349
347
|
data,
|
|
350
348
|
headers,
|
|
351
349
|
})
|
|
352
|
-
.then((response) => resolve(pushFromResponseData(response.data,
|
|
350
|
+
.then((response) => resolve(pushFromResponseData(response.data, config, onClose, onAfterLeave)))
|
|
353
351
|
.catch((error) => {
|
|
354
352
|
reject(error)
|
|
355
353
|
})
|
|
@@ -377,7 +375,6 @@ export const ModalStackProvider = ({ children }) => {
|
|
|
377
375
|
push,
|
|
378
376
|
pushFromResponseData,
|
|
379
377
|
closeAll: () => {
|
|
380
|
-
console.log('Closing all modals', { stack, localStackCopy })
|
|
381
378
|
localStackCopy.reverse().forEach((modal) => modal.close())
|
|
382
379
|
},
|
|
383
380
|
reset: () => updateStack(() => []),
|
package/src/SlideoverContent.jsx
CHANGED
|
@@ -2,41 +2,41 @@ import { TransitionChild, DialogPanel } from '@headlessui/react'
|
|
|
2
2
|
import CloseButton from './CloseButton'
|
|
3
3
|
import clsx from 'clsx'
|
|
4
4
|
|
|
5
|
-
const SlideoverContent = ({ modalContext,
|
|
5
|
+
const SlideoverContent = ({ modalContext, config, children }) => {
|
|
6
6
|
return (
|
|
7
7
|
<div className="im-slideover-container fixed inset-0 z-40 overflow-y-auto overflow-x-hidden">
|
|
8
8
|
<div
|
|
9
9
|
className={clsx('im-slideover-positioner flex min-h-full items-center', {
|
|
10
|
-
'justify-start':
|
|
11
|
-
'justify-end':
|
|
10
|
+
'justify-start': config.position === 'left',
|
|
11
|
+
'justify-end': config.position === 'right',
|
|
12
12
|
})}
|
|
13
13
|
>
|
|
14
14
|
<TransitionChild
|
|
15
|
-
enterFrom={`opacity-0 ${
|
|
15
|
+
enterFrom={`opacity-0 ${config.position === 'left' ? '-translate-x-full' : 'translate-x-full'}`}
|
|
16
16
|
enterTo="opacity-100 translate-x-0"
|
|
17
17
|
leaveFrom="opacity-100 translate-x-0"
|
|
18
|
-
leaveTo={`opacity-0 ${
|
|
18
|
+
leaveTo={`opacity-0 ${config.position === 'left' ? '-translate-x-full' : 'translate-x-full'}`}
|
|
19
19
|
afterLeave={modalContext.afterLeave}
|
|
20
20
|
className={clsx('im-slideover-wrapper w-full transition duration-300 ease-in-out', modalContext.onTopOfStack ? '' : 'blur-sm', {
|
|
21
|
-
'sm:max-w-sm':
|
|
22
|
-
'sm:max-w-md':
|
|
23
|
-
'sm:max-w-md md:max-w-lg':
|
|
24
|
-
'sm:max-w-md md:max-w-xl':
|
|
25
|
-
'sm:max-w-md md:max-w-xl lg:max-w-2xl':
|
|
26
|
-
'sm:max-w-md md:max-w-xl lg:max-w-3xl':
|
|
27
|
-
'sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-4xl':
|
|
28
|
-
'sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-5xl':
|
|
29
|
-
'sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-5xl 2xl:max-w-6xl':
|
|
30
|
-
'sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-5xl 2xl:max-w-7xl':
|
|
21
|
+
'sm:max-w-sm': config.maxWidth === 'sm',
|
|
22
|
+
'sm:max-w-md': config.maxWidth === 'md',
|
|
23
|
+
'sm:max-w-md md:max-w-lg': config.maxWidth === 'lg',
|
|
24
|
+
'sm:max-w-md md:max-w-xl': config.maxWidth === 'xl',
|
|
25
|
+
'sm:max-w-md md:max-w-xl lg:max-w-2xl': config.maxWidth === '2xl',
|
|
26
|
+
'sm:max-w-md md:max-w-xl lg:max-w-3xl': config.maxWidth === '3xl',
|
|
27
|
+
'sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-4xl': config.maxWidth === '4xl',
|
|
28
|
+
'sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-5xl': config.maxWidth === '5xl',
|
|
29
|
+
'sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-5xl 2xl:max-w-6xl': config.maxWidth === '6xl',
|
|
30
|
+
'sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-5xl 2xl:max-w-7xl': config.maxWidth === '7xl',
|
|
31
31
|
})}
|
|
32
32
|
>
|
|
33
|
-
<DialogPanel className={`im-slideover-content relative ${
|
|
34
|
-
{
|
|
33
|
+
<DialogPanel className={`im-slideover-content relative ${config.paddingClasses} ${config.panelClasses}`}>
|
|
34
|
+
{config.closeButton && (
|
|
35
35
|
<div className="absolute right-0 top-0 pr-3 pt-3">
|
|
36
36
|
<CloseButton onClick={modalContext.close} />
|
|
37
37
|
</div>
|
|
38
38
|
)}
|
|
39
|
-
{typeof children === 'function' ? children({ modalContext,
|
|
39
|
+
{typeof children === 'function' ? children({ modalContext, config }) : children}
|
|
40
40
|
</DialogPanel>
|
|
41
41
|
</TransitionChild>
|
|
42
42
|
</div>
|
package/src/inertiauiModal.js
CHANGED
|
@@ -4,5 +4,6 @@ import { useModalStack, ModalRoot, ModalStackProvider, renderApp } from './Modal
|
|
|
4
4
|
import HeadlessModal from './HeadlessModal.jsx'
|
|
5
5
|
import Modal from './Modal.jsx'
|
|
6
6
|
import ModalLink from './ModalLink.jsx'
|
|
7
|
+
import useModal from './useModal.js'
|
|
7
8
|
|
|
8
|
-
export { getConfig, putConfig, resetConfig, useModalStack, useModalIndex, HeadlessModal, Modal, ModalLink, ModalRoot, ModalStackProvider, renderApp }
|
|
9
|
+
export { getConfig, putConfig, resetConfig, useModalStack, useModalIndex, HeadlessModal, Modal, ModalLink, ModalRoot, ModalStackProvider, renderApp, useModal }
|