@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,503 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Input.test.ts
|
|
3
|
+
* v1.1.0
|
|
4
|
+
* 变更记录 (2026-04-20): 新增 I-39/I-40 覆盖 Input as="search" 在 Listbox 内的过滤与自定义值功能。
|
|
5
|
+
* 变更记录 (2026-03-30): 将 Input-Demo 的 I-00 ~ I-38(保留现存编号)迁入 test 项目,后续输入框与 Figma 的样式比对统一在 test 中进行。
|
|
6
|
+
* 变更记录 (2026-03-29): 删除 `Input type="file"` 示例;该类型不再作为组件支持范围。
|
|
7
|
+
* 变更记录 (2026-03-28): 删除 `Input type="range"` 示例;该类型不再作为组件支持范围。
|
|
8
|
+
* 变更记录 (2026-03-17): temporal 输入统一为 segmented editor,补充 month / week / time / datetime-local 的占位、默认 icon 与 trailing 组合示例。
|
|
9
|
+
* 变更记录 (2026-03-17): 更新日期输入示例,补充当前 segmented date 行为、月日两位显示规则与 trailing 组合示例。
|
|
10
|
+
* 变更记录 (2026-03-16): `text` / `date` 改为自定义编辑层,示例保持 API 不变,继续覆盖默认文本输入与日期输入场景。
|
|
11
|
+
* 变更记录 (2026-03-14): 同步 Input 默认样式更新,Frame 态示例中的默认背景为 Background/3。
|
|
12
|
+
* 变更记录 (2026-03-13): 新增 Input 组件示例,覆盖原生输入属性/事件透传、外部 form 归属与 Frame 通用能力。
|
|
13
|
+
*/
|
|
14
|
+
export const examples = [
|
|
15
|
+
{
|
|
16
|
+
name: "I-00:Figma 颜色输入复刻",
|
|
17
|
+
code: `I-00
|
|
18
|
+
<div class="flex-col gap-8" style="width: 20rem;">
|
|
19
|
+
<Input type="color" value="#007AFF" title="Color picker" />
|
|
20
|
+
<Text class="text-12 text-black-40">默认样式会展示色点与 HEX 值。</Text>
|
|
21
|
+
</div>`,
|
|
22
|
+
logic: ["Color"],
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
name: "I-01:空态占位符",
|
|
26
|
+
code: `I-01
|
|
27
|
+
<Input placeholder="请输入内容" style="width: 20rem;" />`,
|
|
28
|
+
logic: ["Basic"],
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
name: "I-02:默认值展示",
|
|
32
|
+
code: `I-02
|
|
33
|
+
<Input defaultValue="SnowUI" style="width: 20rem;" />`,
|
|
34
|
+
logic: ["Value"],
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
name: "I-03:disabled 禁用态",
|
|
38
|
+
code: `I-03
|
|
39
|
+
<Input disabled placeholder="Disabled" style="width: 20rem;" />`,
|
|
40
|
+
logic: ["Disabled"],
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: "I-04:readonly 只读态",
|
|
44
|
+
code: `I-04
|
|
45
|
+
<Input readonly value="Readonly value" style="width: 20rem;" />`,
|
|
46
|
+
logic: ["Readonly"],
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
name: "I-05:默认文本输入",
|
|
50
|
+
code: `I-05
|
|
51
|
+
<Input placeholder="请输入内容" style="width: 20rem;" />`,
|
|
52
|
+
logic: ["Basic"],
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
name: "I-06:默认外壳样式",
|
|
56
|
+
code: `I-06
|
|
57
|
+
<Input placeholder="请输入内容" style="width: 20rem;" />`,
|
|
58
|
+
logic: ["Basic"],
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
name: "I-07:type=text",
|
|
62
|
+
code: `I-07
|
|
63
|
+
<Input type="text" placeholder="Text" style="width: 20rem;" />`,
|
|
64
|
+
logic: ["Type"],
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
name: "I-08:type=email",
|
|
68
|
+
code: `I-08
|
|
69
|
+
<Input type="email" placeholder="name@example.com" autocomplete="email" style="width: 20rem;" />`,
|
|
70
|
+
logic: ["Type", "Autocomplete"],
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
name: "I-09:type=password",
|
|
74
|
+
code: `I-09
|
|
75
|
+
<Input type="password" placeholder="Password" style="width: 20rem;" />`,
|
|
76
|
+
logic: ["Type"],
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
name: "I-10:type=search",
|
|
80
|
+
code: `I-10
|
|
81
|
+
<Input type="search" placeholder="Search..." value="snowui" style="width: 20rem;" />`,
|
|
82
|
+
logic: ["Type", "Value"],
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
name: "I-11:type=url",
|
|
86
|
+
code: `I-11
|
|
87
|
+
<Input type="url" placeholder="https://snowui.design" style="width: 20rem;" />`,
|
|
88
|
+
logic: ["Type"],
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
name: "I-12:type=tel + inputmode",
|
|
92
|
+
code: `I-12
|
|
93
|
+
<Input type="tel" placeholder="+86 138 0000 0000" inputmode="tel" style="width: 20rem;" />`,
|
|
94
|
+
logic: ["Type", "NativeProps"],
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
name: "I-13:type=number + stepper",
|
|
98
|
+
code: `I-13
|
|
99
|
+
<Input
|
|
100
|
+
type="number"
|
|
101
|
+
placeholder="0"
|
|
102
|
+
min={0}
|
|
103
|
+
max={100}
|
|
104
|
+
step={5}
|
|
105
|
+
defaultValue={20}
|
|
106
|
+
style="width: 20rem;"
|
|
107
|
+
/>`,
|
|
108
|
+
logic: ["Type", "Validation"],
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
name: "I-14:type=date",
|
|
112
|
+
code: `I-14
|
|
113
|
+
<Input type="date" style="width: 20rem;" />`,
|
|
114
|
+
logic: ["Type", "Date"],
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
name: "I-14b:type=date + 外置 Icon",
|
|
118
|
+
code: `I-14b
|
|
119
|
+
<Field style="width: 20rem;">
|
|
120
|
+
<Input type="date" />
|
|
121
|
+
<Button as="trailing" type="button" variant="borderless" iconButton={16} aria-label="打开日期选择器">
|
|
122
|
+
<CalendarBlank />
|
|
123
|
+
</Button>
|
|
124
|
+
</Field>`,
|
|
125
|
+
logic: ["Type", "Date"],
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
name: "I-14c:type=date + 前置外置 Icon",
|
|
129
|
+
code: `I-14c
|
|
130
|
+
<Field style="width: 20rem;">
|
|
131
|
+
<Icon as="leading"><CalendarBlank /></Icon>
|
|
132
|
+
<Input type="date" />
|
|
133
|
+
</Field>`,
|
|
134
|
+
logic: ["Type", "Date"],
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
name: "I-15:type=time",
|
|
138
|
+
code: `I-15
|
|
139
|
+
<Input type="time" style="width: 20rem;" />`,
|
|
140
|
+
logic: ["Type", "Date"],
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
name: "I-15b:type=time + 外置 Icon",
|
|
144
|
+
code: `I-15b
|
|
145
|
+
<Field style="width: 20rem;">
|
|
146
|
+
<Input type="time" />
|
|
147
|
+
<Button as="trailing" type="button" variant="borderless" iconButton={16} aria-label="打开时间选择器">
|
|
148
|
+
<Clock />
|
|
149
|
+
</Button>
|
|
150
|
+
</Field>`,
|
|
151
|
+
logic: ["Type", "Date"],
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
name: "I-15c:type=time + 前置外置 Icon",
|
|
155
|
+
code: `I-15c
|
|
156
|
+
<Field style="width: 20rem;">
|
|
157
|
+
<Icon as="leading"><Clock /></Icon>
|
|
158
|
+
<Input type="time" />
|
|
159
|
+
</Field>`,
|
|
160
|
+
logic: ["Type", "Date"],
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
name: "I-16:type=datetime-local",
|
|
164
|
+
code: `I-16
|
|
165
|
+
<Input type="datetime-local" style="width: 20rem;" />`,
|
|
166
|
+
logic: ["Type", "Date"],
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
name: "I-17:type=month",
|
|
170
|
+
code: `I-17
|
|
171
|
+
<Input type="month" style="width: 20rem;" />`,
|
|
172
|
+
logic: ["Type", "Date"],
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
name: "I-18:type=week",
|
|
176
|
+
code: `I-18
|
|
177
|
+
<Input type="week" style="width: 20rem;" />`,
|
|
178
|
+
logic: ["Type", "Date"],
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
name: "I-19:type=color",
|
|
182
|
+
code: `I-19
|
|
183
|
+
<Input type="color" value="#007AFF" title="Color picker" style="width: 20rem;" />`,
|
|
184
|
+
logic: ["Type", "Color"],
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
name: "I-22:id / title / placeholder",
|
|
188
|
+
code: `I-22
|
|
189
|
+
<div class="flex-col gap-8" style="width: 20rem;">
|
|
190
|
+
<label for="input-demo-profile" class="text-12 text-black-40">id + title + placeholder</label>
|
|
191
|
+
<Input
|
|
192
|
+
id="input-demo-profile"
|
|
193
|
+
placeholder="Profile name"
|
|
194
|
+
title="用于展示 id / title 透传"
|
|
195
|
+
/>
|
|
196
|
+
<Text class="text-12 text-black-40">原生 input 对照</Text>
|
|
197
|
+
<label for="native-input-demo-profile" class="text-12 text-black-40">id + title + placeholder</label>
|
|
198
|
+
<input
|
|
199
|
+
id="native-input-demo-profile"
|
|
200
|
+
placeholder="Profile name"
|
|
201
|
+
title="用于展示 id / title 透传"
|
|
202
|
+
/>
|
|
203
|
+
</div>`,
|
|
204
|
+
logic: ["NativeProps"],
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
name: "I-23:required / minlength / maxlength / pattern",
|
|
208
|
+
code: `I-23
|
|
209
|
+
<div class="flex-col gap-8" style="width: 20rem;">
|
|
210
|
+
<Input
|
|
211
|
+
placeholder="3~12 位字母数字下划线"
|
|
212
|
+
minlength={3}
|
|
213
|
+
maxlength={12}
|
|
214
|
+
pattern="[A-Za-z0-9_]+"
|
|
215
|
+
title="仅允许字母、数字和下划线"
|
|
216
|
+
required
|
|
217
|
+
/>
|
|
218
|
+
<Text class="text-12 text-black-40">原生 input 对照</Text>
|
|
219
|
+
<input
|
|
220
|
+
placeholder="3~12 位字母数字下划线"
|
|
221
|
+
minlength="3"
|
|
222
|
+
maxlength="12"
|
|
223
|
+
pattern="[A-Za-z0-9_]+"
|
|
224
|
+
title="仅允许字母、数字和下划线"
|
|
225
|
+
required
|
|
226
|
+
/>
|
|
227
|
+
</div>`,
|
|
228
|
+
logic: ["Validation", "NativeProps"],
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
name: "I-24:name / autocomplete / enterkeyhint / spellcheck",
|
|
232
|
+
code: `I-24
|
|
233
|
+
<div class="flex-col gap-8" style="width: 20rem;">
|
|
234
|
+
<Input
|
|
235
|
+
placeholder="username"
|
|
236
|
+
name="username"
|
|
237
|
+
autocomplete="username"
|
|
238
|
+
enterkeyhint="next"
|
|
239
|
+
spellcheck={false}
|
|
240
|
+
/>
|
|
241
|
+
<Text class="text-12 text-black-40">原生 input 对照</Text>
|
|
242
|
+
<input
|
|
243
|
+
placeholder="username"
|
|
244
|
+
name="username"
|
|
245
|
+
autocomplete="username"
|
|
246
|
+
enterkeyhint="next"
|
|
247
|
+
spellcheck="false"
|
|
248
|
+
/>
|
|
249
|
+
</div>`,
|
|
250
|
+
logic: ["NativeProps", "Autocomplete"],
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
name: "I-25:list / aria-describedby",
|
|
254
|
+
code: `I-25
|
|
255
|
+
<div class="flex-col gap-8" style="width: 20rem;">
|
|
256
|
+
<Input
|
|
257
|
+
list="input-demo-cities"
|
|
258
|
+
placeholder="datalist 示例"
|
|
259
|
+
aria-describedby="input-demo-city-help"
|
|
260
|
+
/>
|
|
261
|
+
<Text class="text-12 text-black-40">原生 input 对照</Text>
|
|
262
|
+
<input
|
|
263
|
+
list="input-demo-cities"
|
|
264
|
+
placeholder="datalist 示例"
|
|
265
|
+
aria-describedby="input-demo-city-help"
|
|
266
|
+
/>
|
|
267
|
+
<datalist id="input-demo-cities">
|
|
268
|
+
<option value="Shanghai"></option>
|
|
269
|
+
<option value="Hangzhou"></option>
|
|
270
|
+
<option value="Shenzhen"></option>
|
|
271
|
+
</datalist>
|
|
272
|
+
<Text id="input-demo-city-help" class="text-12 text-black-40">
|
|
273
|
+
该输入展示 list / aria-describedby 的透传效果。
|
|
274
|
+
</Text>
|
|
275
|
+
</div>`,
|
|
276
|
+
logic: ["NativeProps", "Accessibility"],
|
|
277
|
+
},
|
|
278
|
+
{
|
|
279
|
+
name: "I-26:aria-invalid 错误 / 错误焦点",
|
|
280
|
+
code: `I-26
|
|
281
|
+
<div class="grid grid-cols-2 gap-12" style="width: 41rem;">
|
|
282
|
+
<div class="flex-col gap-8">
|
|
283
|
+
<Input
|
|
284
|
+
placeholder="仅数字键盘"
|
|
285
|
+
inputmode="numeric"
|
|
286
|
+
aria-invalid="true"
|
|
287
|
+
/>
|
|
288
|
+
<Text class="text-12 text-black-40">错误态</Text>
|
|
289
|
+
</div>
|
|
290
|
+
<div class="flex-col gap-8">
|
|
291
|
+
<Input
|
|
292
|
+
placeholder="仅数字键盘"
|
|
293
|
+
inputmode="numeric"
|
|
294
|
+
aria-invalid="true"
|
|
295
|
+
autofocus
|
|
296
|
+
/>
|
|
297
|
+
<Text class="text-12 text-black-40">错误 focus 态</Text>
|
|
298
|
+
</div>
|
|
299
|
+
</div>`,
|
|
300
|
+
logic: ["NativeProps", "Accessibility"],
|
|
301
|
+
},
|
|
302
|
+
{
|
|
303
|
+
name: "I-27:tabindex=2",
|
|
304
|
+
code: `I-27
|
|
305
|
+
<div class="flex-col gap-8" style="width: 20rem;">
|
|
306
|
+
<Input tabindex={2} placeholder="TabIndex 2" />
|
|
307
|
+
<Text class="text-12 text-black-40">原生 input 对照</Text>
|
|
308
|
+
<input tabindex="2" placeholder="TabIndex 2" />
|
|
309
|
+
</div>`,
|
|
310
|
+
logic: ["NativeProps"],
|
|
311
|
+
},
|
|
312
|
+
{
|
|
313
|
+
name: "I-28:tabindex=1",
|
|
314
|
+
code: `I-28
|
|
315
|
+
<div class="flex-col gap-8" style="width: 20rem;">
|
|
316
|
+
<Input tabindex={1} placeholder="TabIndex 1" />
|
|
317
|
+
<Text class="text-12 text-black-40">原生 input 对照</Text>
|
|
318
|
+
<input tabindex="1" placeholder="TabIndex 1" />
|
|
319
|
+
</div>`,
|
|
320
|
+
logic: ["NativeProps"],
|
|
321
|
+
},
|
|
322
|
+
{
|
|
323
|
+
name: "I-29:受控值展示",
|
|
324
|
+
code: `I-29
|
|
325
|
+
<div class="flex-col gap-8" style="width: 20rem;">
|
|
326
|
+
<Input value="snowui" placeholder="受控输入" />
|
|
327
|
+
<Text class="text-12 text-black-40">当前受控值:snowui</Text>
|
|
328
|
+
</div>`,
|
|
329
|
+
logic: ["Value"],
|
|
330
|
+
},
|
|
331
|
+
{
|
|
332
|
+
name: "I-30:autofocus 自动聚焦",
|
|
333
|
+
code: `I-30
|
|
334
|
+
<Input autofocus placeholder="我会在挂载后自动聚焦" style="width: 20rem;" />`,
|
|
335
|
+
logic: ["Autofocus"],
|
|
336
|
+
},
|
|
337
|
+
{
|
|
338
|
+
name: "I-31:form submit + reset",
|
|
339
|
+
code: `I-31
|
|
340
|
+
<form class="flex-col gap-12" style="width: 20rem;">
|
|
341
|
+
<Input
|
|
342
|
+
name="project"
|
|
343
|
+
placeholder="Project name"
|
|
344
|
+
autocomplete="organization-title"
|
|
345
|
+
required
|
|
346
|
+
/>
|
|
347
|
+
<Input
|
|
348
|
+
name="slug"
|
|
349
|
+
placeholder="project_slug"
|
|
350
|
+
pattern="[a-z0-9-]+"
|
|
351
|
+
title="仅允许小写字母、数字和短横线"
|
|
352
|
+
required
|
|
353
|
+
/>
|
|
354
|
+
<Input
|
|
355
|
+
name="budget"
|
|
356
|
+
type="number"
|
|
357
|
+
min={100}
|
|
358
|
+
max={10000}
|
|
359
|
+
step={100}
|
|
360
|
+
defaultValue={500}
|
|
361
|
+
/>
|
|
362
|
+
<div class="flex gap-8">
|
|
363
|
+
<Button type="submit" variant="filled">提交表单</Button>
|
|
364
|
+
<Button type="reset" variant="outline">重置</Button>
|
|
365
|
+
</div>
|
|
366
|
+
</form>`,
|
|
367
|
+
logic: ["Form"],
|
|
368
|
+
},
|
|
369
|
+
{
|
|
370
|
+
name: "I-32:表单内字段",
|
|
371
|
+
code: `I-32
|
|
372
|
+
<form id="input-demo-external-form" class="flex-col gap-12" style="width: 20rem;">
|
|
373
|
+
<Input
|
|
374
|
+
name="inlineField"
|
|
375
|
+
placeholder="form 内部字段"
|
|
376
|
+
defaultValue="inside"
|
|
377
|
+
/>
|
|
378
|
+
</form>`,
|
|
379
|
+
logic: ["Form"],
|
|
380
|
+
},
|
|
381
|
+
{
|
|
382
|
+
name: "I-33:form 外部归属",
|
|
383
|
+
code: `I-33
|
|
384
|
+
<div class="flex-col gap-12" style="width: 20rem;">
|
|
385
|
+
<form id="input-demo-external-form"></form>
|
|
386
|
+
<Input
|
|
387
|
+
form="input-demo-external-form"
|
|
388
|
+
name="externalField"
|
|
389
|
+
placeholder="通过 form 属性归属到上面的表单"
|
|
390
|
+
defaultValue="outside"
|
|
391
|
+
/>
|
|
392
|
+
<div class="flex gap-8">
|
|
393
|
+
<Button form="input-demo-external-form" type="submit" variant="filled">提交外部归属表单</Button>
|
|
394
|
+
<Button form="input-demo-external-form" type="reset" variant="outline">重置</Button>
|
|
395
|
+
</div>
|
|
396
|
+
</div>`,
|
|
397
|
+
logic: ["Form"],
|
|
398
|
+
},
|
|
399
|
+
{
|
|
400
|
+
name: "I-34:click / keyboard / copy-paste 事件",
|
|
401
|
+
code: `I-34
|
|
402
|
+
<Input
|
|
403
|
+
value="尝试点击、双击、键盘、复制粘贴"
|
|
404
|
+
placeholder="尝试点击、双击、键盘、复制粘贴"
|
|
405
|
+
style="width: 20rem;"
|
|
406
|
+
onclick={() => {}}
|
|
407
|
+
ondblclick={() => {}}
|
|
408
|
+
oninput={() => {}}
|
|
409
|
+
onchange={() => {}}
|
|
410
|
+
onfocus={() => {}}
|
|
411
|
+
onblur={() => {}}
|
|
412
|
+
onkeydown={() => {}}
|
|
413
|
+
onkeyup={() => {}}
|
|
414
|
+
onkeypress={() => {}}
|
|
415
|
+
onpaste={() => {}}
|
|
416
|
+
oncopy={() => {}}
|
|
417
|
+
oncut={() => {}}
|
|
418
|
+
/>`,
|
|
419
|
+
logic: ["Events"],
|
|
420
|
+
},
|
|
421
|
+
{
|
|
422
|
+
name: "I-35:loading / skeleton",
|
|
423
|
+
code: `I-35
|
|
424
|
+
<Input loading placeholder="loading + skeleton" style="width: 20rem;" />`,
|
|
425
|
+
logic: ["Frame", "Loading"],
|
|
426
|
+
},
|
|
427
|
+
{
|
|
428
|
+
name: "I-36:Click 状态切换 + 无按压位移",
|
|
429
|
+
code: `I-36
|
|
430
|
+
<Input
|
|
431
|
+
value="点击输入框切换到无边框态"
|
|
432
|
+
style="width: 20rem;"
|
|
433
|
+
Click={{ Idle: "Active", Active: "Idle" }}
|
|
434
|
+
whileClick={false}
|
|
435
|
+
whileActive={false}
|
|
436
|
+
stateStyle={{
|
|
437
|
+
Idle: "--snowui-input-background: var(--surface-1, #ffffffcc); --snowui-field-border-width: var(--border-1); --snowui-field-hover-border-color: var(--black-20, #00000033); --snowui-field-focus-border-color: var(--black-40, #00000066); --snowui-field-focus-ring-width: 0.25rem; --snowui-field-cursor: text;",
|
|
438
|
+
Active: "--snowui-input-background: var(--surface-2, #00000008); --snowui-field-border-width: 0rem; --snowui-field-hover-border-color: transparent; --snowui-field-focus-border-color: transparent; --snowui-field-focus-ring-width: 0rem; --snowui-field-cursor: default;",
|
|
439
|
+
}}
|
|
440
|
+
/>`,
|
|
441
|
+
logic: ["Frame", "StateStyle"],
|
|
442
|
+
},
|
|
443
|
+
{
|
|
444
|
+
name: "I-37:responsive 宽度",
|
|
445
|
+
code: `I-37
|
|
446
|
+
<Input
|
|
447
|
+
enableResponsive={true}
|
|
448
|
+
responsive={{
|
|
449
|
+
sm: { width: "100%" },
|
|
450
|
+
lg: { width: "20rem" },
|
|
451
|
+
}}
|
|
452
|
+
placeholder="responsive width"
|
|
453
|
+
/>`,
|
|
454
|
+
logic: ["Frame", "Responsive"],
|
|
455
|
+
},
|
|
456
|
+
{
|
|
457
|
+
name: "I-38:whileAppear / layoutId",
|
|
458
|
+
code: `I-38
|
|
459
|
+
<Input
|
|
460
|
+
whileAppear
|
|
461
|
+
layoutId="input-demo-shared"
|
|
462
|
+
placeholder="whileAppear / layoutId"
|
|
463
|
+
style="width: 20rem;"
|
|
464
|
+
/>`,
|
|
465
|
+
logic: ["Frame", "Motion"],
|
|
466
|
+
},
|
|
467
|
+
{
|
|
468
|
+
name: "I-39:as=\"search\" 嵌套在 Listbox 内(过滤模式)",
|
|
469
|
+
code: `I-39
|
|
470
|
+
<Select placeholder="请选择国家" style="width: 20rem;">
|
|
471
|
+
<Listbox>
|
|
472
|
+
<Input as="search" placeholder="搜索..." />
|
|
473
|
+
<MenuItem value="china">China</MenuItem>
|
|
474
|
+
<MenuItem value="usa">United States</MenuItem>
|
|
475
|
+
<MenuItem value="japan">Japan</MenuItem>
|
|
476
|
+
<MenuItem value="germany">Germany</MenuItem>
|
|
477
|
+
<MenuItem value="france">France</MenuItem>
|
|
478
|
+
<MenuItem value="uk">United Kingdom</MenuItem>
|
|
479
|
+
<MenuItem value="canada">Canada</MenuItem>
|
|
480
|
+
<MenuItem value="australia">Australia</MenuItem>
|
|
481
|
+
<MenuItem value="brazil">Brazil</MenuItem>
|
|
482
|
+
<MenuItem value="india">India</MenuItem>
|
|
483
|
+
<MenuItem value="korea">South Korea</MenuItem>
|
|
484
|
+
<MenuItem value="italy">Italy</MenuItem>
|
|
485
|
+
<MenuItem value="spain">Spain</MenuItem>
|
|
486
|
+
</Listbox>
|
|
487
|
+
</Select>`,
|
|
488
|
+
logic: ["Search", "Filter"],
|
|
489
|
+
},
|
|
490
|
+
{
|
|
491
|
+
name: "I-40:as=\"search\" + allowCustomValue 自定义选项",
|
|
492
|
+
code: `I-40
|
|
493
|
+
<Select placeholder="选择或输入职位" style="width: 20rem;">
|
|
494
|
+
<Listbox>
|
|
495
|
+
<Input as="search" allowCustomValue placeholder="搜索或输入新职位..." />
|
|
496
|
+
<MenuItem value="designer">Designer</MenuItem>
|
|
497
|
+
<MenuItem value="engineer">Engineer</MenuItem>
|
|
498
|
+
<MenuItem value="pm">Product Manager</MenuItem>
|
|
499
|
+
</Listbox>
|
|
500
|
+
</Select>`,
|
|
501
|
+
logic: ["Search", "Filter", "CustomValue"],
|
|
502
|
+
},
|
|
503
|
+
] as const;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# Kbd (键盘快捷键)
|
|
2
|
+
|
|
3
|
+
> **版本**: v1.0.0
|
|
4
|
+
> **职责**: 显示键盘按键或快捷键标识的内联标签组件
|
|
5
|
+
|
|
6
|
+
用于展示键盘按键名称或组合键,如 `⌘K`、`Ctrl+C`、`Enter` 等。支持两种视觉样式:描边(样式 A)和实心底色(样式 B)。
|
|
7
|
+
|
|
8
|
+
## 功能概览
|
|
9
|
+
|
|
10
|
+
- 两种视觉样式:描边(`border`)与实心底色(`solid`),通过 `variant` 切换
|
|
11
|
+
- 语义化 `<kbd>` 元素输出
|
|
12
|
+
- 内联行内元素,可嵌入任何文本流中
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## API 参考
|
|
17
|
+
|
|
18
|
+
### 核心属性
|
|
19
|
+
|
|
20
|
+
| 关键字 | 类型 | 默认值 | 描述 |
|
|
21
|
+
| :--- | :--- | :--- | :--- |
|
|
22
|
+
| variant | `"border" \| "solid"` | `"border"` | 样式 A(描边)或样式 B(实心底色) |
|
|
23
|
+
| children | `Snippet` | — | 按键内容 |
|
|
24
|
+
|
|
25
|
+
### 使用示例
|
|
26
|
+
|
|
27
|
+
#### 基础用法(样式 A — 描边)
|
|
28
|
+
|
|
29
|
+
```svelte
|
|
30
|
+
<Kbd>⌘K</Kbd>
|
|
31
|
+
<Kbd>Ctrl</Kbd>
|
|
32
|
+
<Kbd>Enter</Kbd>
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
#### 样式 B(实心底色)
|
|
36
|
+
|
|
37
|
+
```svelte
|
|
38
|
+
<Kbd variant="solid">⌘K</Kbd>
|
|
39
|
+
<Kbd variant="solid">Ctrl</Kbd>
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
#### 组合键
|
|
43
|
+
|
|
44
|
+
```svelte
|
|
45
|
+
<Kbd>⌘</Kbd>
|
|
46
|
+
<span>+</span>
|
|
47
|
+
<Kbd>K</Kbd>
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
<!-- @UserDefined -->
|
|
51
|
+
## 用户定义区域
|
|
52
|
+
|
|
53
|
+
> 此区域的内容受保护。AI 在修改此区域前必须请求用户审查。
|
|
54
|
+
<!-- /@UserDefined -->
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
> **以下内容供 AI 阅读,用于维护代码与文档的关联**
|
|
59
|
+
|
|
60
|
+
## 开发者指南 (AI)
|
|
61
|
+
|
|
62
|
+
### 布局模型
|
|
63
|
+
|
|
64
|
+
主布局模型:**内联外壳布局(Inline Shell Layout)**
|
|
65
|
+
|
|
66
|
+
根为 `inline-flex` 外壳;内容整体 Hug;padding 决定可见面积;不接入三槽位协议。
|
|
67
|
+
|
|
68
|
+
### 开发者关键字
|
|
69
|
+
|
|
70
|
+
| 类别 | 关键字 | 描述 |
|
|
71
|
+
|:---|:---|:---|
|
|
72
|
+
| CSS 类名 | `snowui-kbd` | 根元素类名 |
|
|
73
|
+
| 变体类名 | `snowui-kbd-solid` | 实心底色变体(`variant="solid"` 时添加) |
|
|
74
|
+
|
|
75
|
+
### 模块索引
|
|
76
|
+
|
|
77
|
+
| 模块 | 文件 | 职责 |
|
|
78
|
+
|:---|:---|:---|
|
|
79
|
+
| Kbd | [Kbd.svelte](./Kbd.svelte) | 主组件 |
|
|
80
|
+
|
|
81
|
+
### 关键字映射
|
|
82
|
+
|
|
83
|
+
| 关键字 | 处理方式 | 说明 |
|
|
84
|
+
|:---|:---|:---|
|
|
85
|
+
| variant | CSS 类 | `"solid"` → `.snowui-kbd-solid`;`"border"` 为默认,无额外类 |
|
|
86
|
+
|
|
87
|
+
### 关联关系
|
|
88
|
+
|
|
89
|
+
- **父组件**: 无
|
|
90
|
+
- **依赖**: Frame
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
## 更新日志 (Changelog)
|
|
95
|
+
|
|
96
|
+
### v1.0.0 (2026-04-29)
|
|
97
|
+
|
|
98
|
+
#### 新功能
|
|
99
|
+
|
|
100
|
+
- 初始版本,支持 `variant` 样式切换(`border` / `solid`)
|