@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
package/README.md CHANGED
@@ -1,4 +1,12 @@
1
- # Temporary Holding Version
1
+ # @smartsoft001/crud-shell-react
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
4
- If no other versions are published within 30 days, this package and version will be deleted.
3
+ The React CRUD screens of the smartsoft001 framework: the list and item pages generated from a
4
+ configuration object and the model's metadata, the filters, and the CRUD service with its store and
5
+ facade, speaking the REST contract of
6
+ [`@smartsoft001/crud-shell-nestjs`](https://www.npmjs.com/package/@smartsoft001/crud-shell-nestjs).
7
+
8
+ ```bash
9
+ npm install @smartsoft001/crud-shell-react @smartsoft001/react react
10
+ ```
11
+
12
+ The full documentation is at https://framework.smartflow.biz.pl/docs/packages/crud-shell-react/.
package/package.json CHANGED
@@ -1,6 +1,31 @@
1
1
  {
2
2
  "name": "@smartsoft001/crud-shell-react",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "2.194.0",
4
+ "type": "commonjs",
5
+ "description": "React CRUD screens driven by model metadata: the list and item pages, filters, the CRUD service and its store.",
6
+ "publishConfig": {
7
+ "access": "public"
8
+ },
9
+ "license": "MIT",
10
+ "main": "./src/index.js",
11
+ "typings": "./src/index.d.ts",
12
+ "dependencies": {
13
+ "moment": "^2.31.0"
14
+ },
15
+ "peerDependencies": {
16
+ "@smartsoft001/domain-core": "2.194.0",
17
+ "@smartsoft001/models": "2.194.0",
18
+ "@smartsoft001/react": "2.194.0",
19
+ "@smartsoft001/utils": "2.194.0",
20
+ "react": "^19.0.0"
21
+ },
22
+ "exports": {
23
+ ".": {
24
+ "types": "./src/index.d.ts",
25
+ "default": "./src/index.js"
26
+ },
27
+ "./styles.css": "./styles.css",
28
+ "./package.json": "./package.json"
29
+ },
30
+ "types": "./src/index.d.ts"
31
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1,19 @@
1
+ export * from './lib/components/export';
2
+ export * from './lib/components/filter';
3
+ export * from './lib/components/filters';
4
+ export * from './lib/components/filters-config';
5
+ export * from './lib/components/group';
6
+ export * from './lib/components/multiselect';
7
+ export * from './lib/crud.config';
8
+ export * from './lib/crud.context';
9
+ export * from './lib/crud.provider';
10
+ export * from './lib/factories/form-options';
11
+ export * from './lib/hooks';
12
+ export * from './lib/models';
13
+ export * from './lib/pages';
14
+ export * from './lib/providers/model-label.provider';
15
+ export * from './lib/services/crud/crud.service';
16
+ export * from './lib/services/list-group/list-group.service';
17
+ export * from './lib/services/page/page.service';
18
+ export * from './lib/services/search/search.service';
19
+ export * from './lib/state';
package/src/index.js ADDED
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./lib/components/export"), exports);
5
+ tslib_1.__exportStar(require("./lib/components/filter"), exports);
6
+ tslib_1.__exportStar(require("./lib/components/filters"), exports);
7
+ tslib_1.__exportStar(require("./lib/components/filters-config"), exports);
8
+ tslib_1.__exportStar(require("./lib/components/group"), exports);
9
+ tslib_1.__exportStar(require("./lib/components/multiselect"), exports);
10
+ tslib_1.__exportStar(require("./lib/crud.config"), exports);
11
+ tslib_1.__exportStar(require("./lib/crud.context"), exports);
12
+ tslib_1.__exportStar(require("./lib/crud.provider"), exports);
13
+ tslib_1.__exportStar(require("./lib/factories/form-options"), exports);
14
+ tslib_1.__exportStar(require("./lib/hooks"), exports);
15
+ tslib_1.__exportStar(require("./lib/models"), exports);
16
+ tslib_1.__exportStar(require("./lib/pages"), exports);
17
+ tslib_1.__exportStar(require("./lib/providers/model-label.provider"), exports);
18
+ tslib_1.__exportStar(require("./lib/services/crud/crud.service"), exports);
19
+ tslib_1.__exportStar(require("./lib/services/list-group/list-group.service"), exports);
20
+ tslib_1.__exportStar(require("./lib/services/page/page.service"), exports);
21
+ tslib_1.__exportStar(require("./lib/services/search/search.service"), exports);
22
+ tslib_1.__exportStar(require("./lib/state"), exports);
23
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/crud/shell/react/src/index.ts"],"names":[],"mappings":";;;AAAA,kEAAwC;AACxC,kEAAwC;AACxC,mEAAyC;AACzC,0EAAgD;AAChD,iEAAuC;AACvC,uEAA6C;AAC7C,4DAAkC;AAClC,6DAAmC;AACnC,8DAAoC;AACpC,uEAA6C;AAC7C,sDAA4B;AAC5B,uDAA6B;AAC7B,sDAA4B;AAC5B,+EAAqD;AACrD,2EAAiD;AACjD,uFAA6D;AAC7D,2EAAiD;AACjD,+EAAqD;AACrD,sDAA4B"}
@@ -0,0 +1,7 @@
1
+ import { IEntity } from '@smartsoft001/domain-core';
2
+ import { SmartCrudExportProps } from './export.types';
3
+ /**
4
+ * The CSV / XLSX buttons exporting the list of the CRUD feature with its
5
+ * current filter.
6
+ */
7
+ export declare function SmartCrudExport<T extends IEntity<string>>(props: SmartCrudExportProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SmartCrudExport = SmartCrudExport;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("@smartsoft001/react");
6
+ const use_crud_export_1 = require("./use-crud-export");
7
+ /**
8
+ * The CSV / XLSX buttons exporting the list of the CRUD feature with its
9
+ * current filter.
10
+ */
11
+ function SmartCrudExport(props) {
12
+ const { elementRef, buttonExportCsvOptions, buttonExportXlsxOptions } = (0, use_crud_export_1.useCrudExport)(props);
13
+ return ((0, jsx_runtime_1.jsxs)("div", { ref: elementRef, className: "smart:p-5", children: [(0, jsx_runtime_1.jsx)("p", { className: "smart:my-2.5 smart:mx-0", children: (0, jsx_runtime_1.jsx)(react_1.SmartButton, { options: buttonExportCsvOptions, className: "smart:w-full smart:block", children: "CSV" }) }), (0, jsx_runtime_1.jsx)("p", { children: (0, jsx_runtime_1.jsx)(react_1.SmartButton, { options: buttonExportXlsxOptions, className: "smart:w-full smart:block", children: "XLSX" }) })] }));
14
+ }
15
+ //# sourceMappingURL=export.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"export.js","sourceRoot":"","sources":["../../../../../../../../../packages/crud/shell/react/src/lib/components/export/export.tsx"],"names":[],"mappings":";;AAUA,0CA0BC;;AAnCD,+CAAkD;AAGlD,uDAAkD;AAElD;;;GAGG;AACH,SAAgB,eAAe,CAC7B,KAA2B;IAE3B,MAAM,EAAE,UAAU,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,GACnE,IAAA,+BAAa,EAAI,KAAK,CAAC,CAAC;IAE1B,OAAO,CACL,iCAAK,GAAG,EAAE,UAAU,EAAE,SAAS,EAAC,WAAW,aACzC,8BAAG,SAAS,EAAC,yBAAyB,YACpC,uBAAC,mBAAW,IACV,OAAO,EAAE,sBAAsB,EAC/B,SAAS,EAAC,0BAA0B,oBAGxB,GACZ,EACJ,wCACE,uBAAC,mBAAW,IACV,OAAO,EAAE,uBAAuB,EAChC,SAAS,EAAC,0BAA0B,qBAGxB,GACZ,IACA,CACP,CAAC;AACJ,CAAC"}
@@ -0,0 +1,8 @@
1
+ /** The props of `<SmartCrudExport>`. */
2
+ export interface SmartCrudExportProps {
3
+ /**
4
+ * Closes the overlay the component is shown in. `ModalService` passes it
5
+ * to the component it opens; without it the last opened modal is closed.
6
+ */
7
+ dismiss?: (data?: unknown) => void;
8
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=export.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"export.types.js","sourceRoot":"","sources":["../../../../../../../../../packages/crud/shell/react/src/lib/components/export/export.types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ export * from './export';
2
+ export * from './export.types';
3
+ export * from './use-crud-export';
@@ -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("./export"), exports);
5
+ tslib_1.__exportStar(require("./export.types"), exports);
6
+ tslib_1.__exportStar(require("./use-crud-export"), exports);
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../../packages/crud/shell/react/src/lib/components/export/index.ts"],"names":[],"mappings":";;;AAAA,mDAAyB;AACzB,yDAA+B;AAC/B,4DAAkC"}
@@ -0,0 +1,15 @@
1
+ import { IEntity } from '@smartsoft001/domain-core';
2
+ import { IButtonOptions } from '@smartsoft001/react';
3
+ import { SmartCrudExportProps } from './export.types';
4
+ /**
5
+ * The behaviour of the export buttons: a click exports the list with the
6
+ * current filter, without paging, in its format, and closes the overlay the
7
+ * component is shown in once the export finished. The buttons are loading
8
+ * while the feature is. Attach `elementRef` to the root element: it gets the
9
+ * application style.
10
+ */
11
+ export declare function useCrudExport<T extends IEntity<string>>({ dismiss, }?: SmartCrudExportProps): {
12
+ elementRef: import("react").RefObject<HTMLDivElement | null>;
13
+ buttonExportCsvOptions: IButtonOptions;
14
+ buttonExportXlsxOptions: IButtonOptions;
15
+ };
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useCrudExport = useCrudExport;
4
+ const react_1 = require("react");
5
+ const react_2 = require("@smartsoft001/react");
6
+ const crud_context_1 = require("../../crud.context");
7
+ const hooks_1 = require("../../hooks");
8
+ /**
9
+ * Runs `callback` once the feature is loaded, now or after a later change.
10
+ * Returns the unsubscribe function.
11
+ */
12
+ function onceLoaded(store, callback) {
13
+ if (store.get().loaded) {
14
+ callback();
15
+ return () => undefined;
16
+ }
17
+ const unsubscribe = store.subscribe(() => {
18
+ if (!store.get().loaded)
19
+ return;
20
+ unsubscribe();
21
+ callback();
22
+ });
23
+ return unsubscribe;
24
+ }
25
+ /**
26
+ * The behaviour of the export buttons: a click exports the list with the
27
+ * current filter, without paging, in its format, and closes the overlay the
28
+ * component is shown in once the export finished. The buttons are loading
29
+ * while the feature is. Attach `elementRef` to the root element: it gets the
30
+ * application style.
31
+ */
32
+ function useCrudExport({ dismiss, } = {}) {
33
+ const { facade, store } = (0, crud_context_1.useCrud)();
34
+ const modalService = (0, react_2.useModalService)();
35
+ const styleService = (0, react_2.useStyleService)();
36
+ const elementRef = (0, react_1.useRef)(null);
37
+ const loading = (0, hooks_1.useCrudState)((state) => !state.loaded);
38
+ const dismissRef = (0, react_1.useRef)(dismiss);
39
+ const subscriptions = (0, react_1.useRef)([]);
40
+ (0, react_1.useEffect)(() => {
41
+ dismissRef.current = dismiss;
42
+ });
43
+ // A local service writes the style, so the shared one is not redirected
44
+ // to this element.
45
+ (0, react_1.useEffect)(() => {
46
+ new react_2.StyleService().init(elementRef.current, styleService.get());
47
+ }, [styleService]);
48
+ (0, react_1.useEffect)(() => {
49
+ const current = subscriptions.current;
50
+ return () => current.forEach((unsubscribe) => unsubscribe());
51
+ }, []);
52
+ // Closes the overlay the buttons are shown in.
53
+ const close = () => {
54
+ if (dismissRef.current)
55
+ dismissRef.current();
56
+ else
57
+ void modalService.dismiss();
58
+ };
59
+ const initButtonExportOptions = (format) => ({
60
+ click: () => {
61
+ facade.export({ ...facade.filter, offset: undefined, limit: undefined }, format);
62
+ subscriptions.current.push(onceLoaded(store, close));
63
+ },
64
+ loading,
65
+ });
66
+ return {
67
+ elementRef,
68
+ buttonExportCsvOptions: initButtonExportOptions('csv'),
69
+ buttonExportXlsxOptions: initButtonExportOptions('xlsx'),
70
+ };
71
+ }
72
+ //# sourceMappingURL=use-crud-export.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-crud-export.js","sourceRoot":"","sources":["../../../../../../../../../packages/crud/shell/react/src/lib/components/export/use-crud-export.ts"],"names":[],"mappings":";;AA0CA,sCAkDC;AA5FD,iCAA0C;AAG1C,+CAK6B;AAG7B,qDAA6C;AAC7C,uCAA2C;AAG3C;;;GAGG;AACH,SAAS,UAAU,CAAC,KAAgB,EAAE,QAAoB;IACxD,IAAI,KAAK,CAAC,GAAG,EAAE,CAAC,MAAM,EAAE,CAAC;QACvB,QAAQ,EAAE,CAAC;QACX,OAAO,GAAG,EAAE,CAAC,SAAS,CAAC;IACzB,CAAC;IAED,MAAM,WAAW,GAAG,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACvC,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,MAAM;YAAE,OAAO;QAEhC,WAAW,EAAE,CAAC;QACd,QAAQ,EAAE,CAAC;IACb,CAAC,CAAC,CAAC;IAEH,OAAO,WAAW,CAAC;AACrB,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,aAAa,CAA4B,EACvD,OAAO,MACiB,EAAE;IAC1B,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,IAAA,sBAAO,GAAK,CAAC;IACvC,MAAM,YAAY,GAAG,IAAA,uBAAe,GAAE,C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AAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,EACzD,MAAM,CACP,CAAC;YAEF,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;QACvD,CAAC;QACD,OAAO;KACR,CAAC,CAAC;IAEH,OAAO;QACL,UAAU;QACV,sBAAsB,EAAE,uBAAuB,CAAC,KAAK,CAAC;QACtD,uBAAuB,EAAE,uBAAuB,CAAC,MAAM,CAAC;KACzD,CAAC;AACJ,CAAC"}
@@ -0,0 +1,65 @@
1
+ import { InputOptions, SmartAbstractControl, SmartFormControl } from '@smartsoft001/react';
2
+ import { ICrudFilter } from '../../../models';
3
+ import { CrudFilterPossibility, SmartCrudFilterProps } from '../filter.types';
4
+ /** How long `refresh` waits, in ms, before it reads the list. */
5
+ export declare const CRUD_FILTER_REFRESH_DEBOUNCE = 500;
6
+ /** What `useCrudFilter` returns. */
7
+ export interface UseCrudFilterResult {
8
+ /** The item's value (a list for a check filter); `null` without a query. */
9
+ value: any;
10
+ /** The item's `>=` value (range "from"). */
11
+ minValue: any;
12
+ /** The item's `<=` value (range "to"). */
13
+ maxValue: any;
14
+ /** Debounced `refresh(val)`. */
15
+ setValue: (val: any) => void;
16
+ /** Debounced `refresh(val, '>=')`. */
17
+ setMinValue: (val: any) => void;
18
+ /** Debounced `refresh(val, '<=')`. */
19
+ setMaxValue: (val: any) => void;
20
+ /** The item's entry has a non-empty value. */
21
+ hasValue: boolean;
22
+ /** The item's `>=` entry has a non-empty value. */
23
+ hasMinValue: boolean;
24
+ /** The item's `<=` entry has a non-empty value. */
25
+ hasMaxValue: boolean;
26
+ /** The options of a radio / check filter. */
27
+ possibilities: CrudFilterPossibility[] | undefined;
28
+ /** An instance of the feature's model, for the input options. */
29
+ model: any;
30
+ /** The current language. */
31
+ lang: string;
32
+ /** The filter the values are read from (the pending copy or the prop). */
33
+ effectiveFilter: ICrudFilter | null | undefined;
34
+ /**
35
+ * Sets the item's entry of `type` (`item.type` by default) to `val`, or
36
+ * removes it for an empty value, and reads the list from the first page;
37
+ * debounced by 500 ms.
38
+ */
39
+ refresh: (val: any, type?: string | null) => void;
40
+ /** Removes every entry of the item and reads the list from the first page. */
41
+ clear: () => void;
42
+ /**
43
+ * The options of a shared `SmartInput*` field bound to `control`; with the
44
+ * possibilities as unchecked options when `withPossibilities`.
45
+ */
46
+ buildInputOptions: (control: SmartAbstractControl, withPossibilities?: boolean) => InputOptions<any>;
47
+ }
48
+ /**
49
+ * The behaviour every filter field shares: the item's values in the current
50
+ * filter, and `refresh` / `clear`, which read the list through the facade
51
+ * with a changed copy of the filter. Until the store's new filter comes back
52
+ * through the `filter` prop, the values are read from that copy.
53
+ *
54
+ * `refresh` is debounced by 500 ms: only the last call within the wait is
55
+ * applied, and a pending call still runs after the field unmounts.
56
+ */
57
+ export declare function useCrudFilter({ item, filter, }: SmartCrudFilterProps): UseCrudFilterResult;
58
+ /**
59
+ * A form control bridged to one query slot of a filter: seeded once with the
60
+ * slot's current value (`null` = `value`, `'>='` = `minValue`, `'<='` =
61
+ * `maxValue`), and every change runs the debounced `refresh` for the slot.
62
+ * The control is not re-synced when the filter changes elsewhere
63
+ * (TODO GAP-19).
64
+ */
65
+ export declare function useCrudFilterControl({ value, minValue, maxValue, refresh, }: Pick<UseCrudFilterResult, 'value' | 'minValue' | 'maxValue' | 'refresh'>, type?: string | null): SmartFormControl;
@@ -0,0 +1,244 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CRUD_FILTER_REFRESH_DEBOUNCE = void 0;
4
+ exports.useCrudFilter = useCrudFilter;
5
+ exports.useCrudFilterControl = useCrudFilterControl;
6
+ const react_1 = require("react");
7
+ const models_1 = require("@smartsoft001/models");
8
+ const react_2 = require("@smartsoft001/react");
9
+ const crud_context_1 = require("../../../crud.context");
10
+ /** How long `refresh` waits, in ms, before it reads the list. */
11
+ exports.CRUD_FILTER_REFRESH_DEBOUNCE = 500;
12
+ /**
13
+ * The item's own possibilities: a function returning the list (as
14
+ * `IModelFilter` types it) or a plain list.
15
+ */
16
+ function readItemPossibilities(source) {
17
+ if (typeof source === 'function')
18
+ return source();
19
+ if (Array.isArray(source))
20
+ return source;
21
+ return undefined;
22
+ }
23
+ /** A check filter holds a list of values, one query entry each. */
24
+ function isArrayType(item) {
25
+ return item?.fieldType === models_1.FieldType.check;
26
+ }
27
+ /**
28
+ * The pending working copy while the `filter` prop is still the one it was
29
+ * derived from; once the store update brings a new prop, the prop wins.
30
+ */
31
+ function getEffectiveFilter(filter, pending) {
32
+ if (pending && filter === pending.source)
33
+ return pending.filter;
34
+ return filter;
35
+ }
36
+ /**
37
+ * A copy safe to change (object, query list and entries), so the filter in
38
+ * the store is never touched.
39
+ */
40
+ function cloneFilter(source) {
41
+ if (!source)
42
+ return undefined;
43
+ const clone = { ...source };
44
+ if (source.query)
45
+ clone.query = source.query.map((q) => ({ ...q }));
46
+ return clone;
47
+ }
48
+ /**
49
+ * The value of the item's query entry of `type` (`value`, `minValue` and
50
+ * `maxValue`): `null` without a query, the list of matching values for a
51
+ * check filter, otherwise the first match's value.
52
+ */
53
+ function readQueryValue(filter, item, type) {
54
+ if (!filter || !item || !filter.query)
55
+ return null;
56
+ if (isArrayType(item)) {
57
+ return filter.query
58
+ .filter((q) => q.key === item.key && q.type === type)
59
+ .map((q) => q.value);
60
+ }
61
+ const query = filter.query.find((q) => q.key === item.key && q.type === type);
62
+ return query?.value;
63
+ }
64
+ function hasQueryValue(filter, item, type) {
65
+ if (!filter || !item || !filter.query)
66
+ return false;
67
+ const query = filter.query.find((q) => q.key === item.key && q.type === type);
68
+ if (!query)
69
+ return false;
70
+ const val = query.value;
71
+ return val !== null && val !== undefined && val !== '';
72
+ }
73
+ function refreshArrayFilter(filter, item, vals, type) {
74
+ const query = (filter.query ?? []).filter((q) => !(q.key === item.key && q.type === type));
75
+ filter.query = query;
76
+ if (vals === null || vals === undefined || !vals.length)
77
+ return filter;
78
+ vals.forEach((val) => {
79
+ query.push({ key: item.key, type: type, value: val });
80
+ });
81
+ return filter;
82
+ }
83
+ /**
84
+ * The filter after `refresh(val, type)`: back on the first page, with the
85
+ * item's entry of the slot set to `val`, or removed for an empty value.
86
+ * `null` when there is nothing to read.
87
+ */
88
+ function refreshFilter(source, item, val, type) {
89
+ const filter = cloneFilter(source);
90
+ if (!filter || !item)
91
+ return null;
92
+ const slot = type || item.type;
93
+ if (!filter.query)
94
+ filter.query = [];
95
+ filter.offset = 0;
96
+ if (isArrayType(item))
97
+ return refreshArrayFilter(filter, item, val, slot);
98
+ const queries = filter.query;
99
+ let query = queries.find((q) => q.key === item.key && q.type === slot);
100
+ if (val === null || val === undefined || val === '') {
101
+ if (query)
102
+ queries.splice(queries.indexOf(query), 1);
103
+ return filter;
104
+ }
105
+ if (!query) {
106
+ query = { key: item.key, type: slot, value: null };
107
+ queries.push(query);
108
+ }
109
+ query.value = val;
110
+ query.label = item.label;
111
+ return filter;
112
+ }
113
+ /** The filter without any entry of the item, back on the first page. */
114
+ function clearFilter(source, item) {
115
+ const filter = cloneFilter(source);
116
+ if (!filter || !item || !filter.query)
117
+ return null;
118
+ filter.query = filter.query.filter((q) => q.key !== item.key);
119
+ filter.offset = 0;
120
+ return filter;
121
+ }
122
+ /**
123
+ * The options of the item: the ones the model possibilities provider returns
124
+ * for the model type and the item key, otherwise the item's own.
125
+ */
126
+ function useFilterPossibilities(item, modelType, model) {
127
+ const provider = (0, react_2.useSmart)().modelPossibilitiesProvider;
128
+ const key = item?.key;
129
+ const [fromProvider, setFromProvider] = (0, react_1.useState)(null);
130
+ (0, react_1.useEffect)(() => {
131
+ if (!provider || !key)
132
+ return undefined;
133
+ let active = true;
134
+ Promise.resolve(provider.get({ type: modelType, key, instance: model })).then((list) => {
135
+ if (active && list)
136
+ setFromProvider({ key, list });
137
+ });
138
+ return () => {
139
+ active = false;
140
+ };
141
+ }, [provider, modelType, key, model]);
142
+ if (fromProvider && fromProvider.key === key)
143
+ return fromProvider.list;
144
+ return readItemPossibilities(item?.possibilities);
145
+ }
146
+ /**
147
+ * The behaviour every filter field shares: the item's values in the current
148
+ * filter, and `refresh` / `clear`, which read the list through the facade
149
+ * with a changed copy of the filter. Until the store's new filter comes back
150
+ * through the `filter` prop, the values are read from that copy.
151
+ *
152
+ * `refresh` is debounced by 500 ms: only the last call within the wait is
153
+ * applied, and a pending call still runs after the field unmounts.
154
+ */
155
+ function useCrudFilter({ item, filter, }) {
156
+ const facade = (0, crud_context_1.useCrudFacade)();
157
+ const modelType = (0, crud_context_1.useCrudConfig)().type;
158
+ const lang = (0, react_2.useSmart)().language;
159
+ const model = (0, react_1.useMemo)(() => (modelType ? new modelType() : undefined), [modelType]);
160
+ const possibilities = useFilterPossibilities(item, modelType, model);
161
+ const [pending, setPending] = (0, react_1.useState)(null);
162
+ const effectiveFilter = getEffectiveFilter(filter, pending);
163
+ const latest = (0, react_1.useRef)({ item, filter, pending, facade });
164
+ const timer = (0, react_1.useRef)(null);
165
+ (0, react_1.useLayoutEffect)(() => {
166
+ latest.current = { item, filter, pending, facade };
167
+ });
168
+ const commitFilter = (0, react_1.useCallback)((next) => {
169
+ if (!next)
170
+ return;
171
+ const current = latest.current;
172
+ const entry = { source: current.filter, filter: next };
173
+ current.pending = entry;
174
+ setPending(entry);
175
+ current.facade.read(next);
176
+ }, []);
177
+ const refresh = (0, react_1.useCallback)((val, type = null) => {
178
+ if (timer.current)
179
+ clearTimeout(timer.current);
180
+ timer.current = setTimeout(() => {
181
+ timer.current = null;
182
+ const current = latest.current;
183
+ commitFilter(refreshFilter(getEffectiveFilter(current.filter, current.pending), current.item, val, type));
184
+ }, exports.CRUD_FILTER_REFRESH_DEBOUNCE);
185
+ }, [commitFilter]);
186
+ const clear = (0, react_1.useCallback)(() => {
187
+ const current = latest.current;
188
+ commitFilter(clearFilter(getEffectiveFilter(current.filter, current.pending), current.item));
189
+ }, [commitFilter]);
190
+ const setValue = (0, react_1.useCallback)((val) => refresh(val), [refresh]);
191
+ const setMinValue = (0, react_1.useCallback)((val) => refresh(val, '>='), [refresh]);
192
+ const setMaxValue = (0, react_1.useCallback)((val) => refresh(val, '<='), [refresh]);
193
+ const fieldKey = item?.key ?? '';
194
+ const buildInputOptions = (0, react_1.useCallback)((control, withPossibilities = false) => {
195
+ const options = {
196
+ treeLevel: 0,
197
+ control,
198
+ model,
199
+ fieldKey,
200
+ };
201
+ if (withPossibilities) {
202
+ options.possibilities = (possibilities ?? []).map(({ id, text }) => ({
203
+ id,
204
+ text,
205
+ checked: false,
206
+ }));
207
+ }
208
+ return options;
209
+ }, [model, fieldKey, possibilities]);
210
+ return {
211
+ value: readQueryValue(effectiveFilter, item, item?.type),
212
+ minValue: readQueryValue(effectiveFilter, item, '>='),
213
+ maxValue: readQueryValue(effectiveFilter, item, '<='),
214
+ setValue,
215
+ setMinValue,
216
+ setMaxValue,
217
+ hasValue: hasQueryValue(effectiveFilter, item, item?.type),
218
+ hasMinValue: hasQueryValue(effectiveFilter, item, '>='),
219
+ hasMaxValue: hasQueryValue(effectiveFilter, item, '<='),
220
+ possibilities,
221
+ model,
222
+ lang,
223
+ effectiveFilter,
224
+ refresh,
225
+ clear,
226
+ buildInputOptions,
227
+ };
228
+ }
229
+ /**
230
+ * A form control bridged to one query slot of a filter: seeded once with the
231
+ * slot's current value (`null` = `value`, `'>='` = `minValue`, `'<='` =
232
+ * `maxValue`), and every change runs the debounced `refresh` for the slot.
233
+ * The control is not re-synced when the filter changes elsewhere
234
+ * (TODO GAP-19).
235
+ */
236
+ function useCrudFilterControl({ value, minValue, maxValue, refresh, }, type = null) {
237
+ const [control] = (0, react_1.useState)(() => new react_2.SmartFormControl(type === '>=' ? minValue : type === '<=' ? maxValue : value));
238
+ (0, react_1.useEffect)(() => {
239
+ const subscription = control.valueChanges.subscribe((val) => refresh(val, type));
240
+ return () => subscription.unsubscribe();
241
+ }, [control, refresh, type]);
242
+ return control;
243
+ }
244
+ //# sourceMappingURL=use-crud-filter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-crud-filter.js","sourceRoot":"","sources":["../../../../../../../../../../packages/crud/shell/react/src/lib/components/filter/base/use-crud-filter.ts"],"names":[],"mappings":";;;AA4RA,sCA8GC;AASD,oDAyBC;AA5aD,iCAOe;AAEf,iDAA+D;AAC/D,+CAK6B;AAE7B,wDAAqE;AAIrE,iEAAiE;AACpD,QAAA,4BAA4B,GAAG,GAAG,CAAC;AAwDhD;;;GAGG;AACH,SAAS,qBAAqB,CAC5B,MAAe;IAEf,IAAI,OAAO,MAAM,KAAK,UAAU;QAAE,OAAO,MAAM,EAAE,CAAC;IAClD,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;QAAE,OAAO,MAAM,CAAC;IAEzC,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,mEAAmE;AACnE,SAAS,WAAW,CAAC,IAA8B;IACjD,OAAO,IAAI,EAAE,SAAS,KAAK,kBAAS,CAAC,KAAK,CAAC;AAC7C,CAAC;AAED;;;GAGG;AACH,SAAS,kBAAkB,CACzB,MAAsC,EACtC,OAA6B;IAE7B,IAAI,OAAO,IAAI,MAAM,KAAK,OAAO,CAAC,MAAM;QAAE,OAAO,OAAO,CAAC,MAAM,CAAC;IAEhE,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;GAGG;AACH,SAAS,WAAW,CAClB,MAAsC;IAEtC,IAAI,CAAC,MAAM;QAAE,OAAO,SAAS,CAAC;IAE9B,MAAM,KAAK,GAAgB,EAAE,GAAG,MAAM,EAAE,CAAC;IAEzC,IAAI,MAAM,CAAC,KAAK;QAAE,KAAK,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;IAEpE,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;GAIG;AACH,SAAS,cAAc,CACrB,MAAsC,EACtC,IAA8B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CAAC,OAAO,CAAC,GAAG,IAAA,gBAAQ,EACxB,GAAG,EAAE,CACH,IAAI,wBAAgB,CAClB,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAC5D,CACJ,CAAC;IAEF,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,MAAM,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,GAAG,EAAE,EAAE,CAC1D,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,CACnB,CAAC;QAEF,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,WAAW,EAAE,CAAC;IAC1C,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC;IAE7B,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { SmartCrudFilterProps } from '../filter.types';
2
+ /**
3
+ * The check filter: a checkbox per possibility, checked when its id is among
4
+ * the item's values, and a clear button while any is checked. Each value is its own query entry.
5
+ */
6
+ export declare function SmartCrudFilterCheck(props: SmartCrudFilterProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SmartCrudFilterCheck = SmartCrudFilterCheck;
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_filter_1 = require("../base/use-crud-filter");
8
+ /**
9
+ * A checkbox that follows the user's click right away and gets `checked`
10
+ * written to it whenever it changes (the read is debounced, so the value
11
+ * follows 500 ms later).
12
+ */
13
+ function FilterCheckbox({ checked, onCheckedChange, }) {
14
+ const ref = (0, react_1.useRef)(null);
15
+ (0, react_1.useEffect)(() => {
16
+ if (ref.current)
17
+ ref.current.checked = checked;
18
+ }, [checked]);
19
+ return ((0, jsx_runtime_1.jsx)("input", { ref: ref, type: "checkbox", defaultChecked: checked, onChange: (e) => onCheckedChange(e.target.checked), className: "smart:h-4 smart:w-4 smart:rounded smart:border-gray-300 smart:text-indigo-600 smart:focus:ring-indigo-500" }));
20
+ }
21
+ /**
22
+ * The check filter: a checkbox per possibility, checked when its id is among
23
+ * the item's values, and a clear button while any is checked. Each value is its own query entry.
24
+ */
25
+ function SmartCrudFilterCheck(props) {
26
+ const t = (0, react_2.useTranslate)();
27
+ const { value, possibilities, setValue, refresh } = (0, use_crud_filter_1.useCrudFilter)(props);
28
+ const values = value ?? [];
29
+ const hasCheckedValues = Array.isArray(value) && value.length > 0;
30
+ const list = (possibilities ?? []).map((pos) => ({
31
+ value: pos,
32
+ isCheck: values.some((r) => r === pos.id),
33
+ }));
34
+ const onCheckChange = (checked, entry) => {
35
+ if (checked && !values.some((r) => r === entry.id)) {
36
+ setValue([...values, entry.id]);
37
+ }
38
+ if (!checked && values.some((r) => r === entry.id)) {
39
+ setValue(value?.filter((r) => r !== entry.id));
40
+ }
41
+ };
42
+ return ((0, jsx_runtime_1.jsx)("div", { className: "smart:block smart:w-full", children: (0, jsx_runtime_1.jsxs)("fieldset", { className: "smart:w-full", children: [(0, jsx_runtime_1.jsxs)("legend", { className: "smart:flex smart:items-center smart:justify-between smart:text-sm smart:font-medium smart:text-gray-900", children: [(0, jsx_runtime_1.jsx)("span", { children: t(props.item?.label || '') }), hasCheckedValues && ((0, jsx_runtime_1.jsx)("button", { type: "button", onClick: () => refresh([]), "aria-label": "clear", className: "smart:rounded smart:px-2 smart:py-1 smart:text-red-600 smart:hover:bg-red-50", children: "\u00D7" }))] }), (0, jsx_runtime_1.jsx)("div", { className: "smart:mt-2 smart:space-y-2", children: list.map((entry) => ((0, jsx_runtime_1.jsxs)("label", { className: "smart:flex smart:items-center smart:gap-x-2", children: [(0, jsx_runtime_1.jsx)(FilterCheckbox, { checked: entry.isCheck, onCheckedChange: (checked) => onCheckChange(checked, entry.value) }), (0, jsx_runtime_1.jsx)("span", { className: "smart:text-sm smart:text-gray-900", children: t(entry.value.text) })] }, entry.value.id))) })] }) }));
43
+ }
44
+ //# sourceMappingURL=filter-check.js.map