Compare commits
3 Commits
35b602e5b9
...
680a592e7b
| Author | SHA1 | Date | |
|---|---|---|---|
| 680a592e7b | |||
| 0b303476c2 | |||
| dc859fb8ae |
@@ -83,6 +83,8 @@ HeroUI 遵循 [BEM](https://getbem.com/) 方法论,确保组件变体与状态
|
||||
|
||||
Description 组件使用以下 CSS 类([查看源码样式](https://github.com/heroui-inc/heroui/blob/v3/packages/styles/components/description.css)):
|
||||
|
||||
> 变体映射 `descriptionVariants` 从 `@heroui-vue/styles` 公开(`@heroui-vue/components` 再导出同一函数与 `DescriptionVariants` 类型);组件渲染的类名由该映射生成。
|
||||
|
||||
#### 基础类 [!toc]
|
||||
|
||||
- `.hv-description` - 基础描述样式,使用 `muted` 文本颜色
|
||||
|
||||
@@ -178,6 +178,8 @@ HeroUI 遵循 [BEM](https://getbem.com/) 方法论,确保组件变体与状态
|
||||
|
||||
FieldError 组件使用以下 CSS 类([查看源码样式](https://github.com/heroui-inc/heroui/blob/v3/packages/styles/components/field-error.css)):
|
||||
|
||||
> 变体映射 `fieldErrorVariants` 从 `@heroui-vue/styles` 公开(`@heroui-vue/components` 再导出同一函数与 `FieldErrorVariants` 类型);组件渲染的类名由该映射生成。
|
||||
|
||||
#### 基础类 [!toc]
|
||||
|
||||
- `.hv-field-error` - 基础错误样式,danger 色
|
||||
|
||||
@@ -88,6 +88,8 @@ HeroUI 遵循 [BEM](https://getbem.com/) 方法论,确保组件变体与状态
|
||||
|
||||
Label 使用以下 CSS 类([查看源码样式](https://github.com/heroui-inc/heroui/blob/v3/packages/styles/components/label.css)):
|
||||
|
||||
> 变体映射 `labelVariants` 从 `@heroui-vue/styles` 公开(`@heroui-vue/components` 再导出同一函数与 `LabelVariants` 类型);组件渲染的类名由该映射生成,状态修饰类随 `isDisabled` / `isInvalid` / `isRequired` 输出。
|
||||
|
||||
#### 基础类 [!toc]
|
||||
|
||||
- `.hv-label` — 基础标签文本样式
|
||||
|
||||
@@ -182,6 +182,8 @@ SwitchGroup 组件使用以下 CSS 类([查看源码样式](https://github.com
|
||||
- `.hv-switch-group--horizontal` - 横向布局
|
||||
- `.hv-switch-group--vertical` - 纵向布局(默认)
|
||||
|
||||
> 变体映射 `switchGroupVariants` 从 `@heroui-vue/styles` 公开(`@heroui-vue/components` 再导出同一函数与 `SwitchGroupVariants` 类型),提供 `base` / `items` 两个槽;组件渲染的类名由该映射生成。
|
||||
|
||||
### 交互状态
|
||||
|
||||
该 Switch 同时支持 CSS 伪类与 data 属性,以提供更灵活的状态控制:
|
||||
|
||||
@@ -133,6 +133,8 @@ HeroUI 遵循 [BEM](https://getbem.com/) 方法论,确保组件变体与状态
|
||||
|
||||
- `.hv-textfield` – 根容器,样式极少(`flex flex-col gap-1`)
|
||||
|
||||
> 变体映射 `textFieldVariants` 从 `@heroui-vue/styles` 公开(`@heroui-vue/components` 再导出同一函数与 `TextFieldVariants` 类型);`full-width` 输出 `.hv-textfield--full-width`,组件根类名由该映射生成。
|
||||
|
||||
> **提示:** 子组件([Label](/components/label)、[Input](/components/input)、[TextArea](/components/textarea)、[Description](/components/description)、[FieldError](/components/field-error))各自拥有 CSS 类与样式,定制方式请参见对应文档。
|
||||
|
||||
### 交互状态
|
||||
|
||||
@@ -115,6 +115,22 @@ React 的函数式 `className` / `style` 和 render props 不直接用于 Vue。
|
||||
|
||||
库 CSS 使用 `theme, base, components, utilities` 层顺序。需要确保覆盖优先级时,应检查实际层、选择器与导入顺序;无层的应用 CSS 会优先于普通有层规则。Vue scoped 样式触及嵌套部件时使用 `:deep()` 或直接给该部件添加类,不在文档壳中隐藏组件问题。
|
||||
|
||||
库的基础层还提供全局边框色回退(与固定源一致):
|
||||
|
||||
```css
|
||||
*,
|
||||
::after,
|
||||
::before,
|
||||
::backdrop,
|
||||
::file-selector-button {
|
||||
border-color: var(--border, currentColor);
|
||||
}
|
||||
```
|
||||
|
||||
没有显式 `border-color` 的边框默认使用主题的 `--border`(未定义时回退 `currentColor`)。该规则位于 `base` 层且不带 `!important`,组件规则、工具类与调用方 CSS 都能正常覆盖它;显式边框色(包括 `transparent` 的字段边框)不受影响。
|
||||
|
||||
组件与类名的变体映射从 `@heroui-vue/styles` 公开(`buttonVariants`、`labelVariants`、`descriptionVariants`、`fieldErrorVariants`、`textFieldVariants`、`switchGroupVariants` 等),`@heroui-vue/components` 再导出同一组函数与 `*Variants` 类型;组件内部消费的也是这些映射,状态类只有这一处来源。
|
||||
|
||||
## 创建包装组件
|
||||
|
||||
使用公开 Props 类型与 `tv` 扩展变体。包装组件需要显式管理 `$attrs`、插槽、事件和需要公开的方法,不能把 DOM `ref` 当作普通属性传递。
|
||||
|
||||
@@ -290,3 +290,7 @@ ComboBox/Autocomplete的正式组合、原30项返修和本轮定位/ref/ARIA/lo
|
||||
固定源六篇56章节的实现证据与差异见 [Handbook审计](handbook-audit.md)。修复 data-scrollbar 三模式、八类浮层/Skeleton/Drawer 的减少动效与动态取消动画后的进入标记清理。按需 CSS 子路径、公共 useTheme、局部主题自动跨 Teleport 及 Skeleton 动画变量的局部/动态读取仍未提供;不声明所有组件已完成全部规范的浏览器验收。逐项场景与实际验证见 [任务结果](tasks/results/HANDBOOK-IMPLEMENTATION-AUDIT.md)。
|
||||
|
||||
HD-01(2026-10-28):按钮/切换组与导航示例已恢复固定cn基线;ButtonGroup内Dropdown保留根attrs/事件,以容器位置适配接缝。HD01-R1已关闭;不升级整族API兼容状态,详见[结果](tasks/results/HD-01-BUTTON-NAV-DEMOS.md)。
|
||||
|
||||
## HD-05 styles 导出与全局边框回退(2026-10-28)
|
||||
|
||||
`@heroui-vue/styles` 增量补齐固定源缺失的 5 个 tv 映射与类型:`labelVariants`/`descriptionVariants`/`fieldErrorVariants`/`textFieldVariants`/`switchGroupVariants`(hv- 命名空间,变体集合与默认值与 `heroui/packages/styles/src/components/{label,description,field-error,textfield,switch-group}/*.styles.ts` 逐键一致),`@heroui-vue/components` 再导出同一组函数与 `*Variants` 类型。Label/Description/FieldError/useTextField/SwitchGroup 改为消费同一映射,状态类只保留一处来源,渲染类输出不变(tests/shared-field-styles.test.ts 钉住映射输出与组件输出一致)。恢复 `base` 层全局边框色回退 `border-color: var(--border, currentColor)`(与固定源 base/base.css 同选择器、同层序:preflight 之后);独立 tarball 消费者真实浏览器验证浅/深 `--border`、显式边框色(含字段透明边框)、调用方普通 CSS 覆盖(含与库同选择器的注入规则)与 `--border` 缺失时的 currentColor 回退,CSSOM 确认规则位于 base 层且无 `!important`。`view-transition-name`/`::view-transition` 两条上游全局规则经核查无使用证据(库与文档站均未使用 View Transitions API),不迁移、不建专项。chip `size:"md"`、kbd `variant:"default"` 等效默认类、reduced-motion、Spinner 定尺、Table th 行头、定位补偿与 HD-01~HD-04 成果均未改动。见 [任务结果](tasks/results/HD-05-STYLES.md)。
|
||||
|
||||
@@ -22,3 +22,8 @@
|
||||
- [结果](results/HD-04-DOCS.md)逐条核销:范围1过期/虚构文案(input TextField、color-field ColorPicker、header Header.Root与菜单未迁移、radio-group三处Checkbox残留、input-otp虚构data-complete)全部修正并带源码依据;范围2自链接清除、toggle-button禁用选择器改实、Header MenuSection注册说明+集合分组示例(单测+浏览器双证aria-labelledby链路);范围3 button/accordion/card/switch/ColorField.Group/InputOTP补部件API、CSS类、交互状态与真实全局样式示例,input-group补两段用法示例章;范围4 RelatedComponents按固定映射迁移(64页+2补节+7空映射删节,9样本链接实测),RelatedShowcases核实仅2案例、依赖showcase站不迁移不占位;范围5 granularity/visibleYears三处口径统一(以Reka推断与year-picker实现为证),HD-03转交项全部核销(focus-visible归HD-06已如实注明),新示例2个+empty-state去重+回退边界兼容说明;范围6 minHeight/isBgSolid按上游30处补齐(实测生效),tabs-overflow实测保留max-w-full(内部滚动/箭头正常)。全量110文件1630项、typecheck、build:docs通过;未改公开API/styles无需tarball。遗留:RelatedShowcases待showcase站决策;button-toggle.test.ts间歇失败为预存在(基线对照),建议归HD-11排查。
|
||||
|
||||
- HD-04 已验收:复核补修 f9938eea8c48958991294d687697766259482af2,修正文档CSS示例/状态节点并恢复四页相关案例卡片(链接上游React详情,无本地showcase站)。全量110文件1631项、最终docs-shell14项、类型、文档构建通过。按用户授权合入main并push origin/main;工作区释放,下一项HD-05-STYLES未启动,保留5173/5174。
|
||||
|
||||
- HD-05-STYLES已实施待复核,工作区释放;分支task/hd-05-styles,起点35b602e(main tip,含HD-04验收与复核补修f9938ee),实施dc859fb8aeacac7eb3a798676356cb2c387e5d45。
|
||||
- [结果](results/HD-05-STYLES.md)逐条核销:范围1 styles入口增量补 labelVariants/descriptionVariants/fieldErrorVariants/textFieldVariants/switchGroupVariants 五映射与类型(变体/默认值/slot 与固定源逐键一致),Label/Description/FieldError/useTextField/SwitchGroup 改为消费同一映射(类输出不变,映射↔组件一致性单测钉住);范围2 恢复 base 层全局 border-color: var(--border, currentColor) 回退(与固定源同层同序),独立 tarball 消费者真实浏览器验证浅/深、默认边框、显式色(含字段透明边框)、调用方普通/同选择器覆盖、--border 缺失 currentColor 回退,CSSOM 证 base 层无 !important;范围3 view-transition 两规则核查无使用证据,记录无需修改不建专项;范围4 chip/kbd/reduced-motion/Spinner/Table th/定位补偿与 HD-01~HD-04 成果零改动(未恢复日期弹层 w-full 强制规则)。全量111文件1634项、typecheck、build:docs、shared-styles/api-root-aliases/handbook-styles 最终tarball(运行时+类型两种解析)通过;任务卡 checks 重复项已清理并补实际检查。
|
||||
|
||||
- HD-05 已验收:独立复核0b303476c2d682a47157f345fcc0a5ab0a23aa8d,实施dc859fb无功能阻断,仅纠正结果记录CSS特异性表述。全量111文件1634项、类型、文档构建、shared-styles/api-root-aliases/handbook-styles最终tarball及本轮独立消费者5198浅深/覆盖/回退均通过。按用户授权合入main并push origin/main;工作区释放,下一项HD-06-LINK-FOCUS未启动。停止本轮5198,保留原5173/5174及他人5199服务。
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
<!-- task-metadata
|
||||
{"base":"db5670f4e1efe0e6ef7433002de5fb0a4a284f84","upstream":"ce90ea3ab49d58f6c428f71bfd6fe8ae2a87b960","status":"pending","requires":["docs/tasks/HD-QUEUE.md"],"sources":["packages/styles/src/components/label/label.styles.ts"],"checks":["pnpm typecheck","pnpm typecheck"]}
|
||||
{"base":"db5670f4e1efe0e6ef7433002de5fb0a4a284f84","upstream":"ce90ea3ab49d58f6c428f71bfd6fe8ae2a87b960","status":"accepted","requires":["docs/tasks/HD-QUEUE.md"],"sources":["packages/styles/src/components/label/label.styles.ts"],"checks":["pnpm typecheck","pnpm exec vitest run tests/shared-field-styles.test.ts","node scripts/check-package.mjs shared-styles"]}
|
||||
-->
|
||||
|
||||
# HD-05-STYLES:styles 导出与全局边框回退
|
||||
|
||||
优先级:P1。证据范围:审计组 02、04、06;总表 2.3/2.4;详见 [清单入口](HD-QUEUE.md) 和其中证据链接。
|
||||
|
||||
## 执行范围
|
||||
|
||||
- [ ] 在现有 styles 入口增量补 labelVariants/descriptionVariants/fieldErrorVariants/textFieldVariants/switchGroupVariants 及必要类型,保留固定源变体和默认值;相关组件复用映射,避免维护两套状态类。
|
||||
- [ ] 补核并恢复上游全局 border-color: var(--border, currentColor) 回退,确认最终 CSS 的层级和覆盖语义;验证独立消费者中的无显式色边框。
|
||||
- [ ] view-transition-name/pointer-events 先核当前站点是否使用该机制;只修实际支持路径中的遮挡,不为未用功能建专项。
|
||||
- [ ] 保留 chip size=md、kbd variant=default 的等效类、reduced-motion、Spinner 定尺、th 行头适配和必要定位补偿。
|
||||
- [x] 在现有 styles 入口增量补 labelVariants/descriptionVariants/fieldErrorVariants/textFieldVariants/switchGroupVariants 及必要类型,保留固定源变体和默认值;相关组件复用映射,避免维护两套状态类。
|
||||
- [x] 补核并恢复上游全局 border-color: var(--border, currentColor) 回退,确认最终 CSS 的层级和覆盖语义;验证独立消费者中的无显式色边框。
|
||||
- [x] view-transition-name/pointer-events 先核当前站点是否使用该机制;只修实际支持路径中的遮挡,不为未用功能建专项。
|
||||
- [x] 保留 chip size=md、kbd variant=default 的等效类、reduced-motion、Spinner 定尺、th 行头适配和必要定位补偿。
|
||||
|
||||
## 用户可见通过条件
|
||||
|
||||
@@ -26,4 +27,3 @@
|
||||
结果写到 `docs/tasks/results/HD-05-STYLES.md`,逐条记录改动或“无需修改”的证据及限制;只在本卡元数据更新状态。核实后无需修改是有效结论,不为凑修复量重写底座。普通实施提交自己的分支,不合 main、不 push、不派发其他会话。
|
||||
|
||||
仅浏览器客户端;不开发或运行 SSR/水合/Nuxt 服务端、逐像素自动对比、完整读屏或真机矩阵专项。
|
||||
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
# HD-05-STYLES 结果记录
|
||||
|
||||
- 任务卡:[HD-05-STYLES](../HD-05-STYLES.md);固定上游 `ce90ea3ab49d58f6c428f71bfd6fe8ae2a87b960`(`heroui/packages/styles/src/components/*/**.styles.ts`、`heroui/packages/styles/base/base.css`、`heroui/packages/styles/index.css`)。
|
||||
- 分支 task/hd-05-styles;起点 35b602e(main tip,含 HD-04 验收与复核补修 f9938ee);实施 dc859fb8aeacac7eb3a798676356cb2c387e5d45(26 文件,styles/vue 包、契约与浏览器夹具、单测、文档与记录源);记录提交为本文件所在提交。主会话实施/自测,未合 main、未 push。
|
||||
- 任务卡 checks 的 `pnpm typecheck` 重复项已清理,替换为 `pnpm typecheck`、`pnpm exec vitest run tests/shared-field-styles.test.ts`、`node scripts/check-package.mjs shared-styles` 三项实际检查(元数据随记录提交)。
|
||||
|
||||
## 范围 1:styles 入口增量补齐五个 tv 映射
|
||||
|
||||
**修改**。`packages/styles/src/index.ts` 增量新增(不改动既有导出):
|
||||
|
||||
| 新导出 | 固定源 | 逐键核对 |
|
||||
| --------------------------------------------- | ------------------------------------- | ----------------------------------------------------------------------------------------------------------- |
|
||||
| `labelVariants` / `LabelVariants` | `label/label.styles.ts` | base `hv-label`;isDisabled/isInvalid/isRequired(默认全 false)→ `hv-label--disabled/--invalid/--required` |
|
||||
| `descriptionVariants` / `DescriptionVariants` | `description/description.styles.ts` | base-only `hv-description` |
|
||||
| `fieldErrorVariants` / `FieldErrorVariants` | `field-error/field-error.styles.ts` | base-only `hv-field-error` |
|
||||
| `textFieldVariants` / `TextFieldVariants` | `textfield/textfield.styles.ts` | base `hv-textfield`;fullWidth(默认 false)→ `hv-textfield--full-width` |
|
||||
| `switchGroupVariants` / `SwitchGroupVariants` | `switch-group/switch-group.styles.ts` | slots `base`/`items`;orientation(默认 vertical)→ `hv-switch-group--horizontal/--vertical` |
|
||||
|
||||
变体键、默认值、slot 集合与固定源逐键一致(仅 `hv-` 前缀,沿用本库命名约定)。
|
||||
|
||||
**组件复用同一映射(避免两套状态类)**:Label.vue、Description.vue、FieldError.vue、useTextField.ts、SwitchGroup.vue 原先内联写死类名,全部改为消费上述映射(全仓 `hv-label*/hv-description/hv-field-error/hv-textfield*/hv-switch-group*` 字符串仅存于 styles 映射一处)。渲染类输出不变:`tests/shared-field-styles.test.ts` 钉住「映射输出 ↔ 组件实际类输出」逐类相等(Label 双状态、Description、FieldError、SwitchGroup base/items 槽);既有 field-foundation/fieldset-search-field 等类断言未改动并通过。attrs 归属未变(各组件 inheritAttrs 策略与 class 合并路径原样,Description/FieldError/Label 的 `v-bind="attrs"` + `:class` 合并行为不变)。
|
||||
|
||||
**公共类型**:`@heroui-vue/styles` 导出五个 `*Variants` 类型(VariantProps);`@heroui-vue/components` 再导出同一组函数与类型(运行时同函数对象,check-client 断言 `stylesLib[name] === lib[name]`)。
|
||||
|
||||
## 范围 2:全局边框色回退
|
||||
|
||||
**修改**。新增 `packages/styles/base/base.css`(移植 `heroui/packages/styles/base/base.css` 的边框色继承规则,Apache-2.0 来源声明保留),`packages/styles/index.css` 在 `tailwindcss/preflight.css` 之后以 `layer(base)` 导入——与固定源 `@import "./base/base.css" layer(base)` 同层、同相对次序(preflight 的 `border: 0 solid` 先出、回退规则后出,同层平手由次序裁决)。
|
||||
|
||||
层级与覆盖语义:规则在 `base` 层、选择器 `*, ::after, ::before, ::backdrop, ::file-selector-button`(通配选择器为 0-0-0,伪元素为 0-0-1)、无 `!important`;components 层组件规则、utilities 与无层调用方 CSS 均可正常覆盖。
|
||||
|
||||
**独立 tarball 消费者真实浏览器验证**(`shared-styles-consumer-app` 夹具 + Playwright/系统 Chrome,消费者目录为 check-package 打包安装的最终 tarball,无工作区源码/alias;浅深用真实点击 `#theme-toggle` 切换):
|
||||
|
||||
| 场景 | 浅色实值 | 深色实值 | 结论 |
|
||||
| ------------------------------------------------------------------ | --------------------------------------------------- | ---------------------------------------- | ------------------------------------ |
|
||||
| 无显式色边框(`.box`) | `oklch(0.9 0.004 286.32)` = 同元素解析的 `--border` | `oklch(0.28 0.006 286.033)` = `--border` | 默认边框走主题 `--border` 且随主题变 |
|
||||
| 显式 border 颜色(红) | `rgb(200, 0, 0)` | `rgb(200, 0, 0)` | 显式色不受回退影响 |
|
||||
| 组件显式透明边框(`.hv-input-otp__slot` 的 `var(--field-border)`) | `rgba(0, 0, 0, 0)` | `rgba(0, 0, 0, 0)` | 显式声明(含 transparent)不被覆盖 |
|
||||
| 调用方覆盖(普通 CSS、无 `!important`) | `rgb(0, 128, 0)` | `rgb(0, 128, 0)` | 消费者定制生效 |
|
||||
| 调用方**同选择器**注入规则(与库规则完全同选择器) | `rgb(255, 165, 0)` | — | 库规则是低优先级默认,不破坏定制 |
|
||||
| `--border: initial`(缺失回退) | `rgb(0, 0, 255)` = 元素 `color` | 同 | 回退 `currentColor` |
|
||||
|
||||
CSSOM 证据:规则 `*, ::after, ::before, ::backdrop` 值 `var(--border,currentColor)`,`layer=base`、`priority=""`(递归 @layer 遍历取得;截图 hd05-shared-styles-{light,dark}.png 存档)。
|
||||
|
||||
## 范围 3:view-transition-name / pointer-events
|
||||
|
||||
**无需修改**。核查全仓(`packages/`、`apps/docs`、`apps/playground`)与上游 `apps/docs/src`、`packages/react/src`:View Transitions API(`document.startViewTransition`、`view-transition-name`、`::view-transition`)均无使用;唯一提及是 `toast-queue.ts` 注释中的举例文案(两仓相同)。固定源 `base/base.css` 的 `:root { view-transition-name: none }` 与 `::view-transition { pointer-events: none }` 因此不迁移、不建立专项;无「已支持路径中可复现的遮挡」需要修复。若未来引入 View Transitions,应随其能力卡补这两条防御规则。
|
||||
|
||||
## 范围 4:保留的合理适配(未改动)
|
||||
|
||||
git 改动面核对(见提交):chip `size:"md"`、kbd `variant:"default"` 等效默认类、reduced-motion 补强、Spinner `.spinner > svg` 定尺、Table `th` 行头与 resizer `z-index`、dropdown/popover 定位补偿、color-swatch-picker 浅色勾选修正等全部原样;**未**恢复日期弹层的库级 `w-full` 强制视口宽规则(`date-range-picker.css` 零改动)。HD-01~HD-04 成果保留。
|
||||
|
||||
## 检查与验证
|
||||
|
||||
- `node scripts/task-check.mjs HD-05-STYLES`(head 35b602e、最低 base 满足)✅
|
||||
- 卡内 checks(清理重复后):`pnpm typecheck` ✅;`pnpm exec vitest run tests/shared-field-styles.test.ts`(3 项)✅;`node scripts/check-package.mjs shared-styles` ✅
|
||||
- 全量回归 `pnpm exec vitest run`:**111 文件 / 1634 项**(新增 3 项映射↔组件一致性)✅
|
||||
- `pnpm build:docs` ✅(styling.md 与五页 API 文档更新后);prettier ✅
|
||||
- 最终 tarball 验证 `node scripts/check-package.mjs shared-styles api-root-aliases handbook-styles` ✅:
|
||||
- 五个导出从打包产物 `@heroui-vue/components` 与 `@heroui-vue/styles` 均可导入且为同一函数;
|
||||
- `shared-styles-contract.ts` 类型正反例在 nodenext/bundler 两种解析下 strict 通过(含五个 `*Variants` 类型、tv 扩展、`@ts-expect-error` 反例;类型可解析);
|
||||
- 变体输出断言(check-client)覆盖默认/各状态/fullWidth/orientation 组合,与组件实际状态类一致;
|
||||
- CSS 契约含 `border-color:var(--border,currentColor)` 与五个组件类标记。
|
||||
- 独立消费者真实浏览器验证见范围 2 表格(浅/深、默认边框、显式色、覆盖、回退、CSSOM 层级),非 CSS 字符串搜索、非源码 alias。
|
||||
|
||||
## 未完成与限制
|
||||
|
||||
1. `view-transition` 两条上游全局规则未迁移(无使用证据,见范围 3);如后续引入 View Transitions 需随能力卡补。
|
||||
2. 浏览器夹具 `shared-styles-consumer-app` 由 check-package 放入消费者后需按输出命令显式启动 vite(与 b01/b02/color-picker 夹具同一约定);本记录的浏览器证据由该夹具 + Playwright 取得,夹具 README 写明核对清单。
|
||||
3. 无使用 `--border` 之外的全局语义变化;本卡未评估其他上游 base.css 内容(scrollbar 注释块本库已有对应实现)。
|
||||
|
||||
|
||||
## 独立复核与集成验收(2026-10-28)
|
||||
|
||||
- 复核 HEAD `0b303476c2d682a47157f345fcc0a5ab0a23aa8d`,实施 `dc859fb8aeacac7eb3a798676356cb2c387e5d45`,实际基线 `35b602e5b9c67aba97e35b67c7a64ab69d96d4af`。**未发现功能阻断,无需修改实施代码**;仅纠正本记录“所有选择器特异性为0”的表述:通配符0-0-0,伪元素0-0-1,仍为低优先级base默认。
|
||||
- 五个映射的默认值、状态键与slot逐项对固定源;组件的原有字段上下文、attrs/class与事件归属未变。Description/FieldError/Label模板透传路径及useTextField根类复用、SwitchGroup双槽复用均核对。
|
||||
- 独立运行全量 **111文件 / 1634项通过**;`pnpm typecheck`、`pnpm build:docs`通过(仅既有chunk大小提示)。本次未删除、跳过或放宽测试。
|
||||
- 重新运行 `node scripts/check-package.mjs shared-styles api-root-aliases handbook-styles`通过;含最终tarball运行时导出同一性、CSS、五种类型正反例的NodeNext/bundler解析。
|
||||
- 浏览器最终消费者为脚本本轮输出的 `heroui-client-package-sv9jcZ`,入口main.js只从tarball安装包根及发布CSS导入;临时服务5198经lsof确认cwd指向该消费者。5199原由另一消费者占用,未停用、不将其初始读数计入最终证据。
|
||||
- 本轮消费者实测浅/深默认边框:`oklch(0.9 0.004 286.32)` / `oklch(0.28 0.006 286.033)`;两主题显式红色`rgb(200,0,0)`、调用方绿色`rgb(0,128,0)`、缺失token回退蓝色文字`rgb(0,0,255)`均不变,四个OTP槽显式透明边框均保持透明。
|
||||
- 仅在临时消费者样式追加同选择器普通无层规则,默认边框变`rgb(255,165,0)`,显式红色仍保留;CSSOM递归读取确认库规则在base层、值`var(--border,currentColor)`、priority为空。测试后临时追加规则撤回,停止本轮5198服务;保留他人5199与文档5173/playground5174服务。
|
||||
- 全仓再次核对View Transition使用:仅toast-queue注释有`document.startViewTransition`示意,无实际使用路径;本卡不新增相关机制合理。
|
||||
|
||||
结论:**HD-05 accepted**,按用户授权快进合入main并推送origin/main;无本卡未关闭复核项。下一项HD-06-LINK-FOCUS未自动启动。
|
||||
@@ -356,3 +356,8 @@ CSS/tv 仅加 `hv-` 前缀与 Apache-2.0 来源;`colorPickerVariants` 保持
|
||||
## HD-01 示例与 Dropdown 组合(2026-10-28)
|
||||
|
||||
Button/ButtonGroup/ToggleButton/ToggleButtonGroup与指定Accordion/Disclosure示例按ce90ea3的cn源码恢复,保留Tabler图标适配。Vue Dropdown根容器承载attrs/原生事件;ButtonGroup CSS增加仅作用于标记直接成员的位置规则,圆角/outline数值沿用基线,来源许可保留。行为和证据见HD-01任务结果。
|
||||
|
||||
## HD-05 来源(2026-10-28)
|
||||
|
||||
- packages/styles/src/index.ts 的 `labelVariants`/`descriptionVariants`/`fieldErrorVariants`/`textFieldVariants`/`switchGroupVariants`:移植 `heroui/packages/styles/src/components/{label/label,description/description,field-error/field-error,textfield/textfield,switch-group/switch-group}.styles.ts`,仅加 `hv-` 前缀;变体键、默认值与 slot 集合逐键保留(Apache-2.0,见 third-party/HEROUI-LICENSE)。
|
||||
- packages/styles/base/base.css:移植 `heroui/packages/styles/base/base.css` 的边框色继承规则(`*, ::after, ::before, ::backdrop, ::file-selector-button { border-color: var(--border, currentColor) }`),导入序保持 preflight 之后的 base 层。同文件的 `:root { view-transition-name: none }` 与 `::view-transition { pointer-events: none }` 未移植:库与文档站均无 View Transitions API 使用证据,按 HD-05 约定记录无需修改,不建立专项。
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
/* Adapted from HeroUI ce90ea3, packages/styles/base/base.css.
|
||||
* Copyright 2025 NextUI Inc. Apache-2.0; see third-party/HEROUI-LICENSE. */
|
||||
|
||||
/* Border color inheritance
|
||||
*
|
||||
* Every border without an explicit color resolves to the theme border token
|
||||
* instead of `currentColor`. This lives in the base layer right after
|
||||
* Tailwind preflight, so component rules (components layer), utilities and
|
||||
* consumer CSS all override it normally — no !important required. When
|
||||
* `--border` is undefined the declaration falls back to `currentColor`. */
|
||||
*,
|
||||
::after,
|
||||
::before,
|
||||
::backdrop,
|
||||
::file-selector-button {
|
||||
border-color: var(--border, currentColor);
|
||||
}
|
||||
@@ -1,6 +1,9 @@
|
||||
@layer theme, base, components, utilities;
|
||||
@import "tailwindcss/theme.css" layer(theme);
|
||||
@import "tailwindcss/preflight.css" layer(base);
|
||||
/* Base defaults follow preflight so they win same-layer ties (border color
|
||||
* fallback); upstream keeps them in base/base.css in the same order. */
|
||||
@import "./base/base.css" layer(base);
|
||||
@import "./themes/shared/theme.css";
|
||||
@import "./themes/default/variables.css";
|
||||
/* Mode overrides must follow theme defaults so an explicit mode on a theme root wins. */
|
||||
|
||||
@@ -119,6 +119,28 @@ export const switchVariants = tv({
|
||||
|
||||
export type SwitchVariants = VariantProps<typeof switchVariants>;
|
||||
|
||||
export const switchGroupVariants = tv({
|
||||
defaultVariants: {
|
||||
orientation: "vertical",
|
||||
},
|
||||
slots: {
|
||||
base: "hv-switch-group",
|
||||
items: "hv-switch-group__items",
|
||||
},
|
||||
variants: {
|
||||
orientation: {
|
||||
horizontal: {
|
||||
base: "hv-switch-group--horizontal",
|
||||
},
|
||||
vertical: {
|
||||
base: "hv-switch-group--vertical",
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export type SwitchGroupVariants = VariantProps<typeof switchGroupVariants>;
|
||||
|
||||
export { tv, cn, type VariantProps } from "tailwind-variants";
|
||||
|
||||
export const closeButtonVariants = tv({
|
||||
@@ -199,6 +221,21 @@ export const textAreaVariants = tv({
|
||||
|
||||
export type TextAreaVariants = VariantProps<typeof textAreaVariants>;
|
||||
|
||||
export const textFieldVariants = tv({
|
||||
base: "hv-textfield",
|
||||
defaultVariants: {
|
||||
fullWidth: false,
|
||||
},
|
||||
variants: {
|
||||
fullWidth: {
|
||||
false: "",
|
||||
true: "hv-textfield--full-width",
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export type TextFieldVariants = VariantProps<typeof textFieldVariants>;
|
||||
|
||||
export const avatarVariants = tv({
|
||||
defaultVariants: {
|
||||
color: "default",
|
||||
@@ -1746,6 +1783,40 @@ export const errorMessageVariants = tv({
|
||||
|
||||
export type ErrorMessageVariants = VariantProps<typeof errorMessageVariants>;
|
||||
|
||||
export const labelVariants = tv({
|
||||
base: "hv-label",
|
||||
defaultVariants: {
|
||||
isDisabled: false,
|
||||
isInvalid: false,
|
||||
isRequired: false,
|
||||
},
|
||||
variants: {
|
||||
isDisabled: {
|
||||
true: "hv-label--disabled",
|
||||
},
|
||||
isInvalid: {
|
||||
true: "hv-label--invalid",
|
||||
},
|
||||
isRequired: {
|
||||
true: "hv-label--required",
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export type LabelVariants = VariantProps<typeof labelVariants>;
|
||||
|
||||
export const descriptionVariants = tv({
|
||||
base: "hv-description",
|
||||
});
|
||||
|
||||
export type DescriptionVariants = VariantProps<typeof descriptionVariants>;
|
||||
|
||||
export const fieldErrorVariants = tv({
|
||||
base: "hv-field-error",
|
||||
});
|
||||
|
||||
export type FieldErrorVariants = VariantProps<typeof fieldErrorVariants>;
|
||||
|
||||
export const comboBoxVariants = tv({
|
||||
defaultVariants: {
|
||||
fullWidth: false,
|
||||
|
||||
@@ -1,12 +1,18 @@
|
||||
<script setup lang="ts">
|
||||
import { useAttrs } from "vue";
|
||||
import { descriptionVariants } from "@heroui-vue/styles";
|
||||
import { useFieldPart } from "../field/useFieldPart";
|
||||
defineOptions({ inheritAttrs: false });
|
||||
const attrs = useAttrs();
|
||||
const { id } = useFieldPart("description", attrs);
|
||||
</script>
|
||||
<template>
|
||||
<p v-bind="attrs" :id="id" class="hv-description" data-slot="description">
|
||||
<p
|
||||
v-bind="attrs"
|
||||
:id="id"
|
||||
:class="descriptionVariants()"
|
||||
data-slot="description"
|
||||
>
|
||||
<slot />
|
||||
</p>
|
||||
</template>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { useAttrs } from "vue";
|
||||
import { fieldErrorVariants } from "@heroui-vue/styles";
|
||||
import { useFieldPart } from "./useFieldPart";
|
||||
defineOptions({ inheritAttrs: false });
|
||||
const attrs = useAttrs();
|
||||
@@ -12,7 +13,7 @@ const { field, id } = useFieldPart("error", attrs);
|
||||
:id="id"
|
||||
data-slot="field-error"
|
||||
data-visible
|
||||
class="hv-field-error"
|
||||
:class="fieldErrorVariants()"
|
||||
role="alert"
|
||||
>
|
||||
<slot
|
||||
|
||||
@@ -18,6 +18,7 @@ import {
|
||||
type VNode,
|
||||
type VNodeChild,
|
||||
} from "vue";
|
||||
import { textFieldVariants } from "@heroui-vue/styles";
|
||||
import {
|
||||
fieldContextKey,
|
||||
formContextKey,
|
||||
@@ -325,10 +326,8 @@ export function useTextField(
|
||||
Object.entries(attrs).filter(([key]) => !key.startsWith("aria-")),
|
||||
),
|
||||
class: [
|
||||
options.rootClass?.() ?? [
|
||||
"hv-textfield",
|
||||
props.fullWidth && "hv-textfield--full-width",
|
||||
],
|
||||
options.rootClass?.() ??
|
||||
textFieldVariants({ fullWidth: props.fullWidth }),
|
||||
attrs.class,
|
||||
],
|
||||
"data-slot": options.rootSlot ?? "textfield",
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { inject, onUnmounted, useAttrs, useId, watch } from "vue";
|
||||
import { labelVariants } from "@heroui-vue/styles";
|
||||
import { useFieldPart } from "../field/useFieldPart";
|
||||
import { useInheritedDisabled } from "../field/disabled";
|
||||
import { fieldContextKey } from "../field/context";
|
||||
@@ -68,12 +69,13 @@ onUnmounted(() => {
|
||||
:for="
|
||||
attrs.for ?? (field?.kind === 'text' ? field.controlId.value : undefined)
|
||||
"
|
||||
class="hv-label"
|
||||
:class="{
|
||||
'hv-label--required': props.isRequired || field?.required.value,
|
||||
'hv-label--disabled': disabled,
|
||||
'hv-label--invalid': props.isInvalid || field?.invalid.value,
|
||||
}"
|
||||
:class="
|
||||
labelVariants({
|
||||
isRequired: Boolean(props.isRequired || field?.required.value),
|
||||
isDisabled: Boolean(disabled),
|
||||
isInvalid: Boolean(props.isInvalid || field?.invalid.value),
|
||||
})
|
||||
"
|
||||
data-slot="label"
|
||||
>
|
||||
<slot />
|
||||
|
||||
@@ -1,16 +1,19 @@
|
||||
<script setup lang="ts">
|
||||
withDefaults(defineProps<{ orientation?: "horizontal" | "vertical" }>(), {
|
||||
orientation: "vertical",
|
||||
});
|
||||
import { computed } from "vue";
|
||||
import { switchGroupVariants } from "@heroui-vue/styles";
|
||||
const props = withDefaults(
|
||||
defineProps<{ orientation?: "horizontal" | "vertical" }>(),
|
||||
{
|
||||
orientation: "vertical",
|
||||
},
|
||||
);
|
||||
const styles = computed(() =>
|
||||
switchGroupVariants({ orientation: props.orientation }),
|
||||
);
|
||||
</script>
|
||||
<template>
|
||||
<div
|
||||
role="group"
|
||||
class="hv-switch-group"
|
||||
:class="`hv-switch-group--${orientation}`"
|
||||
data-slot="switch-group"
|
||||
>
|
||||
<div class="hv-switch-group__items" data-slot="switch-group-items">
|
||||
<div role="group" :class="styles.base()" data-slot="switch-group">
|
||||
<div :class="styles.items()" data-slot="switch-group-items">
|
||||
<slot />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -38,6 +38,11 @@ export {
|
||||
badgeVariants,
|
||||
alertVariants,
|
||||
inputGroupVariants,
|
||||
labelVariants,
|
||||
descriptionVariants,
|
||||
fieldErrorVariants,
|
||||
textFieldVariants,
|
||||
switchGroupVariants,
|
||||
type ButtonVariants,
|
||||
type CardVariants,
|
||||
type InputVariants,
|
||||
@@ -56,6 +61,11 @@ export {
|
||||
type BadgeVariants,
|
||||
type AlertVariants,
|
||||
type InputGroupVariants,
|
||||
type LabelVariants,
|
||||
type DescriptionVariants,
|
||||
type FieldErrorVariants,
|
||||
type TextFieldVariants,
|
||||
type SwitchGroupVariants,
|
||||
} from "@heroui-vue/styles";
|
||||
export type {
|
||||
ButtonProps,
|
||||
|
||||
@@ -110,7 +110,9 @@ const browser = ids.includes("b02-pickers")
|
||||
? "b01"
|
||||
: ids.includes("color-picker")
|
||||
? "color-picker"
|
||||
: null;
|
||||
: ids.includes("shared-styles")
|
||||
? "shared-styles"
|
||||
: null;
|
||||
if (browser) {
|
||||
for (const file of ["index.html", "main.js", "style.css"])
|
||||
fs.copyFileSync(
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { readFileSync } from "node:fs";
|
||||
import * as lib from "@heroui-vue/components";
|
||||
import * as stylesLib from "@heroui-vue/styles";
|
||||
|
||||
const checks = JSON.parse(
|
||||
readFileSync(new URL("./client-checks.json", import.meta.url), "utf8"),
|
||||
@@ -202,10 +203,7 @@ for (const id of process.argv.slice(2)) {
|
||||
assert(lib.ColorSwatchPickerSwatch);
|
||||
assert(lib.ColorSwatchPickerIndicator);
|
||||
assert(
|
||||
lib
|
||||
.colorSwatchPickerVariants()
|
||||
.base()
|
||||
.includes("hv-color-swatch-picker"),
|
||||
lib.colorSwatchPickerVariants().base().includes("hv-color-swatch-picker"),
|
||||
);
|
||||
assert(
|
||||
lib
|
||||
@@ -214,19 +212,16 @@ for (const id of process.argv.slice(2)) {
|
||||
.includes("hv-color-swatch-picker--stack"),
|
||||
);
|
||||
assert(
|
||||
lib
|
||||
.colorSwatchPickerVariants({ size: "xs" })
|
||||
.item() === "hv-color-swatch-picker__item",
|
||||
lib.colorSwatchPickerVariants({ size: "xs" }).item() ===
|
||||
"hv-color-swatch-picker__item",
|
||||
);
|
||||
assert(
|
||||
lib
|
||||
.colorSwatchPickerVariants()
|
||||
.swatch() === "hv-color-swatch-picker__swatch",
|
||||
lib.colorSwatchPickerVariants().swatch() ===
|
||||
"hv-color-swatch-picker__swatch",
|
||||
);
|
||||
assert(
|
||||
lib
|
||||
.colorSwatchPickerVariants()
|
||||
.indicator() === "hv-color-swatch-picker__indicator",
|
||||
lib.colorSwatchPickerVariants().indicator() ===
|
||||
"hv-color-swatch-picker__indicator",
|
||||
);
|
||||
const pickerDts = readFileSync(
|
||||
new URL(
|
||||
@@ -360,5 +355,52 @@ for (const id of process.argv.slice(2)) {
|
||||
);
|
||||
}
|
||||
}
|
||||
if (id === "shared-styles") {
|
||||
// The five shared mappings are importable from both entry points and are
|
||||
// the same functions the components consume.
|
||||
for (const name of spec.exports)
|
||||
assert.equal(
|
||||
stylesLib[name],
|
||||
lib[name],
|
||||
`${name} must match styles entry`,
|
||||
);
|
||||
// Variant outputs must mirror the classes the components actually emit.
|
||||
assert.equal(lib.labelVariants(), "hv-label");
|
||||
assert.equal(
|
||||
lib.labelVariants({
|
||||
isRequired: false,
|
||||
isDisabled: false,
|
||||
isInvalid: false,
|
||||
}),
|
||||
"hv-label",
|
||||
);
|
||||
assert(
|
||||
lib.labelVariants({ isRequired: true }).includes("hv-label--required"),
|
||||
);
|
||||
assert(
|
||||
lib.labelVariants({ isDisabled: true }).includes("hv-label--disabled"),
|
||||
);
|
||||
assert(
|
||||
lib.labelVariants({ isInvalid: true }).includes("hv-label--invalid"),
|
||||
);
|
||||
assert.equal(lib.descriptionVariants(), "hv-description");
|
||||
assert.equal(lib.fieldErrorVariants(), "hv-field-error");
|
||||
assert(lib.textFieldVariants().includes("hv-textfield"));
|
||||
assert(!lib.textFieldVariants().includes("full-width"));
|
||||
assert(
|
||||
lib
|
||||
.textFieldVariants({ fullWidth: true })
|
||||
.includes("hv-textfield--full-width"),
|
||||
);
|
||||
const group = lib.switchGroupVariants();
|
||||
assert(group.base().includes("hv-switch-group--vertical"));
|
||||
assert.equal(group.items(), "hv-switch-group__items");
|
||||
assert(
|
||||
lib
|
||||
.switchGroupVariants({ orientation: "horizontal" })
|
||||
.base()
|
||||
.includes("hv-switch-group--horizontal"),
|
||||
);
|
||||
}
|
||||
console.log(`${id}: packed ESM exports and CSS passed (client scope)`);
|
||||
}
|
||||
|
||||
@@ -18,6 +18,27 @@
|
||||
".hv-popover"
|
||||
]
|
||||
},
|
||||
"shared-styles": {
|
||||
"exports": [
|
||||
"labelVariants",
|
||||
"descriptionVariants",
|
||||
"fieldErrorVariants",
|
||||
"textFieldVariants",
|
||||
"switchGroupVariants"
|
||||
],
|
||||
"css": [
|
||||
"border-color:var(--border,currentColor)",
|
||||
".hv-label--required",
|
||||
".hv-label--disabled",
|
||||
".hv-label--invalid",
|
||||
".hv-description",
|
||||
".hv-field-error",
|
||||
".hv-textfield--full-width",
|
||||
".hv-switch-group__items",
|
||||
".hv-switch-group--horizontal",
|
||||
".hv-switch-group--vertical"
|
||||
]
|
||||
},
|
||||
"b01-menu-dropdown": {
|
||||
"exports": [
|
||||
"DropdownRoot",
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
# Shared styles 独立产物验收(styles 导出与全局边框回退)
|
||||
|
||||
先运行 `node scripts/check-package.mjs shared-styles`(可与受影响契约合跑)统一构建、打包、安装和类型验收;它会把本夹具放入独立消费者并打印路径和 Vite 命令。按输出显式选空闲端口启动,不另外复制安装流程;入口不会自动启动服务。main.js 只从包根/发布 CSS 导入,不用源码 alias、私有路径或 Vue 模板编译器。
|
||||
|
||||
在真实浏览器核对:
|
||||
|
||||
1. `#default-border`(无显式 border 颜色)的计算 `border-color` 等于当前主题的 `--border`(浅/深两值不同)。
|
||||
2. `#explicit-border` 的显式红边框不被全局回退覆盖。
|
||||
3. `#override-border` 的调用方普通 CSS(无 `!important`)覆盖生效;另在页面注入与库规则**同等选择器**的普通样式,验证库规则不是高优先级、不破坏消费者定制。
|
||||
4. `#fallback-border`(`--border: initial`)边框色回退为 `currentColor`(元素文字色)。
|
||||
5. `#component-border` 内 `.hv-input-otp__slot` 的显式 `var(--field-border)`(默认 transparent)不被全局回退覆盖;点 `#theme-toggle` 切深色后上述 `--border` 期望值同步变化。
|
||||
|
||||
记录计算样式实值与截图;不能因 CSS 文本包含 `var(--border` 就通过。类型正反例使用上级 `shared-styles-contract.ts` 的两种解析模式。
|
||||
@@ -0,0 +1,12 @@
|
||||
<!doctype html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>Shared styles 独立产物验收</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script type="module" src="/main.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,85 @@
|
||||
import { createApp, defineComponent, h, shallowRef } from "vue";
|
||||
import {
|
||||
Button,
|
||||
InputOTP,
|
||||
InputOTPGroup,
|
||||
InputOTPSlot,
|
||||
} from "@heroui-vue/components";
|
||||
import "@heroui-vue/styles/css";
|
||||
import "./style.css";
|
||||
|
||||
const theme = shallowRef("light");
|
||||
|
||||
const app = defineComponent({
|
||||
setup() {
|
||||
const toggleTheme = () => {
|
||||
theme.value = theme.value === "light" ? "dark" : "light";
|
||||
document.documentElement.dataset.theme = theme.value;
|
||||
};
|
||||
return () =>
|
||||
h("main", {}, [
|
||||
h(
|
||||
Button,
|
||||
{ id: "theme-toggle", variant: "secondary", onClick: toggleTheme },
|
||||
{ default: () => `主题:${theme.value}` },
|
||||
),
|
||||
h(
|
||||
"div",
|
||||
{
|
||||
id: "default-border",
|
||||
class: "box default-border",
|
||||
"data-testid": "default-border",
|
||||
},
|
||||
"默认边框(无显式颜色)",
|
||||
),
|
||||
h(
|
||||
"div",
|
||||
{
|
||||
id: "explicit-border",
|
||||
class: "box explicit-border",
|
||||
"data-testid": "explicit-border",
|
||||
},
|
||||
"显式 border 颜色",
|
||||
),
|
||||
h(
|
||||
"div",
|
||||
{
|
||||
id: "override-border",
|
||||
class: "box override-border",
|
||||
"data-testid": "override-border",
|
||||
},
|
||||
"调用方覆盖",
|
||||
),
|
||||
h(
|
||||
"div",
|
||||
{
|
||||
id: "fallback-border",
|
||||
class: "box fallback-border",
|
||||
"data-testid": "fallback-border",
|
||||
},
|
||||
"缺少 --border 时回退 currentColor",
|
||||
),
|
||||
h("div", { id: "component-border" }, [
|
||||
h(
|
||||
InputOTP,
|
||||
{ "aria-label": "验证码", "max-length": 4, modelValue: "" },
|
||||
{
|
||||
default: () =>
|
||||
h(
|
||||
InputOTPGroup,
|
||||
{},
|
||||
{
|
||||
default: () =>
|
||||
[0, 1, 2, 3].map((index) =>
|
||||
h(InputOTPSlot, { index, key: index }),
|
||||
),
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
]),
|
||||
]);
|
||||
},
|
||||
});
|
||||
|
||||
createApp(app).mount("#app");
|
||||
@@ -0,0 +1,35 @@
|
||||
/* Consumer-side CSS: plain unlayered rules must override the library's
|
||||
* base-layer border fallback without !important. */
|
||||
main {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 24px;
|
||||
padding: 32px;
|
||||
}
|
||||
|
||||
.box {
|
||||
padding: 8px;
|
||||
border-style: solid;
|
||||
border-width: 2px;
|
||||
}
|
||||
|
||||
/* 1. default border: no explicit color -> theme --border */
|
||||
.default-border {
|
||||
background: var(--surface);
|
||||
}
|
||||
|
||||
/* 2. explicit color survives the global fallback */
|
||||
.explicit-border {
|
||||
border-color: rgb(200, 0, 0);
|
||||
}
|
||||
|
||||
/* 3. consumer override wins without !important */
|
||||
.override-border {
|
||||
border-color: rgb(0, 128, 0);
|
||||
}
|
||||
|
||||
/* 4. missing --border falls back to currentColor */
|
||||
.fallback-border {
|
||||
--border: initial;
|
||||
color: rgb(0, 0, 255);
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
import {
|
||||
descriptionVariants,
|
||||
fieldErrorVariants,
|
||||
labelVariants,
|
||||
switchGroupVariants,
|
||||
textFieldVariants,
|
||||
type DescriptionVariants,
|
||||
type FieldErrorVariants,
|
||||
type LabelVariants,
|
||||
type SwitchGroupVariants,
|
||||
type TextFieldVariants,
|
||||
type VariantProps,
|
||||
} from "@heroui-vue/styles";
|
||||
import {
|
||||
labelVariants as componentsLabelVariants,
|
||||
type LabelVariants as ComponentsLabelVariants,
|
||||
} from "@heroui-vue/components";
|
||||
|
||||
const required: LabelVariants = { isRequired: true, isDisabled: false };
|
||||
labelVariants(required);
|
||||
labelVariants({ isInvalid: true });
|
||||
descriptionVariants();
|
||||
fieldErrorVariants();
|
||||
const wide: TextFieldVariants = { fullWidth: true };
|
||||
textFieldVariants(wide);
|
||||
const horizontal: SwitchGroupVariants = { orientation: "horizontal" };
|
||||
switchGroupVariants(horizontal);
|
||||
switchGroupVariants({ orientation: "vertical" }).items();
|
||||
|
||||
// Components re-export the same mapping and type.
|
||||
const viaComponents: ComponentsLabelVariants = { isDisabled: true };
|
||||
componentsLabelVariants(viaComponents);
|
||||
|
||||
type Description = VariantProps<typeof descriptionVariants>;
|
||||
const base: Description = {};
|
||||
descriptionVariants(base);
|
||||
|
||||
// @ts-expect-error variant flags stay boolean-typed
|
||||
const badRequired: LabelVariants = { isRequired: "yes" };
|
||||
// @ts-expect-error unknown label variant keys stay rejected
|
||||
const badLabelKey: LabelVariants = { isDanger: true };
|
||||
// @ts-expect-error fullWidth stays boolean-typed
|
||||
const badWidth: TextFieldVariants = { fullWidth: "yes" };
|
||||
// @ts-expect-error orientation stays a closed union
|
||||
const badOrientation: SwitchGroupVariants = { orientation: "diagonal" };
|
||||
// @ts-expect-error the exported description shape stays non-nullable object-typed
|
||||
const badDescription: DescriptionVariants = null;
|
||||
// @ts-expect-error the exported field-error shape stays non-nullable object-typed
|
||||
const badFieldError: FieldErrorVariants = null;
|
||||
void badRequired;
|
||||
void badLabelKey;
|
||||
void badWidth;
|
||||
void badOrientation;
|
||||
void badDescription;
|
||||
void badFieldError;
|
||||
@@ -0,0 +1,90 @@
|
||||
import { expect, it, describe } from "vitest";
|
||||
import { mount } from "@vue/test-utils";
|
||||
import {
|
||||
descriptionVariants,
|
||||
fieldErrorVariants,
|
||||
labelVariants,
|
||||
switchGroupVariants,
|
||||
textFieldVariants,
|
||||
} from "@heroui-vue/styles";
|
||||
|
||||
import Label from "../packages/vue/src/components/label/Label.vue";
|
||||
import Description from "../packages/vue/src/components/description/Description.vue";
|
||||
import FieldError from "../packages/vue/src/components/field/FieldError.vue";
|
||||
import SwitchGroup from "../packages/vue/src/components/switch/SwitchGroup.vue";
|
||||
import {
|
||||
labelVariants as componentsLabelVariants,
|
||||
descriptionVariants as componentsDescriptionVariants,
|
||||
fieldErrorVariants as componentsFieldErrorVariants,
|
||||
textFieldVariants as componentsTextFieldVariants,
|
||||
switchGroupVariants as componentsSwitchGroupVariants,
|
||||
} from "../packages/vue/src";
|
||||
|
||||
describe("shared field style mappings", () => {
|
||||
it("mirror the pinned upstream variant sets and defaults", () => {
|
||||
expect(labelVariants()).toBe("hv-label");
|
||||
expect(labelVariants({ isRequired: true })).toContain("hv-label--required");
|
||||
expect(labelVariants({ isDisabled: true })).toContain("hv-label--disabled");
|
||||
expect(labelVariants({ isInvalid: true })).toContain("hv-label--invalid");
|
||||
expect(labelVariants({ isRequired: false })).toBe("hv-label");
|
||||
expect(descriptionVariants()).toBe("hv-description");
|
||||
expect(fieldErrorVariants()).toBe("hv-field-error");
|
||||
expect(textFieldVariants()).toContain("hv-textfield");
|
||||
expect(textFieldVariants()).not.toContain("full-width");
|
||||
expect(textFieldVariants({ fullWidth: true })).toContain(
|
||||
"hv-textfield--full-width",
|
||||
);
|
||||
const group = switchGroupVariants();
|
||||
expect(group.base()).toContain("hv-switch-group--vertical");
|
||||
expect(group.items()).toBe("hv-switch-group__items");
|
||||
expect(switchGroupVariants({ orientation: "horizontal" }).base()).toContain(
|
||||
"hv-switch-group--horizontal",
|
||||
);
|
||||
});
|
||||
|
||||
it("are re-exported unchanged from the components entry", () => {
|
||||
expect(componentsLabelVariants).toBe(labelVariants);
|
||||
expect(componentsDescriptionVariants).toBe(descriptionVariants);
|
||||
expect(componentsFieldErrorVariants).toBe(fieldErrorVariants);
|
||||
expect(componentsTextFieldVariants).toBe(textFieldVariants);
|
||||
expect(componentsSwitchGroupVariants).toBe(switchGroupVariants);
|
||||
});
|
||||
|
||||
it("components render exactly the shared mapping output for their states", () => {
|
||||
const label = mount(Label, {
|
||||
props: { isRequired: true, isInvalid: true },
|
||||
slots: { default: "名称" },
|
||||
attachTo: document.body,
|
||||
});
|
||||
expect(label.classes().sort()).toEqual(
|
||||
labelVariants({ isRequired: true, isInvalid: true }).split(" ").sort(),
|
||||
);
|
||||
label.unmount();
|
||||
|
||||
const description = mount(Description, {
|
||||
slots: { default: "说明" },
|
||||
attachTo: document.body,
|
||||
});
|
||||
expect(description.classes()).toEqual(descriptionVariants().split(" "));
|
||||
description.unmount();
|
||||
|
||||
const error = mount(FieldError, {
|
||||
slots: { default: "错误" },
|
||||
attachTo: document.body,
|
||||
});
|
||||
expect(error.classes()).toContain("hv-field-error");
|
||||
error.unmount();
|
||||
|
||||
const group = mount(SwitchGroup, {
|
||||
props: { orientation: "horizontal" },
|
||||
slots: { default: "选项" },
|
||||
attachTo: document.body,
|
||||
});
|
||||
const expected = switchGroupVariants({ orientation: "horizontal" });
|
||||
expect(group.classes().sort()).toEqual(expected.base().split(" ").sort());
|
||||
expect(group.find('[data-slot="switch-group-items"]').classes()).toEqual(
|
||||
expected.items().split(" "),
|
||||
);
|
||||
group.unmount();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user