Files
heroui-vue/tests/package/shared-styles-consumer-app/main.js
T
maoyingjie dc859fb8ae 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.
2026-10-28 23:36:59 +08:00

86 lines
2.1 KiB
JavaScript

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");