1- import { Controller } from '@hotwired/stimulus' ;
2- import Backend , { type BackendInterface } from './Backend/Backend' ;
3- import Component , { proxifyComponent } from './Component' ;
4- import { StimulusElementDriver } from './Component/ElementDriver' ;
1+ import { Controller } from '@hotwired/stimulus' ;
2+ import Backend , { type BackendInterface } from './Backend/Backend' ;
3+ import Component , { proxifyComponent } from './Component' ;
4+ import { StimulusElementDriver } from './Component/ElementDriver' ;
55import ChildComponentPlugin from './Component/plugins/ChildComponentPlugin' ;
66import LazyPlugin from './Component/plugins/LazyPlugin' ;
77import LoadingPlugin from './Component/plugins/LoadingPlugin' ;
88import PageUnloadingPlugin from './Component/plugins/PageUnloadingPlugin' ;
9- import type { PluginInterface } from './Component/plugins/PluginInterface' ;
9+ import type { PluginInterface } from './Component/plugins/PluginInterface' ;
1010import PollingPlugin from './Component/plugins/PollingPlugin' ;
1111import QueryStringPlugin from './Component/plugins/QueryStringPlugin' ;
1212import SetValueOntoModelFieldsPlugin from './Component/plugins/SetValueOntoModelFieldsPlugin' ;
1313import ValidatedFieldsPlugin from './Component/plugins/ValidatedFieldsPlugin' ;
14- import { type DirectiveModifier , parseDirectives } from './Directive/directives_parser' ;
14+ import { type DirectiveModifier , parseDirectives } from './Directive/directives_parser' ;
1515import getModelBinding from './Directive/get_model_binding' ;
16- import { elementBelongsToThisComponent , getModelDirectiveFromElement , getValueFromElement } from './dom_utils' ;
16+ import { elementBelongsToThisComponent , getModelDirectiveFromElement , getValueFromElement } from './dom_utils' ;
1717import getElementAsTagText from './Util/getElementAsTagText' ;
1818
19- export { Component } ;
20- export { getComponent } from './ComponentRegistry' ;
19+ export { Component } ;
20+ export { getComponent } from './ComponentRegistry' ;
2121
2222export interface LiveEvent extends CustomEvent {
2323 detail : {
@@ -35,15 +35,15 @@ export default class LiveControllerDefault extends Controller<HTMLElement> imple
3535 static values = {
3636 name : String ,
3737 url : String ,
38- props : { type : Object , default : { } } ,
39- propsUpdatedFromParent : { type : Object , default : { } } ,
40- listeners : { type : Array , default : [ ] } ,
41- eventsToEmit : { type : Array , default : [ ] } ,
42- eventsToDispatch : { type : Array , default : [ ] } ,
43- debounce : { type : Number , default : 150 } ,
44- fingerprint : { type : String , default : '' } ,
45- requestMethod : { type : String , default : 'post' } ,
46- queryMapping : { type : Object , default : { } } ,
38+ props : { type : Object , default : { } } ,
39+ propsUpdatedFromParent : { type : Object , default : { } } ,
40+ listeners : { type : Array , default : [ ] } ,
41+ eventsToEmit : { type : Array , default : [ ] } ,
42+ eventsToDispatch : { type : Array , default : [ ] } ,
43+ debounce : { type : Number , default : 150 } ,
44+ fingerprint : { type : String , default : '' } ,
45+ requestMethod : { type : String , default : 'post' } ,
46+ queryMapping : { type : Object , default : { } } ,
4747 } ;
4848
4949 declare readonly nameValue : string ;
@@ -72,8 +72,8 @@ export default class LiveControllerDefault extends Controller<HTMLElement> imple
7272 pendingActionTriggerModelElement : HTMLElement | null = null ;
7373
7474 private elementEventListeners : Array < { event : string ; callback : ( event : any ) => void } > = [
75- { event : 'input' , callback : ( event ) => this . handleInputEvent ( event ) } ,
76- { event : 'change' , callback : ( event ) => this . handleChangeEvent ( event ) } ,
75+ { event : 'input' , callback : ( event ) => this . handleInputEvent ( event ) } ,
76+ { event : 'change' , callback : ( event ) => this . handleChangeEvent ( event ) } ,
7777 ] ;
7878 private pendingFiles : { [ key : string ] : HTMLInputElement } = { } ;
7979
@@ -128,7 +128,7 @@ export default class LiveControllerDefault extends Controller<HTMLElement> imple
128128 }
129129 const rawAction = params . action ;
130130 // all other params are considered action arguments
131- const actionArgs = { ...params } ;
131+ const actionArgs = { ...params } ;
132132 delete actionArgs . action ;
133133
134134 // data-live-action-param="debounce(1000)|save"
@@ -160,8 +160,7 @@ export default class LiveControllerDefault extends Controller<HTMLElement> imple
160160 directive . modifiers . forEach ( ( modifier ) => {
161161 if ( validModifiers . has ( modifier . name ) ) {
162162 // variable is entirely to make ts happy
163- const callable = validModifiers . get ( modifier . name ) ?? ( ( ) => {
164- } ) ;
163+ const callable = validModifiers . get ( modifier . name ) ?? ( ( ) => { } ) ;
165164 callable ( modifier ) ;
166165
167166 return ;
@@ -197,19 +196,19 @@ export default class LiveControllerDefault extends Controller<HTMLElement> imple
197196 }
198197
199198 emit ( event : any ) {
200- this . getEmitDirectives ( event ) . forEach ( ( { name, data, nameMatch} ) => {
199+ this . getEmitDirectives ( event ) . forEach ( ( { name, data, nameMatch } ) => {
201200 this . component . emit ( name , data , nameMatch ) ;
202201 } ) ;
203202 }
204203
205204 emitUp ( event : any ) {
206- this . getEmitDirectives ( event ) . forEach ( ( { name, data, nameMatch} ) => {
205+ this . getEmitDirectives ( event ) . forEach ( ( { name, data, nameMatch } ) => {
207206 this . component . emitUp ( name , data , nameMatch ) ;
208207 } ) ;
209208 }
210209
211210 emitSelf ( event : any ) {
212- this . getEmitDirectives ( event ) . forEach ( ( { name, data} ) => {
211+ this . getEmitDirectives ( event ) . forEach ( ( { name, data } ) => {
213212 this . component . emitSelf ( name , data ) ;
214213 } ) ;
215214 }
@@ -245,7 +244,7 @@ export default class LiveControllerDefault extends Controller<HTMLElement> imple
245244 }
246245 const eventInfo = params . event ;
247246 // all other params are considered event arguments
248- const eventArgs = { ...params } ;
247+ const eventArgs = { ...params } ;
249248 delete eventArgs . event ;
250249
251250 // data-event="name(product_list)|some_event"
@@ -317,7 +316,7 @@ export default class LiveControllerDefault extends Controller<HTMLElement> imple
317316 attributes : true ,
318317 } ) ;
319318
320- this . elementEventListeners . forEach ( ( { event, callback} ) => {
319+ this . elementEventListeners . forEach ( ( { event, callback } ) => {
321320 this . component . element . addEventListener ( event , callback ) ;
322321 } ) ;
323322
@@ -326,7 +325,7 @@ export default class LiveControllerDefault extends Controller<HTMLElement> imple
326325
327326 private disconnectComponent ( ) {
328327 this . component . disconnect ( ) ;
329- this . elementEventListeners . forEach ( ( { event, callback} ) => {
328+ this . elementEventListeners . forEach ( ( { event, callback } ) => {
330329 this . component . element . removeEventListener ( event , callback ) ;
331330 } ) ;
332331 this . dispatchEvent ( 'disconnect' ) ;
@@ -432,13 +431,22 @@ export default class LiveControllerDefault extends Controller<HTMLElement> imple
432431 const finalValue = getValueFromElement ( element , this . component . valueStore ) ;
433432
434433 if (
435- ( element instanceof HTMLInputElement && [ 'text' , 'email' , 'password' , 'search' , 'tel' , 'url' ] . includes ( element . type ) ) ||
434+ ( element instanceof HTMLInputElement &&
435+ [ 'text' , 'email' , 'password' , 'search' , 'tel' , 'url' ] . includes ( element . type ) ) ||
436436 element instanceof HTMLTextAreaElement
437437 ) {
438- if ( modelBinding . minLength !== null && typeof finalValue === "string" && finalValue . length < modelBinding . minLength ) {
438+ if (
439+ modelBinding . minLength !== null &&
440+ typeof finalValue === 'string' &&
441+ finalValue . length < modelBinding . minLength
442+ ) {
439443 return ;
440444 }
441- if ( modelBinding . maxLength !== null && typeof finalValue === "string" && finalValue . length > modelBinding . maxLength ) {
445+ if (
446+ modelBinding . maxLength !== null &&
447+ typeof finalValue === 'string' &&
448+ finalValue . length > modelBinding . maxLength
449+ ) {
442450 return ;
443451 }
444452 }
@@ -459,7 +467,7 @@ export default class LiveControllerDefault extends Controller<HTMLElement> imple
459467 detail . controller = this ;
460468 detail . component = this . proxiedComponent ;
461469
462- this . dispatch ( name , { detail, prefix : 'live' , cancelable, bubbles : canBubble } ) ;
470+ this . dispatch ( name , { detail, prefix : 'live' , cancelable, bubbles : canBubble } ) ;
463471 }
464472
465473 private onMutations ( mutations : MutationRecord [ ] ) : void {
0 commit comments