@donotdev/ui 0.0.16 → 0.0.18
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 +2 -3
- 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/EntityFormRenderer.d.ts.map +1 -1
- package/dist/crud/components/EntityFormRenderer.js +22 -2
- package/dist/crud/components/EntityList.d.ts.map +1 -1
- package/dist/crud/components/EntityList.js +7 -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 +47 -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 +1452 -100
- package/dist/index.js +4 -4
- 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/styles/index.css +1418 -121
- package/dist/vite-routing/AppRoutes.d.ts.map +1 -1
- package/dist/vite-routing/AppRoutes.js +31 -4
- package/package.json +11 -11
|
@@ -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;AAsBD,eAAO,MAAM,QAAQ,GAAI,iFAOtB,aAAa,mDA0Of,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';
|
|
@@ -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":"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,2CA0c5B;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(() => {
|
|
@@ -217,6 +219,24 @@ export function EntityFormRenderer({ entity, onSubmit, t, className = '', submit
|
|
|
217
219
|
gridColumn: '1 / -1',
|
|
218
220
|
display: 'contents',
|
|
219
221
|
}, 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 }) => {
|
|
222
|
+
// Evaluate dynamic conditions for this field
|
|
223
|
+
const cond = fieldConditions[name];
|
|
224
|
+
if (cond && !cond.visible)
|
|
225
|
+
return null;
|
|
226
|
+
// Apply condition overrides to field config
|
|
227
|
+
const effectiveConfig = cond
|
|
228
|
+
? {
|
|
229
|
+
...config,
|
|
230
|
+
// Merge dynamic required into validation (condition overrides static)
|
|
231
|
+
...(cond.required && config.validation
|
|
232
|
+
? { validation: { ...config.validation, required: true } }
|
|
233
|
+
: cond.required
|
|
234
|
+
? { validation: { required: true } }
|
|
235
|
+
: {}),
|
|
236
|
+
}
|
|
237
|
+
: config;
|
|
238
|
+
// Condition-based disabled/readonly override editability
|
|
239
|
+
const effectiveEditable = editable && !cond?.disabled && !cond?.readonly;
|
|
220
240
|
// Show visibility badge for non-guest fields when visibility badges are enabled (admins/super only)
|
|
221
241
|
const showBadge = showVisibilityBadges && config.visibility !== 'guest';
|
|
222
242
|
const badgeVariant = config.visibility !== 'hidden'
|
|
@@ -225,7 +245,7 @@ export function EntityFormRenderer({ entity, onSubmit, t, className = '', submit
|
|
|
225
245
|
const badgeLabel = roleLabels[config.visibility] ??
|
|
226
246
|
config.visibility;
|
|
227
247
|
// Wrap field with visibility badge when enabled
|
|
228
|
-
const fieldElement = !
|
|
248
|
+
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
249
|
// If no badge needed, return field directly
|
|
230
250
|
if (!showBadge)
|
|
231
251
|
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,2CAiRjB"}
|
|
@@ -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);
|
|
@@ -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,2CAqFrB"}
|
|
@@ -0,0 +1,47 @@
|
|
|
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: stepData[currentStep.id], onSubmit: async (data) => {
|
|
41
|
+
await wf.goNext(data);
|
|
42
|
+
}, submitText: isLast
|
|
43
|
+
? t('workflow.submit', { defaultValue: 'Submit' })
|
|
44
|
+
: t('workflow.next', { defaultValue: 'Next' }), cancelText: isFirst
|
|
45
|
+
? null
|
|
46
|
+
: 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' }) }))] }));
|
|
47
|
+
}
|
|
@@ -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';
|