questions, cleaning, fix _sanitizeRgba undefined
This commit is contained in:
parent
8554c7b78c
commit
9c3179b4b7
2 changed files with 7 additions and 11 deletions
|
@ -14,8 +14,7 @@ import type {
|
||||||
IValidCompoundProps,
|
IValidCompoundProps,
|
||||||
ShorthandCompoundPropsToLonghandCompoundProps,
|
ShorthandCompoundPropsToLonghandCompoundProps,
|
||||||
} from './internals'
|
} from './internals'
|
||||||
import {sanitizeCompoundProps} from './internals'
|
import {propTypeSymbol, sanitizeCompoundProps} from './internals'
|
||||||
import {propTypeSymbol} from './internals'
|
|
||||||
// eslint-disable-next-line unused-imports/no-unused-imports
|
// eslint-disable-next-line unused-imports/no-unused-imports
|
||||||
import type SheetObject from '@theatre/core/sheetObjects/SheetObject'
|
import type SheetObject from '@theatre/core/sheetObjects/SheetObject'
|
||||||
|
|
||||||
|
@ -91,9 +90,7 @@ const validateCommonOpts = (fnCallSignature: string, opts?: CommonOpts) => {
|
||||||
*/
|
*/
|
||||||
export const compound = <Props extends IShorthandCompoundProps>(
|
export const compound = <Props extends IShorthandCompoundProps>(
|
||||||
props: Props,
|
props: Props,
|
||||||
opts: {
|
opts: CommonOpts = {},
|
||||||
label?: string
|
|
||||||
} = {},
|
|
||||||
): PropTypeConfig_Compound<
|
): PropTypeConfig_Compound<
|
||||||
ShorthandCompoundPropsToLonghandCompoundProps<Props>
|
ShorthandCompoundPropsToLonghandCompoundProps<Props>
|
||||||
> => {
|
> => {
|
||||||
|
@ -287,9 +284,7 @@ const _interpolateNumber = (
|
||||||
|
|
||||||
export const rgba = (
|
export const rgba = (
|
||||||
defaultValue: Rgba = {r: 0, g: 0, b: 0, a: 1},
|
defaultValue: Rgba = {r: 0, g: 0, b: 0, a: 1},
|
||||||
opts: {
|
opts: CommonOpts = {},
|
||||||
label?: string
|
|
||||||
} = {},
|
|
||||||
): PropTypeConfig_Rgba => {
|
): PropTypeConfig_Rgba => {
|
||||||
if (process.env.NODE_ENV !== 'production') {
|
if (process.env.NODE_ENV !== 'production') {
|
||||||
validateCommonOpts('t.rgba(defaultValue, opts)', opts)
|
validateCommonOpts('t.rgba(defaultValue, opts)', opts)
|
||||||
|
@ -337,6 +332,7 @@ export const rgba = (
|
||||||
}
|
}
|
||||||
|
|
||||||
const _sanitizeRgba = (val: unknown): Rgba | undefined => {
|
const _sanitizeRgba = (val: unknown): Rgba | undefined => {
|
||||||
|
if (!val) return undefined
|
||||||
let valid = true
|
let valid = true
|
||||||
for (const c of ['r', 'g', 'b', 'a']) {
|
for (const c of ['r', 'g', 'b', 'a']) {
|
||||||
if (
|
if (
|
||||||
|
@ -555,8 +551,6 @@ export function stringLiteral<
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export type Sanitizer<T> = (value: unknown) => T | undefined
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A linear interpolator for a certain value type.
|
* A linear interpolator for a certain value type.
|
||||||
*
|
*
|
||||||
|
@ -669,7 +663,7 @@ const defaultNumberNudgeFn: NumberNudgeFn = ({
|
||||||
export interface PropTypeConfig_Boolean
|
export interface PropTypeConfig_Boolean
|
||||||
extends ISimplePropType<'boolean', boolean> {}
|
extends ISimplePropType<'boolean', boolean> {}
|
||||||
|
|
||||||
interface CommonOpts {
|
type CommonOpts = {
|
||||||
/**
|
/**
|
||||||
* Each prop type may be given a custom label instead of the name of the sub-prop
|
* Each prop type may be given a custom label instead of the name of the sub-prop
|
||||||
* it is in.
|
* it is in.
|
||||||
|
|
|
@ -17,6 +17,8 @@ export type IValidCompoundProps = {
|
||||||
[K in string]: PropTypeConfig
|
[K in string]: PropTypeConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Question: Why doesn't this include Rgba? Should it include Marker?
|
||||||
|
// - Is this just for compound props?
|
||||||
type IShorthandProp =
|
type IShorthandProp =
|
||||||
| string
|
| string
|
||||||
| number
|
| number
|
||||||
|
|
Loading…
Reference in a new issue