@@ -2,6 +2,7 @@ import { isFunction, isObject } from "../utils.js";
22import { PropError } from "./errors.js" ;
33
44export const CUSTOM_TYPE_NAME = "Custom" ;
5+
56/**
67 * The Any type avoids the validation of prop types
78 * @type {null }
@@ -16,11 +17,11 @@ const TRUE_VALUES = { true: 1, "": 1, 1: 1 };
1617/**
1718 * Constructs the setter and getter of the associated property
1819 * only if it is not defined in the prototype
19- * @param {Object } prototype - CustomElement prototype
20- * @param {string } prop - Name of the reactive property to associate with the customElement
21- * @param {any } schema - Structure to be evaluated for the definition of the property
22- * @param {Attrs } attrs - Dictionary of attributes to properties
23- * @param {Values } values - Values to initialize the customElements
20+ * @param {object } prototype CustomElement prototype
21+ * @param {string } prop Name of the reactive property to associate with the customElement
22+ * @param {any } schema Structure to be evaluated for the definition of the property
23+ * @param {Attrs } attrs Dictionary of attributes to properties
24+ * @param {Values } values Values to initialize the customElements
2425 */
2526export function setPrototype ( prototype , prop , schema , attrs , values ) {
2627 /** @type {Schema } */
@@ -103,8 +104,8 @@ export function setPrototype(prototype, prop, schema, attrs, values) {
103104
104105/**
105106 * Dispatch an event
106- * @param {Element } node - DOM node to dispatch the event
107- * @param {InternalEvent & InternalEventInit } event - Event to dispatch on node
107+ * @param {Element } node DOM node to dispatch the event
108+ * @param {InternalEvent & InternalEventInit } event Event to dispatch on node
108109 */
109110export const dispatchEvent = (
110111 node ,
@@ -113,7 +114,7 @@ export const dispatchEvent = (
113114
114115/**
115116 * Transform a Camel Case string to a Kebab case
116- * @param {string } prop - string to apply the format
117+ * @param {string } prop string to apply the format
117118 * @returns {string }
118119 */
119120export const getAttr = ( prop ) => prop . replace ( / ( [ A - Z ] ) / g, "-$1" ) . toLowerCase ( ) ;
@@ -160,9 +161,8 @@ export const transformValue = (type, value) =>
160161 new type ( value ) ;
161162
162163/**
163- * @param {import("schema").TypeCustom<(...args:any)=>any> } TypeCustom
164- * @param {* } value
165- * @returns
164+ * @param {import("schema").TypeCustom<(...args: any[]) => any> } TypeCustom
165+ * @param {any } value
166166 */
167167export const mapValue = ( { map } , value ) => {
168168 try {
@@ -176,7 +176,7 @@ export const mapValue = ({ map }, value) => {
176176 * Filter the values based on their type
177177 * @param {any } type
178178 * @param {any } value
179- * @returns {{error?:boolean,value:any} }
179+ * @returns {{ error?: boolean, value: any } }
180180 */
181181export const filterValue = ( type , value ) =>
182182 type == null || value == null
@@ -202,9 +202,9 @@ export const filterValue = (type, value) =>
202202 : { value, error : true } ;
203203
204204/**
205- * @param {(...args:any[])=> any } map
206- * @param {(...args:any[])=> any } [serialize]
207- * @returns {import("schema").TypeCustom<(...args:any)=> any> }
205+ * @param {(...args: any[]) => any } map
206+ * @param {(...args: any[]) => any } [serialize]
207+ * @returns {import("schema").TypeCustom<(...args: any[]) => any> }
208208 */
209209export const createType = ( map , serialize ) => ( {
210210 name : CUSTOM_TYPE_NAME ,
@@ -218,33 +218,33 @@ export const createType = (map, serialize) => ({
218218 */
219219
220220/**
221- * @typedef {Object } InternalEventInit
222- * @property {typeof CustomEvent| typeof Event } [base] - Optional constructor to initialize the event
223- * @property {boolean } [bubbles] - indicating whether the event bubbles. The default is false.
224- * @property {boolean } [cancelable] - indicating whether the event will trigger listeners outside of a shadow root.
225- * @property {boolean } [composed] - indicating whether the event will trigger listeners outside of a shadow root.
226- * @property {any } [detail] - indicating whether the event will trigger listeners outside of a shadow root.
221+ * @typedef {object } InternalEventInit
222+ * @property {typeof CustomEvent | typeof Event } [base] Optional constructor to initialize the event
223+ * @property {boolean } [bubbles] indicating whether the event bubbles. The default is false.
224+ * @property {boolean } [cancelable] indicating whether the event will trigger listeners outside of a shadow root.
225+ * @property {boolean } [composed] indicating whether the event will trigger listeners outside of a shadow root.
226+ * @property {any } [detail] indicating whether the event will trigger listeners outside of a shadow root.
227227 */
228228
229229/**
230230 * Interface used by dispatchEvent to automate event firing
231- * @typedef {Object } InternalEvent
232- * @property {string } type - type of event to dispatch.
231+ * @typedef {object } InternalEvent
232+ * @property {string } type type of event to dispatch.
233233 */
234234
235235/**
236- * @typedef {Object< string, { prop:string,type:Function}> } Attrs
236+ * @typedef {{ [attr: string]: { prop: string, type: Function } } } Attrs
237237 */
238238
239239/**
240- * @typedef {Object< string, any> } Values
240+ * @typedef {{ [prop: string]: any } } Values
241241 */
242242
243243/**
244- * @typedef {Object } Schema
245- * @property {any } [type] - data type to be worked as property and attribute
246- * @property {string } [attr] - allows customizing the name as an attribute by skipping the camelCase format
247- * @property {boolean } [reflect] - reflects property as attribute of node
248- * @property {InternalEvent & InternalEventInit } [event] - Allows to emit an event every time the property changes
249- * @property {any } [value] - defines a default value when instantiating the component
244+ * @typedef {object } Schema
245+ * @property {any } [type] data type to be worked as property and attribute
246+ * @property {string } [attr] allows customizing the name as an attribute by skipping the camelCase format
247+ * @property {boolean } [reflect] reflects property as attribute of node
248+ * @property {InternalEvent & InternalEventInit } [event] Allows to emit an event every time the property changes
249+ * @property {any } [value] defines a default value when instantiating the component
250250 */
0 commit comments