forstok-ui-lib 6.2.11 → 6.2.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "forstok-ui-lib",
3
- "version": "6.2.11",
3
+ "version": "6.2.12",
4
4
  "description": "Forstok UI Components Library",
5
5
  "path": "dist",
6
6
  "main": "dist/index.js",
@@ -646,4 +646,37 @@ export const isTablet = () => {
646
646
 
647
647
  export const isMobile = () => {
648
648
  return document.body.clientWidth < 768 ? true : false;
649
+ }
650
+
651
+ export const evCloseDropdown = (currentTarget: EventTarget & HTMLElement) => {
652
+ const containerEl = currentTarget.closest('._refContainer') as HTMLElement
653
+ const isOpen = containerEl ? containerEl.classList.contains('is-shown') : false
654
+ if (isOpen) {
655
+ const containerRefs = document.getElementsByClassName('_refContainer is-shown') as HTMLCollectionOf<HTMLElement>
656
+ if (containerRefs?.length) {
657
+ for (let i = 0; i < containerRefs.length; i++) {
658
+ const overlay = containerRefs[i].querySelector(`._refDropdownOverlay`) as HTMLElement
659
+ overlay && (overlay.style.display = 'none')
660
+ containerRefs[i].classList.remove('is-shown')
661
+ }
662
+ }
663
+ const refScrollContainerEl = document.querySelector('._refScrollContainer') as HTMLElement
664
+ const bodyEl = document.getElementsByTagName('BODY')[0] as HTMLBodyElement
665
+ bodyEl.classList.remove('is-immuned')
666
+ if (refScrollContainerEl) {
667
+ refScrollContainerEl.style.overflow = 'auto'
668
+ const child = refScrollContainerEl.firstChild as HTMLElement
669
+ child.style.overflowY = 'unset'
670
+ }
671
+ }
672
+ }
673
+
674
+ export const evSetTotal = (totalCount: number, totalEl: HTMLSpanElement, callback?: () => void) => {
675
+ if (totalCount && totalEl) {
676
+ totalEl.innerText =`(${totalCount})`
677
+ totalEl.removeAttribute('hidden')
678
+ }
679
+ if (callback && typeof(callback) == "function") {
680
+ callback()
681
+ }
649
682
  }