diff --git a/AGENTS.md b/AGENTS.md index 7da0fab..e002b40 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -508,3 +508,9 @@ Area 覆盖所有有序轴和 RTL;稳定 Root 捕获指针,内容区/边框/ 先读 [COLOR-03](docs/migrations/COLOR-03-input-foundation.md)。通道数值和文本草稿共用接受值 owner;禁止用 Reka 的乐观 ColorSlider ref 或 ColorField 的 hex 回传再建颜色模型。alpha 显示百分数、模型小数;未编辑的格式化草稿不得反向量化原始模型。IME、严格 locale 解析、拒绝/重试和取消原生事件分别回归。 同一真实 input 只绑定当前模式的控制器/reset,inactive 控制器不得覆盖文本。字段校验与 reset 复用 choice/Form;夹具的 hex/原始通道提交不是最终公开格式。native range 验证不等于自定义 Track/Thumb 的方向/几何/捕获通过,正式 Slider/Field/Picker 仍由集成人完成高风险接入后再交普通收尾。 + +## COLOR-04 自定义轨道与组合(2026-10-25) + +先读 [COLOR-04](docs/migrations/COLOR-04-slider-picker-foundation.md)。颜色自定义 Track 和 native-channel 共用一个 token/原生 range;显示色与接受色分开,hue 的完整色环不得改变灰色 hue/alpha。完整精度序列化是私有 owner 证明,不提前承诺公开字段格式。退出观察弹层已接受的 open 状态,不能按被拒绝的关闭提案取消颜色事务;可选布尔 open 显式保留 undefined。 + +草稿 Escape 与弹层 Escape 分层,无草稿不拦截关闭。Popover 的 available-height 必须在真实长面板上核对,Dialog 内滚动同时保留外层箭头,不靠 docs 定位补丁。下一批公开 Slider 的依赖/范围见 [COLOR-05](docs/migrations/COLOR-05-slider-prompt.md);Picker/字段协议仍由集成人维护。 diff --git a/apps/playground/src/App.vue b/apps/playground/src/App.vue index b58545f..26396d7 100644 --- a/apps/playground/src/App.vue +++ b/apps/playground/src/App.vue @@ -1,5 +1,9 @@ - + + diff --git a/apps/playground/src/ColorSliderFoundationLab.vue b/apps/playground/src/ColorSliderFoundationLab.vue new file mode 100644 index 0000000..0fe9792 --- /dev/null +++ b/apps/playground/src/ColorSliderFoundationLab.vue @@ -0,0 +1,135 @@ + + + + 颜色轨道与 Picker 组合 · 私有基建 + + 自定义轨道、原生焦点输入和共享接受值;正式公开部件与文档示例仍待收尾。 + + + + 灰色色相 / 拖动完成 + + change {{ changes }} / changeEnd {{ ends }} + + + 受控拒绝 / 重复提案 + + change {{ rejected }} / changeEnd {{ rejectEnds }} + + + RGB / RTL / 缩放与边框 + + + + + + 透明度与两侧边帽 + + + + HSL 明度中间色 + + + + 竖向 / RTL + + + + + + Popover / 唯一提交 / reset + + + 重置 + + + + + + diff --git a/docs/compatibility.md b/docs/compatibility.md index 9a2638c..76f5e99 100644 --- a/docs/compatibility.md +++ b/docs/compatibility.md @@ -226,3 +226,7 @@ Toast 11/11 与 Table 13/13 预览、各部件 Props、文档和默认源样式 ## COLOR-03 颜色输入基建 共享通道解析、原生 range 事务及文本草稿/IME/locale/校验/reset 已由私有夹具验证,没有公开 ColorSlider/Field/InputGroup/Picker。自定义轨道、正式字段提交格式和 Picker 组合仍待接续;准确范围见 [COLOR-03](migrations/COLOR-03-input-foundation.md)。 + +## COLOR-04 颜色轨道与 Picker 组合 + +私有 ColorSlider 自定义轨道、捕获/取消、方向/渐变与 Picker 共享 owner/Popover/唯一提交证明已通过重点验证,尚未公开这些组件。公共 Popover 已补可用高度与 Dialog 滚动;实际范围与待办见 [COLOR-04](migrations/COLOR-04-slider-picker-foundation.md)。 diff --git a/docs/decisions/color-foundation.md b/docs/decisions/color-foundation.md index b02fd85..2f4962f 100644 --- a/docs/decisions/color-foundation.md +++ b/docs/decisions/color-foundation.md @@ -56,3 +56,7 @@ ColorArea CSS 已从基线准备,hv- 命名空间及 Apache 声明保留;未 ## COLOR-03 输入协议接续(2026-10-25) 通道解析/空间选择、原生 range 事务和文本草稿已作为私有层接入同一接受值 owner,详见 [COLOR-03](../migrations/COLOR-03-input-foundation.md)。不使用 Reka ColorSlider 的内部乐观颜色缓存或 ColorField 的 hex 发值作为本库状态源。草稿不参与提交,未修改的格式化输入不量化模型,alpha 显示/模型尺度明确转换。当前 native range 不是最终 Track 几何实现;私有夹具的提交格式不提前成为公共 API。 + +## COLOR-04 轨道与组合接续(2026-10-25) + +自定义 Slider Track 通过 native-channel 私有 transaction 桥接复用同一 token;指针捕获/抓取偏移/步长和位置只从接受值派生。显示色单独计算,不改变模型。私有 Picker 在现有 Popover/Teleport 上证明共享 owner、单一完整精度序列化与接受关闭后取消;正式公开表单格式仍待核对。详见 [COLOR-04](../migrations/COLOR-04-slider-picker-foundation.md),普通公开 Slider 收尾可按 COLOR-05 交接。 diff --git a/docs/migration-handoff.md b/docs/migration-handoff.md index 6b01925..7e856c1 100644 --- a/docs/migration-handoff.md +++ b/docs/migration-handoff.md @@ -338,3 +338,7 @@ DateField 七部件与 DateInputGroup 六部件、17 例已落地,范围和差 ### COLOR-03 私有输入协议(2026-10-25) [报告](migrations/COLOR-03-input-foundation.md) 已验证共享通道、文本草稿、IME、locale、受控拒绝/重试与现有 Form/reset。禁止把安装版 hex 回传作为颜色状态源,也不要让 inactive range 控制器改文本 input。alpha 显示百分数、模型小数;未编辑草稿保留高精度接受值。当前没有公共 Slider/Field/Picker,native range 不代替自定义轨道验收;集成人继续几何/Picker/公共提交协议,COLOR-02 Area/Swatch 范围不变。 + +### COLOR-04 轨道与弹层组合(2026-10-25) + +[COLOR-04](migrations/COLOR-04-slider-picker-foundation.md) 已验证自定义 Track 几何/捕获/方向/拒绝、显示色渐变与 Picker 共享 owner/关闭协议。不要再建拖动颜色缓存;同一 native range/token 覆盖指针/键盘/AT。Boolean open 省略时保持 undefined;仅接受的关闭取消手势;无文本草稿时 Escape 留给弹层。公共 Popover 高度约束在组件层修正,Dialog 滚动不应裁外层箭头。Area/Swatch 集成后可按 [COLOR-05](migrations/COLOR-05-slider-prompt.md) 交接 Slider 四部件/9例;正式字段提交/Picker 仍由集成人核对。 diff --git a/docs/migrations/COLOR-04-slider-picker-foundation.md b/docs/migrations/COLOR-04-slider-picker-foundation.md new file mode 100644 index 0000000..646765d --- /dev/null +++ b/docs/migrations/COLOR-04-slider-picker-foundation.md @@ -0,0 +1,35 @@ +# COLOR-04:颜色滑条几何与 Picker 组合验证 + +2026-10-25,从同步后的 main `e59d1be` 新建 `feat/color-slider-geometry`。本轮完成私有自定义轨道与组合协议,没有公开 ColorSlider/Field/Picker 或正式组件页。COLOR-02 的 Area/Swatch 公共任务范围不变。 + +## 实现与约束 + +- `color/slider.ts` 在 COLOR-03 native-channel 上增加稳定 Track pointer capture;共享同一 token、接受值与键盘/AT 输入,不建第二个拖动颜色缓存。Track 排除边框并适配祖先缩放;Thumb 抓取偏移、RTL 与竖向各自计算,按通道步长吸附。 +- 移动和 pointerup 最后一点均处理,同一坐标不重复提案。受控拒绝时 Thumb/原生值保持父值,完成事件保留最后提案,下一次手势可重试;取消不回滚已经接受的进度,也不报告完成。 +- canceled down/move/up、非主指针/右键/修饰鼠标、丢失捕获、窗口失焦、禁用/只读、方向/通道变化、父值替换、原节点替换与卸载均有清理。捕获在原 Track 上释放,不尝试在新节点释放旧捕获。 +- 源 ColorSlider CSS 加 hv- 前缀并保留尺寸、间距、阴影与动效,作为私有夹具的暂存样式。Thumb 的位移来自接受值;真实 visually-hidden range 保留一个焦点/原生提交入口,step=any 不量化程序化小数值。 +- `slider-gradient.ts` 将显示色与接受色分开:hue 始终显示完整、不透明色环;其他非 alpha 通道显示不透明颜色;alpha 保留透明度。HSL lightness 包含中间色,方向与端帽跟随 RTL/竖向。 +- 源端帽的单色 `linear-gradient(var(...))` 不产生有效浏览器渐变,改为重复两个相同色标;末端也叠棋盘背景,透明时不透出页面底色。浏览器读取了实际伪元素计算样式,而非仅检查 CSS 文本。 +- 私有 `ColorPickerComposition.vue` 验证 owner → Popover → Teleport 内 Area/Slider/文本共享。每个子项不命名,只有 owner 提交一次;`submission.ts` 以原始通道及完整 JS 数值精度输出功能字符串,科学计数法展开成严格解析器可回读的小数。此为完整精度证明,仍不是最终公开 Picker 的表单格式承诺。 +- Popover accepted open 状态由既有弹层设施维护,Boundary 观察接受的关闭后取消颜色事务;父拒绝关闭不取消正在编辑的事务。可选 Boolean open 显式保留 undefined,不能误把非受控弹层锁死。 +- 文本 Escape 只在存在草稿时取消默认事件;无草稿时让既有弹层处理关闭。修正的是共享 text 控制器,不在演示中拦截键盘。 + +## 公共 Popover 修复 + +真实长面板暴露 `.hv-popover` 未应用 Reka 已计算可用高度的问题,面板顶端超出视口。组件层新增 `max-height: var(--reka-popover-content-available-height)`,Dialog 继承高度并纵向滚动/限制滚动链;外层继续允许箭头溢出。原有 Popover/Select/Tooltip/日期回归保留,非 Dialog 自定义子结构仍需按自身布局处理内容滚动。 + +## 来源 + +固定 HeroUI ce90ea3 的 ColorSlider/Picker 源码、ColorSlider CSS/tv 与中文演示。移植 CSS 的 Apache-2.0 声明沿用 `third-party/HEROUI-LICENSE`。当日 Adobe [useColorSliderState](https://github.com/adobe/react-spectrum/blob/main/packages/react-stately/src/color/useColorSliderState.ts) / [useColorSlider](https://github.com/adobe/react-spectrum/blob/main/packages/react-aria/src/color/useColorSlider.ts) 只辅助审计显示色/通道梯度及原生 name/form 语义,未复制 React hook,不替换固定 HeroUI 基线。 + +## 验证与边界 + +- 新增 17 项轨道/渐变、10 项组合/精度/实际水合、2 项真实 Node SSR。全库、类型、构建与独立消费的最终结果记录在 `docs/verification.md`。 +- 浏览器 `5176/?color-slider-foundation`:216×20 横向 Track,16×16 Thumb;带 2px 抓取偏移拖动 hue 270→90,8 次 change/1 次 changeEnd;拒绝拖动同样发出提案但仍保持 270;竖向 RTL 90→270;0.9 缩放和 4px 边框的 RGB RTL 点击得到 191。 +- Teleport 内 hue 270→271、alpha 文本→.25,同步外部完整接受值且只有一个 name=color;reset 恢复 .123456789,关闭重开保持同一 owner;草稿 Escape/弹层 Escape 与触发焦点均验证。 +- 长弹层从 top=-30 修复到 top=12、bottom=403(可用高391);Tab 到底部 Hex 字段后 scrollTop=93,字段 top=349/bottom=387,保持在面板内。截图保存为临时 `/private/tmp/heroui-color-slider-review.png` 与 `heroui-color-picker-scroll-review.png`,不参与构建。 +- 未验物理触屏、多浏览器、完整读屏、逐像素或 Nuxt。ColorSlider 的 aria-valuetext 当前为通道数字/单位,感知色名仍未迁移;闭态 SSR/水合不证明所有公开组合已经验收。 + +## 后续分工 + +ColorSlider 的高风险几何/事务/渐变已稳定,可在 Area/Swatch 的公共颜色类型落地后交接四部件、全部 Props、variants、9 个正式预览与完整文档,见 COLOR-05。公共颜色字段提交、ColorInputGroup 组合和 Picker 正式协议/类型仍由集成人核对;不把私有夹具直接导出成正式组件。 diff --git a/docs/migrations/COLOR-05-slider-prompt.md b/docs/migrations/COLOR-05-slider-prompt.md new file mode 100644 index 0000000..8e78820 --- /dev/null +++ b/docs/migrations/COLOR-05-slider-prompt.md @@ -0,0 +1,13 @@ +# COLOR-05:其他 AI 的 ColorSlider 公共收尾提示词 + +在 COLOR-02 Area/Swatch(含公共 Color/parseColor)已经集成 main 后执行;若尚未集成,先完成原任务,不并行改包根和颜色公共类型。 + +请同步最新 main 后新开 `feat/color-05-slider`,完成 ColorSlider 公共迁移。先读根 AGENTS.md、迁移说明及 COLOR-01/03/04。固定 HeroUI ce90ea3,不能改写共享颜色 owner、通道、native-channel、slider 几何或梯度来迎合演示。底座缺口交最小失败用例给集成人。 + +范围:ColorSlider/ColorSliderRoot、Output、Track、Thumb 四部件及全部 Props,样式包 variants/导出、根导出、中文文档与 basic/channels/alpha-channel/vertical/disabled/controlled/rgb-channels/custom-styles/render-function 共九个基线预览。预览/高亮/复制取同一 SFC,图标用 Tabler Vue,表格满宽换行。不要顺带迁移 ColorField/Picker/SwatchPicker。 + +消费私有 `color/slider.ts` 的同一 native 输入/token;Thumb 不能另建乐观坐标或颜色。Root 默认/受控/继承、通道/空间合法组合类型与运行时修正、Label/Output/ARIA、attrs/事件取消、name/form 直接命名唯一原生 range。保持受控拒绝/相同提案重试、取消无完成、父值替换/禁用/旧节点释放、RTL/竖向、抓取偏移和原生 reset;确认 defaultValue 与公共是否允许 null 的规则来自固定上游,不照搬私有夹具宽松类型。 + +源 CSS 已暂存,数值不要改;hue 显示完整色环而不改变接受色的灰色/alpha,其他通道的显示 alpha 与接受 alpha 分开。端帽透明棋盘适配和公共 Popover 高度修复保留。感知色名差异须写入兼容矩阵,不假造已完成的全读屏支持。 + +新增行为/SSR/实际水合、九例共存/交互测试和类型正反例;最后库/文档/消费构建及独立 tarball 的 strict NodeNext/bundler 正反例。浏览器重点验拖动/取消/方向/缩放与焦点,不必每页机械点击。更新 compatibility/upstream/verification 与本轮验收,说明真实验收边界;完成后给集成人检查,不擅自合入 main。 diff --git a/docs/upstream.md b/docs/upstream.md index b157d99..13c40ff 100644 --- a/docs/upstream.md +++ b/docs/upstream.md @@ -214,3 +214,7 @@ M18–M20 的标签桥接在 Vue 使用 indicator 注册表与 SSR 直接/原生 ## COLOR-03 颜色输入基建(2026-10-25) 核对固定 ce90ea3 ColorSlider/Field/InputGroup、中文文档及示例;安装版 Reka 2.11 的 Field/Slider 公开探针记录 hex 量化/乐观值差异。仅新增本库私有输入适配,未复制底座 hook/CSS。Adobe 当日 useColorFieldState 的草稿/整数步进语义为辅助参考,链接与边界见 [COLOR-03](migrations/COLOR-03-input-foundation.md)。 + +## COLOR-04 颜色轨道与组合(2026-10-25) + +固定 ce90ea3 ColorSlider/Picker、ColorSlider CSS/tv 及演示;CSS 加 hv- 前缀并保留 Apache 声明,单色渐变端帽改合法双色标并补透明棋盘。Adobe 当日 ColorSlider 的显示色和梯度语义仅作辅助审计,不复制 React hook;来源链接与公共 Popover 高度适配见 [COLOR-04](migrations/COLOR-04-slider-picker-foundation.md)。 diff --git a/docs/verification.md b/docs/verification.md index 010f208..4d326c2 100644 --- a/docs/verification.md +++ b/docs/verification.md @@ -931,3 +931,10 @@ Button/PopoverTrigger/Link/ToggleButtonGroup 源码及几何复核后,移除 - 从 main `6b85014` 新建 feat/color-input-foundation;26 项行为/集成/实际水合 + 2 安装版 Reka 探针 + 2 真实 Node SSR,全库 81 文件 / 992 项通过。范围及未完成项见 [COLOR-03](migrations/COLOR-03-input-foundation.md)。 - vue-tsc 含通道必填/无效通道/空间类型反例、库/样式/文档 SSR 构建通过;既有文档大 chunk 提示保留。无新增依赖或公共导出,未重复本轮 tarball 安装验收。 - 浏览器 5176 `?color-input-foundation` 已验共享灰色 hue、德语 alpha、拒绝重复提案/原生拖动复位、必填错误焦点及跨视图 reset;原生 range 不是最终自定义轨道,不声称公共 Slider/Field/Picker 迁移完成。物理触屏、完整 AT、逐像素及 Nuxt 未验。 + +## COLOR-04 自定义颜色轨道与 Picker 组合(2026-10-25) + +- 从 main `e59d1be` 新建 feat/color-slider-geometry。新增 17 项轨道/渐变、10 项组合/精度/实际水合和 2 项真正 Node SSR;最终全库 **84 文件 / 1021 项通过**,类型检查含竖向反例通过。私有实现/限制见 [COLOR-04](migrations/COLOR-04-slider-picker-foundation.md),没有公开 Slider/Field/Picker。 +- 库/样式/文档 SSR 与 playground 构建、Prettier 和 diff 空白检查通过;原有文档大 chunk 提示保留。独立 `/private/tmp/heroui-color-slider-consumer` 安装最终两份 tarball,新增暂存 Slider CSS/合法端帽/Popover 高度约束与无公开占位导出检查,并保留 Calendar/DateField/Select 的 ESM/SSR/CSS 与 strict NodeNext/bundler 类型正反例。 +- 真实浏览器证明自定义横向/竖向/RTL/缩放边框/抓取偏移、拒绝后 Thumb 位置、8 change/1 changeEnd、Teleport 共享 owner/唯一命名提交、reset 与 Escape/恢复焦点。公共 Popover 从 top=-30 改为12,长 Dialog 内滚动后底部焦点字段保持可见;详见报告的实际数值与截图位置。 +- 显示色与接受色分离、原节点捕获释放和接受关闭后取消均有回归。辅助全精度序列化不成为公开表单格式承诺;未验真机触屏、全 AT、多浏览器、逐像素、Nuxt。ColorSlider 的普通公开收尾可在 Area/Swatch 集成后交接 COLOR-05,字段/Picker 正式契约仍待集成人核对。 diff --git a/package.json b/package.json index b4717dc..b8c2379 100644 --- a/package.json +++ b/package.json @@ -15,8 +15,8 @@ "build:docs": "pnpm build && pnpm --filter @heroui-vue/docs build", "typecheck": "vue-tsc --noEmit", "test": "vitest run", - "test:unit": "vitest run tests/choice-demos.test.ts tests/choice-fields.test.ts tests/fieldset-search-field.test.ts tests/components.test.ts tests/composition.test.ts tests/docs-search.test.ts tests/button-demos.test.ts tests/aligned-components.test.ts tests/surface-link-spinner.test.ts tests/close-button-avatar-skeleton.test.ts tests/separator-kbd-chip.test.ts tests/badge-alert.test.ts tests/input-group.test.ts tests/field-docs-textarea.test.ts tests/field-foundation.test.ts tests/typography-empty-breadcrumbs.test.ts tests/progress-meter.test.ts tests/disclosure-accordion.test.ts tests/overlay-foundation.test.ts tests/modal.test.ts tests/popover-tooltip.test.ts tests/overlay-demos.test.ts tests/scroll-tabs.test.ts tests/button-toggle.test.ts tests/m26-review.probe.test.ts tests/toolbar.test.ts tests/m29-review.probe.test.ts tests/m30-m32-review.probe.test.ts tests/pagination.test.ts tests/header.test.ts tests/input-otp.test.ts tests/number-field-foundation.test.ts tests/number-field.test.ts tests/slider-foundation.test.ts tests/slider.test.ts tests/collection-state.test.ts tests/collection-foundation.test.ts tests/list-box.test.ts tests/alert-dialog.test.ts tests/drawer.test.ts tests/m33-m34-review.probe.test.ts tests/m33-m34-lifecycle-review.probe.test.ts tests/m33-m34-coexist.test.ts tests/select.test.ts tests/date-value.test.ts tests/date-model.test.ts tests/date-foundation.test.ts tests/date-field.test.ts tests/date-field-demos.test.ts tests/toast.test.ts tests/table.test.ts tests/m35-m36-takeover.test.ts tests/m35-m36-review.probe.test.ts tests/m35-m36-review-2.probe.test.ts tests/m35-m36-review-3.probe.test.ts tests/m35-m36-review-4.probe.test.ts tests/m35-m36-review-5.probe.test.ts tests/m35-m36-hydration.test.ts tests/docs-shell.test.ts tests/calendar-view.test.ts tests/calendar.test.ts tests/calendar-demos.test.ts tests/range-calendar-foundation.test.ts tests/color-foundation.test.ts tests/color-foundation-probes.test.ts tests/color-input-foundation.test.ts tests/color-input-probes.test.ts", - "test:ssr": "vitest run tests/ssr.test.ts tests/input-otp-ssr.test.ts tests/slider-foundation-ssr.test.ts tests/slider-ssr.test.ts tests/collection-foundation-ssr.test.ts tests/list-box-ssr.test.ts tests/select-ssr.test.ts tests/date-foundation-ssr.test.ts tests/date-field-ssr.test.ts tests/m35-m36-ssr.test.ts tests/calendar-ssr.test.ts tests/range-calendar-foundation-ssr.test.ts tests/color-foundation-ssr.test.ts tests/color-input-foundation-ssr.test.ts", + "test:unit": "vitest run tests/choice-demos.test.ts tests/choice-fields.test.ts tests/fieldset-search-field.test.ts tests/components.test.ts tests/composition.test.ts tests/docs-search.test.ts tests/button-demos.test.ts tests/aligned-components.test.ts tests/surface-link-spinner.test.ts tests/close-button-avatar-skeleton.test.ts tests/separator-kbd-chip.test.ts tests/badge-alert.test.ts tests/input-group.test.ts tests/field-docs-textarea.test.ts tests/field-foundation.test.ts tests/typography-empty-breadcrumbs.test.ts tests/progress-meter.test.ts tests/disclosure-accordion.test.ts tests/overlay-foundation.test.ts tests/modal.test.ts tests/popover-tooltip.test.ts tests/overlay-demos.test.ts tests/scroll-tabs.test.ts tests/button-toggle.test.ts tests/m26-review.probe.test.ts tests/toolbar.test.ts tests/m29-review.probe.test.ts tests/m30-m32-review.probe.test.ts tests/pagination.test.ts tests/header.test.ts tests/input-otp.test.ts tests/number-field-foundation.test.ts tests/number-field.test.ts tests/slider-foundation.test.ts tests/slider.test.ts tests/collection-state.test.ts tests/collection-foundation.test.ts tests/list-box.test.ts tests/alert-dialog.test.ts tests/drawer.test.ts tests/m33-m34-review.probe.test.ts tests/m33-m34-lifecycle-review.probe.test.ts tests/m33-m34-coexist.test.ts tests/select.test.ts tests/date-value.test.ts tests/date-model.test.ts tests/date-foundation.test.ts tests/date-field.test.ts tests/date-field-demos.test.ts tests/toast.test.ts tests/table.test.ts tests/m35-m36-takeover.test.ts tests/m35-m36-review.probe.test.ts tests/m35-m36-review-2.probe.test.ts tests/m35-m36-review-3.probe.test.ts tests/m35-m36-review-4.probe.test.ts tests/m35-m36-review-5.probe.test.ts tests/m35-m36-hydration.test.ts tests/docs-shell.test.ts tests/calendar-view.test.ts tests/calendar.test.ts tests/calendar-demos.test.ts tests/range-calendar-foundation.test.ts tests/color-foundation.test.ts tests/color-foundation-probes.test.ts tests/color-input-foundation.test.ts tests/color-input-probes.test.ts tests/color-slider-foundation.test.ts tests/color-picker-composition.test.ts", + "test:ssr": "vitest run tests/ssr.test.ts tests/input-otp-ssr.test.ts tests/slider-foundation-ssr.test.ts tests/slider-ssr.test.ts tests/collection-foundation-ssr.test.ts tests/list-box-ssr.test.ts tests/select-ssr.test.ts tests/date-foundation-ssr.test.ts tests/date-field-ssr.test.ts tests/m35-m36-ssr.test.ts tests/calendar-ssr.test.ts tests/range-calendar-foundation-ssr.test.ts tests/color-foundation-ssr.test.ts tests/color-input-foundation-ssr.test.ts tests/color-slider-foundation-ssr.test.ts", "format": "prettier --check .", "format:fix": "prettier --write .", "dev:playground": "pnpm build && pnpm --filter @heroui-vue/playground dev" diff --git a/packages/styles/components/color-slider.css b/packages/styles/components/color-slider.css new file mode 100644 index 0000000..34d536c --- /dev/null +++ b/packages/styles/components/color-slider.css @@ -0,0 +1,277 @@ +/* Adapted from HeroUI ce90ea3, Apache-2.0; see third-party/HEROUI-LICENSE. */ +/* ========================================================================== + ColorSlider - A slider for adjusting individual color channel values + ========================================================================== */ + +/* Base styles */ +.hv-color-slider { + @apply grid w-full gap-1; + + grid-template-areas: + "label output" + "track track"; + grid-template-columns: 1fr auto; + grid-template-rows: auto auto; + + /* When neither label nor output exist, collapse to single row */ + &:not(:has([data-slot="label"])):not(:has(.hv-color-slider__output)) { + grid-template-areas: "track"; + grid-template-columns: 1fr; + grid-template-rows: auto; + gap: 0; + } + + /* When only label exists (no output) */ + &:has([data-slot="label"]):not(:has(.hv-color-slider__output)) { + grid-template-areas: + "label" + "track"; + grid-template-columns: 1fr; + } + + /* When only output exists (no label) */ + &:not(:has([data-slot="label"])):has(.hv-color-slider__output) { + grid-template-areas: + "output" + "track"; + grid-template-columns: 1fr; + + .hv-color-slider__output { + justify-self: end; + } + } + + [data-slot="label"] { + @apply w-fit text-sm font-medium; + + grid-area: label; + } + + .hv-color-slider__output { + @apply text-sm font-medium tabular-nums; + + grid-area: output; + } + + .hv-color-slider__track { + @apply relative rounded-2xl; + + grid-area: track; + /* Edge cap pseudo-elements */ + &::before, + &::after { + content: ""; + position: absolute; + z-index: 0; + pointer-events: none; + } + } + + .hv-color-slider__thumb { + /* Flex container for centering */ + @apply absolute flex cursor-grab items-center justify-center rounded-2xl no-highlight; + + /* Border to create white ring around the thumb */ + @apply border-3 border-white shadow-overlay; + + /* Ensure thumb is above edge caps */ + z-index: 1; + + /** + * Transitions + * CRITICAL: motion-reduce must be AFTER transition for correct override specificity + */ + transition: + transform 250ms var(--ease-out), + box-shadow 150ms var(--ease-out); + @apply motion-reduce:transition-none; + + /* Dragging state - cursor changes and thumb scales down */ + &[data-dragging="true"] { + @apply cursor-grabbing; + } + + /* Focus state - show focus ring */ + &[data-focus-visible="true"] { + @apply z-10 status-focused; + } + + /* Disabled state */ + &[data-disabled="true"] { + @apply cursor-default bg-default; + } + } + + /* Disabled state */ + &:disabled, + &[data-disabled="true"], + &[aria-disabled="true"] { + @apply status-disabled; + + [data-slot="label"] { + @apply opacity-100; + } + } + + /* Horizontal orientation */ + &[data-orientation="horizontal"] { + flex-direction: column; + + .hv-color-slider__track { + @apply h-5 justify-self-center rounded-none; + width: calc(100% - 1.25rem); + + /* Default border for visibility against similar backgrounds */ + box-shadow: + inset 0 1px 0 0 rgba(0, 0, 0, 0.1), + inset 0 -1px 0 0 rgba(0, 0, 0, 0.1); + + /* Edge caps for horizontal orientation */ + &::before, + &::after { + @apply top-0 h-full; + width: 0.625rem; /* Half thumb width + 2px gap */ + } + + &::before { + @apply rounded-ss-2xl rounded-es-2xl; + inset-inline-start: -0.625rem; + box-shadow: + inset 1px 0 0 0 rgba(0, 0, 0, 0.1), + inset 0 1px 0 0 rgba(0, 0, 0, 0.1), + inset 0 -1px 0 0 rgba(0, 0, 0, 0.1); + background: + linear-gradient( + var(--track-start-color, transparent), + var(--track-start-color, transparent) + ), + repeating-conic-gradient(#efefef 0% 25%, #f7f7f7 0% 50%) 50% / 16px + 16px; + } + + &::after { + @apply rounded-se-2xl rounded-ee-2xl; + inset-inline-end: -0.625rem; + box-shadow: + inset -1px 0 0 0 rgba(0, 0, 0, 0.1), + inset 0 1px 0 0 rgba(0, 0, 0, 0.1), + inset 0 -1px 0 0 rgba(0, 0, 0, 0.1); + background: + linear-gradient( + var(--track-end-color, transparent), + var(--track-end-color, transparent) + ), + repeating-conic-gradient(#efefef 0% 25%, #f7f7f7 0% 50%) 50% / 16px + 16px; + } + } + + .hv-color-slider__thumb { + @apply top-1/2 size-4; + } + } + + /* Vertical orientation */ + &[data-orientation="vertical"] { + @apply h-full gap-2; + + flex-direction: row; + grid-template-areas: + "output" + "track" + "label"; + grid-template-rows: auto 1fr auto; + grid-template-columns: 1fr; + align-items: center; + justify-items: center; + + /* When neither label nor output exist in vertical, just show track */ + &:not(:has([data-slot="label"])):not(:has(.hv-color-slider__output)) { + grid-template-areas: "track"; + grid-template-rows: 1fr; + gap: 0; + } + + /* When only label exists in vertical (no output) */ + &:has([data-slot="label"]):not(:has(.hv-color-slider__output)) { + grid-template-areas: + "track" + "label"; + grid-template-rows: 1fr auto; + } + + /* When only output exists in vertical (no label) */ + &:not(:has([data-slot="label"])):has(.hv-color-slider__output) { + grid-template-areas: + "output" + "track"; + grid-template-rows: auto 1fr; + } + + .hv-color-slider__output { + text-align: center; + } + + [data-slot="label"] { + text-align: center; + } + + .hv-color-slider__track { + @apply w-5 justify-self-center rounded-none; + height: calc(100% - 1.25rem); + + /* Left and right borders for vertical track */ + box-shadow: + inset 1px 0 0 0 rgba(0, 0, 0, 0.1), + inset -1px 0 0 0 rgba(0, 0, 0, 0.1); + + /* Edge caps for vertical orientation */ + &::before, + &::after { + @apply start-0 w-full; + height: 0.625rem; /* Half thumb height + 2px gap */ + } + + &::before { + bottom: -0.625rem; + border-end-start-radius: 999px; + border-end-end-radius: 999px; + /* Left, right, and bottom borders for bottom cap */ + box-shadow: + inset 1px 0 0 0 rgba(0, 0, 0, 0.1), + inset -1px 0 0 0 rgba(0, 0, 0, 0.1), + inset 0 -1px 0 0 rgba(0, 0, 0, 0.1); + background: + linear-gradient( + var(--track-start-color, transparent), + var(--track-start-color, transparent) + ), + repeating-conic-gradient(#efefef 0% 25%, #f7f7f7 0% 50%) 50% / 16px + 16px; + } + + &::after { + top: -0.625rem; + border-start-start-radius: 999px; + border-start-end-radius: 999px; + /* Left, right, and top borders for top cap */ + box-shadow: + inset 1px 0 0 0 rgba(0, 0, 0, 0.1), + inset -1px 0 0 0 rgba(0, 0, 0, 0.1), + inset 0 1px 0 0 rgba(0, 0, 0, 0.1); + background: + linear-gradient( + var(--track-end-color, transparent), + var(--track-end-color, transparent) + ), + repeating-conic-gradient(#efefef 0% 25%, #f7f7f7 0% 50%) 50% / 16px + 16px; + } + } + + .hv-color-slider__thumb { + /* Cross-axis centering; React Aria applies a physical translateX(-50%), so keep left-1/2 for RTL correctness */ + @apply left-1/2 size-4; + } + } +} diff --git a/packages/styles/components/popover.css b/packages/styles/components/popover.css index 8e4a5f2..3ec199d 100644 --- a/packages/styles/components/popover.css +++ b/packages/styles/components/popover.css @@ -7,6 +7,8 @@ @apply origin-(--reka-popper-transform-origin) bg-overlay p-0 text-sm; border-radius: min(32px, var(--radius-3xl)); box-shadow: var(--overlay-shadow); + /* React Aria supplies this constraint inline; Reka exposes the available size. */ + max-height: var(--reka-popover-content-available-height); /* Entering animations */ &[data-entering="true"] { @@ -51,6 +53,10 @@ /* Popover dialog */ .hv-popover__dialog { @apply p-4 outline-none; + /* Keep arrows outside the surface visible; scroll the dialog's content instead. */ + max-height: inherit; + overflow-y: auto; + overscroll-behavior: contain; } /* Popover heading */ diff --git a/packages/styles/index.css b/packages/styles/index.css index 372a5b7..57ce2b5 100644 --- a/packages/styles/index.css +++ b/packages/styles/index.css @@ -163,3 +163,5 @@ /* Private color interaction foundation; public components are not exported yet. */ @import "./components/color-area.css" layer(components); + +@import "./components/color-slider.css" layer(components); diff --git a/packages/vue/src/components/color/native-channel.ts b/packages/vue/src/components/color/native-channel.ts index f38059a..ea9a3c6 100644 --- a/packages/vue/src/components/color/native-channel.ts +++ b/packages/vue/src/components/color/native-channel.ts @@ -1,4 +1,10 @@ -import { nextTick, onBeforeUnmount, watch, type ShallowRef } from "vue"; +import { + computed, + nextTick, + onBeforeUnmount, + watch, + type ShallowRef, +} from "vue"; import { useChoiceForm } from "../choice/shared"; import { useConfig } from "../../providers/context"; import { useColorChannel, type ColorChannelOptions } from "./channel"; @@ -9,6 +15,7 @@ export function useColorNativeChannel( state: ColorState, props: ColorChannelOptions & { dir?: "ltr" | "rtl"; + orientation?: "horizontal" | "vertical"; }, input: ShallowRef, ) { @@ -66,7 +73,11 @@ export function useColorNativeChannel( return; } const { minValue, maxValue, step, pageSize } = channel.range.value; - const sign = (props.dir ?? config?.dir.value) === "rtl" ? -1 : 1; + const sign = + (props.dir ?? config?.dir.value) === "rtl" && + props.orientation !== "vertical" + ? -1 + : 1; const delta = event.shiftKey ? pageSize : step; let next = channel.value.value; switch (event.key) { @@ -113,6 +124,7 @@ export function useColorNativeChannel( () => props.channel, () => props.colorSpace, () => props.dir, + () => props.orientation, () => config?.dir.value, input, ], @@ -143,5 +155,11 @@ export function useColorNativeChannel( keyup, commit: () => stop(true), cancel: () => stop(), + // Private custom-track bridge; keyboard, native AT and pointer share one token. + transaction: { + begin, + propose, + active: computed(() => state.active.value === token), + }, }; } diff --git a/packages/vue/src/components/color/slider-gradient.ts b/packages/vue/src/components/color/slider-gradient.ts new file mode 100644 index 0000000..9de83cd --- /dev/null +++ b/packages/vue/src/components/color/slider-gradient.ts @@ -0,0 +1,55 @@ +import { colorChannel } from "./channel"; +import { Color, type ColorChannel, type ColorSpace } from "./value"; +export function colorSliderDisplay( + color: Color, + channel: ColorChannel, + space?: ColorSpace, +) { + const native = colorChannel(color, channel, space).color; + return channel === "hue" + ? new Color({ + space: "hsl", + h: native.getChannelValue("hue"), + s: 100, + l: 50, + alpha: 1, + }) + : channel === "alpha" + ? native + : native.withAlpha(1); +} +/** Exact piecewise sRGB ramps; HSL lightness needs its chromatic midpoint. */ +export function colorSliderBackground( + color: Color, + channel: ColorChannel, + space?: ColorSpace, + orientation: "horizontal" | "vertical" = "horizontal", + dir: "ltr" | "rtl" = "ltr", +) { + const d = colorChannel( + colorSliderDisplay(color, channel, space), + channel, + space, + ), + max = d.range.maxValue; + const values = + channel === "hue" + ? [0, 60, 120, 180, 240, 300, 360] + : channel === "lightness" + ? [0, 50, 100] + : [0, max]; + const css = (value: number) => + d.color.withChannelValue(channel, value).toString("css"); + const direction = + orientation === "vertical" + ? "to top" + : dir === "rtl" + ? "to left" + : "to right"; + const ramp = `linear-gradient(${direction}, ${values.map((value) => `${css(value)} ${(value / max) * 100}%`).join(", ")})`; + return { + background: `${ramp}, repeating-conic-gradient(#efefef 0% 25%, #f7f7f7 0% 50%) 50% / 16px 16px`, + "--track-start-color": css(0), + "--track-end-color": css(max), + }; +} diff --git a/packages/vue/src/components/color/slider.ts b/packages/vue/src/components/color/slider.ts new file mode 100644 index 0000000..5e14b7d --- /dev/null +++ b/packages/vue/src/components/color/slider.ts @@ -0,0 +1,190 @@ +import { + computed, + onBeforeUnmount, + shallowRef, + watch, + type ShallowRef, +} from "vue"; +import { useConfig } from "../../providers/context"; +import { useColorNativeChannel } from "./native-channel"; +import type { ColorChannelOptions } from "./channel"; +import type { ColorState } from "./model"; + +export interface ColorSliderOptions extends ColorChannelOptions { + dir?: "ltr" | "rtl"; + orientation?: "horizontal" | "vertical"; +} +/** One native input plus a stable custom track; all edits share the native channel token. */ +export function useColorSlider( + state: ColorState, + props: ColorSliderOptions, + elements: { + track: ShallowRef; + thumb: ShallowRef; + input: ShallowRef; + }, +) { + const control = useColorNativeChannel(state, props, elements.input); + const config = useConfig(); + const dir = computed(() => props.dir ?? config?.dir.value ?? "ltr"); + const orientation = computed(() => props.orientation ?? "horizontal"); + const vertical = computed(() => orientation.value === "vertical"); + const percent = computed(() => { + const r = control.range.value; + return (control.value.value - r.minValue) / (r.maxValue - r.minValue); + }); + const position = computed(() => + vertical.value + ? { left: "50%", top: `${(1 - percent.value) * 100}%` } + : { + left: `${(dir.value === "rtl" ? 1 - percent.value : percent.value) * 100}%`, + top: "50%", + }, + ); + const dragging = shallowRef(false); + let pointer: number | undefined, + owner: HTMLElement | undefined, + grab = 0, + last: number | undefined; + function stop(commit = false) { + const id = pointer, + node = owner; + pointer = undefined; + owner = undefined; + dragging.value = false; + grab = 0; + last = undefined; + if (id !== undefined && node?.hasPointerCapture?.(id)) + node.releasePointerCapture(id); + if (commit) control.commit(); + else control.cancel(); + } + function local(event: PointerEvent) { + const node = elements.track.value; + if (!node) return; + const rect = node.getBoundingClientRect(), + css = getComputedStyle(node); + const length = vertical.value ? rect.height : rect.width; + const scale = + length / (vertical.value ? node.offsetHeight : node.offsetWidth) || 1; + const before = + (parseFloat(vertical.value ? css.borderTopWidth : css.borderLeftWidth) || + 0) * scale; + const after = + (parseFloat( + vertical.value ? css.borderBottomWidth : css.borderRightWidth, + ) || 0) * scale; + const size = length - before - after; + if (size <= 0) return; + let p = + ((vertical.value ? event.clientY - rect.top : event.clientX - rect.left) - + before) / + size; + if (vertical.value || dir.value === "rtl") p = 1 - p; + const range = control.range.value; + return range.minValue + p * (range.maxValue - range.minValue); + } + function update(raw: number) { + const { minValue, maxValue, step } = control.range.value; + const next = Math.min( + maxValue, + Math.max( + minValue, + Number( + ( + Math.round((raw - grab - minValue) / step) * step + + minValue + ).toFixed(12), + ), + ), + ); + if (next === last) return; + last = next; + control.transaction.propose(next); + } + function pointerdown(event: PointerEvent) { + if ( + event.defaultPrevented || + event.button !== 0 || + event.isPrimary === false || + pointer !== undefined || + state.disabled.value || + state.readOnly.value || + (event.pointerType === "mouse" && + (event.ctrlKey || event.metaKey || event.altKey)) + ) + return; + const point = local(event), + track = elements.track.value; + if (point === undefined || !track || !elements.input.value) return; + stop(); + if (!control.transaction.begin()) return; + pointer = event.pointerId; + owner = track; + dragging.value = true; + const hit = elements.thumb.value?.contains(event.target as Node); + grab = hit ? point - control.value.value : 0; + event.preventDefault(); + elements.input.value.focus({ preventScroll: true }); + owner.setPointerCapture?.(event.pointerId); + if (!hit) update(point); + } + function pointermove(event: PointerEvent) { + if (event.defaultPrevented || event.pointerId !== pointer) return; + const point = local(event); + if (point === undefined) return; + event.preventDefault(); + update(point); + } + function pointerup(event: PointerEvent) { + if (event.pointerId !== pointer) return; + if (!event.defaultPrevented) { + const point = local(event); + if (point !== undefined) update(point); + } + stop(!event.defaultPrevented); + } + function cancel(event?: PointerEvent) { + if (!event || event.pointerId === pointer) stop(); + } + watch( + [ + state.disabled, + state.readOnly, + dir, + orientation, + () => props.channel, + () => props.colorSpace, + elements.track, + elements.thumb, + elements.input, + ], + () => stop(), + { flush: "sync" }, + ); + watch( + control.transaction.active, + (active) => { + if (!active && pointer !== undefined) stop(); + }, + { flush: "sync" }, + ); + onBeforeUnmount(() => stop()); + return { + ...control, + dir, + orientation, + percent, + position, + dragging, + pointerdown, + pointermove, + pointerup, + cancel, + commit: () => stop(true), + keydown: (event: KeyboardEvent) => { + if (pointer !== undefined && event.key !== "Escape") return; + control.keydown(event); + }, + }; +} diff --git a/packages/vue/src/components/color/submission.ts b/packages/vue/src/components/color/submission.ts new file mode 100644 index 0000000..5f50989 --- /dev/null +++ b/packages/vue/src/components/color/submission.ts @@ -0,0 +1,28 @@ +import type { Color } from "./value"; +/** Full JS numeric precision, expanded so the strict functional parser can round-trip exponents. */ +function decimal(value: number) { + const text = String(value), + parts = text.split("e"); + if (parts.length === 1) return text; + const coefficient = parts[0]!, + exponent = Number(parts[1]); + const dot = coefficient.indexOf("."); + const digits = coefficient.replace(".", ""); + const point = (dot === -1 ? digits.length : dot) + exponent; + if (point <= 0) return `0.${"0".repeat(-point)}${digits}`; + if (point >= digits.length) return digits + "0".repeat(point - digits.length); + return `${digits.slice(0, point)}.${digits.slice(point)}`; +} +/** Private owner serialization proof, separate from display CSS and final public field formats. */ +export function serializeColorValue(color: Color | null) { + if (!color) return ""; + const space = color.getColorSpace(); + const channels = color + .getChannels() + .map( + (channel, index) => + decimal(color.getChannelValue(channel)) + + (space !== "rgb" && index > 0 ? "%" : ""), + ); + return `${space}a(${channels.join(", ")}, ${decimal(color.getChannelValue("alpha"))})`; +} diff --git a/packages/vue/src/components/color/text.ts b/packages/vue/src/components/color/text.ts index f09d73c..99cd291 100644 --- a/packages/vue/src/components/color/text.ts +++ b/packages/vue/src/components/color/text.ts @@ -171,8 +171,10 @@ export function useColorText( return; } if (event.key === "Escape") { - event.preventDefault(); - cancel(); + if (draft.value !== formatted.value) { + event.preventDefault(); + cancel(); + } return; } const direction = diff --git a/packages/vue/tests/fixtures/ColorPickerBoundary.ts b/packages/vue/tests/fixtures/ColorPickerBoundary.ts new file mode 100644 index 0000000..3487803 --- /dev/null +++ b/packages/vue/tests/fixtures/ColorPickerBoundary.ts @@ -0,0 +1,19 @@ +import { defineComponent, watch } from "vue"; +import { usePopover } from "../../src/components/popover/context"; +import { useColorStateContext } from "../../src/components/color/model"; +/** Observe accepted overlay state, never its potentially rejected close proposal. */ +export default defineComponent({ + name: "ColorPickerBoundary", + setup(_, { slots }) { + const overlay = usePopover(), + color = useColorStateContext()!; + watch( + overlay.state.isOpen, + (open) => { + if (!open) color.cancel(); + }, + { flush: "sync" }, + ); + return () => slots.default?.(); + }, +}); diff --git a/packages/vue/tests/fixtures/ColorPickerComposition.vue b/packages/vue/tests/fixtures/ColorPickerComposition.vue new file mode 100644 index 0000000..9588e32 --- /dev/null +++ b/packages/vue/tests/fixtures/ColorPickerComposition.vue @@ -0,0 +1,123 @@ + + + + + + + + + 选择颜色 + + + + + + + + + + + + + + + {{ serialized }} + + + diff --git a/packages/vue/tests/fixtures/ColorSliderFoundation.vue b/packages/vue/tests/fixtures/ColorSliderFoundation.vue new file mode 100644 index 0000000..f2d2220 --- /dev/null +++ b/packages/vue/tests/fixtures/ColorSliderFoundation.vue @@ -0,0 +1,134 @@ + + + + {{ label }} + + + + + + + diff --git a/tests/color-picker-composition.test.ts b/tests/color-picker-composition.test.ts new file mode 100644 index 0000000..fd857e2 --- /dev/null +++ b/tests/color-picker-composition.test.ts @@ -0,0 +1,255 @@ +import { afterEach, beforeEach, describe, it, expect, vi } from "vitest"; +import { mount, flushPromises } from "@vue/test-utils"; +import { defineComponent, shallowRef, createSSRApp } from "vue"; +import { renderToString } from "@vue/server-renderer"; +import Picker from "../packages/vue/tests/fixtures/ColorPickerComposition.vue"; +import { parseColor, Color } from "../packages/vue/src/components/color/value"; +import { serializeColorValue } from "../packages/vue/src/components/color/submission"; +const wrappers: ReturnType[] = []; +beforeEach(() => + vi.stubGlobal( + "ResizeObserver", + class { + observe() {} + unobserve() {} + disconnect() {} + }, + ), +); +afterEach(async () => { + wrappers.splice(0).forEach((w) => w.unmount()); + await flushPromises(); + document.body.innerHTML = ""; + vi.unstubAllGlobals(); + vi.restoreAllMocks(); +}); +function view(attrs = "", setup = () => ({})) { + const w = mount( + defineComponent({ + components: { Picker }, + setup, + template: ``, + }), + { attachTo: document.body }, + ); + wrappers.push(w); + return w; +} +const native = (w: ReturnType) => + w.get("input[type=hidden]"); +const values = (w: ReturnType) => + new FormData(w.get("form").element as HTMLFormElement).getAll("color"); +async function open(w: ReturnType) { + await w.get("button").trigger("click"); + await flushPromises(); + expect(document.querySelector("[role=dialog]")).not.toBeNull(); +} +async function key(input: HTMLInputElement, key: string) { + input.dispatchEvent( + new KeyboardEvent("keydown", { key, bubbles: true, cancelable: true }), + ); + input.dispatchEvent( + new KeyboardEvent("keyup", { key, bubbles: true, cancelable: true }), + ); + await flushPromises(); +} +describe("private color owner and Popover composition", () => { + it("restores a dirty text draft on Escape, then lets Escape close the popup", async () => { + const w = view(); + await open(w); + const text = document.querySelector( + '[aria-label="Color hex text"]', + )!; + text.focus(); + text.value = "#abc"; + text.dispatchEvent(new Event("input", { bubbles: true })); + await flushPromises(); + await key(text, "Escape"); + expect(document.querySelector("[role=dialog]")).not.toBeNull(); + expect(text.value).toBe("#808080"); + expect(w.getComponent(Picker).emitted("change")).toBeUndefined(); + await key(text, "Escape"); + expect(document.querySelector("[role=dialog]")).toBeNull(); + expect(document.activeElement).toBe(w.get("button").element); + }); + + it("serializes all spaces without numeric precision loss or an 8-bit alpha round trip", () => { + for (const c of [ + parseColor("hsba(270,0%,50%,.123456789012345)"), + parseColor( + "hsla(21.123456789,67.987654321%,45.333333333%,.23456789012345)", + ), + new Color({ + space: "rgb", + r: 0.00000001, + g: 2.3456789012345, + b: 255, + alpha: 5e-324, + }), + ]) + expect(parseColor(serializeColorValue(c)).equals(c)).toBe(true); + expect(serializeColorValue(null)).toBe(""); + }); + it("has one named submission while closed and with every popup child mounted", async () => { + const w = view(); + expect(values(w)).toEqual(["hsba(270, 0%, 50%, 0.123456789)"]); + await open(w); + expect(document.querySelectorAll("input[name=color]")).toHaveLength(1); + expect(document.querySelectorAll("[role=dialog]")).toHaveLength(1); + expect(native(w).element.value).toBe("hsba(270, 0%, 50%, 0.123456789)"); + }); + it("updates hue and alpha through Teleport while preserving gray hue and one owner", async () => { + const w = view(); + await open(w); + const sliders = document.querySelectorAll( + "[data-color-slider-input]", + ); + await key(sliders[0]!, "ArrowUp"); + const text = document.querySelector( + '[aria-label="Color alpha text"]', + )!; + text.value = "25"; + text.dispatchEvent(new Event("input", { bubbles: true })); + await key(text, "Enter"); + const c = parseColor(String(values(w)[0])); + expect(c.getChannelValue("hue")).toBe(271); + expect(c.getChannelValue("alpha")).toBe(0.25); + expect(sliders[1]!.value).toBe("0.25"); + expect(w.getComponent(Picker).emitted("change")).toHaveLength(2); + expect(w.getComponent(Picker).emitted("changeEnd")).toHaveLength(2); + }); + it("restores accepted color after rejection and retries an identical edit after reopening", async () => { + const w = view('model-value="hsba(270,0%,50%,.123456789)"'); + for (let i = 0; i < 2; i++) { + await open(w); + const slider = document.querySelector( + "[data-color-slider-input]", + )!; + await key(slider, "ArrowUp"); + expect(slider.value).toBe("270"); + window.dispatchEvent( + new KeyboardEvent("keydown", { + key: "Escape", + bubbles: true, + cancelable: true, + }), + ); + await flushPromises(); + } + expect(w.getComponent(Picker).emitted("change")).toHaveLength(2); + expect(values(w)).toEqual(["hsba(270, 0%, 50%, 0.123456789)"]); + }); + it("cancels an unfinished accepted close immediately and restores trigger focus", async () => { + const w = view(); + await open(w); + const slider = document.querySelector( + "[data-color-slider-input]", + )!; + slider.focus(); + slider.dispatchEvent( + new KeyboardEvent("keydown", { + key: "ArrowUp", + bubbles: true, + cancelable: true, + }), + ); + window.dispatchEvent( + new KeyboardEvent("keydown", { + key: "Escape", + bubbles: true, + cancelable: true, + }), + ); + await flushPromises(); + expect(document.querySelector("[role=dialog]")).toBeNull(); + expect(w.getComponent(Picker).emitted("changeEnd")).toBeUndefined(); + expect(document.activeElement).toBe(w.get("button").element); + }); + it("does not cancel the input transaction when controlled overlay close is rejected", async () => { + const w = view(':open="true"'); + await flushPromises(); + const slider = document.querySelector( + "[data-color-slider-input]", + )!; + slider.dispatchEvent( + new KeyboardEvent("keydown", { + key: "ArrowUp", + bubbles: true, + cancelable: true, + }), + ); + window.dispatchEvent( + new KeyboardEvent("keydown", { + key: "Escape", + bubbles: true, + cancelable: true, + }), + ); + await flushPromises(); + expect(document.querySelector("[role=dialog]")).not.toBeNull(); + slider.dispatchEvent( + new KeyboardEvent("keyup", { + key: "ArrowUp", + bubbles: true, + cancelable: true, + }), + ); + await flushPromises(); + expect(w.getComponent(Picker).emitted("changeEnd")).toHaveLength(1); + }); + it("resets one owner while the popup is open and retains controlled accepted values", async () => { + const w = view(); + await open(w); + const slider = document.querySelector( + "[data-color-slider-input]", + )!; + await key(slider, "ArrowUp"); + (w.get("form").element as HTMLFormElement).reset(); + await flushPromises(); + expect(slider.value).toBe("270"); + expect(values(w)).toEqual(["hsba(270, 0%, 50%, 0.123456789)"]); + expect(w.getComponent(Picker).emitted("change")).toHaveLength(1); + }); + it("inherits disabled/readOnly and permits later accepted programmatic values", async () => { + const off = shallowRef(false), + value = shallowRef(parseColor("hsba(270,0%,50%,.123456789)")); + const w = view( + ':model-value="value" :is-disabled="off" is-read-only', + () => ({ off, value }), + ); + await open(w); + const slider = document.querySelector( + "[data-color-slider-input]", + )!; + await key(slider, "ArrowUp"); + expect(w.getComponent(Picker).emitted("change")).toBeUndefined(); + value.value = parseColor("hsba(90,50%,50%,.125)"); + await flushPromises(); + expect(slider.value).toBe("90"); + off.value = true; + await flushPromises(); + expect(values(w)).toEqual([]); + expect(w.get("button").element.disabled).toBe(true); + }); + it("hydrates closed owners with one stable submission and no popup duplication", async () => { + const App = defineComponent({ + components: { Picker }, + template: '', + }); + const container = document.createElement("div"); + container.innerHTML = await renderToString(createSSRApp(App)); + document.body.append(container); + const nodes = [...container.querySelectorAll("input")]; + const warn = vi.spyOn(console, "warn").mockImplementation(() => {}), + error = vi.spyOn(console, "error").mockImplementation(() => {}); + const app = createSSRApp(App); + app.mount(container); + await flushPromises(); + expect([...container.querySelectorAll("input")]).toEqual(nodes); + const ids = [...container.querySelectorAll("[id]")].map((n) => n.id); + expect(new Set(ids).size).toBe(ids.length); + expect(warn).not.toHaveBeenCalled(); + expect(error).not.toHaveBeenCalled(); + app.unmount(); + }); +}); diff --git a/tests/color-slider-foundation-ssr.test.ts b/tests/color-slider-foundation-ssr.test.ts new file mode 100644 index 0000000..088e5bb --- /dev/null +++ b/tests/color-slider-foundation-ssr.test.ts @@ -0,0 +1,40 @@ +// @vitest-environment node +import { describe, it, expect } from "vitest"; +import { createSSRApp, defineComponent } from "vue"; +import { renderToString } from "@vue/server-renderer"; +import Slider from "../packages/vue/tests/fixtures/ColorSliderFoundation.vue"; +import Picker from "../packages/vue/tests/fixtures/ColorPickerComposition.vue"; +describe("private custom color track and picker actual Node SSR", () => { + it("renders direction, gradient, native value and accepted thumb consistently without layout globals", async () => { + const html = await renderToString( + createSSRApp( + defineComponent({ + components: { Slider }, + template: + '', + }), + ), + ); + expect(html).toContain('value="0.12345"'); + expect(html).toContain("top:87.655%"); + expect(html).toContain('aria-orientation="vertical"'); + expect(html).toContain("linear-gradient(to top"); + expect(html.match(/name="alpha"/g)).toHaveLength(1); + expect(html).not.toContain("NaN"); + }); + it("renders a single exact owner submission while closed, without popup controls", async () => { + const html = await renderToString( + createSSRApp( + defineComponent({ + components: { Picker }, + template: + '', + }), + ), + ); + expect(html).toContain('value="hsba(270, 0%, 50%, 0.123456789012345)"'); + expect(html.match(/name="color"/g)).toHaveLength(1); + expect(html).toContain('aria-expanded="false"'); + expect(html).not.toContain("data-color-slider-track"); + }); +}); diff --git a/tests/color-slider-foundation.test.ts b/tests/color-slider-foundation.test.ts new file mode 100644 index 0000000..dad777f --- /dev/null +++ b/tests/color-slider-foundation.test.ts @@ -0,0 +1,348 @@ +import { afterEach, describe, it, expect, vi } from "vitest"; +import { mount, flushPromises } from "@vue/test-utils"; +import { defineComponent, shallowRef } from "vue"; +import Slider from "../packages/vue/tests/fixtures/ColorSliderFoundation.vue"; +import Picker from "../packages/vue/tests/fixtures/ColorPickerFoundation.vue"; +import { + parseColor, + type Color, +} from "../packages/vue/src/components/color/value"; +import { + colorSliderBackground, + colorSliderDisplay, +} from "../packages/vue/src/components/color/slider-gradient"; +const wrappers: ReturnType[] = []; +afterEach(() => { + wrappers.splice(0).forEach((w) => w.unmount()); + document.body.innerHTML = ""; + vi.restoreAllMocks(); +}); +function fixture(attrs = "", setup = () => ({})) { + const w = mount( + defineComponent({ + components: { Slider, Picker }, + setup, + template: ``, + }), + { attachTo: document.body }, + ); + wrappers.push(w); + return w; +} +const input = (w: ReturnType) => + w.get("[data-color-slider-input]"); +const changes = (w: ReturnType) => + (w.getComponent(Slider).emitted("change") ?? []).map(([v]) => v as Color); +const ends = (w: ReturnType) => + w.getComponent(Slider).emitted("changeEnd") ?? []; +function geometry( + w: ReturnType, + vertical = false, + scale = 1, + border = 0, +) { + const track = w.get("[data-color-slider-track]").element; + const width = vertical ? 20 : 220, + height = vertical ? 220 : 20; + track.style.border = `${border}px solid transparent`; + Object.defineProperties(track, { + offsetWidth: { get: () => width, configurable: true }, + offsetHeight: { get: () => height, configurable: true }, + }); + vi.spyOn(track, "getBoundingClientRect").mockReturnValue({ + left: 10, + top: 20, + width: width * scale, + height: height * scale, + right: 10 + width * scale, + bottom: 20 + height * scale, + x: 10, + y: 20, + toJSON: () => ({}), + }); + let capture: number | undefined; + track.setPointerCapture = vi.fn((id) => { + capture = id; + }); + track.hasPointerCapture = vi.fn((id) => capture === id); + track.releasePointerCapture = vi.fn(() => { + capture = undefined; + }); + return track; +} +async function pointer(node: Element, type: string, extra = {}) { + const e = new Event(type, { bubbles: true, cancelable: true }); + Object.assign(e, { + pointerId: 1, + pointerType: "mouse", + button: 0, + isPrimary: true, + clientX: 120, + clientY: 30, + ...extra, + }); + node.dispatchEvent(e); + await flushPromises(); + return e; +} +describe("color slider custom track", () => { + it("uses content coordinates through borders and ancestor scaling and commits once", async () => { + const w = fixture(), + track = geometry(w, false, 2, 10); + await pointer(track, "pointerdown", { clientX: 330, clientY: 40 }); + expect(changes(w).at(-1)?.getChannelValue("hue")).toBe(270); + await pointer(track, "pointerup", { clientX: 330, clientY: 40 }); + expect(changes(w)).toHaveLength(1); + expect(ends(w)).toHaveLength(1); + expect(track.releasePointerCapture).toHaveBeenCalledWith(1); + expect(changes(w)[0]?.getChannelValue("alpha")).toBe(0.12345); + }); + it("retains grab offset, clamps outside and consumes final pointerup coordinate", async () => { + const w = fixture(), + track = geometry(w); + const thumb = w.get("[data-color-slider-thumb]").element; + const start = 10 + 220 * (240 / 360) + 3; + await pointer(thumb, "pointerdown", { clientX: start }); + expect(changes(w)).toHaveLength(0); + await pointer(track, "pointermove", { clientX: start + 22 }); + expect(changes(w).at(-1)?.getChannelValue("hue")).toBe(276); + await pointer(track, "pointerup", { clientX: 1000 }); + expect(changes(w).at(-1)?.getChannelValue("hue")).toBe(360); + expect(ends(w)).toHaveLength(1); + }); + it("maps RTL and vertical independently", async () => { + const rtl = fixture('dir="rtl"'), + rt = geometry(rtl); + await pointer(rt, "pointerdown", { clientX: 65 }); + await pointer(rt, "pointerup", { clientX: 65 }); + expect(changes(rtl)[0]?.getChannelValue("hue")).toBe(270); + const vertical = fixture('orientation="vertical" dir="rtl"'), + vt = geometry(vertical, true); + await pointer(vt, "pointerdown", { clientX: 20, clientY: 75 }); + await pointer(vt, "pointerup", { clientX: 20, clientY: 75 }); + expect(changes(vertical)[0]?.getChannelValue("hue")).toBe(270); + expect(input(vertical).attributes("aria-orientation")).toBe("vertical"); + expect( + vertical.get("[data-color-slider-thumb]").attributes("style"), + ).toContain("top: 25%"); + }); + it("keeps accepted geometry on rejection, de-duplicates points, and retries next gesture", async () => { + const w = fixture('model-value="hsb(240,50%,50%,.12345)"'), + track = geometry(w); + for (let i = 0; i < 2; i++) { + await pointer(track, "pointerdown", { clientX: 65 }); + await pointer(track, "pointermove", { clientX: 65 }); + await pointer(track, "pointerup", { clientX: 65 }); + } + expect(changes(w)).toHaveLength(2); + expect(ends(w)).toHaveLength(2); + expect((ends(w)[0]?.[0] as Color).getChannelValue("hue")).toBe(90); + expect(input(w).element.value).toBe("240"); + expect(w.get("[data-color-slider-thumb]").attributes("style")).toContain( + "66.666", + ); + }); + it("shares pointer and keyboard lifecycle without double end and preserves accepted gray hue", async () => { + const w = fixture('model-value="hsb(270,0%,50%,.125)"'), + track = geometry(w); + await pointer(track, "pointerdown", { clientX: 65 }); + await input(w).trigger("keydown", { key: "ArrowRight" }); + expect(changes(w)).toHaveLength(1); + await input(w).trigger("keydown", { key: "Escape" }); + await pointer(track, "pointerup", { clientX: 100 }); + expect(ends(w)).toHaveLength(0); + expect(track.releasePointerCapture).toHaveBeenCalledWith(1); + await input(w).trigger("keydown", { key: "ArrowRight" }); + await input(w).trigger("keyup", { key: "ArrowRight" }); + expect(changes(w).at(-1)?.getChannelValue("hue")).toBe(271); + expect(ends(w)).toHaveLength(1); + }); + it.each(["pointercancel", "lostpointercapture"])( + "cancels %s and ignores unrelated pointers", + async (type) => { + const w = fixture(), + track = geometry(w); + await pointer(track, "pointerdown", { clientX: 65 }); + await pointer(track, "pointermove", { clientX: 180, pointerId: 2 }); + await pointer(track, type, { pointerId: 2 }); + expect(track.hasPointerCapture(1)).toBe(true); + await pointer(track, type); + await pointer(track, "pointerup"); + expect(ends(w)).toHaveLength(0); + expect(track.hasPointerCapture(1)).toBe(false); + }, + ); + it("ignores canceled down/move and canceled completion does not emit end", async () => { + const w = fixture(), + track = geometry(w); + track.addEventListener("pointerdown", (e) => e.preventDefault(), { + capture: true, + once: true, + }); + await pointer(track, "pointerdown"); + expect(changes(w)).toHaveLength(0); + await pointer(track, "pointerdown", { clientX: 65 }); + track.addEventListener("pointermove", (e) => e.preventDefault(), { + capture: true, + once: true, + }); + await pointer(track, "pointermove", { clientX: 180 }); + expect(changes(w)).toHaveLength(1); + track.addEventListener("pointerup", (e) => e.preventDefault(), { + capture: true, + once: true, + }); + await pointer(track, "pointerup"); + expect(ends(w)).toHaveLength(0); + }); + it("cleans original capture on disable, mode changes, blur and unmount", async () => { + const off = shallowRef(false), + orientation = shallowRef<"horizontal" | "vertical">("horizontal"); + const w = fixture(':is-disabled="off" :orientation="orientation"', () => ({ + off, + orientation, + })), + track = geometry(w); + await pointer(track, "pointerdown"); + off.value = true; + await flushPromises(); + expect(track.hasPointerCapture(1)).toBe(false); + off.value = false; + await flushPromises(); + await pointer(track, "pointerdown"); + orientation.value = "vertical"; + await flushPromises(); + expect(track.hasPointerCapture(1)).toBe(false); + orientation.value = "horizontal"; + await flushPromises(); + await pointer(track, "pointerdown"); + window.dispatchEvent(new Event("blur")); + await flushPromises(); + expect(track.hasPointerCapture(1)).toBe(false); + await pointer(track, "pointerdown"); + const slider = w.getComponent(Slider); + w.unmount(); + expect(track.hasPointerCapture(1)).toBe(false); + expect(slider.emitted("changeEnd")).toBeUndefined(); + }); + it("aborts drag on unrelated parent replacement but accepts synchronous echoes", async () => { + const value = shallowRef(parseColor("hsb(240,50%,50%)")); + const w = fixture(':model-value="value"', () => ({ value })), + track = geometry(w); + await pointer(track, "pointerdown", { clientX: 65 }); + value.value = parseColor("hsb(180,50%,50%)"); + await flushPromises(); + expect(track.hasPointerCapture(1)).toBe(false); + await pointer(track, "pointerup"); + expect(ends(w)).toHaveLength(0); + const e = fixture('v-model="value"', () => ({ + value: shallowRef(parseColor("hsb(240,50%,50%)")), + })), + et = geometry(e); + await pointer(et, "pointerdown", { clientX: 65 }); + await pointer(et, "pointermove", { clientX: 120 }); + await pointer(et, "pointerup", { clientX: 175 }); + expect(ends(e)).toHaveLength(1); + expect(changes(e).at(-1)?.getChannelValue("hue")).toBe(270); + }); + it("rejects non-primary, modified/right-button and zero-size tracks", async () => { + const w = fixture(), + track = geometry(w); + for (const attrs of [ + { isPrimary: false }, + { button: 2 }, + { ctrlKey: true }, + { altKey: true }, + { metaKey: true }, + ]) + await pointer(track, "pointerdown", attrs); + expect(changes(w)).toHaveLength(0); + vi.spyOn(track, "getBoundingClientRect").mockReturnValue(new DOMRect()); + await pointer(track, "pointerdown"); + expect(changes(w)).toHaveLength(0); + }); + it("submits one native accepted channel value and resets it without synthetic changes", async () => { + const w = fixture('name="hue"'), + track = geometry(w); + await pointer(track, "pointerdown", { clientX: 65 }); + await pointer(track, "pointerup", { clientX: 65 }); + const form = w.get("form").element as HTMLFormElement; + expect(new FormData(form).getAll("hue")).toEqual(["90"]); + form.reset(); + await flushPromises(); + expect(input(w).element.value).toBe("240"); + expect(changes(w)).toHaveLength(1); + expect(ends(w)).toHaveLength(1); + }); +}); +describe("color track replacement", () => { + it("keeps vertical left/right semantics independent of RTL", async () => { + const w = fixture('orientation="vertical" dir="rtl"'); + for (const [key, value] of [ + ["ArrowLeft", "239"], + ["ArrowRight", "240"], + ["ArrowUp", "241"], + ]) { + await input(w).trigger("keydown", { key }); + await input(w).trigger("keyup", { key }); + expect(input(w).element.value).toBe(value); + } + }); + it("releases the original node and does not keep an old gesture after replacement", async () => { + const trackKey = shallowRef("first"); + const w = fixture(':track-key="trackKey"', () => ({ trackKey })); + const old = geometry(w); + await pointer(old, "pointerdown", { clientX: 65 }); + trackKey.value = "second"; + await flushPromises(); + expect(old.hasPointerCapture(1)).toBe(false); + expect(w.get("[data-color-slider-track]").element).not.toBe(old); + await pointer(old, "pointerup", { clientX: 180 }); + expect(ends(w)).toHaveLength(0); + }); + it("blocks readonly pointer edits while accepted parent changes still render", async () => { + const value = shallowRef(parseColor("hsb(240,0%,50%)")); + const w = fixture('is-read-only :model-value="value"', () => ({ value })); + const track = geometry(w); + await pointer(track, "pointerdown", { clientX: 65 }); + await pointer(track, "pointerup", { clientX: 65 }); + expect(changes(w)).toHaveLength(0); + value.value = parseColor("hsb(90,0%,50%)"); + await flushPromises(); + expect(input(w).element.value).toBe("90"); + }); +}); +describe("channel display ramps", () => { + it("renders a full opaque hue spectrum even for an accepted transparent gray", () => { + const c = parseColor("hsb(270,0%,50%,.1)"); + expect(colorSliderDisplay(c, "hue").toString("css")).toBe( + "rgb(128, 0, 255)", + ); + const ramp = colorSliderBackground(c, "hue"); + expect(ramp.background).toContain("rgb(255, 0, 0) 0%"); + expect(ramp.background).toContain("rgb(0, 255, 0)"); + expect(ramp.background).not.toContain("rgba("); + expect(c.getChannelValue("alpha")).toBe(0.1); + }); + it("has the HSL midpoint and keeps alpha checkerboard with correctly directed caps", () => { + const c = parseColor("hsla(0,100%,50%,.25)"); + const light = colorSliderBackground(c, "lightness"); + expect(light.background).toContain("rgb(255, 0, 0) 50%"); + expect(light.background).toContain("rgb(255, 255, 255) 100%"); + const alpha = colorSliderBackground( + c, + "alpha", + undefined, + "horizontal", + "rtl", + ); + expect(alpha.background).toContain("to left"); + expect(alpha["--track-start-color"]).toBe("rgba(255, 0, 0, 0)"); + expect(alpha["--track-end-color"]).toBe("rgb(255, 0, 0)"); + expect(alpha.background).toContain("repeating-conic-gradient"); + expect( + colorSliderBackground(c, "alpha", undefined, "vertical", "rtl") + .background, + ).toContain("to top"); + }); +}); diff --git a/tests/package/README.md b/tests/package/README.md index 3e0cc74..92e2b06 100644 --- a/tests/package/README.md +++ b/tests/package/README.md @@ -31,3 +31,5 @@ DATE-03 新增 `consume-calendar.mjs` / `calendar-contract.ts`,安装两份新 DATE-04 提取共享 Calendar 视图并完成私有范围内核,公共 RangeCalendar 尚未导出。最终 tarball 在 `/private/tmp/heroui-range-core-consumer` 运行 Calendar/DateField/Select 的 ESM/SSR/CSS 与两种解析模式正反类型回归;私有范围的 node SSR / 实际水合在工作区测试,不能据此声明公共范围产物已验收。公开范围下一轮须新增自己的完整消费契约。 COLOR-01 增加 `consume-color-foundation.mjs`:只验证准备好的 Area CSS 和没有提前暴露公共占位。独立目录 `/private/tmp/heroui-color-foundation-consumer` 同时运行旧 Calendar/DateField/Select 的运行与双解析模式类型回归。新颜色实现目前私有,其正反类型在 `tests/types/color-foundation.ts` 执行;公开批次必须另加自己的完整 ESM/SSR/Props/events/slots 产物契约。 + +COLOR-04 增加 `consume-color-slider-foundation.mjs`,在 `/private/tmp/heroui-color-slider-consumer` 用最终两份 tarball 验证暂存 Slider CSS、端帽变量、公共 Popover 高度/滚动约束与无公共颜色占位导出,同时保留 Calendar/DateField/Select 的 ESM/SSR/CSS 和 strict NodeNext/bundler 正反类型回归。私有 Slider/Picker 的实际交互/SSR/水合在工作区验收,公开组件仍需另写完整产物契约。 diff --git a/tests/package/consume-color-slider-foundation.mjs b/tests/package/consume-color-slider-foundation.mjs new file mode 100644 index 0000000..4402154 --- /dev/null +++ b/tests/package/consume-color-slider-foundation.mjs @@ -0,0 +1,23 @@ +import assert from "node:assert/strict"; +import fs from "node:fs"; +import * as ui from "@heroui-vue/components"; +const css = fs.readFileSync( + new URL(import.meta.resolve("@heroui-vue/styles/css")), + "utf8", +); +for (const marker of [ + ".hv-color-slider", + ".hv-color-slider__track", + ".hv-color-slider__thumb", + "--track-start-color", + "--track-end-color", + "--reka-popover-content-available-height", + "max-height:inherit", + "overscroll-behavior:contain", +]) + assert.ok(css.includes(marker), marker); +for (const name of ["ColorSlider", "ColorField", "ColorPicker"]) + assert.equal(name in ui, false); +console.log( + "Color slider foundation CSS and Popover constraints present; private components stay private.", +); diff --git a/tests/types/color-foundation.ts b/tests/types/color-foundation.ts index 17f05d9..7ae39e1 100644 --- a/tests/types/color-foundation.ts +++ b/tests/types/color-foundation.ts @@ -41,3 +41,17 @@ void hueSlider; void missingChannel; void invalidChannel; void invalidSpace; + +import type { ColorSliderOptions } from "../../packages/vue/src/components/color/slider"; +const verticalSlider: ColorSliderOptions = { + channel: "alpha", + orientation: "vertical", + dir: "rtl", +}; +const invalidOrientation: ColorSliderOptions = { + channel: "hue", + // @ts-expect-error no third orientation + orientation: "diagonal", +}; +void verticalSlider; +void invalidOrientation;
+ 自定义轨道、原生焦点输入和共享接受值;正式公开部件与文档示例仍待收尾。 +