|
|
// eslint-disable-next-line @typescript-eslint/triple-slash-reference
|
|
|
/// <reference path="./css-plugin.d.ts"/>
|
|
|
|
|
|
import _WidgetBase = require("dijit/_WidgetBase");
|
|
|
import { Rendition } from "./tsx/traits";
|
|
|
|
|
|
declare global {
|
|
|
namespace JSX {
|
|
|
|
|
|
type Ref<T> = ((value: T | undefined) => void);
|
|
|
|
|
|
type Element = Rendition | _WidgetBase;
|
|
|
|
|
|
interface DjxIntrinsicAttributes<E> {
|
|
|
/** alias for className */
|
|
|
class?: string;
|
|
|
|
|
|
/** specifies the name of the property in the widget where the the
|
|
|
* reference to the current object will be stored
|
|
|
*/
|
|
|
"data-dojo-attach-point"?: string;
|
|
|
|
|
|
/** specifies handlers map for the events */
|
|
|
"data-dojo-attach-event"?: string;
|
|
|
|
|
|
ref?: Ref<E>;
|
|
|
|
|
|
/** @deprecated */
|
|
|
[attr: string]: unknown;
|
|
|
}
|
|
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
|
|
interface DjxIntrinsicElements {
|
|
|
}
|
|
|
|
|
|
type RecursivePartial<T> = T extends string | number | boolean | null | undefined | ((...args: unknown[]) => unknown) ?
|
|
|
T :
|
|
|
{ [k in keyof T]?: RecursivePartial<T[k]> };
|
|
|
|
|
|
type MatchingMemberKeys<T, U> = {
|
|
|
[K in keyof T]: T[K] extends U ? K : never;
|
|
|
}[keyof T];
|
|
|
type NotMatchingMemberKeys<T, U> = {
|
|
|
[K in keyof T]: T[K] extends U ? never : K;
|
|
|
}[keyof T];
|
|
|
|
|
|
type ExtractMembers<T, U> = Pick<T, MatchingMemberKeys<T, U>>;
|
|
|
|
|
|
type ExcludeMembers<T, U> = Pick<T, NotMatchingMemberKeys<T, U>>;
|
|
|
|
|
|
type ElementAttrNames<E> = NotMatchingMemberKeys<E, (...args: unknown[]) => unknown>;
|
|
|
|
|
|
type ElementAttrType<E, K extends string | symbol> = K extends keyof E ? RecursivePartial<E[K]> : string;
|
|
|
|
|
|
|
|
|
type ElementAttrNamesBlacklist = "children" | "getRootNode" | keyof EventTarget;
|
|
|
|
|
|
/** This type extracts keys of the specified parameter E by the following rule:
|
|
|
* 1. skips all ElementAttrNamesBlacklist
|
|
|
* 2. skips all methods except with the signature of event handlers
|
|
|
*/
|
|
|
type AssignableElementAttrNames<E> = {
|
|
|
[K in keyof E]: K extends ElementAttrNamesBlacklist ? never :
|
|
|
((evt: Event) => unknown) extends E[K] ? K :
|
|
|
E[K] extends ((...args: unknown[]) => unknown) ? never :
|
|
|
K;
|
|
|
}[keyof E];
|
|
|
|
|
|
type LaxElement<E extends object> =
|
|
|
RecursivePartial<Pick<E, AssignableElementAttrNames<E>>> &
|
|
|
DjxIntrinsicAttributes<E>;
|
|
|
|
|
|
type LaxIntrinsicElementsMap = {
|
|
|
[tag in keyof HTMLElementTagNameMap]: LaxElement<HTMLElementTagNameMap[tag]>
|
|
|
} & DjxIntrinsicElements;
|
|
|
|
|
|
type IntrinsicElements = {
|
|
|
[tag in keyof LaxIntrinsicElementsMap]: LaxIntrinsicElementsMap[tag];
|
|
|
};
|
|
|
|
|
|
interface ElementChildrenAttribute {
|
|
|
children: unknown;
|
|
|
}
|
|
|
|
|
|
interface IntrinsicClassAttributes<T> {
|
|
|
ref?: Ref<T>;
|
|
|
children?: unknown;
|
|
|
}
|
|
|
}
|
|
|
}
|