feat(styles): export shared field variant maps and restore the border fallback

HD-05 scope, against heroui ce90ea3 styles sources:

- add labelVariants/descriptionVariants/fieldErrorVariants/
  textFieldVariants/switchGroupVariants (+ VariantProps types) to
  @heroui-vue/styles and re-export them from @heroui-vue/components;
  variant keys, defaultVariants and slot sets match the pinned
  *.styles.ts files key for key (hv- namespace only)
- Label/Description/FieldError/useTextField/SwitchGroup now consume
  those mappings instead of inline class strings, so the state classes
  have a single source; rendered class output is unchanged and pinned
  by tests/shared-field-styles.test.ts (mapping output <-> component
  output)
- restore the global border-color fallback
  (*, ::after, ::before, ::backdrop, ::file-selector-button ->
  border-color: var(--border, currentColor)) in a new base/base.css,
  imported layer(base) right after preflight like the pinned entry:
  a low-priority default that components, utilities and consumer CSS
  override without !important
- view-transition globals from the pinned base.css stay unported: no
  View Transitions API usage exists in the library or docs site
- shared-styles package contract: packed runtime exports from both
  entries, variant-output assertions, CSS tokens incl. the fallback,
  strict nodenext+bundler type contract, and a real-browser consumer
  fixture (light/dark --border, explicit colors, consumer overrides,
  currentColor fallback) wired into check-package.mjs
- docs: styling layers/border fallback/exports notes, five component
  API pages, compatibility matrix and upstream source records

Full suite 111 files / 1634 tests, typecheck and build:docs pass;
shared-styles + api-root-aliases + handbook-styles verified against
the final tarballs.
This commit is contained in:
maoyingjie
2026-10-28 23:36:59 +08:00
parent 35b602e5b9
commit dc859fb8ae
26 changed files with 538 additions and 36 deletions
+55 -13
View File
@@ -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)`);
}