ding-react-admin 1.0.1 → 1.0.4
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/README.md +107 -2
- package/dist/index.js +712 -723
- package/dist/src/crud/InlineFormSet.d.ts +13 -11
- package/dist/src/crud/InlineFormSet.d.ts.map +1 -1
- package/dist/src/crud/ResourceForm.d.ts +10 -2
- package/dist/src/crud/ResourceForm.d.ts.map +1 -1
- package/dist/src/crud/ResourceFormModal.d.ts.map +1 -1
- package/dist/src/crud/ResourceList.d.ts.map +1 -1
- package/dist/src/crud/context/SubmitFieldsContext.d.ts +18 -0
- package/dist/src/crud/context/SubmitFieldsContext.d.ts.map +1 -0
- package/dist/src/crud/fields/BooleanField.d.ts +3 -1
- package/dist/src/crud/fields/BooleanField.d.ts.map +1 -1
- package/dist/src/crud/fields/DateField.d.ts +3 -1
- package/dist/src/crud/fields/DateField.d.ts.map +1 -1
- package/dist/src/crud/fields/FieldWrapper.d.ts +7 -14
- package/dist/src/crud/fields/FieldWrapper.d.ts.map +1 -1
- package/dist/src/crud/fields/NumberField.d.ts +5 -3
- package/dist/src/crud/fields/NumberField.d.ts.map +1 -1
- package/dist/src/crud/fields/PasswordField.d.ts +5 -3
- package/dist/src/crud/fields/PasswordField.d.ts.map +1 -1
- package/dist/src/crud/fields/ReferenceField.d.ts +6 -5
- package/dist/src/crud/fields/ReferenceField.d.ts.map +1 -1
- package/dist/src/crud/fields/ReferenceManyField.d.ts +3 -1
- package/dist/src/crud/fields/ReferenceManyField.d.ts.map +1 -1
- package/dist/src/crud/fields/SelectField.d.ts +3 -1
- package/dist/src/crud/fields/SelectField.d.ts.map +1 -1
- package/dist/src/crud/fields/TextField.d.ts +5 -3
- package/dist/src/crud/fields/TextField.d.ts.map +1 -1
- package/dist/src/crud/index.d.ts +8 -4
- package/dist/src/crud/index.d.ts.map +1 -1
- package/dist/src/crud/types.d.ts +21 -20
- package/dist/src/crud/types.d.ts.map +1 -1
- package/dist/src/crud/utils/inlineFieldName.d.ts +3 -0
- package/dist/src/crud/utils/inlineFieldName.d.ts.map +1 -0
- package/dist/src/crud/utils/useAbortableEffect.d.ts +7 -0
- package/dist/src/crud/utils/useAbortableEffect.d.ts.map +1 -0
- package/dist/src/crud/utils/useResourceFormData.d.ts +47 -0
- package/dist/src/crud/utils/useResourceFormData.d.ts.map +1 -0
- package/dist/src/data/abortError.d.ts +3 -0
- package/dist/src/data/abortError.d.ts.map +1 -0
- package/dist/src/data/abortError.test.d.ts +2 -0
- package/dist/src/data/abortError.test.d.ts.map +1 -0
- package/dist/src/data/createRestResourceHandlers.d.ts +2 -2
- package/dist/src/data/createRestResourceHandlers.d.ts.map +1 -1
- package/dist/src/data/dataProviderTypes.d.ts +7 -1
- package/dist/src/data/dataProviderTypes.d.ts.map +1 -1
- package/dist/src/data/resourceHandlers.d.ts +2 -2
- package/dist/src/data/resourceHandlers.d.ts.map +1 -1
- package/dist/src/index.d.ts +4 -3
- package/dist/src/index.d.ts.map +1 -1
- package/docs/assets/form-with-inline.png +0 -0
- package/package.json +59 -59
- package/src/crud/InlineFormSet.tsx +77 -89
- package/src/crud/ResourceForm.tsx +87 -202
- package/src/crud/ResourceFormModal.tsx +37 -25
- package/src/crud/ResourceList.tsx +35 -26
- package/src/crud/context/SubmitFieldsContext.tsx +62 -0
- package/src/crud/fields/BooleanField.tsx +22 -16
- package/src/crud/fields/DateField.tsx +32 -26
- package/src/crud/fields/FieldWrapper.tsx +32 -54
- package/src/crud/fields/NumberField.tsx +36 -34
- package/src/crud/fields/PasswordField.tsx +41 -40
- package/src/crud/fields/ReferenceField.tsx +35 -130
- package/src/crud/fields/ReferenceManyField.tsx +31 -25
- package/src/crud/fields/SelectField.tsx +6 -0
- package/src/crud/fields/TextField.tsx +32 -30
- package/src/crud/index.ts +19 -2
- package/src/crud/types.ts +132 -130
- package/src/crud/utils/inlineFieldName.ts +8 -0
- package/src/crud/utils/useAbortableEffect.ts +17 -0
- package/src/crud/utils/useResourceFormData.ts +231 -0
- package/src/data/abortError.test.ts +19 -0
- package/src/data/abortError.ts +10 -0
- package/src/data/createMemoryResourceHandlers.ts +1 -1
- package/src/data/createRestResourceHandlers.ts +4 -4
- package/src/data/dataProviderTypes.ts +8 -0
- package/src/data/resourceHandlers.ts +4 -3
- package/src/index.ts +14 -1
- package/dist/src/crud/context/FormFieldsContext.d.ts +0 -14
- package/dist/src/crud/context/FormFieldsContext.d.ts.map +0 -1
- package/dist/src/crud/context/InlineFormContext.d.ts +0 -16
- package/dist/src/crud/context/InlineFormContext.d.ts.map +0 -1
- package/dist/src/crud/fields/useInlineOrFormField.d.ts +0 -10
- package/dist/src/crud/fields/useInlineOrFormField.d.ts.map +0 -1
- package/src/crud/context/FormFieldsContext.tsx +0 -76
- package/src/crud/context/InlineFormContext.tsx +0 -71
- package/src/crud/fields/useInlineOrFormField.tsx +0 -91
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createRestResourceHandlers.d.ts","sourceRoot":"","sources":["../../../src/data/createRestResourceHandlers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"createRestResourceHandlers.d.ts","sourceRoot":"","sources":["../../../src/data/createRestResourceHandlers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACnF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,MAAM,MAAM,0BAA0B,CACpC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IACzD;IACF,IAAI,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,OAAO,CAAC;QAAE,IAAI,EAAE,CAAC,EAAE,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACvE,QAAQ,EAAE,CAAC,EAAE,EAAE,UAAU,EAAE,MAAM,CAAC,EAAE,YAAY,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;IAChE,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;IACtD,MAAM,EAAE,CAAC,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;IACtE,OAAO,EAAE,CAAC,EAAE,EAAE,UAAU,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3C,6DAA6D;IAC7D,eAAe,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC;IAC7D,6DAA6D;IAC7D,eAAe,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC;CAC9D,CAAC;AAEF;;;GAGG;AACH,wBAAgB,0BAA0B,CACxC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC3D,MAAM,EAAE,0BAA0B,CAAC,CAAC,CAAC,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAiC5D"}
|
|
@@ -9,12 +9,18 @@ export type PaginationParams = {
|
|
|
9
9
|
page: number;
|
|
10
10
|
perPage: number;
|
|
11
11
|
};
|
|
12
|
+
export type GetOneParams = {
|
|
13
|
+
/** Forward to fetch/axios to cancel in-flight reads when the UI unmounts or deps change. */
|
|
14
|
+
signal?: AbortSignal;
|
|
15
|
+
};
|
|
12
16
|
export type GetListParams = {
|
|
13
17
|
pagination?: PaginationParams;
|
|
14
18
|
/** Single or multi-column sort. */
|
|
15
19
|
sort?: SortSpec | SortSpec[];
|
|
16
20
|
/** Filter values; arrays mean "match any of" for that field. */
|
|
17
21
|
filter?: Record<string, unknown>;
|
|
22
|
+
/** Forward to fetch/axios to cancel in-flight reads when the UI unmounts or deps change. */
|
|
23
|
+
signal?: AbortSignal;
|
|
18
24
|
};
|
|
19
25
|
export type GetListResult<RecordType extends Record<string, unknown>> = {
|
|
20
26
|
data: RecordType[];
|
|
@@ -57,7 +63,7 @@ export type ParseFormError = (error: unknown, context: ParseFormErrorContext) =>
|
|
|
57
63
|
*/
|
|
58
64
|
export type DataProvider<RecordType extends Record<string, unknown> = Record<string, unknown>> = {
|
|
59
65
|
getList: (resource: string, params: GetListParams) => Promise<GetListResult<RecordType>>;
|
|
60
|
-
getOne: (resource: string, id: Identifier) => Promise<GetOneResult<RecordType>>;
|
|
66
|
+
getOne: (resource: string, id: Identifier, params?: GetOneParams) => Promise<GetOneResult<RecordType>>;
|
|
61
67
|
create: (resource: string, data: Partial<RecordType>) => Promise<CreateResult<RecordType>>;
|
|
62
68
|
update: (resource: string, params: UpdateParams<RecordType>) => Promise<UpdateResult<RecordType>>;
|
|
63
69
|
delete: (resource: string, id: Identifier) => Promise<DeleteResult<RecordType>>;
|
|
@@ -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,aAAa,GAAG;IAC1B,UAAU,CAAC,E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Y,CACtB,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,KACtB,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,13 +1,13 @@
|
|
|
1
1
|
import { PermissionsChecker } from '../context/PermissionsProvider';
|
|
2
2
|
import { ResourcePermissions } from '../permissions/resourcePermissions';
|
|
3
|
-
import { CreateResult, DataProvider, DeleteResult, GetListParams, GetListResult, GetOneResult, Identifier, ParseFormError, UpdateParams, UpdateResult } from './dataProviderTypes';
|
|
3
|
+
import { CreateResult, DataProvider, DeleteResult, GetListParams, GetListResult, GetOneParams, GetOneResult, Identifier, ParseFormError, UpdateParams, UpdateResult } from './dataProviderTypes';
|
|
4
4
|
export type ResourceAction = "list" | "read" | "add" | "change" | "delete";
|
|
5
5
|
/** @deprecated Use per-resource `permissions` with `can` in combineResourceHandlers options. */
|
|
6
6
|
export type ResourceGuard = (resource: string, action: ResourceAction) => void;
|
|
7
7
|
/** CRUD handlers for a single resource (no resource name on each method). */
|
|
8
8
|
export type ResourceHandlers<RecordType extends Record<string, unknown> = Record<string, unknown>> = {
|
|
9
9
|
getList: (params: GetListParams) => Promise<GetListResult<RecordType>>;
|
|
10
|
-
getOne: (id: Identifier) => Promise<GetOneResult<RecordType>>;
|
|
10
|
+
getOne: (id: Identifier, params?: GetOneParams) => Promise<GetOneResult<RecordType>>;
|
|
11
11
|
create: (data: Partial<RecordType>) => Promise<CreateResult<RecordType>>;
|
|
12
12
|
update: (params: UpdateParams<RecordType>) => Promise<UpdateResult<RecordType>>;
|
|
13
13
|
delete: (id: Identifier) => Promise<DeleteResult<RecordType>>;
|
|
@@ -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,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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,KAAK,OAAO,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC,CAAC;IACzE,MAAM,EAAE,CACN,MAAM,EAAE,YAAY,CAAC,UAAU,CAAC,KAC7B,OAAO,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC,CAAC;IACvC,MAAM,EAAE,CAAC,EAAE,EAAE,UAAU,KAAK,OAAO,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC,CAAC;CAC/D,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAC5B,gBAAgB,GAChB;IACE,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,WAAW,CAAC,EAAE,mBAAmB,CAAC;CACnC,CAAC;AAEN,MAAM,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;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"}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -4,8 +4,9 @@ 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, 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, FormValidationErrors, ParseFormError, ParseFormErrorContext, } from './data/dataProviderTypes';
|
|
8
8
|
export { combineResourceHandlers } from './data/resourceHandlers';
|
|
9
|
+
export { isAbortError } from './data/abortError';
|
|
9
10
|
export { parseDjangoDRFFormErrors, parseDotNetFormErrors, parseNodeFormErrors, getErrorBody, applyInlineFieldPaths, asStringMessages, finalizeFormErrors, } from './data/parseFormErrorHelpers';
|
|
10
11
|
export type { DotNetFormErrorOptions, NodeFormErrorOptions, } from './data/parseFormErrorHelpers';
|
|
11
12
|
export { createMemoryResourceHandlers } from './data/createMemoryResourceHandlers';
|
|
@@ -26,6 +27,6 @@ export { Guard, GuestOnly, Protected, RequirePermission } from './router/guards'
|
|
|
26
27
|
export { createAdminRouter } from './router/createAdminRouter';
|
|
27
28
|
export { deriveAuthPaths, getRouteAccess, partitionAdminRoutes, } from './router/routeAccess';
|
|
28
29
|
export type { AdminAppProps, AdminLayoutProps, AdminRouteChild, AppThemeProviderProps, AuthAdapter, LoginCredentials, AuthRedirects, CreateAdminRouterOptions, AuthAlternateLinkProps, AuthPageLayoutProps, LoginPageProps, NavItem, RouteAccess, ThemeDensity, ThemeMode, } from './types';
|
|
29
|
-
export { ResourceList, FilterBar, ResourceForm, ResourceFormModal, InlineFormSet, FormTabs, FormTab, FormSteps, FormStep, saveInlineRows, loadInlineRows, TextField, NumberField, BooleanField, DateField, SelectField, PasswordField, ReferenceField, ReferenceManyField, TextColumn, NumberColumn, BooleanColumn, DateColumn, ReferenceColumn, ReferenceManyColumn, CustomColumn, TextFilter, NumberFilter, BooleanFilter, DateFilter, SelectFilter, ReferenceFilter, ReferenceManyFilter, useListQueryState, useChoices, getByPath, pickBySources, inlineArrayName, useResourceListContext,
|
|
30
|
-
export type { ResourceFormProps, ResourceFormInlineConfig, ResourceFormModalProps, InlineFormSetProps, FormTabsProps, FormTabProps, FormStepsProps, FormStepProps, SaveInlineOptions, InlineFormSetLayout, ResourceListProps, BaseSourceProps, ChoiceOption, ChoicesLoader, ReferenceProps, DisplayProps, EditMode, FieldRules, ResourceListBuiltInActions, ResourceListBulkAction, ResourceListBulkActionHelpers, ResourceListRowActionsHelpers, ListQueryState, ListQueryActions, } from './crud';
|
|
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';
|
|
31
32
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EA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ACX,aAAa,EACb,cAAc,EACd,kBAAkB,EAClB,UAAU,EACV,YAAY,EACZ,aAAa,EACb,UAAU,EACV,eAAe,EACf,mBAAmB,EACnB,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,aAAa,EACb,UAAU,EACV,YAAY,EACZ,eAAe,EACf,mBAAmB,EACnB,iBAAiB,EACjB,UAAU,EACV,SAAS,EACT,aAAa,EACb,eAAe,EACf,sBAAsB,EACtB,
|
|
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,EACb,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,gBAAgB,EAChB,SAAS,EACT,QAAQ,EACR,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,oBAAoB,EACpB,cAAc,EACd,qBAAqB,GACtB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EACL,wBAAwB,EACxB,qBAAqB,EACrB,mBAAmB,EACnB,YAAY,EAC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|
Binary file
|
package/package.json
CHANGED
|
@@ -1,59 +1,59 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "ding-react-admin",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"type": "module",
|
|
5
|
-
"license": "MIT",
|
|
6
|
-
"description": "Composable admin shell (Ant Design + React Router): quick-start AdminApp or build your own layout.",
|
|
7
|
-
"repository": {
|
|
8
|
-
"type": "git",
|
|
9
|
-
"url": "https://github.com/Muhammadinaam/ding-react-admin.git"
|
|
10
|
-
},
|
|
11
|
-
"main": "./dist/index.js",
|
|
12
|
-
"module": "./dist/index.js",
|
|
13
|
-
"types": "./dist/index.d.ts",
|
|
14
|
-
"exports": {
|
|
15
|
-
".": {
|
|
16
|
-
"types": "./dist/index.d.ts",
|
|
17
|
-
"import": "./dist/index.js"
|
|
18
|
-
}
|
|
19
|
-
},
|
|
20
|
-
"files": [
|
|
21
|
-
"dist",
|
|
22
|
-
"src",
|
|
23
|
-
"docs/assets"
|
|
24
|
-
],
|
|
25
|
-
"scripts": {
|
|
26
|
-
"build": "vite build && node -e \"require('fs').writeFileSync('dist/index.d.ts','export * from \\\"./src/index\\\";\\n')\"",
|
|
27
|
-
"dev:example": "yarn --cwd examples/playground dev",
|
|
28
|
-
"build:example": "yarn --cwd examples/playground build",
|
|
29
|
-
"build:example:gh-pages": "yarn --cwd examples/playground build:gh-pages",
|
|
30
|
-
"test": "vitest run",
|
|
31
|
-
"prepublishOnly": "yarn build"
|
|
32
|
-
},
|
|
33
|
-
"peerDependencies": {
|
|
34
|
-
"@ant-design/icons": ">=6",
|
|
35
|
-
"antd": ">=6",
|
|
36
|
-
"dayjs": ">=1",
|
|
37
|
-
"react": ">=18",
|
|
38
|
-
"react-dom": ">=18",
|
|
39
|
-
"react-hook-form": ">=7",
|
|
40
|
-
"react-router-dom": ">=6"
|
|
41
|
-
},
|
|
42
|
-
"devDependencies": {
|
|
43
|
-
"@ant-design/icons": "^6.0.0",
|
|
44
|
-
"@types/react": "^19.2.14",
|
|
45
|
-
"@types/react-dom": "^19.2.3",
|
|
46
|
-
"@vitejs/plugin-react": "^6.0.1",
|
|
47
|
-
"antd": "^6.0.0",
|
|
48
|
-
"dayjs": "^1.11.13",
|
|
49
|
-
"react": "^19.2.5",
|
|
50
|
-
"react-dom": "^19.2.5",
|
|
51
|
-
"react-hook-form": "^7.56.4",
|
|
52
|
-
"react-router-dom": "^7.14.2",
|
|
53
|
-
"typescript": "~6.0.2",
|
|
54
|
-
"vite": "^8.0.9",
|
|
55
|
-
"vite-plugin-dts": "^4.5.4",
|
|
56
|
-
"vitest": "^3.2.4"
|
|
57
|
-
},
|
|
58
|
-
"dependencies": {}
|
|
59
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "ding-react-admin",
|
|
3
|
+
"version": "1.0.4",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"description": "Composable admin shell (Ant Design + React Router): quick-start AdminApp or build your own layout.",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/Muhammadinaam/ding-react-admin.git"
|
|
10
|
+
},
|
|
11
|
+
"main": "./dist/index.js",
|
|
12
|
+
"module": "./dist/index.js",
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"import": "./dist/index.js"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"dist",
|
|
22
|
+
"src",
|
|
23
|
+
"docs/assets"
|
|
24
|
+
],
|
|
25
|
+
"scripts": {
|
|
26
|
+
"build": "vite build && node -e \"require('fs').writeFileSync('dist/index.d.ts','export * from \\\"./src/index\\\";\\n')\"",
|
|
27
|
+
"dev:example": "yarn --cwd examples/playground dev",
|
|
28
|
+
"build:example": "yarn --cwd examples/playground build",
|
|
29
|
+
"build:example:gh-pages": "yarn --cwd examples/playground build:gh-pages",
|
|
30
|
+
"test": "vitest run",
|
|
31
|
+
"prepublishOnly": "yarn build"
|
|
32
|
+
},
|
|
33
|
+
"peerDependencies": {
|
|
34
|
+
"@ant-design/icons": ">=6",
|
|
35
|
+
"antd": ">=6",
|
|
36
|
+
"dayjs": ">=1",
|
|
37
|
+
"react": ">=18",
|
|
38
|
+
"react-dom": ">=18",
|
|
39
|
+
"react-hook-form": ">=7",
|
|
40
|
+
"react-router-dom": ">=6"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@ant-design/icons": "^6.0.0",
|
|
44
|
+
"@types/react": "^19.2.14",
|
|
45
|
+
"@types/react-dom": "^19.2.3",
|
|
46
|
+
"@vitejs/plugin-react": "^6.0.1",
|
|
47
|
+
"antd": "^6.0.0",
|
|
48
|
+
"dayjs": "^1.11.13",
|
|
49
|
+
"react": "^19.2.5",
|
|
50
|
+
"react-dom": "^19.2.5",
|
|
51
|
+
"react-hook-form": "^7.56.4",
|
|
52
|
+
"react-router-dom": "^7.14.2",
|
|
53
|
+
"typescript": "~6.0.2",
|
|
54
|
+
"vite": "^8.0.9",
|
|
55
|
+
"vite-plugin-dts": "^4.5.4",
|
|
56
|
+
"vitest": "^3.2.4"
|
|
57
|
+
},
|
|
58
|
+
"dependencies": {}
|
|
59
|
+
}
|
|
@@ -1,72 +1,79 @@
|
|
|
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 {
|
|
5
|
-
InlineFormSetProvider,
|
|
6
|
-
useInlineFormSetContext,
|
|
7
|
-
type InlineFormSetLayout,
|
|
8
|
-
} from "./context/InlineFormContext";
|
|
9
4
|
import type { Identifier } from "../data/dataProviderTypes";
|
|
10
5
|
import type { DataProvider } from "../data/dataProviderTypes";
|
|
6
|
+
import type {
|
|
7
|
+
InlineColumnDef,
|
|
8
|
+
InlineFormSetBaseProps,
|
|
9
|
+
InlineRowContext,
|
|
10
|
+
} from "./types";
|
|
11
11
|
import { inlineArrayName as buildInlineArrayName } from "./utils/inlineArrayName";
|
|
12
|
+
import { inlineFieldName } from "./utils/inlineFieldName";
|
|
12
13
|
|
|
13
|
-
export type
|
|
14
|
+
export type InlineFormSetLayout = "tabular" | "stacked";
|
|
14
15
|
|
|
15
|
-
export type InlineFormSetProps = {
|
|
16
|
-
|
|
17
|
-
foreignKey: string;
|
|
18
|
-
label?: string;
|
|
19
|
-
children: ReactNode;
|
|
20
|
-
name?: string;
|
|
21
|
-
/** `tabular` (default) — Django TabularInline; `stacked` — Django StackedInline. */
|
|
22
|
-
layout?: InlineFormSetLayout;
|
|
16
|
+
export type InlineFormSetProps = InlineFormSetBaseProps & {
|
|
17
|
+
columns: InlineColumnDef[];
|
|
23
18
|
};
|
|
24
19
|
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
export type InlineFormSetStackedProps = InlineFormSetBaseProps & {
|
|
21
|
+
/** Field sources in each row — used when appending an empty row. */
|
|
22
|
+
sources: string[];
|
|
23
|
+
renderRow: (ctx: InlineRowContext) => ReactNode;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
function emptyRow(sources: string[]) {
|
|
27
|
+
const row: Record<string, unknown> = {};
|
|
28
|
+
for (const source of sources) row[source] = undefined;
|
|
29
|
+
return row;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function useInlineRows(arrayName: string, sources: string[]) {
|
|
27
33
|
const { control } = useFormContext<FieldValues>();
|
|
28
34
|
const { fields, append, remove } = useFieldArray({
|
|
29
35
|
control,
|
|
30
36
|
name: arrayName,
|
|
31
37
|
});
|
|
32
38
|
|
|
33
|
-
const appendEmpty = () =>
|
|
34
|
-
if (!ctx) return;
|
|
35
|
-
const empty: Record<string, unknown> = {};
|
|
36
|
-
for (const f of ctx.fields) empty[f.source] = undefined;
|
|
37
|
-
append(empty);
|
|
38
|
-
};
|
|
39
|
+
const appendEmpty = () => append(emptyRow(sources));
|
|
39
40
|
|
|
40
|
-
return {
|
|
41
|
+
return { fields, remove, appendEmpty };
|
|
41
42
|
}
|
|
42
43
|
|
|
43
|
-
|
|
44
|
-
|
|
44
|
+
/** Tabular inline (Django TabularInline) — table with column headers. */
|
|
45
|
+
export function InlineFormSet({
|
|
46
|
+
resource,
|
|
45
47
|
label,
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
48
|
+
name,
|
|
49
|
+
columns,
|
|
50
|
+
}: InlineFormSetProps) {
|
|
51
|
+
const arrayName = buildInlineArrayName(resource, name);
|
|
52
|
+
const sources = useMemo(
|
|
53
|
+
() => columns.map((col) => col.source),
|
|
54
|
+
[columns],
|
|
55
|
+
);
|
|
56
|
+
const { fields, remove, appendEmpty } = useInlineRows(arrayName, sources);
|
|
57
|
+
|
|
58
|
+
const tableColumns = useMemo(
|
|
59
|
+
() =>
|
|
60
|
+
columns.map((col) => ({
|
|
61
|
+
title: col.label ?? col.source,
|
|
62
|
+
key: col.source,
|
|
63
|
+
width: col.width,
|
|
64
|
+
onHeaderCell: () =>
|
|
65
|
+
col.minWidth != null ? { style: { minWidth: col.minWidth } } : {},
|
|
66
|
+
onCell: () =>
|
|
67
|
+
col.minWidth != null ? { style: { minWidth: col.minWidth } } : {},
|
|
68
|
+
render: (_: unknown, __: unknown, index: number) =>
|
|
69
|
+
col.cell({
|
|
70
|
+
name: inlineFieldName(arrayName, index, col.source),
|
|
71
|
+
index,
|
|
72
|
+
arrayName,
|
|
73
|
+
}),
|
|
74
|
+
})),
|
|
75
|
+
[columns, arrayName],
|
|
76
|
+
);
|
|
70
77
|
|
|
71
78
|
return (
|
|
72
79
|
<div style={{ marginTop: 24 }}>
|
|
@@ -77,7 +84,7 @@ function InlineFormSetTable({
|
|
|
77
84
|
scroll={{ x: "max-content" }}
|
|
78
85
|
dataSource={fields.map((f) => ({ ...f, key: f.id }))}
|
|
79
86
|
columns={[
|
|
80
|
-
...
|
|
87
|
+
...tableColumns,
|
|
81
88
|
{
|
|
82
89
|
title: "",
|
|
83
90
|
key: "__remove",
|
|
@@ -102,16 +109,16 @@ function InlineFormSetTable({
|
|
|
102
109
|
);
|
|
103
110
|
}
|
|
104
111
|
|
|
105
|
-
|
|
106
|
-
|
|
112
|
+
/** Stacked inline (Django StackedInline) — each row in a card with field labels. */
|
|
113
|
+
export function InlineFormSetStacked({
|
|
114
|
+
resource,
|
|
107
115
|
label,
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}) {
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
if (!ctx) return null;
|
|
116
|
+
name,
|
|
117
|
+
sources,
|
|
118
|
+
renderRow,
|
|
119
|
+
}: InlineFormSetStackedProps) {
|
|
120
|
+
const arrayName = buildInlineArrayName(resource, name);
|
|
121
|
+
const { fields, remove, appendEmpty } = useInlineRows(arrayName, sources);
|
|
115
122
|
|
|
116
123
|
return (
|
|
117
124
|
<div style={{ marginTop: 24 }}>
|
|
@@ -123,19 +130,21 @@ function InlineFormSetStacked({
|
|
|
123
130
|
size="small"
|
|
124
131
|
title={`Item ${index + 1}`}
|
|
125
132
|
extra={
|
|
126
|
-
<Button
|
|
133
|
+
<Button
|
|
134
|
+
type="link"
|
|
135
|
+
danger
|
|
136
|
+
size="small"
|
|
137
|
+
onClick={() => remove(index)}
|
|
138
|
+
>
|
|
127
139
|
Remove
|
|
128
140
|
</Button>
|
|
129
141
|
}
|
|
130
142
|
>
|
|
131
|
-
{
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
})}
|
|
137
|
-
</div>
|
|
138
|
-
))}
|
|
143
|
+
{renderRow({
|
|
144
|
+
arrayName,
|
|
145
|
+
index,
|
|
146
|
+
name: (source) => inlineFieldName(arrayName, index, source),
|
|
147
|
+
})}
|
|
139
148
|
</Card>
|
|
140
149
|
))}
|
|
141
150
|
</Space>
|
|
@@ -146,27 +155,6 @@ function InlineFormSetStacked({
|
|
|
146
155
|
);
|
|
147
156
|
}
|
|
148
157
|
|
|
149
|
-
export function InlineFormSet({
|
|
150
|
-
resource,
|
|
151
|
-
label,
|
|
152
|
-
children,
|
|
153
|
-
name,
|
|
154
|
-
layout = "tabular",
|
|
155
|
-
}: InlineFormSetProps) {
|
|
156
|
-
const arrayName = buildInlineArrayName(resource, name);
|
|
157
|
-
|
|
158
|
-
return (
|
|
159
|
-
<InlineFormSetProvider arrayName={arrayName} layout={layout}>
|
|
160
|
-
{children}
|
|
161
|
-
{layout === "stacked" ? (
|
|
162
|
-
<InlineFormSetStacked arrayName={arrayName} label={label} />
|
|
163
|
-
) : (
|
|
164
|
-
<InlineFormSetTable arrayName={arrayName} label={label} />
|
|
165
|
-
)}
|
|
166
|
-
</InlineFormSetProvider>
|
|
167
|
-
);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
158
|
export type SaveInlineOptions = {
|
|
171
159
|
resource: string;
|
|
172
160
|
foreignKey: string;
|