/* * HSStaticMethods * @version: 3.2.3 * @author: Preline Labs Ltd. * @license: Licensed under MIT and Preline UI Fair Use License (https://preline.co/docs/license.html) * Copyright 2024 Preline Labs Ltd. */ import { getClassProperty, afterTransition } from '../utils' import { COLLECTIONS } from '../spa/index' import { IStaticMethods } from '../static/interfaces' import type HSAccessibilityObserver from '../plugins/accessibility-manager' import { ICollectionItem } from '../interfaces' import type HSCopyMarkup from '../plugins/copy-markup' import type HSAccordion from '../plugins/accordion' import type HSCarousel from '../plugins/carousel' import type HSCollapse from '../plugins/collapse' import type HSComboBox from '../plugins/combobox' import type HSDataTable from '../plugins/datatable' import type HSDropdown from '../plugins/dropdown' import type HSFileUpload from '../plugins/file-upload' import type HSInputNumber from '../plugins/input-number' import type HSOverlay from '../plugins/overlay' import type HSPinInput from '../plugins/pin-input' import type HSRangeSlider from '../plugins/range-slider' import type HSRemoveElement from '../plugins/remove-element' import type HSScrollspy from '../plugins/scrollspy' import type HSSelect from '../plugins/select' import type HSStepper from '../plugins/stepper' import type HSStrongPassword from '../plugins/strong-password' import type HSTabs from '../plugins/tabs' import type HSToggleCount from '../plugins/toggle-count' import type HSTogglePassword from '../plugins/toggle-password' import type HSTooltip from '../plugins/tooltip' import type HSTreeView from '../plugins/tree-view' declare global { interface Window { HSStaticMethods: IStaticMethods HSAccessibilityObserver: HSAccessibilityObserver $hsCopyMarkupCollection: ICollectionItem[] $hsAccordionCollection: ICollectionItem[] $hsCarouselCollection: ICollectionItem[] $hsCollapseCollection: ICollectionItem[] $hsComboBoxCollection: ICollectionItem[] $hsDataTableCollection: ICollectionItem[] $hsDropdownCollection: ICollectionItem[] $hsFileUploadCollection: ICollectionItem[] $hsInputNumberCollection: { id: number; element: HSInputNumber }[] $hsOverlayCollection: ICollectionItem[] $hsPinInputCollection: ICollectionItem[] $hsRangeSliderCollection: ICollectionItem[] $hsRemoveElementCollection: ICollectionItem[] $hsScrollspyCollection: ICollectionItem[] $hsSelectCollection: ICollectionItem[] $hsStepperCollection: ICollectionItem[] $hsStrongPasswordCollection: ICollectionItem[] $hsTabsCollection: ICollectionItem[] $hsToggleCountCollection: ICollectionItem[] $hsTogglePasswordCollection: ICollectionItem[] $hsTooltipCollection: ICollectionItem[] $hsTreeViewCollection: ICollectionItem[] } } const HSStaticMethods: IStaticMethods = { getClassProperty, afterTransition, autoInit(collection: string | string[] = 'all') { if (collection === 'all') { COLLECTIONS.forEach(({ fn }) => { fn?.autoInit() }) } else { COLLECTIONS.forEach(({ key, fn }) => { if (collection.includes(key)) fn?.autoInit() }) } }, cleanCollection(name: string | string[] = 'all') { if (name === 'all') { COLLECTIONS.forEach(({ collection }) => { if ((window as any)[collection] instanceof Array) { ;(window as any)[collection] = [] } }) } else { COLLECTIONS.forEach(({ key, collection }) => { if (name.includes(key) && (window as any)[collection] instanceof Array) { ;(window as any)[collection] = [] } }) } } } if (typeof window !== 'undefined') { window.HSStaticMethods = HSStaticMethods } export default HSStaticMethods