solid-tiny-utils 0.4.2 → 0.6.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.
Files changed (70) hide show
  1. package/dist/{chunk-ZGYORUAX.js → chunk-6G7GFZV2.js} +1 -1
  2. package/dist/{chunk-ILGNNUQK.js → chunk-6OVLJ45M.js} +5 -5
  3. package/dist/chunk-ACZGS7DG.js +72 -0
  4. package/dist/{chunk-CSAKXWF3.js → chunk-BT47ISVC.js} +2 -2
  5. package/dist/{chunk-KVG6TCSE.js → chunk-DKZ3RJJI.js} +20 -2
  6. package/dist/chunk-KFLH3AZ6.js +40 -0
  7. package/dist/{chunk-KFWZFQMB.js → chunk-KKFGUHFR.js} +1 -1
  8. package/dist/chunk-LEWF7QAQ.js +47 -0
  9. package/dist/chunk-PD6VHMH6.js +26 -0
  10. package/dist/{chunk-BGLY6NJK.js → chunk-QPEF6LHH.js} +2 -2
  11. package/dist/{chunk-PBALVUKK.js → chunk-QQVSG76Z.js} +2 -2
  12. package/dist/chunk-S7U3LZNS.js +23 -0
  13. package/dist/chunk-TDJLPDJF.js +66 -0
  14. package/dist/{chunk-OUAI75QC.js → chunk-TGWWPUWD.js} +3 -3
  15. package/dist/chunk-U5LQ2AS5.js +0 -0
  16. package/dist/{chunk-NFDGLC4A.js → chunk-WJHRONQU.js} +2 -2
  17. package/dist/{chunk-PNR5G432.js → chunk-Y4GYGFIT.js} +1 -1
  18. package/dist/{chunk-M5A3VVYI.js → chunk-YK5QQQ43.js} +1 -1
  19. package/dist/color/hex-rgb.d.ts +36 -0
  20. package/dist/color/hex-rgb.js +15 -0
  21. package/dist/color/index.d.ts +3 -0
  22. package/dist/color/index.js +30 -0
  23. package/dist/color/oklch-rgb.d.ts +49 -0
  24. package/dist/color/oklch-rgb.js +15 -0
  25. package/dist/color/validation.d.ts +26 -0
  26. package/dist/color/validation.js +18 -0
  27. package/dist/dom/css.d.ts +5 -1
  28. package/dist/dom/css.js +14 -9
  29. package/dist/dom/index.d.ts +2 -1
  30. package/dist/dom/index.js +14 -9
  31. package/dist/event/create-click-outside.js +11 -10
  32. package/dist/event/create-event-listener.js +11 -10
  33. package/dist/event/create-intersection-observer.d.ts +6 -0
  34. package/dist/event/create-intersection-observer.js +16 -0
  35. package/dist/event/create-visibility-observer.d.ts +12 -0
  36. package/dist/event/create-visibility-observer.js +16 -0
  37. package/dist/event/index.d.ts +2 -0
  38. package/dist/event/index.js +21 -12
  39. package/dist/event/make-event-listener.js +10 -9
  40. package/dist/fn/create-debounce.js +9 -8
  41. package/dist/fn/create-loop-exec.js +9 -8
  42. package/dist/fn/create-throttle.js +9 -8
  43. package/dist/fn/index.js +9 -8
  44. package/dist/index.d.ts +14 -7
  45. package/dist/index.js +72 -27
  46. package/dist/reactive/access.js +8 -7
  47. package/dist/reactive/create-debounce-watch.js +9 -8
  48. package/dist/reactive/index.js +9 -8
  49. package/dist/types/index.d.ts +1 -1
  50. package/dist/types/maybe.d.ts +2 -1
  51. package/dist/{lodash → utils}/array.js +2 -2
  52. package/dist/{lodash → utils}/async.js +1 -1
  53. package/dist/{lodash → utils}/index.d.ts +1 -0
  54. package/dist/{lodash → utils}/index.js +28 -16
  55. package/dist/{lodash → utils}/is.js +1 -1
  56. package/dist/utils/number.d.ts +113 -0
  57. package/dist/utils/number.js +14 -0
  58. package/dist/utils/object.d.ts +10 -0
  59. package/dist/utils/object.js +7 -0
  60. package/dist/utils/random.js +14 -0
  61. package/dist/{lodash → utils}/str.js +1 -1
  62. package/package.json +10 -8
  63. package/dist/lodash/random.js +0 -14
  64. /package/dist/{chunk-B6TZK2S5.js → chunk-BLX3XSA6.js} +0 -0
  65. /package/dist/{chunk-OECLQ3OT.js → chunk-LUFOWTRW.js} +0 -0
  66. /package/dist/{lodash → utils}/array.d.ts +0 -0
  67. /package/dist/{lodash → utils}/async.d.ts +0 -0
  68. /package/dist/{lodash → utils}/is.d.ts +0 -0
  69. /package/dist/{lodash → utils}/random.d.ts +0 -0
  70. /package/dist/{lodash → utils}/str.d.ts +0 -0
@@ -1,4 +1,4 @@
1
- // src/lodash/is.ts
1
+ // src/utils/is.ts
2
2
  import { isServer } from "solid-js/web";
3
3
  var isSymbol = (value) => {
4
4
  return !!value && value.constructor === Symbol;
@@ -1,21 +1,21 @@
1
1
  import {
2
2
  makeEventListener
3
- } from "./chunk-OUAI75QC.js";
3
+ } from "./chunk-TGWWPUWD.js";
4
4
  import {
5
5
  noop
6
- } from "./chunk-BGLY6NJK.js";
6
+ } from "./chunk-QPEF6LHH.js";
7
7
  import {
8
8
  access
9
- } from "./chunk-M5A3VVYI.js";
9
+ } from "./chunk-YK5QQQ43.js";
10
10
  import {
11
11
  createWatch
12
12
  } from "./chunk-4L6FK7MF.js";
13
13
  import {
14
14
  clearArray
15
- } from "./chunk-CSAKXWF3.js";
15
+ } from "./chunk-BT47ISVC.js";
16
16
  import {
17
17
  isArray
18
- } from "./chunk-ZGYORUAX.js";
18
+ } from "./chunk-6G7GFZV2.js";
19
19
 
20
20
  // src/event/create-event-listener.ts
21
21
  function createEventListener(...args) {
@@ -0,0 +1,72 @@
1
+ import {
2
+ clamp,
3
+ max
4
+ } from "./chunk-PD6VHMH6.js";
5
+
6
+ // src/color/oklch-rgb.ts
7
+ var PI_180 = Math.PI / 180;
8
+ var INV_PI_180 = 180 / Math.PI;
9
+ var linearToSRGB = (x) => x <= 31308e-7 ? 12.92 * x : 1.055 * x ** (1 / 2.4) - 0.055;
10
+ var sRGBToLinear = (x) => x <= 0.04045 ? x / 12.92 : ((x + 0.055) / 1.055) ** 2.4;
11
+ function normalizeHue(hue) {
12
+ return (hue % 360 + 360) % 360;
13
+ }
14
+ function oklchToRgb(oklch) {
15
+ const { l, c, h } = oklch;
16
+ const clampedL = clamp(l, 0, 1);
17
+ const clampedC = max(0, c);
18
+ const normalizedH = normalizeHue(h);
19
+ const a_ = clampedC * Math.cos(normalizedH * PI_180);
20
+ const b_ = clampedC * Math.sin(normalizedH * PI_180);
21
+ const L = clampedL;
22
+ const A = a_;
23
+ const B = b_;
24
+ const l_ = L + 0.3963377774 * A + 0.2158037573 * B;
25
+ const m_ = L - 0.1055613458 * A - 0.0638541728 * B;
26
+ const s_ = L - 0.0894841775 * A - 1.291485548 * B;
27
+ const l3 = l_ ** 3;
28
+ const m3 = m_ ** 3;
29
+ const s3 = s_ ** 3;
30
+ let r = 4.0767416621 * l3 - 3.3077115913 * m3 + 0.2309699292 * s3;
31
+ let g = -1.2684380046 * l3 + 2.6097574011 * m3 - 0.3413193965 * s3;
32
+ let b = -0.0041960863 * l3 - 0.7034186147 * m3 + 1.707614701 * s3;
33
+ r = linearToSRGB(r);
34
+ g = linearToSRGB(g);
35
+ b = linearToSRGB(b);
36
+ return {
37
+ r: Math.round(clamp(r) * 255),
38
+ g: Math.round(clamp(g) * 255),
39
+ b: Math.round(clamp(b) * 255)
40
+ };
41
+ }
42
+ function rgbToOklch(rgb) {
43
+ const r = clamp(rgb.r, 0, 255);
44
+ const g = clamp(rgb.g, 0, 255);
45
+ const b = clamp(rgb.b, 0, 255);
46
+ const rLinear = sRGBToLinear(r / 255);
47
+ const gLinear = sRGBToLinear(g / 255);
48
+ const bLinear = sRGBToLinear(b / 255);
49
+ const l_ = Math.cbrt(
50
+ 0.4122214708 * rLinear + 0.5363325363 * gLinear + 0.0514459929 * bLinear
51
+ );
52
+ const m_ = Math.cbrt(
53
+ 0.2119034982 * rLinear + 0.6806995451 * gLinear + 0.1073969566 * bLinear
54
+ );
55
+ const s_ = Math.cbrt(
56
+ 0.0883024619 * rLinear + 0.2817188376 * gLinear + 0.6299787005 * bLinear
57
+ );
58
+ const L = 0.2104542553 * l_ + 0.793617785 * m_ - 0.0040720468 * s_;
59
+ const A = 1.9779984951 * l_ - 2.428592205 * m_ + 0.4505937099 * s_;
60
+ const B = 0.0259040371 * l_ + 0.7827717662 * m_ - 0.808675766 * s_;
61
+ const c = Math.sqrt(A * A + B * B);
62
+ let h = Math.atan2(B, A) * INV_PI_180;
63
+ if (h < 0) {
64
+ h += 360;
65
+ }
66
+ return { l: L, c, h };
67
+ }
68
+
69
+ export {
70
+ oklchToRgb,
71
+ rgbToOklch
72
+ };
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  isFn
3
- } from "./chunk-ZGYORUAX.js";
3
+ } from "./chunk-6G7GFZV2.js";
4
4
 
5
- // src/lodash/array.ts
5
+ // src/utils/array.ts
6
6
  var iterate = (count, func, initValue) => {
7
7
  let value = initValue;
8
8
  for (let i = 1; i <= count; i++) {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  isClient
3
- } from "./chunk-ZGYORUAX.js";
3
+ } from "./chunk-6G7GFZV2.js";
4
4
 
5
5
  // src/dom/css.ts
6
6
  var alreadyInjected = [];
@@ -22,7 +22,25 @@ function mountStyle(style, id, refresh = false) {
22
22
  document.head.appendChild(styleElement);
23
23
  alreadyInjected.push(id);
24
24
  }
25
+ var extractCSSregex = /((?:--)?(?:\w+-?)+)\s*:\s*([^;]*)/g;
26
+ function stringStyleToObject(style) {
27
+ const object = {};
28
+ let match = extractCSSregex.exec(style);
29
+ while (match) {
30
+ if (match[1] && match[2]) {
31
+ object[match[1]] = match[2];
32
+ }
33
+ match = extractCSSregex.exec(style);
34
+ }
35
+ return object;
36
+ }
37
+ function combineStyle(a, b) {
38
+ const bb = typeof b === "string" ? stringStyleToObject(b) : b;
39
+ return { ...a, ...bb };
40
+ }
25
41
 
26
42
  export {
27
- mountStyle
43
+ mountStyle,
44
+ stringStyleToObject,
45
+ combineStyle
28
46
  };
@@ -0,0 +1,40 @@
1
+ import {
2
+ isArray
3
+ } from "./chunk-6G7GFZV2.js";
4
+ import {
5
+ clamp,
6
+ toHex
7
+ } from "./chunk-PD6VHMH6.js";
8
+
9
+ // src/color/hex-rgb.ts
10
+ var HEX_PREFIX_REGEX = /^#/;
11
+ var HEX_VALIDATION_REGEX = /^[0-9a-fA-F]{6}$/;
12
+ function hexToRgb(hex) {
13
+ if (!hex || typeof hex !== "string") {
14
+ return null;
15
+ }
16
+ let value = hex.trim().replace(HEX_PREFIX_REGEX, "");
17
+ if (value.length === 3) {
18
+ value = value.split("").map((c) => c + c).join("");
19
+ }
20
+ if (!HEX_VALIDATION_REGEX.test(value)) {
21
+ return null;
22
+ }
23
+ const r = Number.parseInt(value.slice(0, 2), 16);
24
+ const g = Number.parseInt(value.slice(2, 4), 16);
25
+ const b = Number.parseInt(value.slice(4, 6), 16);
26
+ return { r, g, b };
27
+ }
28
+ function rgbToHex(rgb) {
29
+ const c = (v) => Math.round(clamp(v, 0, 255));
30
+ const rgb_ = isArray(rgb) ? rgb : [rgb.r, rgb.g, rgb.b];
31
+ const r = c(rgb_[0]);
32
+ const g = c(rgb_[1]);
33
+ const b = c(rgb_[2]);
34
+ return `#${toHex(r)}${toHex(g)}${toHex(b)}`;
35
+ }
36
+
37
+ export {
38
+ hexToRgb,
39
+ rgbToHex
40
+ };
@@ -1,4 +1,4 @@
1
- // src/lodash/async.ts
1
+ // src/utils/async.ts
2
2
  var sleep = (milliseconds) => {
3
3
  return new Promise((res) => setTimeout(res, milliseconds));
4
4
  };
@@ -0,0 +1,47 @@
1
+ import {
2
+ noop
3
+ } from "./chunk-QPEF6LHH.js";
4
+ import {
5
+ access
6
+ } from "./chunk-YK5QQQ43.js";
7
+ import {
8
+ createWatch
9
+ } from "./chunk-4L6FK7MF.js";
10
+ import {
11
+ clearArray
12
+ } from "./chunk-BT47ISVC.js";
13
+
14
+ // src/event/create-intersection-observer.ts
15
+ import { onCleanup } from "solid-js";
16
+ import { isServer } from "solid-js/web";
17
+ function createIntersectionObserver(targets, callback, options = {}) {
18
+ if (isServer) {
19
+ return noop;
20
+ }
21
+ const io = new IntersectionObserver(callback, options);
22
+ onCleanup(() => io.disconnect());
23
+ const cleanups = [];
24
+ const cleanup = () => {
25
+ for (const c of cleanups) {
26
+ c();
27
+ }
28
+ clearArray(cleanups);
29
+ };
30
+ createWatch(
31
+ () => targets.map(access),
32
+ (elements) => {
33
+ cleanup();
34
+ for (const element of elements) {
35
+ if (element) {
36
+ io.observe(element);
37
+ cleanups.push(() => io.unobserve(element));
38
+ }
39
+ }
40
+ }
41
+ );
42
+ return () => io.disconnect();
43
+ }
44
+
45
+ export {
46
+ createIntersectionObserver
47
+ };
@@ -0,0 +1,26 @@
1
+ // src/utils/number.ts
2
+ function min(...numbers) {
3
+ return Math.min(...numbers);
4
+ }
5
+ function max(...numbers) {
6
+ return Math.max(...numbers);
7
+ }
8
+ function clamp(x, minimum = 0, maximum = 1) {
9
+ return min(maximum, max(minimum, x));
10
+ }
11
+ function inRange(x, minimum = 0, maximum = 1, inclusivity = "[]") {
12
+ const minCheck = inclusivity[0] === "[" ? x >= minimum : x > minimum;
13
+ const maxCheck = inclusivity[1] === "]" ? x <= maximum : x < maximum;
14
+ return minCheck && maxCheck;
15
+ }
16
+ function toHex(x, pad = 2) {
17
+ return x.toString(16).padStart(pad, "0");
18
+ }
19
+
20
+ export {
21
+ min,
22
+ max,
23
+ clamp,
24
+ inRange,
25
+ toHex
26
+ };
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  access
3
- } from "./chunk-M5A3VVYI.js";
3
+ } from "./chunk-YK5QQQ43.js";
4
4
  import {
5
5
  createWatch
6
6
  } from "./chunk-4L6FK7MF.js";
7
7
  import {
8
8
  isNumber
9
- } from "./chunk-ZGYORUAX.js";
9
+ } from "./chunk-6G7GFZV2.js";
10
10
 
11
11
  // src/fn/create-debounce.ts
12
12
  import { onCleanup as onCleanup3 } from "solid-js";
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  iterate
3
- } from "./chunk-CSAKXWF3.js";
3
+ } from "./chunk-BT47ISVC.js";
4
4
 
5
- // src/lodash/random.ts
5
+ // src/utils/random.ts
6
6
  var random = (min, max) => {
7
7
  return Math.floor(Math.random() * (max - min + 1) + min);
8
8
  };
@@ -0,0 +1,23 @@
1
+ import {
2
+ hexToRgb
3
+ } from "./chunk-KFLH3AZ6.js";
4
+ import {
5
+ inRange
6
+ } from "./chunk-PD6VHMH6.js";
7
+
8
+ // src/color/validation.ts
9
+ function isValidRGB(rgb) {
10
+ return Object.values(rgb).every((x) => inRange(x, 0, 255));
11
+ }
12
+ function isValidOKLCH(oklch) {
13
+ return inRange(oklch.l) && oklch.c >= 0 && inRange(oklch.h, 0, 360);
14
+ }
15
+ function isValidHex(hex) {
16
+ return hexToRgb(hex) !== null;
17
+ }
18
+
19
+ export {
20
+ isValidRGB,
21
+ isValidOKLCH,
22
+ isValidHex
23
+ };
@@ -0,0 +1,66 @@
1
+ import {
2
+ access
3
+ } from "./chunk-YK5QQQ43.js";
4
+ import {
5
+ createWatch
6
+ } from "./chunk-4L6FK7MF.js";
7
+ import {
8
+ isObject
9
+ } from "./chunk-6G7GFZV2.js";
10
+
11
+ // src/event/create-visibility-observer.ts
12
+ import { createSignal, onCleanup } from "solid-js";
13
+ function createVisibilityObserver(arg1, arg2) {
14
+ let target;
15
+ let options;
16
+ if (arg1 && !isObject(arg1)) {
17
+ target = arg1;
18
+ options = arg2 ?? {};
19
+ } else {
20
+ options = arg1 ?? {};
21
+ }
22
+ const callbacks = /* @__PURE__ */ new WeakMap();
23
+ const io = new IntersectionObserver((entries, instance) => {
24
+ for (const entry of entries) {
25
+ callbacks.get(entry.target)?.(entry, instance);
26
+ }
27
+ }, options);
28
+ onCleanup(() => io.disconnect());
29
+ const addEntry = (el, callback) => {
30
+ io.observe(el);
31
+ callbacks.set(el, callback);
32
+ };
33
+ const removeEntry = (el) => {
34
+ io.unobserve(el);
35
+ callbacks.delete(el);
36
+ };
37
+ const useVisibilityObserverFn = (element) => {
38
+ const [isVisible, setVisible] = createSignal(
39
+ options?.initialValue ?? false
40
+ );
41
+ let prevEl;
42
+ createWatch(
43
+ () => access(element),
44
+ (el) => {
45
+ if (prevEl) {
46
+ removeEntry(prevEl);
47
+ }
48
+ if (el) {
49
+ addEntry(el, (entry) => {
50
+ setVisible(entry.isIntersecting);
51
+ });
52
+ prevEl = el;
53
+ }
54
+ }
55
+ );
56
+ return isVisible;
57
+ };
58
+ if (target) {
59
+ return useVisibilityObserverFn(target);
60
+ }
61
+ return useVisibilityObserverFn;
62
+ }
63
+
64
+ export {
65
+ createVisibilityObserver
66
+ };
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  noop
3
- } from "./chunk-BGLY6NJK.js";
3
+ } from "./chunk-QPEF6LHH.js";
4
4
  import {
5
5
  clearArray
6
- } from "./chunk-CSAKXWF3.js";
6
+ } from "./chunk-BT47ISVC.js";
7
7
  import {
8
8
  isArray
9
- } from "./chunk-ZGYORUAX.js";
9
+ } from "./chunk-6G7GFZV2.js";
10
10
 
11
11
  // src/event/make-event-listener.ts
12
12
  import { onCleanup } from "solid-js";
File without changes
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  makeEventListener
3
- } from "./chunk-OUAI75QC.js";
3
+ } from "./chunk-TGWWPUWD.js";
4
4
  import {
5
5
  access
6
- } from "./chunk-M5A3VVYI.js";
6
+ } from "./chunk-YK5QQQ43.js";
7
7
 
8
8
  // src/event/create-click-outside.ts
9
9
  function createClickOutside(target, handler, options) {
@@ -1,4 +1,4 @@
1
- // src/lodash/str.ts
1
+ // src/utils/str.ts
2
2
  var capitalize = (str) => {
3
3
  if (!str || str.length === 0) {
4
4
  return "";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  isFn
3
- } from "./chunk-ZGYORUAX.js";
3
+ } from "./chunk-6G7GFZV2.js";
4
4
 
5
5
  // src/reactive/access.ts
6
6
  function access(value) {
@@ -0,0 +1,36 @@
1
+ import { RGB } from './oklch-rgb.js';
2
+
3
+ /**
4
+ * Converts a hex color string to RGB color values.
5
+ *
6
+ * Supports both 3-digit (#rgb) and 6-digit (#rrggbb) hex formats.
7
+ * The hash symbol (#) is optional.
8
+ *
9
+ * @param hex - Hex color string (e.g., "#ffcc00", "ffcc00", "#fc0", "fc0")
10
+ * @returns RGB object with r, g, b values (0-255), or null if invalid
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * hexToRgb("#ffcc00") // => { r: 255, g: 204, b: 0 }
15
+ * hexToRgb("fc0") // => { r: 255, g: 204, b: 0 }
16
+ * hexToRgb("#invalid") // => null
17
+ * ```
18
+ */
19
+ declare function hexToRgb(hex: string): RGB | null;
20
+ /**
21
+ * Converts RGB color values to a hex color string.
22
+ *
23
+ * RGB values are automatically clamped to the 0-255 range.
24
+ *
25
+ * @param rgb - RGB object with r, g, b values
26
+ * @returns Hex color string with # prefix (e.g., "#ffcc00")
27
+ *
28
+ * @example
29
+ * ```typescript
30
+ * rgbToHex({ r: 255, g: 204, b: 0 }) // => "#ffcc00"
31
+ * rgbToHex({ r: 300, g: -10, b: 128 }) // => "#ff0080" (clamped values)
32
+ * ```
33
+ */
34
+ declare function rgbToHex(rgb: RGB | [number, number, number]): string;
35
+
36
+ export { hexToRgb, rgbToHex };
@@ -0,0 +1,15 @@
1
+ import {
2
+ hexToRgb,
3
+ rgbToHex
4
+ } from "../chunk-KFLH3AZ6.js";
5
+ import "../chunk-U5LQ2AS5.js";
6
+ import "../chunk-QQVSG76Z.js";
7
+ import "../chunk-Y4GYGFIT.js";
8
+ import "../chunk-BT47ISVC.js";
9
+ import "../chunk-KKFGUHFR.js";
10
+ import "../chunk-6G7GFZV2.js";
11
+ import "../chunk-PD6VHMH6.js";
12
+ export {
13
+ hexToRgb,
14
+ rgbToHex
15
+ };
@@ -0,0 +1,3 @@
1
+ export { hexToRgb, rgbToHex } from './hex-rgb.js';
2
+ export { OKLCH, RGB, oklchToRgb, rgbToOklch } from './oklch-rgb.js';
3
+ export { isValidHex, isValidOKLCH, isValidRGB } from './validation.js';
@@ -0,0 +1,30 @@
1
+ import "../chunk-BLX3XSA6.js";
2
+ import {
3
+ oklchToRgb,
4
+ rgbToOklch
5
+ } from "../chunk-ACZGS7DG.js";
6
+ import {
7
+ isValidHex,
8
+ isValidOKLCH,
9
+ isValidRGB
10
+ } from "../chunk-S7U3LZNS.js";
11
+ import {
12
+ hexToRgb,
13
+ rgbToHex
14
+ } from "../chunk-KFLH3AZ6.js";
15
+ import "../chunk-U5LQ2AS5.js";
16
+ import "../chunk-QQVSG76Z.js";
17
+ import "../chunk-Y4GYGFIT.js";
18
+ import "../chunk-BT47ISVC.js";
19
+ import "../chunk-KKFGUHFR.js";
20
+ import "../chunk-6G7GFZV2.js";
21
+ import "../chunk-PD6VHMH6.js";
22
+ export {
23
+ hexToRgb,
24
+ isValidHex,
25
+ isValidOKLCH,
26
+ isValidRGB,
27
+ oklchToRgb,
28
+ rgbToHex,
29
+ rgbToOklch
30
+ };
@@ -0,0 +1,49 @@
1
+ interface RGB {
2
+ r: number;
3
+ g: number;
4
+ b: number;
5
+ }
6
+ interface OKLCH {
7
+ l: number;
8
+ c: number;
9
+ h: number;
10
+ }
11
+ /**
12
+ * Converts OKLCH color to RGB color space.
13
+ *
14
+ * OKLCH is a perceptually uniform color space based on OKLab.
15
+ * Input values are automatically clamped to valid ranges.
16
+ *
17
+ * @param oklch - The OKLCH color to convert
18
+ * @param oklch.l - Lightness (0-1, will be clamped)
19
+ * @param oklch.c - Chroma (≥0, will be clamped)
20
+ * @param oklch.h - Hue in degrees (will be normalized to 0-360)
21
+ * @returns RGB color with values 0-255
22
+ *
23
+ * @example
24
+ * ```typescript
25
+ * const rgb = oklchToRgb({ l: 0.7, c: 0.1, h: 200 });
26
+ * // => { r: 64, g: 177, b: 183 }
27
+ * ```
28
+ */
29
+ declare function oklchToRgb(oklch: OKLCH): RGB;
30
+ /**
31
+ * Converts RGB color to OKLCH color space.
32
+ *
33
+ * RGB values are automatically clamped to 0-255 range.
34
+ *
35
+ * @param rgb - The RGB color to convert
36
+ * @param rgb.r - Red component (0-255, will be clamped)
37
+ * @param rgb.g - Green component (0-255, will be clamped)
38
+ * @param rgb.b - Blue component (0-255, will be clamped)
39
+ * @returns OKLCH color with l∈[0,1], c≥0, h∈[0,360)
40
+ *
41
+ * @example
42
+ * ```typescript
43
+ * const oklch = rgbToOklch({ r: 64, g: 177, b: 183 });
44
+ * // => { l: 0.7, c: 0.1, h: 200 }
45
+ * ```
46
+ */
47
+ declare function rgbToOklch(rgb: RGB): OKLCH;
48
+
49
+ export { type OKLCH, type RGB, oklchToRgb, rgbToOklch };
@@ -0,0 +1,15 @@
1
+ import {
2
+ oklchToRgb,
3
+ rgbToOklch
4
+ } from "../chunk-ACZGS7DG.js";
5
+ import "../chunk-U5LQ2AS5.js";
6
+ import "../chunk-QQVSG76Z.js";
7
+ import "../chunk-Y4GYGFIT.js";
8
+ import "../chunk-BT47ISVC.js";
9
+ import "../chunk-KKFGUHFR.js";
10
+ import "../chunk-6G7GFZV2.js";
11
+ import "../chunk-PD6VHMH6.js";
12
+ export {
13
+ oklchToRgb,
14
+ rgbToOklch
15
+ };
@@ -0,0 +1,26 @@
1
+ import { RGB, OKLCH } from './oklch-rgb.js';
2
+
3
+ /**
4
+ * Checks if RGB values are in valid range (0-255)
5
+ */
6
+ declare function isValidRGB(rgb: RGB): boolean;
7
+ /**
8
+ * Checks if OKLCH values are in valid ranges
9
+ */
10
+ declare function isValidOKLCH(oklch: OKLCH): boolean;
11
+ /**
12
+ * Checks if a string is a valid hex color format.
13
+ *
14
+ * @param hex - String to validate
15
+ * @returns `true` if the string is a valid hex color, `false` otherwise
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * isValidHex("#ffcc00") // => true
20
+ * isValidHex("fc0") // => true
21
+ * isValidHex("#invalid") // => false
22
+ * ```
23
+ */
24
+ declare function isValidHex(hex: string): boolean;
25
+
26
+ export { isValidHex, isValidOKLCH, isValidRGB };
@@ -0,0 +1,18 @@
1
+ import {
2
+ isValidHex,
3
+ isValidOKLCH,
4
+ isValidRGB
5
+ } from "../chunk-S7U3LZNS.js";
6
+ import "../chunk-KFLH3AZ6.js";
7
+ import "../chunk-U5LQ2AS5.js";
8
+ import "../chunk-QQVSG76Z.js";
9
+ import "../chunk-Y4GYGFIT.js";
10
+ import "../chunk-BT47ISVC.js";
11
+ import "../chunk-KKFGUHFR.js";
12
+ import "../chunk-6G7GFZV2.js";
13
+ import "../chunk-PD6VHMH6.js";
14
+ export {
15
+ isValidHex,
16
+ isValidOKLCH,
17
+ isValidRGB
18
+ };
package/dist/dom/css.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import { JSX } from 'solid-js/jsx-runtime';
2
+
1
3
  /**
2
4
  * Mounts a style element to the document head.
3
5
  * If the style element with the given id already exists, it updates its content.
@@ -9,5 +11,7 @@
9
11
  * @param refresh - Whether to refresh the style if it already exists. Defaults to **false**.
10
12
  */
11
13
  declare function mountStyle(style: string, id: string, refresh?: boolean): void;
14
+ declare function stringStyleToObject(style: string): JSX.CSSProperties;
15
+ declare function combineStyle(a: JSX.CSSProperties, b: JSX.CSSProperties | string | undefined): JSX.CSSProperties | string;
12
16
 
13
- export { mountStyle };
17
+ export { combineStyle, mountStyle, stringStyleToObject };