11import anim from "animejs" ;
22
3- import { M } from "./global " ;
3+ import { Utils } from "./utils " ;
44import { Component , BaseOptions , InitElements , Openable } from "./component" ;
55
66export interface DropdownOptions extends BaseOptions {
@@ -114,7 +114,7 @@ export class Dropdown extends Component<DropdownOptions> implements Openable {
114114 ( this . el as any ) . M_Dropdown = this ;
115115
116116 Dropdown . _dropdowns . push ( this ) ;
117- this . id = M . getIdFromTrigger ( el ) ;
117+ this . id = Utils . getIdFromTrigger ( el ) ;
118118 this . dropdownEl = document . getElementById ( this . id ) ;
119119
120120 this . options = {
@@ -264,7 +264,7 @@ export class Dropdown extends Component<DropdownOptions> implements Openable {
264264
265265 _handleTriggerKeydown = ( e : KeyboardEvent ) => {
266266 // ARROW DOWN OR ENTER WHEN SELECT IS CLOSED - open Dropdown
267- const arrowDownOrEnter = M . keys . ARROW_DOWN . includes ( e . key ) || M . keys . ENTER . includes ( e . key ) ;
267+ const arrowDownOrEnter = Utils . keys . ARROW_DOWN . includes ( e . key ) || Utils . keys . ENTER . includes ( e . key ) ;
268268 if ( arrowDownOrEnter && ! this . isOpen ) {
269269 e . preventDefault ( ) ;
270270 this . open ( ) ;
@@ -287,15 +287,15 @@ export class Dropdown extends Component<DropdownOptions> implements Openable {
287287 }
288288
289289 _handleDropdownKeydown = ( e : KeyboardEvent ) => {
290- const arrowUpOrDown = M . keys . ARROW_DOWN . includes ( e . key ) || M . keys . ARROW_UP . includes ( e . key ) ;
291- if ( M . keys . TAB . includes ( e . key ) ) {
290+ const arrowUpOrDown = Utils . keys . ARROW_DOWN . includes ( e . key ) || Utils . keys . ARROW_UP . includes ( e . key ) ;
291+ if ( Utils . keys . TAB . includes ( e . key ) ) {
292292 e . preventDefault ( ) ;
293293 this . close ( ) ;
294294 }
295295 // Navigate down dropdown list
296296 else if ( arrowUpOrDown && this . isOpen ) {
297297 e . preventDefault ( ) ;
298- const direction = M . keys . ARROW_DOWN . includes ( e . key ) ? 1 : - 1 ;
298+ const direction = Utils . keys . ARROW_DOWN . includes ( e . key ) ? 1 : - 1 ;
299299 let newFocusedIndex = this . focusedIndex ;
300300 let hasFoundNewIndex = false ;
301301 do {
@@ -318,7 +318,7 @@ export class Dropdown extends Component<DropdownOptions> implements Openable {
318318 }
319319 }
320320 // ENTER selects choice on focused item
321- else if ( M . keys . ENTER . includes ( e . key ) && this . isOpen ) {
321+ else if ( Utils . keys . ENTER . includes ( e . key ) && this . isOpen ) {
322322 // Search for <a> and <button>
323323 const focusedElement = this . dropdownEl . children [ this . focusedIndex ] ;
324324 const activatableElement = < HTMLElement > focusedElement . querySelector ( 'a, button' ) ;
@@ -333,15 +333,15 @@ export class Dropdown extends Component<DropdownOptions> implements Openable {
333333 }
334334 }
335335 // Close dropdown on ESC
336- else if ( M . keys . ESC . includes ( e . key ) && this . isOpen ) {
336+ else if ( Utils . keys . ESC . includes ( e . key ) && this . isOpen ) {
337337 e . preventDefault ( ) ;
338338 this . close ( ) ;
339339 }
340340
341341 // CASE WHEN USER TYPE LTTERS
342342 const keyText = e . key . toLowerCase ( ) ;
343343 const isLetter = / [ a - z A - Z 0 - 9 - _ ] / . test ( keyText ) ;
344- const specialKeys = [ ...M . keys . ARROW_DOWN , ...M . keys . ARROW_UP , ...M . keys . ENTER , ...M . keys . ESC , ...M . keys . TAB ] ;
344+ const specialKeys = [ ...Utils . keys . ARROW_DOWN , ...Utils . keys . ARROW_UP , ...Utils . keys . ENTER , ...Utils . keys . ESC , ...Utils . keys . TAB ] ;
345345 if ( isLetter && ! specialKeys . includes ( e . key ) ) {
346346 this . filterQuery . push ( keyText ) ;
347347 const string = this . filterQuery . join ( '' ) ;
@@ -430,7 +430,7 @@ export class Dropdown extends Component<DropdownOptions> implements Openable {
430430 width : idealWidth
431431 } ;
432432
433- const alignments = M . checkPossibleAlignments (
433+ const alignments = Utils . checkPossibleAlignments (
434434 this . el ,
435435 closestOverflowParent ,
436436 dropdownBounds ,
0 commit comments