@lynx-js/lynx-ui-dialog 0.0.0 → 3.130.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.
@@ -0,0 +1,300 @@
1
+ import type { ReactNode } from '@lynx-js/react';
2
+ import type { ComponentBasicProps } from '@lynx-js/lynx-ui-common';
3
+ import type { PresenceChildrenType } from '@lynx-js/lynx-ui-presence';
4
+ import type { OverlayProps, ViewProps } from '@lynx-js/types';
5
+ /**
6
+ * The backdrop mask of the dialog.
7
+ * @zh 弹窗的背景遮罩。
8
+ */
9
+ export interface DialogBackdropProps extends ComponentBasicProps {
10
+ /**
11
+ * children
12
+ * @zh 子元素
13
+ * @Android
14
+ * @iOS
15
+ * @Harmony
16
+ */
17
+ children?: ReactNode;
18
+ /**
19
+ * If the content needs a delayed first screen to do first render, you need to set this property to true.
20
+ * @zh 如果内容需要延迟首屏进行首次渲染,则需要将此属性设置为 true。
21
+ */
22
+ delayed?: boolean;
23
+ /**
24
+ * If set to true, the className will has the transition classes like 'ui-entering', 'ui-leaving', 'ui-animating'
25
+ * @Android
26
+ * @iOS
27
+ * @Harmony
28
+ * @zh 如果设置为 true,则 className 会包含 'ui-entering', 'ui-leaving', 'ui-animating' 等动画相关类名
29
+ */
30
+ transition?: boolean;
31
+ /**
32
+ * Determines whether clicking on the backdrop closes the dialog.
33
+ * This prop acts as a behavior switch for the backdrop's click event.
34
+ *
35
+ * When `true`, clicking the backdrop will trigger the `onClose` callback and close the dialog if the dialog is in uncontrolled mode (when `show` is not provided).
36
+ * When `false`, clicking the backdrop will have no effect.
37
+ * @defaultValue true
38
+ * @Android
39
+ * @iOS
40
+ * @Harmony
41
+ * @zh 确定点击背景是否关闭弹窗。此属性作为背景点击事件的行为开关。当值为 `true` 时,如果弹窗处于非受控模式(未提供 `show` 属性),点击背景将触发 `onClose` 回调并关闭弹窗。当值为 `false` 时,点击背景将没有任何效果。
42
+ */
43
+ clickToClose?: boolean;
44
+ /**
45
+ * DialogBackdrop supports original view props to be directly spread in this prop.
46
+ * @Android
47
+ * @iOS
48
+ * @Harmony
49
+ * @zh DialogBackdrop 支持将原始 view 属性直接展开到这个属性中。
50
+ */
51
+ dialogBackdropProps?: ViewProps;
52
+ /**
53
+ * Triggered when the backdrop is clicked.
54
+ * @zh 点击背景时触发。
55
+ * @Android
56
+ * @iOS
57
+ * @Harmony
58
+ */
59
+ onClick?: () => void;
60
+ }
61
+ /**
62
+ * The main content of the dialog.
63
+ * @zh 弹窗的主要内容。
64
+ */
65
+ export interface DialogContentProps extends ComponentBasicProps {
66
+ /**
67
+ * children
68
+ * @zh 子元素
69
+ * @Android
70
+ * @iOS
71
+ * @Harmony
72
+ */
73
+ children?: ReactNode;
74
+ /**
75
+ * If the content needs a delayed first screen to do first render, you need to set this property to true.
76
+ * @zh 如果内容需要延迟首屏进行首次渲染,则需要将此属性设置为 true。
77
+ */
78
+ delayed?: boolean;
79
+ /**
80
+ * If set to true, the className will has the transition classes like 'ui-entering', 'ui-leaving', 'ui-animating'
81
+ * @Android
82
+ * @iOS
83
+ * @Harmony
84
+ * @zh 如果设置为 true,则 className 会包含 'ui-entering', 'ui-leaving', 'ui-animating' 等动画相关类名
85
+ */
86
+ transition?: boolean;
87
+ /**
88
+ * DialogContent supports original view props to be directly spread in this prop.
89
+ * @Android
90
+ * @iOS
91
+ * @Harmony
92
+ * @zh DialogContent 支持将原始 view 属性直接展开到这个属性中。
93
+ */
94
+ dialogContentProps?: ViewProps;
95
+ }
96
+ export type TriggerChildrenType = (DialogButtonStatus: {
97
+ active: boolean;
98
+ busy: boolean;
99
+ }) => ReactNode;
100
+ /**
101
+ * The trigger of the dialog. Controls the display of the popper.
102
+ * @zh 弹窗的触发组件。控制弹窗的显示
103
+ */
104
+ export interface DialogTriggerProps extends ComponentBasicProps {
105
+ /**
106
+ * The content of the close component. It can be a function that returns a `ReactNode` or a `ReactNode` itself.
107
+ * @Android
108
+ * @iOS
109
+ * @Harmony
110
+ * @zh 关闭组件的内容。它可以是一个返回 `ReactNode` 的函数,也可以是一个 `ReactNode` 本身。
111
+ */
112
+ children: TriggerChildrenType | ReactNode;
113
+ /**
114
+ * Determines whether the close component is disabled.
115
+ * When `true`, the component will be in a disabled state and cannot be interacted with.
116
+ * @defaultValue false
117
+ * @Android
118
+ * @iOS
119
+ * @Harmony
120
+ * @zh 确定关闭组件是否被禁用。当值为 `true` 时,组件将处于禁用状态,无法进行交互。
121
+ */
122
+ disabled?: boolean;
123
+ /**
124
+ * If set to true, the className will has the transition classes like 'ui-entering', 'ui-leaving', 'ui-animating'
125
+ * @Android
126
+ * @iOS
127
+ * @Harmony
128
+ * @zh 如果设置为 true,则 className 会包含 'ui-entering', 'ui-leaving', 'ui-animating' 等动画相关类名
129
+ */
130
+ transition?: boolean;
131
+ }
132
+ /**
133
+ * The close component of the Dialog, used to close the dialog.
134
+ * @zh 弹窗的关闭组件,用于关闭弹窗。
135
+ */
136
+ export interface DialogCloseProps extends ComponentBasicProps {
137
+ /**
138
+ * The content of the close component. It can be a function that returns a `ReactNode` or a `ReactNode` itself.
139
+ * @Android
140
+ * @iOS
141
+ * @Harmony
142
+ * @zh 关闭组件的内容。它可以是一个返回 `ReactNode` 的函数,也可以是一个 `ReactNode` 本身。
143
+ */
144
+ children: TriggerChildrenType | ReactNode;
145
+ /**
146
+ * Determines whether the close component is disabled.
147
+ * When `true`, the component will be in a disabled state and cannot be interacted with.
148
+ * @defaultValue false
149
+ * @Android
150
+ * @iOS
151
+ * @Harmony
152
+ * @zh 确定关闭组件是否被禁用。 当值为 `true` 时,组件将处于禁用状态,无法进行交互。
153
+ */
154
+ disabled?: boolean;
155
+ /**
156
+ * If set to true, the className will has the transition classes like 'ui-entering', 'ui-leaving', 'ui-animating'
157
+ * @Android
158
+ * @iOS
159
+ * @Harmony
160
+ * @zh 如果设置为 true,则 className 会包含 'ui-entering', 'ui-leaving', 'ui-animating' 等动画相关类名
161
+ */
162
+ transition?: boolean;
163
+ }
164
+ /**
165
+ * The root component of the Dialog, containing all of its child components.
166
+ * @zh 弹窗的根组件,包含其所有子组件。
167
+ */
168
+ export interface DialogRootProps {
169
+ /**
170
+ * children
171
+ * @zh 子元素
172
+ * @Android
173
+ * @iOS
174
+ * @Harmony
175
+ * @docTypeFallback ReactNode | (status: {open?: boolean, closed?: boolean, leaving?: boolean, entering?: boolean, animating?: boolean)} => ReactNode
176
+ */
177
+ children?: ReactNode | PresenceChildrenType;
178
+ /**
179
+ * Whether to show the popper. If this property is not set, the popper will be in controlled mode, meaning the defaultShow property will take no effects. And you have to control behavior of clicking close button and backdrop.
180
+ * @zh 是否显示弹出框。如果未设置此属性,弹出框将处于受控模式,这意味着 defaultShow 属性将无效。并且你必须控制点击关闭按钮和背景的行为。
181
+ * @Android
182
+ * @iOS
183
+ * @Harmony
184
+ */
185
+ show?: boolean;
186
+ /**
187
+ * Determines whether the dialog should be shown by default. Use this property means the Dialog is uncontrolled.
188
+ * @defaultValue false
189
+ * @Android
190
+ * @iOS
191
+ * @Harmony
192
+ * @zh 确定弹窗是否默认显示。使用此属性意味着弹窗处于非受控模式。
193
+ */
194
+ defaultShow?: boolean;
195
+ /**
196
+ * Mount the popper and render the content even when it's not shown. At this time, the internal state is "closed".
197
+ * @defaultValue false
198
+ * @Android
199
+ * @iOS
200
+ * @Harmony
201
+ * @zh 即使弹窗未显示,也会挂载弹窗并渲染内容。此时内部状态处于 closed
202
+ */
203
+ forceMount?: boolean;
204
+ /**
205
+ * Triggered when the dialog is about to be closed, which can be triggered by clicking the backdrop or via a close button. In controlled mode (when `show` is provided), you should use this handler to update the state that controls the dialog's visibility. In uncontrolled mode, this handler is optional and is called before the dialog's internal state is updated.
206
+ * @Android
207
+ * @iOS
208
+ * @Harmony
209
+ * @zh 当弹窗即将关闭时触发,可通过点击背景或关闭按钮触发。在受控模式下(提供了 `show` 属性),您应该使用此处理器来更新控制弹窗可见性的状态。在非受控模式下,此处理器是可选的,会在弹窗内部状态更新之前调用。
210
+ */
211
+ onShowChange?: (open: boolean) => void;
212
+ /**
213
+ * Triggered when the popper is actually show and the potential animation is finished.
214
+ * @zh 当弹出框实际显示且可能的动画结束时触发。
215
+ * @Android
216
+ * @iOS
217
+ * @Harmony
218
+ */
219
+ onOpen?: () => void;
220
+ /**
221
+ * Triggered when the popper is actually closed and the potential animation is finished.
222
+ * @zh 当弹出框实际关闭且可能的动画结束时触发。
223
+ * @Android
224
+ * @iOS
225
+ * @Harmony
226
+ */
227
+ onClose?: () => void;
228
+ /**
229
+ * Display debug logs. Open it when you find a bug.
230
+ * @Android
231
+ * @iOS
232
+ * @Harmony
233
+ * @zh 显示调试日志。发现 bug 时开启。
234
+ */
235
+ debugLog?: boolean;
236
+ }
237
+ /**
238
+ * View container. When 'container' is set correctly, the underlying layer will be replaced with overlay; otherwise, it will be a regular view. When the underlying layer is overlay, the 'level' property can be used to control the hierarchical relationship. For a regular view, use 'z-index' to control the hierarchical relationship. If this dialog needs to be used outside of LynxView, consider enabling overlay.
239
+ * @zh 视图容器。当正确设置 'container' 时,底层将替换为 overlay;否则,将是一个普通视图。当底层为 overlay 时,可以使用 'level' 属性控制层级关系。对于普通视图,使用 'z-index' 控制层级关系。如果此弹窗需要在 LynxView 外部使用,考虑启用 overlay。
240
+ */
241
+ export interface DialogViewProps extends ComponentBasicProps {
242
+ /**
243
+ * id
244
+ * @Android
245
+ * @iOS
246
+ * @Harmony
247
+ * @zh 标识符
248
+ */
249
+ id?: string;
250
+ /**
251
+ * children
252
+ * @Android
253
+ * @iOS
254
+ * @Harmony
255
+ * @zh 子元素
256
+ * @docTypeFallback ReactNode | (status: {open?: boolean, closed?: boolean, leaving?: boolean, entering?: boolean, animating?: boolean)} => ReactNode
257
+ */
258
+ children: ReactNode | PresenceChildrenType;
259
+ /**
260
+ * If set to true, the className will has the transition classes like 'ui-entering', 'ui-leaving', 'ui-animating'
261
+ * @Android
262
+ * @iOS
263
+ * @Harmony
264
+ * @zh 如果设置为 true,则 className 会包含 'ui-entering', 'ui-leaving', 'ui-animating' 等动画相关类名
265
+ */
266
+ transition?: boolean;
267
+ /**
268
+ * If you want to use the poppers outside of the LynxView, you need to set this property. The value is the name of the native container.
269
+ * @Android
270
+ * @iOS
271
+ * @Harmony
272
+ * @zh 如果你想在 LynxView 外部使用弹出框,则需要设置此属性。值为原生容器的名称。
273
+ */
274
+ container?: string;
275
+ /**
276
+ * Only works when the 'container' is set to non-empty string. Adjust nearby elements display level.
277
+ * @Android
278
+ * @iOS
279
+ * @Harmony
280
+ * @zh 仅当 'container' 设置为非空字符串时有效。调整附近元素的显示层级。
281
+ */
282
+ overlayLevel?: 1 | 2 | 3 | 4;
283
+ /**
284
+ * Display debug logs. Open it when you find a bug.
285
+ * @Android
286
+ * @iOS
287
+ * @Harmony
288
+ * @zh 显示调试日志。发现 bug 时开启。
289
+ */
290
+ debugLog?: boolean;
291
+ /**
292
+ * Additional props that will be spread to the underlying OverlayView element
293
+ * @zh 将被直接传递到底层 OverlayView 元素的额外 view 或 overlay 属性
294
+ * @Android
295
+ * @iOS
296
+ * @Harmony
297
+ */
298
+ dialogViewProps?: OverlayProps | ViewProps;
299
+ }
300
+ //# sourceMappingURL=index.docs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.docs.d.ts","sourceRoot":"","sources":["../../src/types/index.docs.ts"],"names":[],"mappings":"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"}
File without changes
package/package.json CHANGED
@@ -1,9 +1,55 @@
1
1
  {
2
2
  "name": "@lynx-js/lynx-ui-dialog",
3
- "version": "0.0.0",
4
- "description": "Empty placeholder package",
5
- "main": "index.js",
3
+ "version": "3.130.0",
4
+ "repository": {
5
+ "type": "git",
6
+ "url": "git+https://github.com/lynx-family/lynx-ui.git",
7
+ "directory": "packages/lynx-ui-dialog"
8
+ },
9
+ "license": "Apache-2.0",
10
+ "author": {
11
+ "name": "The Lynx Authors"
12
+ },
13
+ "sideEffects": false,
14
+ "type": "module",
15
+ "main": "./dist/index.jsx",
16
+ "module": "./dist/index.jsx",
17
+ "types": "./dist/index.d.ts",
18
+ "files": [
19
+ "src/**",
20
+ "README.md",
21
+ "CHANGELOG.md",
22
+ "LICENSE",
23
+ "tsconfig.docs.json",
24
+ "tsconfig.json",
25
+ "dist/**"
26
+ ],
27
+ "dependencies": {
28
+ "clsx": "^2.1.1",
29
+ "@lynx-js/lynx-ui-button": "3.130.0",
30
+ "@lynx-js/lynx-ui-common": "3.130.0",
31
+ "@lynx-js/lynx-ui-overlay": "3.130.0",
32
+ "@lynx-js/lynx-ui-presence": "3.130.0"
33
+ },
34
+ "devDependencies": {
35
+ "@lynx-js/react": "0.113.0",
36
+ "@lynx-js/types": "3.6.0",
37
+ "@rslib/core": "^0.16.0",
38
+ "@types/react": "^18.3.8",
39
+ "typescript": "^5.5.3"
40
+ },
41
+ "peerDependencies": {
42
+ "@lynx-js/react": ">=0.100.0",
43
+ "@lynx-js/types": "*",
44
+ "@types/react": "^18"
45
+ },
6
46
  "publishConfig": {
7
47
  "access": "public"
48
+ },
49
+ "jsnext:source": "./src/index.tsx",
50
+ "scripts": {
51
+ "build": "rslib build",
52
+ "build:watch": "rslib build --watch",
53
+ "test": "vitest"
8
54
  }
9
- }
55
+ }
package/src/Dialog.tsx ADDED
@@ -0,0 +1,295 @@
1
+ // Copyright 2026 The Lynx Authors. All rights reserved.
2
+ // Licensed under the Apache License Version 2.0 that can be found in the
3
+ // LICENSE file in the root directory of this source tree.
4
+
5
+ import type { ReactNode } from '@lynx-js/react'
6
+ import { useContext, useMemo, useState } from '@lynx-js/react'
7
+
8
+ import { OverlayView } from '@lynx-js/lynx-ui-overlay'
9
+ import type { PresenceAnimationStatus } from '@lynx-js/lynx-ui-presence'
10
+ import {
11
+ PresenceContext,
12
+ PresenceState,
13
+ presenceClassVariants,
14
+ resolveAnimationStatus,
15
+ usePresenceGroup,
16
+ } from '@lynx-js/lynx-ui-presence'
17
+
18
+ import { DialogButton, resolveBusyState } from './DialogButton'
19
+ import { DialogContext } from './DialogContext'
20
+ import type {
21
+ DialogBackdropProps,
22
+ DialogCloseProps,
23
+ DialogContentProps,
24
+ DialogRootProps,
25
+ DialogTriggerProps,
26
+ DialogViewProps,
27
+ } from './types'
28
+
29
+ type childType<T = PresenceState> = (groupState: T) => ReactNode
30
+ type renderChildrenType<T = PresenceState> = (
31
+ children: childType<T> | ReactNode,
32
+ status: T,
33
+ ) => ReactNode
34
+
35
+ const renderedChildren: renderChildrenType<PresenceAnimationStatus> = (
36
+ children,
37
+ status,
38
+ ) => {
39
+ if (typeof children === 'function') {
40
+ return children(status)
41
+ }
42
+ return children
43
+ }
44
+
45
+ export function DialogRoot(props: DialogRootProps) {
46
+ const {
47
+ show,
48
+ defaultShow = false,
49
+ forceMount = false,
50
+ children,
51
+ onOpen,
52
+ onClose,
53
+ onShowChange,
54
+ debugLog,
55
+ } = props
56
+ const isControlled = show !== undefined
57
+ const [uncontrolledShow, setUncontrolledShow] = useState<boolean>(defaultShow)
58
+ const actualShow = isControlled ? show : uncontrolledShow
59
+
60
+ const [groupState, setGroupState] = useState<PresenceState>(
61
+ actualShow ? PresenceState.Entering : PresenceState.Left,
62
+ )
63
+
64
+ const childrenStatus = resolveAnimationStatus({
65
+ state: groupState,
66
+ enableDelay: false,
67
+ grouped: true,
68
+ })
69
+
70
+ const contextValue = useMemo(() => ({
71
+ show: actualShow,
72
+ forceMount,
73
+ setUncontrolledShow,
74
+ groupState,
75
+ setGroupState,
76
+ onOpen,
77
+ onClose,
78
+ onShowChange,
79
+ debugLog,
80
+ }), [
81
+ actualShow,
82
+ forceMount,
83
+ setUncontrolledShow,
84
+ groupState,
85
+ setGroupState,
86
+ onOpen,
87
+ onClose,
88
+ onShowChange,
89
+ debugLog,
90
+ ])
91
+
92
+ return (
93
+ <DialogContext.Provider value={contextValue}>
94
+ {renderedChildren(children, childrenStatus)}
95
+ </DialogContext.Provider>
96
+ )
97
+ }
98
+
99
+ export function DialogTrigger(props: DialogTriggerProps) {
100
+ const { className, transition } = props
101
+ const { groupState } = useContext(DialogContext)
102
+ const presenceClassName = presenceClassVariants({
103
+ state: groupState,
104
+ enableDelay: false,
105
+ className,
106
+ transition,
107
+ })
108
+ return (
109
+ <DialogButton {...props} className={presenceClassName} changeShow={true} />
110
+ )
111
+ }
112
+ export function DialogClose(props: DialogCloseProps) {
113
+ const { className, transition } = props
114
+ const { groupState } = useContext(DialogContext)
115
+ const presenceClassName = presenceClassVariants({
116
+ state: groupState,
117
+ enableDelay: false,
118
+ className,
119
+ transition,
120
+ })
121
+ return (
122
+ <DialogButton {...props} className={presenceClassName} changeShow={false} />
123
+ )
124
+ }
125
+
126
+ export const DialogBackdrop = (props: DialogBackdropProps) => {
127
+ const {
128
+ children,
129
+ className,
130
+ style,
131
+ clickToClose = true,
132
+ transition,
133
+ dialogBackdropProps,
134
+ onClick,
135
+ } = props
136
+ const {
137
+ animationHandlers,
138
+ controllers,
139
+ } = useContext(PresenceContext)
140
+ const state = controllers.state
141
+ const { setUncontrolledShow, onShowChange, groupState } = useContext(
142
+ DialogContext,
143
+ )
144
+ const presenceClassName = presenceClassVariants({
145
+ state,
146
+ enableDelay: false,
147
+ className,
148
+ transition,
149
+ })
150
+
151
+ const {
152
+ handleKFStart,
153
+ handleKFEnd,
154
+ handleTransitionEnd,
155
+ handleTransitionStart,
156
+ } = animationHandlers
157
+ const busy = resolveBusyState(groupState)
158
+ const handleClick = () => {
159
+ if (!clickToClose || busy) {
160
+ return
161
+ }
162
+ onShowChange?.(false)
163
+ setUncontrolledShow(false)
164
+ onClick?.()
165
+ }
166
+
167
+ return (
168
+ <view
169
+ className={presenceClassName}
170
+ bindtap={handleClick}
171
+ bindanimationstart={handleKFStart}
172
+ bindanimationend={handleKFEnd}
173
+ bindtransitionstart={handleTransitionStart}
174
+ bindtransitionend={handleTransitionEnd}
175
+ bindanimationcancel={handleKFEnd}
176
+ event-through={false}
177
+ style={{
178
+ width: '100%',
179
+ height: '100%',
180
+ position: 'absolute',
181
+ ...style,
182
+ }}
183
+ {...dialogBackdropProps}
184
+ >
185
+ {children}
186
+ </view>
187
+ )
188
+ }
189
+
190
+ export const DialogView = (props: DialogViewProps) => {
191
+ const {
192
+ container,
193
+ children,
194
+ className,
195
+ style,
196
+ overlayLevel,
197
+ transition,
198
+ dialogViewProps,
199
+ } = props
200
+
201
+ const {
202
+ show,
203
+ forceMount,
204
+ onClose,
205
+ onOpen,
206
+ groupState,
207
+ setGroupState,
208
+ debugLog,
209
+ } = useContext(
210
+ DialogContext,
211
+ )
212
+
213
+ const { mountView, renderChildren } = usePresenceGroup({
214
+ show,
215
+ forceMount,
216
+ setGroupState,
217
+ children,
218
+ onOpen,
219
+ onClose,
220
+ debugLog,
221
+ })
222
+ const presenceClassName = presenceClassVariants({
223
+ state: groupState,
224
+ enableDelay: false,
225
+ className,
226
+ transition,
227
+ grouped: true,
228
+ })
229
+
230
+ return (
231
+ (mountView || forceMount)
232
+ ? (
233
+ <OverlayView
234
+ container={container}
235
+ className={presenceClassName}
236
+ style={{
237
+ ...style,
238
+ position: container ? 'relative' : 'fixed',
239
+ }}
240
+ overlayLevel={overlayLevel}
241
+ // When the container is not given and the OverlayView is a normal view, attach the `native-interaction-enabled` prop to the view itself.
242
+ // If this is not set, the default value on iOS is true while on Android it is false.
243
+ overlayViewProps={container
244
+ ? dialogViewProps
245
+ : {
246
+ 'native-interaction-enabled': true,
247
+ 'flatten': false,
248
+ ...dialogViewProps,
249
+ }}
250
+ >
251
+ {renderChildren}
252
+ </OverlayView>
253
+ )
254
+ : null
255
+ )
256
+ }
257
+
258
+ export function DialogContent(props: DialogContentProps) {
259
+ const { className, style, children, transition, dialogContentProps } = props
260
+ const {
261
+ animationHandlers,
262
+ controllers,
263
+ } = useContext(PresenceContext)
264
+ const state = controllers.state
265
+
266
+ const presenceClassName = presenceClassVariants({
267
+ state,
268
+ enableDelay: false,
269
+ className,
270
+ transition,
271
+ })
272
+ const {
273
+ handleKFStart,
274
+ handleKFEnd,
275
+ handleTransitionEnd,
276
+ handleTransitionStart,
277
+ } = animationHandlers
278
+
279
+ return (
280
+ <view
281
+ className={presenceClassName}
282
+ overlap={false}
283
+ style={style}
284
+ event-through={false}
285
+ bindanimationstart={handleKFStart}
286
+ bindanimationend={handleKFEnd}
287
+ bindtransitionstart={handleTransitionStart}
288
+ bindtransitionend={handleTransitionEnd}
289
+ bindanimationcancel={handleKFEnd}
290
+ {...dialogContentProps}
291
+ >
292
+ {children}
293
+ </view>
294
+ )
295
+ }