@e1011/es-kit 1.1.85 → 1.2.0

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 (71) hide show
  1. package/dist/hooks/esm/index.css +333 -333
  2. package/dist/hooks/esm/src/core/hooks/index.js +1 -1
  3. package/dist/hooks/esm/src/core/hooks/useThemePreference.js +1 -1
  4. package/dist/hooks/esm/src/core/hooks/useThemePreference.js.map +1 -1
  5. package/dist/hooks/esm/src/core/utils/helpers/ui.js +1 -1
  6. package/dist/hooks/esm/src/core/utils/helpers/ui.js.map +1 -1
  7. package/dist/hooks/index.css +333 -333
  8. package/dist/hooks/src/core/hooks/index.js +1 -1
  9. package/dist/hooks/src/core/hooks/useThemePreference.js +1 -1
  10. package/dist/hooks/src/core/hooks/useThemePreference.js.map +1 -1
  11. package/dist/hooks/src/core/utils/helpers/ui.js +1 -1
  12. package/dist/hooks/src/core/utils/helpers/ui.js.map +1 -1
  13. package/dist/lib/cjs/src/core/hooks/useThemePreference.js +1 -1
  14. package/dist/lib/cjs/src/core/hooks/useThemePreference.js.map +1 -1
  15. package/dist/lib/cjs/src/core/ui/components/atoms/icons.js +1 -1
  16. package/dist/lib/cjs/src/core/ui/components/atoms/icons.js.map +1 -1
  17. package/dist/lib/cjs/src/core/ui/components/atoms/text/Text.js +1 -1
  18. package/dist/lib/cjs/src/core/ui/components/atoms/text/Text.js.map +1 -1
  19. package/dist/lib/cjs/src/core/ui/components/error/ErrorBoundary.js.map +1 -1
  20. package/dist/lib/cjs/src/core/ui/components/molecules/popover/PopoverLite.js +1 -1
  21. package/dist/lib/cjs/src/core/ui/components/molecules/popover/PopoverLite.js.map +1 -1
  22. package/dist/lib/cjs/src/core/utils/helpers/ui.js +1 -1
  23. package/dist/lib/cjs/src/core/utils/helpers/ui.js.map +1 -1
  24. package/dist/lib/cjs/src/index.js +1 -1
  25. package/dist/lib/esm/src/core/hooks/useThemePreference.js +1 -1
  26. package/dist/lib/esm/src/core/hooks/useThemePreference.js.map +1 -1
  27. package/dist/lib/esm/src/core/ui/components/atoms/icons.js +1 -1
  28. package/dist/lib/esm/src/core/ui/components/atoms/icons.js.map +1 -1
  29. package/dist/lib/esm/src/core/ui/components/atoms/text/Text.js +1 -1
  30. package/dist/lib/esm/src/core/ui/components/atoms/text/Text.js.map +1 -1
  31. package/dist/lib/esm/src/core/ui/components/error/ErrorBoundary.js.map +1 -1
  32. package/dist/lib/esm/src/core/ui/components/molecules/popover/PopoverLite.js +1 -1
  33. package/dist/lib/esm/src/core/ui/components/molecules/popover/PopoverLite.js.map +1 -1
  34. package/dist/lib/esm/src/core/utils/helpers/ui.js +1 -1
  35. package/dist/lib/esm/src/core/utils/helpers/ui.js.map +1 -1
  36. package/dist/lib/esm/src/index.js +1 -1
  37. package/dist/lib/tsconfig.tsbuildinfo +1 -1
  38. package/dist/types/src/core/hooks/useThemePreference.d.ts +0 -41
  39. package/dist/types/src/core/hooks/useThemePreference.d.ts.map +1 -1
  40. package/dist/types/src/core/ui/components/atoms/icons.d.ts.map +1 -1
  41. package/dist/types/src/core/ui/components/atoms/text/Text.d.ts.map +1 -1
  42. package/dist/types/src/core/ui/components/error/ErrorBoundary.d.ts +2 -2
  43. package/dist/types/src/core/ui/components/error/ErrorBoundary.d.ts.map +1 -1
  44. package/dist/types/src/core/ui/components/molecules/popover/PopoverLite.d.ts.map +1 -1
  45. package/dist/types/src/core/utils/helpers/ui.d.ts +40 -0
  46. package/dist/types/src/core/utils/helpers/ui.d.ts.map +1 -1
  47. package/dist/ui/esm/src/core/ui/components/atoms/icons.js +1 -1
  48. package/dist/ui/esm/src/core/ui/components/atoms/icons.js.map +1 -1
  49. package/dist/ui/esm/src/core/ui/components/atoms/text/Text.js +1 -1
  50. package/dist/ui/esm/src/core/ui/components/atoms/text/Text.js.map +1 -1
  51. package/dist/ui/esm/src/core/ui/components/error/ErrorBoundary.js.map +1 -1
  52. package/dist/ui/esm/src/core/ui/components/molecules/popover/PopoverLite.js +1 -1
  53. package/dist/ui/esm/src/core/ui/components/molecules/popover/PopoverLite.js.map +1 -1
  54. package/dist/ui/esm/src/core/utils/helpers/ui.js.map +1 -1
  55. package/dist/ui/src/core/ui/components/atoms/icons.js +1 -1
  56. package/dist/ui/src/core/ui/components/atoms/icons.js.map +1 -1
  57. package/dist/ui/src/core/ui/components/atoms/text/Text.js +1 -1
  58. package/dist/ui/src/core/ui/components/atoms/text/Text.js.map +1 -1
  59. package/dist/ui/src/core/ui/components/error/ErrorBoundary.js.map +1 -1
  60. package/dist/ui/src/core/ui/components/molecules/popover/PopoverLite.js +1 -1
  61. package/dist/ui/src/core/ui/components/molecules/popover/PopoverLite.js.map +1 -1
  62. package/dist/ui/src/core/utils/helpers/ui.js.map +1 -1
  63. package/dist/utils/esm/index.css +333 -333
  64. package/dist/utils/esm/src/core/utils/helpers/ui.js +1 -1
  65. package/dist/utils/esm/src/core/utils/helpers/ui.js.map +1 -1
  66. package/dist/utils/esm/src/core/utils/index.js +1 -1
  67. package/dist/utils/index.css +333 -333
  68. package/dist/utils/src/core/utils/helpers/ui.js +1 -1
  69. package/dist/utils/src/core/utils/helpers/ui.js.map +1 -1
  70. package/dist/utils/src/core/utils/index.js +1 -1
  71. package/package.json +4 -3
@@ -1,2 +1,2 @@
1
- export{useApi}from"./useApi.js";export{useToggle}from"./useToggle.js";export{useToggle2}from"./useToggle2.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";export{useTimeoutFn}from"./useSetTimeout.js";
1
+ export{useApi}from"./useApi.js";export{useToggle}from"./useToggle.js";export{useToggle2}from"./useToggle2.js";export{outsideClickHandler,useOutsideClick}from"./useOutsideClick.js";export{useResize}from"./useResize.js";export{useClassNames}from"./useClassNames.js";export{useParseProps}from"./useParseProps.js";export{useThemePreference}from"./useThemePreference.js";export{useAnimation}from"./useAnimation.js";export{useIntersectionObserver}from"./useIntersectionObserver.js";export{useTimeoutFn}from"./useSetTimeout.js";
2
2
  //# sourceMappingURL=index.js.map
@@ -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 c=o=>{const c=e();null==s||s(o,c),null==t||t(o)},d=e=>{c(e.matches)},l=e=>{c(!e.matches)},r=window.matchMedia("(prefers-color-scheme: dark)");try{window.matchMedia("(prefers-color-scheme: dark)").removeEventListener(o,d),window.matchMedia("(prefers-color-scheme: light)").removeEventListener(o,l)}catch(e){}return c(null==r?void 0:r.matches),window.matchMedia("(prefers-color-scheme: dark)").addEventListener(o,d),window.matchMedia("(prefers-color-scheme: light)").addEventListener(o,l),()=>{window.matchMedia("(prefers-color-scheme: dark)").removeEventListener(o,d),window.matchMedia("(prefers-color-scheme: light)").removeEventListener(o,l)}},c=function(){let o=arguments.length>0&&void 0!==arguments[0]?arguments[0]:()=>document.body,c=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e=>e;e((()=>t(o,c)),[o,c])};let d={dark:"theme-dark",light:"theme-light"};const l=()=>d,r=e=>{d=e},s=function(e,o){let t=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];const c=e?d.light:d.dark,l=e?d.dark:d.light;o&&(o.classList.remove(c),o.classList.remove(l),o.classList.add(l)),"undefined"!=typeof document&&(document.querySelectorAll(".".concat(c)).forEach((e=>{e.classList.add(".".concat(l)),e.classList.remove(".".concat(c))})),t&&(document.querySelectorAll(".shadow-div").forEach((e=>{var o,t;null===(o=e.shadowRoot)||void 0===o||null===(o=o.querySelector(".".concat(c)))||void 0===o||o.classList.add(l),null===(t=e.shadowRoot)||void 0===t||null===(t=t.querySelector(".".concat(c)))||void 0===t||t.classList.remove(c)})),document.querySelectorAll("esmf-wrapper").forEach((e=>{var o,t,d;null===(o=e.shadowRoot)||void 0===o||null===(o=o.querySelector(".".concat(c)))||void 0===o||o.classList.add(l),null===(t=e.shadowRoot)||void 0===t||null===(t=t.querySelector(".".concat(c)))||void 0===t||t.classList.remove(c);const r=null===(d=e.shadowRoot)||void 0===d?void 0:d.childNodes[0];r&&(r.classList.add(l),r.classList.remove(c))}))))},n=(e,o)=>{let t=e||!1;"undefined"!=typeof document&&void 0===e&&(t=document.body.classList.contains(d.dark)),s(t,o||document.body)};export{l as getBaseThemes,t as observeThemePreference,r as setThemeClassNames,s as switchColorTheme,n as updateColorTheme,c as useThemePreference};
1
+ import{useEffect as o}from"react";import{observeThemePreference as t}from"../utils/helpers/ui.js";const e=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:()=>document.body,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:o=>o;o((()=>t(e,i)),[e,i])};export{e 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\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","concat","forEach","element","_element$shadowRoot","_element$shadowRoot2","shadowRoot","querySelector","_element$shadowRoot3","_element$shadowRoot4","_element$shadowRoot5","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,SAAAA,EAAmBH,EAAQE,GAC3BH,SAAAA,EAAiBC,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,EAEpC,CAAC,MAAOI,GAAO,CAYhB,OARAV,EAAwBD,eAAAA,EAAQM,SAChCE,OAAOC,WAAW,gCAAgCG,iBAChDrB,EAAiCa,GAEnCI,OAAOC,WAAW,iCAAiCG,iBACjDrB,EAAiCgB,GAG5B,KACLC,OAAOC,WAAW,gCAAgCC,oBAChDnB,EAAiCa,G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EAAS,IAG/EzB,SAAS8B,iBAAiB,gBAAgBE,SAASC,IAAY,IAAAK,EAAAC,EAAAC,EAC3C,QAAlBF,EAAAL,EAAQG,kBAAU,IAAAE,GAA+B,QAA/BA,EAAlBA,EAAoBD,cAAa,IAAAN,OAAKN,WAAW,IAAAa,GAAjDA,EAAmDX,UAAUE,IAAIH,GAC/C,QAAlBa,EAAAN,EAAQG,kBAAU,IAAAG,GAA+B,QAA/BA,EAAlBA,EAAoBF,cAAa,IAAAN,OAAKN,WAAW,IAAAc,GAAjDA,EAAmDZ,UAAUC,OAAOH,GAEpE,MAAMgB,EAA4CD,QAArBA,EAAGP,EAAQG,sBAAUI,SAAlBA,EAAoBE,WAAW,GAE3DD,IACFA,EAAWd,UAAUE,IAAIH,GACzBe,EAAWd,UAAUC,OAAOH,GAC9B,KAIR,EAOakB,EAAmBA,CAACxC,EAAkBE,KACjD,IAAIuC,EAA0BzC,IAAU,EAEhB,oBAAbH,eAAuCD,IAAXI,IACrCyC,EAAiB5C,SAASC,KAAK0B,UAAUkB,SAAS3B,EAAWC,OAE/Db,EAAiBsC,EAAgBvC,GAAeL,SAASC,KAAK"}
1
+ {"version":3,"file":"useThemePreference.js","sources":["../../../../../../src/core/hooks/useThemePreference.ts"],"sourcesContent":["import { useEffect } from 'react'\n\nimport { observeThemePreference } from '../utils/helpers/ui'\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"],"names":["useThemePreference","getHtmlElement","arguments","length","undefined","document","body","switchCallback","isDark","useEffect","observeThemePreference"],"mappings":"kGASaA,MAAAA,EAAqB,WAGvB,IAFTC,EAAiCC,UAAAC,OAAAD,QAAAE,IAAAF,UAAAE,GAAAF,UAAA,GAAG,IAAmBG,SAASC,KAChEC,EAAyCL,UAAAC,OAAAD,QAAAE,IAAAF,UAAAE,GAAAF,UAAIM,GAAAA,GAA6BA,EAE1EC,GAAU,IAAMC,EAAuBT,EAAgBM,IAAiB,CAACN,EAAgBM,GAC3F"}
@@ -1,2 +1,2 @@
1
- import"../../../../node_modules/core-js/modules/web.dom-collections.iterator.js";const t=function(){for(var t=arguments.length,r=new Array(t),e=0;e<t;e++)r[e]=arguments[e];return r.filter((t=>"string"==typeof t&&null!=t)).filter(Boolean).join(" ")},r=t=>{const r={},e={};return Object.entries(t).forEach((t=>{let[o,s]=t;"data-"===o.substr(0,5)||"data"===o.substr(0,4)?r[o]=s:e[o]=s})),{dataProps:r,restProps:e}};export{t as classNames,r as parseProps};
1
+ import"../../../../node_modules/core-js/modules/web.dom-collections.iterator.js";const e=function(){for(var e=arguments.length,o=new Array(e),t=0;t<e;t++)o[t]=arguments[t];return o.filter((e=>"string"==typeof e&&null!=e)).filter(Boolean).join(" ")},o=e=>{const o={},t={};return Object.entries(e).forEach((e=>{let[r,s]=e;"data-"===r.substr(0,5)||"data"===r.substr(0,4)?o[r]=s:t[r]=s})),{dataProps:o,restProps:t}};let t="theme-dark",r="theme-light";const s=function(e,o){let s=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];const c=e?r:t,l=e?t:r;o&&(o.classList.remove(c),o.classList.remove(l),o.classList.add(l)),"undefined"!=typeof document&&(document.querySelectorAll(".".concat(c)).forEach((e=>{e.classList.add(".".concat(l)),e.classList.remove(".".concat(c))})),s&&(document.querySelectorAll(".shadow-div").forEach((e=>{var o,t;null===(o=e.shadowRoot)||void 0===o||null===(o=o.querySelector(".".concat(c)))||void 0===o||o.classList.add(l),null===(t=e.shadowRoot)||void 0===t||null===(t=t.querySelector(".".concat(c)))||void 0===t||t.classList.remove(c)})),document.querySelectorAll("esmf-wrapper").forEach((e=>{var o,t,r;null===(o=e.shadowRoot)||void 0===o||null===(o=o.querySelector(".".concat(c)))||void 0===o||o.classList.add(l),null===(t=e.shadowRoot)||void 0===t||null===(t=t.querySelector(".".concat(c)))||void 0===t||t.classList.remove(c);const s=null===(r=e.shadowRoot)||void 0===r?void 0:r.childNodes[0];s&&(s.classList.add(l),s.classList.remove(c))}))))},c="change",l=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:()=>document.body,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e=>e;const t=t=>{const r=e();null==s||s(t,r),null==o||o(t)},r=e=>{t(e.matches)},l=e=>{t(!e.matches)},n=window.matchMedia("(prefers-color-scheme: dark)");try{window.matchMedia("(prefers-color-scheme: dark)").removeEventListener(c,r),window.matchMedia("(prefers-color-scheme: light)").removeEventListener(c,l)}catch(e){}return t(null==n?void 0:n.matches),window.matchMedia("(prefers-color-scheme: dark)").addEventListener(c,r),window.matchMedia("(prefers-color-scheme: light)").addEventListener(c,l),()=>{window.matchMedia("(prefers-color-scheme: dark)").removeEventListener(c,r),window.matchMedia("(prefers-color-scheme: light)").removeEventListener(c,l)}};export{e as classNames,l as observeThemePreference,o as parseProps,s as switchColorTheme};
2
2
  //# sourceMappingURL=ui.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ui.js","sources":["../../../../../../../src/core/utils/helpers/ui.ts"],"sourcesContent":["export const mapSerReplacer\n= (key: string, value: unknown): unknown | { dataType: string; value: Array<unknown>} => {\n if (value instanceof Map) {\n return {\n dataType: 'Map',\n value: Array.from(value.entries()), // or with spread: value: [...value]\n }\n }\n return value\n}\n\nexport type TClassName = string | boolean | null | undefined\nexport const classNames = (...classes: TClassName[]): string => classes\n .filter((className: TClassName) => (typeof className === 'string' && className !== undefined && className !== null))\n .filter(Boolean).join(' ')\n\n\nexport type PropsCategoriesType = {\n dataProps: Record<string, unknown>\n restProps: Record<string, unknown>\n};\n\nexport const parseProps = (props: Record<string, unknown>):PropsCategoriesType => {\n const dataProps: Record<string, unknown> = {}\n const restProps: Record<string, unknown> = {}\n\n Object.entries(props).forEach(([key, value]) => {\n if (key.substr(0, 5) === 'data-' || key.substr(0, 4) === 'data') {\n dataProps[key] = value\n } else {\n restProps[key] = value\n }\n })\n return { dataProps, restProps }\n}\n\n\n\ntype GeneratorIdCallable = (token: string, increment?: boolean, forcedValue?: number | undefined) => string\ntype GenerateId = { tokens?: Record<string, number | null | undefined> } & GeneratorIdCallable\n\nexport const generateId: GenerateId = (\n token: string,\n increment = true,\n forcedValue: number | undefined = undefined,\n) => {\n generateId.tokens = generateId.tokens || {}\n\n if (forcedValue !== undefined && forcedValue !== null) {\n generateId.tokens[token] = forcedValue\n return `${token}${generateId?.tokens?.[token] as number}`\n }\n\n const noValue = generateId?.tokens[token] === undefined || generateId?.tokens[token] === null\n\n generateId.tokens[token] = generateId.tokens[token] || 0\n\n if (noValue) {\n return `${token}${0}`\n }\n\n if (increment) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n generateId.tokens[token] += 1\n\n return `${token}${generateId?.tokens?.[token] as number}`\n }\n\n return `${token}${generateId?.tokens?.[token] as number}`\n}\n\ntype FAnchorClick = { aElement?: HTMLAnchorElement | null }\n & ((href: string, target?: string, remove?: boolean) => void)\n\nexport const anchorClick: FAnchorClick = (href: string, target = '_top', remove = false): HTMLAnchorElement | null => {\n anchorClick.aElement = anchorClick.aElement || document.createElement('a')\n\n const { aElement } = anchorClick\n\n aElement.setAttribute('href', href)\n aElement.setAttribute('target', target)\n\n aElement.dataset.date = `${Date.now()}`\n aElement.click()\n if (remove) {\n aElement.remove()\n anchorClick.aElement = null\n }\n\n return aElement\n}\n\n\n\nexport type NoopEvent = {\n preventDefault?: () => void\n stopPropagation?: () => void\n stopImmediatePropagation?: () => void\n} | Event\n\nexport const noop = (event?: NoopEvent): void => {\n event?.preventDefault?.()\n event?.stopPropagation?.()\n event?.stopImmediatePropagation?.()\n}\n"],"names":["classNames","_len","arguments","length","classes","Array","_key","filter","className","Boolean","join","parseProps","props","dataProps","restProps","Object","entries","forEach","_ref","key","value","substr"],"mappings":"iFAYaA,MAAAA,EAAa,WAAA,IAAA,IAAAC,EAAAC,UAAAC,OAAIC,EAAOC,IAAAA,MAAAJ,GAAAK,EAAA,EAAAA,EAAAL,EAAAK,IAAPF,EAAOE,GAAAJ,UAAAI,GAAA,OAA2BF,EAC7DG,QAAQC,GAAgD,iBAAdA,GAAP,MAAiCA,IACpED,OAAOE,SAASC,KAAK,IAAI,EAQfC,EAAcC,IACzB,MAAMC,EAAqC,CAAE,EACvCC,EAAqC,CAAE,EAS7C,OAPAC,OAAOC,QAAQJ,GAAOK,SAAQC,IAAkB,IAAhBC,EAAKC,GAAMF,EAChB,UAArBC,EAAIE,OAAO,EAAG,IAAuC,SAArBF,EAAIE,OAAO,EAAG,GAChDR,EAAUM,GAAOC,EAEjBN,EAAUK,GAAOC,CACnB,IAEK,CAAEP,YAAWC,YAAW"}
1
+ {"version":3,"file":"ui.js","sources":["../../../../../../../src/core/utils/helpers/ui.ts"],"sourcesContent":["export const mapSerReplacer\n= (key: string, value: unknown): unknown | { dataType: string; value: Array<unknown>} => {\n if (value instanceof Map) {\n return {\n dataType: 'Map',\n value: Array.from(value.entries()), // or with spread: value: [...value]\n }\n }\n return value\n}\n\nexport type TClassName = string | boolean | null | undefined\nexport const classNames = (...classes: TClassName[]): string => classes\n .filter((className: TClassName) => (typeof className === 'string' && className !== undefined && className !== null))\n .filter(Boolean).join(' ')\n\n\nexport type PropsCategoriesType = {\n dataProps: Record<string, unknown>\n restProps: Record<string, unknown>\n};\n\nexport const parseProps = (props: Record<string, unknown>):PropsCategoriesType => {\n const dataProps: Record<string, unknown> = {}\n const restProps: Record<string, unknown> = {}\n\n Object.entries(props).forEach(([key, value]) => {\n if (key.substr(0, 5) === 'data-' || key.substr(0, 4) === 'data') {\n dataProps[key] = value\n } else {\n restProps[key] = value\n }\n })\n return { dataProps, restProps }\n}\n\n\n\ntype GeneratorIdCallable = (token: string, increment?: boolean, forcedValue?: number | undefined) => string\ntype GenerateId = { tokens?: Record<string, number | null | undefined> } & GeneratorIdCallable\n\nexport const generateId: GenerateId = (\n token: string,\n increment = true,\n forcedValue: number | undefined = undefined,\n) => {\n generateId.tokens = generateId.tokens || {}\n\n if (forcedValue !== undefined && forcedValue !== null) {\n generateId.tokens[token] = forcedValue\n return `${token}${generateId?.tokens?.[token] as number}`\n }\n\n const noValue = generateId?.tokens[token] === undefined || generateId?.tokens[token] === null\n\n generateId.tokens[token] = generateId.tokens[token] || 0\n\n if (noValue) {\n return `${token}${0}`\n }\n\n if (increment) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n generateId.tokens[token] += 1\n\n return `${token}${generateId?.tokens?.[token] as number}`\n }\n\n return `${token}${generateId?.tokens?.[token] as number}`\n}\n\ntype FAnchorClick = { aElement?: HTMLAnchorElement | null }\n & ((href: string, target?: string, remove?: boolean) => void)\n\nexport const anchorClick: FAnchorClick = (href: string, target = '_top', remove = false): HTMLAnchorElement | null => {\n anchorClick.aElement = anchorClick.aElement || document.createElement('a')\n\n const { aElement } = anchorClick\n\n aElement.setAttribute('href', href)\n aElement.setAttribute('target', target)\n\n aElement.dataset.date = `${Date.now()}`\n aElement.click()\n if (remove) {\n aElement.remove()\n anchorClick.aElement = null\n }\n\n return aElement\n}\n\n\n\nexport type NoopEvent = {\n preventDefault?: () => void\n stopPropagation?: () => void\n stopImmediatePropagation?: () => void\n} | Event\n\nexport const noop = (event?: NoopEvent): void => {\n event?.preventDefault?.()\n event?.stopPropagation?.()\n event?.stopImmediatePropagation?.()\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 */\nexport type 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\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"],"names":["classNames","_len","arguments","length","classes","Array","_key","filter","className","Boolean","join","parseProps","props","dataProps","restProps","Object","entries","forEach","_ref","key","value","substr","baseThemes","switchColorTheme","isDark","htmlElement","findShadows","undefined","oldClass","newClass","classList","remove","add","document","querySelectorAll","concat","element","_element$shadowRoot","_element$shadowRoot2","shadowRoot","querySelector","_element$shadowRoot3","_element$shadowRoot4","_element$shadowRoot5","firstChild","childNodes","windowMatchMediaChangeEventType","observeThemePreference","getHtmlElement","body","switchCallback","switchColorThemeHandler","changeDarkColorThemeHandler","event","matches","changeLightColorThemeHandler","window","matchMedia","removeEventListener","error","addEventListener"],"mappings":"iFAYaA,MAAAA,EAAa,WAAA,IAAA,IAAAC,EAAAC,UAAAC,OAAIC,EAAOC,IAAAA,MAAAJ,GAAAK,EAAA,EAAAA,EAAAL,EAAAK,IAAPF,EAAOE,GAAAJ,UAAAI,GAAA,OAA2BF,EAC7DG,QAAQC,GAAgD,iBAAdA,GAAP,MAAiCA,IACpED,OAAOE,SAASC,KAAK,IAAI,EAQfC,EAAcC,IACzB,MAAMC,EAAqC,CAAE,EACvCC,EAAqC,CAAE,EAS7C,OAPAC,OAAOC,QAAQJ,GAAOK,SAAQC,IAAkB,IAAhBC,EAAKC,GAAMF,EAChB,UAArBC,EAAIE,OAAO,EAAG,IAAuC,SAArBF,EAAIE,OAAO,EAAG,GAChDR,EAAUM,GAAOC,EAEjBN,EAAUK,GAAOC,CACnB,IAEK,CAAEP,YAAWC,YAAW,EAqFjC,IAAIQ,EACI,aADJA,EAEK,cAuBF,MAAMC,EAAmB,SAACC,EAAiBC,GAAwD,IAA7BC,IAAWxB,UAAAC,OAAA,QAAAwB,IAAAzB,UAAA,KAAAA,UAAA,GACtF,MAAM0B,EAAWJ,EAASF,EAAmBA,EACvCO,EAAWL,EAASF,EAAkBA,EAExCG,IACFA,EAAYK,UAAUC,OAAOH,GAC7BH,EAAYK,UAAUC,OAAOF,GAC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