@brillout/docpress 0.10.0 → 0.10.1

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/Layout.tsx CHANGED
@@ -13,7 +13,7 @@ import { EditPageNote } from './components/EditPageNote'
13
13
  import { parseTitle } from './parseTitle'
14
14
  import { usePageContext, usePageContext2 } from './renderer/usePageContext'
15
15
  import { NavSecondaryContent } from './NavSecondaryContent'
16
- import { closeMenuModalWithDelay, openMenuModal, toggleMenuModal } from './MenuModal/toggleMenuModal'
16
+ import { closeMenuOnMouseLeave, openMenuModal, toggleMenuModal } from './MenuModal/toggleMenuModal'
17
17
  import { MenuModal } from './MenuModal'
18
18
  import { autoScrollNav_SSR } from './autoScrollNav'
19
19
  import { SearchLink } from './docsearch/SearchLink'
@@ -563,7 +563,7 @@ function MenuToggle({ menuId, ...props }: PropsDiv & { menuId: number }) {
563
563
  }}
564
564
  onMouseLeave={() => {
565
565
  if (onMouseIgnore) return
566
- closeMenuModalWithDelay()
566
+ closeMenuOnMouseLeave()
567
567
  }}
568
568
  onTouchStart={() => {
569
569
  onMouseIgnore = setTimeout(() => {
@@ -1,7 +1,8 @@
1
1
  export { toggleMenuModal }
2
2
  export { openMenuModal }
3
+ export { keepMenuModalOpen }
3
4
  export { closeMenuModal }
4
- export { closeMenuModalWithDelay }
5
+ export { closeMenuOnMouseLeave }
5
6
  export { addListenerOpenMenuModal }
6
7
 
7
8
  import { containerQueryMobileLayout } from '../Layout'
@@ -10,8 +11,14 @@ import { isBrowser } from '../utils/isBrowser'
10
11
 
11
12
  initScrollListener()
12
13
 
13
- function openMenuModal(menuNavigationId?: number) {
14
- if (openIsForbidden) return
14
+ function keepMenuModalOpen() {
15
+ if (keepOpenIsDisabled) return
16
+ open()
17
+ }
18
+ function openMenuModal(menuNavigationId: number) {
19
+ open(menuNavigationId)
20
+ }
21
+ function open(menuNavigationId?: number) {
15
22
  if (menuModalLock) {
16
23
  if (menuNavigationId === undefined) {
17
24
  clearTimeout(menuModalLock?.timeout)
@@ -40,14 +47,14 @@ function addListenerOpenMenuModal(cb: () => void) {
40
47
  function closeMenuModal() {
41
48
  document.documentElement.classList.remove('menu-modal-show')
42
49
  }
43
- let openIsForbidden: true | undefined
44
- function closeMenuModalAndBlock() {
50
+ let keepOpenIsDisabled: true | undefined
51
+ function closeAndForbidKeepOpen() {
45
52
  if (!document.documentElement.classList.contains('menu-modal-show')) return
46
- openIsForbidden = true
53
+ keepOpenIsDisabled = true
47
54
  closeMenuModal()
48
55
  setTimeout(() => {
49
- openIsForbidden = undefined
50
- }, 430)
56
+ keepOpenIsDisabled = undefined
57
+ }, 500)
51
58
  }
52
59
 
53
60
  let menuModalLock:
@@ -57,7 +64,7 @@ let menuModalLock:
57
64
  timeout: NodeJS.Timeout
58
65
  }
59
66
  | undefined
60
- function closeMenuModalWithDelay() {
67
+ function closeMenuOnMouseLeave() {
61
68
  const currentModalId = getCurrentMenuId()
62
69
  if (currentModalId === null) return
63
70
  const timeout = setTimeout(() => {
@@ -65,7 +72,7 @@ function closeMenuModalWithDelay() {
65
72
  menuModalLock = undefined
66
73
  if (idNext === idCurrent) return
67
74
  if (idNext === undefined) {
68
- closeMenuModal()
75
+ closeAndForbidKeepOpen()
69
76
  } else {
70
77
  openMenuModal(idNext)
71
78
  }
@@ -87,18 +94,11 @@ function getCurrentMenuId(): null | number {
87
94
 
88
95
  function initScrollListener() {
89
96
  if (!isBrowser()) return
90
- window.addEventListener('scroll', closeMenuModalAndBlock, { passive: true })
91
- window.addEventListener(
92
- 'mousemove',
93
- () => {
94
- openIsForbidden = undefined
95
- },
96
- { passive: true },
97
- )
97
+ window.addEventListener('scroll', closeAndForbidKeepOpen, { passive: true })
98
98
  }
99
99
 
100
100
  function toggleMenuModal(menuId: number) {
101
- openIsForbidden = undefined
101
+ keepOpenIsDisabled = undefined
102
102
  const { classList } = document.documentElement
103
103
  if (classList.contains('menu-modal-show') && classList.contains(`menu-modal-show-${menuId}`)) {
104
104
  closeMenuModal()
package/MenuModal.tsx CHANGED
@@ -7,7 +7,7 @@ import { blockMargin, containerQueryMobileLayout, containerQueryMobileMenu } fro
7
7
  import { NavSecondaryContent } from './NavSecondaryContent'
8
8
  import { Style } from './utils/Style'
9
9
  import { NavigationWithColumnLayout } from './MenuModal/NavigationWithColumnLayout'
10
- import { addListenerOpenMenuModal, closeMenuModal, openMenuModal } from './MenuModal/toggleMenuModal'
10
+ import { addListenerOpenMenuModal, closeMenuModal, keepMenuModalOpen } from './MenuModal/toggleMenuModal'
11
11
 
12
12
  function MenuModal({ isTopNav }: { isTopNav: boolean }) {
13
13
  const ref = useRef<HTMLDivElement>(null)
@@ -43,7 +43,7 @@ function MenuModal({ isTopNav }: { isTopNav: boolean }) {
43
43
  height,
44
44
  }}
45
45
  ref={ref}
46
- onMouseOver={() => openMenuModal()}
46
+ onMouseOver={() => keepMenuModalOpen()}
47
47
  onMouseLeave={closeMenuModal}
48
48
  >
49
49
  <div
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brillout/docpress",
3
- "version": "0.10.0",
3
+ "version": "0.10.1",
4
4
  "type": "module",
5
5
  "dependencies": {
6
6
  "@brillout/picocolors": "^1.0.10",