@e1011/es-kit 1.1.24 → 1.1.28

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.
Files changed (222) hide show
  1. package/dist/hooks/esm/index.css +310 -305
  2. package/dist/hooks/esm/node_modules/gsap/CSSPlugin.js +11 -0
  3. package/dist/hooks/esm/node_modules/gsap/CSSPlugin.js.map +1 -0
  4. package/dist/hooks/esm/node_modules/gsap/gsap-core.js +11 -0
  5. package/dist/hooks/esm/node_modules/gsap/gsap-core.js.map +1 -0
  6. package/dist/hooks/esm/node_modules/gsap/index.js +2 -0
  7. package/dist/hooks/esm/node_modules/gsap/index.js.map +1 -0
  8. package/dist/hooks/esm/src/core/hooks/index.js +1 -1
  9. package/dist/hooks/esm/src/core/hooks/useAnimation.js +2 -0
  10. package/dist/hooks/esm/src/core/hooks/useAnimation.js.map +1 -0
  11. package/dist/hooks/esm/src/core/hooks/useClassNames.js.map +1 -1
  12. package/dist/hooks/esm/src/core/hooks/useIntersectionObserver.js +2 -0
  13. package/dist/hooks/esm/src/core/hooks/useIntersectionObserver.js.map +1 -0
  14. package/dist/hooks/esm/src/core/hooks/useOutsideClick.js.map +1 -1
  15. package/dist/hooks/esm/src/core/hooks/useParseProps.js.map +1 -1
  16. package/dist/hooks/esm/src/core/hooks/useResize.js.map +1 -1
  17. package/dist/hooks/esm/src/core/hooks/useThemePreference.js +1 -1
  18. package/dist/hooks/esm/src/core/hooks/useThemePreference.js.map +1 -1
  19. package/dist/hooks/esm/src/core/hooks/useToggle.js.map +1 -1
  20. package/dist/hooks/index.css +310 -305
  21. package/dist/hooks/node_modules/gsap/CSSPlugin.js +11 -0
  22. package/dist/hooks/node_modules/gsap/CSSPlugin.js.map +1 -0
  23. package/dist/hooks/node_modules/gsap/gsap-core.js +11 -0
  24. package/dist/hooks/node_modules/gsap/gsap-core.js.map +1 -0
  25. package/dist/hooks/node_modules/gsap/index.js +2 -0
  26. package/dist/hooks/node_modules/gsap/index.js.map +1 -0
  27. package/dist/hooks/src/core/hooks/index.js +1 -1
  28. package/dist/hooks/src/core/hooks/useAnimation.js +2 -0
  29. package/dist/hooks/src/core/hooks/useAnimation.js.map +1 -0
  30. package/dist/hooks/src/core/hooks/useClassNames.js.map +1 -1
  31. package/dist/hooks/src/core/hooks/useIntersectionObserver.js +2 -0
  32. package/dist/hooks/src/core/hooks/useIntersectionObserver.js.map +1 -0
  33. package/dist/hooks/src/core/hooks/useOutsideClick.js.map +1 -1
  34. package/dist/hooks/src/core/hooks/useParseProps.js.map +1 -1
  35. package/dist/hooks/src/core/hooks/useResize.js.map +1 -1
  36. package/dist/hooks/src/core/hooks/useThemePreference.js +1 -1
  37. package/dist/hooks/src/core/hooks/useThemePreference.js.map +1 -1
  38. package/dist/hooks/src/core/hooks/useToggle.js.map +1 -1
  39. package/dist/lib/cjs/index.css +5 -0
  40. package/dist/lib/cjs/node_modules/gsap/CSSPlugin.js +11 -0
  41. package/dist/lib/cjs/node_modules/gsap/CSSPlugin.js.map +1 -0
  42. package/dist/lib/cjs/node_modules/gsap/gsap-core.js +11 -0
  43. package/dist/lib/cjs/node_modules/gsap/gsap-core.js.map +1 -0
  44. package/dist/lib/cjs/node_modules/gsap/index.js +2 -0
  45. package/dist/lib/cjs/node_modules/gsap/index.js.map +1 -0
  46. package/dist/lib/cjs/src/core/hooks/useAnimation.js +2 -0
  47. package/dist/lib/cjs/src/core/hooks/useAnimation.js.map +1 -0
  48. package/dist/lib/cjs/src/core/hooks/useClassNames.js.map +1 -1
  49. package/dist/lib/cjs/src/core/hooks/useIntersectionObserver.js +2 -0
  50. package/dist/lib/cjs/src/core/hooks/useIntersectionObserver.js.map +1 -0
  51. package/dist/lib/cjs/src/core/hooks/useOutsideClick.js.map +1 -1
  52. package/dist/lib/cjs/src/core/hooks/useParseProps.js.map +1 -1
  53. package/dist/lib/cjs/src/core/hooks/useResize.js.map +1 -1
  54. package/dist/lib/cjs/src/core/hooks/useThemePreference.js +1 -1
  55. package/dist/lib/cjs/src/core/hooks/useThemePreference.js.map +1 -1
  56. package/dist/lib/cjs/src/core/hooks/useToggle.js.map +1 -1
  57. package/dist/lib/cjs/src/core/ui/components/atoms/icons.js.map +1 -1
  58. package/dist/lib/cjs/src/core/ui/components/atoms/text/Headline.js.map +1 -1
  59. package/dist/lib/cjs/src/core/ui/components/atoms/text/Link.js.map +1 -1
  60. package/dist/lib/cjs/src/core/ui/components/atoms/text/Paragraph.js.map +1 -1
  61. package/dist/lib/cjs/src/core/ui/components/atoms/text/Text.js.map +1 -1
  62. package/dist/lib/cjs/src/core/ui/components/atoms/textAndContent/TextAndContent.js +2 -0
  63. package/dist/lib/cjs/src/core/ui/components/atoms/textAndContent/TextAndContent.js.map +1 -0
  64. package/dist/lib/cjs/src/core/ui/components/atoms/textAndContent/textAndContent.module.scss.js +2 -0
  65. package/dist/lib/cjs/src/core/ui/components/atoms/textAndContent/textAndContent.module.scss.js.map +1 -0
  66. package/dist/lib/cjs/src/core/ui/components/container/layoutBox/LayoutBox.js.map +1 -1
  67. package/dist/lib/cjs/src/core/ui/components/error/propsValidationError.js +2 -0
  68. package/dist/lib/cjs/src/core/ui/components/error/propsValidationError.js.map +1 -0
  69. package/dist/lib/cjs/src/core/ui/components/icon/IconBase.js.map +1 -1
  70. package/dist/lib/cjs/src/core/ui/components/icon/IconWC.js.map +1 -1
  71. package/dist/lib/cjs/src/core/ui/components/molecules/popup/Popup.js.map +1 -1
  72. package/dist/lib/cjs/src/core/utils/appState/peregrineMQ/peregrineMQ.js.map +1 -1
  73. package/dist/lib/cjs/src/core/utils/appState/store/store.vanillajs.js.map +1 -1
  74. package/dist/lib/cjs/src/index.js +1 -1
  75. package/dist/lib/esm/index.css +5 -0
  76. package/dist/lib/esm/node_modules/gsap/CSSPlugin.js +11 -0
  77. package/dist/lib/esm/node_modules/gsap/CSSPlugin.js.map +1 -0
  78. package/dist/lib/esm/node_modules/gsap/gsap-core.js +11 -0
  79. package/dist/lib/esm/node_modules/gsap/gsap-core.js.map +1 -0
  80. package/dist/lib/esm/node_modules/gsap/index.js +2 -0
  81. package/dist/lib/esm/node_modules/gsap/index.js.map +1 -0
  82. package/dist/lib/esm/src/core/hooks/useAnimation.js +2 -0
  83. package/dist/lib/esm/src/core/hooks/useAnimation.js.map +1 -0
  84. package/dist/lib/esm/src/core/hooks/useClassNames.js.map +1 -1
  85. package/dist/lib/esm/src/core/hooks/useIntersectionObserver.js +2 -0
  86. package/dist/lib/esm/src/core/hooks/useIntersectionObserver.js.map +1 -0
  87. package/dist/lib/esm/src/core/hooks/useOutsideClick.js.map +1 -1
  88. package/dist/lib/esm/src/core/hooks/useParseProps.js.map +1 -1
  89. package/dist/lib/esm/src/core/hooks/useResize.js.map +1 -1
  90. package/dist/lib/esm/src/core/hooks/useThemePreference.js +1 -1
  91. package/dist/lib/esm/src/core/hooks/useThemePreference.js.map +1 -1
  92. package/dist/lib/esm/src/core/hooks/useToggle.js.map +1 -1
  93. package/dist/lib/esm/src/core/ui/components/atoms/icons.js.map +1 -1
  94. package/dist/lib/esm/src/core/ui/components/atoms/text/Headline.js.map +1 -1
  95. package/dist/lib/esm/src/core/ui/components/atoms/text/Link.js.map +1 -1
  96. package/dist/lib/esm/src/core/ui/components/atoms/text/Paragraph.js.map +1 -1
  97. package/dist/lib/esm/src/core/ui/components/atoms/text/Text.js.map +1 -1
  98. package/dist/lib/esm/src/core/ui/components/atoms/textAndContent/TextAndContent.js +2 -0
  99. package/dist/lib/esm/src/core/ui/components/atoms/textAndContent/TextAndContent.js.map +1 -0
  100. package/dist/lib/esm/src/core/ui/components/atoms/textAndContent/textAndContent.module.scss.js +2 -0
  101. package/dist/lib/esm/src/core/ui/components/atoms/textAndContent/textAndContent.module.scss.js.map +1 -0
  102. package/dist/lib/esm/src/core/ui/components/container/layoutBox/LayoutBox.js.map +1 -1
  103. package/dist/lib/esm/src/core/ui/components/error/propsValidationError.js +2 -0
  104. package/dist/lib/esm/src/core/ui/components/error/propsValidationError.js.map +1 -0
  105. package/dist/lib/esm/src/core/ui/components/icon/IconBase.js.map +1 -1
  106. package/dist/lib/esm/src/core/ui/components/icon/IconWC.js.map +1 -1
  107. package/dist/lib/esm/src/core/ui/components/molecules/popup/Popup.js.map +1 -1
  108. package/dist/lib/esm/src/core/utils/appState/peregrineMQ/peregrineMQ.js.map +1 -1
  109. package/dist/lib/esm/src/core/utils/appState/store/store.vanillajs.js.map +1 -1
  110. package/dist/lib/esm/src/index.js +1 -1
  111. package/dist/lib/tsconfig.tsbuildinfo +1 -1
  112. package/dist/types/src/core/hooks/index.d.ts +2 -0
  113. package/dist/types/src/core/hooks/index.d.ts.map +1 -1
  114. package/dist/types/src/core/hooks/useAnimation.d.ts +23 -0
  115. package/dist/types/src/core/hooks/useAnimation.d.ts.map +1 -0
  116. package/dist/types/src/core/hooks/useClassNames.d.ts +6 -0
  117. package/dist/types/src/core/hooks/useClassNames.d.ts.map +1 -1
  118. package/dist/types/src/core/hooks/useIntersectionObserver.d.ts +28 -0
  119. package/dist/types/src/core/hooks/useIntersectionObserver.d.ts.map +1 -0
  120. package/dist/types/src/core/hooks/useOutsideClick.d.ts +14 -0
  121. package/dist/types/src/core/hooks/useOutsideClick.d.ts.map +1 -1
  122. package/dist/types/src/core/hooks/useParseProps.d.ts +5 -0
  123. package/dist/types/src/core/hooks/useParseProps.d.ts.map +1 -1
  124. package/dist/types/src/core/hooks/useResize.d.ts +23 -0
  125. package/dist/types/src/core/hooks/useResize.d.ts.map +1 -1
  126. package/dist/types/src/core/hooks/useThemePreference.d.ts +37 -1
  127. package/dist/types/src/core/hooks/useThemePreference.d.ts.map +1 -1
  128. package/dist/types/src/core/hooks/useToggle.d.ts +17 -2
  129. package/dist/types/src/core/hooks/useToggle.d.ts.map +1 -1
  130. package/dist/types/src/core/ui/components/atoms/button/button.stories.d.ts +1 -1
  131. package/dist/types/src/core/ui/components/atoms/button/button.stories.d.ts.map +1 -1
  132. package/dist/types/src/core/ui/components/atoms/icons.d.ts +5 -0
  133. package/dist/types/src/core/ui/components/atoms/icons.d.ts.map +1 -1
  134. package/dist/types/src/core/ui/components/atoms/index.d.ts +1 -0
  135. package/dist/types/src/core/ui/components/atoms/index.d.ts.map +1 -1
  136. package/dist/types/src/core/ui/components/atoms/tag/Tag.d.ts +38 -0
  137. package/dist/types/src/core/ui/components/atoms/tag/Tag.d.ts.map +1 -0
  138. package/dist/types/src/core/ui/components/atoms/tag/Tag.test.d.ts +5 -0
  139. package/dist/types/src/core/ui/components/atoms/tag/Tag.test.d.ts.map +1 -0
  140. package/dist/types/src/core/ui/components/atoms/tag/tag.stories.d.ts +6 -0
  141. package/dist/types/src/core/ui/components/atoms/tag/tag.stories.d.ts.map +1 -0
  142. package/dist/types/src/core/ui/components/atoms/text/Headline.d.ts +1 -1
  143. package/dist/types/src/core/ui/components/atoms/text/Headline.d.ts.map +1 -1
  144. package/dist/types/src/core/ui/components/atoms/text/Link.d.ts +1 -1
  145. package/dist/types/src/core/ui/components/atoms/text/Link.d.ts.map +1 -1
  146. package/dist/types/src/core/ui/components/atoms/text/Paragraph.d.ts +1 -1
  147. package/dist/types/src/core/ui/components/atoms/text/Paragraph.d.ts.map +1 -1
  148. package/dist/types/src/core/ui/components/atoms/text/Text.d.ts +2 -15
  149. package/dist/types/src/core/ui/components/atoms/text/Text.d.ts.map +1 -1
  150. package/dist/types/src/core/ui/components/atoms/text/anchor-link/anchorLink.stories.d.ts +1 -1
  151. package/dist/types/src/core/ui/components/atoms/text/anchor-link/anchorLink.stories.d.ts.map +1 -1
  152. package/dist/types/src/core/ui/components/atoms/text/anchor-link/anchorLink.types.d.ts +1 -1
  153. package/dist/types/src/core/ui/components/atoms/text/anchor-link/anchorLink.types.d.ts.map +1 -1
  154. package/dist/types/src/core/ui/components/atoms/text/text.types.d.ts +16 -0
  155. package/dist/types/src/core/ui/components/atoms/text/text.types.d.ts.map +1 -0
  156. package/dist/types/src/core/ui/components/atoms/textAndContent/TextAndContent.d.ts +17 -0
  157. package/dist/types/src/core/ui/components/atoms/textAndContent/TextAndContent.d.ts.map +1 -0
  158. package/dist/types/src/core/ui/components/atoms/textAndContent/index.d.ts +3 -0
  159. package/dist/types/src/core/ui/components/atoms/textAndContent/index.d.ts.map +1 -0
  160. package/dist/types/src/core/ui/components/atoms/textAndContent/textAndContent.stories.d.ts +8 -0
  161. package/dist/types/src/core/ui/components/atoms/textAndContent/textAndContent.stories.d.ts.map +1 -0
  162. package/dist/types/src/core/ui/components/atoms/textAndContent/textAndContent.test.d.ts +5 -0
  163. package/dist/types/src/core/ui/components/atoms/textAndContent/textAndContent.test.d.ts.map +1 -0
  164. package/dist/types/src/core/ui/components/atoms/textAndContent/textAndContent.types.d.ts +24 -0
  165. package/dist/types/src/core/ui/components/atoms/textAndContent/textAndContent.types.d.ts.map +1 -0
  166. package/dist/types/src/core/ui/components/error/errorBoundary.stories.d.ts +3 -3
  167. package/dist/types/src/core/ui/components/error/errorBoundary.stories.d.ts.map +1 -1
  168. package/dist/types/src/core/ui/components/error/propsValidationError.d.ts +4 -0
  169. package/dist/types/src/core/ui/components/error/propsValidationError.d.ts.map +1 -0
  170. package/dist/types/src/core/ui/components/molecules/popup/popup.stories.d.ts +2 -2
  171. package/dist/types/src/core/ui/components/molecules/popup/popup.stories.d.ts.map +1 -1
  172. package/dist/types/src/core/utils/appState/peregrineMQ/peregrineMQ.stories.d.ts +1 -1
  173. package/dist/types/src/core/utils/appState/peregrineMQ/peregrineMQ.stories.d.ts.map +1 -1
  174. package/dist/types/src/core/utils/appState/store/store.stories.d.ts +1 -1
  175. package/dist/types/src/core/utils/appState/store/store.stories.d.ts.map +1 -1
  176. package/dist/ui/esm/index.css +5 -0
  177. package/dist/ui/esm/src/core/hooks/useOutsideClick.js.map +1 -1
  178. package/dist/ui/esm/src/core/hooks/useParseProps.js.map +1 -1
  179. package/dist/ui/esm/src/core/hooks/useResize.js.map +1 -1
  180. package/dist/ui/esm/src/core/ui/components/atoms/icons.js.map +1 -1
  181. package/dist/ui/esm/src/core/ui/components/atoms/text/Headline.js.map +1 -1
  182. package/dist/ui/esm/src/core/ui/components/atoms/text/Link.js.map +1 -1
  183. package/dist/ui/esm/src/core/ui/components/atoms/text/Paragraph.js.map +1 -1
  184. package/dist/ui/esm/src/core/ui/components/atoms/text/Text.js.map +1 -1
  185. package/dist/ui/esm/src/core/ui/components/atoms/textAndContent/TextAndContent.js +2 -0
  186. package/dist/ui/esm/src/core/ui/components/atoms/textAndContent/TextAndContent.js.map +1 -0
  187. package/dist/ui/esm/src/core/ui/components/atoms/textAndContent/textAndContent.module.scss.js +2 -0
  188. package/dist/ui/esm/src/core/ui/components/atoms/textAndContent/textAndContent.module.scss.js.map +1 -0
  189. package/dist/ui/esm/src/core/ui/components/container/layoutBox/LayoutBox.js.map +1 -1
  190. package/dist/ui/esm/src/core/ui/components/error/propsValidationError.js +2 -0
  191. package/dist/ui/esm/src/core/ui/components/error/propsValidationError.js.map +1 -0
  192. package/dist/ui/esm/src/core/ui/components/icon/IconBase.js.map +1 -1
  193. package/dist/ui/esm/src/core/ui/components/icon/IconWC.js.map +1 -1
  194. package/dist/ui/esm/src/core/ui/components/molecules/popup/Popup.js.map +1 -1
  195. package/dist/ui/esm/src/core/ui/index.js +1 -1
  196. package/dist/ui/index.css +5 -0
  197. package/dist/ui/src/core/hooks/useOutsideClick.js.map +1 -1
  198. package/dist/ui/src/core/hooks/useParseProps.js.map +1 -1
  199. package/dist/ui/src/core/hooks/useResize.js.map +1 -1
  200. package/dist/ui/src/core/ui/components/atoms/icons.js.map +1 -1
  201. package/dist/ui/src/core/ui/components/atoms/text/Headline.js.map +1 -1
  202. package/dist/ui/src/core/ui/components/atoms/text/Link.js.map +1 -1
  203. package/dist/ui/src/core/ui/components/atoms/text/Paragraph.js.map +1 -1
  204. package/dist/ui/src/core/ui/components/atoms/text/Text.js.map +1 -1
  205. package/dist/ui/src/core/ui/components/atoms/textAndContent/TextAndContent.js +2 -0
  206. package/dist/ui/src/core/ui/components/atoms/textAndContent/TextAndContent.js.map +1 -0
  207. package/dist/ui/src/core/ui/components/atoms/textAndContent/textAndContent.module.scss.js +2 -0
  208. package/dist/ui/src/core/ui/components/atoms/textAndContent/textAndContent.module.scss.js.map +1 -0
  209. package/dist/ui/src/core/ui/components/container/layoutBox/LayoutBox.js.map +1 -1
  210. package/dist/ui/src/core/ui/components/error/propsValidationError.js +2 -0
  211. package/dist/ui/src/core/ui/components/error/propsValidationError.js.map +1 -0
  212. package/dist/ui/src/core/ui/components/icon/IconBase.js.map +1 -1
  213. package/dist/ui/src/core/ui/components/icon/IconWC.js.map +1 -1
  214. package/dist/ui/src/core/ui/components/molecules/popup/Popup.js.map +1 -1
  215. package/dist/ui/src/core/ui/index.js +1 -1
  216. package/dist/utils/esm/index.css +310 -305
  217. package/dist/utils/esm/src/core/utils/appState/peregrineMQ/peregrineMQ.js.map +1 -1
  218. package/dist/utils/esm/src/core/utils/appState/store/store.vanillajs.js.map +1 -1
  219. package/dist/utils/index.css +310 -305
  220. package/dist/utils/src/core/utils/appState/peregrineMQ/peregrineMQ.js.map +1 -1
  221. package/dist/utils/src/core/utils/appState/store/store.vanillajs.js.map +1 -1
  222. package/package.json +20 -11
@@ -0,0 +1,2 @@
1
+ import{gsap as e}from"./gsap-core.js";export{Timeline as TimelineLite,Timeline as TimelineMax,Tween as TweenLite}from"./gsap-core.js";import{CSSPlugin as i}from"./CSSPlugin.js";var r=e.registerPlugin(i)||e;r.core.Tween;export{i as CSSPlugin,r as default,r as gsap};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../../../node_modules/gsap/index.js"],"sourcesContent":["import { gsap, Power0, Power1, Power2, Power3, Power4, Linear, Quad, Cubic, Quart, Quint, Strong, Elastic, Back, SteppedEase, Bounce, Sine, Expo, Circ, TweenLite, TimelineLite, TimelineMax } from \"./gsap-core.js\";\nimport { CSSPlugin } from \"./CSSPlugin.js\";\nvar gsapWithCSS = gsap.registerPlugin(CSSPlugin) || gsap,\n // to protect from tree shaking\nTweenMaxWithCSS = gsapWithCSS.core.Tween;\nexport { gsapWithCSS as gsap, gsapWithCSS as default, CSSPlugin, TweenMaxWithCSS as TweenMax, TweenLite, TimelineMax, TimelineLite, Power0, Power1, Power2, Power3, Power4, Linear, Quad, Cubic, Quart, Quint, Strong, Elastic, Back, SteppedEase, Bounce, Sine, Expo, Circ };"],"names":["gsapWithCSS","gsap","registerPlugin","CSSPlugin","core","Tween"],"mappings":"iLAEG,IAACA,EAAcC,EAAKC,eAAeC,IAAcF,EAElCD,EAAYI,KAAKC","x_google_ignoreList":[0]}
@@ -1,2 +1,2 @@
1
- export{useApi}from"./useApi.js";export{useToggle}from"./useToggle.js";export{outsideClickHandler,useOutsideClick}from"./useOutsideClick.js";export{useResize}from"./useResize.js";export{useClassNames}from"./useClassNames.js";export{useParseProps}from"./useParseProps.js";export{getBaseThemes,observeThemePreference,setTHemeClassNames,switchColorTheme,updateColorTheme,useThemePreference}from"./useThemePreference.js";
1
+ export{useApi}from"./useApi.js";export{useToggle}from"./useToggle.js";export{outsideClickHandler,useOutsideClick}from"./useOutsideClick.js";export{useResize}from"./useResize.js";export{useClassNames}from"./useClassNames.js";export{useParseProps}from"./useParseProps.js";export{getBaseThemes,observeThemePreference,setThemeClassNames,switchColorTheme,updateColorTheme,useThemePreference}from"./useThemePreference.js";export{useAnimation}from"./useAnimation.js";export{useIntersectionObserver}from"./useIntersectionObserver.js";
2
2
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,2 @@
1
+ import{gsap as r}from"../../../node_modules/gsap/index.js";import{useState as t,useRef as e,useEffect as o,useLayoutEffect as n}from"react";const a=a=>{let{start:s,end:d,duration:u,ease:p="expo.inOut",rounded:c}=a;const[i,l]=t(d),m=e(s);return o((()=>{m.current=i}),[i]),n((()=>{const t={val:m.current},e=r.context((()=>{r.to(t,u,{val:d,ease:p,duration:u,...c?{roundProps:"val"}:{},onUpdate(){l(t.val)}})}));return()=>e.revert()}),[u,p,d,c,s]),i};export{a as useAnimation};
2
+ //# sourceMappingURL=useAnimation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAnimation.js","sources":["../../../../../../src/core/hooks/useAnimation.ts"],"sourcesContent":["import gsap from 'gsap'\nimport { useEffect, useLayoutEffect, useRef, useState } from 'react'\n\n/**\n * Type definition for the parameters used in the `useAnimation` hook.\n * @typedef {Object} UseAnimationType\n * @property {number} start - The starting value of the animation.\n * @property {number} end - The ending value of the animation.\n * @property {number} duration - The duration of the animation in seconds.\n * @property {string} [ease='expo.inOut'] - The easing function for the animation.\n * @property {boolean} [rounded] - Flag to determine if the value should be rounded during the animation.\n */\nexport type UseAnimationType = {\n start: number\n end: number\n duration: number\n ease?: string\n rounded?: boolean\n}\n\n/**\n * Custom hook to create an animation using GSAP.\n * @param {UseAnimationType} params - The parameters for the animation.\n * @returns {number} The current value of the animation.\n */\nexport const useAnimation = ({ start, end, duration, ease = 'expo.inOut', rounded }: UseAnimationType): number => {\n const [val, setVal] = useState(end)\n\n const startValueRef = useRef(start)\n\n useEffect(() => {\n startValueRef.current = val\n }, [val])\n\n useLayoutEffect(() => {\n const valObj = { val: startValueRef.current }\n\n const gsapCtx = gsap.context(() => {\n gsap.to(valObj, duration, {\n val: end,\n ease,\n duration,\n ...(rounded ? { roundProps: 'val' } : {}),\n onUpdate () {\n setVal(valObj.val)\n },\n })\n })\n\n return (): void => gsapCtx.revert()\n }, [duration, ease, end, rounded, start])\n\n return val\n}\n"],"names":["useAnimation","_ref","start","end","duration","ease","rounded","val","setVal","useState","startValueRef","useRef","useEffect","current","useLayoutEffect","valObj","gsapCtx","gsap","context","to","roundProps","onUpdate","revert"],"mappings":"4IAyBaA,MAAAA,EAAeC,IAAsF,IAArFC,MAAEA,EAAKC,IAAEA,EAAGC,SAAEA,EAAQC,KAAEA,EAAO,aAAYC,QAAEA,GAA2BL,EACnG,MAAOM,EAAKC,GAAUC,EAASN,GAEzBO,EAAgBC,EAAOT,GAwB7B,OAtBAU,GAAU,KACRF,EAAcG,QAAUN,CAAG,GAC1B,CAACA,IAEJO,GAAgB,KACd,MAAMC,EAAS,CAAER,IAAKG,EAAcG,SAE9BG,EAAUC,EAAKC,SAAQ,KAC3BD,EAAKE,GAAGJ,EAAQX,EAAU,CACxBG,IAAKJ,EACLE,OACAD,cACIE,EAAU,CAAEc,WAAY,OAAU,GACtCC,QAAAA,GACEb,EAAOO,EAAOR,IAChB,GACA,IAGJ,MAAO,IAAYS,EAAQM,QAAQ,GAClC,CAAClB,EAAUC,EAAMF,EAAKG,EAASJ,IAE3BK,CAAG"}
@@ -1 +1 @@
1
- {"version":3,"file":"useClassNames.js","sources":["../../../../../../src/core/hooks/useClassNames.ts"],"sourcesContent":["import { useMemo } from 'react'\n\nimport { classNames, TClassName } from '../utils/helpers/ui'\n\nexport const useClassNames = (\n classes: TClassName[],\n deps: unknown[],\n// eslint-disable-next-line react-hooks/exhaustive-deps\n): ReturnType<typeof classNames> => useMemo(() => classNames(...classes), [classes, deps])\n"],"names":["useClassNames","classes","deps","useMemo","classNames"],"mappings":"oFAIaA,MAAAA,EAAgBA,CAC3BC,EACAC,IAEkCC,GAAQ,IAAMC,KAAcH,IAAU,CAACA,EAASC"}
1
+ {"version":3,"file":"useClassNames.js","sources":["../../../../../../src/core/hooks/useClassNames.ts"],"sourcesContent":["import { useMemo } from 'react'\n\nimport { classNames, TClassName } from '../utils/helpers/ui'\n\n\n/**\n * Custom hook to memoize class names.\n * @param {TClassName[]} classes - Array of class names or conditions to be applied.\n * @param {unknown[]} deps - Dependencies array for the `useMemo` hook.\n * @returns {ReturnType<typeof classNames>} The computed class names as a string.\n */\nexport const useClassNames = (\n classes: TClassName[],\n deps: unknown[],\n// eslint-disable-next-line react-hooks/exhaustive-deps\n): ReturnType<typeof classNames> => useMemo(() => classNames(...classes), [classes, deps])\n"],"names":["useClassNames","classes","deps","useMemo","classNames"],"mappings":"oFAWaA,MAAAA,EAAgBA,CAC3BC,EACAC,IAEkCC,GAAQ,IAAMC,KAAcH,IAAU,CAACA,EAASC"}
@@ -0,0 +1,2 @@
1
+ import{useRef as n,useCallback as r,useEffect as t}from"react";const e={root:null,rootMargin:"0px",threshold:.5},c=c=>{let{callback:o,notIntersectingCallback:s,options:i={},granular:l}=c;const u=n(null),a=n(),g=r((n=>{!function(n,r,t){arguments.length>3&&void 0!==arguments[3]&&arguments[3]?n.forEach((n=>{n.isIntersecting?r():t?.()})):n[0].isIntersecting?r():t?.()}(n,o,s,l)}),[o,l,s]);return t((()=>{a.current?.disconnect();const n=u.current;return a.current=new IntersectionObserver(g,{...e,...i}),n&&a.current.observe(n),()=>{a.current?.disconnect()}}),[g,i]),u};export{c as useIntersectionObserver};
2
+ //# sourceMappingURL=useIntersectionObserver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useIntersectionObserver.js","sources":["../../../../../../src/core/hooks/useIntersectionObserver.ts"],"sourcesContent":["import { MutableRefObject, useCallback, useEffect, useRef } from 'react'\n\nconst defaultOptions = {\n root: null,\n rootMargin: '0px',\n threshold: 0.5,\n}\n\n/**\n * Type definition for the parameters used in the `useIntersectionObserver` hook.\n * @typedef {Object} UseIntersectionObserverType\n * @property {() => void} callback - Function to be called when the element intersects.\n * @property {() => void} [notIntersectingCallback] - Optional function to be called\n * when the element is not intersecting.\n * @property {Partial<{ root: HTMLElement | null; rootMargin: string; threshold: number }>} [options] -\n * Optional IntersectionObserver options.\n * @property {boolean} [granular] - Flag to determine if each entry should be checked individually.\n */\nexport type UseIntersectionObserverType = {\n callback: () => void\n notIntersectingCallback?: () => void\n options?: Partial<{\n root: HTMLElement | null\n rootMargin: string\n threshold: number\n }>\n granular?: boolean\n}\n\n/**\n * Default handler for intersection changes.\n * @param {IntersectionObserverEntry[]} entries - Array of intersection observer entries.\n * @param {() => void} callback - Function to be called when the element intersects.\n * @param {() => void} [notIntersectingCallback] - Optional function to be called when the element is not intersecting.\n * @param {boolean} [granular=false] - Flag to determine if each entry should be checked individually.\n */\nconst defaultIntersectionHandler = (\n entries: IntersectionObserverEntry[],\n callback: UseIntersectionObserverType['callback'],\n notIntersectingCallback: UseIntersectionObserverType['notIntersectingCallback'],\n granular = false,\n): void => {\n if (granular) {\n entries.forEach((entry) => {\n if (entry.isIntersecting) {\n callback()\n } else {\n notIntersectingCallback?.()\n }\n })\n } else {\n // eslint-disable-next-line no-lonely-if\n if (entries[0].isIntersecting) {\n callback()\n } else {\n notIntersectingCallback?.()\n }\n }\n}\n\n/**\n * Custom hook to observe the intersection of an element.\n * @param {UseIntersectionObserverType} params - The parameters for the intersection observer.\n * @returns {MutableRefObject<T | null>} Ref object for the observed element.\n */\nexport const useIntersectionObserver = <T extends Element = Element>({\n callback, notIntersectingCallback, options = {}, granular,\n}: UseIntersectionObserverType): MutableRefObject<T | null> => {\n const elementRef = useRef<T | null>(null)\n\n const observerRef = useRef<IntersectionObserver>()\n\n // entries: IntersectionObserverEntry[], observer: IntersectionObserver)\n const intersectionHandler = useCallback((entries: IntersectionObserverEntry[]) => {\n defaultIntersectionHandler(entries, callback, notIntersectingCallback, granular)\n }, [callback, granular, notIntersectingCallback])\n\n useEffect(() => {\n observerRef.current?.disconnect()\n\n const observeElement = elementRef.current\n\n observerRef.current = new IntersectionObserver(intersectionHandler, { ...defaultOptions, ...options })\n\n if (observeElement) {\n observerRef.current.observe(observeElement)\n }\n\n return (): void => {\n observerRef.current?.disconnect()\n }\n }, [intersectionHandler, options])\n\n return elementRef\n}\n"],"names":["defaultOptions","root","rootMargin","threshold","useIntersectionObserver","_ref","callback","notIntersectingCallback","options","granular","elementRef","useRef","observerRef","intersectionHandler","useCallback","entries","arguments","length","undefined","forEach","entry","isIntersecting","defaultIntersectionHandler","useEffect","current","disconnect","observeElement","IntersectionObserver","observe"],"mappings":"+DAEA,MAAMA,EAAiB,CACrBC,KAAM,KACNC,WAAY,MACZC,UAAW,IA4DAC,EAA0BC,IAEwB,IAFMC,SACnEA,EAAQC,wBAAEA,EAAuBC,QAAEA,EAAU,CAAE,EAAAC,SAAEA,GACrBJ,EAC5B,MAAMK,EAAaC,EAAiB,MAE9BC,EAAcD,IAGdE,EAAsBC,GAAaC,KArCR,SACjCA,EACAT,EACAC,GACQS,UAAAC,OAAA,QAAAC,IAAAF,UAAA,IAAAA,UAAA,GAGND,EAAQI,SAASC,IACXA,EAAMC,eACRf,IAEAC,KACF,IAIEQ,EAAQ,GAAGM,eACbf,IAEAC,KAGN,CAgBIe,CAA2BP,EAAST,EAAUC,EAAyBE,EAAS,GAC/E,CAACH,EAAUG,EAAUF,IAkBxB,OAhBAgB,GAAU,KACRX,EAAYY,SAASC,aAErB,MAAMC,EAAiBhB,EAAWc,QAQlC,OANAZ,EAAYY,QAAU,IAAIG,qBAAqBd,EAAqB,IAAKb,KAAmBQ,IAExFkB,GACFd,EAAYY,QAAQI,QAAQF,GAGvB,KACLd,EAAYY,SAASC,YAAY,CAClC,GACA,CAACZ,EAAqBL,IAElBE,CAAU"}
@@ -1 +1 @@
1
- {"version":3,"file":"useOutsideClick.js","sources":["../../../../../../src/core/hooks/useOutsideClick.ts"],"sourcesContent":["import { useEffect, useCallback } from 'react'\n\nimport { EventName } from '../constants/ui.constants'\nimport { handleClickOutside as defaultHandleClickOutside } from '../ui/utils/clickOutside'\n\ntype Element = HTMLElement | null | (() => HTMLElement)\ntype CallbackFunction = (target: HTMLElement | null) => void\n\nexport function useOutsideClick(\n element: Element,\n callback?: CallbackFunction,\n handleClickOutside = defaultHandleClickOutside(element, callback),\n): () => void {\n const unsubscriber = useCallback(\n () => document.removeEventListener(EventName.Click, handleClickOutside), [handleClickOutside],\n )\n\n useEffect(() => {\n unsubscriber()\n document.addEventListener(EventName.Click, handleClickOutside)\n\n return unsubscriber\n }, [element, handleClickOutside, unsubscriber])\n\n return unsubscriber\n}\n\nexport function outsideClickHandler(\n element: Element,\n callback?: CallbackFunction,\n handleClickOutside = defaultHandleClickOutside(element, callback),\n): () => void {\n const unsubscriber = (): void => document.removeEventListener(EventName.Click, handleClickOutside)\n\n document.addEventListener(EventName.Click, handleClickOutside)\n\n return unsubscriber\n}\n"],"names":["useOutsideClick","element","callback","handleClickOutside","arguments","length","undefined","defaultHandleClickOutside","unsubscriber","useCallback","document","removeEventListener","EventName","Click","useEffect","addEventListener","outsideClickHandler"],"mappings":"6KAQO,SAASA,EACdC,EACAC,GAEY,IADZC,EAAkBC,UAAAC,eAAAC,IAAAF,UAAA,GAAAA,UAAGG,GAAAA,EAA0BN,EAASC,GAExD,MAAMM,EAAeC,GACnB,IAAMC,SAASC,oBAAoBC,EAAUC,MAAOV,IAAqB,CAACA,IAU5E,OAPAW,GAAU,KACRN,IACAE,SAASK,iBAAiBH,EAAUC,MAAOV,GAEpCK,IACN,CAACP,EAASE,EAAoBK,IAE1BA,CACT,CAEO,SAASQ,EACdf,EACAC,GAEY,IADZC,EAAkBC,UAAAC,eAAAC,IAAAF,UAAA,GAAAA,UAAGG,GAAAA,EAA0BN,EAASC,GAMxD,OAFAQ,SAASK,iBAAiBH,EAAUC,MAAOV,GAFtBK,IAAYE,SAASC,oBAAoBC,EAAUC,MAAOV,EAKjF"}
1
+ {"version":3,"file":"useOutsideClick.js","sources":["../../../../../../src/core/hooks/useOutsideClick.ts"],"sourcesContent":["import { useEffect, useCallback } from 'react'\n\nimport { EventName } from '../constants/ui.constants'\nimport { handleClickOutside as defaultHandleClickOutside } from '../ui/utils/clickOutside'\n\ntype Element = HTMLElement | null | (() => HTMLElement)\ntype CallbackFunction = (target: HTMLElement | null) => void\n\n/**\n * Custom hook to handle clicks outside a specified element.\n * @param {Element} element - The element to detect outside clicks for.\n * @param {CallbackFunction} [callback] - Optional callback function to execute when an outside click is detected.\n * @param {Function} [handleClickOutside=defaultHandleClickOutside] - Optional custom function to handle outside clicks.\n * @returns {() => void} Function to unsubscribe the event listener.\n */\nexport function useOutsideClick(\n element: Element,\n callback?: CallbackFunction,\n handleClickOutside = defaultHandleClickOutside(element, callback),\n): () => void {\n const unsubscriber = useCallback(\n () => document.removeEventListener(EventName.Click, handleClickOutside), [handleClickOutside],\n )\n\n useEffect(() => {\n unsubscriber()\n document.addEventListener(EventName.Click, handleClickOutside)\n\n return unsubscriber\n }, [element, handleClickOutside, unsubscriber])\n\n return unsubscriber\n}\n\n/**\n * Function to handle clicks outside a specified element.\n * @param {Element} element - The element to detect outside clicks for.\n * @param {CallbackFunction} [callback] - Optional callback function to execute when an outside click is detected.\n * @param {Function} [handleClickOutside=defaultHandleClickOutside] - Optional custom function to handle outside clicks.\n * @returns {() => void} Function to unsubscribe the event listener.\n */\nexport function outsideClickHandler(\n element: Element,\n callback?: CallbackFunction,\n handleClickOutside = defaultHandleClickOutside(element, callback),\n): () => void {\n const unsubscriber = (): void => document.removeEventListener(EventName.Click, handleClickOutside)\n\n document.addEventListener(EventName.Click, handleClickOutside)\n\n return unsubscriber\n}\n"],"names":["useOutsideClick","element","callback","handleClickOutside","arguments","length","undefined","defaultHandleClickOutside","unsubscriber","useCallback","document","removeEventListener","EventName","Click","useEffect","addEventListener","outsideClickHandler"],"mappings":"6KAeO,SAASA,EACdC,EACAC,GAEY,IADZC,EAAkBC,UAAAC,eAAAC,IAAAF,UAAA,GAAAA,UAAGG,GAAAA,EAA0BN,EAASC,GAExD,MAAMM,EAAeC,GACnB,IAAMC,SAASC,oBAAoBC,EAAUC,MAAOV,IAAqB,CAACA,IAU5E,OAPAW,GAAU,KACRN,IACAE,SAASK,iBAAiBH,EAAUC,MAAOV,GAEpCK,IACN,CAACP,EAASE,EAAoBK,IAE1BA,CACT,CASO,SAASQ,EACdf,EACAC,GAEY,IADZC,EAAkBC,UAAAC,eAAAC,IAAAF,UAAA,GAAAA,UAAGG,GAAAA,EAA0BN,EAASC,GAMxD,OAFAQ,SAASK,iBAAiBH,EAAUC,MAAOV,GAFtBK,IAAYE,SAASC,oBAAoBC,EAAUC,MAAOV,EAKjF"}
@@ -1 +1 @@
1
- {"version":3,"file":"useParseProps.js","sources":["../../../../../../src/core/hooks/useParseProps.ts"],"sourcesContent":["import { useMemo } from 'react'\n\nimport { parseProps } from '../utils/helpers/ui'\n\n\nexport const useParseProps = (props: Record<string, unknown>): ReturnType<typeof parseProps> => {\n const propsCategories = useMemo(() => parseProps(props), [props])\n\n return propsCategories\n}\n"],"names":["useParseProps","props","useMemo","parseProps"],"mappings":"oFAKaA,MAAAA,EAAiBC,GACJC,GAAQ,IAAMC,EAAWF,IAAQ,CAACA"}
1
+ {"version":3,"file":"useParseProps.js","sources":["../../../../../../src/core/hooks/useParseProps.ts"],"sourcesContent":["import { useMemo } from 'react'\n\nimport { parseProps } from '../utils/helpers/ui'\n\n/**\n * Custom hook to parse properties using the `parseProps` utility function.\n * @param {Record<string, unknown>} props - The properties to be parsed.\n * @returns {ReturnType<typeof parseProps>} The parsed properties categorized by the `parseProps` function.\n */\nexport const useParseProps = (props: Record<string, unknown>): ReturnType<typeof parseProps> => {\n const propsCategories = useMemo(() => parseProps(props), [props])\n\n return propsCategories\n}\n"],"names":["useParseProps","props","useMemo","parseProps"],"mappings":"oFASaA,MAAAA,EAAiBC,GACJC,GAAQ,IAAMC,EAAWF,IAAQ,CAACA"}
@@ -1 +1 @@
1
- {"version":3,"file":"useResize.js","sources":["../../../../../../src/core/hooks/useResize.ts"],"sourcesContent":["import { MutableRefObject, useLayoutEffect, useMemo, useState, useRef } from 'react'\nimport debounce from 'lodash-es/debounce'\n\nexport type WrapperSize = {width: undefined | number; height: undefined | number}\n\n\ntype Unobserver = () => (null | void)\n\nexport type UseResizeCallBack = (wrapperSize: WrapperSize) => void\n\n// eslint-disable-next-line default-param-last\nexport const useResize = (debounceDelay = 250, callBack?: UseResizeCallBack): [\n MutableRefObject<HTMLElement | null | undefined>, WrapperSize, Unobserver | undefined] => {\n const [containerSize, setContainerSize]\n = useState<WrapperSize>({ width: undefined, height: undefined })\n\n const lastResizeWidthRef = useRef<WrapperSize>({ width: 0, height: 0 })\n const containerRef: MutableRefObject<HTMLElement | undefined | null> = useRef<HTMLElement | undefined | null>()\n const unobserverRef = useRef<Unobserver>()\n\n const debouncedResizeWrapper = useMemo(() => debounce((entries) => {\n const newResizeWidth = entries[0].contentRect.width\n const newResizeHeight = entries[0].contentRect.height\n\n if (lastResizeWidthRef.current?.width === newResizeWidth\n && lastResizeWidthRef.current?.height === newResizeHeight) {\n return\n }\n lastResizeWidthRef.current = { width: newResizeWidth, height: newResizeHeight }\n\n // eslint-disable-next-line semi-style\n ;(callBack || setContainerSize)({\n width: containerRef?.current?.clientWidth,\n height: containerRef?.current?.clientHeight,\n })\n }, debounceDelay), [callBack, debounceDelay])\n\n useLayoutEffect(() => {\n let resizeObserver: ResizeObserver\n let containerElement: HTMLElement\n\n if (containerRef?.current) {\n containerElement = containerRef?.current\n resizeObserver = new ResizeObserver(debouncedResizeWrapper)\n resizeObserver.observe(containerElement as Element)\n\n // eslint-disable-next-line semi-style\n ;(callBack || setContainerSize)({\n width: containerRef?.current?.clientWidth,\n height: containerRef?.current?.clientHeight,\n })\n }\n\n const unobserver = (): void => {\n resizeObserver?.unobserve?.(containerElement as Element)\n }\n\n // setUnobserver(unobserver)\n unobserverRef.current = unobserver\n\n return unobserver\n }, [debouncedResizeWrapper, containerRef, callBack])\n\n return [containerRef, containerSize, unobserverRef.current]\n}\n"],"names":["useResize","debounceDelay","arguments","length","undefined","callBack","containerSize","setContainerSize","useState","width","height","lastResizeWidthRef","useRef","containerRef","unobserverRef","debouncedResizeWrapper","useMemo","debounce","entries","newResizeWidth","contentRect","newResizeHeight","current","clientWidth","clientHeight","useLayoutEffect","resizeObserver","containerElement","ResizeObserver","observe","unobserver","unobserve"],"mappings":"0IAWaA,MAAAA,EAAY,WACmE,IADlEC,EAAaC,UAAAC,OAAA,QAAAC,IAAAF,UAAA,GAAAA,UAAA,GAAG,IAAKG,EAA4BH,UAAAC,OAAAD,EAAAA,kBAAAE,EAEzE,MAAOE,EAAeC,GAClBC,EAAsB,CAAEC,WAAOL,EAAWM,YAAQN,IAEhDO,EAAqBC,EAAoB,CAAEH,MAAO,EAAGC,OAAQ,IAC7DG,EAAiED,IACjEE,EAAgBF,IAEhBG,EAAyBC,GAAQ,IAAMC,GAAUC,IACrD,MAAMC,EAAiBD,EAAQ,GAAGE,YAAYX,MACxCY,EAAkBH,EAAQ,GAAGE,YAAYV,OAE3CC,EAAmBW,SAASb,QAAUU,GACrCR,EAAmBW,SAASZ,SAAWW,IAG5CV,EAAmBW,QAAU,CAAEb,MAAOU,EAAgBT,OAAQW,IAG5DhB,GAAYE,GAAkB,CAC9BE,MAAOI,GAAcS,SAASC,YAC9Bb,OAAQG,GAAcS,SAASE,eAC/B,GACDvB,IAAgB,CAACI,EAAUJ,IA4B9B,OA1BAwB,GAAgB,KACd,IAAIC,EACAC,EAEAd,GAAcS,UAChBK,EAAmBd,GAAcS,QACjCI,EAAiB,IAAIE,eAAeb,GACpCW,EAAeG,QAAQF,IAGrBtB,GAAYE,GAAkB,CAC9BE,MAAOI,GAAcS,SAASC,YAC9Bb,OAAQG,GAAcS,SAASE,gBAInC,MAAMM,EAAaA,KACjBJ,GAAgBK,YAAYJ,EAA4B,EAM1D,OAFAb,EAAcQ,QAAUQ,EAEjBA,CAAU,GAChB,CAACf,EAAwBF,EAAcR,IAEnC,CAACQ,EAAcP,EAAeQ,EAAcQ,QACrD"}
1
+ {"version":3,"file":"useResize.js","sources":["../../../../../../src/core/hooks/useResize.ts"],"sourcesContent":["import { MutableRefObject, useLayoutEffect, useMemo, useState, useRef } from 'react'\nimport debounce from 'lodash-es/debounce'\n\n/**\n * Type definition for the size of the wrapper element.\n * @typedef {Object} WrapperSize\n * @property {undefined | number} width - The width of the wrapper element.\n * @property {undefined | number} height - The height of the wrapper element.\n */\nexport type WrapperSize = { width: undefined | number; height: undefined | number }\n\n/**\n * Type definition for the unobserver function.\n * @typedef {() => (null | void)} Unobserver\n */\ntype Unobserver = () => (null | void)\n\n/**\n * Type definition for the resize callback function.\n * @typedef {(wrapperSize: WrapperSize) => void} UseResizeCallBack\n */\nexport type UseResizeCallBack = (wrapperSize: WrapperSize) => void\n\n/**\n * Custom hook to observe the resize event of an HTML element\n * and execute a callback or update the state with the new size.\n * @param {number} [debounceDelay=250] - The delay in milliseconds for debouncing the resize event.\n * @param {UseResizeCallBack} [callBack] - Optional callback function to execute when the element is resized.\n * @returns {[MutableRefObject<HTMLElement | null | undefined>, WrapperSize, Unobserver | undefined]}\n * An array containing the ref object for the container element,\n * the current size of the container, and an unobserver function.\n */\n// eslint-disable-next-line default-param-last\nexport const useResize = (debounceDelay = 250, callBack?: UseResizeCallBack): [\n MutableRefObject<HTMLElement | null | undefined>, WrapperSize, Unobserver | undefined] => {\n const [containerSize, setContainerSize] = useState<WrapperSize>({ width: undefined, height: undefined })\n\n const lastResizeWidthRef = useRef<WrapperSize>({ width: 0, height: 0 })\n const containerRef: MutableRefObject<HTMLElement | undefined | null> = useRef<HTMLElement | undefined | null>()\n const unobserverRef = useRef<Unobserver>()\n\n const debouncedResizeWrapper = useMemo(() => debounce((entries) => {\n const newResizeWidth = entries[0].contentRect.width\n const newResizeHeight = entries[0].contentRect.height\n\n if (lastResizeWidthRef.current?.width === newResizeWidth\n && lastResizeWidthRef.current?.height === newResizeHeight) {\n return\n }\n lastResizeWidthRef.current = { width: newResizeWidth, height: newResizeHeight }\n\n // eslint-disable-next-line semi-style\n ;(callBack || setContainerSize)({\n width: containerRef?.current?.clientWidth,\n height: containerRef?.current?.clientHeight,\n })\n }, debounceDelay), [callBack, debounceDelay])\n\n useLayoutEffect(() => {\n let resizeObserver: ResizeObserver\n let containerElement: HTMLElement\n\n if (containerRef?.current) {\n containerElement = containerRef?.current\n resizeObserver = new ResizeObserver(debouncedResizeWrapper)\n resizeObserver.observe(containerElement as Element)\n\n // eslint-disable-next-line semi-style\n ;(callBack || setContainerSize)({\n width: containerRef?.current?.clientWidth,\n height: containerRef?.current?.clientHeight,\n })\n }\n\n const unobserver = (): void => {\n resizeObserver?.unobserve?.(containerElement as Element)\n }\n\n // setUnobserver(unobserver)\n unobserverRef.current = unobserver\n\n return unobserver\n }, [debouncedResizeWrapper, containerRef, callBack])\n\n return [containerRef, containerSize, unobserverRef.current]\n}\n"],"names":["useResize","debounceDelay","arguments","length","undefined","callBack","containerSize","setContainerSize","useState","width","height","lastResizeWidthRef","useRef","containerRef","unobserverRef","debouncedResizeWrapper","useMemo","debounce","entries","newResizeWidth","contentRect","newResizeHeight","current","clientWidth","clientHeight","useLayoutEffect","resizeObserver","containerElement","ResizeObserver","observe","unobserver","unobserve"],"mappings":"0IAiCaA,MAAAA,EAAY,WACmE,IADlEC,EAAaC,UAAAC,OAAA,QAAAC,IAAAF,UAAA,GAAAA,UAAA,GAAG,IAAKG,EAA4BH,UAAAC,OAAAD,EAAAA,kBAAAE,EAEzE,MAAOE,EAAeC,GAAoBC,EAAsB,CAAEC,WAAOL,EAAWM,YAAQN,IAEtFO,EAAqBC,EAAoB,CAAEH,MAAO,EAAGC,OAAQ,IAC7DG,EAAiED,IACjEE,EAAgBF,IAEhBG,EAAyBC,GAAQ,IAAMC,GAAUC,IACrD,MAAMC,EAAiBD,EAAQ,GAAGE,YAAYX,MACxCY,EAAkBH,EAAQ,GAAGE,YAAYV,OAE3CC,EAAmBW,SAASb,QAAUU,GACrCR,EAAmBW,SAASZ,SAAWW,IAG5CV,EAAmBW,QAAU,CAAEb,MAAOU,EAAgBT,OAAQW,IAG5DhB,GAAYE,GAAkB,CAC9BE,MAAOI,GAAcS,SAASC,YAC9Bb,OAAQG,GAAcS,SAASE,eAC/B,GACDvB,IAAgB,CAACI,EAAUJ,IA4B9B,OA1BAwB,GAAgB,KACd,IAAIC,EACAC,EAEAd,GAAcS,UAChBK,EAAmBd,GAAcS,QACjCI,EAAiB,IAAIE,eAAeb,GACpCW,EAAeG,QAAQF,IAGrBtB,GAAYE,GAAkB,CAC9BE,MAAOI,GAAcS,SAASC,YAC9Bb,OAAQG,GAAcS,SAASE,gBAInC,MAAMM,EAAaA,KACjBJ,GAAgBK,YAAYJ,EAA4B,EAM1D,OAFAb,EAAcQ,QAAUQ,EAEjBA,CAAU,GAChB,CAACf,EAAwBF,EAAcR,IAEnC,CAACQ,EAAcP,EAAeQ,EAAcQ,QACrD"}
@@ -1,2 +1,2 @@
1
- import{useEffect as e}from"react";const o="change",t=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:()=>document.body,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e=>e;const s=o=>{const s=e();a?.(o,s),t?.(o)},r=e=>{s(e.matches)},c=e=>{s(!e.matches)},d=window.matchMedia("(prefers-color-scheme: dark)");try{window.matchMedia("(prefers-color-scheme: dark)").removeEventListener(o,r),window.matchMedia("(prefers-color-scheme: light)").removeEventListener(o,c)}catch(e){}return s(d?.matches),window.matchMedia("(prefers-color-scheme: dark)").addEventListener(o,r),window.matchMedia("(prefers-color-scheme: light)").addEventListener(o,c),()=>{window.matchMedia("(prefers-color-scheme: dark)").removeEventListener(o,r),window.matchMedia("(prefers-color-scheme: light)").removeEventListener(o,c)}},s=function(){let o=arguments.length>0&&void 0!==arguments[0]?arguments[0]:()=>document.body,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e=>e;e((()=>t(o,s)),[o,s])};let r={dark:"theme-dark",light:"theme-light"};const c=()=>r,d=e=>{r=e},a=function(e,o){let t=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];const s=e?r.light:r.dark,c=e?r.dark:r.light;o&&(o.classList.remove(s),o.classList.remove(c),o.classList.add(c)),"undefined"!=typeof document&&(document.querySelectorAll(`.${s}`).forEach((e=>{e.classList.add(`.${c}`),e.classList.remove(`.${s}`)})),t&&(document.querySelectorAll(".shadow-div").forEach((e=>{e.shadowRoot?.querySelector(`.${s}`)?.classList.add(c),e.shadowRoot?.querySelector(`.${s}`)?.classList.remove(s)})),document.querySelectorAll("esmf-wrapper").forEach((e=>{e.shadowRoot?.querySelector(`.${s}`)?.classList.add(c),e.shadowRoot?.querySelector(`.${s}`)?.classList.remove(s);const o=e.shadowRoot?.childNodes[0];o&&(o.classList.add(c),o.classList.remove(s))}))))},i=(e,o)=>{let t=e||!1;"undefined"!=typeof document&&void 0===e&&(t=document.body.classList.contains(r.dark)),a(t,o||document.body)};export{c as getBaseThemes,t as observeThemePreference,d as setTHemeClassNames,a as switchColorTheme,i as updateColorTheme,s as useThemePreference};
1
+ import{useEffect as e}from"react";const o="change",t=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:()=>document.body,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e=>e;const s=o=>{const s=e();a?.(o,s),t?.(o)},r=e=>{s(e.matches)},c=e=>{s(!e.matches)},d=window.matchMedia("(prefers-color-scheme: dark)");try{window.matchMedia("(prefers-color-scheme: dark)").removeEventListener(o,r),window.matchMedia("(prefers-color-scheme: light)").removeEventListener(o,c)}catch(e){}return s(d?.matches),window.matchMedia("(prefers-color-scheme: dark)").addEventListener(o,r),window.matchMedia("(prefers-color-scheme: light)").addEventListener(o,c),()=>{window.matchMedia("(prefers-color-scheme: dark)").removeEventListener(o,r),window.matchMedia("(prefers-color-scheme: light)").removeEventListener(o,c)}},s=function(){let o=arguments.length>0&&void 0!==arguments[0]?arguments[0]:()=>document.body,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e=>e;e((()=>t(o,s)),[o,s])};let r={dark:"theme-dark",light:"theme-light"};const c=()=>r,d=e=>{r=e},a=function(e,o){let t=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];const s=e?r.light:r.dark,c=e?r.dark:r.light;o&&(o.classList.remove(s),o.classList.remove(c),o.classList.add(c)),"undefined"!=typeof document&&(document.querySelectorAll(`.${s}`).forEach((e=>{e.classList.add(`.${c}`),e.classList.remove(`.${s}`)})),t&&(document.querySelectorAll(".shadow-div").forEach((e=>{e.shadowRoot?.querySelector(`.${s}`)?.classList.add(c),e.shadowRoot?.querySelector(`.${s}`)?.classList.remove(s)})),document.querySelectorAll("esmf-wrapper").forEach((e=>{e.shadowRoot?.querySelector(`.${s}`)?.classList.add(c),e.shadowRoot?.querySelector(`.${s}`)?.classList.remove(s);const o=e.shadowRoot?.childNodes[0];o&&(o.classList.add(c),o.classList.remove(s))}))))},i=(e,o)=>{let t=e||!1;"undefined"!=typeof document&&void 0===e&&(t=document.body.classList.contains(r.dark)),a(t,o||document.body)};export{c as getBaseThemes,t as observeThemePreference,d as setThemeClassNames,a as switchColorTheme,i as updateColorTheme,s as useThemePreference};
2
2
  //# sourceMappingURL=useThemePreference.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useThemePreference.js","sources":["../../../../../../src/core/hooks/useThemePreference.ts"],"sourcesContent":["import { useEffect } from 'react'\n\n\nconst windowMatchMediaChangeEventType = 'change'\n\nexport const observeThemePreference = (\n getHtmlElement: () => HTMLElement = (): HTMLElement => document.body,\n switchCallback: (isDark: boolean) => void = (isDark: boolean): boolean => isDark,\n): () => void => {\n const switchColorThemeHandler = (isDark: boolean): void => {\n const htmlElement = getHtmlElement()\n\n switchColorTheme?.(isDark, htmlElement)\n switchCallback?.(isDark)\n }\n\n const changeDarkColorThemeHandler = (event: MediaQueryListEvent): void => {\n switchColorThemeHandler(event.matches)\n }\n\n const changeLightColorThemeHandler = (event: MediaQueryListEvent): void => {\n switchColorThemeHandler(!event.matches)\n }\n\n const isDark = window.matchMedia('(prefers-color-scheme: dark)')\n\n try {\n window.matchMedia('(prefers-color-scheme: dark)').removeEventListener(\n windowMatchMediaChangeEventType, changeDarkColorThemeHandler,\n )\n window.matchMedia('(prefers-color-scheme: light)').removeEventListener(\n windowMatchMediaChangeEventType, changeLightColorThemeHandler,\n )\n } catch (error) {\n console.error(`Error::observeThemePreference::removeEventListener: ${error}`)\n }\n\n switchColorThemeHandler(isDark?.matches)\n window.matchMedia('(prefers-color-scheme: dark)').addEventListener(\n windowMatchMediaChangeEventType, changeDarkColorThemeHandler,\n )\n window.matchMedia('(prefers-color-scheme: light)').addEventListener(\n windowMatchMediaChangeEventType, changeLightColorThemeHandler,\n )\n\n return () => {\n window.matchMedia('(prefers-color-scheme: dark)').removeEventListener(\n windowMatchMediaChangeEventType, changeDarkColorThemeHandler,\n )\n window.matchMedia('(prefers-color-scheme: light)').removeEventListener(\n windowMatchMediaChangeEventType, changeLightColorThemeHandler,\n )\n }\n}\n\nexport const useThemePreference = (\n getHtmlElement: () => HTMLElement = (): HTMLElement => document.body,\n switchCallback: (isDark: boolean) => void = (isDark: boolean): boolean => isDark,\n): void => {\n useEffect(() => observeThemePreference(getHtmlElement, switchCallback), [getHtmlElement, switchCallback])\n}\n\ntype ThemeMap = {\n dark: string\n light: string\n}\n\nlet baseThemes: ThemeMap = {\n dark: 'theme-dark',\n light: 'theme-light',\n}\n\n\nexport const getBaseThemes = (): ThemeMap => baseThemes\n\nexport const setTHemeClassNames = (themes: ThemeMap): void => {\n baseThemes = themes\n}\n\nexport const switchColorTheme = (isDark: boolean, htmlElement?: HTMLElement, findShadows = true): void => {\n const oldClass = isDark ? baseThemes.light : baseThemes.dark\n const newClass = isDark ? baseThemes.dark : baseThemes.light\n\n if (htmlElement) {\n htmlElement.classList.remove(oldClass)\n htmlElement.classList.remove(newClass)\n htmlElement.classList.add(newClass)\n }\n\n if (typeof document !== 'undefined') {\n document.querySelectorAll(`.${oldClass}`).forEach((element) => {\n element.classList.add(`.${newClass}`)\n element.classList.remove(`.${oldClass}`)\n })\n\n if (findShadows) {\n document.querySelectorAll('.shadow-div').forEach((element) => {\n element.shadowRoot?.querySelector(`.${oldClass}`)?.classList.add(newClass)\n element.shadowRoot?.querySelector(`.${oldClass}`)?.classList.remove(oldClass)\n })\n\n document.querySelectorAll('esmf-wrapper').forEach((element) => {\n element.shadowRoot?.querySelector(`.${oldClass}`)?.classList.add(newClass)\n element.shadowRoot?.querySelector(`.${oldClass}`)?.classList.remove(oldClass)\n\n const firstChild: HTMLElement = element.shadowRoot?.childNodes[0] as HTMLElement\n\n if (firstChild) {\n firstChild.classList.add(newClass)\n firstChild.classList.remove(oldClass)\n }\n })\n }\n }\n}\n\nexport const updateColorTheme = (isDark?: boolean, htmlElement?: HTMLElement): void => {\n let resolvedIsDark: boolean = isDark || false\n\n if (typeof document !== 'undefined' && isDark === undefined) {\n resolvedIsDark = document.body.classList.contains(baseThemes.dark)\n }\n switchColorTheme(resolvedIsDark, htmlElement || document.body)\n}\n"],"names":["windowMatchMediaChangeEventType","observeThemePreference","getHtmlElement","arguments","length","undefined","document","body","switchCallback","isDark","switchColorThemeHandler","htmlElement","switchColorTheme","changeDarkColorThemeHandler","event","matches","changeLightColorThemeHandler","window","matchMedia","removeEventListener","error","addEventListener","useThemePreference","useEffect","baseThemes","dark","light","getBaseThemes","setTHemeClassNames","themes","findShadows","oldClass","newClass","classList","remove","add","querySelectorAll","forEach","element","shadowRoot","querySelector","firstChild","childNodes","updateColorTheme","resolvedIsDark","contains"],"mappings":"kCAGA,MAAMA,EAAkC,SAE3BC,EAAyB,WAGrB,IAFfC,EAAiCC,UAAAC,OAAAD,QAAAE,IAAAF,UAAAE,GAAAF,UAAA,GAAG,IAAmBG,SAASC,KAChEC,EAAyCL,UAAAC,OAAAD,QAAAE,IAAAF,UAAAE,GAAAF,UAAIM,GAAAA,GAA6BA,EAE1E,MAAMC,EAA2BD,IAC/B,MAAME,EAAcT,IAEpBU,IAAmBH,EAAQE,GAC3BH,IAAiBC,EAAO,EAGpBI,EAA+BC,IACnCJ,EAAwBI,EAAMC,QAAQ,EAGlCC,EAAgCF,IACpCJ,GAAyBI,EAAMC,QAAQ,EAGnCN,EAASQ,OAAOC,WAAW,gCAEjC,IACED,OAAOC,WAAW,gCAAgCC,oBAChDnB,EAAiCa,GAEnCI,OAAOC,WAAW,iCAAiCC,oBACjDnB,EAAiCgB,EAErC,CAAE,MAAOI,GAET,CAUA,OARAV,EAAwBD,GAAQM,SAChCE,OAAOC,WAAW,gCAAgCG,iBAChDrB,EAAiCa,GAEnCI,OAAOC,WAAW,iCAAiCG,iBACjDrB,EAAiCgB,GAG5B,KACLC,OAAOC,WAAW,gCAAgCC,oBAChDnB,EAAiCa,GAEnCI,OAAOC,WAAW,iCAAiCC,oBACjDnB,EAAiCgB,EAClC,CAEL,EAEaM,EAAqB,WAGvB,IAFTpB,EAAiCC,UAAAC,OAAAD,QAAAE,IAAAF,UAAAE,GAAAF,UAAA,GAAG,IAAmBG,SAASC,KAChEC,EAAyCL,UAAAC,OAAAD,QAAAE,IAAAF,UAAAE,GAAAF,UAAIM,GAAAA,GAA6BA,EAE1Ec,GAAU,IAAMtB,EAAuBC,EAAgBM,IAAiB,CAACN,EAAgBM,GAC3F,EAOA,IAAIgB,EAAuB,CACzBC,KAAM,aACNC,MAAO,eAIIC,MAAAA,EAAgBA,IAAgBH,EAEhCI,EAAsBC,IACjCL,EAAaK,CAAM,EAGRjB,EAAmB,SAACH,EAAiBE,GAAwD,IAA7BmB,IAAW3B,UAAAC,OAAA,QAAAC,IAAAF,UAAA,KAAAA,UAAA,GACtF,MAAM4B,EAAWtB,EAASe,EAAWE,MAAQF,EAAWC,KAClDO,EAAWvB,EAASe,EAAWC,KAAOD,EAAWE,MAEnDf,IACFA,EAAYsB,UAAUC,OAAOH,GAC7BpB,EAAYsB,UAAUC,OAAOF,GAC7BrB,EAAYsB,UAAUE,IAAIH,IAGJ,oBAAb1B,WACTA,SAAS8B,iBAAiB,IAAIL,KAAYM,SAASC,IACjDA,EAAQL,UAAUE,IAAI,IAAIH,KAC1BM,EAAQL,UAAUC,OAAO,IAAIH,IAAW,IAGtCD,IACFxB,SAAS8B,iBAAiB,eAAeC,SAASC,IAChDA,EAAQC,YAAYC,cAAc,IAAIT,MAAaE,UAAUE,IAAIH,GACjEM,EAAQC,YAAYC,cAAc,IAAIT,MAAaE,UAAUC,OAAOH,EAAS,IAG/EzB,SAAS8B,iBAAiB,gBAAgBC,SAASC,IACjDA,EAAQC,YAAYC,cAAc,IAAIT,MAAaE,UAAUE,IAAIH,GACjEM,EAAQC,YAAYC,cAAc,IAAIT,MAAaE,UAAUC,OAAOH,GAEpE,MAAMU,EAA0BH,EAAQC,YAAYG,WAAW,GAE3DD,IACFA,EAAWR,UAAUE,IAAIH,GACzBS,EAAWR,UAAUC,OAAOH,GAC9B,KAIR,EAEaY,EAAmBA,CAAClC,EAAkBE,KACjD,IAAIiC,EAA0BnC,IAAU,EAEhB,oBAAbH,eAAuCD,IAAXI,IACrCmC,EAAiBtC,SAASC,KAAK0B,UAAUY,SAASrB,EAAWC,OAE/Db,EAAiBgC,EAAgBjC,GAAeL,SAASC,KAAK"}
1
+ {"version":3,"file":"useThemePreference.js","sources":["../../../../../../src/core/hooks/useThemePreference.ts"],"sourcesContent":["import { useEffect } from 'react'\n\n\nconst windowMatchMediaChangeEventType = 'change'\n\n/**\n * Observes the user's theme preference and applies the appropriate theme.\n * @param {() => HTMLElement} [getHtmlElement] - Function to get the HTML element to which the theme will be applied.\n * @param {(isDark: boolean) => void} [switchCallback] - Callback function to execute when the theme changes.\n * @returns {() => void} Function to stop observing the theme preference.\n */\nexport const observeThemePreference = (\n getHtmlElement: () => HTMLElement = (): HTMLElement => document.body,\n switchCallback: (isDark: boolean) => void = (isDark: boolean): boolean => isDark,\n): () => void => {\n const switchColorThemeHandler = (isDark: boolean): void => {\n const htmlElement = getHtmlElement()\n\n switchColorTheme?.(isDark, htmlElement)\n switchCallback?.(isDark)\n }\n\n const changeDarkColorThemeHandler = (event: MediaQueryListEvent): void => {\n switchColorThemeHandler(event.matches)\n }\n\n const changeLightColorThemeHandler = (event: MediaQueryListEvent): void => {\n switchColorThemeHandler(!event.matches)\n }\n\n const isDark = window.matchMedia('(prefers-color-scheme: dark)')\n\n try {\n window.matchMedia('(prefers-color-scheme: dark)').removeEventListener(\n windowMatchMediaChangeEventType, changeDarkColorThemeHandler,\n )\n window.matchMedia('(prefers-color-scheme: light)').removeEventListener(\n windowMatchMediaChangeEventType, changeLightColorThemeHandler,\n )\n } catch (error) {\n console.error(`Error::observeThemePreference::removeEventListener: ${error}`)\n }\n\n switchColorThemeHandler(isDark?.matches)\n window.matchMedia('(prefers-color-scheme: dark)').addEventListener(\n windowMatchMediaChangeEventType, changeDarkColorThemeHandler,\n )\n window.matchMedia('(prefers-color-scheme: light)').addEventListener(\n windowMatchMediaChangeEventType, changeLightColorThemeHandler,\n )\n\n return () => {\n window.matchMedia('(prefers-color-scheme: dark)').removeEventListener(\n windowMatchMediaChangeEventType, changeDarkColorThemeHandler,\n )\n window.matchMedia('(prefers-color-scheme: light)').removeEventListener(\n windowMatchMediaChangeEventType, changeLightColorThemeHandler,\n )\n }\n}\n\n/**\n * Custom hook to use theme preference in a React component.\n * @param {() => HTMLElement} [getHtmlElement] - Function to get the HTML element to which the theme will be applied.\n * @param {(isDark: boolean) => void} [switchCallback] - Callback function to execute when the theme changes.\n */\nexport const useThemePreference = (\n getHtmlElement: () => HTMLElement = (): HTMLElement => document.body,\n switchCallback: (isDark: boolean) => void = (isDark: boolean): boolean => isDark,\n): void => {\n useEffect(() => observeThemePreference(getHtmlElement, switchCallback), [getHtmlElement, switchCallback])\n}\n\n/**\n * Type definition for theme map.\n * @typedef {Object} ThemeMap\n * @property {string} dark - CSS class for the dark theme.\n * @property {string} light - CSS class for the light theme.\n */\ntype ThemeMap = {\n dark: string\n light: string\n}\n\nlet baseThemes: ThemeMap = {\n dark: 'theme-dark',\n light: 'theme-light',\n}\n\n/**\n * Gets the base themes.\n * @returns {ThemeMap} The current base themes.\n */\nexport const getBaseThemes = (): ThemeMap => baseThemes\n\n/**\n * Sets the base theme class names.\n * @param {ThemeMap} themes - Object containing the CSS classes for dark and light themes.\n */\nexport const setThemeClassNames = (themes: ThemeMap): void => {\n baseThemes = themes\n}\n\n/**\n * Switches the color theme of the document.\n * @param {boolean} isDark - Flag to determine if the dark theme should be applied.\n * @param {HTMLElement} [htmlElement] - The HTML element to which the theme will be applied.\n * @param {boolean} [findShadows=true] - Flag to determine if shadow DOM elements should also be themed.\n */\nexport const switchColorTheme = (isDark: boolean, htmlElement?: HTMLElement, findShadows = true): void => {\n const oldClass = isDark ? baseThemes.light : baseThemes.dark\n const newClass = isDark ? baseThemes.dark : baseThemes.light\n\n if (htmlElement) {\n htmlElement.classList.remove(oldClass)\n htmlElement.classList.remove(newClass)\n htmlElement.classList.add(newClass)\n }\n\n if (typeof document !== 'undefined') {\n document.querySelectorAll(`.${oldClass}`).forEach((element) => {\n element.classList.add(`.${newClass}`)\n element.classList.remove(`.${oldClass}`)\n })\n\n if (findShadows) {\n document.querySelectorAll('.shadow-div').forEach((element) => {\n element.shadowRoot?.querySelector(`.${oldClass}`)?.classList.add(newClass)\n element.shadowRoot?.querySelector(`.${oldClass}`)?.classList.remove(oldClass)\n })\n\n document.querySelectorAll('esmf-wrapper').forEach((element) => {\n element.shadowRoot?.querySelector(`.${oldClass}`)?.classList.add(newClass)\n element.shadowRoot?.querySelector(`.${oldClass}`)?.classList.remove(oldClass)\n\n const firstChild: HTMLElement = element.shadowRoot?.childNodes[0] as HTMLElement\n\n if (firstChild) {\n firstChild.classList.add(newClass)\n firstChild.classList.remove(oldClass)\n }\n })\n }\n }\n}\n\n/**\n * Updates the color theme of the document.\n * @param {boolean} [isDark] - Optional flag to determine if the dark theme should be applied.\n * @param {HTMLElement} [htmlElement] - The HTML element to which the theme will be applied.\n */\nexport const updateColorTheme = (isDark?: boolean, htmlElement?: HTMLElement): void => {\n let resolvedIsDark: boolean = isDark || false\n\n if (typeof document !== 'undefined' && isDark === undefined) {\n resolvedIsDark = document.body.classList.contains(baseThemes.dark)\n }\n switchColorTheme(resolvedIsDark, htmlElement || document.body)\n}\n"],"names":["windowMatchMediaChangeEventType","observeThemePreference","getHtmlElement","arguments","length","undefined","document","body","switchCallback","isDark","switchColorThemeHandler","htmlElement","switchColorTheme","changeDarkColorThemeHandler","event","matches","changeLightColorThemeHandler","window","matchMedia","removeEventListener","error","addEventListener","useThemePreference","useEffect","baseThemes","dark","light","getBaseThemes","setThemeClassNames","themes","findShadows","oldClass","newClass","classList","remove","add","querySelectorAll","forEach","element","shadowRoot","querySelector","firstChild","childNodes","updateColorTheme","resolvedIsDark","contains"],"mappings":"kCAGA,MAAMA,EAAkC,SAQ3BC,EAAyB,WAGrB,IAFfC,EAAiCC,UAAAC,OAAAD,QAAAE,IAAAF,UAAAE,GAAAF,UAAA,GAAG,IAAmBG,SAASC,KAChEC,EAAyCL,UAAAC,OAAAD,QAAAE,IAAAF,UAAAE,GAAAF,UAAIM,GAAAA,GAA6BA,EAE1E,MAAMC,EAA2BD,IAC/B,MAAME,EAAcT,IAEpBU,IAAmBH,EAAQE,GAC3BH,IAAiBC,EAAO,EAGpBI,EAA+BC,IACnCJ,EAAwBI,EAAMC,QAAQ,EAGlCC,EAAgCF,IACpCJ,GAAyBI,EAAMC,QAAQ,EAGnCN,EAASQ,OAAOC,WAAW,gCAEjC,IACED,OAAOC,WAAW,gCAAgCC,oBAChDnB,EAAiCa,GAEnCI,OAAOC,WAAW,iCAAiCC,oBACjDnB,EAAiCgB,EAErC,CAAE,MAAOI,GAET,CAUA,OARAV,EAAwBD,GAAQM,SAChCE,OAAOC,WAAW,gCAAgCG,iBAChDrB,EAAiCa,GAEnCI,OAAOC,WAAW,iCAAiCG,iBACjDrB,EAAiCgB,GAG5B,KACLC,OAAOC,WAAW,gCAAgCC,oBAChDnB,EAAiCa,GAEnCI,OAAOC,WAAW,iCAAiCC,oBACjDnB,EAAiCgB,EAClC,CAEL,EAOaM,EAAqB,WAGvB,IAFTpB,EAAiCC,UAAAC,OAAAD,QAAAE,IAAAF,UAAAE,GAAAF,UAAA,GAAG,IAAmBG,SAASC,KAChEC,EAAyCL,UAAAC,OAAAD,QAAAE,IAAAF,UAAAE,GAAAF,UAAIM,GAAAA,GAA6BA,EAE1Ec,GAAU,IAAMtB,EAAuBC,EAAgBM,IAAiB,CAACN,EAAgBM,GAC3F,EAaA,IAAIgB,EAAuB,CACzBC,KAAM,aACNC,MAAO,eAOIC,MAAAA,EAAgBA,IAAgBH,EAMhCI,EAAsBC,IACjCL,EAAaK,CAAM,EASRjB,EAAmB,SAACH,EAAiBE,GAAwD,IAA7BmB,IAAW3B,UAAAC,OAAA,QAAAC,IAAAF,UAAA,KAAAA,UAAA,GACtF,MAAM4B,EAAWtB,EAASe,EAAWE,MAAQF,EAAWC,KAClDO,EAAWvB,EAASe,EAAWC,KAAOD,EAAWE,MAEnDf,IACFA,EAAYsB,UAAUC,OAAOH,GAC7BpB,EAAYsB,UAAUC,OAAOF,GAC7BrB,EAAYsB,UAAUE,IAAIH,IAGJ,oBAAb1B,WACTA,SAAS8B,iBAAiB,IAAIL,KAAYM,SAASC,IACjDA,EAAQL,UAAUE,IAAI,IAAIH,KAC1BM,EAAQL,UAAUC,OAAO,IAAIH,IAAW,IAGtCD,IACFxB,SAAS8B,iBAAiB,eAAeC,SAASC,IAChDA,EAAQC,YAAYC,cAAc,IAAIT,MAAaE,UAAUE,IAAIH,GACjEM,EAAQC,YAAYC,cAAc,IAAIT,MAAaE,UAAUC,OAAOH,EAAS,IAG/EzB,SAAS8B,iBAAiB,gBAAgBC,SAASC,IACjDA,EAAQC,YAAYC,cAAc,IAAIT,MAAaE,UAAUE,IAAIH,GACjEM,EAAQC,YAAYC,cAAc,IAAIT,MAAaE,UAAUC,OAAOH,GAEpE,MAAMU,EAA0BH,EAAQC,YAAYG,WAAW,GAE3DD,IACFA,EAAWR,UAAUE,IAAIH,GACzBS,EAAWR,UAAUC,OAAOH,GAC9B,KAIR,EAOaY,EAAmBA,CAAClC,EAAkBE,KACjD,IAAIiC,EAA0BnC,IAAU,EAEhB,oBAAbH,eAAuCD,IAAXI,IACrCmC,EAAiBtC,SAASC,KAAK0B,UAAUY,SAASrB,EAAWC,OAE/Db,EAAiBgC,EAAgBjC,GAAeL,SAASC,KAAK"}
@@ -1 +1 @@
1
- {"version":3,"file":"useToggle.js","sources":["../../../../../../src/core/hooks/useToggle.ts"],"sourcesContent":["import { useState, useCallback } from 'react'\n\n\nexport type useTogggleReturnType = [\n boolean,\n (value?: any | boolean) => void,\n (value?: any | boolean) => void,\n (value?: any | boolean) => void\n]\n\nexport const useToggle = (defaultValue: boolean, async = true): useTogggleReturnType => {\n const [toggled, setToggled] = useState(defaultValue)\n\n const handleToggle: (value?: any | boolean) => void = useCallback((value?: any | boolean) => {\n if (async) {\n setToggled((prevToggled) => (typeof (value) === 'boolean' ? value : !prevToggled))\n } else {\n setToggled((value !== undefined && value !== null ? value : !toggled))\n }\n }, [async, toggled, setToggled])\n\n const handleToggleTrue = useCallback(\n (forceValue?: boolean) => handleToggle(forceValue === undefined ? true : forceValue), [handleToggle],\n )\n\n const handleToggleFalse = useCallback(\n (forceValue?: boolean) => handleToggle(forceValue === undefined ? false : forceValue), [handleToggle],\n )\n\n return [toggled, handleToggle, handleToggleTrue, handleToggleFalse]\n}\n"],"names":["useToggle","defaultValue","async","arguments","length","undefined","toggled","setToggled","useState","handleToggle","useCallback","value","prevToggled","handleToggleTrue","forceValue","handleToggleFalse"],"mappings":"wDAUaA,EAAY,SAACC,GAA8D,IAAvCC,IAAKC,UAAAC,OAAA,QAAAC,IAAAF,UAAA,KAAAA,UAAA,GACpD,MAAOG,EAASC,GAAcC,EAASP,GAEjCQ,EAAgDC,GAAaC,IAE/DJ,EADEL,EACUU,GAAoC,kBAAXD,EAAuBA,GAASC,EAEzDD,QAAwCA,GAASL,EAC/D,GACC,CAACJ,EAAOI,EAASC,IAEdM,EAAmBH,GACtBI,GAAyBL,OAA4BJ,IAAfS,GAAkCA,IAAa,CAACL,IAGnFM,EAAoBL,GACvBI,GAAyBL,OAA4BJ,IAAfS,GAAmCA,IAAa,CAACL,IAG1F,MAAO,CAACH,EAASG,EAAcI,EAAkBE,EACnD"}
1
+ {"version":3,"file":"useToggle.js","sources":["../../../../../../src/core/hooks/useToggle.ts"],"sourcesContent":["import { useState, useCallback } from 'react'\n\n/**\n * Type definition for the return value of the `useToggle` hook.\n * @typedef {Array} useToggleReturnType\n * @property {boolean} 0 - The current toggled state.\n * @property {(value?: any | boolean) => void} 1 - Function to toggle the state.\n * @property {(value?: any | boolean) => void} 2 - Function to forcefully set the state to true.\n * @property {(value?: any | boolean) => void} 3 - Function to forcefully set the state to false.\n */\nexport type useToggleReturnType = [\n boolean,\n (value?: any | boolean) => void,\n (value?: any | boolean) => void,\n (value?: any | boolean) => void\n]\n\n/**\n * Custom hook to manage a boolean state with toggle functionality.\n * @param {boolean} defaultValue - The initial value of the toggled state.\n * @param {boolean} [async=true] - Flag to determine if the toggle should be asynchronous.\n * @returns {useToggleReturnType} An array containing the current state, a toggle function,\n * and functions to set the state to true or false.\n */\nexport const useToggle = (defaultValue: boolean, async = true): useToggleReturnType => {\n const [toggled, setToggled] = useState(defaultValue)\n\n /**\n * Function to toggle the state.\n * @param {any | boolean} [value] - Optional value to set the state. If not provided, the state will be toggled.\n */\n const handleToggle: (value?: any | boolean) => void = useCallback((value?: any | boolean) => {\n if (async) {\n setToggled((prevToggled) => (typeof (value) === 'boolean' ? value : !prevToggled))\n } else {\n setToggled((value !== undefined && value !== null ? value : !toggled))\n }\n }, [async, toggled, setToggled])\n\n /**\n * Function to set the state to true.\n * @param {boolean} [forceValue] - Optional value to forcefully set the state.\n * If not provided, the state will be set to true.\n */\n const handleToggleTrue = useCallback(\n (forceValue?: boolean) => handleToggle(forceValue === undefined ? true : forceValue), [handleToggle],\n )\n\n /**\n * Function to set the state to false.\n * @param {boolean} [forceValue] - Optional value to forcefully set the state.\n * If not provided, the state will be set to false.\n */\n const handleToggleFalse = useCallback(\n (forceValue?: boolean) => handleToggle(forceValue === undefined ? false : forceValue), [handleToggle],\n )\n\n return [toggled, handleToggle, handleToggleTrue, handleToggleFalse]\n}\n"],"names":["useToggle","defaultValue","async","arguments","length","undefined","toggled","setToggled","useState","handleToggle","useCallback","value","prevToggled","handleToggleTrue","forceValue","handleToggleFalse"],"mappings":"wDAwBaA,EAAY,SAACC,GAA6D,IAAtCC,IAAKC,UAAAC,OAAA,QAAAC,IAAAF,UAAA,KAAAA,UAAA,GACpD,MAAOG,EAASC,GAAcC,EAASP,GAMjCQ,EAAgDC,GAAaC,IAE/DJ,EADEL,EACUU,GAAoC,kBAAXD,EAAuBA,GAASC,EAEzDD,QAAwCA,GAASL,EAC/D,GACC,CAACJ,EAAOI,EAASC,IAOdM,EAAmBH,GACtBI,GAAyBL,OAA4BJ,IAAfS,GAAkCA,IAAa,CAACL,IAQnFM,EAAoBL,GACvBI,GAAyBL,OAA4BJ,IAAfS,GAAmCA,IAAa,CAACL,IAG1F,MAAO,CAACH,EAASG,EAAcI,EAAkBE,EACnD"}