All files / src/custom-element interfaces.ts

100% Statements 1/1
100% Branches 0/0
0% Functions 0/1
100% Lines 1/1

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138                                                                                                                                                                                                                                                                            2x      
/**
 * Describes the configurator of the component
 */
export interface CustomElementComponentMetadata {
 
    /**
     * Whether to create a shadow DOM for the component
     * Defaults to true
     */
    shadow?: boolean;
}
 
/**
 * Describes the configurator of the properties
 */
export interface CustomElementPropertyMetadata {
    /**
     * The name of the property in the props object
     * It corresponds to the key of the record
     */
    name?: string;
 
    /**
     * The name of the HTML attribute mapped to the property
     */
    attribute?: string;
 
    /**
     * The type of the property. If not provided it defaults to a string
     */
    type?: Function | Function[];
 
    /**
     * When the type of the property is a function and we don't want to evaluate the function when initializing it value
     * but we want to call that function at a later time
     */
    defer?: boolean;
 
    /**
     * The default value of the property if no attribute is set in HTML
     */
    value?: any;
 
    /**
     * Whether the value of the property can be changed
     */
    mutable?: boolean;
 
    /**
     * Whether to reflect the change of the property in its mapped HTML attribute
     */
    reflect?: boolean;
 
    /**
     * Whether to request the value of the property in the parent if it is not set in the child. e.g., size, kind, etc.
     */
    inherit?: boolean;
 
    /**
     * The range to restrict the values of the property
     */
    options?: string[];
 
    /**
     * Whether the property must have a value by the time the connectedCallback method is called
     */
    required?: boolean;
 
    /**
     * Hook to allow for extra manipulation of the property value before being set
     */
    transform?: (value: any) => any;
 
    /**
     * Called when the property has changed but after the DOM has been updated
     * Used to perform modifications to the DOM after updating it
     */
    afterUpdate?: Function;
}
 
/**
 * Describes the configurator of the state
 */
export interface CustomElementStateMetadata {
 
    /**
     * The name of the property in the state object
     */
    name?: string;
 
    /**
     * The default value of the state
     */
    value: any;
}
 
/**
 * Contains the merged metadata of this custom component and its ancestors
 * to perform validations of the custom element as well as initialization of its instances
 */
export interface CustomElementMetadata {
 
    /**
     * Whether to create a shadow DOM for the component
     */
    shadow: boolean;
 
    /**
     * The merged properties configuration of the custom element mapped by its name.
     * They are indexed by the name of the property
     */
    properties: Map<string, CustomElementPropertyMetadata>;
 
    /**
     * The merged properties indexed by the name of the attribute
     */
    propertiesByAttribute: Map<string, CustomElementPropertyMetadata>;
 
    /**
     * The merged observed attributes of the custom element
     */
    observedAttributes: string[];
 
    /**
     * The merged state configuration of the custom element mapped by its name
     */
    state: Map<string, CustomElementStateMetadata>;
 
    /**
     * The merged styles of the custom element
     */
    styles: string;
}
 
export function Callback() {}
 
export type Constructor<T> = new (...args: any[]) => T;