@fuf-stack/pixel-utils 2.0.0-next.1 → 2.0.0-next.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 +1 -1
- package/dist/index.d.mts +0 -20
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +8 -16
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -108,7 +108,7 @@ styling.cn('text-sm text-danger', 'text-body');
|
|
|
108
108
|
// => 'text-danger text-body'
|
|
109
109
|
|
|
110
110
|
// Resolve an existing module-level recipe before merging slot overrides.
|
|
111
|
-
const input = tv({ slots: { input: 'text-
|
|
111
|
+
const input = tv({ slots: { input: 'text-sm text-danger' } });
|
|
112
112
|
styling.variantsToClassNames(styling.resolve(input), { input: 'text-body' });
|
|
113
113
|
// => { base: undefined, input: 'text-danger text-body' }
|
|
114
114
|
```
|
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
|
*
|
|
@@ -17,8 +16,6 @@ import { Options } from "slug";
|
|
|
17
16
|
* ```
|
|
18
17
|
*/
|
|
19
18
|
export declare const cn: (...classes: ArgumentArray) => string;
|
|
20
|
-
//#endregion
|
|
21
|
-
//#region src/isTestEnvironment.d.ts
|
|
22
19
|
/**
|
|
23
20
|
* Checks if the code is running in a test environment.
|
|
24
21
|
*
|
|
@@ -42,8 +39,6 @@ export declare const cn: (...classes: ArgumentArray) => string;
|
|
|
42
39
|
* ```
|
|
43
40
|
*/
|
|
44
41
|
export declare const isTestEnvironment: () => boolean;
|
|
45
|
-
//#endregion
|
|
46
|
-
//#region ../../node_modules/.pnpm/tailwind-merge@3.7.0/node_modules/tailwind-merge/dist/types.d.ts
|
|
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
|
*
|
|
@@ -250,8 +245,6 @@ type AnyThemeGroupIds = string;
|
|
|
250
245
|
type AnyConfig = Config<AnyClassGroupIds, AnyThemeGroupIds>;
|
|
251
246
|
type CreateConfigSubsequent = (config: AnyConfig) => AnyConfig;
|
|
252
247
|
declare const extendTailwindMerge: <AdditionalClassGroupIds extends string = never, AdditionalThemeGroupIds extends string = never>(configExtension: ConfigExtension<DefaultClassGroupIds | AdditionalClassGroupIds, DefaultThemeGroupIds | AdditionalThemeGroupIds> | CreateConfigSubsequent, ...createConfig: CreateConfigSubsequent[]) => (...classLists: ClassNameValue[]) => string;
|
|
253
|
-
//#endregion
|
|
254
|
-
//#region src/proseTwMerge.d.ts
|
|
255
248
|
type ProseClassGroupIds = 'prose-size' | 'prose-color';
|
|
256
249
|
export declare const proseTwMergeClassGroups: NonNullable<NonNullable<ConfigExtension<ProseClassGroupIds, never>['extend']>['classGroups']>;
|
|
257
250
|
/**
|
|
@@ -260,15 +253,11 @@ export declare const proseTwMergeClassGroups: NonNullable<NonNullable<ConfigExte
|
|
|
260
253
|
* that need prose-aware class merging outside of `cn`.
|
|
261
254
|
*/
|
|
262
255
|
export declare const proseTwMerge: (...classLists: ClassNameValue[]) => string;
|
|
263
|
-
//#endregion
|
|
264
|
-
//#region src/slugify.d.ts
|
|
265
256
|
interface SlugifyOptions extends Options {
|
|
266
257
|
/** When true, dots are also replaced (default is false) */
|
|
267
258
|
replaceDots?: boolean;
|
|
268
259
|
}
|
|
269
260
|
export declare const slugify: (string: string, options?: SlugifyOptions) => string;
|
|
270
|
-
//#endregion
|
|
271
|
-
//#region ../../node_modules/.pnpm/tailwind-variants@3.2.2_tailwind-merge@3.7.0_tailwindcss@4.3.3/node_modules/tailwind-variants/dist/config.d.ts
|
|
272
261
|
type MergeConfig = Parameters<typeof extendTailwindMerge>[0];
|
|
273
262
|
type LegacyMergeConfig = Extract<MergeConfig, {
|
|
274
263
|
extend?: unknown;
|
|
@@ -289,8 +278,6 @@ type TWMConfig = {
|
|
|
289
278
|
twMergeConfig?: TWMergeConfig;
|
|
290
279
|
};
|
|
291
280
|
type TVConfig = TWMConfig;
|
|
292
|
-
//#endregion
|
|
293
|
-
//#region ../../node_modules/.pnpm/tailwind-variants@3.2.2_tailwind-merge@3.7.0_tailwindcss@4.3.3/node_modules/tailwind-variants/dist/types.d.ts
|
|
294
281
|
type ClassProp<V extends unknown = ClassNameValue> = {
|
|
295
282
|
class?: V;
|
|
296
283
|
className?: never;
|
|
@@ -396,8 +383,6 @@ type TV = {
|
|
|
396
383
|
config?: TVConfig): TVReturnType<V, S, B, EV, ES, E>;
|
|
397
384
|
};
|
|
398
385
|
type VariantProps<Component extends (...args: any) => any> = Omit<OmitUndefined<Parameters<Component>[0]>, "class" | "className">;
|
|
399
|
-
//#endregion
|
|
400
|
-
//#region src/slotClassNames.d.ts
|
|
401
386
|
/**
|
|
402
387
|
* Props accepted by tailwind-variants slot functions
|
|
403
388
|
* Combines a dynamic record of string/number values with the ClassProp from tailwind-variants
|
|
@@ -442,8 +427,6 @@ type TVRecord = Record<string, TVFunction>;
|
|
|
442
427
|
* ```
|
|
443
428
|
*/
|
|
444
429
|
declare const variantsToClassNames: <T extends TVRecord>(variants: T, className?: ClassValue | Record<string, ClassValue | undefined>, baseSlot?: keyof T) => Record<keyof T, string>;
|
|
445
|
-
//#endregion
|
|
446
|
-
//#region src/tv.d.ts
|
|
447
430
|
/**
|
|
448
431
|
* Represents a class value which can be either a string or an array of strings
|
|
449
432
|
* Used for handling both single class names and multiple class names
|
|
@@ -464,8 +447,6 @@ export type TVProps<Component extends (...args: any) => any> = VariantProps<Comp
|
|
|
464
447
|
* Can be either a partial record of slot names to class values, or a single class value
|
|
465
448
|
*/
|
|
466
449
|
export type TVClassName<Component extends (...args: any) => any> = Partial<Record<keyof ReturnType<Component>, ClassValue>> | ClassValue;
|
|
467
|
-
//#endregion
|
|
468
|
-
//#region src/styling.d.ts
|
|
469
450
|
type Recipe = (...args: any[]) => any;
|
|
470
451
|
export type StylingConfig = ConfigExtension<string, string>;
|
|
471
452
|
export interface Styling {
|
|
@@ -482,6 +463,5 @@ export interface Styling {
|
|
|
482
463
|
*/
|
|
483
464
|
export declare const createStyling: (config?: StylingConfig) => Styling;
|
|
484
465
|
export declare const defaultStyling: Styling;
|
|
485
|
-
//#endregion
|
|
486
466
|
export { variantsToClassNames };
|
|
487
467
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":["_$tailwind_merge0.ClassNameValue","SlugOptions","ClassValue","TVProps"],"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.
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":["_$tailwind_merge0.ClassNameValue","SlugOptions","ClassValue","TVProps"],"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.5/node_modules/tailwind-variants/dist/config.d.ts","../../../node_modules/.pnpm/tailwind-variants@3.2.2_tailwind-merge@3.7.0_tailwindcss@4.3.5/node_modules/tailwind-variants/dist/types.d.ts","../src/slotClassNames.ts","../src/tv.ts","../src/styling.ts"],"ignoreList":[2,5,6],"mappings":";;;;;;;;;;;;;;;;;qBAsBa,QAAS,SAAS;;;;;;;;;;;;;;;;;;;;;;;qBCElB;;;;;;;;;;KCfR,iBAAiB;KACjB,0BAA0B;;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
|
@@ -2,7 +2,7 @@ import classNames from "classnames";
|
|
|
2
2
|
import { extendTailwindMerge, mergeConfigs, validators } from "tailwind-merge";
|
|
3
3
|
import slug from "slug";
|
|
4
4
|
import { tv as tv$1 } from "tailwind-variants/lite";
|
|
5
|
-
|
|
5
|
+
// src/proseTwMerge.ts
|
|
6
6
|
/**
|
|
7
7
|
* Typography plugin size classes are standalone tokens like `prose-sm`
|
|
8
8
|
* instead of regular utilities, so we register them as a custom merge group.
|
|
@@ -27,8 +27,7 @@ const proseTwMergeClassGroups = {
|
|
|
27
27
|
* that need prose-aware class merging outside of `cn`.
|
|
28
28
|
*/
|
|
29
29
|
const proseTwMerge = extendTailwindMerge({ extend: { classGroups: proseTwMergeClassGroups } });
|
|
30
|
-
|
|
31
|
-
//#region src/cn.ts
|
|
30
|
+
// src/cn.ts
|
|
32
31
|
/**
|
|
33
32
|
* A utility function that combines `classnames` and `tailwind-merge`.
|
|
34
33
|
*
|
|
@@ -47,8 +46,7 @@ const proseTwMerge = extendTailwindMerge({ extend: { classGroups: proseTwMergeCl
|
|
|
47
46
|
const cn = (...classes) => {
|
|
48
47
|
return proseTwMerge(classNames(...classes));
|
|
49
48
|
};
|
|
50
|
-
|
|
51
|
-
//#region src/isTestEnvironment.ts
|
|
49
|
+
// src/isTestEnvironment.ts
|
|
52
50
|
/**
|
|
53
51
|
* Checks if the code is running in a test environment.
|
|
54
52
|
*
|
|
@@ -74,8 +72,7 @@ const cn = (...classes) => {
|
|
|
74
72
|
const isTestEnvironment = () => {
|
|
75
73
|
return typeof process !== "undefined" && (process.env.NODE_ENV === "test" || process.env.VITEST === "true");
|
|
76
74
|
};
|
|
77
|
-
|
|
78
|
-
//#region src/slugify.ts
|
|
75
|
+
// src/slugify.ts
|
|
79
76
|
const slugify = (string, options) => {
|
|
80
77
|
const replacement = options?.replacement ?? "_";
|
|
81
78
|
const replaceDots = options?.replaceDots ?? false;
|
|
@@ -90,8 +87,7 @@ const slugify = (string, options) => {
|
|
|
90
87
|
...options ?? {}
|
|
91
88
|
});
|
|
92
89
|
};
|
|
93
|
-
|
|
94
|
-
//#region src/semanticMergeConfig.ts
|
|
90
|
+
// src/semanticMergeConfig.ts
|
|
95
91
|
const sizes = [
|
|
96
92
|
"small",
|
|
97
93
|
"medium",
|
|
@@ -129,8 +125,7 @@ const semanticMergeConfig = { extend: {
|
|
|
129
125
|
]
|
|
130
126
|
}
|
|
131
127
|
} };
|
|
132
|
-
|
|
133
|
-
//#region src/slotClassNames.ts
|
|
128
|
+
// src/slotClassNames.ts
|
|
134
129
|
/**
|
|
135
130
|
* Converts tailwind-variants slots instance to actual classnames object
|
|
136
131
|
*
|
|
@@ -165,8 +160,7 @@ const variantsToClassNames = (variants, className, baseSlot) => {
|
|
|
165
160
|
return acc;
|
|
166
161
|
}, {});
|
|
167
162
|
};
|
|
168
|
-
|
|
169
|
-
//#region src/styling.ts
|
|
163
|
+
// src/styling.ts
|
|
170
164
|
const rawRecipes = /* @__PURE__ */ new WeakMap();
|
|
171
165
|
const copyConfig = (value) => {
|
|
172
166
|
if (Array.isArray(value)) return value.map(copyConfig);
|
|
@@ -243,14 +237,12 @@ const createStyling = (config = {}) => {
|
|
|
243
237
|
});
|
|
244
238
|
};
|
|
245
239
|
const defaultStyling = createStyling();
|
|
246
|
-
|
|
247
|
-
//#region src/tv.ts
|
|
240
|
+
// src/tv.ts
|
|
248
241
|
/**
|
|
249
242
|
* Tailwind Variants recipe factory with isolated semantic class merging
|
|
250
243
|
* Used to create variant definitions with slots and variants
|
|
251
244
|
*/
|
|
252
245
|
const tv = defaultStyling.tv;
|
|
253
|
-
//#endregion
|
|
254
246
|
export { cn, createStyling, defaultStyling, isTestEnvironment, proseTwMerge, proseTwMergeClassGroups, slugify, tv, variantsToClassNames };
|
|
255
247
|
|
|
256
248
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["unmergedTV"],"sources":["../src/proseTwMerge.ts","../src/cn.ts","../src/isTestEnvironment.ts","../src/slugify.ts","../src/semanticMergeConfig.ts","../src/slotClassNames.ts","../src/styling.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 { StylingConfig } from './styling';\n\n// Owned merge rules for semantic utilities already used by the workspace.\n// These classify utilities; tokens.css generates their CSS.\nconst sizes = ['small', 'medium', 'large'];\n\nconst semanticMergeConfig: StylingConfig = {\n extend: {\n theme: { spacing: ['divider'], radius: sizes },\n classGroups: {\n shadow: [{ shadow: sizes }],\n opacity: [{ opacity: ['disabled'] }],\n 'font-size': [{ text: ['tiny', ...sizes] }],\n 'border-w': [{ border: sizes }],\n 'bg-image': [\n {\n 'bg-stripe-gradient': [\n 'default',\n 'primary',\n 'secondary',\n 'success',\n 'warning',\n 'danger',\n ],\n },\n ],\n transition: [\n 'transition-background',\n 'transition-colors-opacity',\n 'transition-width',\n 'transition-height',\n 'transition-size',\n 'transition-left',\n 'transition-transform-opacity',\n 'transition-transform-background',\n 'transition-transform-colors',\n 'transition-transform-colors-opacity',\n ],\n },\n },\n};\n\nexport default semanticMergeConfig;\n","import type { ClassProp } from 'tailwind-variants';\nimport type { ClassValue } from './tv';\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 * 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 */\nconst variantsToClassNames = <T extends TVRecord>(\n variants: T,\n className?: ClassValue | Record<string, ClassValue | undefined>,\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\nexport default variantsToClassNames;\n","import type { ArgumentArray } from 'classnames';\nimport type { ConfigExtension } from 'tailwind-merge';\nimport type { TV, TVConfig } from 'tailwind-variants';\n\nimport classNames from 'classnames';\nimport { extendTailwindMerge, mergeConfigs } from 'tailwind-merge';\nimport { tv as unmergedTV } from 'tailwind-variants/lite';\n\nimport { proseTwMergeClassGroups } from './proseTwMerge';\nimport semanticMergeConfig from './semanticMergeConfig';\nimport variantsToClassNames from './slotClassNames';\n\n// Preserve the full callable signature and recipe metadata (including generics).\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype Recipe = (...args: any[]) => any;\nconst rawRecipes = new WeakMap<Recipe, Recipe>();\n\nexport type StylingConfig = ConfigExtension<string, string>;\n\nexport interface Styling {\n readonly cn: (...classes: ArgumentArray) => string;\n /** Resolve a module-level pixel-utils recipe with this instance's merge rules. */\n readonly resolve: <T extends Recipe>(\n recipe: T,\n ...props: Parameters<T>\n ) => ReturnType<T>;\n readonly tv: TV;\n readonly variantsToClassNames: typeof variantsToClassNames;\n}\n\n// Configs contain validator functions, so structuredClone is unsuitable.\nconst copyConfig = <T>(value: T): T => {\n if (Array.isArray(value)) {\n return value.map(copyConfig) as T;\n }\n if (value && typeof value === 'object') {\n return Object.fromEntries(\n Object.entries(value).map(([key, entry]) => {\n return [key, copyConfig(entry)];\n }),\n ) as T;\n }\n return value;\n};\n\n/**\n * Creates isolated class helpers. No React or process-global configuration.\n * Recipe classes are concatenated by the lite engine, then merged once, after\n * defaults, variants, compounds, and caller overrides have all been collected.\n */\nexport const createStyling = (config: StylingConfig = {}): Styling => {\n const instanceConfig = copyConfig(config);\n const merge = extendTailwindMerge<string, string>(\n { extend: { classGroups: proseTwMergeClassGroups } },\n (defaults) => {\n return mergeConfigs(defaults, semanticMergeConfig);\n },\n (defaults) => {\n return mergeConfigs(defaults, instanceConfig);\n },\n );\n\n const resolveWith = (\n recipe: Recipe,\n props: unknown[],\n merger: (value: string) => string,\n ) => {\n const result = (rawRecipes.get(recipe) ?? recipe)(...props);\n const mergeResult = (value: string | undefined) => {\n return value ? merger(value) || undefined : value;\n };\n if (typeof result !== 'object' || result === null) {\n return mergeResult(result);\n }\n return Object.fromEntries(\n Object.entries(result).map(([slot, fn]) => {\n return [\n slot,\n (...slotProps: unknown[]) => {\n return mergeResult((fn as Recipe)(...slotProps));\n },\n ];\n }),\n );\n };\n\n // The generic TV signature is unchanged; only its final class resolution is\n // replaced. The lite engine retains metadata for extension without merging.\n const tv = ((options, recipeConfig?: TVConfig) => {\n const raw = unmergedTV(options, { twMerge: false, twMergeConfig: {} });\n const mergeConfig = copyConfig(recipeConfig?.twMergeConfig);\n const shouldMerge = recipeConfig?.twMerge !== false;\n // Keep the legacy top-level config fields accepted by Tailwind Variants.\n const normalizedConfig =\n mergeConfig && typeof mergeConfig !== 'function'\n ? {\n ...mergeConfig,\n extend: {\n theme: mergeConfig.theme,\n classGroups: mergeConfig.classGroups,\n conflictingClassGroupModifiers:\n mergeConfig.conflictingClassGroupModifiers,\n conflictingClassGroups: mergeConfig.conflictingClassGroups,\n ...mergeConfig.extend,\n },\n }\n : mergeConfig;\n const recipeMerge = normalizedConfig\n ? extendTailwindMerge<string, string>(\n { extend: { classGroups: proseTwMergeClassGroups } },\n (defaults) => {\n return mergeConfigs(defaults, semanticMergeConfig);\n },\n (defaults) => {\n return mergeConfigs(defaults, instanceConfig);\n },\n (defaults) => {\n return typeof normalizedConfig === 'function'\n ? normalizedConfig(defaults)\n : mergeConfigs(defaults, normalizedConfig);\n },\n )\n : merge;\n const wrapped = Object.assign((...props: unknown[]) => {\n return resolveWith(\n raw,\n props,\n !shouldMerge\n ? (v) => {\n return v;\n }\n : recipeMerge,\n );\n }, raw);\n rawRecipes.set(wrapped, raw);\n return wrapped;\n }) as TV;\n\n return Object.freeze({\n cn: (...classes: ArgumentArray) => {\n return merge(classNames(...classes));\n },\n tv,\n variantsToClassNames,\n resolve: (recipe, ...props) => {\n return resolveWith(recipe, props, merge);\n },\n });\n};\n\nexport const defaultStyling: Styling = createStyling();\n","import type { TV, VariantProps } from 'tailwind-variants';\n\nimport { defaultStyling } from './styling';\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 * Tailwind Variants recipe factory with isolated semantic class merging\n * Used to create variant definitions with slots and variants\n */\nexport const tv: TV = defaultStyling.tv;\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>> | ClassValue;\n\nexport { default as variantsToClassNames } from './slotClassNames';\n"],"mappings":";;;;;;;;;AAUA,MAAM,eAAe,UAA2B;CAC9C,OAAO,UAAU,UAAU,WAAW,aAAa,KAAK;AAC1D;;;;;AAMA,MAAM,gBAAgB,U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O;EACnB,KAAK,GAAG,YAA2B;GACjC,OAAO,MAAM,WAAW,GAAG,OAAO,CAAC;EACrC;EACA;EACA;EACA,UAAU,QAAQ,GAAG,UAAU;GAC7B,OAAO,YAAY,QAAQ,OAAO,KAAK;EACzC;CACF,CAAC;AACH;AAEA,MAAa,iBAA0B,cAAc;;;;;;;ACxIrD,MAAa,KAAS,eAAe"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["unmergedTV"],"sources":["../src/proseTwMerge.ts","../src/cn.ts","../src/isTestEnvironment.ts","../src/slugify.ts","../src/semanticMergeConfig.ts","../src/slotClassNames.ts","../src/styling.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 { StylingConfig } from './styling';\n\n// Owned merge rules for semantic utilities already used by the workspace.\n// These classify utilities; tokens.css generates their CSS.\nconst sizes = ['small', 'medium', 'large'];\n\nconst semanticMergeConfig: StylingConfig = {\n extend: {\n theme: { spacing: ['divider'], radius: sizes },\n classGroups: {\n shadow: [{ shadow: sizes }],\n opacity: [{ opacity: ['disabled'] }],\n 'font-size': [{ text: ['tiny', ...sizes] }],\n 'border-w': [{ border: sizes }],\n 'bg-image': [\n {\n 'bg-stripe-gradient': [\n 'default',\n 'primary',\n 'secondary',\n 'success',\n 'warning',\n 'danger',\n ],\n },\n ],\n transition: [\n 'transition-background',\n 'transition-colors-opacity',\n 'transition-width',\n 'transition-height',\n 'transition-size',\n 'transition-left',\n 'transition-transform-opacity',\n 'transition-transform-background',\n 'transition-transform-colors',\n 'transition-transform-colors-opacity',\n ],\n },\n },\n};\n\nexport default semanticMergeConfig;\n","import type { ClassProp } from 'tailwind-variants';\nimport type { ClassValue } from './tv';\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 * 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 */\nconst variantsToClassNames = <T extends TVRecord>(\n variants: T,\n className?: ClassValue | Record<string, ClassValue | undefined>,\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\nexport default variantsToClassNames;\n","import type { ArgumentArray } from 'classnames';\nimport type { ConfigExtension } from 'tailwind-merge';\nimport type { TV, TVConfig } from 'tailwind-variants';\n\nimport classNames from 'classnames';\nimport { extendTailwindMerge, mergeConfigs } from 'tailwind-merge';\nimport { tv as unmergedTV } from 'tailwind-variants/lite';\n\nimport { proseTwMergeClassGroups } from './proseTwMerge';\nimport semanticMergeConfig from './semanticMergeConfig';\nimport variantsToClassNames from './slotClassNames';\n\n// Preserve the full callable signature and recipe metadata (including generics).\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype Recipe = (...args: any[]) => any;\nconst rawRecipes = new WeakMap<Recipe, Recipe>();\n\nexport type StylingConfig = ConfigExtension<string, string>;\n\nexport interface Styling {\n readonly cn: (...classes: ArgumentArray) => string;\n /** Resolve a module-level pixel-utils recipe with this instance's merge rules. */\n readonly resolve: <T extends Recipe>(\n recipe: T,\n ...props: Parameters<T>\n ) => ReturnType<T>;\n readonly tv: TV;\n readonly variantsToClassNames: typeof variantsToClassNames;\n}\n\n// Configs contain validator functions, so structuredClone is unsuitable.\nconst copyConfig = <T>(value: T): T => {\n if (Array.isArray(value)) {\n return value.map(copyConfig) as T;\n }\n if (value && typeof value === 'object') {\n return Object.fromEntries(\n Object.entries(value).map(([key, entry]) => {\n return [key, copyConfig(entry)];\n }),\n ) as T;\n }\n return value;\n};\n\n/**\n * Creates isolated class helpers. No React or process-global configuration.\n * Recipe classes are concatenated by the lite engine, then merged once, after\n * defaults, variants, compounds, and caller overrides have all been collected.\n */\nexport const createStyling = (config: StylingConfig = {}): Styling => {\n const instanceConfig = copyConfig(config);\n const merge = extendTailwindMerge<string, string>(\n { extend: { classGroups: proseTwMergeClassGroups } },\n (defaults) => {\n return mergeConfigs(defaults, semanticMergeConfig);\n },\n (defaults) => {\n return mergeConfigs(defaults, instanceConfig);\n },\n );\n\n const resolveWith = (\n recipe: Recipe,\n props: unknown[],\n merger: (value: string) => string,\n ) => {\n const result = (rawRecipes.get(recipe) ?? recipe)(...props);\n const mergeResult = (value: string | undefined) => {\n return value ? merger(value) || undefined : value;\n };\n if (typeof result !== 'object' || result === null) {\n return mergeResult(result);\n }\n return Object.fromEntries(\n Object.entries(result).map(([slot, fn]) => {\n return [\n slot,\n (...slotProps: unknown[]) => {\n return mergeResult((fn as Recipe)(...slotProps));\n },\n ];\n }),\n );\n };\n\n // The generic TV signature is unchanged; only its final class resolution is\n // replaced. The lite engine retains metadata for extension without merging.\n const tv = ((options, recipeConfig?: TVConfig) => {\n const raw = unmergedTV(options, { twMerge: false, twMergeConfig: {} });\n const mergeConfig = copyConfig(recipeConfig?.twMergeConfig);\n const shouldMerge = recipeConfig?.twMerge !== false;\n // Keep the legacy top-level config fields accepted by Tailwind Variants.\n const normalizedConfig =\n mergeConfig && typeof mergeConfig !== 'function'\n ? {\n ...mergeConfig,\n extend: {\n theme: mergeConfig.theme,\n classGroups: mergeConfig.classGroups,\n conflictingClassGroupModifiers:\n mergeConfig.conflictingClassGroupModifiers,\n conflictingClassGroups: mergeConfig.conflictingClassGroups,\n ...mergeConfig.extend,\n },\n }\n : mergeConfig;\n const recipeMerge = normalizedConfig\n ? extendTailwindMerge<string, string>(\n { extend: { classGroups: proseTwMergeClassGroups } },\n (defaults) => {\n return mergeConfigs(defaults, semanticMergeConfig);\n },\n (defaults) => {\n return mergeConfigs(defaults, instanceConfig);\n },\n (defaults) => {\n return typeof normalizedConfig === 'function'\n ? normalizedConfig(defaults)\n : mergeConfigs(defaults, normalizedConfig);\n },\n )\n : merge;\n const wrapped = Object.assign((...props: unknown[]) => {\n return resolveWith(\n raw,\n props,\n !shouldMerge\n ? (v) => {\n return v;\n }\n : recipeMerge,\n );\n }, raw);\n rawRecipes.set(wrapped, raw);\n return wrapped;\n }) as TV;\n\n return Object.freeze({\n cn: (...classes: ArgumentArray) => {\n return merge(classNames(...classes));\n },\n tv,\n variantsToClassNames,\n resolve: (recipe, ...props) => {\n return resolveWith(recipe, props, merge);\n },\n });\n};\n\nexport const defaultStyling: Styling = createStyling();\n","import type { TV, VariantProps } from 'tailwind-variants';\n\nimport { defaultStyling } from './styling';\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 * Tailwind Variants recipe factory with isolated semantic class merging\n * Used to create variant definitions with slots and variants\n */\nexport const tv: TV = defaultStyling.tv;\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>> | ClassValue;\n\nexport { default as variantsToClassNames } from './slotClassNames';\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;;ACvBA,MAAM,QAAQ;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AO,qBAAqB,aAC/B,iBAAiB,QAAQ,IACzB,aAAa,UAAU,gBAAgB;EAC7C,CACF,IACA;EACJ,MAAM,UAAU,OAAO,QAAQ,GAAG,UAAqB;GACrD,OAAO,YACL,KACA,OACA,CAAC,eACI,MAAM;IACL,OAAO;GACT,IACA,WACN;EACF,GAAG,GAAG;EACN,WAAW,IAAI,SAAS,GAAG;EAC3B,OAAO;CACT;CAEA,OAAO,OAAO,OAAO;EACnB,KAAK,GAAG,YAA2B;GACjC,OAAO,MAAM,WAAW,GAAG,OAAO,CAAC;EACrC;EACA;EACA;EACA,UAAU,QAAQ,GAAG,UAAU;GAC7B,OAAO,YAAY,QAAQ,OAAO,KAAK;EACzC;CACF,CAAC;AACH;AAEA,MAAa,iBAA0B,cAAc;;;;;;ACxIrD,MAAa,KAAS,eAAe"}
|
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": "2.0.0-next.
|
|
5
|
+
"version": "2.0.0-next.2",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"types": "./dist/index.d.mts",
|
|
8
8
|
"sideEffects": [
|
|
@@ -51,5 +51,5 @@
|
|
|
51
51
|
"tailwind-merge": "3.7.0",
|
|
52
52
|
"tailwind-variants": "3.2.2"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "e6c186d8dfc102ea13e3a24a47f26907c983f813"
|
|
55
55
|
}
|