@apexhub/apex-ui-react-source 1.3.3 → 1.3.4
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/dist/files/AGENTS.md +1 -1
- package/dist/files/alert/llm.txt +1 -1
- package/dist/files/alert/tokens.txt +1 -1
- package/dist/files/apex-provider/llm.txt +1 -1
- package/dist/files/auto-complete/llm.txt +1 -1
- package/dist/files/auto-complete/tokens.txt +1 -1
- package/dist/files/avatar/llm.txt +1 -1
- package/dist/files/avatar/tokens.txt +1 -1
- package/dist/files/breadcrumb/llm.txt +1 -1
- package/dist/files/breadcrumb/tokens.txt +1 -1
- package/dist/files/button/llm.txt +1 -1
- package/dist/files/button/tokens.txt +1 -1
- package/dist/files/card/llm.txt +1 -1
- package/dist/files/card/tokens.txt +1 -1
- package/dist/files/cascader/llm.txt +1 -1
- package/dist/files/cascader/tokens.txt +1 -1
- package/dist/files/checkbox/llm.txt +1 -1
- package/dist/files/checkbox/tokens.txt +1 -1
- package/dist/files/collapse/llm.txt +1 -1
- package/dist/files/collapse/tokens.txt +1 -1
- package/dist/files/date-picker/llm.txt +1 -1
- package/dist/files/date-picker/tokens.txt +1 -1
- package/dist/files/divider/llm.txt +1 -1
- package/dist/files/divider/tokens.txt +1 -1
- package/dist/files/drawer/Drawer.tsx +81 -48
- package/dist/files/drawer/interface.ts +6 -1
- package/dist/files/drawer/llm.txt +3 -2
- package/dist/files/drawer/tokens.txt +1 -1
- package/dist/files/dropdown/llm.txt +1 -1
- package/dist/files/dropdown/tokens.txt +1 -1
- package/dist/files/form/llm.txt +1 -1
- package/dist/files/form/tokens.txt +1 -1
- package/dist/files/grid/llm.txt +1 -1
- package/dist/files/image/llm.txt +1 -1
- package/dist/files/image/tokens.txt +1 -1
- package/dist/files/input/llm.txt +1 -1
- package/dist/files/input/tokens.txt +1 -1
- package/dist/files/input-number/llm.txt +1 -1
- package/dist/files/input-number/tokens.txt +1 -1
- package/dist/files/layout/llm.txt +1 -1
- package/dist/files/layout/tokens.txt +1 -1
- package/dist/files/menu/llm.txt +1 -1
- package/dist/files/menu/tokens.txt +1 -1
- package/dist/files/message/llm.txt +1 -1
- package/dist/files/message/tokens.txt +1 -1
- package/dist/files/modal/llm.txt +1 -1
- package/dist/files/modal/tokens.txt +1 -1
- package/dist/files/notification/llm.txt +1 -1
- package/dist/files/notification/tokens.txt +1 -1
- package/dist/files/pagination/llm.txt +1 -1
- package/dist/files/pagination/tokens.txt +1 -1
- package/dist/files/popover/llm.txt +1 -1
- package/dist/files/popover/tokens.txt +1 -1
- package/dist/files/progress/llm.txt +1 -1
- package/dist/files/progress/tokens.txt +1 -1
- package/dist/files/radio/llm.txt +1 -1
- package/dist/files/radio/tokens.txt +1 -1
- package/dist/files/rate/llm.txt +1 -1
- package/dist/files/rate/tokens.txt +1 -1
- package/dist/files/select/llm.txt +1 -1
- package/dist/files/select/tokens.txt +1 -1
- package/dist/files/skeleton/llm.txt +1 -1
- package/dist/files/skeleton/tokens.txt +1 -1
- package/dist/files/spin/llm.txt +1 -1
- package/dist/files/spin/tokens.txt +1 -1
- package/dist/files/steps/llm.txt +1 -1
- package/dist/files/steps/tokens.txt +1 -1
- package/dist/files/switch/llm.txt +1 -1
- package/dist/files/switch/tokens.txt +1 -1
- package/dist/files/table/llm.txt +1 -1
- package/dist/files/table/tokens.txt +1 -1
- package/dist/files/tabs/llm.txt +1 -1
- package/dist/files/tabs/tokens.txt +1 -1
- package/dist/files/tag/llm.txt +1 -1
- package/dist/files/tag/tokens.txt +1 -1
- package/dist/files/tooltip/llm.txt +1 -1
- package/dist/files/tooltip/tokens.txt +1 -1
- package/dist/files/tree/llm.txt +1 -1
- package/dist/files/tree/tokens.txt +1 -1
- package/dist/files/tree-select/llm.txt +1 -1
- package/dist/files/tree-select/tokens.txt +1 -1
- package/dist/files/typography/llm.txt +1 -1
- package/dist/files/typography/tokens.txt +1 -1
- package/dist/files/upload/llm.txt +1 -1
- package/dist/files/upload/tokens.txt +1 -1
- package/dist/manifest.json +86 -86
- package/package.json +3 -3
package/dist/files/AGENTS.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Apex UI source (React) — rules for AI assistants
|
|
2
2
|
|
|
3
|
-
This folder is Apex UI 1.3.
|
|
3
|
+
This folder is Apex UI 1.3.4, installed as source code by `@apexhub/apex-ui-react-source`.
|
|
4
4
|
The code now belongs to this project: you may edit it.
|
|
5
5
|
|
|
6
6
|
## Using components
|
package/dist/files/alert/llm.txt
CHANGED
package/dist/files/card/llm.txt
CHANGED
|
@@ -69,7 +69,6 @@ function buildPanelSizeStyle(size: DrawerSize | undefined): React.CSSProperties
|
|
|
69
69
|
type NonModalDrawerRootProps = {
|
|
70
70
|
open: boolean
|
|
71
71
|
keyboard: boolean
|
|
72
|
-
focusTriggerAfterClose: boolean
|
|
73
72
|
labelledBy: string
|
|
74
73
|
placement: DrawerProps['placement']
|
|
75
74
|
onEscape: (event: KeyboardEvent) => void
|
|
@@ -79,7 +78,6 @@ type NonModalDrawerRootProps = {
|
|
|
79
78
|
function NonModalDrawerRoot({
|
|
80
79
|
open,
|
|
81
80
|
keyboard,
|
|
82
|
-
focusTriggerAfterClose,
|
|
83
81
|
labelledBy,
|
|
84
82
|
placement,
|
|
85
83
|
onEscape,
|
|
@@ -87,28 +85,7 @@ function NonModalDrawerRoot({
|
|
|
87
85
|
}: NonModalDrawerRootProps) {
|
|
88
86
|
const rootRef = React.useRef<HTMLDivElement | null>(null)
|
|
89
87
|
const onEscapeRef = React.useRef(onEscape)
|
|
90
|
-
const focusTriggerAfterCloseRef = React.useRef(focusTriggerAfterClose)
|
|
91
88
|
onEscapeRef.current = onEscape
|
|
92
|
-
focusTriggerAfterCloseRef.current = focusTriggerAfterClose
|
|
93
|
-
|
|
94
|
-
React.useEffect(() => {
|
|
95
|
-
if (!open) return
|
|
96
|
-
|
|
97
|
-
const ownerDocument = rootRef.current?.ownerDocument
|
|
98
|
-
const HTMLElementConstructor = ownerDocument?.defaultView?.HTMLElement
|
|
99
|
-
const previouslyFocused = ownerDocument?.activeElement
|
|
100
|
-
|
|
101
|
-
return () => {
|
|
102
|
-
if (!focusTriggerAfterCloseRef.current || !HTMLElementConstructor) return
|
|
103
|
-
if (
|
|
104
|
-
!(previouslyFocused instanceof HTMLElementConstructor) ||
|
|
105
|
-
!previouslyFocused.isConnected
|
|
106
|
-
) {
|
|
107
|
-
return
|
|
108
|
-
}
|
|
109
|
-
previouslyFocused.focus({ preventScroll: true })
|
|
110
|
-
}
|
|
111
|
-
}, [open])
|
|
112
89
|
|
|
113
90
|
React.useEffect(() => {
|
|
114
91
|
if (!open || !keyboard) return
|
|
@@ -140,6 +117,23 @@ function NonModalDrawerRoot({
|
|
|
140
117
|
)
|
|
141
118
|
}
|
|
142
119
|
|
|
120
|
+
// Mount with the dialog content so the cleanup runs after Headless UI queues its restoration.
|
|
121
|
+
function DrawerFocusLifecycle({
|
|
122
|
+
onExit,
|
|
123
|
+
}: {
|
|
124
|
+
onExit: (activeRef: React.RefObject<boolean>) => void
|
|
125
|
+
}) {
|
|
126
|
+
const activeRef = React.useRef(false)
|
|
127
|
+
React.useEffect(() => {
|
|
128
|
+
activeRef.current = true
|
|
129
|
+
return () => {
|
|
130
|
+
activeRef.current = false
|
|
131
|
+
onExit(activeRef)
|
|
132
|
+
}
|
|
133
|
+
}, [onExit])
|
|
134
|
+
return null
|
|
135
|
+
}
|
|
136
|
+
|
|
143
137
|
/**
|
|
144
138
|
* Drawer — antd 风格侧滑面板(默认 Headless UI Dialog,支持 Apex 非模态分支)
|
|
145
139
|
*/
|
|
@@ -170,7 +164,6 @@ export const Drawer: React.FC<DrawerProps> = ({
|
|
|
170
164
|
const titleFontClass = getTextFontClass(localeKind, 'heading-3')
|
|
171
165
|
const maskConfig = normalizeMask(mask)
|
|
172
166
|
const trapFocus = focusable?.trap !== false
|
|
173
|
-
const focusTriggerAfterClose = focusable?.focusTriggerAfterClose !== false
|
|
174
167
|
const drawerTitleId = React.useId()
|
|
175
168
|
const afterOpenChangeRef = React.useRef(afterOpenChange)
|
|
176
169
|
afterOpenChangeRef.current = afterOpenChange
|
|
@@ -178,8 +171,67 @@ export const Drawer: React.FC<DrawerProps> = ({
|
|
|
178
171
|
const onCloseRef = React.useRef(onClose)
|
|
179
172
|
onCloseRef.current = onClose
|
|
180
173
|
|
|
181
|
-
const closeViaButtonRef = React.useRef(false)
|
|
182
174
|
const panelRef = React.useRef<HTMLElement | null>(null)
|
|
175
|
+
const focusableRef = React.useRef(focusable)
|
|
176
|
+
focusableRef.current = focusable
|
|
177
|
+
const focusSessionRef = React.useRef<{
|
|
178
|
+
ownerDocument: Document
|
|
179
|
+
trigger: HTMLElement | null
|
|
180
|
+
triggerIsTabPanel: boolean
|
|
181
|
+
} | null>(null)
|
|
182
|
+
|
|
183
|
+
React.useLayoutEffect(() => {
|
|
184
|
+
if (!open) return
|
|
185
|
+
const ownerDocument = panelRef.current?.ownerDocument ?? document
|
|
186
|
+
const active = ownerDocument.activeElement
|
|
187
|
+
const trigger = active instanceof HTMLElement && active !== ownerDocument.body ? active : null
|
|
188
|
+
focusSessionRef.current = {
|
|
189
|
+
ownerDocument,
|
|
190
|
+
trigger,
|
|
191
|
+
triggerIsTabPanel: trigger?.matches('[role="tabpanel"]') ?? false,
|
|
192
|
+
}
|
|
193
|
+
}, [open])
|
|
194
|
+
|
|
195
|
+
const handleFocusExit = React.useCallback(
|
|
196
|
+
(activeRef: React.RefObject<boolean>) => {
|
|
197
|
+
const session = focusSessionRef.current
|
|
198
|
+
if (!session) return
|
|
199
|
+
const { ownerDocument, trigger, triggerIsTabPanel } = session
|
|
200
|
+
const focusedBeforeRestore = ownerDocument.activeElement
|
|
201
|
+
queueMicrotask(() => {
|
|
202
|
+
if (
|
|
203
|
+
activeRef.current ||
|
|
204
|
+
focusSessionRef.current !== session ||
|
|
205
|
+
panelRef.current?.dataset.state === 'open'
|
|
206
|
+
)
|
|
207
|
+
return
|
|
208
|
+
const options = focusableRef.current
|
|
209
|
+
const enabled = options?.focusTriggerAfterClose !== false
|
|
210
|
+
const resolveTarget = options?.getReturnFocus
|
|
211
|
+
if (enabled && !resolveTarget && !triggerIsTabPanel) {
|
|
212
|
+
if (!trapFocus && trigger?.isConnected) trigger.focus({ preventScroll: true })
|
|
213
|
+
return
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
const target = enabled ? resolveTarget?.() : null
|
|
217
|
+
if (target?.isConnected && target.ownerDocument === ownerDocument) {
|
|
218
|
+
target.focus({ preventScroll: true })
|
|
219
|
+
if (ownerDocument.activeElement === target) return
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// Undo automatic restoration while preserving focus the consumer placed during close.
|
|
223
|
+
const restored = ownerDocument.activeElement
|
|
224
|
+
if (restored !== focusedBeforeRestore && restored instanceof HTMLElement) {
|
|
225
|
+
if (focusedBeforeRestore instanceof HTMLElement && focusedBeforeRestore.isConnected) {
|
|
226
|
+
focusedBeforeRestore.focus({ preventScroll: true })
|
|
227
|
+
}
|
|
228
|
+
if (ownerDocument.activeElement === restored) restored.blur()
|
|
229
|
+
}
|
|
230
|
+
})
|
|
231
|
+
},
|
|
232
|
+
[trapFocus],
|
|
233
|
+
)
|
|
234
|
+
|
|
183
235
|
const dismissIntentRef = useDismissIntent(panelRef, open && trapFocus)
|
|
184
236
|
|
|
185
237
|
useEmbeddedScrollLockGuard(open && trapFocus)
|
|
@@ -249,11 +301,6 @@ export const Drawer: React.FC<DrawerProps> = ({
|
|
|
249
301
|
}, [])
|
|
250
302
|
|
|
251
303
|
const handleDialogClose = React.useCallback(() => {
|
|
252
|
-
if (closeViaButtonRef.current) {
|
|
253
|
-
closeViaButtonRef.current = false
|
|
254
|
-
return
|
|
255
|
-
}
|
|
256
|
-
|
|
257
304
|
const intent = consumeDismissIntent(dismissIntentRef)
|
|
258
305
|
|
|
259
306
|
if (intent?.source === 'escape' && !keyboard) return
|
|
@@ -282,13 +329,9 @@ export const Drawer: React.FC<DrawerProps> = ({
|
|
|
282
329
|
onCloseRef.current?.(syntheticEvent as unknown as React.KeyboardEvent<HTMLElement>)
|
|
283
330
|
}, [dismissIntentRef, keyboard, maskConfig.closable, open])
|
|
284
331
|
|
|
285
|
-
const handleCloseButtonClick = React.useCallback(
|
|
286
|
-
(event
|
|
287
|
-
|
|
288
|
-
onCloseRef.current?.(event)
|
|
289
|
-
},
|
|
290
|
-
[trapFocus],
|
|
291
|
-
)
|
|
332
|
+
const handleCloseButtonClick = React.useCallback((event: React.MouseEvent<HTMLElement>) => {
|
|
333
|
+
onCloseRef.current?.(event)
|
|
334
|
+
}, [])
|
|
292
335
|
|
|
293
336
|
const handleNonModalEscape = React.useCallback(
|
|
294
337
|
(event: KeyboardEvent) => {
|
|
@@ -400,15 +443,6 @@ export const Drawer: React.FC<DrawerProps> = ({
|
|
|
400
443
|
</>
|
|
401
444
|
)
|
|
402
445
|
|
|
403
|
-
const handlePanelFocusCapture = React.useCallback(
|
|
404
|
-
(event: React.FocusEvent<HTMLDivElement>) => {
|
|
405
|
-
if (trapFocus && !focusTriggerAfterClose) {
|
|
406
|
-
event.stopPropagation()
|
|
407
|
-
}
|
|
408
|
-
},
|
|
409
|
-
[focusTriggerAfterClose, trapFocus],
|
|
410
|
-
)
|
|
411
|
-
|
|
412
446
|
const panelProps = {
|
|
413
447
|
className: cn(scopeClass, className, classNames?.content),
|
|
414
448
|
style: { ...panelSizeStyle, ...style, ...styles?.content },
|
|
@@ -416,7 +450,6 @@ export const Drawer: React.FC<DrawerProps> = ({
|
|
|
416
450
|
'data-placement': placement,
|
|
417
451
|
'data-state': open ? 'open' : 'closed',
|
|
418
452
|
onAnimationEnd: handlePanelAnimationEnd,
|
|
419
|
-
onFocusCapture: handlePanelFocusCapture,
|
|
420
453
|
}
|
|
421
454
|
|
|
422
455
|
const panel = trapFocus ? (
|
|
@@ -440,6 +473,7 @@ export const Drawer: React.FC<DrawerProps> = ({
|
|
|
440
473
|
style={{ ...rootStyle, ...styles?.wrapper, zIndex: overlayZIndex.drawer }}
|
|
441
474
|
data-slot="drawer-wrapper"
|
|
442
475
|
>
|
|
476
|
+
{trapFocus || open ? <DrawerFocusLifecycle onExit={handleFocusExit} /> : null}
|
|
443
477
|
{maskConfig.enabled ? (
|
|
444
478
|
<div
|
|
445
479
|
className={cn(
|
|
@@ -471,7 +505,6 @@ export const Drawer: React.FC<DrawerProps> = ({
|
|
|
471
505
|
<NonModalDrawerRoot
|
|
472
506
|
open={open}
|
|
473
507
|
keyboard={keyboard}
|
|
474
|
-
focusTriggerAfterClose={focusTriggerAfterClose}
|
|
475
508
|
labelledBy={drawerTitleId}
|
|
476
509
|
placement={placement}
|
|
477
510
|
onEscape={handleNonModalEscape}
|
|
@@ -31,10 +31,15 @@ export type DrawerFocusable = {
|
|
|
31
31
|
*/
|
|
32
32
|
trap?: boolean
|
|
33
33
|
/**
|
|
34
|
-
*
|
|
34
|
+
* 是否在关闭后自动回焦,模态和非模态均生效
|
|
35
35
|
* @default true
|
|
36
36
|
*/
|
|
37
37
|
focusTriggerAfterClose?: boolean
|
|
38
|
+
/**
|
|
39
|
+
* 在关闭时解析回焦元素,可通过 ref 为已移除的入口提供备用控件。
|
|
40
|
+
* 返回 null 跳过自动回焦。仅在 focusTriggerAfterClose 启用时调用。
|
|
41
|
+
*/
|
|
42
|
+
getReturnFocus?: () => HTMLElement | null
|
|
38
43
|
}
|
|
39
44
|
|
|
40
45
|
/** Portal 挂载目标 */
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
> Drawer:需要从屏幕边缘滑出面板展示详情、表单或临时任务,且保留原页面上下文时。
|
|
4
4
|
|
|
5
|
-
版本:`1.3.
|
|
5
|
+
版本:`1.3.4`。组件源码在本目录,属于当前项目。
|
|
6
6
|
|
|
7
7
|
公开导出:`Drawer`。
|
|
8
8
|
|
|
@@ -122,7 +122,8 @@ type DrawerSize = number
|
|
|
122
122
|
| 属性 | 说明 | 类型 | 必填 | 默认值 |
|
|
123
123
|
| --- | --- | --- | --- | --- |
|
|
124
124
|
| trap | 是否启用模态焦点管理。`false` 时允许与 Drawer 外页面继续交互 | `boolean` | 否 | `true` |
|
|
125
|
-
| focusTriggerAfterClose |
|
|
125
|
+
| focusTriggerAfterClose | 是否在关闭后自动回焦,模态和非模态均生效 | `boolean` | 否 | `true` |
|
|
126
|
+
| getReturnFocus | 在关闭时解析回焦元素,可通过 ref 为已移除的入口提供备用控件。<br>返回 null 跳过自动回焦。仅在 focusTriggerAfterClose 启用时调用。 | `() => HTMLElement \| null` | 否 | — |
|
|
126
127
|
|
|
127
128
|
### DrawerContainer
|
|
128
129
|
|
package/dist/files/form/llm.txt
CHANGED
package/dist/files/grid/llm.txt
CHANGED
package/dist/files/image/llm.txt
CHANGED
package/dist/files/input/llm.txt
CHANGED
package/dist/files/menu/llm.txt
CHANGED