@infonomic/uikit 6.1.0 → 6.2.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.
Files changed (68) hide show
  1. package/dist/components/inputs/input.module.css +7 -0
  2. package/dist/components/inputs/input_module.css +4 -0
  3. package/dist/components/inputs/text-area.module.css +15 -9
  4. package/dist/components/inputs/text-area_module.css +4 -0
  5. package/dist/styles/components-vanilla.css +1 -1
  6. package/dist/widgets/drawer/drawer-container.d.ts.map +1 -1
  7. package/dist/widgets/drawer/drawer-container.js +0 -1
  8. package/dist/widgets/drawer/drawer.d.ts +1 -1
  9. package/dist/widgets/drawer/drawer.d.ts.map +1 -1
  10. package/dist/widgets/drawer/drawer.js +34 -49
  11. package/dist/widgets/drawer/drawer.module.css +66 -54
  12. package/dist/widgets/drawer/drawer.module.js +3 -5
  13. package/dist/widgets/drawer/drawer_module.css +47 -81
  14. package/dist/widgets/modal/modal.d.ts +1 -1
  15. package/dist/widgets/modal/modal.d.ts.map +1 -1
  16. package/dist/widgets/modal/modal.js +23 -36
  17. package/dist/widgets/modal/modal.module.css +50 -9
  18. package/dist/widgets/modal/modal.module.js +1 -0
  19. package/dist/widgets/modal/modal_module.css +40 -8
  20. package/package.json +1 -1
  21. package/src/components/inputs/input.module.css +7 -0
  22. package/src/components/inputs/text-area.module.css +15 -9
  23. package/src/styles/local-fonts.css +5 -1
  24. package/src/widgets/drawer/drawer-container.tsx +0 -1
  25. package/src/widgets/drawer/drawer.module.css +66 -54
  26. package/src/widgets/drawer/drawer.stories.tsx +51 -5
  27. package/src/widgets/drawer/drawer.tsx +33 -50
  28. package/src/widgets/modal/modal.module.css +50 -9
  29. package/src/widgets/modal/modal.tsx +27 -45
  30. package/dist/components/overlay/index.d.ts +0 -2
  31. package/dist/components/overlay/index.d.ts.map +0 -1
  32. package/dist/components/overlay/index.js +0 -1
  33. package/dist/components/overlay/overlay.d.ts +0 -9
  34. package/dist/components/overlay/overlay.d.ts.map +0 -1
  35. package/dist/components/overlay/overlay.js +0 -51
  36. package/dist/components/overlay/overlay.module.css +0 -56
  37. package/dist/components/overlay/overlay.module.js +0 -13
  38. package/dist/components/overlay/overlay_module.css +0 -46
  39. package/dist/hooks/use-focus-trap/index.d.ts +0 -2
  40. package/dist/hooks/use-focus-trap/index.d.ts.map +0 -1
  41. package/dist/hooks/use-focus-trap/scope-tab.d.ts +0 -11
  42. package/dist/hooks/use-focus-trap/scope-tab.d.ts.map +0 -1
  43. package/dist/hooks/use-focus-trap/tabbable.d.ts +0 -14
  44. package/dist/hooks/use-focus-trap/tabbable.d.ts.map +0 -1
  45. package/dist/hooks/use-focus-trap/use-focus-trap.d.ts +0 -11
  46. package/dist/hooks/use-focus-trap/use-focus-trap.d.ts.map +0 -1
  47. package/dist/utils/getPortalRoot.d.ts +0 -2
  48. package/dist/utils/getPortalRoot.d.ts.map +0 -1
  49. package/dist/widgets/drawer/drawer-wrapper.d.ts +0 -9
  50. package/dist/widgets/drawer/drawer-wrapper.d.ts.map +0 -1
  51. package/dist/widgets/drawer/drawer-wrapper.js +0 -37
  52. package/dist/widgets/drawer/motionDomAnimation.d.ts +0 -3
  53. package/dist/widgets/drawer/motionDomAnimation.d.ts.map +0 -1
  54. package/dist/widgets/drawer/motionDomMax.d.ts +0 -3
  55. package/dist/widgets/drawer/motionDomMax.d.ts.map +0 -1
  56. package/dist/widgets/modal/modal-wrapper.d.ts +0 -8
  57. package/dist/widgets/modal/modal-wrapper.d.ts.map +0 -1
  58. package/dist/widgets/modal/modal-wrapper.js +0 -37
  59. package/dist/widgets/modal/motionDomAnimation.d.ts +0 -3
  60. package/dist/widgets/modal/motionDomAnimation.d.ts.map +0 -1
  61. package/dist/widgets/modal/motionDomMax.d.ts +0 -3
  62. package/dist/widgets/modal/motionDomMax.d.ts.map +0 -1
  63. package/src/components/overlay/index.stories.tsx +0 -26
  64. package/src/components/overlay/index.ts +0 -2
  65. package/src/components/overlay/overlay.module.css +0 -56
  66. package/src/components/overlay/overlay.tsx +0 -70
  67. package/src/widgets/drawer/drawer-wrapper.tsx +0 -53
  68. package/src/widgets/modal/modal-wrapper.tsx +0 -51
@@ -1,84 +1,108 @@
1
1
  @layer infonomic-base, infonomic-utilities, infonomic-theme, infonomic-components;
2
2
 
3
3
  @layer infonomic-components {
4
+
5
+ /* Backdrop overlay (replaces previous Overlay component) */
6
+
7
+ .backdrop,
8
+ :global(.infonomic-drawer-backdrop) {
9
+ position: fixed;
10
+ top: 0;
11
+ left: 0;
12
+ right: 0;
13
+ bottom: 0;
14
+ background-color: rgba(245, 245, 245, 0.35);
15
+ transition: opacity 200ms ease;
16
+ }
17
+
18
+ .backdrop[data-starting-style],
19
+ .backdrop[data-ending-style] {
20
+ opacity: 0;
21
+ }
22
+
23
+ :global(.dark) .backdrop,
24
+ :global([data-theme="dark"]) .backdrop,
25
+ :global(.dark .infonomic-drawer-backdrop),
26
+ :global([data-theme="dark"] .infonomic-drawer-backdrop) {
27
+ background-color: rgba(0, 0, 0, 0.5);
28
+ }
29
+
30
+ /* Drawer wrapper / popup — the sliding panel itself */
31
+
4
32
  .drawer-wrapper,
5
33
  :global(.infonomic-drawer-wrapper) {
6
34
  position: fixed;
7
35
  display: flex;
8
36
  flex-direction: column;
9
- justify-content: end;
10
37
  top: 0;
11
- left: 0;
12
38
  right: 0;
13
39
  bottom: 0;
14
- z-index: 30;
15
- opacity: 1;
40
+ background-color: var(--surface-panel);
41
+ box-shadow: var(--shadow-md);
42
+ overflow: hidden;
43
+ transition: transform 200ms cubic-bezier(0.16, 1, 0.3, 1);
44
+ }
45
+
46
+ .drawer-wrapper[data-open] {
47
+ transform: translateX(var(--drawer-swipe-movement-x, 0px));
48
+ }
49
+
50
+ .drawer-wrapper[data-closed],
51
+ .drawer-wrapper[data-starting-style] {
52
+ transform: translateX(100%);
16
53
  }
17
54
 
55
+ .drawer-wrapper[data-swiping] {
56
+ transition: none;
57
+ }
58
+
59
+ /* Container (inner wrapper, no longer needs positioning) */
60
+
18
61
  .drawer-container,
19
62
  :global(.infonomic-drawer-container) {
20
- position: absolute;
21
- right: 0;
22
63
  height: 100%;
23
- background-color: var(--surface-panel);
24
- box-shadow: var(--shadow-md);
25
- z-index: inherit;
26
64
  }
27
65
 
28
- .drawer-container[aria-hidden="false"],
29
- :global(.infonomic-drawer-container[aria-hidden="false"]) {
30
- animation: slideIn 150ms cubic-bezier(0.16, 1, 0.3, 1);
66
+ /* Width variant: narrow */
67
+
68
+ .drawer-narrow,
69
+ :global(.infonomic-drawer-narrow) {
70
+ width: calc(100% - 32px);
71
+ max-width: 400px;
31
72
  }
32
73
 
33
- .drawer-depth-0.drawer-medium .drawer-container,
34
- .drawer-depth-0.drawer-wide .drawer-container,
35
- :global(.infonomic-drawer-depth-0.drawer-medium .drawer-container),
36
- :global(.infonomic-drawer-depth-0.drawer-wide .drawer-container) {
74
+ /* Width variants: medium/wide at different depths */
75
+
76
+ .drawer-depth-0.drawer-medium,
77
+ .drawer-depth-0.drawer-wide {
37
78
  width: 90%;
38
79
  }
39
80
 
40
- .drawer-depth-1.drawer-medium .drawer-container,
41
- .drawer-depth-1.drawer-wide .drawer-container,
42
- :global(.infonomic-drawer-depth-1.drawer-medium .drawer-container),
43
- :global(.infonomic-drawer-depth-1.drawer-wide .drawer-container) {
81
+ .drawer-depth-1.drawer-medium,
82
+ .drawer-depth-1.drawer-wide {
44
83
  width: 88%;
45
84
  }
46
85
 
47
- .drawer-depth-2.drawer- .drawer-container,
48
- .drawer-depth-2.drawer-wide .drawer-container,
49
- :global(.infonomic-drawer-depth-2.drawer-medium .drawer-container),
50
- :global(.infonomic-drawer-depth-2.drawer-wide .drawer-container) {
86
+ .drawer-depth-2.drawer-medium,
87
+ .drawer-depth-2.drawer-wide {
51
88
  width: 86%;
52
89
  }
53
90
 
54
91
  @media (min-width: 48rem) {
55
- .drawer-depth-0.drawer-medium .drawer-container,
56
- :global(.infonomic-drawer-depth-0.drawer-medium .drawer-container) {
92
+ .drawer-depth-0.drawer-medium {
57
93
  width: 600px;
58
94
  }
59
95
 
60
- .drawer-depth-1.drawer-medium .drawer-container,
61
- :global(.infonomic-drawer-depth-1.drawer-medium .drawer-container) {
96
+ .drawer-depth-1.drawer-medium {
62
97
  width: 580px;
63
98
  }
64
99
 
65
- .drawer-depth-2.drawer- .drawer-container,
66
- :global(.infonomic-drawer-depth-2.drawer-medium .drawer-container) {
100
+ .drawer-depth-2.drawer-medium {
67
101
  width: 560px;
68
102
  }
69
103
  }
70
104
 
71
- .drawer-narrow .drawer-container,
72
- :global(.infonomic-drawer-narrow .infonomic-drawer-container) {
73
- width: calc(100% - 32px);
74
- max-width: 400px;
75
- }
76
-
77
- .drawer-container[aria-hidden="true"],
78
- :global(.infonomic-drawer-container[aria-hidden="true"]) {
79
- transform: translateX(100%);
80
- opacity: 0;
81
- }
105
+ /* Sub-component styles */
82
106
 
83
107
  .drawer-top-actions,
84
108
  :global(.infonomic-drawer-top-actions) {
@@ -115,16 +139,4 @@
115
139
  :global(.infonomic-drawer-content) {
116
140
  padding: var(--spacing-12);
117
141
  }
118
-
119
- @keyframes slideIn {
120
- from {
121
- transform: translateX(100%);
122
- opacity: 0;
123
- }
124
-
125
- to {
126
- transform: translateX(0);
127
- opacity: 1;
128
- }
129
- }
130
- }
142
+ }
@@ -31,7 +31,53 @@ export const Default = (): React.JSX.Element => {
31
31
  isOpen={isOpen}
32
32
  onDismiss={() => setIsOpen(false)}
33
33
  >
34
- <Drawer.Container aria-hidden={!isOpen}>
34
+ <Drawer.Container>
35
+ <Drawer.TopActions>
36
+ <button type="button" tabIndex={0} className="sr-only">
37
+ no action
38
+ </button>
39
+ <IconButton
40
+ arial-label="Close"
41
+ size="xs"
42
+ onClick={() => {
43
+ setIsOpen(false)
44
+ }}
45
+ >
46
+ <CloseIcon width="14px" height="14px" />
47
+ </IconButton>
48
+ </Drawer.TopActions>
49
+ <Drawer.Header className="flex items-center justify-between mb-4">
50
+ <h2>Drawer Actions Here</h2>
51
+ </Drawer.Header>
52
+ <Drawer.Content>
53
+ <p>Drawer content here...</p>
54
+ </Drawer.Content>
55
+ </Drawer.Container>
56
+ </Drawer>
57
+ </>
58
+ )
59
+ }
60
+
61
+ export const TopOffset = (): React.JSX.Element => {
62
+ const [isOpen, setIsOpen] = React.useState(false)
63
+
64
+ return (
65
+ <>
66
+ <Button
67
+ onClick={() => {
68
+ setIsOpen(true)
69
+ }}
70
+ >
71
+ Open Drawer
72
+ </Button>
73
+ <Drawer
74
+ id="top-offset-drawer"
75
+ topOffset="60px"
76
+ closeOnOverlayClick={false}
77
+ isOpen={isOpen}
78
+ onDismiss={() => setIsOpen(false)}
79
+ >
80
+ <Drawer.Container>
35
81
  <Drawer.TopActions>
36
82
  <button type="button" tabIndex={0} className="sr-only">
37
83
  no action
@@ -72,12 +118,12 @@ export const Wide = (): React.JSX.Element => {
72
118
  </Button>
73
119
  <Drawer
74
120
  id="first-drawer"
75
- closeOnOverlayClick={true}
121
+ closeOnOverlayClick={false}
76
122
  isOpen={isOpen}
77
123
  width="wide"
78
124
  onDismiss={() => setIsOpen(false)}
79
125
  >
80
- <Drawer.Container aria-hidden={!isOpen}>
126
+ <Drawer.Container>
81
127
  <Drawer.TopActions>
82
128
  <button type="button" tabIndex={0} className="sr-only">
83
129
  no action
@@ -136,7 +182,7 @@ export const Nested = (): React.JSX.Element => {
136
182
  isOpen={isOpen1}
137
183
  onDismiss={() => setIsOpen1(false)}
138
184
  >
139
- <Drawer.Container aria-hidden={!isOpen1}>
185
+ <Drawer.Container>
140
186
  <Drawer.TopActions>
141
187
  <button type="button" tabIndex={0} className="sr-only">
142
188
  no action
@@ -170,7 +216,7 @@ export const Nested = (): React.JSX.Element => {
170
216
  isOpen={isOpen2}
171
217
  onDismiss={() => setIsOpen2(false)}
172
218
  >
173
- <Drawer.Container aria-hidden={!isOpen2}>
219
+ <Drawer.Container>
174
220
  <Drawer.TopActions>
175
221
  <button type="button" tabIndex={0} className="sr-only">
176
222
  no action
@@ -3,20 +3,15 @@
3
3
  import type { ReactNode } from 'react'
4
4
  import { useEffect } from 'react'
5
5
 
6
+ import { Drawer as BaseDrawer } from '@base-ui/react/drawer'
6
7
  import cx from 'classnames'
7
- import { AnimatePresence, type FeatureBundle, LazyMotion } from 'motion/react'
8
- import { createPortal } from 'react-dom'
9
8
 
10
- import { Overlay } from '../../components/overlay'
11
- import { useMediaQuery } from '../../hooks/use-media-query'
12
- import { getPortalRoot } from '../../utils/getPortalRoot'
13
9
  import styles from './drawer.module.css'
14
10
  import { DrawerContainer } from './drawer-container'
15
11
  import { DrawerContent } from './drawer-content'
16
12
  import { useDrawer } from './drawer-context'
17
13
  import { DrawerHeader } from './drawer-header'
18
14
  import { DrawerTopActions } from './drawer-top-actions'
19
- import { DrawerWrapper } from './drawer-wrapper'
20
15
 
21
16
  type Styles = {
22
17
  [key: string]: string
@@ -24,11 +19,6 @@ type Styles = {
24
19
 
25
20
  const typedStyles: Styles = styles
26
21
 
27
- const DomMax: () => Promise<FeatureBundle> = async () =>
28
- await import('./motionDomMax').then((mod) => mod.default)
29
- const DomAnimation: () => Promise<FeatureBundle> = async () =>
30
- await import('./motionDomAnimation').then((mod) => mod.default)
31
-
32
22
  export interface DrawerProps {
33
23
  id: string
34
24
  isOpen: boolean
@@ -47,20 +37,10 @@ const Drawer = ({
47
37
  children,
48
38
  width = 'narrow',
49
39
  topOffset = '0',
50
- ...rest
51
40
  }: DrawerProps) => {
52
- const isMobile = useMediaQuery('(max-width: 768px)') ?? false
53
41
  const { addDrawer, removeDrawer, drawers } = useDrawer()
54
42
  const depth = drawers.indexOf(id)
55
43
 
56
- const handleOverlayDismiss = (e: any): void => {
57
- e.stopPropagation()
58
- e.preventDefault()
59
- if (closeOnOverlayClick === true) {
60
- onDismiss?.()
61
- }
62
- }
63
-
64
44
  useEffect(() => {
65
45
  if (isOpen) {
66
46
  addDrawer(id)
@@ -70,35 +50,38 @@ const Drawer = ({
70
50
  return () => removeDrawer(id)
71
51
  }, [isOpen, id, addDrawer, removeDrawer])
72
52
 
73
- const portal = getPortalRoot()
74
-
75
- if (portal === false) return null
76
-
77
- return createPortal(
78
- <LazyMotion features={isMobile ? DomMax : DomAnimation}>
79
- <AnimatePresence>
80
- {isOpen === true && (
81
- <DrawerWrapper
82
- style={{ zIndex: 20 + depth, top: topOffset }}
83
- transition={{ duration: 0.2 }}
84
- onEscapeKey={handleOverlayDismiss}
85
- className={cx(
86
- typedStyles[`drawer-${width}`],
87
- typedStyles[`drawer-depth-${depth.toString()}`]
88
- )}
89
- {...rest}
90
- >
91
- <Overlay
92
- onClick={handleOverlayDismiss}
93
- style={{ top: topOffset }}
94
- isUnmounting={!(isOpen ?? false)}
95
- />
96
- {children}
97
- </DrawerWrapper>
98
- )}
99
- </AnimatePresence>
100
- </LazyMotion>,
101
- portal
53
+ const hasTopOffset = topOffset !== '0'
54
+
55
+ return (
56
+ <BaseDrawer.Root
57
+ open={isOpen}
58
+ onOpenChange={(open) => {
59
+ if (!open) {
60
+ onDismiss()
61
+ }
62
+ }}
63
+ modal={hasTopOffset ? 'trap-focus' : true}
64
+ swipeDirection="right"
65
+ disablePointerDismissal={closeOnOverlayClick !== true}
66
+ >
67
+ <BaseDrawer.Portal>
68
+ <BaseDrawer.Backdrop
69
+ className={cx('infonomic-drawer-backdrop', styles.backdrop)}
70
+ style={hasTopOffset ? { top: topOffset } : undefined}
71
+ />
72
+ <BaseDrawer.Popup
73
+ className={cx(
74
+ 'infonomic-drawer-wrapper',
75
+ styles['drawer-wrapper'],
76
+ typedStyles[`drawer-${width}`],
77
+ typedStyles[`drawer-depth-${depth.toString()}`]
78
+ )}
79
+ style={hasTopOffset ? { top: topOffset } : undefined}
80
+ >
81
+ {children}
82
+ </BaseDrawer.Popup>
83
+ </BaseDrawer.Portal>
84
+ </BaseDrawer.Root>
102
85
  )
103
86
  }
104
87
 
@@ -1,33 +1,72 @@
1
1
  @layer infonomic-base, infonomic-utilities, infonomic-theme, infonomic-components;
2
2
 
3
3
  @layer infonomic-components {
4
+
5
+ /* Backdrop overlay */
6
+
7
+ .backdrop,
8
+ :global(.infonomic-modal-backdrop) {
9
+ position: fixed;
10
+ top: 0;
11
+ left: 0;
12
+ right: 0;
13
+ bottom: 0;
14
+ background-color: rgba(245, 245, 245, 0.35);
15
+ transition: opacity 200ms ease;
16
+ }
17
+
18
+ .backdrop[data-starting-style],
19
+ .backdrop[data-ending-style] {
20
+ opacity: 0;
21
+ }
22
+
23
+ :global(.dark) .backdrop,
24
+ :global([data-theme="dark"]) .backdrop,
25
+ :global(.dark .infonomic-modal-backdrop),
26
+ :global([data-theme="dark"] .infonomic-modal-backdrop) {
27
+ background-color: rgba(0, 0, 0, 0.5);
28
+ }
29
+
30
+ /* Modal wrapper / popup — the dialog surface */
31
+
4
32
  .modal-wrapper,
5
- :global(.infonomic-modal-open) {
33
+ :global(.infonomic-modal-wrapper) {
6
34
  position: fixed;
7
35
  display: flex;
8
36
  flex-direction: column;
9
- justify-content: center;
37
+ justify-content: flex-end;
10
38
  align-items: center;
11
39
  top: 0;
12
40
  left: 0;
13
41
  right: 0;
14
42
  bottom: 0;
15
- z-index: 30;
16
- opacity: 1;
43
+ transition: opacity 200ms ease;
44
+ }
45
+
46
+ .modal-wrapper[data-starting-style],
47
+ .modal-wrapper[data-ending-style] {
48
+ opacity: 0;
17
49
  }
18
50
 
51
+ @media screen and (min-width: 40rem) {
52
+
53
+ .modal-wrapper,
54
+ :global(.infonomic-modal-wrapper) {
55
+ justify-content: center;
56
+ }
57
+ }
58
+
59
+ /* Container — the visible dialog box */
60
+
19
61
  .modal-container,
20
62
  :global(.infonomic-modal-container) {
21
- position: absolute;
22
63
  display: flex;
23
64
  flex-direction: column;
24
65
  box-shadow: var(--shadow-md);
25
66
  border-radius: var(--border-radius-md);
26
- z-index: 20;
27
67
  min-height: 300px;
28
68
  max-height: 88vh;
29
69
  width: 100%;
30
- bottom: 0;
31
70
  background-color: var(--surface-panel);
32
71
  border: 1px solid var(--border-color);
33
72
  margin-left: var(--spacing-8);
@@ -35,15 +74,17 @@
35
74
  }
36
75
 
37
76
  @media screen and (min-width: 40rem) {
77
+
38
78
  .modal-container,
39
79
  :global(.infonomic-modal-container) {
40
80
  max-height: calc(100vh - 24px);
41
81
  min-height: auto;
42
- bottom: auto;
43
82
  width: auto;
44
83
  }
45
84
  }
46
85
 
86
+ /* Sub-component styles */
87
+
47
88
  .modal-header,
48
89
  :global(.infonomic-modal-header) {
49
90
  display: flex;
@@ -86,4 +127,4 @@
86
127
  padding-left: var(--spacing-16);
87
128
  padding-right: var(--spacing-16);
88
129
  }
89
- }
130
+ }
@@ -1,25 +1,16 @@
1
1
  'use client'
2
2
 
3
- /* eslint-disable @typescript-eslint/consistent-type-imports */
4
3
  import type React from 'react'
5
4
  import { createContext, useCallback, useState } from 'react'
6
5
 
7
- import { AnimatePresence, type FeatureBundle, LazyMotion } from 'motion/react'
8
- import { createPortal } from 'react-dom'
6
+ import { Dialog } from '@base-ui/react/dialog'
7
+ import cx from 'classnames'
9
8
 
10
- import { Overlay } from '../../components/overlay'
11
- import { useMediaQuery } from '../../hooks/use-media-query'
12
- import { getPortalRoot } from '../../utils/getPortalRoot'
9
+ import styles from './modal.module.css'
13
10
  import { ModalActions } from './modal-actions'
14
11
  import { ModalContainer } from './modal-container'
15
12
  import { ModalContent } from './modal-content'
16
13
  import { ModalHeader } from './modal-header'
17
- import { ModalWrapper } from './modal-wrapper'
18
-
19
- const DomMax: () => Promise<FeatureBundle> = async () =>
20
- await import('./motionDomMax').then((mod) => mod.default)
21
- const DomAnimation: () => Promise<FeatureBundle> = async () =>
22
- await import('./motionDomAnimation').then((mod) => mod.default)
23
14
 
24
15
  export interface ModalProps {
25
16
  isOpen?: boolean
@@ -63,40 +54,31 @@ function Modal({
63
54
  onDismiss,
64
55
  closeOnOverlayClick,
65
56
  children,
66
- ...rest
67
- }: ModalProps): React.ReactPortal | null {
68
- const isMobile = useMediaQuery('(max-width: 768px)') ?? false
69
-
70
- const handleOverlayDismiss = (e: any): void => {
71
- e.stopPropagation()
72
- e.preventDefault()
73
- if (closeOnOverlayClick === true) {
74
- onDismiss?.()
75
- }
76
- }
77
-
78
- const portal = getPortalRoot()
79
-
80
- if (portal === false) return null
81
-
82
- return createPortal(
57
+ }: ModalProps): React.JSX.Element {
58
+ return (
83
59
  <ModalContext.Provider value={{ onDismiss }}>
84
- <LazyMotion features={isMobile ? DomMax : DomAnimation}>
85
- <AnimatePresence>
86
- {isOpen === true && (
87
- <ModalWrapper
88
- transition={{ duration: 0.2 }}
89
- onEscapeKey={handleOverlayDismiss}
90
- {...rest}
91
- >
92
- <Overlay onClick={handleOverlayDismiss} isUnmounting={!(isOpen ?? false)} />
93
- {children}
94
- </ModalWrapper>
95
- )}
96
- </AnimatePresence>
97
- </LazyMotion>
98
- </ModalContext.Provider>,
99
- portal
60
+ <Dialog.Root
61
+ open={isOpen}
62
+ onOpenChange={(open) => {
63
+ if (!open) {
64
+ onDismiss?.()
65
+ }
66
+ }}
67
+ modal
68
+ disablePointerDismissal={closeOnOverlayClick !== true}
69
+ >
70
+ <Dialog.Portal>
71
+ <Dialog.Backdrop
72
+ className={cx('infonomic-modal-backdrop', styles.backdrop)}
73
+ />
74
+ <Dialog.Popup
75
+ className={cx('infonomic-modal-wrapper', styles['modal-wrapper'])}
76
+ >
77
+ {children}
78
+ </Dialog.Popup>
79
+ </Dialog.Portal>
80
+ </Dialog.Root>
81
+ </ModalContext.Provider>
100
82
  )
101
83
  }
102
84
 
@@ -1,2 +0,0 @@
1
- export * from './overlay';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/overlay/index.ts"],"names":[],"mappings":"AACA,cAAc,WAAW,CAAA"}
@@ -1 +0,0 @@
1
- export * from "./overlay.js";
@@ -1,9 +0,0 @@
1
- import type React from 'react';
2
- type OverlayIntrinsicProps = React.JSX.IntrinsicElements['div'];
3
- export interface OverlayProps extends OverlayIntrinsicProps {
4
- isUnmounting?: boolean;
5
- className?: string;
6
- }
7
- export declare function Overlay(props: OverlayProps): React.JSX.Element;
8
- export {};
9
- //# sourceMappingURL=overlay.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"overlay.d.ts","sourceRoot":"","sources":["../../../src/components/overlay/overlay.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAO9B,KAAK,qBAAqB,GAAG,KAAK,CAAC,GAAG,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAA;AAC/D,MAAM,WAAW,YAAa,SAAQ,qBAAqB;IACzD,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAuCD,wBAAgB,OAAO,CAAC,KAAK,EAAE,YAAY,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAiB9D"}
@@ -1,51 +0,0 @@
1
- "use client";
2
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
- import { useEffect } from "react";
4
- import classnames from "classnames";
5
- import overlay_module from "./overlay.module.js";
6
- const BodyLock = ()=>{
7
- useEffect(()=>{
8
- const mediaMatch = window.matchMedia('(min-width: 768px)');
9
- let appBar;
10
- const classList = document.body.classList;
11
- appBar = document.getElementById('app-bar');
12
- classList.add('overlay-shown');
13
- if (null != appBar) appBar.classList.add('app-bar-overlay-shown');
14
- if (mediaMatch.matches) {
15
- classList.add('overlay-shown--desktop');
16
- if (null != appBar) appBar.classList.add('app-bar-overlay-shown--desktop');
17
- } else {
18
- classList.add('overlay-shown--mobile');
19
- if (null != appBar) appBar.classList.add('app-bar-overlay-shown--mobile');
20
- }
21
- return ()=>{
22
- classList.remove('overlay-shown');
23
- if (null != appBar) appBar.classList.remove('app-bar-overlay-shown');
24
- if (mediaMatch.matches) {
25
- classList.remove('overlay-shown--desktop');
26
- if (null != appBar) appBar.classList.remove('app-bar-overlay-shown', 'app-bar-overlay-shown--desktop');
27
- } else {
28
- classList.remove('overlay-shown--mobile');
29
- if (null != appBar) appBar.classList.remove('app-bar-overlay-shown--mobile');
30
- }
31
- };
32
- }, []);
33
- return null;
34
- };
35
- function Overlay(props) {
36
- const { isUnmounting, className, ...rest } = props;
37
- const classes = classnames(overlay_module.overlay, 'animate-fade-in', {
38
- 'animate-fade-out': isUnmounting
39
- });
40
- return /*#__PURE__*/ jsxs(Fragment, {
41
- children: [
42
- /*#__PURE__*/ jsx(BodyLock, {}),
43
- /*#__PURE__*/ jsx("div", {
44
- role: "presentation",
45
- className: classnames(classes, className),
46
- ...rest
47
- })
48
- ]
49
- });
50
- }
51
- export { Overlay };