@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.d.ts
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 };
|
package/dist/events/index.js
CHANGED
|
@@ -2,18 +2,19 @@
|
|
|
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
|
-
import {
|
|
11
|
-
import { t as
|
|
12
|
-
import { t as
|
|
10
|
+
import { E as isPlainObject, t as createMessage, w as isNonEmptyString } from "../logger-CLWnKRKE.js";
|
|
11
|
+
import { t as isNumber } from "../isNumber-BCWD4dW0.js";
|
|
12
|
+
import { t as assertIsString } from "../assertIsString-CHIwE12y.js";
|
|
13
|
+
import { t as isServer } from "../isServer-CQzrX5e0.js";
|
|
13
14
|
const disableUserInteraction = (className = "on_processing") => {
|
|
14
15
|
if (isServer()) return;
|
|
15
16
|
assertIsString(className, { message({ validType, currentType }) {
|
|
16
|
-
return `First parameter \`className\` must be of type \`${validType}\`, but received: \`${currentType}
|
|
17
|
+
return createMessage("disableUserInteraction", `First parameter \`className\` must be of type \`${validType}\`, but received: \`${currentType}\`.`);
|
|
17
18
|
} });
|
|
18
19
|
const { documentElement } = document;
|
|
19
20
|
if (documentElement && !documentElement.classList.contains(className)) documentElement.classList.add(className);
|
|
@@ -21,7 +22,7 @@ const disableUserInteraction = (className = "on_processing") => {
|
|
|
21
22
|
const enableUserInteraction = (className = "on_processing") => {
|
|
22
23
|
if (isServer()) return;
|
|
23
24
|
assertIsString(className, { message({ validType, currentType }) {
|
|
24
|
-
return `First parameter \`className\` must be of type \`${validType}\`, but received: \`${currentType}
|
|
25
|
+
return createMessage("enableUserInteraction", `First parameter \`className\` must be of type \`${validType}\`, but received: \`${currentType}\`.`);
|
|
25
26
|
} });
|
|
26
27
|
const { documentElement } = document;
|
|
27
28
|
if (documentElement && documentElement.classList.contains(className)) documentElement.classList.remove(className);
|
|
@@ -34,12 +35,12 @@ const removeElementFocus = () => {
|
|
|
34
35
|
const scrollToTop = (options) => {
|
|
35
36
|
if (isServer()) return;
|
|
36
37
|
if (!isPlainObject(options)) options = {};
|
|
37
|
-
const behavior =
|
|
38
|
+
const behavior = options.behavior && isNonEmptyString(options.behavior) && [
|
|
38
39
|
"auto",
|
|
39
40
|
"instant",
|
|
40
41
|
"smooth"
|
|
41
42
|
].includes(options.behavior) ? options.behavior : "smooth";
|
|
42
|
-
let timeout =
|
|
43
|
+
let timeout = options.timeout && isNumber(options.timeout) && options.timeout >= 1 ? options.timeout : 1;
|
|
43
44
|
timeout = timeout > 2147483647 ? 2147483647 : timeout;
|
|
44
45
|
setTimeout(() => window.scrollTo({
|
|
45
46
|
top: 0,
|
package/dist/events/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"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,IAAI,SAAS,GAAG;CAEhB,eAAe,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,IAAI,SAAS,GAAG;CAEhB,eAAe,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,IAAI,SAAS,GAAG;CAEhB,MAAM,gBAAgB,SAAS;CAE/B,IAAI,yBAAyB,aAC3B,cAAc,KAAK;AAKvB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC6CA,MAAa,eAAe,YAAuC;CAEjE,IAAI,SAAS,GAAG;CAGhB,IAAI,CAAC,cAAc,OAAO,GACxB,UAAU,CAAC;CAGb,MAAM,WACJ,WAAW,SAAS,UAAU,KAC9B,iBAAiB,QAAQ,QAAQ,KACjC;EAAC;EAAQ;EAAW;CAAQ,EAAE,SAAS,QAAQ,QAAQ,IACnD,QAAQ,WACR;CACN,IAAI,UACF,WAAW,SAAS,SAAS,KAC7B,SAAS,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.js","names":[],"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,IAAI,SAAS,GAAG;CAEhB,eAAe,WAAW,EACxB,QAAQ,EAAE,WAAW,eAAe;EAClC,OAAO,cACL,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,IAAI,SAAS,GAAG;CAEhB,eAAe,WAAW,EACxB,QAAQ,EAAE,WAAW,eAAe;EAClC,OAAO,cACL,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,IAAI,SAAS,GAAG;CAEhB,MAAM,gBAAgB,SAAS;CAE/B,IAAI,yBAAyB,aAC3B,cAAc,KAAK;AAKvB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACyEA,MAAa,eAAe,YAAuC;CAEjE,IAAI,SAAS,GAAG;CAGhB,IAAI,CAAC,cAAc,OAAO,GAAG,UAAU,CAAC;CAExC,MAAM,WACJ,QAAQ,YACR,iBAAiB,QAAQ,QAAQ,KACjC;EAAC;EAAQ;EAAW;CAAQ,EAAE,SAAS,QAAQ,QAAQ,IACnD,QAAQ,WACR;CACN,IAAI,UACF,QAAQ,WAAW,SAAS,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"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* ========================================================================
|
|
3
|
+
* @rzl-zone/utils-js
|
|
4
|
+
* ------------------------------------------------------------------------
|
|
5
|
+
* Version: `3.14.0-beta.0`
|
|
6
|
+
* Author: `Rizalvin Dwiky <rizalvindwiky@gmail.com>`
|
|
7
|
+
* Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/utils-js`
|
|
8
|
+
* ========================================================================
|
|
9
|
+
*/
|
|
10
|
+
/*!
|
|
11
|
+
* ========================================================================
|
|
12
|
+
* @rzl-zone/build-tools
|
|
13
|
+
* ------------------------------------------------------------------------
|
|
14
|
+
* Version: `0.0.13-beta.0`
|
|
15
|
+
* Author: `Rizalvin Dwiky <rizalvindwiky1998@gmail.com>`
|
|
16
|
+
* Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/build-tools`
|
|
17
|
+
* ========================================================================
|
|
18
|
+
*/
|
|
19
|
+
"use strict";
|
|
20
|
+
function isArray(value) {
|
|
21
|
+
return Array.isArray(value);
|
|
22
|
+
}
|
|
23
|
+
function isObject(value) {
|
|
24
|
+
return typeof value === "object" && !isNil(value) && !isArray(value);
|
|
25
|
+
}
|
|
26
|
+
const isNil = (value) => {
|
|
27
|
+
return value == null;
|
|
28
|
+
};
|
|
29
|
+
const isFunction = (value) => {
|
|
30
|
+
return typeof value === "function";
|
|
31
|
+
};
|
|
32
|
+
const hasGlobalRequire = (value) => isObject(value) && isFunction(value.require);
|
|
33
|
+
const getRuntimeRequire = () => {
|
|
34
|
+
if (!hasGlobalRequire(globalThis)) return void 0;
|
|
35
|
+
return globalThis.require;
|
|
36
|
+
};
|
|
37
|
+
const __runtimeRequire = ((x) => {
|
|
38
|
+
const r = getRuntimeRequire();
|
|
39
|
+
if (r) return r;
|
|
40
|
+
if (typeof Proxy !== "undefined") return new Proxy(x, { get(target, prop) {
|
|
41
|
+
const r2 = getRuntimeRequire();
|
|
42
|
+
return r2 ? r2[prop] : target[prop];
|
|
43
|
+
} });
|
|
44
|
+
return x;
|
|
45
|
+
})(function(id) {
|
|
46
|
+
const r = getRuntimeRequire();
|
|
47
|
+
if (r) return r.call(this, id);
|
|
48
|
+
throw new Error(`Calling \`require\` for "${id}" in an environment that doesn't expose the \`require\` function.`);
|
|
49
|
+
});
|
|
50
|
+
const NEWLINE = atob("Cg==");
|
|
51
|
+
const EOL = hasGlobalRequire(globalThis) ? __runtimeRequire("node:os").EOL : NEWLINE;
|
|
52
|
+
function joinLines(...text) {
|
|
53
|
+
return text.filter(Boolean).join(EOL);
|
|
54
|
+
}
|
|
55
|
+
Object.defineProperty(exports, 'EOL', {
|
|
56
|
+
enumerable: true,
|
|
57
|
+
get: function () {
|
|
58
|
+
return EOL;
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
Object.defineProperty(exports, 'joinLines', {
|
|
62
|
+
enumerable: true,
|
|
63
|
+
get: function () {
|
|
64
|
+
return joinLines;
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
//# sourceMappingURL=formatter-ekJQF_bA-BepnCBkQ.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatter-ekJQF_bA-BepnCBkQ.cjs","names":[],"sources":["../../build-tools/dist/formatter-ekJQF_bA.js"],"sourcesContent":["/*!\n* ========================================================================\n* @rzl-zone/build-tools\n* ------------------------------------------------------------------------\n* Version: `0.0.13-beta.0`\n* Author: `Rizalvin Dwiky <rizalvindwiky1998@gmail.com>`\n* Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/build-tools`\n* ========================================================================\n*/\n\nimport pcr from \"picocolors\";\nfunction deepFreeze(value) {\n\tif (typeof value !== \"object\" || value === null) return value;\n\tconst seen = /* @__PURE__ */ new WeakSet();\n\tconst stack = [value];\n\twhile (stack.length) {\n\t\tconst obj = stack.pop();\n\t\tif (seen.has(obj) || Object.isFrozen(obj)) continue;\n\t\tseen.add(obj);\n\t\tif (isMap(obj)) for (const [k, v] of obj) {\n\t\t\tif (typeof k === \"object\" && k !== null) stack.push(k);\n\t\t\tif (typeof v === \"object\" && v !== null) stack.push(v);\n\t\t}\n\t\telse if (isSet(obj)) {\n\t\t\tfor (const v of obj) if (typeof v === \"object\" && v !== null) stack.push(v);\n\t\t} else if (isArray(obj)) {\n\t\t\tfor (const v of obj) if (typeof v === \"object\" && v !== null) stack.push(v);\n\t\t} else {\n\t\t\tconst record = obj;\n\t\t\tfor (const key of Reflect.ownKeys(record)) {\n\t\t\t\tconst v = record[key];\n\t\t\t\tif (typeof v === \"object\" && v !== null) stack.push(v);\n\t\t\t}\n\t\t}\n\t\tObject.freeze(obj);\n\t}\n\treturn value;\n}\nconst isRegExp = (value) => {\n\treturn value instanceof RegExp;\n};\nconst isString = (value) => {\n\treturn typeof value === \"string\";\n};\nfunction isSet(value) {\n\treturn Object.prototype.toString.call(value) === \"[object Set]\" || value instanceof Set;\n}\nfunction isMap(value) {\n\treturn Object.prototype.toString.call(value) === \"[object Map]\" || value instanceof Map;\n}\nfunction isArray(value) {\n\treturn Array.isArray(value);\n}\nconst isNull = (val) => val === null;\nfunction isPlainObject(value) {\n\tif (!isObject(value)) return false;\n\tconst proto = Object.getPrototypeOf(value);\n\treturn proto === Object.prototype || proto === null;\n}\nfunction isObject(value) {\n\treturn typeof value === \"object\" && !isNil(value) && !isArray(value);\n}\nfunction isObjectOrArray(value) {\n\treturn isArray(value) || isObject(value);\n}\nconst isNil = (value) => {\n\treturn value == null;\n};\nconst isBoolean = (value) => {\n\treturn typeof value === \"boolean\";\n};\nconst isUndefined = (value) => {\n\treturn typeof value === \"undefined\";\n};\nconst isFunction = (value) => {\n\treturn typeof value === \"function\";\n};\nconst isNumberObject = (value) => {\n\treturn isObject(value) && Object.prototype.toString.call(value) === \"[object Number]\";\n};\nconst isStringObject = (value) => {\n\treturn isObject(value) && Object.prototype.toString.call(value) === \"[object String]\";\n};\nconst isBooleanObject = (value) => {\n\treturn isObject(value) && Object.prototype.toString.call(value) === \"[object Boolean]\";\n};\nconst isInfinityNumber = (value) => {\n\tif (typeof value === \"number\" || isNumberObject(value)) {\n\t\tconst num = Number(value);\n\t\treturn num === Infinity || num === -Infinity;\n\t}\n\treturn false;\n};\nconst isSymbol = (value) => {\n\treturn typeof value === \"symbol\";\n};\nconst isBigInt = (value) => {\n\treturn typeof value === \"bigint\";\n};\nconst isNaN = (value) => {\n\treturn typeof value === \"number\" ? Number.isNaN(value) : isNumberObject(value) && Number.isNaN(value.valueOf());\n};\nconst isNonEmptyString = (value, options = {}) => {\n\tif (!isString(value)) return false;\n\treturn (options.trim ?? true ? value.trim() : value).length > 0;\n};\nconst isNumber = (value, options = {}) => {\n\tconst includeNaN = isPlainObject(options) && isBoolean(options.includeNaN) ? options.includeNaN : false;\n\tconst aNumber = typeof value === \"number\";\n\treturn includeNaN ? aNumber : aNumber && !Number.isNaN(value);\n};\nconst isError = (error) => {\n\treturn Object.prototype.toString.call(error) === \"[object Error]\" || error instanceof Error;\n};\nconst isDate = (value, options = {}) => {\n\tconst skipInvalidDate = isPlainObject(options) && isBoolean(options.skipInvalidDate) ? options.skipInvalidDate : false;\n\tconst instanceDate = value instanceof Date;\n\tif (skipInvalidDate) return instanceDate;\n\treturn instanceDate && !isNaN(value.getTime());\n};\nconst safeStableStringify = (value, options = {}) => {\n\tconst pretty = options.pretty ?? false;\n\tconst sortKeys = options.sortKeys ?? true;\n\tconst sortArray = options.sortArray ?? false;\n\tconst keepUndefined = options.keepUndefined ?? false;\n\tif (isUndefined(value)) return keepUndefined ? \"undefined\" : \"null\";\n\tconst seen = /* @__PURE__ */ new WeakSet();\n\tconst isPrimitive = (val) => isNull(val) || !isObjectOrArray(val) && !isFunction(val);\n\tconst deepProcess = (val) => {\n\t\tif (isNumberObject(val)) {\n\t\t\tconst valOf = val.valueOf();\n\t\t\treturn isNaN(valOf) || isInfinityNumber(valOf) ? null : valOf;\n\t\t}\n\t\tif (isStringObject(val)) return val.valueOf();\n\t\tif (isBooleanObject(val)) return val.valueOf();\n\t\tif (isFunction(val) || isSymbol(val)) return void 0;\n\t\tif (isBigInt(val)) return val.toString();\n\t\tif (isNaN(val) || isInfinityNumber(val)) return null;\n\t\tif (isUndefined(val)) return keepUndefined ? void 0 : null;\n\t\tif (isObjectOrArray(val)) {\n\t\t\tif (seen.has(val)) return \"[Circular]\";\n\t\t\tseen.add(val);\n\t\t\tif (isDate(val)) return val.toISOString();\n\t\t\tif (isMap(val)) return { map: Array.from(val.entries()).map(([k, v]) => [k, deepProcess(v)]) };\n\t\t\tif (isSet(val)) return { set: Array.from(val.values()).map(deepProcess) };\n\t\t\tif (isArray(val)) {\n\t\t\t\tconst processedArr = val.map(deepProcess);\n\t\t\t\tif (sortArray) {\n\t\t\t\t\tconst primitives = [];\n\t\t\t\t\tconst nonPrimitives = [];\n\t\t\t\t\tfor (const item of processedArr) if (isPrimitive(item)) primitives.push(item);\n\t\t\t\t\telse nonPrimitives.push(item);\n\t\t\t\t\tprimitives.sort((a, b) => {\n\t\t\t\t\t\tif (isNumber(a) && isNumber(b)) return a - b;\n\t\t\t\t\t\treturn String(a).localeCompare(String(b));\n\t\t\t\t\t});\n\t\t\t\t\treturn [...primitives, ...nonPrimitives];\n\t\t\t\t}\n\t\t\t\treturn processedArr;\n\t\t\t}\n\t\t\tconst keys = Object.keys(val);\n\t\t\tif (sortKeys) keys.sort((a, b) => {\n\t\t\t\tconst na = Number(a);\n\t\t\t\tconst nb = Number(b);\n\t\t\t\tif (!isNaN(na) && !isNaN(nb)) return na - nb;\n\t\t\t\treturn a.localeCompare(b);\n\t\t\t});\n\t\t\tconst result = {};\n\t\t\tif (isObject(val)) for (const k of keys) {\n\t\t\t\tconst v = deepProcess(val[k]);\n\t\t\t\tif (!isUndefined(v)) result[k] = v;\n\t\t\t}\n\t\t\treturn result;\n\t\t}\n\t\treturn val;\n\t};\n\ttry {\n\t\treturn JSON.stringify(deepProcess(value), null, pretty ? 2 : 0);\n\t} catch (err) {\n\t\tconsole.warn(\"Error in safeStableStringify:\", err);\n\t\treturn \"{}\";\n\t}\n};\nconst normalizeSpaces = (value, options = {\n\twithTrim: true,\n\ttrimOnly: false\n}) => {\n\tif (!isNonEmptyString(value)) return \"\";\n\tif (!isPlainObject(options)) options = {};\n\tconst { trimOnly = false, withTrim = true } = options;\n\tif (trimOnly) return value.trim();\n\tif (withTrim) value = value.trim();\n\treturn value.replace(/\\s+/g, \" \");\n};\nconst isStringArray = (v) => isArray(v) && v.every((i) => isString(i));\nconst isStringSet = (v) => isSet(v) && [...v].every((i) => isString(i));\nconst assertValidatePatternArgs = (v, parameterKey = \"pattern\") => {\n\tif (!isString(v) && !isStringArray(v) && !isStringSet(v)) throw new TypeError(`The \\`${parameterKey}\\` argument must be a string, string[] or Set<string>.`);\n};\nconst flattenStrings = (input) => {\n\treturn input.flat(Infinity).filter((v) => typeof v === \"string\");\n};\nconst toStringSet = (pattern, options = {}) => {\n\tconst { withValidationType = true, parameterKey = \"pattern\" } = options;\n\tif (withValidationType) assertValidatePatternArgs(pattern, parameterKey);\n\treturn toObjectSet(pattern);\n};\nconst toObjectSet = (value) => {\n\tif (isSet(value)) return value;\n\treturn new Set(isArray(value) ? value : [value]);\n};\nconst toArray = (value) => {\n\treturn isArray(value) ? value : [value];\n};\nconst hasGlobalRequire = (value) => isObject(value) && isFunction(value.require);\nconst getRuntimeRequire = () => {\n\tif (!hasGlobalRequire(globalThis)) return void 0;\n\treturn globalThis.require;\n};\nconst __runtimeRequire = ((x) => {\n\tconst r = getRuntimeRequire();\n\tif (r) return r;\n\tif (typeof Proxy !== \"undefined\") return new Proxy(x, { get(target, prop) {\n\t\tconst r2 = getRuntimeRequire();\n\t\treturn r2 ? r2[prop] : target[prop];\n\t} });\n\treturn x;\n})(function(id) {\n\tconst r = getRuntimeRequire();\n\tif (r) return r.call(this, id);\n\tthrow new Error(`Calling \\`require\\` for \"${id}\" in an environment that doesn't expose the \\`require\\` function.`);\n});\nconst picocolors = pcr;\nconst NEWLINE = atob(\"Cg==\");\nconst EOL = hasGlobalRequire(globalThis) ? __runtimeRequire(\"node:os\").EOL : NEWLINE;\nfunction plural(count, word, pluralWord) {\n\tif (count === 1) return word;\n\treturn pluralWord ?? `${word}s`;\n}\nfunction padText(value, options = {}) {\n\tconst { start = true, end = true, padOnInvalid = true } = options;\n\tif (!isNonEmptyString(value)) return padOnInvalid ? \" \" : \"\";\n\treturn `${start ? \" \" : \"\"}${value}${end ? \" \" : \"\"}`;\n}\nfunction joinInline(...text) {\n\treturn text.filter(Boolean).join(\" \");\n}\nfunction joinLines(...text) {\n\treturn text.filter(Boolean).join(EOL);\n}\nfunction joinLinesLoose(...text) {\n\treturn text.filter((v) => v !== false && v !== null && v !== void 0).join(EOL);\n}\nfunction formatOptionValue(value, options) {\n\tconst { pretty = false, indent = 2, sortKeys = false, sortArray = false } = options ?? {};\n\tconst indentUnit = \" \".repeat(indent);\n\tfunction formatRecursive(input, depth = 0) {\n\t\tconst currentIndent = indentUnit.repeat(depth);\n\t\tconst nextIndent = indentUnit.repeat(depth + 1);\n\t\tconst joinInline = picocolors.dim(\", \");\n\t\tconst joinPretty = `,${EOL}`;\n\t\tif (isSet(input)) return formatRecursive([...input], depth);\n\t\tif (isMap(input)) return formatRecursive(Object.fromEntries(input), depth);\n\t\tif (isArray(input)) {\n\t\t\tconst arr = sortArray ? [...input].sort() : input;\n\t\t\tif (arr.length === 0) return picocolors.gray(\"[]\");\n\t\t\tif (!pretty) {\n\t\t\t\tconst items = arr.map((v) => formatRecursive(v, depth)).join(joinInline);\n\t\t\t\treturn picocolors.gray(\"[\") + items + picocolors.gray(\"]\");\n\t\t\t}\n\t\t\tconst items = arr.map((v) => nextIndent + formatRecursive(v, depth + 1)).join(joinPretty);\n\t\t\treturn picocolors.gray(`[${EOL}`) + items + EOL + currentIndent + picocolors.gray(\"]\");\n\t\t}\n\t\tif (isPlainObject(input)) {\n\t\t\tlet entries = Object.entries(input);\n\t\t\tif (sortKeys) entries = entries.sort(([a], [b]) => a.localeCompare(b));\n\t\t\tif (entries.length === 0) return picocolors.gray(\"{}\");\n\t\t\tif (!pretty) {\n\t\t\t\tconst props = entries.map(([key, val]) => {\n\t\t\t\t\treturn picocolors.dim(key) + picocolors.gray(\": \") + formatRecursive(val, depth);\n\t\t\t\t}).join(joinInline);\n\t\t\t\treturn picocolors.gray(\"{ \") + props + picocolors.gray(\" }\");\n\t\t\t}\n\t\t\tconst props = entries.map(([key, val]) => {\n\t\t\t\treturn nextIndent + picocolors.dim(key) + picocolors.gray(\": \") + formatRecursive(val, depth + 1);\n\t\t\t}).join(joinPretty);\n\t\t\treturn picocolors.gray(`{${EOL}`) + props + EOL + currentIndent + picocolors.gray(\"}\");\n\t\t}\n\t\tif (isRegExp(input)) return picocolors.greenBright(\"/\") + picocolors.redBright(input.source) + picocolors.greenBright(\"/\") + picocolors.magentaBright(input.flags);\n\t\tif (isString(input)) return picocolors.gray(`\"${input}\"`);\n\t\tif (isNumber(input, { includeNaN: true })) return picocolors.redBright(String(input));\n\t\tif (isBoolean(input)) return picocolors.redBright(String(input));\n\t\tif (isNil(input)) return picocolors.redBright(String(input));\n\t\tif (isObject(input)) return picocolors.cyanBright(Object.prototype.toString.call(input));\n\t\treturn picocolors.cyanBright(String(input));\n\t}\n\treturn formatRecursive(value);\n}\nexport { isString as C, toArray as D, safeStableStringify as E, toObjectSet as O, isSet as S, normalizeSpaces as T, isNonEmptyString as _, joinLines as a, isPlainObject as b, picocolors as c, flattenStrings as d, isArray as f, isNil as g, isFunction as h, joinInline as i, toStringSet as k, plural as l, isError as m, NEWLINE as n, joinLinesLoose as o, isBoolean as p, formatOptionValue as r, padText as s, EOL as t, deepFreeze as u, isNull as v, isUndefined as w, isRegExp as x, isNumber as y };\n//# sourceMappingURL=formatter-ekJQF_bA.js.map\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAkDA,SAAS,QAAQ,OAAO;CACvB,OAAO,MAAM,QAAQ,KAAK;AAC3B;AAOA,SAAS,SAAS,OAAO;CACxB,OAAO,OAAO,UAAU,YAAY,CAAC,MAAM,KAAK,KAAK,CAAC,QAAQ,KAAK;AACpE;AAIA,MAAM,SAAS,UAAU;CACxB,OAAO,SAAS;AACjB;AAOA,MAAM,cAAc,UAAU;CAC7B,OAAO,OAAO,UAAU;AACzB;AA0IA,MAAM,oBAAoB,UAAU,SAAS,KAAK,KAAK,WAAW,MAAM,OAAO;AAC/E,MAAM,0BAA0B;CAC/B,IAAI,CAAC,iBAAiB,UAAU,GAAG,OAAO,KAAK;CAC/C,OAAO,WAAW;AACnB;AACA,MAAM,qBAAqB,MAAM;CAChC,MAAM,IAAI,kBAAkB;CAC5B,IAAI,GAAG,OAAO;CACd,IAAI,OAAO,UAAU,aAAa,OAAO,IAAI,MAAM,GAAG,EAAE,IAAI,QAAQ,MAAM;EACzE,MAAM,KAAK,kBAAkB;EAC7B,OAAO,KAAK,GAAG,QAAQ,OAAO;CAC/B,EAAE,CAAC;CACH,OAAO;AACR,GAAG,SAAS,IAAI;CACf,MAAM,IAAI,kBAAkB;CAC5B,IAAI,GAAG,OAAO,EAAE,KAAK,MAAM,EAAE;CAC7B,MAAM,IAAI,MAAM,4BAA4B,GAAG,kEAAkE;AAClH,CAAC;AAED,MAAM,UAAU,KAAK,MAAM;AAC3B,MAAM,MAAM,iBAAiB,UAAU,IAAI,iBAAiB,SAAS,EAAE,MAAM;AAa7E,SAAS,UAAU,GAAG,MAAM;CAC3B,OAAO,KAAK,OAAO,OAAO,EAAE,KAAK,GAAG;AACrC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* ========================================================================
|
|
3
|
+
* @rzl-zone/utils-js
|
|
4
|
+
* ------------------------------------------------------------------------
|
|
5
|
+
* Version: `3.14.0-beta.0`
|
|
6
|
+
* Author: `Rizalvin Dwiky <rizalvindwiky@gmail.com>`
|
|
7
|
+
* Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/utils-js`
|
|
8
|
+
* ========================================================================
|
|
9
|
+
*/
|
|
10
|
+
/*!
|
|
11
|
+
* ========================================================================
|
|
12
|
+
* @rzl-zone/build-tools
|
|
13
|
+
* ------------------------------------------------------------------------
|
|
14
|
+
* Version: `0.0.13-beta.0`
|
|
15
|
+
* Author: `Rizalvin Dwiky <rizalvindwiky1998@gmail.com>`
|
|
16
|
+
* Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/build-tools`
|
|
17
|
+
* ========================================================================
|
|
18
|
+
*/
|
|
19
|
+
function isArray(value) {
|
|
20
|
+
return Array.isArray(value);
|
|
21
|
+
}
|
|
22
|
+
function isObject(value) {
|
|
23
|
+
return typeof value === "object" && !isNil(value) && !isArray(value);
|
|
24
|
+
}
|
|
25
|
+
const isNil = (value) => {
|
|
26
|
+
return value == null;
|
|
27
|
+
};
|
|
28
|
+
const isFunction = (value) => {
|
|
29
|
+
return typeof value === "function";
|
|
30
|
+
};
|
|
31
|
+
const hasGlobalRequire = (value) => isObject(value) && isFunction(value.require);
|
|
32
|
+
const getRuntimeRequire = () => {
|
|
33
|
+
if (!hasGlobalRequire(globalThis)) return void 0;
|
|
34
|
+
return globalThis.require;
|
|
35
|
+
};
|
|
36
|
+
const __runtimeRequire = ((x) => {
|
|
37
|
+
const r = getRuntimeRequire();
|
|
38
|
+
if (r) return r;
|
|
39
|
+
if (typeof Proxy !== "undefined") return new Proxy(x, { get(target, prop) {
|
|
40
|
+
const r2 = getRuntimeRequire();
|
|
41
|
+
return r2 ? r2[prop] : target[prop];
|
|
42
|
+
} });
|
|
43
|
+
return x;
|
|
44
|
+
})(function(id) {
|
|
45
|
+
const r = getRuntimeRequire();
|
|
46
|
+
if (r) return r.call(this, id);
|
|
47
|
+
throw new Error(`Calling \`require\` for "${id}" in an environment that doesn't expose the \`require\` function.`);
|
|
48
|
+
});
|
|
49
|
+
const NEWLINE = atob("Cg==");
|
|
50
|
+
const EOL = hasGlobalRequire(globalThis) ? __runtimeRequire("node:os").EOL : NEWLINE;
|
|
51
|
+
function joinLines(...text) {
|
|
52
|
+
return text.filter(Boolean).join(EOL);
|
|
53
|
+
}
|
|
54
|
+
export { joinLines as n, EOL as t };
|
|
55
|
+
//# sourceMappingURL=formatter-ekJQF_bA-xLD9mGk4.js.map
|