@thewhileloop/whileui 0.2.10 → 0.2.11

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.
@@ -1 +1 @@
1
- {"version":3,"file":"theme-colors.d.ts","sourceRoot":"","sources":["../../src/lib/theme-colors.ts"],"names":[],"mappings":"AA6BA;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,wBAAgB,cAAc,IAAI,WAAW,CAqD5C;AAED,oFAAoF;AACpF,wBAAgB,aAAa;;;;;;;EAU5B"}
1
+ {"version":3,"file":"theme-colors.d.ts","sourceRoot":"","sources":["../../src/lib/theme-colors.ts"],"names":[],"mappings":"AA6BA;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,wBAAgB,cAAc,IAAI,WAAW,CAkC5C;AAED,oFAAoF;AACpF,wBAAgB,aAAa;;;;;;;EAU5B"}
@@ -1,29 +1,31 @@
1
1
  import { useCSSVariable } from 'uniwind';
2
- const HEX_RE = /^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/;
3
- const RGB_RE = /^rgba?\(/i;
4
- const HSL_RE = /^hsla?\(/i;
5
- const NAMED_RE = /^[a-z]+$/i;
6
- function isNativeColor(value) {
7
- const s = value.trim();
8
- if (!s)
9
- return false;
10
- return HEX_RE.test(s) || RGB_RE.test(s) || HSL_RE.test(s) || NAMED_RE.test(s);
11
- }
12
- function toNativeColor(value, appFallback, fallback) {
13
- if (value != null) {
14
- const s = String(value);
15
- if (isNativeColor(s))
16
- return s;
2
+ import { formatHex, parse } from 'culori';
3
+ // 1. Remove the simple regex checks (isNativeColor)
4
+ // 2. Add a robust converter function
5
+ function resolveToHex(value, fallback) {
6
+ if (value === undefined || value === null)
7
+ return fallback;
8
+ const s = String(value);
9
+ // If it's already a simple hex/rgb string, return it (performance optimization)
10
+ if (s.startsWith('#') || s.startsWith('rgb')) {
11
+ return s;
12
+ }
13
+ // Parse and convert modern CSS colors (oklch, hsl, etc.) to Hex
14
+ try {
15
+ const parsed = parse(s);
16
+ if (parsed) {
17
+ const hex = formatHex(parsed);
18
+ if (hex)
19
+ return hex;
20
+ }
17
21
  }
18
- if (appFallback != null) {
19
- const s = String(appFallback);
20
- if (isNativeColor(s))
21
- return s;
22
+ catch (e) {
23
+ // console.warn('Failed to parse color:', value);
22
24
  }
23
25
  return fallback;
24
26
  }
25
27
  export function useThemeColors() {
26
- const [primary, primaryForeground, foreground, muted, mutedForeground, background, border, accent, destructive, appPrimary, appPrimaryForeground, appForeground, appMuted, appMutedForeground, appBackground, appBorder, appAccent, appDestructive,] = useCSSVariable([
28
+ const [primary, primaryForeground, foreground, muted, mutedForeground, background, border, accent, destructive,] = useCSSVariable([
27
29
  '--color-primary',
28
30
  '--color-primary-foreground',
29
31
  '--color-foreground',
@@ -33,27 +35,17 @@ export function useThemeColors() {
33
35
  '--color-border',
34
36
  '--color-accent',
35
37
  '--color-destructive',
36
- '--app-color-primary',
37
- '--app-color-primary-foreground',
38
- '--app-color-foreground',
39
- '--app-color-muted',
40
- '--app-color-muted-foreground',
41
- '--app-color-background',
42
- '--app-color-border',
43
- '--app-color-accent',
44
- '--app-color-destructive',
45
38
  ]);
46
- // Fallbacks when undefined; prefer app hex tokens if theme colors are non-native (oklch).
47
39
  return {
48
- primary: toNativeColor(primary, appPrimary, '#000000'),
49
- primaryForeground: toNativeColor(primaryForeground, appPrimaryForeground, '#ffffff'),
50
- foreground: toNativeColor(foreground, appForeground, '#000000'),
51
- muted: toNativeColor(muted, appMuted, '#f5f5f5'),
52
- mutedForeground: toNativeColor(mutedForeground, appMutedForeground, '#737373'),
53
- background: toNativeColor(background, appBackground, '#ffffff'),
54
- border: toNativeColor(border, appBorder, '#e5e5e5'),
55
- accent: toNativeColor(accent, appAccent, '#22c55e'),
56
- destructive: toNativeColor(destructive, appDestructive, '#dc2626'),
40
+ primary: resolveToHex(primary, '#000000'),
41
+ primaryForeground: resolveToHex(primaryForeground, '#ffffff'),
42
+ foreground: resolveToHex(foreground, '#000000'),
43
+ muted: resolveToHex(muted, '#f5f5f5'),
44
+ mutedForeground: resolveToHex(mutedForeground, '#737373'),
45
+ background: resolveToHex(background, '#ffffff'),
46
+ border: resolveToHex(border, '#e5e5e5'),
47
+ accent: resolveToHex(accent, '#22c55e'),
48
+ destructive: resolveToHex(destructive, '#dc2626'),
57
49
  };
58
50
  }
59
51
  /** Icon colors derived from theme. For @expo/vector-icons which need hex values. */
@@ -1 +1 @@
1
- {"version":3,"file":"theme-colors.js","sourceRoot":"","sources":["../../src/lib/theme-colors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEzC,MAAM,MAAM,GAAG,oEAAoE,CAAC;AACpF,MAAM,MAAM,GAAG,WAAW,CAAC;AAC3B,MAAM,MAAM,GAAG,WAAW,CAAC;AAC3B,MAAM,QAAQ,GAAG,WAAW,CAAC;AAE7B,SAAS,aAAa,CAAC,KAAa;IAClC,MAAM,CAAC,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IACvB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D,UAAU,EAAE,YAAY,CAAC,UAAU,EAAE,SAAS,CAAC;QAC/C,MAAM,EAAE,YAAY,CAAC,MAAM,EAAE,SAAS,CAAC;QACvC,MAAM,EAAE,YAAY,CAAC,MAAM,EAAE,SAAS,CAAC;QACvC,WAAW,EAAE,YAAY,CAAC,WAAW,EAAE,SAAS,CAAC;KAClD,CAAC;AACJ,CAAC;AAED,oFAAoF;AACpF,MAAM,UAAU,aAAa;IAC3B,MAAM,CAAC,GAAG,cAAc,EAAE,CAAC;IAC3B,OAAO;QACL,UAAU,EAAE,CAAC,CAAC,UAAU;QACxB,KAAK,EAAE,CAAC,CAAC,eAAe;QACxB,OAAO,EAAE,CAAC,CAAC,OAAO;QAClB,iBAAiB,EAAE,CAAC,CAAC,iBAAiB;QACtC,MAAM,EAAE,CAAC,CAAC,MAAM;QAChB,WAAW,EAAE,CAAC,CAAC,WAAW;KAC3B,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thewhileloop/whileui",
3
- "version": "0.2.10",
3
+ "version": "0.2.11",
4
4
  "description": "WhileUI Native — Copy-paste components for React Native. You own the code.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -69,11 +69,13 @@
69
69
  },
70
70
  "dependencies": {
71
71
  "clsx": "^2.1.0",
72
+ "culori": "^4.0.2",
72
73
  "react-native-calendars": "^1.1314.0",
73
74
  "tailwind-merge": "^3.0.0",
74
75
  "tailwind-variants": "^0.3.0"
75
76
  },
76
77
  "devDependencies": {
78
+ "@types/culori": "^4.0.1",
77
79
  "@types/react": "~19.1.0",
78
80
  "react-native-screens": "^4.23.0",
79
81
  "typescript": "^5.7.0"