@donotdev/ui 0.2.3 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/dist/ChildRowsPicker-63M4EQUQ.js +1 -0
  2. package/dist/ChildRowsPicker-ISP365ON.js +1 -0
  3. package/dist/ChildRowsPicker-PQFE6NCR.js +1 -0
  4. package/dist/ChildRowsPicker-XXFFSMWY.js +1 -0
  5. package/dist/GoToDialog-XBK5EZF4.js +1 -0
  6. package/dist/chunk-3CIZFGST.js +1 -0
  7. package/dist/chunk-LHMKU342.js +1 -0
  8. package/dist/chunk-P2DHZWPY.js +1 -0
  9. package/dist/components/layout/components/Breadcrumbs.d.ts.map +1 -1
  10. package/dist/components/layout/components/Breadcrumbs.js +4 -3
  11. package/dist/components/layout/components/header/SettingsMenu.js +2 -2
  12. package/dist/crud/components/ChildRowsPicker.d.ts +21 -0
  13. package/dist/crud/components/ChildRowsPicker.d.ts.map +1 -0
  14. package/dist/crud/components/ChildRowsPicker.js +68 -0
  15. package/dist/crud/components/EntityCardList.d.ts.map +1 -1
  16. package/dist/crud/components/EntityCardList.js +9 -17
  17. package/dist/crud/components/EntityDisplayRenderer.js +2 -2
  18. package/dist/crud/components/EntityFormRenderer.d.ts +4 -2
  19. package/dist/crud/components/EntityFormRenderer.d.ts.map +1 -1
  20. package/dist/crud/components/EntityFormRenderer.js +137 -55
  21. package/dist/crud/components/EntityList.d.ts +3 -1
  22. package/dist/crud/components/EntityList.d.ts.map +1 -1
  23. package/dist/crud/components/EntityList.js +324 -56
  24. package/dist/crud/components/EntityRecommendations.js +1 -1
  25. package/dist/crud/components/EntityWorkflow.d.ts.map +1 -1
  26. package/dist/crud/components/EntityWorkflow.js +6 -4
  27. package/dist/crud/components/cellEditFor.d.ts +23 -8
  28. package/dist/crud/components/cellEditFor.d.ts.map +1 -1
  29. package/dist/crud/components/cellEditFor.js +40 -20
  30. package/dist/crud/components/entityParent.d.ts +8 -15
  31. package/dist/crud/components/entityParent.d.ts.map +1 -1
  32. package/dist/crud/components/entityParent.js +30 -8
  33. package/dist/crud/components/useRecordBreadcrumb.d.ts +1 -1
  34. package/dist/crud/components/useRecordBreadcrumb.d.ts.map +1 -1
  35. package/dist/crud/components/useRecordBreadcrumb.js +12 -3
  36. package/dist/crud/crudImports.d.ts +11 -2
  37. package/dist/crud/crudImports.d.ts.map +1 -1
  38. package/dist/crud/crudImports.js +10 -1
  39. package/dist/dndev-next.css +302 -51
  40. package/dist/dndev.css +304 -51
  41. package/dist/index.js +4 -4
  42. package/dist/internal/initializers/NextJsStoresInitializer.d.ts +3 -0
  43. package/dist/internal/initializers/NextJsStoresInitializer.d.ts.map +1 -1
  44. package/dist/internal/initializers/NextJsStoresInitializer.js +8 -1
  45. package/dist/internal/layout/components/AutoMetaTags.d.ts.map +1 -1
  46. package/dist/internal/layout/components/AutoMetaTags.js +3 -2
  47. package/dist/internal/layout/components/FontPreloadLinks.d.ts +7 -4
  48. package/dist/internal/layout/components/FontPreloadLinks.d.ts.map +1 -1
  49. package/dist/internal/layout/components/FontPreloadLinks.js +12 -25
  50. package/dist/internal/layout/components/footer/FooterCopyright.d.ts +2 -0
  51. package/dist/internal/layout/components/footer/FooterCopyright.d.ts.map +1 -1
  52. package/dist/internal/layout/components/footer/FooterCopyright.js +4 -0
  53. package/dist/internal/layout/components/footer/useLegalLinks.d.ts +2 -1
  54. package/dist/internal/layout/components/footer/useLegalLinks.d.ts.map +1 -1
  55. package/dist/internal/layout/components/footer/useLegalLinks.js +4 -3
  56. package/dist/internal/providers/UIProviders.d.ts +0 -8
  57. package/dist/internal/providers/UIProviders.d.ts.map +1 -1
  58. package/dist/internal/providers/UIProviders.js +39 -1
  59. package/dist/providers/NextJsAppProviders.d.ts.map +1 -1
  60. package/dist/providers/NextJsAppProviders.js +1 -2
  61. package/dist/providers/ViteAppProviders.d.ts.map +1 -1
  62. package/dist/providers/ViteAppProviders.js +1 -4
  63. package/dist/routing/404.d.ts +8 -1
  64. package/dist/routing/404.d.ts.map +1 -1
  65. package/dist/routing/404.js +6 -2
  66. package/dist/routing/hooks/hooks.next.js +1 -1
  67. package/dist/routing/hooks/useRedirectGuard.next.d.ts +3 -1
  68. package/dist/routing/hooks/useRedirectGuard.next.d.ts.map +1 -1
  69. package/dist/routing/hooks/useRedirectGuard.next.js +11 -9
  70. package/dist/routing/parentRoute.d.ts +27 -0
  71. package/dist/routing/parentRoute.d.ts.map +1 -0
  72. package/dist/routing/parentRoute.js +43 -0
  73. package/dist/routing/useNavigation.d.ts.map +1 -1
  74. package/dist/routing/useNavigation.js +5 -24
  75. package/dist/routing/useRouteDiscovery.d.ts +2 -2
  76. package/dist/routing/useRouteDiscovery.d.ts.map +1 -1
  77. package/dist/routing/useRouteDiscovery.js +6 -5
  78. package/dist/styles/index.css +301 -50
  79. package/dist/symbol-index.json +1 -1
  80. package/guidelines/GOTCHAS.md +2 -0
  81. package/guidelines/LAYOUTS.md +4 -0
  82. package/guidelines/PAGES.md +23 -3
  83. package/guidelines/ROUTING.md +26 -1
  84. package/guidelines/SEO.md +1 -1
  85. package/package.json +8 -8
@@ -10,17 +10,31 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
10
10
  * @since 0.0.1
11
11
  * @author AMBROISE PARK Consulting
12
12
  */
13
- import { useEffect, useId, useMemo, useRef, useState, } from 'react';
13
+ import { useEffect, useMemo, useRef, useState, } from 'react';
14
14
  import { FormProvider, useWatch } from 'react-hook-form';
15
- import { Badge, Button, DropdownMenu, Grid, Stack, Spinner, } from '@donotdev/components';
15
+ import { Alert, Badge, Button, DropdownMenu, Grid, Stack, Spinner, } from '@donotdev/components';
16
16
  import { hasRoleAccess, useTranslation } from '@donotdev/core';
17
17
  import { useNavigate } from '../../routing';
18
18
  import { useAuthSafe } from '../../utils/useAuthSafe';
19
- import { isCrudModuleAvailable, DisplayFieldRenderer, FormFieldRenderer, UploadProvider, useEntityForm, useFormStore, useFieldConditions, } from '../crudImports';
19
+ import { isCrudModuleAvailable, DisplayFieldRenderer, FormFieldRenderer, UploadProvider, useEntityForm, useFormStore, useFormError, useFieldConditions, translateFieldLabel, } from '../crudImports';
20
20
  import { referencePrefillFromQuery } from './entityParent';
21
21
  import { useRecordBreadcrumb } from './useRecordBreadcrumb';
22
+ const errorSummaryStyle = { gridColumn: '1 / -1', width: '100%' };
23
+ // RHF root errors may be a single message or named server errors.
24
+ function rootErrorMessages(error) {
25
+ if (!error || typeof error !== 'object')
26
+ return [];
27
+ return Object.entries(error).flatMap(([key, value]) => {
28
+ if (key === 'message' && typeof value === 'string')
29
+ return [value];
30
+ if (key === 'ref' || key === 'types')
31
+ return [];
32
+ return rootErrorMessages(value);
33
+ });
34
+ }
22
35
  /**
23
- * Read-only field inside a form.
36
+ * Read-only field the form writes (`editable: 'computed'`, or an input disabled
37
+ * by a condition).
24
38
  *
25
39
  * Subscribes to the field's live form value rather than reading the initial
26
40
  * `defaultValues`, so fields written during the session — a computed value set
@@ -30,9 +44,23 @@ import { useRecordBreadcrumb } from './useRecordBreadcrumb';
30
44
  * Mirrors FormFieldRenderer's contract: takes `control`, subscribes itself.
31
45
  */
32
46
  function FormDisplayField({ name, config, control, t, }) {
33
- const value = useWatch({ control, name });
47
+ // why: renderable field names are the entity's own field names
48
+ const value = useWatch({ control, name: name });
34
49
  return (_jsx(DisplayFieldRenderer, { name: name, config: config, value: value, t: t }));
35
50
  }
51
+ /**
52
+ * Value of a field in the stored row (`form.record`): an extension field
53
+ * (`offer.price`) reads the extension row under its key.
54
+ */
55
+ function recordValue(record, name) {
56
+ const dot = name.indexOf('.');
57
+ if (dot === -1)
58
+ return record?.[name];
59
+ const nested = record?.[name.slice(0, dot)];
60
+ return typeof nested === 'object' && nested !== null
61
+ ? nested[name.slice(dot + 1)]
62
+ : undefined;
63
+ }
36
64
  /**
37
65
  * EntityFormRenderer - Dumb component that renders a form from entity definition.
38
66
  *
@@ -41,6 +69,8 @@ function FormDisplayField({ name, config, control, t, }) {
41
69
  * - Generates formId
42
70
  * - Renders fields
43
71
  * - Renders submit button with status from useEntityForm
72
+ * - Submits through `onSubmit`, or, without it, useEntityForm's default writer
73
+ * (the record plus the child rows joined to the form, one `bulkAcross`)
44
74
  *
45
75
  * @version 0.1.0
46
76
  * @since 0.0.1
@@ -55,18 +85,21 @@ export function EntityFormRenderer(props) {
55
85
  const { instanceKey, ...rest } = props;
56
86
  return _jsx(EntityFormRendererCore, { ...rest }, instanceKey);
57
87
  }
58
- 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, }) {
88
+ function EntityFormRendererCore({ entity, onSubmit, t, className = '', submitText, loading = false, defaultValues, submitVariant = 'primary', secondaryButtonText, secondaryButtonVariant = 'outline', onSecondarySubmit, viewerRole: viewerRoleProp, operation: operationProp, formId: externalFormId, cancelText, cancelPath, successPath, onCancel, hideVisibilityInfo = false, }) {
59
89
  // Safe guard: isCrudModuleAvailable is a module-level constant (immutable after load).
60
90
  // Hooks below are either ALL called or NONE — no Rules-of-Hooks violation at runtime.
61
91
  if (!isCrudModuleAvailable)
62
92
  return null;
93
+ // why: without the prop, Op is FieldOperation (both operations), so the runtime
94
+ // default ('edit' with defaultValues, else 'create') is an Op
95
+ const operation = (operationProp ?? (defaultValues ? 'edit' : 'create'));
63
96
  const navigate = useNavigate();
64
97
  // Auto-detect role from auth; prop overrides (e.g. View-As preview)
65
98
  const authRole = useAuthSafe('userRole');
66
99
  const viewerRole = viewerRoleProp ?? authRole;
67
- // Generate stable form ID
68
- const generatedFormId = useId();
69
- const formId = externalFormId ?? `entity-form-${entity.name}-${generatedFormId}`;
100
+ // Deterministic form ID: it also keys the auto-saved draft, so it must survive reloads.
101
+ // Several forms of the same entity on one page pass their own formId.
102
+ const formId = externalFormId ?? `entity-form-${entity.name}`;
70
103
  // Entity + crud namespaces so translateLabel can resolve crud:status.* etc.
71
104
  const { t: translationFn } = useTranslation([entity.namespace, 'crud']);
72
105
  const { t: tCrud } = useTranslation('crud');
@@ -120,8 +153,62 @@ function EntityFormRendererCore({ entity, onSubmit, t, className = '', submitTex
120
153
  viewerRole,
121
154
  t: translate,
122
155
  loading,
156
+ successPath,
123
157
  });
124
158
  const { control, setValue, handleSubmit, fields: rawFields, formStatus, uploadProgress, isDirty, hasUserInteracted, resetForm, } = form;
159
+ const submissionError = useFormError(formId);
160
+ const { errors, submitCount } = form.formState;
161
+ const formRef = useRef(null);
162
+ const summaryRef = useRef(null);
163
+ // RHF keeps only the fields that have an error (cleared ones are unset)
164
+ const errorFields = Object.keys(errors).filter((name) => name !== 'root');
165
+ const rootMessages = rootErrorMessages(errors.root);
166
+ const hasErrors = errorFields.length > 0 || rootMessages.length > 0 || !!submissionError;
167
+ const previousFeedback = useRef({ submitCount: 0, rootKey: '', submissionError: null });
168
+ const rootKey = JSON.stringify(rootMessages);
169
+ useEffect(() => {
170
+ const previous = previousFeedback.current;
171
+ previousFeedback.current = { submitCount, rootKey, submissionError };
172
+ // Blur/condition revalidation may update errors while the user is editing.
173
+ // Announce them inline, but move focus only for a submit or a new root failure.
174
+ const submitted = submitCount > previous.submitCount;
175
+ const rootFailure = (rootKey !== previous.rootKey && rootKey !== '[]') ||
176
+ (!!submissionError && submissionError !== previous.submissionError);
177
+ if (!submitted && !rootFailure)
178
+ return;
179
+ const summary = summaryRef.current;
180
+ const formElement = formRef.current;
181
+ if (!summary || !formElement)
182
+ return;
183
+ // The orchestrator owns actionable field focus. Only focus the summary when
184
+ // there is no mounted, focusable invalid control in THIS form (e.g. a hidden
185
+ // field or a server/root error), including inside a Sheet's scroll container.
186
+ const invalidNames = Object.keys(errors).filter((name) => name !== 'root');
187
+ const hasActionableError = Array.from(formElement.querySelectorAll('input, textarea, select, button, [tabindex]')).some((control) => {
188
+ const name = control.getAttribute('name');
189
+ const invalid = control.getAttribute('aria-invalid') === 'true' ||
190
+ (name !== null &&
191
+ invalidNames.some((field) => name === field || name.startsWith(`${field}.`)));
192
+ if (!invalid ||
193
+ control.matches(':disabled, input[type="hidden"]') ||
194
+ control.closest('[hidden], [inert], [aria-hidden="true"]') ||
195
+ control.getClientRects().length === 0) {
196
+ return false;
197
+ }
198
+ for (let element = control; element; element = element.parentElement) {
199
+ const style = getComputedStyle(element);
200
+ if (style.display === 'none' || style.visibility === 'hidden')
201
+ return false;
202
+ if (element === formElement)
203
+ break;
204
+ }
205
+ return true;
206
+ });
207
+ if (hasActionableError)
208
+ return;
209
+ summary.focus({ preventScroll: true });
210
+ summary.scrollIntoView({ block: 'center', behavior: 'smooth' });
211
+ }, [errors, submitCount, submissionError, rootKey]);
125
212
  const isDirtyForBlocking = isDirty && hasUserInteracted;
126
213
  // Create: prefill reference fields named in the URL (`?brandId=…`, from a nested
127
214
  // EntityList's add button). After mount, client-only (no Suspense / hydration
@@ -133,6 +220,8 @@ function EntityFormRendererCore({ entity, onSubmit, t, className = '', submitTex
133
220
  prefilled.current = true;
134
221
  const prefill = referencePrefillFromQuery(entity, new URLSearchParams(window.location.search), viewerRole);
135
222
  for (const [field, value] of Object.entries(prefill)) {
223
+ // why: prefill keys are reference fields the form writes on create
224
+ // (referencePrefillFromQuery), values record ids
136
225
  setValue(field, value);
137
226
  }
138
227
  }, [operation, entity, viewerRole, setValue]);
@@ -174,25 +263,22 @@ function EntityFormRendererCore({ entity, onSubmit, t, className = '', submitTex
174
263
  navigate('back');
175
264
  }
176
265
  };
177
- // Wrap onSubmit to await the result before navigating
178
- // handleSubmit from react-hook-form expects: (data: EntityData) => void | Promise<void>
179
- // Our onSubmit prop is (data: T) => void | Promise<void>, where T extends EntityRecord
180
- // EntityData should be compatible with T, so we can safely pass it
266
+ // onSubmit receives the written fields (FormValues), not the whole row
181
267
  // No try/catch here — errors MUST propagate to useEntityForm's orchestrator
182
268
  // which properly calls setError() and does NOT clearDraft/reset.
183
- const handleFormSubmit = async (data) => {
184
- await onSubmit(data);
185
- // Navigate only when successPath is explicitly provided.
186
- // Edit: stay on page (most common UX). Create: consumer navigates
187
- // in onSubmit (knows the new ID) or provides successPath.
188
- if (successPath) {
189
- navigate(successPath);
269
+ // Leaving on save (successPath) is useEntityForm's job: it leaves before the
270
+ // write and returns on rejection.
271
+ // Without onSubmit, useEntityForm's default writer saves the record and the
272
+ // child rows joined to this form (nested EntityList on this record).
273
+ const handleFormSubmit = onSubmit
274
+ ? async (data) => {
275
+ await onSubmit(data);
190
276
  }
191
- };
277
+ : undefined;
192
278
  // Determine if cancel button should show
193
279
  // Show by default, hide only if cancelText is explicitly null
194
280
  const showCancelButton = cancelText !== null;
195
- const cancelButtonText = cancelText ?? tCrud('form.cancel', { defaultValue: 'Cancel' });
281
+ const cancelButtonText = cancelText ?? tCrud('form.cancel');
196
282
  // Common button container style (sticky footer)
197
283
  const buttonContainerStyle = {
198
284
  gridColumn: '1 / -1',
@@ -215,38 +301,33 @@ function EntityFormRendererCore({ entity, onSubmit, t, className = '', submitTex
215
301
  loadingText: uploadProgress < 100
216
302
  ? tCrud('form.uploading', {
217
303
  progress: Math.round(uploadProgress),
218
- defaultValue: `Uploading ${Math.round(uploadProgress)}%...`,
219
304
  })
220
- : tCrud('form.processing', { defaultValue: 'Processing...' }),
305
+ : tCrud('form.processing'),
221
306
  progress: uploadProgress,
222
307
  };
223
308
  }
224
309
  if (formStatus === 'validating') {
225
310
  return {
226
311
  loading: true,
227
- loadingText: tCrud('form.validating', {
228
- defaultValue: 'Validating...',
229
- }),
312
+ loadingText: tCrud('form.validating'),
230
313
  };
231
314
  }
232
315
  if (formStatus === 'submitting') {
233
316
  return {
234
317
  loading: true,
235
- loadingText: tCrud('form.saving', { defaultValue: 'Saving...' }),
318
+ loadingText: tCrud('form.saving'),
236
319
  };
237
320
  }
238
321
  if (formStatus === 'success') {
239
322
  return {
240
323
  loading: false,
241
- successText: tCrud('form.saved', { defaultValue: 'Saved' }),
324
+ successText: tCrud('form.saved'),
242
325
  };
243
326
  }
244
327
  if (formStatus === 'error') {
245
328
  return {
246
329
  loading: false,
247
- errorText: tCrud('form.error', {
248
- defaultValue: 'Error — try again',
249
- }),
330
+ errorText: tCrud('form.error'),
250
331
  };
251
332
  }
252
333
  return { loading: false };
@@ -256,26 +337,26 @@ function EntityFormRendererCore({ entity, onSubmit, t, className = '', submitTex
256
337
  width: '100%',
257
338
  gridColumn: '1 / -1',
258
339
  display: 'contents',
259
- }, children: [isLoading && _jsx(Spinner, { overlay: true }), _jsxs("form", { onSubmit: (e) => {
260
- console.log('[EntityFormRenderer] native form onSubmit event', {
261
- defaultPrevented: e.defaultPrevented,
262
- });
263
- return handleSubmit(handleFormSubmit)(e);
264
- }, noValidate: true, className: className, style: { width: '100%', gridColumn: '1 / -1', display: 'contents' }, children: [renderableFields.map(({ name, config, editable }) => {
340
+ }, children: [isLoading && _jsx(Spinner, { overlay: true }), _jsxs("form", { ref: formRef, id: formId, onSubmit: (e) => {
341
+ // The orchestrator records failure and preserves the draft before
342
+ // rethrowing. Consume only the final DOM event promise, never the
343
+ // consumer callback's rejection (which must remain a failure).
344
+ void handleSubmit(handleFormSubmit)(e).catch(() => { });
345
+ }, noValidate: true, className: className, style: { width: '100%', gridColumn: '1 / -1', display: 'contents' }, children: [hasErrors && (_jsx("div", { ref: summaryRef, tabIndex: -1, "aria-label": tCrud('form.error'), style: errorSummaryStyle, children: _jsxs(Alert, { variant: "error", title: tCrud(errorFields.length > 0 ? 'form.validationFailed' : 'form.error'), children: [errorFields.length > 0 && (_jsx("p", { children: tCrud('form.fixFields', {
346
+ fields: errorFields
347
+ .map((name) => translateFieldLabel(name, entity.fields[name], translate))
348
+ .join(', '),
349
+ }) })), rootMessages.map((message, index) => (_jsx("p", { children: translate(message) }, index))), submissionError && _jsx("p", { children: translate(submissionError) })] }) })), renderableFields.map(({ name, config, editable, written }) => {
265
350
  // Evaluate dynamic conditions for this field
266
351
  const cond = fieldConditions[name];
267
352
  if (cond && !cond.visible)
268
353
  return null;
269
354
  // Apply condition overrides to field config
270
- const effectiveConfig = cond
355
+ const effectiveConfig = cond && config.conditions?.required !== undefined
271
356
  ? {
272
357
  ...config,
273
- // Merge dynamic required into validation (condition overrides static)
274
- ...(cond.required && config.validation
275
- ? { validation: { ...config.validation, required: true } }
276
- : cond.required
277
- ? { validation: { required: true } }
278
- : {}),
358
+ // An explicit condition overrides static required in BOTH directions.
359
+ validation: { ...config.validation, required: cond.required },
279
360
  }
280
361
  : config;
281
362
  // Condition-based disabled/readonly override editability
@@ -287,10 +368,10 @@ function EntityFormRendererCore({ entity, onSubmit, t, className = '', submitTex
287
368
  : undefined;
288
369
  const badgeLabel = roleLabels[config.visibility] ??
289
370
  config.visibility;
290
- // Wrap field with visibility badge when enabled
291
- const fieldElement = !effectiveEditable ? (_jsx(FormDisplayField, { name: name, config: effectiveConfig,
292
- // why: RHF Control<T> is invariant in T; FormDisplayField reads by string name, so it takes the erased Control<FieldValues>
293
- control: control, t: translate }, name)) : (_jsx(FormFieldRenderer, { name: name, config: effectiveConfig, control: control, t: translate }, name));
371
+ // Read-only: a field the form writes from form state (computed, or an
372
+ // input disabled by a condition), any other from the stored row
373
+ // (technical, editable: false, role-denied: never in form state).
374
+ const fieldElement = !effectiveEditable ? (written ? (_jsx(FormDisplayField, { name: name, config: effectiveConfig, control: control, t: translate }, name)) : (_jsx(DisplayFieldRenderer, { name: name, config: effectiveConfig, value: recordValue(form.record, name), t: translate }, name))) : (_jsx(FormFieldRenderer, { name: name, config: effectiveConfig, control: control, t: translate }, name));
294
375
  // If no badge needed, return field directly
295
376
  if (!showBadge)
296
377
  return fieldElement;
@@ -307,33 +388,34 @@ function EntityFormRendererCore({ entity, onSubmit, t, className = '', submitTex
307
388
  const buttons = [];
308
389
  // Cancel button
309
390
  if (showCancelButton && cancelButtonText) {
310
- buttons.push(_jsx(Button, { type: "button", onClick: handleCancel, disabled: buttonState.loading, variant: "outline", className: "dndev-w-full", children: cancelButtonText }, "cancel"));
391
+ buttons.push(_jsx(Button, { type: "button", intent: "cancel", onClick: handleCancel, disabled: buttonState.loading, variant: "outline", className: "dndev-w-full", children: cancelButtonText }, "cancel"));
311
392
  }
312
393
  // Preview dropdown (user/admin/super only)
313
394
  if (canPreviewRole) {
314
395
  const previewVariant = visibilityBadgeVariant[previewRole] || 'muted';
315
- buttons.push(_jsx(DropdownMenu, { trigger: _jsxs(Button, { type: "button", variant: previewVariant, disabled: buttonState.loading, className: "dndev-w-full", children: [tCrud('visibility.preview', {
316
- defaultValue: 'Preview',
317
- }), ": ", roleLabels[previewRole]] }), items: previewMenuItems }, "preview"));
396
+ buttons.push(_jsx(DropdownMenu, { trigger: _jsxs(Button, { type: "button", intent: "preview", variant: previewVariant, disabled: buttonState.loading, className: "dndev-w-full", children: [tCrud('visibility.preview'), ": ", roleLabels[previewRole]] }), items: previewMenuItems }, "preview"));
318
397
  }
319
398
  // Secondary submit button
320
399
  if (secondaryButtonText) {
321
400
  buttons.push(_jsx(Button, { type: "button", onClick: () => {
322
401
  if (onSecondarySubmit) {
402
+ // why: form state is typed for both operations (EntityFormState); at
403
+ // runtime it is the projection for this form's Op (the fields it
404
+ // writes), the shape onSubmit receives, not validated.
323
405
  const currentValues = form.getValues();
324
406
  onSecondarySubmit(currentValues);
325
407
  }
326
408
  }, loading: buttonState.loading, loadingText: buttonState.loadingText, progress: buttonState.progress, variant: secondaryButtonVariant, className: "dndev-w-full", children: secondaryButtonText }, "secondary"));
327
409
  }
328
410
  // Primary submit button (always shown)
329
- buttons.push(_jsx(Button, { type: "submit", loading: buttonState.loading, loadingText: buttonState.loadingText, progress: buttonState.progress, variant: buttonState.successText
411
+ buttons.push(_jsx(Button, { type: "submit", intent: "save", loading: buttonState.loading, loadingText: buttonState.loadingText, progress: buttonState.progress, variant: buttonState.successText
330
412
  ? 'success'
331
413
  : buttonState.errorText
332
414
  ? 'destructive'
333
415
  : submitVariant, disabled: !!buttonState.successText, className: "dndev-w-full", children: buttonState.successText ||
334
416
  buttonState.errorText ||
335
417
  submitText ||
336
- tCrud('form.submit', { defaultValue: 'Submit' }) }, "submit"));
418
+ tCrud('form.submit') }, "submit"));
337
419
  const buttonCount = buttons.length;
338
420
  // Single button: use Stack
339
421
  if (buttonCount === 1) {
@@ -9,6 +9,8 @@ export type { EntityListProps };
9
9
  * - Excel-like table display with formatted values
10
10
  * - Open-link icon per row, bulk select, bulk delete of the checked rows
11
11
  * - Auto-routing when handlers not provided
12
+ * - With `parent`, `editable` (default) and an edit form open on that record:
13
+ * joined to the form (`useChildRows`), saved by its Save
12
14
  */
13
- export declare function EntityList({ entity, basePath, onClick, hideFilters, pagination, pageSize: pageSizeProp, queryOptions, exportable, editable, parent, preview, tone, }: EntityListProps): import("react").JSX.Element | null;
15
+ export declare function EntityList(props: EntityListProps): import("react").JSX.Element | null;
14
16
  //# sourceMappingURL=EntityList.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"EntityList.d.ts","sourceRoot":"","sources":["../../../src/crud/components/EntityList.tsx"],"names":[],"mappings":"AA2CA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAmBtD,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,QAAe,EACf,MAAM,EACN,OAAO,EACP,IAAI,GACL,EAAE,eAAe,sCA2YjB"}
1
+ {"version":3,"file":"EntityList.d.ts","sourceRoot":"","sources":["../../../src/crud/components/EntityList.tsx"],"names":[],"mappings":"AA6DA,OAAO,KAAK,EAGV,eAAe,EAChB,MAAM,gBAAgB,CAAC;AAwBxB,YAAY,EAAE,eAAe,EAAE,CAAC;AAsFhC;;;;;;;;;;;GAWG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,sCAwBhD"}