@apexhub/apex-ui-react-source 1.3.3 → 1.3.5
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 +123 -48
- package/dist/files/drawer/drawer.css +8 -0
- 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 +87 -87
- 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.5, 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
|
@@ -25,6 +25,17 @@ import { drawerScopeVariants } from './variants'
|
|
|
25
25
|
|
|
26
26
|
const OVERLAY_LAYER_SELECTOR = '[data-slot="message-root"],[data-slot="notification-root"]'
|
|
27
27
|
|
|
28
|
+
const RESTORED_FOCUS_ATTRIBUTE = 'data-apex-drawer-restored-focus'
|
|
29
|
+
|
|
30
|
+
type OpeningInput = 'pointer' | 'keyboard'
|
|
31
|
+
|
|
32
|
+
function markRestoredFocus(target: HTMLElement, input: OpeningInput) {
|
|
33
|
+
target.setAttribute(RESTORED_FOCUS_ATTRIBUTE, input)
|
|
34
|
+
target.addEventListener('blur', () => target.removeAttribute(RESTORED_FOCUS_ATTRIBUTE), {
|
|
35
|
+
once: true,
|
|
36
|
+
})
|
|
37
|
+
}
|
|
38
|
+
|
|
28
39
|
function isInsideOverlayLayer(target: EventTarget | null): boolean {
|
|
29
40
|
const el =
|
|
30
41
|
target instanceof Element ? target : target instanceof Node ? target.parentElement : null
|
|
@@ -69,7 +80,6 @@ function buildPanelSizeStyle(size: DrawerSize | undefined): React.CSSProperties
|
|
|
69
80
|
type NonModalDrawerRootProps = {
|
|
70
81
|
open: boolean
|
|
71
82
|
keyboard: boolean
|
|
72
|
-
focusTriggerAfterClose: boolean
|
|
73
83
|
labelledBy: string
|
|
74
84
|
placement: DrawerProps['placement']
|
|
75
85
|
onEscape: (event: KeyboardEvent) => void
|
|
@@ -79,7 +89,6 @@ type NonModalDrawerRootProps = {
|
|
|
79
89
|
function NonModalDrawerRoot({
|
|
80
90
|
open,
|
|
81
91
|
keyboard,
|
|
82
|
-
focusTriggerAfterClose,
|
|
83
92
|
labelledBy,
|
|
84
93
|
placement,
|
|
85
94
|
onEscape,
|
|
@@ -87,28 +96,7 @@ function NonModalDrawerRoot({
|
|
|
87
96
|
}: NonModalDrawerRootProps) {
|
|
88
97
|
const rootRef = React.useRef<HTMLDivElement | null>(null)
|
|
89
98
|
const onEscapeRef = React.useRef(onEscape)
|
|
90
|
-
const focusTriggerAfterCloseRef = React.useRef(focusTriggerAfterClose)
|
|
91
99
|
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
100
|
|
|
113
101
|
React.useEffect(() => {
|
|
114
102
|
if (!open || !keyboard) return
|
|
@@ -140,6 +128,23 @@ function NonModalDrawerRoot({
|
|
|
140
128
|
)
|
|
141
129
|
}
|
|
142
130
|
|
|
131
|
+
// Mount with the dialog content so the cleanup runs after Headless UI queues its restoration.
|
|
132
|
+
function DrawerFocusLifecycle({
|
|
133
|
+
onExit,
|
|
134
|
+
}: {
|
|
135
|
+
onExit: (activeRef: React.RefObject<boolean>) => void
|
|
136
|
+
}) {
|
|
137
|
+
const activeRef = React.useRef(false)
|
|
138
|
+
React.useEffect(() => {
|
|
139
|
+
activeRef.current = true
|
|
140
|
+
return () => {
|
|
141
|
+
activeRef.current = false
|
|
142
|
+
onExit(activeRef)
|
|
143
|
+
}
|
|
144
|
+
}, [onExit])
|
|
145
|
+
return null
|
|
146
|
+
}
|
|
147
|
+
|
|
143
148
|
/**
|
|
144
149
|
* Drawer — antd 风格侧滑面板(默认 Headless UI Dialog,支持 Apex 非模态分支)
|
|
145
150
|
*/
|
|
@@ -170,7 +175,6 @@ export const Drawer: React.FC<DrawerProps> = ({
|
|
|
170
175
|
const titleFontClass = getTextFontClass(localeKind, 'heading-3')
|
|
171
176
|
const maskConfig = normalizeMask(mask)
|
|
172
177
|
const trapFocus = focusable?.trap !== false
|
|
173
|
-
const focusTriggerAfterClose = focusable?.focusTriggerAfterClose !== false
|
|
174
178
|
const drawerTitleId = React.useId()
|
|
175
179
|
const afterOpenChangeRef = React.useRef(afterOpenChange)
|
|
176
180
|
afterOpenChangeRef.current = afterOpenChange
|
|
@@ -178,8 +182,98 @@ export const Drawer: React.FC<DrawerProps> = ({
|
|
|
178
182
|
const onCloseRef = React.useRef(onClose)
|
|
179
183
|
onCloseRef.current = onClose
|
|
180
184
|
|
|
181
|
-
const closeViaButtonRef = React.useRef(false)
|
|
182
185
|
const panelRef = React.useRef<HTMLElement | null>(null)
|
|
186
|
+
const focusableRef = React.useRef(focusable)
|
|
187
|
+
focusableRef.current = focusable
|
|
188
|
+
const openingInputRef = React.useRef<OpeningInput | undefined>(undefined)
|
|
189
|
+
const focusSessionRef = React.useRef<{
|
|
190
|
+
ownerDocument: Document
|
|
191
|
+
trigger: HTMLElement | null
|
|
192
|
+
triggerIsTabPanel: boolean
|
|
193
|
+
openingInput: OpeningInput
|
|
194
|
+
} | null>(null)
|
|
195
|
+
|
|
196
|
+
React.useLayoutEffect(() => {
|
|
197
|
+
const ownerDocument = panelRef.current?.ownerDocument ?? document
|
|
198
|
+
if (!open) {
|
|
199
|
+
const onPointerDown = () => {
|
|
200
|
+
openingInputRef.current = 'pointer'
|
|
201
|
+
}
|
|
202
|
+
const onKeyDown = () => {
|
|
203
|
+
openingInputRef.current = 'keyboard'
|
|
204
|
+
}
|
|
205
|
+
ownerDocument.addEventListener('pointerdown', onPointerDown, true)
|
|
206
|
+
ownerDocument.addEventListener('keydown', onKeyDown, true)
|
|
207
|
+
return () => {
|
|
208
|
+
ownerDocument.removeEventListener('pointerdown', onPointerDown, true)
|
|
209
|
+
ownerDocument.removeEventListener('keydown', onKeyDown, true)
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
const active = ownerDocument.activeElement
|
|
214
|
+
const trigger = active instanceof HTMLElement && active !== ownerDocument.body ? active : null
|
|
215
|
+
focusSessionRef.current = {
|
|
216
|
+
ownerDocument,
|
|
217
|
+
trigger,
|
|
218
|
+
triggerIsTabPanel: trigger?.matches('[role="tabpanel"]') ?? false,
|
|
219
|
+
openingInput:
|
|
220
|
+
openingInputRef.current ?? (trigger?.matches(':focus-visible') ? 'keyboard' : 'pointer'),
|
|
221
|
+
}
|
|
222
|
+
openingInputRef.current = undefined
|
|
223
|
+
}, [open])
|
|
224
|
+
|
|
225
|
+
const handleFocusExit = React.useCallback(
|
|
226
|
+
(activeRef: React.RefObject<boolean>) => {
|
|
227
|
+
const session = focusSessionRef.current
|
|
228
|
+
if (!session) return
|
|
229
|
+
const { ownerDocument, trigger, triggerIsTabPanel, openingInput } = session
|
|
230
|
+
const focusedBeforeRestore = ownerDocument.activeElement
|
|
231
|
+
queueMicrotask(() => {
|
|
232
|
+
if (
|
|
233
|
+
activeRef.current ||
|
|
234
|
+
focusSessionRef.current !== session ||
|
|
235
|
+
panelRef.current?.dataset.state === 'open'
|
|
236
|
+
)
|
|
237
|
+
return
|
|
238
|
+
const options = focusableRef.current
|
|
239
|
+
const enabled = options?.focusTriggerAfterClose !== false
|
|
240
|
+
const resolveTarget = options?.getReturnFocus
|
|
241
|
+
if (enabled && !resolveTarget && !triggerIsTabPanel) {
|
|
242
|
+
if (!trapFocus && trigger?.isConnected) trigger.focus({ preventScroll: true })
|
|
243
|
+
|
|
244
|
+
const restored = ownerDocument.activeElement
|
|
245
|
+
if (
|
|
246
|
+
restored instanceof HTMLElement &&
|
|
247
|
+
restored !== ownerDocument.body &&
|
|
248
|
+
(restored === trigger || (trapFocus && restored !== focusedBeforeRestore))
|
|
249
|
+
) {
|
|
250
|
+
markRestoredFocus(restored, openingInput)
|
|
251
|
+
}
|
|
252
|
+
return
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
const target = enabled ? resolveTarget?.() : null
|
|
256
|
+
if (target?.isConnected && target.ownerDocument === ownerDocument) {
|
|
257
|
+
target.focus({ preventScroll: true })
|
|
258
|
+
if (ownerDocument.activeElement === target) {
|
|
259
|
+
markRestoredFocus(target, openingInput)
|
|
260
|
+
return
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
// Undo automatic restoration while preserving focus the consumer placed during close.
|
|
265
|
+
const restored = ownerDocument.activeElement
|
|
266
|
+
if (restored !== focusedBeforeRestore && restored instanceof HTMLElement) {
|
|
267
|
+
if (focusedBeforeRestore instanceof HTMLElement && focusedBeforeRestore.isConnected) {
|
|
268
|
+
focusedBeforeRestore.focus({ preventScroll: true })
|
|
269
|
+
}
|
|
270
|
+
if (ownerDocument.activeElement === restored) restored.blur()
|
|
271
|
+
}
|
|
272
|
+
})
|
|
273
|
+
},
|
|
274
|
+
[trapFocus],
|
|
275
|
+
)
|
|
276
|
+
|
|
183
277
|
const dismissIntentRef = useDismissIntent(panelRef, open && trapFocus)
|
|
184
278
|
|
|
185
279
|
useEmbeddedScrollLockGuard(open && trapFocus)
|
|
@@ -249,11 +343,6 @@ export const Drawer: React.FC<DrawerProps> = ({
|
|
|
249
343
|
}, [])
|
|
250
344
|
|
|
251
345
|
const handleDialogClose = React.useCallback(() => {
|
|
252
|
-
if (closeViaButtonRef.current) {
|
|
253
|
-
closeViaButtonRef.current = false
|
|
254
|
-
return
|
|
255
|
-
}
|
|
256
|
-
|
|
257
346
|
const intent = consumeDismissIntent(dismissIntentRef)
|
|
258
347
|
|
|
259
348
|
if (intent?.source === 'escape' && !keyboard) return
|
|
@@ -282,13 +371,9 @@ export const Drawer: React.FC<DrawerProps> = ({
|
|
|
282
371
|
onCloseRef.current?.(syntheticEvent as unknown as React.KeyboardEvent<HTMLElement>)
|
|
283
372
|
}, [dismissIntentRef, keyboard, maskConfig.closable, open])
|
|
284
373
|
|
|
285
|
-
const handleCloseButtonClick = React.useCallback(
|
|
286
|
-
(event
|
|
287
|
-
|
|
288
|
-
onCloseRef.current?.(event)
|
|
289
|
-
},
|
|
290
|
-
[trapFocus],
|
|
291
|
-
)
|
|
374
|
+
const handleCloseButtonClick = React.useCallback((event: React.MouseEvent<HTMLElement>) => {
|
|
375
|
+
onCloseRef.current?.(event)
|
|
376
|
+
}, [])
|
|
292
377
|
|
|
293
378
|
const handleNonModalEscape = React.useCallback(
|
|
294
379
|
(event: KeyboardEvent) => {
|
|
@@ -400,15 +485,6 @@ export const Drawer: React.FC<DrawerProps> = ({
|
|
|
400
485
|
</>
|
|
401
486
|
)
|
|
402
487
|
|
|
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
488
|
const panelProps = {
|
|
413
489
|
className: cn(scopeClass, className, classNames?.content),
|
|
414
490
|
style: { ...panelSizeStyle, ...style, ...styles?.content },
|
|
@@ -416,7 +492,6 @@ export const Drawer: React.FC<DrawerProps> = ({
|
|
|
416
492
|
'data-placement': placement,
|
|
417
493
|
'data-state': open ? 'open' : 'closed',
|
|
418
494
|
onAnimationEnd: handlePanelAnimationEnd,
|
|
419
|
-
onFocusCapture: handlePanelFocusCapture,
|
|
420
495
|
}
|
|
421
496
|
|
|
422
497
|
const panel = trapFocus ? (
|
|
@@ -440,6 +515,7 @@ export const Drawer: React.FC<DrawerProps> = ({
|
|
|
440
515
|
style={{ ...rootStyle, ...styles?.wrapper, zIndex: overlayZIndex.drawer }}
|
|
441
516
|
data-slot="drawer-wrapper"
|
|
442
517
|
>
|
|
518
|
+
{trapFocus || open ? <DrawerFocusLifecycle onExit={handleFocusExit} /> : null}
|
|
443
519
|
{maskConfig.enabled ? (
|
|
444
520
|
<div
|
|
445
521
|
className={cn(
|
|
@@ -471,7 +547,6 @@ export const Drawer: React.FC<DrawerProps> = ({
|
|
|
471
547
|
<NonModalDrawerRoot
|
|
472
548
|
open={open}
|
|
473
549
|
keyboard={keyboard}
|
|
474
|
-
focusTriggerAfterClose={focusTriggerAfterClose}
|
|
475
550
|
labelledBy={drawerTitleId}
|
|
476
551
|
placement={placement}
|
|
477
552
|
onEscape={handleNonModalEscape}
|
|
@@ -10,6 +10,14 @@
|
|
|
10
10
|
pointer-events: none;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
:root [data-apex-drawer-restored-focus='pointer']:focus {
|
|
14
|
+
outline: none;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
[data-apex-drawer-restored-focus='keyboard']:focus:not(:focus-visible) {
|
|
18
|
+
outline: auto;
|
|
19
|
+
}
|
|
20
|
+
|
|
13
21
|
.apex-drawer__mask {
|
|
14
22
|
position: fixed;
|
|
15
23
|
inset: 0;
|
|
@@ -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.5`。组件源码在本目录,属于当前项目。
|
|
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