dc859fb8ae
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.
407 lines
13 KiB
JavaScript
407 lines
13 KiB
JavaScript
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"),
|
|
);
|
|
const css = readFileSync(
|
|
new URL(import.meta.resolve("@heroui-vue/styles/css")),
|
|
"utf8",
|
|
);
|
|
for (const id of process.argv.slice(2)) {
|
|
const spec = checks[id];
|
|
assert(spec, `Unknown package contract: ${id}`);
|
|
for (const name of spec.exports) assert(lib[name], `Missing export ${name}`);
|
|
for (const token of spec.css)
|
|
assert(css.includes(token), `Missing CSS ${token}`);
|
|
for (const name of spec.absent ?? [])
|
|
assert(!(name in lib), `Private component exposed: ${name}`);
|
|
if (id === "handbook-styles") {
|
|
const extended = lib.tv({
|
|
extend: lib.buttonVariants,
|
|
variants: { intent: { quiet: "audit-quiet" } },
|
|
});
|
|
const classes = extended({ intent: "quiet", size: "sm" });
|
|
assert(
|
|
classes.includes("hv-button--sm") && classes.includes("audit-quiet"),
|
|
);
|
|
// This proves final CSS packaging; computed style and lifecycle assertions
|
|
// run separately in apps/playground/src/HandbookLab.vue.
|
|
for (const mode of ["none", "default", "thin"])
|
|
assert(new RegExp(`\\[data-scrollbar=["']?${mode}["']?\\]`).test(css));
|
|
}
|
|
if (id === "b02-pickers") {
|
|
assert(
|
|
lib
|
|
.comboBoxVariants({ fullWidth: true })
|
|
.base()
|
|
.includes("hv-combo-box--full-width"),
|
|
);
|
|
assert(
|
|
lib
|
|
.autocompleteVariants({ variant: "secondary" })
|
|
.base()
|
|
.includes("hv-autocomplete--secondary"),
|
|
);
|
|
}
|
|
if (id === "list-box") {
|
|
assert(lib.listboxVariants().includes("hv-list-box"));
|
|
assert(
|
|
lib
|
|
.listboxItemVariants()
|
|
.indicator()
|
|
.includes("hv-list-box-item__indicator"),
|
|
);
|
|
}
|
|
if (id === "range-calendar") {
|
|
assert(lib.RangeCalendar === lib.RangeCalendarRoot);
|
|
assert(lib.rangeCalendarVariants().cell() === "hv-range-calendar__cell");
|
|
}
|
|
if (id === "color-field") {
|
|
assert(lib.ColorField === lib.ColorFieldRoot);
|
|
assert(lib.ColorFieldGroup === lib.ColorInputGroup);
|
|
assert(lib.ColorFieldGroup === lib.ColorInputGroupRoot);
|
|
assert(lib.ColorFieldInput === lib.ColorInputGroupInput);
|
|
assert(lib.ColorFieldPrefix === lib.ColorInputGroupPrefix);
|
|
assert(lib.ColorFieldSuffix === lib.ColorInputGroupSuffix);
|
|
assert(
|
|
lib
|
|
.colorFieldVariants({ fullWidth: true })
|
|
.includes("hv-color-field--full-width"),
|
|
);
|
|
const slots = lib.colorInputGroupVariants({
|
|
variant: "secondary",
|
|
fullWidth: true,
|
|
});
|
|
assert(slots.base().includes("hv-color-input-group--secondary"));
|
|
assert(slots.base().includes("hv-color-input-group--full-width"));
|
|
assert(slots.input() === "hv-color-input-group__input");
|
|
}
|
|
if (id === "time-field") {
|
|
assert(lib.TimeField === lib.TimeFieldRoot);
|
|
assert(lib.TimeFieldGroup === lib.DateInputGroup);
|
|
assert(lib.TimeFieldInput === lib.DateInputGroupInput);
|
|
assert(
|
|
lib
|
|
.timeFieldVariants({ fullWidth: true })
|
|
.includes("hv-time-field--full-width"),
|
|
);
|
|
}
|
|
if (id === "date-range-picker") {
|
|
assert(lib.DateRangePicker === lib.DateRangePickerRoot);
|
|
assert(lib.dateRangePickerVariants().base() === "hv-date-range-picker");
|
|
assert(
|
|
lib.dateRangePickerVariants().trigger() ===
|
|
"hv-date-range-picker__trigger",
|
|
);
|
|
assert(
|
|
lib.dateRangePickerVariants().rangeSeparator() ===
|
|
"hv-date-range-picker__range-separator",
|
|
);
|
|
assert(
|
|
lib.dateRangePickerVariants().popover() ===
|
|
"hv-date-range-picker__popover",
|
|
);
|
|
assert(
|
|
lib.dateRangePickerVariants().triggerIndicator() ===
|
|
"hv-date-range-picker__trigger-indicator",
|
|
);
|
|
assert(lib.DateFieldInput);
|
|
}
|
|
if (id === "date-picker") {
|
|
assert(lib.DatePicker === lib.DatePickerRoot);
|
|
assert(lib.datePickerVariants().base() === "hv-date-picker");
|
|
assert(lib.datePickerVariants().trigger() === "hv-date-picker__trigger");
|
|
assert(lib.datePickerVariants().popover() === "hv-date-picker__popover");
|
|
}
|
|
if (id === "slider")
|
|
assert(lib.sliderVariants().thumb().includes("hv-slider__thumb"));
|
|
if (id === "select")
|
|
assert(
|
|
lib
|
|
.selectVariants({ variant: "secondary" })
|
|
.base()
|
|
.includes("hv-select--secondary"),
|
|
);
|
|
if (id === "color-area") {
|
|
assert(lib.ColorArea === lib.ColorAreaRoot);
|
|
assert(lib.ColorAreaThumb);
|
|
assert(
|
|
lib
|
|
.colorAreaVariants({ showDots: true })
|
|
.base()
|
|
.includes("hv-color-area--show-dots"),
|
|
);
|
|
assert(
|
|
lib.colorAreaVariants().thumb() === "hv-color-area__thumb",
|
|
"ColorArea thumb class must stay in the baseline namespace",
|
|
);
|
|
const areaDts = readFileSync(
|
|
new URL(
|
|
"./node_modules/@heroui-vue/components/dist/components/color-area/ColorArea.vue.d.ts",
|
|
import.meta.url,
|
|
),
|
|
"utf8",
|
|
);
|
|
const thumbDts = readFileSync(
|
|
new URL(
|
|
"./node_modules/@heroui-vue/components/dist/components/color-area/ColorAreaThumb.vue.d.ts",
|
|
import.meta.url,
|
|
),
|
|
"utf8",
|
|
);
|
|
assert(
|
|
!areaDts.includes("reka-ui"),
|
|
"ColorArea declarations leak Reka types",
|
|
);
|
|
assert(
|
|
!thumbDts.includes("reka-ui"),
|
|
"ColorAreaThumb declarations leak Reka types",
|
|
);
|
|
}
|
|
if (id === "color-swatch") {
|
|
assert(lib.ColorSwatch === lib.ColorSwatchRoot);
|
|
assert(
|
|
lib
|
|
.colorSwatchVariants({ shape: "square", size: "xl" })
|
|
.includes("hv-color-swatch--square"),
|
|
);
|
|
assert(
|
|
lib
|
|
.colorSwatchVariants({ shape: "square", size: "xl" })
|
|
.includes("hv-color-swatch--xl"),
|
|
);
|
|
assert(lib.parseColor("#f008").toString("hexa") === "#FF000088");
|
|
assert(
|
|
lib.parseColor("rgba(4, 133, 247, 0.5)").getChannelValue("alpha") === 0.5,
|
|
);
|
|
const valueDts = readFileSync(
|
|
new URL(
|
|
"./node_modules/@heroui-vue/components/dist/components/color/value.d.ts",
|
|
import.meta.url,
|
|
),
|
|
"utf8",
|
|
);
|
|
const swatchDts = readFileSync(
|
|
new URL(
|
|
"./node_modules/@heroui-vue/components/dist/components/color-swatch/ColorSwatch.vue.d.ts",
|
|
import.meta.url,
|
|
),
|
|
"utf8",
|
|
);
|
|
assert(!valueDts.includes("reka-ui"), "Color declarations leak Reka types");
|
|
assert(
|
|
!swatchDts.includes("reka-ui"),
|
|
"ColorSwatch declarations leak Reka types",
|
|
);
|
|
}
|
|
if (id === "color-swatch-picker") {
|
|
assert(lib.ColorSwatchPicker === lib.ColorSwatchPickerRoot);
|
|
assert(lib.ColorSwatchPickerItem);
|
|
assert(lib.ColorSwatchPickerSwatch);
|
|
assert(lib.ColorSwatchPickerIndicator);
|
|
assert(
|
|
lib.colorSwatchPickerVariants().base().includes("hv-color-swatch-picker"),
|
|
);
|
|
assert(
|
|
lib
|
|
.colorSwatchPickerVariants({ layout: "stack", variant: "square" })
|
|
.base()
|
|
.includes("hv-color-swatch-picker--stack"),
|
|
);
|
|
assert(
|
|
lib.colorSwatchPickerVariants({ size: "xs" }).item() ===
|
|
"hv-color-swatch-picker__item",
|
|
);
|
|
assert(
|
|
lib.colorSwatchPickerVariants().swatch() ===
|
|
"hv-color-swatch-picker__swatch",
|
|
);
|
|
assert(
|
|
lib.colorSwatchPickerVariants().indicator() ===
|
|
"hv-color-swatch-picker__indicator",
|
|
);
|
|
const pickerDts = readFileSync(
|
|
new URL(
|
|
"./node_modules/@heroui-vue/components/dist/components/color-swatch-picker/ColorSwatchPicker.vue.d.ts",
|
|
import.meta.url,
|
|
),
|
|
"utf8",
|
|
);
|
|
const itemDts = readFileSync(
|
|
new URL(
|
|
"./node_modules/@heroui-vue/components/dist/components/color-swatch-picker/ColorSwatchPickerItem.vue.d.ts",
|
|
import.meta.url,
|
|
),
|
|
"utf8",
|
|
);
|
|
assert(
|
|
!pickerDts.includes("reka-ui"),
|
|
"ColorSwatchPicker declarations leak Reka types",
|
|
);
|
|
assert(
|
|
!itemDts.includes("reka-ui"),
|
|
"ColorSwatchPickerItem declarations leak Reka types",
|
|
);
|
|
}
|
|
if (id === "color-picker") {
|
|
assert(lib.ColorPicker === lib.ColorPickerRoot);
|
|
assert(lib.ColorPickerTrigger);
|
|
assert(lib.ColorPickerPopover);
|
|
assert(
|
|
lib.colorPickerVariants().base() === "hv-color-picker",
|
|
"ColorPicker base class must stay in the baseline namespace",
|
|
);
|
|
assert(
|
|
lib.colorPickerVariants().trigger() === "hv-color-picker__trigger",
|
|
"ColorPicker trigger class must stay in the baseline namespace",
|
|
);
|
|
assert(
|
|
lib.colorPickerVariants().popover() === "hv-color-picker__popover",
|
|
"ColorPicker popover class must stay in the baseline namespace",
|
|
);
|
|
const pickerDts = readFileSync(
|
|
new URL(
|
|
"./node_modules/@heroui-vue/components/dist/components/color-picker/ColorPicker.vue.d.ts",
|
|
import.meta.url,
|
|
),
|
|
"utf8",
|
|
);
|
|
const triggerDts = readFileSync(
|
|
new URL(
|
|
"./node_modules/@heroui-vue/components/dist/components/color-picker/ColorPickerTrigger.vue.d.ts",
|
|
import.meta.url,
|
|
),
|
|
"utf8",
|
|
);
|
|
const popoverDts = readFileSync(
|
|
new URL(
|
|
"./node_modules/@heroui-vue/components/dist/components/color-picker/ColorPickerPopover.vue.d.ts",
|
|
import.meta.url,
|
|
),
|
|
"utf8",
|
|
);
|
|
assert(
|
|
!pickerDts.includes("reka-ui"),
|
|
"ColorPicker declarations leak Reka types",
|
|
);
|
|
assert(
|
|
!triggerDts.includes("reka-ui"),
|
|
"ColorPickerTrigger declarations leak Reka types",
|
|
);
|
|
assert(
|
|
!popoverDts.includes("reka-ui"),
|
|
"ColorPickerPopover declarations leak Reka types",
|
|
);
|
|
}
|
|
if (id === "color-slider") {
|
|
assert(lib.ColorSlider === lib.ColorSliderRoot);
|
|
assert(lib.ColorSliderOutput);
|
|
assert(lib.ColorSliderTrack);
|
|
assert(lib.ColorSliderThumb);
|
|
assert(
|
|
lib.colorSliderVariants().base() === "hv-color-slider",
|
|
"ColorSlider base class must stay in the baseline namespace",
|
|
);
|
|
assert(
|
|
lib.colorSliderVariants().track() === "hv-color-slider__track",
|
|
"ColorSlider track class must stay in the baseline namespace",
|
|
);
|
|
const sliderDts = readFileSync(
|
|
new URL(
|
|
"./node_modules/@heroui-vue/components/dist/components/color-slider/ColorSlider.vue.d.ts",
|
|
import.meta.url,
|
|
),
|
|
"utf8",
|
|
);
|
|
const thumbDts = readFileSync(
|
|
new URL(
|
|
"./node_modules/@heroui-vue/components/dist/components/color-slider/ColorSliderThumb.vue.d.ts",
|
|
import.meta.url,
|
|
),
|
|
"utf8",
|
|
);
|
|
assert(
|
|
!sliderDts.includes("reka-ui"),
|
|
"ColorSlider declarations leak Reka types",
|
|
);
|
|
assert(
|
|
!thumbDts.includes("reka-ui"),
|
|
"ColorSliderThumb declarations leak Reka types",
|
|
);
|
|
}
|
|
if (id === "b03-tag-error-message") {
|
|
assert(/\.hv-tag-group\s*\[data-slot=["']?error-message/.test(css));
|
|
assert(lib.tagVariants({ size: "sm" }).base().includes("hv-tag--sm"));
|
|
assert(
|
|
lib
|
|
.tagVariants({ variant: "surface" })
|
|
.base()
|
|
.includes("hv-tag--surface"),
|
|
);
|
|
assert(lib.errorMessageVariants().includes("hv-error-message"));
|
|
}
|
|
if (id === "api-root-aliases") {
|
|
assert(
|
|
spec.aliases.length === 82,
|
|
"Root alias inventory must cover all 82 upstream root pairs",
|
|
);
|
|
for (const [plain, root] of spec.aliases) {
|
|
assert(
|
|
lib[plain] === lib[root],
|
|
`${root} must be the same component object as ${plain}`,
|
|
);
|
|
}
|
|
}
|
|
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)`);
|
|
}
|