@smartsoft001/crud-shell-react 0.0.0-stage → 2.193.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.
- package/README.md +12 -3
- package/package.json +29 -4
- package/src/index.d.ts +19 -0
- package/src/index.js +23 -0
- package/src/index.js.map +1 -0
- package/src/lib/components/export/export.d.ts +7 -0
- package/src/lib/components/export/export.js +15 -0
- package/src/lib/components/export/export.js.map +1 -0
- package/src/lib/components/export/export.types.d.ts +8 -0
- package/src/lib/components/export/export.types.js +3 -0
- package/src/lib/components/export/export.types.js.map +1 -0
- package/src/lib/components/export/index.d.ts +3 -0
- package/src/lib/components/export/index.js +7 -0
- package/src/lib/components/export/index.js.map +1 -0
- package/src/lib/components/export/use-crud-export.d.ts +16 -0
- package/src/lib/components/export/use-crud-export.js +74 -0
- package/src/lib/components/export/use-crud-export.js.map +1 -0
- package/src/lib/components/filter/base/use-crud-filter.d.ts +68 -0
- package/src/lib/components/filter/base/use-crud-filter.js +248 -0
- package/src/lib/components/filter/base/use-crud-filter.js.map +1 -0
- package/src/lib/components/filter/check/filter-check.d.ts +7 -0
- package/src/lib/components/filter/check/filter-check.js +45 -0
- package/src/lib/components/filter/check/filter-check.js.map +1 -0
- package/src/lib/components/filter/date/filter-date.d.ts +7 -0
- package/src/lib/components/filter/date/filter-date.js +19 -0
- package/src/lib/components/filter/date/filter-date.js.map +1 -0
- package/src/lib/components/filter/date/use-crud-filter-date.d.ts +23 -0
- package/src/lib/components/filter/date/use-crud-filter-date.js +41 -0
- package/src/lib/components/filter/date/use-crud-filter-date.js.map +1 -0
- package/src/lib/components/filter/date/use-crud-filter-ng-model.d.ts +6 -0
- package/src/lib/components/filter/date/use-crud-filter-ng-model.js +25 -0
- package/src/lib/components/filter/date/use-crud-filter-ng-model.js.map +1 -0
- package/src/lib/components/filter/date-time/filter-date-time.d.ts +8 -0
- package/src/lib/components/filter/date-time/filter-date-time.js +27 -0
- package/src/lib/components/filter/date-time/filter-date-time.js.map +1 -0
- package/src/lib/components/filter/date-with-edit/filter-date-with-edit.d.ts +9 -0
- package/src/lib/components/filter/date-with-edit/filter-date-with-edit.js +42 -0
- package/src/lib/components/filter/date-with-edit/filter-date-with-edit.js.map +1 -0
- package/src/lib/components/filter/filter.d.ts +8 -0
- package/src/lib/components/filter/filter.js +43 -0
- package/src/lib/components/filter/filter.js.map +1 -0
- package/src/lib/components/filter/filter.types.d.ts +17 -0
- package/src/lib/components/filter/filter.types.js +3 -0
- package/src/lib/components/filter/filter.types.js.map +1 -0
- package/src/lib/components/filter/flag/filter-flag.d.ts +7 -0
- package/src/lib/components/filter/flag/filter-flag.js +20 -0
- package/src/lib/components/filter/flag/filter-flag.js.map +1 -0
- package/src/lib/components/filter/index.d.ts +13 -0
- package/src/lib/components/filter/index.js +17 -0
- package/src/lib/components/filter/index.js.map +1 -0
- package/src/lib/components/filter/int/filter-int.d.ts +12 -0
- package/src/lib/components/filter/int/filter-int.js +47 -0
- package/src/lib/components/filter/int/filter-int.js.map +1 -0
- package/src/lib/components/filter/radio/filter-radio.d.ts +7 -0
- package/src/lib/components/filter/radio/filter-radio.js +20 -0
- package/src/lib/components/filter/radio/filter-radio.js.map +1 -0
- package/src/lib/components/filter/text/filter-text.d.ts +7 -0
- package/src/lib/components/filter/text/filter-text.js +20 -0
- package/src/lib/components/filter/text/filter-text.js.map +1 -0
- package/src/lib/components/filters/filters.d.ts +10 -0
- package/src/lib/components/filters/filters.js +20 -0
- package/src/lib/components/filters/filters.js.map +1 -0
- package/src/lib/components/filters/filters.types.d.ts +5 -0
- package/src/lib/components/filters/filters.types.js +3 -0
- package/src/lib/components/filters/filters.types.js.map +1 -0
- package/src/lib/components/filters/index.d.ts +3 -0
- package/src/lib/components/filters/index.js +7 -0
- package/src/lib/components/filters/index.js.map +1 -0
- package/src/lib/components/filters/use-crud-filters.d.ts +17 -0
- package/src/lib/components/filters/use-crud-filters.js +63 -0
- package/src/lib/components/filters/use-crud-filters.js.map +1 -0
- package/src/lib/components/filters-config/filters-config.d.ts +6 -0
- package/src/lib/components/filters-config/filters-config.js +38 -0
- package/src/lib/components/filters-config/filters-config.js.map +1 -0
- package/src/lib/components/filters-config/index.d.ts +1 -0
- package/src/lib/components/filters-config/index.js +5 -0
- package/src/lib/components/filters-config/index.js.map +1 -0
- package/src/lib/components/group/group.d.ts +10 -0
- package/src/lib/components/group/group.js +19 -0
- package/src/lib/components/group/group.js.map +1 -0
- package/src/lib/components/group/group.types.d.ts +8 -0
- package/src/lib/components/group/group.types.js +3 -0
- package/src/lib/components/group/group.types.js.map +1 -0
- package/src/lib/components/group/index.d.ts +3 -0
- package/src/lib/components/group/index.js +7 -0
- package/src/lib/components/group/index.js.map +1 -0
- package/src/lib/components/group/use-crud-group.d.ts +17 -0
- package/src/lib/components/group/use-crud-group.js +50 -0
- package/src/lib/components/group/use-crud-group.js.map +1 -0
- package/src/lib/components/multiselect/index.d.ts +2 -0
- package/src/lib/components/multiselect/index.js +6 -0
- package/src/lib/components/multiselect/index.js.map +1 -0
- package/src/lib/components/multiselect/multiselect.d.ts +10 -0
- package/src/lib/components/multiselect/multiselect.js +25 -0
- package/src/lib/components/multiselect/multiselect.js.map +1 -0
- package/src/lib/components/multiselect/use-crud-multiselect.d.ts +24 -0
- package/src/lib/components/multiselect/use-crud-multiselect.js +72 -0
- package/src/lib/components/multiselect/use-crud-multiselect.js.map +1 -0
- package/src/lib/crud.config.d.ts +67 -0
- package/src/lib/crud.config.js +3 -0
- package/src/lib/crud.config.js.map +1 -0
- package/src/lib/crud.context.d.ts +23 -0
- package/src/lib/crud.context.js +25 -0
- package/src/lib/crud.context.js.map +1 -0
- package/src/lib/crud.provider.d.ts +16 -0
- package/src/lib/crud.provider.js +69 -0
- package/src/lib/crud.provider.js.map +1 -0
- package/src/lib/factories/form-options.d.ts +10 -0
- package/src/lib/factories/form-options.js +26 -0
- package/src/lib/factories/form-options.js.map +1 -0
- package/src/lib/hooks.d.ts +15 -0
- package/src/lib/hooks.js +66 -0
- package/src/lib/hooks.js.map +1 -0
- package/src/lib/models/index.d.ts +1 -0
- package/src/lib/models/index.js +5 -0
- package/src/lib/models/index.js.map +1 -0
- package/src/lib/models/interfaces.d.ts +29 -0
- package/src/lib/models/interfaces.js +3 -0
- package/src/lib/models/interfaces.js.map +1 -0
- package/src/lib/pages/crud-pages.d.ts +32 -0
- package/src/lib/pages/crud-pages.js +64 -0
- package/src/lib/pages/crud-pages.js.map +1 -0
- package/src/lib/pages/index.d.ts +12 -0
- package/src/lib/pages/index.js +16 -0
- package/src/lib/pages/index.js.map +1 -0
- package/src/lib/pages/item/item-page.d.ts +18 -0
- package/src/lib/pages/item/item-page.js +31 -0
- package/src/lib/pages/item/item-page.js.map +1 -0
- package/src/lib/pages/item/item-page.types.d.ts +47 -0
- package/src/lib/pages/item/item-page.types.js +3 -0
- package/src/lib/pages/item/item-page.types.js.map +1 -0
- package/src/lib/pages/item/standard/item-page-standard.d.ts +10 -0
- package/src/lib/pages/item/standard/item-page-standard.js +19 -0
- package/src/lib/pages/item/standard/item-page-standard.js.map +1 -0
- package/src/lib/pages/item/use-crud-item-page-base.d.ts +22 -0
- package/src/lib/pages/item/use-crud-item-page-base.js +47 -0
- package/src/lib/pages/item/use-crud-item-page-base.js.map +1 -0
- package/src/lib/pages/item/use-crud-item-page.d.ts +44 -0
- package/src/lib/pages/item/use-crud-item-page.js +297 -0
- package/src/lib/pages/item/use-crud-item-page.js.map +1 -0
- package/src/lib/pages/list/list-page.d.ts +17 -0
- package/src/lib/pages/list/list-page.js +32 -0
- package/src/lib/pages/list/list-page.js.map +1 -0
- package/src/lib/pages/list/list-page.types.d.ts +27 -0
- package/src/lib/pages/list/list-page.types.js +3 -0
- package/src/lib/pages/list/list-page.types.js.map +1 -0
- package/src/lib/pages/list/standard/list-page-standard.d.ts +13 -0
- package/src/lib/pages/list/standard/list-page-standard.js +28 -0
- package/src/lib/pages/list/standard/list-page-standard.js.map +1 -0
- package/src/lib/pages/list/use-crud-list-page.d.ts +35 -0
- package/src/lib/pages/list/use-crud-list-page.js +309 -0
- package/src/lib/pages/list/use-crud-list-page.js.map +1 -0
- package/src/lib/pages/use-crud-bound-component.d.ts +10 -0
- package/src/lib/pages/use-crud-bound-component.js +28 -0
- package/src/lib/pages/use-crud-bound-component.js.map +1 -0
- package/src/lib/pages/use-crud-page-config.d.ts +9 -0
- package/src/lib/pages/use-crud-page-config.js +19 -0
- package/src/lib/pages/use-crud-page-config.js.map +1 -0
- package/src/lib/providers/model-label.provider.d.ts +11 -0
- package/src/lib/providers/model-label.provider.js +27 -0
- package/src/lib/providers/model-label.provider.js.map +1 -0
- package/src/lib/services/crud/crud.service.d.ts +44 -0
- package/src/lib/services/crud/crud.service.js +113 -0
- package/src/lib/services/crud/crud.service.js.map +1 -0
- package/src/lib/services/list-group/list-group.service.d.ts +18 -0
- package/src/lib/services/list-group/list-group.service.js +52 -0
- package/src/lib/services/list-group/list-group.service.js.map +1 -0
- package/src/lib/services/page/page.service.d.ts +8 -0
- package/src/lib/services/page/page.service.js +33 -0
- package/src/lib/services/page/page.service.js.map +1 -0
- package/src/lib/services/search/search.service.d.ts +14 -0
- package/src/lib/services/search/search.service.js +28 -0
- package/src/lib/services/search/search.service.js.map +1 -0
- package/src/lib/state/crud.actions.d.ts +157 -0
- package/src/lib/state/crud.actions.js +257 -0
- package/src/lib/state/crud.actions.js.map +1 -0
- package/src/lib/state/crud.effects.d.ts +20 -0
- package/src/lib/state/crud.effects.js +128 -0
- package/src/lib/state/crud.effects.js.map +1 -0
- package/src/lib/state/crud.facade.d.ts +43 -0
- package/src/lib/state/crud.facade.js +93 -0
- package/src/lib/state/crud.facade.js.map +1 -0
- package/src/lib/state/crud.reducer.d.ts +20 -0
- package/src/lib/state/crud.reducer.js +218 -0
- package/src/lib/state/crud.reducer.js.map +1 -0
- package/src/lib/state/crud.selectors.d.ts +9 -0
- package/src/lib/state/crud.selectors.js +25 -0
- package/src/lib/state/crud.selectors.js.map +1 -0
- package/src/lib/state/crud.store.d.ts +17 -0
- package/src/lib/state/crud.store.js +33 -0
- package/src/lib/state/crud.store.js.map +1 -0
- package/src/lib/state/index.d.ts +6 -0
- package/src/lib/state/index.js +10 -0
- package/src/lib/state/index.js.map +1 -0
- package/styles.css +6001 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { ComponentType } from 'react';
|
|
2
|
+
import { ICellPipe, IIconButtonOptions, ListMode, PaginationMode, SmartPageVariant } from '@smartsoft001/react';
|
|
3
|
+
import { ICrudFilterQueryItem, ICrudListGroup } from './models';
|
|
4
|
+
import type { CrudAction } from './state/crud.actions';
|
|
5
|
+
import type { CrudState } from './state/crud.reducer';
|
|
6
|
+
/**
|
|
7
|
+
* What a CRUD feature talks to: the REST resource and the model. The Angular
|
|
8
|
+
* `CrudConfig` was a class used as an injection token; here it is a plain
|
|
9
|
+
* object handed to `<CrudProvider config>`.
|
|
10
|
+
*/
|
|
11
|
+
export interface CrudConfig<T> {
|
|
12
|
+
apiUrl: string;
|
|
13
|
+
/** The name the feature's state is kept under; one store per entity. */
|
|
14
|
+
entity: string;
|
|
15
|
+
/** The `@Model` class of the items. */
|
|
16
|
+
type?: any;
|
|
17
|
+
/** Replaces the default reducer of the feature. */
|
|
18
|
+
reducerFactory?: () => (state: CrudState<any>, action: CrudAction) => CrudState<any>;
|
|
19
|
+
/** Query items every read sends unless the filter brings its own. */
|
|
20
|
+
baseQuery?: Array<ICrudFilterQueryItem>;
|
|
21
|
+
}
|
|
22
|
+
export interface CrudComponentSlots {
|
|
23
|
+
top?: ComponentType<any>;
|
|
24
|
+
bottom?: ComponentType<any>;
|
|
25
|
+
}
|
|
26
|
+
/** The configuration of the full CRUD screens (list + item pages). */
|
|
27
|
+
export interface CrudFullConfig<T> extends CrudConfig<T> {
|
|
28
|
+
title: string;
|
|
29
|
+
details?: boolean | {
|
|
30
|
+
cellPipe?: ICellPipe<T>;
|
|
31
|
+
components?: CrudComponentSlots;
|
|
32
|
+
};
|
|
33
|
+
edit?: boolean | {
|
|
34
|
+
cellPipe?: ICellPipe<T>;
|
|
35
|
+
components?: CrudComponentSlots;
|
|
36
|
+
};
|
|
37
|
+
add?: boolean | {
|
|
38
|
+
components?: CrudComponentSlots;
|
|
39
|
+
};
|
|
40
|
+
remove?: boolean;
|
|
41
|
+
search?: boolean;
|
|
42
|
+
export?: boolean;
|
|
43
|
+
pagination?: {
|
|
44
|
+
limit: number;
|
|
45
|
+
};
|
|
46
|
+
sort?: boolean | {
|
|
47
|
+
default?: string;
|
|
48
|
+
defaultDesc?: boolean;
|
|
49
|
+
};
|
|
50
|
+
list?: {
|
|
51
|
+
cellPipe?: ICellPipe<T>;
|
|
52
|
+
components?: {
|
|
53
|
+
top?: ComponentType<any>;
|
|
54
|
+
multi?: ComponentType<any>;
|
|
55
|
+
};
|
|
56
|
+
mode?: ListMode;
|
|
57
|
+
paginationMode?: PaginationMode;
|
|
58
|
+
resetQuery?: 'beforeInit';
|
|
59
|
+
groups?: Array<ICrudListGroup>;
|
|
60
|
+
};
|
|
61
|
+
buttons?: Array<IIconButtonOptions>;
|
|
62
|
+
inputComponents?: {
|
|
63
|
+
[key: string]: ComponentType<any>;
|
|
64
|
+
};
|
|
65
|
+
className?: string;
|
|
66
|
+
variant?: SmartPageVariant;
|
|
67
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crud.config.js","sourceRoot":"","sources":["../../../../../../../packages/crud/shell/react/src/lib/crud.config.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { IEntity } from '@smartsoft001/domain-core';
|
|
2
|
+
import { CrudConfig, CrudFullConfig } from './crud.config';
|
|
3
|
+
import { CrudService } from './services/crud/crud.service';
|
|
4
|
+
import { CrudListGroupService } from './services/list-group/list-group.service';
|
|
5
|
+
import { CrudSearchService } from './services/search/search.service';
|
|
6
|
+
import { CrudFacade } from './state/crud.facade';
|
|
7
|
+
import { CrudStore } from './state/crud.store';
|
|
8
|
+
export interface CrudContextValue<T extends IEntity<string>> {
|
|
9
|
+
config: CrudConfig<T> & Partial<CrudFullConfig<T>>;
|
|
10
|
+
service: CrudService<T>;
|
|
11
|
+
store: CrudStore;
|
|
12
|
+
facade: CrudFacade<T>;
|
|
13
|
+
searchService: CrudSearchService;
|
|
14
|
+
listGroupService: CrudListGroupService<T>;
|
|
15
|
+
}
|
|
16
|
+
export declare const CrudContext: import("react").Context<CrudContextValue<any> | null>;
|
|
17
|
+
/** The CRUD feature the component is rendered in (`<CrudProvider>`). */
|
|
18
|
+
export declare function useCrud<T extends IEntity<string>>(): CrudContextValue<T>;
|
|
19
|
+
export declare const useCrudConfig: <T extends IEntity<string>>() => CrudConfig<T> & Partial<CrudFullConfig<T>>;
|
|
20
|
+
export declare const useCrudService: <T extends IEntity<string>>() => CrudService<T>;
|
|
21
|
+
export declare const useCrudFacade: <T extends IEntity<string>>() => CrudFacade<T>;
|
|
22
|
+
export declare const useCrudSearchService: () => CrudSearchService;
|
|
23
|
+
export declare const useCrudListGroupService: <T extends IEntity<string>>() => CrudListGroupService<T>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useCrudListGroupService = exports.useCrudSearchService = exports.useCrudFacade = exports.useCrudService = exports.useCrudConfig = exports.CrudContext = void 0;
|
|
4
|
+
exports.useCrud = useCrud;
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
exports.CrudContext = (0, react_1.createContext)(null);
|
|
7
|
+
/** The CRUD feature the component is rendered in (`<CrudProvider>`). */
|
|
8
|
+
function useCrud() {
|
|
9
|
+
const context = (0, react_1.useContext)(exports.CrudContext);
|
|
10
|
+
if (!context) {
|
|
11
|
+
throw new Error('useCrud: render the component inside <CrudProvider config={...}>');
|
|
12
|
+
}
|
|
13
|
+
return context;
|
|
14
|
+
}
|
|
15
|
+
const useCrudConfig = () => useCrud().config;
|
|
16
|
+
exports.useCrudConfig = useCrudConfig;
|
|
17
|
+
const useCrudService = () => useCrud().service;
|
|
18
|
+
exports.useCrudService = useCrudService;
|
|
19
|
+
const useCrudFacade = () => useCrud().facade;
|
|
20
|
+
exports.useCrudFacade = useCrudFacade;
|
|
21
|
+
const useCrudSearchService = () => useCrud().searchService;
|
|
22
|
+
exports.useCrudSearchService = useCrudSearchService;
|
|
23
|
+
const useCrudListGroupService = () => useCrud().listGroupService;
|
|
24
|
+
exports.useCrudListGroupService = useCrudListGroupService;
|
|
25
|
+
//# sourceMappingURL=crud.context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crud.context.js","sourceRoot":"","sources":["../../../../../../../packages/crud/shell/react/src/lib/crud.context.ts"],"names":[],"mappings":";;;AAuBA,0BAUC;AAjCD,iCAAkD;AAoBrC,QAAA,WAAW,GAAG,IAAA,qBAAa,EAA+B,IAAI,CAAC,CAAC;AAE7E,wEAAwE;AACxE,SAAgB,OAAO;IACrB,MAAM,OAAO,GAAG,IAAA,kBAAU,EAAC,mBAAW,CAAC,CAAC;IAExC,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CACb,kEAAkE,CACnE,CAAC;IACJ,CAAC;IAED,OAAO,OAA8B,CAAC;AACxC,CAAC;AAEM,MAAM,aAAa,GAAG,GAA8B,EAAE,CAC3D,OAAO,EAAK,CAAC,MAAM,CAAC;AADT,QAAA,aAAa,iBACJ;AACf,MAAM,cAAc,GAAG,GAA8B,EAAE,CAC5D,OAAO,EAAK,CAAC,OAAO,CAAC;AADV,QAAA,cAAc,kBACJ;AAChB,MAAM,aAAa,GAAG,GAA8B,EAAE,CAC3D,OAAO,EAAK,CAAC,MAAM,CAAC;AADT,QAAA,aAAa,iBACJ;AACf,MAAM,oBAAoB,GAAG,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC,aAAa,CAAC;AAArD,QAAA,oBAAoB,wBAAiC;AAC3D,MAAM,uBAAuB,GAAG,GAA8B,EAAE,CACrE,OAAO,EAAK,CAAC,gBAAgB,CAAC;AADnB,QAAA,uBAAuB,2BACJ"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import { IEntity } from '@smartsoft001/domain-core';
|
|
3
|
+
import { CrudConfig, CrudFullConfig } from './crud.config';
|
|
4
|
+
import { CrudService } from './services/crud/crud.service';
|
|
5
|
+
export interface CrudProviderProps<T extends IEntity<string>> {
|
|
6
|
+
config: CrudConfig<T> | CrudFullConfig<T>;
|
|
7
|
+
/** Replaces the REST client, e.g. with a subclass. */
|
|
8
|
+
service?: CrudService<T>;
|
|
9
|
+
children?: ReactNode;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Sets up a CRUD feature for its subtree: the service, the store with its
|
|
13
|
+
* effects, the facade and the file service pointed at the resource, what
|
|
14
|
+
* `CrudModule.forFeature` provided in Angular. Pass a memoised `config`.
|
|
15
|
+
*/
|
|
16
|
+
export declare function CrudProvider<T extends IEntity<string>>({ config, service, children, }: CrudProviderProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CrudProvider = CrudProvider;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const react_2 = require("@smartsoft001/react");
|
|
7
|
+
const crud_context_1 = require("./crud.context");
|
|
8
|
+
const crud_service_1 = require("./services/crud/crud.service");
|
|
9
|
+
const list_group_service_1 = require("./services/list-group/list-group.service");
|
|
10
|
+
const search_service_1 = require("./services/search/search.service");
|
|
11
|
+
const crud_effects_1 = require("./state/crud.effects");
|
|
12
|
+
const crud_facade_1 = require("./state/crud.facade");
|
|
13
|
+
const crud_reducer_1 = require("./state/crud.reducer");
|
|
14
|
+
const crud_store_1 = require("./state/crud.store");
|
|
15
|
+
// One registry per application (per `SmartProvider`, whose HTTP client is
|
|
16
|
+
// created once), so features with the same entity share their state the way
|
|
17
|
+
// the NgRx feature did, while two applications rendered in one process (SSR)
|
|
18
|
+
// stay apart.
|
|
19
|
+
const registries = new WeakMap();
|
|
20
|
+
function getRegistry(http) {
|
|
21
|
+
let registry = registries.get(http);
|
|
22
|
+
if (!registry) {
|
|
23
|
+
registry = { features: new Map(), searchService: new search_service_1.CrudSearchService() };
|
|
24
|
+
registries.set(http, registry);
|
|
25
|
+
}
|
|
26
|
+
return registry;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Sets up a CRUD feature for its subtree: the service, the store with its
|
|
30
|
+
* effects, the facade and the file service pointed at the resource, what
|
|
31
|
+
* `CrudModule.forFeature` provided in Angular. Pass a memoised `config`.
|
|
32
|
+
*/
|
|
33
|
+
function CrudProvider({ config, service, children, }) {
|
|
34
|
+
const smart = (0, react_2.useSmart)();
|
|
35
|
+
const crud = (0, react_1.useMemo)(() => {
|
|
36
|
+
const registry = getRegistry(smart.http);
|
|
37
|
+
const crudService = service ?? new crud_service_1.CrudService(config, smart.http);
|
|
38
|
+
let feature = registry.features.get(config.entity);
|
|
39
|
+
if (!feature) {
|
|
40
|
+
const store = new crud_store_1.CrudStore(config.entity, config.reducerFactory
|
|
41
|
+
? config.reducerFactory()
|
|
42
|
+
: (0, crud_reducer_1.getReducer)(config.entity));
|
|
43
|
+
const effects = new crud_effects_1.CrudEffects(crudService);
|
|
44
|
+
effects.init(store);
|
|
45
|
+
feature = { store, effects };
|
|
46
|
+
registry.features.set(config.entity, feature);
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
// The effects talk to the latest service, e.g. after `apiUrl` changed.
|
|
50
|
+
feature.effects.service = crudService;
|
|
51
|
+
}
|
|
52
|
+
const facade = new crud_facade_1.CrudFacade(feature.store, config);
|
|
53
|
+
return {
|
|
54
|
+
config,
|
|
55
|
+
service: crudService,
|
|
56
|
+
store: feature.store,
|
|
57
|
+
facade,
|
|
58
|
+
searchService: registry.searchService,
|
|
59
|
+
listGroupService: new list_group_service_1.CrudListGroupService(facade),
|
|
60
|
+
};
|
|
61
|
+
}, [config, service, smart.http]);
|
|
62
|
+
// Attachments of the feature's items live under its own API.
|
|
63
|
+
const smartValue = (0, react_1.useMemo)(() => ({
|
|
64
|
+
...smart,
|
|
65
|
+
fileService: new react_2.FileService({ apiUrl: config.apiUrl }, smart.http, () => smart.authService.getAccessToken()),
|
|
66
|
+
}), [smart, config.apiUrl]);
|
|
67
|
+
return ((0, jsx_runtime_1.jsx)(react_2.SmartContext.Provider, { value: smartValue, children: (0, jsx_runtime_1.jsx)(crud_context_1.CrudContext.Provider, { value: crud, children: children }) }));
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=crud.provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crud.provider.js","sourceRoot":"","sources":["../../../../../../../packages/crud/shell/react/src/lib/crud.provider.tsx"],"names":[],"mappings":";;AA4DA,oCAyDC;;AArHD,iCAAgC;AAIhC,+CAK6B;AAG7B,iDAA+D;AAC/D,+DAA2D;AAC3D,iFAAgF;AAChF,qEAAqE;AACrE,uDAAmD;AACnD,qDAAiD;AACjD,uDAAkD;AAClD,mDAA+C;AAY/C,0EAA0E;AAC1E,4EAA4E;AAC5E,6EAA6E;AAC7E,cAAc;AACd,MAAM,UAAU,GAAG,IAAI,OAAO,EAAiC,CAAC;AAEhE,SAAS,WAAW,CAAC,IAAqB;IACxC,IAAI,QAAQ,GAAG,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAEpC,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,QAAQ,GAAG,EAAE,QAAQ,EAAE,IAAI,GAAG,EAAE,EAAE,aAAa,EAAE,IAAI,kCAAiB,EAAE,EAAE,CAAC;QAC3E,UAAU,CAAC,GAAG,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IACjC,CAAC;IAED,OAA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;YACpB,MAAM;YACN,aAAa,EAAE,QAAQ,CAAC,aAAa;YACrC,gBAAgB,EAAE,IAAI,yCAAoB,CAAI,MAAM,CAAC;SACtD,CAAC;IACJ,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;IAElC,6DAA6D;IAC7D,MAAM,UAAU,GAAG,IAAA,eAAO,EACxB,GAAG,EAAE,CAAC,CAAC;QACL,GAAG,KAAK;QACR,WAAW,EAAE,IAAI,mBAAW,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,EAAE,KAAK,CAAC,IAAI,EAAE,GAAG,EAAE,CACvE,KAAK,CAAC,WAAW,CAAC,cAAc,EAAE,CACnC;KACF,CAAC,EACF,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,CACvB,CAAC;IAEF,OAAO,CACL,uBAAC,oBAAY,CAAC,QAAQ,IAAC,KAAK,EAAE,UAAU,YACtC,uBAAC,0BAAW,CAAC,QAAQ,IAAC,KAAK,EAAE,IAAI,YAAG,QAAQ,GAAwB,GAC9C,CACzB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ComponentType } from 'react';
|
|
2
|
+
import { IEntity } from '@smartsoft001/domain-core';
|
|
3
|
+
import { IFormOptions } from '@smartsoft001/react';
|
|
4
|
+
/**
|
|
5
|
+
* The form options of the item page (the Angular `smartFormOptions` pipe): a
|
|
6
|
+
* fresh model for `create`, a model filled from `item` for any other mode.
|
|
7
|
+
*/
|
|
8
|
+
export declare function getCrudFormOptions<T extends IEntity<string>>(item: T | null | undefined, mode: string, type: any, uniqueProvider?: (values: Record<keyof T, any>) => Promise<boolean>, inputComponents?: {
|
|
9
|
+
[key: string]: ComponentType<any>;
|
|
10
|
+
}): IFormOptions<T> | null;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getCrudFormOptions = getCrudFormOptions;
|
|
4
|
+
/**
|
|
5
|
+
* The form options of the item page (the Angular `smartFormOptions` pipe): a
|
|
6
|
+
* fresh model for `create`, a model filled from `item` for any other mode.
|
|
7
|
+
*/
|
|
8
|
+
function getCrudFormOptions(item, mode, type, uniqueProvider, inputComponents) {
|
|
9
|
+
if (!mode || !type)
|
|
10
|
+
return null;
|
|
11
|
+
const model = new type();
|
|
12
|
+
if (mode !== 'create' && item) {
|
|
13
|
+
Object.keys(item).forEach((key) => {
|
|
14
|
+
model[key] = item[key];
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
return {
|
|
18
|
+
mode,
|
|
19
|
+
possibilities: {},
|
|
20
|
+
inputComponents,
|
|
21
|
+
uniqueProvider,
|
|
22
|
+
model,
|
|
23
|
+
show: true,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=form-options.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"form-options.js","sourceRoot":"","sources":["../../../../../../../../packages/crud/shell/react/src/lib/factories/form-options.ts"],"names":[],"mappings":";;AASA,gDAyBC;AA7BD;;;GAGG;AACH,SAAgB,kBAAkB,CAChC,IAA0B,EAC1B,IAAY,EACZ,IAAS,EACT,cAAmE,EACnE,eAAuD;IAEvD,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAC;IAEhC,MAAM,KAAK,GAAG,IAAI,IAAI,EAAE,CAAC;IAEzB,IAAI,IAAI,KAAK,QAAQ,IAAI,IAAI,EAAE,CAAC;QAC9B,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;YAC/B,KAAa,CAAC,GAAG,CAAC,GAAI,IAAY,CAAC,GAAG,CAAC,CAAC;QAC3C,CAAC,CAAC,CAAC;IACL,CAAC;IAED,OAAO;QACL,IAAI;QACJ,aAAa,EAAE,EAAE;QACjB,eAAe;QACf,cAAc;QACd,KAAK;QACL,IAAI,EAAE,IAAI;KACX,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { IEntity } from '@smartsoft001/domain-core';
|
|
2
|
+
import { IListPaginationOptions, PaginationMode } from '@smartsoft001/react';
|
|
3
|
+
import { CrudState } from './state/crud.reducer';
|
|
4
|
+
/** The feature's state (or a slice of it), re-rendering when it changes. */
|
|
5
|
+
export declare function useCrudState<T extends IEntity<string>>(): CrudState<T>;
|
|
6
|
+
export declare function useCrudState<T extends IEntity<string>, S>(selector: (state: CrudState<T>) => S): S;
|
|
7
|
+
/**
|
|
8
|
+
* The pagination options of the list, driven by the feature's filter and
|
|
9
|
+
* links (the Angular `CrudListPaginationFactory`): the next / previous page
|
|
10
|
+
* loaders resolve once the read settled, with whether there is a further page.
|
|
11
|
+
*/
|
|
12
|
+
export declare function useCrudListPagination(options: {
|
|
13
|
+
mode?: PaginationMode;
|
|
14
|
+
limit: number;
|
|
15
|
+
}): IListPaginationOptions;
|
package/src/lib/hooks.js
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useCrudState = useCrudState;
|
|
4
|
+
exports.useCrudListPagination = useCrudListPagination;
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const react_2 = require("@smartsoft001/react");
|
|
7
|
+
const crud_context_1 = require("./crud.context");
|
|
8
|
+
function useCrudState(selector) {
|
|
9
|
+
const { store } = (0, crud_context_1.useCrud)();
|
|
10
|
+
return (0, react_2.useStore)(store, (selector ?? ((state) => state)));
|
|
11
|
+
}
|
|
12
|
+
function whenLoaded(store) {
|
|
13
|
+
return new Promise((resolve) => {
|
|
14
|
+
if (store.get().loaded) {
|
|
15
|
+
resolve();
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
const unsubscribe = store.subscribe(() => {
|
|
19
|
+
if (!store.get().loaded)
|
|
20
|
+
return;
|
|
21
|
+
unsubscribe();
|
|
22
|
+
resolve();
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The pagination options of the list, driven by the feature's filter and
|
|
28
|
+
* links (the Angular `CrudListPaginationFactory`): the next / previous page
|
|
29
|
+
* loaders resolve once the read settled, with whether there is a further page.
|
|
30
|
+
*/
|
|
31
|
+
function useCrudListPagination(options) {
|
|
32
|
+
const { store, facade } = (0, crud_context_1.useCrud)();
|
|
33
|
+
const filter = useCrudState((state) => state.filter);
|
|
34
|
+
const totalCount = useCrudState((state) => state.totalCount);
|
|
35
|
+
const { mode, limit } = options;
|
|
36
|
+
return (0, react_1.useMemo)(() => {
|
|
37
|
+
const load = (direction) => {
|
|
38
|
+
const links = store.get().links;
|
|
39
|
+
if (!links || !links[direction])
|
|
40
|
+
return Promise.resolve(false);
|
|
41
|
+
const current = store.get().filter ?? {};
|
|
42
|
+
const step = current.limit || 0;
|
|
43
|
+
const settled = new Promise((resolve) => {
|
|
44
|
+
// Reading flips `loaded` to false first; wait for it to come back.
|
|
45
|
+
queueMicrotask(() => whenLoaded(store).then(() => setTimeout(() => {
|
|
46
|
+
const next = store.get().links;
|
|
47
|
+
resolve(!!(next && next[direction]));
|
|
48
|
+
})));
|
|
49
|
+
});
|
|
50
|
+
facade.read({
|
|
51
|
+
...current,
|
|
52
|
+
offset: (current.offset || 0) + (direction === 'next' ? step : -step),
|
|
53
|
+
});
|
|
54
|
+
return settled;
|
|
55
|
+
};
|
|
56
|
+
return {
|
|
57
|
+
mode,
|
|
58
|
+
limit,
|
|
59
|
+
loadNextPage: () => load('next'),
|
|
60
|
+
loadPrevPage: () => load('prev'),
|
|
61
|
+
page: filter?.limit ? (filter.offset || 0) / filter.limit + 1 : 0,
|
|
62
|
+
totalPages: filter?.limit && totalCount ? Math.ceil(totalCount / filter.limit) : 0,
|
|
63
|
+
};
|
|
64
|
+
}, [store, facade, mode, limit, filter, totalCount]);
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=hooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.js","sourceRoot":"","sources":["../../../../../../../packages/crud/shell/react/src/lib/hooks.ts"],"names":[],"mappings":";;AAmBA,oCAWC;AAuBD,sDA+CC;AApGD,iCAAgC;AAGhC,+CAI6B;AAE7B,iDAAyC;AAUzC,SAAgB,YAAY,CAC1B,QAAqC;IAErC,MAAM,EAAE,KAAK,EAAE,GAAG,IAAA,sBAAO,GAAK,CAAC;IAE/B,OAAO,IAAA,gBAAQ,EACb,KAAK,EACL,CAAC,QAAQ,IAAI,CAAC,CAAC,KAAqB,EAAE,EAAE,CAAC,KAAK,CAAC,CAEzC,CACP,CAAC;AACJ,CAAC;AAED,SAAS,UAAU,CAAC,KAAgB;IAClC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,IAAI,KAAK,CAAC,GAAG,EAAE,CAAC,MAAM,EAAE,CAAC;YACvB,OAAO,EAAE,CAAC;YACV,OAAO;QACT,CAAC;QAED,MAAM,WAAW,GAAG,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;YACvC,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,MAAM;gBAAE,OAAO;YAEhC,WAAW,EAAE,CAAC;YACd,OAAO,EAAE,CAAC;QACZ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;GAIG;AACH,SAAgB,qBAAqB,CAAC,OAGrC;IACC,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,IAAA,sBAAO,GAAE,CAAC;IACpC,MAAM,MAAM,GAAG,YAAY,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACrD,MAAM,UAAU,GAAG,YAAY,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,UAAU,C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EAAE,CAAC,IAAI,CAAC,MAAM,CAAC;YAChC,YAAY,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC;YAChC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,IAAI,CAAC,CAAC,GAAG,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;YACjE,UAAU,EACR,MAAM,EAAE,KAAK,IAAI,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;SACzE,CAAC;IACJ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;AACvD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './interfaces';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../packages/crud/shell/react/src/lib/models/index.ts"],"names":[],"mappings":";;;AAAA,uDAA6B"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { IModelFilter } from '@smartsoft001/models';
|
|
2
|
+
import { PaginationMode } from '@smartsoft001/react';
|
|
3
|
+
export interface ICrudFilter {
|
|
4
|
+
searchText?: string;
|
|
5
|
+
sortBy?: string;
|
|
6
|
+
sortDesc?: boolean;
|
|
7
|
+
offset?: number;
|
|
8
|
+
limit?: number;
|
|
9
|
+
paginationMode?: PaginationMode;
|
|
10
|
+
query?: Array<ICrudFilterQueryItem>;
|
|
11
|
+
}
|
|
12
|
+
export interface ICrudFilterQueryItem extends IModelFilter {
|
|
13
|
+
key: string;
|
|
14
|
+
value: any;
|
|
15
|
+
type: '=' | '!=' | '>=' | '<=' | '<' | '>';
|
|
16
|
+
hidden?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export interface ICrudCreateManyOptions {
|
|
19
|
+
mode: CrudCreateManyMode;
|
|
20
|
+
}
|
|
21
|
+
export interface ICrudListGroup {
|
|
22
|
+
key: string;
|
|
23
|
+
value: string;
|
|
24
|
+
text: string;
|
|
25
|
+
show?: boolean;
|
|
26
|
+
changed?: boolean;
|
|
27
|
+
children?: Array<ICrudListGroup>;
|
|
28
|
+
}
|
|
29
|
+
export type CrudCreateManyMode = 'default' | 'replace';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../../../../../../packages/crud/shell/react/src/lib/models/interfaces.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/** The page of a CRUD feature a URL leads to (see `matchCrudRoute`). */
|
|
2
|
+
export type CrudRoute = {
|
|
3
|
+
page: 'list';
|
|
4
|
+
} | {
|
|
5
|
+
page: 'item';
|
|
6
|
+
id?: string;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* The page of the routes of the Angular `CrudFullModule` that `url` leads to,
|
|
10
|
+
* relative to `basePath`: `basePath` is the list, `basePath/add` the item
|
|
11
|
+
* page creating an item, `basePath/:id` the item page of `id`. `null` for any
|
|
12
|
+
* other URL.
|
|
13
|
+
*/
|
|
14
|
+
export declare function matchCrudRoute(url: string, basePath: string): CrudRoute | null;
|
|
15
|
+
export interface SmartCrudPagesProps {
|
|
16
|
+
/** The path the CRUD feature is mounted at, e.g. `/notes`. */
|
|
17
|
+
basePath: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The routes of the Angular `CrudFullModule` without a router: renders
|
|
21
|
+
* `SmartCrudListPage` on `basePath`, `SmartCrudItemPage` creating an item on
|
|
22
|
+
* `basePath/add` and `SmartCrudItemPage` of the item on `basePath/:id`,
|
|
23
|
+
* following the URL of `useNavigation()` (`getCurrentUrl()` + `subscribe`).
|
|
24
|
+
* Renders nothing on any other URL. Render it inside the `CrudProvider` of
|
|
25
|
+
* the feature.
|
|
26
|
+
*
|
|
27
|
+
* An application with a router can render the two pages from its own routes
|
|
28
|
+
* instead: `<SmartCrudListPage basePath="/notes" />` on `/notes`,
|
|
29
|
+
* `<SmartCrudItemPage basePath="/notes" />` on `/notes/add` and
|
|
30
|
+
* `<SmartCrudItemPage id={id} basePath="/notes" />` on `/notes/:id`.
|
|
31
|
+
*/
|
|
32
|
+
export declare function SmartCrudPages({ basePath }: SmartCrudPagesProps): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.matchCrudRoute = matchCrudRoute;
|
|
4
|
+
exports.SmartCrudPages = SmartCrudPages;
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const react_1 = require("react");
|
|
7
|
+
const react_2 = require("@smartsoft001/react");
|
|
8
|
+
const item_page_1 = require("./item/item-page");
|
|
9
|
+
const list_page_1 = require("./list/list-page");
|
|
10
|
+
/** The path without the query string, the hash and trailing slashes. */
|
|
11
|
+
function normalizePath(path) {
|
|
12
|
+
return path.split(/[?#]/)[0].replace(/\/+$/, '') || '/';
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* The page of the routes of the Angular `CrudFullModule` that `url` leads to,
|
|
16
|
+
* relative to `basePath`: `basePath` is the list, `basePath/add` the item
|
|
17
|
+
* page creating an item, `basePath/:id` the item page of `id`. `null` for any
|
|
18
|
+
* other URL.
|
|
19
|
+
*/
|
|
20
|
+
function matchCrudRoute(url, basePath) {
|
|
21
|
+
const path = normalizePath(url);
|
|
22
|
+
const base = normalizePath(basePath);
|
|
23
|
+
if (path === base)
|
|
24
|
+
return { page: 'list' };
|
|
25
|
+
const prefix = base === '/' ? '/' : base + '/';
|
|
26
|
+
if (!path.startsWith(prefix))
|
|
27
|
+
return null;
|
|
28
|
+
const segment = path.slice(prefix.length);
|
|
29
|
+
if (!segment || segment.includes('/'))
|
|
30
|
+
return null;
|
|
31
|
+
if (segment === 'add')
|
|
32
|
+
return { page: 'item' };
|
|
33
|
+
return { page: 'item', id: decodeURIComponent(segment) };
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The routes of the Angular `CrudFullModule` without a router: renders
|
|
37
|
+
* `SmartCrudListPage` on `basePath`, `SmartCrudItemPage` creating an item on
|
|
38
|
+
* `basePath/add` and `SmartCrudItemPage` of the item on `basePath/:id`,
|
|
39
|
+
* following the URL of `useNavigation()` (`getCurrentUrl()` + `subscribe`).
|
|
40
|
+
* Renders nothing on any other URL. Render it inside the `CrudProvider` of
|
|
41
|
+
* the feature.
|
|
42
|
+
*
|
|
43
|
+
* An application with a router can render the two pages from its own routes
|
|
44
|
+
* instead: `<SmartCrudListPage basePath="/notes" />` on `/notes`,
|
|
45
|
+
* `<SmartCrudItemPage basePath="/notes" />` on `/notes/add` and
|
|
46
|
+
* `<SmartCrudItemPage id={id} basePath="/notes" />` on `/notes/:id`.
|
|
47
|
+
*/
|
|
48
|
+
function SmartCrudPages({ basePath }) {
|
|
49
|
+
const navigation = (0, react_2.useNavigation)();
|
|
50
|
+
const [url, setUrl] = (0, react_1.useState)(() => navigation.getCurrentUrl());
|
|
51
|
+
(0, react_1.useEffect)(() => {
|
|
52
|
+
setUrl(navigation.getCurrentUrl());
|
|
53
|
+
return navigation.subscribe(setUrl);
|
|
54
|
+
}, [navigation]);
|
|
55
|
+
const route = matchCrudRoute(url, basePath);
|
|
56
|
+
if (!route)
|
|
57
|
+
return null;
|
|
58
|
+
if (route.page === 'list')
|
|
59
|
+
return (0, jsx_runtime_1.jsx)(list_page_1.SmartCrudListPage, { basePath: basePath });
|
|
60
|
+
// `add` and `:id` were two routes, so the page is created anew between
|
|
61
|
+
// them; between two ids it stays, as the Angular router reused it.
|
|
62
|
+
return ((0, jsx_runtime_1.jsx)(item_page_1.SmartCrudItemPage, { id: route.id, basePath: basePath }, route.id === undefined ? 'add' : 'item'));
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=crud-pages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crud-pages.js","sourceRoot":"","sources":["../../../../../../../../packages/crud/shell/react/src/lib/pages/crud-pages.tsx"],"names":[],"mappings":";;AAqBA,wCAoBC;AAoBD,wCAyBC;;AAtFD,iCAA4C;AAE5C,+CAAoD;AAEpD,gDAAqD;AACrD,gDAAqD;AAKrD,wEAAwE;AACxE,SAAS,aAAa,CAAC,IAAY;IACjC,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC;AAC1D,CAAC;AAED;;;;;GAKG;AACH,SAAgB,cAAc,CAC5B,GAAW,EACX,QAAgB;IAEhB,MAAM,IAAI,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC;IAChC,MAAM,IAAI,GAAG,aAAa,CAAC,QAAQ,CAAC,CAAC;IAErC,IAAI,IAAI,KAAK,IAAI;QAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IAE3C,MAAM,MAAM,GAAG,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,GAAG,GAAG,CAAC;IAE/C,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC;QAAE,OAAO,IAAI,CAAC;IAE1C,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAE1C,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC;IAEnD,IAAI,OAAO,KAAK,KAAK;QAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IAE/C,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,kBAAkB,CAAC,OAAO,CAAC,EAAE,CAAC;AAC3D,CAAC;AAOD;;;;;;;;;;;;GAYG;AACH,SAAgB,cAAc,CAAC,EAAE,QAAQ,EAAuB;IAC9D,MAAM,UAAU,GAAG,IAAA,qBAAa,GAAE,CAAC;IACnC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,IAAA,gBAAQ,EAAC,GAAG,EAAE,CAAC,UAAU,CAAC,aAAa,EAAE,CAAC,CAAC;IAEjE,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,MAAM,CAAC,UAAU,CAAC,aAAa,EAAE,CAAC,CAAC;QAEnC,OAAO,UAAU,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IACtC,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;IAEjB,MAAM,KAAK,GAAG,cAAc,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;IAE5C,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAC;IAExB,IAAI,KAAK,CAAC,IAAI,KAAK,MAAM;QAAE,OAAO,uBAAC,6BAAiB,IAAC,QAAQ,EAAE,QAAQ,GAAI,CAAC;IAE5E,uEAAuE;IACvE,mEAAmE;IACnE,OAAO,CACL,uBAAC,6BAAiB,IAEhB,EAAE,EAAE,KAAK,CAAC,EAAE,EACZ,QAAQ,EAAE,QAAQ,IAFb,KAAK,CAAC,EAAE,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAG5C,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from './crud-pages';
|
|
2
|
+
export * from './item/item-page';
|
|
3
|
+
export * from './item/item-page.types';
|
|
4
|
+
export * from './item/standard/item-page-standard';
|
|
5
|
+
export * from './item/use-crud-item-page';
|
|
6
|
+
export * from './item/use-crud-item-page-base';
|
|
7
|
+
export * from './list/list-page';
|
|
8
|
+
export * from './list/list-page.types';
|
|
9
|
+
export * from './list/standard/list-page-standard';
|
|
10
|
+
export * from './list/use-crud-list-page';
|
|
11
|
+
export * from './use-crud-bound-component';
|
|
12
|
+
export * from './use-crud-page-config';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./crud-pages"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./item/item-page"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./item/item-page.types"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./item/standard/item-page-standard"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./item/use-crud-item-page"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("./item/use-crud-item-page-base"), exports);
|
|
10
|
+
tslib_1.__exportStar(require("./list/list-page"), exports);
|
|
11
|
+
tslib_1.__exportStar(require("./list/list-page.types"), exports);
|
|
12
|
+
tslib_1.__exportStar(require("./list/standard/list-page-standard"), exports);
|
|
13
|
+
tslib_1.__exportStar(require("./list/use-crud-list-page"), exports);
|
|
14
|
+
tslib_1.__exportStar(require("./use-crud-bound-component"), exports);
|
|
15
|
+
tslib_1.__exportStar(require("./use-crud-page-config"), exports);
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../packages/crud/shell/react/src/lib/pages/index.ts"],"names":[],"mappings":";;;AAAA,uDAA6B;AAC7B,2DAAiC;AACjC,iEAAuC;AACvC,6EAAmD;AACnD,oEAA0C;AAC1C,yEAA+C;AAC/C,2DAAiC;AACjC,iEAAuC;AACvC,6EAAmD;AACnD,oEAA0C;AAC1C,qEAA2C;AAC3C,iEAAuC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { IEntity } from '@smartsoft001/domain-core';
|
|
2
|
+
import { SmartCrudItemPageProps } from './item-page.types';
|
|
3
|
+
/**
|
|
4
|
+
* `<smart-crud-item-page>` (the Angular `ItemComponent` of the
|
|
5
|
+
* `CrudFullModule` `add` and `:id` routes): a `SmartPage` with the title,
|
|
6
|
+
* back button and mode buttons of `useCrudItemPage`, the add / edit
|
|
7
|
+
* components above and below the body, and the body: the one registered as
|
|
8
|
+
* `components['crud-item-page']` on `SmartProvider` (the Angular
|
|
9
|
+
* `crud-item-page` dynamic component), else `SmartCrudItemPageStandard`.
|
|
10
|
+
* Without `id` it creates an item. Render it inside the feature's
|
|
11
|
+
* `CrudProvider` with a `CrudFullConfig`.
|
|
12
|
+
*
|
|
13
|
+
* Like the Angular page, a registered body renders in the `.dynamic-content`
|
|
14
|
+
* element. It gets the same props as the standard one and must put the form
|
|
15
|
+
* it renders in `formRef` (see `useCrudItemPageBase`), or add and save do
|
|
16
|
+
* nothing.
|
|
17
|
+
*/
|
|
18
|
+
export declare function SmartCrudItemPage<T extends IEntity<string>>(props: SmartCrudItemPageProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SmartCrudItemPage = SmartCrudItemPage;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("@smartsoft001/react");
|
|
6
|
+
const item_page_standard_1 = require("./standard/item-page-standard");
|
|
7
|
+
const use_crud_item_page_1 = require("./use-crud-item-page");
|
|
8
|
+
/**
|
|
9
|
+
* `<smart-crud-item-page>` (the Angular `ItemComponent` of the
|
|
10
|
+
* `CrudFullModule` `add` and `:id` routes): a `SmartPage` with the title,
|
|
11
|
+
* back button and mode buttons of `useCrudItemPage`, the add / edit
|
|
12
|
+
* components above and below the body, and the body: the one registered as
|
|
13
|
+
* `components['crud-item-page']` on `SmartProvider` (the Angular
|
|
14
|
+
* `crud-item-page` dynamic component), else `SmartCrudItemPageStandard`.
|
|
15
|
+
* Without `id` it creates an item. Render it inside the feature's
|
|
16
|
+
* `CrudProvider` with a `CrudFullConfig`.
|
|
17
|
+
*
|
|
18
|
+
* Like the Angular page, a registered body renders in the `.dynamic-content`
|
|
19
|
+
* element. It gets the same props as the standard one and must put the form
|
|
20
|
+
* it renders in `formRef` (see `useCrudItemPageBase`), or add and save do
|
|
21
|
+
* nothing.
|
|
22
|
+
*/
|
|
23
|
+
function SmartCrudItemPage(props) {
|
|
24
|
+
const { children } = props;
|
|
25
|
+
const { config, mode, pageOptions, detailsOptions, uniqueProvider, onPartialChange, onChange, onValidChange, formRef, TopComponent, BottomComponent, } = (0, use_crud_item_page_1.useCrudItemPage)(props);
|
|
26
|
+
const Body = (0, react_1.useSmartComponent)('crud-item-page', item_page_standard_1.SmartCrudItemPageStandard);
|
|
27
|
+
const standard = Body === item_page_standard_1.SmartCrudItemPageStandard;
|
|
28
|
+
const body = ((0, jsx_runtime_1.jsx)(Body, { detailsOptions: detailsOptions, mode: mode, uniqueProvider: uniqueProvider, onPartialChange: onPartialChange, onChange: onChange, onValidChange: onValidChange, formRef: formRef, children: children }));
|
|
29
|
+
return ((0, jsx_runtime_1.jsxs)(react_1.SmartPage, { options: pageOptions, className: config.className || '', children: [(0, jsx_runtime_1.jsx)("div", { className: "text-xl py-2.5 separator", children: TopComponent ? (0, jsx_runtime_1.jsx)(TopComponent, {}) : null }), standard ? body : null, (0, jsx_runtime_1.jsx)("div", { className: "dynamic-content", children: !standard ? body : null }), (0, jsx_runtime_1.jsx)("div", { className: "text-xl py-2.5 separator", children: BottomComponent ? (0, jsx_runtime_1.jsx)(BottomComponent, {}) : null })] }));
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=item-page.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"item-page.js","sourceRoot":"","sources":["../../../../../../../../../packages/crud/shell/react/src/lib/pages/item/item-page.tsx"],"names":[],"mappings":";;AAyBA,8CAiDC;;AAzED,+CAAmE;AAMnE,sEAA0E;AAC1E,6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