@startupjs-ui/popover 0.3.1 → 0.3.6

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/CHANGELOG.md CHANGED
@@ -3,6 +3,22 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [0.3.6](https://github.com/startupjs/startupjs-ui/compare/v0.3.5...v0.3.6) (2026-06-19)
7
+
8
+ **Note:** Version bump only for package @startupjs-ui/popover
9
+
10
+
11
+
12
+
13
+
14
+ ## [0.3.4](https://github.com/startupjs/startupjs-ui/compare/v0.3.3...v0.3.4) (2026-06-18)
15
+
16
+ **Note:** Version bump only for package @startupjs-ui/popover
17
+
18
+
19
+
20
+
21
+
6
22
  ## [0.3.1](https://github.com/startupjs/startupjs-ui/compare/v0.3.0...v0.3.1) (2026-06-08)
7
23
 
8
24
  **Note:** Version bump only for package @startupjs-ui/popover
package/README.mdx CHANGED
@@ -13,7 +13,7 @@ A floating panel that appears near an anchor element when triggered. Use it to d
13
13
 
14
14
  The `visible` prop controls whether the popover is shown, and `onChange` is called when visibility should change. You can also use `$visible` for two-way data binding. Pass `children` as the anchor (the always-visible element) and `renderContent` to render the popover content. A `ref` can be used to programmatically call `open()` and `close()`.
15
15
 
16
- The component also supports lifecycle callbacks inherited from AbstractPopover: `onRequestOpen`, `onRequestClose`, `onOpenComplete`, and `onCloseComplete`. Use `renderWrapper` to wrap the popover node with custom markup.
16
+ The component also supports lifecycle callbacks inherited from AbstractPopover: `onRequestOpen`, `onRequestClose`, `onOpenComplete`, and `onCloseComplete`. Use `onDismiss` when you need to react after the popover finishes closing. Use `renderWrapper` to wrap the popover node with custom markup.
17
17
 
18
18
  ```jsx
19
19
  import { Popover } from 'startupjs-ui'
package/index.d.ts CHANGED
@@ -21,6 +21,8 @@ export interface PopoverProps extends Omit<AbstractPopoverProps, 'anchorRef' | '
21
21
  $visible?: any;
22
22
  /** Called when visibility should change */
23
23
  onChange?: (visible: boolean) => void;
24
+ /** Called when popover finishes closing */
25
+ onDismiss?: () => void;
24
26
  /** Open the popover when the anchor wrapper is pressed @default true */
25
27
  openOnAnchorPress?: boolean;
26
28
  /** Anchor content */
package/index.tsx CHANGED
@@ -1,4 +1,4 @@
1
- import { useMemo, useRef, useCallback, useImperativeHandle, type ReactNode, type RefObject } from 'react'
1
+ import { Children, isValidElement, useMemo, useRef, useCallback, useImperativeHandle, type ReactNode, type RefObject } from 'react'
2
2
  import { View, TouchableWithoutFeedback, type StyleProp, type ViewStyle } from 'react-native'
3
3
  import { pug, observer, useBind, $ } from 'startupjs'
4
4
  import { themed } from '@startupjs-ui/core'
@@ -23,6 +23,8 @@ export interface PopoverProps extends Omit<AbstractPopoverProps, 'anchorRef' | '
23
23
  $visible?: any
24
24
  /** Called when visibility should change */
25
25
  onChange?: (visible: boolean) => void
26
+ /** Called when popover finishes closing */
27
+ onDismiss?: () => void
26
28
  /** Open the popover when the anchor wrapper is pressed @default true */
27
29
  openOnAnchorPress?: boolean
28
30
  /** Anchor content */
@@ -46,6 +48,8 @@ function Popover ({
46
48
  children,
47
49
  renderContent,
48
50
  onChange,
51
+ onCloseComplete,
52
+ onDismiss,
49
53
  openOnAnchorPress = true,
50
54
  renderWrapper,
51
55
  overlayStyle,
@@ -86,6 +90,21 @@ function Popover ({
86
90
 
87
91
  const setVisibleTrue = useCallback(() => { handleChange(true) }, [handleChange])
88
92
  const setVisibleFalse = useCallback(() => { handleChange(false) }, [handleChange])
93
+ const handleCloseComplete = useCallback((...args: any[]) => {
94
+ onCloseComplete?.(...args)
95
+ onDismiss?.()
96
+ }, [onCloseComplete, onDismiss])
97
+ const shouldOpenOnAnchorPress = useMemo(() => {
98
+ if (!openOnAnchorPress) return false
99
+
100
+ const childArray = Children.toArray(children)
101
+ if (childArray.length !== 1) return true
102
+
103
+ const child = childArray[0]
104
+ if (!isValidElement<{ onPress?: unknown }>(child)) return true
105
+
106
+ return typeof child.props.onPress !== 'function'
107
+ }, [children, openOnAnchorPress])
89
108
 
90
109
  const renderOverlayWrapper = (node: ReactNode): ReactNode => {
91
110
  const wrappedNode = renderWrapper ? renderWrapper(node) : node
@@ -101,7 +120,7 @@ function Popover ({
101
120
  Div(
102
121
  style=style
103
122
  ref=anchorRef
104
- onPress=!isUncontrolled && openOnAnchorPress ? setVisibleTrue : null
123
+ onPress=shouldOpenOnAnchorPress ? setVisibleTrue : null
105
124
  )= children
106
125
  AbstractPopover.attachment(
107
126
  ...props
@@ -109,6 +128,7 @@ function Popover ({
109
128
  style=[attachmentStyle]
110
129
  anchorRef=anchorRef
111
130
  renderWrapper=renderOverlayWrapper
131
+ onCloseComplete=handleCloseComplete
112
132
  )= renderContent && renderContent()
113
133
  `
114
134
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@startupjs-ui/popover",
3
- "version": "0.3.1",
3
+ "version": "0.3.6",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -10,12 +10,12 @@
10
10
  "dependencies": {
11
11
  "@startupjs-ui/abstract-popover": "^0.3.0",
12
12
  "@startupjs-ui/core": "^0.3.0",
13
- "@startupjs-ui/div": "^0.3.1"
13
+ "@startupjs-ui/div": "^0.3.4"
14
14
  },
15
15
  "peerDependencies": {
16
16
  "react": "*",
17
17
  "react-native": "*",
18
18
  "startupjs": "*"
19
19
  },
20
- "gitHead": "60311773bdc83f354c797a272774304502d28c58"
20
+ "gitHead": "97eb49aeff8423d10ff280e2a809e352961bc0f2"
21
21
  }