@tbox.cn/app-agent-ui-kit 1.0.0-alpha.17 → 1.0.0-alpha.18
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/README.md
CHANGED
|
@@ -48,7 +48,7 @@ import { BottomSheet } from '@tbox.cn/app-agent-ui-kit/bottom-sheet';
|
|
|
48
48
|
</BottomSheet>
|
|
49
49
|
```
|
|
50
50
|
|
|
51
|
-
支持 `className` 定制内容区,默认最大高度为视口的 65
|
|
51
|
+
支持 `className` 定制内容区,默认最大高度为视口的 65%;`size="large"` 固定为视口的 86%,用于活动详情等长内容,支持动态视口高度。长内容在弹层内部滚动。`preloadBottomSheet()` 保留为已废弃的空操作(弹层不再有第三方运行时需要预热)。
|
|
52
52
|
|
|
53
53
|
### 大图预览
|
|
54
54
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tbox.cn/app-agent-ui-kit",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.18",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Agent 对话壳 UI 组件包(源码发布,单一模板统一化 W2-1):ChatPage/壳组件族/主题 tokens。",
|
|
6
6
|
"exports": {
|
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
"remark-gfm": "4.0.1",
|
|
45
45
|
"yet-another-react-lightbox": "3.33.1",
|
|
46
46
|
"zustand": "4.5.7",
|
|
47
|
-
"@tbox.cn/app-
|
|
48
|
-
"@tbox.cn/app-
|
|
47
|
+
"@tbox.cn/app-contracts": "1.0.0-alpha.18",
|
|
48
|
+
"@tbox.cn/app-agent-sdk-client": "1.0.0-alpha.18"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
51
|
"react": "18.3.1",
|
|
@@ -28,6 +28,17 @@ async function renderSheet(open: boolean, onClose = vi.fn()) {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
describe('BottomSheet', () => {
|
|
31
|
+
it('大尺寸固定 86% 视口并保留内部滚动,默认尺寸仍最高 65%', async () => {
|
|
32
|
+
await renderSheet(true);
|
|
33
|
+
expect(document.querySelector('[role="dialog"]')?.classList.contains('max-h-[65vh]')).toBe(true);
|
|
34
|
+
await act(async () => root!.render(<BottomSheet open title="活动详情" onClose={vi.fn()} size="large"><p>活动内容</p></BottomSheet>));
|
|
35
|
+
const panel = document.querySelector('[role="dialog"]')!;
|
|
36
|
+
expect(panel.classList.contains('h-[86vh]')).toBe(true);
|
|
37
|
+
expect(panel.classList.contains('supports-[height:100dvh]:h-[86dvh]')).toBe(true);
|
|
38
|
+
expect(panel.classList.contains('max-h-[65vh]')).toBe(false);
|
|
39
|
+
expect(panel.querySelector('.tbox-bottom-sheet__body')?.classList.contains('overflow-y-auto')).toBe(true);
|
|
40
|
+
});
|
|
41
|
+
|
|
31
42
|
it('关闭态不挂载内容;打开通过 portal 展示命名对话框和业务内容', async () => {
|
|
32
43
|
await renderSheet(false);
|
|
33
44
|
expect(document.querySelector('[role="dialog"]')).toBeNull();
|
|
@@ -9,6 +9,8 @@ export interface BottomSheetProps {
|
|
|
9
9
|
children: ReactNode;
|
|
10
10
|
/** 内容容器的业务样式;弹层外壳由组件统一管理。 */
|
|
11
11
|
className?: string;
|
|
12
|
+
/** large 与门店详情同高;默认按内容撑开,最高 65% 视口。 */
|
|
13
|
+
size?: 'default' | 'large';
|
|
12
14
|
/**
|
|
13
15
|
* `default` = 标题栏 + 关闭按钮;
|
|
14
16
|
* `card` = 只留拖拽条与悬浮关闭按钮,让内容里的卡片标题成为唯一主标题(避免「抽屉大标题 + 卡内标题」双头)。
|
|
@@ -24,7 +26,7 @@ export interface BottomSheetProps {
|
|
|
24
26
|
export async function preloadBottomSheet(): Promise<void> {}
|
|
25
27
|
|
|
26
28
|
/** 受控底部弹层:业务只提供内容与开关,不自行处理遮罩、滚动和焦点。 */
|
|
27
|
-
export function BottomSheet({ open, title, onClose, children, className, variant = 'default' }: BottomSheetProps) {
|
|
29
|
+
export function BottomSheet({ open, title, onClose, children, className, variant = 'default', size = 'default' }: BottomSheetProps) {
|
|
28
30
|
const titleId = useId();
|
|
29
31
|
const closeRef = useRef<HTMLButtonElement>(null);
|
|
30
32
|
const cardMode = variant === 'card';
|
|
@@ -38,7 +40,12 @@ export function BottomSheet({ open, title, onClose, children, className, variant
|
|
|
38
40
|
initialFocus={closeRef}
|
|
39
41
|
exitMs={200}
|
|
40
42
|
rootClassName="tbox-bottom-sheet-root group"
|
|
41
|
-
panelClassName=
|
|
43
|
+
panelClassName={[
|
|
44
|
+
'tbox-bottom-sheet tbox-bottom-sheet__panel flex w-full max-w-content flex-col overflow-hidden rounded-t-[14px] bg-card text-foreground animate-[tbox-sheet-in_200ms_ease-out] group-data-[state=closed]:animate-[tbox-sheet-out_200ms_ease-in_both] motion-reduce:animate-none',
|
|
45
|
+
size === 'large'
|
|
46
|
+
? 'h-[86vh] max-h-[86vh] supports-[height:100dvh]:h-[86dvh] supports-[height:100dvh]:max-h-[86dvh]'
|
|
47
|
+
: 'max-h-[65vh] supports-[height:100dvh]:max-h-[65dvh]',
|
|
48
|
+
].join(' ')}
|
|
42
49
|
maskClassName="bg-scrim animate-[tbox-fade-in_200ms_ease-out] group-data-[state=closed]:animate-[tbox-fade-out_200ms_ease-in_both] motion-reduce:animate-none"
|
|
43
50
|
>
|
|
44
51
|
{cardMode ? (
|