@clds/common-definitions
Advanced tools
Comparing version 0.56.0-beta.1 to 0.56.0-beta.2
import { FocusEvent, MouseEventHandler, ReactNode, SyntheticEvent } from 'react'; | ||
export declare type FieldValidationState = 'error' | 'warning' | 'success' | 'none'; | ||
export type FieldValidationState = 'error' | 'warning' | 'success' | 'none'; | ||
/** Interface for props of all form field components (requires implementation of mixed field control). */ | ||
@@ -4,0 +4,0 @@ export interface CommonFieldProps<ValueType, EventType extends SyntheticEvent> { |
import { InputHTMLAttributes } from 'react'; | ||
export declare type InputProps = InputHTMLAttributes<HTMLInputElement> & { | ||
export type InputProps = InputHTMLAttributes<HTMLInputElement> & { | ||
'data-test-specifier'?: string; | ||
}; |
@@ -1,7 +0,7 @@ | ||
export declare type JSONified<T> = T extends string | number | boolean | null ? T : T extends Function ? never : T extends Array<infer U> ? JSONifiedArray<U> : T extends object ? JSONifiedObject<T> : never; | ||
declare type UndefinedAsNull<T> = T extends undefined ? null : T; | ||
declare type JSONifiedArray<T> = Array<UndefinedAsNull<JSONified<T>>>; | ||
declare type JSONifiedObject<T> = { | ||
export type JSONified<T> = T extends string | number | boolean | null ? T : T extends Function ? never : T extends Array<infer U> ? JSONifiedArray<U> : T extends object ? JSONifiedObject<T> : never; | ||
type UndefinedAsNull<T> = T extends undefined ? null : T; | ||
type JSONifiedArray<T> = Array<UndefinedAsNull<JSONified<T>>>; | ||
type JSONifiedObject<T> = { | ||
[P in keyof T]: JSONified<T[P]>; | ||
}; | ||
export {}; |
@@ -1,2 +0,2 @@ | ||
declare type DefaultValueName<Name extends string> = `default${Capitalize<Name>}`; | ||
type DefaultValueName<Name extends string> = `default${Capitalize<Name>}`; | ||
interface ExceptionalCallbackNames { | ||
@@ -8,21 +8,21 @@ selected: 'onSelect'; | ||
} | ||
declare type AllowedFieldNames = keyof ExceptionalCallbackNames | string; | ||
declare type RegularCallbackName<Name extends string> = `on${Capitalize<Name>}Change`; | ||
declare type CallbackName<Name extends string> = Name extends keyof ExceptionalCallbackNames ? ExceptionalCallbackNames[Name] : RegularCallbackName<Name>; | ||
declare type NormalSetterName<Name extends string> = Name; | ||
declare type BooleanSetterName<Name extends string> = `is${Capitalize<Name>}`; | ||
declare type SetterName<Name extends string, Value> = Value extends boolean ? BooleanSetterName<Name> : NormalSetterName<Name>; | ||
declare type ObjectWithKey<Key extends string, Value> = { | ||
type AllowedFieldNames = keyof ExceptionalCallbackNames | string; | ||
type RegularCallbackName<Name extends string> = `on${Capitalize<Name>}Change`; | ||
type CallbackName<Name extends string> = Name extends keyof ExceptionalCallbackNames ? ExceptionalCallbackNames[Name] : RegularCallbackName<Name>; | ||
type NormalSetterName<Name extends string> = Name; | ||
type BooleanSetterName<Name extends string> = `is${Capitalize<Name>}`; | ||
type SetterName<Name extends string, Value> = Value extends boolean ? BooleanSetterName<Name> : NormalSetterName<Name>; | ||
type ObjectWithKey<Key extends string, Value> = { | ||
[key in Key]: Value; | ||
}; | ||
declare type ObjectWithOptionalKey<Key extends string, Value> = { | ||
type ObjectWithOptionalKey<Key extends string, Value> = { | ||
[key in Key]?: Value; | ||
}; | ||
declare type ObjectWithoutKey<Key extends string> = { | ||
type ObjectWithoutKey<Key extends string> = { | ||
[key in Key]?: never; | ||
}; | ||
declare type ExplicitUncontrolledModeProps<Name extends string, Value> = ObjectWithoutKey<SetterName<Name, Value>> & ObjectWithoutKey<CallbackName<Name>> & ObjectWithKey<DefaultValueName<Name>, Value>; | ||
declare type ImplicitUncontrolledModeProps<Name extends string, Value> = ObjectWithoutKey<SetterName<Name, Value>> & ObjectWithoutKey<CallbackName<Name>> & ObjectWithOptionalKey<DefaultValueName<Name>, Value>; | ||
declare type ImplicitTraceableUncontrolledModeProps<Name extends string, Value> = ObjectWithoutKey<SetterName<Name, Value>> & ObjectWithOptionalKey<CallbackName<Name>, (value: Value) => void> & ObjectWithOptionalKey<DefaultValueName<Name>, Value>; | ||
declare type ControlledModeProps<Name extends string, Value> = ObjectWithKey<SetterName<Name, Value>, Value> & ObjectWithOptionalKey<CallbackName<Name>, (value: Value) => void> & ObjectWithoutKey<DefaultValueName<Name>>; | ||
type ExplicitUncontrolledModeProps<Name extends string, Value> = ObjectWithoutKey<SetterName<Name, Value>> & ObjectWithoutKey<CallbackName<Name>> & ObjectWithKey<DefaultValueName<Name>, Value>; | ||
type ImplicitUncontrolledModeProps<Name extends string, Value> = ObjectWithoutKey<SetterName<Name, Value>> & ObjectWithoutKey<CallbackName<Name>> & ObjectWithOptionalKey<DefaultValueName<Name>, Value>; | ||
type ImplicitTraceableUncontrolledModeProps<Name extends string, Value> = ObjectWithoutKey<SetterName<Name, Value>> & ObjectWithOptionalKey<CallbackName<Name>, (value: Value) => void> & ObjectWithOptionalKey<DefaultValueName<Name>, Value>; | ||
type ControlledModeProps<Name extends string, Value> = ObjectWithKey<SetterName<Name, Value>, Value> & ObjectWithOptionalKey<CallbackName<Name>, (value: Value) => void> & ObjectWithoutKey<DefaultValueName<Name>>; | ||
/** | ||
@@ -56,3 +56,3 @@ * Type that describes props that either controls the value by providing setter and callback (ie. color, onColorChange) | ||
*/ | ||
export declare type ExplicitMixedControlProps<Name extends AllowedFieldNames, Value> = ExplicitUncontrolledModeProps<Name, Value> | ControlledModeProps<Name, Value>; | ||
export type ExplicitMixedControlProps<Name extends AllowedFieldNames, Value> = ExplicitUncontrolledModeProps<Name, Value> | ControlledModeProps<Name, Value>; | ||
/** | ||
@@ -69,3 +69,3 @@ * Since MixedControlProps requires either value or defaultValue to be passed | ||
*/ | ||
export declare type ImplicitMixedControlProps<Name extends AllowedFieldNames, Value> = ImplicitUncontrolledModeProps<Name, Value> | ControlledModeProps<Name, Value>; | ||
export type ImplicitMixedControlProps<Name extends AllowedFieldNames, Value> = ImplicitUncontrolledModeProps<Name, Value> | ControlledModeProps<Name, Value>; | ||
/** | ||
@@ -77,3 +77,3 @@ * In rare cases we also allow that the component has uncontrolled mode but we want to allow to listen for the change. | ||
*/ | ||
export declare type ImplicitTraceableMixedControlProps<Name extends AllowedFieldNames, Value> = ImplicitTraceableUncontrolledModeProps<Name, Value> | ControlledModeProps<Name, Value>; | ||
export type ImplicitTraceableMixedControlProps<Name extends AllowedFieldNames, Value> = ImplicitTraceableUncontrolledModeProps<Name, Value> | ControlledModeProps<Name, Value>; | ||
export {}; |
import { Assign } from 'utility-types'; | ||
export declare type Undefinable<T> = T | undefined; | ||
export type Undefinable<T> = T | undefined; | ||
/** | ||
@@ -17,3 +17,3 @@ * Allows to make certain field an union with specific type. | ||
*/ | ||
export declare type UnionBy<T, V, K extends keyof T> = { | ||
export type UnionBy<T, V, K extends keyof T> = { | ||
[k in keyof T]: k extends K ? T[k] | V : T[k]; | ||
@@ -24,3 +24,3 @@ }; | ||
*/ | ||
export declare type ReplaceBy<T, V, K extends keyof T> = { | ||
export type ReplaceBy<T, V, K extends keyof T> = { | ||
[k in keyof T]: k extends K ? V : T[k]; | ||
@@ -41,3 +41,3 @@ }; | ||
*/ | ||
export declare type MapDependentField<T, DependentPropertyName extends keyof T, DependentPropertyValue extends T[DependentPropertyName], MappedPropertyName extends keyof T, MappedPropertyValue> = T extends { | ||
export type MapDependentField<T, DependentPropertyName extends keyof T, DependentPropertyValue extends T[DependentPropertyName], MappedPropertyName extends keyof T, MappedPropertyValue> = T extends { | ||
[P in DependentPropertyName]: DependentPropertyValue; | ||
@@ -49,9 +49,8 @@ } & { | ||
}> : T; | ||
export declare const isFieldOfObject: <T>(object: T, field: string | number | symbol) => field is keyof T; | ||
export declare type MapValuesToType<U, T> = { | ||
export type MapValuesToType<U, T> = { | ||
[k in keyof U]: T; | ||
}; | ||
export declare type DeepMap<Keys extends Array<string>, Value> = Keys extends [ | ||
export type DeepMap<Keys extends Array<string>, Value> = Keys extends [ | ||
infer Key, | ||
...infer OtherKeys | ||
] ? Record<Key extends string ? Key : never, DeepMap<OtherKeys extends Array<string> ? OtherKeys : never, Value>> : Value; |
@@ -1,2 +0,2 @@ | ||
export const isFieldOfObject = (object, field) => field in object; | ||
export {}; | ||
//# sourceMappingURL=utilityTypes.js.map |
{ | ||
"name": "@clds/common-definitions", | ||
"description": "Common Design System TypeScript definitions", | ||
"version": "0.56.0-beta.1", | ||
"version": "0.56.0-beta.2", | ||
"author": "Cloudinary", | ||
@@ -6,0 +6,0 @@ "main": "./dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
57319
192