@fuf-stack/pixel-utils 0.4.3 → 0.5.1
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 +37 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -3
- package/dist/index.d.ts +6 -3
- package/dist/index.js +36 -2
- package/dist/index.js.map +1 -1
- package/package.json +5 -3
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,24 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
|
|
21
|
+
// src/cn.ts
|
|
2
22
|
var _classnames = require('classnames'); var _classnames2 = _interopRequireDefault(_classnames);
|
|
3
23
|
var _tailwindmerge = require('tailwind-merge');
|
|
4
24
|
var cn = (...classes) => {
|
|
@@ -6,7 +26,7 @@ var cn = (...classes) => {
|
|
|
6
26
|
};
|
|
7
27
|
|
|
8
28
|
// src/theme.ts
|
|
9
|
-
var _theme = require('@
|
|
29
|
+
var _theme = require('@heroui/theme');
|
|
10
30
|
|
|
11
31
|
// src/tv.ts
|
|
12
32
|
var _tailwindvariants = require('tailwind-variants');
|
|
@@ -26,9 +46,23 @@ var variantsToClassNames = (variants, className, baseSlot) => {
|
|
|
26
46
|
);
|
|
27
47
|
};
|
|
28
48
|
|
|
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
|
+
return _slug2.default.call(void 0, string, __spreadValues(__spreadProps(__spreadValues({}, _slug2.default.defaults.modes.rfc3986), {
|
|
54
|
+
charmap: __spreadValues(__spreadProps(__spreadValues({}, _slug2.default.defaults.modes.rfc3986.charmap), {
|
|
55
|
+
// allow dots by default
|
|
56
|
+
".": "."
|
|
57
|
+
}), replacement !== "-" ? { "-": "_" } : {}),
|
|
58
|
+
replacement
|
|
59
|
+
}), options || {}));
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
|
|
29
63
|
|
|
30
64
|
|
|
31
65
|
|
|
32
66
|
|
|
33
|
-
exports.cn = cn; exports.
|
|
67
|
+
exports.cn = cn; exports.heroui = _theme.heroui; exports.slugify = slugify; exports.tv = tv; exports.variantsToClassNames = variantsToClassNames;
|
|
34
68
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -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"],"names":["classNames"],"mappings":"AAAA;
|
|
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":"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","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\nexport const slugify = (string: string, options?: SlugOptions) => {\n const replacement = options?.replacement || '_';\n return slug(string, {\n ...slug.defaults.modes.rfc3986,\n charmap: {\n ...slug.defaults.modes.rfc3986.charmap,\n // allow dots by default\n '.': '.',\n // convert hyphens to underscores (when replacement is not hyphen)\n ...(replacement !== '-' ? { '-': '_' } : {}),\n },\n replacement,\n ...(options || {}),\n });\n};\n"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { ArgumentArray } from 'classnames';
|
|
2
|
-
import { VariantProps } from '@
|
|
3
|
-
export {
|
|
2
|
+
import { VariantProps } from '@heroui/theme';
|
|
3
|
+
export { heroui } from '@heroui/theme';
|
|
4
4
|
import { TV, ClassProp } from 'tailwind-variants';
|
|
5
|
+
import { Options } from 'slug';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* A utility function that combines `classnames` and `tailwind-merge`.
|
|
@@ -87,4 +88,6 @@ type TVClassName<Component extends (...args: any) => any> = Partial<Record<keyof
|
|
|
87
88
|
*/
|
|
88
89
|
declare const variantsToClassNames: <T extends TVRecord>(variants: T, className?: ClassValue | Record<string, ClassValue>, baseSlot?: keyof T) => Record<keyof T, string>;
|
|
89
90
|
|
|
90
|
-
|
|
91
|
+
declare const slugify: (string: string, options?: Options) => string;
|
|
92
|
+
|
|
93
|
+
export { type ClassValue, type TVClassName, type TVProps, cn, slugify, tv, variantsToClassNames };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { ArgumentArray } from 'classnames';
|
|
2
|
-
import { VariantProps } from '@
|
|
3
|
-
export {
|
|
2
|
+
import { VariantProps } from '@heroui/theme';
|
|
3
|
+
export { heroui } from '@heroui/theme';
|
|
4
4
|
import { TV, ClassProp } from 'tailwind-variants';
|
|
5
|
+
import { Options } from 'slug';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* A utility function that combines `classnames` and `tailwind-merge`.
|
|
@@ -87,4 +88,6 @@ type TVClassName<Component extends (...args: any) => any> = Partial<Record<keyof
|
|
|
87
88
|
*/
|
|
88
89
|
declare const variantsToClassNames: <T extends TVRecord>(variants: T, className?: ClassValue | Record<string, ClassValue>, baseSlot?: keyof T) => Record<keyof T, string>;
|
|
89
90
|
|
|
90
|
-
|
|
91
|
+
declare const slugify: (string: string, options?: Options) => string;
|
|
92
|
+
|
|
93
|
+
export { type ClassValue, type TVClassName, type TVProps, cn, slugify, tv, variantsToClassNames };
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
|
|
1
21
|
// src/cn.ts
|
|
2
22
|
import classNames from "classnames";
|
|
3
23
|
import { twMerge } from "tailwind-merge";
|
|
@@ -6,7 +26,7 @@ var cn = (...classes) => {
|
|
|
6
26
|
};
|
|
7
27
|
|
|
8
28
|
// src/theme.ts
|
|
9
|
-
import {
|
|
29
|
+
import { heroui } from "@heroui/theme";
|
|
10
30
|
|
|
11
31
|
// src/tv.ts
|
|
12
32
|
import { tv as tailwindVariants } from "tailwind-variants";
|
|
@@ -25,9 +45,23 @@ var variantsToClassNames = (variants, className, baseSlot) => {
|
|
|
25
45
|
{}
|
|
26
46
|
);
|
|
27
47
|
};
|
|
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
|
+
return slug(string, __spreadValues(__spreadProps(__spreadValues({}, slug.defaults.modes.rfc3986), {
|
|
54
|
+
charmap: __spreadValues(__spreadProps(__spreadValues({}, slug.defaults.modes.rfc3986.charmap), {
|
|
55
|
+
// allow dots by default
|
|
56
|
+
".": "."
|
|
57
|
+
}), replacement !== "-" ? { "-": "_" } : {}),
|
|
58
|
+
replacement
|
|
59
|
+
}), options || {}));
|
|
60
|
+
};
|
|
28
61
|
export {
|
|
29
62
|
cn,
|
|
30
|
-
|
|
63
|
+
heroui,
|
|
64
|
+
slugify,
|
|
31
65
|
tv,
|
|
32
66
|
variantsToClassNames
|
|
33
67
|
};
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/cn.ts","../src/theme.ts","../src/tv.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 {
|
|
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\nexport const slugify = (string: string, options?: SlugOptions) => {\n const replacement = options?.replacement || '_';\n return slug(string, {\n ...slug.defaults.modes.rfc3986,\n charmap: {\n ...slug.defaults.modes.rfc3986.charmap,\n // allow dots by default\n '.': '.',\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;AAEV,IAAM,UAAU,CAAC,QAAgB,YAA0B;AAChE,QAAM,eAAc,mCAAS,gBAAe;AAC5C,SAAO,KAAK,QAAQ,gDACf,KAAK,SAAS,MAAM,UADL;AAAA,IAElB,SAAS,gDACJ,KAAK,SAAS,MAAM,QAAQ,UADxB;AAAA;AAAA,MAGP,KAAK;AAAA,QAED,gBAAgB,MAAM,EAAE,KAAK,IAAI,IAAI,CAAC;AAAA,IAE5C;AAAA,MACI,WAAW,CAAC,EACjB;AACH;","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": "Hannes Tiede",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.5.1",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "./dist/index.cjs",
|
|
8
8
|
"module": "./dist/index.js",
|
|
@@ -37,12 +37,14 @@
|
|
|
37
37
|
"url": "https://github.com/fuf-stack/pixels/issues"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@
|
|
40
|
+
"@heroui/theme": "2.4.11",
|
|
41
41
|
"classnames": "2.5.1",
|
|
42
|
+
"slug": "9.1.0",
|
|
42
43
|
"tailwind-merge": "2.6.0",
|
|
43
|
-
"tailwind-variants": "0.3.
|
|
44
|
+
"tailwind-variants": "0.3.1"
|
|
44
45
|
},
|
|
45
46
|
"devDependencies": {
|
|
47
|
+
"@types/slug": "5.0.9",
|
|
46
48
|
"@repo/tsup-config": "0.0.1"
|
|
47
49
|
},
|
|
48
50
|
"scripts": {
|