@lynx-js/lynx-ui-dialog 3.142.0 → 3.143.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/CHANGELOG.md +11 -0
- package/SKILL.md +157 -0
- package/dist/types/index.docs.d.ts +9 -9
- package/package.json +9 -8
- package/src/types/index.docs.ts +9 -9
- package/tsconfig.docs.json +0 -7
- package/tsconfig.json +0 -14
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @lynx-js/lynx-ui-dialog
|
|
2
2
|
|
|
3
|
+
## 3.143.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Include missing README/CHANGELOG/SKILL/LICENSE files in published tarballs and exclude test and workspace-only config files. ([#404](https://github.com/lynx-family/lynx-ui/pull/404))
|
|
8
|
+
- Updated dependencies [[`29beec7`](https://github.com/lynx-family/lynx-ui/commit/29beec7b241026010b83c417f7e1d1c961cd4f09)]:
|
|
9
|
+
- @lynx-js/lynx-ui-button@3.143.0
|
|
10
|
+
- @lynx-js/lynx-ui-common@3.143.0
|
|
11
|
+
- @lynx-js/lynx-ui-overlay@3.143.0
|
|
12
|
+
- @lynx-js/lynx-ui-presence@3.143.0
|
|
13
|
+
|
|
3
14
|
## 3.142.0
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
package/SKILL.md
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
# lynx-ui-dialog SKILL
|
|
2
|
+
|
|
3
|
+
`Dialog` is a dialog component, used to display important information or require user interaction, interrupting the current workflow. `lynx-ui-dialog` is a composite component built on `primitives`, offering high flexibility and customizability.
|
|
4
|
+
|
|
5
|
+
## 1. Core Capabilities
|
|
6
|
+
|
|
7
|
+
- **Composite Component Structure**: Composed of `DialogRoot`, `DialogView`, `DialogBackdrop`, `DialogContent`, `DialogTrigger`, and `DialogClose`, allowing for free assembly of the dialog's structure.
|
|
8
|
+
- **Controlled and Uncontrolled Modes**: Supports being fully controlled by the parent component (`show` + `onShowChange`) or managing its own state (`defaultShow`).
|
|
9
|
+
- **High-performance Rendering**: `DialogView` can render content into a high-performance native overlay layer via the `container` prop, preventing the main document from being affected.
|
|
10
|
+
- **Customizable Animations**: Supports custom enter and exit animations via the `transition` property and CSS classes (`ui-entering`, `ui-leaving`).
|
|
11
|
+
- **Accessibility**: Built-in handling for keyboard interactions and focus management.
|
|
12
|
+
|
|
13
|
+
## 2. AI Coding Guide
|
|
14
|
+
|
|
15
|
+
### Minimal Usable Example
|
|
16
|
+
|
|
17
|
+
#### Uncontrolled Mode
|
|
18
|
+
|
|
19
|
+
```tsx
|
|
20
|
+
import {
|
|
21
|
+
DialogRoot,
|
|
22
|
+
DialogView,
|
|
23
|
+
DialogBackdrop,
|
|
24
|
+
DialogContent,
|
|
25
|
+
DialogTrigger,
|
|
26
|
+
DialogClose,
|
|
27
|
+
} from '@lynx-js/lynx-ui'
|
|
28
|
+
|
|
29
|
+
function UncontrolledDialog() {
|
|
30
|
+
return (
|
|
31
|
+
<DialogRoot>
|
|
32
|
+
<DialogTrigger>
|
|
33
|
+
<button>Open Dialog</button>
|
|
34
|
+
</DialogTrigger>
|
|
35
|
+
<DialogView>
|
|
36
|
+
<DialogBackdrop />
|
|
37
|
+
<DialogContent>
|
|
38
|
+
<text>This is a dialog.</text>
|
|
39
|
+
<DialogClose>
|
|
40
|
+
<button>Close</button>
|
|
41
|
+
</DialogClose>
|
|
42
|
+
</DialogContent>
|
|
43
|
+
</DialogView>
|
|
44
|
+
</DialogRoot>
|
|
45
|
+
)
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Recommended Prompt Formula
|
|
50
|
+
|
|
51
|
+
> **Mode (Controlled/Uncontrolled)** + **Content and Structure** + **Interaction Logic (e.g., closing, confirmation)**
|
|
52
|
+
|
|
53
|
+
**Example Prompt:**
|
|
54
|
+
|
|
55
|
+
- "Create an uncontrolled `Dialog`. Clicking a trigger button opens it, and clicking a close button inside the dialog or the backdrop closes it."
|
|
56
|
+
- "Implement a controlled `Dialog` for a confirmation box. It contains a title, content, and two buttons, ‘Cancel’ and ‘Confirm’. The dialog is controlled by a `useState` variable."
|
|
57
|
+
- "Customize the enter and exit animations of the `Dialog` to be a fade-in/fade-out effect."
|
|
58
|
+
|
|
59
|
+
<!-- Removed pitfalls; converted into FAQ to match FeedList structure -->
|
|
60
|
+
|
|
61
|
+
## 3. Use Cases & Best Practices
|
|
62
|
+
|
|
63
|
+
### Uncontrolled Dialog
|
|
64
|
+
|
|
65
|
+
Simple to use, with the component managing its own state.
|
|
66
|
+
|
|
67
|
+
```tsx
|
|
68
|
+
import { DialogRoot, ... } from '@lynx-js/lynx-ui';
|
|
69
|
+
|
|
70
|
+
function UncontrolledDialogExample() {
|
|
71
|
+
return (
|
|
72
|
+
<DialogRoot>
|
|
73
|
+
<DialogTrigger>Open</DialogTrigger>
|
|
74
|
+
<DialogView>
|
|
75
|
+
<DialogBackdrop clickToClose />
|
|
76
|
+
<DialogContent>
|
|
77
|
+
{/* ... Dialog Content ... */}
|
|
78
|
+
<DialogClose>Close</DialogClose>
|
|
79
|
+
</DialogContent>
|
|
80
|
+
</DialogView>
|
|
81
|
+
</DialogRoot>
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
**Example Path**: `apps/examples/src/Dialog/Uncontrolled/index.tsx`
|
|
87
|
+
|
|
88
|
+
### Controlled Confirmation Dialog
|
|
89
|
+
|
|
90
|
+
Suitable for scenarios that require interaction with external business logic, such as confirmation boxes.
|
|
91
|
+
|
|
92
|
+
```tsx
|
|
93
|
+
import { useState } from '@lynx-js/react';
|
|
94
|
+
import { DialogRoot, ... } from '@lynx-js/lynx-ui';
|
|
95
|
+
|
|
96
|
+
function ControlledConfirmDialog() {
|
|
97
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
98
|
+
|
|
99
|
+
const handleConfirm = () => {
|
|
100
|
+
// business logic
|
|
101
|
+
setIsOpen(false);
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
return (
|
|
105
|
+
<view>
|
|
106
|
+
<button onClick={() => setIsOpen(true)}>Delete</button>
|
|
107
|
+
<DialogRoot show={isOpen} onShowChange={setIsOpen}>
|
|
108
|
+
<DialogView>
|
|
109
|
+
<DialogBackdrop />
|
|
110
|
+
<DialogContent>
|
|
111
|
+
<text>Are you sure?</text>
|
|
112
|
+
<DialogClose>Cancel</DialogClose>
|
|
113
|
+
<button onClick={handleConfirm}>Confirm</button>
|
|
114
|
+
</DialogContent>
|
|
115
|
+
</DialogView>
|
|
116
|
+
</DialogRoot>
|
|
117
|
+
</view>
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
**Example Path**: `apps/examples/src/Dialog/Controlled/index.tsx`
|
|
123
|
+
|
|
124
|
+
## 4. FAQ
|
|
125
|
+
|
|
126
|
+
**Q: Why doesn’t the dialog open/close when I set `show`?**
|
|
127
|
+
|
|
128
|
+
A: In controlled mode, `DialogRoot` does not mutate state internally. Provide `onShowChange` and update the external `show` state in that callback.
|
|
129
|
+
|
|
130
|
+
**Q: The dialog appears but is covered by other elements. How do I make it visible?**
|
|
131
|
+
|
|
132
|
+
A: Use `container` and `overlayLevel` on `DialogView` to render into a higher native overlay layer, for example `container="window" overlayLevel={2}`.
|
|
133
|
+
|
|
134
|
+
**Q: Can I use `show` and `defaultShow` at the same time?**
|
|
135
|
+
|
|
136
|
+
A: No. Choose one mode only. Mixing controlled and uncontrolled props will cause incorrect behavior.
|
|
137
|
+
|
|
138
|
+
**Q: How should I set `z-index` for the `Dialog` to avoid stacking issues?**
|
|
139
|
+
|
|
140
|
+
A: Due to `DialogView` defaulting to `position: fixed`, and because of stacking context limitations, if you need to set `z-index` for the Dialog, you should set it on the `DialogView` layer, at the same level as `position: fixed`. Otherwise, layer stacking issues may occur.
|
|
141
|
+
|
|
142
|
+
```tsx
|
|
143
|
+
<DialogView container='window' style={{ zIndex: 2000 }}>
|
|
144
|
+
{/* ... */}
|
|
145
|
+
</DialogView>
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## 5. Sub components
|
|
149
|
+
|
|
150
|
+
- **`DialogRoot`**: The root component, manages the open/close state.
|
|
151
|
+
- **`DialogTrigger`**: A clickable element to open the `Dialog`.
|
|
152
|
+
- **`DialogView`**: The rendering container for the dialog, can be placed in a native overlay layer.
|
|
153
|
+
- **`DialogContent`**: The container for the main content of the `Dialog`.
|
|
154
|
+
- **`DialogBackdrop`**: The background mask layer.
|
|
155
|
+
- **`DialogClose`**: A clickable element to close the `Dialog`.
|
|
156
|
+
|
|
157
|
+
<!-- Removed the "More Examples" section to align with FeedList structure -->
|
|
@@ -22,7 +22,7 @@ export interface DialogBackdropProps extends ComponentBasicProps {
|
|
|
22
22
|
*/
|
|
23
23
|
delayed?: boolean;
|
|
24
24
|
/**
|
|
25
|
-
*
|
|
25
|
+
* When true, className includes transition classes such as 'ui-entering', 'ui-leaving', and 'ui-animating'.
|
|
26
26
|
* @Android
|
|
27
27
|
* @iOS
|
|
28
28
|
* @Harmony
|
|
@@ -78,7 +78,7 @@ export interface DialogContentProps extends ComponentBasicProps {
|
|
|
78
78
|
*/
|
|
79
79
|
delayed?: boolean;
|
|
80
80
|
/**
|
|
81
|
-
*
|
|
81
|
+
* When true, className includes transition classes such as 'ui-entering', 'ui-leaving', and 'ui-animating'.
|
|
82
82
|
* @Android
|
|
83
83
|
* @iOS
|
|
84
84
|
* @Harmony
|
|
@@ -104,26 +104,26 @@ export type TriggerChildrenType = (DialogButtonStatus: {
|
|
|
104
104
|
*/
|
|
105
105
|
export interface DialogTriggerProps extends ComponentBasicProps {
|
|
106
106
|
/**
|
|
107
|
-
* The content of the
|
|
107
|
+
* The content of the trigger component. It can be a function that returns a `ReactNode` or a `ReactNode` itself.
|
|
108
108
|
* @Android
|
|
109
109
|
* @iOS
|
|
110
110
|
* @Harmony
|
|
111
|
-
* @zh
|
|
111
|
+
* @zh 触发组件的内容。它可以是一个返回 `ReactNode` 的函数,也可以是一个 `ReactNode` 本身。
|
|
112
112
|
* @docTypeFallback ReactNode | (status: {active: boolean, busy: boolean}) => ReactNode
|
|
113
113
|
*/
|
|
114
114
|
children: TriggerChildrenType | ReactNode;
|
|
115
115
|
/**
|
|
116
|
-
* Determines whether the
|
|
116
|
+
* Determines whether the trigger component is disabled.
|
|
117
117
|
* When `true`, the component will be in a disabled state and cannot be interacted with.
|
|
118
118
|
* @defaultValue false
|
|
119
119
|
* @Android
|
|
120
120
|
* @iOS
|
|
121
121
|
* @Harmony
|
|
122
|
-
* @zh
|
|
122
|
+
* @zh 确定触发组件是否被禁用。当值为 `true` 时,组件将处于禁用状态,无法进行交互。
|
|
123
123
|
*/
|
|
124
124
|
disabled?: boolean;
|
|
125
125
|
/**
|
|
126
|
-
*
|
|
126
|
+
* When true, className includes transition classes such as 'ui-entering', 'ui-leaving', and 'ui-animating'.
|
|
127
127
|
* @Android
|
|
128
128
|
* @iOS
|
|
129
129
|
* @Harmony
|
|
@@ -156,7 +156,7 @@ export interface DialogCloseProps extends ComponentBasicProps {
|
|
|
156
156
|
*/
|
|
157
157
|
disabled?: boolean;
|
|
158
158
|
/**
|
|
159
|
-
*
|
|
159
|
+
* When true, className includes transition classes such as 'ui-entering', 'ui-leaving', and 'ui-animating'.
|
|
160
160
|
* @Android
|
|
161
161
|
* @iOS
|
|
162
162
|
* @Harmony
|
|
@@ -260,7 +260,7 @@ export interface DialogViewProps extends ComponentBasicProps {
|
|
|
260
260
|
*/
|
|
261
261
|
children: ReactNode | PresenceChildrenType;
|
|
262
262
|
/**
|
|
263
|
-
*
|
|
263
|
+
* When true, className includes transition classes such as 'ui-entering', 'ui-leaving', and 'ui-animating'.
|
|
264
264
|
* @Android
|
|
265
265
|
* @iOS
|
|
266
266
|
* @Harmony
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lynx-js/lynx-ui-dialog",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.143.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/lynx-family/lynx-ui.git",
|
|
@@ -16,20 +16,21 @@
|
|
|
16
16
|
"module": "./dist/index.jsx",
|
|
17
17
|
"types": "./dist/index.d.ts",
|
|
18
18
|
"files": [
|
|
19
|
-
"src
|
|
19
|
+
"src",
|
|
20
|
+
"!src/**/__tests__/**",
|
|
21
|
+
"!src/**/*.test.*",
|
|
20
22
|
"README.md",
|
|
23
|
+
"SKILL.md",
|
|
21
24
|
"CHANGELOG.md",
|
|
22
25
|
"LICENSE",
|
|
23
|
-
"tsconfig.docs.json",
|
|
24
|
-
"tsconfig.json",
|
|
25
26
|
"dist/**"
|
|
26
27
|
],
|
|
27
28
|
"dependencies": {
|
|
28
29
|
"clsx": "^2.1.1",
|
|
29
|
-
"@lynx-js/lynx-ui-button": "3.
|
|
30
|
-
"@lynx-js/lynx-ui-common": "3.
|
|
31
|
-
"@lynx-js/lynx-ui-overlay": "3.
|
|
32
|
-
"@lynx-js/lynx-ui-presence": "3.
|
|
30
|
+
"@lynx-js/lynx-ui-button": "3.143.0",
|
|
31
|
+
"@lynx-js/lynx-ui-common": "3.143.0",
|
|
32
|
+
"@lynx-js/lynx-ui-overlay": "3.143.0",
|
|
33
|
+
"@lynx-js/lynx-ui-presence": "3.143.0"
|
|
33
34
|
},
|
|
34
35
|
"devDependencies": {
|
|
35
36
|
"@lynx-js/react": "0.123.1",
|
package/src/types/index.docs.ts
CHANGED
|
@@ -32,7 +32,7 @@ export interface DialogBackdropProps extends ComponentBasicProps {
|
|
|
32
32
|
*/
|
|
33
33
|
delayed?: boolean
|
|
34
34
|
/**
|
|
35
|
-
*
|
|
35
|
+
* When true, className includes transition classes such as 'ui-entering', 'ui-leaving', and 'ui-animating'.
|
|
36
36
|
* @Android
|
|
37
37
|
* @iOS
|
|
38
38
|
* @Harmony
|
|
@@ -89,7 +89,7 @@ export interface DialogContentProps extends ComponentBasicProps {
|
|
|
89
89
|
*/
|
|
90
90
|
delayed?: boolean
|
|
91
91
|
/**
|
|
92
|
-
*
|
|
92
|
+
* When true, className includes transition classes such as 'ui-entering', 'ui-leaving', and 'ui-animating'.
|
|
93
93
|
* @Android
|
|
94
94
|
* @iOS
|
|
95
95
|
* @Harmony
|
|
@@ -116,28 +116,28 @@ export type TriggerChildrenType = (
|
|
|
116
116
|
*/
|
|
117
117
|
export interface DialogTriggerProps extends ComponentBasicProps {
|
|
118
118
|
/**
|
|
119
|
-
* The content of the
|
|
119
|
+
* The content of the trigger component. It can be a function that returns a `ReactNode` or a `ReactNode` itself.
|
|
120
120
|
* @Android
|
|
121
121
|
* @iOS
|
|
122
122
|
* @Harmony
|
|
123
|
-
* @zh
|
|
123
|
+
* @zh 触发组件的内容。它可以是一个返回 `ReactNode` 的函数,也可以是一个 `ReactNode` 本身。
|
|
124
124
|
* @docTypeFallback ReactNode | (status: {active: boolean, busy: boolean}) => ReactNode
|
|
125
125
|
*/
|
|
126
126
|
children:
|
|
127
127
|
| TriggerChildrenType
|
|
128
128
|
| ReactNode
|
|
129
129
|
/**
|
|
130
|
-
* Determines whether the
|
|
130
|
+
* Determines whether the trigger component is disabled.
|
|
131
131
|
* When `true`, the component will be in a disabled state and cannot be interacted with.
|
|
132
132
|
* @defaultValue false
|
|
133
133
|
* @Android
|
|
134
134
|
* @iOS
|
|
135
135
|
* @Harmony
|
|
136
|
-
* @zh
|
|
136
|
+
* @zh 确定触发组件是否被禁用。当值为 `true` 时,组件将处于禁用状态,无法进行交互。
|
|
137
137
|
*/
|
|
138
138
|
disabled?: boolean
|
|
139
139
|
/**
|
|
140
|
-
*
|
|
140
|
+
* When true, className includes transition classes such as 'ui-entering', 'ui-leaving', and 'ui-animating'.
|
|
141
141
|
* @Android
|
|
142
142
|
* @iOS
|
|
143
143
|
* @Harmony
|
|
@@ -173,7 +173,7 @@ export interface DialogCloseProps extends ComponentBasicProps {
|
|
|
173
173
|
*/
|
|
174
174
|
disabled?: boolean
|
|
175
175
|
/**
|
|
176
|
-
*
|
|
176
|
+
* When true, className includes transition classes such as 'ui-entering', 'ui-leaving', and 'ui-animating'.
|
|
177
177
|
* @Android
|
|
178
178
|
* @iOS
|
|
179
179
|
* @Harmony
|
|
@@ -280,7 +280,7 @@ export interface DialogViewProps extends ComponentBasicProps {
|
|
|
280
280
|
| ReactNode
|
|
281
281
|
| PresenceChildrenType
|
|
282
282
|
/**
|
|
283
|
-
*
|
|
283
|
+
* When true, className includes transition classes such as 'ui-entering', 'ui-leaving', and 'ui-animating'.
|
|
284
284
|
* @Android
|
|
285
285
|
* @iOS
|
|
286
286
|
* @Harmony
|
package/tsconfig.docs.json
DELETED