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:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user