@rzl-zone/utils-js 3.12.1-beta.0 → 3.13.0-beta.2
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 +15 -35
- package/dist/.references/index.d.cts +1 -3
- package/dist/.references/index.d.ts +1 -3
- package/dist/{assertIsArray-BfAbIUfa.js → assertIsArray-6BcSdNa-.js} +3 -3
- package/dist/{assertIsArray-BfAbIUfa.js.map → assertIsArray-6BcSdNa-.js.map} +1 -1
- package/dist/{assertIsArray-BChqwPiP.cjs → assertIsArray-BqjMoan3.cjs} +3 -3
- package/dist/{assertIsArray-BChqwPiP.cjs.map → assertIsArray-BqjMoan3.cjs.map} +1 -1
- package/dist/{assertIsBoolean-BlBct0Fc.js → assertIsBoolean-Bv6gL-xe.js} +8 -8
- package/dist/assertIsBoolean-Bv6gL-xe.js.map +1 -0
- package/dist/{assertIsBoolean-DozdtbNi.cjs → assertIsBoolean-amRiJHnh.cjs} +8 -8
- package/dist/assertIsBoolean-amRiJHnh.cjs.map +1 -0
- package/dist/{assertIsString-DqV9NwbI.js → assertIsString-1WiUjgqf.js} +3 -3
- package/dist/{assertIsString-DqV9NwbI.js.map → assertIsString-1WiUjgqf.js.map} +1 -1
- package/dist/{assertIsString-Bvk7bUL7.cjs → assertIsString-C0b28AU1.cjs} +3 -3
- package/dist/{assertIsString-Bvk7bUL7.cjs.map → assertIsString-C0b28AU1.cjs.map} +1 -1
- package/dist/assertions/index.cjs +5 -5
- package/dist/assertions/index.d.cts +2 -2
- package/dist/assertions/index.d.ts +2 -2
- package/dist/assertions/index.js +5 -5
- 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-EMJa3g-D.js → conversions-BrI0GIOr.js} +16 -18
- package/dist/conversions-BrI0GIOr.js.map +1 -0
- package/dist/{conversions-CBs8-REq.cjs → conversions-lvvAYiZs.cjs} +16 -18
- package/dist/conversions-lvvAYiZs.cjs.map +1 -0
- package/dist/events/index.cjs +4 -4
- package/dist/events/index.cjs.map +1 -1
- package/dist/events/index.d.cts +153 -151
- package/dist/events/index.d.ts +153 -151
- package/dist/events/index.js +4 -4
- package/dist/events/index.js.map +1 -1
- 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-lAYgA11L.cjs → formatters-DQr05EUA.cjs} +17 -15
- package/dist/formatters-DQr05EUA.cjs.map +1 -0
- package/dist/{formatters-QcZO_Cpx.js → formatters-zDzQvtb4.js} +17 -15
- package/dist/formatters-zDzQvtb4.js.map +1 -0
- package/dist/generators/index.cjs +12 -8
- 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 +12 -8
- package/dist/generators/index.js.map +1 -1
- package/dist/index-3jBnthag.d.cts +340 -0
- package/dist/index-BXwimNPA.d.cts +2361 -0
- package/dist/index-BlTCrSyc.d.cts +2158 -0
- package/dist/index-CEm8ZOvj.d.ts +2158 -0
- package/dist/index-CLq5kZmQ.d.cts +822 -0
- package/dist/index-Ckao53JY.d.ts +2361 -0
- package/dist/index-DHHrLc0B.d.ts +947 -0
- package/dist/index-DIeR8qa-.d.ts +340 -0
- package/dist/index-DxZlGbAH.d.ts +1716 -0
- package/dist/index-DyVWeYP3.d.cts +765 -0
- package/dist/index-GSUN6rjA.d.ts +822 -0
- package/dist/index-_dJhBl1h.d.ts +765 -0
- package/dist/index-bMa-0Yr4.d.cts +1716 -0
- package/dist/index-z_uCh5KW.d.cts +947 -0
- package/dist/{isBigInt-B1cijjqm.cjs → isBigInt-CIFRnsdx.cjs} +2 -2
- package/dist/{isBigInt-B1cijjqm.cjs.map → isBigInt-CIFRnsdx.cjs.map} +1 -1
- package/dist/{isBigInt-C0bN0Rhu.js → isBigInt-D-Pu9sxp.js} +2 -2
- package/dist/{isBigInt-C0bN0Rhu.js.map → isBigInt-D-Pu9sxp.js.map} +1 -1
- package/dist/{isEmptyObject-DI42NEo0.cjs → isEmptyObject-CEySmyHK.cjs} +3 -3
- package/dist/{isEmptyObject-DI42NEo0.cjs.map → isEmptyObject-CEySmyHK.cjs.map} +1 -1
- package/dist/{isEmptyObject-DeLVIJpl.js → isEmptyObject-CZ9DLi7R.js} +3 -3
- package/dist/{isEmptyObject-DeLVIJpl.js.map → isEmptyObject-CZ9DLi7R.js.map} +1 -1
- package/dist/{isEmptyString-BTUWYTbw.js → isEmptyString-DFDtBbNr.js} +3 -3
- package/dist/{isEmptyString-BTUWYTbw.js.map → isEmptyString-DFDtBbNr.js.map} +1 -1
- package/dist/{isEmptyString-CCK3bP74.cjs → isEmptyString-DI64RQCy.cjs} +3 -3
- package/dist/{isEmptyString-CCK3bP74.cjs.map → isEmptyString-DI64RQCy.cjs.map} +1 -1
- package/dist/{isEmptyValue-DMSMFTU8.cjs → isEmptyValue-Cw6ovu7z.cjs} +5 -5
- package/dist/{isEmptyValue-DMSMFTU8.cjs.map → isEmptyValue-Cw6ovu7z.cjs.map} +1 -1
- package/dist/{isEmptyValue-fjnfQnt5.js → isEmptyValue-aGyeClwA.js} +5 -5
- package/dist/{isEmptyValue-fjnfQnt5.js.map → isEmptyValue-aGyeClwA.js.map} +1 -1
- package/dist/{isEqual-DhyP8fB_.js → isEqual-Dtb2sXUv.js} +4 -4
- package/dist/{isEqual-DhyP8fB_.js.map → isEqual-Dtb2sXUv.js.map} +1 -1
- package/dist/{isEqual-B1fRgEuU.cjs → isEqual-UsvOwrlY.cjs} +4 -4
- package/dist/{isEqual-B1fRgEuU.cjs.map → isEqual-UsvOwrlY.cjs.map} +1 -1
- package/dist/{isFinite-BYMOo0os.js → isFinite-Cz_IFXuV.js} +3 -3
- package/dist/{isFinite-BYMOo0os.js.map → isFinite-Cz_IFXuV.js.map} +1 -1
- package/dist/{isFinite-sFkps2TY.cjs → isFinite-uukWvxJh.cjs} +3 -3
- package/dist/{isFinite-sFkps2TY.cjs.map → isFinite-uukWvxJh.cjs.map} +1 -1
- package/dist/{isInteger-FTCthMre.cjs → isInteger-DPYjliLZ.cjs} +2 -2
- package/dist/{isInteger-FTCthMre.cjs.map → isInteger-DPYjliLZ.cjs.map} +1 -1
- package/dist/{isInteger-DS9V7l_f.js → isInteger-DZ163OQg.js} +2 -2
- package/dist/{isInteger-DS9V7l_f.js.map → isInteger-DZ163OQg.js.map} +1 -1
- package/dist/isPlainObject-CBABRyEX.d.cts +339 -0
- package/dist/isPlainObject-Dr8gi89U.d.ts +339 -0
- package/dist/{isServer-D1TXfOs3.js → isServer-BDShLyVJ.js} +2 -2
- package/dist/{isServer-D1TXfOs3.js.map → isServer-BDShLyVJ.js.map} +1 -1
- package/dist/{isServer-q-QLFCqE.cjs → isServer-BzDeYuGg.cjs} +2 -2
- package/dist/{isServer-q-QLFCqE.cjs.map → isServer-BzDeYuGg.cjs.map} +1 -1
- package/dist/{isTypedArray-DiCoqffZ.cjs → isTypedArray-DaYAkyrt.cjs} +3 -3
- package/dist/{isTypedArray-DiCoqffZ.cjs.map → isTypedArray-DaYAkyrt.cjs.map} +1 -1
- package/dist/{isTypedArray-47R0wdrc.js → isTypedArray-DuUUA4CL.js} +3 -3
- package/dist/{isTypedArray-47R0wdrc.js.map → isTypedArray-DuUUA4CL.js.map} +1 -1
- package/dist/{isValidDomain-BSXshgkC.cjs → isValidDomain-BxyToAlh.cjs} +74 -8
- package/dist/isValidDomain-BxyToAlh.cjs.map +1 -0
- package/dist/{isValidDomain-DwA2EN79.js → isValidDomain-CTw5vZFY.js} +57 -9
- package/dist/isValidDomain-CTw5vZFY.js.map +1 -0
- package/dist/{noop-B2mTBhW-.cjs → noop-7KrqC9DC.cjs} +2 -2
- package/dist/{noop-B2mTBhW-.cjs.map → noop-7KrqC9DC.cjs.map} +1 -1
- package/dist/{noop-BzktGBVz.js → noop-DGg9vMSD.js} +2 -2
- package/dist/{noop-BzktGBVz.js.map → noop-DGg9vMSD.js.map} +1 -1
- package/dist/{normalizeSpaces-DQHR3Tlr.cjs → normalizeSpaces-B6ZQOZRX.cjs} +3 -3
- package/dist/{normalizeSpaces-DQHR3Tlr.cjs.map → normalizeSpaces-B6ZQOZRX.cjs.map} +1 -1
- package/dist/{normalizeSpaces-WS_iERJk.js → normalizeSpaces-C1eLwykD.js} +3 -3
- package/dist/{normalizeSpaces-WS_iERJk.js.map → normalizeSpaces-C1eLwykD.js.map} +1 -1
- package/dist/operations/index.cjs +10 -10
- package/dist/operations/index.cjs.map +1 -1
- package/dist/operations/index.d.cts +120 -120
- package/dist/operations/index.d.ts +120 -120
- package/dist/operations/index.js +10 -10
- package/dist/operations/index.js.map +1 -1
- package/dist/parsers/index.cjs +2 -2
- package/dist/parsers/index.d.cts +222 -222
- package/dist/parsers/index.d.ts +222 -222
- package/dist/parsers/index.js +2 -2
- package/dist/{parsers-DXtpsDyj.cjs → parsers-DEFpCYhw.cjs} +4 -4
- package/dist/{parsers-DXtpsDyj.cjs.map → parsers-DEFpCYhw.cjs.map} +1 -1
- package/dist/{parsers-Dpuq-V4u.js → parsers-bQQ9mStV.js} +4 -4
- package/dist/{parsers-Dpuq-V4u.js.map → parsers-bQQ9mStV.js.map} +1 -1
- package/dist/{parsing-B43x1sxn.js → parsing-BngARhmu.js} +3 -3
- package/dist/{parsing-B43x1sxn.js.map → parsing-BngARhmu.js.map} +1 -1
- package/dist/{parsing-lRoxn1Nz.cjs → parsing-lI5EN4LY.cjs} +3 -3
- package/dist/{parsing-lRoxn1Nz.cjs.map → parsing-lI5EN4LY.cjs.map} +1 -1
- package/dist/predicates/index.cjs +15 -16
- package/dist/predicates/index.d.cts +3 -3
- package/dist/predicates/index.d.ts +3 -3
- package/dist/predicates/index.js +14 -15
- package/dist/{predicates-DiaYA7Ps.cjs → predicates-CMmP3fPJ.cjs} +15 -16
- package/dist/{predicates-DiaYA7Ps.cjs.map → predicates-CMmP3fPJ.cjs.map} +1 -1
- package/dist/{predicates-gNepszvo.js → predicates-V87QD8hs.js} +13 -14
- package/dist/{predicates-gNepszvo.js.map → predicates-V87QD8hs.js.map} +1 -1
- package/dist/promises/index.cjs +4 -4
- package/dist/promises/index.d.cts +101 -101
- package/dist/promises/index.d.ts +101 -101
- package/dist/promises/index.js +4 -4
- package/dist/{punyCode-hmiFzLWT.js → punyCode-BeFYDjj0.js} +6 -6
- package/dist/punyCode-BeFYDjj0.js.map +1 -0
- package/dist/{punyCode-CTWXVVFo.cjs → punyCode-DmTsB7q_.cjs} +6 -6
- package/dist/punyCode-DmTsB7q_.cjs.map +1 -0
- package/dist/{removeSpaces-BE8lfh-4.js → removeSpaces-B96axxP6.js} +7 -4
- package/dist/removeSpaces-B96axxP6.js.map +1 -0
- package/dist/{removeSpaces-DRRxNWlb.cjs → removeSpaces-C8mu_yp3.cjs} +12 -3
- package/dist/removeSpaces-C8mu_yp3.cjs.map +1 -0
- package/dist/rzl-utils.global.js +21 -0
- package/dist/{safeJsonParse-BBnQElk8.cjs → safeJsonParse-BXbtX_j7.cjs} +9 -9
- package/dist/safeJsonParse-BXbtX_j7.cjs.map +1 -0
- package/dist/{safeJsonParse-CXruaP0p.js → safeJsonParse-DyCsTXlU.js} +9 -9
- package/dist/safeJsonParse-DyCsTXlU.js.map +1 -0
- package/dist/{safeStableStringify-BNh3D0K0.js → safeStableStringify-BrOcdX9n.js} +4 -4
- package/dist/{safeStableStringify-BNh3D0K0.js.map → safeStableStringify-BrOcdX9n.js.map} +1 -1
- package/dist/{safeStableStringify-Cc62pfRp.cjs → safeStableStringify-DRYQ56Dg.cjs} +4 -4
- package/dist/{safeStableStringify-Cc62pfRp.cjs.map → safeStableStringify-DRYQ56Dg.cjs.map} +1 -1
- package/dist/strings/index.cjs +12 -10
- 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 +11 -9
- package/dist/strings/index.js.map +1 -1
- package/dist/tailwind/index.cjs +6 -2
- 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-IJvOdkZp.js → tailwind-BZ2_MeNX.js} +18 -8
- package/dist/tailwind-BZ2_MeNX.js.map +1 -0
- package/dist/{tailwind-DJ4cmLUw.cjs → tailwind-C1YtxJ-K.cjs} +39 -5
- package/dist/tailwind-C1YtxJ-K.cjs.map +1 -0
- package/dist/{toStringArrayUnRecursive-xUaU8Ot9.cjs → toStringArrayUnRecursive-D1mPM4wg.cjs} +6 -6
- package/dist/{toStringArrayUnRecursive-xUaU8Ot9.cjs.map → toStringArrayUnRecursive-D1mPM4wg.cjs.map} +1 -1
- package/dist/{toStringArrayUnRecursive-CFs0jTEg.js → toStringArrayUnRecursive-tHp2a7KR.js} +6 -6
- package/dist/{toStringArrayUnRecursive-CFs0jTEg.js.map → toStringArrayUnRecursive-tHp2a7KR.js.map} +1 -1
- package/dist/urls/index.cjs +9 -119
- package/dist/urls/index.d.cts +656 -659
- package/dist/urls/index.d.ts +656 -659
- package/dist/urls/index.js +3 -113
- package/dist/urls-CoxDAoki.js +263 -0
- package/dist/urls-CoxDAoki.js.map +1 -0
- package/dist/urls-DCyx8Wpk.cjs +299 -0
- package/dist/urls-DCyx8Wpk.cjs.map +1 -0
- package/package.json +4 -25
- package/dist/assertIsBoolean-BlBct0Fc.js.map +0 -1
- package/dist/assertIsBoolean-DozdtbNi.cjs.map +0 -1
- package/dist/conversions-CBs8-REq.cjs.map +0 -1
- package/dist/conversions-EMJa3g-D.js.map +0 -1
- package/dist/formatEnvPort-DpIXzPAZ.js +0 -159
- package/dist/formatEnvPort-DpIXzPAZ.js.map +0 -1
- package/dist/formatEnvPort-hHNvOim-.cjs +0 -171
- package/dist/formatEnvPort-hHNvOim-.cjs.map +0 -1
- package/dist/formatters-QcZO_Cpx.js.map +0 -1
- package/dist/formatters-lAYgA11L.cjs.map +0 -1
- package/dist/index-26W7ItWx.d.ts +0 -760
- package/dist/index-BPPQjAfs.d.cts +0 -2359
- package/dist/index-BXjlgBLz.d.cts +0 -2139
- package/dist/index-B_Wwo91H.d.ts +0 -2359
- package/dist/index-CpufydcI.d.cts +0 -704
- package/dist/index-Czc4O526.d.ts +0 -333
- package/dist/index-DPs1_p5G.d.cts +0 -760
- package/dist/index-DRpOyBSC.d.ts +0 -1703
- package/dist/index-DWWvtHUn.d.cts +0 -822
- package/dist/index-DnM0LD0n.d.cts +0 -333
- package/dist/index-GUZ9fK6T.d.ts +0 -2139
- package/dist/index-I4fAzwXV.d.ts +0 -704
- package/dist/index-JDrOl_19.d.ts +0 -822
- package/dist/index-b66P49Qe.d.cts +0 -1703
- package/dist/isPlainObject-DcFGh3_5.d.ts +0 -530
- package/dist/isPlainObject-doTI11Ib.d.cts +0 -530
- package/dist/isURL-CQiowFq2.js +0 -14
- package/dist/isURL-CQiowFq2.js.map +0 -1
- package/dist/isURL-WZypXsax.cjs +0 -20
- package/dist/isURL-WZypXsax.cjs.map +0 -1
- package/dist/isValidDomain-BSXshgkC.cjs.map +0 -1
- package/dist/isValidDomain-DwA2EN79.js.map +0 -1
- package/dist/next/index.cjs +0 -129
- package/dist/next/index.cjs.map +0 -1
- package/dist/next/index.d.cts +0 -226
- package/dist/next/index.d.ts +0 -226
- package/dist/next/index.js +0 -124
- package/dist/next/index.js.map +0 -1
- package/dist/next/server/index.cjs +0 -28
- package/dist/next/server/index.cjs.map +0 -1
- package/dist/next/server/index.d.cts +0 -39
- package/dist/next/server/index.d.ts +0 -39
- package/dist/next/server/index.js +0 -26
- package/dist/next/server/index.js.map +0 -1
- package/dist/normalizeString-2WLth_Gj.js +0 -15
- package/dist/normalizeString-2WLth_Gj.js.map +0 -1
- package/dist/normalizeString-D8euBcRD.cjs +0 -21
- package/dist/normalizeString-D8euBcRD.cjs.map +0 -1
- package/dist/punyCode-CTWXVVFo.cjs.map +0 -1
- package/dist/punyCode-hmiFzLWT.js.map +0 -1
- package/dist/removeSpaces-BE8lfh-4.js.map +0 -1
- package/dist/removeSpaces-DRRxNWlb.cjs.map +0 -1
- package/dist/safeJsonParse-BBnQElk8.cjs.map +0 -1
- package/dist/safeJsonParse-CXruaP0p.js.map +0 -1
- package/dist/tailwind-DJ4cmLUw.cjs.map +0 -1
- package/dist/tailwind-IJvOdkZp.js.map +0 -1
- package/dist/urls/index.cjs.map +0 -1
- package/dist/urls/index.js.map +0 -1
|
@@ -1,704 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* ========================================================================
|
|
3
|
-
* @rzl-zone/utils-js
|
|
4
|
-
* ------------------------------------------------------------------------
|
|
5
|
-
* Version: `3.12.1-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
|
-
import { Stringify } from "@rzl-zone/ts-types-plus";
|
|
12
|
-
import { Config } from "tailwindcss";
|
|
13
|
-
import { ClassNameValue, ConfigExtension } from "tailwind-merge-v4";
|
|
14
|
-
import { ClassNameValue as ClassNameValue$1, ConfigExtension as ConfigExtension$1 } from "tailwind-merge-v3";
|
|
15
|
-
/** ----------------------------------------------------------
|
|
16
|
-
* * ***Type-Utility: `ClassValue`.***
|
|
17
|
-
* ----------------------------------------------------------
|
|
18
|
-
* **Represents a single valid value that can be converted to a CSS class string.**
|
|
19
|
-
* @description
|
|
20
|
-
* - Supports the following types:
|
|
21
|
-
* - `string` → literal class names (non-empty only)
|
|
22
|
-
* - `number | bigint` → numeric class names
|
|
23
|
-
* - `boolean` → only `true` is considered in objects/arrays
|
|
24
|
-
* - `null | undefined` → ignored
|
|
25
|
-
* - `ClassObject` → objects where **keys with truthy values** are included
|
|
26
|
-
* - `ClassValues` → arrays recursively flattened
|
|
27
|
-
* - Used internally by ***`cx` utility function*** to process mixed input values.
|
|
28
|
-
* @example
|
|
29
|
-
* ```ts
|
|
30
|
-
* const val1: ClassValue = "button"; // ➔ string
|
|
31
|
-
* const val2: ClassValue = 0; // ➔ number
|
|
32
|
-
* const val3: ClassValue = ["a", { b: true }]; // ➔ array with object
|
|
33
|
-
* const val4: ClassValue = { d: true, e: false }; // ➔ object
|
|
34
|
-
* const val5: ClassValue = new String("foo"); // ➔ boxed string
|
|
35
|
-
* const val6: ClassValue = new Number("123"); // ➔ boxed number
|
|
36
|
-
* const val7: ClassValue = new Boolean("true"); // ➔ boxed boolean
|
|
37
|
-
* ```
|
|
38
|
-
*/
|
|
39
|
-
type ClassValue = ClassValues | ClassObject | string | number | bigint | null | boolean | undefined;
|
|
40
|
-
/** ----------------------------------------------------------
|
|
41
|
-
* * ***Type-Utility: `ClassObject`.***
|
|
42
|
-
* ----------------------------------------------------------
|
|
43
|
-
* **Represents an object whose keys with truthy values are included in the final class string.**
|
|
44
|
-
* @example
|
|
45
|
-
* ```ts
|
|
46
|
-
* const obj: ClassObject = { "text-red": true, "hidden": false };
|
|
47
|
-
* // ➔ "text-red" when processed by cx
|
|
48
|
-
* ```
|
|
49
|
-
*/
|
|
50
|
-
type ClassObject = Record<string, any>;
|
|
51
|
-
/** ----------------------------------------------------------
|
|
52
|
-
* * ***Type-Utility: `ClassValues`.***
|
|
53
|
-
* ----------------------------------------------------------
|
|
54
|
-
* **Represents an array of {@link ClassValue | `ClassValue's`}, potentially nested.**
|
|
55
|
-
* @example
|
|
56
|
-
* ```ts
|
|
57
|
-
* const arr: ClassValues = [
|
|
58
|
-
* "a",
|
|
59
|
-
* 1,
|
|
60
|
-
* ["b", { c: true, d: false }],
|
|
61
|
-
* { e: 2 }
|
|
62
|
-
* ];
|
|
63
|
-
* ```
|
|
64
|
-
*/
|
|
65
|
-
type ClassValues = ClassValue[];
|
|
66
|
-
/** ----------------------------------------------------------
|
|
67
|
-
* * ***Utility: `cx`.***
|
|
68
|
-
* ----------------------------------------------------------
|
|
69
|
-
* **Merge multiple class values into a single, space-separated string suitable for CSS usage.**
|
|
70
|
-
* @description
|
|
71
|
-
* - Supports **nested combinations** of arrays and objects, recursively.
|
|
72
|
-
* - **Falsy values** are skipped:
|
|
73
|
-
* - `false`, `null`, `undefined`, empty strings `""` are ignored anywhere.
|
|
74
|
-
* - Numbers `0` are ignored inside nested arrays/objects.
|
|
75
|
-
* - **Boxed primitives** are correctly unwrapped to their primitive value.
|
|
76
|
-
* - **Inherited object keys** are included in the final class string.
|
|
77
|
-
* - Optimized for **CSS class merging** where conditional inclusion is common.
|
|
78
|
-
* @param {ClassValues} values
|
|
79
|
-
* A list of mixed class values, which can include:
|
|
80
|
-
* - **Strings** → literal class names.
|
|
81
|
-
* - **Numbers** → numeric class names.
|
|
82
|
-
* - **BigInt** → numeric class names larger than JS safe integer limit.
|
|
83
|
-
* - **Arrays** → recursively flattened, can contain nested arrays or objects.
|
|
84
|
-
* - **Objects** → include keys whose values are truthy. Inherited keys are also included.
|
|
85
|
-
* - **Boxed primitives** (`new String()`, `new Number()`, `new Boolean()`) → automatically unwrapped.
|
|
86
|
-
* - **Falsy values** (`false`, `null`, `undefined`, `""`, `0`) are ignored according to original behavior.
|
|
87
|
-
* @returns {string}
|
|
88
|
-
* A single space-separated string containing all valid class names.
|
|
89
|
-
* @example
|
|
90
|
-
* ```ts
|
|
91
|
-
* // Basic string merge
|
|
92
|
-
* cx("btn", "btn-primary");
|
|
93
|
-
* // ➔ "btn btn-primary"
|
|
94
|
-
*
|
|
95
|
-
* // Mixed arrays and objects
|
|
96
|
-
* cx("a", ["b", { c: true, d: false }], { e: 1, f: 0 }, null, 2);
|
|
97
|
-
* // ➔ "a b c e 2"
|
|
98
|
-
*
|
|
99
|
-
* // Empty and falsy values are ignored
|
|
100
|
-
* cx("", null, undefined, false, 0);
|
|
101
|
-
* // ➔ ""
|
|
102
|
-
*
|
|
103
|
-
* // Nested arrays with objects
|
|
104
|
-
* cx(["a", ["b", { c: true, d: false }]]);
|
|
105
|
-
* // ➔ "a b c"
|
|
106
|
-
*
|
|
107
|
-
* // Boxed primitives are unwrapped
|
|
108
|
-
* cx(new String("foo"), new Number(42), new Boolean(true), new Number(0), new Boolean(false));
|
|
109
|
-
* // ➔ "foo 42 true"
|
|
110
|
-
*
|
|
111
|
-
* // Inherited keys from objects are included
|
|
112
|
-
* const proto = { inherited: true };
|
|
113
|
-
* const obj = Object.create(proto);
|
|
114
|
-
* obj.own = true;
|
|
115
|
-
* cx(obj);
|
|
116
|
-
* // ➔ "own inherited"
|
|
117
|
-
* ```
|
|
118
|
-
*/
|
|
119
|
-
declare function cx(...values: ClassValues): string;
|
|
120
|
-
/** -------------------------------------------------------------
|
|
121
|
-
* * ***Default `cnV3` utility (Tailwind v3).***
|
|
122
|
-
* -------------------------------------------------------------
|
|
123
|
-
* **Combines class-name values and then deduplicates/resolves
|
|
124
|
-
* conflicts using {@link twMergeDefaultV3 | `twMergeDefaultV3`}
|
|
125
|
-
* with **Tailwind v3 default config only**.**
|
|
126
|
-
* - ✅ **Use this when:**
|
|
127
|
-
* - Your project uses **Tailwind v3**.
|
|
128
|
-
* - You need a simple `cn` that works out of the box without a custom config.
|
|
129
|
-
* - ⚡ **Need custom rules?**
|
|
130
|
-
* - Create a project-wide helper using
|
|
131
|
-
* {@link twMergeDefaultV3 | `twMergeDefaultV3`} +
|
|
132
|
-
* {@link customCnV3 | `customCnV3`} (see Example 2).
|
|
133
|
-
* @param {ClassValues} classes - Class values (`string`, `array`, `object`, `etc`).
|
|
134
|
-
* @returns {string} Merged Tailwind class string.
|
|
135
|
-
* @example
|
|
136
|
-
* #### Example 1: ✅ Default usage (Tailwind v3).
|
|
137
|
-
* ```ts
|
|
138
|
-
* cnV3("p-2", "p-4");
|
|
139
|
-
* // ➔ "p-4"
|
|
140
|
-
*
|
|
141
|
-
* cnV3("text-red-500", { "text-blue-500": true });
|
|
142
|
-
* // ➔ "text-blue-500"
|
|
143
|
-
*
|
|
144
|
-
* cnV3(["m-2", ["m-4"]], "m-8");
|
|
145
|
-
* // ➔ "m-8"
|
|
146
|
-
* ```
|
|
147
|
-
* #### Example 2: ⚡ Custom project-wide usage with Tailwind config.
|
|
148
|
-
* ```ts
|
|
149
|
-
* import tailwindConfig from "../tailwind.config";
|
|
150
|
-
* import { twMergeDefaultV3, customCnV3, type ClassValues } from "@rzl-zone/utils-js/tailwind";
|
|
151
|
-
*
|
|
152
|
-
* const cnApp = (...classes: ClassValues) => {
|
|
153
|
-
* return customCnV3(
|
|
154
|
-
* twMergeDefaultV3({
|
|
155
|
-
* config: tailwindConfig,
|
|
156
|
-
* extend: {
|
|
157
|
-
* classGroups: {
|
|
158
|
-
* "text-shadow": [
|
|
159
|
-
* "text-shadow",
|
|
160
|
-
* "text-shadow-sm",
|
|
161
|
-
* "text-shadow-md",
|
|
162
|
-
* ],
|
|
163
|
-
* },
|
|
164
|
-
* },
|
|
165
|
-
* }),
|
|
166
|
-
* // ...other options classes,
|
|
167
|
-
* );
|
|
168
|
-
* };
|
|
169
|
-
*
|
|
170
|
-
* cnApp("p-2 p-4"); // ➔ "p-4"
|
|
171
|
-
* cnApp("shadow-sm shadow-md"); // ➔ "shadow-md"
|
|
172
|
-
* cnApp("text-base text-xxs"); // ➔ "text-xxs" (resolved from config)
|
|
173
|
-
* ```
|
|
174
|
-
*/
|
|
175
|
-
declare const cnV3: (...classes: ClassValues) => string;
|
|
176
|
-
/** -------------------------------------------------------------
|
|
177
|
-
* * ***Default `cnV4` utility (Tailwind v4).***
|
|
178
|
-
* -------------------------------------------------------------
|
|
179
|
-
* **Combines class-name values and then deduplicates/resolves
|
|
180
|
-
* conflicts using {@link twMergeDefaultV4 | `twMergeDefaultV4`}
|
|
181
|
-
* with **Tailwind v4 default config only**.**
|
|
182
|
-
* - ✅ **Use this when:**
|
|
183
|
-
* - Your project uses **Tailwind v4**.
|
|
184
|
-
* - You need a simple `cn` that works out of the box without a custom config.
|
|
185
|
-
* - ⚡ **Need custom rules?**
|
|
186
|
-
* - Create a project-wide helper using
|
|
187
|
-
* {@link twMergeDefaultV4 | `twMergeDefaultV4`} +
|
|
188
|
-
* {@link customCnV4 | `customCnV4`} (see Example 2).
|
|
189
|
-
* @param {ClassValues} classes - Class values (`string`, `array`, `object`, `etc`).
|
|
190
|
-
* @returns {string} Merged Tailwind class string.
|
|
191
|
-
* @example
|
|
192
|
-
* #### Example 1: ✅ Default usage (Tailwind v4).
|
|
193
|
-
* ```ts
|
|
194
|
-
* cnV4("p-2", "p-4");
|
|
195
|
-
* // ➔ "p-4"
|
|
196
|
-
*
|
|
197
|
-
* cnV4("text-red-500", { "text-blue-500": true });
|
|
198
|
-
* // ➔ "text-blue-500"
|
|
199
|
-
*
|
|
200
|
-
* cnV4(["m-2", ["m-4"]], "m-8");
|
|
201
|
-
* // ➔ "m-8"
|
|
202
|
-
* ```
|
|
203
|
-
* #### Example 2: ⚡ Custom project-wide usage with Tailwind config.
|
|
204
|
-
* ```ts
|
|
205
|
-
* import tailwindConfig from "../tailwind.config";
|
|
206
|
-
* import { twMergeDefaultV4, customCnV4, type ClassValues } from "@rzl-zone/utils-js/tailwind";
|
|
207
|
-
*
|
|
208
|
-
* const cnApp = (...classes: ClassValues) => {
|
|
209
|
-
* return customCnV4(
|
|
210
|
-
* twMergeDefaultV4({
|
|
211
|
-
* config: tailwindConfig,
|
|
212
|
-
* extend: {
|
|
213
|
-
* classGroups: {
|
|
214
|
-
* "text-shadow": [
|
|
215
|
-
* "text-shadow",
|
|
216
|
-
* "text-shadow-sm",
|
|
217
|
-
* "text-shadow-md",
|
|
218
|
-
* ],
|
|
219
|
-
* },
|
|
220
|
-
* },
|
|
221
|
-
* }),
|
|
222
|
-
* // ...other options classes,
|
|
223
|
-
* );
|
|
224
|
-
* };
|
|
225
|
-
*
|
|
226
|
-
* cnApp("p-2 p-4"); // ➔ "p-4"
|
|
227
|
-
* cnApp("shadow-sm shadow-md"); // ➔ "shadow-md"
|
|
228
|
-
* cnApp("text-base text-xxs"); // ➔ "text-xxs" (resolved from config)
|
|
229
|
-
* ```
|
|
230
|
-
*/
|
|
231
|
-
declare const cnV4: (...classes: ClassValues) => string;
|
|
232
|
-
/** Tailwind Merge config extension type */
|
|
233
|
-
type TwMergeConfigExt$1 = ConfigExtension<string, string>;
|
|
234
|
-
/** * ***Extra options for customized Tailwind class merge.*** */
|
|
235
|
-
type OptionsConfigMergeTwCn$1 = {
|
|
236
|
-
/** ----------------------------------------------------------
|
|
237
|
-
* * ***Optional Tailwind CSS configuration object.***
|
|
238
|
-
* ----------------------------------------------------------
|
|
239
|
-
* - **Pass your project’s `tailwind.config.ts` if you want to:**
|
|
240
|
-
* - Respect custom theme values (`colors`, `fontSize`, `spacing`, `etc`.)
|
|
241
|
-
* - Enable/disable `corePlugins`
|
|
242
|
-
* - Register `plugins`
|
|
243
|
-
* - Extend class groups (e.g., `text-shadow`)
|
|
244
|
-
* - **If omitted, the **default Tailwind config** is used.**
|
|
245
|
-
* @example
|
|
246
|
-
* ```ts
|
|
247
|
-
* import tailwindConfig from "../tailwind.config";
|
|
248
|
-
* import { twMergeDefaultV4 } from "@rzl-zone/utils-js/tailwind";
|
|
249
|
-
*
|
|
250
|
-
* const myCustomTwCls = twMergeDefaultV4({
|
|
251
|
-
* config: tailwindConfig,
|
|
252
|
-
* });
|
|
253
|
-
*
|
|
254
|
-
* myCustomTwCls("text-primary text-secondary");
|
|
255
|
-
* // => "text-secondary" (resolved from your theme config)
|
|
256
|
-
* ```
|
|
257
|
-
*/
|
|
258
|
-
config?: TailwindConfig;
|
|
259
|
-
/** ----------------------------------------------------------
|
|
260
|
-
* * ***Prefix added to Tailwind-generated classes.***
|
|
261
|
-
* ----------------------------------------------------------
|
|
262
|
-
* - **Tailwind v3**:
|
|
263
|
-
* - Use {@link twMergeDefaultV3 | **`twMergeDefaultV3`**} instead.
|
|
264
|
-
* - Reference:
|
|
265
|
-
* [**`Tailwind v3 using prefix docs`**](https://v3.tailwindcss.com/docs/configuration#prefix).
|
|
266
|
-
*
|
|
267
|
-
* - **Tailwind v4**:
|
|
268
|
-
* - Configure in your CSS import, e.g. `@import "tailwindcss" prefix(tw);`
|
|
269
|
-
* - The prefix appears like a variant at the start of the class, e.g. `tw:flex`,
|
|
270
|
-
* `tw:bg-red-500`, `tw:hover:bg-red-600`.
|
|
271
|
-
* - Reference:
|
|
272
|
-
* [**`Tailwind v4 using prefix docs`**](https://tailwindcss.com/docs/upgrade-guide#using-a-prefix).
|
|
273
|
-
*
|
|
274
|
-
* - **ℹ️ Notes**:
|
|
275
|
-
* - Tailwind v3:
|
|
276
|
-
* - Use {@link twMergeDefaultV3 | **`twMergeDefaultV3`**} instead.
|
|
277
|
-
* - Tailwind v4: prefer identifier (e.g. `tw`) without `-`.
|
|
278
|
-
* - Fallback order:
|
|
279
|
-
* 1. `prefix` option
|
|
280
|
-
* 2. `config.prefix` (if defined)
|
|
281
|
-
* 3. `undefined`
|
|
282
|
-
*
|
|
283
|
-
* @example
|
|
284
|
-
* - Tailwind version 4 (in CSS entry only):
|
|
285
|
-
* - CSS files:
|
|
286
|
-
* ```css
|
|
287
|
-
* `@import "tailwindcss" prefix(tw);`
|
|
288
|
-
* ```
|
|
289
|
-
* - Your custom TwMerge file:
|
|
290
|
-
* ```ts
|
|
291
|
-
* import { twMergeDefaultV4 } from "@rzl-zone/utils-js/tailwind";
|
|
292
|
-
*
|
|
293
|
-
* const twMergeV3 = twMergeDefaultV4({
|
|
294
|
-
* prefix: "tw",
|
|
295
|
-
* // ... other config
|
|
296
|
-
* });
|
|
297
|
-
* ```
|
|
298
|
-
* - Tailwind version 4 (with `tailwind.config.{js,ts,mjs,...etc}`):
|
|
299
|
-
* - Reference:
|
|
300
|
-
* [**`Tailwind v4 using @config docs`**](https://tailwindcss.com/docs/functions-and-directives#config-directive).
|
|
301
|
-
* - CSS files:
|
|
302
|
-
* ```css
|
|
303
|
-
* `@import "tailwindcss";`
|
|
304
|
-
* `@config "./tailwind.config.ts";`
|
|
305
|
-
* ```
|
|
306
|
-
* - Config files:
|
|
307
|
-
* ```ts
|
|
308
|
-
* import type { Config } from "tailwindcss";
|
|
309
|
-
*
|
|
310
|
-
* const config: Config = {
|
|
311
|
-
* prefix: 'tw-',
|
|
312
|
-
* // ... other config
|
|
313
|
-
* };
|
|
314
|
-
*
|
|
315
|
-
* export default config;
|
|
316
|
-
* ```
|
|
317
|
-
* - Your custom TwMerge file:
|
|
318
|
-
* ```ts
|
|
319
|
-
* import config from "../tailwind.config";
|
|
320
|
-
* import { twMergeDefaultV4 } from "@rzl-zone/utils-js/tailwind";
|
|
321
|
-
*
|
|
322
|
-
* const twMergeV4 = twMergeDefaultV4({ config });
|
|
323
|
-
* // now without passing `prefix` options, will use automatic from config.
|
|
324
|
-
* ```
|
|
325
|
-
*/
|
|
326
|
-
prefix?: string;
|
|
327
|
-
};
|
|
328
|
-
/** * ***Options type for Tailwind Merge v4 wrapper.*** */
|
|
329
|
-
type OptionsMergeTwClsV4 = Omit<TwMergeConfigExt$1, "prefix"> & OptionsConfigMergeTwCn$1;
|
|
330
|
-
/** * ***Tailwind Merge function Version 4 signature (same as twMerge).*** */
|
|
331
|
-
type TwMergeDefaultFnV4 = (...classLists: ClassNameValue[]) => string;
|
|
332
|
-
type TailwindConfig = Config;
|
|
333
|
-
/** Tailwind Merge config extension type */
|
|
334
|
-
type TwMergeConfigExt = ConfigExtension$1<string, string>;
|
|
335
|
-
/** * ***Extra options for customized Tailwind class merge.*** */
|
|
336
|
-
type OptionsConfigMergeTwCn = {
|
|
337
|
-
/** ----------------------------------------------------------
|
|
338
|
-
* * ***Optional Tailwind CSS configuration object.***
|
|
339
|
-
* ----------------------------------------------------------
|
|
340
|
-
* - **Pass your project’s `tailwind.config.ts` if you want to:**
|
|
341
|
-
* - Respect custom theme values (`colors`, `fontSize`, `spacing`, `etc`.)
|
|
342
|
-
* - Enable/disable `corePlugins`
|
|
343
|
-
* - Register `plugins`
|
|
344
|
-
* - Extend class groups (e.g., `text-shadow`)
|
|
345
|
-
* - **If omitted, the **default Tailwind config** is used.**
|
|
346
|
-
* @example
|
|
347
|
-
* ```ts
|
|
348
|
-
* import tailwindConfig from "../tailwind.config";
|
|
349
|
-
* import { twMergeDefaultV3 } from "@rzl-zone/utils-js/tailwind";
|
|
350
|
-
*
|
|
351
|
-
* const myCustomTwCls = twMergeDefaultV3({
|
|
352
|
-
* config: tailwindConfig,
|
|
353
|
-
* });
|
|
354
|
-
*
|
|
355
|
-
* myCustomTwCls("text-primary text-secondary");
|
|
356
|
-
* // => "text-secondary" (resolved from your theme config)
|
|
357
|
-
* ```
|
|
358
|
-
*/
|
|
359
|
-
config?: TailwindConfig;
|
|
360
|
-
/** ----------------------------------------------------------
|
|
361
|
-
* * ***Prefix added to Tailwind-generated classes.***
|
|
362
|
-
* ----------------------------------------------------------
|
|
363
|
-
* - **Tailwind v3**:
|
|
364
|
-
* - Configure in `tailwind.config.js`, e.g. `prefix: 'tw-'`.
|
|
365
|
-
* - Variants first; negative utilities: `-mt-8` ➔ `-tw-mt-8`.
|
|
366
|
-
* - Reference:
|
|
367
|
-
* [**`Tailwind v3 using prefix docs`**](https://v3.tailwindcss.com/docs/configuration#prefix).
|
|
368
|
-
* - **Tailwind v4**:
|
|
369
|
-
* - Use {@link twMergeDefaultV4 | **`twMergeDefaultV4`**} instead.
|
|
370
|
-
* - Reference:
|
|
371
|
-
* [**`Tailwind v4 using prefix docs`**](https://tailwindcss.com/docs/upgrade-guide#using-a-prefix).
|
|
372
|
-
* - **ℹ️ Notes**:
|
|
373
|
-
* - Tailwind v3: use hyphenated prefix (`tw-`).
|
|
374
|
-
* - Fallback order:
|
|
375
|
-
* 1. `prefix` option
|
|
376
|
-
* 2. `config.prefix` (if defined)
|
|
377
|
-
* 3. `undefined`
|
|
378
|
-
* - Tailwind v4:
|
|
379
|
-
* - Use {@link twMergeDefaultV4 | **`twMergeDefaultV4`**} instead.
|
|
380
|
-
* @example
|
|
381
|
-
* - Tailwind version 3 (`tailwind.config.ts`):
|
|
382
|
-
* ```ts
|
|
383
|
-
* import type { Config } from "tailwindcss";
|
|
384
|
-
*
|
|
385
|
-
* const config: Config = {
|
|
386
|
-
* prefix: 'tw-',
|
|
387
|
-
* // ... other config
|
|
388
|
-
* };
|
|
389
|
-
*
|
|
390
|
-
* export default config;
|
|
391
|
-
* ```
|
|
392
|
-
*/
|
|
393
|
-
prefix?: string;
|
|
394
|
-
};
|
|
395
|
-
/** * ***Options type for Tailwind Merge v3 wrapper.*** */
|
|
396
|
-
type OptionsMergeTwClsV3 = Omit<TwMergeConfigExt, "prefix"> & OptionsConfigMergeTwCn;
|
|
397
|
-
/** * ***Tailwind Merge function Version 3 signature (same as twMerge).*** */
|
|
398
|
-
type TwMergeDefaultFnV3 = (...classLists: ClassNameValue$1[]) => string;
|
|
399
|
-
/** -------------------------------------------------------------
|
|
400
|
-
* * ***Factory utility for building a custom `cn` helper (Tailwind `v3`).***
|
|
401
|
-
* -------------------------------------------------------------
|
|
402
|
-
* **Wraps internally function to combines class-name values and applies the provided
|
|
403
|
-
* Tailwind merge function (from {@link twMergeDefaultV3 | `twMergeDefaultV3`}).**
|
|
404
|
-
* - 🔑 **When to use it?**
|
|
405
|
-
* - Your project uses **Tailwind v3**.
|
|
406
|
-
* - You extend Tailwind merge rules (`classGroups`, `tailwind.config`).
|
|
407
|
-
* - You need multiple `cn*` variants across apps/packages.
|
|
408
|
-
* @param {TwMergeDefaultFnV3} customTwMergeV3 - Merge function created via {@link twMergeDefaultV3 | `twMergeDefaultV3`}.
|
|
409
|
-
* @param {ClassValues} classes - Class values (`string`, `array`, `object`, `etc`).
|
|
410
|
-
* @returns {string} Merged Tailwind class string.
|
|
411
|
-
* @example
|
|
412
|
-
* ```ts
|
|
413
|
-
* import tailwindConfig from "../tailwind.config";
|
|
414
|
-
* import { twMergeDefaultV3, customCnV3, type ClassValues } from "@rzl-zone/utils-js/tailwind";
|
|
415
|
-
*
|
|
416
|
-
* // 1. Create a custom merge function
|
|
417
|
-
* const myCustomTwMerge = twMergeDefaultV3({
|
|
418
|
-
* config: tailwindConfig,
|
|
419
|
-
* extend: {
|
|
420
|
-
* classGroups: {
|
|
421
|
-
* "text-shadow": ["text-shadow", "text-shadow-sm", "text-shadow-md"],
|
|
422
|
-
* },
|
|
423
|
-
* },
|
|
424
|
-
* });
|
|
425
|
-
*
|
|
426
|
-
* // 2. Build your helper using `customCnV3`
|
|
427
|
-
* export const cnApp = (...classes: ClassValues) => {
|
|
428
|
-
* return customCnV3(myCustomTwMerge, ...classes);
|
|
429
|
-
* };
|
|
430
|
-
* // ✅ Usage
|
|
431
|
-
* cnApp("p-2", "p-4"); // ➔ "p-4"
|
|
432
|
-
* cnApp("shadow-sm shadow-md"); // ➔ "shadow-md"
|
|
433
|
-
* cnApp("text-base text-xxs"); // ➔ "text-xxs" (resolved from config)
|
|
434
|
-
* ```
|
|
435
|
-
*/
|
|
436
|
-
declare const customCnV3: (customTwMergeV3: TwMergeDefaultFnV3, ...classes: ClassValues) => string;
|
|
437
|
-
/** -------------------------------------------------------------
|
|
438
|
-
* * ***Factory utility for building a custom `cn` helper (Tailwind `v4`).***
|
|
439
|
-
* -------------------------------------------------------------
|
|
440
|
-
* **Wraps internally function to combines class-name values and applies the provided
|
|
441
|
-
* Tailwind merge function (from {@link twMergeDefaultV4 | `twMergeDefaultV4`}).**
|
|
442
|
-
* - 🔑 **When to use it?**
|
|
443
|
-
* - Your project uses **Tailwind v4**.
|
|
444
|
-
* - You extend Tailwind merge rules (`classGroups`, `tailwind.config`).
|
|
445
|
-
* - You need multiple `cn*` variants across apps/packages.
|
|
446
|
-
* @param {TwMergeDefaultFnV4} customTwMergeV4 - Merge function created via {@link twMergeDefaultV4 | `twMergeDefaultV4`}.
|
|
447
|
-
* @param {ClassValues} classes - Class values (`string`, `array`, `object`, `etc`).
|
|
448
|
-
* @returns {string} Merged Tailwind class string.
|
|
449
|
-
* @example
|
|
450
|
-
* ```ts
|
|
451
|
-
* import tailwindConfig from "../tailwind.config";
|
|
452
|
-
* import { twMergeDefaultV4, customCnV4, type ClassValues } from "@rzl-zone/utils-js/tailwind";
|
|
453
|
-
*
|
|
454
|
-
* // 1. Create a custom merge function
|
|
455
|
-
* const myCustomTwMerge = twMergeDefaultV4({
|
|
456
|
-
* config: tailwindConfig,
|
|
457
|
-
* extend: {
|
|
458
|
-
* classGroups: {
|
|
459
|
-
* "text-shadow": ["text-shadow", "text-shadow-sm", "text-shadow-md"],
|
|
460
|
-
* },
|
|
461
|
-
* },
|
|
462
|
-
* });
|
|
463
|
-
*
|
|
464
|
-
* // 2. Build your helper using `customCnV4`
|
|
465
|
-
* export const cnApp = (...classes: ClassValues) => {
|
|
466
|
-
* return customCnV4(myCustomTwMerge, ...classes);
|
|
467
|
-
* };
|
|
468
|
-
*
|
|
469
|
-
* // ✅ Usage
|
|
470
|
-
* cnApp("p-2", "p-4"); // ➔ "p-4"
|
|
471
|
-
* cnApp("shadow-sm shadow-md"); // ➔ "shadow-md"
|
|
472
|
-
* cnApp("text-base text-xxs"); // ➔ "text-xxs" (resolved from config)
|
|
473
|
-
* ```
|
|
474
|
-
*/
|
|
475
|
-
declare const customCnV4: (customTwMergeV4: TwMergeDefaultFnV4, ...classes: ClassValues) => string;
|
|
476
|
-
/** ----------------------------------------------------------
|
|
477
|
-
* * ***Utility: `shouldForwardProp`.***
|
|
478
|
-
* ----------------------------------------------------------
|
|
479
|
-
* **Creates a helper for styled-components `shouldForwardProp`.**
|
|
480
|
-
*
|
|
481
|
-
* @description
|
|
482
|
-
* 1. Returns a **predicate function** that determines whether a given prop
|
|
483
|
-
* should be forwarded to the DOM.
|
|
484
|
-
* 2. Useful for filtering out internal props (e.g., `$size`, `$active`)
|
|
485
|
-
* so they don't become invalid HTML attributes.
|
|
486
|
-
*
|
|
487
|
-
* - **Behavior:**
|
|
488
|
-
* - Accepts a strict tuple of **string keys** to exclude from forwarding.
|
|
489
|
-
* - Every key is validated as a **non-empty string** at runtime.
|
|
490
|
-
* - Throws a `TypeError` if:
|
|
491
|
-
* - `props` is not an array, or
|
|
492
|
-
* - any item is not a non-empty string.
|
|
493
|
-
* - Automatically coerces the tested prop name to string for matching.
|
|
494
|
-
*
|
|
495
|
-
* @template CustomProps
|
|
496
|
-
* The component props type to validate against.
|
|
497
|
-
*
|
|
498
|
-
* @param {readonly Stringify<keyof CustomProps>[]}
|
|
499
|
-
* props
|
|
500
|
-
* The list of prop names (keys of `CustomProps`) to exclude from forwarding.
|
|
501
|
-
*
|
|
502
|
-
* @returns {(propName: keyof CustomProps | ({} & string)) => boolean}
|
|
503
|
-
* A function that receives a prop name and returns:
|
|
504
|
-
* - `true` ➔ the prop **will** be forwarded to the DOM.
|
|
505
|
-
* - `false` ➔ the prop **will not** be forwarded.
|
|
506
|
-
*
|
|
507
|
-
* @throws **{@link TypeError | `TypeError`}**
|
|
508
|
-
* when:
|
|
509
|
-
* - `props` is not an array, or
|
|
510
|
-
* - any item is not a non-empty string.
|
|
511
|
-
*
|
|
512
|
-
* @example
|
|
513
|
-
* // Basic usage
|
|
514
|
-
* type Props = { $size: string; color: string; visible: boolean };
|
|
515
|
-
* const filter = shouldForwardProp<Props>(["$size"]);
|
|
516
|
-
*
|
|
517
|
-
* filter("$size"); // ➔ false (blocked).
|
|
518
|
-
* filter("color"); // ➔ true (forwarded).
|
|
519
|
-
* filter("visible"); // ➔ true (forwarded).
|
|
520
|
-
*
|
|
521
|
-
* @example
|
|
522
|
-
* // With styled-components
|
|
523
|
-
* type CustomProps = { $internal: boolean; public: string; another: boolean };
|
|
524
|
-
*
|
|
525
|
-
* styled.div.withConfig({
|
|
526
|
-
* shouldForwardProp: shouldForwardProp<CustomProps>(["$internal"])
|
|
527
|
-
* });
|
|
528
|
-
*/
|
|
529
|
-
declare const shouldForwardProp: <CustomProps extends Record<string, unknown>>(props: readonly Stringify<keyof CustomProps>[]) => ((propName: keyof CustomProps | ({} & string)) => boolean);
|
|
530
|
-
/** -------------------------------------------------------------
|
|
531
|
-
* * ***Customized Tailwind class merger Version 3 with extended rules.***
|
|
532
|
-
* -------------------------------------------------------------
|
|
533
|
-
* **Wraps ***`extendTailwindMerge` from tailwind-merge-v3*** with Tailwind’s default
|
|
534
|
-
* config (_*`getDefaultConfig()` from tailwind-merge-v3*_) to create a **project-ready `twMerge`**.**
|
|
535
|
-
* - 🔑 **When to use it?**
|
|
536
|
-
* - Your project uses **Tailwind v3**.
|
|
537
|
-
* - Extend **class groups** (e.g. add `text-shadow`).
|
|
538
|
-
* - Respect your own **`tailwind.config.ts`** (colors, spacing, fontSize, etc).
|
|
539
|
-
* - Override or fine-tune **merge behavior**.
|
|
540
|
-
* - Create a **project-wide `cn` helper** that replaces raw `twMerge`.
|
|
541
|
-
* @param {OptionsMergeTwClsV3} [options={}]
|
|
542
|
-
* ***Merge options:***
|
|
543
|
-
* - `config` – Your Tailwind config (from `tailwind.config.ts`).
|
|
544
|
-
* - `prefix` - Utility prefix (e.g. `tw-` or `tw`).
|
|
545
|
-
* - `extend` – Extra merge rules (classGroups, theme, etc).
|
|
546
|
-
* - `override` – Fully replace rules.
|
|
547
|
-
* - `cacheSize` – Parsed class cache size.
|
|
548
|
-
* - `experimentalParseClassName` – Custom classname parser.
|
|
549
|
-
* @returns {TwMergeDefaultFnV3}
|
|
550
|
-
* Customized Tailwind class merge function version 3 (same signature as `twMerge`).
|
|
551
|
-
* @example
|
|
552
|
-
* #### Example 1: ***Default behavior (same as tailwind-merge).***
|
|
553
|
-
* ```ts
|
|
554
|
-
* import { twMergeDefaultV3 } from "@rzl-zone/utils-js/tailwind";
|
|
555
|
-
*
|
|
556
|
-
* const twMerge = twMergeDefaultV3();
|
|
557
|
-
* twMerge("p-2 p-4");
|
|
558
|
-
* // ➔ "p-4"
|
|
559
|
-
* ```
|
|
560
|
-
* #### Example 2: ***Extend class groups.***
|
|
561
|
-
* ```ts
|
|
562
|
-
* import { twMergeDefaultV3 } from "@rzl-zone/utils-js/tailwind";
|
|
563
|
-
*
|
|
564
|
-
* const twMerge2 = twMergeDefaultV3({
|
|
565
|
-
* extend: {
|
|
566
|
-
* classGroups: {
|
|
567
|
-
* shadow: ["shadow-soft", "shadow-hard"],
|
|
568
|
-
* },
|
|
569
|
-
* },
|
|
570
|
-
* });
|
|
571
|
-
* twMerge2("shadow-soft shadow-hard");
|
|
572
|
-
* // ➔ "shadow-hard"
|
|
573
|
-
* ```
|
|
574
|
-
* #### Example 3: ***Respect your Tailwind config.***
|
|
575
|
-
* ```ts
|
|
576
|
-
* import config from "../tailwind.config";
|
|
577
|
-
* import { twMergeDefaultV3 } from "@rzl-zone/utils-js/tailwind";
|
|
578
|
-
*
|
|
579
|
-
* const twMerge3 = twMergeDefaultV3({ config });
|
|
580
|
-
* twMerge3("text-base text-xxs");
|
|
581
|
-
* // ➔ "text-xxs" (resolved from config)
|
|
582
|
-
* ```
|
|
583
|
-
* #### Example 4: ***Project-wide helper (recommended).***
|
|
584
|
-
* ```ts
|
|
585
|
-
* import configTwCss from "../tailwind.config";
|
|
586
|
-
* import { customCnV3, twMergeDefaultV3, type ClassValues } from "@rzl-zone/utils-js/tailwind";
|
|
587
|
-
*
|
|
588
|
-
* const customTwMerge = twMergeDefaultV3({
|
|
589
|
-
* config: configTwCss,
|
|
590
|
-
* extend: {
|
|
591
|
-
* classGroups: { shadow: ["shadow-soft", "shadow-hard"] },
|
|
592
|
-
* },
|
|
593
|
-
* });
|
|
594
|
-
*
|
|
595
|
-
* export const cnApp = (...classes: ClassValues) => {
|
|
596
|
-
* return customCnV3(customTwMerge, ...classes);
|
|
597
|
-
* };
|
|
598
|
-
*
|
|
599
|
-
* // ✅ Usage
|
|
600
|
-
* cnApp("p-2 p-4"); // ➔ "p-4"
|
|
601
|
-
* cnApp("shadow-soft shadow-hard"); // ➔ "shadow-hard"
|
|
602
|
-
* cnApp("text-base text-xxs"); // ➔ "text-xxs" (uses config)
|
|
603
|
-
*
|
|
604
|
-
* // ⚡ Difference with package-level `cn`
|
|
605
|
-
* import { cnV3, cnV4 } from "@rzl-zone/utils-js/tailwind";
|
|
606
|
-
*
|
|
607
|
-
* cnV3("text-base text-xxs");
|
|
608
|
-
* // or
|
|
609
|
-
* cnV4("text-base text-xxs");
|
|
610
|
-
* // ➔ "text-base" (❌ doesn't know about your config)
|
|
611
|
-
*
|
|
612
|
-
* cnApp("text-base text-xxs");
|
|
613
|
-
* // ➔ "text-xxs" (✅ respects config)
|
|
614
|
-
* ```
|
|
615
|
-
*/
|
|
616
|
-
declare const twMergeDefaultV3: (options?: OptionsMergeTwClsV3) => TwMergeDefaultFnV3;
|
|
617
|
-
/** -------------------------------------------------------------
|
|
618
|
-
* * ***Customized Tailwind class merger Version 4 with extended rules.***
|
|
619
|
-
* -------------------------------------------------------------
|
|
620
|
-
* **Wraps ***`extendTailwindMerge` from tailwind-merge-v4*** with Tailwind’s default
|
|
621
|
-
* config (_*`getDefaultConfig()` from tailwind-merge-v4*_) to create a **project-ready `twMerge`**.**
|
|
622
|
-
* - 🔑 **When to use it?**
|
|
623
|
-
* - Your project uses **Tailwind v4**.
|
|
624
|
-
* - Extend **class groups** (e.g. add `text-shadow`).
|
|
625
|
-
* - Respect your own **`tailwind.config.ts`** (colors, spacing, fontSize, etc).
|
|
626
|
-
* - Override or fine-tune **merge behavior**.
|
|
627
|
-
* - Create a **project-wide `cn` helper** that replaces raw `twMerge`.
|
|
628
|
-
* @param {OptionsMergeTwClsV4} [options={}]
|
|
629
|
-
* ***Merge options:***
|
|
630
|
-
* - `config` – Your Tailwind config (from `tailwind.config.ts`).
|
|
631
|
-
* - `prefix` - Utility prefix (e.g. `tw-` or `tw`).
|
|
632
|
-
* - `extend` – Extra merge rules (classGroups, theme, etc).
|
|
633
|
-
* - `override` – Fully replace rules.
|
|
634
|
-
* - `cacheSize` – Parsed class cache size.
|
|
635
|
-
* - `experimentalParseClassName` – Custom classname parser.
|
|
636
|
-
* @returns {TwMergeDefaultFnV4}
|
|
637
|
-
* Customized Tailwind class merge function version 4 (same signature as `twMerge`).
|
|
638
|
-
* @example
|
|
639
|
-
* #### Example 1: ***Default behavior (same as tailwind-merge).***
|
|
640
|
-
* ```ts
|
|
641
|
-
* import { twMergeDefaultV4 } from "@rzl-zone/utils-js/tailwind";
|
|
642
|
-
*
|
|
643
|
-
* const twMerge = twMergeDefaultV4();
|
|
644
|
-
* twMerge("p-2 p-4");
|
|
645
|
-
* // ➔ "p-4"
|
|
646
|
-
* ```
|
|
647
|
-
* #### Example 2: ***Extend class groups.***
|
|
648
|
-
* ```ts
|
|
649
|
-
* import { twMergeDefaultV4 } from "@rzl-zone/utils-js/tailwind";
|
|
650
|
-
*
|
|
651
|
-
* const twMerge2 = twMergeDefaultV4({
|
|
652
|
-
* extend: {
|
|
653
|
-
* classGroups: {
|
|
654
|
-
* shadow: ["shadow-soft", "shadow-hard"],
|
|
655
|
-
* },
|
|
656
|
-
* },
|
|
657
|
-
* });
|
|
658
|
-
* twMerge2("shadow-soft shadow-hard");
|
|
659
|
-
* // ➔ "shadow-hard"
|
|
660
|
-
* ```
|
|
661
|
-
* #### Example 3: ***Respect your Tailwind config.***
|
|
662
|
-
* ```ts
|
|
663
|
-
* import config from "../tailwind.config";
|
|
664
|
-
* import { twMergeDefaultV4 } from "@rzl-zone/utils-js/tailwind";
|
|
665
|
-
*
|
|
666
|
-
* const twMerge3 = twMergeDefaultV4({ config });
|
|
667
|
-
* twMerge3("text-base text-xxs");
|
|
668
|
-
* // ➔ "text-xxs" (resolved from config)
|
|
669
|
-
* ```
|
|
670
|
-
* #### Example 4: ***Project-wide helper (recommended).***
|
|
671
|
-
* ```ts
|
|
672
|
-
* import configTwCss from "../tailwind.config";
|
|
673
|
-
* import { customCnV4, twMergeDefaultV4, type ClassValues } from "@rzl-zone/utils-js/tailwind";
|
|
674
|
-
*
|
|
675
|
-
* const customTwMerge = twMergeDefaultV4({
|
|
676
|
-
* config: configTwCss,
|
|
677
|
-
* extend: {
|
|
678
|
-
* classGroups: { shadow: ["shadow-soft", "shadow-hard"] },
|
|
679
|
-
* },
|
|
680
|
-
* });
|
|
681
|
-
*
|
|
682
|
-
* export const cnApp = (...classes: ClassValues) => {
|
|
683
|
-
* return customCnV4(customTwMerge, ...classes);
|
|
684
|
-
* };
|
|
685
|
-
*
|
|
686
|
-
* // ✅ Usage
|
|
687
|
-
* cnApp("p-2 p-4"); // ➔ "p-4"
|
|
688
|
-
* cnApp("shadow-soft shadow-hard"); // ➔ "shadow-hard"
|
|
689
|
-
* cnApp("text-base text-xxs"); // ➔ "text-xxs" (uses config)
|
|
690
|
-
*
|
|
691
|
-
* // ⚡ Difference with package-level `cn`
|
|
692
|
-
* import { cnV3, cnV4 } from "@rzl-zone/utils-js/tailwind";
|
|
693
|
-
*
|
|
694
|
-
* cnV3("text-base text-xxs");
|
|
695
|
-
* // or
|
|
696
|
-
* cnV4("text-base text-xxs");
|
|
697
|
-
* // ➔ "text-base" (❌ doesn't know about your config)
|
|
698
|
-
*
|
|
699
|
-
* cnApp("text-base text-xxs");
|
|
700
|
-
* // ➔ "text-xxs" (✅ respects config)
|
|
701
|
-
* ```
|
|
702
|
-
*/
|
|
703
|
-
declare const twMergeDefaultV4: (options?: OptionsMergeTwClsV4) => TwMergeDefaultFnV4;
|
|
704
|
-
export { customCnV4 as a, ClassObject as c, cx as d, customCnV3 as i, ClassValue as l, twMergeDefaultV3 as n, cnV3 as o, shouldForwardProp as r, cnV4 as s, twMergeDefaultV4 as t, ClassValues as u };
|