ding-react-admin 1.0.4 → 2.0.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 (112) hide show
  1. package/README.md +4 -10
  2. package/dist/index.js +1071 -803
  3. package/dist/src/crud/InlineFormSet.d.ts +2 -17
  4. package/dist/src/crud/InlineFormSet.d.ts.map +1 -1
  5. package/dist/src/crud/ResourceForm.d.ts +4 -9
  6. package/dist/src/crud/ResourceForm.d.ts.map +1 -1
  7. package/dist/src/crud/ResourceList.d.ts.map +1 -1
  8. package/dist/src/crud/columns/ImageColumn.d.ts +14 -0
  9. package/dist/src/crud/columns/ImageColumn.d.ts.map +1 -0
  10. package/dist/src/crud/context/InlineFieldsRegistry.d.ts +15 -0
  11. package/dist/src/crud/context/InlineFieldsRegistry.d.ts.map +1 -0
  12. package/dist/src/crud/context/PayloadFieldsContext.d.ts +18 -0
  13. package/dist/src/crud/context/PayloadFieldsContext.d.ts.map +1 -0
  14. package/dist/src/crud/fields/FileField.d.ts +12 -0
  15. package/dist/src/crud/fields/FileField.d.ts.map +1 -0
  16. package/dist/src/crud/fields/ImageField.d.ts +14 -0
  17. package/dist/src/crud/fields/ImageField.d.ts.map +1 -0
  18. package/dist/src/crud/fields/uploadFieldUtils.d.ts +5 -0
  19. package/dist/src/crud/fields/uploadFieldUtils.d.ts.map +1 -0
  20. package/dist/src/crud/fields/useUploadPreviewUrl.d.ts +4 -0
  21. package/dist/src/crud/fields/useUploadPreviewUrl.d.ts.map +1 -0
  22. package/dist/src/crud/index.d.ts +22 -9
  23. package/dist/src/crud/index.d.ts.map +1 -1
  24. package/dist/src/crud/types.d.ts +9 -7
  25. package/dist/src/crud/types.d.ts.map +1 -1
  26. package/dist/src/crud/utils/buildFormPayload.d.ts +6 -0
  27. package/dist/src/crud/utils/buildFormPayload.d.ts.map +1 -0
  28. package/dist/src/crud/utils/buildInlineRowsPayload.d.ts +6 -0
  29. package/dist/src/crud/utils/buildInlineRowsPayload.d.ts.map +1 -0
  30. package/dist/src/crud/utils/buildResourceFormSubmitBody.d.ts +5 -0
  31. package/dist/src/crud/utils/buildResourceFormSubmitBody.d.ts.map +1 -0
  32. package/dist/src/crud/utils/formErrors.d.ts +1 -1
  33. package/dist/src/crud/utils/formErrors.d.ts.map +1 -1
  34. package/dist/src/crud/utils/getFormValue.d.ts +3 -0
  35. package/dist/src/crud/utils/getFormValue.d.ts.map +1 -0
  36. package/dist/src/crud/utils/hasUploadValues.d.ts +3 -0
  37. package/dist/src/crud/utils/hasUploadValues.d.ts.map +1 -0
  38. package/dist/src/crud/utils/nestedFieldPath.d.ts +3 -0
  39. package/dist/src/crud/utils/nestedFieldPath.d.ts.map +1 -0
  40. package/dist/src/crud/utils/prepareFormSubmitBody.d.ts +7 -0
  41. package/dist/src/crud/utils/prepareFormSubmitBody.d.ts.map +1 -0
  42. package/dist/src/crud/utils/setFormValue.d.ts +3 -0
  43. package/dist/src/crud/utils/setFormValue.d.ts.map +1 -0
  44. package/dist/src/crud/utils/toFormData.d.ts +13 -0
  45. package/dist/src/crud/utils/toFormData.d.ts.map +1 -0
  46. package/dist/src/crud/utils/useFormRecord.d.ts +42 -0
  47. package/dist/src/crud/utils/useFormRecord.d.ts.map +1 -0
  48. package/dist/src/data/createRestResourceHandlers.d.ts +5 -5
  49. package/dist/src/data/createRestResourceHandlers.d.ts.map +1 -1
  50. package/dist/src/data/dataProviderTypes.d.ts +6 -5
  51. package/dist/src/data/dataProviderTypes.d.ts.map +1 -1
  52. package/dist/src/data/parseFormErrorHelpers.d.ts +44 -6
  53. package/dist/src/data/parseFormErrorHelpers.d.ts.map +1 -1
  54. package/dist/src/data/resourceHandlers.d.ts +1 -1
  55. package/dist/src/data/resourceHandlers.d.ts.map +1 -1
  56. package/dist/src/index.d.ts +4 -4
  57. package/dist/src/index.d.ts.map +1 -1
  58. package/dist/src/layouts/AdminLayout.d.ts.map +1 -1
  59. package/package.json +1 -1
  60. package/src/crud/InlineFormSet.tsx +28 -85
  61. package/src/crud/ResourceForm.tsx +60 -66
  62. package/src/crud/ResourceFormModal.tsx +25 -25
  63. package/src/crud/ResourceList.tsx +1 -0
  64. package/src/crud/columns/ImageColumn.tsx +58 -0
  65. package/src/crud/columns/TextColumn.tsx +2 -2
  66. package/src/crud/context/InlineFieldsRegistry.tsx +61 -0
  67. package/src/crud/context/PayloadFieldsContext.tsx +62 -0
  68. package/src/crud/fields/FieldWrapper.tsx +87 -87
  69. package/src/crud/fields/FileField.tsx +123 -0
  70. package/src/crud/fields/ImageField.tsx +120 -0
  71. package/src/crud/fields/uploadFieldUtils.ts +21 -0
  72. package/src/crud/fields/useUploadPreviewUrl.ts +20 -0
  73. package/src/crud/index.ts +23 -19
  74. package/src/crud/types.ts +9 -7
  75. package/src/crud/utils/buildFormPayload.ts +24 -0
  76. package/src/crud/utils/buildInlineRowsPayload.ts +37 -0
  77. package/src/crud/utils/buildResourceFormSubmitBody.ts +29 -0
  78. package/src/crud/utils/formErrors.ts +42 -38
  79. package/src/crud/utils/{getByPath.ts → getFormValue.ts} +2 -2
  80. package/src/crud/utils/hasUploadValues.ts +9 -0
  81. package/src/crud/utils/nestedFieldPath.ts +8 -0
  82. package/src/crud/utils/prepareFormSubmitBody.ts +17 -0
  83. package/src/crud/utils/{setByPath.ts → setFormValue.ts} +2 -2
  84. package/src/crud/utils/toFormData.ts +81 -0
  85. package/src/crud/utils/useFormRecord.ts +156 -0
  86. package/src/data/createRestResourceHandlers.ts +19 -13
  87. package/src/data/dataProviderTypes.ts +7 -5
  88. package/src/data/dataUtils.test.ts +118 -6
  89. package/src/data/parseFormErrorHelpers.test.ts +138 -84
  90. package/src/data/parseFormErrorHelpers.ts +311 -224
  91. package/src/data/resourceHandlers.ts +1 -1
  92. package/src/index.ts +23 -11
  93. package/src/layouts/AdminLayout.tsx +2 -1
  94. package/dist/src/crud/context/SubmitFieldsContext.d.ts +0 -18
  95. package/dist/src/crud/context/SubmitFieldsContext.d.ts.map +0 -1
  96. package/dist/src/crud/utils/getByPath.d.ts +0 -3
  97. package/dist/src/crud/utils/getByPath.d.ts.map +0 -1
  98. package/dist/src/crud/utils/inlineArrayName.d.ts +0 -3
  99. package/dist/src/crud/utils/inlineArrayName.d.ts.map +0 -1
  100. package/dist/src/crud/utils/inlineFieldName.d.ts +0 -3
  101. package/dist/src/crud/utils/inlineFieldName.d.ts.map +0 -1
  102. package/dist/src/crud/utils/pickBySources.d.ts +0 -6
  103. package/dist/src/crud/utils/pickBySources.d.ts.map +0 -1
  104. package/dist/src/crud/utils/setByPath.d.ts +0 -3
  105. package/dist/src/crud/utils/setByPath.d.ts.map +0 -1
  106. package/dist/src/crud/utils/useResourceFormData.d.ts +0 -47
  107. package/dist/src/crud/utils/useResourceFormData.d.ts.map +0 -1
  108. package/src/crud/context/SubmitFieldsContext.tsx +0 -62
  109. package/src/crud/utils/inlineArrayName.ts +0 -4
  110. package/src/crud/utils/inlineFieldName.ts +0 -8
  111. package/src/crud/utils/pickBySources.ts +0 -24
  112. package/src/crud/utils/useResourceFormData.ts +0 -231
@@ -1 +1 @@
1
- {"version":3,"file":"dataProviderTypes.d.ts","sourceRoot":"","sources":["../../../src/data/dataProviderTypes.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,MAAM,CAAC;AAEzC,MAAM,MAAM,SAAS,GAAG,KAAK,GAAG,MAAM,CAAC;AAEvC,MAAM,MAAM,QAAQ,GAAG;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,SAAS,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,4FAA4F;IAC5F,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,UAAU,CAAC,EA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tB,UAAU,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAClE;IACF,OAAO,EAAE,CACP,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,aAAa,KAClB,OAAO,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC,CAAC;IACxC,MAAM,EAAE,CACN,QAAQ,EAAE,MAAM,EAChB,EAAE,EAAE,UAAU,EACd,MAAM,CAAC,EAAE,YAAY,KAClB,OAAO,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC,CAAC;IACvC,MAAM,EAAE,CACN,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,OAAO,CAAC,UAAU,CAAC,GAAG,QAAQ,KACjC,OAAO,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC,CAAC;IACvC,MAAM,EAAE,CACN,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,YAAY,CAAC,UAAU,CAAC,KAC7B,OAAO,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC,CAAC;IACvC,MAAM,EAAE,CACN,QAAQ,EAAE,MAAM,EAChB,EAAE,EAAE,UAAU,KACX,OAAO,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC,CAAC;IACvC,+DAA+D;IAC/D,cAAc,CAAC,EAAE,cAAc,CAAC;CACjC,CAAC"}
@@ -1,14 +1,44 @@
1
1
  import { FormValidationErrors, ParseFormErrorContext } from './dataProviderTypes';
2
2
  export declare function asStringMessages(value: unknown): string[];
3
- /** Read JSON from `throw { body }` or axios-style `{ response: { data } }`. */
3
+ /**
4
+
5
+ * Read a parsed JSON validation body when it is already available on the error.
6
+
7
+ *
8
+
9
+ * Supported transport shapes (sync only):
10
+
11
+ * - `{ body: { email: ["…"] } }` — explicit throw from a handler
12
+
13
+ * - `{ response: { data: { email: ["…"] } } }` — axios-style wrappers
14
+
15
+ * - `{ data: { email: ["…"] } }` — some HTTP clients attach parsed JSON here
16
+
17
+ *
18
+
19
+ * For fetch / OpenAPI clients that only expose a `Response`, use `resolveErrorBody`.
20
+
21
+ */
4
22
  export declare function getErrorBody(error: unknown): Record<string, unknown> | null;
5
- export declare function applyInlineFieldPaths(fields: Record<string, string | string[]>, ctx: ParseFormErrorContext): Record<string, string | string[]>;
6
- export declare function finalizeFormErrors(fields: Record<string, string | string[]>, global: string[], ctx: ParseFormErrorContext): FormValidationErrors;
7
23
  /**
24
+
25
+ * Resolve a validation JSON body from any common HTTP client error shape.
26
+
27
+ * Falls back to reading `response.json()` for fetch / OpenAPI `ResponseError`.
28
+
29
+ */
30
+ export declare function resolveErrorBody(error: unknown): Promise<Record<string, unknown> | null>;
31
+ /** Map `{ lines: [{ label: ["…"] }] }` → `{ "lines.0.label": "…" }`. */
32
+ export declare function flattenNestedArrayErrors(arrayKey: string, rows: unknown[], fields: Record<string, string | string[]>): void;
33
+ export declare function finalizeFormErrors(fields: Record<string, string | string[]>, global: string[]): FormValidationErrors;
34
+ /**
35
+
8
36
  * Django REST framework validation body:
37
+
9
38
  * `{ "email": ["Invalid"], "non_field_errors": ["…"] }`
39
+
10
40
  */
11
- export declare function parseDjangoDRFFormErrors(error: unknown, ctx: ParseFormErrorContext): FormValidationErrors | null;
41
+ export declare function parseDjangoDRFFormErrors(error: unknown, _ctx: ParseFormErrorContext): FormValidationErrors | null;
12
42
  export type DotNetFormErrorOptions = {
13
43
  /** Map API property names to form `source` paths. */
14
44
  fieldMap?: Record<string, string>;
@@ -18,18 +48,26 @@ export type DotNetFormErrorOptions = {
18
48
  includeSummary?: boolean;
19
49
  };
20
50
  /**
51
+
21
52
  * ASP.NET Core `ValidationProblemDetails`:
53
+
22
54
  * `{ "errors": { "Email": ["The Email field is required."] } }`
55
+
23
56
  */
24
- export declare function parseDotNetFormErrors(error: unknown, ctx: ParseFormErrorContext, options?: DotNetFormErrorOptions): FormValidationErrors | null;
57
+ export declare function parseDotNetFormErrors(error: unknown, _ctx: ParseFormErrorContext, options?: DotNetFormErrorOptions): FormValidationErrors | null;
25
58
  export type NodeFormErrorOptions = {
26
59
  fieldMap?: Record<string, string>;
27
60
  };
28
61
  /**
62
+
29
63
  * Common Node / Express shapes:
64
+
30
65
  * - `{ errors: { email: ["Invalid"] } }`
66
+
31
67
  * - `{ errors: [{ path: "email", msg: "Invalid" }] }` (express-validator)
68
+
32
69
  * - `{ details: [{ message: "…", path: ["email"] }] }` (Joi)
70
+
33
71
  */
34
- export declare function parseNodeFormErrors(error: unknown, ctx: ParseFormErrorContext, options?: NodeFormErrorOptions): FormValidationErrors | null;
72
+ export declare function parseNodeFormErrors(error: unknown, _ctx: ParseFormErrorContext, options?: NodeFormErrorOptions): FormValidationErrors | null;
35
73
  //# sourceMappingURL=parseFormErrorHelpers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"parseFormErrorHelpers.d.ts","sourceRoot":"","sources":["../../../src/data/parseFormErrorHelpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,qBAAqB,EACtB,MAAM,qBAAqB,CAAC;AAE7B,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,EAAE,CAOzD;AAMD,+EAA+E;AAC/E,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAc3E;AAED,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,EACzC,GAAG,EAAE,qBAAqB,GACzB,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAQnC;AAED,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,EACzC,MAAM,EAAE,MAAM,EAAE,EAChB,GAAG,EAAE,qBAAqB,GACzB,oBAAoB,CAMtB;AAID;;;GAGG;AACH,wBAAgB,wBAA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void;
8
8
  export type ResourceHandlers<RecordType extends Record<string, unknown> = Record<string, unknown>> = {
9
9
  getList: (params: GetListParams) => Promise<GetListResult<RecordType>>;
10
10
  getOne: (id: Identifier, params?: GetOneParams) => Promise<GetOneResult<RecordType>>;
11
- create: (data: Partial<RecordType>) => Promise<CreateResult<RecordType>>;
11
+ create: (data: Partial<RecordType> | FormData) => Promise<CreateResult<RecordType>>;
12
12
  update: (params: UpdateParams<RecordType>) => Promise<UpdateResult<RecordType>>;
13
13
  delete: (id: Identifier) => Promise<DeleteResult<RecordType>>;
14
14
  };
@@ -1 +1 @@
1
- {"version":3,"file":"resourceHandlers.d.ts","sourceRoot":"","sources":["../../../src/data/resourceHandlers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACzE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAE9E,OAAO,KAAK,EACV,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,cAAc,EACd,YAAY,EACZ,YAAY,EACb,MAAM,qBAAqB,CAAC;AAE7B,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAE3E,gGAAgG;AAChG,MAAM,MAAM,aAAa,GAAG,CAC1B,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,cAAc,KACnB,IAAI,CAAC;AAEV,6EAA6E;AAC7E,MAAM,MAAM,gBAAgB,CAC1B,UAAU,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAClE;IACF,OAAO,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,OAAO,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC,CAAC;IACvE,MAAM,EAAE,CAAC,EAAE,EAAE,UAAU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;AAEtE,MAAM,MAAM,8BAA8B,GAAG;IAC3C,0DAA0D;IAC1D,GAAG,CAAC,EAAE,kBAAkB,CAAC;IACzB,kEAAkE;IAClE,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,yEAAyE;IACzE,cAAc,CAAC,EAAE,cAAc,CAAC;CACjC,CAAC;AAqBF;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,kBAAkB,EAC5B,OAAO,CAAC,EAAE,8BAA8B,GACvC,YAAY,CA0Cd"}
@@ -4,10 +4,10 @@ export { AuthProvider, createSessionStorageAuthAdapter, useAuth, type AuthProvid
4
4
  export { DataProvider, useDataProvider, type DataProviderProps, } from './context/DataProvider';
5
5
  export { PermissionsProvider, createPermissionsChecker, useCan, usePermissions, type PermissionsProviderProps, } from './context/PermissionsProvider';
6
6
  export { AppThemeProvider, useThemeMode, } from './context/AppThemeProvider';
7
- export type { CreateResult, DataProvider as DataProviderContract, DeleteResult, GetListParams, GetListResult, GetOneParams, GetOneResult, Identifier, PaginationParams, SortOrder, SortSpec, UpdateParams, UpdateResult, FormMutation, FormValidationErrors, ParseFormError, ParseFormErrorContext, } from './data/dataProviderTypes';
7
+ export type { CreateResult, DataProvider as DataProviderContract, DeleteResult, GetListParams, GetListResult, GetOneParams, GetOneResult, Identifier, PaginationParams, SortOrder, SortSpec, UpdateParams, UpdateResult, FormMutation, FormMutationBody, FormValidationErrors, ParseFormError, ParseFormErrorContext, } from './data/dataProviderTypes';
8
8
  export { combineResourceHandlers } from './data/resourceHandlers';
9
9
  export { isAbortError } from './data/abortError';
10
- export { parseDjangoDRFFormErrors, parseDotNetFormErrors, parseNodeFormErrors, getErrorBody, applyInlineFieldPaths, asStringMessages, finalizeFormErrors, } from './data/parseFormErrorHelpers';
10
+ export { parseDjangoDRFFormErrors, parseDotNetFormErrors, parseNodeFormErrors, getErrorBody, resolveErrorBody, flattenNestedArrayErrors, asStringMessages, finalizeFormErrors, } from './data/parseFormErrorHelpers';
11
11
  export type { DotNetFormErrorOptions, NodeFormErrorOptions, } from './data/parseFormErrorHelpers';
12
12
  export { createMemoryResourceHandlers } from './data/createMemoryResourceHandlers';
13
13
  export { createRestResourceHandlers } from './data/createRestResourceHandlers';
@@ -27,6 +27,6 @@ export { Guard, GuestOnly, Protected, RequirePermission } from './router/guards'
27
27
  export { createAdminRouter } from './router/createAdminRouter';
28
28
  export { deriveAuthPaths, getRouteAccess, partitionAdminRoutes, } from './router/routeAccess';
29
29
  export type { AdminAppProps, AdminLayoutProps, AdminRouteChild, AppThemeProviderProps, AuthAdapter, LoginCredentials, AuthRedirects, CreateAdminRouterOptions, AuthAlternateLinkProps, AuthPageLayoutProps, LoginPageProps, NavItem, RouteAccess, ThemeDensity, ThemeMode, } from './types';
30
- export { ResourceList, FilterBar, ResourceForm, ResourceFormModal, InlineFormSet, InlineFormSetStacked, FormTabs, FormTab, FormSteps, FormStep, saveInlineRows, loadInlineRows, TextField, NumberField, BooleanField, DateField, SelectField, PasswordField, ReferenceField, ReferenceManyField, FieldWrapper, TextColumn, NumberColumn, BooleanColumn, DateColumn, ReferenceColumn, ReferenceManyColumn, CustomColumn, TextFilter, NumberFilter, BooleanFilter, DateFilter, SelectFilter, ReferenceFilter, ReferenceManyFilter, useListQueryState, useChoices, useAbortableEffect, getByPath, pickBySources, inlineArrayName, inlineFieldName, useResourceListContext, useSubmitField, useSectionField, } from './crud';
31
- export type { ResourceFormProps, ResourceFormInlineConfig, ResourceFormModalProps, InlineFormSetProps, InlineFormSetStackedProps, FormTabsProps, FormTabProps, FormStepsProps, FormStepProps, SaveInlineOptions, InlineFormSetLayout, ResourceListProps, BaseSourceProps, ChoiceOption, ChoicesLoader, ReferenceProps, DisplayProps, EditMode, FieldRules, InlineCellContext, InlineColumnDef, InlineFormSetBaseProps, InlineRowContext, FieldWrapperProps, ResourceListBuiltInActions, ResourceListBulkAction, ResourceListBulkActionHelpers, ResourceListRowActionsHelpers, ListQueryState, ListQueryActions, } from './crud';
30
+ export { ResourceList, FilterBar, ResourceForm, ResourceFormModal, InlineFormSet, InlineFormSetStacked, FormTabs, FormTab, FormSteps, FormStep, TextField, NumberField, BooleanField, DateField, SelectField, PasswordField, ReferenceField, ReferenceManyField, ImageField, FileField, FieldWrapper, TextColumn, NumberColumn, BooleanColumn, DateColumn, ReferenceColumn, ReferenceManyColumn, ImageColumn, CustomColumn, TextFilter, NumberFilter, BooleanFilter, DateFilter, SelectFilter, ReferenceFilter, ReferenceManyFilter, useListQueryState, useChoices, useAbortableEffect, getFormValue, setFormValue, buildFormPayload, buildInlineRowsPayload, buildResourceFormSubmitBody, prepareFormSubmitBody, toFormData, hasUploadValues, nestedFieldPath, useResourceListContext, useRegisterPayloadField, useRegisterSectionField, } from './crud';
31
+ export type { ResourceFormProps, ResourceFormModalProps, InlineFormSetProps, InlineFormSetStackedProps, FormTabsProps, FormTabProps, FormStepsProps, FormStepProps, InlineFormSetLayout, ResourceListProps, BaseSourceProps, ChoiceOption, ChoicesLoader, ReferenceProps, DisplayProps, EditMode, FieldRules, InlineCellContext, InlineColumnDef, InlineFormSetBaseProps, InlineRowContext, InlineFieldRegistration, FieldWrapperProps, ImageFieldProps, FileFieldProps, UploadFieldValue, ToFormDataOptions, PrepareFormSubmitBodyOptions, ResourceListBuiltInActions, ResourceListBulkAction, ResourceListBulkActionHelpers, ResourceListRowActionsHelpers, ListQueryState, ListQueryActions, } from './crud';
32
32
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EACL,YAAY,EACZ,+BAA+B,EAC/B,OAAO,EACP,KAAK,iBAAiB,GACvB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,YAAY,EACZ,eAAe,EACf,KAAK,iBAAiB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,EACb,UAAU,EACV,YAAY,EACZ,eAAe,EACf,mBAAmB,EACnB,iBAAiB,EACjB,UAAU,EACV,kBAAkB,EAClB,SAAS,EACT,aAAa,EACb,eAAe,EACf,eAAe,EACf,sBAAsB,EACtB,cAAc,EACd,eAAe,GAChB,MAAM,QAAQ,CAAC;AAChB,YAAY,EACV,iBAAiB,EACjB,wBAAwB,EACxB,sBAAsB,EACtB,kBAAkB,EAClB,yBAAyB,EACzB,aAAa,EACb,YAAY,EACZ,cAAc,EACd,aAAa,EACb,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,EACjB,eAAe,EACf,YAAY,EACZ,aAAa,EACb,cAAc,EACd,YAAY,EACZ,QAAQ,EACR,UAAU,EACV,iBAAiB,EACjB,eAAe,EACf,sBAAsB,EACtB,gBAAgB,EAChB,iBAAiB,EACjB,0BAA0B,EAC1B,sBAAsB,EACtB,6BAA6B,EAC7B,6BAA6B,EAC7B,cAAc,EACd,gBAAgB,GACjB,MAAM,QAAQ,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EACL,YAAY,EACZ,+BAA+B,EAC/B,OAAO,EACP,KAAK,iBAAiB,GACvB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,YAAY,EACZ,eAAe,EACf,KAAK,iBAAiB,GACvB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,mBAAmB,EACnB,wBAAwB,EACxB,MAAM,EACN,cAAc,EACd,KAAK,wBAAwB,GAC9B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,gBAAgB,EAChB,YAAY,GACb,MAAM,4BAA4B,CAAC;AACpC,YAAY,EACV,YAAY,EACZ,YAAY,IAAI,oBAAoB,EACpC,YAAY,EACZ,aAAa,EACb,aAAa,EAC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GACxB,MAAM,QAAQ,CAAC;AAChB,YAAY,EACV,iBAAiB,EACjB,sBAAsB,EACtB,kBAAkB,EAClB,yBAAyB,EACzB,aAAa,EACb,YAAY,EACZ,cAAc,EACd,aAAa,EACb,mBAAmB,EACnB,iBAAiB,EACjB,eAAe,EACf,YAAY,EACZ,aAAa,EACb,cAAc,EACd,YAAY,EACZ,QAAQ,EACR,UAAU,EACV,iBAAiB,EACjB,eAAe,EACf,sBAAsB,EACtB,gBAAgB,EAChB,uBAAuB,EACvB,iBAAiB,EACjB,eAAe,EACf,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,4BAA4B,EAC5B,0BAA0B,EAC1B,sBAAsB,EACtB,6BAA6B,EAC7B,6BAA6B,EAC7B,cAAc,EACd,gBAAgB,GACjB,MAAM,QAAQ,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"AdminLayout.d.ts","sourceRoot":"","sources":["../../../src/layouts/AdminLayout.tsx"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,gBAAgB,EAAW,MAAM,UAAU,CAAC;AAyG1D,wBAAgB,WAAW,CAAC,EAC1B,QAAQ,EACR,KAAe,EACf,cAAoB,EACpB,iBAAiB,EACjB,YAAY,EACZ,aAAa,EACb,eAAe,EACf,SAAoB,EACpB,wBAA4C,GAC7C,EAAE,gBAAgB,2CAiPlB"}
1
+ {"version":3,"file":"AdminLayout.d.ts","sourceRoot":"","sources":["../../../src/layouts/AdminLayout.tsx"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,gBAAgB,EAAW,MAAM,UAAU,CAAC;AAyG1D,wBAAgB,WAAW,CAAC,EAC1B,QAAQ,EACR,KAAe,EACf,cAAoB,EACpB,iBAAiB,EACjB,YAAY,EACZ,aAAa,EACb,eAAe,EACf,SAAoB,EACpB,wBAA4C,GAC7C,EAAE,gBAAgB,2CAkPlB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ding-react-admin",
3
- "version": "1.0.4",
3
+ "version": "2.0.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "description": "Composable admin shell (Ant Design + React Router): quick-start AdminApp or build your own layout.",
@@ -1,15 +1,14 @@
1
1
  import { Button, Card, Space, Table, Typography } from "antd";
2
2
  import { useFieldArray, useFormContext, type FieldValues } from "react-hook-form";
3
3
  import { useMemo, type ReactNode } from "react";
4
- import type { Identifier } from "../data/dataProviderTypes";
5
- import type { DataProvider } from "../data/dataProviderTypes";
6
4
  import type {
7
5
  InlineColumnDef,
8
6
  InlineFormSetBaseProps,
9
7
  InlineRowContext,
10
8
  } from "./types";
11
- import { inlineArrayName as buildInlineArrayName } from "./utils/inlineArrayName";
12
- import { inlineFieldName } from "./utils/inlineFieldName";
9
+ import { nestedFieldPath } from "./utils/nestedFieldPath";
10
+ import { useRegisterInlineField } from "./context/InlineFieldsRegistry";
11
+ import { useRegisterPayloadField } from "./context/PayloadFieldsContext";
13
12
 
14
13
  export type InlineFormSetLayout = "tabular" | "stacked";
15
14
 
@@ -29,11 +28,12 @@ function emptyRow(sources: string[]) {
29
28
  return row;
30
29
  }
31
30
 
32
- function useInlineRows(arrayName: string, sources: string[]) {
31
+ function useInlineRows(field: string, sources: string[]) {
33
32
  const { control } = useFormContext<FieldValues>();
34
33
  const { fields, append, remove } = useFieldArray({
35
34
  control,
36
- name: arrayName,
35
+ name: field,
36
+ keyName: "rowKey",
37
37
  });
38
38
 
39
39
  const appendEmpty = () => append(emptyRow(sources));
@@ -43,17 +43,20 @@ function useInlineRows(arrayName: string, sources: string[]) {
43
43
 
44
44
  /** Tabular inline (Django TabularInline) — table with column headers. */
45
45
  export function InlineFormSet({
46
- resource,
46
+ field,
47
47
  label,
48
- name,
48
+ payloadKey,
49
+ transformRows,
49
50
  columns,
50
51
  }: InlineFormSetProps) {
51
- const arrayName = buildInlineArrayName(resource, name);
52
52
  const sources = useMemo(
53
53
  () => columns.map((col) => col.source),
54
54
  [columns],
55
55
  );
56
- const { fields, remove, appendEmpty } = useInlineRows(arrayName, sources);
56
+ const { fields, remove, appendEmpty } = useInlineRows(field, sources);
57
+
58
+ useRegisterPayloadField(field);
59
+ useRegisterInlineField(field, sources, payloadKey, transformRows);
57
60
 
58
61
  const tableColumns = useMemo(
59
62
  () =>
@@ -67,12 +70,12 @@ export function InlineFormSet({
67
70
  col.minWidth != null ? { style: { minWidth: col.minWidth } } : {},
68
71
  render: (_: unknown, __: unknown, index: number) =>
69
72
  col.cell({
70
- name: inlineFieldName(arrayName, index, col.source),
73
+ name: nestedFieldPath(field, index, col.source),
71
74
  index,
72
- arrayName,
75
+ field,
73
76
  }),
74
77
  })),
75
- [columns, arrayName],
78
+ [columns, field],
76
79
  );
77
80
 
78
81
  return (
@@ -82,7 +85,7 @@ export function InlineFormSet({
82
85
  size="small"
83
86
  pagination={false}
84
87
  scroll={{ x: "max-content" }}
85
- dataSource={fields.map((f) => ({ ...f, key: f.id }))}
88
+ dataSource={fields.map((f) => ({ ...f, key: f.rowKey }))}
86
89
  columns={[
87
90
  ...tableColumns,
88
91
  {
@@ -111,22 +114,25 @@ export function InlineFormSet({
111
114
 
112
115
  /** Stacked inline (Django StackedInline) — each row in a card with field labels. */
113
116
  export function InlineFormSetStacked({
114
- resource,
117
+ field,
115
118
  label,
116
- name,
119
+ payloadKey,
120
+ transformRows,
117
121
  sources,
118
122
  renderRow,
119
123
  }: InlineFormSetStackedProps) {
120
- const arrayName = buildInlineArrayName(resource, name);
121
- const { fields, remove, appendEmpty } = useInlineRows(arrayName, sources);
124
+ const { fields, remove, appendEmpty } = useInlineRows(field, sources);
125
+
126
+ useRegisterPayloadField(field);
127
+ useRegisterInlineField(field, sources, payloadKey, transformRows);
122
128
 
123
129
  return (
124
130
  <div style={{ marginTop: 24 }}>
125
131
  <Typography.Title level={5}>{label ?? "Related items"}</Typography.Title>
126
132
  <Space orientation="vertical" size="middle" style={{ width: "100%" }}>
127
- {fields.map((field, index) => (
133
+ {fields.map((rowField, index) => (
128
134
  <Card
129
- key={field.id}
135
+ key={rowField.rowKey}
130
136
  size="small"
131
137
  title={`Item ${index + 1}`}
132
138
  extra={
@@ -141,9 +147,9 @@ export function InlineFormSetStacked({
141
147
  }
142
148
  >
143
149
  {renderRow({
144
- arrayName,
150
+ field,
145
151
  index,
146
- name: (source) => inlineFieldName(arrayName, index, source),
152
+ name: (source) => nestedFieldPath(field, index, source),
147
153
  })}
148
154
  </Card>
149
155
  ))}
@@ -154,66 +160,3 @@ export function InlineFormSetStacked({
154
160
  </div>
155
161
  );
156
162
  }
157
-
158
- export type SaveInlineOptions = {
159
- resource: string;
160
- foreignKey: string;
161
- parentId: Identifier;
162
- rows: Record<string, unknown>[];
163
- existingIds?: Identifier[];
164
- /** Return true when the error was handled (field errors applied). Stops saving further rows. */
165
- onRowError?: (error: unknown, index: number) => boolean;
166
- };
167
-
168
- export async function saveInlineRows(
169
- dp: DataProvider,
170
- opts: SaveInlineOptions,
171
- ): Promise<boolean> {
172
- const { resource, foreignKey, parentId, rows, existingIds = [], onRowError } =
173
- opts;
174
- const keptIds: Identifier[] = [];
175
-
176
- for (let index = 0; index < rows.length; index++) {
177
- const row = rows[index];
178
- try {
179
- const { id: _id, ...rest } = row;
180
- const data = { ...rest, [foreignKey]: parentId };
181
- const rowId = row.id as Identifier | undefined;
182
- if (rowId != null && existingIds.some((e) => e === rowId)) {
183
- await dp.update(resource, { id: rowId, data });
184
- keptIds.push(rowId);
185
- } else {
186
- const res = await dp.create(resource, data);
187
- const created = res.data as { id: Identifier };
188
- keptIds.push(created.id);
189
- }
190
- } catch (e) {
191
- if (onRowError?.(e, index)) return false;
192
- throw e;
193
- }
194
- }
195
-
196
- for (const oldId of existingIds) {
197
- if (!keptIds.some((k) => k === oldId)) {
198
- await dp.delete(resource, oldId);
199
- }
200
- }
201
-
202
- return true;
203
- }
204
-
205
- export async function loadInlineRows(
206
- dp: DataProvider,
207
- resource: string,
208
- foreignKey: string,
209
- parentId: Identifier,
210
- ) {
211
- const res = await dp.getList(resource, {
212
- filter: { [foreignKey]: Number(parentId) || parentId },
213
- pagination: { page: 1, perPage: 500 },
214
- });
215
- return {
216
- rows: res.data as Record<string, unknown>[],
217
- ids: (res.data as { id: Identifier }[]).map((r) => r.id),
218
- };
219
- }
@@ -8,14 +8,12 @@ import { usePermissions } from "../context/PermissionsProvider";
8
8
  import type { ResourcePermissions } from "../permissions/resourcePermissions";
9
9
  import { checkResourcePermission } from "../permissions/resourcePermissions";
10
10
  import { FormMetaProvider } from "./context/FormContext";
11
- import { SubmitFieldsProvider } from "./context/SubmitFieldsContext";
11
+ import { PayloadFieldsProvider } from "./context/PayloadFieldsContext";
12
12
  import {
13
- useResourceFormLoad,
14
- useResourceFormSubmit,
15
- type ResourceFormInlineConfig,
16
- } from "./utils/useResourceFormData";
17
-
18
- export type { ResourceFormInlineConfig };
13
+ InlineFieldsRegistryProvider,
14
+ type InlineFieldRegistration,
15
+ } from "./context/InlineFieldsRegistry";
16
+ import { useFormRecordLoad, useFormRecordSave } from "./utils/useFormRecord";
19
17
 
20
18
  export type ResourceFormProps<T extends FieldValues> = {
21
19
  resource: string;
@@ -25,18 +23,15 @@ export type ResourceFormProps<T extends FieldValues> = {
25
23
  defaultValues?: Partial<T>;
26
24
  onSaved?: (record: T) => void;
27
25
  stayOnPage?: boolean;
28
- inlines?: ResourceFormInlineConfig[];
29
26
  /** Permission strings for create vs edit. Omit to allow all (demos only). */
30
27
  permissions?: Pick<ResourcePermissions, "add" | "change">;
31
28
  };
32
29
 
33
30
  /**
34
- * Create/edit page shell around react-hook-form.
31
+ * Create/edit page standard react-hook-form under the hood.
35
32
  *
36
- * Flow:
37
- * 1. Load edit: getOne(parent) + loadInlineRows form.reset (see useResourceFormLoad)
38
- * 2. Edit — children render fields; useSubmitField tracks sources for the API payload
39
- * 3. Save — pickBySources → create/update parent → saveInlineRows (see useResourceFormSubmit)
33
+ * Load: one `getOne` → `form.reset(record)` (nested inline arrays included).
34
+ * Save: one `create` or `update` with parent fields + nested inline rows.
40
35
  */
41
36
  export function ResourceForm<T extends FieldValues & { id?: unknown }>({
42
37
  resource,
@@ -46,7 +41,6 @@ export function ResourceForm<T extends FieldValues & { id?: unknown }>({
46
41
  defaultValues,
47
42
  onSaved,
48
43
  stayOnPage,
49
- inlines,
50
44
  permissions,
51
45
  }: ResourceFormProps<T>) {
52
46
  const { id } = useParams();
@@ -56,13 +50,14 @@ export function ResourceForm<T extends FieldValues & { id?: unknown }>({
56
50
  const navigate = useNavigate();
57
51
  const { message } = App.useApp();
58
52
  const { token } = theme.useToken();
59
- const submitFieldsRef = useRef(new Set<string>());
53
+ const payloadFieldsRef = useRef(new Set<string>());
54
+ const inlineRegistryRef = useRef(new Map<string, InlineFieldRegistration>());
60
55
 
61
56
  const form = useForm<T>({
62
57
  defaultValues: defaultValues as DefaultValues<T>,
63
58
  });
64
59
 
65
- const { loading, formVersion, existingInlineIds } = useResourceFormLoad({
60
+ const { loading, formVersion } = useFormRecordLoad({
66
61
  dp,
67
62
  resource,
68
63
  id,
@@ -70,10 +65,9 @@ export function ResourceForm<T extends FieldValues & { id?: unknown }>({
70
65
  form,
71
66
  message,
72
67
  defaultValues,
73
- inlines,
74
68
  });
75
69
 
76
- const onSubmit = useResourceFormSubmit({
70
+ const onSubmit = useFormRecordSave({
77
71
  dp,
78
72
  resource,
79
73
  id,
@@ -82,9 +76,8 @@ export function ResourceForm<T extends FieldValues & { id?: unknown }>({
82
76
  message,
83
77
  navigate,
84
78
  listPath,
85
- submitFieldsRef,
86
- inlines,
87
- existingInlineIds,
79
+ payloadFieldsRef,
80
+ inlineRegistryRef,
88
81
  onSaved,
89
82
  stayOnPage,
90
83
  });
@@ -115,51 +108,52 @@ export function ResourceForm<T extends FieldValues & { id?: unknown }>({
115
108
  }
116
109
  >
117
110
  <FormMetaProvider resource={resource} isNew={isNew}>
118
- <SubmitFieldsProvider fieldsRef={submitFieldsRef}>
119
- <div style={{ position: "relative" }}>
120
- {loading ? (
121
- <div
122
- style={{
123
- position: "absolute",
124
- inset: 0,
125
- display: "flex",
126
- alignItems: "center",
127
- justifyContent: "center",
128
- zIndex: 1,
129
- }}
130
- >
131
- <Spin />
132
- </div>
133
- ) : null}
134
- {/* formVersion remounts RHF after load so inline field arrays bind correctly */}
135
- <FormProvider {...form} key={formVersion}>
136
- <Form
137
- layout="vertical"
138
- onFinish={() => void form.handleSubmit(onSubmit)()}
139
- style={{
140
- opacity: loading ? 0.4 : 1,
141
- pointerEvents: loading ? "none" : undefined,
142
- }}
143
- >
144
- {children}
145
- <Form.Item style={{ marginTop: 16 }}>
146
- <Space>
147
- <Button
148
- type="primary"
149
- htmlType="submit"
150
- disabled={loading || !canSave}
151
- >
152
- Save
153
- </Button>
154
- <Link to={listPath}>
155
- <Button disabled={loading}>Cancel</Button>
156
- </Link>
157
- </Space>
158
- </Form.Item>
159
- </Form>
160
- </FormProvider>
161
- </div>
162
- </SubmitFieldsProvider>
111
+ <PayloadFieldsProvider fieldsRef={payloadFieldsRef}>
112
+ <InlineFieldsRegistryProvider registryRef={inlineRegistryRef}>
113
+ <div style={{ position: "relative" }}>
114
+ {loading ? (
115
+ <div
116
+ style={{
117
+ position: "absolute",
118
+ inset: 0,
119
+ display: "flex",
120
+ alignItems: "center",
121
+ justifyContent: "center",
122
+ zIndex: 1,
123
+ }}
124
+ >
125
+ <Spin />
126
+ </div>
127
+ ) : null}
128
+ <FormProvider {...form} key={formVersion}>
129
+ <Form
130
+ layout="vertical"
131
+ onFinish={() => void form.handleSubmit(onSubmit)()}
132
+ style={{
133
+ opacity: loading ? 0.4 : 1,
134
+ pointerEvents: loading ? "none" : undefined,
135
+ }}
136
+ >
137
+ {children}
138
+ <Form.Item style={{ marginTop: 16 }}>
139
+ <Space>
140
+ <Button
141
+ type="primary"
142
+ htmlType="submit"
143
+ disabled={loading || !canSave}
144
+ >
145
+ Save
146
+ </Button>
147
+ <Link to={listPath}>
148
+ <Button disabled={loading}>Cancel</Button>
149
+ </Link>
150
+ </Space>
151
+ </Form.Item>
152
+ </Form>
153
+ </FormProvider>
154
+ </div>
155
+ </InlineFieldsRegistryProvider>
156
+ </PayloadFieldsProvider>
163
157
  </FormMetaProvider>
164
158
  </Card>
165
159
  );