@donotdev/ui 0.0.2 → 0.0.3

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 (104) hide show
  1. package/dist/components/auth/AuthMenu.d.ts.map +1 -1
  2. package/dist/components/auth/AuthMenu.js +15 -28
  3. package/dist/components/common/FeatureCard.js +1 -1
  4. package/dist/components/cookie-consent/CookieConsent.d.ts.map +1 -1
  5. package/dist/components/cookie-consent/CookieConsent.js +2 -41
  6. package/dist/components/cookie-consent/index.d.ts +0 -1
  7. package/dist/components/cookie-consent/index.d.ts.map +1 -1
  8. package/dist/components/cookie-consent/index.js +1 -1
  9. package/dist/components/layout/components/DropdownNavigation.d.ts.map +1 -1
  10. package/dist/components/layout/components/header/ThemeToggle.d.ts +1 -1
  11. package/dist/components/layout/components/header/ThemeToggle.d.ts.map +1 -1
  12. package/dist/components/layout/components/header/ThemeToggle.js +5 -4
  13. package/dist/dndev.css +137 -120
  14. package/dist/index.js +4 -4
  15. package/dist/internal/devtools/DebugTools.d.ts.map +1 -1
  16. package/dist/internal/devtools/DebugTools.js +8 -4
  17. package/dist/internal/devtools/components/ConfigTab.d.ts.map +1 -1
  18. package/dist/internal/devtools/components/ConfigTab.js +31 -133
  19. package/dist/internal/devtools/components/DebugDialog.d.ts.map +1 -1
  20. package/dist/internal/devtools/components/DebugDialog.js +11 -520
  21. package/dist/internal/devtools/components/DesignTab.d.ts +2 -0
  22. package/dist/internal/devtools/components/DesignTab.d.ts.map +1 -0
  23. package/dist/internal/devtools/components/DesignTab.js +220 -0
  24. package/dist/internal/devtools/components/StoresTab.d.ts.map +1 -1
  25. package/dist/internal/devtools/components/StoresTab.js +54 -102
  26. package/dist/internal/devtools/components/index.d.ts +1 -6
  27. package/dist/internal/devtools/components/index.d.ts.map +1 -1
  28. package/dist/internal/devtools/components/index.js +1 -6
  29. package/dist/internal/devtools/utils/index.d.ts +0 -1
  30. package/dist/internal/devtools/utils/index.d.ts.map +1 -1
  31. package/dist/internal/devtools/utils/index.js +0 -1
  32. package/dist/internal/initializers/BaseStoresInitializer.d.ts.map +1 -1
  33. package/dist/internal/initializers/BaseStoresInitializer.js +25 -58
  34. package/dist/internal/layout/DnDevLayout.js +3 -3
  35. package/dist/internal/layout/components/footer/FooterBranding.d.ts.map +1 -1
  36. package/dist/internal/layout/components/footer/FooterBranding.js +3 -1
  37. package/dist/routing/AuthGuard.d.ts +14 -10
  38. package/dist/routing/AuthGuard.d.ts.map +1 -1
  39. package/dist/routing/AuthGuard.js +25 -22
  40. package/dist/routing/Link.d.ts +2 -2
  41. package/dist/routing/Link.js +2 -2
  42. package/dist/routing/hooks/hooks.next.js +1 -1
  43. package/dist/routing/hooks/hooks.vite.js +1 -1
  44. package/dist/routing/hooks/useRedirectGuard.next.d.ts +2 -36
  45. package/dist/routing/hooks/useRedirectGuard.next.d.ts.map +1 -1
  46. package/dist/routing/hooks/useRedirectGuard.next.js +14 -55
  47. package/dist/routing/hooks/useRedirectGuard.vite.d.ts +2 -36
  48. package/dist/routing/hooks/useRedirectGuard.vite.d.ts.map +1 -1
  49. package/dist/routing/hooks/useRedirectGuard.vite.js +14 -55
  50. package/dist/routing/index.d.ts +0 -1
  51. package/dist/routing/index.d.ts.map +1 -1
  52. package/dist/routing/index.js +1 -1
  53. package/dist/styles/index.css +137 -120
  54. package/dist/utils/assetResolver.d.ts +5 -5
  55. package/dist/utils/assetResolver.js +4 -4
  56. package/dist/utils/useAuthSafe.d.ts +25 -12
  57. package/dist/utils/useAuthSafe.d.ts.map +1 -1
  58. package/dist/utils/useAuthSafe.js +3 -1
  59. package/dist/utils/useAuthVisibility.d.ts +3 -3
  60. package/dist/utils/useAuthVisibility.d.ts.map +1 -1
  61. package/dist/utils/useAuthVisibility.js +25 -21
  62. package/dist/utils/useBillingVisibility.d.ts +2 -2
  63. package/dist/utils/useBillingVisibility.d.ts.map +1 -1
  64. package/dist/utils/useBillingVisibility.js +12 -13
  65. package/dist/utils/useCrudSafe.d.ts +1 -1
  66. package/dist/utils/useCrudSafe.d.ts.map +1 -1
  67. package/dist/utils/useCrudSafe.js +26 -13
  68. package/dist/utils/useOAuthSafe.d.ts +25 -12
  69. package/dist/utils/useOAuthSafe.d.ts.map +1 -1
  70. package/dist/utils/useStripeBillingSafe.d.ts +30 -18
  71. package/dist/utils/useStripeBillingSafe.d.ts.map +1 -1
  72. package/dist/utils/useStripeBillingSafe.js +5 -6
  73. package/dist/vite-routing/AppRoutes.d.ts.map +1 -1
  74. package/dist/vite-routing/AppRoutes.js +5 -5
  75. package/dist/vite-routing/RootLayout.d.ts.map +1 -1
  76. package/dist/vite-routing/RootLayout.js +34 -7
  77. package/package.json +9 -9
  78. package/dist/internal/devtools/components/AuthTab.d.ts +0 -2
  79. package/dist/internal/devtools/components/AuthTab.d.ts.map +0 -1
  80. package/dist/internal/devtools/components/AuthTab.js +0 -98
  81. package/dist/internal/devtools/components/ColorRatioTab.d.ts +0 -2
  82. package/dist/internal/devtools/components/ColorRatioTab.d.ts.map +0 -1
  83. package/dist/internal/devtools/components/ColorRatioTab.js +0 -322
  84. package/dist/internal/devtools/components/DebugToggle.d.ts +0 -2
  85. package/dist/internal/devtools/components/DebugToggle.d.ts.map +0 -1
  86. package/dist/internal/devtools/components/DebugToggle.js +0 -57
  87. package/dist/internal/devtools/components/EnvironmentTab.d.ts +0 -2
  88. package/dist/internal/devtools/components/EnvironmentTab.d.ts.map +0 -1
  89. package/dist/internal/devtools/components/EnvironmentTab.js +0 -26
  90. package/dist/internal/devtools/components/I18nTab.d.ts +0 -2
  91. package/dist/internal/devtools/components/I18nTab.d.ts.map +0 -1
  92. package/dist/internal/devtools/components/I18nTab.js +0 -76
  93. package/dist/internal/devtools/components/OAuthGuideButton.d.ts +0 -10
  94. package/dist/internal/devtools/components/OAuthGuideButton.d.ts.map +0 -1
  95. package/dist/internal/devtools/components/OAuthGuideButton.js +0 -71
  96. package/dist/internal/devtools/components/StripeDebugTab.d.ts +0 -2
  97. package/dist/internal/devtools/components/StripeDebugTab.d.ts.map +0 -1
  98. package/dist/internal/devtools/components/StripeDebugTab.js +0 -175
  99. package/dist/internal/devtools/components/ThemesTab.d.ts +0 -2
  100. package/dist/internal/devtools/components/ThemesTab.d.ts.map +0 -1
  101. package/dist/internal/devtools/components/ThemesTab.js +0 -77
  102. package/dist/internal/devtools/utils/spacingAnalyzer.d.ts +0 -15
  103. package/dist/internal/devtools/utils/spacingAnalyzer.d.ts.map +0 -1
  104. package/dist/internal/devtools/utils/spacingAnalyzer.js +0 -88
@@ -1,98 +0,0 @@
1
- 'use client';
2
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
- // packages/ui/src/internal/devtools/components/AuthTab.tsx
4
- /**
5
- * @fileoverview Auth Tab Component
6
- * @description User-friendly authentication and OAuth debugging for consumers
7
- *
8
- * @version 0.0.1
9
- * @since 0.0.1
10
- * @author AMBROISE PARK Consulting
11
- */
12
- import { useState, useMemo } from 'react';
13
- import { Card, CARD_VARIANT, Badge, BADGE_VARIANT, Button, BUTTON_VARIANT, DescriptionList, Alert, ALERT_VARIANT, Text, Stack, } from '@donotdev/components';
14
- import { getDndevConfig } from '@donotdev/core';
15
- import { useAuthSafe } from '../../../utils/useAuthSafe';
16
- import { discoverEnvVarsByPattern } from '../utils';
17
- import { MaskedValue } from './MaskedValue';
18
- export const AuthTab = () => {
19
- const user = useAuthSafe('user');
20
- const loading = useAuthSafe('loading');
21
- const error = useAuthSafe('error');
22
- const [isOAuthExpanded, setIsOAuthExpanded] = useState(false);
23
- const config = getDndevConfig();
24
- const envVars = config?.env || {};
25
- const oauthVars = useMemo(() => discoverEnvVarsByPattern(envVars, [
26
- '*OAUTH*',
27
- '*GOOGLE*CLIENT*',
28
- '*GITHUB*CLIENT*',
29
- '*AUTH*PARTNER*',
30
- ]), [envVars]);
31
- const googleClientId = Object.entries(oauthVars).find(([key]) => key.toUpperCase().includes('GOOGLE') &&
32
- key.toUpperCase().includes('CLIENT'))?.[1];
33
- const githubClientId = Object.entries(oauthVars).find(([key]) => key.toUpperCase().includes('GITHUB') &&
34
- key.toUpperCase().includes('CLIENT'))?.[1];
35
- const authPartners = Object.entries(oauthVars).find(([key]) => key.toUpperCase().includes('AUTH') &&
36
- key.toUpperCase().includes('PARTNER'))?.[1];
37
- const getStatusBadge = () => {
38
- if (loading)
39
- return _jsx(Badge, { variant: BADGE_VARIANT.SECONDARY, children: "Loading" });
40
- if (error)
41
- return _jsx(Badge, { variant: BADGE_VARIANT.DESTRUCTIVE, children: "Error" });
42
- if (user)
43
- return _jsx(Badge, { children: "Signed In" });
44
- return _jsx(Badge, { variant: BADGE_VARIANT.OUTLINE, children: "Not Signed In" });
45
- };
46
- const authStatusItems = [{ label: 'Status', value: getStatusBadge() }];
47
- const userInfoItems = user
48
- ? [
49
- {
50
- label: 'Email',
51
- value: (_jsx(Text, { as: "span", className: "dndev-font-mono", children: user.email || 'N/A' })),
52
- },
53
- {
54
- label: 'User ID',
55
- value: (_jsx(Text, { as: "span", className: "dndev-font-mono dndev-text-xs", children: user.id })),
56
- },
57
- ...(user.displayName
58
- ? [{ label: 'Display Name', value: user.displayName }]
59
- : []),
60
- ]
61
- : [];
62
- const oauthConfigItems = Object.keys(oauthVars).length > 0
63
- ? Object.entries(oauthVars).map(([key, value]) => ({
64
- label: key,
65
- value: (_jsxs(Stack, { gap: "tight", children: [_jsx("div", { className: "dndev-flex dndev-items-center dndev-justify-between", children: _jsx(Badge, { children: "Configured" }) }), _jsx(MaskedValue, { keyName: key, value: String(value), textClassName: "dndev-font-mono dndev-text-xs dndev-text-muted-foreground" })] })),
66
- }))
67
- : [
68
- {
69
- label: 'OAuth Variables',
70
- value: (_jsx(Text, { as: "span", className: "dndev-text-sm dndev-text-muted-foreground", children: "No OAuth environment variables detected. Add variables matching patterns: *OAUTH*, *GOOGLE*CLIENT*, *GITHUB*CLIENT*, *AUTH*PARTNER*" })),
71
- },
72
- ];
73
- const setupSteps = [
74
- {
75
- title: '1. Firebase Console',
76
- steps: [
77
- _jsxs(_Fragment, { children: ["Go to", ' ', _jsx("a", { href: "https://console.firebase.google.com", target: "_blank", rel: "noopener noreferrer", className: "dndev-text-primary dndev-underline", children: "Firebase Console" })] }),
78
- 'Authentication → Sign-in method',
79
- 'Enable Google, GitHub, etc.',
80
- ],
81
- },
82
- {
83
- title: '2. GitHub OAuth',
84
- steps: [
85
- _jsxs(_Fragment, { children: ["Create OAuth App at", ' ', _jsx("a", { href: "https://github.com/settings/applications/new", target: "_blank", rel: "noopener noreferrer", className: "dndev-text-primary dndev-underline", children: "GitHub" })] }),
86
- _jsxs(_Fragment, { children: ["Callback URL:", ' ', _jsx("code", { className: "dndev-bg-background dndev-px-sm dndev-rounded dndev-text-xs", children: "https://your-project.firebaseapp.com/__/auth/handler" })] }),
87
- 'Copy Client ID/Secret to Firebase',
88
- ],
89
- },
90
- {
91
- title: '3. Authorized Domains',
92
- steps: [
93
- 'Add localhost, your-domain.com to Firebase Console → Authentication → Settings',
94
- ],
95
- },
96
- ];
97
- return (_jsxs(Stack, { gap: "medium", children: [_jsx(Card, { title: "Authentication Status", subtitle: "Current authentication state", children: _jsxs(Stack, { gap: "medium", children: [_jsx(DescriptionList, { items: authStatusItems }), user && (_jsx(Stack, { gap: "tight", children: _jsx(DescriptionList, { items: userInfoItems }) })), error && (_jsx(Alert, { variant: ALERT_VARIANT.ERROR, title: "Error", children: error.message }))] }) }), _jsx(Card, { title: "OAuth Configuration", subtitle: "OAuth provider setup status", children: _jsxs(Stack, { gap: "medium", children: [_jsx(DescriptionList, { items: oauthConfigItems }), _jsxs(Button, { onClick: () => setIsOAuthExpanded(!isOAuthExpanded), variant: BUTTON_VARIANT.OUTLINE, className: "dndev-w-full", children: [isOAuthExpanded ? 'Hide' : 'Show', " Setup Guide"] }), isOAuthExpanded && (_jsxs(Card, { variant: CARD_VARIANT.MUTED, className: "dndev-grid dndev-gap-md", children: [setupSteps.map((section, idx) => (_jsxs("div", { className: "dndev-grid dndev-gap-sm", children: [_jsx(Text, { as: "span", className: "dndev-font-semibold", children: section.title }), _jsx("ol", { className: "dndev-list dndev-list-decimal dndev-list-inside dndev-text-muted-foreground dndev-text-sm dndev-grid dndev-gap-xs", children: section.steps.map((step, stepIdx) => (_jsx("li", { children: step }, stepIdx))) })] }, idx))), _jsxs(Alert, { variant: ALERT_VARIANT.WARNING, children: [_jsx("strong", { children: "Note:" }), " 400 error = GitHub OAuth not configured in Firebase"] })] }))] }) })] }));
98
- };
@@ -1,2 +0,0 @@
1
- export declare const ColorRatioTab: () => import("react/jsx-runtime").JSX.Element;
2
- //# sourceMappingURL=ColorRatioTab.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ColorRatioTab.d.ts","sourceRoot":"","sources":["../../../../src/internal/devtools/components/ColorRatioTab.tsx"],"names":[],"mappings":"AAmCA,eAAO,MAAM,aAAa,+CAodzB,CAAC"}
@@ -1,322 +0,0 @@
1
- 'use client';
2
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
- // packages/ui/src/internal/devtools/components/ColorRatioTab.tsx
4
- /**
5
- * @fileoverview Color Ratio Tab Component
6
- * @description 60/30/10 color ratio checker with copy/paste functionality
7
- *
8
- * @version 0.0.1
9
- * @since 0.0.1
10
- * @author AMBROISE PARK Consulting
11
- */
12
- import { Palette } from 'lucide-react';
13
- import { useState } from 'react';
14
- import { Card, Button, BUTTON_VARIANT, Stack, Label, CopyToClipboard, Alert, ALERT_VARIANT, toast, ScrollArea, } from '@donotdev/components';
15
- export const ColorRatioTab = () => {
16
- const [colorRatio, setColorRatio] = useState(null);
17
- const [isAnalyzing, setIsAnalyzing] = useState(false);
18
- const checkColorRatio = () => {
19
- setIsAnalyzing(true);
20
- try {
21
- const elements = document.querySelectorAll('*');
22
- const colorMap = new Map();
23
- elements.forEach((el) => {
24
- const style = getComputedStyle(el);
25
- const bg = style.backgroundColor;
26
- const rect = el.getBoundingClientRect();
27
- const area = rect.width * rect.height;
28
- if (bg &&
29
- bg !== 'rgba(0, 0, 0, 0)' &&
30
- bg !== 'transparent' &&
31
- area > 0) {
32
- const existing = colorMap.get(bg) || { count: 0, area: 0 };
33
- colorMap.set(bg, {
34
- count: existing.count + 1,
35
- area: existing.area + area,
36
- });
37
- }
38
- });
39
- const rootStyles = getComputedStyle(document.documentElement);
40
- const getComputedColor = (varName) => {
41
- const testEl = document.createElement('div');
42
- testEl.style.setProperty('background-color', `var(${varName})`);
43
- testEl.style.position = 'absolute';
44
- testEl.style.visibility = 'hidden';
45
- document.body.appendChild(testEl);
46
- const computed = getComputedStyle(testEl).backgroundColor;
47
- document.body.removeChild(testEl);
48
- return computed || '';
49
- };
50
- const bgColor = getComputedColor('--background') || rootStyles.backgroundColor || '';
51
- const mutedColor = getComputedColor('--muted') || '';
52
- const primaryColor = getComputedColor('--primary') || '';
53
- const accentColor = getComputedColor('--accent') || '';
54
- const totalArea = Array.from(colorMap.values()).reduce((sum, v) => sum + v.area, 0);
55
- if (totalArea === 0) {
56
- setColorRatio({
57
- dominant: 0,
58
- secondary: 0,
59
- accent: 0,
60
- details: [],
61
- });
62
- setIsAnalyzing(false);
63
- return;
64
- }
65
- const colors = Array.from(colorMap.entries())
66
- .map(([color, data]) => ({
67
- color,
68
- percentage: (data.area / totalArea) * 100,
69
- area: data.area,
70
- }))
71
- .sort((a, b) => b.percentage - a.percentage);
72
- const rgbToHex = (rgb) => {
73
- const match = rgb.match(/\d+/g);
74
- if (!match || match.length < 3 || !match[0] || !match[1] || !match[2])
75
- return '';
76
- const r = parseInt(match[0]).toString(16).padStart(2, '0');
77
- const g = parseInt(match[1]).toString(16).padStart(2, '0');
78
- const b = parseInt(match[2]).toString(16).padStart(2, '0');
79
- return `#${r}${g}${b}`;
80
- };
81
- const normalizeToRgb = (color) => {
82
- if (!color || color === 'transparent' || color === 'rgba(0, 0, 0, 0)') {
83
- return null;
84
- }
85
- if (color.startsWith('rgb')) {
86
- const match = color.match(/\d+/g);
87
- if (match && match.length >= 3) {
88
- return `rgb(${match[0]}, ${match[1]}, ${match[2]})`;
89
- }
90
- return color;
91
- }
92
- if (color.startsWith('#')) {
93
- const hex = color.replace('#', '');
94
- if (hex.length === 3 && hex[0] && hex[1] && hex[2]) {
95
- const r = parseInt(hex[0] + hex[0], 16);
96
- const g = parseInt(hex[1] + hex[1], 16);
97
- const b = parseInt(hex[2] + hex[2], 16);
98
- return `rgb(${r}, ${g}, ${b})`;
99
- }
100
- if (hex.length >= 6) {
101
- const r = parseInt(hex.substr(0, 2), 16);
102
- const g = parseInt(hex.substr(2, 2), 16);
103
- const b = parseInt(hex.substr(4, 2), 16);
104
- return `rgb(${r}, ${g}, ${b})`;
105
- }
106
- }
107
- if (color.startsWith('oklab') || color.startsWith('color(')) {
108
- const testEl = document.createElement('div');
109
- testEl.style.backgroundColor = color;
110
- testEl.style.position = 'absolute';
111
- testEl.style.visibility = 'hidden';
112
- document.body.appendChild(testEl);
113
- const computed = getComputedStyle(testEl).backgroundColor;
114
- document.body.removeChild(testEl);
115
- if (computed && computed.startsWith('rgb')) {
116
- const match = computed.match(/\d+/g);
117
- if (match && match.length >= 3) {
118
- return `rgb(${match[0]}, ${match[1]}, ${match[2]})`;
119
- }
120
- return computed;
121
- }
122
- }
123
- return null;
124
- };
125
- const getBrightness = (rgb) => {
126
- if (!rgb)
127
- return 0;
128
- const match = rgb.match(/\d+/g);
129
- if (!match || match.length < 3 || !match[0] || !match[1] || !match[2])
130
- return 0;
131
- const r = parseInt(match[0]);
132
- const g = parseInt(match[1]);
133
- const b = parseInt(match[2]);
134
- return (r * 299 + g * 587 + b * 114) / 1000;
135
- };
136
- const getSaturation = (rgb) => {
137
- if (!rgb)
138
- return 0;
139
- const match = rgb.match(/\d+/g);
140
- if (!match || match.length < 3 || !match[0] || !match[1] || !match[2])
141
- return 0;
142
- const r = parseInt(match[0]) / 255;
143
- const g = parseInt(match[1]) / 255;
144
- const b = parseInt(match[2]) / 255;
145
- const max = Math.max(r, g, b);
146
- const min = Math.min(r, g, b);
147
- const delta = max - min;
148
- if (max === 0)
149
- return 0;
150
- return delta / max;
151
- };
152
- const colorsMatch = (c1, c2, threshold = 15) => {
153
- if (!c1 || !c2)
154
- return false;
155
- const rgb1 = normalizeToRgb(c1);
156
- const rgb2 = normalizeToRgb(c2);
157
- if (!rgb1 || !rgb2)
158
- return false;
159
- const match1 = rgb1.match(/\d+/g);
160
- const match2 = rgb2.match(/\d+/g);
161
- if (!match1 || !match2 || match1.length < 3 || match2.length < 3)
162
- return false;
163
- if (!match1[0] || !match1[1] || !match1[2] || !match2[0] || !match2[1] || !match2[2])
164
- return false;
165
- const r1 = parseInt(match1[0]);
166
- const g1 = parseInt(match1[1]);
167
- const b1 = parseInt(match1[2]);
168
- const r2 = parseInt(match2[0]);
169
- const g2 = parseInt(match2[1]);
170
- const b2 = parseInt(match2[2]);
171
- const diff = Math.abs(r1 - r2) + Math.abs(g1 - g2) + Math.abs(b1 - b2);
172
- return diff <= threshold * 3;
173
- };
174
- const groupSimilarColors = (colors) => {
175
- const grouped = [];
176
- const groups = [];
177
- let currentGroup = 0;
178
- for (const color of colors) {
179
- const normalized = normalizeToRgb(color.color);
180
- let assigned = false;
181
- for (let i = 0; i < grouped.length; i++) {
182
- const existing = grouped[i];
183
- if (!existing)
184
- continue;
185
- const existingNormalized = normalizeToRgb(existing.color);
186
- if (colorsMatch(normalized, existingNormalized)) {
187
- grouped.push({ ...color, group: existing.group });
188
- assigned = true;
189
- break;
190
- }
191
- }
192
- if (!assigned) {
193
- grouped.push({ ...color, group: currentGroup++ });
194
- }
195
- }
196
- return grouped;
197
- };
198
- const categorizeByColorRole = (colors) => {
199
- const categoryMap = new Map();
200
- const normalizedAccent = accentColor ? normalizeToRgb(accentColor) : null;
201
- const normalizedPrimary = primaryColor ? normalizeToRgb(primaryColor) : null;
202
- const normalizedBg = bgColor ? normalizeToRgb(bgColor) : null;
203
- const normalizedMuted = mutedColor ? normalizeToRgb(mutedColor) : null;
204
- const bgBrightness = normalizedBg ? getBrightness(normalizedBg) : 0;
205
- for (const color of colors) {
206
- const normalized = normalizeToRgb(color.color);
207
- if (!normalized) {
208
- categoryMap.set(color.color, 'secondary');
209
- continue;
210
- }
211
- const brightness = getBrightness(normalized);
212
- const saturation = getSaturation(normalized);
213
- if ((normalizedAccent && colorsMatch(normalized, normalizedAccent, 15)) ||
214
- (normalizedPrimary && colorsMatch(normalized, normalizedPrimary, 15)) ||
215
- (saturation > 0.5 && brightness > 120)) {
216
- categoryMap.set(color.color, 'accent');
217
- }
218
- else if ((normalizedBg && colorsMatch(normalized, normalizedBg, 20)) ||
219
- (normalizedMuted && colorsMatch(normalized, normalizedMuted, 20)) ||
220
- (normalizedBg && brightness < bgBrightness + 30 && brightness > bgBrightness - 30)) {
221
- categoryMap.set(color.color, 'dominant');
222
- }
223
- else if (brightness < 60) {
224
- categoryMap.set(color.color, 'dominant');
225
- }
226
- else if (brightness > 200) {
227
- categoryMap.set(color.color, 'secondary');
228
- }
229
- else {
230
- categoryMap.set(color.color, 'secondary');
231
- }
232
- }
233
- return categoryMap;
234
- };
235
- const categoryMap = categorizeByColorRole(colors);
236
- const categorized = colors.map((c) => ({
237
- ...c,
238
- category: categoryMap.get(c.color) || 'secondary',
239
- }));
240
- const dominant = categorized
241
- .filter((c) => c.category === 'dominant')
242
- .reduce((sum, c) => sum + c.percentage, 0);
243
- const secondary = categorized
244
- .filter((c) => c.category === 'secondary')
245
- .reduce((sum, c) => sum + c.percentage, 0);
246
- const accent = categorized
247
- .filter((c) => c.category === 'accent')
248
- .reduce((sum, c) => sum + c.percentage, 0);
249
- setColorRatio({
250
- dominant,
251
- secondary,
252
- accent,
253
- details: categorized.slice(0, 20),
254
- });
255
- }
256
- catch (error) {
257
- console.error('Color ratio check failed:', error);
258
- toast('error', 'Failed to analyze color ratio');
259
- }
260
- finally {
261
- setIsAnalyzing(false);
262
- }
263
- };
264
- const formatResults = () => {
265
- if (!colorRatio)
266
- return '';
267
- return `60/30/10 Color Ratio Analysis
268
-
269
- Dominant (60%): ${colorRatio.dominant.toFixed(1)}%
270
- Secondary (30%): ${colorRatio.secondary.toFixed(1)}%
271
- Accent (10%): ${colorRatio.accent.toFixed(1)}%
272
-
273
- Status: ${colorRatio.dominant >= 55 &&
274
- colorRatio.dominant <= 65 &&
275
- colorRatio.secondary >= 25 &&
276
- colorRatio.secondary <= 35 &&
277
- colorRatio.accent >= 5 &&
278
- colorRatio.accent <= 15
279
- ? '✅ Compliant'
280
- : '⚠️ Not compliant'}
281
-
282
- Top Colors:
283
- ${colorRatio.details
284
- .map((c, i) => `${i + 1}. ${c.color} - ${c.percentage.toFixed(1)}% (${c.category})`)
285
- .join('\n')}`;
286
- };
287
- const isCompliant = colorRatio &&
288
- colorRatio.dominant >= 55 &&
289
- colorRatio.dominant <= 65 &&
290
- colorRatio.secondary >= 25 &&
291
- colorRatio.secondary <= 35 &&
292
- colorRatio.accent >= 5 &&
293
- colorRatio.accent <= 15;
294
- return (_jsx(Stack, { gap: "medium", style: { padding: 'var(--gap-md)' }, children: _jsx(Card, { title: _jsxs(Stack, { direction: "row", align: "center", justify: "between", className: "dndev-w-full", children: [_jsx("span", { children: "60/30/10 Color Ratio" }), _jsx(Button, { onClick: checkColorRatio, variant: BUTTON_VARIANT.OUTLINE, icon: Palette, disabled: isAnalyzing, children: isAnalyzing ? 'Analyzing...' : 'Analyze' })] }), content: _jsx(Stack, { gap: "medium", children: colorRatio ? (_jsxs(_Fragment, { children: [isCompliant ? (_jsx(Alert, { variant: ALERT_VARIANT.SUCCESS, children: "Color ratio is compliant with 60/30/10 rule" })) : (_jsx(Alert, { variant: ALERT_VARIANT.WARNING, children: "Color ratio does not match 60/30/10 rule" })), _jsxs(Stack, { gap: "tight", children: [_jsxs(Stack, { direction: "row", align: "center", justify: "between", className: "dndev-w-full", children: [_jsx(Label, { className: "dndev-font-mono", children: "Results" }), _jsx(CopyToClipboard, { text: formatResults(), variant: BUTTON_VARIANT.GHOST, onCopy: () => toast('success', 'Results copied') })] }), _jsxs(Stack, { gap: "tight", children: [_jsxs("div", { style: {
295
- display: 'flex',
296
- justifyContent: 'space-between',
297
- }, children: [_jsx("span", { children: "Dominant (60%):" }), _jsxs("span", { className: colorRatio.dominant >= 55 &&
298
- colorRatio.dominant <= 65
299
- ? 'dndev-text-primary'
300
- : 'dndev-text-destructive', children: [colorRatio.dominant.toFixed(1), "%"] })] }), _jsxs("div", { style: {
301
- display: 'flex',
302
- justifyContent: 'space-between',
303
- }, children: [_jsx("span", { children: "Secondary (30%):" }), _jsxs("span", { className: colorRatio.secondary >= 25 &&
304
- colorRatio.secondary <= 35
305
- ? 'dndev-text-primary'
306
- : 'dndev-text-destructive', children: [colorRatio.secondary.toFixed(1), "%"] })] }), _jsxs("div", { style: {
307
- display: 'flex',
308
- justifyContent: 'space-between',
309
- }, children: [_jsx("span", { children: "Accent (10%):" }), _jsxs("span", { className: colorRatio.accent >= 5 && colorRatio.accent <= 15
310
- ? 'dndev-text-primary'
311
- : 'dndev-text-destructive', children: [colorRatio.accent.toFixed(1), "%"] })] })] }), colorRatio.details.length > 0 && (_jsxs("details", { style: { marginTop: 'var(--gap-xs)' }, children: [_jsxs("summary", { className: "dndev-text-sm dndev-cursor-pointer", children: ["Top Colors (", colorRatio.details.length, ")"] }), _jsx(ScrollArea, { className: "dndev-max-h-96", style: { marginTop: 'var(--gap-xs)' }, children: _jsx(Stack, { gap: "tight", children: colorRatio.details.map((c, i) => (_jsxs("div", { style: {
312
- display: 'flex',
313
- gap: 'var(--gap-xs)',
314
- alignItems: 'center',
315
- }, children: [_jsx("div", { style: {
316
- width: '1rem',
317
- height: '1rem',
318
- backgroundColor: c.color,
319
- border: '1px solid var(--border)',
320
- flexShrink: 0,
321
- } }), _jsx("span", { className: "dndev-text-xs dndev-font-mono", children: c.color }), _jsxs("span", { className: "dndev-text-xs", children: [c.percentage.toFixed(1), "% (", c.category, ")"] })] }, i))) }) })] }))] })] })) : (_jsx(Alert, { variant: ALERT_VARIANT.INFO, children: "Click \"Analyze\" to check color ratio distribution" })) }) }) }));
322
- };
@@ -1,2 +0,0 @@
1
- export declare const DebugToggle: () => import("react/jsx-runtime").JSX.Element;
2
- //# sourceMappingURL=DebugToggle.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DebugToggle.d.ts","sourceRoot":"","sources":["../../../../src/internal/devtools/components/DebugToggle.tsx"],"names":[],"mappings":"AAgBA,eAAO,MAAM,WAAW,+CA8EvB,CAAC"}
@@ -1,57 +0,0 @@
1
- 'use client';
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- // packages/ui/src/internal/devtools/components/DebugToggle.tsx
4
- /**
5
- * @fileoverview Debug Toggle Component
6
- * @description Toggle button for enabling/disabling debug borders and visual debugging aids
7
- *
8
- * @version 0.0.1
9
- * @since 0.0.1
10
- * @author AMBROISE PARK Consulting
11
- */
12
- import { useState } from 'react';
13
- import { cn, Stack } from '@donotdev/components';
14
- export const DebugToggle = () => {
15
- const [debugEnabled, setDebugEnabled] = useState(false);
16
- const toggleDebug = () => {
17
- const newValue = debugEnabled ? '0' : '1';
18
- document.documentElement.style.setProperty('--debug-enabled', newValue);
19
- setDebugEnabled(!debugEnabled);
20
- console.log(`🐛 Debug mode: ${newValue === '1' ? 'ON' : 'OFF'}`);
21
- };
22
- return (_jsx(Stack, { as: "button", align: "center", justify: "center", onClick: toggleDebug, className: cn('hover:scale-105 active:scale-95 transition-transform duration-fast'), style: {
23
- width: 'var(--touch-target)',
24
- height: 'var(--touch-target)',
25
- borderRadius: 'var(--radius-lg)',
26
- transition: 'var(--transition-fast)',
27
- ...(debugEnabled
28
- ? {
29
- backgroundColor: 'rgb(from var(--destructive) r g b / 0.2)',
30
- color: 'var(--destructive)',
31
- boxShadow: 'var(--shadow-xl)',
32
- }
33
- : {
34
- color: 'var(--muted-foreground)',
35
- }),
36
- }, onMouseEnter: (e) => {
37
- if (debugEnabled) {
38
- e.currentTarget.style.backgroundColor =
39
- 'rgb(from var(--destructive) r g b / 0.3)';
40
- }
41
- else {
42
- e.currentTarget.style.backgroundColor = 'var(--accent)';
43
- e.currentTarget.style.color = 'var(--accent-foreground)';
44
- e.currentTarget.style.boxShadow = 'var(--shadow-xl)';
45
- }
46
- }, onMouseLeave: (e) => {
47
- if (debugEnabled) {
48
- e.currentTarget.style.backgroundColor =
49
- 'rgb(from var(--destructive) r g b / 0.2)';
50
- }
51
- else {
52
- e.currentTarget.style.backgroundColor = 'transparent';
53
- e.currentTarget.style.color = 'var(--muted-foreground)';
54
- e.currentTarget.style.boxShadow = 'none';
55
- }
56
- }, title: `Toggle debug borders (${debugEnabled ? 'ON' : 'OFF'})`, "aria-label": "Toggle debug mode", children: _jsxs("svg", { style: { width: '1.5rem', height: '1.5rem' }, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [_jsx("path", { d: "m8 2 1.88 1.88" }), _jsx("path", { d: "M14.12 3.88 16 2" }), _jsx("path", { d: "M9 7.13v-1a3.003 3.003 0 1 1 6 0v1" }), _jsx("path", { d: "M12 20c-3.3 0-6-2.7-6-6v-3a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v3c0 3.3-2.7 6-6 6" }), _jsx("path", { d: "M12 20v-9" }), _jsx("path", { d: "M6.53 9C4.6 8.8 3 7.1 3 5" }), _jsx("path", { d: "M6 13H2" }), _jsx("path", { d: "M3 21c0-2.1 1.7-3.9 3.8-4" }), _jsx("path", { d: "M20.97 5c0 2.1-1.6 3.8-3.5 4" }), _jsx("path", { d: "M22 13h-4" }), _jsx("path", { d: "M17.2 17c2.1.1 3.8 1.9 3.8 4" })] }) }));
57
- };
@@ -1,2 +0,0 @@
1
- export declare const EnvironmentTab: () => import("react/jsx-runtime").JSX.Element;
2
- //# sourceMappingURL=EnvironmentTab.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"EnvironmentTab.d.ts","sourceRoot":"","sources":["../../../../src/internal/devtools/components/EnvironmentTab.tsx"],"names":[],"mappings":"AAiBA,eAAO,MAAM,cAAc,+CA8B1B,CAAC"}
@@ -1,26 +0,0 @@
1
- 'use client';
2
- import { jsx as _jsx } from "react/jsx-runtime";
3
- // packages/ui/src/internal/devtools/components/EnvironmentTab.tsx
4
- /**
5
- * @fileoverview Environment Tab Component
6
- * @description Displays all environment variables in a clean, copyable format
7
- *
8
- * @version 0.0.1
9
- * @since 0.0.1
10
- * @author AMBROISE PARK Consulting
11
- */
12
- import { Card, DescriptionList, Text } from '@donotdev/components';
13
- import { getDndevConfig } from '@donotdev/core';
14
- import { MaskedValue } from './MaskedValue';
15
- export const EnvironmentTab = () => {
16
- const config = getDndevConfig();
17
- const envVars = config?.env || {};
18
- const envItems = Object.entries(envVars).map(([key, value]) => ({
19
- label: key,
20
- value: _jsx(MaskedValue, { keyName: key, value: String(value) }),
21
- }));
22
- if (Object.keys(envVars).length === 0) {
23
- return (_jsx(Card, { title: "Environment Variables", subtitle: "No environment variables found", children: _jsx(Text, { as: "span", className: "dndev-text-muted-foreground", children: "No environment variables detected in config." }) }));
24
- }
25
- return (_jsx(Card, { title: "Environment Variables", subtitle: `${Object.keys(envVars).length} variable${Object.keys(envVars).length !== 1 ? 's' : ''}`, children: _jsx(DescriptionList, { items: envItems, className: "dndev-gap-sm" }) }));
26
- };
@@ -1,2 +0,0 @@
1
- export declare const I18nTab: () => import("react/jsx-runtime").JSX.Element;
2
- //# sourceMappingURL=I18nTab.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"I18nTab.d.ts","sourceRoot":"","sources":["../../../../src/internal/devtools/components/I18nTab.tsx"],"names":[],"mappings":"AAuBA,eAAO,MAAM,OAAO,+CA4JnB,CAAC"}
@@ -1,76 +0,0 @@
1
- 'use client';
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- // packages/ui/src/internal/devtools/components/I18nTab.tsx
4
- /**
5
- * @fileoverview i18n Tab Component
6
- * @description Displays i18n configuration and current language state
7
- *
8
- * @version 0.0.1
9
- * @since 0.0.1
10
- * @author AMBROISE PARK Consulting
11
- */
12
- import { Card, DescriptionList, Text, Badge, Stack, } from '@donotdev/components';
13
- import { useTranslation } from '@donotdev/core';
14
- import { useLanguageSelector } from '@donotdev/core';
15
- import { getI18nConfig } from '@donotdev/core';
16
- export const I18nTab = () => {
17
- const { i18n, ready, isLoading } = useTranslation('dndev');
18
- const { languages, currentLanguage } = useLanguageSelector();
19
- const i18nConfig = getI18nConfig();
20
- const currentLangInfo = languages.find((lang) => lang.id === currentLanguage);
21
- const currentLanguageItems = [
22
- {
23
- label: 'Current Language',
24
- value: (_jsx(Text, { as: "span", className: "dndev-font-mono", children: currentLanguage })),
25
- },
26
- {
27
- label: 'Display Name',
28
- value: (_jsx(Text, { as: "span", className: "dndev-font-mono", children: currentLangInfo?.name || 'Unknown' })),
29
- },
30
- {
31
- label: 'Ready',
32
- value: (_jsx(Text, { as: "span", className: "dndev-font-mono", children: ready ? 'Yes' : 'No' })),
33
- },
34
- {
35
- label: 'Loading',
36
- value: (_jsx(Text, { as: "span", className: "dndev-font-mono", children: isLoading ? 'Yes' : 'No' })),
37
- },
38
- ...(i18n
39
- ? [
40
- {
41
- label: 'i18next Language',
42
- value: (_jsx(Text, { as: "span", className: "dndev-font-mono", children: i18n.language })),
43
- },
44
- {
45
- label: 'Fallback Language',
46
- value: (_jsx(Text, { as: "span", className: "dndev-font-mono", children: i18n.options.fallbackLng?.[0] || 'none' })),
47
- },
48
- ]
49
- : []),
50
- ];
51
- const configItems = i18nConfig
52
- ? [
53
- {
54
- label: 'Languages',
55
- value: (_jsx(Text, { as: "span", className: "dndev-font-mono", children: i18nConfig.languages.join(', ') })),
56
- },
57
- {
58
- label: 'Fallback',
59
- value: (_jsx(Text, { as: "span", className: "dndev-font-mono", children: i18nConfig.fallback })),
60
- },
61
- {
62
- label: 'Eager Namespaces',
63
- value: (_jsx(Text, { as: "span", className: "dndev-font-mono", children: i18nConfig.eager.join(', ') })),
64
- },
65
- ...(i18nConfig.manifest
66
- ? [
67
- {
68
- label: 'Total Namespaces',
69
- value: (_jsxs(Text, { as: "span", className: "dndev-font-mono", children: [i18nConfig.manifest.totalNamespaces || 0, " namespaces"] })),
70
- },
71
- ]
72
- : []),
73
- ]
74
- : [];
75
- return (_jsxs(Stack, { gap: "medium", children: [_jsx(Card, { title: "Current Language", subtitle: "Active i18n state", children: _jsx(DescriptionList, { items: currentLanguageItems }) }), _jsx(Card, { title: "Available Languages", subtitle: `${languages.length} language${languages.length !== 1 ? 's' : ''} supported`, children: _jsx(Stack, { gap: "tight", children: Array.isArray(languages) && languages.length > 0 ? (languages.map((lang, index) => (_jsx(Card, { variant: lang.id === currentLanguage ? 'accent' : 'default', children: _jsxs(Stack, { direction: "row", align: "center", justify: "between", children: [_jsxs("div", { children: [_jsx(Text, { as: "span", className: "dndev-font-semibold", children: lang.name }), _jsx(Text, { as: "span", className: "dndev-text-xs dndev-text-muted-foreground dndev-font-mono", children: lang.id })] }), _jsx(Stack, { direction: "row", align: "center", gap: "tight", children: lang.id === currentLanguage && _jsx(Badge, { children: "Active" }) })] }) }, lang.id || `lang-${index}`)))) : (_jsx(Text, { as: "span", className: "dndev-text-sm dndev-text-muted-foreground", children: "No languages available" })) }) }), i18nConfig && (_jsx(Card, { title: "Config", subtitle: "i18n configuration from build", children: _jsx(DescriptionList, { items: configItems }) }))] }));
76
- };
@@ -1,10 +0,0 @@
1
- import type { ComponentType } from 'react';
2
- /**
3
-
4
- * OAuth Setup Guide Button Component
5
-
6
- * Shows OAuth setup instructions in a compact format
7
-
8
- */
9
- export declare const OAuthGuideButton: ComponentType;
10
- //# sourceMappingURL=OAuthGuideButton.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"OAuthGuideButton.d.ts","sourceRoot":"","sources":["../../../../src/internal/devtools/components/OAuthGuideButton.tsx"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAE3C;;;;;;GAMG;AAEH,eAAO,MAAM,gBAAgB,EAAE,aA+L9B,CAAC"}