@snowui-design-system/components 0.1.0 → 0.2.0-alpha.3
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 +1 -2
- package/package.json +6 -2
- package/src/components/Accordion.md +218 -0
- package/src/components/Accordion.svelte +301 -0
- package/src/components/Accordion.test.ts +126 -0
- package/src/components/AccordionItem.md +114 -0
- package/src/components/AccordionItem.svelte +389 -0
- package/src/components/AccordionItem.test.ts +52 -0
- package/src/components/Avatar.md +54 -36
- package/src/components/Avatar.svelte +73 -126
- package/src/components/AvatarGroup.md +17 -14
- package/src/components/AvatarGroup.svelte +12 -50
- package/src/components/AvatarGroup.test.ts +69 -68
- package/src/components/Badge.md +53 -8
- package/src/components/Badge.svelte +303 -79
- package/src/components/Badge.test.ts +47 -0
- package/src/components/Breadcrumb.md +164 -0
- package/src/components/Breadcrumb.svelte +330 -0
- package/src/components/Breadcrumb.test.ts +154 -0
- package/src/components/Button.md +243 -57
- package/src/components/Button.svelte +278 -177
- package/src/components/Button.test.ts +175 -86
- package/src/components/ButtonGroup.md +140 -0
- package/src/components/ButtonGroup.svelte +491 -0
- package/src/components/ButtonGroup.test.ts +58 -0
- package/src/components/Card.md +186 -0
- package/src/components/Card.svelte +408 -0
- package/src/components/Card.test.ts +193 -0
- package/src/components/Checkbox.md +14 -10
- package/src/components/Checkbox.svelte +39 -99
- package/src/components/Chip.md +185 -0
- package/src/components/Chip.svelte +241 -0
- package/src/components/Chip.test.ts +117 -0
- package/src/components/CodeBlock.md +29 -16
- package/src/components/CodeBlock.svelte +132 -352
- package/src/components/CodeBlock.test.ts +15 -1
- package/src/components/CopyButton.md +41 -0
- package/src/components/CopyButton.svelte +164 -0
- package/src/components/CopyButton.test.ts +26 -0
- package/src/components/Dialog.md +95 -0
- package/src/components/Dialog.svelte +416 -0
- package/src/components/Dialog.test.ts +145 -0
- package/src/components/ExpandButton.md +41 -0
- package/src/components/ExpandButton.svelte +103 -0
- package/src/components/ExpandButton.test.ts +18 -0
- package/src/components/Form.md +4 -3
- package/src/components/Form.test.ts +72 -73
- package/src/components/Frame.md +243 -0
- package/src/components/Frame.svelte +208 -87
- package/src/components/Frame.test.ts +121 -0
- package/src/components/Icon.md +34 -6
- package/src/components/Icon.svelte +46 -95
- package/src/components/Image.md +24 -13
- package/src/components/Image.svelte +42 -128
- package/src/components/ImageGroup.md +6 -7
- package/src/components/ImageGroup.svelte +1 -28
- package/src/components/Indicator.md +92 -0
- package/src/components/Indicator.svelte +490 -0
- package/src/components/Indicator.test.ts +57 -0
- package/src/components/Input.md +81 -28
- package/src/components/Input.svelte +291 -178
- package/src/components/Input.test.ts +85 -48
- package/src/components/Kbd.md +0 -3
- package/src/components/Kbd.svelte +0 -1
- package/src/components/Link.md +192 -0
- package/src/components/Link.svelte +464 -0
- package/src/components/Link.test.ts +110 -0
- package/src/components/Listbox.md +52 -10
- package/src/components/Listbox.svelte +204 -50
- package/src/components/Listbox.test.ts +76 -33
- package/src/components/LocaleProvider.md +52 -0
- package/src/components/LocaleProvider.svelte +30 -0
- package/src/components/LocaleProvider.test.ts +32 -0
- package/src/components/MenuItem.md +23 -9
- package/src/components/MenuItem.svelte +57 -47
- package/src/components/MenuItem.test.ts +72 -65
- package/src/components/Pagination.md +504 -0
- package/src/components/Pagination.svelte +958 -0
- package/src/components/Pagination.test.ts +316 -0
- package/src/components/Popover.md +245 -42
- package/src/components/Popover.svelte +558 -127
- package/src/components/Popover.test.ts +361 -44
- package/src/components/Progress.md +91 -0
- package/src/components/Progress.svelte +374 -0
- package/src/components/Progress.test.ts +56 -0
- package/src/components/Radio.md +4 -6
- package/src/components/Radio.svelte +25 -117
- package/src/components/ScrollArea.md +116 -0
- package/src/components/ScrollArea.svelte +180 -0
- package/src/components/ScrollArea.test.ts +84 -0
- package/src/components/SearchInput.md +135 -0
- package/src/components/SearchInput.svelte +153 -0
- package/src/components/SearchInput.test.ts +61 -0
- package/src/components/Select.md +39 -8
- package/src/components/Select.svelte +196 -45
- package/src/components/Select.test.ts +79 -41
- package/src/components/SelectButton.md +50 -0
- package/src/components/SelectButton.svelte +186 -0
- package/src/components/SelectButton.test.ts +142 -0
- package/src/components/Separator.md +89 -0
- package/src/components/Separator.svelte +143 -0
- package/src/components/Separator.test.ts +35 -0
- package/src/components/Skeleton.md +2 -5
- package/src/components/Skeleton.svelte +202 -7
- package/src/components/Skeleton.test.ts +10 -10
- package/src/components/Slider.md +101 -0
- package/src/components/Slider.svelte +566 -0
- package/src/components/Slider.test.ts +51 -0
- package/src/components/Spinner.md +3 -4
- package/src/components/Spinner.svelte +11 -23
- package/src/components/{Toggle.md → Switch.md} +20 -21
- package/src/components/Switch.svelte +314 -0
- package/src/components/Switch.test.ts +57 -0
- package/src/components/Table.md +249 -0
- package/src/components/Table.svelte +139 -0
- package/src/components/Table.test.ts +64 -0
- package/src/components/TableBody.md +63 -0
- package/src/components/TableBody.svelte +78 -0
- package/src/components/TableBody.test.ts +13 -0
- package/src/components/TableCell.md +89 -0
- package/src/components/TableCell.svelte +368 -0
- package/src/components/TableCell.test.ts +51 -0
- package/src/components/TableHead.md +129 -0
- package/src/components/TableHead.svelte +281 -0
- package/src/components/TableHead.test.ts +44 -0
- package/src/components/TableHeader.md +26 -0
- package/src/components/TableHeader.svelte +10 -0
- package/src/components/TableHeader.test.ts +3 -0
- package/src/components/TableRow.md +36 -0
- package/src/components/TableRow.svelte +64 -0
- package/src/components/TableRow.test.ts +2 -0
- package/src/components/TableToolbar.svelte +260 -0
- package/src/components/Tag.md +270 -0
- package/src/components/Tag.svelte +462 -0
- package/src/components/Tag.test.ts +91 -0
- package/src/components/Text.md +87 -25
- package/src/components/Text.svelte +467 -93
- package/src/components/Text.test.ts +21 -36
- package/src/components/Textarea.md +22 -7
- package/src/components/Textarea.svelte +76 -155
- package/src/components/Textarea.test.ts +12 -5
- package/src/components/Tooltip.md +101 -12
- package/src/components/Tooltip.svelte +581 -108
- package/src/components/Tooltip.test.ts +63 -1
- package/src/context.ts +93 -5
- package/src/dev.ts +6 -10
- package/src/i18n/locale.svelte.ts +60 -0
- package/src/i18n/messages.ts +45 -0
- package/src/index.ts +177 -2
- package/src/keys.ts +7 -0
- package/src/lib/clipboard.ts +10 -0
- package/src/lib/color.md +36 -0
- package/src/lib/color.ts +57 -0
- package/src/lib/date-format.md +37 -0
- package/src/lib/date-format.ts +130 -0
- package/src/lib/edge-fade.md +101 -0
- package/src/lib/edge-fade.ts +55 -0
- package/src/lib/floating-position.md +20 -0
- package/src/lib/floating-position.ts +107 -0
- package/src/lib/number-format.md +40 -0
- package/src/lib/number-format.ts +132 -0
- package/src/lib/overlay-scrollbar.md +36 -0
- package/src/lib/overlay-scrollbar.svelte.ts +221 -0
- package/src/lib/overlay-trigger-timing.md +15 -0
- package/src/lib/overlay-trigger-timing.ts +8 -0
- package/src/lib/progressive-blur.md +95 -0
- package/src/lib/progressive-blur.ts +266 -0
- package/src/lib/resizable.md +41 -0
- package/src/lib/resizable.ts +211 -0
- package/src/lib/table-context.svelte.ts +129 -0
- package/src/lib/table-row-context.svelte.ts +16 -0
- package/src/lib/tooltip-behavior.ts +39 -0
- package/src/lib/tooltip-delay.md +33 -0
- package/src/lib/tooltip-delay.ts +49 -0
- package/src/lib/tooltip-overlay.md +30 -0
- package/src/lib/tooltip-overlay.ts +64 -0
- package/src/lib/truncate.md +7 -2
- package/src/lib/truncate.ts +105 -10
- package/src/logic/README.md +17 -7
- package/src/logic/component-parts.md +32 -0
- package/src/logic/component-parts.svelte.ts +130 -0
- package/src/logic/dialog.md +30 -0
- package/src/logic/dialog.svelte.ts +88 -0
- package/src/logic/frame-actions.md +28 -0
- package/src/logic/frame-actions.svelte.ts +49 -0
- package/src/logic/frame-class-state.md +21 -0
- package/src/logic/frame-class-state.svelte.ts +163 -0
- package/src/logic/frame-dom-runtime.svelte.ts +51 -0
- package/src/logic/frame-inline-style.md +56 -0
- package/src/logic/frame-inline-style.svelte.ts +623 -0
- package/src/logic/frame-motion-defaults.md +90 -9
- package/src/logic/frame-motion-defaults.ts +55 -49
- package/src/logic/frame-motion.svelte.ts +173 -0
- package/src/logic/frame-perception.md +83 -0
- package/src/logic/frame-perception.svelte.ts +273 -0
- package/src/logic/frame-prop-filter.ts +7 -1
- package/src/logic/frame-scale-observer.md +153 -0
- package/src/logic/frame-scale-observer.svelte.ts +98 -0
- package/src/logic/frame-scale-resolver.md +25 -0
- package/src/logic/frame-scale-resolver.svelte.ts +56 -0
- package/src/logic/frame-state-value.md +74 -0
- package/src/logic/frame-state-value.ts +30 -0
- package/src/logic/frame-state.svelte.ts +426 -0
- package/src/logic/frame-truncation.md +17 -3
- package/src/logic/frame-truncation.svelte.ts +23 -43
- package/src/logic/frame-types.md +2 -1
- package/src/logic/frame-types.ts +41 -7
- package/src/logic/frame-utils.md +4 -0
- package/src/logic/frame-utils.ts +54 -26
- package/src/logic/image-preview.md +9 -2
- package/src/logic/image-preview.ts +33 -7
- package/src/logic/morph.md +19 -0
- package/src/logic/morph.ts +7 -0
- package/src/logic/motion-config.ts +49 -3
- package/src/logic/motion-engine.md +43 -0
- package/src/logic/motion-engine.ts +272 -0
- package/src/logic/overlay-presence.svelte.ts +71 -0
- package/src/logic/popover.md +89 -0
- package/src/logic/popover.svelte.ts +236 -0
- package/src/logic/resource-size.md +21 -0
- package/src/logic/resource-size.ts +53 -0
- package/src/logic/text-collapse.md +2 -1
- package/src/logic/text-collapse.svelte.ts +1 -1
- package/src/logic/wc-adapter.ts +1 -1
- package/src/motion/README.md +97 -37
- package/src/motion/{defaults/bridge.md → bridge.md} +24 -4
- package/src/motion/{defaults/bridge.ts → bridge.ts} +16 -5
- package/src/motion/{defaults/content-crossfade.ts → content-crossfade.ts} +1 -1
- package/src/motion/{defaults/expand.md → expand.md} +2 -2
- package/src/motion/{defaults/expand.ts → expand.ts} +4 -3
- package/src/motion/fade-in.md +40 -0
- package/src/motion/fade-in.ts +14 -0
- package/src/motion/{defaults/fade-out.md → fade-out.md} +2 -2
- package/src/motion/fade-out.ts +14 -0
- package/src/motion/{defaults/morph.md → morph.md} +1 -1
- package/src/motion/{defaults/morph.ts → morph.ts} +3 -3
- package/src/motion/move.md +179 -0
- package/src/motion/move.ts +74 -0
- package/src/motion/number.md +50 -0
- package/src/motion/number.ts +30 -0
- package/src/motion/presets/README.md +50 -0
- package/src/motion/presets/dialog.md +20 -0
- package/src/motion/presets/dialog.ts +47 -0
- package/src/motion/presets/effects.md +32 -0
- package/src/motion/presets/effects.ts +111 -0
- package/src/motion/presets/generic.md +27 -0
- package/src/motion/presets/generic.ts +32 -0
- package/src/motion/presets/overlay.md +21 -0
- package/src/motion/presets/overlay.ts +18 -0
- package/src/motion/presets/replacement.md +19 -0
- package/src/motion/presets/replacement.ts +6 -0
- package/src/motion/presets/resize.md +23 -0
- package/src/motion/presets/resize.ts +16 -0
- package/src/motion/presets/tab.md +21 -0
- package/src/motion/presets/tab.ts +19 -0
- package/src/motion/presets/tooltip.md +20 -0
- package/src/motion/presets/tooltip.ts +37 -0
- package/src/motion/presets/utils.md +15 -0
- package/src/motion/presets/utils.ts +11 -0
- package/src/motion/primitives.md +22 -0
- package/src/motion/primitives.ts +46 -0
- package/src/motion/{defaults/replace.md → replace.md} +2 -2
- package/src/motion/{defaults/replace.ts → replace.ts} +4 -4
- package/src/motion/{defaults/rotate.md → rotate.md} +4 -4
- package/src/motion/{defaults/rotate.ts → rotate.ts} +4 -3
- package/src/motion/scale-in.md +40 -0
- package/src/motion/scale-in.ts +19 -0
- package/src/motion/spring.md +19 -0
- package/src/motion/spring.ts +96 -0
- package/src/motion/tokens.md +45 -0
- package/src/motion/tokens.ts +80 -0
- package/src/motion/{defaults/while-2xl.ts → while-2xl.ts} +1 -1
- package/src/motion/{defaults/while-active.ts → while-active.ts} +1 -1
- package/src/motion/while-appear.ts +10 -0
- package/src/motion/{defaults/while-click.ts → while-click.ts} +1 -1
- package/src/motion/{defaults/while-collapsed.ts → while-collapsed.ts} +1 -1
- package/src/motion/{defaults/while-disabled.ts → while-disabled.ts} +3 -2
- package/src/motion/while-disappear.ts +10 -0
- package/src/motion/{defaults/while-drag.ts → while-drag.ts} +1 -1
- package/src/motion/{defaults/while-editing.ts → while-editing.ts} +1 -1
- package/src/motion/{defaults/while-expanded.ts → while-expanded.ts} +1 -1
- package/src/motion/{defaults/while-focus.ts → while-focus.ts} +1 -1
- package/src/motion/{defaults/while-hover.ts → while-hover.ts} +1 -1
- package/src/motion/{defaults/while-idle.ts → while-idle.ts} +1 -1
- package/src/motion/{defaults/while-key.ts → while-key.ts} +1 -1
- package/src/motion/{defaults/while-lg.ts → while-lg.ts} +1 -1
- package/src/motion/{defaults/while-load.ts → while-load.ts} +3 -2
- package/src/motion/{defaults/while-md.ts → while-md.ts} +1 -1
- package/src/motion/{defaults/while-reload.ts → while-reload.ts} +1 -1
- package/src/motion/{defaults/while-scroll.ts → while-scroll.ts} +1 -1
- package/src/motion/{defaults/while-sm.ts → while-sm.ts} +1 -1
- package/src/motion/{defaults/while-uploading.ts → while-uploading.ts} +1 -1
- package/src/motion/{defaults/while-validating.ts → while-validating.ts} +1 -1
- package/src/motion/{defaults/while-xl.ts → while-xl.ts} +1 -1
- package/src/motion/{defaults/while-xs.ts → while-xs.ts} +1 -1
- package/src/styles/auto-layout.css +92 -10
- package/src/styles/layout.css +370 -30
- package/src/styles/scrollbar.css +72 -7
- package/src/App.svelte +0 -103
- package/src/components/QuickAction.md +0 -146
- package/src/components/QuickAction.svelte +0 -161
- package/src/components/QuickAction.test.ts +0 -299
- package/src/components/Test.md +0 -72
- package/src/components/Test.svelte +0 -106
- package/src/components/Test.test.ts +0 -27
- package/src/components/Toggle.svelte +0 -384
- package/src/components/Toggle.test.ts +0 -57
- package/src/logic/frame-profile.md +0 -156
- package/src/logic/frame-profile.ts +0 -130
- package/src/motion/NumberFlow.md +0 -16
- package/src/motion/defaults/fade-out.ts +0 -14
- package/src/motion/defaults/move.md +0 -81
- package/src/motion/defaults/move.ts +0 -31
- package/src/motion/defaults/number.md +0 -41
- package/src/motion/defaults/number.ts +0 -17
- package/src/motion/defaults/while-appear.ts +0 -12
- package/src/motion/defaults/while-disappear.ts +0 -12
- package/src//344/273/243/347/240/201.txt +0 -61
- /package/src/motion/{defaults/rotate.css → rotate.css} +0 -0
|
@@ -1,84 +1,6 @@
|
|
|
1
1
|
<!--
|
|
2
2
|
Input 组件:基础单行输入框
|
|
3
|
-
v1.
|
|
4
|
-
|
|
5
|
-
变更记录 (2026-04-09):
|
|
6
|
-
- 修复嵌入原生宿主的 segment 识别:`Field row > Input as="segment"` 现在会显式导出 `data-as / data-embedded`,让 Field 分段 padding 与分隔线规则正确命中
|
|
7
|
-
- 按需求文档给出的期望 HTML 收敛 `text` 链路:改回可见原生 `<input>`,移除额外的 editor / placeholder 覆盖层
|
|
8
|
-
- `Field > Input` 的 text 结构回到 `div > input`,placeholder 与输入内容统一走浏览器原生单行输入排版
|
|
9
|
-
|
|
10
|
-
变更记录 (2026-04-27):
|
|
11
|
-
- 直系 `as="leading"` / `as="trailing"` 支持复杂结构,按三段布局显式落列;自定义 trailing 保持替换默认 trailing 槽的行为
|
|
12
|
-
- 内建清除 X 恢复为输入有值且 Input focus-within 时显示,失焦隐藏且不预留额外 gap
|
|
13
|
-
|
|
14
|
-
变更记录 (2026-04-25):
|
|
15
|
-
- 修复独立 Input 有值但 X 隐藏时右侧输入区域多出 8px:只有内建清除按钮时,隐藏态不再保留 grid gap;X 显示时再恢复 gap 与按钮列。
|
|
16
|
-
|
|
17
|
-
变更记录 (2026-03-31):
|
|
18
|
-
- 错误态焦点外环统一回收到 layout.css 的 Field Profile,Input / Select / Textarea / Field 共用同一套 focus ring
|
|
19
|
-
- 默认错误图标改为组件内建 trailing 挂件,并对齐 Figma 的单行居中布局与红色语义
|
|
20
|
-
|
|
21
|
-
变更记录 (2026-03-30):
|
|
22
|
-
- 对齐 Figma 错误焦点态:独立 invalid 输入框的 focus ring 改为 Black/4% 4px 外环,保留红色 0.5px 内边框
|
|
23
|
-
|
|
24
|
-
变更记录 (2026-03-29, v1.0.39):
|
|
25
|
-
- 修复 `list` / `datalist` 建议项失效:当文本输入声明 `list` 时,组件回退为可见原生 `<input type="text">`,保留浏览器原生建议列表能力
|
|
26
|
-
|
|
27
|
-
变更记录 (2026-03-29, v1.0.38):
|
|
28
|
-
- 明确移除 `type="file"` 支持:组件内部统一把 `file` 归一为 `text`,不再透传浏览器原生文件上传器
|
|
29
|
-
- 删除文件选择器专用样式,避免 `Input` 继续保留 file 类型的残余视觉实现
|
|
30
|
-
|
|
31
|
-
变更记录 (2026-03-28, v1.0.37):
|
|
32
|
-
- 明确移除 `type="range"` 支持:组件内部统一把 `range` 归一为 `text`,不再直接透传浏览器原生滑杆
|
|
33
|
-
- 回收 demo 中对 `Input type="range"` 的示例引用,避免把非设计体系内的原生滑杆误认为组件能力
|
|
34
|
-
|
|
35
|
-
变更记录 (2026-03-25, v1.0.36):
|
|
36
|
-
- 新增 `type="color"` 的默认可见展示层:改为 Figma 对应的“色点 + # + HEX”呈现,颜色值随原生 color picker 同步更新
|
|
37
|
-
- 保留隐藏原生 `<input type="color">` 作为真实宿主,继续承接表单归属、聚焦、键盘与 `bind:value` 同步能力
|
|
38
|
-
- 对齐示例规范:颜色输入示例改回直接使用 `<Input type="color" />`,不再用 `Frame + Text` 人工拼装展示态
|
|
39
|
-
|
|
40
|
-
变更记录 (2026-03-24):
|
|
41
|
-
- 对齐 number 默认 stepper 与 `Button iconButton={true}` 的基准高度:默认上下箭头按钮盒子回到 `sm` iconButton 对应尺寸,并复用相同箭头资源,避免 Playground 中默认 stepper 比自定义 iconButton 版本更高
|
|
42
|
-
|
|
43
|
-
变更记录 (2026-03-19, v1.0.35):
|
|
44
|
-
- 新增“不能编辑”视觉规则:`readonly` 统一采用 `Background/2` 背景且移除边框,覆盖独立模式与 Field 容器模式
|
|
45
|
-
- 修复数字输入框原生上下箭头未完全隐藏的问题:增强 `type="number"` 的浏览器兜底隐藏规则,保留自定义 `as="up/down"` 步进按钮
|
|
46
|
-
- 规范性对齐 (v1.5.10): 补齐 Props 接口中的 children 声明,对齐 enableResponsive 默认值为 true,并同步修正 Frame 能力开关显式传参
|
|
47
|
-
- CSS 规范对齐: 收敛 stepper 相关选择器到 :global(:where()),移除强制优先级写法,补齐主题 token fallback,并改用 Input 命名空间变量承接自身几何样式
|
|
48
|
-
- 内部逻辑优化: 保持 renderHints 与 Skeleton.svelte 计算链路一致
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
变更记录 (2026-03-14):
|
|
52
|
-
- Refactor: Input 的 focus 变量桥接回归 Field Profile 通用值,默认聚焦态改为 Black/40% 内边框 + Black/4% 的 4px 外层 ring
|
|
53
|
-
- Fix: placeholder 最终修复为拆分浏览器私有选择器并分别命中,统一输出 Black/20%
|
|
54
|
-
- Cleanup: 移除为光标问题添加的 placeholder 覆盖层与专项 cursor 兜底,回归原生 input + Field Profile 的最小实现
|
|
55
|
-
- Refactor: Input 默认边框/hover/focus/cursor 改为通过 Field Profile 变量桥接到 layout.css,focus 效果与文字光标统一由通用 Profile 控制
|
|
56
|
-
- Refactor: 抽离字段宿主桥接逻辑到 ../logic/frame-field-control.ts,统一 value/defaultValue、invalid/aria-invalid 与 file 类型值同步规则,为后续 Textarea/Select 复用
|
|
57
|
-
- Slim: 删除组件内重复的默认 hover/focus 规则,改为依赖 Field Profile 的通用行为;移除冗余 data-disabled 链路
|
|
58
|
-
- Refactor: 改用 ../logic/frame-prop-filter.ts 提供的共享 props 分发器,复用 Frame 内部关键字识别逻辑,为后续 Textarea/原生宿主类组件提供统一接口
|
|
59
|
-
- 按 Figma 样式翻译更新默认视觉:14 文字、12/16 padding、8 gap、16 圆角、Black/20% 0.5px 内边框、Background/3 背景
|
|
60
|
-
- 默认高度随排版与 padding 推导,符合流式布局规范,并同步更新 Skeleton renderHints
|
|
61
|
-
- 补齐默认 focus 链路,避免组件基础样式覆盖 Field Profile 的 focus ring
|
|
62
|
-
|
|
63
|
-
变更记录 (2026-03-16):
|
|
64
|
-
- 重构 text/date 编辑体验:`text` 与 `date` 改为“可见自定义编辑层 + 隐藏原生宿主同步值”的实现,统一选中文字视觉
|
|
65
|
-
- 修正日期分段高亮命中方式:Chrome 中 `year/month/day` 采用 `::-webkit-datetime-edit-* :focus` 链路,而非 `::selection`
|
|
66
|
-
- 收敛先前无效的普通 input `::selection` 方案,保留 Field 高亮变量给可命中的日期分段样式复用
|
|
67
|
-
- 修复普通 placeholder 颜色回归:沿用日期空态的成功方式,为 `:placeholder-shown` 的 input 本体追加 `Black/20%` 文本色,避免浏览器未命中 `::placeholder` 时仍显示为正文色
|
|
68
|
-
- 再次修复日期空态文案颜色:沿用 placeholder 的成功修复方式,把空值 `date input` 本体文字颜色也统一压到 `Black/20%`,不再只依赖浏览器内部字段伪元素
|
|
69
|
-
- 修复日期空态文案颜色:`type="date"` 在空值时改由组件侧统一把浏览器内部日期占位文本压到 `Black/20%`,与普通 placeholder 保持一致
|
|
70
|
-
- 修复无 trailing 按钮时的日期宿主外观:`type="date"` 在未绑定自定义 trigger 时恢复浏览器原生 appearance,保留默认日期 icon;仅在存在 `Button as="trailing"` 时才切换到自定义隐藏链路
|
|
71
|
-
- 修正日期 icon 修复判断:恢复 `::-webkit-calendar-picker-indicator` 隐藏分支,并与宿主右侧遮罩共同作为组合修复;此前删除该分支会导致默认日期 icon 再次出现
|
|
72
|
-
- 修复日期 trigger 命中不稳定:改为在 Input 运行时检测同一局部容器内的 direct trailing Button,并回写自身 `data-has-date-trigger`
|
|
73
|
-
- 移除 `control="date-picker"` 依赖;日期输入的自定义触发器仅基于局部容器内的 `Button as="trailing"` 自动识别
|
|
74
|
-
|
|
75
|
-
变更记录 (2026-03-15):
|
|
76
|
-
- 新增自定义日期触发器桥接:当宿主被自动 trailing 日期触发器绑定时,隐藏原生日期选择 icon,把选择入口交给外部组合按钮
|
|
77
|
-
|
|
78
|
-
变更记录 (2026-03-13):
|
|
79
|
-
- 新增基于 Frame 的单行输入组件,承接原生 <input> 属性透传与 Frame 通用能力
|
|
80
|
-
- 组件仅负责输入控件本体,不内建 Label / Description / Error
|
|
81
|
-
- 新增 invalid / readonly / file selector / datalist 等基础样式链路
|
|
3
|
+
v1.1.1
|
|
82
4
|
|
|
83
5
|
文档: ./Input.md
|
|
84
6
|
-->
|
|
@@ -97,13 +19,9 @@
|
|
|
97
19
|
-->
|
|
98
20
|
<script lang="ts">
|
|
99
21
|
import Frame, { type FrameProps } from "./Frame.svelte";
|
|
100
|
-
import
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
Calendar,
|
|
104
|
-
Clock,
|
|
105
|
-
Warning,
|
|
106
|
-
} from "@snowui-design-system/resource-svelte";
|
|
22
|
+
import Text from "./Text.svelte";
|
|
23
|
+
import { Icon as ResourceIcon } from "@snowui-design-system/resource-svelte";
|
|
24
|
+
import type { Snippet } from "svelte";
|
|
107
25
|
import { getField, getListboxOwner, getListboxHeaderPortal } from "../context";
|
|
108
26
|
import {
|
|
109
27
|
resolveFrameFieldInvalid,
|
|
@@ -111,7 +29,13 @@
|
|
|
111
29
|
syncFrameFieldValue,
|
|
112
30
|
} from "../logic/frame-field-control";
|
|
113
31
|
import { splitFrameHostProps } from "../logic/frame-prop-filter";
|
|
32
|
+
import {
|
|
33
|
+
mergeComponentPartProps,
|
|
34
|
+
useComponentPart,
|
|
35
|
+
} from "../logic/component-parts.svelte";
|
|
114
36
|
import type { HTMLInputAttributes } from "svelte/elements";
|
|
37
|
+
import type { ComponentPartsOf } from "../logic/component-parts.svelte";
|
|
38
|
+
import { resizeManager } from "../logic/observer.svelte";
|
|
115
39
|
|
|
116
40
|
type InputValue = string | number | undefined;
|
|
117
41
|
type TemporalInputType =
|
|
@@ -130,7 +54,7 @@
|
|
|
130
54
|
| "second";
|
|
131
55
|
type DateDraft = Record<TemporalSegmentKey, string>;
|
|
132
56
|
|
|
133
|
-
interface Props extends Omit<FrameProps, "tag"
|
|
57
|
+
interface Props extends Omit<FrameProps, "tag"> {
|
|
134
58
|
type?: HTMLInputAttributes["type"];
|
|
135
59
|
value?: InputValue;
|
|
136
60
|
defaultValue?: InputValue;
|
|
@@ -159,6 +83,9 @@
|
|
|
159
83
|
title?: string;
|
|
160
84
|
id?: string;
|
|
161
85
|
invalid?: boolean;
|
|
86
|
+
/** invalid 时显示的内置错误文字;默认不生成。 */
|
|
87
|
+
error?: string | Snippet;
|
|
88
|
+
parts?: ComponentPartsOf<{ Text: typeof Text }>;
|
|
162
89
|
onclick?: (event: MouseEvent) => void;
|
|
163
90
|
ondblclick?: (event: MouseEvent) => void;
|
|
164
91
|
oninput?: (event: Event) => void;
|
|
@@ -171,7 +98,7 @@
|
|
|
171
98
|
onpaste?: (event: ClipboardEvent) => void;
|
|
172
99
|
oncopy?: (event: ClipboardEvent) => void;
|
|
173
100
|
oncut?: (event: ClipboardEvent) => void;
|
|
174
|
-
children?:
|
|
101
|
+
children?: Snippet;
|
|
175
102
|
/**
|
|
176
103
|
* 仅当 `as="search"` 且位于 `<Listbox>` 内时生效。
|
|
177
104
|
* 启用后,搜索无匹配时按 Enter 可将用户输入的文本作为自定义选项添加并选中。
|
|
@@ -180,9 +107,13 @@
|
|
|
180
107
|
[key: string]: any;
|
|
181
108
|
}
|
|
182
109
|
|
|
110
|
+
const inheritedInputPart = useComponentPart<Props>("Input");
|
|
183
111
|
let {
|
|
184
|
-
type = "text",
|
|
185
112
|
value = $bindable(),
|
|
113
|
+
...explicitProps
|
|
114
|
+
}: Props = $props();
|
|
115
|
+
let {
|
|
116
|
+
type = "text",
|
|
186
117
|
defaultValue = undefined,
|
|
187
118
|
placeholder = undefined,
|
|
188
119
|
name = undefined,
|
|
@@ -209,6 +140,8 @@
|
|
|
209
140
|
title = undefined,
|
|
210
141
|
id = undefined,
|
|
211
142
|
invalid = false,
|
|
143
|
+
error = undefined,
|
|
144
|
+
parts = undefined,
|
|
212
145
|
onclick: userOnClick = undefined,
|
|
213
146
|
ondblclick: userOnDoubleClick = undefined,
|
|
214
147
|
oninput: userOnInput = undefined,
|
|
@@ -231,7 +164,12 @@
|
|
|
231
164
|
children = undefined,
|
|
232
165
|
allowCustomValue = false,
|
|
233
166
|
...rest
|
|
234
|
-
}: Props = $
|
|
167
|
+
}: Omit<Props, "value"> = $derived(
|
|
168
|
+
mergeComponentPartProps(
|
|
169
|
+
inheritedInputPart.current as Partial<Omit<Props, "value">>,
|
|
170
|
+
explicitProps,
|
|
171
|
+
),
|
|
172
|
+
);
|
|
235
173
|
|
|
236
174
|
const splitProps = $derived.by(() => splitFrameHostProps(rest));
|
|
237
175
|
const frameRestProps = $derived(splitProps.frameProps);
|
|
@@ -249,6 +187,7 @@
|
|
|
249
187
|
skipTypes: ["file"],
|
|
250
188
|
});
|
|
251
189
|
let didApplyAutofocus = false;
|
|
190
|
+
let errorLayoutWidth = $state<string>();
|
|
252
191
|
|
|
253
192
|
const resolvedValue = $derived(
|
|
254
193
|
resolveFrameFieldValue(value, defaultValue, fieldControlOptions),
|
|
@@ -256,6 +195,20 @@
|
|
|
256
195
|
const resolvedInvalid = $derived(
|
|
257
196
|
resolveFrameFieldInvalid(invalid, inputRestProps),
|
|
258
197
|
);
|
|
198
|
+
const hasBuiltInError = $derived(error !== undefined);
|
|
199
|
+
|
|
200
|
+
$effect(() => {
|
|
201
|
+
if (!hasBuiltInError || !hostElement) {
|
|
202
|
+
errorLayoutWidth = undefined;
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
const update = () => {
|
|
206
|
+
if (!hostElement) return;
|
|
207
|
+
errorLayoutWidth = `${hostElement.getBoundingClientRect().width}px`;
|
|
208
|
+
};
|
|
209
|
+
update();
|
|
210
|
+
return resizeManager.watch(hostElement, update);
|
|
211
|
+
});
|
|
259
212
|
const isCustomColorType = $derived(normalizedInputType === "color");
|
|
260
213
|
const isCustomTemporalType = $derived(
|
|
261
214
|
normalizedInputType === "date" ||
|
|
@@ -290,8 +243,14 @@
|
|
|
290
243
|
const listboxOwner = getListboxOwner();
|
|
291
244
|
const isListboxSearch = $derived(rest.as === "search" && !!listboxOwner);
|
|
292
245
|
const listboxHeaderPortal = getListboxHeaderPortal();
|
|
246
|
+
// 浮层搜索头:as="search" 且存在 header portal(Listbox / Popover 等任意浮层提供)
|
|
247
|
+
const isOverlaySearchHeader = $derived(
|
|
248
|
+
rest.as === "search" && !!listboxHeaderPortal?.el,
|
|
249
|
+
);
|
|
293
250
|
// as="search" 时若未显式设置 maxlength,默认限制 100 字符
|
|
294
|
-
const resolvedMaxlength = $derived(
|
|
251
|
+
const resolvedMaxlength = $derived(
|
|
252
|
+
isOverlaySearchHeader ? (maxlength ?? 100) : maxlength,
|
|
253
|
+
);
|
|
295
254
|
const embeddedRoleClass = $derived.by(() => {
|
|
296
255
|
const role = rest.as;
|
|
297
256
|
if (typeof role !== "string" || !role.trim()) return "";
|
|
@@ -304,9 +263,9 @@
|
|
|
304
263
|
isEmbedded && !isCustomColorType && !isCustomTemporalType,
|
|
305
264
|
);
|
|
306
265
|
let hostElement = $state<HTMLElement | undefined>(undefined);
|
|
307
|
-
// as="search"
|
|
266
|
+
// as="search" 时自动移入浮层 header 区域(固定置顶,不随内容滚动)
|
|
308
267
|
$effect(() => {
|
|
309
|
-
if (!
|
|
268
|
+
if (!isOverlaySearchHeader || !listboxHeaderPortal?.el || !hostElement) return;
|
|
310
269
|
listboxHeaderPortal.el.appendChild(hostElement);
|
|
311
270
|
});
|
|
312
271
|
let nativeInputElement = $state<HTMLInputElement | undefined>(undefined);
|
|
@@ -330,6 +289,35 @@
|
|
|
330
289
|
let hasCustomStepperUp = $state(false);
|
|
331
290
|
let hasCustomStepperDown = $state(false);
|
|
332
291
|
let hasCustomTrailing = $state(false);
|
|
292
|
+
let horizontalScrollMask = $state<"left" | "right" | "both" | undefined>(undefined);
|
|
293
|
+
|
|
294
|
+
function updateHorizontalScrollMask() {
|
|
295
|
+
const el = nativeInputElement;
|
|
296
|
+
if (!el || isCustomColorType || isCustomTemporalType) {
|
|
297
|
+
horizontalScrollMask = undefined;
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
horizontalScrollMask = el.scrollWidth > el.clientWidth + 1
|
|
301
|
+
? "both"
|
|
302
|
+
: undefined;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
$effect(() => {
|
|
306
|
+
const el = nativeInputElement;
|
|
307
|
+
if (!el || isCustomColorType || isCustomTemporalType) return;
|
|
308
|
+
updateHorizontalScrollMask();
|
|
309
|
+
el.addEventListener("scroll", updateHorizontalScrollMask);
|
|
310
|
+
const unwatch = resizeManager.watch(el, updateHorizontalScrollMask);
|
|
311
|
+
return () => {
|
|
312
|
+
el.removeEventListener("scroll", updateHorizontalScrollMask);
|
|
313
|
+
unwatch();
|
|
314
|
+
};
|
|
315
|
+
});
|
|
316
|
+
|
|
317
|
+
$effect(() => {
|
|
318
|
+
resolvedValue;
|
|
319
|
+
queueMicrotask(updateHorizontalScrollMask);
|
|
320
|
+
});
|
|
333
321
|
|
|
334
322
|
const stepperCurrentValue = $derived(
|
|
335
323
|
normalizedInputType === "number" &&
|
|
@@ -395,7 +383,7 @@
|
|
|
395
383
|
normalizeColorValue(resolvedValue) ?? "#000000",
|
|
396
384
|
);
|
|
397
385
|
const colorHexValue = $derived(colorDisplayValue.slice(1));
|
|
398
|
-
const
|
|
386
|
+
const temporalDefaultIconName = $derived(
|
|
399
387
|
getTemporalDefaultIcon(temporalInputType),
|
|
400
388
|
);
|
|
401
389
|
|
|
@@ -415,6 +403,7 @@
|
|
|
415
403
|
const v = (event.currentTarget as HTMLInputElement)?.value ?? "";
|
|
416
404
|
listboxOwner!.setFilterText(v);
|
|
417
405
|
}
|
|
406
|
+
queueMicrotask(updateHorizontalScrollMask);
|
|
418
407
|
userOnInput?.(event);
|
|
419
408
|
}
|
|
420
409
|
|
|
@@ -426,7 +415,11 @@
|
|
|
426
415
|
function handleClear() {
|
|
427
416
|
value = "";
|
|
428
417
|
if (isListboxSearch) listboxOwner?.setFilterText("");
|
|
429
|
-
nativeInputElement
|
|
418
|
+
if (nativeInputElement) {
|
|
419
|
+
nativeInputElement.value = "";
|
|
420
|
+
nativeInputElement.focus();
|
|
421
|
+
}
|
|
422
|
+
queueMicrotask(updateHorizontalScrollMask);
|
|
430
423
|
emitSyntheticInput();
|
|
431
424
|
emitSyntheticChange();
|
|
432
425
|
}
|
|
@@ -499,11 +492,11 @@
|
|
|
499
492
|
emitSyntheticChange();
|
|
500
493
|
}
|
|
501
494
|
function emitSyntheticChange() {
|
|
502
|
-
|
|
495
|
+
nativeInputElement?.dispatchEvent(new Event("change", { bubbles: true }));
|
|
503
496
|
}
|
|
504
497
|
|
|
505
498
|
function emitSyntheticInput() {
|
|
506
|
-
|
|
499
|
+
nativeInputElement?.dispatchEvent(new Event("input", { bubbles: true }));
|
|
507
500
|
}
|
|
508
501
|
|
|
509
502
|
function getTemporalSegments(inputType: TemporalInputType | null) {
|
|
@@ -511,7 +504,7 @@
|
|
|
511
504
|
}
|
|
512
505
|
|
|
513
506
|
function getTemporalDefaultIcon(inputType: TemporalInputType | null) {
|
|
514
|
-
return inputType === "time" ?
|
|
507
|
+
return inputType === "time" ? "clock" : "calendar-blank";
|
|
515
508
|
}
|
|
516
509
|
|
|
517
510
|
function getTemporalTriggerLabel(inputType: TemporalInputType | null) {
|
|
@@ -1257,11 +1250,20 @@
|
|
|
1257
1250
|
}
|
|
1258
1251
|
|
|
1259
1252
|
const update = () => {
|
|
1260
|
-
|
|
1261
|
-
(
|
|
1262
|
-
child instanceof HTMLElement &&
|
|
1263
|
-
child.matches(".snowui-button.snowui-role-trailing"),
|
|
1253
|
+
const hasRootTrailing = !!host.querySelector(
|
|
1254
|
+
':scope > [data-as="trailing"]:not(.snowui-input-warning-icon):not(.snowui-input-clear-btn)',
|
|
1264
1255
|
);
|
|
1256
|
+
const hasSiblingTrailing = Array.from(scope.children).some(
|
|
1257
|
+
(child) => {
|
|
1258
|
+
if (!(child instanceof HTMLElement) || child === host) {
|
|
1259
|
+
return false;
|
|
1260
|
+
}
|
|
1261
|
+
return child.matches(
|
|
1262
|
+
'[data-as="trailing"], .snowui-role-trailing',
|
|
1263
|
+
);
|
|
1264
|
+
},
|
|
1265
|
+
);
|
|
1266
|
+
hasTemporalTrigger = hasRootTrailing || hasSiblingTrailing;
|
|
1265
1267
|
};
|
|
1266
1268
|
|
|
1267
1269
|
update();
|
|
@@ -1272,7 +1274,7 @@
|
|
|
1272
1274
|
childList: true,
|
|
1273
1275
|
subtree: true,
|
|
1274
1276
|
attributes: true,
|
|
1275
|
-
attributeFilter: ["class"],
|
|
1277
|
+
attributeFilter: ["class", "data-as"],
|
|
1276
1278
|
});
|
|
1277
1279
|
|
|
1278
1280
|
return () => {
|
|
@@ -1287,7 +1289,7 @@
|
|
|
1287
1289
|
const updateTrailing = () => {
|
|
1288
1290
|
// 检测是否存在用户自定义的 trailing 元素 (排除内置的 stepper 按钮、Warning 和内置 clear 按钮)
|
|
1289
1291
|
hasCustomTrailing = !!host.querySelector(
|
|
1290
|
-
'[data-as="trailing"]:not(.snowui-input-warning-icon):not(.snowui-input-clear-btn)',
|
|
1292
|
+
':scope > [data-as="trailing"]:not(.snowui-input-warning-icon):not(.snowui-input-clear-btn)',
|
|
1291
1293
|
);
|
|
1292
1294
|
};
|
|
1293
1295
|
|
|
@@ -1369,6 +1371,7 @@
|
|
|
1369
1371
|
});
|
|
1370
1372
|
</script>
|
|
1371
1373
|
|
|
1374
|
+
{#snippet inputSurface()}
|
|
1372
1375
|
{#if rendersEmbeddedNativeHost}
|
|
1373
1376
|
<div
|
|
1374
1377
|
bind:this={hostElement}
|
|
@@ -1376,6 +1379,7 @@
|
|
|
1376
1379
|
data-auto-layout="true"
|
|
1377
1380
|
data-as={typeof rest.as === "string" ? rest.as : undefined}
|
|
1378
1381
|
data-embedded={isEmbedded ? "true" : undefined}
|
|
1382
|
+
data-field-control={isEmbedded ? "input" : undefined}
|
|
1379
1383
|
data-has-root-accessory={(hasRootAccessory || (resolvedInvalid && !hasCustomTrailing))
|
|
1380
1384
|
? "true"
|
|
1381
1385
|
: undefined}
|
|
@@ -1390,7 +1394,8 @@
|
|
|
1390
1394
|
<input
|
|
1391
1395
|
{...inputRestProps}
|
|
1392
1396
|
bind:this={nativeInputElement}
|
|
1393
|
-
class="snowui-input-control snowui-input-embedded-native"
|
|
1397
|
+
class="snowui-input-control snowui-input-embedded-native snowui-horizontal-scroll-mask"
|
|
1398
|
+
data-scroll-mask-x={horizontalScrollMask}
|
|
1394
1399
|
{id}
|
|
1395
1400
|
type={normalizedInputType}
|
|
1396
1401
|
{name}
|
|
@@ -1437,21 +1442,14 @@
|
|
|
1437
1442
|
{#if isClearableType && !disabled && !readonly}
|
|
1438
1443
|
<button
|
|
1439
1444
|
type="button"
|
|
1440
|
-
class="snowui-input-clear-btn"
|
|
1445
|
+
class="snowui-clear-icon-btn snowui-input-clear-btn"
|
|
1441
1446
|
data-as="trailing"
|
|
1442
1447
|
aria-label="清除输入"
|
|
1443
1448
|
onclick={handleClear}
|
|
1444
1449
|
onmousedown={(e) => e.preventDefault()}
|
|
1445
1450
|
tabindex={-1}
|
|
1446
1451
|
>
|
|
1447
|
-
<
|
|
1448
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
1449
|
-
viewBox="0 0 32 32"
|
|
1450
|
-
aria-hidden="true"
|
|
1451
|
-
focusable="false"
|
|
1452
|
-
>
|
|
1453
|
-
<path fill="currentColor" d="M16 3a13 13 0 1 0 13 13A13.013 13.013 0 0 0 16 3m4.708 16.293a1 1 0 0 1-1.415 1.415L16 17.414l-3.293 3.293a1 1 0 0 1-1.415-1.415L14.587 16l-3.293-3.293a1 1 0 1 1 1.415-1.415L16 14.587l3.293-3.293a1 1 0 0 1 1.415 1.415L17.414 16z"/>
|
|
1454
|
-
</svg>
|
|
1452
|
+
<ResourceIcon name="x-circle" weight="fill" size={16} aria-hidden="true" />
|
|
1455
1453
|
</button>
|
|
1456
1454
|
{/if}
|
|
1457
1455
|
{#if resolvedInvalid && !hasCustomTrailing}
|
|
@@ -1459,7 +1457,7 @@
|
|
|
1459
1457
|
class="snowui-input-warning-icon snowui-role-trailing text-secondary-red"
|
|
1460
1458
|
aria-hidden="true"
|
|
1461
1459
|
>
|
|
1462
|
-
<
|
|
1460
|
+
<ResourceIcon name="warning" size={16} aria-hidden="true" />
|
|
1463
1461
|
</span>
|
|
1464
1462
|
{/if}
|
|
1465
1463
|
</div>
|
|
@@ -1467,8 +1465,7 @@
|
|
|
1467
1465
|
<Frame
|
|
1468
1466
|
bind:element={hostElement}
|
|
1469
1467
|
tag="div"
|
|
1470
|
-
|
|
1471
|
-
class={`snowui-input${isEmbedded ? " snowui-field-host" : ""}${hasRootAccessory ? " snowui-input-has-root-accessory" : ""}${userClass ? ` ${userClass}` : ""}`}
|
|
1468
|
+
class={`snowui-input${isEmbedded ? " snowui-field-host" : " snowui-field-bordered"}${hasRootAccessory ? " snowui-input-has-root-accessory" : ""}${userClass ? ` ${userClass}` : ""}`}
|
|
1472
1469
|
data-invalid={resolvedInvalid ? "true" : undefined}
|
|
1473
1470
|
data-readonly={readonly ? "true" : undefined}
|
|
1474
1471
|
data-input-type={normalizedInputType}
|
|
@@ -1477,6 +1474,7 @@
|
|
|
1477
1474
|
data-temporal-empty={isTemporalValueEmpty ? "true" : undefined}
|
|
1478
1475
|
data-has-temporal-trigger={hasTemporalTrigger ? "true" : undefined}
|
|
1479
1476
|
data-embedded={isEmbedded ? "true" : undefined}
|
|
1477
|
+
data-field-control={isEmbedded ? "input" : undefined}
|
|
1480
1478
|
data-has-root-accessory={hasRootAccessory ? "true" : undefined}
|
|
1481
1479
|
data-has-value={hasClearableValue ? "true" : undefined}
|
|
1482
1480
|
{disabled}
|
|
@@ -1636,7 +1634,7 @@
|
|
|
1636
1634
|
{disabled}
|
|
1637
1635
|
tabindex={disabled ? undefined : -1}
|
|
1638
1636
|
>
|
|
1639
|
-
<
|
|
1637
|
+
<ResourceIcon name={temporalDefaultIconName} size={16} aria-hidden="true" />
|
|
1640
1638
|
</button>
|
|
1641
1639
|
{/if}
|
|
1642
1640
|
</div>
|
|
@@ -1645,7 +1643,8 @@
|
|
|
1645
1643
|
<input
|
|
1646
1644
|
{...inputRestProps}
|
|
1647
1645
|
bind:this={nativeInputElement}
|
|
1648
|
-
class="snowui-input-control"
|
|
1646
|
+
class="snowui-input-control snowui-horizontal-scroll-mask"
|
|
1647
|
+
data-scroll-mask-x={horizontalScrollMask}
|
|
1649
1648
|
{id}
|
|
1650
1649
|
type={normalizedInputType}
|
|
1651
1650
|
{name}
|
|
@@ -1707,7 +1706,7 @@
|
|
|
1707
1706
|
onclick={handleStepUp}
|
|
1708
1707
|
onmousedown={(e) => e.preventDefault()}
|
|
1709
1708
|
>
|
|
1710
|
-
<
|
|
1709
|
+
<ResourceIcon name="arrow-line-up" size={16} aria-hidden="true" />
|
|
1711
1710
|
</button>
|
|
1712
1711
|
{/if}
|
|
1713
1712
|
{#if !hasCustomStepperDown}
|
|
@@ -1720,7 +1719,7 @@
|
|
|
1720
1719
|
onclick={handleStepDown}
|
|
1721
1720
|
onmousedown={(e) => e.preventDefault()}
|
|
1722
1721
|
>
|
|
1723
|
-
<
|
|
1722
|
+
<ResourceIcon name="arrow-line-down" size={16} aria-hidden="true" />
|
|
1724
1723
|
</button>
|
|
1725
1724
|
{/if}
|
|
1726
1725
|
{@render children?.()}
|
|
@@ -1729,7 +1728,7 @@
|
|
|
1729
1728
|
class="snowui-input-warning-icon snowui-role-trailing text-secondary-red"
|
|
1730
1729
|
aria-hidden="true"
|
|
1731
1730
|
>
|
|
1732
|
-
<
|
|
1731
|
+
<ResourceIcon name="warning" size={16} aria-hidden="true" />
|
|
1733
1732
|
</span>
|
|
1734
1733
|
{/if}
|
|
1735
1734
|
</div>
|
|
@@ -1738,21 +1737,14 @@
|
|
|
1738
1737
|
{#if isClearableType && !disabled && !readonly}
|
|
1739
1738
|
<button
|
|
1740
1739
|
type="button"
|
|
1741
|
-
class="snowui-input-clear-btn"
|
|
1740
|
+
class="snowui-clear-icon-btn snowui-input-clear-btn"
|
|
1742
1741
|
data-as="trailing"
|
|
1743
1742
|
aria-label="清除输入"
|
|
1744
1743
|
onclick={handleClear}
|
|
1745
1744
|
onmousedown={(e) => e.preventDefault()}
|
|
1746
1745
|
tabindex={-1}
|
|
1747
1746
|
>
|
|
1748
|
-
<
|
|
1749
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
1750
|
-
viewBox="0 0 32 32"
|
|
1751
|
-
aria-hidden="true"
|
|
1752
|
-
focusable="false"
|
|
1753
|
-
>
|
|
1754
|
-
<path fill="currentColor" d="M16 3a13 13 0 1 0 13 13A13.013 13.013 0 0 0 16 3m4.708 16.293a1 1 0 0 1-1.415 1.415L16 17.414l-3.293 3.293a1 1 0 0 1-1.415-1.415L14.587 16l-3.293-3.293a1 1 0 1 1 1.415-1.415L16 14.587l3.293-3.293a1 1 0 0 1 1.415 1.415L17.414 16z"/>
|
|
1755
|
-
</svg>
|
|
1747
|
+
<ResourceIcon name="x-circle" weight="fill" size={16} aria-hidden="true" />
|
|
1756
1748
|
</button>
|
|
1757
1749
|
{/if}
|
|
1758
1750
|
{#if resolvedInvalid && !hasCustomTrailing}
|
|
@@ -1760,12 +1752,35 @@
|
|
|
1760
1752
|
class="snowui-input-warning-icon snowui-role-trailing text-secondary-red"
|
|
1761
1753
|
aria-hidden="true"
|
|
1762
1754
|
>
|
|
1763
|
-
<
|
|
1755
|
+
<ResourceIcon name="warning" size={16} aria-hidden="true" />
|
|
1764
1756
|
</span>
|
|
1765
1757
|
{/if}
|
|
1766
1758
|
{/if}
|
|
1767
1759
|
</Frame>
|
|
1768
1760
|
{/if}
|
|
1761
|
+
{/snippet}
|
|
1762
|
+
|
|
1763
|
+
{#if hasBuiltInError}
|
|
1764
|
+
<div
|
|
1765
|
+
class="snowui-input-error-layout"
|
|
1766
|
+
style:width={errorLayoutWidth}
|
|
1767
|
+
>
|
|
1768
|
+
{@render inputSurface()}
|
|
1769
|
+
<Text
|
|
1770
|
+
{...parts?.Text}
|
|
1771
|
+
as="error"
|
|
1772
|
+
class={`snowui-input-error${parts?.Text?.class ? ` ${parts.Text.class}` : ""}`}
|
|
1773
|
+
>
|
|
1774
|
+
{#if typeof error === "function"}
|
|
1775
|
+
{@render error()}
|
|
1776
|
+
{:else}
|
|
1777
|
+
{error}
|
|
1778
|
+
{/if}
|
|
1779
|
+
</Text>
|
|
1780
|
+
</div>
|
|
1781
|
+
{:else}
|
|
1782
|
+
{@render inputSurface()}
|
|
1783
|
+
{/if}
|
|
1769
1784
|
|
|
1770
1785
|
<style>
|
|
1771
1786
|
:global(:where(.snowui-input)) {
|
|
@@ -1774,6 +1789,7 @@
|
|
|
1774
1789
|
flex-wrap: nowrap;
|
|
1775
1790
|
align-items: center;
|
|
1776
1791
|
position: relative;
|
|
1792
|
+
cursor: var(--snowui-field-cursor, text);
|
|
1777
1793
|
--snowui-input-width: 100%;
|
|
1778
1794
|
--snowui-input-height: auto;
|
|
1779
1795
|
--snowui-input-radius: var(--radius-4);
|
|
@@ -1805,9 +1821,66 @@
|
|
|
1805
1821
|
--snowui-input-background-override,
|
|
1806
1822
|
var(--snowui-input-background)
|
|
1807
1823
|
);
|
|
1824
|
+
font-size: var(
|
|
1825
|
+
--snowui-input-font-size-override,
|
|
1826
|
+
var(--snowui-input-font-size)
|
|
1827
|
+
);
|
|
1828
|
+
line-height: var(
|
|
1829
|
+
--snowui-input-line-height-override,
|
|
1830
|
+
var(--snowui-input-line-height)
|
|
1831
|
+
);
|
|
1808
1832
|
box-sizing: border-box;
|
|
1809
1833
|
}
|
|
1810
1834
|
|
|
1835
|
+
:global(:where(.snowui-input-error-layout)) {
|
|
1836
|
+
display: grid;
|
|
1837
|
+
grid-template-columns: minmax(0, 1fr);
|
|
1838
|
+
align-items: start;
|
|
1839
|
+
gap: 0;
|
|
1840
|
+
min-width: 0;
|
|
1841
|
+
max-width: 100%;
|
|
1842
|
+
}
|
|
1843
|
+
|
|
1844
|
+
:global(:where(.snowui-input-error-layout > .snowui-input)) {
|
|
1845
|
+
width: 100%;
|
|
1846
|
+
}
|
|
1847
|
+
|
|
1848
|
+
:global(:where(.snowui-input-error-layout > .snowui-input-error)) {
|
|
1849
|
+
display: none;
|
|
1850
|
+
width: 100%;
|
|
1851
|
+
padding: 0;
|
|
1852
|
+
color: var(--secondary-red, #ff4747ff);
|
|
1853
|
+
font-size: var(--text-12);
|
|
1854
|
+
line-height: var(--leading-12);
|
|
1855
|
+
box-sizing: border-box;
|
|
1856
|
+
}
|
|
1857
|
+
|
|
1858
|
+
:global(
|
|
1859
|
+
:where(
|
|
1860
|
+
.snowui-input-error-layout:has(
|
|
1861
|
+
> .snowui-input[data-invalid="true"]
|
|
1862
|
+
)
|
|
1863
|
+
)
|
|
1864
|
+
) {
|
|
1865
|
+
gap: var(--gap-2);
|
|
1866
|
+
}
|
|
1867
|
+
|
|
1868
|
+
:global(
|
|
1869
|
+
:where(
|
|
1870
|
+
.snowui-input-error-layout
|
|
1871
|
+
> .snowui-input[data-invalid="true"]
|
|
1872
|
+
+ .snowui-input-error
|
|
1873
|
+
)
|
|
1874
|
+
) {
|
|
1875
|
+
display: block;
|
|
1876
|
+
}
|
|
1877
|
+
|
|
1878
|
+
:global(:where(.snowui-input.snowui-search-input-borderless)) {
|
|
1879
|
+
--snowui-input-padding-y: 0rem;
|
|
1880
|
+
--snowui-input-padding-x: 0rem;
|
|
1881
|
+
--snowui-input-radius-override: 0rem;
|
|
1882
|
+
}
|
|
1883
|
+
|
|
1811
1884
|
/* 所有嵌入态 Input 外层 div 不持有自身 padding,避免与内层 control 的 override padding 叠加 */
|
|
1812
1885
|
:global(:where(.snowui-input[data-embedded="true"])) {
|
|
1813
1886
|
padding: 0;
|
|
@@ -2062,7 +2135,7 @@
|
|
|
2062
2135
|
grid-row: 1;
|
|
2063
2136
|
grid-column: -2 / -1;
|
|
2064
2137
|
display: inline-flex;
|
|
2065
|
-
align-items:
|
|
2138
|
+
align-items: inherit;
|
|
2066
2139
|
justify-content: center;
|
|
2067
2140
|
gap: var(--snowui-input-gap);
|
|
2068
2141
|
min-width: 0;
|
|
@@ -2108,7 +2181,7 @@
|
|
|
2108
2181
|
grid-row: 1;
|
|
2109
2182
|
grid-column: 1;
|
|
2110
2183
|
display: inline-flex;
|
|
2111
|
-
align-items:
|
|
2184
|
+
align-items: inherit;
|
|
2112
2185
|
justify-content: center;
|
|
2113
2186
|
gap: var(--snowui-input-gap);
|
|
2114
2187
|
min-width: 0;
|
|
@@ -2179,14 +2252,8 @@
|
|
|
2179
2252
|
outline: none;
|
|
2180
2253
|
background: transparent;
|
|
2181
2254
|
color: inherit;
|
|
2182
|
-
font-size:
|
|
2183
|
-
|
|
2184
|
-
var(--snowui-input-font-size)
|
|
2185
|
-
);
|
|
2186
|
-
line-height: var(
|
|
2187
|
-
--snowui-input-line-height-override,
|
|
2188
|
-
var(--snowui-input-line-height)
|
|
2189
|
-
);
|
|
2255
|
+
font-size: inherit;
|
|
2256
|
+
line-height: inherit;
|
|
2190
2257
|
caret-color: currentColor;
|
|
2191
2258
|
-webkit-appearance: none;
|
|
2192
2259
|
appearance: none;
|
|
@@ -2227,14 +2294,8 @@
|
|
|
2227
2294
|
width: 100%;
|
|
2228
2295
|
position: relative;
|
|
2229
2296
|
color: inherit;
|
|
2230
|
-
font-size:
|
|
2231
|
-
|
|
2232
|
-
var(--snowui-input-font-size)
|
|
2233
|
-
);
|
|
2234
|
-
line-height: var(
|
|
2235
|
-
--snowui-input-line-height-override,
|
|
2236
|
-
var(--snowui-input-line-height)
|
|
2237
|
-
);
|
|
2297
|
+
font-size: inherit;
|
|
2298
|
+
line-height: inherit;
|
|
2238
2299
|
caret-color: currentColor;
|
|
2239
2300
|
user-select: text;
|
|
2240
2301
|
box-sizing: border-box;
|
|
@@ -2451,7 +2512,7 @@
|
|
|
2451
2512
|
grid-row: 1;
|
|
2452
2513
|
grid-column: -2 / -1;
|
|
2453
2514
|
justify-self: center;
|
|
2454
|
-
align-self:
|
|
2515
|
+
align-self: auto;
|
|
2455
2516
|
}
|
|
2456
2517
|
|
|
2457
2518
|
:global(:where(.snowui-input-warning-icon svg)) {
|
|
@@ -2638,38 +2699,89 @@
|
|
|
2638
2699
|
display: none;
|
|
2639
2700
|
}
|
|
2640
2701
|
|
|
2641
|
-
/* ─── Clear (X) 按钮
|
|
2702
|
+
/* ─── Clear (X) 按钮 ─────────────────────────────────────────
|
|
2703
|
+
* 视觉/交互复用共享基类 .snowui-clear-icon-btn(layout.css)。
|
|
2704
|
+
* 此处仅保留 Input 专属的 grid 落列与默认隐藏;显示时机由下方
|
|
2705
|
+
* focus-within 规则接管。 */
|
|
2642
2706
|
|
|
2643
2707
|
:global(:where(.snowui-input-clear-btn)) {
|
|
2644
2708
|
display: none;
|
|
2645
2709
|
grid-row: 1;
|
|
2646
2710
|
grid-column: -2 / -1;
|
|
2647
2711
|
justify-self: center;
|
|
2648
|
-
align-self:
|
|
2649
|
-
|
|
2650
|
-
width: var(--size-4, 1rem);
|
|
2651
|
-
height: var(--size-4, 1rem);
|
|
2652
|
-
padding: 0;
|
|
2653
|
-
border: none;
|
|
2654
|
-
border-radius: var(--radius-full);
|
|
2655
|
-
background: transparent;
|
|
2656
|
-
color: var(--black-100, #000000ff);
|
|
2657
|
-
opacity: var(--snowui-state-opacity, 0.4);
|
|
2658
|
-
cursor: pointer;
|
|
2659
|
-
line-height: inherit;
|
|
2660
|
-
transition:
|
|
2661
|
-
color var(--snowui-frame-color-motion-duration, 0.15s) var(--snowui-frame-color-motion-easing, ease-out),
|
|
2662
|
-
opacity var(--snowui-frame-color-motion-duration, 0.15s) var(--snowui-frame-color-motion-easing, ease-out);
|
|
2712
|
+
align-self: auto;
|
|
2713
|
+
z-index: 2;
|
|
2663
2714
|
}
|
|
2664
2715
|
|
|
2665
|
-
|
|
2666
|
-
|
|
2716
|
+
/* 普通 Input 的内置清除 X 与 control 共用同一网格列,X 显隐不新增轨道,
|
|
2717
|
+
避免 shrink-to-fit 宿主宽度变化。SearchInput borderless 继续使用自身的
|
|
2718
|
+
预留列策略。 */
|
|
2719
|
+
:global(
|
|
2720
|
+
.snowui-input:not(.snowui-search-input-borderless)[data-has-root-accessory="true"]:has(
|
|
2721
|
+
> .snowui-input-clear-btn
|
|
2722
|
+
):not(:has(> [data-as="leading"])):not(
|
|
2723
|
+
:has(
|
|
2724
|
+
> [data-as="trailing"]:not(
|
|
2725
|
+
.snowui-input-clear-btn
|
|
2726
|
+
),
|
|
2727
|
+
> .snowui-input-warning-icon,
|
|
2728
|
+
> .snowui-input-stepper
|
|
2729
|
+
)
|
|
2730
|
+
)
|
|
2731
|
+
) {
|
|
2732
|
+
grid-template-columns: minmax(0, 1fr);
|
|
2733
|
+
gap: 0;
|
|
2667
2734
|
}
|
|
2668
2735
|
|
|
2669
|
-
:global(
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2736
|
+
:global(
|
|
2737
|
+
.snowui-input:not(.snowui-search-input-borderless)[data-has-root-accessory="true"]:has(
|
|
2738
|
+
> .snowui-input-clear-btn
|
|
2739
|
+
):has(> [data-as="leading"]):not(
|
|
2740
|
+
:has(
|
|
2741
|
+
> [data-as="trailing"]:not(
|
|
2742
|
+
.snowui-input-clear-btn
|
|
2743
|
+
),
|
|
2744
|
+
> .snowui-input-warning-icon,
|
|
2745
|
+
> .snowui-input-stepper
|
|
2746
|
+
)
|
|
2747
|
+
)
|
|
2748
|
+
) {
|
|
2749
|
+
grid-template-columns: auto minmax(0, 1fr);
|
|
2750
|
+
gap: var(
|
|
2751
|
+
--snowui-input-gap-override,
|
|
2752
|
+
var(--snowui-input-gap)
|
|
2753
|
+
);
|
|
2754
|
+
}
|
|
2755
|
+
|
|
2756
|
+
:global(
|
|
2757
|
+
.snowui-input:not(.snowui-search-input-borderless)[data-has-root-accessory="true"]:has(
|
|
2758
|
+
> .snowui-input-clear-btn
|
|
2759
|
+
):not(
|
|
2760
|
+
:has(
|
|
2761
|
+
> [data-as="trailing"]:not(
|
|
2762
|
+
.snowui-input-clear-btn
|
|
2763
|
+
),
|
|
2764
|
+
> .snowui-input-warning-icon,
|
|
2765
|
+
> .snowui-input-stepper
|
|
2766
|
+
)
|
|
2767
|
+
)
|
|
2768
|
+
> .snowui-input-clear-btn
|
|
2769
|
+
) {
|
|
2770
|
+
justify-self: end;
|
|
2771
|
+
}
|
|
2772
|
+
|
|
2773
|
+
/* X 显示时,输入内容在靠近按钮的一侧渐隐。参数与 Table 表头 overlay
|
|
2774
|
+
checkbox 的内容渐隐一致:完全透明区 14px,26px 后恢复清晰。 */
|
|
2775
|
+
:global(
|
|
2776
|
+
:where(
|
|
2777
|
+
.snowui-input[data-has-value="true"]:focus-within:has(
|
|
2778
|
+
> .snowui-input-clear-btn
|
|
2779
|
+
)
|
|
2780
|
+
> .snowui-input-control.snowui-horizontal-scroll-mask
|
|
2781
|
+
)
|
|
2782
|
+
) {
|
|
2783
|
+
--snowui-input-horizontal-scroll-mask-right-transparent: 20px;
|
|
2784
|
+
--snowui-input-horizontal-scroll-mask-right-visible: 32px;
|
|
2673
2785
|
}
|
|
2674
2786
|
|
|
2675
2787
|
/* 独立 Input(非嵌入)焦点态 + 有内容 → 显示 X */
|
|
@@ -2722,11 +2834,12 @@
|
|
|
2722
2834
|
}
|
|
2723
2835
|
|
|
2724
2836
|
/*
|
|
2725
|
-
* ───
|
|
2726
|
-
* Listbox / QuickAction
|
|
2727
|
-
*
|
|
2837
|
+
* ─── 浮层搜索输入 ──────────────────────────────────────
|
|
2838
|
+
* Listbox / QuickAction 使用固定 header + 滚动 body 结构。
|
|
2839
|
+
* SearchPopup 直接在面板内组合 SearchInput。
|
|
2840
|
+
* 选择器覆盖移位前(列表内)、移位后(header 内)和 SearchPopup 内,确保浮层输入视觉一致。
|
|
2728
2841
|
*/
|
|
2729
|
-
:global(:where(.snowui-listbox-header > .snowui-input, .snowui-listbox > .snowui-input, .snowui-quick-action-header > .snowui-input, .snowui-quick-action-list > .snowui-input)) {
|
|
2842
|
+
:global(:where(.snowui-quick-action-panel-header > .snowui-input, .snowui-listbox-header > .snowui-input, .snowui-listbox > .snowui-input, .snowui-quick-action-header > .snowui-input, .snowui-quick-action-list > .snowui-input, .snowui-search-popup > .snowui-input)) {
|
|
2730
2843
|
--snowui-input-padding-y: var(--padding-2);
|
|
2731
2844
|
--snowui-input-padding-x: var(--padding-2);
|
|
2732
2845
|
--snowui-input-gap: var(--gap-2);
|
|
@@ -2734,7 +2847,7 @@
|
|
|
2734
2847
|
}
|
|
2735
2848
|
|
|
2736
2849
|
/* 焦点态:仅保留边框颜色变化,移除外扩阴影环 */
|
|
2737
|
-
:global(:where(.snowui-listbox-header > .snowui-input, .snowui-listbox > .snowui-input, .snowui-quick-action-header > .snowui-input, .snowui-quick-action-list > .snowui-input):focus-within) {
|
|
2850
|
+
:global(:where(.snowui-quick-action-panel-header > .snowui-input, .snowui-listbox-header > .snowui-input, .snowui-listbox > .snowui-input, .snowui-quick-action-header > .snowui-input, .snowui-quick-action-list > .snowui-input, .snowui-search-popup > .snowui-input):focus-within) {
|
|
2738
2851
|
--snowui-field-focus-ring-width: 0rem;
|
|
2739
2852
|
}
|
|
2740
2853
|
|