@smartsoft001/crud-shell-react 0.0.0-stage → 2.194.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 +11 -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 +15 -0
  16. package/src/lib/components/export/use-crud-export.js +72 -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 +65 -0
  19. package/src/lib/components/filter/base/use-crud-filter.js +244 -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 +6 -0
  22. package/src/lib/components/filter/check/filter-check.js +44 -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 +6 -0
  25. package/src/lib/components/filter/date/filter-date.js +18 -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 +22 -0
  28. package/src/lib/components/filter/date/use-crud-filter-date.js +40 -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-value.d.ts +6 -0
  31. package/src/lib/components/filter/date/use-crud-filter-value.js +25 -0
  32. package/src/lib/components/filter/date/use-crud-filter-value.js.map +1 -0
  33. package/src/lib/components/filter/date-time/filter-date-time.d.ts +7 -0
  34. package/src/lib/components/filter/date-time/filter-date-time.js +26 -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 +8 -0
  37. package/src/lib/components/filter/date-with-edit/filter-date-with-edit.js +41 -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 +7 -0
  40. package/src/lib/components/filter/filter.js +42 -0
  41. package/src/lib/components/filter/filter.js.map +1 -0
  42. package/src/lib/components/filter/filter.types.d.ts +14 -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 +6 -0
  46. package/src/lib/components/filter/flag/filter-flag.js +19 -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 +11 -0
  52. package/src/lib/components/filter/int/filter-int.js +45 -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 +9 -0
  61. package/src/lib/components/filters/filters.js +19 -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 +16 -0
  70. package/src/lib/components/filters/use-crud-filters.js +62 -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 +37 -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 +9 -0
  79. package/src/lib/components/group/group.js +18 -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 +16 -0
  88. package/src/lib/components/group/use-crud-group.js +48 -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 +9 -0
  94. package/src/lib/components/multiselect/multiselect.js +24 -0
  95. package/src/lib/components/multiselect/multiselect.js.map +1 -0
  96. package/src/lib/components/multiselect/use-crud-multiselect.d.ts +23 -0
  97. package/src/lib/components/multiselect/use-crud-multiselect.js +71 -0
  98. package/src/lib/components/multiselect/use-crud-multiselect.js.map +1 -0
  99. package/src/lib/crud.config.d.ts +66 -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 +68 -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 +31 -0
  121. package/src/lib/pages/crud-pages.js +63 -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 +15 -0
  127. package/src/lib/pages/item/item-page.js +28 -0
  128. package/src/lib/pages/item/item-page.js.map +1 -0
  129. package/src/lib/pages/item/item-page.types.d.ts +43 -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 +8 -0
  133. package/src/lib/pages/item/standard/item-page-standard.js +17 -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 +21 -0
  136. package/src/lib/pages/item/use-crud-item-page-base.js +46 -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 +296 -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 +14 -0
  142. package/src/lib/pages/list/list-page.js +29 -0
  143. package/src/lib/pages/list/list-page.js.map +1 -0
  144. package/src/lib/pages/list/list-page.types.d.ts +25 -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 +11 -0
  148. package/src/lib/pages/list/standard/list-page-standard.js +26 -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 +307 -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 +9 -0
  154. package/src/lib/pages/use-crud-bound-component.js +27 -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 +8 -0
  157. package/src/lib/pages/use-crud-page-config.js +18 -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 +43 -0
  163. package/src/lib/services/crud/crud.service.js +112 -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 +19 -0
  178. package/src/lib/state/crud.effects.js +127 -0
  179. package/src/lib/state/crud.effects.js.map +1 -0
  180. package/src/lib/state/crud.facade.d.ts +42 -0
  181. package/src/lib/state/crud.facade.js +92 -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 +24 -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,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, for `SmartCrudItemPage` or a page of your own
8
+ * 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`): the mode
30
+ * is set once, when the page is created.
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,296 @@
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, for `SmartCrudItemPage` or a page of your own
62
+ * 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`): the mode
84
+ * is set once, when the page is created.
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: the details set the root while rendering.
98
+ (0, react_1.useState)(() => detailsService.init());
99
+ const formRef = (0, react_1.useRef)(null);
100
+ const formValue = (0, react_1.useRef)(undefined);
101
+ const formPartialValue = (0, react_1.useRef)(undefined);
102
+ // The last reported validity; the buttons validate the form itself.
103
+ const formValid = (0, react_1.useRef)(false);
104
+ const idRef = (0, react_1.useRef)(id);
105
+ (0, react_1.useEffect)(() => {
106
+ idRef.current = id;
107
+ });
108
+ (0, react_1.useEffect)(() => {
109
+ if (id !== undefined)
110
+ facade.select(id);
111
+ }, [facade, id]);
112
+ (0, react_1.useEffect)(() => {
113
+ if (create)
114
+ return undefined;
115
+ const check = (url) => {
116
+ if (hasEditParam(url))
117
+ setMode('update');
118
+ };
119
+ check(navigation.getCurrentUrl());
120
+ return navigation.subscribe(check);
121
+ }, [create, navigation]);
122
+ // One provider for the page's lifetime: it is part of the form options,
123
+ // and a new one would build the form again.
124
+ const uniqueProvider = (0, react_1.useCallback)(async (values) => {
125
+ const query = [];
126
+ const filter = { query };
127
+ Object.keys(values).forEach((key) => {
128
+ query.push({
129
+ key: key,
130
+ value: values[key],
131
+ type: '=',
132
+ });
133
+ });
134
+ if (idRef.current) {
135
+ query.push({ key: 'id', value: idRef.current, type: '!=' });
136
+ }
137
+ const { totalCount } = await service.getList(filter);
138
+ return !totalCount;
139
+ }, [service]);
140
+ const onPartialChange = (0, react_1.useCallback)((val) => {
141
+ formPartialValue.current = val;
142
+ }, []);
143
+ const onChange = (0, react_1.useCallback)((val) => {
144
+ formValue.current = val;
145
+ }, []);
146
+ const onValidChange = (0, react_1.useCallback)((val) => {
147
+ formValid.current = val;
148
+ }, []);
149
+ const checkFirstInvalid = (0, react_1.useCallback)(() => {
150
+ const form = formRef.current;
151
+ // Nothing has been built yet, so there is nothing valid to submit.
152
+ if (!form)
153
+ return true;
154
+ if (form.valid)
155
+ return false;
156
+ const invalidFields = [];
157
+ getInvalidFields(form, invalidFields, '', t);
158
+ void toastService.info({
159
+ title: t('INPUT.ERRORS.requires'),
160
+ message: invalidFields.slice(0, 3).join('<br/>'),
161
+ });
162
+ return true;
163
+ }, [t, toastService]);
164
+ const leave = (0, react_1.useCallback)(() => {
165
+ if (basePath !== undefined)
166
+ navigation.navigate(basePath);
167
+ else
168
+ navigation.back();
169
+ }, [basePath, navigation]);
170
+ const modelOptions = (0, react_1.useMemo)(() => (0, models_1.getModelOptions)(config.type), [config]);
171
+ const endButtons = (0, react_1.useMemo)(() => {
172
+ switch (mode) {
173
+ case 'create':
174
+ return [
175
+ {
176
+ icon: 'add',
177
+ text: 'add',
178
+ handler: () => {
179
+ if (checkFirstInvalid())
180
+ return;
181
+ facade.create(formValue.current);
182
+ leave();
183
+ },
184
+ },
185
+ ];
186
+ case 'update':
187
+ return [
188
+ ...(config.details
189
+ ? [
190
+ {
191
+ icon: 'close',
192
+ text: 'cancel',
193
+ handler: () => setMode('details'),
194
+ disabled: false,
195
+ },
196
+ ]
197
+ : []),
198
+ {
199
+ icon: 'save',
200
+ text: 'save',
201
+ handler: () => {
202
+ if (checkFirstInvalid())
203
+ return;
204
+ facade.updatePartial({
205
+ ...formPartialValue.current,
206
+ id: id,
207
+ });
208
+ if (config.details)
209
+ setMode('details');
210
+ else
211
+ leave();
212
+ },
213
+ },
214
+ ];
215
+ case 'details':
216
+ return config.edit &&
217
+ (!modelOptions?.update?.enabled ||
218
+ utils_1.SpecificationService.valid(selected, modelOptions.update.enabled))
219
+ ? [
220
+ {
221
+ icon: 'create',
222
+ text: 'edit',
223
+ handler: () => setMode('update'),
224
+ disabled: false,
225
+ },
226
+ ]
227
+ : [];
228
+ default:
229
+ return undefined;
230
+ }
231
+ }, [
232
+ mode,
233
+ config,
234
+ modelOptions,
235
+ selected,
236
+ id,
237
+ facade,
238
+ checkFirstInvalid,
239
+ leave,
240
+ ]);
241
+ const title = (0, react_1.useMemo)(() => {
242
+ const titleKey = modelOptions?.titleKey;
243
+ const prefix = titleKey && selected
244
+ ? removeParagraph(selected[titleKey]) + ' - '
245
+ : '';
246
+ switch (mode) {
247
+ case 'create':
248
+ return 'add';
249
+ case 'update':
250
+ return prefix + t('change');
251
+ case 'details':
252
+ return prefix + t('details');
253
+ default:
254
+ return undefined;
255
+ }
256
+ }, [mode, modelOptions, selected, t]);
257
+ const pageOptions = (0, react_1.useMemo)(() => ({
258
+ title: title || '',
259
+ variant: config.variant,
260
+ showBackButton: true,
261
+ hideMenuButton: true,
262
+ endButtons,
263
+ }), [title, config, endButtons]);
264
+ const detailsOptions = (0, react_1.useMemo)(() => {
265
+ if (!config.details)
266
+ return undefined;
267
+ const slots = getSlots(config.details);
268
+ return {
269
+ type: config.type,
270
+ item: selected,
271
+ cellPipe: config.details.cellPipe,
272
+ componentFactories: { top: slots?.top, bottom: slots?.bottom },
273
+ };
274
+ }, [config, selected]);
275
+ const slots = mode === 'create'
276
+ ? getSlots(config.add)
277
+ : mode === 'update'
278
+ ? getSlots(config.edit)
279
+ : undefined;
280
+ const TopComponent = slots?.top;
281
+ const BottomComponent = slots?.bottom;
282
+ return {
283
+ config,
284
+ mode,
285
+ pageOptions,
286
+ detailsOptions,
287
+ uniqueProvider,
288
+ onPartialChange,
289
+ onChange,
290
+ onValidChange,
291
+ formRef,
292
+ TopComponent,
293
+ BottomComponent,
294
+ };
295
+ }
296
+ //# 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,0CA2PC;AA5XD,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,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,GAAG,CAAC;QACtB,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,14 @@
1
+ import { IEntity } from '@smartsoft001/domain-core';
2
+ import { SmartCrudListPageProps } from './list-page.types';
3
+ /**
4
+ * The list page of a CRUD feature: a `SmartPage` with the title, search and
5
+ * end buttons of `useCrudListPage`, `config.list.components.top`, and the
6
+ * body: the one registered as `components['crud-list-page']` on
7
+ * `SmartProvider`, else `SmartCrudListPageStandard`. Renders nothing until
8
+ * the feature's filter is set by the first read. Render it inside the
9
+ * feature's `CrudProvider` with a `CrudFullConfig`.
10
+ *
11
+ * A registered body renders in the `.dynamic-content` element. The list
12
+ * options are built synchronously, so the body never gets `null` ones.
13
+ */
14
+ export declare function SmartCrudListPage<T extends IEntity<string>>(props: SmartCrudListPageProps): import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,29 @@
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
+ * The list page of a CRUD feature: a `SmartPage` with the title, search and
10
+ * end buttons of `useCrudListPage`, `config.list.components.top`, and the
11
+ * body: the one registered as `components['crud-list-page']` on
12
+ * `SmartProvider`, else `SmartCrudListPageStandard`. Renders nothing until
13
+ * the feature's filter is set by the first read. Render it inside the
14
+ * feature's `CrudProvider` with a `CrudFullConfig`.
15
+ *
16
+ * A registered body renders in the `.dynamic-content` element. The list
17
+ * options are built synchronously, so the body never gets `null` ones.
18
+ */
19
+ function SmartCrudListPage(props) {
20
+ const { children } = props;
21
+ const { config, filter, pageOptions, listOptions, TopComponent } = (0, use_crud_list_page_1.useCrudListPage)(props);
22
+ const Body = (0, react_1.useSmartComponent)('crud-list-page', list_page_standard_1.SmartCrudListPageStandard);
23
+ const standard = Body === list_page_standard_1.SmartCrudListPageStandard;
24
+ if (!filter)
25
+ return null;
26
+ const body = (0, jsx_runtime_1.jsx)(Body, { listOptions: listOptions, children: children });
27
+ 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 })] }));
28
+ }
29
+ //# 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":";;AAqBA,8CAwBC;;AA5CD,+CAAmE;AAMnE,sEAA0E;AAC1E,6DAAuD;AAEvD;;;;;;;;;;GAUG;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,25 @@
1
+ import type { ReactNode } from 'react';
2
+ import { IEntity } from '@smartsoft001/domain-core';
3
+ import { IListOptions } from '@smartsoft001/react';
4
+ /** The props of `<SmartCrudListPage>`. */
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 path of the
9
+ * navigation adapter's current URL when omitted.
10
+ */
11
+ basePath?: string;
12
+ /**
13
+ * Handed to the body. The standard body does not render it; a body
14
+ * registered as `crud-list-page` can.
15
+ */
16
+ children?: ReactNode;
17
+ }
18
+ /**
19
+ * The props of the list page body: `SmartCrudListPageStandard` or a body
20
+ * registered as `components['crud-list-page']` on `SmartProvider`.
21
+ */
22
+ export interface SmartCrudListPageBodyProps<T extends IEntity<string> = any> {
23
+ listOptions: IListOptions<T> | null;
24
+ children?: ReactNode;
25
+ }
@@ -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,11 @@
1
+ import { IEntity } from '@smartsoft001/domain-core';
2
+ import { SmartCrudListPageBodyProps } from '../list-page.types';
3
+ /**
4
+ * The default list page body: the active filters (`SmartCrudFiltersConfig`)
5
+ * and `SmartList`; with `config.list.groups` the list is hidden behind
6
+ * `SmartCrudGroup` unless a text is searched. `children` are not rendered.
7
+ *
8
+ * The list is hidden through a `div` around it, rendered only when there are
9
+ * groups.
10
+ */
11
+ export declare function SmartCrudListPageStandard<T extends IEntity<string>>({ listOptions, }: SmartCrudListPageBodyProps<T>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SmartCrudListPageStandard = SmartCrudListPageStandard;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("@smartsoft001/react");
6
+ const filters_config_1 = require("../../../components/filters-config/filters-config");
7
+ const group_1 = require("../../../components/group/group");
8
+ const crud_context_1 = require("../../../crud.context");
9
+ const hooks_1 = require("../../../hooks");
10
+ /**
11
+ * The default list page body: the active filters (`SmartCrudFiltersConfig`)
12
+ * and `SmartList`; with `config.list.groups` the list is hidden behind
13
+ * `SmartCrudGroup` unless a text is searched. `children` are not rendered.
14
+ *
15
+ * The list is hidden through a `div` around it, rendered only when there are
16
+ * groups.
17
+ */
18
+ function SmartCrudListPageStandard({ listOptions, }) {
19
+ const config = (0, crud_context_1.useCrudConfig)();
20
+ const isSearch = (0, hooks_1.useCrudState)((state) => !!state.filter?.searchText);
21
+ const groups = config.list?.groups;
22
+ const hideList = !!groups && !isSearch;
23
+ const list = listOptions ? (0, jsx_runtime_1.jsx)(react_1.SmartList, { options: listOptions }) : null;
24
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(filters_config_1.SmartCrudFiltersConfig, {}), groups ? (0, jsx_runtime_1.jsx)("div", { hidden: hideList || undefined, children: list }) : list, groups && !isSearch ? ((0, jsx_runtime_1.jsx)(group_1.SmartCrudGroup, { groups: groups, listOptions: listOptions || null })) : null] }));
25
+ }
26
+ //# sourceMappingURL=list-page-standard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list-page-standard.js","sourceRoot":"","sources":["../../../../../../../../../../packages/crud/shell/react/src/lib/pages/list/standard/list-page-standard.tsx"],"names":[],"mappings":";;AAiBA,8DAqBC;;AArCD,+CAAgD;AAEhD,sFAA2F;AAC3F,2DAAiE;AACjE,wDAAsD;AACtD,0CAA8C;AAG9C;;;;;;;GAOG;AACH,SAAgB,yBAAyB,CAA4B,EACnE,WAAW,GACmB;IAC9B,MAAM,MAAM,GAAG,IAAA,4BAAa,GAAK,CAAC;IAClC,MAAM,QAAQ,GAAG,IAAA,oBAAY,EAC3B,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,EAAE,UAAU,CACtC,CAAC;IACF,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC;IACnC,MAAM,QAAQ,GAAG,CAAC,CAAC,MAAM,IAAI,CAAC,QAAQ,CAAC;IAEvC,MAAM,IAAI,GAAG,WAAW,CAAC,CAAC,CAAC,uBAAC,iBAAS,IAAC,OAAO,EAAE,WAAW,GAAI,CAAC,CAAC,CAAC,IAAI,CAAC;IAEtE,OAAO,CACL,6DACE,uBAAC,uCAAsB,KAAG,EACzB,MAAM,CAAC,CAAC,CAAC,gCAAK,MAAM,EAAE,QAAQ,IAAI,SAAS,YAAG,IAAI,GAAO,CAAC,CAAC,CAAC,IAAI,EAChE,MAAM,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CACrB,uBAAC,sBAAc,IAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,WAAW,IAAI,IAAI,GAAI,CACrE,CAAC,CAAC,CAAC,IAAI,IACP,CACJ,CAAC;AACJ,CAAC"}
@@ -0,0 +1,35 @@
1
+ import type { ComponentType } from 'react';
2
+ import { IEntity } from '@smartsoft001/domain-core';
3
+ import { IListOptions, IPageOptions } from '@smartsoft001/react';
4
+ import { SmartCrudListPageProps } from './list-page.types';
5
+ import { CrudFullConfig } from '../../crud.config';
6
+ import { ICrudFilter } from '../../models';
7
+ /**
8
+ * The logic of the list page, for `SmartCrudListPage` or a page of your own
9
+ * around the same feature:
10
+ *
11
+ * - `config`: the `CrudFullConfig` after the model's permissions;
12
+ * - the first read on mount (pagination, default sort, base query and the
13
+ * enabled `CrudSearchService` filter; `list.resetQuery: 'beforeInit'`
14
+ * starts from the defaults instead of the feature's filter);
15
+ * - `pageOptions`: the title, `variant`, the search (`config.search`) and the
16
+ * end buttons: multi edit, filters (`SmartCrudFilters` in the end menu),
17
+ * add (navigates to `<basePath>/add`), export (`SmartCrudExport` in a
18
+ * modal) and `config.buttons`;
19
+ * - `listOptions` for `SmartList`: the feature's items and loading, details
20
+ * through the facade, item links to `<basePath>/<id>`, remove through the
21
+ * facade (the list confirms it), the pagination of
22
+ * `useCrudListPagination`, sort and the multi selection (it opens
23
+ * `SmartCrudMultiselect` in the end menu);
24
+ * - `filter`: the feature's filter (the page renders once it is set);
25
+ * - `TopComponent`: `config.list.components.top`.
26
+ *
27
+ * A navigation closes the end menu and ends the multi selection.
28
+ */
29
+ export declare function useCrudListPage<T extends IEntity<string>>({ basePath, }?: SmartCrudListPageProps): {
30
+ config: CrudFullConfig<T>;
31
+ filter: ICrudFilter | null | undefined;
32
+ pageOptions: IPageOptions;
33
+ listOptions: IListOptions<T>;
34
+ TopComponent: ComponentType | undefined;
35
+ };