Files

17 KiB
Raw Permalink Blame History

05-forms-basic:checkbox / checkbox-group / radio-group / switch / slider / input / textarea / text-field / search-field

上游基线 ce90ea3(heroui/,只读)对照 heroui-vue/。路径均相对仓库根。示例名全局差异已由简报核过(仅 text-area↔textarea、text-field↔textfield 命名),下文不再重复。

checkbox

  • [示例] checkbox-form:提交反馈交互不同——UP 用 alert(\表单提交数据:\n…`)(heroui/apps/docs/src/demos/cn/checkbox/form.tsx L10-16),VUE 渲染行内结果

    {{ result }}

    `(heroui-vue/apps/docs/demos/checkbox-form.vue)。alert→行内输出为系统性差异(见小结)。
  • [示例] checkbox-custom-indicator:自定义指示器图形不同——UP 为内联 SVG(心形 path、加号 strokeWidth="3"、半选横线,custom-indicator.tsx L15-70),VUE 用 Tabler IconHeartFilled/IconPlus/IconMinus 且无尺寸类(checkbox-custom-indicator.vue)。UP svg 无宽高按容器填充,Tabler 默认 24px,呈现不同。
  • [示例] checkbox-group-with-custom-indicator:UP 内联 X SVG(M6 18L18 6M6 6l12 12,checkbox-group/with-custom-indicator.tsx),VUE 用 Tabler 图标(checkbox-group-with-custom-indicator.vue)。同上图标差异。
  • [API] value 默认值:UP 文档写 -((forms)/checkbox.mdx L217),实际原生/RAC 默认 'on';VUE 明确 'on'(checkbox.md L223)——UP 文档与自身代码不一致,VUE 更准确。
  • [API] validate 返回类型:UP ValidationError | true | null | undefined(checkbox.mdx L213),VUE string | string[] | true | null | undefined(checkbox.md L229);ValidationError 对象结构在 VUE 不支持(VUE 文档自述"暂不提供完整 validationDetails")。
  • [文档] 组件结构示例:UP 含 <FieldError /> {/* 可选 — 校验消息 */}(checkbox.mdx L37),VUE 结构示例无 FieldError(checkbox.md L44-52)。Hover 归属描述不同:UP"Checkbox.Control(按钮)上的 :hover"(checkbox.mdx L193),VUE"CheckboxContent(可点击标签)上的 :hover"(checkbox.md L206)。
  • [样式] motion-reduce 写法:UP @apply motion-reduce:transition-none(heroui/packages/styles/components/checkbox.css L78、L91)→ VUE 原生 @media (prefers-reduced-motion: reduce){transition:none}(heroui-vue/packages/styles/components/checkbox.css L84-86、L99-101)。语义等价(VUE 注释:Tailwind 4 嵌套伪变体可产出非法 :not(:is())),仅写法差异。cursor 规则逐条核对一致(.checkbox/.checkbox__control cursor:var(--cursor-interactive)、.checkbox__content[data-slot="label"] 同值、description/field-error cursor-default),未见差异。

checkbox-group

  • [示例] checkbox-group-validation:UP alert(\已选偏好:${values.join(", ")}`)(checkbox-group/validation.tsx L10-18),VUE 行内

    `(checkbox-group-validation.vue);结构/文案/props 一致。

  • [示例] checkbox-group-features-and-addons:VUE <section> 类多 max-sm:min-w-0(checkbox-group-features-and-addons.vue L34;UP features-and-addons.tsx L26 无),响应式行为差异(小);图标 gravity-ui Envelope/Comment/Bell → Tabler IconMail/IconMessage/IconBell。Content/Control 类经复核完全一致(demo_classes 的 clsx 拆分误报)。
  • [API] defaultValue 默认值:UP -((forms)/checkbox-group.mdx L137),VUE [](checkbox-group.md L153);UP 文档与 RAC 实际(空数组)不一致。
  • [API] UP 表格缺 validate/validationBehavior(RAC CheckboxGroup 自身支持),VUE 提供(checkbox-group.md L159-160);VUE 另增 form/id。
  • [文档] 结构示例:UP 有组级 <Description /> 与 name="interests"(checkbox-group.mdx L28-41),VUE 缺组级 Description 与 name(checkbox-group.md L46-58)。
  • [样式] checkbox-group.css 仅许可头差异;tv 映射一致(heroui/packages/styles/src/components/checkbox-group/checkbox-group.styles.ts ↔ heroui-vue/packages/styles/src/index.ts L602-615)。

radio-group

  • [示例] radio-group-validation:结果提示缺类名——UP <p className="text-sm text-muted">(radio-group/validation.tsx 末行),VUE <p role="status" class="text-sm">(radio-group-validation.vue),少 text-muted(可见视觉差异,小)。
  • [示例] radio-group-custom-indicator:选中指示器内容不同——UP <span className="text-xs leading-none text-background">✓</span>(radio-group/custom-indicator.tsx L15-19 等),VUE Tabler IconCheck class="size-3 text-background"(radio-group-custom-indicator.vue)。"✓"文本字形 vs 图标、尺寸类不同。
  • [API] UP 表格缺 validate/validationBehavior/dir/loop(RAC 支持),VUE 提供(radio-group.md L214-219)。
  • [文档] VUE 自身错误:RadioGroup variant 行误写"Checkbox 成员可显式覆盖"(radio-group.md L210);"事件与暴露"表沿用 CheckboxGroup 文案"发出新的数组或标量"(L237,RadioGroup 仅标量);L240 提交说明段以"CheckboxGroup 按原生约定…"开头(复用文本)。
  • [文档] UP 有 ## 相关案例 <RelatedShowcases component="RadioGroup" />((forms)/radio-group.mdx L249-251),VUE 无此章节。
  • [样式] radio.css/radio-group.css:motion-reduce 同 checkbox 的原生 media 重写(radio.css L55-57、L71-73、L140-142),语义等价;其余仅换行。tv 一致。

switch

  • [示例] switch-form:UP alert(\表单提交内容:\n…`)(switch/form.tsx L10-16);VUE 行内 ,并新增"重置"按钮(type="reset"+@click="result = ''")、空态文案"未选择任何选项"、分隔符由 \n` 改为","(switch-form.vue)。
  • [示例] switch-with-icons:aria-label 不同——UP aria-label={key}("check"/"darkMode"/"microphone"/"notification"/"volume" 英文 key,switch/with-icons.tsx L45),VUE 中文标签"电源/深色模式/静音麦克风/通知/静音音量"(switch-with-icons.vue);容器 flex gap-3→flex flex-wrap gap-3;图标 gravity-ui→Tabler;opacity-100/70 改为动态 class(渲染等价)。
  • [API] UP SwitchFieldRenderProps 含 state: ToggleState((controls)/switch.mdx L261),VUE 根作用域插槽仅 isSelected/isDisabled/isReadOnly/isInvalid/isRequired,无 state(switch.md L145)。
  • [API] onPress(PressEvent)(switch.mdx L238)VUE 无对应事件(简报忽略项含 onPress→@click,简注;VUE 在"当前差异"自述 PressEvent 不等价,switch.md L175)。
  • [文档] 组件结构:UP 含 Switch.Icon 可选件、Label/Description 于 Content 内,以及独立的 SwitchGroup 分组结构代码块(switch.mdx L25-64);VUE 结构示例仅单个 Switch,缺 SwitchGroup 结构片段(switch.md L29-37)。
  • [文档] 样式参考大幅缺章:UP 有 Switch 类清单 8 项(含 --sm/--md/--lg)+ SwitchGroup 类清单 4 项 + 交互状态列表(switch.mdx L185-217);VUE 压缩为一段散文(switch.md L117),SwitchGroup 类与交互状态章节缺失。
  • [文档] 全局 CSS 示例内容不同:UP 覆盖 .switch/.switch__control/.switch__thumb/.switch__content/.switch__icon(switch.mdx L157-178);VUE 仅 .hv-switch__control { border-radius: 12px; }(switch.md L107-113)。
  • [样式] switch.css 逐条核对仅换行差异,规则/数值/运动降级均一致;switchVariants tv 一致(up switch.styles.ts ↔ vue styles/src/index.ts L94-120)。

slider

  • [示例] slider-range:VUE 为每个 Thumb 增加 :aria-label="index === 0 ? '最低价格' : '最高价格'"(slider-range.vue),UP 无(slider/range.tsx)。
  • [示例] slider-custom-output:VUE 同样增加"区间下限/区间上限" aria-label(slider-custom-output.vue),UP 无(slider/custom-output.tsx)。
  • [API] defaultValue 默认值:UP 文档 -((controls)/slider.mdx L184),VUE 0(slider.md L156)。
  • [API] RenderProps 的 state: SliderState(slider.mdx L235)在 VUE 根/Track 作用域插槽中缺失(slider.md L180-186、L203 只有 value/values/isDisabled/orientation/getThumbValueLabel)。
  • [API] VUE 新增 locale/dir/as/id、Thumb form/id(slider.md L161-167、L214-215,能力增强)。
  • [文档] "全局 CSS"示例内容不同:UP 用 .slider-track/.slider-fill/.slider-thumb(与其实际 BEM .slider__track 等命名不一致)及另一套属性(slider.mdx L121-143);VUE 用 .hv-slider__track{bg-default} 等(slider.md L107-125)。
  • [文档] UP ## 无障碍 章节(含 React Aria 链接,slider.mdx L241-253)对应 VUE ## 可访问性与表单+实现差异说明(slider.md L227-235),内容重写非翻译(大体等价,简注)。
  • [样式] VUE 新增 .slider__thumb:has(.slider__input:focus-visible){ z-10 status-focused }(heroui-vue/packages/styles/components/slider.css L182);UP 仅 &[data-focus-visible="true"](heroui/.../slider.css L68)。VUE Thumb 也会输出 data-focus-visible(SliderThumb.vue L156),该规则为兜底,未见可见差异(简注)。
  • [样式/动画] motion-reduce 重写:UP @apply motion-reduce:transition-none(slider.css L34/L42)与 motion-reduce:scale-100(L48)→ VUE 文件末尾 @media (prefers-reduced-motion: reduce){.slider__thumb,.slider__thumb::after{transition:none} .slider__thumb[data-dragging="true"]::after{scale:1}}(vue slider.css L185-193)。语义等价。
  • [实现] Thumb 内真实 input 从 VisuallyHidden 改为透明覆盖层(opacity:0; inset:0; z-index:20; cursor:inherit,SliderThumb.vue L183-200)并显式补 role="slider" 与 aria-valuenow/min/max/valuetext;拖动改为轨道局部 pointer capture(slider.md L235 自述 Reka Collection Thumb 缺口)。行为目标一致,复杂指针/多指场景(待核实)。

input

  • [示例] input-on-surface:UP <Surface className="… rounded-3xl bg-surface p-4">,VUE 少 bg-surface、另加 variant="default"(input-on-surface.vue;UP input/on-surface.tsx)。背景是否由 Surface 变体等价补回(待核实);VUE 另加 aria-label="你的姓名"。
  • [API] defaultValue 默认值:UP -((forms)/input.mdx L113),VUE ''(input.md L80,等价更明确)。
  • [API] 原生直通属性归属:UP 表格逐项列 maxLength/minLength/pattern/min/max/step(input.mdx L121-126);VUE 合并为 maxlength/minlength、pattern、min/max/step 行(input.md L86-88),经 v-bind="{...control.inheritedAttrs(), ...attrs}" 落在真实 <input>(Input.vue L26),归属一致、仅表格呈现不同。VUE 增 invalid prop(UP 引导用 TextField 的 isInvalid)。
  • [文档] UP <Callout> 校验、标签与错误消息请参阅 TextField(input.mdx L19-21);VUE 改写为"TextField 尚未迁移,当前请使用原生 label、aria-describedby 和 aria-invalid 关联"(input.md L18-20)——与事实不符:TextField 已实现并导出(heroui-vue/packages/vue/src/index.ts L192;apps/docs/components/text-field.md 存在)。
  • [文档] 全局 CSS 示例:UP 完整 .input 覆盖样例(hover/focus-visible/invalid,input.mdx L62-82);VUE 仅 border-radius: 8px(input.md L59-65)。样式参考:UP 有交互状态清单含 Read Only:[aria-readonly="true"](input.mdx L94-100);VUE 一行散文且缺 readonly 状态(input.md L69)。
  • [样式] input.css 仅换行差异;inputVariants tv 一致。

textarea

  • [API] 原生直通属性归属:UP 表格逐项列 rows(默认3)/cols/wrap/maxLength/minLength/autoComplete((forms)/text-area.mdx L109-122);VUE 表格仅 rows(默认3)/fullWidth/variant/invalid/class,cols/wrap/minlength/maxlength/autocomplete 等以文字声明透传(textarea.md L114),经 TextArea.vue v-bind="{...attrs}" 确实透传到真实 <textarea>——能力一致,仅 API 表归属不同(文档结构差异,小)。
  • [文档] UP 有 ## 相关案例 <RelatedShowcases component="TextArea" />(text-area.mdx L128-130),VUE 无此章节。
  • [示例] 内容经核对一致(textarea-rows 的 resize: vertical 两侧都有;text-area-custom-styles↔textarea-custom-styles 仅命名)。
  • [样式] textarea.css 仅换行差异;textAreaVariants tv 一致。

text-field

  • [API] VUE 缺 autoFocus:UP Form Props((forms)/text-field.mdx L189),useTextField.ts 无 autofocus 支持,VUE API 表也无(text-field.md L151-171)。
  • [API] validationErrors: string[] prop(text-field.mdx L167)VUE 未提供,改由 Form validation-errors 按 name 映射(text-field.md L173,文档已声明差异)。
  • [API] TextFieldRenderProps 的 isFocusWithin/isFocusVisible(含已弃用 isFocused,text-field.mdx L231-233)在 VUE 作用域插槽缺失(text-field.md L235 自述"无 isFocusWithin / isFocusVisible")。
  • [实现] 根 data 属性:VUE 输出 data-slot/data-invalid/data-disabled/data-required/data-readonly(heroui-vue/packages/vue/src/components/field/useTextField.ts L334-338),未输出 data-focus-within/data-focus-visible(UP 文档声明自动管理,text-field.mdx L136-139;UP textfield.tsx 仅 data-slot="textfield"、焦点态由 RAC 提供,实际 DOM 输出(待核实))。
  • [文档] 交互状态清单差异:UP 列 invalid(含 aria-invalid 同步)/disabled/focus-within/focus-visible(text-field.mdx L132-141);VUE 列 invalid(仅 data-invalid)/disabled/required/readonly(text-field.md L138-146)。
  • [文档] UP 有 ## 相关案例 <RelatedShowcases component="TextField" />(text-field.mdx L235-237),VUE 无。
  • [样式] textfield.css 一致;tv:UP 导出 textFieldVariants(heroui/packages/styles/src/components/textfield/textfield.styles.ts),VUE styles 包无对应导出,类名在 useTextField.ts L329-330 内联字符串("hv-textfield"、"hv-textfield--full-width")——公共 styles API 少一个导出。
  • [示例] text-field-custom-styles 等经核对内容一致(模板串拆分误报)。

search-field

  • [示例] search-field-form-example:UP 模拟 API 仅 console.log("Search submitted:", …)(search-field/form-example.tsx L22-26);VUE 生成行内反馈并展示 已模拟提交搜索:${query}(search-field-form-example.vue,<output class="text-sm text-muted">)。
  • [示例] search-field-custom-icons:自定义图标不同——UP 内联 SVG(人形搜索 glyph + 圆形 X,search-field/custom-icons.tsx),VUE Tabler IconFilter/IconCircleX(search-field-custom-icons.vue);搜索图标形状(filter vs 人形搜索)与基线明显不同。
  • [API] SearchFieldRenderProps 的 value: string((forms)/search-field.mdx L336)在 VUE 作用域插槽缺失(search-field.md L262-266 有 isEmpty/isHovered/isFocusWithin/isFocusVisible 但无 value)。
  • [API] validationErrors prop(search-field.mdx L225)同 text-field:VUE 走 Form 映射,未提供该 prop(search-field.md L235,文档已声明)。
  • [实现] clear 按钮保留 slot="clear" 属性(heroui-vue/packages/vue/src/components/search-field/SearchFieldClearButton.vue L38),与 CSS .search-field__group:has([slot="clear"]) 匹配,无差异;data-focus-within/focus-visible/hovered/empty 均输出(SearchField.vue L45-47、SearchFieldGroup.vue L38-39)。
  • [实现] submit 语义:VUE 声明"注册 @submit 时接管该次 Enter、不再触发表单默认提交;未监听时保留隐式提交"(search-field.md L242/247);UP RAC onSubmit 与表单隐式提交是否并存(待核实)。
  • [样式] search-field.css 与 searchFieldVariants tv 完全一致(仅许可头)。

本组小结

  1. 文档事实错误:input.md L18-20 称"TextField 尚未迁移",但 TextField 已实现/导出且有文档(与上游 Callout 指向 TextField 的引导相反);radio-group.md L210/L237 沿用 CheckboxGroup 文案("Checkbox 成员可显式覆盖"、"数组或标量")。
  2. switch 文档缺章:SwitchGroup 组件结构片段、Switch/SwitchGroup CSS 类清单、交互状态章节缺失,全局 CSS 示例只剩单条规则(switch.md vs switch.mdx L43-64、L157-217)。
  3. 表单示例提交反馈系统性改写:checkbox-form、checkbox-group-validation、switch-form、search-field-form-example 由 alert()/console 改为行内输出,switch-form 另加"重置"按钮与"未选择任何选项"空态,radio-group-validation 结果提示缺 text-muted。
  4. API 缺口:TextField 缺 autoFocus;TextField/SearchField 缺 validationErrors prop(改 Form 映射,已声明);render props/state 对象缺失(Slider state: SliderState、Switch state: ToggleState、TextField/SearchField 的 isFocusWithin/isFocusVisible/value);TextField 根不输出 data-focus-within/data-focus-visible;@heroui-vue/styles 无 textFieldVariants 导出。
  5. 指示器/图标基线差异:radio-group-custom-indicator 的 "✓" span(text-xs leading-none)→ Tabler IconCheck(size-3),search-field-custom-icons 人形搜索 SVG → Tabler IconFilter,checkbox-custom-indicator 内联 SVG → Tabler,图形与尺寸呈现与基线不同(受"演示用 Tabler"约定影响,但非等价复刻)。