shorty.d.ts 55 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144
  1. import { version } from '../package.json';
  2. /**
  3. * A global namespace for `abort` event.
  4. */
  5. export declare const abortEvent = "abort";
  6. declare interface AbstractView {
  7. styleMedia: StyleMedia;
  8. document: Document;
  9. }
  10. /**
  11. * Add one or more CSS classes to `Element.classList`.
  12. *
  13. * @param element target
  14. * @param classNAME to add
  15. */
  16. export declare const addClass: (element: Element, ...classNAME: string[]) => void;
  17. /**
  18. * A global namespace for 'addEventListener' string.
  19. */
  20. declare const addEventListener_2 = "addEventListener";
  21. export { addEventListener_2 as addEventListener }
  22. /**
  23. * Utility to add focus trap inside a designated target element;
  24. * @param target
  25. */
  26. export declare const addFocusTrap: (target: Element) => void;
  27. /**
  28. * A global namespace for 'animationDelay' string.
  29. */
  30. export declare const animationDelay = "animationDelay";
  31. /**
  32. * A global namespace for 'animationDuration' string.
  33. */
  34. export declare const animationDuration = "animationDuration";
  35. /**
  36. * A global namespace for 'animationend' string.
  37. */
  38. export declare const animationEndEvent = "animationend";
  39. declare interface AnimationEvent_2<T extends EventTarget = HTMLElement>
  40. extends NativeEvent<T, NativeAnimationEvent> {
  41. animationName: string;
  42. elapsedTime: number;
  43. pseudoElement: string;
  44. }
  45. export { AnimationEvent_2 as AnimationEvent }
  46. export declare type AnimationEventHandler<T extends EventTarget = HTMLElement> = EventHandler<
  47. T,
  48. AnimationEvent_2<T>
  49. >;
  50. /**
  51. * A global namespace for 'animationName' string.
  52. */
  53. export declare const animationName = "animationName";
  54. /**
  55. * A global namespace for aria-checked.
  56. */
  57. export declare const ariaChecked = "aria-checked";
  58. /**
  59. * A global namespace for aria-describedby.
  60. */
  61. export declare const ariaDescribedBy = "aria-describedby";
  62. /**
  63. * A global namespace for aria-description.
  64. */
  65. export declare const ariaDescription = "aria-description";
  66. /**
  67. * A global namespace for aria-expanded.
  68. */
  69. export declare const ariaExpanded = "aria-expanded";
  70. /**
  71. * A global namespace for aria-haspopup.
  72. */
  73. export declare const ariaHasPopup = "aria-haspopup";
  74. /**
  75. * A global namespace for aria-hidden.
  76. */
  77. export declare const ariaHidden = "aria-hidden";
  78. /**
  79. * A global namespace for aria-label.
  80. */
  81. export declare const ariaLabel = "aria-label";
  82. /**
  83. * A global namespace for aria-labelledby.
  84. */
  85. export declare const ariaLabelledBy = "aria-labelledby";
  86. /**
  87. * A global namespace for aria-modal.
  88. */
  89. export declare const ariaModal = "aria-modal";
  90. /**
  91. * A global namespace for aria-pressed.
  92. */
  93. export declare const ariaPressed = "aria-pressed";
  94. /**
  95. * A global namespace for aria-selected.
  96. */
  97. export declare const ariaSelected = "aria-selected";
  98. /**
  99. * A global namespace for aria-valuemax.
  100. */
  101. export declare const ariaValueMax = "aria-valuemax";
  102. /**
  103. * A global namespace for aria-valuemin.
  104. */
  105. export declare const ariaValueMin = "aria-valuemin";
  106. /**
  107. * A global namespace for aria-valuenow.
  108. */
  109. export declare const ariaValueNow = "aria-valuenow";
  110. /**
  111. * A global namespace for aria-valuetext.
  112. */
  113. export declare const ariaValueText = "aria-valuetext";
  114. /**
  115. * Shortie for `Array.from()` static method.
  116. * The utility should also work with any typed arrays
  117. * like Float64Array or Int32Array.
  118. *
  119. * @param arr array-like iterable object
  120. * @returns a new array from iterable object
  121. */
  122. export declare const ArrayFrom: <T>(arr: ArrayLike<T> | Iterable<T>) => T[];
  123. declare interface BaseEvent<E = Event, C = unknown, T = unknown> {
  124. nativeEvent: E;
  125. currentTarget: C | null;
  126. target: T & EventTarget;
  127. bubbles: boolean;
  128. cancelable: boolean;
  129. defaultPrevented: boolean;
  130. eventPhase: number;
  131. isTrusted: boolean;
  132. preventDefault(): void;
  133. isDefaultPrevented(): boolean;
  134. stopPropagation(): void;
  135. isPropagationStopped(): boolean;
  136. persist(): void;
  137. timeStamp: number;
  138. type: string;
  139. }
  140. /**
  141. * A global namespace for `beforeunload` event.
  142. */
  143. export declare const beforeunloadEvent = "beforeunload";
  144. /**
  145. * A global namespace for predefined
  146. * CSS3 'cubic-bezier()' easing functions.
  147. */
  148. export declare const bezierEasings: {
  149. linear: string;
  150. easingSinusoidalIn: string;
  151. easingSinusoidalOut: string;
  152. easingSinusoidalInOut: string;
  153. easingQuadraticIn: string;
  154. easingQuadraticOut: string;
  155. easingQuadraticInOut: string;
  156. easingCubicIn: string;
  157. easingCubicOut: string;
  158. easingCubicInOut: string;
  159. easingQuarticIn: string;
  160. easingQuarticOut: string;
  161. easingQuarticInOut: string;
  162. easingQuinticIn: string;
  163. easingQuinticOut: string;
  164. easingQuinticInOut: string;
  165. easingExponentialIn: string;
  166. easingExponentialOut: string;
  167. easingExponentialInOut: string;
  168. easingCircularIn: string;
  169. easingCircularOut: string;
  170. easingCircularInOut: string;
  171. easingBackIn: string;
  172. easingBackOut: string;
  173. easingBackInOut: string;
  174. };
  175. /**
  176. * A global namespace for `blur` event.
  177. */
  178. export declare const blurEvent = "blur";
  179. export declare interface BoundingClientRect {
  180. width: number;
  181. height: number;
  182. top: number;
  183. left: number;
  184. right: number;
  185. bottom: number;
  186. x: number;
  187. y: number;
  188. }
  189. /**
  190. * Transform a string to camel case.
  191. * @param input source string
  192. */
  193. export declare const camelCase: (input: string) => string;
  194. /**
  195. * Capitalize first character in a string.
  196. * @param input source string
  197. */
  198. export declare const capitalize: (input: string) => string;
  199. export declare interface ChangeEvent<T extends EventTarget = FormControl>
  200. extends FormEvent<T> {
  201. target: EventTarget & T;
  202. }
  203. /**
  204. * A global namespace for `change` event.
  205. */
  206. export declare const changeEvent = "change";
  207. export declare type ChangeEventHandler<T extends EventTarget = HTMLElement> = EventHandler<
  208. T,
  209. ChangeEvent<T>
  210. >;
  211. declare interface ClipboardEvent_2<T extends EventTarget = HTMLElement>
  212. extends NativeEvent<T, NativeClipboardEvent> {
  213. clipboardData: DataTransfer;
  214. }
  215. export { ClipboardEvent_2 as ClipboardEvent }
  216. export declare type ClipboardEventHandler<T extends EventTarget = HTMLElement> = EventHandler<
  217. T,
  218. ClipboardEvent_2<T>
  219. >;
  220. /**
  221. * Shortcut for `HTMLElement.closest` method which also works
  222. * with children of `ShadowRoot`. The order of the parameters
  223. * is intentional since they're both required.
  224. *
  225. * @see https://stackoverflow.com/q/54520554/803358
  226. *
  227. * @param element target Element to check
  228. * @param selector the selector string
  229. * @return the query result
  230. */
  231. export declare const closest: <T extends Element>(element: T, selector: string) => T | null;
  232. declare interface CompositionEvent_2<T extends EventTarget = HTMLElement>
  233. extends NativeEvent<T, NativeCompositionEvent> {
  234. data: string;
  235. }
  236. export { CompositionEvent_2 as CompositionEvent }
  237. export declare type CompositionEventHandler<T extends EventTarget = HTMLElement> =
  238. EventHandler<
  239. T,
  240. CompositionEvent_2<T>
  241. >;
  242. /**
  243. * A global namespace for `contextmenu` event.
  244. */
  245. export declare const contextmenuEvent = "contextmenu";
  246. /**
  247. * Returns a namespaced `CustomEvent` specific to each component.
  248. *
  249. * @param eventType Event.type
  250. * @param config Event.options | Event.properties
  251. * @returns a new namespaced event
  252. */
  253. export declare const createCustomEvent: <O extends unknown & Record<string, unknown>, T extends OriginalEvent>(eventType: string, config?: O) => T;
  254. /**
  255. * Shortie for `document.createElement` method
  256. * which allows you to create a new `HTMLElement` for a given `tagName`
  257. * or based on an object with specific non-readonly attributes with string values:
  258. * `id`, `className`, `textContent`, `style`, etc.
  259. *
  260. * @see https://developer.mozilla.org/en-US/docs/Web/API/Document/createElement
  261. *
  262. * @param param `tagName` or object
  263. * @return a new `HTMLElement`
  264. */
  265. export declare const createElement: <T extends HTMLElement>(param?: string | Partial<T>) => T | undefined;
  266. /**
  267. * Shortie for `document.createElementNS` method
  268. * which allows you to create a new `Element` for a given `tagName`
  269. * or based on an object with specific non-readonly attributes with string values:
  270. * `id`, `className`, `textContent`, `style`, etc.
  271. * Note: some elements resulted from this function call may not be compatible with
  272. * some attributes.
  273. *
  274. * @see https://developer.mozilla.org/en-US/docs/Web/API/Document/createElementNS
  275. *
  276. * @param ns `namespaceURI` to associate with the new `Element`
  277. * @param param `tagName` or object
  278. * @return a new `Element`
  279. */
  280. export declare const createElementNS: <T extends Element>(ns: string, param?: string | Partial<T>) => T | undefined;
  281. export declare interface CSS4Declaration
  282. extends Exclude<() => string | symbol, CSSStyleDeclaration> {
  283. [key: string]: string;
  284. }
  285. export declare interface CustomElement extends HTMLElement {
  286. shadowRoot: ShadowRoot;
  287. connectedCallback?: () => void;
  288. disconnectedCallback?: () => void;
  289. adoptedCallback?: () => void;
  290. attributeChangedCallback?: () => void;
  291. // [key: PropertyKey]: any;
  292. }
  293. /**
  294. * An interface for web components background data.
  295. *
  296. * @see https://github.com/thednp/bootstrap.native/blob/master/src/components/base-component.js
  297. */
  298. export declare const Data: {
  299. data: Map<string, Map<Element, unknown>>;
  300. /**
  301. * Sets web components data.
  302. *
  303. * @param element target element
  304. * @param component the component's name or a unique key
  305. * @param instance the component instance
  306. */
  307. set: <T>(element: Element, component: string, instance: T) => void;
  308. /**
  309. * Returns all instances for specified component.
  310. *
  311. * @param component the component's name or a unique key
  312. * @returns all the component instances
  313. */
  314. getAllFor: <T>(component: string) => Map<Element, T> | null;
  315. /**
  316. * Returns the instance associated with the target.
  317. *
  318. * @param element target element
  319. * @param component the component's name or a unique key
  320. * @returns the instance
  321. */
  322. get: <T>(element: Element, component: string) => T | null;
  323. /**
  324. * Removes web components data.
  325. *
  326. * @param element target element
  327. * @param component the component's name or a unique key
  328. */
  329. remove: <T>(element: Element, component: string) => void;
  330. };
  331. /**
  332. * Shortcut for the `Element.dispatchEvent(Event)` method.
  333. *
  334. * @param element is the target
  335. * @param event is the `Event` object
  336. */
  337. declare const dispatchEvent_2: (element: EventTarget, event: Event) => boolean;
  338. export { dispatchEvent_2 as dispatchEvent }
  339. /**
  340. * JavaScript `Array` distinct.
  341. *
  342. * @see https://codeburst.io/javascript-array-distinct-5edc93501dc4
  343. *
  344. * @example
  345. * ```
  346. * [0,1,1,2].filter(distinct)
  347. * // => [0,1,2]
  348. * ```
  349. * @param value array item value
  350. * @param index array item index
  351. * @param arr a clone of the target array
  352. * @returns the query result
  353. */
  354. export declare const distinct: <T>(value: T, index: number, arr: T[]) => boolean;
  355. /**
  356. * A global namespace for `document.body`.
  357. */
  358. export declare const documentBody: HTMLElement;
  359. /**
  360. * A global namespace for `document.documentElement` or the `<HTML>`.
  361. */
  362. export declare const documentElement: HTMLElement;
  363. /**
  364. * A global namespace for `document.head`.
  365. */
  366. export declare const documentHead: HTMLHeadElement;
  367. /**
  368. * A global namespace for `DOMContentLoaded` event.
  369. */
  370. export declare const DOMContentLoadedEvent = "DOMContentLoaded";
  371. /**
  372. * A global namespace for `DOMMouseScroll` event.
  373. */
  374. export declare const DOMMouseScrollEvent = "DOMMouseScroll";
  375. /**
  376. * A global namespace for `dragend` event.
  377. */
  378. export declare const dragendEvent = "dragend";
  379. /**
  380. * A global namespace for `dragenter` event.
  381. */
  382. export declare const dragenterEvent = "dragenter";
  383. /**
  384. * A global namespace for `drag` event.
  385. */
  386. export declare const dragEvent = "drag";
  387. declare interface DragEvent_2<T extends EventTarget = HTMLElement>
  388. extends MouseEvent_2<T, NativeDragEvent> {
  389. dataTransfer: DataTransfer;
  390. }
  391. export { DragEvent_2 as DragEvent }
  392. export declare type DragEventHandler<T extends EventTarget = HTMLElement> = EventHandler<
  393. T,
  394. DragEvent_2<T>
  395. >;
  396. /**
  397. * A global namespace for `dragleave` event.
  398. */
  399. export declare const dragleaveEvent = "dragleave";
  400. /**
  401. * A global namespace for `dragover` event.
  402. */
  403. export declare const dragoverEvent = "dragover";
  404. /**
  405. * A global namespace for `dragstart` event.
  406. */
  407. export declare const dragstartEvent = "dragstart";
  408. /**
  409. * Utility to make sure callbacks are consistently
  410. * called when animation ends.
  411. *
  412. * @param element target
  413. * @param handler `animationend` callback
  414. */
  415. export declare const emulateAnimationEnd: (element: Element, handler: EventListener) => void;
  416. /**
  417. * Utility to make sure callbacks are consistently
  418. * called when transition ends.
  419. *
  420. * @param element element target
  421. * @param handler `transitionend` callback
  422. */
  423. export declare const emulateTransitionEnd: (element: Element, handler: EventListener) => void;
  424. /**
  425. * A global namespace for `error` event.
  426. */
  427. export declare const errorEvent = "error";
  428. declare type EventHandler<
  429. T extends EventTarget = HTMLElement,
  430. E = Event | NativeEvent<T>,
  431. > = (event: E) => void;
  432. /**
  433. * Shortcut for `Float32Array.from()` static method.
  434. *
  435. * @param arr array-like iterable object
  436. * @returns a new Float32Array
  437. */
  438. export declare const Float32ArrayFrom: (arr: ArrayLike<number> | Iterable<number>) => Float32Array;
  439. /**
  440. * Shortcut for `Float64Array.from()` static method.
  441. *
  442. * @param arr array-like iterable object
  443. * @returns a new Float64Array
  444. */
  445. export declare const Float64ArrayFrom: (arr: ArrayLike<number> | Iterable<number>) => Float64Array;
  446. declare type Fn = (...args: unknown[]) => unknown;
  447. /**
  448. * Shortie for `HTMLOrSVGElement.focus()` method.
  449. *
  450. * @param element is the target
  451. * @param options allows to pass additional options such as `preventScroll: boolean`
  452. */
  453. declare const focus_2: (element: HTMLOrSVGElement, options?: FocusOptions) => void;
  454. export { focus_2 as focus }
  455. export declare type FocusableElement = HTMLAnchorElement | HTMLButtonElement | HTMLInputElement | HTMLTextAreaElement | HTMLDataListElement | HTMLDetailsElement | HTMLSelectElement;
  456. export declare const focusableSelector = "a[href], button, input, textarea, select, details, [tabindex]:not([tabindex=\"-1\"]";
  457. /**
  458. * A global namespace for `focus` event.
  459. */
  460. export declare const focusEvent = "focus";
  461. declare interface FocusEvent_2<
  462. T extends EventTarget = HTMLElement,
  463. R extends Element = HTMLElement,
  464. > extends NativeEvent<T, NativeFocusEvent> {
  465. relatedTarget: (EventTarget & R) | null;
  466. target: EventTarget & T;
  467. }
  468. export { FocusEvent_2 as FocusEvent }
  469. export declare type FocusEventHandler<T extends EventTarget = HTMLElement> = EventHandler<
  470. T,
  471. FocusEvent_2<T>
  472. >;
  473. /**
  474. * A global namespace for focus event names.
  475. */
  476. export declare const focusEvents: {
  477. in: string;
  478. out: string;
  479. };
  480. /**
  481. * A global namespace for `focusin` event.
  482. */
  483. export declare const focusinEvent = "focusin";
  484. /**
  485. * A global namespace for `focusout` event.
  486. */
  487. export declare const focusoutEvent = "focusout";
  488. declare type FormControl = HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement;
  489. export declare type FormEvent<T extends EventTarget = FormControl> = NativeEvent<T>;
  490. export declare type FormEventHandler<T extends EventTarget = HTMLElement> = EventHandler<
  491. T,
  492. FormEvent<T>
  493. >;
  494. /**
  495. * A global namespace for `gesturechange` event.
  496. */
  497. export declare const gesturechangeEvent = "gesturechange";
  498. /**
  499. * A global namespace for `gestureend` event.
  500. */
  501. export declare const gestureendEvent = "gestureend";
  502. /**
  503. * A global namespace for `gesturestart` event.
  504. */
  505. export declare const gesturestartEvent = "gesturestart";
  506. /**
  507. * Shortcut for `Element.getAttribute()` method.
  508. *
  509. * @param element target element
  510. * @param att attribute name
  511. * @returns attribute value
  512. */
  513. export declare const getAttribute: (element: Element, att: string) => string | null;
  514. /**
  515. * Shortcut for `Element.getAttributeNS()` method.
  516. *
  517. * @param ns attribute namespace
  518. * @param element target element
  519. * @param att attribute name
  520. * @returns attribute value
  521. */
  522. export declare const getAttributeNS: (ns: string, element: Element, att: string) => string | null;
  523. /**
  524. * Returns the bounding client rect of a target `Element`.
  525. *
  526. * @see https://github.com/floating-ui/floating-ui
  527. *
  528. * @param element event.target
  529. * @param includeScale when *true*, the target scale is also computed
  530. * @returns the bounding client rect object
  531. */
  532. export declare const getBoundingClientRect: (element: Element, includeScale?: boolean) => BoundingClientRect;
  533. /**
  534. * Returns an `Array` of `Node` elements that are registered as
  535. * `CustomElement`.
  536. *
  537. * @see https://stackoverflow.com/questions/27334365/how-to-get-list-of-registered-custom-elements
  538. *
  539. * @param parent parent to look into
  540. * @returns the query result
  541. */
  542. export declare const getCustomElements: (parent?: ParentNode) => CustomElement[];
  543. /**
  544. * Returns the `document` or the `#document` element.
  545. *
  546. * @see https://github.com/floating-ui/floating-ui
  547. *
  548. * @param node the reference node
  549. * @returns the parent document of the given node
  550. */
  551. export declare const getDocument: (node?: Node | Document | Window) => Document;
  552. /**
  553. * Returns the `document.body` or the `<body>` element.
  554. *
  555. * @param node the reference node
  556. * @returns the parent `<body>` of the specified node
  557. */
  558. export declare const getDocumentBody: (node?: Node | Document | Window) => HTMLElement;
  559. /**
  560. * Returns the `document.documentElement` or the `<HTML>` element.
  561. *
  562. * @param node the reference node
  563. * @returns the parent `<HTML>` of the node's parent document
  564. */
  565. export declare const getDocumentElement: (node?: Node | Document | Window) => HTMLElement;
  566. /**
  567. * Returns the `document.head` or the `<head>` element.
  568. *
  569. * @param node the reference node
  570. * @returns the `<head>` of the node's parent document
  571. */
  572. export declare const getDocumentHead: (node?: Node | Document | Window) => HTMLHeadElement;
  573. /**
  574. * Utility to get the computed `animationDelay`
  575. * from Element in miliseconds.
  576. *
  577. * @param element target
  578. * @return the `animationDelay` value in miliseconds
  579. */
  580. export declare const getElementAnimationDelay: (element: Element) => number;
  581. /**
  582. * Utility to get the computed `animationDuration`
  583. * from `Element` in miliseconds.
  584. *
  585. * @param element target
  586. * @return the `animationDuration` value in miliseconds
  587. */
  588. export declare const getElementAnimationDuration: (element: Element) => number;
  589. /**
  590. * Returns an `HTMLElement` that matches the id in the document.
  591. * Within multiple <iframe> elements, a `parent` parameter
  592. * would decisively locate the correct element.
  593. *
  594. * @param id the ID selector
  595. * @param context an element in it's document or document
  596. * @returns the requested element
  597. */
  598. export declare const getElementById: (id: string, context?: Node) => HTMLElement | null;
  599. /**
  600. * Shortcut for `Element.getElementsByClassName` method. Some `Node` elements
  601. * like `ShadowRoot` do not support `getElementsByClassName`.
  602. *
  603. * @param selector the class name
  604. * @param parent optional Element to look into
  605. * @return the 'HTMLCollection'
  606. */
  607. export declare const getElementsByClassName: <T extends Element>(selector: string, parent?: ParentNode) => HTMLCollectionOf<T>;
  608. /**
  609. * Shortcut for `Element.getElementsByTagName` method. Some `Node` elements
  610. * like `ShadowRoot` do not support `getElementsByTagName`.
  611. *
  612. * @param selector the tag name
  613. * @param parent optional Element to look into
  614. * @return the 'HTMLCollection'
  615. */
  616. export declare const getElementsByTagName: <T extends Element>(selector: string, parent?: ParentNode) => HTMLCollectionOf<T>;
  617. /**
  618. * Shortcut for `window.getComputedStyle(element).propertyName`
  619. * static method.
  620. *
  621. * * If `element` parameter is not an `Element`, `getComputedStyle`
  622. * throws a `ReferenceError`.
  623. *
  624. * @param element target `Element`
  625. * @param property the css property
  626. * @param pseudoElt pseudo-elements
  627. * @return the css property value
  628. */
  629. export declare const getElementStyle: (element: Element, property: string, pseudoElt?: string | null) => string;
  630. /**
  631. * Utility to get the computed `transitionDelay`
  632. * from Element in miliseconds.
  633. *
  634. * @param element target
  635. * @return the `transitionDelay` value in miliseconds
  636. */
  637. export declare const getElementTransitionDelay: (element: Element) => number;
  638. /**
  639. * Utility to get the computed `transitionDuration`
  640. * from Element in miliseconds.
  641. *
  642. * @param element target
  643. * @return the `transitionDuration` value in miliseconds
  644. */
  645. export declare const getElementTransitionDuration: (element: Element) => number;
  646. /**
  647. * An alias for `Data.get()`.
  648. */
  649. export declare const getInstance: <T>(target: Element, component: string) => T | null;
  650. /**
  651. * Returns the value of `node.nodeName` for the given node.
  652. * @param node target node
  653. * @returns the node name
  654. */
  655. export declare const getNodeName: (node: Node | Window) => string;
  656. /**
  657. * Returns an `{x, y}` object with the target
  658. * `Element` / `Node` scroll position.
  659. *
  660. * @see https://github.com/floating-ui/floating-ui
  661. *
  662. * @param element target node / element
  663. * @returns the scroll tuple
  664. */
  665. export declare const getNodeScroll: (element: Element | Window) => {
  666. x: number;
  667. y: number;
  668. };
  669. /**
  670. * Returns the `offsetParent` for a given target.
  671. *
  672. * @see https://github.com/floating-ui/floating-ui
  673. *
  674. * @param element the target node
  675. * @returns the offset parent node
  676. */
  677. export declare const getOffsetParent: (element: Element) => Element | Window;
  678. /**
  679. * Returns the `parentNode` also going through `ShadowRoot`.
  680. *
  681. * @see https://github.com/floating-ui/floating-ui
  682. *
  683. * @param node the target node
  684. * @returns the apropriate parent node
  685. */
  686. export declare const getParentNode: (node: Node) => ParentNode;
  687. /**
  688. * Returns the rect relative to a given offset parent and its scroll position.
  689. *
  690. * @see https://github.com/floating-ui/floating-ui
  691. *
  692. * @param element target
  693. * @param offsetParent the container / offset parent
  694. * @param scroll the offsetParent scroll position
  695. * @returns a DOMRect like object
  696. */
  697. export declare const getRectRelativeToOffsetParent: (element: Element, offsetParent: Element | Window, scroll: {
  698. x: number;
  699. y: number;
  700. }) => OffsetRect;
  701. /**
  702. * Returns a unique identifier for popover, tooltip, scrollspy.
  703. *
  704. * @param element target element
  705. * @param key optional identifier key
  706. * @returns an existing or new unique ID
  707. */
  708. export declare const getUID: (element: Element, key?: string) => number;
  709. /**
  710. * Returns the `Window` object of a target node.
  711. *
  712. * @see https://github.com/floating-ui/floating-ui
  713. *
  714. * @param node target node
  715. * @returns the `Window` object
  716. */
  717. export declare const getWindow: (node?: Node) => Window;
  718. export declare function handleKeyboardNavigation<T extends Element & EventTarget>(this: T, event: KeyboardEvent_2<T>): void;
  719. /**
  720. * Shortcut for `Element.hasAttribute()` method.
  721. *
  722. * @param element target element
  723. * @param att attribute name
  724. * @returns the query result
  725. */
  726. export declare const hasAttribute: (element: Element, att: string) => boolean;
  727. /**
  728. * Shortcut for `Element.hasAttributeNS()` method.
  729. *
  730. * @param ns attribute namespace
  731. * @param element target element
  732. * @param att attribute name
  733. * @returns the query result
  734. */
  735. export declare const hasAttributeNS: (ns: string, element: Element, att: string) => boolean;
  736. /**
  737. * Check class in `Element.classList`.
  738. *
  739. * @param element target
  740. * @param classNAME to check
  741. */
  742. export declare const hasClass: (element: Element, classNAME: string) => boolean;
  743. /**
  744. * Utility to check if a designated element is affected by focus trap;
  745. * @param target
  746. */
  747. export declare const hasFocusTrap: (target: Element) => boolean;
  748. /**
  749. * An accessor that checks for Apple browsers.
  750. */
  751. export declare const isApple: () => boolean;
  752. /**
  753. * Shortie for the `Array.isArray()` static method.
  754. *
  755. * @param obj array-like iterable object
  756. * @returns the query result
  757. */
  758. export declare const isArray: (obj?: unknown) => obj is unknown[];
  759. /**
  760. * Checks if an element is an `HTMLCanvasElement` or `<canvas>`.
  761. *
  762. * @param element the target element
  763. * @returns the query result
  764. */
  765. export declare const isCanvas: (element?: unknown) => element is HTMLCanvasElement;
  766. /**
  767. * Checks if an object is a `CustomElement`.
  768. *
  769. * @param element the target object
  770. * @returns the query result
  771. */
  772. export declare const isCustomElement: <T extends CustomElement>(element?: unknown) => element is T;
  773. /**
  774. * Checks if an object is a `Document`.
  775. *
  776. * @see https://dom.spec.whatwg.org/#node
  777. *
  778. * @param obj the target object
  779. * @returns the query result
  780. */
  781. export declare const isDocument: (obj?: unknown) => obj is Document;
  782. /**
  783. * Checks if an object is an `Element`.
  784. *
  785. * @param element the target object
  786. * @returns the query result
  787. */
  788. export declare const isElement: (element?: unknown) => element is Element;
  789. /**
  790. * Utility to determine if an `Element`
  791. * is partially visible in viewport.
  792. *
  793. * @param element target
  794. * @return the query result
  795. */
  796. export declare const isElementInScrollRange: (element?: Element) => boolean;
  797. /**
  798. * Utility to determine if an `Element`
  799. * is fully visible in the viewport.
  800. *
  801. * @param element target
  802. * @return the query result
  803. */
  804. export declare const isElementInViewport: (element?: Element) => boolean;
  805. /**
  806. * Checks if an object is an `Array` in which all items are `Element`.
  807. *
  808. * @param obj the target object
  809. * @returns the query result
  810. */
  811. export declare const isElementsArray: (obj?: unknown) => obj is Element[];
  812. /**
  813. * An accessor that checks for Gecko browsers. When writing this file,
  814. * Gecko was not supporting `userAgentData`.
  815. */
  816. export declare const isFirefox: () => boolean;
  817. /**
  818. * Checks if an object is a `Function`.
  819. *
  820. * @param fn the target object
  821. * @returns the query result
  822. */
  823. export declare const isFunction: (fn?: unknown) => fn is Fn;
  824. /**
  825. * Checks if an object is an `HTMLCollection`.
  826. *
  827. * @param obj the target object
  828. * @returns the query result
  829. */
  830. export declare const isHTMLCollection: (obj?: unknown) => obj is HTMLCollection;
  831. /**
  832. * Checks if an element is an `HTMLElement`.
  833. *
  834. * @see https://dom.spec.whatwg.org/#node
  835. *
  836. * @param element the target object
  837. * @returns the query result
  838. */
  839. export declare const isHTMLElement: (element?: unknown) => element is HTMLElement;
  840. /**
  841. * Check if a target element is an `<img>`.
  842. *
  843. * @param element the target element
  844. * @returns the query result
  845. */
  846. export declare const isHTMLImageElement: (element?: unknown) => element is HTMLImageElement;
  847. /**
  848. * Checks if a string is a `JSON` string.
  849. *
  850. * @param str the target string
  851. * @returns the query result
  852. */
  853. export declare const isJSON: (str?: string) => boolean;
  854. /**
  855. * Checks if an element is a `Map`.
  856. *
  857. * @param obj the target object
  858. * @returns the query result
  859. */
  860. export declare const isMap: (obj?: unknown) => obj is Map<unknown, unknown>;
  861. /**
  862. * Checks if an element is an `<svg>` (or any type of SVG element),
  863. * `<img>`, `<video>` or `<canvas>`.
  864. *
  865. * *Tooltip* / *Popover* works different with media elements.
  866. *
  867. * @param element the target element
  868. * @returns the query result
  869. */
  870. export declare const isMedia: (element?: unknown) => element is SVGElement | HTMLImageElement | HTMLVideoElement | HTMLCanvasElement;
  871. /**
  872. * An accessor that checks for mobile detection.
  873. */
  874. export declare const isMobile: () => boolean;
  875. /**
  876. * Checks if an object is a `Node`.
  877. *
  878. * @param node the target object
  879. * @see https://dom.spec.whatwg.org/#node
  880. *
  881. * ```
  882. * ELEMENT_NODE = 1;
  883. * ATTRIBUTE_NODE = 2;
  884. * TEXT_NODE = 3;
  885. * CDATA_SECTION_NODE = 4;
  886. * ENTITY_REFERENCE_NODE = 5; // legacy
  887. * ENTITY_NODE = 6; // legacy
  888. * PROCESSING_INSTRUCTION_NODE = 7;
  889. * COMMENT_NODE = 8;
  890. * DOCUMENT_NODE = 9;
  891. * DOCUMENT_TYPE_NODE = 10;
  892. * DOCUMENT_FRAGMENT_NODE = 11;
  893. * @returns the query result
  894. */
  895. export declare const isNode: (node?: unknown) => node is Node;
  896. /**
  897. * Checks if an object is a `NodeList`.
  898. * => equivalent to `object instanceof NodeList`
  899. *
  900. * @param obj the target object
  901. * @returns the query result
  902. */
  903. export declare const isNodeList: (obj?: unknown) => obj is NodeList;
  904. /**
  905. * Shortie for `typeof SOMETHING === "number"`.
  906. *
  907. * @param num input value
  908. * @returns the query result
  909. */
  910. export declare const isNumber: (num?: unknown) => num is number;
  911. /**
  912. * Checks if a value is an `Object`.
  913. *
  914. * @param obj the target object
  915. * @returns the query result
  916. */
  917. export declare const isObject: (obj?: unknown) => obj is object;
  918. /**
  919. * Checks if a page is Right To Left.
  920. *
  921. * @param node the target
  922. * @returns the query result
  923. */
  924. export declare const isRTL: (node?: Node) => boolean;
  925. /**
  926. * Checks if a target `Element` is affected by scale.
  927. *
  928. * @see https://github.com/floating-ui/floating-ui
  929. *
  930. * @param element target
  931. * @returns the query result
  932. */
  933. export declare const isScaledElement: (element?: Element) => boolean;
  934. /**
  935. * Check if target is a `ShadowRoot`.
  936. *
  937. * @param element target
  938. * @returns the query result
  939. */
  940. export declare const isShadowRoot: (element?: unknown) => element is ShadowRoot;
  941. /**
  942. * Shortie for `typeof SOMETHING === "string"`.
  943. *
  944. * @param str input value
  945. * @returns the query result
  946. */
  947. export declare const isString: (str?: unknown) => str is string;
  948. /**
  949. * Check if an element is an `<svg>` or any other SVG element,
  950. * an equivalent to `SOMETHING instanceof SVGElement`.
  951. *
  952. * @param element the target element
  953. * @returns the query result
  954. */
  955. export declare const isSVGElement: (element?: unknown) => element is SVGElement;
  956. /**
  957. * Check if a target element is a `<table>`, `<td>` or `<th>`.
  958. * This specific check is important for determining
  959. * the `offsetParent` of a given element.
  960. *
  961. * @param element the target element
  962. * @returns the query result
  963. */
  964. export declare const isTableElement: (element?: unknown) => element is HTMLTableElement | HTMLTableCellElement;
  965. /**
  966. * Checks if an element is a `WeakMap`.
  967. *
  968. * @param obj the target object
  969. * @returns the query result
  970. */
  971. export declare const isWeakMap: (obj?: unknown) => obj is WeakMap<WeakKey, unknown>;
  972. export declare const isWebKit: () => boolean;
  973. /**
  974. * Check if a target object is `Window`.
  975. * => equivalent to `object instanceof Window`
  976. *
  977. * @param obj the target object
  978. * @returns the query result
  979. */
  980. export declare const isWindow: (obj?: unknown) => obj is Window;
  981. /**
  982. * Transform a string to kebab case.
  983. * @param input source string
  984. */
  985. export declare const kebabCase: (input: string) => string;
  986. /**
  987. * A global namespace for `Alt` key.
  988. * e.which = 18
  989. */
  990. export declare const keyAlt = "Alt";
  991. /**
  992. * A global namespace for `ArrowDown` key.
  993. * e.which = 40 equivalent
  994. */
  995. export declare const keyArrowDown = "ArrowDown";
  996. /**
  997. * A global namespace for `ArrowLeft` key.
  998. * e.which = 37 equivalent
  999. */
  1000. export declare const keyArrowLeft = "ArrowLeft";
  1001. /**
  1002. * A global namespace for `ArrowRight` key.
  1003. * e.which = 39 equivalent
  1004. */
  1005. export declare const keyArrowRight = "ArrowRight";
  1006. /**
  1007. * A global namespace for `ArrowUp` key.
  1008. * e.which = 38 equivalent
  1009. */
  1010. export declare const keyArrowUp = "ArrowUp";
  1011. /**
  1012. * A global namespace for `Backspace` key.
  1013. * e.which === 8 equivalent
  1014. */
  1015. export declare const keyBackspace = "Backspace";
  1016. declare interface KeyboardEvent_2<T extends EventTarget = HTMLElement>
  1017. extends UIEvent_2<T, NativeKeyboardEvent> {
  1018. altKey: boolean;
  1019. /** @deprecated */
  1020. charCode: number;
  1021. ctrlKey: boolean;
  1022. code: string;
  1023. /**
  1024. * See [DOM Level 3 Events spec](https://www.w3.org/TR/uievents-key/#keys-modifier). for a list of valid (case-sensitive) arguments to this method.
  1025. */
  1026. getModifierState(key: ModifierKey): boolean;
  1027. /**
  1028. * See the [DOM Level 3 Events spec](https://www.w3.org/TR/uievents-key/#named-key-attribute-values). for possible values
  1029. */
  1030. key: string;
  1031. /** @deprecated */
  1032. keyCode: number;
  1033. locale: string;
  1034. location: number;
  1035. metaKey: boolean;
  1036. repeat: boolean;
  1037. shiftKey: boolean;
  1038. /** @deprecated */
  1039. which: number;
  1040. }
  1041. export { KeyboardEvent_2 as KeyboardEvent }
  1042. export declare type KeyboardEventHandler<T extends EventTarget = HTMLElement> = EventHandler<
  1043. T,
  1044. KeyboardEvent_2<T>
  1045. >;
  1046. /**
  1047. * A global namespace for keyboard event keys.
  1048. */
  1049. export declare const keyboardEventKeys: {
  1050. Backspace: string;
  1051. Tab: string;
  1052. Enter: string;
  1053. Shift: string;
  1054. Control: string;
  1055. Alt: string;
  1056. Pause: string;
  1057. CapsLock: string;
  1058. Escape: string;
  1059. Scape: string;
  1060. ArrowLeft: string;
  1061. ArrowUp: string;
  1062. ArrowRight: string;
  1063. ArrowDown: string;
  1064. Insert: string;
  1065. Delete: string;
  1066. Meta: string;
  1067. ContextMenu: string;
  1068. ScrollLock: string;
  1069. };
  1070. /**
  1071. * A global namespace for `CapsLock` key.
  1072. * e.which = 20 equivalent
  1073. */
  1074. export declare const keyCapsLock = "CapsLock";
  1075. /**
  1076. * A global namespace for `Control` key.
  1077. * e.which = 17
  1078. */
  1079. export declare const keyControl = "Control";
  1080. /**
  1081. * A global namespace for `Delete` key.
  1082. * e.which = 46 equivalent
  1083. */
  1084. export declare const keyDelete = "Delete";
  1085. /**
  1086. * A global namespace for `keydown` event.
  1087. */
  1088. export declare const keydownEvent = "keydown";
  1089. /**
  1090. * A global namespace for `Enter` key.
  1091. * e.which = 13 equivalent
  1092. */
  1093. export declare const keyEnter = "Enter";
  1094. /**
  1095. * A global namespace for `Escape` key.
  1096. * e.which = 27 equivalent
  1097. */
  1098. export declare const keyEscape = "Escape";
  1099. /**
  1100. * A global namespace for `Insert` key.
  1101. * e.which = 45 equivalent
  1102. */
  1103. export declare const keyInsert = "Insert";
  1104. /**
  1105. * A global namespace for `Meta` key.
  1106. * e.which = 93 equivalent
  1107. */
  1108. export declare const keyMeta = "Meta";
  1109. /**
  1110. * A global namespace for `Enter` key.
  1111. * e.which = 13 equivalent
  1112. */
  1113. export declare const keyNumpadEnter = "NumpadEnter";
  1114. /**
  1115. * A global namespace for `Pause` key.
  1116. * e.which = 19
  1117. */
  1118. export declare const keyPause = "Pause";
  1119. /**
  1120. * A global namespace for `keypress` event.
  1121. */
  1122. export declare const keypressEvent = "keypress";
  1123. /**
  1124. * A global namespace for `ScrollLock` key.
  1125. * e.which = 145 equivalent
  1126. */
  1127. export declare const keyScrollLock = "ScrollLock";
  1128. /**
  1129. * A global namespace for `Shift` key.
  1130. * e.which = 16
  1131. */
  1132. export declare const keyShift = "Shift";
  1133. /**
  1134. * A global namespace for `Space` key.
  1135. * e.which = 32 equivalent
  1136. */
  1137. export declare const keySpace = "Space";
  1138. /**
  1139. * A global namespace for `Tab` key.
  1140. * e.which = 9 equivalent
  1141. */
  1142. export declare const keyTab = "Tab";
  1143. /**
  1144. * A global namespace for `keyup` event.
  1145. */
  1146. export declare const keyupEvent = "keyup";
  1147. /**
  1148. * A global namespace for `load` event.
  1149. */
  1150. export declare const loadEvent = "load";
  1151. /**
  1152. * A global namespace for `loadstart` event.
  1153. */
  1154. export declare const loadstartEvent = "loadstart";
  1155. /**
  1156. * Check if element matches a CSS selector.
  1157. *
  1158. * @param target the target element
  1159. * @param selector the selector to match
  1160. * @returns the query result
  1161. */
  1162. export declare const matches: (target: Element, selector: string) => boolean;
  1163. declare type ModifierKey =
  1164. | "Alt"
  1165. | "AltGraph"
  1166. | "CapsLock"
  1167. | "Control"
  1168. | "Fn"
  1169. | "FnLock"
  1170. | "Hyper"
  1171. | "Meta"
  1172. | "NumLock"
  1173. | "ScrollLock"
  1174. | "Shift"
  1175. | "Super"
  1176. | "Symbol"
  1177. | "SymbolLock";
  1178. /**
  1179. * A global namespace for `click` event.
  1180. */
  1181. export declare const mouseclickEvent = "click";
  1182. /**
  1183. * A global namespace for mouse click events.
  1184. */
  1185. export declare const mouseClickEvents: {
  1186. down: string;
  1187. up: string;
  1188. };
  1189. /**
  1190. * A global namespace for `dblclick` event.
  1191. */
  1192. export declare const mousedblclickEvent = "dblclick";
  1193. /**
  1194. * A global namespace for `mousedown` event.
  1195. */
  1196. export declare const mousedownEvent = "mousedown";
  1197. /**
  1198. * A global namespace for `mouseenter` event.
  1199. */
  1200. export declare const mouseenterEvent = "mouseenter";
  1201. declare interface MouseEvent_2<T extends EventTarget = HTMLElement, E = NativeMouseEvent>
  1202. extends UIEvent_2<T, E> {
  1203. altKey: boolean;
  1204. button: number;
  1205. buttons: number;
  1206. clientX: number;
  1207. clientY: number;
  1208. ctrlKey: boolean;
  1209. /**
  1210. * See [DOM Level 3 Events spec](https://www.w3.org/TR/uievents-key/#keys-modifier). for a list of valid (case-sensitive) arguments to this method.
  1211. */
  1212. getModifierState(key: ModifierKey): boolean;
  1213. metaKey: boolean;
  1214. movementX: number;
  1215. movementY: number;
  1216. pageX: number;
  1217. pageY: number;
  1218. relatedTarget: EventTarget | null;
  1219. screenX: number;
  1220. screenY: number;
  1221. shiftKey: boolean;
  1222. }
  1223. export { MouseEvent_2 as MouseEvent }
  1224. export declare type MouseEventHandler<T extends EventTarget = HTMLElement> = EventHandler<
  1225. T,
  1226. MouseEvent_2<T>
  1227. >;
  1228. /**
  1229. * A global namespace for `hover` event.
  1230. */
  1231. export declare const mousehoverEvent = "hover";
  1232. /**
  1233. * A global namespace for mouse hover events.
  1234. */
  1235. export declare const mouseHoverEvents: string[];
  1236. /**
  1237. * A global namespace for `mousein` event.
  1238. */
  1239. export declare const mouseinEvent = "mousein";
  1240. /**
  1241. * A global namespace for `mouseleave` event.
  1242. */
  1243. export declare const mouseleaveEvent = "mouseleave";
  1244. /**
  1245. * A global namespace for `mousemove` event.
  1246. */
  1247. export declare const mousemoveEvent = "mousemove";
  1248. /**
  1249. * A global namespace for `mouseout` event.
  1250. */
  1251. export declare const mouseoutEvent = "mouseout";
  1252. /**
  1253. * A global namespace for `mouseover` event.
  1254. */
  1255. export declare const mouseoverEvent = "mouseover";
  1256. /**
  1257. * A global namespace for mouse events equivalent to touch events.
  1258. */
  1259. export declare const mouseSwipeEvents: {
  1260. start: string;
  1261. end: string;
  1262. move: string;
  1263. cancel: string;
  1264. };
  1265. /**
  1266. * A global namespace for `mouseup` event.
  1267. */
  1268. export declare const mouseupEvent = "mouseup";
  1269. /**
  1270. * A global namespace for `mousewheel` event.
  1271. */
  1272. export declare const mousewheelEvent = "mousewheel";
  1273. /**
  1274. * A global namespace for `move` event.
  1275. */
  1276. export declare const moveEvent = "move";
  1277. /**
  1278. * Type definitions addapted from React 18.2
  1279. * Project: https://react.dev/
  1280. */
  1281. declare type NativeAnimationEvent = AnimationEvent_2;
  1282. declare type NativeClipboardEvent = ClipboardEvent_2;
  1283. declare type NativeCompositionEvent = CompositionEvent_2;
  1284. declare type NativeDragEvent = DragEvent_2;
  1285. /**
  1286. * currentTarget - a reference to the element on which the event listener is registered.
  1287. *
  1288. * target - a reference to the element from which the event was originally dispatched.
  1289. * This might be a child element to the element on which the event listener is registered.
  1290. * If you thought this should be `EventTarget & T`, see https://github.com/DefinitelyTyped/DefinitelyTyped/issues/11508#issuecomment-256045682
  1291. */
  1292. export declare type NativeEvent<T extends EventTarget = HTMLElement, E = Event> = BaseEvent<
  1293. E,
  1294. T,
  1295. T
  1296. >;
  1297. export declare type NativeEventHandler<T extends EventTarget = HTMLElement> = EventHandler<
  1298. T,
  1299. NativeEvent<T>
  1300. >;
  1301. /**
  1302. * A global namespace for all browser native events.
  1303. */
  1304. export declare const nativeEvents: {
  1305. DOMContentLoaded: string;
  1306. DOMMouseScroll: string;
  1307. abort: string;
  1308. beforeunload: string;
  1309. blur: string;
  1310. change: string;
  1311. click: string;
  1312. contextmenu: string;
  1313. dblclick: string;
  1314. error: string;
  1315. focus: string;
  1316. focusin: string;
  1317. focusout: string;
  1318. gesturechange: string;
  1319. gestureend: string;
  1320. gesturestart: string;
  1321. hover: string;
  1322. keydown: string;
  1323. keypress: string;
  1324. keyup: string;
  1325. load: string;
  1326. mousedown: string;
  1327. mousemove: string;
  1328. mousein: string;
  1329. mouseout: string;
  1330. mouseenter: string;
  1331. mouseleave: string;
  1332. mouseover: string;
  1333. mouseup: string;
  1334. mousewheel: string;
  1335. move: string;
  1336. orientationchange: string;
  1337. pointercancel: string;
  1338. pointerdown: string;
  1339. pointerleave: string;
  1340. pointermove: string;
  1341. pointerup: string;
  1342. readystatechange: string;
  1343. reset: string;
  1344. resize: string;
  1345. scroll: string;
  1346. select: string;
  1347. selectend: string;
  1348. selectstart: string;
  1349. submit: string;
  1350. touchcancel: string;
  1351. touchend: string;
  1352. touchmove: string;
  1353. touchstart: string;
  1354. unload: string;
  1355. };
  1356. declare type NativeFocusEvent = FocusEvent_2;
  1357. declare type NativeKeyboardEvent = KeyboardEvent_2;
  1358. declare type NativeMouseEvent = MouseEvent_2;
  1359. declare type NativePointerEvent = PointerEvent_2;
  1360. declare type NativeTouchEvent = TouchEvent_2;
  1361. declare type NativeTransitionEvent = TransitionEvent_2;
  1362. declare type NativeUIEvent = UIEvent_2;
  1363. declare type NativeWheelEvent = WheelEvent_2;
  1364. export declare interface NavigatorUA extends Navigator {
  1365. readonly userAgentData: NavigatorUAData;
  1366. }
  1367. export declare interface NavigatorUABrand {
  1368. readonly brand: string;
  1369. readonly version: string;
  1370. }
  1371. export declare interface NavigatorUAData {
  1372. readonly brands: NavigatorUABrand[];
  1373. readonly mobile: boolean;
  1374. readonly platform: string;
  1375. }
  1376. /** A generic function with empty body. */
  1377. export declare const noop: () => void;
  1378. /**
  1379. * Utility to normalize component options.
  1380. *
  1381. * @param element target
  1382. * @param defaultOps component default options
  1383. * @param inputOps component instance options
  1384. * @param ns component namespace
  1385. * @return normalized component options object
  1386. */
  1387. export declare const normalizeOptions: <T extends {
  1388. [key: string]: unknown;
  1389. }>(element: Element, defaultOps: T, inputOps: Partial<T>, ns?: string) => T;
  1390. /**
  1391. * Utility to normalize component options
  1392. *
  1393. * @param value the input value
  1394. * @return the normalized value
  1395. */
  1396. export declare const normalizeValue: (value?: unknown) => NormalValue;
  1397. declare type NormalValue = boolean | number | string | Fn | null;
  1398. /**
  1399. * Shortcut for `Object.assign()` static method.
  1400. *
  1401. * @param obj a target object
  1402. * @param source source object(s)
  1403. * @see https://github.com/devinrhode2/ObjectTyped/blob/master/src/index.ts
  1404. */
  1405. export declare const ObjectAssign: typeof ObjectAssignTyped;
  1406. /**
  1407. * Overloads for Object.assign.
  1408. *
  1409. * @see https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/object-assign/index.d.ts
  1410. */
  1411. declare function ObjectAssignTyped<T, U>(target: T, source: U): T & U;
  1412. declare function ObjectAssignTyped<T, U, V>(target: T, source1: U, source2: V): T & U & V;
  1413. declare function ObjectAssignTyped<T, U, V, W>(target: T, source1: U, source2: V, source3: W): T & U & V & W;
  1414. declare function ObjectAssignTyped<T, U, V, W, Q>(target: T, source1: U, source2: V, source3: W, source4: Q): T & U & V & W & Q;
  1415. declare function ObjectAssignTyped<T, U, V, W, Q, R>(target: T, source1: U, source2: V, source3: W, source4: Q, source5: R): T & U & V & W & Q & R;
  1416. declare function ObjectAssignTyped(target: unknown, ...sources: unknown[]): unknown;
  1417. /**
  1418. * Shortcut for `Object.entries()` static method.
  1419. *
  1420. * @param obj a target object
  1421. * @returns the entries of an object in an array format [key, value][]
  1422. * @see https://github.com/devinrhode2/ObjectTyped/blob/master/src/index.ts
  1423. */
  1424. export declare const ObjectEntries: <O extends Record<keyof O, unknown>>(obj: O) => [keyof O, O[keyof O]][];
  1425. /**
  1426. * Shortcut for `Object.fromEntries()` static method.
  1427. *
  1428. * @param entries a target entries object
  1429. * @returns a new Object created from the specified entries in array format [key, value][]
  1430. * @see https://github.com/devinrhode2/ObjectTyped/blob/master/src/index.ts
  1431. */
  1432. export declare const ObjectFromEntries: <K extends string, V>(entries: [K, V][]) => Record<K, V>;
  1433. /**
  1434. * A shortcut to `Object.hasOwn()` static method to work
  1435. * with regular `Object` elements.
  1436. *
  1437. * @see https://fettblog.eu/typescript-hasownproperty/
  1438. * @param obj the target object
  1439. * @param prop the property to check
  1440. * @returns the query result
  1441. */
  1442. export declare const ObjectHasOwn: <T extends object, K extends PropertyKey>(obj: T, prop: K) => obj is T & Record<K, unknown>;
  1443. /**
  1444. * Shortcut for `Object.keys()` static method.
  1445. *
  1446. * @param obj a target object
  1447. * @returns an array with object keys
  1448. * @see https://github.com/devinrhode2/ObjectTyped/blob/master/src/index.ts
  1449. */
  1450. export declare const ObjectKeys: <O extends Record<keyof O, unknown>>(obj: O) => (keyof O)[];
  1451. /**
  1452. * Shortcut for `Object.values()` static method.
  1453. *
  1454. * @param obj a target object
  1455. * @returns an array with the object values
  1456. * @see https://github.com/devinrhode2/ObjectTyped/blob/master/src/index.ts
  1457. */
  1458. export declare const ObjectValues: <O extends Record<string, unknown>>(obj: O) => O[keyof O][];
  1459. /**
  1460. * Remove eventListener from an `EventTarget` object.
  1461. */
  1462. export declare const off: <T extends EventTarget, L = EventListener>(element: T, eventName: string, listener: L, options?: AddEventListenerOptions) => void;
  1463. /**
  1464. * A global namespace for `offsetHeight` property.
  1465. */
  1466. export declare const offsetHeight = "offsetHeight";
  1467. export declare interface OffsetRect {
  1468. width: number;
  1469. height: number;
  1470. x: number;
  1471. y: number;
  1472. }
  1473. /**
  1474. * A global namespace for `offsetWidth` property.
  1475. */
  1476. export declare const offsetWidth = "offsetWidth";
  1477. /**
  1478. * Add eventListener to an `EventTarget` object.
  1479. */
  1480. export declare const on: <T extends EventTarget, L = EventListener>(element: T, eventName: string, listener: L, options?: AddEventListenerOptions) => void;
  1481. /**
  1482. * Add an `eventListener` to an `EventTarget`
  1483. * element and remove it once callback is called.
  1484. */
  1485. export declare const one: <T extends EventTarget, L = EventListener>(element: T, eventName: string, listener: L, options?: AddEventListenerOptions) => void;
  1486. /**
  1487. * A global namespace for `orientationchange` event.
  1488. */
  1489. export declare const orientationchangeEvent = "orientationchange";
  1490. export declare interface OriginalEvent extends CustomEvent<unknown> {
  1491. readonly type: string;
  1492. relatedTarget?: EventTarget & HTMLElement;
  1493. }
  1494. /**
  1495. * A global namespace for most scroll event listeners.
  1496. */
  1497. export declare const passiveHandler: Partial<AddEventListenerOptions>;
  1498. /**
  1499. * A global namespace for `pointercancel` event.
  1500. */
  1501. export declare const pointercancelEvent = "pointercancel";
  1502. /**
  1503. * A global namespace for `pointerdown` event.
  1504. */
  1505. export declare const pointerdownEvent = "pointerdown";
  1506. declare interface PointerEvent_2<T extends EventTarget = HTMLElement>
  1507. extends MouseEvent_2<T, NativePointerEvent> {
  1508. pointerId: number;
  1509. pressure: number;
  1510. tangentialPressure: number;
  1511. tiltX: number;
  1512. tiltY: number;
  1513. twist: number;
  1514. width: number;
  1515. height: number;
  1516. pointerType: "mouse" | "pen" | "touch";
  1517. isPrimary: boolean;
  1518. }
  1519. export { PointerEvent_2 as PointerEvent }
  1520. export declare type PointerEventHandler<T extends EventTarget = HTMLElement> = EventHandler<
  1521. T,
  1522. PointerEvent_2<T>
  1523. >;
  1524. /**
  1525. * A global namespace for `pointerleave` event.
  1526. */
  1527. export declare const pointerleaveEvent = "pointerleave";
  1528. /**
  1529. * A global namespace for `pointermove` event.
  1530. */
  1531. export declare const pointermoveEvent = "pointermove";
  1532. /**
  1533. * A global namespace for `pointerup` event.
  1534. */
  1535. export declare const pointerupEvent = "pointerup";
  1536. export declare type PossibleEventTarget = EventTarget & (Element | Document | Window);
  1537. /**
  1538. * Utility to check if target is typeof `Element`, `Node`
  1539. * or find one that matches a selector.
  1540. *
  1541. * @param selector the input selector or target element
  1542. * @param parent optional node to look into
  1543. * @return the `Element` or null
  1544. */
  1545. export declare const querySelector: <T extends Element>(selector: T | string, parent?: ParentNode) => T | null;
  1546. /**
  1547. * A shortcut for `(document|Element).querySelectorAll`.
  1548. *
  1549. * @param selector the input selector
  1550. * @param parent optional node to look into
  1551. * @return the query result
  1552. */
  1553. export declare const querySelectorAll: <T extends Element>(selector: string, parent?: ParentNode) => NodeListOf<T>;
  1554. /**
  1555. * A global namespace for `readystatechange` event.
  1556. */
  1557. export declare const readystatechangeEvent = "readystatechange";
  1558. /**
  1559. * Utility to force re-paint of an `HTMLElement` target.
  1560. *
  1561. * @param element is the target
  1562. * @return the `Element.offsetHeight` value
  1563. */
  1564. export declare const reflow: (element: HTMLElement) => number;
  1565. /**
  1566. * Shortcut for `Element.removeAttribute()` method.
  1567. *
  1568. * @param element target element
  1569. * @param att attribute name
  1570. */
  1571. export declare const removeAttribute: (element: Element, att: string) => void;
  1572. /**
  1573. * Shortcut for `Element.removeAttributeNS()` method.
  1574. *
  1575. * @param ns attribute namespace
  1576. * @param element target element
  1577. * @param att attribute name
  1578. */
  1579. export declare const removeAttributeNS: (ns: string, element: Element, att: string) => void;
  1580. /**
  1581. * Remove one or more classes from `Element.classList`.
  1582. *
  1583. * @param element target
  1584. * @param classNAME to remove
  1585. */
  1586. export declare const removeClass: (element: Element, ...classNAME: string[]) => void;
  1587. /**
  1588. * A global namespace for 'removeEventListener' string.
  1589. */
  1590. declare const removeEventListener_2 = "removeEventListener";
  1591. export { removeEventListener_2 as removeEventListener }
  1592. /**
  1593. * Utility to remove focus trap inside a designated target element;
  1594. * @param target
  1595. */
  1596. export declare const removeFocusTrap: (target: Element) => void;
  1597. /**
  1598. * A global namespace for `reset` event.
  1599. */
  1600. export declare const resetEvent = "reset";
  1601. /**
  1602. * A global namespace for `resize` event.
  1603. */
  1604. export declare const resizeEvent = "resize";
  1605. /**
  1606. * A global namespace for `scroll` event.
  1607. */
  1608. export declare const scrollEvent = "scroll";
  1609. /**
  1610. * A global namespace for `scrollHeight` property.
  1611. */
  1612. export declare const scrollHeight = "scrollHeight";
  1613. /**
  1614. * A global namespace for `scrollWidth` property.
  1615. */
  1616. export declare const scrollWidth = "scrollWidth";
  1617. /**
  1618. * A global namespace for the `selectend` event.
  1619. */
  1620. export declare const selectendEvent = "selectend";
  1621. /**
  1622. * A global namespace for `select` event.
  1623. */
  1624. export declare const selectEvent = "select";
  1625. /**
  1626. * A global namespace for the `selectstart` event.
  1627. */
  1628. export declare const selectstartEvent = "selectstart";
  1629. /**
  1630. * Shortcut for `Element.setAttribute()` method.
  1631. *
  1632. * @param element target element
  1633. * @param att attribute name
  1634. * @param value attribute value
  1635. */
  1636. export declare const setAttribute: (element: Element, att: string, value: string) => void;
  1637. /**
  1638. * Shortcut for `Element.setAttributeNS()` method.
  1639. *
  1640. * @param ns attribute namespace
  1641. * @param element target element
  1642. * @param att attribute name
  1643. * @param value attribute value
  1644. */
  1645. export declare const setAttributeNS: (ns: string, element: Element, att: string, value: string) => void;
  1646. /**
  1647. * Shortcut for multiple uses of `HTMLElement.style.propertyName` method.
  1648. *
  1649. * @param element target element
  1650. * @param styles attribute value
  1651. */
  1652. export declare const setElementStyle: (element: Element, styles: Partial<CSS4Declaration>) => void;
  1653. /**
  1654. * A global namespace for `submit` event.
  1655. */
  1656. export declare const submitEvent = "submit";
  1657. /**
  1658. * An accessor that checks for CSS3 3D transform support.
  1659. */
  1660. export declare const support3DTransform: () => boolean;
  1661. /**
  1662. * An accessor that checks for CSS3 animation support.
  1663. */
  1664. export declare const supportAnimation: () => boolean;
  1665. /**
  1666. * An accessor that checks for passive events support,
  1667. * in general event options are not suited for scroll prevention.
  1668. *
  1669. * @see https://github.com/WICG/EventListenerOptions/blob/gh-pages/explainer.md#feature-detection
  1670. */
  1671. export declare const supportPassive: () => boolean;
  1672. /**
  1673. * An accessor that checks for touch events support.
  1674. */
  1675. export declare const supportTouch: () => boolean;
  1676. /**
  1677. * An accessor that checks for CSS3 transform support.
  1678. */
  1679. export declare const supportTransform: () => boolean;
  1680. /**
  1681. * An accessor that checks for CSS3 transition support.
  1682. */
  1683. export declare const supportTransition: () => boolean;
  1684. /**
  1685. * A global namespace for `touchcancel` event.
  1686. */
  1687. export declare const tabindex = "tabindex";
  1688. /**
  1689. * An interface for one or more `TimerHandler`s per `Element`.
  1690. *
  1691. * @see https://github.com/thednp/navbar/
  1692. */
  1693. export declare const Timer: {
  1694. /**
  1695. * Sets a new timeout timer for an element, or element -> key association.
  1696. *
  1697. * @param element target element
  1698. * @param callback the callback
  1699. * @param delay the execution delay
  1700. * @param key a unique key
  1701. */
  1702. set: (element: Element, callback: TimerHandler, delay: number, key?: string) => void;
  1703. /**
  1704. * Returns the timer associated with the target.
  1705. *
  1706. * @param element target element
  1707. * @param key a unique
  1708. * @returns the timer
  1709. */
  1710. get: (element: Element, key?: string) => number | null;
  1711. /**
  1712. * Clears the element's timer.
  1713. *
  1714. * @param element target element
  1715. * @param key a unique key
  1716. */
  1717. clear: (element: Element, key?: string) => void;
  1718. };
  1719. /**
  1720. * Utility to toggle focus trap inside a designated target element;
  1721. * @param target
  1722. */
  1723. export declare const toggleFocusTrap: (target: Element) => void;
  1724. /**
  1725. * Shortcut for `String.toLowerCase()`.
  1726. *
  1727. * @param source input string
  1728. * @returns lowercase output string
  1729. */
  1730. export declare const toLowerCase: (source: string) => string;
  1731. /**
  1732. * A global namespace for `touchcancel` event.
  1733. */
  1734. export declare const touchcancelEvent = "touchcancel";
  1735. /**
  1736. * A global namespace for `touchend` event.
  1737. */
  1738. export declare const touchendEvent = "touchend";
  1739. declare interface TouchEvent_2<T extends EventTarget = HTMLElement>
  1740. extends UIEvent_2<T, NativeTouchEvent> {
  1741. altKey: boolean;
  1742. changedTouches: TouchList;
  1743. ctrlKey: boolean;
  1744. /**
  1745. * See [DOM Level 3 Events spec](https://www.w3.org/TR/uievents-key/#keys-modifier). for a list of valid (case-sensitive) arguments to this method.
  1746. */
  1747. getModifierState(key: ModifierKey): boolean;
  1748. metaKey: boolean;
  1749. shiftKey: boolean;
  1750. targetTouches: TouchList;
  1751. touches: TouchList;
  1752. }
  1753. export { TouchEvent_2 as TouchEvent }
  1754. export declare type TouchEventHandler<T extends EventTarget = HTMLElement> = EventHandler<
  1755. T,
  1756. TouchEvent_2<T>
  1757. >;
  1758. /**
  1759. * A global namespace for touch events.
  1760. */
  1761. export declare const touchEvents: {
  1762. start: string;
  1763. end: string;
  1764. move: string;
  1765. cancel: string;
  1766. };
  1767. /**
  1768. * A global namespace for `touchmove` event.
  1769. */
  1770. export declare const touchmoveEvent = "touchmove";
  1771. /**
  1772. * A global namespace for `touchstart` event.
  1773. */
  1774. export declare const touchstartEvent = "touchstart";
  1775. /**
  1776. * Shortcut for `String.toUpperCase()`.
  1777. *
  1778. * @param source input string
  1779. * @returns uppercase output string
  1780. */
  1781. export declare const toUpperCase: (source: string) => string;
  1782. /**
  1783. * A global namespace for 'transitionDelay' string.
  1784. */
  1785. export declare const transitionDelay = "transitionDelay";
  1786. /**
  1787. * A global namespace for 'transitionDuration' string.
  1788. */
  1789. export declare const transitionDuration = "transitionDuration";
  1790. /**
  1791. * A global namespace for 'transitionend' string.
  1792. */
  1793. export declare const transitionEndEvent = "transitionend";
  1794. declare interface TransitionEvent_2<T extends EventTarget = HTMLElement>
  1795. extends NativeEvent<T, NativeTransitionEvent> {
  1796. elapsedTime: number;
  1797. propertyName: string;
  1798. pseudoElement: string;
  1799. }
  1800. export { TransitionEvent_2 as TransitionEvent }
  1801. export declare type TransitionEventHandler<T extends EventTarget = HTMLElement> = EventHandler<
  1802. T,
  1803. TransitionEvent_2<T>
  1804. >;
  1805. /**
  1806. * A global namespace for `transitionProperty` string for modern browsers.
  1807. */
  1808. export declare const transitionProperty = "transitionProperty";
  1809. declare interface UIEvent_2<T extends EventTarget = HTMLElement, E = NativeUIEvent>
  1810. extends NativeEvent<T, E> {
  1811. detail: number;
  1812. view: AbstractView;
  1813. }
  1814. export { UIEvent_2 as UIEvent }
  1815. export declare type UIEventHandler<T extends EventTarget = HTMLElement> = EventHandler<
  1816. T,
  1817. UIEvent_2<T>
  1818. >;
  1819. /**
  1820. * A global namespace for `unload` event.
  1821. */
  1822. export declare const unloadEvent = "unload";
  1823. /**
  1824. * A global namespace for `navigator.userAgent` string.
  1825. */
  1826. export declare const userAgent: string;
  1827. /**
  1828. * A global namespace for `userAgentData` object.
  1829. */
  1830. export declare const userAgentData: NavigatorUA["userAgentData"];
  1831. export { version }
  1832. declare interface WheelEvent_2<T extends EventTarget = HTMLElement>
  1833. extends MouseEvent_2<T, NativeWheelEvent> {
  1834. deltaMode: number;
  1835. deltaX: number;
  1836. deltaY: number;
  1837. deltaZ: number;
  1838. }
  1839. export { WheelEvent_2 as WheelEvent }
  1840. export declare type WheelEventHandler<T extends EventTarget = HTMLElement> = EventHandler<
  1841. T,
  1842. WheelEvent_2<T>
  1843. >;
  1844. export { }