@fuf-stack/pixel-utils 1.4.0 → 1.5.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/dist/index.d.mts +16 -42
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +5 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ArgumentArray } from "classnames";
|
|
2
2
|
import { Options } from "slug";
|
|
3
|
-
//#region src/cn.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* A utility function that combines `classnames` and `tailwind-merge`.
|
|
6
5
|
*
|
|
@@ -16,9 +15,7 @@ import { Options } from "slug";
|
|
|
16
15
|
* // Output: 'text-center bg-red-500 p-4'
|
|
17
16
|
* ```
|
|
18
17
|
*/
|
|
19
|
-
declare const cn: (...classes: ArgumentArray) => string;
|
|
20
|
-
//#endregion
|
|
21
|
-
//#region src/isTestEnvironment.d.ts
|
|
18
|
+
export declare const cn: (...classes: ArgumentArray) => string;
|
|
22
19
|
/**
|
|
23
20
|
* Checks if the code is running in a test environment.
|
|
24
21
|
*
|
|
@@ -41,9 +38,7 @@ declare const cn: (...classes: ArgumentArray) => string;
|
|
|
41
38
|
* return debouncedValue;
|
|
42
39
|
* ```
|
|
43
40
|
*/
|
|
44
|
-
declare const isTestEnvironment: () => boolean;
|
|
45
|
-
//#endregion
|
|
46
|
-
//#region ../../node_modules/.pnpm/tailwind-merge@3.6.0/node_modules/tailwind-merge/dist/types.d.ts
|
|
41
|
+
export declare const isTestEnvironment: () => boolean;
|
|
47
42
|
/**
|
|
48
43
|
* The code in this file is copied from https://github.com/lukeed/clsx and modified to suit the needs of tailwind-merge better.
|
|
49
44
|
*
|
|
@@ -210,6 +205,10 @@ type ClassValidator = (classPart: string) => boolean;
|
|
|
210
205
|
interface ThemeGetter {
|
|
211
206
|
(theme: ThemeObject<AnyThemeGroupIds>): ClassGroup<AnyClassGroupIds>;
|
|
212
207
|
isThemeGetter: true;
|
|
208
|
+
/**
|
|
209
|
+
* The theme key the getter reads. Set on getters created with `fromTheme` so that tooling (e.g. config generators) can identify the referenced theme scale without invoking the getter. Optional because theme getters can be hand-written.
|
|
210
|
+
*/
|
|
211
|
+
themeKey?: string;
|
|
213
212
|
}
|
|
214
213
|
type ClassObject<ThemeGroupIds extends string> = Record<string, readonly ClassDefinition<ThemeGroupIds>[]>;
|
|
215
214
|
/**
|
|
@@ -230,7 +229,7 @@ type NoInferString<T extends string> = T extends (infer S) ? S & string : never;
|
|
|
230
229
|
* If you want to use a scale that is not supported in the `ThemeObject` type,
|
|
231
230
|
* consider using `classGroups` instead of `theme`.
|
|
232
231
|
*
|
|
233
|
-
* @see https://github.com/dcastil/tailwind-merge/blob/
|
|
232
|
+
* @see https://github.com/dcastil/tailwind-merge/blob/tailwind-merge@3.7.0/packages/tailwind-merge/docs/configuration.md#theme
|
|
234
233
|
* (the list of supported keys may vary between `tailwind-merge` versions)
|
|
235
234
|
*/
|
|
236
235
|
type DefaultThemeGroupIds = 'animate' | 'aspect' | 'blur' | 'breakpoint' | 'color' | 'container' | 'drop-shadow' | 'ease' | 'font-weight' | 'font' | 'inset-shadow' | 'leading' | 'perspective' | 'radius' | 'shadow' | 'spacing' | 'text' | 'text-shadow' | 'tracking';
|
|
@@ -246,25 +245,19 @@ type AnyThemeGroupIds = string;
|
|
|
246
245
|
type AnyConfig = Config$1<AnyClassGroupIds, AnyThemeGroupIds>;
|
|
247
246
|
type CreateConfigSubsequent = (config: AnyConfig) => AnyConfig;
|
|
248
247
|
declare const extendTailwindMerge: <AdditionalClassGroupIds extends string = never, AdditionalThemeGroupIds extends string = never>(configExtension: ConfigExtension<DefaultClassGroupIds | AdditionalClassGroupIds, DefaultThemeGroupIds | AdditionalThemeGroupIds> | CreateConfigSubsequent, ...createConfig: CreateConfigSubsequent[]) => (...classLists: ClassNameValue[]) => string;
|
|
249
|
-
//#endregion
|
|
250
|
-
//#region src/proseTwMerge.d.ts
|
|
251
248
|
type ProseClassGroupIds = 'prose-size' | 'prose-color';
|
|
252
|
-
declare const proseTwMergeClassGroups: NonNullable<NonNullable<ConfigExtension<ProseClassGroupIds, never>['extend']>['classGroups']>;
|
|
249
|
+
export declare const proseTwMergeClassGroups: NonNullable<NonNullable<ConfigExtension<ProseClassGroupIds, never>['extend']>['classGroups']>;
|
|
253
250
|
/**
|
|
254
251
|
* Prose-aware `tailwind-merge` instance that deduplicates `prose-*` classes.
|
|
255
252
|
* Used by `cn(...)` internally. Also exported for direct use in components
|
|
256
253
|
* that need prose-aware class merging outside of `cn`.
|
|
257
254
|
*/
|
|
258
|
-
declare const proseTwMerge: (...classLists: ClassNameValue[]) => string;
|
|
259
|
-
//#endregion
|
|
260
|
-
//#region src/slugify.d.ts
|
|
255
|
+
export declare const proseTwMerge: (...classLists: ClassNameValue[]) => string;
|
|
261
256
|
interface SlugifyOptions extends Options {
|
|
262
257
|
/** When true, dots are also replaced (default is false) */
|
|
263
258
|
replaceDots?: boolean;
|
|
264
259
|
}
|
|
265
|
-
declare const slugify: (string: string, options?: SlugifyOptions) => string;
|
|
266
|
-
//#endregion
|
|
267
|
-
//#region ../../node_modules/.pnpm/tailwind-variants@3.2.2_tailwind-merge@3.6.0_tailwindcss@4.3.2/node_modules/tailwind-variants/dist/config.d.ts
|
|
260
|
+
export declare const slugify: (string: string, options?: SlugifyOptions) => string;
|
|
268
261
|
type MergeConfig = Parameters<typeof extendTailwindMerge>[0];
|
|
269
262
|
type LegacyMergeConfig = Extract<MergeConfig, {
|
|
270
263
|
extend?: unknown;
|
|
@@ -285,8 +278,6 @@ type TWMConfig = {
|
|
|
285
278
|
twMergeConfig?: TWMergeConfig;
|
|
286
279
|
};
|
|
287
280
|
type TVConfig = TWMConfig;
|
|
288
|
-
//#endregion
|
|
289
|
-
//#region ../../node_modules/.pnpm/tailwind-variants@3.2.2_tailwind-merge@3.6.0_tailwindcss@4.3.2/node_modules/tailwind-variants/dist/types.d.ts
|
|
290
281
|
type ClassProp<V extends unknown = ClassNameValue> = {
|
|
291
282
|
class?: V;
|
|
292
283
|
className?: never;
|
|
@@ -392,8 +383,6 @@ type TV = {
|
|
|
392
383
|
config?: TVConfig): TVReturnType<V, S, B, EV, ES, E>;
|
|
393
384
|
};
|
|
394
385
|
type VariantProps<Component extends (...args: any) => any> = Omit<OmitUndefined<Parameters<Component>[0]>, "class" | "className">;
|
|
395
|
-
//#endregion
|
|
396
|
-
//#region ../../node_modules/.pnpm/@heroui+theme@2.4.26_tailwindcss@4.3.2/node_modules/@heroui/theme/dist/colors/types.d.ts
|
|
397
386
|
type ColorScale = Partial<{
|
|
398
387
|
50: string;
|
|
399
388
|
100: string;
|
|
@@ -427,8 +416,6 @@ type ThemeColors = BaseColors & {
|
|
|
427
416
|
warning: ColorScale;
|
|
428
417
|
danger: ColorScale;
|
|
429
418
|
};
|
|
430
|
-
//#endregion
|
|
431
|
-
//#region ../../node_modules/.pnpm/@heroui+theme@2.4.26_tailwindcss@4.3.2/node_modules/@heroui/theme/dist/types.d.ts
|
|
432
419
|
type DefaultThemeType = "light" | "dark";
|
|
433
420
|
type BaseThemeUnit = {
|
|
434
421
|
small?: string;
|
|
@@ -563,8 +550,6 @@ type HeroUIPluginConfig = {
|
|
|
563
550
|
*/
|
|
564
551
|
defaultExtendTheme?: DefaultThemeType;
|
|
565
552
|
};
|
|
566
|
-
//#endregion
|
|
567
|
-
//#region ../../node_modules/.pnpm/tailwindcss@4.3.2/node_modules/tailwindcss/dist/colors.d.mts
|
|
568
553
|
declare const _default: {
|
|
569
554
|
inherit: string;
|
|
570
555
|
current: string;
|
|
@@ -910,8 +895,6 @@ declare const _default: {
|
|
|
910
895
|
'950': string;
|
|
911
896
|
};
|
|
912
897
|
};
|
|
913
|
-
//#endregion
|
|
914
|
-
//#region ../../node_modules/.pnpm/tailwindcss@4.3.2/node_modules/tailwindcss/dist/resolve-config-QUZ9b-Gn.d.mts
|
|
915
898
|
type NamedUtilityValue = {
|
|
916
899
|
kind: 'named';
|
|
917
900
|
/**
|
|
@@ -936,8 +919,6 @@ type PluginUtils = {
|
|
|
936
919
|
theme: (keypath: string, defaultValue?: any) => any;
|
|
937
920
|
colors: typeof _default;
|
|
938
921
|
};
|
|
939
|
-
//#endregion
|
|
940
|
-
//#region ../../node_modules/.pnpm/tailwindcss@4.3.2/node_modules/tailwindcss/dist/types-DWdTiksJ.d.mts
|
|
941
922
|
/**
|
|
942
923
|
* The source code for one or more nodes in the AST
|
|
943
924
|
*
|
|
@@ -1060,26 +1041,20 @@ interface UserConfig {
|
|
|
1060
1041
|
interface UserConfig {
|
|
1061
1042
|
experimental?: 'all' | Record<string, boolean>;
|
|
1062
1043
|
}
|
|
1063
|
-
//#endregion
|
|
1064
|
-
//#region ../../node_modules/.pnpm/tailwindcss@4.3.2/node_modules/tailwindcss/dist/plugin.d.mts
|
|
1065
1044
|
declare function createPlugin(handler: PluginFn, config?: Partial<Config>): PluginWithConfig;
|
|
1066
1045
|
declare namespace createPlugin {
|
|
1067
1046
|
var withOptions: <T>(pluginFunction: (options?: T) => PluginFn, configFunction?: (options?: T) => Partial<Config>) => PluginWithOptions<T>;
|
|
1068
1047
|
}
|
|
1069
|
-
//#endregion
|
|
1070
|
-
//#region ../../node_modules/.pnpm/@heroui+theme@2.4.26_tailwindcss@4.3.2/node_modules/@heroui/theme/dist/plugin.d.ts
|
|
1071
1048
|
/**
|
|
1072
1049
|
* Based on tw-colors by L-Blondy
|
|
1073
1050
|
* @see https://github.com/L-Blondy/tw-colors
|
|
1074
1051
|
*/
|
|
1075
1052
|
declare const heroui: (config?: HeroUIPluginConfig) => ReturnType<typeof createPlugin>;
|
|
1076
|
-
//#endregion
|
|
1077
|
-
//#region src/tv.d.ts
|
|
1078
1053
|
/**
|
|
1079
1054
|
* Represents a class value which can be either a string or an array of strings
|
|
1080
1055
|
* Used for handling both single class names and multiple class names
|
|
1081
1056
|
*/
|
|
1082
|
-
type ClassValue = string | string[];
|
|
1057
|
+
export type ClassValue = string | string[];
|
|
1083
1058
|
/**
|
|
1084
1059
|
* Props accepted by tailwind-variants slot functions
|
|
1085
1060
|
* Combines a dynamic record of string/number values with the ClassProp from tailwind-variants
|
|
@@ -1102,17 +1077,17 @@ type TVRecord = Record<string, TVFunction>;
|
|
|
1102
1077
|
* Re-export of tailwind-variants tv function
|
|
1103
1078
|
* Used to create variant definitions with slots and variants
|
|
1104
1079
|
*/
|
|
1105
|
-
declare const tv: TV;
|
|
1080
|
+
export declare const tv: TV;
|
|
1106
1081
|
/**
|
|
1107
1082
|
* Extracts variant props from a tailwind-variants component
|
|
1108
1083
|
* Used for typing component props that use variants
|
|
1109
1084
|
*/
|
|
1110
|
-
type TVProps<Component extends (...args: any) => any> = VariantProps<Component>;
|
|
1085
|
+
export type TVProps<Component extends (...args: any) => any> = VariantProps<Component>;
|
|
1111
1086
|
/**
|
|
1112
1087
|
* Extracts className type from a tailwind-variants component
|
|
1113
1088
|
* Can be either a partial record of slot names to class values, or a single class value
|
|
1114
1089
|
*/
|
|
1115
|
-
type TVClassName<Component extends (...args: any) => any> = Partial<Record<keyof ReturnType<Component>, ClassValue>> | ClassValue;
|
|
1090
|
+
export type TVClassName<Component extends (...args: any) => any> = Partial<Record<keyof ReturnType<Component>, ClassValue>> | ClassValue;
|
|
1116
1091
|
/**
|
|
1117
1092
|
* Converts tailwind-variants slots instance to actual classnames object
|
|
1118
1093
|
*
|
|
@@ -1138,7 +1113,6 @@ type TVClassName<Component extends (...args: any) => any> = Partial<Record<keyof
|
|
|
1138
1113
|
* // Result: { base: 'bg-white', content: 'p-4 text-gray-700' }
|
|
1139
1114
|
* ```
|
|
1140
1115
|
*/
|
|
1141
|
-
declare const variantsToClassNames: <T extends TVRecord>(variants: T, className?: ClassValue | Record<string, ClassValue>, baseSlot?: keyof T) => Record<keyof T, string>;
|
|
1142
|
-
|
|
1143
|
-
export { ClassValue, TVClassName, TVProps, cn, heroui, isTestEnvironment, proseTwMerge, proseTwMergeClassGroups, slugify, tv, variantsToClassNames };
|
|
1116
|
+
export declare const variantsToClassNames: <T extends TVRecord>(variants: T, className?: ClassValue | Record<string, ClassValue>, baseSlot?: keyof T) => Record<keyof T, string>;
|
|
1117
|
+
export { heroui };
|
|
1144
1118
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/cn.ts","../src/isTestEnvironment.ts","../../../node_modules/.pnpm/tailwind-merge@3.
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":["Config","_$tailwind_merge0.ClassNameValue","SlugOptions","ClassValue","TVProps","plugin"],"sources":["../src/cn.ts","../src/isTestEnvironment.ts","../../../node_modules/.pnpm/tailwind-merge@3.7.0/node_modules/tailwind-merge/dist/types.d.ts","../src/proseTwMerge.ts","../src/slugify.ts","../../../node_modules/.pnpm/tailwind-variants@3.2.2_tailwind-merge@3.7.0_tailwindcss@4.3.4/node_modules/tailwind-variants/dist/config.d.ts","../../../node_modules/.pnpm/tailwind-variants@3.2.2_tailwind-merge@3.7.0_tailwindcss@4.3.4/node_modules/tailwind-variants/dist/types.d.ts","../../../node_modules/.pnpm/@heroui+theme@2.4.26_tailwindcss@4.3.4/node_modules/@heroui/theme/dist/colors/types.d.ts","../../../node_modules/.pnpm/@heroui+theme@2.4.26_tailwindcss@4.3.4/node_modules/@heroui/theme/dist/types.d.ts","../../../node_modules/.pnpm/tailwindcss@4.3.4/node_modules/tailwindcss/dist/colors.d.mts","../../../node_modules/.pnpm/tailwindcss@4.3.4/node_modules/tailwindcss/dist/resolve-config-QUZ9b-Gn.d.mts","../../../node_modules/.pnpm/tailwindcss@4.3.4/node_modules/tailwindcss/dist/types-DWdTiksJ.d.mts","../../../node_modules/.pnpm/tailwindcss@4.3.4/node_modules/tailwindcss/dist/plugin.d.mts","../../../node_modules/.pnpm/@heroui+theme@2.4.26_tailwindcss@4.3.4/node_modules/@heroui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;;;;;;;;;;EAYb,SAAS;;;;;;;;EAQT;;;;;;;;EAQA;;;;;;;EAOA;;;;;;;;;;;EAWA,cAAc;;;;;;;;;;;EAWd,YAAY;;KAEX;EACD;EACA,SAAS;EACT,SAAS,QAAQ;;KAEhB,eAAe,eAAe;;;;;KAK9B;;;;;EAKD;;;;;EAKA;;;;EAIA,SAAS;;;;EAIT,SAAS;;;;;EAKT,eAAe;;;;;EAKf,qBAAqB;;cCtIX;EACV;EACA;EACA;EACA;EACA;EACA;IACI;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;;EAEJ;IACI;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;;EAEJ;IACI;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;;EAEJ;IACI;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;;EAEJ;IACI;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;;EAEJ;IACI;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;;EAEJ;IACI;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;;EAEJ;IACI;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;;EAEJ;IACI;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;;EAEJ;IACI;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;;EAEJ;IACI;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;;EAEJ;IACI;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;;EAEJ;IACI;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;;EAEJ;IACI;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;;EAEJ;IACI;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;;EAEJ;IACI;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;;EAEJ;IACI;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;;EAEJ;IACI;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;;EAEJ;IACI;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;;EAEJ;IACI;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;;EAEJ;IACI;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;;EAEJ;IACI;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;;EAEJ;IACI;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;;EAEJ;IACI;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;;EAEJ;IACI;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;;EAEJ;IACI;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;;;KC1TH;EACD;;;;;;;;;;EAUA;;;;;;;EAOA;;KA0IC;EACD,QAAQ,iBAAiB;EACzB,eAAe;;;;;;;UCnLT;;;;;;EAMN;;;;EAIA;;;;;;;;;KASC,kBAAkB,QAAQ,QAAQ,eAAe;KAEjD,SAAS;KACT,YAAY,KAAK;KACjB;EACD,SAAS;EACT,SAAS;;EAET;EACA,MAAM;;KAEL,kBAAkB;GAClB,UAAU,IAAI;EACf;;KAEC,SAAS,WAAW,mBAAmB;KACvC;EACD,QAAQ,MAAM;EACd,WAAW,cAAc,6BAA6B;EACtD,aAAa,YAAY,cAAc,KAAK,OAAO,YAAY;IAC3D;2BACqB;IACrB,SAAS,eAAe;IACxB,MAAM;MACF,OAAO;MACP;OACD;MACC,OAAO;MACP;;;EAGR,aAAa,WAAW,eAAe,UAAU,aAAa,eAAe,UAAU,cAAc;EACrG,eAAe,WAAW,gBAAgB,eA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|
import slug from "slug";
|
|
4
4
|
import { heroui } from "@heroui/theme";
|
|
5
5
|
import { tv as tv$1 } from "tailwind-variants";
|
|
6
|
-
|
|
6
|
+
// src/proseTwMerge.ts
|
|
7
7
|
/**
|
|
8
8
|
* Typography plugin size classes are standalone tokens like `prose-sm`
|
|
9
9
|
* instead of regular utilities, so we register them as a custom merge group.
|
|
@@ -28,8 +28,7 @@ const proseTwMergeClassGroups = {
|
|
|
28
28
|
* that need prose-aware class merging outside of `cn`.
|
|
29
29
|
*/
|
|
30
30
|
const proseTwMerge = extendTailwindMerge({ extend: { classGroups: proseTwMergeClassGroups } });
|
|
31
|
-
|
|
32
|
-
//#region src/cn.ts
|
|
31
|
+
// src/cn.ts
|
|
33
32
|
/**
|
|
34
33
|
* A utility function that combines `classnames` and `tailwind-merge`.
|
|
35
34
|
*
|
|
@@ -48,8 +47,7 @@ const proseTwMerge = extendTailwindMerge({ extend: { classGroups: proseTwMergeCl
|
|
|
48
47
|
const cn = (...classes) => {
|
|
49
48
|
return proseTwMerge(classNames(...classes));
|
|
50
49
|
};
|
|
51
|
-
|
|
52
|
-
//#region src/isTestEnvironment.ts
|
|
50
|
+
// src/isTestEnvironment.ts
|
|
53
51
|
/**
|
|
54
52
|
* Checks if the code is running in a test environment.
|
|
55
53
|
*
|
|
@@ -75,8 +73,7 @@ const cn = (...classes) => {
|
|
|
75
73
|
const isTestEnvironment = () => {
|
|
76
74
|
return typeof process !== "undefined" && (process.env.NODE_ENV === "test" || process.env.VITEST === "true");
|
|
77
75
|
};
|
|
78
|
-
|
|
79
|
-
//#region src/slugify.ts
|
|
76
|
+
// src/slugify.ts
|
|
80
77
|
const slugify = (string, options) => {
|
|
81
78
|
const replacement = options?.replacement ?? "_";
|
|
82
79
|
const replaceDots = options?.replaceDots ?? false;
|
|
@@ -91,8 +88,7 @@ const slugify = (string, options) => {
|
|
|
91
88
|
...options ?? {}
|
|
92
89
|
});
|
|
93
90
|
};
|
|
94
|
-
|
|
95
|
-
//#region src/tv.ts
|
|
91
|
+
// src/tv.ts
|
|
96
92
|
/**
|
|
97
93
|
* Re-export of tailwind-variants tv function
|
|
98
94
|
* Used to create variant definitions with slots and variants
|
|
@@ -132,7 +128,6 @@ const variantsToClassNames = (variants, className, baseSlot) => {
|
|
|
132
128
|
return acc;
|
|
133
129
|
}, {});
|
|
134
130
|
};
|
|
135
|
-
//#endregion
|
|
136
131
|
export { cn, heroui, isTestEnvironment, proseTwMerge, proseTwMergeClassGroups, slugify, tv, variantsToClassNames };
|
|
137
132
|
|
|
138
133
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["tailwindVariants"],"sources":["../src/proseTwMerge.ts","../src/cn.ts","../src/isTestEnvironment.ts","../src/slugify.ts","../src/tv.ts"],"sourcesContent":["import type { ConfigExtension } from 'tailwind-merge';\n\nimport { extendTailwindMerge, validators } from 'tailwind-merge';\n\ntype ProseClassGroupIds = 'prose-size' | 'prose-color';\n\n/**\n * Typography plugin size classes are standalone tokens like `prose-sm`\n * instead of regular utilities, so we register them as a custom merge group.\n */\nconst isProseSize = (value: string): boolean => {\n return value === 'base' || validators.isTshirtSize(value);\n};\n\n/**\n * Typography plugin color themes are also standalone `prose-*` classes.\n * Keep `prose-invert` out of this group so it can coexist with a color class.\n */\nconst isProseColor = (value: string): boolean => {\n return (\n value !== 'invert' &&\n !isProseSize(value) &&\n (validators.isAnyNonArbitrary(value) || validators.isArbitraryValue(value))\n );\n};\n\nexport const proseTwMergeClassGroups: NonNullable<\n NonNullable<\n ConfigExtension<ProseClassGroupIds, never>['extend']\n >['classGroups']\n> = {\n // Typography plugin sizes are mutually exclusive standalone classes.\n 'prose-size': [{ prose: [isProseSize] }],\n // Typography plugin color themes are also mutually exclusive standalone classes.\n 'prose-color': [{ prose: [isProseColor] }],\n};\n\n/**\n * Prose-aware `tailwind-merge` instance that deduplicates `prose-*` classes.\n * Used by `cn(...)` internally. Also exported for direct use in components\n * that need prose-aware class merging outside of `cn`.\n */\nexport const proseTwMerge = extendTailwindMerge<ProseClassGroupIds>({\n extend: {\n classGroups: proseTwMergeClassGroups,\n },\n});\n","/* eslint-disable import-x/prefer-default-export */\nimport type { ArgumentArray } from 'classnames';\n\nimport classNames from 'classnames';\n\nimport { proseTwMerge } from './proseTwMerge';\n\n/**\n * A utility function that combines `classnames` and `tailwind-merge`.\n *\n * It takes multiple class values (strings, arrays, or objects), merges them,\n * and ensures Tailwind CSS classes are handled properly by resolving conflicts.\n *\n * @param classes - A list of class names that can be strings, objects, or arrays.\n * @returns A string of combined class names with Tailwind CSS conflict resolution.\n *\n * Example usage:\n * ```\n * cn('p-4', 'text-center', { 'bg-red-500': true, 'p-2': false });\n * // Output: 'text-center bg-red-500 p-4'\n * ```\n */\nexport const cn = (...classes: ArgumentArray) => {\n // First, `classnames` merges the input class names (conditionally if needed).\n // Then, the shared prose-aware `tailwind-merge` instance resolves conflicts.\n return proseTwMerge(classNames(...classes));\n};\n","/* eslint-disable import-x/prefer-default-export */\n\n/**\n * Checks if the code is running in a test environment.\n *\n * This helper safely detects test environments by checking:\n * - Node.js: `process.env.NODE_ENV === 'test'` or `process.env.VITEST === 'true'`\n * - Browser: Always returns `false` (production code)\n *\n * The check is safe for both Node.js and browser environments by verifying\n * that `process` exists before accessing its properties.\n *\n * @returns `true` if running in a test environment, `false` otherwise\n *\n * @example\n * ```ts\n * if (isTestEnvironment()) {\n * // Skip debouncing in tests for immediate snapshots\n * return value;\n * }\n * // Normal production behavior with debouncing\n * return debouncedValue;\n * ```\n */\nexport const isTestEnvironment = (): boolean => {\n // Safe check: only access process if it exists (Node.js environment)\n // In browsers, process is undefined, so this returns false\n return (\n typeof process !== 'undefined' &&\n (process.env.NODE_ENV === 'test' || process.env.VITEST === 'true')\n );\n};\n","/* eslint-disable import-x/prefer-default-export */\n\nimport type { Options as SlugOptions } from 'slug';\n\nimport slug from 'slug';\n\ninterface SlugifyOptions extends SlugOptions {\n /** When true, dots are also replaced (default is false) */\n replaceDots?: boolean;\n}\n\nexport const slugify = (string: string, options?: SlugifyOptions) => {\n const replacement = options?.replacement ?? '_';\n const replaceDots = options?.replaceDots ?? false;\n\n return slug(string, {\n ...slug.defaults.modes.rfc3986,\n charmap: {\n ...slug.defaults.modes.rfc3986.charmap,\n // do not replace dots when replaceDots is false\n ...(!replaceDots ? { '.': '.' } : { '.': replacement }),\n // convert hyphens to underscores (when replacement is not hyphen)\n ...(replacement !== '-' ? { '-': '_' } : {}),\n },\n replacement,\n ...(options ?? {}),\n });\n};\n","import type { VariantProps } from '@heroui/theme';\nimport type { ClassProp, TV } from 'tailwind-variants';\n\nimport { tv as tailwindVariants } from 'tailwind-variants';\n\n/**\n * Represents a class value which can be either a string or an array of strings\n * Used for handling both single class names and multiple class names\n */\nexport type ClassValue = string | string[];\n\n/**\n * Props accepted by tailwind-variants slot functions\n * Combines a dynamic record of string/number values with the ClassProp from tailwind-variants\n */\ntype TVSlotProps = {\n [x: string]: string | number | undefined;\n [x: number]: string | number | undefined;\n} & ClassProp<ClassValue>;\n\n/**\n * Represents a tailwind-variants slot function\n * Takes optional TVSlotProps and returns a string of class names\n */\ntype TVFunction = (slotProps?: TVSlotProps) => string;\n\n/**\n * A record of slot names to their corresponding tailwind-variants functions\n * Used to type the variants parameter in variantsToClassNames\n */\ntype TVRecord = Record<string, TVFunction>;\n\n/**\n * Re-export of tailwind-variants tv function\n * Used to create variant definitions with slots and variants\n */\nexport const tv: TV = tailwindVariants;\n\n/**\n * Extracts variant props from a tailwind-variants component\n * Used for typing component props that use variants\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type TVProps<Component extends (...args: any) => any> =\n VariantProps<Component>;\n\n/**\n * Extracts className type from a tailwind-variants component\n * Can be either a partial record of slot names to class values, or a single class value\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type TVClassName<Component extends (...args: any) => any> =\n | Partial<Record<keyof ReturnType<Component>, ClassValue>>\n | ClassValue;\n\n/**\n * Converts tailwind-variants slots instance to actual classnames object\n *\n * @param variants - Object containing slot variant functions from tailwind-variants\n * @param className - Optional class names to merge with variant classes. Can be string, array, or record\n * @param baseSlot - Optional slot name to apply global className to\n * @returns Record mapping slot names to their final class name strings\n *\n * @example\n * ```tsx\n * const variants = tv({ slots: { base: 'bg-white', content: 'p-4' } });\n * const classes = variantsToClassNames(variants(), 'shadow-lg', 'base');\n * // Result: { base: 'bg-white shadow-lg', content: 'p-4' }\n * ```\n *\n * @example\n * ```tsx\n * const variants = tv({ slots: { base: '', content: '' } });\n * const classes = variantsToClassNames(variants(), {\n * base: 'bg-white',\n * content: ['p-4', 'text-gray-700']\n * });\n * // Result: { base: 'bg-white', content: 'p-4 text-gray-700' }\n * ```\n */\nexport const variantsToClassNames = <T extends TVRecord>(\n variants: T,\n className?: ClassValue | Record<string, ClassValue>,\n baseSlot?: keyof T,\n): Record<keyof T, string> => {\n const classNames =\n typeof className === 'object' && !Array.isArray(className) ? className : {};\n\n return Object.entries(variants).reduce(\n (acc, [slot, variantFn]) => {\n const slotKey = slot as keyof T;\n const slotClassName =\n typeof className === 'string' || Array.isArray(className)\n ? className\n : classNames[slot];\n\n // @ts-expect-error not sure here\n acc[slotKey] = variantFn({\n className:\n baseSlot && slot === baseSlot ? slotClassName : classNames[slot],\n });\n\n return acc;\n },\n {} as Record<keyof T, string>,\n );\n};\n"],"mappings":";;;;;;;;;;AAUA,MAAM,eAAe,UAA2B;CAC9C,OAAO,UAAU,UAAU,WAAW,aAAa,KAAK;AAC1D;;;;;AAMA,MAAM,gBAAgB,UAA2B;CAC/C,OACE,UAAU,YACV,CAAC,YAAY,KAAK,MACjB,WAAW,kBAAkB,KAAK,KAAK,WAAW,iBAAiB,KAAK;AAE7E;AAEA,MAAa,0BAIT;CAEF,cAAc,CAAC,EAAE,OAAO,CAAC,WAAW,EAAE,CAAC;CAEvC,eAAe,CAAC,EAAE,OAAO,CAAC,YAAY,EAAE,CAAC;AAC3C;;;;;;AAOA,MAAa,eAAe,oBAAwC,EAClE,QAAQ,EACN,aAAa,wBACf,EACF,CAAC
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["tailwindVariants"],"sources":["../src/proseTwMerge.ts","../src/cn.ts","../src/isTestEnvironment.ts","../src/slugify.ts","../src/tv.ts"],"sourcesContent":["import type { ConfigExtension } from 'tailwind-merge';\n\nimport { extendTailwindMerge, validators } from 'tailwind-merge';\n\ntype ProseClassGroupIds = 'prose-size' | 'prose-color';\n\n/**\n * Typography plugin size classes are standalone tokens like `prose-sm`\n * instead of regular utilities, so we register them as a custom merge group.\n */\nconst isProseSize = (value: string): boolean => {\n return value === 'base' || validators.isTshirtSize(value);\n};\n\n/**\n * Typography plugin color themes are also standalone `prose-*` classes.\n * Keep `prose-invert` out of this group so it can coexist with a color class.\n */\nconst isProseColor = (value: string): boolean => {\n return (\n value !== 'invert' &&\n !isProseSize(value) &&\n (validators.isAnyNonArbitrary(value) || validators.isArbitraryValue(value))\n );\n};\n\nexport const proseTwMergeClassGroups: NonNullable<\n NonNullable<\n ConfigExtension<ProseClassGroupIds, never>['extend']\n >['classGroups']\n> = {\n // Typography plugin sizes are mutually exclusive standalone classes.\n 'prose-size': [{ prose: [isProseSize] }],\n // Typography plugin color themes are also mutually exclusive standalone classes.\n 'prose-color': [{ prose: [isProseColor] }],\n};\n\n/**\n * Prose-aware `tailwind-merge` instance that deduplicates `prose-*` classes.\n * Used by `cn(...)` internally. Also exported for direct use in components\n * that need prose-aware class merging outside of `cn`.\n */\nexport const proseTwMerge = extendTailwindMerge<ProseClassGroupIds>({\n extend: {\n classGroups: proseTwMergeClassGroups,\n },\n});\n","/* eslint-disable import-x/prefer-default-export */\nimport type { ArgumentArray } from 'classnames';\n\nimport classNames from 'classnames';\n\nimport { proseTwMerge } from './proseTwMerge';\n\n/**\n * A utility function that combines `classnames` and `tailwind-merge`.\n *\n * It takes multiple class values (strings, arrays, or objects), merges them,\n * and ensures Tailwind CSS classes are handled properly by resolving conflicts.\n *\n * @param classes - A list of class names that can be strings, objects, or arrays.\n * @returns A string of combined class names with Tailwind CSS conflict resolution.\n *\n * Example usage:\n * ```\n * cn('p-4', 'text-center', { 'bg-red-500': true, 'p-2': false });\n * // Output: 'text-center bg-red-500 p-4'\n * ```\n */\nexport const cn = (...classes: ArgumentArray) => {\n // First, `classnames` merges the input class names (conditionally if needed).\n // Then, the shared prose-aware `tailwind-merge` instance resolves conflicts.\n return proseTwMerge(classNames(...classes));\n};\n","/* eslint-disable import-x/prefer-default-export */\n\n/**\n * Checks if the code is running in a test environment.\n *\n * This helper safely detects test environments by checking:\n * - Node.js: `process.env.NODE_ENV === 'test'` or `process.env.VITEST === 'true'`\n * - Browser: Always returns `false` (production code)\n *\n * The check is safe for both Node.js and browser environments by verifying\n * that `process` exists before accessing its properties.\n *\n * @returns `true` if running in a test environment, `false` otherwise\n *\n * @example\n * ```ts\n * if (isTestEnvironment()) {\n * // Skip debouncing in tests for immediate snapshots\n * return value;\n * }\n * // Normal production behavior with debouncing\n * return debouncedValue;\n * ```\n */\nexport const isTestEnvironment = (): boolean => {\n // Safe check: only access process if it exists (Node.js environment)\n // In browsers, process is undefined, so this returns false\n return (\n typeof process !== 'undefined' &&\n (process.env.NODE_ENV === 'test' || process.env.VITEST === 'true')\n );\n};\n","/* eslint-disable import-x/prefer-default-export */\n\nimport type { Options as SlugOptions } from 'slug';\n\nimport slug from 'slug';\n\ninterface SlugifyOptions extends SlugOptions {\n /** When true, dots are also replaced (default is false) */\n replaceDots?: boolean;\n}\n\nexport const slugify = (string: string, options?: SlugifyOptions) => {\n const replacement = options?.replacement ?? '_';\n const replaceDots = options?.replaceDots ?? false;\n\n return slug(string, {\n ...slug.defaults.modes.rfc3986,\n charmap: {\n ...slug.defaults.modes.rfc3986.charmap,\n // do not replace dots when replaceDots is false\n ...(!replaceDots ? { '.': '.' } : { '.': replacement }),\n // convert hyphens to underscores (when replacement is not hyphen)\n ...(replacement !== '-' ? { '-': '_' } : {}),\n },\n replacement,\n ...(options ?? {}),\n });\n};\n","import type { VariantProps } from '@heroui/theme';\nimport type { ClassProp, TV } from 'tailwind-variants';\n\nimport { tv as tailwindVariants } from 'tailwind-variants';\n\n/**\n * Represents a class value which can be either a string or an array of strings\n * Used for handling both single class names and multiple class names\n */\nexport type ClassValue = string | string[];\n\n/**\n * Props accepted by tailwind-variants slot functions\n * Combines a dynamic record of string/number values with the ClassProp from tailwind-variants\n */\ntype TVSlotProps = {\n [x: string]: string | number | undefined;\n [x: number]: string | number | undefined;\n} & ClassProp<ClassValue>;\n\n/**\n * Represents a tailwind-variants slot function\n * Takes optional TVSlotProps and returns a string of class names\n */\ntype TVFunction = (slotProps?: TVSlotProps) => string;\n\n/**\n * A record of slot names to their corresponding tailwind-variants functions\n * Used to type the variants parameter in variantsToClassNames\n */\ntype TVRecord = Record<string, TVFunction>;\n\n/**\n * Re-export of tailwind-variants tv function\n * Used to create variant definitions with slots and variants\n */\nexport const tv: TV = tailwindVariants;\n\n/**\n * Extracts variant props from a tailwind-variants component\n * Used for typing component props that use variants\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type TVProps<Component extends (...args: any) => any> =\n VariantProps<Component>;\n\n/**\n * Extracts className type from a tailwind-variants component\n * Can be either a partial record of slot names to class values, or a single class value\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type TVClassName<Component extends (...args: any) => any> =\n | Partial<Record<keyof ReturnType<Component>, ClassValue>>\n | ClassValue;\n\n/**\n * Converts tailwind-variants slots instance to actual classnames object\n *\n * @param variants - Object containing slot variant functions from tailwind-variants\n * @param className - Optional class names to merge with variant classes. Can be string, array, or record\n * @param baseSlot - Optional slot name to apply global className to\n * @returns Record mapping slot names to their final class name strings\n *\n * @example\n * ```tsx\n * const variants = tv({ slots: { base: 'bg-white', content: 'p-4' } });\n * const classes = variantsToClassNames(variants(), 'shadow-lg', 'base');\n * // Result: { base: 'bg-white shadow-lg', content: 'p-4' }\n * ```\n *\n * @example\n * ```tsx\n * const variants = tv({ slots: { base: '', content: '' } });\n * const classes = variantsToClassNames(variants(), {\n * base: 'bg-white',\n * content: ['p-4', 'text-gray-700']\n * });\n * // Result: { base: 'bg-white', content: 'p-4 text-gray-700' }\n * ```\n */\nexport const variantsToClassNames = <T extends TVRecord>(\n variants: T,\n className?: ClassValue | Record<string, ClassValue>,\n baseSlot?: keyof T,\n): Record<keyof T, string> => {\n const classNames =\n typeof className === 'object' && !Array.isArray(className) ? className : {};\n\n return Object.entries(variants).reduce(\n (acc, [slot, variantFn]) => {\n const slotKey = slot as keyof T;\n const slotClassName =\n typeof className === 'string' || Array.isArray(className)\n ? className\n : classNames[slot];\n\n // @ts-expect-error not sure here\n acc[slotKey] = variantFn({\n className:\n baseSlot && slot === baseSlot ? slotClassName : classNames[slot],\n });\n\n return acc;\n },\n {} as Record<keyof T, string>,\n );\n};\n"],"mappings":";;;;;;;;;;AAUA,MAAM,eAAe,UAA2B;CAC9C,OAAO,UAAU,UAAU,WAAW,aAAa,KAAK;AAC1D;;;;;AAMA,MAAM,gBAAgB,UAA2B;CAC/C,OACE,UAAU,YACV,CAAC,YAAY,KAAK,MACjB,WAAW,kBAAkB,KAAK,KAAK,WAAW,iBAAiB,KAAK;AAE7E;AAEA,MAAa,0BAIT;CAEF,cAAc,CAAC,EAAE,OAAO,CAAC,WAAW,EAAE,CAAC;CAEvC,eAAe,CAAC,EAAE,OAAO,CAAC,YAAY,EAAE,CAAC;AAC3C;;;;;;AAOA,MAAa,eAAe,oBAAwC,EAClE,QAAQ,EACN,aAAa,wBACf,EACF,CAAC;;;;;;;;;;;;;;;;;ACxBD,MAAa,MAAM,GAAG,YAA2B;CAG/C,OAAO,aAAa,WAAW,GAAG,OAAO,CAAC;AAC5C;;;;;;;;;;;;;;;;;;;;;;;;ACFA,MAAa,0BAAmC;CAG9C,OACE,OAAO,YAAY,gBAClB,QAAQ,IAAI,aAAa,UAAU,QAAQ,IAAI,WAAW;AAE/D;;ACpBA,MAAa,WAAW,QAAgB,YAA6B;CACnE,MAAM,cAAc,SAAS,eAAe;CAC5C,MAAM,cAAc,SAAS,eAAe;CAE5C,OAAO,KAAK,QAAQ;EAClB,GAAG,KAAK,SAAS,MAAM;EACvB,SAAS;GACP,GAAG,KAAK,SAAS,MAAM,QAAQ;GAE/B,GAAI,CAAC,cAAc,EAAE,KAAK,IAAI,IAAI,EAAE,KAAK,YAAY;GAErD,GAAI,gBAAgB,MAAM,EAAE,KAAK,IAAI,IAAI,CAAC;EAC5C;EACA;EACA,GAAI,WAAW,CAAC;CAClB,CAAC;AACH;;;;;;ACSA,MAAa,KAASA;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CtB,MAAa,wBACX,UACA,WACA,aAC4B;CAC5B,MAAM,aACJ,OAAO,cAAc,YAAY,CAAC,MAAM,QAAQ,SAAS,IAAI,YAAY,CAAC;CAE5E,OAAO,OAAO,QAAQ,QAAQ,CAAC,CAAC,QAC7B,KAAK,CAAC,MAAM,eAAe;EAC1B,MAAM,UAAU;EAChB,MAAM,gBACJ,OAAO,cAAc,YAAY,MAAM,QAAQ,SAAS,IACpD,YACA,WAAW;EAGjB,IAAI,WAAW,UAAU,EACvB,WACE,YAAY,SAAS,WAAW,gBAAgB,WAAW,MAC/D,CAAC;EAED,OAAO;CACT,GACA,CAAC,CACH;AACF"}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@fuf-stack/pixel-utils",
|
|
3
3
|
"description": "fuf pixels helper utils",
|
|
4
4
|
"author": "Fröhlich ∧ Frei",
|
|
5
|
-
"version": "1.
|
|
5
|
+
"version": "1.5.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"types": "./dist/index.d.mts",
|
|
8
8
|
"sideEffects": false,
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"@heroui/theme": "2.4.26",
|
|
40
40
|
"classnames": "2.5.1",
|
|
41
41
|
"slug": "9.1.0",
|
|
42
|
-
"tailwind-merge": "3.
|
|
42
|
+
"tailwind-merge": "3.7.0",
|
|
43
43
|
"tailwind-variants": "3.2.2"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
@@ -47,9 +47,9 @@
|
|
|
47
47
|
},
|
|
48
48
|
"inlinedDependencies": {
|
|
49
49
|
"@heroui/theme": "2.4.26",
|
|
50
|
-
"tailwind-merge": "3.
|
|
50
|
+
"tailwind-merge": "3.7.0",
|
|
51
51
|
"tailwind-variants": "3.2.2",
|
|
52
|
-
"tailwindcss": "4.3.
|
|
52
|
+
"tailwindcss": "4.3.4"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "3ef1bcc4f979ce9eb7dafc68ef2e3670a225015f"
|
|
55
55
|
}
|