@donotdev/ui 0.1.1 → 0.1.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +21 -242
- package/README.md +1 -19
- package/assets/apple-touch-icon.png +0 -0
- package/assets/favicon.ico +0 -0
- package/assets/fonts/Inter-latin-ext.woff2 +0 -0
- package/assets/fonts/Inter-latin.woff2 +0 -0
- package/assets/fonts/PlayfairDisplay-latin-ext.woff2 +0 -0
- package/assets/fonts/PlayfairDisplay-latin.woff2 +0 -0
- package/assets/fonts/Roboto-400-cyrillic-ext.woff2 +0 -0
- package/assets/fonts/Roboto-400-cyrillic.woff2 +0 -0
- package/assets/fonts/Roboto-400-greek-ext.woff2 +0 -0
- package/assets/fonts/Roboto-400-greek.woff2 +0 -0
- package/assets/fonts/Roboto-400-latin-ext.woff2 +0 -0
- package/assets/fonts/Roboto-400-latin.woff2 +0 -0
- package/assets/fonts/Roboto-400-vietnamese.woff2 +0 -0
- package/assets/fonts/Roboto-700-cyrillic-ext.woff2 +0 -0
- package/assets/fonts/Roboto-700-cyrillic.woff2 +0 -0
- package/assets/fonts/Roboto-700-greek-ext.woff2 +0 -0
- package/assets/fonts/Roboto-700-greek.woff2 +0 -0
- package/assets/fonts/Roboto-700-latin-ext.woff2 +0 -0
- package/assets/fonts/Roboto-700-latin.woff2 +0 -0
- package/assets/fonts/Roboto-700-vietnamese.woff2 +0 -0
- package/assets/icon-192x192.png +0 -0
- package/assets/icon-512x512.png +0 -0
- package/assets/logo.png +0 -0
- package/assets/logo.svg +1 -1
- package/assets/manifest.json +0 -0
- package/dist/CookieConsent-5NH5DNTP.js +1 -0
- package/dist/{GoToDialog-RU5RP7S2.js → GoToDialog-CICRYHHG.js} +1 -1
- package/dist/chunk-MIPTBUWY.js +1 -0
- package/dist/components/common/FeatureCard.d.ts +9 -6
- package/dist/components/common/FeatureCard.d.ts.map +1 -1
- package/dist/components/common/FeatureCard.js +43 -32
- package/dist/components/cookie-consent/CookieConsent.d.ts +3 -3
- package/dist/components/cookie-consent/CookieConsent.d.ts.map +1 -1
- package/dist/components/cookie-consent/CookieConsent.js +36 -35
- package/dist/components/index.d.ts +0 -1
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +0 -1
- package/dist/components/layout/components/header/CacheSettings.d.ts.map +1 -1
- package/dist/components/layout/components/header/CacheSettings.js +6 -2
- package/dist/crud/components/EntityCardList.d.ts.map +1 -1
- package/dist/crud/components/EntityCardList.js +17 -4
- package/dist/crud/components/EntityDisplayRenderer.js +4 -4
- package/dist/crud/components/EntityFormRenderer.d.ts +6 -1
- package/dist/crud/components/EntityFormRenderer.d.ts.map +1 -1
- package/dist/crud/components/EntityFormRenderer.js +31 -21
- package/dist/crud/components/EntityList.d.ts.map +1 -1
- package/dist/crud/components/EntityList.js +56 -72
- package/dist/crud/components/EntityRecommendations.d.ts.map +1 -1
- package/dist/crud/components/EntityWorkflow.d.ts.map +1 -1
- package/dist/crud/components/EntityWorkflow.js +1 -1
- package/dist/crud/crudImports.d.ts +0 -1
- package/dist/crud/crudImports.d.ts.map +1 -1
- package/dist/crud/crudImports.js +0 -1
- package/dist/dndev-next.css +644 -107
- package/dist/dndev.css +778 -117
- package/dist/files/inter-cyrillic-300-normal.woff +0 -0
- package/dist/files/inter-cyrillic-300-normal.woff2 +0 -0
- package/dist/files/inter-cyrillic-400-normal.woff +0 -0
- package/dist/files/inter-cyrillic-400-normal.woff2 +0 -0
- package/dist/files/inter-cyrillic-600-normal.woff +0 -0
- package/dist/files/inter-cyrillic-600-normal.woff2 +0 -0
- package/dist/files/inter-cyrillic-700-normal.woff +0 -0
- package/dist/files/inter-cyrillic-700-normal.woff2 +0 -0
- package/dist/files/inter-cyrillic-ext-300-normal.woff +0 -0
- package/dist/files/inter-cyrillic-ext-300-normal.woff2 +0 -0
- package/dist/files/inter-cyrillic-ext-400-normal.woff +0 -0
- package/dist/files/inter-cyrillic-ext-400-normal.woff2 +0 -0
- package/dist/files/inter-cyrillic-ext-600-normal.woff +0 -0
- package/dist/files/inter-cyrillic-ext-600-normal.woff2 +0 -0
- package/dist/files/inter-cyrillic-ext-700-normal.woff +0 -0
- package/dist/files/inter-cyrillic-ext-700-normal.woff2 +0 -0
- package/dist/files/inter-greek-300-normal.woff +0 -0
- package/dist/files/inter-greek-300-normal.woff2 +0 -0
- package/dist/files/inter-greek-400-normal.woff +0 -0
- package/dist/files/inter-greek-400-normal.woff2 +0 -0
- package/dist/files/inter-greek-600-normal.woff +0 -0
- package/dist/files/inter-greek-600-normal.woff2 +0 -0
- package/dist/files/inter-greek-700-normal.woff +0 -0
- package/dist/files/inter-greek-700-normal.woff2 +0 -0
- package/dist/files/inter-greek-ext-300-normal.woff +0 -0
- package/dist/files/inter-greek-ext-300-normal.woff2 +0 -0
- package/dist/files/inter-greek-ext-400-normal.woff +0 -0
- package/dist/files/inter-greek-ext-400-normal.woff2 +0 -0
- package/dist/files/inter-greek-ext-600-normal.woff +0 -0
- package/dist/files/inter-greek-ext-600-normal.woff2 +0 -0
- package/dist/files/inter-greek-ext-700-normal.woff +0 -0
- package/dist/files/inter-greek-ext-700-normal.woff2 +0 -0
- package/dist/files/inter-latin-300-normal.woff +0 -0
- package/dist/files/inter-latin-300-normal.woff2 +0 -0
- package/dist/files/inter-latin-400-normal.woff +0 -0
- package/dist/files/inter-latin-400-normal.woff2 +0 -0
- package/dist/files/inter-latin-600-normal.woff +0 -0
- package/dist/files/inter-latin-600-normal.woff2 +0 -0
- package/dist/files/inter-latin-700-normal.woff +0 -0
- package/dist/files/inter-latin-700-normal.woff2 +0 -0
- package/dist/files/inter-latin-ext-300-normal.woff +0 -0
- package/dist/files/inter-latin-ext-300-normal.woff2 +0 -0
- package/dist/files/inter-latin-ext-400-normal.woff +0 -0
- package/dist/files/inter-latin-ext-400-normal.woff2 +0 -0
- package/dist/files/inter-latin-ext-600-normal.woff +0 -0
- package/dist/files/inter-latin-ext-600-normal.woff2 +0 -0
- package/dist/files/inter-latin-ext-700-normal.woff +0 -0
- package/dist/files/inter-latin-ext-700-normal.woff2 +0 -0
- package/dist/files/inter-vietnamese-300-normal.woff +0 -0
- package/dist/files/inter-vietnamese-300-normal.woff2 +0 -0
- package/dist/files/inter-vietnamese-400-normal.woff +0 -0
- package/dist/files/inter-vietnamese-400-normal.woff2 +0 -0
- package/dist/files/inter-vietnamese-600-normal.woff +0 -0
- package/dist/files/inter-vietnamese-600-normal.woff2 +0 -0
- package/dist/files/inter-vietnamese-700-normal.woff +0 -0
- package/dist/files/inter-vietnamese-700-normal.woff2 +0 -0
- package/dist/files/playfair-display-cyrillic-400-normal.woff +0 -0
- package/dist/files/playfair-display-cyrillic-400-normal.woff2 +0 -0
- package/dist/files/playfair-display-cyrillic-500-normal.woff +0 -0
- package/dist/files/playfair-display-cyrillic-500-normal.woff2 +0 -0
- package/dist/files/playfair-display-cyrillic-600-normal.woff +0 -0
- package/dist/files/playfair-display-cyrillic-600-normal.woff2 +0 -0
- package/dist/files/playfair-display-cyrillic-700-normal.woff +0 -0
- package/dist/files/playfair-display-cyrillic-700-normal.woff2 +0 -0
- package/dist/files/playfair-display-latin-400-normal.woff +0 -0
- package/dist/files/playfair-display-latin-400-normal.woff2 +0 -0
- package/dist/files/playfair-display-latin-500-normal.woff +0 -0
- package/dist/files/playfair-display-latin-500-normal.woff2 +0 -0
- package/dist/files/playfair-display-latin-600-normal.woff +0 -0
- package/dist/files/playfair-display-latin-600-normal.woff2 +0 -0
- package/dist/files/playfair-display-latin-700-normal.woff +0 -0
- package/dist/files/playfair-display-latin-700-normal.woff2 +0 -0
- package/dist/files/playfair-display-latin-ext-400-normal.woff +0 -0
- package/dist/files/playfair-display-latin-ext-400-normal.woff2 +0 -0
- package/dist/files/playfair-display-latin-ext-500-normal.woff +0 -0
- package/dist/files/playfair-display-latin-ext-500-normal.woff2 +0 -0
- package/dist/files/playfair-display-latin-ext-600-normal.woff +0 -0
- package/dist/files/playfair-display-latin-ext-600-normal.woff2 +0 -0
- package/dist/files/playfair-display-latin-ext-700-normal.woff +0 -0
- package/dist/files/playfair-display-latin-ext-700-normal.woff2 +0 -0
- package/dist/files/playfair-display-vietnamese-400-normal.woff +0 -0
- package/dist/files/playfair-display-vietnamese-400-normal.woff2 +0 -0
- package/dist/files/playfair-display-vietnamese-500-normal.woff +0 -0
- package/dist/files/playfair-display-vietnamese-500-normal.woff2 +0 -0
- package/dist/files/playfair-display-vietnamese-600-normal.woff +0 -0
- package/dist/files/playfair-display-vietnamese-600-normal.woff2 +0 -0
- package/dist/files/playfair-display-vietnamese-700-normal.woff +0 -0
- package/dist/files/playfair-display-vietnamese-700-normal.woff2 +0 -0
- package/dist/files/press-start-2p-cyrillic-400-normal.woff +0 -0
- package/dist/files/press-start-2p-cyrillic-400-normal.woff2 +0 -0
- package/dist/files/press-start-2p-cyrillic-ext-400-normal.woff +0 -0
- package/dist/files/press-start-2p-cyrillic-ext-400-normal.woff2 +0 -0
- package/dist/files/press-start-2p-greek-400-normal.woff +0 -0
- package/dist/files/press-start-2p-greek-400-normal.woff2 +0 -0
- package/dist/files/press-start-2p-latin-400-normal.woff +0 -0
- package/dist/files/press-start-2p-latin-400-normal.woff2 +0 -0
- package/dist/files/press-start-2p-latin-ext-400-normal.woff +0 -0
- package/dist/files/press-start-2p-latin-ext-400-normal.woff2 +0 -0
- package/dist/files/roboto-cyrillic-400-normal.woff +0 -0
- package/dist/files/roboto-cyrillic-400-normal.woff2 +0 -0
- package/dist/files/roboto-cyrillic-700-normal.woff +0 -0
- package/dist/files/roboto-cyrillic-700-normal.woff2 +0 -0
- package/dist/files/roboto-cyrillic-ext-400-normal.woff +0 -0
- package/dist/files/roboto-cyrillic-ext-400-normal.woff2 +0 -0
- package/dist/files/roboto-cyrillic-ext-700-normal.woff +0 -0
- package/dist/files/roboto-cyrillic-ext-700-normal.woff2 +0 -0
- package/dist/files/roboto-greek-400-normal.woff +0 -0
- package/dist/files/roboto-greek-400-normal.woff2 +0 -0
- package/dist/files/roboto-greek-700-normal.woff +0 -0
- package/dist/files/roboto-greek-700-normal.woff2 +0 -0
- package/dist/files/roboto-greek-ext-400-normal.woff +0 -0
- package/dist/files/roboto-greek-ext-400-normal.woff2 +0 -0
- package/dist/files/roboto-greek-ext-700-normal.woff +0 -0
- package/dist/files/roboto-greek-ext-700-normal.woff2 +0 -0
- package/dist/files/roboto-latin-400-normal.woff +0 -0
- package/dist/files/roboto-latin-400-normal.woff2 +0 -0
- package/dist/files/roboto-latin-700-normal.woff +0 -0
- package/dist/files/roboto-latin-700-normal.woff2 +0 -0
- package/dist/files/roboto-latin-ext-400-normal.woff +0 -0
- package/dist/files/roboto-latin-ext-400-normal.woff2 +0 -0
- package/dist/files/roboto-latin-ext-700-normal.woff +0 -0
- package/dist/files/roboto-latin-ext-700-normal.woff2 +0 -0
- package/dist/files/roboto-math-400-normal.woff +0 -0
- package/dist/files/roboto-math-400-normal.woff2 +0 -0
- package/dist/files/roboto-math-700-normal.woff +0 -0
- package/dist/files/roboto-math-700-normal.woff2 +0 -0
- package/dist/files/roboto-symbols-400-normal.woff +0 -0
- package/dist/files/roboto-symbols-400-normal.woff2 +0 -0
- package/dist/files/roboto-symbols-700-normal.woff +0 -0
- package/dist/files/roboto-symbols-700-normal.woff2 +0 -0
- package/dist/files/roboto-vietnamese-400-normal.woff +0 -0
- package/dist/files/roboto-vietnamese-400-normal.woff2 +0 -0
- package/dist/files/roboto-vietnamese-700-normal.woff +0 -0
- package/dist/files/roboto-vietnamese-700-normal.woff2 +0 -0
- package/dist/files/space-grotesk-latin-300-normal.woff +0 -0
- package/dist/files/space-grotesk-latin-300-normal.woff2 +0 -0
- package/dist/files/space-grotesk-latin-400-normal.woff +0 -0
- package/dist/files/space-grotesk-latin-400-normal.woff2 +0 -0
- package/dist/files/space-grotesk-latin-500-normal.woff +0 -0
- package/dist/files/space-grotesk-latin-500-normal.woff2 +0 -0
- package/dist/files/space-grotesk-latin-600-normal.woff +0 -0
- package/dist/files/space-grotesk-latin-600-normal.woff2 +0 -0
- package/dist/files/space-grotesk-latin-700-normal.woff +0 -0
- package/dist/files/space-grotesk-latin-700-normal.woff2 +0 -0
- package/dist/files/space-grotesk-latin-ext-300-normal.woff +0 -0
- package/dist/files/space-grotesk-latin-ext-300-normal.woff2 +0 -0
- package/dist/files/space-grotesk-latin-ext-400-normal.woff +0 -0
- package/dist/files/space-grotesk-latin-ext-400-normal.woff2 +0 -0
- package/dist/files/space-grotesk-latin-ext-500-normal.woff +0 -0
- package/dist/files/space-grotesk-latin-ext-500-normal.woff2 +0 -0
- package/dist/files/space-grotesk-latin-ext-600-normal.woff +0 -0
- package/dist/files/space-grotesk-latin-ext-600-normal.woff2 +0 -0
- package/dist/files/space-grotesk-latin-ext-700-normal.woff +0 -0
- package/dist/files/space-grotesk-latin-ext-700-normal.woff2 +0 -0
- package/dist/files/space-grotesk-vietnamese-300-normal.woff +0 -0
- package/dist/files/space-grotesk-vietnamese-300-normal.woff2 +0 -0
- package/dist/files/space-grotesk-vietnamese-400-normal.woff +0 -0
- package/dist/files/space-grotesk-vietnamese-400-normal.woff2 +0 -0
- package/dist/files/space-grotesk-vietnamese-500-normal.woff +0 -0
- package/dist/files/space-grotesk-vietnamese-500-normal.woff2 +0 -0
- package/dist/files/space-grotesk-vietnamese-600-normal.woff +0 -0
- package/dist/files/space-grotesk-vietnamese-600-normal.woff2 +0 -0
- package/dist/files/space-grotesk-vietnamese-700-normal.woff +0 -0
- package/dist/files/space-grotesk-vietnamese-700-normal.woff2 +0 -0
- package/dist/index.js +4 -4
- package/dist/internal/devtools/components/DesignTab.d.ts.map +1 -1
- package/dist/internal/devtools/utils/virtualModuleInspector.d.ts.map +1 -1
- package/dist/internal/devtools/utils/virtualModuleInspector.js +12 -1
- package/dist/internal/initializers/BaseStoresInitializer.d.ts +3 -1
- package/dist/internal/initializers/BaseStoresInitializer.d.ts.map +1 -1
- package/dist/internal/initializers/BaseStoresInitializer.js +8 -4
- package/dist/internal/initializers/NextJsStoresInitializer.d.ts +1 -1
- package/dist/internal/initializers/NextJsStoresInitializer.d.ts.map +1 -1
- package/dist/internal/initializers/NextJsStoresInitializer.js +2 -13
- package/dist/internal/layout/DnDevLayout.d.ts.map +1 -1
- package/dist/internal/layout/DnDevLayout.js +32 -13
- package/dist/internal/layout/components/AutoMetaTags.d.ts.map +1 -1
- package/dist/internal/layout/components/AutoMetaTags.js +3 -7
- package/dist/internal/layout/config/presets/moolti.d.ts.map +1 -1
- package/dist/internal/layout/config/presets/moolti.js +11 -13
- package/dist/internal/layout/zones/DnDevFooter.d.ts +1 -1
- package/dist/internal/layout/zones/DnDevFooter.d.ts.map +1 -1
- package/dist/internal/layout/zones/DnDevFooter.js +1 -1
- package/dist/providers/NextJsAppProviders.d.ts.map +1 -1
- package/dist/providers/NextJsAppProviders.js +12 -8
- package/dist/routing/AuthGuard.d.ts.map +1 -1
- package/dist/routing/AuthGuard.js +1 -1
- package/dist/routing/AuthReturnTo.d.ts.map +1 -1
- package/dist/routing/GoToInput.d.ts.map +1 -1
- package/dist/routing/GoToInput.js +5 -5
- package/dist/routing/Link.d.ts.map +1 -1
- package/dist/routing/Link.js +14 -0
- package/dist/routing/hooks/hooks.next.js +1 -1
- package/dist/routing/hooks/hooks.vite.js +1 -1
- package/dist/routing/hooks/useNavigate.next.d.ts +2 -6
- package/dist/routing/hooks/useNavigate.next.d.ts.map +1 -1
- package/dist/routing/hooks/useNavigate.next.js +5 -52
- package/dist/routing/hooks/useNavigate.vite.d.ts +2 -6
- package/dist/routing/hooks/useNavigate.vite.d.ts.map +1 -1
- package/dist/routing/hooks/useNavigate.vite.js +5 -52
- package/dist/routing/hooks/useRedirectGuard.next.d.ts.map +1 -1
- package/dist/routing/hooks/useRedirectGuard.next.js +5 -1
- package/dist/routing/hooks/useRedirectGuard.vite.d.ts.map +1 -1
- package/dist/routing/hooks/useRedirectGuard.vite.js +5 -1
- package/dist/routing/useGoTo.d.ts.map +1 -1
- package/dist/routing/useGoTo.js +12 -17
- package/dist/styles/index.css +778 -117
- package/dist/symbol-index.json +1 -1
- package/dist/utils/useAuthSafe.d.ts.map +1 -1
- package/dist/utils/useSeo.d.ts +1 -1
- package/dist/utils/useSeo.d.ts.map +1 -1
- package/dist/utils/useSeo.js +3 -1
- package/dist/vite-routing/AppRoutes.d.ts.map +1 -1
- package/dist/vite-routing/AppRoutes.js +7 -2
- package/dist/vite-routing/RootLayout.d.ts.map +1 -1
- package/dist/vite-routing/RootLayout.js +1 -4
- package/guidelines/COMPONENTS.md +0 -0
- package/guidelines/GOTCHAS.md +0 -0
- package/guidelines/LAYOUTS.md +0 -0
- package/guidelines/PAGES.md +0 -0
- package/guidelines/ROUTING.md +0 -0
- package/guidelines/SEO.md +0 -0
- package/package.json +13 -13
- package/dist/CookieConsent-UVTR7CWW.js +0 -1
- package/dist/chunk-ETE4RC7M.js +0 -1
- package/dist/components/license/LicenseWatermark.d.ts +0 -25
- package/dist/components/license/LicenseWatermark.d.ts.map +0 -1
- package/dist/components/license/LicenseWatermark.js +0 -109
- package/dist/components/license/watermarkData.d.ts +0 -7
- package/dist/components/license/watermarkData.d.ts.map +0 -1
- package/dist/components/license/watermarkData.js +0 -18
|
@@ -7,7 +7,8 @@ import { handleError, useConsent, getCookieExamples, hasOptionalCookies as check
|
|
|
7
7
|
import { CONSENT_CATEGORY, } from '@donotdev/core';
|
|
8
8
|
import { useTranslation } from '@donotdev/core';
|
|
9
9
|
import { isClient } from '@donotdev/core';
|
|
10
|
-
|
|
10
|
+
const MAX_WIDTH = 480;
|
|
11
|
+
function CookieConsent({ position = 'bottom', className = '', }) {
|
|
11
12
|
const hasConsented = useConsent('hasConsented');
|
|
12
13
|
const categories = useConsent('categories');
|
|
13
14
|
const acceptAll = useConsent('acceptAll');
|
|
@@ -24,8 +25,7 @@ function CookieConsent({ position = 'bottom', showBranding = true, brandingText
|
|
|
24
25
|
setShowBanner(true);
|
|
25
26
|
}
|
|
26
27
|
}, [storeShowBanner]);
|
|
27
|
-
// Get categories
|
|
28
|
-
// Store only includes categories that are needed (from featureMatrix or requiredCookies config)
|
|
28
|
+
// Get categories actually required by the app's features
|
|
29
29
|
const requiredCategories = Object.keys(categories);
|
|
30
30
|
const categoryDefs = [
|
|
31
31
|
{
|
|
@@ -62,32 +62,27 @@ function CookieConsent({ position = 'bottom', showBranding = true, brandingText
|
|
|
62
62
|
locked: false,
|
|
63
63
|
},
|
|
64
64
|
].filter((cat) => requiredCategories.includes(cat.id));
|
|
65
|
-
// Check if app has optional categories based on detected features
|
|
66
65
|
const hasOptionalCategories = checkHasOptionalCookies();
|
|
67
|
-
// Auto-accept if only necessary cookies (GDPR/CCPA
|
|
66
|
+
// Auto-accept if only necessary cookies (GDPR/CCPA — necessary don't need consent)
|
|
68
67
|
useEffect(() => {
|
|
69
68
|
if (!hasConsented && !hasOptionalCategories) {
|
|
70
|
-
acceptAll();
|
|
69
|
+
acceptAll();
|
|
71
70
|
}
|
|
72
71
|
}, [hasConsented, hasOptionalCategories, acceptAll]);
|
|
73
|
-
// Sync local draft state
|
|
74
|
-
// Default all optional categories to ON for better UX (easier to uncheck than check all)
|
|
72
|
+
// Sync local draft state when accordion opens — default optional ON for easier UX
|
|
75
73
|
useEffect(() => {
|
|
76
|
-
const
|
|
77
|
-
// Default all optional categories to true if accordion is open and they're undefined
|
|
74
|
+
const defaulted = { ...categories };
|
|
78
75
|
if (showPreferences) {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
mutableCategories[cat] === false) {
|
|
84
|
-
mutableCategories[cat] = true;
|
|
76
|
+
const mutable = defaulted;
|
|
77
|
+
Object.keys(mutable).forEach((cat) => {
|
|
78
|
+
if (cat !== CONSENT_CATEGORY.NECESSARY && mutable[cat] === false) {
|
|
79
|
+
mutable[cat] = true;
|
|
85
80
|
}
|
|
86
81
|
});
|
|
87
82
|
}
|
|
88
|
-
setPreferenceCategories(
|
|
83
|
+
setPreferenceCategories(defaulted);
|
|
89
84
|
}, [categories, showPreferences]);
|
|
90
|
-
//
|
|
85
|
+
// Dismiss on outside click when banner is showing pre-consent
|
|
91
86
|
useEffect(() => {
|
|
92
87
|
if (!isClient() || hasConsented || !showBanner)
|
|
93
88
|
return;
|
|
@@ -112,7 +107,6 @@ function CookieConsent({ position = 'bottom', showBranding = true, brandingText
|
|
|
112
107
|
Object.entries(preferenceCategories).forEach(([cat, val]) => {
|
|
113
108
|
if (cat !== CONSENT_CATEGORY.NECESSARY && val !== undefined) {
|
|
114
109
|
const categoryKey = cat;
|
|
115
|
-
// Check if category value exists in CONSENT_CATEGORY values (not keys)
|
|
116
110
|
if (Object.values(CONSENT_CATEGORY).includes(categoryKey)) {
|
|
117
111
|
updateCategory(categoryKey, Boolean(val));
|
|
118
112
|
}
|
|
@@ -140,30 +134,37 @@ function CookieConsent({ position = 'bottom', showBranding = true, brandingText
|
|
|
140
134
|
declineAll();
|
|
141
135
|
setShowBanner(false);
|
|
142
136
|
};
|
|
143
|
-
const bannerContent = (_jsxs(Stack, { children: [_jsx(Text, { as: "p", variant: "muted", level: "small", children: t('cookieBannerDescription') }), hasOptionalCategories && (_jsx(Accordion, { type: "single", collapsible: true, value: showPreferences ? 'preferences' : '', onValueChange: (value) => setShowPreferences(value === 'preferences'), items: [
|
|
137
|
+
const bannerContent = (_jsxs(Stack, { gap: "medium", children: [_jsx(Text, { as: "p", variant: "muted", level: "small", style: { lineHeight: 1.55 }, children: t('cookieBannerDescription') }), hasOptionalCategories && (_jsx(Accordion, { type: "single", collapsible: true, value: showPreferences ? 'preferences' : '', onValueChange: (value) => setShowPreferences(value === 'preferences'), items: [
|
|
144
138
|
{
|
|
145
139
|
value: 'preferences',
|
|
146
|
-
trigger: (_jsxs(Stack, { direction: "row", align: "center", gap: "tight", children: [_jsx(Settings, { className: "dndev-size-
|
|
147
|
-
content: (_jsx(Stack, { children: categoryDefs.map((cat) => {
|
|
140
|
+
trigger: (_jsxs(Stack, { direction: "row", align: "center", gap: "tight", children: [_jsx(Settings, { className: "dndev-size-sm" }), _jsx(Text, { as: "span", level: "small", weight: "medium", children: t('customize') })] })),
|
|
141
|
+
content: (_jsx(Stack, { gap: "tight", children: categoryDefs.map((cat) => {
|
|
148
142
|
const Icon = cat.icon;
|
|
149
143
|
const enabled = preferenceCategories[cat.id] ?? false;
|
|
150
|
-
return (
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
144
|
+
return (_jsxs(Stack, { direction: "row", align: "start", justify: "between", gap: "medium", style: {
|
|
145
|
+
padding: '0.75rem',
|
|
146
|
+
borderRadius: 'var(--radius-surface, 0.5rem)',
|
|
147
|
+
background: 'var(--muted)',
|
|
148
|
+
}, children: [_jsxs(Stack, { direction: "row", align: "start", gap: "tight", style: { flex: 1, minWidth: 0 }, children: [_jsx(Icon, { className: "dndev-size-sm", style: {
|
|
149
|
+
color: 'var(--primary)',
|
|
150
|
+
marginTop: '0.15rem',
|
|
151
|
+
flexShrink: 0,
|
|
152
|
+
} }), _jsxs(Stack, { gap: "none", style: { minWidth: 0 }, children: [_jsx(Text, { as: "span", level: "small", weight: "semibold", children: cat.title }), _jsx(Text, { as: "span", variant: "muted", level: "caption", style: { lineHeight: 1.45 }, children: cat.description })] })] }), cat.locked ? (_jsx(Text, { as: "span", variant: "muted", level: "caption", weight: "medium", style: { flexShrink: 0 }, children: t('alwaysOn') })) : (_jsx(Switch, { checked: enabled, onCheckedChange: (val) => setPreferenceCategories((prev) => ({
|
|
153
|
+
...prev,
|
|
154
|
+
[cat.id]: val,
|
|
155
|
+
})) }))] }, cat.id));
|
|
157
156
|
}) })),
|
|
158
157
|
},
|
|
159
158
|
] }))] }));
|
|
160
|
-
const bannerFooter = showPreferences ? (_jsxs(Stack, { direction: "row", gap: "tight", style: { width: '100%' }, children: [_jsx(Button, { onClick:
|
|
161
|
-
return (_jsxs(_Fragment, { children: [showBanner && (_jsx(Card, { ref: bannerRef,
|
|
159
|
+
const bannerFooter = showPreferences ? (_jsxs(Stack, { direction: "row", gap: "tight", style: { width: '100%' }, children: [_jsx(Button, { onClick: () => setShowPreferences(false), variant: BUTTON_VARIANT.OUTLINE, style: { flex: 1 }, children: t('form.cancel', 'Cancel') }), _jsx(Button, { onClick: handleSave, variant: BUTTON_VARIANT.DEFAULT, style: { flex: 1 }, children: t('savePreferences', 'Save Preferences') })] })) : (_jsxs(Stack, { direction: "row", gap: "tight", style: { width: '100%' }, children: [hasOptionalCategories && (_jsx(Button, { onClick: handleDeclineAll, variant: BUTTON_VARIANT.OUTLINE, style: { flex: 1 }, children: t('declineOptional') })), _jsx(Button, { onClick: handleAcceptAll, variant: BUTTON_VARIANT.DEFAULT, style: { flex: 1 }, children: t('acceptAll') })] }));
|
|
160
|
+
return (_jsxs(_Fragment, { children: [showBanner && (_jsx(Card, { ref: bannerRef, elevated: true, icon: Cookie, title: t('cookiePreferences'), content: bannerContent, footer: bannerFooter, className: cn('dndev-fixed dndev-z-modal', className), style: {
|
|
162
161
|
[position === 'top' ? 'top' : 'bottom']: 'var(--gap-md)',
|
|
163
162
|
insetInlineStart: 'var(--gap-md)',
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
163
|
+
width: `min(${MAX_WIDTH}px, calc(100vw - var(--gap-md) * 2))`,
|
|
164
|
+
height: 'auto',
|
|
165
|
+
} })), !showBanner && !hasConsented && (_jsx(Button, { onClick: () => setShowBanner(true), variant: BUTTON_VARIANT.OUTLINE, floating: true, icon: Cookie, display: "compact", tooltip: t('cookiePreferences'), "aria-label": t('cookiePreferences'), className: "dndev-fixed dndev-z-toast", style: {
|
|
166
|
+
[position === 'top' ? 'top' : 'bottom']: 'var(--gap-md)',
|
|
167
|
+
insetInlineStart: 'var(--gap-md)',
|
|
168
|
+
} }))] }));
|
|
168
169
|
}
|
|
169
170
|
export default CookieConsent;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AAEH,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,kBAAkB,CAAC;AACjC,cAAc,UAAU,CAAC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AAEH,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,kBAAkB,CAAC;AACjC,cAAc,UAAU,CAAC"}
|
package/dist/components/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CacheSettings.d.ts","sourceRoot":"","sources":["../../../../../src/components/layout/components/header/CacheSettings.tsx"],"names":[],"mappings":"AA0BA;;;;;;;;;GASG;AACH,iBAAS,aAAa,
|
|
1
|
+
{"version":3,"file":"CacheSettings.d.ts","sourceRoot":"","sources":["../../../../../src/components/layout/components/header/CacheSettings.tsx"],"names":[],"mappings":"AA0BA;;;;;;;;;GASG;AACH,iBAAS,aAAa,4CA+PrB;AAED,eAAe,aAAa,CAAC"}
|
|
@@ -89,7 +89,9 @@ function CacheSettings() {
|
|
|
89
89
|
console.error('Failed to clear IndexedDB:', err);
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
|
-
if (cacheOptions.webSQL &&
|
|
92
|
+
if (cacheOptions.webSQL &&
|
|
93
|
+
typeof window !== 'undefined' &&
|
|
94
|
+
'openDatabase' in window) {
|
|
93
95
|
try {
|
|
94
96
|
const db = globalThis.openDatabase('', '', '', '');
|
|
95
97
|
if (db && db.transaction) {
|
|
@@ -111,7 +113,9 @@ function CacheSettings() {
|
|
|
111
113
|
}
|
|
112
114
|
}
|
|
113
115
|
// Clear Application Cache API
|
|
114
|
-
if (cacheOptions.applicationCache &&
|
|
116
|
+
if (cacheOptions.applicationCache &&
|
|
117
|
+
typeof window !== 'undefined' &&
|
|
118
|
+
'caches' in window) {
|
|
115
119
|
try {
|
|
116
120
|
const keys = await caches.keys();
|
|
117
121
|
await Promise.all(keys.map(async (key) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityCardList.d.ts","sourceRoot":"","sources":["../../../src/crud/components/EntityCardList.tsx"],"names":[],"mappings":"AAmCA,OAAO,KAAK,EAAE,mBAAmB,EAAgB,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"EntityCardList.d.ts","sourceRoot":"","sources":["../../../src/crud/components/EntityCardList.tsx"],"names":[],"mappings":"AAmCA,OAAO,KAAK,EAAE,mBAAmB,EAAgB,MAAM,gBAAgB,CAAC;AAWxE,YAAY,EAAE,mBAAmB,EAAE,CAAC;AA0GpC;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,EAC7B,MAAM,EACN,QAAQ,EACR,OAAO,EACP,IAAmB,EACnB,SAA0B,EAAE,2BAA2B;AACvD,YAAY,EACZ,MAAM,EACN,WAAmB,EACnB,WAAW,EACX,IAAI,EACJ,iBAAiB,EACjB,UAAU,EACV,WAAmB,EACnB,WAAW,EACX,OAAO,GACR,EAAE,mBAAmB,kDA4OrB"}
|
|
@@ -96,7 +96,12 @@ queryOptions, filter, hideFilters = false, resultLabel, tone, renderCardOverlay,
|
|
|
96
96
|
const navigate = useNavigate();
|
|
97
97
|
const base = basePath ?? `/${entity.collection}`;
|
|
98
98
|
// useCrudCardList -> handles fetching + client-side filter/search/sort via `processed`
|
|
99
|
-
const { items: rawData, processed, loading: fetchLoading, } = useCrudCardList(entity, {
|
|
99
|
+
const { items: rawData, processed, loading: fetchLoading, error: fetchError, } = useCrudCardList(entity, {
|
|
100
|
+
enabled: !isPreview,
|
|
101
|
+
staleTime,
|
|
102
|
+
queryOptions,
|
|
103
|
+
clientSort,
|
|
104
|
+
});
|
|
100
105
|
// In preview mode: use preview data, skip loading state
|
|
101
106
|
const loading = isPreview ? false : fetchLoading;
|
|
102
107
|
// Favorites - always enabled, no props needed
|
|
@@ -104,7 +109,7 @@ queryOptions, filter, hideFilters = false, resultLabel, tone, renderCardOverlay,
|
|
|
104
109
|
collection: entity.collection,
|
|
105
110
|
});
|
|
106
111
|
// Favorites toggle from CrudStore (persists across navigation)
|
|
107
|
-
const { showFavoritesOnly, setShowFavoritesOnly } = useCrudFilters({
|
|
112
|
+
const { showFavoritesOnly, setShowFavoritesOnly, filters, setFilters } = useCrudFilters({
|
|
108
113
|
collection: entity.collection,
|
|
109
114
|
});
|
|
110
115
|
// Apply UI-specific filters (favorites, consumer filter prop) on top of processed
|
|
@@ -159,14 +164,22 @@ queryOptions, filter, hideFilters = false, resultLabel, tone, renderCardOverlay,
|
|
|
159
164
|
defaultValue: data.length === 1
|
|
160
165
|
? 'Found 1 occurrence'
|
|
161
166
|
: `Found ${data.length} occurrences`,
|
|
162
|
-
}), collapsible: collapsible, defaultOpen: collapsible ? true : undefined, tone: tone, children: loading ? (_jsx(CardListSkeleton, { cols: cols, entity: entity })) :
|
|
167
|
+
}), collapsible: collapsible, defaultOpen: collapsible ? true : undefined, tone: tone, children: loading ? (_jsx(CardListSkeleton, { cols: cols, entity: entity })) : fetchError ? (_jsxs(Stack, { align: "center", justify: "center", style: { padding: 'var(--gap-3xl)', textAlign: 'center' }, children: [_jsx(Text, { level: "h3", style: { color: 'var(--destructive)' }, children: tCrud('errors.fetchFailed', {
|
|
168
|
+
defaultValue: `Failed to load ${entity.name.toLowerCase()}`,
|
|
169
|
+
}) }), _jsx(Text, { level: "small", style: { color: 'var(--destructive)' }, children: fetchError instanceof Error
|
|
170
|
+
? fetchError.message
|
|
171
|
+
: String(fetchError) })] })) : data.length === 0 ? (_jsxs(Stack, { align: "center", justify: "center", style: { padding: 'var(--gap-3xl)', textAlign: 'center' }, children: [_jsx(Text, { level: "h3", style: { color: 'var(--muted-foreground)' }, children: tCrud('emptyState.title', {
|
|
163
172
|
defaultValue: `No ${entity.name.toLowerCase()} found`,
|
|
164
173
|
}) }), _jsx(Text, { style: { color: 'var(--muted-foreground)' }, children: tCrud('emptyState.description', {
|
|
165
174
|
defaultValue: `No ${entity.name.toLowerCase()} available at this time.`,
|
|
166
175
|
}) })] })) : (_jsx(Grid, { cols: cols, children: data.map((item) => {
|
|
167
176
|
const itemIsFavorite = isFavorite(item.id);
|
|
168
177
|
const detailHref = isPreview || onClick ? undefined : `${base}/${item.id}`;
|
|
169
|
-
return (_jsx(CrudCard, { item: item, entity: entity, detailHref: detailHref, onClick: isPreview
|
|
178
|
+
return (_jsx(CrudCard, { item: item, entity: entity, detailHref: detailHref, onClick: isPreview
|
|
179
|
+
? undefined
|
|
180
|
+
: onClick
|
|
181
|
+
? () => handleView(item.id)
|
|
182
|
+
: undefined, renderOverlay: renderCardOverlay?.(item), renderActions: _jsx(Heart, { fill: itemIsFavorite ? '#ef4444' : '#ffffff', stroke: itemIsFavorite ? '#ef4444' : 'var(--muted-foreground)', onClick: (e) => {
|
|
170
183
|
e.preventDefault();
|
|
171
184
|
e.stopPropagation();
|
|
172
185
|
if (!isPreview)
|
|
@@ -94,9 +94,9 @@ export function EntityDisplayRenderer({ entity, id, t, className = '', loadingMe
|
|
|
94
94
|
}, [id, get, isAvailable, isPreview]);
|
|
95
95
|
// In preview mode: use preview data directly
|
|
96
96
|
// Priority: preview > store data (reactive) > local fetch data
|
|
97
|
-
const displayData = isPreview ? preview :
|
|
98
|
-
const displayError = isPreview ? null :
|
|
99
|
-
const isLoading = isPreview ? false :
|
|
97
|
+
const displayData = isPreview ? preview : storeData || data;
|
|
98
|
+
const displayError = isPreview ? null : storeError || fetchError;
|
|
99
|
+
const isLoading = isPreview ? false : loading || isFetching || !id;
|
|
100
100
|
// Filter fields: respect visibility AND skip empty values
|
|
101
101
|
// MUST be called before any early returns (Rules of Hooks)
|
|
102
102
|
const visibleFields = useMemo(() => {
|
|
@@ -115,7 +115,7 @@ export function EntityDisplayRenderer({ entity, id, t, className = '', loadingMe
|
|
|
115
115
|
if (fieldConfig.visibility === 'hidden') {
|
|
116
116
|
return false;
|
|
117
117
|
}
|
|
118
|
-
// Get field value
|
|
118
|
+
// Get field value (displayData may be preview T or store row; entity is AnyEntity in props)
|
|
119
119
|
const value = displayData[fieldName];
|
|
120
120
|
// Hide if value is empty/null/undefined
|
|
121
121
|
if (value === null || value === undefined) {
|
|
@@ -13,6 +13,11 @@ export type { EntityFormRendererProps };
|
|
|
13
13
|
* @since 0.0.1
|
|
14
14
|
* @author AMBROISE PARK Consulting
|
|
15
15
|
*/
|
|
16
|
-
|
|
16
|
+
/**
|
|
17
|
+
* EntityFormRenderer - public API.
|
|
18
|
+
* Applies instanceKey as React key on the inner component for clean state isolation
|
|
19
|
+
* when navigating between entities on the same route (e.g. /cars/:id).
|
|
20
|
+
*/
|
|
21
|
+
export declare function EntityFormRenderer<T extends EntityRecord = EntityRecord>(props: EntityFormRendererProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
17
22
|
export default EntityFormRenderer;
|
|
18
23
|
//# sourceMappingURL=EntityFormRenderer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityFormRenderer.d.ts","sourceRoot":"","sources":["../../../src/crud/components/EntityFormRenderer.tsx"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EACV,uBAAuB,EACvB,YAAY,EAEb,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"EntityFormRenderer.d.ts","sourceRoot":"","sources":["../../../src/crud/components/EntityFormRenderer.tsx"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EACV,uBAAuB,EACvB,YAAY,EAEb,MAAM,gBAAgB,CAAC;AAexB,YAAY,EAAE,uBAAuB,EAAE,CAAC;AAExC;;;;;;;;;;;;GAYG;AACH;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,YAAY,GAAG,YAAY,EACtE,KAAK,EAAE,uBAAuB,CAAC,CAAC,CAAC,2CAIlC;AAoeD,eAAe,kBAAkB,CAAC"}
|
|
@@ -14,7 +14,7 @@ import { useEffect, useId, useMemo, useState } from 'react';
|
|
|
14
14
|
import { FormProvider } from 'react-hook-form';
|
|
15
15
|
import { Badge, Button, DropdownMenu, Grid, Stack, Spinner, } from '@donotdev/components';
|
|
16
16
|
import { hasRoleAccess, useTranslation } from '@donotdev/core';
|
|
17
|
-
import { isCrudModuleAvailable, DisplayFieldRenderer, FormFieldRenderer, UploadProvider, useEntityForm,
|
|
17
|
+
import { isCrudModuleAvailable, DisplayFieldRenderer, FormFieldRenderer, UploadProvider, useEntityForm, useFormStore, useFieldConditions, } from '../crudImports';
|
|
18
18
|
import { useNavigate } from '../../routing';
|
|
19
19
|
import { useAuthSafe } from '../../utils/useAuthSafe';
|
|
20
20
|
/**
|
|
@@ -30,7 +30,16 @@ import { useAuthSafe } from '../../utils/useAuthSafe';
|
|
|
30
30
|
* @since 0.0.1
|
|
31
31
|
* @author AMBROISE PARK Consulting
|
|
32
32
|
*/
|
|
33
|
-
|
|
33
|
+
/**
|
|
34
|
+
* EntityFormRenderer - public API.
|
|
35
|
+
* Applies instanceKey as React key on the inner component for clean state isolation
|
|
36
|
+
* when navigating between entities on the same route (e.g. /cars/:id).
|
|
37
|
+
*/
|
|
38
|
+
export function EntityFormRenderer(props) {
|
|
39
|
+
const { instanceKey, ...rest } = props;
|
|
40
|
+
return _jsx(EntityFormRendererCore, { ...rest }, instanceKey);
|
|
41
|
+
}
|
|
42
|
+
function EntityFormRendererCore({ entity, onSubmit, t, className = '', submitText, loading = false, defaultValues, submitVariant = 'primary', secondaryButtonText, secondaryButtonVariant = 'outline', onSecondarySubmit, viewerRole: viewerRoleProp, operation = defaultValues ? 'edit' : 'create', formId: externalFormId, cancelText, cancelPath, successPath, onCancel, hideVisibilityInfo = false, }) {
|
|
34
43
|
// Safe guard: isCrudModuleAvailable is a module-level constant (immutable after load).
|
|
35
44
|
// Hooks below are either ALL called or NONE — no Rules-of-Hooks violation at runtime.
|
|
36
45
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
@@ -90,8 +99,9 @@ export function EntityFormRenderer({ entity, onSubmit, t, className = '', submit
|
|
|
90
99
|
defaultValues,
|
|
91
100
|
viewerRole,
|
|
92
101
|
t: translate,
|
|
102
|
+
loading,
|
|
93
103
|
});
|
|
94
|
-
const { control, handleSubmit, formState: { errors }, fields: rawFields, formStatus, uploadProgress,
|
|
104
|
+
const { control, handleSubmit, formState: { errors }, fields: rawFields, formStatus, uploadProgress, isDirty, hasUserInteracted, resetForm, } = form;
|
|
95
105
|
const isDirtyForBlocking = isDirty && hasUserInteracted;
|
|
96
106
|
// Filter fields based on previewRole when visibility info is shown
|
|
97
107
|
const renderableFields = useMemo(() => {
|
|
@@ -118,22 +128,6 @@ export function EntityFormRenderer({ entity, onSubmit, t, className = '', submit
|
|
|
118
128
|
useFormStore.getState().setIsDirty(formId, isDirtyForBlocking);
|
|
119
129
|
}
|
|
120
130
|
}, [formId, isDirtyForBlocking]);
|
|
121
|
-
// Cleanup on unmount
|
|
122
|
-
useEffect(() => {
|
|
123
|
-
return cleanup;
|
|
124
|
-
}, [cleanup]);
|
|
125
|
-
// Compute i18n messages once (DRY, performance)
|
|
126
|
-
const unsavedChangesLeaveMessage = useMemo(() => unsavedChangesMessage ||
|
|
127
|
-
tCrud('messages.unsavedChangesLeave', {
|
|
128
|
-
defaultValue: 'You have unsaved changes. Are you sure you want to leave?',
|
|
129
|
-
}), [unsavedChangesMessage, tCrud]);
|
|
130
|
-
// Warn about unsaved changes when navigating away (browser refresh/close)
|
|
131
|
-
// beforeunload is the only place we can't toast — browser requires native dialog
|
|
132
|
-
useUnsavedChangesWarning({
|
|
133
|
-
isDirty: isDirtyForBlocking,
|
|
134
|
-
enabled: warnOnUnsavedChanges,
|
|
135
|
-
message: unsavedChangesLeaveMessage,
|
|
136
|
-
});
|
|
137
131
|
// Handle cancel — auto-save ensures draft is persisted, no confirm needed
|
|
138
132
|
const handleCancel = () => {
|
|
139
133
|
resetForm();
|
|
@@ -214,6 +208,14 @@ export function EntityFormRenderer({ entity, onSubmit, t, className = '', submit
|
|
|
214
208
|
successText: tCrud('form.saved', { defaultValue: 'Saved' }),
|
|
215
209
|
};
|
|
216
210
|
}
|
|
211
|
+
if (formStatus === 'error') {
|
|
212
|
+
return {
|
|
213
|
+
loading: false,
|
|
214
|
+
errorText: tCrud('form.error', {
|
|
215
|
+
defaultValue: 'Error — try again',
|
|
216
|
+
}),
|
|
217
|
+
};
|
|
218
|
+
}
|
|
217
219
|
return { loading: false };
|
|
218
220
|
}, [formStatus, uploadProgress, tCrud]);
|
|
219
221
|
return (_jsx(FormProvider, { ...form, children: _jsx(UploadProvider, { formId: formId, children: _jsxs("div", { style: {
|
|
@@ -221,7 +223,10 @@ export function EntityFormRenderer({ entity, onSubmit, t, className = '', submit
|
|
|
221
223
|
width: '100%',
|
|
222
224
|
gridColumn: '1 / -1',
|
|
223
225
|
display: 'contents',
|
|
224
|
-
}, children: [isLoading && _jsx(Spinner, { overlay: true }), _jsxs("form", { onSubmit:
|
|
226
|
+
}, children: [isLoading && _jsx(Spinner, { overlay: true }), _jsxs("form", { onSubmit: (e) => {
|
|
227
|
+
console.log('[EntityFormRenderer] native form onSubmit event', { defaultPrevented: e.defaultPrevented });
|
|
228
|
+
return handleSubmit(handleFormSubmit)(e);
|
|
229
|
+
}, noValidate: true, className: className, style: { width: '100%', gridColumn: '1 / -1', display: 'contents' }, children: [renderableFields.map(({ name, config, editable }) => {
|
|
225
230
|
// Evaluate dynamic conditions for this field
|
|
226
231
|
const cond = fieldConditions[name];
|
|
227
232
|
if (cond && !cond.visible)
|
|
@@ -284,7 +289,12 @@ export function EntityFormRenderer({ entity, onSubmit, t, className = '', submit
|
|
|
284
289
|
}, loading: buttonState.loading, loadingText: buttonState.loadingText, progress: buttonState.progress, variant: secondaryButtonVariant, className: "dndev-w-full", children: secondaryButtonText }, "secondary"));
|
|
285
290
|
}
|
|
286
291
|
// Primary submit button (always shown)
|
|
287
|
-
buttons.push(_jsx(Button, { type: "submit", loading: buttonState.loading, loadingText: buttonState.loadingText, progress: buttonState.progress, variant: buttonState.successText
|
|
292
|
+
buttons.push(_jsx(Button, { type: "submit", loading: buttonState.loading, loadingText: buttonState.loadingText, progress: buttonState.progress, variant: buttonState.successText
|
|
293
|
+
? 'success'
|
|
294
|
+
: buttonState.errorText
|
|
295
|
+
? 'destructive'
|
|
296
|
+
: submitVariant, disabled: !!buttonState.successText, className: "dndev-w-full", children: buttonState.successText ||
|
|
297
|
+
buttonState.errorText ||
|
|
288
298
|
submitText ||
|
|
289
299
|
tCrud('form.submit', { defaultValue: 'Submit' }) }, "submit"));
|
|
290
300
|
const buttonCount = buttons.length;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityList.d.ts","sourceRoot":"","sources":["../../../src/crud/components/EntityList.tsx"],"names":[],"mappings":"AA8BA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAetD,YAAY,EAAE,eAAe,EAAE,CAAC;AAEhC;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CAAC,EACzB,MAAM,EACN,QAAQ,EACR,OAAO,EACP,WAAmB,EACnB,UAAmB,EACnB,QAAQ,EAAE,YAAY,EACtB,YAAY,EACZ,UAAiB,EACjB,OAAO,EACP,IAAI,GACL,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"EntityList.d.ts","sourceRoot":"","sources":["../../../src/crud/components/EntityList.tsx"],"names":[],"mappings":"AA8BA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAetD,YAAY,EAAE,eAAe,EAAE,CAAC;AAEhC;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CAAC,EACzB,MAAM,EACN,QAAQ,EACR,OAAO,EACP,WAAmB,EACnB,UAAmB,EACnB,QAAQ,EAAE,YAAY,EACtB,YAAY,EACZ,UAAiB,EACjB,OAAO,EACP,IAAI,GACL,EAAE,eAAe,kDAqTjB"}
|
|
@@ -14,11 +14,11 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
14
14
|
* @author AMBROISE PARK Consulting
|
|
15
15
|
*/
|
|
16
16
|
import { RefreshCw, Plus, Trash2, Edit, Search } from 'lucide-react';
|
|
17
|
-
import {
|
|
17
|
+
import { useCallback, useState } from 'react';
|
|
18
18
|
import { DataTable, Button, Stack, ActionButton, Section, Input, } from '@donotdev/components';
|
|
19
19
|
import { useTranslation } from '@donotdev/core';
|
|
20
20
|
import { isCrudModuleAvailable, translateFieldLabel, useCrud, useCrudList, useCrudPageSize, EntityFilters, formatValue, useReferenceResolver, } from '../crudImports';
|
|
21
|
-
import { useNavigate } from '../../routing';
|
|
21
|
+
import { Link, useNavigate } from '../../routing';
|
|
22
22
|
/**
|
|
23
23
|
* Entity List Component - Table view for admin/internal operations
|
|
24
24
|
*
|
|
@@ -60,7 +60,9 @@ export function EntityList({ entity, basePath, onClick, hideFilters = false, pag
|
|
|
60
60
|
}),
|
|
61
61
|
});
|
|
62
62
|
// In preview mode: use preview data, skip loading state
|
|
63
|
-
const filteredData = isPreview
|
|
63
|
+
const filteredData = isPreview
|
|
64
|
+
? preview
|
|
65
|
+
: fetchedData;
|
|
64
66
|
const loading = isPreview ? false : fetchLoading;
|
|
65
67
|
// useCrud -> handles actions (delete)
|
|
66
68
|
const { delete: deleteItem } = useCrud(entity);
|
|
@@ -68,15 +70,9 @@ export function EntityList({ entity, basePath, onClick, hideFilters = false, pag
|
|
|
68
70
|
// Entity + crud namespaces so formatValue can resolve crud:price.* etc.
|
|
69
71
|
const { t } = useTranslation([entity.namespace, 'crud']);
|
|
70
72
|
// Refresh handler - triggers manual refetch in useList
|
|
71
|
-
const handleRefresh =
|
|
73
|
+
const handleRefresh = async () => {
|
|
72
74
|
await refreshList();
|
|
73
|
-
}
|
|
74
|
-
// Edit button: always navigate to basePath/:id
|
|
75
|
-
const handleEdit = useCallback((id) => {
|
|
76
|
-
if (isPreview)
|
|
77
|
-
return;
|
|
78
|
-
navigate(`${base}/${id}`);
|
|
79
|
-
}, [base, navigate, isPreview]);
|
|
75
|
+
};
|
|
80
76
|
// Row click: onClick(id) if provided, else navigate to basePath/:id
|
|
81
77
|
const handleView = useCallback((id) => {
|
|
82
78
|
if (isPreview)
|
|
@@ -88,70 +84,57 @@ export function EntityList({ entity, basePath, onClick, hideFilters = false, pag
|
|
|
88
84
|
navigate(`${base}/${id}`);
|
|
89
85
|
}
|
|
90
86
|
}, [base, navigate, onClick, isPreview]);
|
|
91
|
-
// Add New: navigate to basePath/new
|
|
92
|
-
const handleCreate = useCallback(() => {
|
|
93
|
-
if (isPreview)
|
|
94
|
-
return;
|
|
95
|
-
navigate(`${base}/new`);
|
|
96
|
-
}, [base, navigate, isPreview]);
|
|
97
87
|
// Delete handler - store handles optimistic removal automatically
|
|
98
|
-
const handleDelete =
|
|
88
|
+
const handleDelete = async (itemId) => {
|
|
99
89
|
if (isPreview)
|
|
100
90
|
return;
|
|
101
91
|
await deleteItem(itemId);
|
|
102
|
-
}
|
|
92
|
+
};
|
|
103
93
|
// Generate columns from entity.listFields or entity.fields
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
defaultValue: 'Deleting...',
|
|
149
|
-
}), variant: "destructive", icon: Trash2, disabled: isPreview, "aria-label": tCrud('delete', { defaultValue: 'Delete' }), children: tCrud('delete', { defaultValue: 'Delete' }) })] })),
|
|
150
|
-
});
|
|
151
|
-
return baseColumns;
|
|
152
|
-
// Note: 't' and 'tCrud' are assumed stable across renders (i18next returns the same reference
|
|
153
|
-
// unless the language changes). If i18n language switching causes stale columns, add i18n.language to deps.
|
|
154
|
-
}, [entity, t, tCrud, handleEdit, handleDelete, isPreview]);
|
|
94
|
+
const fieldsToShow = entity.listFields || Object.keys(entity.fields);
|
|
95
|
+
const dataColumns = fieldsToShow
|
|
96
|
+
.map((fieldName) => {
|
|
97
|
+
const fieldConfig = entity.fields[fieldName];
|
|
98
|
+
if (!fieldConfig)
|
|
99
|
+
return null;
|
|
100
|
+
const label = translateFieldLabel(fieldName, fieldConfig, t);
|
|
101
|
+
const fieldType = fieldConfig.type || 'text';
|
|
102
|
+
const isNumeric = fieldType === 'number' || fieldType === 'range';
|
|
103
|
+
const align = isNumeric ? 'end' : 'start';
|
|
104
|
+
return {
|
|
105
|
+
key: fieldName,
|
|
106
|
+
title: label,
|
|
107
|
+
dataIndex: fieldName,
|
|
108
|
+
sortable: !isPreview,
|
|
109
|
+
filterable: !isPreview,
|
|
110
|
+
align,
|
|
111
|
+
render: (value, record) => formatValue(value, fieldConfig, t, {
|
|
112
|
+
compact: true,
|
|
113
|
+
referenceData,
|
|
114
|
+
item: record,
|
|
115
|
+
}),
|
|
116
|
+
};
|
|
117
|
+
})
|
|
118
|
+
.filter(Boolean);
|
|
119
|
+
// Actions column at the front (for mobile accessibility)
|
|
120
|
+
const actionsColumn = {
|
|
121
|
+
key: '_actions',
|
|
122
|
+
title: tCrud('actions.label', { defaultValue: 'Actions' }),
|
|
123
|
+
dataIndex: undefined,
|
|
124
|
+
sortable: false,
|
|
125
|
+
width: 120,
|
|
126
|
+
align: 'center',
|
|
127
|
+
render: (_, record) => (_jsxs(Stack, { direction: "row", gap: "tight", align: "center", justify: "center", children: [isPreview ? (_jsx(Button, { variant: "outline", icon: Edit, disabled: true, "aria-label": tCrud('edit', { defaultValue: 'Edit' }) })) : (_jsx(Button, { variant: "outline", icon: Edit, render: ({ children, ...renderProps }) => (_jsx(Link, { path: `${base}/${record.id}`, onClick: (e) => e.stopPropagation(), ...renderProps, children: children })), "aria-label": tCrud('edit', { defaultValue: 'Edit' }) })), _jsx(ActionButton, { action: async () => {
|
|
128
|
+
await handleDelete(record.id);
|
|
129
|
+
}, confirmText: tCrud('delete.confirm', {
|
|
130
|
+
defaultValue: 'Are you sure you want to delete this item?',
|
|
131
|
+
}), confirmTitle: tCrud('delete.title', {
|
|
132
|
+
defaultValue: 'Delete Item',
|
|
133
|
+
}), loadingText: tCrud('delete.loading', {
|
|
134
|
+
defaultValue: 'Deleting...',
|
|
135
|
+
}), variant: "destructive", icon: Trash2, disabled: isPreview, "aria-label": tCrud('delete', { defaultValue: 'Delete' }), children: tCrud('delete', { defaultValue: 'Delete' }) })] })),
|
|
136
|
+
};
|
|
137
|
+
const columns = [actionsColumn, ...dataColumns];
|
|
155
138
|
// Entity name for section title
|
|
156
139
|
const entityName = t('name', { defaultValue: entity.name });
|
|
157
140
|
// Result count
|
|
@@ -162,7 +145,7 @@ export function EntityList({ entity, basePath, onClick, hideFilters = false, pag
|
|
|
162
145
|
defaultValue: `Browse ${entityName} - Filters`,
|
|
163
146
|
}), collapsible: true, defaultOpen: true, tone: tone, children: _jsxs(Stack, { children: [_jsxs(Stack, { direction: "row", gap: "tight", align: "center", className: "dndev-w-full", style: { display: 'grid', gridTemplateColumns: '1fr auto auto' }, children: [_jsx(Input, { placeholder: tCrud('search.placeholder', {
|
|
164
147
|
defaultValue: 'Search...',
|
|
165
|
-
}), value: searchQuery, onChange: (e) => setSearchQuery(e.target.value), icon: Search, className: "dndev-w-full", disabled: isPreview }), _jsx(Button, { icon: RefreshCw, variant: "outline", onClick: handleRefresh, disabled: isPreview || loading, display: "compact", "aria-label": tCrud('refresh', { defaultValue: 'Refresh' }) }), _jsx(Button, { icon: Plus,
|
|
148
|
+
}), value: searchQuery, onChange: (e) => setSearchQuery(e.target.value), icon: Search, className: "dndev-w-full", disabled: isPreview }), _jsx(Button, { icon: RefreshCw, variant: "outline", onClick: handleRefresh, disabled: isPreview || loading, display: "compact", "aria-label": tCrud('refresh', { defaultValue: 'Refresh' }) }), isPreview ? (_jsx(Button, { icon: Plus, display: "compact", disabled: true, children: tCrud('addNew', { defaultValue: 'Add New' }) })) : (_jsx(Button, { icon: Plus, display: "compact", render: ({ children, ...renderProps }) => (_jsx(Link, { path: `${base}/new`, ...renderProps, children: children })), children: tCrud('addNew', { defaultValue: 'Add New' }) }))] }), !hideFilters && (_jsx(EntityFilters, { entity: entity, data: rawData, fieldsToFilter: entity.listFields }))] }) }), _jsx(Section, { title: loading
|
|
166
149
|
? tCrud('results.title.fetching', {
|
|
167
150
|
defaultValue: 'Fetching...',
|
|
168
151
|
})
|
|
@@ -183,7 +166,8 @@ export function EntityList({ entity, basePath, onClick, hideFilters = false, pag
|
|
|
183
166
|
defaultValue: 'Items per page',
|
|
184
167
|
}),
|
|
185
168
|
// Persisted page size — always controlled via CrudStore
|
|
186
|
-
pageSize: storedPageSize, onPageSizeChange: setStoredPageSize, ...(!isPreview &&
|
|
169
|
+
pageSize: storedPageSize, onPageSizeChange: setStoredPageSize, ...(!isPreview &&
|
|
170
|
+
effectiveMode === 'server' && {
|
|
187
171
|
currentPage,
|
|
188
172
|
total: listData?.total,
|
|
189
173
|
onPageChange: setCurrentPage,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityRecommendations.d.ts","sourceRoot":"","sources":["../../../src/crud/components/EntityRecommendations.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,gBAAgB,CAAC;AAKjE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,wBAAgB,qBAAqB,CAAC,EACpC,MAAM,EACN,YAAY,EACZ,KAAK,EACL,QAAQ,EACR,IAAmB,EACnB,IAAI,EACJ,SAAS,GACV,EAAE,0BAA0B,
|
|
1
|
+
{"version":3,"file":"EntityRecommendations.d.ts","sourceRoot":"","sources":["../../../src/crud/components/EntityRecommendations.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,gBAAgB,CAAC;AAKjE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,wBAAgB,qBAAqB,CAAC,EACpC,MAAM,EACN,YAAY,EACZ,KAAK,EACL,QAAQ,EACR,IAAmB,EACnB,IAAI,EACJ,SAAS,GACV,EAAE,0BAA0B,kDAmE5B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityWorkflow.d.ts","sourceRoot":"","sources":["../../../src/crud/components/EntityWorkflow.tsx"],"names":[],"mappings":"AA2BA,OAAO,KAAK,EACV,cAAc,EAEd,oBAAoB,EACrB,MAAM,gBAAgB,CAAC;AAIxB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,+BAA+B;AAC/B,MAAM,WAAW,mBAAmB;IAClC,mDAAmD;IACnD,QAAQ,EAAE,cAAc,CAAC;IACzB,4CAA4C;IAC5C,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxE,iCAAiC;IACjC,YAAY,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5D,8CAA8C;IAC9C,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACxC,qCAAqC;IACrC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,8DAA8D;IAC9D,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE,oBAAoB,KAAK,SAAS,CAAC;IACnD,2BAA2B;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,EAC7B,QAAQ,EAAE,MAAM,EAChB,UAAU,EACV,YAAY,EACZ,aAAa,EACb,UAAU,EACV,QAAQ,EACR,SAAS,GACV,EAAE,mBAAmB,
|
|
1
|
+
{"version":3,"file":"EntityWorkflow.d.ts","sourceRoot":"","sources":["../../../src/crud/components/EntityWorkflow.tsx"],"names":[],"mappings":"AA2BA,OAAO,KAAK,EACV,cAAc,EAEd,oBAAoB,EACrB,MAAM,gBAAgB,CAAC;AAIxB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,+BAA+B;AAC/B,MAAM,WAAW,mBAAmB;IAClC,mDAAmD;IACnD,QAAQ,EAAE,cAAc,CAAC;IACzB,4CAA4C;IAC5C,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxE,iCAAiC;IACjC,YAAY,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5D,8CAA8C;IAC9C,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACxC,qCAAqC;IACrC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,8DAA8D;IAC9D,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE,oBAAoB,KAAK,SAAS,CAAC;IACnD,2BAA2B;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,EAC7B,QAAQ,EAAE,MAAM,EAChB,UAAU,EACV,YAAY,EACZ,aAAa,EACb,UAAU,EACV,QAAQ,EACR,SAAS,GACV,EAAE,mBAAmB,kDA2FrB"}
|
|
@@ -71,5 +71,5 @@ export function EntityWorkflow({ workflow: config, onComplete, onStepChange, def
|
|
|
71
71
|
? t('workflow.submit', { defaultValue: 'Submit' })
|
|
72
72
|
: t('workflow.next', { defaultValue: 'Next' }), cancelText: isFirst
|
|
73
73
|
? null
|
|
74
|
-
: t('workflow.previous', { defaultValue: 'Previous' }), onCancel: isFirst ? undefined : wf.goPrevious, loading: isSubmitting,
|
|
74
|
+
: t('workflow.previous', { defaultValue: 'Previous' }), onCancel: isFirst ? undefined : wf.goPrevious, loading: isSubmitting, hideVisibilityInfo: true })) : null, currentStep.allowSkip && !isLast && (_jsx(Button, { variant: "ghost", onClick: wf.skipStep, className: "dndev-w-full", children: t('workflow.skip', { defaultValue: 'Skip this step' }) }))] }));
|
|
75
75
|
}
|
|
@@ -16,7 +16,6 @@ import * as crudModule from '@donotdev/crud';
|
|
|
16
16
|
/** true when @donotdev/crud resolved with real exports */
|
|
17
17
|
export declare const isCrudModuleAvailable: boolean;
|
|
18
18
|
export declare const useEntityForm: typeof crudModule.useEntityForm;
|
|
19
|
-
export declare const useUnsavedChangesWarning: typeof crudModule.useUnsavedChangesWarning;
|
|
20
19
|
export declare const useFormStore: import("zustand").UseBoundStore<import("zustand").StoreApi<crudModule.FormStoreState & crudModule.FormStoreActions & import("@donotdev/stores").DoNotDevStore>>;
|
|
21
20
|
export declare const useFieldConditions: typeof crudModule.useFieldConditions;
|
|
22
21
|
export declare const useCrud: typeof crudModule.useCrud;
|