@rzl-zone/utils-js 3.13.1 → 3.14.0-beta.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.
- package/README.md +7 -6
- package/dist/.references/index.d.cts +2 -1
- package/dist/.references/index.d.ts +2 -1
- package/dist/AbortError-DK6kpzbu.cjs +26 -0
- package/dist/AbortError-DK6kpzbu.cjs.map +1 -0
- package/dist/AbortError-DVT8lAKn.js +20 -0
- package/dist/AbortError-DVT8lAKn.js.map +1 -0
- package/dist/{assertIsArray-HgzPQIAM.js → assertIsArray-CG7L7vlt.js} +3 -3
- package/dist/assertIsArray-CG7L7vlt.js.map +1 -0
- package/dist/{assertIsArray-CeXL4xv5.cjs → assertIsArray-CtCRD-_G.cjs} +5 -5
- package/dist/assertIsArray-CtCRD-_G.cjs.map +1 -0
- package/dist/assertIsPlainObject-DPZLj-Ho.cjs +26 -0
- package/dist/assertIsPlainObject-DPZLj-Ho.cjs.map +1 -0
- package/dist/assertIsPlainObject-j9bDqNLo.js +20 -0
- package/dist/assertIsPlainObject-j9bDqNLo.js.map +1 -0
- package/dist/{assertIsString-CY_WkCLr.js → assertIsString-CHIwE12y.js} +4 -4
- package/dist/assertIsString-CHIwE12y.js.map +1 -0
- package/dist/{assertIsString-DUrVt82d.cjs → assertIsString-CjE9kbQ_.cjs} +6 -6
- package/dist/assertIsString-CjE9kbQ_.cjs.map +1 -0
- package/dist/assertions/index.cjs +14 -12
- package/dist/assertions/index.cjs.map +1 -1
- package/dist/assertions/index.d.cts +2 -2
- package/dist/assertions/index.d.ts +2 -2
- package/dist/assertions/index.js +10 -8
- package/dist/assertions/index.js.map +1 -1
- package/dist/conversions/index.cjs +6 -6
- package/dist/conversions/index.d.cts +2 -2
- package/dist/conversions/index.d.ts +2 -2
- package/dist/conversions/index.js +6 -6
- package/dist/conversions-BFz6MKaV.cjs +449 -0
- package/dist/conversions-BFz6MKaV.cjs.map +1 -0
- package/dist/{conversions-1s7xMBe_.js → conversions-Ben5p5Ts.js} +43 -40
- package/dist/conversions-Ben5p5Ts.js.map +1 -0
- package/dist/errors/index.cjs +13 -0
- package/dist/errors/index.d.cts +180 -0
- package/dist/errors/index.d.ts +180 -0
- package/dist/errors/index.js +11 -0
- package/dist/events/index.cjs +10 -9
- package/dist/events/index.cjs.map +1 -1
- package/dist/events/index.d.cts +185 -100
- package/dist/events/index.d.ts +185 -100
- package/dist/events/index.js +9 -8
- package/dist/events/index.js.map +1 -1
- package/dist/formatter-ekJQF_bA-BepnCBkQ.cjs +67 -0
- package/dist/formatter-ekJQF_bA-BepnCBkQ.cjs.map +1 -0
- package/dist/formatter-ekJQF_bA-xLD9mGk4.js +55 -0
- package/dist/formatter-ekJQF_bA-xLD9mGk4.js.map +1 -0
- package/dist/formatters/index.cjs +2 -2
- package/dist/formatters/index.d.cts +2 -2
- package/dist/formatters/index.d.ts +2 -2
- package/dist/formatters/index.js +2 -2
- package/dist/{formatters-C6cVZBbG.js → formatters-BAbGsnYA.js} +78 -71
- package/dist/formatters-BAbGsnYA.js.map +1 -0
- package/dist/formatters-zd0Gs4Cs.cjs +436 -0
- package/dist/formatters-zd0Gs4Cs.cjs.map +1 -0
- package/dist/generators/index.cjs +37 -31
- package/dist/generators/index.cjs.map +1 -1
- package/dist/generators/index.d.cts +2 -2
- package/dist/generators/index.d.ts +2 -2
- package/dist/generators/index.js +29 -23
- package/dist/generators/index.js.map +1 -1
- package/dist/hasOwnProp-CVIhlD1i.js +47 -0
- package/dist/hasOwnProp-CVIhlD1i.js.map +1 -0
- package/dist/hasOwnProp-D9Tpgokd.cjs +53 -0
- package/dist/hasOwnProp-D9Tpgokd.cjs.map +1 -0
- package/dist/{index-RNQBTK8A.d.cts → index-9JsU_wMu.d.ts} +1375 -937
- package/dist/{index-ORbo-7zA.d.cts → index-BP3sUrAx.d.ts} +242 -133
- package/dist/{index-BG8wdusZ.d.cts → index-BVovC-yK.d.cts} +229 -200
- package/dist/index-C1X6ha9s.d.cts +1041 -0
- package/dist/index-CcPQZ41G.d.cts +1103 -0
- package/dist/index-CjpbuJF4.d.ts +2424 -0
- package/dist/index-CssrQyHh.d.cts +2424 -0
- package/dist/index-DZHiYYR7.d.cts +2179 -0
- package/dist/index-DZHiYYR7.d.ts +2179 -0
- package/dist/index-DlyDmXUo.d.ts +1103 -0
- package/dist/index-Dm4a___O.d.ts +1041 -0
- package/dist/{index-CRz9rSZL.d.ts → index-Dwduk7ez.d.cts} +1375 -937
- package/dist/{index-DPJ-e2JZ.d.ts → index-I5V6RbZM.d.cts} +1592 -790
- package/dist/{index-B5EBAgmC.d.cts → index-hOqBIL7F.d.ts} +1592 -790
- package/dist/{index-B1VQ6USF.d.ts → index-jyuOZMX7.d.ts} +229 -200
- package/dist/{index-ORbo-7zA.d.ts → index-lI0b7iUz.d.cts} +242 -133
- package/dist/{isBigInt-y7s3rsKc.js → isBigInt-Cez32M69.js} +2 -2
- package/dist/isBigInt-Cez32M69.js.map +1 -0
- package/dist/{isBigInt-BVj0M5pq.cjs → isBigInt-YgpNKTbA.cjs} +2 -2
- package/dist/isBigInt-YgpNKTbA.cjs.map +1 -0
- package/dist/{isEmptyString-BYMz_wt9.js → isEmptyString-C9QLWjx2.js} +4 -4
- package/dist/isEmptyString-C9QLWjx2.js.map +1 -0
- package/dist/{isEmptyString-C8PYNPgw.cjs → isEmptyString-O4TFe1Ao.cjs} +5 -5
- package/dist/isEmptyString-O4TFe1Ao.cjs.map +1 -0
- package/dist/isEmptyValue-CFExALXZ.cjs +54 -0
- package/dist/isEmptyValue-CFExALXZ.cjs.map +1 -0
- package/dist/isEmptyValue-kCjnLjbN.js +36 -0
- package/dist/isEmptyValue-kCjnLjbN.js.map +1 -0
- package/dist/{isFinite-DeDaBDr2.cjs → isFinite-B_hHbDpa.cjs} +6 -6
- package/dist/isFinite-B_hHbDpa.cjs.map +1 -0
- package/dist/{isFinite-BEJFOv6B.js → isFinite-ZvNhyHlF.js} +5 -5
- package/dist/isFinite-ZvNhyHlF.js.map +1 -0
- package/dist/{isInteger-DEDbBGez.js → isInteger-aZgzTTZG.js} +4 -4
- package/dist/isInteger-aZgzTTZG.js.map +1 -0
- package/dist/{isInteger-CQLThJOR.cjs → isInteger-dnc6W63Z.cjs} +4 -4
- package/dist/isInteger-dnc6W63Z.cjs.map +1 -0
- package/dist/isNumber-BCWD4dW0.js +20 -0
- package/dist/isNumber-BCWD4dW0.js.map +1 -0
- package/dist/isNumber-BkzwAe50.cjs +26 -0
- package/dist/isNumber-BkzwAe50.cjs.map +1 -0
- package/dist/isPlainObject-CAe_ElKO.d.cts +331 -0
- package/dist/isPlainObject-CJvRG4Je.d.ts +331 -0
- package/dist/{isServer-q3o6cSwD.js → isServer-CQzrX5e0.js} +2 -2
- package/dist/isServer-CQzrX5e0.js.map +1 -0
- package/dist/{isServer-DmycqWsF.cjs → isServer-DhFaedeT.cjs} +2 -2
- package/dist/isServer-DhFaedeT.cjs.map +1 -0
- package/dist/{isEqual-DaPDxMyw.cjs → isTypedArray-DjADSu8q.cjs} +45 -13
- package/dist/isTypedArray-DjADSu8q.cjs.map +1 -0
- package/dist/{isEqual-DM4S_kWh.js → isTypedArray-DxsPKrLh.js} +29 -9
- package/dist/isTypedArray-DxsPKrLh.js.map +1 -0
- package/dist/{isValidDomain-B8Nukgw0.js → isValidDomain-CDtNOhMc.js} +13 -54
- package/dist/isValidDomain-CDtNOhMc.js.map +1 -0
- package/dist/{isValidDomain-ZbyeGOO9.cjs → isValidDomain-D_x7uNIu.cjs} +16 -69
- package/dist/isValidDomain-D_x7uNIu.cjs.map +1 -0
- package/dist/{assertIsBoolean-CWUs-I5l.js → logger-CLWnKRKE.js} +657 -587
- package/dist/logger-CLWnKRKE.js.map +1 -0
- package/dist/{assertIsBoolean-D41HrTB_.cjs → logger-CUacYy3D.cjs} +658 -612
- package/dist/logger-CUacYy3D.cjs.map +1 -0
- package/dist/{noop-BY43WaoU.cjs → noop-CjEbNsJL.cjs} +2 -2
- package/dist/noop-CjEbNsJL.cjs.map +1 -0
- package/dist/{noop-CjY8xVHv.js → noop-qxrcogt5.js} +2 -2
- package/dist/noop-qxrcogt5.js.map +1 -0
- package/dist/{normalizeSpaces-BhZp0U_6.cjs → normalizeSpaces-D0_Z4qnO.cjs} +6 -9
- package/dist/normalizeSpaces-D0_Z4qnO.cjs.map +1 -0
- package/dist/{normalizeSpaces-BoUDtq5P.js → normalizeSpaces-DAsxzBEQ.js} +4 -7
- package/dist/normalizeSpaces-DAsxzBEQ.js.map +1 -0
- package/dist/operations/index.cjs +152 -22
- package/dist/operations/index.cjs.map +1 -1
- package/dist/operations/index.d.cts +257 -35
- package/dist/operations/index.d.ts +257 -35
- package/dist/operations/index.js +142 -13
- package/dist/operations/index.js.map +1 -1
- package/dist/parsers/index.cjs +2 -2
- package/dist/parsers/index.d.cts +238 -180
- package/dist/parsers/index.d.ts +238 -180
- package/dist/parsers/index.js +2 -2
- package/dist/{parsers-B8KYXIjE.js → parsers-BBAE_xVM.js} +9 -8
- package/dist/parsers-BBAE_xVM.js.map +1 -0
- package/dist/{parsers-B_FPX35n.cjs → parsers-i8WEeMJl.cjs} +10 -9
- package/dist/parsers-i8WEeMJl.cjs.map +1 -0
- package/dist/{parsing-Bfaw85Hd.js → parsing-D9tbKQ0v.js} +3 -3
- package/dist/parsing-D9tbKQ0v.js.map +1 -0
- package/dist/{parsing-BCZGco7n.cjs → parsing-DGjB8cwr.cjs} +4 -4
- package/dist/parsing-DGjB8cwr.cjs.map +1 -0
- package/dist/predicates/index.cjs +43 -43
- package/dist/predicates/index.d.cts +3 -3
- package/dist/predicates/index.d.ts +3 -3
- package/dist/predicates/index.js +14 -14
- package/dist/{predicates-KlyOvBSC.js → predicates-C0dova7l.js} +45 -40
- package/dist/predicates-C0dova7l.js.map +1 -0
- package/dist/{predicates-8y28VrbT.cjs → predicates-Dd7To7B4.cjs} +89 -84
- package/dist/predicates-Dd7To7B4.cjs.map +1 -0
- package/dist/promises/index.cjs +27 -26
- package/dist/promises/index.cjs.map +1 -1
- package/dist/promises/index.d.cts +227 -75
- package/dist/promises/index.d.ts +227 -75
- package/dist/promises/index.js +27 -26
- package/dist/promises/index.js.map +1 -1
- package/dist/{punyCode-DnKi0qjS.cjs → punyCode-DHTLhGdD.cjs} +12 -12
- package/dist/punyCode-DHTLhGdD.cjs.map +1 -0
- package/dist/{punyCode-Dwto1RpA.js → punyCode-Deb1Mrkc.js} +12 -12
- package/dist/punyCode-Deb1Mrkc.js.map +1 -0
- package/dist/{removeSpaces--8NW-HSx.js → removeSpaces-BPnsdRN0.js} +4 -4
- package/dist/removeSpaces-BPnsdRN0.js.map +1 -0
- package/dist/{removeSpaces-CmrrkeXz.cjs → removeSpaces-CN3pxBz_.cjs} +7 -7
- package/dist/removeSpaces-CN3pxBz_.cjs.map +1 -0
- package/dist/rzl-utils.global.js +13 -13
- package/dist/safeJsonParse-D1FLVTEM.cjs +209 -0
- package/dist/safeJsonParse-D1FLVTEM.cjs.map +1 -0
- package/dist/{safeJsonParse-OnUwG2El.js → safeJsonParse-DEVKNDSn.js} +29 -28
- package/dist/safeJsonParse-DEVKNDSn.js.map +1 -0
- package/dist/safeStableStringify-C5HHKUdn.cjs +125 -0
- package/dist/safeStableStringify-C5HHKUdn.cjs.map +1 -0
- package/dist/{safeStableStringify-B2KTTS3r.js → safeStableStringify-DfwxmiWn.js} +20 -13
- package/dist/safeStableStringify-DfwxmiWn.js.map +1 -0
- package/dist/strings/index.cjs +26 -30
- package/dist/strings/index.cjs.map +1 -1
- package/dist/strings/index.d.cts +2 -2
- package/dist/strings/index.d.ts +2 -2
- package/dist/strings/index.js +13 -17
- package/dist/strings/index.js.map +1 -1
- package/dist/tailwind/index.cjs +3 -3
- package/dist/tailwind/index.d.cts +3 -3
- package/dist/tailwind/index.d.ts +3 -3
- package/dist/tailwind/index.js +3 -3
- package/dist/{tailwind-DUuboq52.cjs → tailwind-BG7B0cDs.cjs} +59 -53
- package/dist/tailwind-BG7B0cDs.cjs.map +1 -0
- package/dist/{tailwind-CUdmv-oO.js → tailwind-tJNnFPsF.js} +38 -32
- package/dist/tailwind-tJNnFPsF.js.map +1 -0
- package/dist/{toStringArrayUnRecursive-OOHGazks.js → toStringArrayUnRecursive-D0WbLIRz.js} +9 -9
- package/dist/toStringArrayUnRecursive-D0WbLIRz.js.map +1 -0
- package/dist/toStringArrayUnRecursive-QLoaNX_-.cjs +51 -0
- package/dist/toStringArrayUnRecursive-QLoaNX_-.cjs.map +1 -0
- package/dist/urls/index.cjs +3 -3
- package/dist/urls/index.d.cts +635 -443
- package/dist/urls/index.d.ts +635 -443
- package/dist/urls/index.js +3 -3
- package/dist/{urls-BXT4Krsq.js → urls-EoWslGgg.js} +50 -41
- package/dist/urls-EoWslGgg.js.map +1 -0
- package/dist/urls-NCzPepe2.cjs +308 -0
- package/dist/urls-NCzPepe2.cjs.map +1 -0
- package/package.json +6 -6
- package/dist/assertIsArray-CeXL4xv5.cjs.map +0 -1
- package/dist/assertIsArray-HgzPQIAM.js.map +0 -1
- package/dist/assertIsBoolean-CWUs-I5l.js.map +0 -1
- package/dist/assertIsBoolean-D41HrTB_.cjs.map +0 -1
- package/dist/assertIsString-CY_WkCLr.js.map +0 -1
- package/dist/assertIsString-DUrVt82d.cjs.map +0 -1
- package/dist/conversions-1s7xMBe_.js.map +0 -1
- package/dist/conversions-B3Rf8uId.cjs +0 -446
- package/dist/conversions-B3Rf8uId.cjs.map +0 -1
- package/dist/formatters-C6cVZBbG.js.map +0 -1
- package/dist/formatters-aEAAuzjx.cjs +0 -429
- package/dist/formatters-aEAAuzjx.cjs.map +0 -1
- package/dist/index-CPCt6_Wq.d.cts +0 -765
- package/dist/index-CPCt6_Wq.d.ts +0 -765
- package/dist/index-DBwNa1iO.d.ts +0 -947
- package/dist/index-DPTYOQkn.d.cts +0 -947
- package/dist/index-Dig1fIhZ.d.cts +0 -1716
- package/dist/index-Dig1fIhZ.d.ts +0 -1716
- package/dist/isBigInt-BVj0M5pq.cjs.map +0 -1
- package/dist/isBigInt-y7s3rsKc.js.map +0 -1
- package/dist/isEmptyObject-BsHngDz4.cjs +0 -37
- package/dist/isEmptyObject-BsHngDz4.cjs.map +0 -1
- package/dist/isEmptyObject-DPGR9iPj.js +0 -25
- package/dist/isEmptyObject-DPGR9iPj.js.map +0 -1
- package/dist/isEmptyString-BYMz_wt9.js.map +0 -1
- package/dist/isEmptyString-C8PYNPgw.cjs.map +0 -1
- package/dist/isEmptyValue-BXf7f1jz.cjs +0 -30
- package/dist/isEmptyValue-BXf7f1jz.cjs.map +0 -1
- package/dist/isEmptyValue-D4OHTB3u.js +0 -24
- package/dist/isEmptyValue-D4OHTB3u.js.map +0 -1
- package/dist/isEqual-DM4S_kWh.js.map +0 -1
- package/dist/isEqual-DaPDxMyw.cjs.map +0 -1
- package/dist/isFinite-BEJFOv6B.js.map +0 -1
- package/dist/isFinite-DeDaBDr2.cjs.map +0 -1
- package/dist/isInteger-CQLThJOR.cjs.map +0 -1
- package/dist/isInteger-DEDbBGez.js.map +0 -1
- package/dist/isPlainObject-BwTkj3G0.d.cts +0 -339
- package/dist/isPlainObject-BwTkj3G0.d.ts +0 -339
- package/dist/isServer-DmycqWsF.cjs.map +0 -1
- package/dist/isServer-q3o6cSwD.js.map +0 -1
- package/dist/isTypedArray-BQLbLXsU.cjs +0 -43
- package/dist/isTypedArray-BQLbLXsU.cjs.map +0 -1
- package/dist/isTypedArray-XiBnifLN.js +0 -31
- package/dist/isTypedArray-XiBnifLN.js.map +0 -1
- package/dist/isValidDomain-B8Nukgw0.js.map +0 -1
- package/dist/isValidDomain-ZbyeGOO9.cjs.map +0 -1
- package/dist/noop-BY43WaoU.cjs.map +0 -1
- package/dist/noop-CjY8xVHv.js.map +0 -1
- package/dist/normalizeSpaces-BhZp0U_6.cjs.map +0 -1
- package/dist/normalizeSpaces-BoUDtq5P.js.map +0 -1
- package/dist/parsers-B8KYXIjE.js.map +0 -1
- package/dist/parsers-B_FPX35n.cjs.map +0 -1
- package/dist/parsing-BCZGco7n.cjs.map +0 -1
- package/dist/parsing-Bfaw85Hd.js.map +0 -1
- package/dist/predicates-8y28VrbT.cjs.map +0 -1
- package/dist/predicates-KlyOvBSC.js.map +0 -1
- package/dist/punyCode-DnKi0qjS.cjs.map +0 -1
- package/dist/punyCode-Dwto1RpA.js.map +0 -1
- package/dist/removeSpaces--8NW-HSx.js.map +0 -1
- package/dist/removeSpaces-CmrrkeXz.cjs.map +0 -1
- package/dist/safeJsonParse-OnUwG2El.js.map +0 -1
- package/dist/safeJsonParse-sFqVXf-e.cjs +0 -208
- package/dist/safeJsonParse-sFqVXf-e.cjs.map +0 -1
- package/dist/safeStableStringify-B2KTTS3r.js.map +0 -1
- package/dist/safeStableStringify-Cmi6GyWj.cjs +0 -106
- package/dist/safeStableStringify-Cmi6GyWj.cjs.map +0 -1
- package/dist/tailwind-CUdmv-oO.js.map +0 -1
- package/dist/tailwind-DUuboq52.cjs.map +0 -1
- package/dist/toStringArrayUnRecursive-OOHGazks.js.map +0 -1
- package/dist/toStringArrayUnRecursive-pfk2oP8C.cjs +0 -51
- package/dist/toStringArrayUnRecursive-pfk2oP8C.cjs.map +0 -1
- package/dist/urls-BL9C_yU3.cjs +0 -299
- package/dist/urls-BL9C_yU3.cjs.map +0 -1
- package/dist/urls-BXT4Krsq.js.map +0 -1
package/dist/events/index.cjs
CHANGED
|
@@ -2,20 +2,21 @@
|
|
|
2
2
|
* ========================================================================
|
|
3
3
|
* @rzl-zone/utils-js
|
|
4
4
|
* ------------------------------------------------------------------------
|
|
5
|
-
* Version: `3.
|
|
5
|
+
* Version: `3.14.0-beta.0`
|
|
6
6
|
* Author: `Rizalvin Dwiky <rizalvindwiky@gmail.com>`
|
|
7
7
|
* Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/utils-js`
|
|
8
8
|
* ========================================================================
|
|
9
9
|
*/
|
|
10
10
|
"use strict";
|
|
11
11
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
12
|
+
const require_logger = require('../logger-CUacYy3D.cjs');
|
|
13
|
+
const require_isNumber = require('../isNumber-BkzwAe50.cjs');
|
|
14
|
+
const require_assertIsString = require('../assertIsString-CjE9kbQ_.cjs');
|
|
15
|
+
const require_isServer = require('../isServer-DhFaedeT.cjs');
|
|
15
16
|
const disableUserInteraction = (className = "on_processing") => {
|
|
16
17
|
if (require_isServer.isServer()) return;
|
|
17
18
|
require_assertIsString.assertIsString(className, { message({ validType, currentType }) {
|
|
18
|
-
return `First parameter \`className\` must be of type \`${validType}\`, but received: \`${currentType}
|
|
19
|
+
return require_logger.createMessage("disableUserInteraction", `First parameter \`className\` must be of type \`${validType}\`, but received: \`${currentType}\`.`);
|
|
19
20
|
} });
|
|
20
21
|
const { documentElement } = document;
|
|
21
22
|
if (documentElement && !documentElement.classList.contains(className)) documentElement.classList.add(className);
|
|
@@ -23,7 +24,7 @@ const disableUserInteraction = (className = "on_processing") => {
|
|
|
23
24
|
const enableUserInteraction = (className = "on_processing") => {
|
|
24
25
|
if (require_isServer.isServer()) return;
|
|
25
26
|
require_assertIsString.assertIsString(className, { message({ validType, currentType }) {
|
|
26
|
-
return `First parameter \`className\` must be of type \`${validType}\`, but received: \`${currentType}
|
|
27
|
+
return require_logger.createMessage("enableUserInteraction", `First parameter \`className\` must be of type \`${validType}\`, but received: \`${currentType}\`.`);
|
|
27
28
|
} });
|
|
28
29
|
const { documentElement } = document;
|
|
29
30
|
if (documentElement && documentElement.classList.contains(className)) documentElement.classList.remove(className);
|
|
@@ -35,13 +36,13 @@ const removeElementFocus = () => {
|
|
|
35
36
|
};
|
|
36
37
|
const scrollToTop = (options) => {
|
|
37
38
|
if (require_isServer.isServer()) return;
|
|
38
|
-
if (!
|
|
39
|
-
const behavior =
|
|
39
|
+
if (!require_logger.isPlainObject(options)) options = {};
|
|
40
|
+
const behavior = options.behavior && require_logger.isNonEmptyString(options.behavior) && [
|
|
40
41
|
"auto",
|
|
41
42
|
"instant",
|
|
42
43
|
"smooth"
|
|
43
44
|
].includes(options.behavior) ? options.behavior : "smooth";
|
|
44
|
-
let timeout =
|
|
45
|
+
let timeout = options.timeout && require_isNumber.isNumber(options.timeout) && options.timeout >= 1 ? options.timeout : 1;
|
|
45
46
|
timeout = timeout > 2147483647 ? 2147483647 : timeout;
|
|
46
47
|
setTimeout(() => window.scrollTo({
|
|
47
48
|
top: 0,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["isServer","isServer","isServer","isServer","isPlainObject","hasOwnProp","isNonEmptyString","isNumber"],"sources":["../../src/events/actions/disableUserInteraction.ts","../../src/events/actions/enableUserInteraction.ts","../../src/events/actions/removeElementFocus.ts","../../src/events/actions/scrollToTop.ts"],"sourcesContent":["import { isServer } from \"@/predicates/is/isServer\";\nimport { assertIsString } from \"@/assertions/strings/assertIsString\";\n\n/** ----------------------------------------------------------\n * * ***Utility: `disableUserInteraction`.***\n * ----------------------------------------------------------\n * **Disables user interaction by adding a CSS class to the `<html>` element.**\n * - **Key points**:\n * - Works **only in browser environments**.\n * - Safely adds the specified CSS class to `<html>`.\n * - Prevents multiple additions of the same class.\n * - Useful to indicate that a process is ongoing\n * (e.g., loading or processing state).\n * - **Using custom CSS classes:**\n * - You can pass any class name that exists in your CSS.\n * - Example: if you have `.loading` in your styles, passing `\"loading\"`\n * will add it and disable interactions accordingly.\n * - **Validation:**\n * - Throws `TypeError` if the `className` parameter is not a string.\n * @defaultValue `\"on_processing\"`\n * @param {string} [className=\"on_processing\"] - The CSS class to add, defaults to `\"on_processing\"`.\n * @returns {void} Does not return anything (void).\n * @throws **{@link TypeError | `TypeError`}** if `className` is not a string.\n * @example\n * * ***Example in your code:***\n * ```ts\n * disableUserInteraction(); // ➔ Adds \"on_processing\" class\n * disableUserInteraction(\"loading\"); // ➔ Adds \"loading\" class\n * // ❌ Invalid value:\n * disableUserInteraction(123); // ➔ Throws TypeError\n * ```\n * * ***Example in your css file (with defaultValue `className` props [on_processing]):***\n * ```css\n * .on_processing {\n * cursor: wait;\n * touch-action: none;\n * user-select: none;\n * }\n *\n * .on_processing > * {\n * pointer-events: none;\n * touch-action: none;\n * user-select: none;\n * }\n * ```\n */\nexport const disableUserInteraction = (\n className: string = \"on_processing\"\n): void => {\n // Ensure function runs only in the browser\n if (isServer()) return;\n\n assertIsString(className, {\n message({ validType, currentType }) {\n return `First parameter \\`className\\` must be of type \\`${validType}\\`, but received: \\`${currentType}\\`.`;\n }\n });\n\n const { documentElement } = document;\n\n if (documentElement && !documentElement.classList.contains(className)) {\n documentElement.classList.add(className);\n }\n};\n","import { isServer } from \"@/predicates/is/isServer\";\nimport { assertIsString } from \"@/assertions/strings/assertIsString\";\n\n/** ----------------------------------------------------------\n * * ***Utility: `enableUserInteraction`.***\n * ----------------------------------------------------------\n * **Enables user interaction by removing a CSS class from the `<html>` element.**\n * - **Key points**:\n * - Works **only in browser environments**.\n * - Safely removes the specified CSS class from `<html>`.\n * - Does nothing if the class is not present.\n * - Useful to re-enable user interactions after a process\n * (e.g., loading or processing) completes.\n * - **Using custom CSS classes:**\n * - You can pass any class name that exists in your CSS.\n * - Example: if you have `.loading` in your styles, passing `\"loading\"`\n * will remove it and re-enable interactions.\n * - **Validation:**\n * - Throws `TypeError` if the `className` parameter is not a string.\n * @defaultValue `\"on_processing\"`\n * @param {string} [className=\"on_processing\"] - The CSS class to remove, defaults to `\"on_processing\"`.\n * @returns {void} Does not return anything (void).\n * @throws **{@link TypeError | `TypeError`}** if `className` is not a string.\n * @example\n * * ***Example in your code:***\n * ```ts\n * enableUserInteraction(); // ➔ Removes \"on_processing\" class\n * enableUserInteraction(\"loading\"); // ➔ Removes \"loading\" class\n * // ❌ Invalid value:\n * enableUserInteraction(123); // ➔ Throws TypeError\n * ```\n * * ***Example in your css file (with defaultValue `className` props [on_processing]):***\n * ```css\n * .on_processing {\n * cursor: wait;\n * touch-action: none;\n * user-select: none;\n * }\n *\n * .on_processing > * {\n * pointer-events: none;\n * touch-action: none;\n * user-select: none;\n * }\n * ```\n */\nexport const enableUserInteraction = (\n className: string = \"on_processing\"\n): void => {\n // Ensure function runs only in the browser\n if (isServer()) return;\n\n assertIsString(className, {\n message({ validType, currentType }) {\n return `First parameter \\`className\\` must be of type \\`${validType}\\`, but received: \\`${currentType}\\`.`;\n }\n });\n\n const { documentElement } = document;\n\n if (documentElement && documentElement.classList.contains(className)) {\n documentElement.classList.remove(className);\n }\n};\n","import { isServer } from \"@/predicates/is/isServer\";\n\n/** ----------------------------------------------------------\n * * ***Utility: `removeElementFocus`.***\n * ----------------------------------------------------------\n * **Removes focus from the currently active element in the document.**\n * - **Features**:\n * - This function works **only in browser environments** ***(safely no-ops in server environments)***.\n * - If an element is focused, it will lose focus by calling `HTMLElement.blur()`.\n * - If no element is focused or the active element is not an `HTMLElement`, nothing happens.\n * @returns {void} Does not return anything (void).\n * @example\n * removeElementFocus(); // ➔ Removes focus from the currently active element\n */\nexport const removeElementFocus = (): void => {\n // Ensure function runs only in the browser\n if (isServer()) return;\n\n const activeElement = document.activeElement;\n\n if (activeElement instanceof HTMLElement) {\n activeElement.blur();\n } else {\n // not-support, currently we nothing to do...\n // console.warn(\"removeElementFocus: No active element to blur or unsupported element type.\");\n }\n};\n","import { isNumber } from \"@/predicates/is/isNumber\";\nimport { hasOwnProp } from \"@/predicates/has/hasOwnProp\";\nimport { isServer } from \"@/predicates/is/isServer\";\nimport { isPlainObject } from \"@/predicates/is/isPlainObject\";\nimport { isNonEmptyString } from \"@/predicates/is/isNonEmptyString\";\n\n/**\n * ***Types options for {@link scrollToTop | `scrollToTop`}.***\n */\ntype ScrollToTopOptions = {\n /** ----------------------------------------------------------\n * * ***Scroll animation type.***\n * ----------------------------------------------------------\n * - ***Behavior:***\n * - Valid values: `\"auto\"`, `\"instant\"`, `\"smooth\"`.\n * - Default force to `\"smooth\"` if missing or invalid.\n *\n * @default \"smooth\"\n */\n behavior?: ScrollBehavior | undefined;\n /** ----------------------------------------------------------\n * * ***Delay before scrolling (in milliseconds).***\n * ----------------------------------------------------------\n * - ***Behavior:***\n * - Default value is `1`.\n * - Valid values: any number `≥` `1`.\n * - Non-integer number are truncated to an integer.\n * - Force to `2147483647` if number is larger than `2147483647`.\n * - Default force to `1` if `missing`, `NaN`, `invalid-type`, or `less-than` `1`.\n *\n * @default 1\n */\n timeout?: number | undefined;\n};\n\n/** ----------------------------------------------------------\n * * ***Utility: `scrollToTop`.***\n * ----------------------------------------------------------\n * **Scrolls the page to the top with optional smooth animation and delay.**\n * - **Features**:\n * - This function works **only in browser environments** (no effect on server-side).\n * - It leverages the native `window.scrollTo()` API with support for smooth scrolling\n * and an optional timeout delay before executing the scroll.\n * - Each option has strict valid values.\n * - If an invalid value is provided, the function **automatically falls back to its default**.\n * @param {ScrollToTopOptions} [options] - Optional settings for scroll behavior.\n * @param {ScrollToTopOptions[\"behavior\"]} [options.behavior=\"smooth\"] - Scroll animation type.\n * - Valid values: `\"auto\"`, `\"instant\"`, `\"smooth\"`.\n * - Default force to `\"smooth\"` if missing or invalid.\n * @param {ScrollToTopOptions[\"timeout\"]} [options.timeout=1] - Delay before scrolling (in milliseconds).\n * - Default value is `1`.\n * - Valid values: any number `≥` `1`.\n * - Non-integer number are truncated to an integer.\n * - Force to `2147483647` if number is larger than `2147483647`.\n * - Default force to `1` if `missing`, `NaN`, `invalid`, or `less-than` `1`.\n * @returns {void} Does not return anything, only scrolling to top (void).\n * @example\n * // ✅ Valid options value:\n * scrollToTop();\n * // ➔ Scroll smoothly to the top after 1ms delay\n * scrollToTop({ behavior: \"instant\" });\n * // ➔ Jump instantly to the top\n * scrollToTop({ timeout: 500 });\n * // ➔ Scroll smoothly to the top after 500ms\n *\n * // ❌ Invalid options value:\n * scrollToTop({ behavior: \"fly\", timeout: -100 });\n * // ➔ Fallback: behavior=\"smooth\", timeout=1\n * scrollToTop({ behavior: \"fly\", timeout: 123.55 });\n * // ➔ Fallback: behavior=\"smooth\", timeout=123\n */\nexport const scrollToTop = (options?: ScrollToTopOptions): void => {\n // Ensure function runs only in the browser\n if (isServer()) return;\n\n // Ensure options is an object and Defensive options check\n if (!isPlainObject(options)) {\n options = {};\n }\n\n const behavior: ScrollBehavior =\n hasOwnProp(options, \"behavior\") &&\n isNonEmptyString(options.behavior) &&\n [\"auto\", \"instant\", \"smooth\"].includes(options.behavior)\n ? options.behavior\n : \"smooth\";\n let timeout =\n hasOwnProp(options, \"timeout\") &&\n isNumber(options.timeout) &&\n options.timeout >= 1\n ? options.timeout\n : 1;\n\n timeout = timeout > 2147483647 ? 2147483647 : timeout;\n\n setTimeout(() => window.scrollTo({ top: 0, left: 0, behavior }), timeout);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8CA,MAAa,0BACX,YAAoB,oBACX;CAET,IAAIA,0BAAS,GAAG;CAEhB,sCAAe,WAAW,EACxB,QAAQ,EAAE,WAAW,eAAe;EAClC,OAAO,mDAAmD,UAAU,sBAAsB,YAAY;CACxG,EACF,CAAC;CAED,MAAM,EAAE,oBAAoB;CAE5B,IAAI,mBAAmB,CAAC,gBAAgB,UAAU,SAAS,SAAS,GAClE,gBAAgB,UAAU,IAAI,SAAS;AAE3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACjBA,MAAa,yBACX,YAAoB,oBACX;CAET,IAAIC,0BAAS,GAAG;CAEhB,sCAAe,WAAW,EACxB,QAAQ,EAAE,WAAW,eAAe;EAClC,OAAO,mDAAmD,UAAU,sBAAsB,YAAY;CACxG,EACF,CAAC;CAED,MAAM,EAAE,oBAAoB;CAE5B,IAAI,mBAAmB,gBAAgB,UAAU,SAAS,SAAS,GACjE,gBAAgB,UAAU,OAAO,SAAS;AAE9C;;;;;;;;;;;;;;;;ACjDA,MAAa,2BAAiC;CAE5C,IAAIC,0BAAS,GAAG;CAEhB,MAAM,gBAAgB,SAAS;CAE/B,IAAI,yBAAyB,aAC3B,cAAc,KAAK;AAKvB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC6CA,MAAa,eAAe,YAAuC;CAEjE,IAAIC,0BAAS,GAAG;CAGhB,IAAI,CAACC,sCAAc,OAAO,GACxB,UAAU,CAAC;CAGb,MAAM,WACJC,mCAAW,SAAS,UAAU,KAC9BC,yCAAiB,QAAQ,QAAQ,KACjC;EAAC;EAAQ;EAAW;CAAQ,EAAE,SAAS,QAAQ,QAAQ,IACnD,QAAQ,WACR;CACN,IAAI,UACFD,mCAAW,SAAS,SAAS,KAC7BE,iCAAS,QAAQ,OAAO,KACxB,QAAQ,WAAW,IACf,QAAQ,UACR;CAEN,UAAU,UAAU,aAAa,aAAa;CAE9C,iBAAiB,OAAO,SAAS;EAAE,KAAK;EAAG,MAAM;EAAG;CAAS,CAAC,GAAG,OAAO;AAC1E"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["isServer","createMessage","isServer","createMessage","isServer","isServer","isPlainObject","isNonEmptyString","isNumber"],"sources":["../../src/events/actions/disableUserInteraction.ts","../../src/events/actions/enableUserInteraction.ts","../../src/events/actions/removeElementFocus.ts","../../src/events/actions/scrollToTop.ts"],"sourcesContent":["import { createMessage } from \"@/_private/logger\";\n\nimport { isServer } from \"@/predicates/is/isServer\";\nimport { assertIsString } from \"@/assertions/strings/assertIsString\";\n\n/** ----------------------------------------------------------\n * * ***Utility: `disableUserInteraction`.***\n * -----------------------------------------------------------\n * **Disables user interaction by adding a CSS class to the `<html>` element.**\n *\n * ---\n * - **Key points**:\n * - Works **only in browser environments**.\n * - Safely adds the specified CSS class to `<html>`.\n * - Prevents multiple additions of the same class.\n * - Useful to indicate that a process is ongoing\n * (e.g., loading or processing state).\n * - **Using custom CSS classes:**\n * - You can pass any class name that exists in your CSS.\n * - Example: if you have `.loading` in your styles, passing `\"loading\"`\n * will add it and disable interactions accordingly.\n * - **Validation:**\n * - Throws `TypeError` if the `className` parameter is not a string.\n *\n * ---\n * @default\n * ```ts\n * \"on_processing\"\n * ```\n *\n * ---\n * @param {string} [className=\"on_processing\"] - The CSS class to add, defaults to `\"on_processing\"`.\n *\n * ---\n * @throws **{@link TypeError | `TypeError`}** if `className` is not a string.\n *\n * ---\n * @returns {void} Does not return anything (void).\n *\n * ---\n * @example\n * - ***Example in your code:***\n * ```ts\n * disableUserInteraction();\n * // ➔ Adds \"on_processing\" class\n * disableUserInteraction(\"loading\");\n * // ➔ Adds \"loading\" class\n *\n * // ❌ Invalid value:\n * disableUserInteraction(123);\n * // ➔ Throws TypeError\n * ```\n * - ***Example in your css file (with defaultValue `className` props [on_processing]):***\n * ```css\n * .on_processing {\n * cursor: wait;\n * touch-action: none;\n * user-select: none;\n * }\n *\n * .on_processing > * {\n * pointer-events: none;\n * touch-action: none;\n * user-select: none;\n * }\n * ```\n */\nexport const disableUserInteraction = (\n className: string = \"on_processing\"\n): void => {\n // Ensure function runs only in the browser\n if (isServer()) return;\n\n assertIsString(className, {\n message({ validType, currentType }) {\n return createMessage(\n \"disableUserInteraction\",\n `First parameter \\`className\\` must be of type \\`${validType}\\`, but received: \\`${currentType}\\`.`\n );\n }\n });\n\n const { documentElement } = document;\n\n if (documentElement && !documentElement.classList.contains(className)) {\n documentElement.classList.add(className);\n }\n};\n","import { createMessage } from \"@/_private/logger\";\n\nimport { isServer } from \"@/predicates/is/isServer\";\nimport { assertIsString } from \"@/assertions/strings/assertIsString\";\n\n/** ----------------------------------------------------------\n * * ***Utility: `enableUserInteraction`.***\n * -----------------------------------------------------------\n * **Enables user interaction by removing a CSS class from the `<html>` element.**\n *\n * ---\n * - **Key points**:\n * - Works **only in browser environments**.\n * - Safely removes the specified CSS class from `<html>`.\n * - Does nothing if the class is not present.\n * - Useful to re-enable user interactions after a process\n * (e.g., loading or processing) completes.\n * - **Using custom CSS classes:**\n * - You can pass any class name that exists in your CSS.\n * - Example: if you have `.loading` in your styles, passing `\"loading\"`\n * will remove it and re-enable interactions.\n * - **Validation:**\n * - Throws `TypeError` if the `className` parameter is not a string.\n *\n * ---\n * @default\n * ```ts\n * \"on_processing\"\n * ```\n *\n * ---\n * @param {string} [className=\"on_processing\"] - The CSS class to remove, defaults to `\"on_processing\"`.\n *\n * ---\n * @throws **{@link TypeError | `TypeError`}** if `className` is not a string.\n *\n * ---\n * @returns {void} Does not return anything (void).\n *\n * ---\n * @example\n * - ***Example in your code:***\n * ```ts\n * enableUserInteraction();\n * // ➔ Removes \"on_processing\" class\n * enableUserInteraction(\"loading\");\n * // ➔ Removes \"loading\" class\n *\n * // ❌ Invalid value:\n * enableUserInteraction(123);\n * // ➔ Throws TypeError\n * ```\n *\n * - ***Example in your css file (with defaultValue `className` props [on_processing]):***\n * ```css\n * .on_processing {\n * cursor: wait;\n * touch-action: none;\n * user-select: none;\n * }\n *\n * .on_processing > * {\n * pointer-events: none;\n * touch-action: none;\n * user-select: none;\n * }\n * ```\n */\nexport const enableUserInteraction = (\n className: string = \"on_processing\"\n): void => {\n // Ensure function runs only in the browser\n if (isServer()) return;\n\n assertIsString(className, {\n message({ validType, currentType }) {\n return createMessage(\n \"enableUserInteraction\",\n `First parameter \\`className\\` must be of type \\`${validType}\\`, but received: \\`${currentType}\\`.`\n );\n }\n });\n\n const { documentElement } = document;\n\n if (documentElement && documentElement.classList.contains(className)) {\n documentElement.classList.remove(className);\n }\n};\n","import { isServer } from \"@/predicates/is/isServer\";\n\n/** ----------------------------------------------------------\n * * ***Utility: `removeElementFocus`.***\n * -----------------------------------------------------------\n * **Removes focus from the currently active element in the document.**\n *\n * ---\n * - **Features**:\n * - This function works **only in browser environments** ***(safely no-ops in server environments)***.\n * - If an element is focused, it will lose focus by calling `HTMLElement.blur()`.\n * - If no element is focused or the active element is not an `HTMLElement`, nothing happens.\n *\n * ---\n * @returns {void} Does not return anything (void).\n *\n * ---\n * @example\n * ```ts\n * removeElementFocus();\n * // ➔ Removes focus from the currently active element\n * ```\n */\nexport const removeElementFocus = (): void => {\n // Ensure function runs only in the browser\n if (isServer()) return;\n\n const activeElement = document.activeElement;\n\n if (activeElement instanceof HTMLElement) {\n activeElement.blur();\n } else {\n // not-support, currently we nothing to do...\n // console.warn(\"removeElementFocus: No active element to blur or unsupported element type.\");\n }\n};\n","import { isNumber } from \"@/predicates/is/isNumber\";\nimport { isServer } from \"@/predicates/is/isServer\";\nimport { isPlainObject } from \"@/predicates/is/isPlainObject\";\nimport { isNonEmptyString } from \"@/predicates/is/isNonEmptyString\";\n\n/**\n * ***Types options for {@link scrollToTop | `scrollToTop`}.***\n */\ntype ScrollToTopOptions = {\n /** ----------------------------------------------------------\n * * ***Scroll animation type.***\n * -----------------------------------------------------------\n * - ***Behavior:***\n * - Valid values: `\"auto\"`, `\"instant\"`, `\"smooth\"`.\n * - Default force to `\"smooth\"` if missing or invalid.\n *\n * ---\n * @default \"smooth\"\n */\n behavior?: ScrollBehavior | undefined;\n\n /** ----------------------------------------------------------\n * * ***Delay before scrolling (in milliseconds).***\n * -----------------------------------------------------------\n * - ***Behavior:***\n * - Default value is `1`.\n * - Valid values: any number `≥` `1`.\n * - Non-integer number are truncated to an integer.\n * - Force to `2147483647` if number is larger than `2147483647`.\n * - Default force to `1` if `missing`, `NaN`, `invalid-type`, or `less-than` `1`.\n *\n * ---\n * @default 1\n */\n timeout?: number | undefined;\n};\n\n/** ----------------------------------------------------------\n * * ***Utility: `scrollToTop`.***\n * -----------------------------------------------------------\n * **Scrolls the page to the top with optional smooth animation and delay.**\n *\n * ---\n * - **Features**:\n * - This function works **only in browser environments** (no effect on server-side).\n * - It leverages the native `window.scrollTo()` API with support for smooth scrolling\n * and an optional timeout delay before executing the scroll.\n * - Each option has strict valid values:\n * - If an invalid value is provided, the function **automatically falls back to its default**.\n *\n * ---\n * @param {ScrollToTopOptions} [options] - Optional settings for scroll behavior.\n * @param {ScrollToTopOptions[\"behavior\"]} [options.behavior=\"smooth\"] - Scroll animation type.\n * - Valid values: `\"auto\"`, `\"instant\"`, `\"smooth\"`.\n * - Default force to `\"smooth\"` if missing or invalid.\n * @param {ScrollToTopOptions[\"timeout\"]} [options.timeout=1] - Delay before scrolling (in milliseconds).\n * - Default value is `1`.\n * - Valid values: any number `≥` `1`.\n * - Non-integer number are truncated to an integer.\n * - Force to `2147483647` if number is larger than `2147483647`.\n * - Default force to `1` if `missing`, `NaN`, `invalid`, or `less-than` `1`.\n *\n * ---\n * @returns {void} Does not return anything, only scrolling to top (void).\n *\n * ---\n * @example\n *\n * 1. #### Default behavior:\n * ```ts\n * scrollToTop();\n * // ➔ Scroll smoothly to the top after 1ms delay\n * ```\n * ---\n * 2. #### Instant scroll:\n * ```ts\n * scrollToTop({\n * behavior: \"instant\"\n * });\n * // ➔ Jump instantly to the top\n * ```\n * ---\n * 3. #### Custom timeout:\n * ```ts\n * scrollToTop({\n * timeout: 500\n * });\n * // ➔ Scroll smoothly to the top after 500ms\n * ```\n * ---\n * 4. #### Invalid options with fallback values:\n * ```ts\n * scrollToTop({\n * behavior: \"fly\",\n * timeout: -100\n * });\n * // ➔ Fallback: behavior=\"smooth\", timeout=1\n * ```\n * ---\n * 5. #### Invalid behavior with decimal timeout:\n * ```ts\n * scrollToTop({\n * behavior: \"fly\",\n * timeout: 123.55\n * });\n * // ➔ Fallback: behavior=\"smooth\", timeout=123\n * ```\n */\nexport const scrollToTop = (options?: ScrollToTopOptions): void => {\n // Ensure function runs only in the browser\n if (isServer()) return;\n\n // Ensure options is an object and Defensive options check\n if (!isPlainObject(options)) options = {};\n\n const behavior: ScrollBehavior =\n options.behavior &&\n isNonEmptyString(options.behavior) &&\n [\"auto\", \"instant\", \"smooth\"].includes(options.behavior)\n ? options.behavior\n : \"smooth\";\n let timeout =\n options.timeout && isNumber(options.timeout) && options.timeout >= 1\n ? options.timeout\n : 1;\n\n timeout = timeout > 2147483647 ? 2147483647 : timeout;\n\n setTimeout(() => window.scrollTo({ top: 0, left: 0, behavior }), timeout);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmEA,MAAa,0BACX,YAAoB,oBACX;CAET,IAAIA,0BAAS,GAAG;CAEhB,sCAAe,WAAW,EACxB,QAAQ,EAAE,WAAW,eAAe;EAClC,OAAOC,6BACL,0BACA,mDAAmD,UAAU,sBAAsB,YAAY,IACjG;CACF,EACF,CAAC;CAED,MAAM,EAAE,oBAAoB;CAE5B,IAAI,mBAAmB,CAAC,gBAAgB,UAAU,SAAS,SAAS,GAClE,gBAAgB,UAAU,IAAI,SAAS;AAE3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACnBA,MAAa,yBACX,YAAoB,oBACX;CAET,IAAIC,0BAAS,GAAG;CAEhB,sCAAe,WAAW,EACxB,QAAQ,EAAE,WAAW,eAAe;EAClC,OAAOC,6BACL,yBACA,mDAAmD,UAAU,sBAAsB,YAAY,IACjG;CACF,EACF,CAAC;CAED,MAAM,EAAE,oBAAoB;CAE5B,IAAI,mBAAmB,gBAAgB,UAAU,SAAS,SAAS,GACjE,gBAAgB,UAAU,OAAO,SAAS;AAE9C;;;;;;;;;;;;;;;;;;;;;;;;;ACjEA,MAAa,2BAAiC;CAE5C,IAAIC,0BAAS,GAAG;CAEhB,MAAM,gBAAgB,SAAS;CAE/B,IAAI,yBAAyB,aAC3B,cAAc,KAAK;AAKvB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACyEA,MAAa,eAAe,YAAuC;CAEjE,IAAIC,0BAAS,GAAG;CAGhB,IAAI,CAACC,6BAAc,OAAO,GAAG,UAAU,CAAC;CAExC,MAAM,WACJ,QAAQ,YACRC,gCAAiB,QAAQ,QAAQ,KACjC;EAAC;EAAQ;EAAW;CAAQ,EAAE,SAAS,QAAQ,QAAQ,IACnD,QAAQ,WACR;CACN,IAAI,UACF,QAAQ,WAAWC,0BAAS,QAAQ,OAAO,KAAK,QAAQ,WAAW,IAC/D,QAAQ,UACR;CAEN,UAAU,UAAU,aAAa,aAAa;CAE9C,iBAAiB,OAAO,SAAS;EAAE,KAAK;EAAG,MAAM;EAAG;CAAS,CAAC,GAAG,OAAO;AAC1E"}
|
package/dist/events/index.d.cts
CHANGED
|
@@ -2,110 +2,158 @@
|
|
|
2
2
|
* ========================================================================
|
|
3
3
|
* @rzl-zone/utils-js
|
|
4
4
|
* ------------------------------------------------------------------------
|
|
5
|
-
* Version: `3.
|
|
5
|
+
* Version: `3.14.0-beta.0`
|
|
6
6
|
* Author: `Rizalvin Dwiky <rizalvindwiky@gmail.com>`
|
|
7
7
|
* Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/utils-js`
|
|
8
8
|
* ========================================================================
|
|
9
9
|
*/
|
|
10
10
|
/** ----------------------------------------------------------
|
|
11
11
|
* * ***Utility: `disableUserInteraction`.***
|
|
12
|
-
*
|
|
12
|
+
* -----------------------------------------------------------
|
|
13
13
|
* **Disables user interaction by adding a CSS class to the `<html>` element.**
|
|
14
|
+
*
|
|
15
|
+
* ---
|
|
14
16
|
* - **Key points**:
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
17
|
+
* - Works **only in browser environments**.
|
|
18
|
+
* - Safely adds the specified CSS class to `<html>`.
|
|
19
|
+
* - Prevents multiple additions of the same class.
|
|
20
|
+
* - Useful to indicate that a process is ongoing
|
|
21
|
+
* (e.g., loading or processing state).
|
|
20
22
|
* - **Using custom CSS classes:**
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
23
|
+
* - You can pass any class name that exists in your CSS.
|
|
24
|
+
* - Example: if you have `.loading` in your styles, passing `"loading"`
|
|
25
|
+
* will add it and disable interactions accordingly.
|
|
24
26
|
* - **Validation:**
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
+
* - Throws `TypeError` if the `className` parameter is not a string.
|
|
28
|
+
*
|
|
29
|
+
* ---
|
|
30
|
+
* @default
|
|
31
|
+
* ```ts
|
|
32
|
+
* "on_processing"
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* ---
|
|
27
36
|
* @param {string} [className="on_processing"] - The CSS class to add, defaults to `"on_processing"`.
|
|
28
|
-
*
|
|
37
|
+
*
|
|
38
|
+
* ---
|
|
29
39
|
* @throws **{@link TypeError | `TypeError`}** if `className` is not a string.
|
|
40
|
+
*
|
|
41
|
+
* ---
|
|
42
|
+
* @returns {void} Does not return anything (void).
|
|
43
|
+
*
|
|
44
|
+
* ---
|
|
30
45
|
* @example
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
46
|
+
* - ***Example in your code:***
|
|
47
|
+
* ```ts
|
|
48
|
+
* disableUserInteraction();
|
|
49
|
+
* // ➔ Adds "on_processing" class
|
|
50
|
+
* disableUserInteraction("loading");
|
|
51
|
+
* // ➔ Adds "loading" class
|
|
52
|
+
*
|
|
53
|
+
* // ❌ Invalid value:
|
|
54
|
+
* disableUserInteraction(123);
|
|
55
|
+
* // ➔ Throws TypeError
|
|
56
|
+
* ```
|
|
57
|
+
* - ***Example in your css file (with defaultValue `className` props [on_processing]):***
|
|
58
|
+
* ```css
|
|
59
|
+
* .on_processing {
|
|
60
|
+
* cursor: wait;
|
|
61
|
+
* touch-action: none;
|
|
62
|
+
* user-select: none;
|
|
63
|
+
* }
|
|
64
|
+
*
|
|
65
|
+
* .on_processing > * {
|
|
66
|
+
* pointer-events: none;
|
|
67
|
+
* touch-action: none;
|
|
68
|
+
* user-select: none;
|
|
69
|
+
* }
|
|
70
|
+
* ```
|
|
52
71
|
*/
|
|
53
72
|
declare const disableUserInteraction: (className?: string) => void;
|
|
54
73
|
/** ----------------------------------------------------------
|
|
55
74
|
* * ***Utility: `enableUserInteraction`.***
|
|
56
|
-
*
|
|
75
|
+
* -----------------------------------------------------------
|
|
57
76
|
* **Enables user interaction by removing a CSS class from the `<html>` element.**
|
|
77
|
+
*
|
|
78
|
+
* ---
|
|
58
79
|
* - **Key points**:
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
80
|
+
* - Works **only in browser environments**.
|
|
81
|
+
* - Safely removes the specified CSS class from `<html>`.
|
|
82
|
+
* - Does nothing if the class is not present.
|
|
83
|
+
* - Useful to re-enable user interactions after a process
|
|
84
|
+
* (e.g., loading or processing) completes.
|
|
64
85
|
* - **Using custom CSS classes:**
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
86
|
+
* - You can pass any class name that exists in your CSS.
|
|
87
|
+
* - Example: if you have `.loading` in your styles, passing `"loading"`
|
|
88
|
+
* will remove it and re-enable interactions.
|
|
68
89
|
* - **Validation:**
|
|
69
|
-
*
|
|
70
|
-
*
|
|
90
|
+
* - Throws `TypeError` if the `className` parameter is not a string.
|
|
91
|
+
*
|
|
92
|
+
* ---
|
|
93
|
+
* @default
|
|
94
|
+
* ```ts
|
|
95
|
+
* "on_processing"
|
|
96
|
+
* ```
|
|
97
|
+
*
|
|
98
|
+
* ---
|
|
71
99
|
* @param {string} [className="on_processing"] - The CSS class to remove, defaults to `"on_processing"`.
|
|
72
|
-
*
|
|
100
|
+
*
|
|
101
|
+
* ---
|
|
73
102
|
* @throws **{@link TypeError | `TypeError`}** if `className` is not a string.
|
|
103
|
+
*
|
|
104
|
+
* ---
|
|
105
|
+
* @returns {void} Does not return anything (void).
|
|
106
|
+
*
|
|
107
|
+
* ---
|
|
74
108
|
* @example
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
*
|
|
109
|
+
* - ***Example in your code:***
|
|
110
|
+
* ```ts
|
|
111
|
+
* enableUserInteraction();
|
|
112
|
+
* // ➔ Removes "on_processing" class
|
|
113
|
+
* enableUserInteraction("loading");
|
|
114
|
+
* // ➔ Removes "loading" class
|
|
115
|
+
*
|
|
116
|
+
* // ❌ Invalid value:
|
|
117
|
+
* enableUserInteraction(123);
|
|
118
|
+
* // ➔ Throws TypeError
|
|
119
|
+
* ```
|
|
120
|
+
*
|
|
121
|
+
* - ***Example in your css file (with defaultValue `className` props [on_processing]):***
|
|
122
|
+
* ```css
|
|
123
|
+
* .on_processing {
|
|
124
|
+
* cursor: wait;
|
|
125
|
+
* touch-action: none;
|
|
126
|
+
* user-select: none;
|
|
127
|
+
* }
|
|
128
|
+
*
|
|
129
|
+
* .on_processing > * {
|
|
130
|
+
* pointer-events: none;
|
|
131
|
+
* touch-action: none;
|
|
132
|
+
* user-select: none;
|
|
133
|
+
* }
|
|
134
|
+
* ```
|
|
96
135
|
*/
|
|
97
136
|
declare const enableUserInteraction: (className?: string) => void;
|
|
98
137
|
/** ----------------------------------------------------------
|
|
99
138
|
* * ***Utility: `removeElementFocus`.***
|
|
100
|
-
*
|
|
139
|
+
* -----------------------------------------------------------
|
|
101
140
|
* **Removes focus from the currently active element in the document.**
|
|
141
|
+
*
|
|
142
|
+
* ---
|
|
102
143
|
* - **Features**:
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
*
|
|
144
|
+
* - This function works **only in browser environments** ***(safely no-ops in server environments)***.
|
|
145
|
+
* - If an element is focused, it will lose focus by calling `HTMLElement.blur()`.
|
|
146
|
+
* - If no element is focused or the active element is not an `HTMLElement`, nothing happens.
|
|
147
|
+
*
|
|
148
|
+
* ---
|
|
106
149
|
* @returns {void} Does not return anything (void).
|
|
150
|
+
*
|
|
151
|
+
* ---
|
|
107
152
|
* @example
|
|
108
|
-
*
|
|
153
|
+
* ```ts
|
|
154
|
+
* removeElementFocus();
|
|
155
|
+
* // ➔ Removes focus from the currently active element
|
|
156
|
+
* ```
|
|
109
157
|
*/
|
|
110
158
|
declare const removeElementFocus: () => void;
|
|
111
159
|
/**
|
|
@@ -114,38 +162,44 @@ declare const removeElementFocus: () => void;
|
|
|
114
162
|
type ScrollToTopOptions = {
|
|
115
163
|
/** ----------------------------------------------------------
|
|
116
164
|
* * ***Scroll animation type.***
|
|
117
|
-
*
|
|
165
|
+
* -----------------------------------------------------------
|
|
118
166
|
* - ***Behavior:***
|
|
119
|
-
*
|
|
120
|
-
*
|
|
167
|
+
* - Valid values: `"auto"`, `"instant"`, `"smooth"`.
|
|
168
|
+
* - Default force to `"smooth"` if missing or invalid.
|
|
121
169
|
*
|
|
170
|
+
* ---
|
|
122
171
|
* @default "smooth"
|
|
123
172
|
*/
|
|
124
173
|
behavior?: ScrollBehavior | undefined;
|
|
125
174
|
/** ----------------------------------------------------------
|
|
126
175
|
* * ***Delay before scrolling (in milliseconds).***
|
|
127
|
-
*
|
|
176
|
+
* -----------------------------------------------------------
|
|
128
177
|
* - ***Behavior:***
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
*
|
|
178
|
+
* - Default value is `1`.
|
|
179
|
+
* - Valid values: any number `≥` `1`.
|
|
180
|
+
* - Non-integer number are truncated to an integer.
|
|
181
|
+
* - Force to `2147483647` if number is larger than `2147483647`.
|
|
182
|
+
* - Default force to `1` if `missing`, `NaN`, `invalid-type`, or `less-than` `1`.
|
|
134
183
|
*
|
|
184
|
+
* ---
|
|
135
185
|
* @default 1
|
|
136
186
|
*/
|
|
137
187
|
timeout?: number | undefined;
|
|
138
188
|
};
|
|
139
189
|
/** ----------------------------------------------------------
|
|
140
190
|
* * ***Utility: `scrollToTop`.***
|
|
141
|
-
*
|
|
191
|
+
* -----------------------------------------------------------
|
|
142
192
|
* **Scrolls the page to the top with optional smooth animation and delay.**
|
|
193
|
+
*
|
|
194
|
+
* ---
|
|
143
195
|
* - **Features**:
|
|
144
|
-
*
|
|
145
|
-
*
|
|
146
|
-
*
|
|
147
|
-
*
|
|
148
|
-
*
|
|
196
|
+
* - This function works **only in browser environments** (no effect on server-side).
|
|
197
|
+
* - It leverages the native `window.scrollTo()` API with support for smooth scrolling
|
|
198
|
+
* and an optional timeout delay before executing the scroll.
|
|
199
|
+
* - Each option has strict valid values:
|
|
200
|
+
* - If an invalid value is provided, the function **automatically falls back to its default**.
|
|
201
|
+
*
|
|
202
|
+
* ---
|
|
149
203
|
* @param {ScrollToTopOptions} [options] - Optional settings for scroll behavior.
|
|
150
204
|
* @param {ScrollToTopOptions["behavior"]} [options.behavior="smooth"] - Scroll animation type.
|
|
151
205
|
* - Valid values: `"auto"`, `"instant"`, `"smooth"`.
|
|
@@ -156,21 +210,52 @@ type ScrollToTopOptions = {
|
|
|
156
210
|
* - Non-integer number are truncated to an integer.
|
|
157
211
|
* - Force to `2147483647` if number is larger than `2147483647`.
|
|
158
212
|
* - Default force to `1` if `missing`, `NaN`, `invalid`, or `less-than` `1`.
|
|
213
|
+
*
|
|
214
|
+
* ---
|
|
159
215
|
* @returns {void} Does not return anything, only scrolling to top (void).
|
|
216
|
+
*
|
|
217
|
+
* ---
|
|
160
218
|
* @example
|
|
161
|
-
*
|
|
162
|
-
*
|
|
163
|
-
*
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
-
*
|
|
167
|
-
*
|
|
168
|
-
*
|
|
169
|
-
*
|
|
170
|
-
*
|
|
171
|
-
*
|
|
172
|
-
*
|
|
173
|
-
*
|
|
219
|
+
*
|
|
220
|
+
* 1. #### Default behavior:
|
|
221
|
+
* ```ts
|
|
222
|
+
* scrollToTop();
|
|
223
|
+
* // ➔ Scroll smoothly to the top after 1ms delay
|
|
224
|
+
* ```
|
|
225
|
+
* ---
|
|
226
|
+
* 2. #### Instant scroll:
|
|
227
|
+
* ```ts
|
|
228
|
+
* scrollToTop({
|
|
229
|
+
* behavior: "instant"
|
|
230
|
+
* });
|
|
231
|
+
* // ➔ Jump instantly to the top
|
|
232
|
+
* ```
|
|
233
|
+
* ---
|
|
234
|
+
* 3. #### Custom timeout:
|
|
235
|
+
* ```ts
|
|
236
|
+
* scrollToTop({
|
|
237
|
+
* timeout: 500
|
|
238
|
+
* });
|
|
239
|
+
* // ➔ Scroll smoothly to the top after 500ms
|
|
240
|
+
* ```
|
|
241
|
+
* ---
|
|
242
|
+
* 4. #### Invalid options with fallback values:
|
|
243
|
+
* ```ts
|
|
244
|
+
* scrollToTop({
|
|
245
|
+
* behavior: "fly",
|
|
246
|
+
* timeout: -100
|
|
247
|
+
* });
|
|
248
|
+
* // ➔ Fallback: behavior="smooth", timeout=1
|
|
249
|
+
* ```
|
|
250
|
+
* ---
|
|
251
|
+
* 5. #### Invalid behavior with decimal timeout:
|
|
252
|
+
* ```ts
|
|
253
|
+
* scrollToTop({
|
|
254
|
+
* behavior: "fly",
|
|
255
|
+
* timeout: 123.55
|
|
256
|
+
* });
|
|
257
|
+
* // ➔ Fallback: behavior="smooth", timeout=123
|
|
258
|
+
* ```
|
|
174
259
|
*/
|
|
175
260
|
declare const scrollToTop: (options?: ScrollToTopOptions) => void;
|
|
176
261
|
export { disableUserInteraction, enableUserInteraction, removeElementFocus, scrollToTop };
|