fix: enforce ColorSlider union props and clean part refs
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { h } from "vue";
|
||||
import {
|
||||
ColorSlider,
|
||||
ColorSliderOutput,
|
||||
@@ -140,6 +141,30 @@ const exposed: ColorSliderExpose = {
|
||||
focus: () => {},
|
||||
};
|
||||
const typedColor: Color = color;
|
||||
type ColorSliderInstanceProps = InstanceType<typeof ColorSlider>["$props"];
|
||||
const instanceProps: ColorSliderInstanceProps = {
|
||||
channel: "hue",
|
||||
colorSpace: "hsb",
|
||||
};
|
||||
// @ts-expect-error the component's own props reject red + hsl
|
||||
const badInstanceRed: ColorSliderInstanceProps = {
|
||||
channel: "red",
|
||||
colorSpace: "hsl",
|
||||
};
|
||||
// @ts-expect-error the component's own props reject hue + rgb
|
||||
const badInstanceHue: ColorSliderInstanceProps = {
|
||||
channel: "hue",
|
||||
colorSpace: "rgb",
|
||||
};
|
||||
const sliderNode = h(ColorSlider, {
|
||||
channel: "hue",
|
||||
colorSpace: "hsb",
|
||||
defaultValue: "hsb(240, 50%, 50%)",
|
||||
});
|
||||
// @ts-expect-error h() rejects red + hsl on the real component
|
||||
h(ColorSlider, { channel: "red", colorSpace: "hsl" });
|
||||
// @ts-expect-error h() rejects hue + rgb on the real component
|
||||
h(ColorSlider, { channel: "hue", colorSpace: "rgb" });
|
||||
|
||||
// @ts-expect-error red requires the rgb color space
|
||||
const badRed: ColorSliderProps = { channel: "red", colorSpace: "hsl" };
|
||||
@@ -219,6 +244,10 @@ void [
|
||||
variants,
|
||||
exposed,
|
||||
typedColor,
|
||||
instanceProps,
|
||||
badInstanceRed,
|
||||
badInstanceHue,
|
||||
sliderNode,
|
||||
badRed,
|
||||
badHue,
|
||||
badBrightness,
|
||||
|
||||
Reference in New Issue
Block a user