@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,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=filters.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filters.types.js","sourceRoot":"","sources":["../../../../../../../../../packages/crud/shell/react/src/lib/components/filters/filters.types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ export * from './filters';
2
+ export * from './filters.types';
3
+ export * from './use-crud-filters';
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./filters"), exports);
5
+ tslib_1.__exportStar(require("./filters.types"), exports);
6
+ tslib_1.__exportStar(require("./use-crud-filters"), exports);
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../../packages/crud/shell/react/src/lib/components/filters/index.ts"],"names":[],"mappings":";;;AAAA,oDAA0B;AAC1B,0DAAgC;AAChC,6DAAmC"}
@@ -0,0 +1,16 @@
1
+ import { IEntity } from '@smartsoft001/domain-core';
2
+ import { IModelFilter } from '@smartsoft001/models';
3
+ import { SmartCrudFiltersProps } from './filters.types';
4
+ /**
5
+ * The behaviour of the filters panel: `list` holds the filters of
6
+ * `config.type`, `filter` the current filter of the feature, and `onClose`
7
+ * closes the end menu the panel is shown in. Attach `elementRef` to the root
8
+ * element: it gets the application style.
9
+ */
10
+ export declare function useCrudFilters<T extends IEntity<string>>({ hideMenu, }?: SmartCrudFiltersProps): {
11
+ elementRef: import("react").RefObject<HTMLDivElement | null>;
12
+ hideMenu: boolean;
13
+ list: IModelFilter[];
14
+ filter: import("../../models").ICrudFilter | null | undefined;
15
+ onClose: () => Promise<void>;
16
+ };
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useCrudFilters = useCrudFilters;
4
+ const react_1 = require("react");
5
+ const models_1 = require("@smartsoft001/models");
6
+ const react_2 = require("@smartsoft001/react");
7
+ const crud_context_1 = require("../../crud.context");
8
+ const hooks_1 = require("../../hooks");
9
+ /**
10
+ * The filters of the model `type`: the model's `filters` (labelled
11
+ * `MODEL.<key>` when they have no label — set on the model's filter itself),
12
+ * then a filter for each field with `list.filter`: `~=` for text fields, `=`
13
+ * for the others.
14
+ */
15
+ function getFilters(type) {
16
+ const modelFilters = (0, models_1.getModelOptions)(type)?.filters;
17
+ return [
18
+ ...(modelFilters
19
+ ? modelFilters.map((item) => {
20
+ if (!item.label) {
21
+ item.label = 'MODEL.' + item.key;
22
+ }
23
+ return item;
24
+ })
25
+ : []),
26
+ ...(0, models_1.getModelFieldsWithOptions)(new type())
27
+ .filter((item) => item.options?.list?.filter)
28
+ .map((item) => ({
29
+ key: item.key,
30
+ type: item.options.type === models_1.FieldType.text ||
31
+ item.options.type === models_1.FieldType.longText
32
+ ? '~='
33
+ : '=',
34
+ label: 'MODEL.' + item.key,
35
+ fieldType: item.options.type,
36
+ })),
37
+ ];
38
+ }
39
+ /**
40
+ * The behaviour of the filters panel: `list` holds the filters of
41
+ * `config.type`, `filter` the current filter of the feature, and `onClose`
42
+ * closes the end menu the panel is shown in. Attach `elementRef` to the root
43
+ * element: it gets the application style.
44
+ */
45
+ function useCrudFilters({ hideMenu = false, } = {}) {
46
+ const config = (0, crud_context_1.useCrudConfig)();
47
+ const menuService = (0, react_2.useMenuService)();
48
+ const styleService = (0, react_2.useStyleService)();
49
+ const elementRef = (0, react_1.useRef)(null);
50
+ const filter = (0, hooks_1.useCrudState)((state) => state.filter);
51
+ const list = (0, react_1.useMemo)(() => getFilters(config.type), [config.type]);
52
+ // A local service writes the style, so the shared one is not redirected
53
+ // to this element.
54
+ (0, react_1.useEffect)(() => {
55
+ new react_2.StyleService().init(elementRef.current, styleService.get());
56
+ }, [styleService]);
57
+ const onClose = (0, react_1.useCallback)(async () => {
58
+ await menuService.closeEnd();
59
+ }, [menuService]);
60
+ return { elementRef, hideMenu, list, filter, onClose };
61
+ }
62
+ //# sourceMappingURL=use-crud-filters.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-crud-filters.js","sourceRoot":"","sources":["../../../../../../../../../packages/crud/shell/react/src/lib/components/filters/use-crud-filters.ts"],"names":[],"mappings":";;AA2DA,wCAsBC;AAjFD,iCAAgE;AAGhE,iDAM8B;AAC9B,+CAI6B;AAG7B,qDAAmD;AACnD,uCAA2C;AAE3C;;;;;GAKG;AACH,SAAS,UAAU,CAAC,IAAsB;IACxC,MAAM,YAAY,GAAG,IAAA,wBAAe,EAAC,IAAI,CAAC,EAAE,OAAO,CAAC;IAEpD,OAAO;QACL,GAAG,CAAC,YAAY;YACd,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;gBACxB,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;oBAChB,IAAI,CAAC,KA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C;IAEnE,wEAAwE;IACxE,mBAAmB;IACnB,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,IAAI,oBAAY,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,YAAY,CAAC,GAAG,EAAE,CAAC,CAAC;IAClE,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC;IAEnB,MAAM,OAAO,GAAG,IAAA,mBAAW,EAAC,KAAK,IAAmB,EAAE;QACpD,MAAM,WAAW,CAAC,QAAQ,EAAE,CAAC;IAC/B,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC;IAElB,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;AACzD,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * The active filters of the CRUD feature (the visible items of
3
+ * `filter.query`) as chips; clicking a chip removes the item and reads the
4
+ * list again. Render it inside `<CrudProvider>`.
5
+ */
6
+ export declare function SmartCrudFiltersConfig(): import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SmartCrudFiltersConfig = SmartCrudFiltersConfig;
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 hooks_1 = require("../../hooks");
9
+ // A text value is translated, any other value is shown as it is.
10
+ function translateValue(t, value) {
11
+ if (value === null || value === undefined)
12
+ return '';
13
+ if (typeof value === 'string')
14
+ return t(value);
15
+ return String(value);
16
+ }
17
+ /**
18
+ * The active filters of the CRUD feature (the visible items of
19
+ * `filter.query`) as chips; clicking a chip removes the item and reads the
20
+ * list again. Render it inside `<CrudProvider>`.
21
+ */
22
+ function SmartCrudFiltersConfig() {
23
+ const t = (0, react_2.useTranslate)();
24
+ const facade = (0, crud_context_1.useCrudFacade)();
25
+ const filter = (0, hooks_1.useCrudState)((state) => state.filter);
26
+ const query = (0, react_1.useMemo)(() => filter?.query?.filter((i) => !i.hidden) || [], [filter]);
27
+ const onRemoveQuery = (item) => {
28
+ const current = facade.filter;
29
+ facade.read(current?.query
30
+ ? { ...current, query: current.query.filter((i) => i !== item) }
31
+ : current);
32
+ };
33
+ if (!query.length)
34
+ return null;
35
+ return ((0, jsx_runtime_1.jsx)("div", { className: "smart:flex smart:flex-wrap smart:gap-2 smart:px-4 smart:py-2", children: query.map((item, index) => ((0, jsx_runtime_1.jsxs)("button", { type: "button", onClick: () => onRemoveQuery(item), className: "smart:inline-flex smart:items-center smart:gap-1 smart:rounded-full smart:border smart:border-gray-300 smart:bg-gray-50 smart:px-3 smart:py-1 smart:text-sm smart:text-gray-700 smart:hover:bg-gray-100", "aria-label": t('remove') + ' ' + t('MODEL.' + item.key), children: [(0, jsx_runtime_1.jsxs)("span", { children: [t('MODEL.' + item.key), " ", item.type, " ", translateValue(t, item.value)] }), (0, jsx_runtime_1.jsx)("span", { "aria-hidden": "true", className: "smart:text-red-600", children: "\u2715" })] }, `${index}:${item.key}:${item.type}`))) }));
36
+ }
37
+ //# sourceMappingURL=filters-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filters-config.js","sourceRoot":"","sources":["../../../../../../../../../packages/crud/shell/react/src/lib/components/filters-config/filters-config.tsx"],"names":[],"mappings":";;AAsBA,wDA0CC;;AAhED,iCAAgC;AAEhC,+CAAmD;AAGnD,qDAAmD;AACnD,uCAA2C;AAG3C,iEAAiE;AACjE,SAAS,cAAc,CAAC,CAAmB,EAAE,KAAc;IACzD,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,EAAE,CAAC;IACrD,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC;IAE/C,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC;AAED;;;;GAIG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G,CAAC,OAAG,IAAI,CAAC,IAAI,OAAG,cAAc,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,IAC9D,EACP,gDAAkB,MAAM,EAAC,SAAS,EAAC,oBAAoB,uBAEhD,KAXF,GAAG,KAAK,IAAI,IAAI,CAAC,GAAG,IAAI,IAAI,CAAC,IAAI,EAAE,CAYjC,CACV,CAAC,GACE,CACP,CAAC;AACJ,CAAC"}
@@ -0,0 +1 @@
1
+ export * from './filters-config';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./filters-config"), exports);
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../../packages/crud/shell/react/src/lib/components/filters-config/index.ts"],"names":[],"mappings":";;;AAAA,2DAAiC"}
@@ -0,0 +1,9 @@
1
+ import { IEntity } from '@smartsoft001/domain-core';
2
+ import { SmartCrudGroupProps } from './group.types';
3
+ /**
4
+ * The list grouped by `groups`, each group an accessible disclosure — a
5
+ * button with `aria-expanded` / `aria-controls` and its region. An open group
6
+ * shows the list with `listOptions`, or its `children` groups. Render it
7
+ * inside `<CrudProvider>`.
8
+ */
9
+ export declare function SmartCrudGroup<T extends IEntity<string>>(props: SmartCrudGroupProps<T>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SmartCrudGroup = SmartCrudGroup;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("@smartsoft001/react");
6
+ const use_crud_group_1 = require("./use-crud-group");
7
+ /**
8
+ * The list grouped by `groups`, each group an accessible disclosure — a
9
+ * button with `aria-expanded` / `aria-controls` and its region. An open group
10
+ * shows the list with `listOptions`, or its `children` groups. Render it
11
+ * inside `<CrudProvider>`.
12
+ */
13
+ function SmartCrudGroup(props) {
14
+ const t = (0, react_1.useTranslate)();
15
+ const { groups, listOptions, change } = (0, use_crud_group_1.useCrudGroup)(props);
16
+ return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: groups?.map((item) => ((0, jsx_runtime_1.jsxs)("div", { className: "smart:border-b smart:border-gray-200", children: [(0, jsx_runtime_1.jsxs)("button", { type: "button", onClick: () => change(!item.show, item), "aria-expanded": item.show || false, "aria-controls": 'smart-crud-group-' + item.key, className: (0, react_1.cn)('smart:flex smart:w-full smart:items-center smart:justify-between smart:py-3 smart:text-left smart:text-sm', item.show && 'smart:font-bold'), children: [(0, jsx_runtime_1.jsx)("span", { children: t(item.text) }), (0, jsx_runtime_1.jsx)("span", { "aria-hidden": "true", className: "smart:text-gray-500", children: item.show ? '▾' : '▸' })] }), item.show && ((0, jsx_runtime_1.jsxs)("div", { id: 'smart-crud-group-' + item.key, className: "smart:pb-3", children: [!item.children && listOptions && ((0, jsx_runtime_1.jsx)(react_1.SmartList, { options: listOptions })), item.children && ((0, jsx_runtime_1.jsx)("div", { className: "smart:ml-12", children: (0, jsx_runtime_1.jsx)(SmartCrudGroup, { groups: item.children, listOptions: listOptions }) }))] }))] }, item.key))) }));
17
+ }
18
+ //# sourceMappingURL=group.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"group.js","sourceRoot":"","sources":["../../../../../../../../../packages/crud/shell/react/src/lib/components/group/group.tsx"],"names":[],"mappings":";;AAYA,wCA4CC;;AAvDD,+CAAkE;AAGlE,qDAAgD;AAEhD;;;;;GAKG;AACH,SAAgB,cAAc,CAC5B,KAA6B;IAE7B,MAAM,CAAC,GAAG,IAAA,oBAAY,GAAE,CAAC;IACzB,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,GAAG,IAAA,6BAAY,EAAI,KAAK,CAAC,CAAC;IAE/D,OAAO,CACL,2DACG,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CACrB,iCAAoB,SAAS,EAAC,sCAAsC,aAClE,oCACE,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,mBACxB,IAAI,CAAC,IAAI,IAAI,KAAK,mBAClB,mBAAmB,GAAG,IAAI,CAAC,GAAG,EAC7C,SAAS,EAAE,IAAA,UAAE,EACX,2GAA2G,EAC3G,IAAI,CAAC,IAAI,IAAI,iBAAiB,CAC/B,aAED,2CAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAQ,EAC3B,gDAAkB,MAAM,EAAC,SAAS,EAAC,qBAAqB,YACrD,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,GACjB,IACA,EACR,IAAI,CAAC,IAAI,IAAI,CACZ,iCAAK,EAAE,EAAE,mBAAmB,GAAG,IAAI,CAAC,GAAG,EAAE,SAAS,EAAC,YAAY,aAC5D,CAAC,IAAI,CAAC,QAAQ,IAAI,WAAW,IAAI,CAChC,uBAAC,iBAAS,IAAC,OAAO,EAAE,WAAW,GAAI,CACpC,EACA,IAAI,CAAC,QAAQ,IAAI,CAChB,gCAAK,SAAS,EAAC,aAAa,YAC1B,uBAAC,cAAc,IACb,MAAM,EAAE,IAAI,CAAC,QAAQ,EACrB,WAAW,EAAE,WAAW,GACxB,GACE,CACP,IACG,CACP,KA9BO,IAAI,CAAC,GAAG,CA+BZ,CACP,CAAC,GACD,CACJ,CAAC;AACJ,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { IEntity } from '@smartsoft001/domain-core';
2
+ import { IListOptions } from '@smartsoft001/react';
3
+ import { ICrudListGroup } from '../../models';
4
+ /** The props of `<SmartCrudGroup>`. */
5
+ export interface SmartCrudGroupProps<T extends IEntity<string>> {
6
+ groups?: Array<ICrudListGroup> | null;
7
+ listOptions?: IListOptions<T> | null;
8
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=group.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"group.types.js","sourceRoot":"","sources":["../../../../../../../../../packages/crud/shell/react/src/lib/components/group/group.types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ export * from './group';
2
+ export * from './group.types';
3
+ export * from './use-crud-group';
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./group"), exports);
5
+ tslib_1.__exportStar(require("./group.types"), exports);
6
+ tslib_1.__exportStar(require("./use-crud-group"), exports);
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../../packages/crud/shell/react/src/lib/components/group/index.ts"],"names":[],"mappings":";;;AAAA,kDAAwB;AACxB,wDAA8B;AAC9B,2DAAiC"}
@@ -0,0 +1,16 @@
1
+ import { IEntity } from '@smartsoft001/domain-core';
2
+ import { SmartCrudGroupProps } from './group.types';
3
+ import { ICrudListGroup } from '../../models';
4
+ /**
5
+ * The behaviour of the list groups. `change(val, item)` closes the other
6
+ * groups, filters the list by the group through `CrudListGroupService` and
7
+ * sets `item.show` — on the next tick when opening (the list reads first), at
8
+ * once when closing. The groups are plain objects changed in place; the hook
9
+ * re-renders after each change. When the component goes away, the service drops the query
10
+ * items of the groups again.
11
+ */
12
+ export declare function useCrudGroup<T extends IEntity<string>>({ groups, listOptions, }: SmartCrudGroupProps<T>): {
13
+ groups: ICrudListGroup[] | null;
14
+ listOptions: import("dist/packages/shared/react/src").IListOptions<T> | null;
15
+ change: (val: boolean, item: ICrudListGroup, force?: boolean) => void;
16
+ };
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useCrudGroup = useCrudGroup;
4
+ const react_1 = require("react");
5
+ const crud_context_1 = require("../../crud.context");
6
+ /**
7
+ * The behaviour of the list groups. `change(val, item)` closes the other
8
+ * groups, filters the list by the group through `CrudListGroupService` and
9
+ * sets `item.show` — on the next tick when opening (the list reads first), at
10
+ * once when closing. The groups are plain objects changed in place; the hook
11
+ * re-renders after each change. When the component goes away, the service drops the query
12
+ * items of the groups again.
13
+ */
14
+ function useCrudGroup({ groups = null, listOptions = null, }) {
15
+ const groupService = (0, crud_context_1.useCrudListGroupService)();
16
+ const [, rerender] = (0, react_1.useReducer)((tick) => tick + 1, 0);
17
+ const latest = (0, react_1.useRef)({ groups, groupService });
18
+ (0, react_1.useEffect)(() => {
19
+ latest.current = { groups, groupService };
20
+ });
21
+ (0, react_1.useEffect)(() => () => {
22
+ const current = latest.current;
23
+ if (current.groups)
24
+ current.groupService.destroy(current.groups);
25
+ }, []);
26
+ const change = (0, react_1.useCallback)((val, item, force = false) => {
27
+ if (groups) {
28
+ groups
29
+ .filter((i) => i.value !== item.value || i.key !== item.key)
30
+ .forEach((i) => {
31
+ i.show = false;
32
+ });
33
+ }
34
+ groupService.change(val, item, force);
35
+ if (val) {
36
+ setTimeout(() => {
37
+ item.show = val;
38
+ rerender();
39
+ });
40
+ }
41
+ else {
42
+ item.show = val;
43
+ rerender();
44
+ }
45
+ }, [groups, groupService]);
46
+ return { groups, listOptions, change };
47
+ }
48
+ //# sourceMappingURL=use-crud-group.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-crud-group.js","sourceRoot":"","sources":["../../../../../../../../../packages/crud/shell/react/src/lib/components/group/use-crud-group.ts"],"names":[],"mappings":";;AAgBA,oCA+CC;AA/DD,iCAAmE;AAKnE,qDAA6D;AAG7D;;;;;;;GAOG;AACH,SAAgB,YAAY,CAA4B,EACtD,MAAM,GAAG,IAAI,EACb,WAAW,GAAG,IAAI,GACK;IACvB,MAAM,YAAY,GAAG,IAAA,sCAAuB,GAAK,CAAC;IAClD,MAAM,CAAC,EAAE,QAAQ,CAAC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,GAAG,GAAG,CAAC;YAChB,QAAQ,EAAE,CAAC;QACb,CAAC;IACH,CAAC,EACD,CAAC,MAAM,EAAE,YAAY,CAAC,CACvB,CAAC;IAEF,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC;AACzC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './multiselect';
2
+ export * from './use-crud-multiselect';
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./multiselect"), exports);
5
+ tslib_1.__exportStar(require("./use-crud-multiselect"), exports);
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../../packages/crud/shell/react/src/lib/components/multiselect/index.ts"],"names":[],"mappings":";;;AAAA,wDAA8B;AAC9B,iEAAuC"}
@@ -0,0 +1,9 @@
1
+ import { IEntity } from '@smartsoft001/domain-core';
2
+ /**
3
+ * The panel of the items selected in the list, opened in the end menu. A
4
+ * header with the count and a close button, the `config.list.components.multi`
5
+ * component with the selected `items`, and the `multiUpdate` form of the
6
+ * model with the button applying it to every selected item. Render it inside
7
+ * `<CrudProvider>`.
8
+ */
9
+ export declare function SmartCrudMultiselect<T extends IEntity<string>>(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SmartCrudMultiselect = SmartCrudMultiselect;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ const react_2 = require("@smartsoft001/react");
7
+ const use_crud_multiselect_1 = require("./use-crud-multiselect");
8
+ const form_options_1 = require("../../factories/form-options");
9
+ /**
10
+ * The panel of the items selected in the list, opened in the end menu. A
11
+ * header with the count and a close button, the `config.list.components.multi`
12
+ * component with the selected `items`, and the `multiUpdate` form of the
13
+ * model with the button applying it to every selected item. Render it inside
14
+ * `<CrudProvider>`.
15
+ */
16
+ function SmartCrudMultiselect() {
17
+ const t = (0, react_2.useTranslate)();
18
+ const { config, list, item, showForm, lock, valid, buttonOptions, onClose, onPartialChange, onValidChange, } = (0, use_crud_multiselect_1.useCrudMultiselect)();
19
+ const Multi = config?.list?.components?.multi;
20
+ // The `multiUpdate` form options of the shared values.
21
+ const formOptions = (0, react_1.useMemo)(() => (0, form_options_1.getCrudFormOptions)(item, 'multiUpdate', config.type), [item, config.type]);
22
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("header", { className: "smart:flex smart:items-center smart:justify-between smart:border-b smart:border-gray-200 smart:px-4 smart:py-3", children: [(0, jsx_runtime_1.jsxs)("h2", { className: "smart:text-lg smart:font-semibold smart:text-gray-900", children: [t('selected'), ": ", list.length] }), (0, jsx_runtime_1.jsx)("button", { type: "button", onClick: onClose, "aria-label": "close", className: "smart:rounded smart:p-1 smart:text-gray-500 smart:hover:bg-gray-100", children: "\u2715" })] }), Multi && ((0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(Multi, { items: list }) })), showForm && item && formOptions && ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)(react_2.SmartForm, { options: formOptions, onValuePartialChange: (changes) => onPartialChange(changes, list), onValidChange: onValidChange }), (0, jsx_runtime_1.jsx)(react_2.SmartButton, { className: "smart:float-right", disabled: lock || !valid, options: buttonOptions, children: t('change') })] }))] }));
23
+ }
24
+ //# sourceMappingURL=multiselect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"multiselect.js","sourceRoot":"","sources":["../../../../../../../../../packages/crud/shell/react/src/lib/components/multiselect/multiselect.tsx"],"names":[],"mappings":";;AAeA,oDAgEC;;AA/ED,iCAAgC;AAGhC,+CAA2E;AAE3E,iEAA4D;AAC5D,+DAAkE;AAElE;;;;;;GAMG;AACH,SAAgB,oBAAoB;I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,0 +1,23 @@
1
+ import { IEntity } from '@smartsoft001/domain-core';
2
+ import { IButtonOptions } from '@smartsoft001/react';
3
+ /**
4
+ * The behaviour of the multi-selection panel: `list` is the selection, `item`
5
+ * a model of `config.type` holding the values the selected items share in
6
+ * the fields with `update.multi` (`showForm` when there is such a field). The form
7
+ * reports its changes with `onPartialChange(changes, list)` and its validity
8
+ * with `onValidChange`; `buttonOptions` (with confirmation) apply the changes
9
+ * to every selected item and close the end menu. `lock` is set again
10
+ * whenever the selection changes, until the form reports.
11
+ */
12
+ export declare function useCrudMultiselect<T extends IEntity<string>>(): {
13
+ config: import("../../crud.config").CrudConfig<T> & Partial<import("../../crud.config").CrudFullConfig<T>>;
14
+ list: T[];
15
+ item: T;
16
+ showForm: boolean;
17
+ lock: boolean;
18
+ valid: boolean;
19
+ buttonOptions: IButtonOptions;
20
+ onClose: () => Promise<void>;
21
+ onPartialChange: (changes: Partial<T>, current: Array<T>) => void;
22
+ onValidChange: (value: boolean) => void;
23
+ };
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useCrudMultiselect = useCrudMultiselect;
4
+ const react_1 = require("react");
5
+ const models_1 = require("@smartsoft001/models");
6
+ const react_2 = require("@smartsoft001/react");
7
+ const crud_context_1 = require("../../crud.context");
8
+ const hooks_1 = require("../../hooks");
9
+ /**
10
+ * The behaviour of the multi-selection panel: `list` is the selection, `item`
11
+ * a model of `config.type` holding the values the selected items share in
12
+ * the fields with `update.multi` (`showForm` when there is such a field). The form
13
+ * reports its changes with `onPartialChange(changes, list)` and its validity
14
+ * with `onValidChange`; `buttonOptions` (with confirmation) apply the changes
15
+ * to every selected item and close the end menu. `lock` is set again
16
+ * whenever the selection changes, until the form reports.
17
+ */
18
+ function useCrudMultiselect() {
19
+ const facade = (0, crud_context_1.useCrudFacade)();
20
+ const config = (0, crud_context_1.useCrudConfig)();
21
+ const menuService = (0, react_2.useMenuService)();
22
+ const multiSelected = (0, hooks_1.useCrudState)((state) => state.multiSelected);
23
+ const list = (0, react_1.useMemo)(() => multiSelected || [], [multiSelected]);
24
+ const [partial, setPartial] = (0, react_1.useState)(null);
25
+ const [valid, setValid] = (0, react_1.useState)(false);
26
+ const { item, showForm } = (0, react_1.useMemo)(() => {
27
+ const model = new config.type();
28
+ const fieldsWithOptions = (0, models_1.getModelFieldsWithOptions)(model)?.filter((f) => f.options.update?.multi);
29
+ fieldsWithOptions.forEach(({ key }) => {
30
+ const uniques = Array.from(new Set(list.map((i) => i[key])));
31
+ if (uniques.length === 1) {
32
+ model[key] = uniques[0];
33
+ }
34
+ });
35
+ return { item: model, showForm: !!fieldsWithOptions.length };
36
+ }, [list, config.type]);
37
+ const lock = partial?.list !== list;
38
+ const buttonOptions = {
39
+ click: async () => {
40
+ const result = (partial?.list ?? []).map((i) => ({
41
+ ...partial?.changes,
42
+ id: i.id,
43
+ }));
44
+ facade.updatePartialMany(result);
45
+ await menuService.closeEnd();
46
+ },
47
+ confirm: true,
48
+ };
49
+ const onClose = (0, react_1.useCallback)(async () => {
50
+ await menuService.closeEnd();
51
+ }, [menuService]);
52
+ const onPartialChange = (0, react_1.useCallback)((changes, current) => {
53
+ setPartial({ list: current, changes });
54
+ }, []);
55
+ const onValidChange = (0, react_1.useCallback)((value) => {
56
+ setValid(value);
57
+ }, []);
58
+ return {
59
+ config,
60
+ list,
61
+ item,
62
+ showForm,
63
+ lock,
64
+ valid,
65
+ buttonOptions,
66
+ onClose,
67
+ onPartialChange,
68
+ onValidChange,
69
+ };
70
+ }
71
+ //# sourceMappingURL=use-crud-multiselect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-crud-multiselect.js","sourceRoot":"","sources":["../../../../../../../../../packages/crud/shell/react/src/lib/components/multiselect/use-crud-multiselect.ts"],"names":[],"mappings":";;AA0BA,gDA2EC;AArGD,iCAAuD;AAGvD,iDAG8B;AAC9B,+CAAqE;AAErE,qDAAkE;AAClE,uCAA2C;AAO3C;;;;;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QACR,IAAI;QACJ,KAAK;QACL,aAAa;QACb,OAAO;QACP,eAAe;QACf,aAAa;KACd,CAAC;AACJ,CAAC"}
@@ -0,0 +1,66 @@
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. A plain
8
+ * object handed to `<CrudProvider config>`.
9
+ */
10
+ export interface CrudConfig<T> {
11
+ apiUrl: string;
12
+ /** The name the feature's state is kept under; one store per entity. */
13
+ entity: string;
14
+ /** The `@Model` class of the items. */
15
+ type?: any;
16
+ /** Replaces the default reducer of the feature. */
17
+ reducerFactory?: () => (state: CrudState<any>, action: CrudAction) => CrudState<any>;
18
+ /** Query items every read sends unless the filter brings its own. */
19
+ baseQuery?: Array<ICrudFilterQueryItem>;
20
+ }
21
+ export interface CrudComponentSlots {
22
+ top?: ComponentType<any>;
23
+ bottom?: ComponentType<any>;
24
+ }
25
+ /** The configuration of the full CRUD screens (list + item pages). */
26
+ export interface CrudFullConfig<T> extends CrudConfig<T> {
27
+ title: string;
28
+ details?: boolean | {
29
+ cellPipe?: ICellPipe<T>;
30
+ components?: CrudComponentSlots;
31
+ };
32
+ edit?: boolean | {
33
+ cellPipe?: ICellPipe<T>;
34
+ components?: CrudComponentSlots;
35
+ };
36
+ add?: boolean | {
37
+ components?: CrudComponentSlots;
38
+ };
39
+ remove?: boolean;
40
+ search?: boolean;
41
+ export?: boolean;
42
+ pagination?: {
43
+ limit: number;
44
+ };
45
+ sort?: boolean | {
46
+ default?: string;
47
+ defaultDesc?: boolean;
48
+ };
49
+ list?: {
50
+ cellPipe?: ICellPipe<T>;
51
+ components?: {
52
+ top?: ComponentType<any>;
53
+ multi?: ComponentType<any>;
54
+ };
55
+ mode?: ListMode;
56
+ paginationMode?: PaginationMode;
57
+ resetQuery?: 'beforeInit';
58
+ groups?: Array<ICrudListGroup>;
59
+ };
60
+ buttons?: Array<IIconButtonOptions>;
61
+ inputComponents?: {
62
+ [key: string]: ComponentType<any>;
63
+ };
64
+ className?: string;
65
+ variant?: SmartPageVariant;
66
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=crud.config.js.map
@@ -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"}