@fuf-stack/pixel-utils 1.0.4 → 1.0.6

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.cjs CHANGED
@@ -25,6 +25,23 @@ var cn = (...classes) => {
25
25
  return _tailwindmerge.twMerge.call(void 0, _classnames2.default.call(void 0, ...classes));
26
26
  };
27
27
 
28
+ // src/isTestEnvironment.ts
29
+ var isTestEnvironment = () => {
30
+ return typeof process !== "undefined" && (process.env.NODE_ENV === "test" || process.env.VITEST === "true");
31
+ };
32
+
33
+ // src/slugify.ts
34
+ var _slug = require('slug'); var _slug2 = _interopRequireDefault(_slug);
35
+ var slugify = (string, options) => {
36
+ var _a, _b;
37
+ const replacement = (_a = options == null ? void 0 : options.replacement) != null ? _a : "_";
38
+ const replaceDots = (_b = options == null ? void 0 : options.replaceDots) != null ? _b : false;
39
+ return _slug2.default.call(void 0, string, __spreadValues(__spreadProps(__spreadValues({}, _slug2.default.defaults.modes.rfc3986), {
40
+ charmap: __spreadValues(__spreadValues(__spreadValues({}, _slug2.default.defaults.modes.rfc3986.charmap), !replaceDots ? { ".": "." } : { ".": replacement }), replacement !== "-" ? { "-": "_" } : {}),
41
+ replacement
42
+ }), options != null ? options : {}));
43
+ };
44
+
28
45
  // src/theme.ts
29
46
  var _theme = require('@heroui/theme');
30
47
 
@@ -46,21 +63,11 @@ var variantsToClassNames = (variants, className, baseSlot) => {
46
63
  );
47
64
  };
48
65
 
49
- // src/slugify.ts
50
- var _slug = require('slug'); var _slug2 = _interopRequireDefault(_slug);
51
- var slugify = (string, options) => {
52
- const replacement = (options == null ? void 0 : options.replacement) || "_";
53
- const replaceDots = (options == null ? void 0 : options.replaceDots) || false;
54
- return _slug2.default.call(void 0, string, __spreadValues(__spreadProps(__spreadValues({}, _slug2.default.defaults.modes.rfc3986), {
55
- charmap: __spreadValues(__spreadValues(__spreadValues({}, _slug2.default.defaults.modes.rfc3986.charmap), replaceDots === false ? { ".": "." } : { ".": replacement }), replacement !== "-" ? { "-": "_" } : {}),
56
- replacement
57
- }), options || {}));
58
- };
59
66
 
60
67
 
61
68
 
62
69
 
63
70
 
64
71
 
65
- exports.cn = cn; exports.heroui = _theme.heroui; exports.slugify = slugify; exports.tv = tv; exports.variantsToClassNames = variantsToClassNames;
72
+ exports.cn = cn; exports.heroui = _theme.heroui; exports.isTestEnvironment = isTestEnvironment; exports.slugify = slugify; exports.tv = tv; exports.variantsToClassNames = variantsToClassNames;
66
73
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/pixels/pixels/packages/pixel-utils/dist/index.cjs","../src/cn.ts","../src/theme.ts","../src/tv.ts","../src/slugify.ts"],"names":["classNames"],"mappings":"AAAA,6KAAI,UAAU,EAAE,MAAM,CAAC,cAAc;AACrC,IAAI,WAAW,EAAE,MAAM,CAAC,gBAAgB;AACxC,IAAI,kBAAkB,EAAE,MAAM,CAAC,yBAAyB;AACxD,IAAI,oBAAoB,EAAE,MAAM,CAAC,qBAAqB;AACtD,IAAI,aAAa,EAAE,MAAM,CAAC,SAAS,CAAC,cAAc;AAClD,IAAI,aAAa,EAAE,MAAM,CAAC,SAAS,CAAC,oBAAoB;AACxD,IAAI,gBAAgB,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,IAAI,GAAG,IAAI,EAAE,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,CAAC,EAAE,EAAE,GAAG,CAAC,GAAG,EAAE,EAAE,KAAK;AAC/J,IAAI,eAAe,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG;AAC/B,EAAE,IAAI,CAAC,IAAI,KAAK,GAAG,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;AAChC,IAAI,GAAG,CAAC,YAAY,CAAC,IAAI,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;AJ+BA;AACE;AACA;AACA;AACA;AACA;AACF,iJAAC","file":"/home/runner/work/pixels/pixels/packages/pixel-utils/dist/index.cjs","sourcesContent":[null,"/* eslint-disable import/prefer-default-export */\nimport type { ArgumentArray } from 'classnames';\n\nimport classNames from 'classnames';\nimport { twMerge } from 'tailwind-merge';\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, `twMerge` is used to resolve any Tailwind CSS conflicts.\n return twMerge(classNames(...classes)) as unknown as string;\n};\n","/* eslint-disable import/prefer-default-export */\nexport { heroui } from '@heroui/theme';\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 = {\n (slotProps?: TVSlotProps | undefined): string;\n};\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","/* eslint-disable import/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 === false ? { '.': '.' } : { '.': replacement }),\n // convert hyphens to underscores (when replacement is not hyphen)\n ...(replacement !== '-' ? { '-': '_' } : {}),\n },\n replacement,\n ...(options || {}),\n });\n};\n"]}
1
+ {"version":3,"sources":["/home/runner/work/pixels/pixels/packages/pixel-utils/dist/index.cjs","../src/cn.ts","../src/isTestEnvironment.ts","../src/slugify.ts","../src/theme.ts","../src/tv.ts"],"names":["classNames"],"mappings":"AAAA,6KAAI,UAAU,EAAE,MAAM,CAAC,cAAc;AACrC,IAAI,WAAW,EAAE,MAAM,CAAC,gBAAgB;AACxC,IAAI,kBAAkB,EAAE,MAAM,CAAC,yBAAyB;AACxD,IAAI,oBAAoB,EAAE,MAAM,CAAC,qBAAqB;AACtD,IAAI,aAAa,EAAE,MAAM,CAAC,SAAS,CAAC,cAAc;AAClD,IAAI,aAAa,EAAE,MAAM,CAAC,SAAS,CAAC,oBAAoB;AACxD,IAAI,gBAAgB,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,IAAI,GAAG,IAAI,EAAE,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,CAAC,EAAE,EAAE,GAAG,CAAC,GAAG,EAAE,EAAE,KAAK;AAC/J,IAAI,eAAe,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG;AAC/B,EAAE,IAAI,CAAC,IAAI,KAAK,GAAG,EAAE,GAAG,CAAC,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A,MAAM,QAAA,EAAU,IAAA;AAChB,MAAA,MAAM,cAAA,EACJ,OAAO,UAAA,IAAc,SAAA,GAAY,KAAA,CAAM,OAAA,CAAQ,SAAS,EAAA,EACpD,UAAA,EACAA,WAAAA,CAAW,IAAI,CAAA;AAGrB,MAAA,GAAA,CAAI,OAAO,EAAA,EAAI,SAAA,CAAU;AAAA,QACvB,SAAA,EACE,SAAA,GAAY,KAAA,IAAS,SAAA,EAAW,cAAA,EAAgBA,WAAAA,CAAW,IAAI;AAAA,MACnE,CAAC,CAAA;AAED,MAAA,OAAO,GAAA;AAAA,IACT,CAAA;AAAA,IACA,CAAC;AAAA,EACH,CAAA;AACF,CAAA;AL1CA;AACE;AACA;AACA;AACA;AACA;AACA;AACF,gMAAC","file":"/home/runner/work/pixels/pixels/packages/pixel-utils/dist/index.cjs","sourcesContent":[null,"/* eslint-disable import-x/prefer-default-export */\nimport type { ArgumentArray } from 'classnames';\n\nimport classNames from 'classnames';\nimport { twMerge } from 'tailwind-merge';\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, `twMerge` is used to resolve any Tailwind CSS conflicts.\n return twMerge(classNames(...classes)) as unknown as string;\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\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","/* eslint-disable import-x/prefer-default-export */\nexport { heroui } from '@heroui/theme';\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"]}
package/dist/index.d.cts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { ArgumentArray } from 'classnames';
2
+ import { Options } from 'slug';
2
3
  import { VariantProps } from '@heroui/theme';
3
4
  export { heroui } from '@heroui/theme';
4
5
  import { TV, ClassProp } from 'tailwind-variants';
5
- import { Options } from 'slug';
6
6
 
7
7
  /**
8
8
  * A utility function that combines `classnames` and `tailwind-merge`.
@@ -21,6 +21,36 @@ import { Options } from 'slug';
21
21
  */
22
22
  declare const cn: (...classes: ArgumentArray) => string;
23
23
 
24
+ /**
25
+ * Checks if the code is running in a test environment.
26
+ *
27
+ * This helper safely detects test environments by checking:
28
+ * - Node.js: `process.env.NODE_ENV === 'test'` or `process.env.VITEST === 'true'`
29
+ * - Browser: Always returns `false` (production code)
30
+ *
31
+ * The check is safe for both Node.js and browser environments by verifying
32
+ * that `process` exists before accessing its properties.
33
+ *
34
+ * @returns `true` if running in a test environment, `false` otherwise
35
+ *
36
+ * @example
37
+ * ```ts
38
+ * if (isTestEnvironment()) {
39
+ * // Skip debouncing in tests for immediate snapshots
40
+ * return value;
41
+ * }
42
+ * // Normal production behavior with debouncing
43
+ * return debouncedValue;
44
+ * ```
45
+ */
46
+ declare const isTestEnvironment: () => boolean;
47
+
48
+ interface SlugifyOptions extends Options {
49
+ /** When true, dots are also replaced (default is false) */
50
+ replaceDots?: boolean;
51
+ }
52
+ declare const slugify: (string: string, options?: SlugifyOptions) => string;
53
+
24
54
  /**
25
55
  * Represents a class value which can be either a string or an array of strings
26
56
  * Used for handling both single class names and multiple class names
@@ -38,9 +68,7 @@ type TVSlotProps = {
38
68
  * Represents a tailwind-variants slot function
39
69
  * Takes optional TVSlotProps and returns a string of class names
40
70
  */
41
- type TVFunction = {
42
- (slotProps?: TVSlotProps | undefined): string;
43
- };
71
+ type TVFunction = (slotProps?: TVSlotProps) => string;
44
72
  /**
45
73
  * A record of slot names to their corresponding tailwind-variants functions
46
74
  * Used to type the variants parameter in variantsToClassNames
@@ -88,10 +116,4 @@ type TVClassName<Component extends (...args: any) => any> = Partial<Record<keyof
88
116
  */
89
117
  declare const variantsToClassNames: <T extends TVRecord>(variants: T, className?: ClassValue | Record<string, ClassValue>, baseSlot?: keyof T) => Record<keyof T, string>;
90
118
 
91
- interface SlugifyOptions extends Options {
92
- /** When true, dots are also replaced (default is false) */
93
- replaceDots?: boolean;
94
- }
95
- declare const slugify: (string: string, options?: SlugifyOptions) => string;
96
-
97
- export { type ClassValue, type TVClassName, type TVProps, cn, slugify, tv, variantsToClassNames };
119
+ export { type ClassValue, type TVClassName, type TVProps, cn, isTestEnvironment, slugify, tv, variantsToClassNames };
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { ArgumentArray } from 'classnames';
2
+ import { Options } from 'slug';
2
3
  import { VariantProps } from '@heroui/theme';
3
4
  export { heroui } from '@heroui/theme';
4
5
  import { TV, ClassProp } from 'tailwind-variants';
5
- import { Options } from 'slug';
6
6
 
7
7
  /**
8
8
  * A utility function that combines `classnames` and `tailwind-merge`.
@@ -21,6 +21,36 @@ import { Options } from 'slug';
21
21
  */
22
22
  declare const cn: (...classes: ArgumentArray) => string;
23
23
 
24
+ /**
25
+ * Checks if the code is running in a test environment.
26
+ *
27
+ * This helper safely detects test environments by checking:
28
+ * - Node.js: `process.env.NODE_ENV === 'test'` or `process.env.VITEST === 'true'`
29
+ * - Browser: Always returns `false` (production code)
30
+ *
31
+ * The check is safe for both Node.js and browser environments by verifying
32
+ * that `process` exists before accessing its properties.
33
+ *
34
+ * @returns `true` if running in a test environment, `false` otherwise
35
+ *
36
+ * @example
37
+ * ```ts
38
+ * if (isTestEnvironment()) {
39
+ * // Skip debouncing in tests for immediate snapshots
40
+ * return value;
41
+ * }
42
+ * // Normal production behavior with debouncing
43
+ * return debouncedValue;
44
+ * ```
45
+ */
46
+ declare const isTestEnvironment: () => boolean;
47
+
48
+ interface SlugifyOptions extends Options {
49
+ /** When true, dots are also replaced (default is false) */
50
+ replaceDots?: boolean;
51
+ }
52
+ declare const slugify: (string: string, options?: SlugifyOptions) => string;
53
+
24
54
  /**
25
55
  * Represents a class value which can be either a string or an array of strings
26
56
  * Used for handling both single class names and multiple class names
@@ -38,9 +68,7 @@ type TVSlotProps = {
38
68
  * Represents a tailwind-variants slot function
39
69
  * Takes optional TVSlotProps and returns a string of class names
40
70
  */
41
- type TVFunction = {
42
- (slotProps?: TVSlotProps | undefined): string;
43
- };
71
+ type TVFunction = (slotProps?: TVSlotProps) => string;
44
72
  /**
45
73
  * A record of slot names to their corresponding tailwind-variants functions
46
74
  * Used to type the variants parameter in variantsToClassNames
@@ -88,10 +116,4 @@ type TVClassName<Component extends (...args: any) => any> = Partial<Record<keyof
88
116
  */
89
117
  declare const variantsToClassNames: <T extends TVRecord>(variants: T, className?: ClassValue | Record<string, ClassValue>, baseSlot?: keyof T) => Record<keyof T, string>;
90
118
 
91
- interface SlugifyOptions extends Options {
92
- /** When true, dots are also replaced (default is false) */
93
- replaceDots?: boolean;
94
- }
95
- declare const slugify: (string: string, options?: SlugifyOptions) => string;
96
-
97
- export { type ClassValue, type TVClassName, type TVProps, cn, slugify, tv, variantsToClassNames };
119
+ export { type ClassValue, type TVClassName, type TVProps, cn, isTestEnvironment, slugify, tv, variantsToClassNames };
package/dist/index.js CHANGED
@@ -25,6 +25,23 @@ var cn = (...classes) => {
25
25
  return twMerge(classNames(...classes));
26
26
  };
27
27
 
28
+ // src/isTestEnvironment.ts
29
+ var isTestEnvironment = () => {
30
+ return typeof process !== "undefined" && (process.env.NODE_ENV === "test" || process.env.VITEST === "true");
31
+ };
32
+
33
+ // src/slugify.ts
34
+ import slug from "slug";
35
+ var slugify = (string, options) => {
36
+ var _a, _b;
37
+ const replacement = (_a = options == null ? void 0 : options.replacement) != null ? _a : "_";
38
+ const replaceDots = (_b = options == null ? void 0 : options.replaceDots) != null ? _b : false;
39
+ return slug(string, __spreadValues(__spreadProps(__spreadValues({}, slug.defaults.modes.rfc3986), {
40
+ charmap: __spreadValues(__spreadValues(__spreadValues({}, slug.defaults.modes.rfc3986.charmap), !replaceDots ? { ".": "." } : { ".": replacement }), replacement !== "-" ? { "-": "_" } : {}),
41
+ replacement
42
+ }), options != null ? options : {}));
43
+ };
44
+
28
45
  // src/theme.ts
29
46
  import { heroui } from "@heroui/theme";
30
47
 
@@ -45,20 +62,10 @@ var variantsToClassNames = (variants, className, baseSlot) => {
45
62
  {}
46
63
  );
47
64
  };
48
-
49
- // src/slugify.ts
50
- import slug from "slug";
51
- var slugify = (string, options) => {
52
- const replacement = (options == null ? void 0 : options.replacement) || "_";
53
- const replaceDots = (options == null ? void 0 : options.replaceDots) || false;
54
- return slug(string, __spreadValues(__spreadProps(__spreadValues({}, slug.defaults.modes.rfc3986), {
55
- charmap: __spreadValues(__spreadValues(__spreadValues({}, slug.defaults.modes.rfc3986.charmap), replaceDots === false ? { ".": "." } : { ".": replacement }), replacement !== "-" ? { "-": "_" } : {}),
56
- replacement
57
- }), options || {}));
58
- };
59
65
  export {
60
66
  cn,
61
67
  heroui,
68
+ isTestEnvironment,
62
69
  slugify,
63
70
  tv,
64
71
  variantsToClassNames
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/cn.ts","../src/theme.ts","../src/tv.ts","../src/slugify.ts"],"sourcesContent":["/* eslint-disable import/prefer-default-export */\nimport type { ArgumentArray } from 'classnames';\n\nimport classNames from 'classnames';\nimport { twMerge } from 'tailwind-merge';\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, `twMerge` is used to resolve any Tailwind CSS conflicts.\n return twMerge(classNames(...classes)) as unknown as string;\n};\n","/* eslint-disable import/prefer-default-export */\nexport { heroui } from '@heroui/theme';\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 = {\n (slotProps?: TVSlotProps | undefined): string;\n};\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","/* eslint-disable import/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 === false ? { '.': '.' } : { '.': replacement }),\n // convert hyphens to underscores (when replacement is not hyphen)\n ...(replacement !== '-' ? { '-': '_' } : {}),\n },\n replacement,\n ...(options || {}),\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAGA,OAAO,gBAAgB;AACvB,SAAS,eAAe;AAiBjB,IAAM,KAAK,IAAI,YAA2B;AAG/C,SAAO,QAAQ,WAAW,GAAG,OAAO,CAAC;AACvC;;;ACxBA,SAAS,cAAc;;;ACEvB,SAAS,MAAM,wBAAwB;AAmChC,IAAM,KAAS;AA4Cf,IAAM,uBAAuB,CAClC,UACA,WACA,aAC4B;AAC5B,QAAMA,cACJ,OAAO,cAAc,YAAY,CAAC,MAAM,QAAQ,SAAS,IAAI,YAAY,CAAC;AAE5E,SAAO,OAAO,QAAQ,QAAQ,EAAE;AAAA,IAC9B,CAAC,KAAK,CAAC,MAAM,SAAS,MAAM;AAC1B,YAAM,UAAU;AAChB,YAAM,gBACJ,OAAO,cAAc,YAAY,MAAM,QAAQ,SAAS,IACpD,YACAA,YAAW,IAAI;AAGrB,UAAI,OAAO,IAAI,UAAU;AAAA,QACvB,WACE,YAAY,SAAS,WAAW,gBAAgBA,YAAW,IAAI;AAAA,MACnE,CAAC;AAED,aAAO;AAAA,IACT;AAAA,IACA,CAAC;AAAA,EACH;AACF;;;ACxGA,OAAO,UAAU;AAOV,IAAM,UAAU,CAAC,QAAgB,YAA6B;AACnE,QAAM,eAAc,mCAAS,gBAAe;AAC5C,QAAM,eAAc,mCAAS,gBAAe;AAE5C,SAAO,KAAK,QAAQ,gDACf,KAAK,SAAS,MAAM,UADL;AAAA,IAElB,SAAS,iDACJ,KAAK,SAAS,MAAM,QAAQ,UAE3B,gBAAgB,QAAQ,EAAE,KAAK,IAAI,IAAI,EAAE,KAAK,YAAY,IAE1D,gBAAgB,MAAM,EAAE,KAAK,IAAI,IAAI,CAAC;AAAA,IAE5C;AAAA,MACI,WAAW,CAAC,EACjB;AACH;","names":["classNames"]}
1
+ {"version":3,"sources":["../src/cn.ts","../src/isTestEnvironment.ts","../src/slugify.ts","../src/theme.ts","../src/tv.ts"],"sourcesContent":["/* eslint-disable import-x/prefer-default-export */\nimport type { ArgumentArray } from 'classnames';\n\nimport classNames from 'classnames';\nimport { twMerge } from 'tailwind-merge';\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, `twMerge` is used to resolve any Tailwind CSS conflicts.\n return twMerge(classNames(...classes)) as unknown as string;\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\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","/* eslint-disable import-x/prefer-default-export */\nexport { heroui } from '@heroui/theme';\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":";;;;;;;;;;;;;;;;;;;;;AAGA,OAAO,gBAAgB;AACvB,SAAS,eAAe;AAiBjB,IAAM,KAAK,IAAI,YAA2B;AAG/C,SAAO,QAAQ,WAAW,GAAG,OAAO,CAAC;AACvC;;;ACDO,IAAM,oBAAoB,MAAe;AAG9C,SACE,OAAO,YAAY,gBAClB,QAAQ,IAAI,aAAa,UAAU,QAAQ,IAAI,WAAW;AAE/D;;;AC3BA,OAAO,UAAU;AAOV,IAAM,UAAU,CAAC,QAAgB,YAA6B;AAXrE;AAYE,QAAM,eAAc,wCAAS,gBAAT,YAAwB;AAC5C,QAAM,eAAc,wCAAS,gBAAT,YAAwB;AAE5C,SAAO,KAAK,QAAQ,gDACf,KAAK,SAAS,MAAM,UADL;AAAA,IAElB,SAAS,iDACJ,KAAK,SAAS,MAAM,QAAQ,UAE3B,CAAC,cAAc,EAAE,KAAK,IAAI,IAAI,EAAE,KAAK,YAAY,IAEjD,gBAAgB,MAAM,EAAE,KAAK,IAAI,IAAI,CAAC;AAAA,IAE5C;AAAA,MACI,4BAAW,CAAC,EACjB;AACH;;;AC1BA,SAAS,cAAc;;;ACEvB,SAAS,MAAM,wBAAwB;AAiChC,IAAM,KAAS;AA4Cf,IAAM,uBAAuB,CAClC,UACA,WACA,aAC4B;AAC5B,QAAMA,cACJ,OAAO,cAAc,YAAY,CAAC,MAAM,QAAQ,SAAS,IAAI,YAAY,CAAC;AAE5E,SAAO,OAAO,QAAQ,QAAQ,EAAE;AAAA,IAC9B,CAAC,KAAK,CAAC,MAAM,SAAS,MAAM;AAC1B,YAAM,UAAU;AAChB,YAAM,gBACJ,OAAO,cAAc,YAAY,MAAM,QAAQ,SAAS,IACpD,YACAA,YAAW,IAAI;AAGrB,UAAI,OAAO,IAAI,UAAU;AAAA,QACvB,WACE,YAAY,SAAS,WAAW,gBAAgBA,YAAW,IAAI;AAAA,MACnE,CAAC;AAED,aAAO;AAAA,IACT;AAAA,IACA,CAAC;AAAA,EACH;AACF;","names":["classNames"]}
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.0.4",
5
+ "version": "1.0.6",
6
6
  "type": "module",
7
7
  "main": "./dist/index.cjs",
8
8
  "module": "./dist/index.js",
@@ -36,17 +36,21 @@
36
36
  "bugs": {
37
37
  "url": "https://github.com/fuf-stack/pixels/issues"
38
38
  },
39
+ "scripts": {
40
+ "build": "tsup --config node_modules/@repo/tsup-config/config.ts",
41
+ "prepack": "pnpm build"
42
+ },
43
+ "peerDependencies": {
44
+ "tailwind-merge": "*",
45
+ "tailwind-variants": "*"
46
+ },
39
47
  "dependencies": {
40
48
  "@heroui/theme": "2.4.20",
41
49
  "classnames": "2.5.1",
42
- "slug": "9.1.0",
43
- "tailwind-merge": "3.3.1",
44
- "tailwind-variants": "3.1.1"
50
+ "slug": "9.1.0"
45
51
  },
46
52
  "devDependencies": {
47
53
  "@types/slug": "5.0.9"
48
54
  },
49
- "scripts": {
50
- "build": "tsup --config node_modules/@repo/tsup-config/config.ts"
51
- }
55
+ "gitHead": "b1ddf3bd7472701d37ad8f100a5b0b311423e639"
52
56
  }