@suid/types
Advanced tools
Comparing version 0.3.0 to 0.4.0
@@ -16,4 +16,4 @@ import { OverridableTypeMap } from "."; | ||
} | ||
export declare type InferPropsType<T> = T extends (props: infer PropsType) => any ? PropsType : T extends keyof JSX.IntrinsicElements ? JSX.IntrinsicElements[T] : never; | ||
export declare type PropsOf<T> = T extends OverridableTypeMap ? DefaultComponentProps<T> & { | ||
export type InferPropsType<T> = T extends (props: infer PropsType) => any ? PropsType : T extends keyof JSX.IntrinsicElements ? JSX.IntrinsicElements[T] : never; | ||
export type PropsOf<T> = T extends OverridableTypeMap ? DefaultComponentProps<T> & { | ||
component?: ElementType; | ||
@@ -23,5 +23,5 @@ } : T extends SuidComponentType ? DefaultComponentProps<T> : T extends OverridableComponent<infer C2> ? DefaultComponentProps<C2> & { | ||
} : T extends ElementType ? _ComponentProps<T> : unknown; | ||
export declare type InPropsOf<T> = T extends OverridableTypeMap | SuidComponentType ? OverridableInProps<T> : T extends OverridableComponent<infer C1> ? OverridableInProps<C1> : T extends ElementType ? _ComponentProps<T> : unknown; | ||
export declare type DefaultPropsOf<T> = T extends OverridableTypeMap | SuidComponentType ? OverridableDefaultProps<T> : T extends OverridableComponent<infer C1> ? OverridableDefaultProps<C1> : T extends ElementType ? _ComponentProps<T> : unknown; | ||
export declare type OverridableDefaultProps<T> = DoRequired<Partial<DefaultComponentProps<T> & (T extends OverridableTypeMap ? { | ||
export type InPropsOf<T> = T extends OverridableTypeMap | SuidComponentType ? OverridableInProps<T> : T extends OverridableComponent<infer C1> ? OverridableInProps<C1> : T extends ElementType ? _ComponentProps<T> : unknown; | ||
export type DefaultPropsOf<T> = T extends OverridableTypeMap | SuidComponentType ? OverridableDefaultProps<T> : T extends OverridableComponent<infer C1> ? OverridableDefaultProps<C1> : T extends ElementType ? _ComponentProps<T> : unknown; | ||
export type OverridableDefaultProps<T> = DoRequired<Partial<DefaultComponentProps<T> & (T extends OverridableTypeMap ? { | ||
component: ElementType; | ||
@@ -31,3 +31,3 @@ } : {})>, T extends { | ||
} ? T["defaultPropNames"] : never>; | ||
export declare type OverridableInProps<T> = DoRequired<DefaultComponentProps<T> & (T extends OverridableTypeMap ? { | ||
export type OverridableInProps<T> = DoRequired<DefaultComponentProps<T> & (T extends OverridableTypeMap ? { | ||
component: ElementType; | ||
@@ -34,0 +34,0 @@ } : {}), T extends { |
import { JSX } from "solid-js"; | ||
export declare type EventParam<T = HTMLElement, E extends Event = Event> = E & { | ||
export type EventParam<T = HTMLElement, E extends Event = Event> = E & { | ||
currentTarget: T; | ||
target: Element; | ||
}; | ||
declare type EH<T, E extends Event> = JSX.EventHandler<T, E>; | ||
export declare type ChangeEvent<T = Element> = EventParam<T, Event> & { | ||
type EH<T, E extends Event> = JSX.EventHandler<T, E>; | ||
export type ChangeEvent<T = Element> = EventParam<T, Event> & { | ||
target: EventTarget & T; | ||
}; | ||
export declare type AnimationEventHandler<T = Element> = EH<T, AnimationEvent>; | ||
export declare type ChangeEventHandler<T = Element, V = string> = (event: ChangeEvent<T>, value: V) => void; | ||
export declare type ClipboardEventHandler<T = Element> = EH<T, ClipboardEvent>; | ||
export declare type CompositionEventHandler<T = Element> = EH<T, CompositionEvent>; | ||
export declare type DragEventHandler<T = Element> = EH<T, DragEvent>; | ||
export declare type FocusEventHandler<T = Element> = EH<T, FocusEvent>; | ||
export declare type InputEventHandler<T = Element> = EH<T, InputEvent>; | ||
export declare type KeyboardEventHandler<T = Element> = EH<T, KeyboardEvent>; | ||
export declare type MouseEventHandler<T = Element> = EH<T, MouseEvent>; | ||
export declare type PointerEventHandler<T = Element> = EH<T, PointerEvent>; | ||
export declare type TouchEventHandler<T = Element> = EH<T, TouchEvent>; | ||
export declare type TransitionEventHandler<T = Element> = EH<T, TransitionEvent>; | ||
export declare type UIEventHandler<T = Element> = EH<T, UIEvent>; | ||
export declare type WheelEventHandler<T = Element> = EH<T, WheelEvent>; | ||
export type AnimationEventHandler<T = Element> = EH<T, AnimationEvent>; | ||
export type ChangeEventHandler<T = Element, V = string> = (event: ChangeEvent<T>, value: V) => void; | ||
export type ClipboardEventHandler<T = Element> = EH<T, ClipboardEvent>; | ||
export type CompositionEventHandler<T = Element> = EH<T, CompositionEvent>; | ||
export type DragEventHandler<T = Element> = EH<T, DragEvent>; | ||
export type FocusEventHandler<T = Element> = EH<T, FocusEvent>; | ||
export type InputEventHandler<T = Element> = EH<T, InputEvent>; | ||
export type KeyboardEventHandler<T = Element> = EH<T, KeyboardEvent>; | ||
export type MouseEventHandler<T = Element> = EH<T, MouseEvent>; | ||
export type PointerEventHandler<T = Element> = EH<T, PointerEvent>; | ||
export type TouchEventHandler<T = Element> = EH<T, TouchEvent>; | ||
export type TransitionEventHandler<T = Element> = EH<T, TransitionEvent>; | ||
export type UIEventHandler<T = Element> = EH<T, UIEvent>; | ||
export type WheelEventHandler<T = Element> = EH<T, WheelEvent>; | ||
export {}; | ||
//# sourceMappingURL=events.d.ts.map |
export {}; | ||
export declare type CamelCaseType<T extends string> = T extends `${infer S1}-${infer S2}${infer S3}` ? `${Lowercase<S1>}${Uppercase<S2>}${CamelCaseType<S3>}` : Lowercase<T>; | ||
export declare type CamelCaseRecordType<T> = { | ||
export type CamelCaseType<T extends string> = T extends `${infer S1}-${infer S2}${infer S3}` ? `${Lowercase<S1>}${Uppercase<S2>}${CamelCaseType<S3>}` : Lowercase<T>; | ||
export type CamelCaseRecordType<T> = { | ||
[K in keyof T as CamelCaseType<string & K>]: T[K] extends {} ? CamelCaseRecordType<T[K]> : T[K]; | ||
}; | ||
export declare type DoRequired<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>; | ||
export declare type DoOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>; | ||
export declare type DeepPartial<T> = T extends string | number | bigint | boolean | null | undefined | symbol | Date ? T | undefined : T extends Array<infer ArrayType> ? Array<DeepPartial<ArrayType>> : T extends ReadonlyArray<infer ArrayType> ? ReadonlyArray<ArrayType> : T extends Set<infer SetType> ? Set<DeepPartial<SetType>> : T extends ReadonlySet<infer SetType> ? ReadonlySet<SetType> : T extends Map<infer KeyType, infer ValueType> ? Map<DeepPartial<KeyType>, DeepPartial<ValueType>> : T extends ReadonlyMap<infer KeyType, infer ValueType> ? ReadonlyMap<DeepPartial<KeyType>, DeepPartial<ValueType>> : { | ||
export type DoRequired<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>; | ||
export type DoOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>; | ||
export type DeepPartial<T> = T extends string | number | bigint | boolean | null | undefined | symbol | Date ? T | undefined : T extends Array<infer ArrayType> ? Array<DeepPartial<ArrayType>> : T extends ReadonlyArray<infer ArrayType> ? ReadonlyArray<ArrayType> : T extends Set<infer SetType> ? Set<DeepPartial<SetType>> : T extends ReadonlySet<infer SetType> ? ReadonlySet<SetType> : T extends Map<infer KeyType, infer ValueType> ? Map<DeepPartial<KeyType>, DeepPartial<ValueType>> : T extends ReadonlyMap<infer KeyType, infer ValueType> ? ReadonlyMap<DeepPartial<KeyType>, DeepPartial<ValueType>> : { | ||
[K in keyof T]?: DeepPartial<T[K]>; | ||
}; | ||
export declare type DeepReadonly<T> = T extends (infer R)[] ? DeepReadonlyArray<R> : T extends Function ? T : T extends object ? DeepReadonlyObject<T> : T; | ||
export type DeepReadonly<T> = T extends (infer R)[] ? DeepReadonlyArray<R> : T extends Function ? T : T extends object ? DeepReadonlyObject<T> : T; | ||
export interface DeepReadonlyArray<T> extends ReadonlyArray<DeepReadonly<T>> { | ||
} | ||
export declare type DeepReadonlyObject<T> = { | ||
export type DeepReadonlyObject<T> = { | ||
readonly [P in keyof T]: DeepReadonly<T[P]>; | ||
}; | ||
//# sourceMappingURL=misc.d.ts.map |
@@ -11,3 +11,3 @@ import { SuidComponentType } from "."; | ||
*/ | ||
export declare type DistributiveOmit<T, K extends keyof any> = T extends any ? Omit<T, K> : never; | ||
export type DistributiveOmit<T, K extends keyof any> = T extends any ? Omit<T, K> : never; | ||
/** | ||
@@ -22,3 +22,3 @@ * Generate a set of string literal types with the given default record `T` and | ||
*/ | ||
export declare type OverridableStringUnion<T extends string | number, U = {}> = GenerateStringUnion<Overwrite<Record<T, true>, U>>; | ||
export type OverridableStringUnion<T extends string | number, U = {}> = GenerateStringUnion<Overwrite<Record<T, true>, U>>; | ||
/** | ||
@@ -29,4 +29,4 @@ * Like `T & U`, but using the value types from `U` where their properties overlap. | ||
*/ | ||
export declare type Overwrite<T, U> = DistributiveOmit<T, keyof U> & U; | ||
declare type GenerateStringUnion<T> = Extract<{ | ||
export type Overwrite<T, U> = DistributiveOmit<T, keyof U> & U; | ||
type GenerateStringUnion<T> = Extract<{ | ||
[Key in keyof T]: true extends T[Key] ? Key : never; | ||
@@ -53,13 +53,14 @@ }[keyof T], string>; | ||
*/ | ||
export declare type OverrideProps<M extends OverridableTypeMap, C extends ElementType> = BaseProps<M> & DistributiveOmit<ComponentPropsWithRef<C>, keyof BaseProps<M>>; | ||
export type OverrideProps<M extends OverridableTypeMap, C extends ElementType> = BaseProps<M> & DistributiveOmit<ComponentPropsWithRef<C>, keyof BaseProps<M>>; | ||
/** | ||
* Props if `component={Component}` is NOT used. | ||
*/ | ||
export declare type DefaultComponentProps<M> = M extends OverridableTypeMap ? BaseProps<M> & DistributiveOmit<ComponentPropsWithRef<M["defaultComponent"]>, keyof BaseProps<M>> : M extends SuidComponentType ? BaseProps<M> : never; | ||
export type DefaultComponentProps<M> = M extends OverridableTypeMap ? BaseProps<M> & DistributiveOmit<ComponentPropsWithRef<M["defaultComponent"]>, keyof BaseProps<M>> : M extends SuidComponentType ? BaseProps<M> : never; | ||
/** | ||
* Props defined on the component. | ||
*/ | ||
export declare type BaseProps<M extends SuidComponentType> = M["props"] & CommonProps; | ||
export type BaseProps<M extends SuidComponentType> = M["props"] & CommonProps; | ||
export interface CommonProps { | ||
class?: string; | ||
as?: ElementType; | ||
} | ||
@@ -66,0 +67,0 @@ export interface OverridableTypeMap extends SuidComponentType { |
{ | ||
"name": "@suid/types", | ||
"version": "0.3.0", | ||
"version": "0.4.0", | ||
"description": "Types used by suid packages.", | ||
@@ -13,3 +13,3 @@ "keywords": [ | ||
"peerDependencies": { | ||
"solid-js": "^1.6.2" | ||
"solid-js": "^1.6.7" | ||
}, | ||
@@ -16,0 +16,0 @@ "bugs": { |
# @suid/types | ||
![GitHub Workflow Status](https://img.shields.io/github/workflow/status/swordev/suid/CI) ![npm (scoped)](https://img.shields.io/npm/v/@suid/types?label=@suid/types) | ||
[![workflow-badge]](https://github.com/swordev/suid/actions/workflows/ci.yaml) [![npm-badge]](https://www.npmjs.com/package/@suid/types) | ||
[workflow-badge]: https://img.shields.io/github/actions/workflow/status/swordev/suid/ci.yaml?branch=main | ||
[npm-badge]: https://img.shields.io/npm/v/@suid/types?label=@suid/types | ||
## Installation | ||
@@ -6,0 +9,0 @@ |
@@ -6,4 +6,4 @@ /** | ||
export {}; | ||
export declare type ElementType = Component<any> | keyof JSX.IntrinsicElements; | ||
export declare type Ref<T> = ((ref: T) => void) | null; | ||
export type ElementType = Component<any> | keyof JSX.IntrinsicElements; | ||
export type Ref<T> = ((ref: T) => void) | null; | ||
export interface RefAttributes<T> { | ||
@@ -13,5 +13,5 @@ ref?: Ref<T> | undefined; | ||
/** Ensures that the props do not include ref at all */ | ||
export declare type PropsWithoutRef<P> = P extends any ? "ref" extends keyof P ? Pick<P, Exclude<keyof P, "ref">> : P : P; | ||
export type PropsWithoutRef<P> = P extends any ? "ref" extends keyof P ? Pick<P, Exclude<keyof P, "ref">> : P : P; | ||
/** Ensures that the props do not include string ref, which cannot be forwarded */ | ||
export declare type PropsWithRef<P> = "ref" extends keyof P ? P extends { | ||
export type PropsWithRef<P> = "ref" extends keyof P ? P extends { | ||
ref?: infer R | undefined; | ||
@@ -21,4 +21,4 @@ } ? string extends R ? PropsWithoutRef<P> & { | ||
} : P : P : P; | ||
export declare type ComponentPropsWithRef<T extends ElementType> = PropsWithRef<ComponentProps<T>>; | ||
export declare type JSXElementConstructor<P> = (props: P) => JSX.Element | null; | ||
export type ComponentPropsWithRef<T extends ElementType> = PropsWithRef<ComponentProps<T>>; | ||
export type JSXElementConstructor<P> = (props: P) => JSX.Element | null; | ||
//# sourceMappingURL=solid.d.ts.map |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
176
21
10874