@snowui-design-system/components 0.2.0-alpha.7 → 0.2.0-alpha.9
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 +27 -22
- package/component-catalog.json +1066 -0
- package/package.json +12 -4
- package/src/assets/gradient-avatar/blue.svg +1 -0
- package/src/assets/gradient-avatar/cyan.svg +1 -0
- package/src/assets/gradient-avatar/green.svg +1 -0
- package/src/assets/gradient-avatar/orange.svg +1 -0
- package/src/assets/gradient-avatar/purple.svg +1 -0
- package/src/assets/gradient-avatar/red.svg +1 -0
- package/src/components/Accordion.md +1 -1
- package/src/components/Accordion.svelte +5 -1
- package/src/components/Avatar.md +95 -58
- package/src/components/Avatar.svelte +286 -92
- package/src/components/Avatar.test.ts +24 -3
- package/src/components/Badge.md +31 -2
- package/src/components/Badge.svelte +38 -3
- package/src/components/Badge.test.ts +14 -1
- package/src/components/Button.md +42 -19
- package/src/components/Button.svelte +56 -50
- package/src/components/Button.test.ts +38 -27
- package/src/components/Card.test.ts +1 -1
- package/src/components/CodeBlock.md +50 -14
- package/src/components/CodeBlock.svelte +213 -34
- package/src/components/CodeBlock.test.ts +43 -2
- package/src/components/ColorSchemeButton.md +50 -0
- package/src/components/ColorSchemeButton.svelte +144 -0
- package/src/components/ColorSchemeButton.test.ts +39 -0
- package/src/components/CopyButton.md +5 -1
- package/src/components/CopyButton.svelte +6 -2
- package/src/components/Dialog.svelte +1 -0
- package/src/components/Dialog.test.ts +2 -2
- package/src/components/ExpandButton.md +5 -1
- package/src/components/ExpandButton.svelte +1 -0
- package/src/components/Form.test.ts +4 -4
- package/src/components/Gradient.md +278 -0
- package/src/components/Gradient.svelte +1283 -0
- package/src/components/Gradient.test.ts +77 -0
- package/src/components/Icon.svelte +3 -1
- package/src/components/Image.svelte +11 -8
- package/src/components/Image.test.ts +1 -1
- package/src/components/Indicator.md +18 -4
- package/src/components/Indicator.svelte +151 -11
- package/src/components/Indicator.test.ts +25 -0
- package/src/components/Input.md +15 -5
- package/src/components/Input.svelte +10 -1
- package/src/components/Input.test.ts +2 -2
- package/src/components/Listbox.md +5 -0
- package/src/components/Listbox.svelte +26 -0
- package/src/components/Listbox.test.ts +14 -0
- package/src/components/MenuItem.md +5 -0
- package/src/components/MenuItem.svelte +6 -0
- package/src/components/OverflowAction.md +41 -0
- package/src/components/OverflowAction.svelte +209 -0
- package/src/components/OverflowAction.test.ts +11 -0
- package/src/components/OverflowActions.md +95 -0
- package/src/components/OverflowActions.svelte +501 -0
- package/src/components/OverflowActions.test.ts +87 -0
- package/src/components/Pagination.md +2 -2
- package/src/components/Pagination.svelte +2 -2
- package/src/components/Pagination.test.ts +2 -2
- package/src/components/Popover.md +5 -0
- package/src/components/Popover.svelte +25 -0
- package/src/components/Popover.test.ts +14 -0
- package/src/components/ScrollArea.md +7 -3
- package/src/components/ScrollArea.test.ts +3 -2
- package/src/components/SearchInput.md +14 -1
- package/src/components/SearchInput.svelte +104 -2
- package/src/components/SearchInput.test.ts +16 -1
- package/src/components/SelectButton.md +1 -1
- package/src/components/SelectButton.svelte +8 -2
- package/src/components/Skeleton.md +13 -1
- package/src/components/Skeleton.svelte +30 -2
- package/src/components/Slider.md +68 -6
- package/src/components/Slider.svelte +329 -21
- package/src/components/Slider.test.ts +65 -0
- package/src/components/SnowUILogo.md +210 -0
- package/src/components/SnowUILogo.svelte +478 -0
- package/src/components/SnowUILogo.test.ts +62 -0
- package/src/components/StyleButton.md +58 -0
- package/src/components/StyleButton.svelte +144 -0
- package/src/components/StyleButton.test.ts +39 -0
- package/src/components/Table.md +23 -7
- package/src/components/Table.svelte +22 -1
- package/src/components/TableBody.md +12 -1
- package/src/components/TableBody.svelte +26 -2
- package/src/components/TableBody.test.ts +3 -0
- package/src/components/TableCell.md +9 -3
- package/src/components/TableCell.svelte +139 -78
- package/src/components/TableCell.test.ts +4 -4
- package/src/components/TableHead.md +9 -3
- package/src/components/TableHead.svelte +56 -43
- package/src/components/TableHead.test.ts +5 -5
- package/src/components/TableRow.md +15 -5
- package/src/components/TableRow.svelte +47 -10
- package/src/components/TableRow.test.ts +2 -2
- package/src/components/TableToolbar.svelte +20 -8
- package/src/components/Text.md +7 -1
- package/src/components/Text.svelte +17 -7
- package/src/components/Tooltip.md +37 -9
- package/src/components/Tooltip.svelte +145 -35
- package/src/components/Tooltip.test.ts +54 -4
- package/src/i18n/messages.ts +12 -0
- package/src/index.ts +24 -0
- package/src/internal/StyleButtonLogo.svelte +49 -0
- package/src/lib/color.md +2 -2
- package/src/lib/edge-fade.md +1 -0
- package/src/lib/overlay-scrollbar.md +6 -1
- package/src/lib/table-context.svelte.ts +36 -0
- package/src/lib/table-role-blur.ts +46 -0
- package/src/lib/table-truncation.md +14 -0
- package/src/lib/table-truncation.ts +83 -0
- package/src/lib/tooltip-delay.md +7 -1
- package/src/lib/tooltip-motion-dismiss.md +33 -0
- package/src/lib/tooltip-motion-dismiss.ts +160 -0
- package/src/lib/tooltip-overlay.md +21 -3
- package/src/lib/tooltip-overlay.ts +13 -2
- package/src/logic/README.md +4 -1
- package/src/logic/continuous-hover.svelte.md +22 -0
- package/src/logic/continuous-hover.svelte.ts +436 -0
- package/src/logic/frame-inline-style.svelte.ts +2 -2
- package/src/logic/frame-truncation.md +9 -3
- package/src/logic/frame-truncation.svelte.ts +6 -0
- package/src/logic/layout-flip.ts +182 -5
- package/src/logic/overflow-actions.svelte.ts +33 -0
- package/src/motion/presets/README.md +6 -2
- package/src/motion/presets/continuous-hover.md +11 -0
- package/src/motion/presets/continuous-hover.ts +18 -0
- package/src/motion/presets/tooltip.md +40 -2
- package/src/motion/presets/tooltip.ts +0 -2
- package/src/motion/tokens.md +9 -4
- package/src/motion/tokens.ts +4 -1
- package/src/styles/README.md +16 -2
- package/src/styles/auto-layout.css +10 -1
- package/src/styles/components.css +920 -0
- package/src/styles/index.css +3 -1
- package/src/styles/layout.css +44 -0
- package/src/styles/scrollbar.css +27 -7
- package/src/styles/themes.css +146 -0
- package/src/styles/tokens.css +33 -33
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gradient.test.ts
|
|
3
|
+
* v2.12.0
|
|
4
|
+
*/
|
|
5
|
+
export const examples = [
|
|
6
|
+
{
|
|
7
|
+
name: "GD-01:六种 Frame 200 配色",
|
|
8
|
+
code: `GD-01
|
|
9
|
+
<Frame row gap={2}>
|
|
10
|
+
<Gradient variant="blue" />
|
|
11
|
+
<Gradient variant="cyan" />
|
|
12
|
+
<Gradient variant="green" />
|
|
13
|
+
<Gradient variant="red" />
|
|
14
|
+
<Gradient variant="orange" />
|
|
15
|
+
<Gradient variant="purple" />
|
|
16
|
+
</Frame>`,
|
|
17
|
+
expected: {
|
|
18
|
+
render: "按 Figma Frame 200 从左到右渲染 blue、cyan、green、red、orange、purple 六种 360 × 360 SVG 矢量渐变,并持续柔和漂移。",
|
|
19
|
+
layout: "每个 Gradient 保持自身 360 × 360 内禀尺寸;外层 Frame 只负责排列与换行。",
|
|
20
|
+
},
|
|
21
|
+
logic: ["Vector", "SixVariants", "FigmaReference", "AlwaysMoving"],
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
name: "GD-02:图形与模糊同步缩放",
|
|
25
|
+
code: `GD-02
|
|
26
|
+
<Frame row gap={2}>
|
|
27
|
+
<Gradient variant="blue" size={90} />
|
|
28
|
+
<Gradient variant="blue" size={180} />
|
|
29
|
+
<Gradient variant="blue" size={360} />
|
|
30
|
+
</Frame>`,
|
|
31
|
+
expected: {
|
|
32
|
+
render: "三项使用同一套 viewBox 矢量;尺寸按 0.25×、0.5×、1× 缩放时,图形边界与四层 Gaussian Blur 同比缩放。",
|
|
33
|
+
performance: "不使用 ResizeObserver、Canvas 或运行时 blur 重算。",
|
|
34
|
+
},
|
|
35
|
+
logic: ["VectorScaling", "BlurScaling"],
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
name: "GD-03:非正方形 Fill",
|
|
39
|
+
code: `GD-03
|
|
40
|
+
<Gradient variant="orange" width={360} height={180} />`,
|
|
41
|
+
expected: {
|
|
42
|
+
render: "SVG 以 preserveAspectRatio=none 填满 360 × 180 画布,X/Y 几何与模糊分别跟随画布缩放。",
|
|
43
|
+
layout: "外部宽高决定内禀画布,不产生留白。",
|
|
44
|
+
},
|
|
45
|
+
logic: ["NonSquare", "FigmaFill", "BlurScaling"],
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: "GD-04:六种 Avatar Hover",
|
|
49
|
+
code: `GD-04
|
|
50
|
+
<Frame style="display: grid; grid-template-columns: repeat(3, 5rem); gap: var(--gap-2);">
|
|
51
|
+
<Avatar fallback={Gradient} data-name="blue" size={80} />
|
|
52
|
+
<Avatar fallback={Gradient} data-name="cyan" size={80} />
|
|
53
|
+
<Avatar fallback={Gradient} data-name="green" size={80} />
|
|
54
|
+
<Avatar fallback={Gradient} data-name="red" size={80} />
|
|
55
|
+
<Avatar fallback={Gradient} data-name="orange" size={80} />
|
|
56
|
+
<Avatar fallback={Gradient} data-name="purple" size={80} />
|
|
57
|
+
</Frame>`,
|
|
58
|
+
expected: {
|
|
59
|
+
render: "以三列两行依次渲染 blue、cyan、green、red、orange、purple 六个 80 × 80 Gradient Avatar;圆形外壳裁切无有色毛边,内部矢量不溢出。",
|
|
60
|
+
interaction: "每个头像 hover 时排除当前 variant,并按实例随机顺序在其余五种 Gradient 中心色之间持续交叉过渡;同时按需淡入实时 SVG,四个图层以 6.4s / 7.2s / 8.4s / 6.8s 不同周期和七段非对称路径持续流动。每次进入随机选择且不重复上一组相位 / 方向配置;颜色 Overlay 保持双层、58% 峰值、10s 循环、1s进入和0.5s退出。",
|
|
61
|
+
performance: "Avatar 常态直接复用 lazy / async / low-priority 的六份静态 SVG 图片资源,不创建 Gradient 组件;hover 时才为当前头像挂载 Gradient、一份实时 SVG、四组 filter 与五色 × 两层 Overlay,淡出后全部卸载;受控 effect 不追踪这些内部动效状态。",
|
|
62
|
+
accessibility: "prefers-reduced-motion: reduce 下停止颜色循环,并以随机序列首色保留静态 hover 反馈。",
|
|
63
|
+
},
|
|
64
|
+
logic: ["SixVariants", "Avatar", "SeedPalette", "RandomColorCycle", "OverlayBlend", "ControlledEffectBoundary", "ReducedMotion"],
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
name: "GD-05:全部动效参数控制台",
|
|
68
|
+
code: `GD-05
|
|
69
|
+
<GradientMotionController />`,
|
|
70
|
+
expected: {
|
|
71
|
+
render: "底色矩形固定不动;Vector 4、Vector 3、Subtract、Subtract 2 分别执行位移 / 旋转、位移 / 缩放、位移 / 非等比形变、位移 / 旋转 / 缩放。图形位于上方,19 条控制条在下方按四列排列,并全部以各自可调范围上限作为默认值;基础时长 60s 与整体速度 4× 合成为实际 15s 循环。",
|
|
72
|
+
performance: "控制状态仅存在于 Test 辅助组件;Gradient 只动画四个有色 SVG 图层的 transform,不逐帧修改 Gaussian Blur、路径、颜色或混合模式。",
|
|
73
|
+
accessibility: "prefers-reduced-motion: reduce 下停止动画并恢复静态基线。",
|
|
74
|
+
},
|
|
75
|
+
logic: ["MotionControls", "LayerTransforms", "StaticBackground", "ReducedMotion"],
|
|
76
|
+
},
|
|
77
|
+
] as const;
|
|
@@ -59,14 +59,17 @@
|
|
|
59
59
|
|
|
60
60
|
// 过滤掉已移除的 Props 和组件内部逻辑 Props,避免透传到 DOM
|
|
61
61
|
// 对齐 Avatar / Frame 的过滤规范
|
|
62
|
-
const {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
62
|
+
const cleanRest = $derived.by(() => {
|
|
63
|
+
const {
|
|
64
|
+
alt: _alt,
|
|
65
|
+
previewMode: _previewMode,
|
|
66
|
+
onOpen: _oo,
|
|
67
|
+
badgePosition: _bp,
|
|
68
|
+
variant: _variant,
|
|
69
|
+
...forwardedProps
|
|
70
|
+
} = rest as Record<string, any>;
|
|
71
|
+
return forwardedProps;
|
|
72
|
+
});
|
|
70
73
|
|
|
71
74
|
getSize();
|
|
72
75
|
const sizeCtx = getSizeContext();
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
# Indicator(尺寸指示手柄)
|
|
2
2
|
|
|
3
|
-
> **版本**: v1.0
|
|
4
|
-
> **更新**: 2026-07-
|
|
3
|
+
> **版本**: v1.2.0
|
|
4
|
+
> **更新**: 2026-07-28
|
|
5
5
|
> **职责**: 提供宿主 hover 显示、Pointer / 键盘拖动与统一视觉反馈的通用尺寸手柄
|
|
6
6
|
> **布局模型**: Pin 布局
|
|
7
7
|
> **文档**: ./Indicator.md
|
|
8
8
|
|
|
9
9
|
Indicator 将原 WidthIndicator、HeightIndicator 与 ResizeHandle 合并为一个可交互组件。它默认调整直接父元素,也可以通过 `target` 显式关联任意祖先宿主。鼠标位于 reveal host 的任意普通后代上时,Indicator 都会显示;只有进入 Indicator **命中带**时才会加深、变粗并开始拖动。
|
|
10
10
|
|
|
11
|
-
**命中带(line
|
|
11
|
+
**命中带(line)**:视觉条与命中区分层。默认情况下 line **不使用 pin 居中**,根节点从**物理边缘 0** 起铺满全高/全宽,命中厚度 = `pinOffset + 8px`(含边框线,可从最外缘拖动);视觉短条中心落在 `pinOffset`(SidePanel 为 4px),默认 2×16 / 16×2。消费方可传 `hitAreaPadding`,将沿边命中范围收窄为“视觉长度 + 两端 padding”;例如 Sidebar 传 4px 后,16px 视觉条只有上下各 4px、合计 24px 的纵向激活范围。corner 仍用 `pin-bottom-right` + 局部命中。
|
|
12
|
+
|
|
13
|
+
Indicator 会在准备显示时检查同一 resize target 内可见的 SnowUI overlay scrollbar。宿主 hover 仍是 Indicator 的默认显示条件;若 Indicator 命中区与实际 scrollbar Thumb 发生矩形重叠,则滚动条优先,Indicator 整体隐藏并关闭 Pointer、hover、拖拽与键盘命中。检测只在宿主 hover、Indicator focus 或 dragging 期间启用,并响应 ScrollArea pointer enter / leave、viewport scroll、Thumb 拖动 / 位移和 scrollbar opacity transition;结束后清理全部监听与观察器。
|
|
12
14
|
|
|
13
15
|
## API 参考
|
|
14
16
|
|
|
@@ -17,6 +19,7 @@ Indicator 将原 WidthIndicator、HeightIndicator 与 ResizeHandle 合并为一
|
|
|
17
19
|
| `axis` | `"width" \| "height" \| "both"` | line 为 `"width"`;corner 为 `"height"` | 调整宿主宽度、高度或同时调整;`both` 只用于 corner |
|
|
18
20
|
| `edge` | `"start" \| "end" \| "top" \| "bottom"` | 根据 axis 推导 | 拖动方向与默认定位边缘 |
|
|
19
21
|
| `appearance` | `"line" \| "corner"` | `"line"` | 线形或右下角图标视觉 |
|
|
22
|
+
| `hitAreaPadding` | `number \| string` | — | line 沿边命中范围两端相对视觉条增加的 padding;未传时继续铺满整条边 |
|
|
20
23
|
| `target` | `HTMLElement` | 直接父元素 | resize target;可显式关联页面中的任意元素,不要求 Indicator 是其 DOM 后代 |
|
|
21
24
|
| `revealTarget` | `HTMLElement` | target | 控制显隐的 hover 宿主 |
|
|
22
25
|
| `value` | `number` | 实测 target 尺寸 | 当前受控尺寸基线,并同步为 ARIA 当前值 |
|
|
@@ -42,7 +45,7 @@ Indicator 将原 WidthIndicator、HeightIndicator 与 ResizeHandle 合并为一
|
|
|
42
45
|
- corner 固定在右下角;默认 `axis="height"`,使用 `ns-resize` 上下双箭头并只调整高度。
|
|
43
46
|
- corner 显式 `axis="both"` 时使用 `nwse-resize` 对角双箭头,同时调整宽度和高度。
|
|
44
47
|
- 定位:line 自管 absolute 贴边(不用 pin 居中);corner 默认 `as="pin-bottom-right"` + `pinOffset="var(--padding-1)"` + `z-index: 4`。
|
|
45
|
-
- 默认隐藏;宿主 hover、focus-visible 或 dragging
|
|
48
|
+
- 默认隐藏;宿主 hover、focus-visible 或 dragging 时显示;与同一 target 内可见 overlay scrollbar Thumb 重叠时继续隐藏,并禁用 Pointer、hover、拖拽与键盘命中。
|
|
46
49
|
- 视觉与命中区分层;line 命中带铺满所在边缘全高/全宽。
|
|
47
50
|
- 动效消费与 overlay scrollbar 相同的 Frame color motion bridge。
|
|
48
51
|
|
|
@@ -82,6 +85,17 @@ Indicator 将原 WidthIndicator、HeightIndicator 与 ResizeHandle 合并为一
|
|
|
82
85
|
|
|
83
86
|
## 更新日志 (Changelog)
|
|
84
87
|
|
|
88
|
+
### v1.2.0 (2026-07-28)
|
|
89
|
+
|
|
90
|
+
- 保持 reveal host 任意区域 hover 即显示 Indicator。
|
|
91
|
+
- 重叠检测由整条 scrollbar 轨道改为实际 Thumb,并响应 ScrollArea hover、滚动、Thumb 拖动与 opacity transition。
|
|
92
|
+
- Indicator 与可见 Thumb 重叠时完全退出 Pointer、hover、拖拽和键盘命中,确保滚动条获得唯一交互优先级。
|
|
93
|
+
|
|
94
|
+
### v1.1.0 (2026-07-28)
|
|
95
|
+
|
|
96
|
+
- line 新增 `hitAreaPadding`,允许消费方把全边命中带收窄为视觉条附近的局部范围。
|
|
97
|
+
- Indicator 与同一 resize target 内的可见 SnowUI overlay scrollbar 重叠时自动隐藏并停止截获指针。
|
|
98
|
+
|
|
85
99
|
### v1.0.1 (2026-07-12)
|
|
86
100
|
|
|
87
101
|
- line 命中带默认铺满所在边缘全高(width)/ 全宽(height):改为 absolute + top/bottom 或 left/right 贴边,不再用 pin 居中;视觉短条与命中带分层。
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<!--
|
|
1
|
+
<!-- 通用可交互尺寸指示手柄;支持局部命中与滚动条重叠避让。文档: ./Indicator.md -->
|
|
2
2
|
<script module lang="ts">
|
|
3
3
|
export type IndicatorAxis = "width" | "height" | "both";
|
|
4
4
|
export type IndicatorEdge = "start" | "end" | "top" | "bottom";
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
import Frame, { type FrameProps } from "./Frame.svelte";
|
|
11
11
|
import { resizable, type ResizableOptions } from "../lib/resizable";
|
|
12
12
|
import { untrack } from "svelte";
|
|
13
|
+
import { resizeManager } from "../logic/observer.svelte";
|
|
13
14
|
import {
|
|
14
15
|
mergeComponentPartProps,
|
|
15
16
|
useComponentPart,
|
|
@@ -19,6 +20,7 @@
|
|
|
19
20
|
axis?: IndicatorAxis;
|
|
20
21
|
edge?: IndicatorEdge;
|
|
21
22
|
appearance?: IndicatorAppearance;
|
|
23
|
+
hitAreaPadding?: number | string;
|
|
22
24
|
target?: HTMLElement;
|
|
23
25
|
revealTarget?: HTMLElement;
|
|
24
26
|
value?: number;
|
|
@@ -45,6 +47,7 @@
|
|
|
45
47
|
axis,
|
|
46
48
|
edge,
|
|
47
49
|
appearance = "line",
|
|
50
|
+
hitAreaPadding = undefined,
|
|
48
51
|
target,
|
|
49
52
|
revealTarget,
|
|
50
53
|
value,
|
|
@@ -82,6 +85,7 @@
|
|
|
82
85
|
let hostHovered = $state(false);
|
|
83
86
|
let focused = $state(false);
|
|
84
87
|
let dragging = $state(false);
|
|
88
|
+
let overlapsScrollbar = $state(false);
|
|
85
89
|
let resizeActions: ReturnType<typeof resizable>[] = [];
|
|
86
90
|
|
|
87
91
|
const resolvedAxis = $derived(
|
|
@@ -103,7 +107,8 @@
|
|
|
103
107
|
);
|
|
104
108
|
const resolvedTarget = $derived(target ?? element?.parentElement ?? undefined);
|
|
105
109
|
const resolvedRevealTarget = $derived(revealTarget ?? resolvedTarget);
|
|
106
|
-
const
|
|
110
|
+
const shouldReveal = $derived(hostHovered || focused || dragging);
|
|
111
|
+
const isVisible = $derived(shouldReveal && !overlapsScrollbar);
|
|
107
112
|
const resolvedAriaLabel = $derived(
|
|
108
113
|
ariaLabel ??
|
|
109
114
|
(resolvedAxis === "width"
|
|
@@ -137,28 +142,36 @@
|
|
|
137
142
|
if (resolvedAppearance !== "line" || resolvedAxis === "both") return "";
|
|
138
143
|
const offset = toCssLength(resolvedPinOffset);
|
|
139
144
|
const grab = "var(--size-2, 0.5rem)";
|
|
145
|
+
const alongPadding =
|
|
146
|
+
hitAreaPadding === undefined
|
|
147
|
+
? undefined
|
|
148
|
+
: toCssLength(hitAreaPadding);
|
|
140
149
|
if (resolvedAxis === "width") {
|
|
141
150
|
const side = resolvedEdge === "start" ? "left:0" : "right:0";
|
|
142
151
|
return [
|
|
143
152
|
"position:absolute",
|
|
144
|
-
"top:0",
|
|
145
|
-
"bottom:0",
|
|
146
|
-
|
|
153
|
+
alongPadding ? "top:50%" : "top:0",
|
|
154
|
+
alongPadding ? "bottom:auto" : "bottom:0",
|
|
155
|
+
alongPadding
|
|
156
|
+
? `height:calc(var(--snowui-indicator-visual-length, var(--size-4)) + ${alongPadding} + ${alongPadding})`
|
|
157
|
+
: "height:auto",
|
|
147
158
|
`width:calc(${offset} + ${grab})`,
|
|
148
159
|
side,
|
|
149
|
-
"translate:none",
|
|
160
|
+
alongPadding ? "translate:0 -50%" : "translate:none",
|
|
150
161
|
`--snowui-indicator-visual-inset:${offset}`,
|
|
151
162
|
].join(";");
|
|
152
163
|
}
|
|
153
164
|
const side = resolvedEdge === "top" ? "top:0" : "bottom:0";
|
|
154
165
|
return [
|
|
155
166
|
"position:absolute",
|
|
156
|
-
"left:0",
|
|
157
|
-
"right:0",
|
|
158
|
-
|
|
167
|
+
alongPadding ? "left:50%" : "left:0",
|
|
168
|
+
alongPadding ? "right:auto" : "right:0",
|
|
169
|
+
alongPadding
|
|
170
|
+
? `width:calc(var(--snowui-indicator-visual-length, var(--size-4)) + ${alongPadding} + ${alongPadding})`
|
|
171
|
+
: "width:auto",
|
|
159
172
|
`height:calc(${offset} + ${grab})`,
|
|
160
173
|
side,
|
|
161
|
-
"translate:none",
|
|
174
|
+
alongPadding ? "translate:-50% 0" : "translate:none",
|
|
162
175
|
`--snowui-indicator-visual-inset:${offset}`,
|
|
163
176
|
].join(";");
|
|
164
177
|
});
|
|
@@ -200,6 +213,50 @@
|
|
|
200
213
|
};
|
|
201
214
|
}
|
|
202
215
|
|
|
216
|
+
function syncScrollbarOverlap() {
|
|
217
|
+
const handle = element;
|
|
218
|
+
const resizeTarget = resolvedTarget;
|
|
219
|
+
if (!handle || !resizeTarget || !shouldReveal) {
|
|
220
|
+
overlapsScrollbar = false;
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
const handleRect = handle.getBoundingClientRect();
|
|
225
|
+
const scrollbars = resizeTarget.querySelectorAll<HTMLElement>(
|
|
226
|
+
'.snowui-overlay-scrollbar[data-visible="true"]',
|
|
227
|
+
);
|
|
228
|
+
overlapsScrollbar = Array.from(scrollbars).some((scrollbar) => {
|
|
229
|
+
const thumb = scrollbar.querySelector<HTMLElement>(
|
|
230
|
+
".snowui-overlay-scrollbar-thumb",
|
|
231
|
+
);
|
|
232
|
+
if (!thumb) return false;
|
|
233
|
+
|
|
234
|
+
const style = getComputedStyle(scrollbar);
|
|
235
|
+
const thumbStyle = getComputedStyle(thumb);
|
|
236
|
+
const scrollbarHost = scrollbar.closest(
|
|
237
|
+
".snowui-overlay-scrollbar-host",
|
|
238
|
+
);
|
|
239
|
+
const isRendered =
|
|
240
|
+
style.display !== "none" &&
|
|
241
|
+
style.visibility !== "hidden" &&
|
|
242
|
+
thumbStyle.display !== "none" &&
|
|
243
|
+
thumbStyle.visibility !== "hidden" &&
|
|
244
|
+
(scrollbar.dataset.axis === "horizontal" ||
|
|
245
|
+
scrollbarHost?.matches(":hover") ||
|
|
246
|
+
thumb.dataset.dragging === "true" ||
|
|
247
|
+
Number(style.opacity) > 0);
|
|
248
|
+
if (!isRendered) return false;
|
|
249
|
+
|
|
250
|
+
const scrollbarRect = thumb.getBoundingClientRect();
|
|
251
|
+
return (
|
|
252
|
+
handleRect.left < scrollbarRect.right &&
|
|
253
|
+
handleRect.right > scrollbarRect.left &&
|
|
254
|
+
handleRect.top < scrollbarRect.bottom &&
|
|
255
|
+
handleRect.bottom > scrollbarRect.top
|
|
256
|
+
);
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
|
|
203
260
|
$effect(() => {
|
|
204
261
|
const node = element;
|
|
205
262
|
if (!node) return;
|
|
@@ -227,6 +284,82 @@
|
|
|
227
284
|
};
|
|
228
285
|
});
|
|
229
286
|
|
|
287
|
+
$effect(() => {
|
|
288
|
+
const handle = element;
|
|
289
|
+
const resizeTarget = resolvedTarget;
|
|
290
|
+
if (!handle || !resizeTarget || !shouldReveal) {
|
|
291
|
+
overlapsScrollbar = false;
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
let frame = 0;
|
|
296
|
+
const scheduleSync = () => {
|
|
297
|
+
cancelAnimationFrame(frame);
|
|
298
|
+
frame = requestAnimationFrame(syncScrollbarOverlap);
|
|
299
|
+
};
|
|
300
|
+
const mutationObserver = new MutationObserver(scheduleSync);
|
|
301
|
+
const scrollbars = resizeTarget.querySelectorAll<HTMLElement>(
|
|
302
|
+
".snowui-overlay-scrollbar",
|
|
303
|
+
);
|
|
304
|
+
const thumbs = Array.from(scrollbars)
|
|
305
|
+
.map((scrollbar) =>
|
|
306
|
+
scrollbar.querySelector<HTMLElement>(
|
|
307
|
+
".snowui-overlay-scrollbar-thumb",
|
|
308
|
+
),
|
|
309
|
+
)
|
|
310
|
+
.filter((thumb): thumb is HTMLElement => Boolean(thumb));
|
|
311
|
+
const resizeCleanups = [
|
|
312
|
+
resizeManager.watch(handle, scheduleSync),
|
|
313
|
+
resizeManager.watch(resizeTarget, scheduleSync),
|
|
314
|
+
...Array.from(scrollbars, (scrollbar) =>
|
|
315
|
+
resizeManager.watch(scrollbar, scheduleSync),
|
|
316
|
+
),
|
|
317
|
+
...thumbs.map((thumb) => resizeManager.watch(thumb, scheduleSync)),
|
|
318
|
+
];
|
|
319
|
+
const eventCleanups: Array<() => void> = [];
|
|
320
|
+
const listen = (
|
|
321
|
+
target: EventTarget | null | undefined,
|
|
322
|
+
type: string,
|
|
323
|
+
options?: AddEventListenerOptions,
|
|
324
|
+
) => {
|
|
325
|
+
if (!target) return;
|
|
326
|
+
target.addEventListener(type, scheduleSync, options);
|
|
327
|
+
eventCleanups.push(() =>
|
|
328
|
+
target.removeEventListener(type, scheduleSync, options),
|
|
329
|
+
);
|
|
330
|
+
};
|
|
331
|
+
|
|
332
|
+
scrollbars.forEach((scrollbar) => {
|
|
333
|
+
const scrollbarHost = scrollbar.closest<HTMLElement>(
|
|
334
|
+
".snowui-overlay-scrollbar-host",
|
|
335
|
+
);
|
|
336
|
+
const viewport = scrollbarHost?.querySelector<HTMLElement>(
|
|
337
|
+
".snowui-overlay-scrollbar-viewport",
|
|
338
|
+
);
|
|
339
|
+
listen(scrollbarHost, "pointerenter");
|
|
340
|
+
listen(scrollbarHost, "pointerleave");
|
|
341
|
+
listen(scrollbar, "transitionrun");
|
|
342
|
+
listen(scrollbar, "transitionend");
|
|
343
|
+
listen(viewport, "scroll", { passive: true });
|
|
344
|
+
});
|
|
345
|
+
|
|
346
|
+
mutationObserver.observe(resizeTarget, {
|
|
347
|
+
subtree: true,
|
|
348
|
+
childList: true,
|
|
349
|
+
attributes: true,
|
|
350
|
+
attributeFilter: ["data-visible", "data-dragging", "style"],
|
|
351
|
+
});
|
|
352
|
+
syncScrollbarOverlap();
|
|
353
|
+
|
|
354
|
+
return () => {
|
|
355
|
+
cancelAnimationFrame(frame);
|
|
356
|
+
resizeCleanups.forEach((cleanup) => cleanup());
|
|
357
|
+
eventCleanups.forEach((cleanup) => cleanup());
|
|
358
|
+
mutationObserver.disconnect();
|
|
359
|
+
overlapsScrollbar = false;
|
|
360
|
+
};
|
|
361
|
+
});
|
|
362
|
+
|
|
230
363
|
$effect(() => {
|
|
231
364
|
const host = resolvedTarget;
|
|
232
365
|
const handle = element;
|
|
@@ -287,6 +420,7 @@
|
|
|
287
420
|
data-axis={resolvedAxis}
|
|
288
421
|
data-appearance={resolvedAppearance}
|
|
289
422
|
data-visible={isVisible ? "true" : undefined}
|
|
423
|
+
data-overlaps-scrollbar={overlapsScrollbar ? "true" : undefined}
|
|
290
424
|
data-dragging={dragging ? "true" : undefined}
|
|
291
425
|
data-disabled={disabled ? "true" : undefined}
|
|
292
426
|
role="separator"
|
|
@@ -296,7 +430,8 @@
|
|
|
296
430
|
: resolvedAxis === "height"
|
|
297
431
|
? "horizontal"
|
|
298
432
|
: undefined}
|
|
299
|
-
tabindex={disabled ? -1 : 0}
|
|
433
|
+
tabindex={disabled || overlapsScrollbar ? -1 : 0}
|
|
434
|
+
aria-hidden={overlapsScrollbar ? "true" : undefined}
|
|
300
435
|
enableAutoLayout={false}
|
|
301
436
|
enableResponsive={enableResponsive}
|
|
302
437
|
enableContext={enableContext}
|
|
@@ -487,4 +622,9 @@
|
|
|
487
622
|
cursor: default;
|
|
488
623
|
pointer-events: none;
|
|
489
624
|
}
|
|
625
|
+
|
|
626
|
+
:global(:where(.snowui-indicator[data-overlaps-scrollbar="true"])) {
|
|
627
|
+
visibility: hidden;
|
|
628
|
+
pointer-events: none;
|
|
629
|
+
}
|
|
490
630
|
</style>
|
|
@@ -54,4 +54,29 @@ export const examples = [
|
|
|
54
54
|
},
|
|
55
55
|
logic: ["Corner", "BothAxes", "Pointer", "Keyboard"],
|
|
56
56
|
},
|
|
57
|
+
{
|
|
58
|
+
name: "IN-04: 局部命中与滚动条避让",
|
|
59
|
+
code: `IN-04
|
|
60
|
+
<Frame style="position: relative; width: 10rem; height: 6rem;">
|
|
61
|
+
<ScrollArea style="height: 100%;">
|
|
62
|
+
<Frame column class="gap-8" style="height: 12rem;">
|
|
63
|
+
<Text>滚动内容</Text>
|
|
64
|
+
<Text>Indicator 与滚动条重叠时只显示滚动条</Text>
|
|
65
|
+
</Frame>
|
|
66
|
+
</ScrollArea>
|
|
67
|
+
<Indicator
|
|
68
|
+
axis="width"
|
|
69
|
+
pinOffset="var(--padding-1)"
|
|
70
|
+
hitAreaPadding="var(--padding-1)"
|
|
71
|
+
/>
|
|
72
|
+
</Frame>`,
|
|
73
|
+
expected: {
|
|
74
|
+
render: "鼠标进入宿主任意区域后显示 Indicator;存在纵向 overlay scrollbar 且 Indicator 与实际 Thumb 重叠时不显示 Indicator。",
|
|
75
|
+
layout: "16px 视觉条的纵向命中范围为上下各 4px,合计 24px。",
|
|
76
|
+
interaction: "重叠时 Indicator 关闭 Pointer、hover、拖拽和键盘命中,只允许操作滚动条;Thumb 移出后恢复 Indicator。",
|
|
77
|
+
performance: "重叠检测只在宿主 hover、Indicator focus 或 dragging 期间启用,响应 ScrollArea hover、scroll、Thumb 位移与 opacity transition,并在结束后清理监听和观察器。",
|
|
78
|
+
responsive: "移除滚动溢出或使二者不再相交后,Indicator 恢复普通显隐与拖动。",
|
|
79
|
+
},
|
|
80
|
+
logic: ["LocalHitArea", "ScrollbarOverlap", "PointerPriority"],
|
|
81
|
+
},
|
|
57
82
|
] as const;
|
package/src/components/Input.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Input.svelte 文档
|
|
2
2
|
|
|
3
|
-
> **版本**: v1.1.
|
|
3
|
+
> **版本**: v1.1.3
|
|
4
4
|
> **职责**: 基础单行输入宿主;`text` 使用原生可见 `<input>`,`date` / `color` 使用自定义可见展示层,其余类型继续承接原生 `<input>` 能力与 Frame 通用能力。
|
|
5
5
|
|
|
6
6
|
**2026-04-27 补充**: 内建清除 X 恢复为焦点态交互:只有输入内容非空且 `Input` 处于 `focus-within` 时显示;失焦后隐藏且不为隐藏 X 预留额外 gap。
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
**2026-04-09 图标规则补充**: `Input` 内建 error trailing icon,以及放在 `Input` 里的前置 / 后置 icon,位置优先由 `Input` 自身控制。默认要求是 icon 到最近可见内边界保持 `16px`;进入 `Field` 后仍沿用这条规则。若 `Input as="segment"` 处于连续字段表面中,icon 到最近边框或分割线的距离仍保持 `16px`,不因为 `Field` 组合而改成新的偏移规则。
|
|
13
13
|
**2026-04-09 补充**: 根据需求文档中 F-01 的期望 HTML,`type="text"` 已回收为可见原生 `<input>`,不再额外渲染自定义 editor / placeholder 覆盖层;`Field > Input` 的结构收敛为 `div > input`,placeholder 与输入内容共同走浏览器原生单行输入排版。
|
|
14
|
-
**2026-
|
|
14
|
+
**2026-08-12 更正**: `Input` 单独使用时的源码默认 padding 为 `12 / 16`;此前文档中的 `12 / 12` 为记录错误。进入 `Field` 后仍由 Field 的既有 `12 / 16` 规则接管。
|
|
15
15
|
**2026-03-29 补充**: 当 `type="text"` 同时声明 `list` 时,`Input` 会回退为可见原生 `<input>`,以保留浏览器原生 `datalist` 建议项。
|
|
16
16
|
**2026-03-29 补充**: `type="file"` 已从 `Input` 组件支持范围中移除;传入该类型时会回退为普通 `text` 输入,不再透传浏览器原生文件上传器。
|
|
17
17
|
**2026-03-28 补充**: `type="range"` 已从 `Input` 组件支持范围中移除;传入该类型时会回退为普通 `text` 输入,不再直接透传浏览器原生滑杆。
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
## 2026-04-04 表单样式规则
|
|
26
26
|
|
|
27
27
|
- 基础节奏统一:`Field` 默认 `padding = 12 / 16`,`gap = 8`
|
|
28
|
-
- `Input` 单独使用时:组件自身带 `12 /
|
|
28
|
+
- `Input` 单独使用时:组件自身带 `12 / 16` padding 和 `8` gap
|
|
29
29
|
- icon 位置由 `Input` 自己控制:leading / trailing icon 到最近可见内边界默认都是 `16px`
|
|
30
30
|
- 错误态内建 warning icon 也走同一条 trailing icon 规则,不额外使用 overlay 偏移
|
|
31
31
|
- 放进 `Field` 后,先看有没有 `as="segment"`
|
|
@@ -81,6 +81,7 @@
|
|
|
81
81
|
| :--- | :--- | :--- | :--- |
|
|
82
82
|
| type | `string` | `"text"` | 原生输入类型,如 `text` / `email` / `password` / `number`;`range` / `file` 不再支持,会回退为 `text` |
|
|
83
83
|
| value | `string \| number` | - | 当前值,支持 `bind:value` |
|
|
84
|
+
| element | `HTMLElement` | - | 外层真实 Frame 根元素引用,支持 `bind:element`;用于宿主特化组件复用根尺寸与焦点能力 |
|
|
84
85
|
| defaultValue | `string \| number` | - | 初始值;未绑定 `value` 时作为初始展示值 |
|
|
85
86
|
| disabled | `boolean` | `false` | 禁用输入 |
|
|
86
87
|
| readonly | `boolean` | `false` | 只读输入;保留聚焦与选中文本能力,但不可直接编辑 |
|
|
@@ -244,7 +245,7 @@ Input 的根布局固定按 Leading / Control / Trailing 三段组织:
|
|
|
244
245
|
<!-- 日期输入 + 自定义 trailing 触发器(简单场景自动推断) -->
|
|
245
246
|
<Field>
|
|
246
247
|
<Input type="date" />
|
|
247
|
-
<Button bare as="trailing">
|
|
248
|
+
<Button bare iconOnly as="trailing" aria-label="打开日期选择">
|
|
248
249
|
<ArrowLineDown size={16} />
|
|
249
250
|
</Button>
|
|
250
251
|
</Field>
|
|
@@ -253,7 +254,7 @@ Input 的根布局固定按 Leading / Control / Trailing 三段组织:
|
|
|
253
254
|
<Field>
|
|
254
255
|
<Frame as="row" row>
|
|
255
256
|
<Input type="date" />
|
|
256
|
-
<Button bare as="trailing">
|
|
257
|
+
<Button bare iconOnly as="trailing" aria-label="打开日期选择">
|
|
257
258
|
<ArrowLineDown size={16} />
|
|
258
259
|
</Button>
|
|
259
260
|
</Frame>
|
|
@@ -530,6 +531,15 @@ invalid=true + !hasCustomTrailing
|
|
|
530
531
|
- **Input-Motion.2026-06-18** 新增默认错误反馈 shake:独立 `Input invalid / aria-invalid` 自动播放,嵌入 `Field` 时由 `Field` 汇总播放,消费方无需手动传类名或状态。
|
|
531
532
|
- **Input-Docs.2026-05-25** 源码顶部历史变更记录已归档;后续新增变更统一写入本文档 Changelog,源码顶部只保留职责、当前关键架构与文档路径。
|
|
532
533
|
|
|
534
|
+
### v1.1.3 (2026-08-12)
|
|
535
|
+
|
|
536
|
+
- 更正独立 Input 标准态 padding 记录为源码实际值 `12px / 16px`;组件行为未改变。
|
|
537
|
+
|
|
538
|
+
### v1.1.2 (2026-08-10)
|
|
539
|
+
|
|
540
|
+
- 补齐从 Frame 继承的 `bind:element` 根宿主引用,使 SearchInput 等宿主特化组件无需 wrapper 或私有 DOM 查询即可复用根尺寸能力。
|
|
541
|
+
- 普通 Input 的 clear + leading 稳定宽度规则在 SearchInput 空值图标态时退出,避免隐藏 clear 的历史 gap 继续占据 Icon 右侧;聚焦或已有值后仍恢复原布局。
|
|
542
|
+
|
|
533
543
|
### v1.1.1 (2026-07-05)
|
|
534
544
|
|
|
535
545
|
#### 修复
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<!--
|
|
2
2
|
Input 组件:基础单行输入框
|
|
3
|
-
v1.1.
|
|
3
|
+
v1.1.3
|
|
4
4
|
|
|
5
5
|
文档: ./Input.md
|
|
6
6
|
-->
|
|
@@ -55,6 +55,7 @@
|
|
|
55
55
|
type DateDraft = Record<TemporalSegmentKey, string>;
|
|
56
56
|
|
|
57
57
|
interface Props extends Omit<FrameProps, "tag"> {
|
|
58
|
+
element?: HTMLElement;
|
|
58
59
|
type?: HTMLInputAttributes["type"];
|
|
59
60
|
value?: InputValue;
|
|
60
61
|
defaultValue?: InputValue;
|
|
@@ -110,6 +111,7 @@
|
|
|
110
111
|
const inheritedInputPart = useComponentPart<Props>("Input");
|
|
111
112
|
let {
|
|
112
113
|
value = $bindable(),
|
|
114
|
+
element = $bindable(),
|
|
113
115
|
...explicitProps
|
|
114
116
|
}: Props = $props();
|
|
115
117
|
let {
|
|
@@ -263,6 +265,9 @@
|
|
|
263
265
|
isEmbedded && !isCustomColorType && !isCustomTemporalType,
|
|
264
266
|
);
|
|
265
267
|
let hostElement = $state<HTMLElement | undefined>(undefined);
|
|
268
|
+
$effect(() => {
|
|
269
|
+
element = hostElement;
|
|
270
|
+
});
|
|
266
271
|
// as="search" 时自动移入浮层 header 区域(固定置顶,不随内容滚动)
|
|
267
272
|
$effect(() => {
|
|
268
273
|
if (!isOverlaySearchHeader || !listboxHeaderPortal?.el || !hostElement) return;
|
|
@@ -2737,6 +2742,10 @@
|
|
|
2737
2742
|
.snowui-input:not(.snowui-search-input-borderless)[data-has-root-accessory="true"]:has(
|
|
2738
2743
|
> .snowui-input-clear-btn
|
|
2739
2744
|
):has(> [data-as="leading"]):not(
|
|
2745
|
+
.snowui-search-input-responsive-icon:not(
|
|
2746
|
+
:focus-within
|
|
2747
|
+
):not(.snowui-search-input-has-value)
|
|
2748
|
+
):not(
|
|
2740
2749
|
:has(
|
|
2741
2750
|
> [data-as="trailing"]:not(
|
|
2742
2751
|
.snowui-input-clear-btn
|
|
@@ -140,7 +140,7 @@ export const examples = [
|
|
|
140
140
|
code: `I-14b
|
|
141
141
|
<Field style="width: 20rem;">
|
|
142
142
|
<Input type="date" />
|
|
143
|
-
<Button as="trailing" type="button" variant="borderless" bare aria-label="打开日期选择器">
|
|
143
|
+
<Button as="trailing" type="button" variant="borderless" bare iconOnly emphasis="muted" aria-label="打开日期选择器">
|
|
144
144
|
<CalendarBlank size={16} />
|
|
145
145
|
</Button>
|
|
146
146
|
</Field>`,
|
|
@@ -166,7 +166,7 @@ export const examples = [
|
|
|
166
166
|
code: `I-15b
|
|
167
167
|
<Field style="width: 20rem;">
|
|
168
168
|
<Input type="time" />
|
|
169
|
-
<Button as="trailing" type="button" variant="borderless" bare aria-label="打开时间选择器">
|
|
169
|
+
<Button as="trailing" type="button" variant="borderless" bare iconOnly emphasis="muted" aria-label="打开时间选择器">
|
|
170
170
|
<Clock size={16} />
|
|
171
171
|
</Button>
|
|
172
172
|
</Field>`,
|
|
@@ -285,3 +285,8 @@ hover 自定义项(`data-custom="true"`)时,✔ 图标位置替换为 ×
|
|
|
285
285
|
- 滚动条间距规范化,Listbox 与 QuickAction 对齐 header + scroll body 区域结构。
|
|
286
286
|
- 外部点击判断统一使用 `ListboxOwnerContext` 的 `triggerEl` / `anchorEl`,不再依赖 Select 私有 class,因此 Pagination 等其他 owner 也能复用同一套 Listbox。
|
|
287
287
|
- 默认出现 / 消失动效与 Popover、Menu 共用 opacity-only dropdown preset,移除 scale 通道。
|
|
288
|
+
## 连续 Hover
|
|
289
|
+
|
|
290
|
+
`continuousHover` 默认 `true`。开启时 Listbox 只使用一个容器级背景层在直接
|
|
291
|
+
`MenuItem` 之间移动,键盘 active 项也复用该层;关闭后恢复 MenuItem 原有的即时
|
|
292
|
+
hover / active 背景。disabled、filtered 项不会成为目标。
|