Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions types/ClientContext.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,5 +126,6 @@ export type NullstackClientContext<TProps = unknown> = TProps & {
*
* @see https://nullstack.app/refs#complex-refable-components
*/

element?: HTMLElement
}
12 changes: 7 additions & 5 deletions types/JSX.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export interface Attributes {
[key: string]: any
}

export type NullstackAttributes = Attributes
export interface NullstackAttributes extends Attributes {}

export interface ClassAttributes extends Attributes {
key?: string
Expand All @@ -69,7 +69,7 @@ export interface ClassAttributes extends Attributes {

type DetailedHTMLFactory<P, T = any> = P

export interface SVGFactory { }
export interface SVGFactory {}

export type NullstackFragment = NullstackNode[]
export type NullstackNode = NullstackFragment | string | number | boolean | null | undefined
Expand Down Expand Up @@ -101,6 +101,7 @@ export interface BaseSyntheticEvent<E = object, C = any, T = any> {
* This might be a child element to the element on which the event listener is registered.
* If you thought this should be `EventTarget & T`, see https://github.com/DefinitelyTyped/DefinitelyTyped/issues/11508#issuecomment-256045682
*/

export type SyntheticEvent<T = Element, E = Event> = BaseSyntheticEvent<E, EventTarget & T, EventTarget>

export interface DragEvent<T = Element> extends MouseEvent<T, NativeDragEvent> {
Expand Down Expand Up @@ -196,6 +197,7 @@ export interface WheelEvent<T = Element> extends MouseEvent<T, NativeWheelEvent>
type EventHandler<E extends SyntheticEvent<any>> =
| object
| {

bivarianceHack(event: { event: E } & NullstackClientContext): void
}['bivarianceHack']

Expand All @@ -216,7 +218,7 @@ type WheelEventHandler<T = Element> = EventHandler<WheelEvent<T>>

type DetailedHTMLProps<E extends HTMLAttributes<T>, T> = E

export interface SVGProps<T> extends SVGAttributes<T>, ClassAttributes { }
export interface SVGProps<T> extends SVGAttributes<T>, ClassAttributes {}

export interface DOMAttributes<T> extends Attributes {
// Focus Events
Expand Down Expand Up @@ -305,7 +307,7 @@ export interface DOMAttributes<T> extends Attributes {

// All the WAI-ARIA 1.1 attributes from https://www.w3.org/TR/wai-aria-1.1/
export interface AriaAttributes {
/** Identifies the currently active element when DOM focus is on a composite widget, textbox, group, or applicatio */
/** Identifies the currently active element when DOM focus is on a composite widget, textbox, group, or application */
'aria-activedescendant'?: string
/** Indicates whether assistive technologies will present all, or only parts of, the changed region based on the change notifications defined by the aria-relevant attribute. */
'aria-atomic'?: Booleanish
Expand Down Expand Up @@ -1423,6 +1425,6 @@ declare global {
element: ElementTagHTMLAttributes
}

interface IntrinsicElements extends ExoticElements, AllElements { }
interface IntrinsicElements extends ExoticElements, AllElements {}
}
}
22 changes: 22 additions & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,28 @@ export * from './Settings.d.ts'
export * from './Worker.d.ts'
export * from './JSX.d.ts'

/**
* Functional component
*
* @example
*
* ```
* import { NullstackClientContext, NullstackFunctionalComponent } from 'nullstack';
*
* interface InputProps {
* label: string;
* }
*
* function Input({ label, page }: NullstackClientContext<InputProps>) {
* console.log(page.title);
* return <p>{label}</p>;
* }
*
* export default Input as NullstackFunctionalComponent<InputProps>;
* ```
*/
export type NullstackFunctionalComponent<TProps> = (props: TProps) => NullstackNode;

export default class Nullstack<TProps = unknown> {

constructor(props?: TProps)
Expand Down