@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.
Files changed (195) hide show
  1. package/README.md +12 -3
  2. package/package.json +29 -4
  3. package/src/index.d.ts +19 -0
  4. package/src/index.js +23 -0
  5. package/src/index.js.map +1 -0
  6. package/src/lib/components/export/export.d.ts +7 -0
  7. package/src/lib/components/export/export.js +15 -0
  8. package/src/lib/components/export/export.js.map +1 -0
  9. package/src/lib/components/export/export.types.d.ts +8 -0
  10. package/src/lib/components/export/export.types.js +3 -0
  11. package/src/lib/components/export/export.types.js.map +1 -0
  12. package/src/lib/components/export/index.d.ts +3 -0
  13. package/src/lib/components/export/index.js +7 -0
  14. package/src/lib/components/export/index.js.map +1 -0
  15. package/src/lib/components/export/use-crud-export.d.ts +16 -0
  16. package/src/lib/components/export/use-crud-export.js +74 -0
  17. package/src/lib/components/export/use-crud-export.js.map +1 -0
  18. package/src/lib/components/filter/base/use-crud-filter.d.ts +68 -0
  19. package/src/lib/components/filter/base/use-crud-filter.js +248 -0
  20. package/src/lib/components/filter/base/use-crud-filter.js.map +1 -0
  21. package/src/lib/components/filter/check/filter-check.d.ts +7 -0
  22. package/src/lib/components/filter/check/filter-check.js +45 -0
  23. package/src/lib/components/filter/check/filter-check.js.map +1 -0
  24. package/src/lib/components/filter/date/filter-date.d.ts +7 -0
  25. package/src/lib/components/filter/date/filter-date.js +19 -0
  26. package/src/lib/components/filter/date/filter-date.js.map +1 -0
  27. package/src/lib/components/filter/date/use-crud-filter-date.d.ts +23 -0
  28. package/src/lib/components/filter/date/use-crud-filter-date.js +41 -0
  29. package/src/lib/components/filter/date/use-crud-filter-date.js.map +1 -0
  30. package/src/lib/components/filter/date/use-crud-filter-ng-model.d.ts +6 -0
  31. package/src/lib/components/filter/date/use-crud-filter-ng-model.js +25 -0
  32. package/src/lib/components/filter/date/use-crud-filter-ng-model.js.map +1 -0
  33. package/src/lib/components/filter/date-time/filter-date-time.d.ts +8 -0
  34. package/src/lib/components/filter/date-time/filter-date-time.js +27 -0
  35. package/src/lib/components/filter/date-time/filter-date-time.js.map +1 -0
  36. package/src/lib/components/filter/date-with-edit/filter-date-with-edit.d.ts +9 -0
  37. package/src/lib/components/filter/date-with-edit/filter-date-with-edit.js +42 -0
  38. package/src/lib/components/filter/date-with-edit/filter-date-with-edit.js.map +1 -0
  39. package/src/lib/components/filter/filter.d.ts +8 -0
  40. package/src/lib/components/filter/filter.js +43 -0
  41. package/src/lib/components/filter/filter.js.map +1 -0
  42. package/src/lib/components/filter/filter.types.d.ts +17 -0
  43. package/src/lib/components/filter/filter.types.js +3 -0
  44. package/src/lib/components/filter/filter.types.js.map +1 -0
  45. package/src/lib/components/filter/flag/filter-flag.d.ts +7 -0
  46. package/src/lib/components/filter/flag/filter-flag.js +20 -0
  47. package/src/lib/components/filter/flag/filter-flag.js.map +1 -0
  48. package/src/lib/components/filter/index.d.ts +13 -0
  49. package/src/lib/components/filter/index.js +17 -0
  50. package/src/lib/components/filter/index.js.map +1 -0
  51. package/src/lib/components/filter/int/filter-int.d.ts +12 -0
  52. package/src/lib/components/filter/int/filter-int.js +47 -0
  53. package/src/lib/components/filter/int/filter-int.js.map +1 -0
  54. package/src/lib/components/filter/radio/filter-radio.d.ts +7 -0
  55. package/src/lib/components/filter/radio/filter-radio.js +20 -0
  56. package/src/lib/components/filter/radio/filter-radio.js.map +1 -0
  57. package/src/lib/components/filter/text/filter-text.d.ts +7 -0
  58. package/src/lib/components/filter/text/filter-text.js +20 -0
  59. package/src/lib/components/filter/text/filter-text.js.map +1 -0
  60. package/src/lib/components/filters/filters.d.ts +10 -0
  61. package/src/lib/components/filters/filters.js +20 -0
  62. package/src/lib/components/filters/filters.js.map +1 -0
  63. package/src/lib/components/filters/filters.types.d.ts +5 -0
  64. package/src/lib/components/filters/filters.types.js +3 -0
  65. package/src/lib/components/filters/filters.types.js.map +1 -0
  66. package/src/lib/components/filters/index.d.ts +3 -0
  67. package/src/lib/components/filters/index.js +7 -0
  68. package/src/lib/components/filters/index.js.map +1 -0
  69. package/src/lib/components/filters/use-crud-filters.d.ts +17 -0
  70. package/src/lib/components/filters/use-crud-filters.js +63 -0
  71. package/src/lib/components/filters/use-crud-filters.js.map +1 -0
  72. package/src/lib/components/filters-config/filters-config.d.ts +6 -0
  73. package/src/lib/components/filters-config/filters-config.js +38 -0
  74. package/src/lib/components/filters-config/filters-config.js.map +1 -0
  75. package/src/lib/components/filters-config/index.d.ts +1 -0
  76. package/src/lib/components/filters-config/index.js +5 -0
  77. package/src/lib/components/filters-config/index.js.map +1 -0
  78. package/src/lib/components/group/group.d.ts +10 -0
  79. package/src/lib/components/group/group.js +19 -0
  80. package/src/lib/components/group/group.js.map +1 -0
  81. package/src/lib/components/group/group.types.d.ts +8 -0
  82. package/src/lib/components/group/group.types.js +3 -0
  83. package/src/lib/components/group/group.types.js.map +1 -0
  84. package/src/lib/components/group/index.d.ts +3 -0
  85. package/src/lib/components/group/index.js +7 -0
  86. package/src/lib/components/group/index.js.map +1 -0
  87. package/src/lib/components/group/use-crud-group.d.ts +17 -0
  88. package/src/lib/components/group/use-crud-group.js +50 -0
  89. package/src/lib/components/group/use-crud-group.js.map +1 -0
  90. package/src/lib/components/multiselect/index.d.ts +2 -0
  91. package/src/lib/components/multiselect/index.js +6 -0
  92. package/src/lib/components/multiselect/index.js.map +1 -0
  93. package/src/lib/components/multiselect/multiselect.d.ts +10 -0
  94. package/src/lib/components/multiselect/multiselect.js +25 -0
  95. package/src/lib/components/multiselect/multiselect.js.map +1 -0
  96. package/src/lib/components/multiselect/use-crud-multiselect.d.ts +24 -0
  97. package/src/lib/components/multiselect/use-crud-multiselect.js +72 -0
  98. package/src/lib/components/multiselect/use-crud-multiselect.js.map +1 -0
  99. package/src/lib/crud.config.d.ts +67 -0
  100. package/src/lib/crud.config.js +3 -0
  101. package/src/lib/crud.config.js.map +1 -0
  102. package/src/lib/crud.context.d.ts +23 -0
  103. package/src/lib/crud.context.js +25 -0
  104. package/src/lib/crud.context.js.map +1 -0
  105. package/src/lib/crud.provider.d.ts +16 -0
  106. package/src/lib/crud.provider.js +69 -0
  107. package/src/lib/crud.provider.js.map +1 -0
  108. package/src/lib/factories/form-options.d.ts +10 -0
  109. package/src/lib/factories/form-options.js +26 -0
  110. package/src/lib/factories/form-options.js.map +1 -0
  111. package/src/lib/hooks.d.ts +15 -0
  112. package/src/lib/hooks.js +66 -0
  113. package/src/lib/hooks.js.map +1 -0
  114. package/src/lib/models/index.d.ts +1 -0
  115. package/src/lib/models/index.js +5 -0
  116. package/src/lib/models/index.js.map +1 -0
  117. package/src/lib/models/interfaces.d.ts +29 -0
  118. package/src/lib/models/interfaces.js +3 -0
  119. package/src/lib/models/interfaces.js.map +1 -0
  120. package/src/lib/pages/crud-pages.d.ts +32 -0
  121. package/src/lib/pages/crud-pages.js +64 -0
  122. package/src/lib/pages/crud-pages.js.map +1 -0
  123. package/src/lib/pages/index.d.ts +12 -0
  124. package/src/lib/pages/index.js +16 -0
  125. package/src/lib/pages/index.js.map +1 -0
  126. package/src/lib/pages/item/item-page.d.ts +18 -0
  127. package/src/lib/pages/item/item-page.js +31 -0
  128. package/src/lib/pages/item/item-page.js.map +1 -0
  129. package/src/lib/pages/item/item-page.types.d.ts +47 -0
  130. package/src/lib/pages/item/item-page.types.js +3 -0
  131. package/src/lib/pages/item/item-page.types.js.map +1 -0
  132. package/src/lib/pages/item/standard/item-page-standard.d.ts +10 -0
  133. package/src/lib/pages/item/standard/item-page-standard.js +19 -0
  134. package/src/lib/pages/item/standard/item-page-standard.js.map +1 -0
  135. package/src/lib/pages/item/use-crud-item-page-base.d.ts +22 -0
  136. package/src/lib/pages/item/use-crud-item-page-base.js +47 -0
  137. package/src/lib/pages/item/use-crud-item-page-base.js.map +1 -0
  138. package/src/lib/pages/item/use-crud-item-page.d.ts +44 -0
  139. package/src/lib/pages/item/use-crud-item-page.js +297 -0
  140. package/src/lib/pages/item/use-crud-item-page.js.map +1 -0
  141. package/src/lib/pages/list/list-page.d.ts +17 -0
  142. package/src/lib/pages/list/list-page.js +32 -0
  143. package/src/lib/pages/list/list-page.js.map +1 -0
  144. package/src/lib/pages/list/list-page.types.d.ts +27 -0
  145. package/src/lib/pages/list/list-page.types.js +3 -0
  146. package/src/lib/pages/list/list-page.types.js.map +1 -0
  147. package/src/lib/pages/list/standard/list-page-standard.d.ts +13 -0
  148. package/src/lib/pages/list/standard/list-page-standard.js +28 -0
  149. package/src/lib/pages/list/standard/list-page-standard.js.map +1 -0
  150. package/src/lib/pages/list/use-crud-list-page.d.ts +35 -0
  151. package/src/lib/pages/list/use-crud-list-page.js +309 -0
  152. package/src/lib/pages/list/use-crud-list-page.js.map +1 -0
  153. package/src/lib/pages/use-crud-bound-component.d.ts +10 -0
  154. package/src/lib/pages/use-crud-bound-component.js +28 -0
  155. package/src/lib/pages/use-crud-bound-component.js.map +1 -0
  156. package/src/lib/pages/use-crud-page-config.d.ts +9 -0
  157. package/src/lib/pages/use-crud-page-config.js +19 -0
  158. package/src/lib/pages/use-crud-page-config.js.map +1 -0
  159. package/src/lib/providers/model-label.provider.d.ts +11 -0
  160. package/src/lib/providers/model-label.provider.js +27 -0
  161. package/src/lib/providers/model-label.provider.js.map +1 -0
  162. package/src/lib/services/crud/crud.service.d.ts +44 -0
  163. package/src/lib/services/crud/crud.service.js +113 -0
  164. package/src/lib/services/crud/crud.service.js.map +1 -0
  165. package/src/lib/services/list-group/list-group.service.d.ts +18 -0
  166. package/src/lib/services/list-group/list-group.service.js +52 -0
  167. package/src/lib/services/list-group/list-group.service.js.map +1 -0
  168. package/src/lib/services/page/page.service.d.ts +8 -0
  169. package/src/lib/services/page/page.service.js +33 -0
  170. package/src/lib/services/page/page.service.js.map +1 -0
  171. package/src/lib/services/search/search.service.d.ts +14 -0
  172. package/src/lib/services/search/search.service.js +28 -0
  173. package/src/lib/services/search/search.service.js.map +1 -0
  174. package/src/lib/state/crud.actions.d.ts +157 -0
  175. package/src/lib/state/crud.actions.js +257 -0
  176. package/src/lib/state/crud.actions.js.map +1 -0
  177. package/src/lib/state/crud.effects.d.ts +20 -0
  178. package/src/lib/state/crud.effects.js +128 -0
  179. package/src/lib/state/crud.effects.js.map +1 -0
  180. package/src/lib/state/crud.facade.d.ts +43 -0
  181. package/src/lib/state/crud.facade.js +93 -0
  182. package/src/lib/state/crud.facade.js.map +1 -0
  183. package/src/lib/state/crud.reducer.d.ts +20 -0
  184. package/src/lib/state/crud.reducer.js +218 -0
  185. package/src/lib/state/crud.reducer.js.map +1 -0
  186. package/src/lib/state/crud.selectors.d.ts +9 -0
  187. package/src/lib/state/crud.selectors.js +25 -0
  188. package/src/lib/state/crud.selectors.js.map +1 -0
  189. package/src/lib/state/crud.store.d.ts +17 -0
  190. package/src/lib/state/crud.store.js +33 -0
  191. package/src/lib/state/crud.store.js.map +1 -0
  192. package/src/lib/state/index.d.ts +6 -0
  193. package/src/lib/state/index.js +10 -0
  194. package/src/lib/state/index.js.map +1 -0
  195. package/styles.css +6001 -0
@@ -0,0 +1,47 @@
1
+ import type { ReactNode, RefObject } from 'react';
2
+ import { IEntity } from '@smartsoft001/domain-core';
3
+ import { IDetailsOptions, SmartFormGroup } from '@smartsoft001/react';
4
+ /** The props of `<SmartCrudItemPage>` (the Angular `<smart-crud-item-page>`). */
5
+ export interface SmartCrudItemPageProps {
6
+ /**
7
+ * The id of the item (the Angular `:id` route). Without it the page creates
8
+ * a new item, as on the Angular `add` route.
9
+ */
10
+ id?: string;
11
+ /**
12
+ * The path of the list. After a create, or a save without details, the page
13
+ * navigates there; without it, it goes back in the history, as the Angular
14
+ * page did with `Location.back()`.
15
+ */
16
+ basePath?: string;
17
+ /**
18
+ * The Angular `ng-content`: handed to the body. The standard body does not
19
+ * render it (its Angular template has no `ng-content`); a body registered
20
+ * as `crud-item-page` can.
21
+ */
22
+ children?: ReactNode;
23
+ }
24
+ /**
25
+ * The props of the item page body: `SmartCrudItemPageStandard` or a body
26
+ * registered as `components['crud-item-page']` on `SmartProvider` (the inputs
27
+ * and outputs of the Angular `CrudItemPageBaseComponent`).
28
+ */
29
+ export interface SmartCrudItemPageBodyProps<T extends IEntity<string> = any> {
30
+ detailsOptions?: IDetailsOptions<T>;
31
+ /** `'create'`, `'update'` or `'details'`. */
32
+ mode?: string;
33
+ uniqueProvider?: (values: Record<keyof T, any>) => Promise<boolean>;
34
+ /** The values of the changed fields (`onPartialChange`). */
35
+ onPartialChange?: (value: Partial<T>) => void;
36
+ /** The form value (`onChange`). */
37
+ onChange?: (value: T) => void;
38
+ /** The form validity (`onValidChange`). */
39
+ onValidChange?: (valid: boolean) => void;
40
+ /**
41
+ * Where the body keeps the form it renders (the Angular `getForm()`): the
42
+ * page validates it before a create or a save. `useCrudItemPageBase` fills
43
+ * it.
44
+ */
45
+ formRef?: RefObject<SmartFormGroup | null>;
46
+ children?: ReactNode;
47
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=item-page.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"item-page.types.js","sourceRoot":"","sources":["../../../../../../../../../packages/crud/shell/react/src/lib/pages/item/item-page.types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,10 @@
1
+ import { IEntity } from '@smartsoft001/domain-core';
2
+ import { SmartCrudItemPageBodyProps } from '../item-page.types';
3
+ /**
4
+ * The default item page body (`<smart-crud-item-standard-page>`, the Angular
5
+ * `ItemStandardComponent`): `SmartDetails` of `detailsOptions` in the
6
+ * details mode, else `SmartForm` of the selected item for the mode, reporting
7
+ * its changes, value and validity. `children` are not rendered, as the
8
+ * Angular template had no `ng-content`.
9
+ */
10
+ export declare function SmartCrudItemPageStandard<T extends IEntity<string>>(props: SmartCrudItemPageBodyProps<T>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SmartCrudItemPageStandard = SmartCrudItemPageStandard;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("@smartsoft001/react");
6
+ const use_crud_item_page_base_1 = require("../use-crud-item-page-base");
7
+ /**
8
+ * The default item page body (`<smart-crud-item-standard-page>`, the Angular
9
+ * `ItemStandardComponent`): `SmartDetails` of `detailsOptions` in the
10
+ * details mode, else `SmartForm` of the selected item for the mode, reporting
11
+ * its changes, value and validity. `children` are not rendered, as the
12
+ * Angular template had no `ng-content`.
13
+ */
14
+ function SmartCrudItemPageStandard(props) {
15
+ const { mode, detailsOptions, onPartialChange, onChange, onValidChange } = props;
16
+ const { formOptions } = (0, use_crud_item_page_base_1.useCrudItemPageBase)(props);
17
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [mode === 'details' ? (detailsOptions ? ((0, jsx_runtime_1.jsx)(react_1.SmartDetails, { options: detailsOptions })) : null) : formOptions ? ((0, jsx_runtime_1.jsx)(react_1.SmartForm, { options: formOptions, onValuePartialChange: onPartialChange, onValueChange: onChange, onValidChange: onValidChange })) : null, (0, jsx_runtime_1.jsx)("br", {}), (0, jsx_runtime_1.jsx)("br", {})] }));
18
+ }
19
+ //# sourceMappingURL=item-page-standard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"item-page-standard.js","sourceRoot":"","sources":["../../../../../../../../../../packages/crud/shell/react/src/lib/pages/item/standard/item-page-standard.tsx"],"names":[],"mappings":";;AAaA,8DAyBC;;AArCD,+CAA8D;AAG9D,wEAAiE;AAEjE;;;;;;GAMG;AACH,SAAgB,yBAAyB,CACvC,KAAoC;IAEpC,MAAM,EAAE,IAAI,EAAE,cAAc,EAAE,eAAe,EAAE,QAAQ,EAAE,aAAa,EAAE,GACtE,KAAK,CAAC;IACR,MAAM,EAAE,WAAW,EAAE,GAAG,IAAA,6CAAmB,EAAI,KAAK,CAAC,CAAC;IAEtD,OAAO,CACL,6DACG,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,CACpB,cAAc,CAAC,CAAC,CAAC,CACf,uBAAC,oBAAY,IAAC,OAAO,EAAE,cAAc,GAAI,CAC1C,CAAC,CAAC,CAAC,IAAI,CACT,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAChB,uBAAC,iBAAS,IACR,OAAO,EAAE,WAAW,EACpB,oBAAoB,EAAE,eAAe,EACrC,aAAa,EAAE,QAAQ,EACvB,aAAa,EAAE,aAAa,GAC5B,CACH,CAAC,CAAC,CAAC,IAAI,EACR,gCAAM,EACN,gCAAM,IACL,CACJ,CAAC;AACJ,CAAC"}
@@ -0,0 +1,22 @@
1
+ import { IEntity } from '@smartsoft001/domain-core';
2
+ import { IFormOptions } from '@smartsoft001/react';
3
+ import { SmartCrudItemPageBodyProps } from './item-page.types';
4
+ /**
5
+ * What every item page body shares (the Angular `CrudItemPageBaseComponent`):
6
+ * `config`, `facade`, the `selected` item and, outside the details mode, the
7
+ * form of the item: `formOptions` (the Angular `smartFormOptions` pipe over
8
+ * `selected`, `mode`, `config.type`, `uniqueProvider` and
9
+ * `config.inputComponents`, with the built form as `control`) and `form`,
10
+ * which is put in `formRef` for the page to validate (the Angular
11
+ * `getForm()`). Render `<SmartForm options={formOptions}>` once both exist.
12
+ *
13
+ * A new form is built when the selected item, the mode or the provider
14
+ * change; while creating, the selected item is ignored.
15
+ */
16
+ export declare function useCrudItemPageBase<T extends IEntity<string>>({ mode, uniqueProvider, formRef, }: SmartCrudItemPageBodyProps<T>): {
17
+ config: import("../../crud.config").CrudConfig<T> & Partial<import("../../crud.config").CrudFullConfig<T>>;
18
+ facade: import("../../state").CrudFacade<T>;
19
+ selected: T | null | undefined;
20
+ formOptions: IFormOptions<T> | null;
21
+ form: import("@smartsoft001/react").SmartFormGroup<Record<string, any>> | null;
22
+ };
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useCrudItemPageBase = useCrudItemPageBase;
4
+ const react_1 = require("react");
5
+ const react_2 = require("@smartsoft001/react");
6
+ const crud_context_1 = require("../../crud.context");
7
+ const form_options_1 = require("../../factories/form-options");
8
+ const hooks_1 = require("../../hooks");
9
+ /**
10
+ * What every item page body shares (the Angular `CrudItemPageBaseComponent`):
11
+ * `config`, `facade`, the `selected` item and, outside the details mode, the
12
+ * form of the item: `formOptions` (the Angular `smartFormOptions` pipe over
13
+ * `selected`, `mode`, `config.type`, `uniqueProvider` and
14
+ * `config.inputComponents`, with the built form as `control`) and `form`,
15
+ * which is put in `formRef` for the page to validate (the Angular
16
+ * `getForm()`). Render `<SmartForm options={formOptions}>` once both exist.
17
+ *
18
+ * A new form is built when the selected item, the mode or the provider
19
+ * change; while creating, the selected item is ignored.
20
+ */
21
+ function useCrudItemPageBase({ mode, uniqueProvider, formRef, }) {
22
+ const config = (0, crud_context_1.useCrudConfig)();
23
+ const facade = (0, crud_context_1.useCrudFacade)();
24
+ const selected = (0, hooks_1.useCrudState)((state) => state.selected);
25
+ const item = mode === 'create' ? null : selected;
26
+ const type = config?.type;
27
+ const inputComponents = config.inputComponents;
28
+ const options = (0, react_1.useMemo)(() => mode && mode !== 'details'
29
+ ? (0, form_options_1.getCrudFormOptions)(item, mode, type, uniqueProvider, inputComponents)
30
+ : null, [item, mode, type, uniqueProvider, inputComponents]);
31
+ const form = (0, react_2.useModelForm)(options?.model, {
32
+ mode: options?.mode,
33
+ uniqueProvider: options?.uniqueProvider,
34
+ });
35
+ (0, react_1.useEffect)(() => {
36
+ if (!formRef)
37
+ return undefined;
38
+ formRef.current = form;
39
+ return () => {
40
+ if (formRef.current === form)
41
+ formRef.current = null;
42
+ };
43
+ }, [form, formRef]);
44
+ const formOptions = (0, react_1.useMemo)(() => (options && form ? { ...options, control: form } : null), [options, form]);
45
+ return { config, facade, selected, formOptions, form };
46
+ }
47
+ //# sourceMappingURL=use-crud-item-page-base.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-crud-item-page-base.js","sourceRoot":"","sources":["../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AC;QAEvB,OAAO,GAAG,EAAE;YACV,IAAI,OAAO,CAAC,OAAO,KAAK,IAAI;gBAAE,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;QACvD,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;IAEpB,MAAM,WAAW,GAAG,IAAA,eAAO,EACzB,GAAG,EAAE,CAAC,CAAC,OAAO,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,EAC9D,CAAC,OAAO,EAAE,IAAI,CAAC,CAChB,CAAC;IAEF,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;AACzD,CAAC"}
@@ -0,0 +1,44 @@
1
+ import type { ComponentType } from 'react';
2
+ import { IEntity } from '@smartsoft001/domain-core';
3
+ import { IDetailsOptions, IPageOptions, SmartFormGroup } from '@smartsoft001/react';
4
+ import { SmartCrudItemPageProps } from './item-page.types';
5
+ import { CrudFullConfig } from '../../crud.config';
6
+ /**
7
+ * The logic of the item page (the Angular `ItemComponent`), for
8
+ * `SmartCrudItemPage` or a page of your own around the same feature:
9
+ *
10
+ * - `mode`: `'create'` without an `id`; with one `'details'` when
11
+ * `config.details` is set, else `'update'`; the `edit` query param (or the
12
+ * edit button) switches to `'update'`; the item of `id` is selected
13
+ * through the facade;
14
+ * - `pageOptions`: the title (`add`, `<titleKey> - change`,
15
+ * `<titleKey> - details`), the back button, no menu button, `variant`, and
16
+ * the buttons of the mode: add (create), cancel + save (update), edit
17
+ * (details, with `config.edit` and the model's `update.enabled`). Add and
18
+ * save validate the form of the body first (`formRef`) and report the
19
+ * invalid fields in a toast; add creates the form value, save sends the
20
+ * changed values with the id (`updatePartial`). Afterwards the page leaves
21
+ * for `basePath` (back in the history without it), or shows the details
22
+ * again when there are details;
23
+ * - `detailsOptions` (with `config.details`), `uniqueProvider` (asks the
24
+ * service whether another item has the values), the body callbacks and
25
+ * `formRef`;
26
+ * - `TopComponent` / `BottomComponent`: the `components` of `config.add`
27
+ * while creating, of `config.edit` while updating.
28
+ *
29
+ * Switching between creating and an id needs a new page (a `key`), as the
30
+ * Angular `add` and `:id` routes created a new component.
31
+ */
32
+ export declare function useCrudItemPage<T extends IEntity<string>>({ id, basePath, }?: SmartCrudItemPageProps): {
33
+ config: CrudFullConfig<T>;
34
+ mode: string;
35
+ pageOptions: IPageOptions;
36
+ detailsOptions: IDetailsOptions<T> | undefined;
37
+ uniqueProvider: (values: Record<keyof T, any>) => Promise<boolean>;
38
+ onPartialChange: (val: Partial<T>) => void;
39
+ onChange: (val: T) => void;
40
+ onValidChange: (val: boolean) => void;
41
+ formRef: import("react").RefObject<SmartFormGroup<Record<string, any>> | null>;
42
+ TopComponent: ComponentType | undefined;
43
+ BottomComponent: ComponentType | undefined;
44
+ };
@@ -0,0 +1,297 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useCrudItemPage = useCrudItemPage;
4
+ const react_1 = require("react");
5
+ const models_1 = require("@smartsoft001/models");
6
+ const react_2 = require("@smartsoft001/react");
7
+ const utils_1 = require("@smartsoft001/utils");
8
+ const crud_context_1 = require("../../crud.context");
9
+ const hooks_1 = require("../../hooks");
10
+ const use_crud_page_config_1 = require("../use-crud-page-config");
11
+ /** The `components` of an object `config.add` / `config.edit` / `config.details`. */
12
+ function getSlots(value) {
13
+ return value && typeof value === 'object' && 'components' in value
14
+ ? value.components
15
+ : undefined;
16
+ }
17
+ /** The first paragraph of an HTML text (`<p>a</p><p>b</p>` → `a`). */
18
+ function removeParagraph(val) {
19
+ if (!val || val.indexOf('<p>') !== 0)
20
+ return val;
21
+ if (typeof document === 'undefined') {
22
+ return /^<p>([\s\S]*?)<\/p>/.exec(val)?.[1] ?? val;
23
+ }
24
+ const div = document.createElement('div');
25
+ div.innerHTML = val;
26
+ return div.querySelectorAll('p').item(0).innerHTML;
27
+ }
28
+ /** Whether the `edit` query param of `url` is set (`?edit=1`). */
29
+ function hasEditParam(url) {
30
+ const query = url.split('?')[1]?.split('#')[0] ?? '';
31
+ return !!new URLSearchParams(query).get('edit');
32
+ }
33
+ /**
34
+ * Collects the labels of the invalid controls under `control`: nested groups
35
+ * as `parent > child`, array entries as `field(1)`, a `customMessage` error
36
+ * in brackets.
37
+ */
38
+ function getInvalidFields(control, invalidFields, baseField, t, key = null) {
39
+ if (control.valid)
40
+ return;
41
+ const field = key ? baseField + ' > ' + t('MODEL.' + key) : baseField;
42
+ if (control.errors?.['customMessage']) {
43
+ invalidFields.push(field + ` (${control.errors['customMessage']})`);
44
+ return;
45
+ }
46
+ if (control instanceof react_2.SmartFormControl) {
47
+ invalidFields.push(field);
48
+ }
49
+ if (control instanceof react_2.SmartFormGroup) {
50
+ Object.keys(control.controls).forEach((groupKey) => {
51
+ getInvalidFields(control.controls[groupKey], invalidFields, field, t, groupKey);
52
+ });
53
+ }
54
+ if (control instanceof react_2.SmartFormArray) {
55
+ control.controls.forEach((c, index) => {
56
+ getInvalidFields(c, invalidFields, field + `(${index + 1})`, t);
57
+ });
58
+ }
59
+ }
60
+ /**
61
+ * The logic of the item page (the Angular `ItemComponent`), for
62
+ * `SmartCrudItemPage` or a page of your own around the same feature:
63
+ *
64
+ * - `mode`: `'create'` without an `id`; with one `'details'` when
65
+ * `config.details` is set, else `'update'`; the `edit` query param (or the
66
+ * edit button) switches to `'update'`; the item of `id` is selected
67
+ * through the facade;
68
+ * - `pageOptions`: the title (`add`, `<titleKey> - change`,
69
+ * `<titleKey> - details`), the back button, no menu button, `variant`, and
70
+ * the buttons of the mode: add (create), cancel + save (update), edit
71
+ * (details, with `config.edit` and the model's `update.enabled`). Add and
72
+ * save validate the form of the body first (`formRef`) and report the
73
+ * invalid fields in a toast; add creates the form value, save sends the
74
+ * changed values with the id (`updatePartial`). Afterwards the page leaves
75
+ * for `basePath` (back in the history without it), or shows the details
76
+ * again when there are details;
77
+ * - `detailsOptions` (with `config.details`), `uniqueProvider` (asks the
78
+ * service whether another item has the values), the body callbacks and
79
+ * `formRef`;
80
+ * - `TopComponent` / `BottomComponent`: the `components` of `config.add`
81
+ * while creating, of `config.edit` while updating.
82
+ *
83
+ * Switching between creating and an id needs a new page (a `key`), as the
84
+ * Angular `add` and `:id` routes created a new component.
85
+ */
86
+ function useCrudItemPage({ id, basePath, } = {}) {
87
+ const config = (0, use_crud_page_config_1.useCrudPageConfig)();
88
+ const facade = (0, crud_context_1.useCrudFacade)();
89
+ const service = (0, crud_context_1.useCrudService)();
90
+ const navigation = (0, react_2.useNavigation)();
91
+ const toastService = (0, react_2.useToastService)();
92
+ const detailsService = (0, react_2.useDetailsService)();
93
+ const t = (0, react_2.useTranslate)();
94
+ const selected = (0, hooks_1.useCrudState)((state) => state.selected);
95
+ const create = id === undefined;
96
+ const [mode, setMode] = (0, react_1.useState)(() => create ? 'create' : config.details ? 'details' : 'update');
97
+ // Before the body renders, as the Angular `ngOnInit` ran before the view:
98
+ // the details set the root while rendering.
99
+ (0, react_1.useState)(() => detailsService.init());
100
+ const formRef = (0, react_1.useRef)(null);
101
+ const formValue = (0, react_1.useRef)(undefined);
102
+ const formPartialValue = (0, react_1.useRef)(undefined);
103
+ // Kept as the Angular `formValid`; the buttons validate the form itself.
104
+ const formValid = (0, react_1.useRef)(false);
105
+ const idRef = (0, react_1.useRef)(id);
106
+ (0, react_1.useEffect)(() => {
107
+ idRef.current = id;
108
+ });
109
+ (0, react_1.useEffect)(() => {
110
+ if (id !== undefined)
111
+ facade.select(id);
112
+ }, [facade, id]);
113
+ (0, react_1.useEffect)(() => {
114
+ if (create)
115
+ return undefined;
116
+ const check = (url) => {
117
+ if (hasEditParam(url))
118
+ setMode('update');
119
+ };
120
+ check(navigation.getCurrentUrl());
121
+ return navigation.subscribe(check);
122
+ }, [create, navigation]);
123
+ // One provider for the page's lifetime: it is part of the form options,
124
+ // and a new one would build the form again.
125
+ const uniqueProvider = (0, react_1.useCallback)(async (values) => {
126
+ const query = [];
127
+ const filter = { query };
128
+ Object.keys(values).forEach((key) => {
129
+ query.push({
130
+ key: key,
131
+ value: values[key],
132
+ type: '=',
133
+ });
134
+ });
135
+ if (idRef.current) {
136
+ query.push({ key: 'id', value: idRef.current, type: '!=' });
137
+ }
138
+ const { totalCount } = await service.getList(filter);
139
+ return !totalCount;
140
+ }, [service]);
141
+ const onPartialChange = (0, react_1.useCallback)((val) => {
142
+ formPartialValue.current = val;
143
+ }, []);
144
+ const onChange = (0, react_1.useCallback)((val) => {
145
+ formValue.current = val;
146
+ }, []);
147
+ const onValidChange = (0, react_1.useCallback)((val) => {
148
+ formValid.current = val;
149
+ }, []);
150
+ const checkFirstInvalid = (0, react_1.useCallback)(() => {
151
+ const form = formRef.current;
152
+ // Nothing has been built yet, so there is nothing valid to submit.
153
+ if (!form)
154
+ return true;
155
+ if (form.valid)
156
+ return false;
157
+ const invalidFields = [];
158
+ getInvalidFields(form, invalidFields, '', t);
159
+ void toastService.info({
160
+ title: t('INPUT.ERRORS.requires'),
161
+ message: invalidFields.slice(0, 3).join('<br/>'),
162
+ });
163
+ return true;
164
+ }, [t, toastService]);
165
+ const leave = (0, react_1.useCallback)(() => {
166
+ if (basePath !== undefined)
167
+ navigation.navigate(basePath);
168
+ else
169
+ navigation.back();
170
+ }, [basePath, navigation]);
171
+ const modelOptions = (0, react_1.useMemo)(() => (0, models_1.getModelOptions)(config.type), [config]);
172
+ const endButtons = (0, react_1.useMemo)(() => {
173
+ switch (mode) {
174
+ case 'create':
175
+ return [
176
+ {
177
+ icon: 'add',
178
+ text: 'add',
179
+ handler: () => {
180
+ if (checkFirstInvalid())
181
+ return;
182
+ facade.create(formValue.current);
183
+ leave();
184
+ },
185
+ },
186
+ ];
187
+ case 'update':
188
+ return [
189
+ ...(config.details
190
+ ? [
191
+ {
192
+ icon: 'close',
193
+ text: 'cancel',
194
+ handler: () => setMode('details'),
195
+ disabled: false,
196
+ },
197
+ ]
198
+ : []),
199
+ {
200
+ icon: 'save',
201
+ text: 'save',
202
+ handler: () => {
203
+ if (checkFirstInvalid())
204
+ return;
205
+ facade.updatePartial({
206
+ ...formPartialValue.current,
207
+ id: id,
208
+ });
209
+ if (config.details)
210
+ setMode('details');
211
+ else
212
+ leave();
213
+ },
214
+ },
215
+ ];
216
+ case 'details':
217
+ return config.edit &&
218
+ (!modelOptions?.update?.enabled ||
219
+ utils_1.SpecificationService.valid(selected, modelOptions.update.enabled))
220
+ ? [
221
+ {
222
+ icon: 'create',
223
+ text: 'edit',
224
+ handler: () => setMode('update'),
225
+ disabled: false,
226
+ },
227
+ ]
228
+ : [];
229
+ default:
230
+ return undefined;
231
+ }
232
+ }, [
233
+ mode,
234
+ config,
235
+ modelOptions,
236
+ selected,
237
+ id,
238
+ facade,
239
+ checkFirstInvalid,
240
+ leave,
241
+ ]);
242
+ const title = (0, react_1.useMemo)(() => {
243
+ const titleKey = modelOptions?.titleKey;
244
+ const prefix = titleKey && selected
245
+ ? removeParagraph(selected[titleKey]) + ' - '
246
+ : '';
247
+ switch (mode) {
248
+ case 'create':
249
+ return 'add';
250
+ case 'update':
251
+ return prefix + t('change');
252
+ case 'details':
253
+ return prefix + t('details');
254
+ default:
255
+ return undefined;
256
+ }
257
+ }, [mode, modelOptions, selected, t]);
258
+ const pageOptions = (0, react_1.useMemo)(() => ({
259
+ title: title || '',
260
+ variant: config.variant,
261
+ showBackButton: true,
262
+ hideMenuButton: true,
263
+ endButtons,
264
+ }), [title, config, endButtons]);
265
+ const detailsOptions = (0, react_1.useMemo)(() => {
266
+ if (!config.details)
267
+ return undefined;
268
+ const slots = getSlots(config.details);
269
+ return {
270
+ type: config.type,
271
+ item: selected,
272
+ cellPipe: config.details.cellPipe,
273
+ componentFactories: { top: slots?.top, bottom: slots?.bottom },
274
+ };
275
+ }, [config, selected]);
276
+ const slots = mode === 'create'
277
+ ? getSlots(config.add)
278
+ : mode === 'update'
279
+ ? getSlots(config.edit)
280
+ : undefined;
281
+ const TopComponent = slots?.top;
282
+ const BottomComponent = slots?.bottom;
283
+ return {
284
+ config,
285
+ mode,
286
+ pageOptions,
287
+ detailsOptions,
288
+ uniqueProvider,
289
+ onPartialChange,
290
+ onChange,
291
+ onValidChange,
292
+ formRef,
293
+ TopComponent,
294
+ BottomComponent,
295
+ };
296
+ }
297
+ //# sourceMappingURL=use-crud-item-page.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-crud-item-page.js","sourceRoot":"","sources":["../../../../../../../../../packages/crud/shell/react/src/lib/pages/item/use-crud-item-page.ts"],"names":[],"mappings":";;AAiIA,0CA4PC;AA7XD,iCAA0E;AAI1E,iDAAuD;AACvD,+CAc6B;AAC7B,+CAA2D;AAI3D,qDAAmE;AACnE,uCAA2C;AAE3C,kEAA4D;AAE5D,qFAAqF;AACrF,SAAS,QAAQ,CACf,KAAsD;IAEtD,OAAO,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,YAAY,IAAI,KAAK;QAChE,CAAC,CAAC,KAAK,CAAC,UAAU;QAClB,CAAC,CAAC,SAAS,CAAC;AAChB,CAAC;AAED,sEAAsE;AACtE,SAAS,eAAe,CAAC,GAAW;IAClC,IAAI,CAAC,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC;QAAE,OAAO,GAAG,CAAC;IAEjD,IAAI,OAAO,QAAQ,KAAK,WAAW,EAAE,CAAC;QACpC,OAAO,qBAAqB,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC;IACrD,CAAC;IAED,MAAM,GAAG,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IAC1C,GAAG,CAAC,SAAS,GAAG,GAAG,CAAC;IAEpB,OAAO,GAAG,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AACrD,CAA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B,CAAC,CAAC,IAAI,KAAK,QAAQ;YACjB,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC;YACvB,CAAC,CAAC,SAAS,CAAC;IAClB,MAAM,YAAY,GAA8B,KAAK,EAAE,GAAG,CAAC;IAC3D,MAAM,eAAe,GAA8B,KAAK,EAAE,MAAM,CAAC;IAEjE,OAAO;QACL,MAAM;QACN,IAAI;QACJ,WAAW;QACX,cAAc;QACd,cAAc;QACd,eAAe;QACf,QAAQ;QACR,aAAa;QACb,OAAO;QACP,YAAY;QACZ,eAAe;KAChB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { IEntity } from '@smartsoft001/domain-core';
2
+ import { SmartCrudListPageProps } from './list-page.types';
3
+ /**
4
+ * `<smart-crud-list-page>` (the Angular `ListComponent` of the
5
+ * `CrudFullModule` `''` route): a `SmartPage` with the title, search and end
6
+ * buttons of `useCrudListPage`, `config.list.components.top`, and the body:
7
+ * the one registered as `components['crud-list-page']` on `SmartProvider`
8
+ * (the Angular `crud-list-page` dynamic component), else
9
+ * `SmartCrudListPageStandard`. Renders nothing until the feature's filter is
10
+ * set by the first read. Render it inside the feature's `CrudProvider` with a
11
+ * `CrudFullConfig`.
12
+ *
13
+ * Like the Angular page, a registered body renders in the
14
+ * `.dynamic-content` element. The list options are built synchronously, so
15
+ * unlike the Angular page the body never gets `null` ones.
16
+ */
17
+ export declare function SmartCrudListPage<T extends IEntity<string>>(props: SmartCrudListPageProps): import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SmartCrudListPage = SmartCrudListPage;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("@smartsoft001/react");
6
+ const list_page_standard_1 = require("./standard/list-page-standard");
7
+ const use_crud_list_page_1 = require("./use-crud-list-page");
8
+ /**
9
+ * `<smart-crud-list-page>` (the Angular `ListComponent` of the
10
+ * `CrudFullModule` `''` route): a `SmartPage` with the title, search and end
11
+ * buttons of `useCrudListPage`, `config.list.components.top`, and the body:
12
+ * the one registered as `components['crud-list-page']` on `SmartProvider`
13
+ * (the Angular `crud-list-page` dynamic component), else
14
+ * `SmartCrudListPageStandard`. Renders nothing until the feature's filter is
15
+ * set by the first read. Render it inside the feature's `CrudProvider` with a
16
+ * `CrudFullConfig`.
17
+ *
18
+ * Like the Angular page, a registered body renders in the
19
+ * `.dynamic-content` element. The list options are built synchronously, so
20
+ * unlike the Angular page the body never gets `null` ones.
21
+ */
22
+ function SmartCrudListPage(props) {
23
+ const { children } = props;
24
+ const { config, filter, pageOptions, listOptions, TopComponent } = (0, use_crud_list_page_1.useCrudListPage)(props);
25
+ const Body = (0, react_1.useSmartComponent)('crud-list-page', list_page_standard_1.SmartCrudListPageStandard);
26
+ const standard = Body === list_page_standard_1.SmartCrudListPageStandard;
27
+ if (!filter)
28
+ return null;
29
+ const body = (0, jsx_runtime_1.jsx)(Body, { listOptions: listOptions, children: children });
30
+ return ((0, jsx_runtime_1.jsxs)(react_1.SmartPage, { options: pageOptions, className: config.className || '', children: [(0, jsx_runtime_1.jsx)("div", { 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 })] }));
31
+ }
32
+ //# sourceMappingURL=list-page.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list-page.js","sourceRoot":"","sources":["../../../../../../../../../packages/crud/shell/react/src/lib/pages/list/list-page.tsx"],"names":[],"mappings":";;AAwBA,8CAwBC;;AA/CD,+CAAmE;AAMnE,sEAA0E;AAC1E,6DAAuD;AAEvD;;;;;;;;;;;;;GAaG;AACH,SAAgB,iBAAiB,CAC/B,KAA6B;IAE7B,MAAM,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IAC3B,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,GAC9D,IAAA,oCAAe,EAAI,KAAK,CAAC,CAAC;IAC5B,MAAM,IAAI,GAAG,IAAA,yBAAiB,EAC5B,gBAAgB,EAChB,8CAAyB,CAC1B,CAAC;IACF,MAAM,QAAQ,GAAG,IAAI,KAAK,8CAAyB,CAAC;IAEpD,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IAEzB,MAAM,IAAI,GAAG,uBAAC,IAAI,IAAC,WAAW,EAAE,WAAW,YAAG,QAAQ,GAAQ,CAAC;IAE/D,OAAO,CACL,wBAAC,iBAAS,IAAC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,CAAC,SAAS,IAAI,EAAE,aAChE,0CAAM,YAAY,CAAC,CAAC,CAAC,uBAAC,YAAY,KAAG,CAAC,CAAC,CAAC,IAAI,GAAO,EAElD,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EACvB,gCAAK,SAAS,EAAC,iBAAiB,YAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,GAAO,IACtD,CACb,CAAC;AACJ,CAAC"}
@@ -0,0 +1,27 @@
1
+ import type { ReactNode } from 'react';
2
+ import { IEntity } from '@smartsoft001/domain-core';
3
+ import { IListOptions } from '@smartsoft001/react';
4
+ /** The props of `<SmartCrudListPage>` (the Angular `<smart-crud-list-page>`). */
5
+ export interface SmartCrudListPageProps {
6
+ /**
7
+ * The path of the list, which the add button (`<basePath>/add`) and the
8
+ * item links (`<basePath>/<id>`) are relative to. The current path when
9
+ * omitted, as the Angular page used the router's current URL.
10
+ */
11
+ basePath?: string;
12
+ /**
13
+ * The Angular `ng-content`: handed to the body. The standard body does not
14
+ * render it (its Angular template has no `ng-content`); a body registered
15
+ * as `crud-list-page` can.
16
+ */
17
+ children?: ReactNode;
18
+ }
19
+ /**
20
+ * The props of the list page body: `SmartCrudListPageStandard` or a body
21
+ * registered as `components['crud-list-page']` on `SmartProvider` (the inputs
22
+ * of the Angular `CrudListPageBaseComponent`).
23
+ */
24
+ export interface SmartCrudListPageBodyProps<T extends IEntity<string> = any> {
25
+ listOptions: IListOptions<T> | null;
26
+ children?: ReactNode;
27
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=list-page.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list-page.types.js","sourceRoot":"","sources":["../../../../../../../../../packages/crud/shell/react/src/lib/pages/list/list-page.types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,13 @@
1
+ import { IEntity } from '@smartsoft001/domain-core';
2
+ import { SmartCrudListPageBodyProps } from '../list-page.types';
3
+ /**
4
+ * The default list page body (`<smart-crud-list-standard-page>`, the Angular
5
+ * `ListStandardComponent`): the active filters (`SmartCrudFiltersConfig`)
6
+ * and `SmartList`; with `config.list.groups` the list is hidden behind
7
+ * `SmartCrudGroup` unless a text is searched. `children` are not rendered,
8
+ * as the Angular template had no `ng-content`.
9
+ *
10
+ * The `hidden` the Angular template set on `<smart-list>` is set on a `div`
11
+ * around it, rendered only when there are groups.
12
+ */
13
+ export declare function SmartCrudListPageStandard<T extends IEntity<string>>({ listOptions, }: SmartCrudListPageBodyProps<T>): import("react/jsx-runtime").JSX.Element;