@sohanemon/utils 1.0.1 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
File without changes
package/dist/index.d.ts CHANGED
@@ -1,6 +1,4 @@
1
1
  import { type ClassValue } from 'clsx';
2
2
  export declare function cn(...inputs: ClassValue[]): string;
3
3
  export declare function isNavActive(href: string, path: string): boolean;
4
- export declare function kebabCase(camelCase: string): string;
5
- export declare function cssColorVariable(colors: Record<string, string>): Record<string, string>;
6
4
  export declare function cleanSrc(src: string): string;
package/dist/index.js CHANGED
@@ -1,57 +1,13 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.cleanSrc = exports.cssColorVariable = exports.kebabCase = exports.isNavActive = exports.cn = void 0;
4
- const clsx_1 = require("clsx");
5
- const tailwind_merge_1 = require("tailwind-merge");
6
- function cn(...inputs) {
7
- return (0, tailwind_merge_1.twMerge)((0, clsx_1.clsx)(inputs));
1
+ import { clsx } from 'clsx';
2
+ import { twMerge } from 'tailwind-merge';
3
+ export function cn(...inputs) {
4
+ return twMerge(clsx(inputs));
8
5
  }
9
- exports.cn = cn;
10
- function isNavActive(href, path) {
11
- return href === '/' ? path === '/' : path === null || path === void 0 ? void 0 : path.includes(href);
6
+ export function isNavActive(href, path) {
7
+ return href === '/' ? path === '/' : path?.includes(href);
12
8
  }
13
- exports.isNavActive = isNavActive;
14
- function hexToHSLFormatted(hexColor) {
15
- var _a;
16
- const [r, g, b] = (_a = hexColor.match(/\w\w/g)) === null || _a === void 0 ? void 0 : _a.map((c) => parseInt(c, 16) / 255);
17
- const maxVal = Math.max(r, g, b), minVal = Math.min(r, g, b);
18
- const lightness = (maxVal + minVal) / 2;
19
- const delta = maxVal - minVal;
20
- const saturation = delta === 0 ? 0 : delta / (1 - Math.abs(2 * lightness - 1));
21
- let hue = delta !== 0
22
- ? maxVal === r
23
- ? ((g - b) / delta + (g < b ? 6 : 0)) * 60
24
- : maxVal === g
25
- ? ((b - r) / delta + 2) * 60
26
- : ((r - g) / delta + 4) * 60
27
- : 0;
28
- if (hue < 0)
29
- hue += 360;
30
- return `${Math.round(hue)} ${Math.round(saturation * 100)}% ${Math.round(lightness * 100)}%`;
31
- }
32
- function extractHSLValues(input) {
33
- if (input.includes('#'))
34
- return hexToHSLFormatted(input);
35
- const matches = input.match(/hsla?\(([\d.]+),\s*([\d.]+)%,\s*([\d.]+)%(?:,\s*[\d.]+)?\)/);
36
- if (!matches)
37
- throw new Error(`Invalid HSL format: ${input}`);
38
- return `${matches[1]} ${matches[2]}% ${matches[3]}%`;
39
- }
40
- function kebabCase(camelCase) {
41
- return camelCase.replace(/[A-Z]+(?![a-z])|[A-Z]/g, ($, ofs) => (ofs ? '-' : '') + $.toLowerCase());
42
- }
43
- exports.kebabCase = kebabCase;
44
- function cssColorVariable(colors) {
45
- const temp = {};
46
- Object.keys(colors).map((key) => {
47
- temp[`--${kebabCase(key)}`] = extractHSLValues(colors[key]);
48
- });
49
- return temp;
50
- }
51
- exports.cssColorVariable = cssColorVariable;
52
- function cleanSrc(src) {
9
+ export function cleanSrc(src) {
53
10
  if (src.includes('/public/'))
54
11
  return src.replace('/public/', '/');
55
12
  return src;
56
13
  }
57
- exports.cleanSrc = cleanSrc;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sohanemon/utils",
3
- "version": "1.0.1",
3
+ "version": "2.0.0",
4
4
  "description": "",
5
5
  "source": "./src/index.ts",
6
6
  "main": "./dist/index.js",
@@ -11,8 +11,7 @@
11
11
  ],
12
12
  "scripts": {
13
13
  "build": "tsc",
14
- "build:watch": "tsc --watch",
15
- "test": "echo \"Error: no test specified\" && exit 1"
14
+ "build:watch": "tsc --watch"
16
15
  },
17
16
  "keywords": [],
18
17
  "author": "sohanemon",