@donotdev/ui 0.3.1 → 0.3.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 (325) hide show
  1. package/README.md +2 -3
  2. package/dist/components/auth/AuthHeader.js +1 -93
  3. package/dist/components/auth/AuthMenu.d.ts.map +1 -1
  4. package/dist/components/auth/AuthMenu.js +3 -286
  5. package/dist/components/auth/index.js +1 -9
  6. package/dist/components/common/FeatureCard.d.ts.map +1 -1
  7. package/dist/components/common/FeatureCard.js +1 -86
  8. package/dist/components/common/FeatureDisabled.js +1 -67
  9. package/dist/components/common/IconPlaceholder.d.ts +24 -0
  10. package/dist/components/common/IconPlaceholder.d.ts.map +1 -0
  11. package/dist/components/common/IconPlaceholder.js +1 -0
  12. package/dist/components/common/LazyLucideIcon.d.ts +39 -0
  13. package/dist/components/common/LazyLucideIcon.d.ts.map +1 -0
  14. package/dist/components/common/LazyLucideIcon.js +1 -0
  15. package/dist/components/common/ProgressBar.js +1 -84
  16. package/dist/components/common/RedirectOverlay.js +1 -243
  17. package/dist/components/common/Skeleton.js +1 -144
  18. package/dist/components/common/TechBento.d.ts.map +1 -1
  19. package/dist/components/common/TechBento.js +1 -53
  20. package/dist/components/common/icon.d.ts +1 -1
  21. package/dist/components/common/icon.d.ts.map +1 -1
  22. package/dist/components/common/icon.js +1 -84
  23. package/dist/components/common/iconByName.d.ts +33 -0
  24. package/dist/components/common/iconByName.d.ts.map +1 -0
  25. package/dist/components/common/iconByName.js +1 -0
  26. package/dist/components/common/index.js +1 -16
  27. package/dist/components/cookie-consent/ConsentBanner.d.ts +3 -1
  28. package/dist/components/cookie-consent/ConsentBanner.d.ts.map +1 -1
  29. package/dist/components/cookie-consent/ConsentBanner.js +1 -31
  30. package/dist/components/cookie-consent/CookieConsent.d.ts.map +1 -1
  31. package/dist/components/cookie-consent/CookieConsent.js +1 -183
  32. package/dist/components/cookie-consent/index.js +1 -11
  33. package/dist/components/cookie-consent/useCookieNoticeRequired.d.ts +7 -0
  34. package/dist/components/cookie-consent/useCookieNoticeRequired.d.ts.map +1 -0
  35. package/dist/components/cookie-consent/useCookieNoticeRequired.js +1 -0
  36. package/dist/components/index.js +1 -13
  37. package/dist/components/layout/GameContainer.d.ts.map +1 -1
  38. package/dist/components/layout/GameContainer.js +1 -72
  39. package/dist/components/layout/GameFlow.d.ts.map +1 -1
  40. package/dist/components/layout/GameFlow.js +1 -93
  41. package/dist/components/layout/PageConfig.d.ts.map +1 -1
  42. package/dist/components/layout/PageConfig.js +1 -47
  43. package/dist/components/layout/PageContainer.d.ts.map +1 -1
  44. package/dist/components/layout/PageContainer.js +1 -38
  45. package/dist/components/layout/components/Breadcrumbs.d.ts +2 -1
  46. package/dist/components/layout/components/Breadcrumbs.d.ts.map +1 -1
  47. package/dist/components/layout/components/Breadcrumbs.js +1 -89
  48. package/dist/components/layout/components/DropdownNavigation.d.ts.map +1 -1
  49. package/dist/components/layout/components/DropdownNavigation.js +1 -30
  50. package/dist/components/layout/components/FloatingLanguageSwitcher.d.ts.map +1 -1
  51. package/dist/components/layout/components/FloatingLanguageSwitcher.js +1 -26
  52. package/dist/components/layout/components/Notifications.js +1 -182
  53. package/dist/components/layout/components/header/AppBranding.d.ts.map +1 -1
  54. package/dist/components/layout/components/header/AppBranding.js +1 -54
  55. package/dist/components/layout/components/header/AppIcon.d.ts.map +1 -1
  56. package/dist/components/layout/components/header/AppIcon.js +1 -59
  57. package/dist/components/layout/components/header/AppTitle.d.ts.map +1 -1
  58. package/dist/components/layout/components/header/AppTitle.js +1 -40
  59. package/dist/components/layout/components/header/CacheSettings.js +1 -225
  60. package/dist/components/layout/components/header/GameTitle.d.ts.map +1 -1
  61. package/dist/components/layout/components/header/GameTitle.js +1 -66
  62. package/dist/components/layout/components/header/HeaderMenu.js +1 -75
  63. package/dist/components/layout/components/header/HeaderNavigation.d.ts.map +1 -1
  64. package/dist/components/layout/components/header/HeaderNavigation.js +1 -66
  65. package/dist/components/layout/components/header/SettingsMenu.d.ts.map +1 -1
  66. package/dist/components/layout/components/header/SettingsMenu.js +1 -85
  67. package/dist/components/layout/components/header/ThemeToggle.d.ts.map +1 -1
  68. package/dist/components/layout/components/header/ThemeToggle.js +1 -93
  69. package/dist/components/layout/components/index.js +1 -25
  70. package/dist/components/layout/index.js +1 -14
  71. package/dist/crud/components/ChildRowsPicker.js +1 -68
  72. package/dist/crud/components/CrudCardLink.js +1 -14
  73. package/dist/crud/components/EntityCardList.d.ts +4 -1
  74. package/dist/crud/components/EntityCardList.d.ts.map +1 -1
  75. package/dist/crud/components/EntityCardList.js +1 -184
  76. package/dist/crud/components/EntityDisplayRenderer.js +1 -130
  77. package/dist/crud/components/EntityFormRenderer.js +1 -433
  78. package/dist/crud/components/EntityList.js +1 -521
  79. package/dist/crud/components/EntityRecommendations.js +1 -87
  80. package/dist/crud/components/EntityWorkflow.js +1 -55
  81. package/dist/crud/components/Form.d.ts.map +1 -1
  82. package/dist/crud/components/Form.js +1 -198
  83. package/dist/crud/components/cellEditFor.js +1 -74
  84. package/dist/crud/components/entityParent.js +1 -76
  85. package/dist/crud/components/index.js +1 -16
  86. package/dist/crud/components/useRecordBreadcrumb.d.ts +3 -1
  87. package/dist/crud/components/useRecordBreadcrumb.d.ts.map +1 -1
  88. package/dist/crud/components/useRecordBreadcrumb.js +1 -43
  89. package/dist/crud/crudImports.js +1 -51
  90. package/dist/crud/index.js +1 -11
  91. package/dist/data/techLogos.js +1 -99
  92. package/dist/dndev-next.css +113 -41
  93. package/dist/dndev.css +113 -41
  94. package/dist/index.js +1 -5
  95. package/dist/internal/common/DnDevErrorBoundary.js +1 -55
  96. package/dist/internal/common/ErrorFallback.js +3 -214
  97. package/dist/internal/common/GlobalErrorFallback.js +1 -45
  98. package/dist/internal/common/RouteErrorFallback.js +3 -140
  99. package/dist/internal/devtools/DebugTools.js +1 -131
  100. package/dist/internal/devtools/components/AuthDebugButton.js +1 -72
  101. package/dist/internal/devtools/components/ConfigTab.js +1 -61
  102. package/dist/internal/devtools/components/CookieTab.js +1 -156
  103. package/dist/internal/devtools/components/DebugDialog.js +1 -48
  104. package/dist/internal/devtools/components/DesignTab.js +1 -469
  105. package/dist/internal/devtools/components/LayoutReset.js +1 -214
  106. package/dist/internal/devtools/components/MaskedValue.js +1 -39
  107. package/dist/internal/devtools/components/StoresTab.js +1 -90
  108. package/dist/internal/devtools/components/index.js +1 -16
  109. package/dist/internal/devtools/index.js +1 -13
  110. package/dist/internal/devtools/types.js +0 -2
  111. package/dist/internal/devtools/utils/envVarDiscovery.js +1 -106
  112. package/dist/internal/devtools/utils/index.js +1 -12
  113. package/dist/internal/devtools/utils/maskSensitive.js +1 -59
  114. package/dist/internal/devtools/utils/virtualModuleInspector.js +1 -309
  115. package/dist/internal/initializers/BaseStoresInitializer.js +1 -367
  116. package/dist/internal/initializers/NextJsStoresInitializer.js +1 -78
  117. package/dist/internal/initializers/ViteStoresInitializer.js +1 -20
  118. package/dist/internal/initializers/index.js +1 -11
  119. package/dist/internal/layout/DnDevLayout.js +1 -321
  120. package/dist/internal/layout/components/AutoMetaTags.d.ts +5 -0
  121. package/dist/internal/layout/components/AutoMetaTags.d.ts.map +1 -1
  122. package/dist/internal/layout/components/AutoMetaTags.js +1 -338
  123. package/dist/internal/layout/components/FaviconHead.d.ts +18 -14
  124. package/dist/internal/layout/components/FaviconHead.d.ts.map +1 -1
  125. package/dist/internal/layout/components/FaviconHead.js +1 -60
  126. package/dist/internal/layout/components/FontPreloadLinks.js +1 -31
  127. package/dist/internal/layout/components/HeadTags.js +1 -20
  128. package/dist/internal/layout/components/PWAUpdateNotification.js +1 -131
  129. package/dist/internal/layout/components/footer/FooterBranding.d.ts.map +1 -1
  130. package/dist/internal/layout/components/footer/FooterBranding.js +1 -35
  131. package/dist/internal/layout/components/footer/FooterCopyright.d.ts.map +1 -1
  132. package/dist/internal/layout/components/footer/FooterCopyright.js +1 -37
  133. package/dist/internal/layout/components/footer/FooterLegalLinks.d.ts.map +1 -1
  134. package/dist/internal/layout/components/footer/FooterLegalLinks.js +1 -44
  135. package/dist/internal/layout/components/footer/useLegalLinks.d.ts +4 -2
  136. package/dist/internal/layout/components/footer/useLegalLinks.d.ts.map +1 -1
  137. package/dist/internal/layout/components/footer/useLegalLinks.js +1 -21
  138. package/dist/internal/layout/components/headTagElement.d.ts +16 -0
  139. package/dist/internal/layout/components/headTagElement.d.ts.map +1 -0
  140. package/dist/internal/layout/components/headTagElement.js +1 -0
  141. package/dist/internal/layout/components/index.js +1 -13
  142. package/dist/internal/layout/components/prerenderedHead.d.ts +15 -0
  143. package/dist/internal/layout/components/prerenderedHead.d.ts.map +1 -0
  144. package/dist/internal/layout/components/prerenderedHead.js +1 -0
  145. package/dist/internal/layout/components/trailingSlash.d.ts +13 -0
  146. package/dist/internal/layout/components/trailingSlash.d.ts.map +1 -0
  147. package/dist/internal/layout/components/trailingSlash.js +1 -0
  148. package/dist/internal/layout/config/defaults.js +1 -47
  149. package/dist/internal/layout/config/index.js +1 -11
  150. package/dist/internal/layout/config/presets/admin.js +1 -35
  151. package/dist/internal/layout/config/presets/blog.js +1 -31
  152. package/dist/internal/layout/config/presets/docs.js +1 -51
  153. package/dist/internal/layout/config/presets/game.js +1 -53
  154. package/dist/internal/layout/config/presets/index.js +1 -24
  155. package/dist/internal/layout/config/presets/landing.js +1 -42
  156. package/dist/internal/layout/config/presets/moolti.js +1 -52
  157. package/dist/internal/layout/config/presets/plain.js +1 -25
  158. package/dist/internal/layout/renderers/index.js +0 -10
  159. package/dist/internal/layout/zones/DnDevFooter.d.ts.map +1 -1
  160. package/dist/internal/layout/zones/DnDevFooter.js +1 -67
  161. package/dist/internal/layout/zones/DnDevHeader.js +1 -41
  162. package/dist/internal/layout/zones/DnDevMergedBar.d.ts.map +1 -1
  163. package/dist/internal/layout/zones/DnDevMergedBar.js +1 -52
  164. package/dist/internal/layout/zones/DnDevSidebar.d.ts.map +1 -1
  165. package/dist/internal/layout/zones/DnDevSidebar.js +1 -181
  166. package/dist/internal/layout/zones/index.js +1 -14
  167. package/dist/internal/providers/NavigationProvider.d.ts.map +1 -1
  168. package/dist/internal/providers/NavigationProvider.js +1 -71
  169. package/dist/internal/providers/SentryInitializer.d.ts.map +1 -1
  170. package/dist/internal/providers/SentryInitializer.js +1 -36
  171. package/dist/internal/providers/UIProviders.js +1 -79
  172. package/dist/internal/providers/index.js +1 -12
  173. package/dist/next.js +1 -11
  174. package/dist/providers/NextJsAppProviders.d.ts.map +1 -1
  175. package/dist/providers/NextJsAppProviders.js +1 -107
  176. package/dist/providers/ViteAppProviders.d.ts +11 -9
  177. package/dist/providers/ViteAppProviders.d.ts.map +1 -1
  178. package/dist/providers/ViteAppProviders.js +1 -117
  179. package/dist/providers/index.js +1 -11
  180. package/dist/routing/404.js +1 -108
  181. package/dist/routing/AuthGuard.js +1 -178
  182. package/dist/routing/AuthGuardFallback.d.ts.map +1 -1
  183. package/dist/routing/AuthGuardFallback.js +1 -67
  184. package/dist/routing/AuthReturnTo.js +1 -68
  185. package/dist/routing/DnDevNavigationMenu.d.ts.map +1 -1
  186. package/dist/routing/DnDevNavigationMenu.js +1 -138
  187. package/dist/routing/GoTo.d.ts.map +1 -1
  188. package/dist/routing/GoTo.js +1 -38
  189. package/dist/routing/GoToDialog.d.ts.map +1 -1
  190. package/dist/routing/GoToDialog.js +1 -97
  191. package/dist/routing/GoToInput.d.ts.map +1 -1
  192. package/dist/routing/GoToInput.js +1 -49
  193. package/dist/routing/GoToWrapper.d.ts.map +1 -1
  194. package/dist/routing/GoToWrapper.js +1 -59
  195. package/dist/routing/Link.d.ts +10 -2
  196. package/dist/routing/Link.d.ts.map +1 -1
  197. package/dist/routing/Link.js +1 -109
  198. package/dist/routing/NavigationItem.d.ts.map +1 -1
  199. package/dist/routing/NavigationItem.js +1 -44
  200. package/dist/routing/NotFoundDocument.d.ts +33 -0
  201. package/dist/routing/NotFoundDocument.d.ts.map +1 -0
  202. package/dist/routing/NotFoundDocument.js +1 -0
  203. package/dist/routing/SignedInRedirect.js +1 -47
  204. package/dist/routing/hooks/hooks.next.js +1 -1
  205. package/dist/routing/hooks/hooks.vite.js +1 -1
  206. package/dist/routing/hooks/index.js +1 -26
  207. package/dist/routing/hooks/types.js +0 -2
  208. package/dist/routing/hooks/useLocation.next.js +1 -35
  209. package/dist/routing/hooks/useLocation.vite.js +1 -13
  210. package/dist/routing/hooks/useMatch.next.js +1 -31
  211. package/dist/routing/hooks/useMatch.vite.js +1 -6
  212. package/dist/routing/hooks/useNavigate.next.js +1 -64
  213. package/dist/routing/hooks/useNavigate.vite.js +1 -61
  214. package/dist/routing/hooks/useParams.next.js +1 -9
  215. package/dist/routing/hooks/useParams.vite.js +1 -6
  216. package/dist/routing/hooks/useQueryParams.next.js +1 -66
  217. package/dist/routing/hooks/useQueryParams.vite.js +1 -66
  218. package/dist/routing/hooks/useRedirectGuard.next.js +1 -119
  219. package/dist/routing/hooks/useRedirectGuard.vite.js +1 -117
  220. package/dist/routing/hooks/useRouteParam.next.js +1 -38
  221. package/dist/routing/hooks/useRouteParam.vite.js +1 -38
  222. package/dist/routing/hooks/useRoutePath.next.d.ts +5 -3
  223. package/dist/routing/hooks/useRoutePath.next.d.ts.map +1 -1
  224. package/dist/routing/hooks/useRoutePath.next.js +1 -36
  225. package/dist/routing/hooks/useRoutePath.vite.js +1 -25
  226. package/dist/routing/hooks/useSearchParams.next.js +1 -22
  227. package/dist/routing/hooks/useSearchParams.vite.js +1 -22
  228. package/dist/routing/hooks/useUrlLanguage.next.js +1 -50
  229. package/dist/routing/hooks/useUrlLanguage.vite.js +1 -41
  230. package/dist/routing/index.d.ts +1 -0
  231. package/dist/routing/index.d.ts.map +1 -1
  232. package/dist/routing/index.js +1 -32
  233. package/dist/routing/link/InternalLink.next.d.ts +23 -0
  234. package/dist/routing/link/InternalLink.next.d.ts.map +1 -0
  235. package/dist/routing/link/InternalLink.next.js +1 -0
  236. package/dist/routing/link/InternalLink.vite.d.ts +22 -0
  237. package/dist/routing/link/InternalLink.vite.d.ts.map +1 -0
  238. package/dist/routing/link/InternalLink.vite.js +1 -0
  239. package/dist/routing/link/absolutePath.d.ts +17 -0
  240. package/dist/routing/link/absolutePath.d.ts.map +1 -0
  241. package/dist/routing/link/absolutePath.js +1 -0
  242. package/dist/routing/link/link.next.d.ts +12 -0
  243. package/dist/routing/link/link.next.d.ts.map +1 -0
  244. package/dist/routing/link/link.next.js +1 -0
  245. package/dist/routing/link/link.vite.d.ts +12 -0
  246. package/dist/routing/link/link.vite.d.ts.map +1 -0
  247. package/dist/routing/link/link.vite.js +1 -0
  248. package/dist/routing/link/types.d.ts +30 -0
  249. package/dist/routing/link/types.d.ts.map +1 -0
  250. package/dist/routing/link/types.js +0 -0
  251. package/dist/routing/parentRoute.js +1 -43
  252. package/dist/routing/useGoTo.d.ts.map +1 -1
  253. package/dist/routing/useGoTo.js +1 -59
  254. package/dist/routing/useNavigation.d.ts.map +1 -1
  255. package/dist/routing/useNavigation.js +1 -114
  256. package/dist/routing/useRouteDiscovery.d.ts +4 -0
  257. package/dist/routing/useRouteDiscovery.d.ts.map +1 -1
  258. package/dist/routing/useRouteDiscovery.js +1 -313
  259. package/dist/rsc.d.ts +28 -0
  260. package/dist/rsc.d.ts.map +1 -0
  261. package/dist/rsc.js +1 -0
  262. package/dist/styles/index.css +113 -41
  263. package/dist/styles/index.js +1 -10
  264. package/dist/styles/layoutConstants.js +1 -134
  265. package/dist/symbol-index.json +1 -1
  266. package/dist/utils/assetResolver.d.ts +19 -19
  267. package/dist/utils/assetResolver.d.ts.map +1 -1
  268. package/dist/utils/assetResolver.js +1 -297
  269. package/dist/utils/index.d.ts +0 -1
  270. package/dist/utils/index.d.ts.map +1 -1
  271. package/dist/utils/index.js +1 -23
  272. package/dist/utils/sanitizeSvg.js +1 -51
  273. package/dist/utils/tList.js +1 -42
  274. package/dist/utils/useAISafe.d.ts.map +1 -1
  275. package/dist/utils/useAISafe.js +1 -53
  276. package/dist/utils/useAuthSafe.d.ts.map +1 -1
  277. package/dist/utils/useAuthSafe.js +1 -78
  278. package/dist/utils/useAuthVisibility.d.ts.map +1 -1
  279. package/dist/utils/useAuthVisibility.js +1 -63
  280. package/dist/utils/useBillingVisibility.d.ts.map +1 -1
  281. package/dist/utils/useBillingVisibility.js +1 -57
  282. package/dist/utils/useCrudSafe.d.ts.map +1 -1
  283. package/dist/utils/useCrudSafe.js +1 -75
  284. package/dist/utils/useDeleteAccountSafe.js +1 -52
  285. package/dist/utils/useFormStoreSafe.d.ts.map +1 -1
  286. package/dist/utils/useFormStoreSafe.js +1 -85
  287. package/dist/utils/useOAuthSafe.d.ts.map +1 -1
  288. package/dist/utils/useOAuthSafe.js +1 -38
  289. package/dist/utils/useStripeBillingSafe.d.ts.map +1 -1
  290. package/dist/utils/useStripeBillingSafe.js +1 -81
  291. package/dist/vite-routing/AppRoutes.d.ts.map +1 -1
  292. package/dist/vite-routing/AppRoutes.js +1 -235
  293. package/dist/vite-routing/RootLayout.d.ts.map +1 -1
  294. package/dist/vite-routing/RootLayout.js +1 -205
  295. package/dist/vite-routing/index.js +1 -11
  296. package/dist/vite.js +1 -10
  297. package/guidelines/COMPONENTS.md +3 -3
  298. package/guidelines/PAGES.md +3 -0
  299. package/guidelines/ROUTING.md +16 -0
  300. package/guidelines/SEO.md +160 -142
  301. package/package.json +18 -8
  302. package/dist/ChildRowsPicker-63M4EQUQ.js +0 -1
  303. package/dist/ChildRowsPicker-ISP365ON.js +0 -1
  304. package/dist/ChildRowsPicker-PQFE6NCR.js +0 -1
  305. package/dist/ChildRowsPicker-XXFFSMWY.js +0 -1
  306. package/dist/CookieConsent-QOUAY6B4.js +0 -1
  307. package/dist/GoToDialog-KSBGOIWO.js +0 -1
  308. package/dist/GoToDialog-XBK5EZF4.js +0 -1
  309. package/dist/chunk-3CIZFGST.js +0 -1
  310. package/dist/chunk-LHMKU342.js +0 -1
  311. package/dist/chunk-MS7ZIW5Z.js +0 -1
  312. package/dist/chunk-O2XFH626.js +0 -1
  313. package/dist/chunk-P2DHZWPY.js +0 -1
  314. package/dist/components/common/lucideIconByName.d.ts +0 -9
  315. package/dist/components/common/lucideIconByName.d.ts.map +0 -1
  316. package/dist/components/common/lucideIconByName.js +0 -32
  317. package/dist/internal/layout/components/PerformanceHints.d.ts +0 -71
  318. package/dist/internal/layout/components/PerformanceHints.d.ts.map +0 -1
  319. package/dist/internal/layout/components/PerformanceHints.js +0 -71
  320. package/dist/internal/layout/components/i18nSeoMeta.d.ts +0 -54
  321. package/dist/internal/layout/components/i18nSeoMeta.d.ts.map +0 -1
  322. package/dist/internal/layout/components/i18nSeoMeta.js +0 -53
  323. package/dist/utils/useSeo.d.ts +0 -129
  324. package/dist/utils/useSeo.d.ts.map +0 -1
  325. package/dist/utils/useSeo.js +0 -151
@@ -1,469 +1 @@
1
- 'use client';
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- // packages/ui/src/internal/devtools/components/DesignTab.tsx
4
- /**
5
- * @fileoverview Design Tab Component
6
- * @description Unified design debugging: themes, color ratio, typography
7
- *
8
- * @version 0.1.0
9
- * @since 0.0.1
10
- * @author AMBROISE PARK Consulting
11
- */
12
- import { Palette, Type } from 'lucide-react';
13
- import { useState, useEffect } from 'react';
14
- import { Card, Button, BUTTON_VARIANT, Stack, Label, Badge, BADGE_VARIANT, Alert, ALERT_VARIANT, DescriptionList, Text, ScrollArea, Accordion, CopyToClipboard, toast, } from '@donotdev/components';
15
- import { useTheme, useThemeReady } from '@donotdev/core';
16
- /** HTML, SVG and MathML elements all carry an inline `style`; narrows a generic Element to it. */
17
- function hasInlineStyle(el) {
18
- return 'style' in el;
19
- }
20
- export const DesignTab = () => {
21
- const currentTheme = useTheme('currentTheme');
22
- const availableThemes = useTheme('availableThemes');
23
- const isDarkMode = useTheme('isDarkMode');
24
- const isReady = useThemeReady();
25
- // Load cached analysis from localStorage
26
- const loadCachedAnalysis = () => {
27
- try {
28
- const cached = localStorage.getItem('dndev-design-analysis');
29
- if (cached) {
30
- const parsed = JSON.parse(cached);
31
- if (parsed.colorRatio)
32
- setColorRatio(parsed.colorRatio);
33
- if (parsed.typography)
34
- setTypography(parsed.typography);
35
- if (parsed.fontSizeColors)
36
- setFontSizeColors(parsed.fontSizeColors);
37
- }
38
- }
39
- catch (e) {
40
- if (process.env.NODE_ENV === 'development')
41
- console.warn('Cache operation failed:', e);
42
- }
43
- };
44
- // Save analysis to localStorage
45
- const saveAnalysis = (colorRatioData, typographyData, fontSizeColorsData) => {
46
- try {
47
- localStorage.setItem('dndev-design-analysis', JSON.stringify({
48
- colorRatio: colorRatioData,
49
- typography: typographyData,
50
- fontSizeColors: fontSizeColorsData,
51
- timestamp: new Date().toISOString(),
52
- }));
53
- }
54
- catch (e) {
55
- if (process.env.NODE_ENV === 'development')
56
- console.warn('Cache operation failed:', e);
57
- }
58
- };
59
- useEffect(() => {
60
- loadCachedAnalysis();
61
- }, []);
62
- const [colorRatio, setColorRatio] = useState(null);
63
- const [typography, setTypography] = useState(null);
64
- const [isAnalyzing, setIsAnalyzing] = useState(false);
65
- const [highlightedSize, setHighlightedSize] = useState(null);
66
- const [fontSizeColors, setFontSizeColors] = useState({});
67
- // Normalize font size for comparison (round to 2 decimals)
68
- const normalizeFontSize = (size) => {
69
- return parseFloat(size).toFixed(2) + 'px';
70
- };
71
- // Highlight/unhighlight elements by font size
72
- const toggleHighlight = (size) => {
73
- // Clear previous highlights
74
- document.querySelectorAll('[data-dndev-highlight]').forEach((el) => {
75
- if (hasInlineStyle(el))
76
- el.style.outline = '';
77
- el.removeAttribute('data-dndev-highlight');
78
- });
79
- if (highlightedSize === size) {
80
- setHighlightedSize(null);
81
- return;
82
- }
83
- // Highlight elements with matching font size - ONLY leaf nodes
84
- const elements = document.querySelectorAll('*');
85
- let count = 0;
86
- const normalizedSize = normalizeFontSize(size);
87
- elements.forEach((el) => {
88
- if (isOverlayElement(el))
89
- return;
90
- // Only highlight leaf nodes (same logic as analysis)
91
- const hasText = el.textContent && el.textContent.trim().length > 0;
92
- const hasChildElements = el.children.length > 0;
93
- if (!hasText || hasChildElements)
94
- return;
95
- const style = getComputedStyle(el);
96
- if (normalizeFontSize(style.fontSize) === normalizedSize) {
97
- if (hasInlineStyle(el))
98
- el.style.outline = '2px solid var(--primary)';
99
- el.setAttribute('data-dndev-highlight', 'true');
100
- count++;
101
- }
102
- });
103
- setHighlightedSize(size);
104
- toast('info', `Highlighting ${count} elements with ${size}`);
105
- };
106
- // Apply color to elements with matching font size
107
- const applyFontSizeColor = (size, color) => {
108
- // Clear previous color for this size
109
- document
110
- .querySelectorAll(`[data-dndev-font-size-color="${size}"]`)
111
- .forEach((el) => {
112
- if (hasInlineStyle(el))
113
- el.style.color = '';
114
- el.removeAttribute('data-dndev-font-size-color');
115
- });
116
- if (!color) {
117
- setFontSizeColors((prev) => {
118
- const next = { ...prev };
119
- delete next[size];
120
- return next;
121
- });
122
- return;
123
- }
124
- // Apply color to all elements with this font size - ONLY leaf nodes
125
- const elements = document.querySelectorAll('*');
126
- let count = 0;
127
- const normalizedSize = normalizeFontSize(size);
128
- elements.forEach((el) => {
129
- if (isOverlayElement(el))
130
- return;
131
- // Only color leaf nodes (same logic as analysis)
132
- const hasText = el.textContent && el.textContent.trim().length > 0;
133
- const hasChildElements = el.children.length > 0;
134
- if (!hasText || hasChildElements)
135
- return;
136
- const style = getComputedStyle(el);
137
- if (normalizeFontSize(style.fontSize) === normalizedSize) {
138
- if (hasInlineStyle(el))
139
- el.style.color = color;
140
- el.setAttribute('data-dndev-font-size-color', size);
141
- count++;
142
- }
143
- });
144
- const newColors = { ...fontSizeColors, [size]: color };
145
- setFontSizeColors(newColors);
146
- saveAnalysis(colorRatio, typography, newColors);
147
- };
148
- // Clear highlights on unmount or when dialog closes
149
- const clearHighlights = () => {
150
- document.querySelectorAll('[data-dndev-highlight]').forEach((el) => {
151
- if (hasInlineStyle(el))
152
- el.style.outline = '';
153
- el.removeAttribute('data-dndev-highlight');
154
- });
155
- document.querySelectorAll('[data-dndev-font-size-color]').forEach((el) => {
156
- if (hasInlineStyle(el))
157
- el.style.color = '';
158
- el.removeAttribute('data-dndev-font-size-color');
159
- });
160
- setHighlightedSize(null);
161
- setFontSizeColors({});
162
- saveAnalysis(colorRatio, typography, {});
163
- };
164
- // Get CSS variables from :root
165
- const getCSSVariables = () => {
166
- if (typeof document === 'undefined')
167
- return {};
168
- const root = document.documentElement;
169
- const style = getComputedStyle(root);
170
- const vars = {};
171
- const relevantVars = [
172
- '--background',
173
- '--foreground',
174
- '--card',
175
- '--card-foreground',
176
- '--popover',
177
- '--popover-foreground',
178
- '--primary',
179
- '--primary-foreground',
180
- '--secondary',
181
- '--secondary-foreground',
182
- '--muted',
183
- '--muted-foreground',
184
- '--accent',
185
- '--accent-foreground',
186
- '--destructive',
187
- '--destructive-foreground',
188
- '--border',
189
- '--input',
190
- '--ring',
191
- '--radius',
192
- '--font-sans',
193
- '--font-mono',
194
- '--font-family',
195
- ];
196
- relevantVars.forEach((varName) => {
197
- const value = style.getPropertyValue(varName).trim();
198
- if (value)
199
- vars[varName] = value;
200
- });
201
- return vars;
202
- };
203
- // Check if element is inside devtools, dialogs, or overlays
204
- const isOverlayElement = (el) => {
205
- return !!(el.closest('[data-dndev-devtools]') ||
206
- el.closest('[data-radix-portal]') ||
207
- el.closest('[role="dialog"]') ||
208
- el.closest('[data-state="open"]') ||
209
- el.closest('.dndev-sheet-content'));
210
- };
211
- const analyzeTypography = () => {
212
- const elements = document.querySelectorAll('*');
213
- const fontSizeMap = new Map();
214
- const fontFamilyMap = new Map();
215
- let analyzedCount = 0;
216
- elements.forEach((el) => {
217
- if (isOverlayElement(el))
218
- return;
219
- if (el.tagName === 'SCRIPT' ||
220
- el.tagName === 'STYLE' ||
221
- el.tagName === 'NOSCRIPT')
222
- return;
223
- const style = getComputedStyle(el);
224
- const rect = el.getBoundingClientRect();
225
- if (rect.width === 0 || rect.height === 0)
226
- return;
227
- if (style.display === 'none' || style.visibility === 'hidden')
228
- return;
229
- // ONLY leaf nodes with text, no children
230
- const hasText = el.textContent && el.textContent.trim().length > 0;
231
- if (!hasText || el.children.length > 0)
232
- return;
233
- analyzedCount++;
234
- const fontSize = style.fontSize;
235
- const fontSizeRounded = parseFloat(fontSize).toFixed(2) + 'px';
236
- fontSizeMap.set(fontSizeRounded, (fontSizeMap.get(fontSizeRounded) || 0) + 1);
237
- const fontFamily = style.fontFamily
238
- ?.split(',')[0]
239
- ?.trim()
240
- ?.replace(/['"]/g, '');
241
- if (fontFamily) {
242
- fontFamilyMap.set(fontFamily, (fontFamilyMap.get(fontFamily) || 0) + 1);
243
- }
244
- });
245
- const fontSizes = Array.from(fontSizeMap.entries())
246
- .map(([size, count]) => ({ size, count }))
247
- .sort((a, b) => b.count - a.count);
248
- const fontFamilies = Array.from(fontFamilyMap.entries())
249
- .map(([family, count]) => ({ family, count }))
250
- .sort((a, b) => b.count - a.count);
251
- return {
252
- fontSizes,
253
- fontFamilies,
254
- totalElements: analyzedCount,
255
- };
256
- };
257
- const analyzeColorRatio = () => {
258
- const elements = document.querySelectorAll('*');
259
- const colorMap = new Map();
260
- elements.forEach((el) => {
261
- // Skip overlay/devtools elements
262
- if (isOverlayElement(el))
263
- return;
264
- const style = getComputedStyle(el);
265
- const bg = style.backgroundColor;
266
- const rect = el.getBoundingClientRect();
267
- const area = rect.width * rect.height;
268
- if (bg && bg !== 'rgba(0, 0, 0, 0)' && bg !== 'transparent' && area > 0) {
269
- const existing = colorMap.get(bg) || { count: 0, area: 0 };
270
- colorMap.set(bg, {
271
- count: existing.count + 1,
272
- area: existing.area + area,
273
- });
274
- }
275
- });
276
- const totalArea = Array.from(colorMap.values()).reduce((sum, v) => sum + v.area, 0);
277
- if (totalArea === 0)
278
- return { dominant: 0, secondary: 0, accent: 0, details: [] };
279
- const colors = Array.from(colorMap.entries())
280
- .map(([color, data]) => ({
281
- color,
282
- percentage: (data.area / totalArea) * 100,
283
- }))
284
- .sort((a, b) => b.percentage - a.percentage);
285
- // Simplified categorization based on percentage
286
- const dominant = colors
287
- .slice(0, 2)
288
- .reduce((sum, c) => sum + c.percentage, 0);
289
- const secondary = colors
290
- .slice(2, 5)
291
- .reduce((sum, c) => sum + c.percentage, 0);
292
- const accent = colors.slice(5).reduce((sum, c) => sum + c.percentage, 0);
293
- return {
294
- dominant,
295
- secondary,
296
- accent,
297
- details: colors.slice(0, 15).map((c) => ({
298
- ...c,
299
- category: c.percentage > 30
300
- ? 'dominant'
301
- : c.percentage > 10
302
- ? 'secondary'
303
- : 'accent',
304
- })),
305
- };
306
- };
307
- const runAnalysis = () => {
308
- setIsAnalyzing(true);
309
- try {
310
- const colorRatioData = analyzeColorRatio();
311
- const typographyData = analyzeTypography();
312
- setColorRatio(colorRatioData);
313
- setTypography(typographyData);
314
- saveAnalysis(colorRatioData, typographyData, fontSizeColors);
315
- toast('success', 'Analysis complete');
316
- }
317
- catch (error) {
318
- console.error('Analysis failed:', error);
319
- toast('error', 'Analysis failed');
320
- }
321
- finally {
322
- setIsAnalyzing(false);
323
- }
324
- };
325
- // Format analysis results for clipboard
326
- const getAnalysisJson = () => {
327
- return JSON.stringify({
328
- theme: {
329
- current: currentTheme,
330
- isDarkMode,
331
- isReady,
332
- availableCount: availableThemes.length,
333
- },
334
- cssVariables: getCSSVariables(),
335
- colorRatio: colorRatio || null,
336
- typography: typography || null,
337
- timestamp: new Date().toISOString(),
338
- }, null, 2);
339
- };
340
- const copyAnalysis = () => {
341
- navigator.clipboard
342
- .writeText(getAnalysisJson())
343
- .then(() => {
344
- toast('success', 'Analysis copied to clipboard');
345
- })
346
- .catch(() => {
347
- toast('error', 'Failed to copy');
348
- });
349
- };
350
- const cssVars = getCSSVariables();
351
- const themeItems = [
352
- {
353
- label: 'Current',
354
- value: _jsx(Text, { className: "dndev-font-mono", children: currentTheme }),
355
- },
356
- {
357
- label: 'Dark Mode',
358
- value: (_jsx(Badge, { variant: isDarkMode ? BADGE_VARIANT.DEFAULT : BADGE_VARIANT.SECONDARY, children: isDarkMode ? 'Yes' : 'No' })),
359
- },
360
- {
361
- label: 'Ready',
362
- value: (_jsx(Badge, { variant: isReady ? BADGE_VARIANT.DEFAULT : BADGE_VARIANT.DESTRUCTIVE, children: isReady ? 'Yes' : 'No' })),
363
- },
364
- {
365
- label: 'Available',
366
- value: (_jsxs(Text, { className: "dndev-font-mono", children: [availableThemes.length, " themes"] })),
367
- },
368
- ];
369
- const isColorCompliant = colorRatio &&
370
- colorRatio.dominant >= 50 &&
371
- colorRatio.dominant <= 70 &&
372
- colorRatio.secondary >= 20 &&
373
- colorRatio.secondary <= 40 &&
374
- colorRatio.accent >= 5 &&
375
- colorRatio.accent <= 20;
376
- return (_jsxs(Stack, { style: { padding: 'var(--gap-md)' }, children: [_jsx(Accordion, { type: "single", collapsible: true, items: [
377
- {
378
- value: 'theme',
379
- trigger: _jsx("span", { children: "Theme Info" }),
380
- content: (_jsxs(Stack, { children: [_jsx(Card, { title: "Theme", subtitle: currentTheme, children: _jsx(DescriptionList, { items: themeItems }) }), _jsx(Card, { title: "CSS Variables", subtitle: `${Object.keys(cssVars).length} variables`, children: _jsx(ScrollArea, { className: "dndev-max-h-48", children: _jsx(Stack, { gap: "tight", children: Object.entries(cssVars).map(([name, value]) => (_jsxs(Stack, { direction: "row", align: "center", justify: "between", gap: "tight", children: [_jsx(Text, { className: "dndev-font-mono dndev-text-xs", children: name }), _jsxs(Stack, { direction: "row", align: "center", gap: "tight", children: [_jsx("div", { style: {
381
- width: '1rem',
382
- height: '1rem',
383
- backgroundColor: `var(${name})`,
384
- border: '1px solid var(--border)',
385
- borderRadius: 'var(--radius-sm)',
386
- } }), _jsx(Text, { className: "dndev-font-mono dndev-text-xs dndev-text-muted-foreground", children: value })] })] }, name))) }) }) })] })),
387
- },
388
- ] }), _jsxs(Stack, { direction: "row", gap: "tight", children: [_jsx(Button, { onClick: runAnalysis, variant: BUTTON_VARIANT.DEFAULT, icon: Palette, disabled: isAnalyzing, style: { flex: 1 }, children: isAnalyzing ? 'Analyzing...' : 'Analyze Page' }), _jsx(Button, { onClick: copyAnalysis, variant: BUTTON_VARIANT.OUTLINE, disabled: !colorRatio && !typography, children: "Copy JSON" })] }), colorRatio && (_jsx(Card, { content: _jsxs(Stack, { direction: "row", align: "center", justify: "between", className: "dndev-w-full", children: [_jsx("span", { children: "60/30/10 Color Ratio" }), _jsx(Badge, { variant: isColorCompliant
389
- ? BADGE_VARIANT.DEFAULT
390
- : BADGE_VARIANT.SECONDARY, children: isColorCompliant ? '✓ Balanced' : '⚠ Review' })] }), children: _jsxs(Stack, { gap: "tight", children: [_jsxs(Stack, { direction: "row", justify: "between", children: [_jsx("span", { children: "Dominant (60%)" }), _jsxs("span", { className: colorRatio.dominant >= 50 && colorRatio.dominant <= 70
391
- ? 'dndev-text-primary'
392
- : 'dndev-text-destructive', children: [colorRatio.dominant.toFixed(1), "%"] })] }), _jsxs(Stack, { direction: "row", justify: "between", children: [_jsx("span", { children: "Secondary (30%)" }), _jsxs("span", { className: colorRatio.secondary >= 20 && colorRatio.secondary <= 40
393
- ? 'dndev-text-primary'
394
- : 'dndev-text-destructive', children: [colorRatio.secondary.toFixed(1), "%"] })] }), _jsxs(Stack, { direction: "row", justify: "between", children: [_jsx("span", { children: "Accent (10%)" }), _jsxs("span", { className: colorRatio.accent >= 5 && colorRatio.accent <= 20
395
- ? 'dndev-text-primary'
396
- : 'dndev-text-destructive', children: [colorRatio.accent.toFixed(1), "%"] })] }), colorRatio.details.length > 0 && (_jsx(Accordion, { type: "single", collapsible: true, items: [
397
- {
398
- value: 'colors',
399
- trigger: (_jsxs("span", { className: "dndev-text-sm", children: ["Top Colors (", colorRatio.details.length, ")"] })),
400
- content: (_jsx(Stack, { gap: "tight", children: colorRatio.details.map((c, i) => (_jsxs(Stack, { direction: "row", align: "center", gap: "tight", children: [_jsx("div", { style: {
401
- width: '1rem',
402
- height: '1rem',
403
- backgroundColor: c.color,
404
- border: '1px solid var(--border)',
405
- flexShrink: 0,
406
- } }), _jsxs(Text, { className: "dndev-text-xs dndev-font-mono", style: { flex: 1 }, children: [c.percentage.toFixed(1), "%"] }), _jsx(Badge, { variant: BADGE_VARIANT.SECONDARY, children: c.category })] }, i))) })),
407
- },
408
- ] }))] }) })), typography && typography.fontFamilies.length > 0 && (_jsx(Card, { content: _jsxs(Stack, { direction: "row", align: "center", justify: "between", className: "dndev-w-full", children: [_jsx("span", { children: "Font Families" }), _jsxs(Badge, { variant: BADGE_VARIANT.SECONDARY, children: [typography.fontFamilies.length, " families"] })] }), children: _jsx(Stack, { gap: "tight", className: "dndev-mt-xs", children: typography.fontFamilies.map((f, i) => (_jsxs(Stack, { direction: "row", justify: "between", align: "center", gap: "tight", style: {
409
- padding: 'var(--gap-sm)',
410
- borderRadius: 'var(--radius-sm)',
411
- }, children: [_jsx(Text, { className: "dndev-font-mono dndev-text-xs", style: { flex: 1 }, children: f.family }), _jsxs(Text, { className: "dndev-text-xs", style: {
412
- opacity: 0.6,
413
- minWidth: '2rem',
414
- textAlign: 'end',
415
- }, children: [f.count, "\u00D7"] })] }, i))) }) })), typography && (_jsxs(Card, { content: _jsxs(Stack, { direction: "row", align: "center", justify: "between", className: "dndev-w-full", children: [_jsx("span", { children: "Font Sizes" }), _jsxs(Badge, { variant: BADGE_VARIANT.SECONDARY, children: [typography.totalElements, " elements"] })] }), children: [_jsxs(Stack, { direction: "row", align: "center", justify: "between", children: [_jsxs(Label, { className: "dndev-text-sm dndev-font-semibold", children: [typography.fontSizes.length, " sizes"] }), (highlightedSize || Object.keys(fontSizeColors).length > 0) && (_jsx(Button, { variant: BUTTON_VARIANT.GHOST, onClick: clearHighlights, style: { padding: '0 var(--gap-sm)', height: 'auto' }, children: _jsx(Text, { className: "dndev-text-xs", children: "Clear All" }) }))] }), _jsx(Stack, { gap: "tight", className: "dndev-mt-xs", children: typography.fontSizes.map((f, i) => {
416
- const isOrphan = f.count < 5;
417
- const isHighlighted = highlightedSize === f.size;
418
- const currentColor = fontSizeColors[f.size] || '';
419
- const findOrphanElements = () => {
420
- const normalizedSize = normalizeFontSize(f.size);
421
- const found = Array.from(document.querySelectorAll('*')).filter((el) => {
422
- if (el.closest('[data-dndev-devtools]') ||
423
- el.closest('[data-radix-portal]') ||
424
- el.closest('[role="dialog"]'))
425
- return false;
426
- const style = getComputedStyle(el);
427
- const hasText = el.textContent && el.textContent.trim().length > 0;
428
- if (!hasText || el.children.length > 0)
429
- return false;
430
- return normalizeFontSize(style.fontSize) === normalizedSize;
431
- });
432
- found.forEach((el) => {
433
- // Log text content only (not the DOM node) to avoid memory leaks from retained element refs
434
- console.log('[DesignTab]', el.textContent?.trim().substring(0, 50));
435
- if (hasInlineStyle(el))
436
- el.style.outline = '2px solid red';
437
- });
438
- console.log(`[DesignTab] Found ${found.length} elements with ${f.size}`);
439
- };
440
- return (_jsxs(Stack, { direction: "row", justify: "between", align: "center", gap: "tight", style: {
441
- padding: 'var(--gap-sm)',
442
- borderRadius: 'var(--radius-sm)',
443
- backgroundColor: isHighlighted
444
- ? 'var(--primary)'
445
- : 'transparent',
446
- color: isHighlighted
447
- ? 'var(--primary-foreground)'
448
- : 'inherit',
449
- }, children: [_jsxs(Stack, { direction: "row", align: "center", gap: "tight", onClick: () => toggleHighlight(f.size), style: { cursor: 'pointer', flex: 1 }, children: [_jsx(Text, { className: "dndev-font-mono dndev-text-xs", children: f.size }), isOrphan && (_jsx(Badge, { variant: BADGE_VARIANT.DESTRUCTIVE, children: "orphan" }))] }), isOrphan ? (_jsx(Button, { variant: BUTTON_VARIANT.GHOST, onClick: (e) => {
450
- e.stopPropagation();
451
- findOrphanElements();
452
- }, style: {
453
- padding: '0 var(--gap-sm)',
454
- height: '1.5rem',
455
- minWidth: '2rem',
456
- }, title: `Find ${f.size} elements in console`, children: _jsx(Text, { className: "dndev-text-xs", children: "\uD83D\uDD0D" }) })) : (_jsx("input", { type: "color", value: currentColor || '#000000', onChange: (e) => applyFontSizeColor(f.size, e.target.value), onClick: (e) => e.stopPropagation(), style: {
457
- width: '2rem',
458
- height: '1.5rem',
459
- border: '1px solid var(--border)',
460
- borderRadius: 'var(--radius-sm)',
461
- cursor: 'pointer',
462
- padding: 0,
463
- }, title: `Color elements with ${f.size}` })), _jsxs(Text, { className: "dndev-text-xs", style: {
464
- opacity: isHighlighted ? 1 : 0.6,
465
- minWidth: '2rem',
466
- textAlign: 'end',
467
- }, children: [f.count, "\u00D7"] })] }, i));
468
- }) })] })), !colorRatio && !typography && (_jsx(Alert, { variant: ALERT_VARIANT.INFO, children: "Click \"Analyze Page\" to check color ratio and typography" }))] }));
469
- };
1
+ "use client";import{Palette as oe}from"lucide-react";import{useState as T,useEffect as ae}from"react";import{Card as N,Button as E,BUTTON_VARIANT as F,Stack as c,Label as re,Badge as f,BADGE_VARIANT as h,Alert as se,ALERT_VARIANT as ie,DescriptionList as le,Text as p,ScrollArea as ce,Accordion as J,toast as R}from"@donotdev/components";import{useTheme as j,useThemeReady as de}from"@donotdev/core";import{jsx as o,jsxs as r}from"react/jsx-runtime";function v(b){return"style"in b}var fe=()=>{let b=j("currentTheme"),L=j("availableThemes"),D=j("isDarkMode"),O=de(),_=()=>{try{let e=localStorage.getItem("dndev-design-analysis");if(e){let a=JSON.parse(e);a.colorRatio&&q(a.colorRatio),a.typography&&M(a.typography),a.fontSizeColors&&w(a.fontSizeColors)}}catch{}},B=(e,a,d)=>{try{localStorage.setItem("dndev-design-analysis",JSON.stringify({colorRatio:e,typography:a,fontSizeColors:d,timestamp:new Date().toISOString()}))}catch{}};ae(()=>{_()},[]);let[i,q]=T(null),[u,M]=T(null),[$,P]=T(!1),[I,V]=T(null),[k,w]=T({}),S=e=>parseFloat(e).toFixed(2)+"px",G=e=>{if(document.querySelectorAll("[data-dndev-highlight]").forEach(l=>{v(l)&&(l.style.outline=""),l.removeAttribute("data-dndev-highlight")}),I===e){V(null);return}let a=document.querySelectorAll("*"),d=0,g=S(e);a.forEach(l=>{if(z(l))return;let m=l.textContent&&l.textContent.trim().length>0,t=l.children.length>0;if(!m||t)return;let n=getComputedStyle(l);S(n.fontSize)===g&&(v(l)&&(l.style.outline="2px solid var(--primary)"),l.setAttribute("data-dndev-highlight","true"),d++)}),V(e),R("info",`Highlighting ${d} elements with ${e}`)},W=(e,a)=>{if(document.querySelectorAll(`[data-dndev-font-size-color="${e}"]`).forEach(t=>{v(t)&&(t.style.color=""),t.removeAttribute("data-dndev-font-size-color")}),!a){w(t=>{let n={...t};return delete n[e],n});return}let d=document.querySelectorAll("*"),g=0,l=S(e);d.forEach(t=>{if(z(t))return;let n=t.textContent&&t.textContent.trim().length>0,s=t.children.length>0;if(!n||s)return;let y=getComputedStyle(t);S(y.fontSize)===l&&(v(t)&&(t.style.color=a),t.setAttribute("data-dndev-font-size-color",e),g++)});let m={...k,[e]:a};w(m),B(i,u,m)},K=()=>{document.querySelectorAll("[data-dndev-highlight]").forEach(e=>{v(e)&&(e.style.outline=""),e.removeAttribute("data-dndev-highlight")}),document.querySelectorAll("[data-dndev-font-size-color]").forEach(e=>{v(e)&&(e.style.color=""),e.removeAttribute("data-dndev-font-size-color")}),V(null),w({}),B(i,u,{})},U=()=>{if(typeof document>"u")return{};let e=document.documentElement,a=getComputedStyle(e),d={};return["--background","--foreground","--card","--card-foreground","--popover","--popover-foreground","--primary","--primary-foreground","--secondary","--secondary-foreground","--muted","--muted-foreground","--accent","--accent-foreground","--destructive","--destructive-foreground","--border","--input","--ring","--radius","--font-sans","--font-mono","--font-family"].forEach(l=>{let m=a.getPropertyValue(l).trim();m&&(d[l]=m)}),d},z=e=>!!(e.closest("[data-dndev-devtools]")||e.closest("[data-radix-portal]")||e.closest('[role="dialog"]')||e.closest('[data-state="open"]')||e.closest(".dndev-sheet-content")),Q=()=>{let e=document.querySelectorAll("*"),a=new Map,d=new Map,g=0;e.forEach(t=>{if(z(t)||t.tagName==="SCRIPT"||t.tagName==="STYLE"||t.tagName==="NOSCRIPT")return;let n=getComputedStyle(t),s=t.getBoundingClientRect();if(s.width===0||s.height===0||n.display==="none"||n.visibility==="hidden"||!(t.textContent&&t.textContent.trim().length>0)||t.children.length>0)return;g++;let C=n.fontSize,A=parseFloat(C).toFixed(2)+"px";a.set(A,(a.get(A)||0)+1);let x=n.fontFamily?.split(",")[0]?.trim()?.replace(/['"]/g,"");x&&d.set(x,(d.get(x)||0)+1)});let l=Array.from(a.entries()).map(([t,n])=>({size:t,count:n})).sort((t,n)=>n.count-t.count),m=Array.from(d.entries()).map(([t,n])=>({family:t,count:n})).sort((t,n)=>n.count-t.count);return{fontSizes:l,fontFamilies:m,totalElements:g}},X=()=>{let e=document.querySelectorAll("*"),a=new Map;e.forEach(n=>{if(z(n))return;let y=getComputedStyle(n).backgroundColor,C=n.getBoundingClientRect(),A=C.width*C.height;if(y&&y!=="rgba(0, 0, 0, 0)"&&y!=="transparent"&&A>0){let x=a.get(y)||{count:0,area:0};a.set(y,{count:x.count+1,area:x.area+A})}});let d=Array.from(a.values()).reduce((n,s)=>n+s.area,0);if(d===0)return{dominant:0,secondary:0,accent:0,details:[]};let g=Array.from(a.entries()).map(([n,s])=>({color:n,percentage:s.area/d*100})).sort((n,s)=>s.percentage-n.percentage),l=g.slice(0,2).reduce((n,s)=>n+s.percentage,0),m=g.slice(2,5).reduce((n,s)=>n+s.percentage,0),t=g.slice(5).reduce((n,s)=>n+s.percentage,0);return{dominant:l,secondary:m,accent:t,details:g.slice(0,15).map(n=>({...n,category:n.percentage>30?"dominant":n.percentage>10?"secondary":"accent"}))}},Z=()=>{P(!0);try{let e=X(),a=Q();q(e),M(a),B(e,a,k),R("success","Analysis complete")}catch{R("error","Analysis failed")}finally{P(!1)}},ee=()=>JSON.stringify({theme:{current:b,isDarkMode:D,isReady:O,availableCount:L.length},cssVariables:U(),colorRatio:i||null,typography:u||null,timestamp:new Date().toISOString()},null,2),te=()=>{navigator.clipboard.writeText(ee()).then(()=>{R("success","Analysis copied to clipboard")}).catch(()=>{R("error","Failed to copy")})},Y=U(),ne=[{label:"Current",value:o(p,{className:"dndev-font-mono",children:b})},{label:"Dark Mode",value:o(f,{variant:D?h.DEFAULT:h.SECONDARY,children:D?"Yes":"No"})},{label:"Ready",value:o(f,{variant:O?h.DEFAULT:h.DESTRUCTIVE,children:O?"Yes":"No"})},{label:"Available",value:r(p,{className:"dndev-font-mono",children:[L.length," themes"]})}],H=i&&i.dominant>=50&&i.dominant<=70&&i.secondary>=20&&i.secondary<=40&&i.accent>=5&&i.accent<=20;return r(c,{style:{padding:"var(--gap-md)"},children:[o(J,{type:"single",collapsible:!0,items:[{value:"theme",trigger:o("span",{children:"Theme Info"}),content:r(c,{children:[o(N,{title:"Theme",subtitle:b,children:o(le,{items:ne})}),o(N,{title:"CSS Variables",subtitle:`${Object.keys(Y).length} variables`,children:o(ce,{className:"dndev-max-h-48",children:o(c,{gap:"tight",children:Object.entries(Y).map(([e,a])=>r(c,{direction:"row",align:"center",justify:"between",gap:"tight",children:[o(p,{className:"dndev-font-mono dndev-text-xs",children:e}),r(c,{direction:"row",align:"center",gap:"tight",children:[o("div",{style:{width:"1rem",height:"1rem",backgroundColor:`var(${e})`,border:"1px solid var(--border)",borderRadius:"var(--radius-sm)"}}),o(p,{className:"dndev-font-mono dndev-text-xs dndev-text-muted-foreground",children:a})]})]},e))})})})]})}]}),r(c,{direction:"row",gap:"tight",children:[o(E,{onClick:Z,variant:F.DEFAULT,icon:oe,disabled:$,style:{flex:1},children:$?"Analyzing...":"Analyze Page"}),o(E,{onClick:te,variant:F.OUTLINE,disabled:!i&&!u,children:"Copy JSON"})]}),i&&o(N,{content:r(c,{direction:"row",align:"center",justify:"between",className:"dndev-w-full",children:[o("span",{children:"60/30/10 Color Ratio"}),o(f,{variant:H?h.DEFAULT:h.SECONDARY,children:H?"\u2713 Balanced":"\u26A0 Review"})]}),children:r(c,{gap:"tight",children:[r(c,{direction:"row",justify:"between",children:[o("span",{children:"Dominant (60%)"}),r("span",{className:i.dominant>=50&&i.dominant<=70?"dndev-text-primary":"dndev-text-destructive",children:[i.dominant.toFixed(1),"%"]})]}),r(c,{direction:"row",justify:"between",children:[o("span",{children:"Secondary (30%)"}),r("span",{className:i.secondary>=20&&i.secondary<=40?"dndev-text-primary":"dndev-text-destructive",children:[i.secondary.toFixed(1),"%"]})]}),r(c,{direction:"row",justify:"between",children:[o("span",{children:"Accent (10%)"}),r("span",{className:i.accent>=5&&i.accent<=20?"dndev-text-primary":"dndev-text-destructive",children:[i.accent.toFixed(1),"%"]})]}),i.details.length>0&&o(J,{type:"single",collapsible:!0,items:[{value:"colors",trigger:r("span",{className:"dndev-text-sm",children:["Top Colors (",i.details.length,")"]}),content:o(c,{gap:"tight",children:i.details.map((e,a)=>r(c,{direction:"row",align:"center",gap:"tight",children:[o("div",{style:{width:"1rem",height:"1rem",backgroundColor:e.color,border:"1px solid var(--border)",flexShrink:0}}),r(p,{className:"dndev-text-xs dndev-font-mono",style:{flex:1},children:[e.percentage.toFixed(1),"%"]}),o(f,{variant:h.SECONDARY,children:e.category})]},a))})}]})]})}),u&&u.fontFamilies.length>0&&o(N,{content:r(c,{direction:"row",align:"center",justify:"between",className:"dndev-w-full",children:[o("span",{children:"Font Families"}),r(f,{variant:h.SECONDARY,children:[u.fontFamilies.length," families"]})]}),children:o(c,{gap:"tight",className:"dndev-mt-xs",children:u.fontFamilies.map((e,a)=>r(c,{direction:"row",justify:"between",align:"center",gap:"tight",style:{padding:"var(--gap-sm)",borderRadius:"var(--radius-sm)"},children:[o(p,{className:"dndev-font-mono dndev-text-xs",style:{flex:1},children:e.family}),r(p,{className:"dndev-text-xs",style:{opacity:.6,minWidth:"2rem",textAlign:"end"},children:[e.count,"\xD7"]})]},a))})}),u&&r(N,{content:r(c,{direction:"row",align:"center",justify:"between",className:"dndev-w-full",children:[o("span",{children:"Font Sizes"}),r(f,{variant:h.SECONDARY,children:[u.totalElements," elements"]})]}),children:[r(c,{direction:"row",align:"center",justify:"between",children:[r(re,{className:"dndev-text-sm dndev-font-semibold",children:[u.fontSizes.length," sizes"]}),(I||Object.keys(k).length>0)&&o(E,{variant:F.GHOST,onClick:K,style:{padding:"0 var(--gap-sm)",height:"auto"},children:o(p,{className:"dndev-text-xs",children:"Clear All"})})]}),o(c,{gap:"tight",className:"dndev-mt-xs",children:u.fontSizes.map((e,a)=>{let d=e.count<5,g=I===e.size,l=k[e.size]||"",m=()=>{let t=S(e.size);Array.from(document.querySelectorAll("*")).filter(s=>{if(s.closest("[data-dndev-devtools]")||s.closest("[data-radix-portal]")||s.closest('[role="dialog"]'))return!1;let y=getComputedStyle(s);return!(s.textContent&&s.textContent.trim().length>0)||s.children.length>0?!1:S(y.fontSize)===t}).forEach(s=>{v(s)&&(s.style.outline="2px solid red")})};return r(c,{direction:"row",justify:"between",align:"center",gap:"tight",style:{padding:"var(--gap-sm)",borderRadius:"var(--radius-sm)",backgroundColor:g?"var(--primary)":"transparent",color:g?"var(--primary-foreground)":"inherit"},children:[r(c,{direction:"row",align:"center",gap:"tight",onClick:()=>G(e.size),style:{cursor:"pointer",flex:1},children:[o(p,{className:"dndev-font-mono dndev-text-xs",children:e.size}),d&&o(f,{variant:h.DESTRUCTIVE,children:"orphan"})]}),d?o(E,{variant:F.GHOST,onClick:t=>{t.stopPropagation(),m()},style:{padding:"0 var(--gap-sm)",height:"1.5rem",minWidth:"2rem"},title:`Find ${e.size} elements in console`,children:o(p,{className:"dndev-text-xs",children:"\u{1F50D}"})}):o("input",{type:"color",value:l||"#000000",onChange:t=>W(e.size,t.target.value),onClick:t=>t.stopPropagation(),style:{width:"2rem",height:"1.5rem",border:"1px solid var(--border)",borderRadius:"var(--radius-sm)",cursor:"pointer",padding:0},title:`Color elements with ${e.size}`}),r(p,{className:"dndev-text-xs",style:{opacity:g?1:.6,minWidth:"2rem",textAlign:"end"},children:[e.count,"\xD7"]})]},a)})})]}),!i&&!u&&o(se,{variant:ie.INFO,children:'Click "Analyze Page" to check color ratio and typography'})]})};export{fe as DesignTab};