@donotdev/ui 0.0.17 → 0.0.19
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/dist/components/auth/AuthHeader.d.ts.map +1 -1
- package/dist/components/auth/AuthHeader.js +2 -2
- package/dist/components/auth/AuthMenu.d.ts.map +1 -1
- package/dist/components/auth/AuthMenu.js +10 -6
- package/dist/components/common/FeatureDisabled.d.ts.map +1 -1
- package/dist/components/common/FeatureDisabled.js +2 -2
- package/dist/components/layout/components/Notifications.js +2 -2
- package/dist/crud/components/EntityDisplayRenderer.d.ts.map +1 -1
- package/dist/crud/components/EntityDisplayRenderer.js +4 -1
- package/dist/crud/components/EntityFormRenderer.d.ts.map +1 -1
- package/dist/crud/components/EntityFormRenderer.js +24 -3
- package/dist/crud/components/EntityList.d.ts.map +1 -1
- package/dist/crud/components/EntityList.js +9 -2
- package/dist/crud/components/EntityWorkflow.d.ts +47 -0
- package/dist/crud/components/EntityWorkflow.d.ts.map +1 -0
- package/dist/crud/components/EntityWorkflow.js +50 -0
- package/dist/crud/components/index.d.ts +2 -0
- package/dist/crud/components/index.d.ts.map +1 -1
- package/dist/crud/components/index.js +1 -0
- package/dist/dndev.css +1510 -114
- package/dist/index.js +4 -4
- package/dist/internal/common/RouteErrorFallback.js +1 -1
- package/dist/internal/devtools/DebugTools.d.ts.map +1 -1
- package/dist/internal/devtools/DebugTools.js +7 -2
- package/dist/internal/initializers/NextJsStoresInitializer.d.ts.map +1 -1
- package/dist/internal/initializers/NextJsStoresInitializer.js +8 -1
- package/dist/internal/layout/DnDevLayout.d.ts.map +1 -1
- package/dist/internal/layout/DnDevLayout.js +4 -3
- package/dist/internal/layout/components/AutoMetaTags.d.ts.map +1 -1
- package/dist/internal/layout/components/AutoMetaTags.js +1 -1
- package/dist/internal/providers/NavigationProvider.js +1 -1
- package/dist/providers/NextJsAppProviders.d.ts.map +1 -1
- package/dist/providers/NextJsAppProviders.js +14 -11
- package/dist/routing/DnDevNavigationMenu.d.ts.map +1 -1
- package/dist/routing/DnDevNavigationMenu.js +3 -2
- package/dist/routing/GoToWrapper.d.ts.map +1 -1
- package/dist/routing/GoToWrapper.js +7 -0
- package/dist/routing/Link.d.ts.map +1 -1
- package/dist/routing/Link.js +2 -1
- package/dist/routing/hooks/hooks.next.js +1 -1
- package/dist/routing/hooks/useLocation.next.d.ts +1 -1
- package/dist/routing/hooks/useLocation.next.d.ts.map +1 -1
- package/dist/routing/hooks/useLocation.next.js +2 -1
- package/dist/routing/hooks/useParams.next.d.ts.map +1 -1
- package/dist/routing/hooks/useParams.next.js +4 -1
- package/dist/routing/hooks/useRedirectGuard.next.js +3 -3
- package/dist/styles/index.css +1473 -132
- package/dist/utils/assetResolver.d.ts +6 -0
- package/dist/utils/assetResolver.d.ts.map +1 -1
- package/dist/utils/assetResolver.js +9 -3
- package/dist/vite-routing/AppRoutes.d.ts.map +1 -1
- package/dist/vite-routing/AppRoutes.js +31 -4
- package/package.json +9 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuthHeader.d.ts","sourceRoot":"","sources":["../../../src/components/auth/AuthHeader.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AuthHeader.d.ts","sourceRoot":"","sources":["../../../src/components/auth/AuthHeader.tsx"],"names":[],"mappings":"AAeA,OAAO,EAKL,OAAO,EACR,MAAM,sBAAsB,CAAC;AAU9B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAyB3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,MAAM,WAAW,eAAe;IAC9B;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,CAAC,OAAO,OAAO,CAAC,CAAC,MAAM,OAAO,OAAO,CAAC,CAAC;IACjD,gDAAgD;IAChD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,4CAA4C;IAC5C,KAAK,CAAC,EAAE,aAAa,CAAC;CACvB;AAED;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,EAAE,aAAa,CAAC,eAAe,CA4IrD,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
3
|
// packages/ui/src/components/auth/AuthHeader.tsx
|
|
2
4
|
/**
|
|
3
5
|
* @fileoverview Auth Header Component
|
|
@@ -7,8 +9,6 @@
|
|
|
7
9
|
* @since 0.0.1
|
|
8
10
|
* @author AMBROISE PARK Consulting
|
|
9
11
|
*/
|
|
10
|
-
'use client';
|
|
11
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
12
|
import { User } from 'lucide-react';
|
|
13
13
|
import React, { Suspense, lazy, useState } from 'react';
|
|
14
14
|
import { Button, BUTTON_VARIANT, DropdownMenu, Dialog, DISPLAY, } from '@donotdev/components';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuthMenu.d.ts","sourceRoot":"","sources":["../../../src/components/auth/AuthMenu.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AuthMenu.d.ts","sourceRoot":"","sources":["../../../src/components/auth/AuthMenu.tsx"],"names":[],"mappings":"AA0EA,OAAO,KAAkC,MAAM,OAAO,CAAC;AAEvD,OAAO,EAML,OAAO,EACR,MAAM,sBAAsB,CAAC;AAc9B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AA8D3C;;;;;;;;;GASG;AACH,MAAM,WAAW,kBAAkB;IACjC,sBAAsB;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,mDAAmD;IACnD,IAAI,CAAC,EAAE,MAAM,GAAG,aAAa,CAAC;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACtD,6DAA6D;IAC7D,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,8DAA8D;IAC9D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,+BAA+B;IAC/B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,mBAAmB;IACnB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;CAC7B;AAED;;;;;;GAMG;AACH,MAAM,WAAW,aAAa;IAC5B,qFAAqF;IACrF,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,CAAC,OAAO,OAAO,CAAC,CAAC,MAAM,OAAO,OAAO,CAAC,CAAC;IAEjD,sBAAsB;IACtB,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB;;;;OAIG;IACH,WAAW,CAAC,EAAE,kBAAkB,EAAE,CAAC;IAEnC,gDAAgD;IAChD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,4CAA4C;IAC5C,KAAK,CAAC,EAAE,aAAa,CAAC;CACvB;AA4BD,eAAO,MAAM,QAAQ,GAAI,iFAOtB,aAAa,mDA2Of,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
3
|
// packages/ui/src/components/auth/AuthMenu.tsx
|
|
2
4
|
/**
|
|
3
5
|
* @fileoverview AuthMenu component for authenticated user menu
|
|
@@ -67,9 +69,6 @@
|
|
|
67
69
|
* @since 0.0.1
|
|
68
70
|
* @author AMBROISE PARK Consulting
|
|
69
71
|
*/
|
|
70
|
-
'use client';
|
|
71
|
-
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
72
|
-
// packages/core/ui/src/components/layout/components/AuthMenu.tsx
|
|
73
72
|
import { User, LogOut, Settings, UserCheck, Trash2 } from 'lucide-react';
|
|
74
73
|
import * as LucideIcons from 'lucide-react';
|
|
75
74
|
import React, { useMemo, lazy, Suspense } from 'react';
|
|
@@ -151,7 +150,11 @@ const getIcon = (iconName) => {
|
|
|
151
150
|
if (typeof iconName === 'function')
|
|
152
151
|
return iconName;
|
|
153
152
|
const cleanIconName = iconName.replace(/['"]/g, '');
|
|
154
|
-
|
|
153
|
+
const resolved = LucideIcons[cleanIconName];
|
|
154
|
+
if (!resolved && process.env.NODE_ENV === 'development') {
|
|
155
|
+
console.warn(`[AuthMenu] Icon name "${cleanIconName}" not found in Lucide icons, falling back to Settings.`);
|
|
156
|
+
}
|
|
157
|
+
return resolved || Settings;
|
|
155
158
|
};
|
|
156
159
|
export const AuthMenu = ({ loginPath, display = DISPLAY.AUTO, 'no-tooltip': noTooltip = false, customItems = [], className, style, }) => {
|
|
157
160
|
const { t } = useTranslation('dndev');
|
|
@@ -165,6 +168,8 @@ export const AuthMenu = ({ loginPath, display = DISPLAY.AUTO, 'no-tooltip': noTo
|
|
|
165
168
|
const navigate = useNavigate();
|
|
166
169
|
const profilePath = authConfig.profilePath;
|
|
167
170
|
const configMenuItems = authConfig.authMenuItems || [];
|
|
171
|
+
// Extract role from user (declared early so getUserTooltip can reference it)
|
|
172
|
+
const role = user?.role;
|
|
168
173
|
// Account deletion flow - managed by useDeleteAccount hook
|
|
169
174
|
const deletion = useDeleteAccount();
|
|
170
175
|
/**
|
|
@@ -292,6 +297,7 @@ export const AuthMenu = ({ loginPath, display = DISPLAY.AUTO, 'no-tooltip': noTo
|
|
|
292
297
|
navigationItems,
|
|
293
298
|
isLaptop,
|
|
294
299
|
user,
|
|
300
|
+
role,
|
|
295
301
|
getUserDisplayName,
|
|
296
302
|
navigate,
|
|
297
303
|
]);
|
|
@@ -301,8 +307,6 @@ export const AuthMenu = ({ loginPath, display = DISPLAY.AUTO, 'no-tooltip': noTo
|
|
|
301
307
|
if (enabled.length === 0 || shouldHide || !isReady) {
|
|
302
308
|
return null;
|
|
303
309
|
}
|
|
304
|
-
// Extract role from user
|
|
305
|
-
const role = user?.role;
|
|
306
310
|
// Return null when unauthenticated - AuthHeader handles unauthenticated state
|
|
307
311
|
if (!isAuthenticated) {
|
|
308
312
|
return null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FeatureDisabled.d.ts","sourceRoot":"","sources":["../../../src/components/common/FeatureDisabled.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FeatureDisabled.d.ts","sourceRoot":"","sources":["../../../src/components/common/FeatureDisabled.tsx"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAE5B;;OAEG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAE7B;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IAErB;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,IAAI,CAAC;IAE7B;;OAEG;IACH,aAAa,CAAC,EAAE,SAAS,CAAC;IAE1B;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,iBAAS,eAAe,CAAC,EACvB,WAAW,EACX,KAAK,EACL,WAAW,EACX,iBAAyB,EACzB,kBAAyB,EACzB,SAAiB,EACjB,YAAoC,EACpC,OAAO,EACP,eAAe,EACf,aAAa,EACb,SAAc,GACf,EAAE,oBAAoB,2CAoGtB;AAED,eAAe,eAAe,CAAC"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
3
|
// packages/ui/src/components/common/FeatureDisabled.tsx
|
|
2
4
|
/**
|
|
3
5
|
* @fileoverview FeatureDisabled Component
|
|
@@ -10,8 +12,6 @@
|
|
|
10
12
|
* @since 0.0.1
|
|
11
13
|
* @author AMBROISE PARK Consulting
|
|
12
14
|
*/
|
|
13
|
-
'use client';
|
|
14
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
15
15
|
import { AlertCircle, RefreshCw, Mail, Cookie } from 'lucide-react';
|
|
16
16
|
import { Card, Button, BUTTON_VARIANT, Stack } from '@donotdev/components';
|
|
17
17
|
import { useTranslation } from '@donotdev/core';
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
3
|
// packages/ui/src/components/layout/components/Notifications.tsx
|
|
2
4
|
/**
|
|
3
5
|
* @fileoverview Notifications component for layout system
|
|
@@ -19,8 +21,6 @@
|
|
|
19
21
|
* />
|
|
20
22
|
* ```
|
|
21
23
|
*/
|
|
22
|
-
'use client';
|
|
23
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
24
24
|
// packages/core/ui/src/components/layout/components/Notifications.tsx
|
|
25
25
|
import { Bell } from 'lucide-react';
|
|
26
26
|
import { useMemo, useEffect, useRef } from 'react';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityDisplayRenderer.d.ts","sourceRoot":"","sources":["../../../src/crud/components/EntityDisplayRenderer.tsx"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,0BAA0B,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAI/E,YAAY,EAAE,0BAA0B,EAAE,CAAC;AAE3C;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,SAAS,YAAY,GAAG,YAAY,EAAE,EAC3E,MAAM,EACN,EAAE,EACF,CAAC,EACD,SAAc,EACd,cAAc,EACd,eAAe,EACf,UAAU,EAAE,cAAc,EAC1B,aAAa,GACd,EAAE,0BAA0B,CAAC,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"EntityDisplayRenderer.d.ts","sourceRoot":"","sources":["../../../src/crud/components/EntityDisplayRenderer.tsx"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,0BAA0B,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAI/E,YAAY,EAAE,0BAA0B,EAAE,CAAC;AAE3C;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,SAAS,YAAY,GAAG,YAAY,EAAE,EAC3E,MAAM,EACN,EAAE,EACF,CAAC,EACD,SAAc,EACd,cAAc,EACd,eAAe,EACf,UAAU,EAAE,cAAc,EAC1B,aAAa,GACd,EAAE,0BAA0B,CAAC,CAAC,CAAC,2CA0M/B;AAED,eAAe,qBAAqB,CAAC"}
|
|
@@ -85,7 +85,10 @@ export function EntityDisplayRenderer({ entity, id, t, className = '', loadingMe
|
|
|
85
85
|
cancelled = true;
|
|
86
86
|
};
|
|
87
87
|
}, [id, get, isAvailable]);
|
|
88
|
-
//
|
|
88
|
+
// Priority: store data (reactive, updated by other components) > local fetch data.
|
|
89
|
+
// Store may already have the entity from a list view or prior navigation,
|
|
90
|
+
// so we prefer it to avoid a redundant fetch. Local fetch is the fallback
|
|
91
|
+
// when the entity isn't in the store yet (e.g., direct URL access).
|
|
89
92
|
const displayData = storeData || data;
|
|
90
93
|
const displayError = storeError || fetchError;
|
|
91
94
|
const isLoading = loading || isFetching || !id;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityFormRenderer.d.ts","sourceRoot":"","sources":["../../../src/crud/components/EntityFormRenderer.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"EntityFormRenderer.d.ts","sourceRoot":"","sources":["../../../src/crud/components/EntityFormRenderer.tsx"],"names":[],"mappings":"AAuCA,OAAO,KAAK,EACV,uBAAuB,EACvB,YAAY,EAEb,MAAM,gBAAgB,CAAC;AAExB,YAAY,EAAE,uBAAuB,EAAE,CAAC;AAExC;;;;;;;;;;;;GAYG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,YAAY,GAAG,YAAY,EAAE,EACxE,MAAM,EACN,QAAQ,EACR,CAAC,EACD,SAAc,EACd,UAAU,EACV,OAAe,EACf,aAAa,EACb,aAAyB,EACzB,mBAAmB,EACnB,sBAAkC,EAClC,iBAAiB,EACjB,UAAU,EAAE,cAAc,EAC1B,SAA6C,EAC7C,MAAM,EAAE,cAAc,EACtB,UAAU,EACV,UAAU,EACV,WAAW,EACX,QAAQ,EACR,oBAA2B,EAC3B,qBAAqB,EACrB,kBAA0B,GAC3B,EAAE,uBAAuB,CAAC,CAAC,CAAC,2CA2c5B;AAED,eAAe,kBAAkB,CAAC"}
|
|
@@ -15,7 +15,7 @@ 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
17
|
import { useNavigate } from '../../routing';
|
|
18
|
-
import { DisplayFieldRenderer, FormFieldRenderer, UploadProvider, useEntityForm, useUnsavedChangesWarning, useFormStore, } from '@donotdev/crud';
|
|
18
|
+
import { DisplayFieldRenderer, FormFieldRenderer, UploadProvider, useEntityForm, useUnsavedChangesWarning, useFormStore, useFieldConditions, } from '@donotdev/crud';
|
|
19
19
|
import { useAuthSafe } from '../../utils/useAuthSafe';
|
|
20
20
|
/**
|
|
21
21
|
* EntityFormRenderer - Dumb component that renders a form from entity definition.
|
|
@@ -104,6 +104,8 @@ export function EntityFormRenderer({ entity, onSubmit, t, className = '', submit
|
|
|
104
104
|
return fieldRoleIndex <= previewRoleIndex;
|
|
105
105
|
});
|
|
106
106
|
}, [rawFields, canPreviewRole, previewRole]);
|
|
107
|
+
// Evaluate field conditions (visible/disabled/required/readonly) against live form values
|
|
108
|
+
const fieldConditions = useFieldConditions(renderableFields, control);
|
|
107
109
|
// Sync isDirty to FormStore (single source of truth)
|
|
108
110
|
// Use getState() to avoid subscribing to the action reference (Zustand anti-pattern)
|
|
109
111
|
useEffect(() => {
|
|
@@ -158,9 +160,10 @@ export function EntityFormRenderer({ entity, onSubmit, t, className = '', submit
|
|
|
158
160
|
navigate('back');
|
|
159
161
|
}
|
|
160
162
|
}
|
|
161
|
-
catch {
|
|
163
|
+
catch (error) {
|
|
162
164
|
// onSubmit rejected — stay on form so user can correct errors
|
|
163
165
|
// Error display is handled by the caller's onSubmit implementation
|
|
166
|
+
console.error(error);
|
|
164
167
|
}
|
|
165
168
|
};
|
|
166
169
|
// Determine if cancel button should show
|
|
@@ -217,6 +220,24 @@ export function EntityFormRenderer({ entity, onSubmit, t, className = '', submit
|
|
|
217
220
|
gridColumn: '1 / -1',
|
|
218
221
|
display: 'contents',
|
|
219
222
|
}, children: [isLoading && _jsx(Spinner, { overlay: true }), _jsxs("form", { onSubmit: handleSubmit(handleFormSubmit), noValidate: true, className: className, style: { width: '100%', gridColumn: '1 / -1', display: 'contents' }, children: [renderableFields.map(({ name, config, editable }) => {
|
|
223
|
+
// Evaluate dynamic conditions for this field
|
|
224
|
+
const cond = fieldConditions[name];
|
|
225
|
+
if (cond && !cond.visible)
|
|
226
|
+
return null;
|
|
227
|
+
// Apply condition overrides to field config
|
|
228
|
+
const effectiveConfig = cond
|
|
229
|
+
? {
|
|
230
|
+
...config,
|
|
231
|
+
// Merge dynamic required into validation (condition overrides static)
|
|
232
|
+
...(cond.required && config.validation
|
|
233
|
+
? { validation: { ...config.validation, required: true } }
|
|
234
|
+
: cond.required
|
|
235
|
+
? { validation: { required: true } }
|
|
236
|
+
: {}),
|
|
237
|
+
}
|
|
238
|
+
: config;
|
|
239
|
+
// Condition-based disabled/readonly override editability
|
|
240
|
+
const effectiveEditable = editable && !cond?.disabled && !cond?.readonly;
|
|
220
241
|
// Show visibility badge for non-guest fields when visibility badges are enabled (admins/super only)
|
|
221
242
|
const showBadge = showVisibilityBadges && config.visibility !== 'guest';
|
|
222
243
|
const badgeVariant = config.visibility !== 'hidden'
|
|
@@ -225,7 +246,7 @@ export function EntityFormRenderer({ entity, onSubmit, t, className = '', submit
|
|
|
225
246
|
const badgeLabel = roleLabels[config.visibility] ??
|
|
226
247
|
config.visibility;
|
|
227
248
|
// Wrap field with visibility badge when enabled
|
|
228
|
-
const fieldElement = !
|
|
249
|
+
const fieldElement = !effectiveEditable ? (_jsx(DisplayFieldRenderer, { name: name, config: effectiveConfig, value: defaultValues?.[name], t: translate }, name)) : (_jsx(FormFieldRenderer, { name: name, config: effectiveConfig, control: control, errors: errors, t: translate }, name));
|
|
229
250
|
// If no badge needed, return field directly
|
|
230
251
|
if (!showBadge)
|
|
231
252
|
return fieldElement;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityList.d.ts","sourceRoot":"","sources":["../../../src/crud/components/EntityList.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"EntityList.d.ts","sourceRoot":"","sources":["../../../src/crud/components/EntityList.tsx"],"names":[],"mappings":"AAyCA,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,UAAqB,EACrB,QAAQ,EAAE,YAAY,EACtB,YAAY,EACZ,UAAiB,GAClB,EAAE,eAAe,2CAmRjB"}
|
|
@@ -18,7 +18,7 @@ import { useMemo, 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 { useNavigate } from '../../routing';
|
|
21
|
-
import { translateFieldLabel, useCrud, useCrudList, EntityFilters, formatValue, } from '@donotdev/crud';
|
|
21
|
+
import { translateFieldLabel, useCrud, useCrudList, EntityFilters, formatValue, useReferenceResolver, } from '@donotdev/crud';
|
|
22
22
|
/**
|
|
23
23
|
* Entity List Component - Table view for admin/internal operations
|
|
24
24
|
*
|
|
@@ -32,6 +32,8 @@ import { translateFieldLabel, useCrud, useCrudList, EntityFilters, formatValue,
|
|
|
32
32
|
export function EntityList({ entity, basePath, onClick, hideFilters = false, pagination = 'client', pageSize: pageSizeProp, queryOptions, exportable = true, }) {
|
|
33
33
|
const navigate = useNavigate();
|
|
34
34
|
const base = basePath ?? `/${entity.collection}`;
|
|
35
|
+
// Pre-fetch referenced collections for display resolution
|
|
36
|
+
const referenceData = useReferenceResolver(entity);
|
|
35
37
|
// Server-side pagination state (only used when pagination='server')
|
|
36
38
|
const [currentPage, setCurrentPage] = useState(1);
|
|
37
39
|
// For server-side, we need to track pageSize state (DataTable will call onPageSizeChange)
|
|
@@ -97,7 +99,10 @@ export function EntityList({ entity, basePath, onClick, hideFilters = false, pag
|
|
|
97
99
|
sortable: true,
|
|
98
100
|
filterable: true,
|
|
99
101
|
align,
|
|
100
|
-
render: (value, record) => formatValue(value, fieldConfig, t, {
|
|
102
|
+
render: (value, record) => formatValue(value, fieldConfig, t, {
|
|
103
|
+
compact: true,
|
|
104
|
+
referenceData,
|
|
105
|
+
}),
|
|
101
106
|
};
|
|
102
107
|
})
|
|
103
108
|
.filter(Boolean);
|
|
@@ -123,6 +128,8 @@ export function EntityList({ entity, basePath, onClick, hideFilters = false, pag
|
|
|
123
128
|
}), variant: "destructive", icon: Trash2, "aria-label": tCrud('delete', { defaultValue: 'Delete' }), children: tCrud('delete', { defaultValue: 'Delete' }) })] })),
|
|
124
129
|
});
|
|
125
130
|
return baseColumns;
|
|
131
|
+
// Note: 't' and 'tCrud' are assumed stable across renders (i18next returns the same reference
|
|
132
|
+
// unless the language changes). If i18n language switching causes stale columns, add i18n.language to deps.
|
|
126
133
|
}, [entity, t, tCrud, handleEdit, handleDelete]);
|
|
127
134
|
// Entity name for section title
|
|
128
135
|
const entityName = t('name', { defaultValue: entity.name });
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview EntityWorkflow component
|
|
3
|
+
* @description Renders a multi-step entity workflow with stepper navigation.
|
|
4
|
+
* Uses useEntityWorkflow for orchestration and EntityFormRenderer for each step's form.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```tsx
|
|
8
|
+
* <EntityWorkflow
|
|
9
|
+
* workflow={onboardingWorkflow}
|
|
10
|
+
* onComplete={async (data) => {
|
|
11
|
+
* await api.createAccount(data);
|
|
12
|
+
* navigate('/dashboard');
|
|
13
|
+
* }}
|
|
14
|
+
* />
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* @version 0.0.1
|
|
18
|
+
* @since 0.0.1
|
|
19
|
+
* @author AMBROISE PARK Consulting
|
|
20
|
+
*/
|
|
21
|
+
import type { ReactNode } from 'react';
|
|
22
|
+
import { type WorkflowConfig, type EntityWorkflowReturn } from '@donotdev/crud';
|
|
23
|
+
/** Props for EntityWorkflow */
|
|
24
|
+
export interface EntityWorkflowProps {
|
|
25
|
+
/** Workflow configuration from defineWorkflow() */
|
|
26
|
+
workflow: WorkflowConfig;
|
|
27
|
+
/** Callback when all steps are completed */
|
|
28
|
+
onComplete?: (allData: Record<string, unknown>) => void | Promise<void>;
|
|
29
|
+
/** Callback when step changes */
|
|
30
|
+
onStepChange?: (fromIndex: number, toIndex: number) => void;
|
|
31
|
+
/** Default values to pre-fill across steps */
|
|
32
|
+
defaultValues?: Record<string, unknown>;
|
|
33
|
+
/** Viewer role for form rendering */
|
|
34
|
+
viewerRole?: string;
|
|
35
|
+
/** Render prop for custom layout (receives workflow state) */
|
|
36
|
+
children?: (wf: EntityWorkflowReturn) => ReactNode;
|
|
37
|
+
/** Additional CSS class */
|
|
38
|
+
className?: string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* EntityWorkflow — renders a multi-step entity workflow.
|
|
42
|
+
*
|
|
43
|
+
* Default mode: auto-renders Stepper + form + navigation buttons.
|
|
44
|
+
* Custom mode: pass a render prop as children for full control.
|
|
45
|
+
*/
|
|
46
|
+
export declare function EntityWorkflow({ workflow: config, onComplete, onStepChange, defaultValues, viewerRole, children, className, }: EntityWorkflowProps): import("react/jsx-runtime").JSX.Element;
|
|
47
|
+
//# sourceMappingURL=EntityWorkflow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EntityWorkflow.d.ts","sourceRoot":"","sources":["../../../src/crud/components/EntityWorkflow.tsx"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIvC,OAAO,EAEL,KAAK,cAAc,EAEnB,KAAK,oBAAoB,EAC1B,MAAM,gBAAgB,CAAC;AAIxB,+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,2CAwFrB"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Button, Stack, Stepper } from '@donotdev/components';
|
|
4
|
+
import { useTranslation } from '@donotdev/core';
|
|
5
|
+
import { useEntityWorkflow, } from '@donotdev/crud';
|
|
6
|
+
import { EntityFormRenderer } from './EntityFormRenderer';
|
|
7
|
+
/**
|
|
8
|
+
* EntityWorkflow — renders a multi-step entity workflow.
|
|
9
|
+
*
|
|
10
|
+
* Default mode: auto-renders Stepper + form + navigation buttons.
|
|
11
|
+
* Custom mode: pass a render prop as children for full control.
|
|
12
|
+
*/
|
|
13
|
+
export function EntityWorkflow({ workflow: config, onComplete, onStepChange, defaultValues, viewerRole, children, className, }) {
|
|
14
|
+
const { t } = useTranslation('crud');
|
|
15
|
+
const wf = useEntityWorkflow(config, {
|
|
16
|
+
onComplete,
|
|
17
|
+
onStepChange,
|
|
18
|
+
defaultValues,
|
|
19
|
+
});
|
|
20
|
+
// Custom render mode
|
|
21
|
+
if (children) {
|
|
22
|
+
return _jsx(_Fragment, { children: children(wf) });
|
|
23
|
+
}
|
|
24
|
+
const { currentStep, currentStepIndex, visibleSteps, isFirst, isLast, isSubmitting, stepData, } = wf;
|
|
25
|
+
// Build stepper steps (for the Stepper header)
|
|
26
|
+
const stepperSteps = visibleSteps.map((step, index) => ({
|
|
27
|
+
number: index + 1,
|
|
28
|
+
title: step.title,
|
|
29
|
+
content: null, // Content is rendered separately below
|
|
30
|
+
}));
|
|
31
|
+
return (_jsxs(Stack, { className: className, gap: "large", children: [_jsx(Stepper, { steps: stepperSteps, activeStep: currentStepIndex, showStepNumbers: true, onStepChange: (index) => {
|
|
32
|
+
// Only allow navigating to completed steps (not jumping forward)
|
|
33
|
+
if (index <= currentStepIndex) {
|
|
34
|
+
wf.goToStep(index);
|
|
35
|
+
}
|
|
36
|
+
} }), currentStep.custom ? (
|
|
37
|
+
// Custom render step (e.g., review/summary)
|
|
38
|
+
currentStep.custom(wf.allData)) : currentStep.entity ? (
|
|
39
|
+
// Entity form step
|
|
40
|
+
_jsx(EntityFormRenderer, { entity: currentStep.entity, operation: "create", viewerRole: viewerRole, defaultValues: {
|
|
41
|
+
...stepData[currentStep.id],
|
|
42
|
+
...(!isLast && { status: 'draft' }),
|
|
43
|
+
}, onSubmit: async (data) => {
|
|
44
|
+
await wf.goNext(data);
|
|
45
|
+
}, submitText: isLast
|
|
46
|
+
? t('workflow.submit', { defaultValue: 'Submit' })
|
|
47
|
+
: t('workflow.next', { defaultValue: 'Next' }), cancelText: isFirst
|
|
48
|
+
? null
|
|
49
|
+
: t('workflow.previous', { defaultValue: 'Previous' }), onCancel: isFirst ? undefined : wf.goPrevious, loading: isSubmitting, warnOnUnsavedChanges: false, 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' }) }))] }));
|
|
50
|
+
}
|
|
@@ -11,6 +11,8 @@ export { EntityList } from './EntityList';
|
|
|
11
11
|
export { EntityCardList } from './EntityCardList';
|
|
12
12
|
export { EntityFormRenderer } from './EntityFormRenderer';
|
|
13
13
|
export { EntityRecommendations } from './EntityRecommendations';
|
|
14
|
+
export { EntityWorkflow } from './EntityWorkflow';
|
|
15
|
+
export type { EntityWorkflowProps } from './EntityWorkflow';
|
|
14
16
|
export * from './Form';
|
|
15
17
|
export type { EntityListProps, EntityCardListProps, EntityRecommendationsProps, EntityFormRendererProps, EntityDisplayRendererProps, } from '@donotdev/core';
|
|
16
18
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/crud/components/index.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,cAAc,QAAQ,CAAC;AAEvB,YAAY,EACV,eAAe,EACf,mBAAmB,EACnB,0BAA0B,EAC1B,uBAAuB,EACvB,0BAA0B,GAC3B,MAAM,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/crud/components/index.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,YAAY,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,cAAc,QAAQ,CAAC;AAEvB,YAAY,EACV,eAAe,EACf,mBAAmB,EACnB,0BAA0B,EAC1B,uBAAuB,EACvB,0BAA0B,GAC3B,MAAM,gBAAgB,CAAC"}
|
|
@@ -12,4 +12,5 @@ export { EntityList } from './EntityList';
|
|
|
12
12
|
export { EntityCardList } from './EntityCardList';
|
|
13
13
|
export { EntityFormRenderer } from './EntityFormRenderer';
|
|
14
14
|
export { EntityRecommendations } from './EntityRecommendations';
|
|
15
|
+
export { EntityWorkflow } from './EntityWorkflow';
|
|
15
16
|
export * from './Form';
|