@maz-ui/utils 4.1.7-beta.0 → 4.1.7-beta.5

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 (35) hide show
  1. package/dist/helpers/TextareaAutogrow.js +5 -5
  2. package/dist/helpers/camelCase.js +3 -3
  3. package/dist/helpers/capitalize.js +3 -3
  4. package/dist/helpers/checkAvailability.js +9 -9
  5. package/dist/helpers/countryCodeToUnicodeFlag.js +7 -7
  6. package/dist/helpers/debounce.js +7 -7
  7. package/dist/helpers/debounceCallback.js +4 -4
  8. package/dist/helpers/debounceId.js +14 -14
  9. package/dist/helpers/fetchLocaleIp.js +6 -6
  10. package/dist/helpers/formatCurrency.js +18 -18
  11. package/dist/helpers/formatDate.js +10 -10
  12. package/dist/helpers/formatNumber.js +12 -12
  13. package/dist/helpers/formatPhoneNumber.js +6 -6
  14. package/dist/helpers/getBrowserLocale.js +6 -6
  15. package/dist/helpers/getCountryFlagUrl.js +6 -6
  16. package/dist/helpers/getErrorMessage.js +3 -3
  17. package/dist/helpers/idleTimeout.js +27 -27
  18. package/dist/helpers/index.js +58 -58
  19. package/dist/helpers/isClient.js +2 -2
  20. package/dist/helpers/isEqual.js +14 -14
  21. package/dist/helpers/isServer.js +2 -2
  22. package/dist/helpers/isStandaloneMode.js +6 -6
  23. package/dist/helpers/kebabCase.js +3 -3
  24. package/dist/helpers/normalizeString.js +22 -22
  25. package/dist/helpers/pascalCase.js +12 -12
  26. package/dist/helpers/scriptLoader.js +20 -20
  27. package/dist/helpers/sleep.js +3 -3
  28. package/dist/helpers/snakeCase.js +3 -3
  29. package/dist/helpers/swipeHandler.js +22 -22
  30. package/dist/helpers/throttle.js +7 -7
  31. package/dist/helpers/throttleId.js +11 -11
  32. package/dist/helpers/truthyFilter.js +3 -3
  33. package/dist/helpers/userVisibility.js +8 -8
  34. package/dist/index.js +58 -58
  35. package/package.json +5 -5
@@ -1,8 +1,8 @@
1
- import { debounce as t } from "./debounce.js";
2
- class o {
1
+ import { debounce } from "./debounce.js";
2
+ class TextareaAutogrow {
3
3
  element;
4
- constructor(e) {
5
- this.element = e, this.onFocus = this.onFocus.bind(this), this.autogrow = this.autogrow.bind(this), this.onResize = t(this.onResize.bind(this), 200), this.connect();
4
+ constructor(element) {
5
+ this.element = element, this.onFocus = this.onFocus.bind(this), this.autogrow = this.autogrow.bind(this), this.onResize = debounce(this.onResize.bind(this), 200), this.connect();
6
6
  }
7
7
  connect() {
8
8
  this.element.addEventListener("focus", this.onFocus), this.element.style.resize = "none", this.element.style.boxSizing = "border-box";
@@ -21,5 +21,5 @@ class o {
21
21
  }
22
22
  }
23
23
  export {
24
- o as TextareaAutogrow
24
+ TextareaAutogrow
25
25
  };
@@ -1,6 +1,6 @@
1
- function l(r) {
2
- return r.replaceAll(/-(\w)/g, (a, e) => e ? e.toUpperCase() : "");
1
+ function camelCase(str) {
2
+ return str.replaceAll(/-(\w)/g, (_, c) => c ? c.toUpperCase() : "");
3
3
  }
4
4
  export {
5
- l as camelCase
5
+ camelCase
6
6
  };
@@ -1,6 +1,6 @@
1
- function r(t) {
2
- return typeof t != "string" ? "" : t.charAt(0).toUpperCase() + t.slice(1);
1
+ function capitalize(value) {
2
+ return typeof value != "string" ? "" : value.charAt(0).toUpperCase() + value.slice(1);
3
3
  }
4
4
  export {
5
- r as capitalize
5
+ capitalize
6
6
  };
@@ -1,16 +1,16 @@
1
- function l(r, o, s) {
2
- const e = {
1
+ function checkAvailability(getRef, callback, options) {
2
+ const opts = {
3
3
  maxAttempts: 20,
4
4
  interval: 100,
5
- ...s
5
+ ...options
6
6
  };
7
- let t = 0;
8
- function a() {
9
- const i = r();
10
- i != null ? e.expectedValue !== void 0 && i !== e.expectedValue ? t < e.maxAttempts ? (t++, setTimeout(a, e.interval)) : e.onError?.(new Error(e.errorMessage || `[maz-ui](checkAvailability) Nothing found after ${e.maxAttempts} attempts`)) : o(i) : t < e.maxAttempts ? (t++, setTimeout(a, e.interval)) : e.onError?.(new Error(e.errorMessage || `[maz-ui](checkAvailability) Nothing found after ${e.maxAttempts} attempts`));
7
+ let attempts = 0;
8
+ function check() {
9
+ const ref = getRef();
10
+ ref != null ? opts.expectedValue !== void 0 && ref !== opts.expectedValue ? attempts < opts.maxAttempts ? (attempts++, setTimeout(check, opts.interval)) : opts.onError?.(new Error(opts.errorMessage || `[maz-ui](checkAvailability) Nothing found after ${opts.maxAttempts} attempts`)) : callback(ref) : attempts < opts.maxAttempts ? (attempts++, setTimeout(check, opts.interval)) : opts.onError?.(new Error(opts.errorMessage || `[maz-ui](checkAvailability) Nothing found after ${opts.maxAttempts} attempts`));
11
11
  }
12
- a();
12
+ check();
13
13
  }
14
14
  export {
15
- l as checkAvailability
15
+ checkAvailability
16
16
  };
@@ -1,10 +1,10 @@
1
- import { truthyFilter as n } from "./truthyFilter.js";
2
- function i(r) {
3
- return [...r].map((o) => {
4
- const t = o.codePointAt(0);
5
- return t ? t % 32 + 127461 : void 0;
6
- }).filter(n).map((o) => String.fromCodePoint(o)).join("");
1
+ import { truthyFilter } from "./truthyFilter.js";
2
+ function countryCodeToUnicodeFlag(locale) {
3
+ return [...locale].map((letter) => {
4
+ const code = letter.codePointAt(0);
5
+ return code ? code % 32 + 127461 : void 0;
6
+ }).filter(truthyFilter).map((n) => String.fromCodePoint(n)).join("");
7
7
  }
8
8
  export {
9
- i as countryCodeToUnicodeFlag
9
+ countryCodeToUnicodeFlag
10
10
  };
@@ -1,11 +1,11 @@
1
- function i(e, o) {
2
- let t;
3
- return function(...u) {
4
- clearTimeout(t), t = setTimeout(() => {
5
- e.apply(this, u);
6
- }, o);
1
+ function debounce(fn, delay) {
2
+ let timeout;
3
+ return function(...args) {
4
+ clearTimeout(timeout), timeout = setTimeout(() => {
5
+ fn.apply(this, args);
6
+ }, delay);
7
7
  };
8
8
  }
9
9
  export {
10
- i as debounce
10
+ debounce
11
11
  };
@@ -1,7 +1,7 @@
1
- let e = null;
2
- function o(t, l) {
3
- e && clearTimeout(e), e = setTimeout(t, l);
1
+ let timeout = null;
2
+ function debounceCallback(callback, delay) {
3
+ timeout && clearTimeout(timeout), timeout = setTimeout(callback, delay);
4
4
  }
5
5
  export {
6
- o as debounceCallback
6
+ debounceCallback
7
7
  };
@@ -1,21 +1,21 @@
1
- function i(o, n, r) {
2
- const t = {};
3
- return function(...c) {
4
- t[o] || (t[o] = { timer: null, promise: null });
5
- const e = t[o];
6
- return e.timer && clearTimeout(e.timer), e.promise = new Promise((u, m) => {
7
- e.timer = setTimeout(async () => {
1
+ function debounceId(identifier, func, delay) {
2
+ const debouncedFunctions = {};
3
+ return function(...args) {
4
+ debouncedFunctions[identifier] || (debouncedFunctions[identifier] = { timer: null, promise: null });
5
+ const debounced = debouncedFunctions[identifier];
6
+ return debounced.timer && clearTimeout(debounced.timer), debounced.promise = new Promise((resolve, reject) => {
7
+ debounced.timer = setTimeout(async () => {
8
8
  try {
9
- u(await n(...c));
10
- } catch (s) {
11
- m(s);
9
+ resolve(await func(...args));
10
+ } catch (error) {
11
+ reject(error);
12
12
  } finally {
13
- delete t[o];
13
+ delete debouncedFunctions[identifier];
14
14
  }
15
- }, r);
16
- }), e.promise;
15
+ }, delay);
16
+ }), debounced.promise;
17
17
  };
18
18
  }
19
19
  export {
20
- i as debounceId
20
+ debounceId
21
21
  };
@@ -1,12 +1,12 @@
1
- async function c() {
1
+ async function fetchLocaleIp() {
2
2
  try {
3
- const o = await fetch("https://ipwho.is"), { country_code: t } = await o.json();
4
- return t;
5
- } catch (o) {
6
- console.error(`[maz-ui](fetchLocaleIp) ${o}`);
3
+ const reponse = await fetch("https://ipwho.is"), { country_code } = await reponse.json();
4
+ return country_code;
5
+ } catch (error) {
6
+ console.error(`[maz-ui](fetchLocaleIp) ${error}`);
7
7
  return;
8
8
  }
9
9
  }
10
10
  export {
11
- c as fetchLocaleIp
11
+ fetchLocaleIp
12
12
  };
@@ -1,34 +1,34 @@
1
- const u = {
1
+ const DEFAULT_OPTIONS = {
2
2
  style: "currency",
3
3
  minimumFractionDigits: 2,
4
4
  round: !1
5
5
  };
6
- function o(t, r, e) {
7
- let i = +t;
8
- return e.round && (i = Math.floor(i), e.minimumFractionDigits = 0), new Intl.NumberFormat(r, e).format(i);
6
+ function getFormattedCurrency(number, locale, options) {
7
+ let numberToFormat = +number;
8
+ return options.round && (numberToFormat = Math.floor(numberToFormat), options.minimumFractionDigits = 0), new Intl.NumberFormat(locale, options).format(numberToFormat);
9
9
  }
10
- function c(t, r, e) {
11
- if (t === void 0)
10
+ function validRequiredAttributes(number, locale, options) {
11
+ if (number === void 0)
12
12
  throw new TypeError("[maz-ui](FilterCurrency) The `number` attribute is required.");
13
- if (r === void 0)
13
+ if (locale === void 0)
14
14
  throw new TypeError("[maz-ui](FilterCurrency) The `locale` attribute is required.");
15
- if (typeof r != "string")
15
+ if (typeof locale != "string")
16
16
  throw new TypeError("[maz-ui](FilterCurrency) The `locale` attribute must be a string.");
17
- if (e.currency === void 0)
17
+ if (options.currency === void 0)
18
18
  throw new TypeError("[maz-ui](FilterCurrency) The `options.currency` attribute is required.");
19
19
  }
20
- function a(t, r, e) {
21
- const i = {
22
- ...u,
23
- ...e
20
+ function formatCurrency(number, locale, options) {
21
+ const options_ = {
22
+ ...DEFAULT_OPTIONS,
23
+ ...options
24
24
  };
25
- c(t, r, i);
25
+ validRequiredAttributes(number, locale, options_);
26
26
  try {
27
- return o(t, r, i);
28
- } catch (n) {
29
- throw new Error(`[maz-ui](FilterCurrency) ${n}`);
27
+ return getFormattedCurrency(number, locale, options_);
28
+ } catch (error) {
29
+ throw new Error(`[maz-ui](FilterCurrency) ${error}`);
30
30
  }
31
31
  }
32
32
  export {
33
- a as formatCurrency
33
+ formatCurrency
34
34
  };
@@ -1,21 +1,21 @@
1
- const a = {
1
+ const DEFAULT_OPTIONS = {
2
2
  month: "short",
3
3
  day: "numeric",
4
4
  year: "numeric"
5
5
  };
6
- function n(t, r, o) {
7
- if (r === void 0)
6
+ function formatDate(date, locale, options) {
7
+ if (locale === void 0)
8
8
  throw new TypeError("[maz-ui](FilterDate) The `locale` attribute is required.");
9
- if (typeof r != "string")
9
+ if (typeof locale != "string")
10
10
  throw new TypeError("[maz-ui](FilterDate) The `locale` attribute must be a string.");
11
- const i = o ?? a;
11
+ const opts = options ?? DEFAULT_OPTIONS;
12
12
  try {
13
- const e = t instanceof Date ? t : new Date(t);
14
- return new Intl.DateTimeFormat(r, i).format(e);
15
- } catch (e) {
16
- throw new Error(`[maz-ui](FilterDate) ${e}`);
13
+ const usedDate = date instanceof Date ? date : new Date(date);
14
+ return new Intl.DateTimeFormat(locale, opts).format(usedDate);
15
+ } catch (error) {
16
+ throw new Error(`[maz-ui](FilterDate) ${error}`);
17
17
  }
18
18
  }
19
19
  export {
20
- n as formatDate
20
+ formatDate
21
21
  };
@@ -1,23 +1,23 @@
1
- const u = {
1
+ const DEFAULT_OPTIONS = {
2
2
  minimumFractionDigits: 2
3
3
  };
4
- function m(t, r, e) {
5
- const i = {
6
- ...u,
7
- ...e
4
+ function formatNumber(number, locale, options) {
5
+ const filterOptions = {
6
+ ...DEFAULT_OPTIONS,
7
+ ...options
8
8
  };
9
- if (t === void 0)
9
+ if (number === void 0)
10
10
  throw new TypeError("[maz-ui](FilterNumber) The `number` attribute is required.");
11
- if (r === void 0)
11
+ if (locale === void 0)
12
12
  throw new TypeError("[maz-ui](FilterNumber) The `locale` attribute is required.");
13
- if (typeof r != "string")
13
+ if (typeof locale != "string")
14
14
  throw new TypeError("[maz-ui](FilterNumber) The `locale` attribute must be a string.");
15
15
  try {
16
- return new Intl.NumberFormat(r, i).format(Number(t));
17
- } catch (o) {
18
- throw new Error(`[maz-ui](FilterNumber) ${o}`);
16
+ return new Intl.NumberFormat(locale, filterOptions).format(Number(number));
17
+ } catch (error) {
18
+ throw new Error(`[maz-ui](FilterNumber) ${error}`);
19
19
  }
20
20
  }
21
21
  export {
22
- m as formatNumber
22
+ formatNumber
23
23
  };
@@ -1,10 +1,10 @@
1
- import { parsePhoneNumberFromString as o } from "libphonenumber-js";
2
- function t(r) {
3
- if (!r)
1
+ import { parsePhoneNumberFromString } from "libphonenumber-js";
2
+ function formatPhoneNumber(phoneNumber) {
3
+ if (!phoneNumber)
4
4
  throw new TypeError("[maz-ui](formatPhoneNumber) The `phoneNumber` argument is required.");
5
- const e = o(r);
6
- return e ? e.formatInternational() : r;
5
+ const parsedPhone = parsePhoneNumberFromString(phoneNumber);
6
+ return parsedPhone ? parsedPhone.formatInternational() : phoneNumber;
7
7
  }
8
8
  export {
9
- t as formatPhoneNumber
9
+ formatPhoneNumber
10
10
  };
@@ -1,11 +1,11 @@
1
- import { isServer as e } from "./isServer.js";
2
- function t() {
1
+ import { isServer } from "./isServer.js";
2
+ function getBrowserLocale() {
3
3
  try {
4
- return e() ? void 0 : globalThis.navigator.language;
5
- } catch (r) {
6
- throw new Error(`[MazInputPhoneNumber] (browserLocale) ${r}`);
4
+ return isServer() ? void 0 : globalThis.navigator.language;
5
+ } catch (error) {
6
+ throw new Error(`[MazInputPhoneNumber] (browserLocale) ${error}`);
7
7
  }
8
8
  }
9
9
  export {
10
- t as getBrowserLocale
10
+ getBrowserLocale
11
11
  };
@@ -1,9 +1,9 @@
1
- const t = ["ad", "ae", "af", "ag", "ai", "al", "am", "ao", "aq", "ar", "as", "at", "au", "aw", "ax", "az", "ba", "bb", "bd", "be", "bf", "bg", "bh", "bi", "bj", "bl", "bm", "bn", "bo", "bq", "br", "bs", "bt", "bv", "bw", "by", "bz", "ca", "cc", "cd", "cf", "cg", "ch", "ci", "ck", "cl", "cm", "cn", "co", "cr", "cu", "cv", "cw", "cx", "cy", "cz", "de", "dj", "dk", "dm", "do", "dz", "ec", "ee", "eg", "eh", "er", "es", "et", "eu", "fi", "fj", "fk", "fm", "fo", "fr", "ga", "gb", "gb-eng", "gb-nir", "gb-sct", "gb-wls", "gd", "ge", "gf", "gg", "gh", "gi", "gl", "gm", "gn", "gp", "gq", "gr", "gs", "gt", "gu", "gw", "gy", "hk", "hm", "hn", "hr", "ht", "hu", "id", "ie", "il", "im", "in", "io", "iq", "ir", "is", "it", "je", "jm", "jo", "jp", "ke", "kg", "kh", "ki", "km", "kn", "kp", "kr", "kw", "ky", "kz", "la", "lb", "lc", "li", "lk", "lr", "ls", "lt", "lu", "lv", "ly", "ma", "mc", "md", "me", "mf", "mg", "mh", "mk", "ml", "mm", "mn", "mo", "mp", "mq", "mr", "ms", "mt", "mu", "mv", "mw", "mx", "my", "mz", "na", "nc", "ne", "nf", "ng", "ni", "nl", "no", "np", "nr", "nu", "nz", "om", "pa", "pe", "pf", "pg", "ph", "pk", "pl", "pm", "pn", "pr", "ps", "pt", "pw", "py", "qa", "re", "ro", "rs", "ru", "rw", "sa", "sb", "sc", "sd", "se", "sg", "sh", "si", "sj", "sk", "sl", "sm", "sn", "so", "sr", "ss", "st", "sv", "sx", "sy", "sz", "tc", "td", "tf", "tg", "th", "tj", "tk", "tl", "tm", "tn", "to", "tr", "tt", "tv", "tw", "tz", "ua", "ug", "um", "un", "us", "us-ak", "us-al", "us-ar", "us-az", "us-ca", "us-co", "us-ct", "us-de", "us-fl", "us-ga", "us-hi", "us-ia", "us-id", "us-il", "us-in", "us-ks", "us-ky", "us-la", "us-ma", "us-md", "us-me", "us-mi", "us-mn", "us-mo", "us-ms", "us-mt", "us-nc", "us-nd", "us-ne", "us-nh", "us-nj", "us-nm", "us-nv", "us-ny", "us-oh", "us-ok", "us-or", "us-pa", "us-ri", "us-sc", "us-sd", "us-tn", "us-tx", "us-ut", "us-va", "us-vt", "us-wa", "us-wi", "us-wv", "us-wy", "uy", "uz", "va", "vc", "ve", "vg", "vi", "vn", "vu", "wf", "ws", "xk", "ye", "yt", "za", "zm", "zw"];
2
- function n(m, u) {
3
- const s = m.toLowerCase();
4
- if (t.includes(s))
5
- return u ? `https://flagcdn.com/${u}/${s}.png` : `https://flagcdn.com/${s}.svg`;
1
+ const _supportedCodes = ["ad", "ae", "af", "ag", "ai", "al", "am", "ao", "aq", "ar", "as", "at", "au", "aw", "ax", "az", "ba", "bb", "bd", "be", "bf", "bg", "bh", "bi", "bj", "bl", "bm", "bn", "bo", "bq", "br", "bs", "bt", "bv", "bw", "by", "bz", "ca", "cc", "cd", "cf", "cg", "ch", "ci", "ck", "cl", "cm", "cn", "co", "cr", "cu", "cv", "cw", "cx", "cy", "cz", "de", "dj", "dk", "dm", "do", "dz", "ec", "ee", "eg", "eh", "er", "es", "et", "eu", "fi", "fj", "fk", "fm", "fo", "fr", "ga", "gb", "gb-eng", "gb-nir", "gb-sct", "gb-wls", "gd", "ge", "gf", "gg", "gh", "gi", "gl", "gm", "gn", "gp", "gq", "gr", "gs", "gt", "gu", "gw", "gy", "hk", "hm", "hn", "hr", "ht", "hu", "id", "ie", "il", "im", "in", "io", "iq", "ir", "is", "it", "je", "jm", "jo", "jp", "ke", "kg", "kh", "ki", "km", "kn", "kp", "kr", "kw", "ky", "kz", "la", "lb", "lc", "li", "lk", "lr", "ls", "lt", "lu", "lv", "ly", "ma", "mc", "md", "me", "mf", "mg", "mh", "mk", "ml", "mm", "mn", "mo", "mp", "mq", "mr", "ms", "mt", "mu", "mv", "mw", "mx", "my", "mz", "na", "nc", "ne", "nf", "ng", "ni", "nl", "no", "np", "nr", "nu", "nz", "om", "pa", "pe", "pf", "pg", "ph", "pk", "pl", "pm", "pn", "pr", "ps", "pt", "pw", "py", "qa", "re", "ro", "rs", "ru", "rw", "sa", "sb", "sc", "sd", "se", "sg", "sh", "si", "sj", "sk", "sl", "sm", "sn", "so", "sr", "ss", "st", "sv", "sx", "sy", "sz", "tc", "td", "tf", "tg", "th", "tj", "tk", "tl", "tm", "tn", "to", "tr", "tt", "tv", "tw", "tz", "ua", "ug", "um", "un", "us", "us-ak", "us-al", "us-ar", "us-az", "us-ca", "us-co", "us-ct", "us-de", "us-fl", "us-ga", "us-hi", "us-ia", "us-id", "us-il", "us-in", "us-ks", "us-ky", "us-la", "us-ma", "us-md", "us-me", "us-mi", "us-mn", "us-mo", "us-ms", "us-mt", "us-nc", "us-nd", "us-ne", "us-nh", "us-nj", "us-nm", "us-nv", "us-ny", "us-oh", "us-ok", "us-or", "us-pa", "us-ri", "us-sc", "us-sd", "us-tn", "us-tx", "us-ut", "us-va", "us-vt", "us-wa", "us-wi", "us-wv", "us-wy", "uy", "uz", "va", "vc", "ve", "vg", "vi", "vn", "vu", "wf", "ws", "xk", "ye", "yt", "za", "zm", "zw"];
2
+ function getCountryFlagUrl(countryIsoCode, size) {
3
+ const code = countryIsoCode.toLowerCase();
4
+ if (_supportedCodes.includes(code))
5
+ return size ? `https://flagcdn.com/${size}/${code}.png` : `https://flagcdn.com/${code}.svg`;
6
6
  }
7
7
  export {
8
- n as getCountryFlagUrl
8
+ getCountryFlagUrl
9
9
  };
@@ -1,6 +1,6 @@
1
- function e(t) {
2
- return t instanceof Error ? t.message : typeof t == "string" ? t : t && typeof t == "object" && "message" in t ? String(t.message) : t ? String(t) : "An unexpected error occurred";
1
+ function getErrorMessage(error) {
2
+ return error instanceof Error ? error.message : typeof error == "string" ? error : error && typeof error == "object" && "message" in error ? String(error.message) : error ? String(error) : "An unexpected error occurred";
3
3
  }
4
4
  export {
5
- e as getErrorMessage
5
+ getErrorMessage
6
6
  };
@@ -1,10 +1,10 @@
1
- import { isClient as s } from "./isClient.js";
2
- class l {
3
- constructor(t, e) {
4
- this.callback = t, this.options = {
1
+ import { isClient } from "./isClient.js";
2
+ class IdleTimeout {
3
+ constructor(callback, options) {
4
+ this.callback = callback, this.options = {
5
5
  ...this.defaultOptions,
6
- ...e
7
- }, s() && this.start();
6
+ ...options
7
+ }, isClient() && this.start();
8
8
  }
9
9
  defaultOptions = {
10
10
  element: void 0,
@@ -38,17 +38,17 @@ class l {
38
38
  return this.options.element ?? document.body;
39
39
  }
40
40
  start() {
41
- if (!s()) {
41
+ if (!isClient()) {
42
42
  console.warn("[IdleTimeout](start) you should run this method on client side");
43
43
  return;
44
44
  }
45
- for (const t of this.eventNames)
46
- this.element.addEventListener(t, this.handleEvent);
45
+ for (const eventName of this.eventNames)
46
+ this.element.addEventListener(eventName, this.handleEvent);
47
47
  this.resetTimeout(), this.options.immediate && this.callback({ isIdle: !1, instance: this });
48
48
  }
49
49
  pause() {
50
- const t = this.startTime + this.options.timeout - Date.now();
51
- t <= 0 || (this.remainingTime = t, this.timeoutHandler && (clearTimeout(this.timeoutHandler), this.timeoutHandler = void 0));
50
+ const remainingTime = this.startTime + this.options.timeout - Date.now();
51
+ remainingTime <= 0 || (this.remainingTime = remainingTime, this.timeoutHandler && (clearTimeout(this.timeoutHandler), this.timeoutHandler = void 0));
52
52
  }
53
53
  resume() {
54
54
  this.remainingTime <= 0 || (this.resetTimeout(), this.callback({ isIdle: this.isIdle, instance: this }), this.remainingTime = 0);
@@ -57,13 +57,13 @@ class l {
57
57
  this.isDestroy = !1, this.isIdle = !1, this.remainingTime = 0, this.resetTimeout(), this.callback({ isIdle: this.isIdle, instance: this });
58
58
  }
59
59
  destroy() {
60
- if (!s()) {
60
+ if (!isClient()) {
61
61
  console.warn("[IdleTimeout](destroy) you should run this method on client side");
62
62
  return;
63
63
  }
64
64
  this.isDestroy = !0;
65
- for (const t of this.eventNames)
66
- this.element.removeEventListener(t, this.handleEvent);
65
+ for (const eventName of this.eventNames)
66
+ this.element.removeEventListener(eventName, this.handleEvent);
67
67
  this.timeoutHandler && clearTimeout(this.timeoutHandler);
68
68
  }
69
69
  resetTimeout() {
@@ -72,19 +72,19 @@ class l {
72
72
  this.remainingTime || this.options.timeout
73
73
  ), this.startTime = Date.now();
74
74
  }
75
- handleEvent = (t) => {
75
+ handleEvent = (event) => {
76
76
  try {
77
77
  if (this.remainingTime > 0)
78
78
  return;
79
- if (t.type === "mousemove") {
80
- const { clientX: e, clientY: i } = t;
81
- if (e === void 0 && i === void 0 || e === this.lastClientX && i === this.lastClientY)
79
+ if (event.type === "mousemove") {
80
+ const { clientX, clientY } = event;
81
+ if (clientX === void 0 && clientY === void 0 || clientX === this.lastClientX && clientY === this.lastClientY)
82
82
  return;
83
- this.lastClientX = e, this.lastClientY = i;
83
+ this.lastClientX = clientX, this.lastClientY = clientY;
84
84
  }
85
- this.resetTimeout(), this.callback({ isIdle: this.isIdle, eventType: t.type, instance: this });
86
- } catch (e) {
87
- throw new Error(`[IdleTimeout](handleEvent) ${e}`);
85
+ this.resetTimeout(), this.callback({ isIdle: this.isIdle, eventType: event.type, instance: this });
86
+ } catch (error) {
87
+ throw new Error(`[IdleTimeout](handleEvent) ${error}`);
88
88
  }
89
89
  };
90
90
  handleTimeout() {
@@ -96,16 +96,16 @@ class l {
96
96
  get timeout() {
97
97
  return this.options.timeout;
98
98
  }
99
- set timeout(t) {
100
- this.options.timeout = t;
99
+ set timeout(value) {
100
+ this.options.timeout = value;
101
101
  }
102
102
  get idle() {
103
103
  return this.isIdle;
104
104
  }
105
- set idle(t) {
106
- t ? this.handleTimeout() : this.reset(), this.callback({ isIdle: this.isIdle, instance: this });
105
+ set idle(value) {
106
+ value ? this.handleTimeout() : this.reset(), this.callback({ isIdle: this.isIdle, instance: this });
107
107
  }
108
108
  }
109
109
  export {
110
- l as IdleTimeout
110
+ IdleTimeout
111
111
  };
@@ -1,60 +1,60 @@
1
- import { camelCase as e } from "./camelCase.js";
2
- import { capitalize as m } from "./capitalize.js";
3
- import { checkAvailability as f } from "./checkAvailability.js";
4
- import { countryCodeToUnicodeFlag as a } from "./countryCodeToUnicodeFlag.js";
5
- import { debounce as l } from "./debounce.js";
6
- import { debounceCallback as c } from "./debounceCallback.js";
7
- import { debounceId as d } from "./debounceId.js";
8
- import { formatCurrency as b } from "./formatCurrency.js";
9
- import { formatDate as g } from "./formatDate.js";
10
- import { formatNumber as S } from "./formatNumber.js";
11
- import { getCountryFlagUrl as k } from "./getCountryFlagUrl.js";
12
- import { getErrorMessage as I } from "./getErrorMessage.js";
13
- import { IdleTimeout as U } from "./idleTimeout.js";
14
- import { isClient as w } from "./isClient.js";
15
- import { isEqual as A } from "./isEqual.js";
16
- import { isServer as M } from "./isServer.js";
17
- import { isStandaloneMode as D } from "./isStandaloneMode.js";
18
- import { kebabCase as N } from "./kebabCase.js";
19
- import { normalizeString as j } from "./normalizeString.js";
20
- import { pascalCase as G } from "./pascalCase.js";
21
- import { ScriptLoader as J } from "./scriptLoader.js";
22
- import { sleep as O } from "./sleep.js";
23
- import { snakeCase as Q } from "./snakeCase.js";
24
- import { Swipe as W } from "./swipeHandler.js";
25
- import { TextareaAutogrow as Y } from "./TextareaAutogrow.js";
26
- import { throttle as _ } from "./throttle.js";
27
- import { throttleId as rr } from "./throttleId.js";
28
- import { truthyFilter as er } from "./truthyFilter.js";
29
- import { UserVisibility as mr } from "./userVisibility.js";
1
+ import { camelCase } from "./camelCase.js";
2
+ import { capitalize } from "./capitalize.js";
3
+ import { checkAvailability } from "./checkAvailability.js";
4
+ import { countryCodeToUnicodeFlag } from "./countryCodeToUnicodeFlag.js";
5
+ import { debounce } from "./debounce.js";
6
+ import { debounceCallback } from "./debounceCallback.js";
7
+ import { debounceId } from "./debounceId.js";
8
+ import { formatCurrency } from "./formatCurrency.js";
9
+ import { formatDate } from "./formatDate.js";
10
+ import { formatNumber } from "./formatNumber.js";
11
+ import { getCountryFlagUrl } from "./getCountryFlagUrl.js";
12
+ import { getErrorMessage } from "./getErrorMessage.js";
13
+ import { IdleTimeout } from "./idleTimeout.js";
14
+ import { isClient } from "./isClient.js";
15
+ import { isEqual } from "./isEqual.js";
16
+ import { isServer } from "./isServer.js";
17
+ import { isStandaloneMode } from "./isStandaloneMode.js";
18
+ import { kebabCase } from "./kebabCase.js";
19
+ import { normalizeString } from "./normalizeString.js";
20
+ import { pascalCase } from "./pascalCase.js";
21
+ import { ScriptLoader } from "./scriptLoader.js";
22
+ import { sleep } from "./sleep.js";
23
+ import { snakeCase } from "./snakeCase.js";
24
+ import { Swipe } from "./swipeHandler.js";
25
+ import { TextareaAutogrow } from "./TextareaAutogrow.js";
26
+ import { throttle } from "./throttle.js";
27
+ import { throttleId } from "./throttleId.js";
28
+ import { truthyFilter } from "./truthyFilter.js";
29
+ import { UserVisibility } from "./userVisibility.js";
30
30
  export {
31
- U as IdleTimeout,
32
- J as ScriptLoader,
33
- W as Swipe,
34
- Y as TextareaAutogrow,
35
- mr as UserVisibility,
36
- e as camelCase,
37
- m as capitalize,
38
- f as checkAvailability,
39
- a as countryCodeToUnicodeFlag,
40
- l as debounce,
41
- c as debounceCallback,
42
- d as debounceId,
43
- b as formatCurrency,
44
- g as formatDate,
45
- S as formatNumber,
46
- k as getCountryFlagUrl,
47
- I as getErrorMessage,
48
- w as isClient,
49
- A as isEqual,
50
- M as isServer,
51
- D as isStandaloneMode,
52
- N as kebabCase,
53
- j as normalizeString,
54
- G as pascalCase,
55
- O as sleep,
56
- Q as snakeCase,
57
- _ as throttle,
58
- rr as throttleId,
59
- er as truthyFilter
31
+ IdleTimeout,
32
+ ScriptLoader,
33
+ Swipe,
34
+ TextareaAutogrow,
35
+ UserVisibility,
36
+ camelCase,
37
+ capitalize,
38
+ checkAvailability,
39
+ countryCodeToUnicodeFlag,
40
+ debounce,
41
+ debounceCallback,
42
+ debounceId,
43
+ formatCurrency,
44
+ formatDate,
45
+ formatNumber,
46
+ getCountryFlagUrl,
47
+ getErrorMessage,
48
+ isClient,
49
+ isEqual,
50
+ isServer,
51
+ isStandaloneMode,
52
+ kebabCase,
53
+ normalizeString,
54
+ pascalCase,
55
+ sleep,
56
+ snakeCase,
57
+ throttle,
58
+ throttleId,
59
+ truthyFilter
60
60
  };
@@ -1,6 +1,6 @@
1
- function e() {
1
+ function isClient() {
2
2
  return typeof document < "u";
3
3
  }
4
4
  export {
5
- e as isClient
5
+ isClient
6
6
  };