@snowui-design-system/components 0.1.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/README.md +82 -0
- package/package.json +47 -0
- package/src/App.svelte +103 -0
- package/src/components/Avatar.md +452 -0
- package/src/components/Avatar.svelte +593 -0
- package/src/components/Avatar.test.ts +231 -0
- package/src/components/AvatarGroup.md +246 -0
- package/src/components/AvatarGroup.svelte +691 -0
- package/src/components/AvatarGroup.test.ts +142 -0
- package/src/components/Badge.md +164 -0
- package/src/components/Badge.svelte +461 -0
- package/src/components/Badge.test.ts +293 -0
- package/src/components/Button.md +312 -0
- package/src/components/Button.svelte +796 -0
- package/src/components/Button.test.ts +631 -0
- package/src/components/Checkbox.md +313 -0
- package/src/components/Checkbox.svelte +466 -0
- package/src/components/Checkbox.test.ts +57 -0
- package/src/components/CodeBlock.md +240 -0
- package/src/components/CodeBlock.svelte +1287 -0
- package/src/components/CodeBlock.test.ts +192 -0
- package/src/components/Form.md +33 -0
- package/src/components/Form.test.ts +307 -0
- package/src/components/Frame.svelte +220 -0
- package/src/components/Icon.md +279 -0
- package/src/components/Icon.svelte +505 -0
- package/src/components/Icon.test.ts +82 -0
- package/src/components/Image.md +292 -0
- package/src/components/Image.svelte +634 -0
- package/src/components/Image.test.ts +42 -0
- package/src/components/ImageGroup.md +168 -0
- package/src/components/ImageGroup.svelte +151 -0
- package/src/components/ImageGroup.test.ts +46 -0
- package/src/components/InView.test.ts +55 -0
- package/src/components/Input.md +666 -0
- package/src/components/Input.svelte +2741 -0
- package/src/components/Input.test.ts +503 -0
- package/src/components/Kbd.md +100 -0
- package/src/components/Kbd.svelte +110 -0
- package/src/components/Kbd.test.ts +50 -0
- package/src/components/Listbox.md +245 -0
- package/src/components/Listbox.svelte +389 -0
- package/src/components/Listbox.test.ts +139 -0
- package/src/components/MenuItem.md +184 -0
- package/src/components/MenuItem.svelte +326 -0
- package/src/components/MenuItem.test.ts +167 -0
- package/src/components/Morph.test.ts +53 -0
- package/src/components/Popover.md +87 -0
- package/src/components/Popover.svelte +186 -0
- package/src/components/Popover.test.ts +60 -0
- package/src/components/QuickAction.md +146 -0
- package/src/components/QuickAction.svelte +161 -0
- package/src/components/QuickAction.test.ts +299 -0
- package/src/components/Radio.md +318 -0
- package/src/components/Radio.svelte +502 -0
- package/src/components/Radio.test.ts +76 -0
- package/src/components/Select.md +492 -0
- package/src/components/Select.svelte +535 -0
- package/src/components/Select.test.ts +146 -0
- package/src/components/Skeleton.md +323 -0
- package/src/components/Skeleton.svelte +791 -0
- package/src/components/Skeleton.test.ts +121 -0
- package/src/components/Spinner.md +136 -0
- package/src/components/Spinner.svelte +296 -0
- package/src/components/Spinner.test.ts +88 -0
- package/src/components/SplitText.test.ts +142 -0
- package/src/components/Stagger.test.ts +57 -0
- package/src/components/Test.md +72 -0
- package/src/components/Test.svelte +106 -0
- package/src/components/Test.test.ts +27 -0
- package/src/components/Text.md +450 -0
- package/src/components/Text.svelte +507 -0
- package/src/components/Text.test.ts +150 -0
- package/src/components/Textarea.md +240 -0
- package/src/components/Textarea.svelte +742 -0
- package/src/components/Textarea.test.ts +131 -0
- package/src/components/Toggle.md +196 -0
- package/src/components/Toggle.svelte +384 -0
- package/src/components/Toggle.test.ts +57 -0
- package/src/components/Tooltip.md +164 -0
- package/src/components/Tooltip.svelte +417 -0
- package/src/components/Tooltip.test.ts +64 -0
- package/src/context.ts +312 -0
- package/src/dev.ts +10 -0
- package/src/index.ts +29 -0
- package/src/keys.ts +26 -0
- package/src/lib/search-filter.md +82 -0
- package/src/lib/search-filter.ts +57 -0
- package/src/lib/truncate.md +25 -0
- package/src/lib/truncate.ts +234 -0
- package/src/logic/README.md +146 -0
- package/src/logic/collapse.svelte.ts +6 -0
- package/src/logic/frame-dom-runtime.md +19 -0
- package/src/logic/frame-dom-runtime.svelte.ts +286 -0
- package/src/logic/frame-field-control.md +38 -0
- package/src/logic/frame-field-control.ts +95 -0
- package/src/logic/frame-identity.md +68 -0
- package/src/logic/frame-identity.svelte.ts +25 -0
- package/src/logic/frame-layout.md +91 -0
- package/src/logic/frame-layout.svelte.ts +111 -0
- package/src/logic/frame-motion-defaults.md +180 -0
- package/src/logic/frame-motion-defaults.ts +711 -0
- package/src/logic/frame-profile.md +156 -0
- package/src/logic/frame-profile.ts +130 -0
- package/src/logic/frame-prop-filter.md +34 -0
- package/src/logic/frame-prop-filter.ts +254 -0
- package/src/logic/frame-responsive.md +91 -0
- package/src/logic/frame-responsive.svelte.ts +92 -0
- package/src/logic/frame-skeleton-runtime.md +20 -0
- package/src/logic/frame-skeleton-runtime.svelte.ts +160 -0
- package/src/logic/frame-truncation.md +127 -0
- package/src/logic/frame-truncation.svelte.ts +193 -0
- package/src/logic/frame-types.md +157 -0
- package/src/logic/frame-types.ts +434 -0
- package/src/logic/frame-utils.md +22 -0
- package/src/logic/frame-utils.ts +250 -0
- package/src/logic/geometry-cache.ts +120 -0
- package/src/logic/image-preview.md +24 -0
- package/src/logic/image-preview.ts +186 -0
- package/src/logic/layout-flip.ts +109 -0
- package/src/logic/motion-config.ts +102 -0
- package/src/logic/motion-types.md +47 -0
- package/src/logic/motion-types.ts +119 -0
- package/src/logic/observer.md +20 -0
- package/src/logic/observer.svelte.ts +53 -0
- package/src/logic/responsive.md +64 -0
- package/src/logic/responsive.svelte.ts +118 -0
- package/src/logic/text-collapse.md +22 -0
- package/src/logic/text-collapse.svelte.ts +507 -0
- package/src/logic/wc-adapter.ts +188 -0
- package/src/motion/NumberFlow.md +16 -0
- package/src/motion/README.md +87 -0
- package/src/motion/defaults/bridge.md +53 -0
- package/src/motion/defaults/bridge.ts +171 -0
- package/src/motion/defaults/content-crossfade.ts +22 -0
- package/src/motion/defaults/expand.md +66 -0
- package/src/motion/defaults/expand.ts +22 -0
- package/src/motion/defaults/fade-out.md +41 -0
- package/src/motion/defaults/fade-out.ts +14 -0
- package/src/motion/defaults/morph.md +42 -0
- package/src/motion/defaults/morph.ts +14 -0
- package/src/motion/defaults/move.md +81 -0
- package/src/motion/defaults/move.ts +31 -0
- package/src/motion/defaults/number.md +41 -0
- package/src/motion/defaults/number.ts +17 -0
- package/src/motion/defaults/replace.md +56 -0
- package/src/motion/defaults/replace.ts +22 -0
- package/src/motion/defaults/rotate.css +15 -0
- package/src/motion/defaults/rotate.md +60 -0
- package/src/motion/defaults/rotate.ts +20 -0
- package/src/motion/defaults/while-2xl.ts +9 -0
- package/src/motion/defaults/while-active.ts +12 -0
- package/src/motion/defaults/while-appear.ts +12 -0
- package/src/motion/defaults/while-click.ts +9 -0
- package/src/motion/defaults/while-collapsed.ts +12 -0
- package/src/motion/defaults/while-disabled.ts +13 -0
- package/src/motion/defaults/while-disappear.ts +12 -0
- package/src/motion/defaults/while-drag.ts +9 -0
- package/src/motion/defaults/while-editing.ts +9 -0
- package/src/motion/defaults/while-expanded.ts +12 -0
- package/src/motion/defaults/while-focus.ts +9 -0
- package/src/motion/defaults/while-hover.ts +13 -0
- package/src/motion/defaults/while-idle.ts +9 -0
- package/src/motion/defaults/while-key.ts +9 -0
- package/src/motion/defaults/while-lg.ts +9 -0
- package/src/motion/defaults/while-load.ts +11 -0
- package/src/motion/defaults/while-md.ts +9 -0
- package/src/motion/defaults/while-reload.ts +12 -0
- package/src/motion/defaults/while-scroll.ts +9 -0
- package/src/motion/defaults/while-sm.ts +9 -0
- package/src/motion/defaults/while-uploading.ts +9 -0
- package/src/motion/defaults/while-validating.ts +9 -0
- package/src/motion/defaults/while-xl.ts +9 -0
- package/src/motion/defaults/while-xs.ts +9 -0
- package/src/styles/README.md +95 -0
- package/src/styles/auto-layout.css +111 -0
- package/src/styles/index.css +7 -0
- package/src/styles/layout.css +319 -0
- package/src/styles/scale.css +106 -0
- package/src/styles/scale.md +218 -0
- package/src/styles/scrollbar.css +173 -0
- package/src/styles/tokens.css +192 -0
- package/src/vite-env.d.ts +9 -0
- package/src//344/273/243/347/240/201.txt +61 -0
|
@@ -0,0 +1,796 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Button 组件:基础交互按钮
|
|
3
|
+
v1.4.4
|
|
4
|
+
|
|
5
|
+
变更记录 (2026-03-16):
|
|
6
|
+
- 移除 `control="date-picker"` 行为协议;日期触发器回归 `as="trailing"` 组合规则,复杂结构仅在 `Field` 直系或 `row` 容器内识别
|
|
7
|
+
|
|
8
|
+
变更记录 (2026-03-15):
|
|
9
|
+
- 修复 `as` 角色透传:Button 现在把 `as` 透传给 Frame 角色类,支持 `as="trailing"` 参与 Field 组合协议
|
|
10
|
+
- 为单图标 `iconButton` 增加最小 `16x16` 的透明点击热区;通过绝对定位伪元素扩展命中区域,不使用 padding 改变可见布局
|
|
11
|
+
- 调整 `iconButton` 行为优先级:忽略 `variant` 视觉;未显式传尺寸时,图标回退到当前 `size` 档位的常规图标尺寸(`sm/md/lg -> 12/16/20`)
|
|
12
|
+
- `iconButton` 仅在“存在图标”时接管图标尺寸,仅在“单图标内容”时接管方形外壳尺寸;无图标内容时只保留透明度与 hover 透明度规则
|
|
13
|
+
- 新增 `iconButton` 图标按钮模式:支持复用 Icon 尺寸梯度(12/16/20/24/28/32/40/48/80),默认透明度 40%,hover 提升到 100%
|
|
14
|
+
- `iconButton` 模式关闭 Surface 默认 hover 背景叠加,并让骨架提示与宽高跟随 Icon 尺寸梯度
|
|
15
|
+
|
|
16
|
+
变更记录 (2026-03-10):
|
|
17
|
+
- 新增 Image / ImageViewer 宿主角色接入,支持 as="badge" / "icon" / "prev" / "next" / "close"
|
|
18
|
+
|
|
19
|
+
变更记录 (2026-03-03):
|
|
20
|
+
- 尺寸默认值改为“可覆盖”模式:移除 sm/md/lg 默认最小宽高约束,外部 class/style/父容器可直接接管尺寸
|
|
21
|
+
|
|
22
|
+
变更记录 (2026-02-25):
|
|
23
|
+
- 新增 Resource Icon 尺寸上下文注入:`<Button><ArrowLineDown2 /></Button>` 直放资源图标时,默认尺寸跟随按钮档位(sm/md/lg => 16/20/24),与 `<Icon>` 包裹行为一致
|
|
24
|
+
- `as="more"` 角色识别改为仅基于 as 值,不再依赖 TextContext 是否存在,确保在 Text 内容中声明即获得 more 按钮定位样式
|
|
25
|
+
- 保留点击时的 Text 展开联动:存在 TextContext 时触发 `handleExpand`
|
|
26
|
+
- 调整 `as="more"` 渲染策略:不再按 `isCollapsed` 条件隐藏,是否显示由 Text 内容是否声明 `<Button as="more">` 决定
|
|
27
|
+
- 保留与 Text 的联动点击行为(`handleExpand`)
|
|
28
|
+
|
|
29
|
+
变更记录 (2026-02-23):
|
|
30
|
+
- 移除 Button 内置文本截断能力(buttonLines + truncate action)
|
|
31
|
+
- 截断统一交由 Text 组件承载,Button 聚焦交互与布局能力
|
|
32
|
+
|
|
33
|
+
变更记录 (2026-02-18):
|
|
34
|
+
- 新增变量桥接链:按钮核心视觉属性改为 override -> internal -> token 三层变量链
|
|
35
|
+
- 变体与状态改为通过桥接变量驱动,保留现有选择器结构与优先级行为
|
|
36
|
+
- link/outline hover 改为更新桥接变量,保留禁用态排除规则
|
|
37
|
+
|
|
38
|
+
变更记录 (2026-02-18):
|
|
39
|
+
- 移除 sm/md/lg 的最小宽高限制(min-width/min-height)
|
|
40
|
+
- 精简尺寸样式写法:减少中间变量,按档位直接声明核心属性
|
|
41
|
+
- 对齐 Figma 尺寸规范:sm/md/lg 的 icon-size、padding、gap、radius
|
|
42
|
+
- 字号与行高改为强配对:sm=12/16, md=14/20, lg=16/24
|
|
43
|
+
- 单图标按钮(icon-only)padding 按档位统一为 4/8/12
|
|
44
|
+
|
|
45
|
+
变更记录 (2026-02-07):
|
|
46
|
+
- 修复 icon+text 被误判为 icon-only 的问题(改为运行时精确检测文本节点)
|
|
47
|
+
- icon-only padding 规则由 :has 选择器改为 .snowui-button-icon-only 类触发
|
|
48
|
+
|
|
49
|
+
变更记录 (2026-02-07):
|
|
50
|
+
- 修复 Icon 组件尺寸未与 Button 档位联动的问题(通过 Frame Size Context 传递 16/20/24)
|
|
51
|
+
- 修复 icon-only 选择器未命中 Icon 根节点的问题(补充 .snowui-icon-wrapper)
|
|
52
|
+
- 修正 link 变体最小高度重置
|
|
53
|
+
|
|
54
|
+
变更记录 (2026-02-07):
|
|
55
|
+
- 调整 sm/md/lg 最小宽高(28/40/56)
|
|
56
|
+
- 调整 sm 常规 padding 为 12x4
|
|
57
|
+
- 增加单图标按钮(icon-only)在 sm/md/lg 的独立 padding(4/8/12)
|
|
58
|
+
- 补齐图标容器(.snowui-icon)尺寸与按钮档位联动
|
|
59
|
+
|
|
60
|
+
变更记录 (2026-02-03):
|
|
61
|
+
- 按钮样式迁移到外部样式文件
|
|
62
|
+
- 补齐 Frame 能力开关显式传参
|
|
63
|
+
|
|
64
|
+
变更记录 (2026-02-26):
|
|
65
|
+
- 子内容透传 Frame 状态:Button 的 children snippet 现在接收 Frame 提供的状态对象(含 currentState)
|
|
66
|
+
- 便于在 Button 示例中使用纯声明式状态链实现文本切换,无需手动 DOM 操作
|
|
67
|
+
|
|
68
|
+
变更记录 (2026-02-26):
|
|
69
|
+
- 移除 stateText 特化能力,统一回归 Frame 的通用状态变量机制(stateVars/stateClass/stateStyle)
|
|
70
|
+
|
|
71
|
+
1. 核心能力 (Capabilities):
|
|
72
|
+
- 继承 Frame 组件的所有通用能力 (交互、动效、响应式等)
|
|
73
|
+
- 多态渲染: 支持渲染为 button 或 a 标签 (通过 Frame 的 as 属性)
|
|
74
|
+
- 角色化组合: 支持 `as="more"` (需配合 Text 组件)
|
|
75
|
+
- 样式扩展: 仅负责 Button 特有的样式定义
|
|
76
|
+
|
|
77
|
+
2. 交互集成 (Interaction):
|
|
78
|
+
- 逻辑委托给 Frame 组件
|
|
79
|
+
- 内部仅处理 Button 特有的内容布局 (Grid Stacking)
|
|
80
|
+
|
|
81
|
+
3. 布局稳定性 (Layout Stability):
|
|
82
|
+
- 使用 Grid Stacking 确保状态切换时尺寸不跳动
|
|
83
|
+
-->
|
|
84
|
+
|
|
85
|
+
<script lang="ts">
|
|
86
|
+
import { onDestroy, setContext, type Snippet } from "svelte";
|
|
87
|
+
import { RESOURCE_ICON_CONTEXT_KEY } from "@snowui-design-system/resource-svelte";
|
|
88
|
+
import Frame, { type FrameProps } from "./Frame.svelte";
|
|
89
|
+
import { getImage, getImageViewer, getText, getSize } from "../context";
|
|
90
|
+
|
|
91
|
+
type ButtonIconButtonSize = 12 | 16 | 20 | 24 | 28 | 32 | 40 | 48 | 80;
|
|
92
|
+
|
|
93
|
+
interface Props extends Omit<FrameProps, "size"> {
|
|
94
|
+
variant?: "gray" | "filled" | "outline" | "borderless" | "link";
|
|
95
|
+
size?: "sm" | "md" | "lg";
|
|
96
|
+
iconButton?: boolean | ButtonIconButtonSize;
|
|
97
|
+
holdRepeat?: boolean;
|
|
98
|
+
holdRepeatDelay?: number;
|
|
99
|
+
holdRepeatInterval?: number;
|
|
100
|
+
children?: Snippet;
|
|
101
|
+
[key: string]: any;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
let {
|
|
105
|
+
variant = "gray",
|
|
106
|
+
size = "sm",
|
|
107
|
+
iconButton = false,
|
|
108
|
+
href = undefined,
|
|
109
|
+
target = undefined,
|
|
110
|
+
rel = undefined,
|
|
111
|
+
disabled = false,
|
|
112
|
+
holdRepeat = false,
|
|
113
|
+
holdRepeatDelay = 260,
|
|
114
|
+
holdRepeatInterval = 80,
|
|
115
|
+
onclick: userOnClick,
|
|
116
|
+
onpointerdown: userOnPointerDown,
|
|
117
|
+
onpointerup: userOnPointerUp,
|
|
118
|
+
onpointerleave: userOnPointerLeave,
|
|
119
|
+
onpointercancel: userOnPointerCancel,
|
|
120
|
+
style: userStyle = "",
|
|
121
|
+
class: className = "",
|
|
122
|
+
renderHints: userRenderHints = undefined,
|
|
123
|
+
as = undefined,
|
|
124
|
+
children,
|
|
125
|
+
...rest // Pass everything else to Frame
|
|
126
|
+
}: Props = $props();
|
|
127
|
+
|
|
128
|
+
// 上下文感知
|
|
129
|
+
const contextSize = getSize();
|
|
130
|
+
// 计算最终尺寸:优先使用 prop size,其次映射上下文尺寸
|
|
131
|
+
const resolvedSize = $derived.by(() => {
|
|
132
|
+
if (size) return size;
|
|
133
|
+
if (contextSize === undefined) return "sm";
|
|
134
|
+
if (typeof contextSize === "number") {
|
|
135
|
+
if (contextSize <= 16) return "sm";
|
|
136
|
+
if (contextSize <= 28) return "md";
|
|
137
|
+
return "lg";
|
|
138
|
+
}
|
|
139
|
+
return "sm";
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
// 响应式的单个图标状态
|
|
143
|
+
let isIconOnly = $state(false);
|
|
144
|
+
let hasIcon = $state(false);
|
|
145
|
+
let buttonElement = $state<HTMLElement | undefined>(undefined);
|
|
146
|
+
|
|
147
|
+
const iconButtonTokenMap: Record<ButtonIconButtonSize, string> = {
|
|
148
|
+
12: "var(--size-3)",
|
|
149
|
+
16: "var(--size-4)",
|
|
150
|
+
20: "var(--size-5)",
|
|
151
|
+
24: "var(--size-6)",
|
|
152
|
+
28: "var(--size-7)",
|
|
153
|
+
32: "var(--size-8)",
|
|
154
|
+
40: "var(--size-10)",
|
|
155
|
+
48: "var(--size-12)",
|
|
156
|
+
80: "var(--size-20)",
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
const defaultButtonIconSize = $derived.by(() => {
|
|
160
|
+
if (resolvedSize === "lg") return 20;
|
|
161
|
+
if (resolvedSize === "md") return 16;
|
|
162
|
+
return 12;
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
const iconButtonIconSize = $derived.by(() => {
|
|
166
|
+
if (!iconButton || !hasIcon) return undefined;
|
|
167
|
+
if (typeof iconButton === "number") return iconButton;
|
|
168
|
+
return defaultButtonIconSize;
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
// 传递给 Frame Context 的尺寸(供 Icon/Avatar 等子组件继承)
|
|
172
|
+
const contextPixelSize = $derived.by(() => {
|
|
173
|
+
if (iconButtonIconSize !== undefined) return iconButtonIconSize;
|
|
174
|
+
if (isIconOnly) {
|
|
175
|
+
if (resolvedSize === "lg") return 24;
|
|
176
|
+
if (resolvedSize === "md") return 20;
|
|
177
|
+
return 16;
|
|
178
|
+
} else {
|
|
179
|
+
if (resolvedSize === "lg") return 20;
|
|
180
|
+
if (resolvedSize === "md") return 16;
|
|
181
|
+
return 12;
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
const buttonRenderHints = $derived.by(() => {
|
|
185
|
+
if (iconButtonIconSize !== undefined && isIconOnly) {
|
|
186
|
+
const iconSizeToken = iconButtonTokenMap[iconButtonIconSize];
|
|
187
|
+
return {
|
|
188
|
+
variant: userRenderHints?.variant ?? "circle",
|
|
189
|
+
width: userRenderHints?.width ?? iconSizeToken,
|
|
190
|
+
height: userRenderHints?.height ?? iconSizeToken,
|
|
191
|
+
radius: userRenderHints?.radius ?? "var(--radius-full)",
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
const base =
|
|
195
|
+
resolvedSize === "lg"
|
|
196
|
+
? {
|
|
197
|
+
variant: "line",
|
|
198
|
+
width: "7rem",
|
|
199
|
+
height: "3rem",
|
|
200
|
+
radius: "var(--radius-5)",
|
|
201
|
+
}
|
|
202
|
+
: resolvedSize === "md"
|
|
203
|
+
? {
|
|
204
|
+
variant: "line",
|
|
205
|
+
width: "6rem",
|
|
206
|
+
height: "2.25rem",
|
|
207
|
+
radius: "var(--radius-4)",
|
|
208
|
+
}
|
|
209
|
+
: {
|
|
210
|
+
variant: "line",
|
|
211
|
+
width: "5rem",
|
|
212
|
+
height: "1.5rem",
|
|
213
|
+
radius: "var(--radius-3)",
|
|
214
|
+
};
|
|
215
|
+
return {
|
|
216
|
+
variant: userRenderHints?.variant ?? base.variant,
|
|
217
|
+
width: userRenderHints?.width ?? base.width,
|
|
218
|
+
height: userRenderHints?.height ?? base.height,
|
|
219
|
+
radius: userRenderHints?.radius ?? base.radius,
|
|
220
|
+
};
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
// 资源图标直接放在 Button 内时,注入默认尺寸上下文(与 <Icon> 包裹一致)
|
|
224
|
+
setContext(RESOURCE_ICON_CONTEXT_KEY, {
|
|
225
|
+
get size() {
|
|
226
|
+
return contextPixelSize;
|
|
227
|
+
},
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
// 上下文感知 (用于 as="more" 逻辑)
|
|
231
|
+
const textCtx = getText();
|
|
232
|
+
const imageCtx = getImage();
|
|
233
|
+
const imageViewerCtx = getImageViewer();
|
|
234
|
+
|
|
235
|
+
// 角色化逻辑:as="more" 即作为 Text 展开按钮样式角色。
|
|
236
|
+
// 是否存在 TextContext 仅影响点击联动,不影响按钮本身渲染与定位样式。
|
|
237
|
+
const isExpandButton = $derived(as === "more");
|
|
238
|
+
const hostStyle = $derived.by(() => {
|
|
239
|
+
if (as === "badge" && imageCtx) return imageCtx.badgeStyle || "";
|
|
240
|
+
if (as === "icon" && imageCtx) return imageCtx.iconStyle || "";
|
|
241
|
+
// ImageViewer 角色仅保留显隐控制,布局定位已回归架构代理
|
|
242
|
+
if (imageViewerCtx) {
|
|
243
|
+
if (as === "prev") return imageViewerCtx.prevStyle || "";
|
|
244
|
+
if (as === "next") return imageViewerCtx.nextStyle || "";
|
|
245
|
+
if (as === "close") return imageViewerCtx.closeStyle || "";
|
|
246
|
+
}
|
|
247
|
+
return "";
|
|
248
|
+
});
|
|
249
|
+
const buttonStyle = $derived.by(() => {
|
|
250
|
+
const iconButtonStyle =
|
|
251
|
+
iconButtonIconSize !== undefined && isIconOnly
|
|
252
|
+
? `--snowui-button-icon-button-size: ${iconButtonTokenMap[iconButtonIconSize]};`
|
|
253
|
+
: "";
|
|
254
|
+
const styles = [hostStyle, iconButtonStyle, userStyle]
|
|
255
|
+
.filter(Boolean)
|
|
256
|
+
.join("; ");
|
|
257
|
+
return styles || undefined;
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
// 计算最终的标签
|
|
261
|
+
let tag = $derived(href ? "a" : "button");
|
|
262
|
+
|
|
263
|
+
let holdStartTimer = $state<ReturnType<typeof setTimeout> | null>(null);
|
|
264
|
+
let holdRepeatTimer = $state<ReturnType<typeof setInterval> | null>(null);
|
|
265
|
+
let holdNativeClickSuppressed = $state(false);
|
|
266
|
+
let holdSuppressResetTimer = $state<ReturnType<typeof setTimeout> | null>(
|
|
267
|
+
null,
|
|
268
|
+
);
|
|
269
|
+
|
|
270
|
+
function clearHoldTimers() {
|
|
271
|
+
if (holdStartTimer) {
|
|
272
|
+
clearTimeout(holdStartTimer);
|
|
273
|
+
holdStartTimer = null;
|
|
274
|
+
}
|
|
275
|
+
if (holdRepeatTimer) {
|
|
276
|
+
clearInterval(holdRepeatTimer);
|
|
277
|
+
holdRepeatTimer = null;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
function clearHoldSuppressResetTimer() {
|
|
282
|
+
if (holdSuppressResetTimer) {
|
|
283
|
+
clearTimeout(holdSuppressResetTimer);
|
|
284
|
+
holdSuppressResetTimer = null;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
function findDirectTemporalHost(scope: HTMLElement | null): HTMLElement | null {
|
|
289
|
+
if (!scope) return null;
|
|
290
|
+
const candidates = Array.from(scope.children).filter(
|
|
291
|
+
(child): child is HTMLElement =>
|
|
292
|
+
child instanceof HTMLElement &&
|
|
293
|
+
child.matches(".snowui-input[data-temporal-input='true']"),
|
|
294
|
+
);
|
|
295
|
+
if (candidates.length !== 1) return null;
|
|
296
|
+
return candidates[0];
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
function resolveDateTriggerBinding(node: HTMLElement) {
|
|
300
|
+
if (as !== "trailing") return null;
|
|
301
|
+
|
|
302
|
+
const fieldRoot =
|
|
303
|
+
node.closest(".snowui-field") instanceof HTMLElement
|
|
304
|
+
? (node.closest(".snowui-field") as HTMLElement)
|
|
305
|
+
: null;
|
|
306
|
+
|
|
307
|
+
let scope = node.parentElement;
|
|
308
|
+
while (scope) {
|
|
309
|
+
const host = findDirectTemporalHost(scope);
|
|
310
|
+
if (host) {
|
|
311
|
+
const input = host.querySelector(".snowui-input-control-native");
|
|
312
|
+
if (input instanceof HTMLInputElement) {
|
|
313
|
+
return { host, input };
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
if (scope === fieldRoot) break;
|
|
317
|
+
scope = scope.parentElement;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
return null;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
function tryOpenDatePicker(
|
|
324
|
+
node: HTMLElement | undefined,
|
|
325
|
+
event?: MouseEvent,
|
|
326
|
+
) {
|
|
327
|
+
if (!node || disabled) return false;
|
|
328
|
+
|
|
329
|
+
const binding = resolveDateTriggerBinding(node);
|
|
330
|
+
if (!binding) return false;
|
|
331
|
+
|
|
332
|
+
event?.preventDefault();
|
|
333
|
+
|
|
334
|
+
const input = binding.input as HTMLInputElement & {
|
|
335
|
+
showPicker?: () => void;
|
|
336
|
+
};
|
|
337
|
+
|
|
338
|
+
// 某些浏览器(Safari / 旧版 Chrome)对 opacity:0 的元素拒绝 showPicker / click(),
|
|
339
|
+
// 临时覆盖 opacity 为极小非零值,完成调用后立即还原。
|
|
340
|
+
input.style.setProperty("opacity", "0.001", "important");
|
|
341
|
+
let opened = false;
|
|
342
|
+
try {
|
|
343
|
+
if (typeof input.showPicker === "function") {
|
|
344
|
+
input.showPicker();
|
|
345
|
+
} else {
|
|
346
|
+
input.click();
|
|
347
|
+
}
|
|
348
|
+
opened = true;
|
|
349
|
+
} catch {
|
|
350
|
+
try {
|
|
351
|
+
input.click();
|
|
352
|
+
opened = true;
|
|
353
|
+
} catch {
|
|
354
|
+
// ignore
|
|
355
|
+
}
|
|
356
|
+
} finally {
|
|
357
|
+
input.style.removeProperty("opacity");
|
|
358
|
+
}
|
|
359
|
+
return opened;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
function dispatchRepeatClick(target: EventTarget | null) {
|
|
363
|
+
if (!(target instanceof HTMLElement)) return;
|
|
364
|
+
target.dispatchEvent(
|
|
365
|
+
new MouseEvent("click", {
|
|
366
|
+
bubbles: true,
|
|
367
|
+
cancelable: true,
|
|
368
|
+
composed: true,
|
|
369
|
+
}),
|
|
370
|
+
);
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
// 处理点击 (Button 特有逻辑: 展开)
|
|
374
|
+
function handleClick(event?: MouseEvent) {
|
|
375
|
+
// holdRepeat 模式下,按下已主动触发 click,这里丢弃随后浏览器的原生 trusted click,避免重复计算
|
|
376
|
+
if (holdRepeat && holdNativeClickSuppressed && event?.isTrusted) {
|
|
377
|
+
holdNativeClickSuppressed = false;
|
|
378
|
+
clearHoldSuppressResetTimer();
|
|
379
|
+
return;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
if (isExpandButton && textCtx) {
|
|
383
|
+
textCtx.handleExpand();
|
|
384
|
+
}
|
|
385
|
+
userOnClick?.(event);
|
|
386
|
+
if (event?.defaultPrevented || userOnClick) return;
|
|
387
|
+
const triggerNode =
|
|
388
|
+
event?.currentTarget instanceof HTMLElement
|
|
389
|
+
? event.currentTarget
|
|
390
|
+
: buttonElement;
|
|
391
|
+
if (tryOpenDatePicker(triggerNode, event)) return;
|
|
392
|
+
if (as === "prev") {
|
|
393
|
+
imageViewerCtx?.showPrev?.();
|
|
394
|
+
return;
|
|
395
|
+
}
|
|
396
|
+
if (as === "next") {
|
|
397
|
+
imageViewerCtx?.showNext?.();
|
|
398
|
+
return;
|
|
399
|
+
}
|
|
400
|
+
if (as === "close") {
|
|
401
|
+
imageViewerCtx?.close?.();
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
function handlePointerDown(event: PointerEvent) {
|
|
406
|
+
userOnPointerDown?.(event);
|
|
407
|
+
if (!holdRepeat) return;
|
|
408
|
+
if (disabled) return;
|
|
409
|
+
if (tag !== "button") return;
|
|
410
|
+
if (event.button !== 0) return;
|
|
411
|
+
|
|
412
|
+
event.preventDefault();
|
|
413
|
+
clearHoldTimers();
|
|
414
|
+
clearHoldSuppressResetTimer();
|
|
415
|
+
holdNativeClickSuppressed = true;
|
|
416
|
+
|
|
417
|
+
const target = event.currentTarget;
|
|
418
|
+
dispatchRepeatClick(target);
|
|
419
|
+
|
|
420
|
+
holdStartTimer = setTimeout(
|
|
421
|
+
() => {
|
|
422
|
+
holdRepeatTimer = setInterval(
|
|
423
|
+
() => {
|
|
424
|
+
dispatchRepeatClick(target);
|
|
425
|
+
},
|
|
426
|
+
Math.max(1, holdRepeatInterval),
|
|
427
|
+
);
|
|
428
|
+
},
|
|
429
|
+
Math.max(0, holdRepeatDelay),
|
|
430
|
+
);
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
function handlePointerUp(event: PointerEvent) {
|
|
434
|
+
userOnPointerUp?.(event);
|
|
435
|
+
clearHoldTimers();
|
|
436
|
+
if (!holdRepeat || !holdNativeClickSuppressed) return;
|
|
437
|
+
clearHoldSuppressResetTimer();
|
|
438
|
+
holdSuppressResetTimer = setTimeout(() => {
|
|
439
|
+
holdNativeClickSuppressed = false;
|
|
440
|
+
holdSuppressResetTimer = null;
|
|
441
|
+
}, 40);
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
function handlePointerLeave(event: PointerEvent) {
|
|
445
|
+
userOnPointerLeave?.(event);
|
|
446
|
+
clearHoldTimers();
|
|
447
|
+
if (!holdRepeat || !holdNativeClickSuppressed) return;
|
|
448
|
+
clearHoldSuppressResetTimer();
|
|
449
|
+
holdSuppressResetTimer = setTimeout(() => {
|
|
450
|
+
holdNativeClickSuppressed = false;
|
|
451
|
+
holdSuppressResetTimer = null;
|
|
452
|
+
}, 40);
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
function handlePointerCancel(event: PointerEvent) {
|
|
456
|
+
userOnPointerCancel?.(event);
|
|
457
|
+
clearHoldTimers();
|
|
458
|
+
holdNativeClickSuppressed = false;
|
|
459
|
+
clearHoldSuppressResetTimer();
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
// 精确识别“仅 1 个图标且无文本节点”的场景,避免 icon + text 误判
|
|
463
|
+
function detectIconOnly(node: HTMLElement) {
|
|
464
|
+
const iconSelector =
|
|
465
|
+
".snowui-icon-wrapper, .snowui-icon, .snowui-avatar, svg, img";
|
|
466
|
+
|
|
467
|
+
const update = () => {
|
|
468
|
+
const elementChildren = Array.from(node.children);
|
|
469
|
+
const hasAnyIconElement = node.querySelector(iconSelector) !== null;
|
|
470
|
+
const hasSingleIconElement =
|
|
471
|
+
elementChildren.length === 1 &&
|
|
472
|
+
elementChildren[0]?.matches?.(iconSelector);
|
|
473
|
+
const hasTextNode = Array.from(node.childNodes).some(
|
|
474
|
+
(child) =>
|
|
475
|
+
child.nodeType === Node.TEXT_NODE && !!child.textContent?.trim(),
|
|
476
|
+
);
|
|
477
|
+
|
|
478
|
+
node.classList.toggle(
|
|
479
|
+
"snowui-button-icon-only",
|
|
480
|
+
hasSingleIconElement && !hasTextNode,
|
|
481
|
+
);
|
|
482
|
+
hasIcon = hasAnyIconElement;
|
|
483
|
+
isIconOnly = hasSingleIconElement && !hasTextNode;
|
|
484
|
+
};
|
|
485
|
+
|
|
486
|
+
update();
|
|
487
|
+
|
|
488
|
+
const observer = new MutationObserver(update);
|
|
489
|
+
observer.observe(node, {
|
|
490
|
+
childList: true,
|
|
491
|
+
subtree: true,
|
|
492
|
+
characterData: true,
|
|
493
|
+
});
|
|
494
|
+
|
|
495
|
+
return {
|
|
496
|
+
destroy() {
|
|
497
|
+
observer.disconnect();
|
|
498
|
+
},
|
|
499
|
+
};
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
onDestroy(() => {
|
|
503
|
+
clearHoldTimers();
|
|
504
|
+
clearHoldSuppressResetTimer();
|
|
505
|
+
});
|
|
506
|
+
</script>
|
|
507
|
+
|
|
508
|
+
<Frame
|
|
509
|
+
bind:element={buttonElement}
|
|
510
|
+
enableResponsive={false}
|
|
511
|
+
enableContext={true}
|
|
512
|
+
enableScaleObserver={false}
|
|
513
|
+
profile="Surface"
|
|
514
|
+
size={contextPixelSize}
|
|
515
|
+
{tag}
|
|
516
|
+
{as}
|
|
517
|
+
{href}
|
|
518
|
+
{target}
|
|
519
|
+
{rel}
|
|
520
|
+
data-variant={iconButton ? undefined : variant}
|
|
521
|
+
data-leading={as === "leading" ? "true" : undefined}
|
|
522
|
+
data-trailing={as === "trailing" ? "true" : undefined}
|
|
523
|
+
type={tag === "button" ? rest.type || "button" : undefined}
|
|
524
|
+
class={[
|
|
525
|
+
"snowui-button",
|
|
526
|
+
`snowui-button-${variant}`,
|
|
527
|
+
`snowui-button-${resolvedSize}`,
|
|
528
|
+
isExpandButton ? "snowui-text-expand-button" : "",
|
|
529
|
+
as === "badge" ? "snowui-button-role-badge" : "",
|
|
530
|
+
as === "icon" ? "snowui-button-role-icon" : "",
|
|
531
|
+
as === "prev" ? "snowui-button-role-prev" : "",
|
|
532
|
+
as === "next" ? "snowui-button-role-next" : "",
|
|
533
|
+
as === "close" ? "snowui-button-role-close" : "",
|
|
534
|
+
iconButton ? "snowui-button-icon-button" : "",
|
|
535
|
+
iconButton && isIconOnly && iconButtonIconSize !== undefined
|
|
536
|
+
? "snowui-button-icon-button-layout"
|
|
537
|
+
: "",
|
|
538
|
+
className,
|
|
539
|
+
]
|
|
540
|
+
.filter(Boolean)
|
|
541
|
+
.join(" ")}
|
|
542
|
+
style={buttonStyle}
|
|
543
|
+
onclick={handleClick}
|
|
544
|
+
onpointerdown={handlePointerDown}
|
|
545
|
+
onpointerup={handlePointerUp}
|
|
546
|
+
onpointerleave={handlePointerLeave}
|
|
547
|
+
onpointercancel={handlePointerCancel}
|
|
548
|
+
renderHints={buttonRenderHints}
|
|
549
|
+
{...rest}
|
|
550
|
+
use={[detectIconOnly]}
|
|
551
|
+
>
|
|
552
|
+
{#snippet children(frameState)}
|
|
553
|
+
{@render children?.(frameState)}
|
|
554
|
+
{/snippet}
|
|
555
|
+
</Frame>
|
|
556
|
+
|
|
557
|
+
<style>
|
|
558
|
+
/* Button 样式 */
|
|
559
|
+
/* Level 2: Component Base (降权为 0) */
|
|
560
|
+
:global(:where(.snowui-button)) {
|
|
561
|
+
display: inline-flex;
|
|
562
|
+
align-items: center;
|
|
563
|
+
justify-content: center;
|
|
564
|
+
position: relative;
|
|
565
|
+
flex-direction: row;
|
|
566
|
+
transition:
|
|
567
|
+
color var(--snowui-frame-color-motion-duration, 0.15s) var(--snowui-frame-color-motion-easing, ease-out),
|
|
568
|
+
background-color var(--snowui-frame-color-motion-duration, 0.15s) var(--snowui-frame-color-motion-easing, ease-out),
|
|
569
|
+
--snowui-hover-overlay-opacity var(--snowui-frame-color-motion-duration, 0.15s) var(--snowui-frame-color-motion-easing, ease-out),
|
|
570
|
+
border-color var(--snowui-frame-color-motion-duration, 0.15s) var(--snowui-frame-color-motion-easing, ease-out),
|
|
571
|
+
box-shadow var(--snowui-frame-color-motion-duration, 0.15s) var(--snowui-frame-color-motion-easing, ease-out);
|
|
572
|
+
border: none;
|
|
573
|
+
cursor: var(--snowui-state-cursor, pointer);
|
|
574
|
+
outline: none;
|
|
575
|
+
box-sizing: border-box;
|
|
576
|
+
text-decoration: none;
|
|
577
|
+
transform: translate(var(--snowui-drag-x, 0), var(--snowui-drag-y, 0));
|
|
578
|
+
opacity: var(--snowui-button-opacity-override, var(--snowui-button-opacity));
|
|
579
|
+
|
|
580
|
+
/* 内部计算层(internal) */
|
|
581
|
+
--snowui-button-border-width: var(--border-1);
|
|
582
|
+
--snowui-button-padding: var(--padding-1) var(--padding-3);
|
|
583
|
+
--snowui-button-icon-only-padding: var(--padding-1);
|
|
584
|
+
--snowui-button-gap: var(--gap-1);
|
|
585
|
+
--snowui-button-radius: var(--radius-3);
|
|
586
|
+
--snowui-button-font-size: var(--text-12);
|
|
587
|
+
--snowui-button-line-height: var(--leading-12);
|
|
588
|
+
--snowui-button-min-width: 0;
|
|
589
|
+
--snowui-button-min-height: 0;
|
|
590
|
+
--snowui-button-width: auto;
|
|
591
|
+
--snowui-button-height: auto;
|
|
592
|
+
--snowui-button-opacity: var(
|
|
593
|
+
--snowui-state-opacity,
|
|
594
|
+
var(--snowui-parallax-opacity, 1)
|
|
595
|
+
);
|
|
596
|
+
--snowui-button-background: var(
|
|
597
|
+
--black-4,
|
|
598
|
+
color-mix(in srgb, currentColor 4%, transparent)
|
|
599
|
+
);
|
|
600
|
+
--snowui-button-color: currentColor;
|
|
601
|
+
--snowui-button-border-color: transparent;
|
|
602
|
+
|
|
603
|
+
/* 三层桥接(override -> internal) */
|
|
604
|
+
width: var(--snowui-button-width-override, var(--snowui-button-width));
|
|
605
|
+
height: var(--snowui-button-height-override, var(--snowui-button-height));
|
|
606
|
+
min-width: var(
|
|
607
|
+
--snowui-button-min-width-override,
|
|
608
|
+
var(--snowui-button-min-width)
|
|
609
|
+
);
|
|
610
|
+
min-height: var(
|
|
611
|
+
--snowui-button-min-height-override,
|
|
612
|
+
var(--snowui-button-min-height)
|
|
613
|
+
);
|
|
614
|
+
padding: var(
|
|
615
|
+
--snowui-button-padding-override,
|
|
616
|
+
var(--snowui-button-padding)
|
|
617
|
+
);
|
|
618
|
+
gap: var(--snowui-button-gap-override, var(--snowui-button-gap));
|
|
619
|
+
border-radius: var(
|
|
620
|
+
--snowui-button-radius-override,
|
|
621
|
+
var(--snowui-button-radius)
|
|
622
|
+
);
|
|
623
|
+
font-size: var(
|
|
624
|
+
--snowui-button-font-size-override,
|
|
625
|
+
var(--snowui-button-font-size)
|
|
626
|
+
);
|
|
627
|
+
line-height: var(
|
|
628
|
+
--snowui-button-line-height-override,
|
|
629
|
+
var(--snowui-button-line-height)
|
|
630
|
+
);
|
|
631
|
+
background-color: var(
|
|
632
|
+
--snowui-button-background-override,
|
|
633
|
+
var(--snowui-button-background)
|
|
634
|
+
);
|
|
635
|
+
color: var(--snowui-button-color-override, var(--snowui-button-color));
|
|
636
|
+
box-shadow: inset 0 0 0
|
|
637
|
+
var(
|
|
638
|
+
--snowui-button-border-width-override,
|
|
639
|
+
var(--snowui-button-border-width)
|
|
640
|
+
)
|
|
641
|
+
var(
|
|
642
|
+
--snowui-button-border-color-override,
|
|
643
|
+
var(--snowui-button-border-color)
|
|
644
|
+
);
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
:global(:where(.snowui-button) svg),
|
|
648
|
+
:global(:where(.snowui-button) img),
|
|
649
|
+
:global(:where(.snowui-button) .snowui-icon-wrapper) {
|
|
650
|
+
color: inherit;
|
|
651
|
+
fill: currentColor;
|
|
652
|
+
object-fit: cover;
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
/* Sizes (Level 4 - compound selector ensures 0,2,0 specificity) */
|
|
656
|
+
:global(:where(.snowui-button).snowui-button-md) {
|
|
657
|
+
--snowui-button-padding: var(--padding-2) var(--padding-4);
|
|
658
|
+
--snowui-button-icon-only-padding: var(--padding-2);
|
|
659
|
+
--snowui-button-gap: calc((var(--gap-1) + var(--gap-2)) / 2);
|
|
660
|
+
--snowui-button-radius: var(--radius-4);
|
|
661
|
+
--snowui-button-font-size: var(--text-14);
|
|
662
|
+
--snowui-button-line-height: var(--leading-14);
|
|
663
|
+
--snowui-button-min-width: 0;
|
|
664
|
+
--snowui-button-min-height: 0;
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
:global(:where(.snowui-button).snowui-button-lg) {
|
|
668
|
+
--snowui-button-padding: var(--padding-3) var(--padding-5);
|
|
669
|
+
--snowui-button-icon-only-padding: var(--padding-3);
|
|
670
|
+
--snowui-button-gap: var(--gap-2);
|
|
671
|
+
--snowui-button-radius: var(--radius-5);
|
|
672
|
+
--snowui-button-font-size: var(--text-16);
|
|
673
|
+
--snowui-button-line-height: var(--leading-16);
|
|
674
|
+
--snowui-button-min-width: 0;
|
|
675
|
+
--snowui-button-min-height: 0;
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
/* 单图标按钮 (Level 2 Extension) */
|
|
679
|
+
:global(:where(.snowui-button).snowui-button-icon-only) {
|
|
680
|
+
padding: var(
|
|
681
|
+
--snowui-button-icon-only-padding-override,
|
|
682
|
+
var(--snowui-button-icon-only-padding)
|
|
683
|
+
);
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
/* Level 4: Component Variants (标准权重,不使用 :where) */
|
|
687
|
+
:global(:where(.snowui-button)[data-variant="filled"]) {
|
|
688
|
+
--snowui-button-background: var(--primary, #000000);
|
|
689
|
+
--snowui-button-color: var(--static-white-100, #ffffff);
|
|
690
|
+
--snowui-button-border-color: transparent;
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
:global(
|
|
694
|
+
:where(.snowui-button)[data-variant="filled"]:hover:not(.snowui-disabled)
|
|
695
|
+
) {
|
|
696
|
+
--snowui-hover-opacity: 20%;
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
:global(:where(.snowui-button)[data-variant="outline"]) {
|
|
700
|
+
--snowui-button-background: transparent;
|
|
701
|
+
--snowui-button-border-color: var(
|
|
702
|
+
--black-10,
|
|
703
|
+
color-mix(in srgb, currentColor 10%, transparent)
|
|
704
|
+
);
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
/* Outline Hover: 边框加深 (参照 StyleGuide 7.5) */
|
|
708
|
+
:global(
|
|
709
|
+
:where(.snowui-button)[data-variant="outline"]:hover:not(.snowui-disabled)
|
|
710
|
+
) {
|
|
711
|
+
--snowui-button-border-color: var(
|
|
712
|
+
--black-40,
|
|
713
|
+
color-mix(in srgb, currentColor 25%, transparent)
|
|
714
|
+
);
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
:global(:where(.snowui-button)[data-variant="borderless"]) {
|
|
718
|
+
--snowui-button-background: transparent;
|
|
719
|
+
--snowui-button-border-color: transparent;
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
:global(:where(.snowui-button)[data-variant="link"]) {
|
|
723
|
+
--snowui-button-background: transparent;
|
|
724
|
+
--snowui-button-color: var(--secondary-indigo, #adadfbff);
|
|
725
|
+
--snowui-button-border-color: transparent;
|
|
726
|
+
--snowui-button-padding: 0;
|
|
727
|
+
--snowui-button-radius: 0;
|
|
728
|
+
--snowui-button-height: auto;
|
|
729
|
+
--snowui-button-min-height: 0;
|
|
730
|
+
--snowui-button-min-width: 0;
|
|
731
|
+
--snowui-hover-overlay-opacity: 0%;
|
|
732
|
+
background-image: none;
|
|
733
|
+
text-decoration: none;
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
:global(
|
|
737
|
+
:where(.snowui-button)[data-variant="link"]:hover:not(.snowui-disabled)
|
|
738
|
+
) {
|
|
739
|
+
--snowui-button-color: color-mix(
|
|
740
|
+
in srgb,
|
|
741
|
+
var(--secondary-indigo, #adadfbff),
|
|
742
|
+
var(--black-80, #000000cc)
|
|
743
|
+
);
|
|
744
|
+
text-decoration: none;
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
:global(:where(.snowui-button).snowui-button-icon-button) {
|
|
748
|
+
--snowui-button-background: transparent;
|
|
749
|
+
--snowui-button-border-color: transparent;
|
|
750
|
+
--snowui-button-opacity: var(--snowui-state-opacity, 0.4);
|
|
751
|
+
background-image: none;
|
|
752
|
+
transition:
|
|
753
|
+
opacity var(--snowui-frame-color-motion-duration, 0.15s) var(--snowui-frame-color-motion-easing, ease-out);
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
:global(:where(.snowui-button).snowui-button-icon-button-layout) {
|
|
757
|
+
--snowui-button-width: var(
|
|
758
|
+
--snowui-button-icon-button-size,
|
|
759
|
+
var(--size-4)
|
|
760
|
+
);
|
|
761
|
+
--snowui-button-height: var(
|
|
762
|
+
--snowui-button-icon-button-size,
|
|
763
|
+
var(--size-4)
|
|
764
|
+
);
|
|
765
|
+
--snowui-button-min-width: var(
|
|
766
|
+
--snowui-button-icon-button-size,
|
|
767
|
+
var(--size-4)
|
|
768
|
+
);
|
|
769
|
+
--snowui-button-min-height: var(
|
|
770
|
+
--snowui-button-icon-button-size,
|
|
771
|
+
var(--size-4)
|
|
772
|
+
);
|
|
773
|
+
--snowui-button-padding: 0;
|
|
774
|
+
--snowui-button-icon-only-padding: 0;
|
|
775
|
+
--snowui-button-gap: 0;
|
|
776
|
+
--snowui-button-radius: var(--radius-full);
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
:global(:where(.snowui-button).snowui-button-icon-button-layout)::before {
|
|
780
|
+
content: "";
|
|
781
|
+
position: absolute;
|
|
782
|
+
left: 50%;
|
|
783
|
+
top: 50%;
|
|
784
|
+
width: var(--snowui-button-icon-button-hit-size, var(--size-4));
|
|
785
|
+
height: var(--snowui-button-icon-button-hit-size, var(--size-4));
|
|
786
|
+
transform: translate(-50%, -50%);
|
|
787
|
+
background: transparent;
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
:global(
|
|
791
|
+
:where(.snowui-button).snowui-button-icon-button:hover:not(.snowui-disabled):not(:disabled)
|
|
792
|
+
) {
|
|
793
|
+
--snowui-button-opacity: var(--snowui-state-opacity, 1);
|
|
794
|
+
background-image: none;
|
|
795
|
+
}
|
|
796
|
+
</style>
|