drf-react-by-schema 0.28.8 → 0.28.9

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 (232) hide show
  1. package/dist/@types/index.d.ts +410 -0
  2. package/dist/@types/index.d.ts.map +1 -0
  3. package/dist/@types/index.js +9 -0
  4. package/dist/@types/string-mask.d.ts +10 -0
  5. package/dist/@types/string-mask.d.ts.map +1 -0
  6. package/dist/@types/string-mask.js +1 -0
  7. package/dist/api.d.ts +81 -0
  8. package/dist/api.d.ts.map +1 -0
  9. package/dist/api.js +1118 -0
  10. package/dist/components/DataGridBySchemaEditable/BooleanInputCell.d.ts +8 -0
  11. package/dist/components/DataGridBySchemaEditable/BooleanInputCell.d.ts.map +1 -0
  12. package/dist/components/DataGridBySchemaEditable/BooleanInputCell.js +86 -0
  13. package/dist/components/DataGridBySchemaEditable/ConditionalEditWrapper.d.ts +12 -0
  14. package/dist/components/DataGridBySchemaEditable/ConditionalEditWrapper.d.ts.map +1 -0
  15. package/dist/components/DataGridBySchemaEditable/ConditionalEditWrapper.js +71 -0
  16. package/dist/components/DataGridBySchemaEditable/ConfirmDialog.d.ts +9 -0
  17. package/dist/components/DataGridBySchemaEditable/ConfirmDialog.d.ts.map +1 -0
  18. package/dist/components/DataGridBySchemaEditable/ConfirmDialog.js +21 -0
  19. package/dist/components/DataGridBySchemaEditable/CustomToolbar.d.ts +26 -0
  20. package/dist/components/DataGridBySchemaEditable/CustomToolbar.d.ts.map +1 -0
  21. package/dist/components/DataGridBySchemaEditable/CustomToolbar.js +146 -0
  22. package/dist/components/DataGridBySchemaEditable/DataGridDesktop.d.ts +73 -0
  23. package/dist/components/DataGridBySchemaEditable/DataGridDesktop.d.ts.map +1 -0
  24. package/dist/components/DataGridBySchemaEditable/DataGridDesktop.js +421 -0
  25. package/dist/components/DataGridBySchemaEditable/DataGridMobile.d.ts +18 -0
  26. package/dist/components/DataGridBySchemaEditable/DataGridMobile.d.ts.map +1 -0
  27. package/dist/components/DataGridBySchemaEditable/DataGridMobile.js +105 -0
  28. package/dist/components/DataGridBySchemaEditable/FileInputCell.d.ts +11 -0
  29. package/dist/components/DataGridBySchemaEditable/FileInputCell.d.ts.map +1 -0
  30. package/dist/components/DataGridBySchemaEditable/FileInputCell.js +155 -0
  31. package/dist/components/DataGridBySchemaEditable/FooterToolbar.d.ts +12 -0
  32. package/dist/components/DataGridBySchemaEditable/FooterToolbar.d.ts.map +1 -0
  33. package/dist/components/DataGridBySchemaEditable/FooterToolbar.js +36 -0
  34. package/dist/components/DataGridBySchemaEditable/GeoEditCell.d.ts +10 -0
  35. package/dist/components/DataGridBySchemaEditable/GeoEditCell.d.ts.map +1 -0
  36. package/dist/components/DataGridBySchemaEditable/GeoEditCell.js +85 -0
  37. package/dist/components/DataGridBySchemaEditable/GeoThumbCell.d.ts +11 -0
  38. package/dist/components/DataGridBySchemaEditable/GeoThumbCell.d.ts.map +1 -0
  39. package/dist/components/DataGridBySchemaEditable/GeoThumbCell.js +87 -0
  40. package/dist/components/DataGridBySchemaEditable/GridActionsCellItemLink.d.ts +18 -0
  41. package/dist/components/DataGridBySchemaEditable/GridActionsCellItemLink.d.ts.map +1 -0
  42. package/dist/components/DataGridBySchemaEditable/GridActionsCellItemLink.js +24 -0
  43. package/dist/components/DataGridBySchemaEditable/GridDateInput.d.ts +8 -0
  44. package/dist/components/DataGridBySchemaEditable/GridDateInput.d.ts.map +1 -0
  45. package/dist/components/DataGridBySchemaEditable/GridDateInput.js +166 -0
  46. package/dist/components/DataGridBySchemaEditable/GridDateTimeInput.d.ts +6 -0
  47. package/dist/components/DataGridBySchemaEditable/GridDateTimeInput.d.ts.map +1 -0
  48. package/dist/components/DataGridBySchemaEditable/GridDateTimeInput.js +154 -0
  49. package/dist/components/DataGridBySchemaEditable/GridDecimalInput.d.ts +10 -0
  50. package/dist/components/DataGridBySchemaEditable/GridDecimalInput.d.ts.map +1 -0
  51. package/dist/components/DataGridBySchemaEditable/GridDecimalInput.js +78 -0
  52. package/dist/components/DataGridBySchemaEditable/GridGenericInput.d.ts +8 -0
  53. package/dist/components/DataGridBySchemaEditable/GridGenericInput.d.ts.map +1 -0
  54. package/dist/components/DataGridBySchemaEditable/GridGenericInput.js +30 -0
  55. package/dist/components/DataGridBySchemaEditable/GridPatternInput.d.ts +7 -0
  56. package/dist/components/DataGridBySchemaEditable/GridPatternInput.d.ts.map +1 -0
  57. package/dist/components/DataGridBySchemaEditable/GridPatternInput.js +74 -0
  58. package/dist/components/DataGridBySchemaEditable/InputInterval.d.ts +21 -0
  59. package/dist/components/DataGridBySchemaEditable/InputInterval.d.ts.map +1 -0
  60. package/dist/components/DataGridBySchemaEditable/InputInterval.js +131 -0
  61. package/dist/components/DataGridBySchemaEditable/MobileSearchBar.d.ts +9 -0
  62. package/dist/components/DataGridBySchemaEditable/MobileSearchBar.d.ts.map +1 -0
  63. package/dist/components/DataGridBySchemaEditable/MobileSearchBar.js +70 -0
  64. package/dist/components/DataGridBySchemaEditable/RowEditingWatcher.d.ts +7 -0
  65. package/dist/components/DataGridBySchemaEditable/RowEditingWatcher.d.ts.map +1 -0
  66. package/dist/components/DataGridBySchemaEditable/RowEditingWatcher.js +41 -0
  67. package/dist/components/DataGridBySchemaEditable/SelectEditInputCell.d.ts +24 -0
  68. package/dist/components/DataGridBySchemaEditable/SelectEditInputCell.d.ts.map +1 -0
  69. package/dist/components/DataGridBySchemaEditable/SelectEditInputCell.js +259 -0
  70. package/dist/components/DataGridBySchemaEditable/geoConstants.d.ts +5 -0
  71. package/dist/components/DataGridBySchemaEditable/geoConstants.d.ts.map +1 -0
  72. package/dist/components/DataGridBySchemaEditable/geoConstants.js +6 -0
  73. package/dist/components/DataGridBySchemaEditable/hooks/useDataGridActions.d.ts +33 -0
  74. package/dist/components/DataGridBySchemaEditable/hooks/useDataGridActions.d.ts.map +1 -0
  75. package/dist/components/DataGridBySchemaEditable/hooks/useDataGridActions.js +161 -0
  76. package/dist/components/DataGridBySchemaEditable/hooks/useOptionsAC.d.ts +14 -0
  77. package/dist/components/DataGridBySchemaEditable/hooks/useOptionsAC.d.ts.map +1 -0
  78. package/dist/components/DataGridBySchemaEditable/hooks/useOptionsAC.js +69 -0
  79. package/dist/components/DataGridBySchemaEditable/hooks/usePreparedColumns.d.ts +9 -0
  80. package/dist/components/DataGridBySchemaEditable/hooks/usePreparedColumns.d.ts.map +1 -0
  81. package/dist/components/DataGridBySchemaEditable/hooks/usePreparedColumns.js +73 -0
  82. package/dist/components/DataGridBySchemaEditable/hooks/useProcessRowUpdate.d.ts +30 -0
  83. package/dist/components/DataGridBySchemaEditable/hooks/useProcessRowUpdate.d.ts.map +1 -0
  84. package/dist/components/DataGridBySchemaEditable/hooks/useProcessRowUpdate.js +199 -0
  85. package/dist/components/DataGridBySchemaEditable/utils/columnFactory.d.ts +33 -0
  86. package/dist/components/DataGridBySchemaEditable/utils/columnFactory.d.ts.map +1 -0
  87. package/dist/components/DataGridBySchemaEditable/utils/columnFactory.js +270 -0
  88. package/dist/components/DataGridBySchemaEditable/utils.d.ts +40 -0
  89. package/dist/components/DataGridBySchemaEditable/utils.d.ts.map +1 -0
  90. package/dist/components/DataGridBySchemaEditable/utils.js +181 -0
  91. package/dist/components/DataGridBySchemaEditable.d.ts +64 -0
  92. package/dist/components/DataGridBySchemaEditable.d.ts.map +1 -0
  93. package/dist/components/DataGridBySchemaEditable.js +172 -0
  94. package/dist/components/DataTotals.d.ts +12 -0
  95. package/dist/components/DataTotals.d.ts.map +1 -0
  96. package/dist/components/DataTotals.js +32 -0
  97. package/dist/components/DataTotalsServer.d.ts +10 -0
  98. package/dist/components/DataTotalsServer.d.ts.map +1 -0
  99. package/dist/components/DataTotalsServer.js +18 -0
  100. package/dist/components/DialogActions.d.ts +11 -0
  101. package/dist/components/DialogActions.d.ts.map +1 -0
  102. package/dist/components/DialogActions.js +20 -0
  103. package/dist/components/FileTypeIcon.d.ts +18 -0
  104. package/dist/components/FileTypeIcon.d.ts.map +1 -0
  105. package/dist/components/FileTypeIcon.js +48 -0
  106. package/dist/components/GenericModelList.d.ts +53 -0
  107. package/dist/components/GenericModelList.d.ts.map +1 -0
  108. package/dist/components/GenericModelList.js +194 -0
  109. package/dist/components/GenericRelatedModelList.d.ts +55 -0
  110. package/dist/components/GenericRelatedModelList.d.ts.map +1 -0
  111. package/dist/components/GenericRelatedModelList.js +181 -0
  112. package/dist/components/GenericRelatedModelListTable.d.ts +56 -0
  113. package/dist/components/GenericRelatedModelListTable.d.ts.map +1 -0
  114. package/dist/components/GenericRelatedModelListTable.js +31 -0
  115. package/dist/components/Image.d.ts +10 -0
  116. package/dist/components/Image.d.ts.map +1 -0
  117. package/dist/components/Image.js +111 -0
  118. package/dist/components/details/DetailBySchema.d.ts +4 -0
  119. package/dist/components/details/DetailBySchema.d.ts.map +1 -0
  120. package/dist/components/details/DetailBySchema.js +175 -0
  121. package/dist/components/details/DetailFieldBySchema.d.ts +4 -0
  122. package/dist/components/details/DetailFieldBySchema.d.ts.map +1 -0
  123. package/dist/components/details/DetailFieldBySchema.js +88 -0
  124. package/dist/components/forms/ChangePasswordForm.d.ts +7 -0
  125. package/dist/components/forms/ChangePasswordForm.d.ts.map +1 -0
  126. package/dist/components/forms/ChangePasswordForm.js +93 -0
  127. package/dist/components/forms/DialogFormBySchema.d.ts +22 -0
  128. package/dist/components/forms/DialogFormBySchema.d.ts.map +1 -0
  129. package/dist/components/forms/DialogFormBySchema.js +97 -0
  130. package/dist/components/forms/FieldBySchema.d.ts +4 -0
  131. package/dist/components/forms/FieldBySchema.d.ts.map +1 -0
  132. package/dist/components/forms/FieldBySchema.js +80 -0
  133. package/dist/components/forms/ForgotPasswordForm.d.ts +11 -0
  134. package/dist/components/forms/ForgotPasswordForm.d.ts.map +1 -0
  135. package/dist/components/forms/ForgotPasswordForm.js +114 -0
  136. package/dist/components/forms/Form.d.ts +61 -0
  137. package/dist/components/forms/Form.d.ts.map +1 -0
  138. package/dist/components/forms/Form.js +264 -0
  139. package/dist/components/forms/FormActions.d.ts +20 -0
  140. package/dist/components/forms/FormActions.d.ts.map +1 -0
  141. package/dist/components/forms/FormActions.js +55 -0
  142. package/dist/components/forms/FormBySchema.d.ts +21 -0
  143. package/dist/components/forms/FormBySchema.d.ts.map +1 -0
  144. package/dist/components/forms/FormBySchema.js +280 -0
  145. package/dist/components/forms/FormWatcher.d.ts +10 -0
  146. package/dist/components/forms/FormWatcher.d.ts.map +1 -0
  147. package/dist/components/forms/FormWatcher.js +25 -0
  148. package/dist/components/forms/inputs/AutocompleteFieldBySchema.d.ts +13 -0
  149. package/dist/components/forms/inputs/AutocompleteFieldBySchema.d.ts.map +1 -0
  150. package/dist/components/forms/inputs/AutocompleteFieldBySchema.js +133 -0
  151. package/dist/components/forms/inputs/BooleanFieldBySchema.d.ts +4 -0
  152. package/dist/components/forms/inputs/BooleanFieldBySchema.d.ts.map +1 -0
  153. package/dist/components/forms/inputs/BooleanFieldBySchema.js +39 -0
  154. package/dist/components/forms/inputs/DesktopDatePickerBySchema.d.ts +5 -0
  155. package/dist/components/forms/inputs/DesktopDatePickerBySchema.d.ts.map +1 -0
  156. package/dist/components/forms/inputs/DesktopDatePickerBySchema.js +54 -0
  157. package/dist/components/forms/inputs/DesktopDateTimePickerBySchema.d.ts +5 -0
  158. package/dist/components/forms/inputs/DesktopDateTimePickerBySchema.d.ts.map +1 -0
  159. package/dist/components/forms/inputs/DesktopDateTimePickerBySchema.js +47 -0
  160. package/dist/components/forms/inputs/EditableAutocompleteFieldBySchema.d.ts +14 -0
  161. package/dist/components/forms/inputs/EditableAutocompleteFieldBySchema.d.ts.map +1 -0
  162. package/dist/components/forms/inputs/EditableAutocompleteFieldBySchema.js +272 -0
  163. package/dist/components/forms/inputs/FileFieldBySchema.d.ts +4 -0
  164. package/dist/components/forms/inputs/FileFieldBySchema.d.ts.map +1 -0
  165. package/dist/components/forms/inputs/FileFieldBySchema.js +144 -0
  166. package/dist/components/forms/inputs/FloatFieldBySchema.d.ts +4 -0
  167. package/dist/components/forms/inputs/FloatFieldBySchema.d.ts.map +1 -0
  168. package/dist/components/forms/inputs/FloatFieldBySchema.js +64 -0
  169. package/dist/components/forms/inputs/GeometryFieldBySchema.d.ts +8 -0
  170. package/dist/components/forms/inputs/GeometryFieldBySchema.d.ts.map +1 -0
  171. package/dist/components/forms/inputs/GeometryFieldBySchema.js +61 -0
  172. package/dist/components/forms/inputs/MapGeometryPicker.d.ts +19 -0
  173. package/dist/components/forms/inputs/MapGeometryPicker.d.ts.map +1 -0
  174. package/dist/components/forms/inputs/MapGeometryPicker.js +344 -0
  175. package/dist/components/forms/inputs/PatternFieldBySchema.d.ts +4 -0
  176. package/dist/components/forms/inputs/PatternFieldBySchema.d.ts.map +1 -0
  177. package/dist/components/forms/inputs/PatternFieldBySchema.js +56 -0
  178. package/dist/components/forms/inputs/TextFieldBySchema.d.ts +4 -0
  179. package/dist/components/forms/inputs/TextFieldBySchema.d.ts.map +1 -0
  180. package/dist/components/forms/inputs/TextFieldBySchema.js +56 -0
  181. package/dist/components/forms/inputs/leafletMarker.d.ts +12 -0
  182. package/dist/components/forms/inputs/leafletMarker.d.ts.map +1 -0
  183. package/dist/components/forms/inputs/leafletMarker.js +52 -0
  184. package/dist/context/APIWrapper.d.ts +18 -0
  185. package/dist/context/APIWrapper.d.ts.map +1 -0
  186. package/dist/context/APIWrapper.js +593 -0
  187. package/dist/context/APIWrapperContext.d.ts +132 -0
  188. package/dist/context/APIWrapperContext.d.ts.map +1 -0
  189. package/dist/context/APIWrapperContext.js +63 -0
  190. package/dist/context/DRFReactBySchemaContext.d.ts +31 -0
  191. package/dist/context/DRFReactBySchemaContext.d.ts.map +1 -0
  192. package/dist/context/DRFReactBySchemaContext.js +20 -0
  193. package/dist/context/DRFReactBySchemaProvider.d.ts +5 -0
  194. package/dist/context/DRFReactBySchemaProvider.d.ts.map +1 -0
  195. package/dist/context/DRFReactBySchemaProvider.js +105 -0
  196. package/dist/context/Overlays.d.ts +5 -0
  197. package/dist/context/Overlays.d.ts.map +1 -0
  198. package/dist/context/Overlays.js +114 -0
  199. package/dist/context/PrivateContext.d.ts +10 -0
  200. package/dist/context/PrivateContext.d.ts.map +1 -0
  201. package/dist/context/PrivateContext.js +16 -0
  202. package/dist/hooks/useDeepMemo.d.ts +2 -0
  203. package/dist/hooks/useDeepMemo.d.ts.map +1 -0
  204. package/dist/hooks/useDeepMemo.js +13 -0
  205. package/dist/hooks/useWhyDidYouUpdate.d.ts +4 -0
  206. package/dist/hooks/useWhyDidYouUpdate.d.ts.map +1 -0
  207. package/dist/hooks/useWhyDidYouUpdate.js +26 -0
  208. package/dist/index.d.ts +37 -0
  209. package/dist/index.d.ts.map +1 -0
  210. package/dist/index.js +108 -0
  211. package/dist/styles/grid.d.ts +3 -0
  212. package/dist/styles/grid.d.ts.map +1 -0
  213. package/dist/styles/grid.js +38 -0
  214. package/dist/styles/index.d.ts +3 -0
  215. package/dist/styles/index.d.ts.map +1 -0
  216. package/dist/styles/index.js +38 -0
  217. package/dist/styles/layout.d.ts +23 -0
  218. package/dist/styles/layout.d.ts.map +1 -0
  219. package/dist/styles/layout.js +71 -0
  220. package/dist/styles/texts.d.ts +66 -0
  221. package/dist/styles/texts.d.ts.map +1 -0
  222. package/dist/styles/texts.js +73 -0
  223. package/dist/styles/theme.d.ts +29 -0
  224. package/dist/styles/theme.d.ts.map +1 -0
  225. package/dist/styles/theme.js +226 -0
  226. package/dist/utils/index.d.ts +2 -0
  227. package/dist/utils/index.d.ts.map +1 -0
  228. package/dist/utils/index.js +17 -0
  229. package/dist/utils/utils.d.ts +107 -0
  230. package/dist/utils/utils.d.ts.map +1 -0
  231. package/dist/utils/utils.js +957 -0
  232. package/package.json +1 -1
@@ -0,0 +1,40 @@
1
+ import { RefObject } from 'react';
2
+ import { GridFilterOperator } from '@mui/x-data-grid';
3
+ import { GridApiCommunity } from '@mui/x-data-grid/models/api/gridApiCommunity';
4
+ import { FieldKey, GridEnrichedBySchemaColDef, Id, Item, TField } from '../../@types';
5
+ export type ResizeType = 'condense' | 'maxContent' | 'fitScreen';
6
+ /**
7
+ *
8
+ * @param columns
9
+ * @param resizeType
10
+ * @param apiRef
11
+ * @returns columns resized to the chosen resizeType
12
+ */
13
+ export declare function resizeColumns(columns: GridEnrichedBySchemaColDef[], resizeType: ResizeType): GridEnrichedBySchemaColDef[];
14
+ export declare const quantityOnlyOperators: ({ type }: {
15
+ type: string;
16
+ }) => GridFilterOperator<any, any, any>[];
17
+ export declare const buildEditPath: (basePath: string, objId: Id) => string;
18
+ export declare const buildExitPath: (basePath: string, objId?: Id) => string;
19
+ export declare const scrollToNewRow: (apiRef: RefObject<GridApiCommunity>, tableAutoHeight?: boolean) => void;
20
+ export declare function addNewRow<T extends TField = void>({ newRow, indexField, tableAutoHeight, apiRef, setDataGridRows, }: {
21
+ newRow: Item<T>;
22
+ indexField?: FieldKey<T>;
23
+ tableAutoHeight?: boolean;
24
+ apiRef: RefObject<GridApiCommunity>;
25
+ setDataGridRows: (value: React.SetStateAction<Item<T>[]>) => void;
26
+ }): void;
27
+ export declare function updateRow<T extends TField = void>({ newRow, setDataGridRows, originalId, apiRef, }: {
28
+ newRow: Item<T>;
29
+ originalId?: Id;
30
+ setDataGridRows: (value: React.SetStateAction<Item<T>[]>) => void;
31
+ apiRef: RefObject<GridApiCommunity>;
32
+ }): void;
33
+ export declare function deleteRow<T extends TField = void>({ id, apiRef, setDataGridRows, onProcessRow, }: {
34
+ id: Id;
35
+ apiRef: RefObject<GridApiCommunity>;
36
+ setDataGridRows: (value: React.SetStateAction<Item<T>[]>) => void;
37
+ onProcessRow?: (p?: Item<T>) => void;
38
+ }): void;
39
+ export declare function getAllRowIds(apiRef: RefObject<GridApiCommunity>): import("@mui/x-data-grid").GridRowId[];
40
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/components/DataGridBySchemaEditable/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS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,CAAC,SAAS,MAAM,GAAG,IAAI,EAAE,EACjD,MAAM,EACN,eAAe,EACf,UAAU,EACV,MAAM,GACP,EAAE;IACD,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;IAChB,UAAU,CAAC,EAAE,EAAE,CAAC;IAChB,eAAe,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,IAAI,CAAC;IAClE,MAAM,EAAE,SAAS,CAAC,gBAAgB,CAAC,CAAC;CACrC,QAqCA;AAED,wBAAgB,SAAS,CAAC,CAAC,SAAS,MAAM,GAAG,IAAI,EAAE,EACjD,EAAE,EACF,MAAM,EACN,eAAe,EACf,YAAY,GACb,EAAE;IACD,EAAE,EAAE,EAAE,CAAC;IACP,MAAM,EAAE,SAAS,CAAC,gBAAgB,CAAC,CAAC;IACpC,eAAe,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,IAAI,CAAC;IAClE,YAAY,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;CACtC,QAMA;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,SAAS,CAAC,gBAAgB,CAAC,0CAM/D"}
@@ -0,0 +1,181 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.scrollToNewRow = exports.buildExitPath = exports.buildEditPath = exports.quantityOnlyOperators = void 0;
4
+ exports.resizeColumns = resizeColumns;
5
+ exports.addNewRow = addNewRow;
6
+ exports.updateRow = updateRow;
7
+ exports.deleteRow = deleteRow;
8
+ exports.getAllRowIds = getAllRowIds;
9
+ const x_data_grid_1 = require("@mui/x-data-grid");
10
+ const InputInterval_1 = require("./InputInterval");
11
+ /**
12
+ * Get the largest width in a column, looking at all rows
13
+ * @param colIndex the column index
14
+ * @returns width of the biggest row inside a column
15
+ */
16
+ function maxOfCol(colIndex) {
17
+ const invisibleContainer = document.createElement('div');
18
+ invisibleContainer.style.visibility = 'hidden';
19
+ invisibleContainer.style.zIndex = '-9999999999';
20
+ invisibleContainer.style.position = 'absolute';
21
+ invisibleContainer.style.fontSize = '14px';
22
+ invisibleContainer.style.top = '0';
23
+ invisibleContainer.style.left = '0';
24
+ document.body.append(invisibleContainer);
25
+ const widths = [];
26
+ document.querySelectorAll(`[aria-colindex='${colIndex}']`).forEach((cell) => {
27
+ const invisibleCell = document.createElement('div');
28
+ invisibleCell.innerHTML = cell.innerHTML;
29
+ invisibleCell.style.width = 'max-content';
30
+ invisibleCell.style.maxWidth = 'none';
31
+ invisibleCell.style.minWidth = 'none';
32
+ invisibleContainer.append(invisibleCell);
33
+ widths.push(Math.ceil(invisibleCell.clientWidth));
34
+ });
35
+ let max = Math.max(...widths);
36
+ if (max !== 0 && max < 50) {
37
+ max = 50;
38
+ }
39
+ invisibleContainer.remove();
40
+ return max;
41
+ }
42
+ /**
43
+ *
44
+ * @param columns
45
+ * @param resizeType
46
+ * @param apiRef
47
+ * @returns columns resized to the chosen resizeType
48
+ */
49
+ function resizeColumns(columns, resizeType) {
50
+ const cols = [...columns];
51
+ cols.forEach((col, index) => {
52
+ if (resizeType === 'fitScreen') {
53
+ delete col.width;
54
+ col.minWidth = 80;
55
+ if (col.isIndexField) {
56
+ col.flex = 1;
57
+ }
58
+ }
59
+ else if (resizeType === 'maxContent') {
60
+ const maxColWidth = maxOfCol(index);
61
+ delete col.flex;
62
+ delete col.minWidth;
63
+ col.width = maxColWidth + 22;
64
+ }
65
+ else {
66
+ col.width = 0;
67
+ }
68
+ });
69
+ return cols;
70
+ }
71
+ const quantityOnlyOperators = ({ type }) => {
72
+ const builtInFilters = type === 'date' ? (0, x_data_grid_1.getGridDateOperators)() : (0, x_data_grid_1.getGridNumericOperators)();
73
+ let InputComponent = InputInterval_1.InputNumberInterval;
74
+ if (type === 'date') {
75
+ InputComponent = InputInterval_1.InputDateInterval;
76
+ }
77
+ if (type === 'float') {
78
+ InputComponent = InputInterval_1.InputFloatInterval;
79
+ }
80
+ const operators = [
81
+ ...builtInFilters,
82
+ {
83
+ label: 'entre',
84
+ value: 'entre',
85
+ getApplyFilterFn: (filterItem) => {
86
+ if (!Array.isArray(filterItem.value) || filterItem.value.length !== 2) {
87
+ return null;
88
+ }
89
+ if (filterItem.value[0] === null || filterItem.value[1] === null) {
90
+ return null;
91
+ }
92
+ return ({ value }) => {
93
+ return value !== null && filterItem.value[0] <= value && value <= filterItem.value[1];
94
+ };
95
+ },
96
+ InputComponent,
97
+ },
98
+ ];
99
+ return operators;
100
+ };
101
+ exports.quantityOnlyOperators = quantityOnlyOperators;
102
+ const buildEditPath = (basePath, objId) => {
103
+ if (basePath.includes('{ID}')) {
104
+ return basePath.replace('{ID}', `${objId}`);
105
+ }
106
+ return `${basePath}${objId}`;
107
+ };
108
+ exports.buildEditPath = buildEditPath;
109
+ const buildExitPath = (basePath, objId) => {
110
+ if (basePath.includes('{ID}') && objId) {
111
+ return basePath.replace('{ID}', `${objId}`);
112
+ }
113
+ return basePath;
114
+ };
115
+ exports.buildExitPath = buildExitPath;
116
+ const scrollToNewRow = (apiRef, tableAutoHeight) => {
117
+ setTimeout(() => {
118
+ if (!tableAutoHeight) {
119
+ apiRef.current.scrollToIndexes({ rowIndex: 0 });
120
+ return;
121
+ }
122
+ const rowCount = apiRef.current.getRowsCount();
123
+ apiRef.current.scrollToIndexes({
124
+ rowIndex: rowCount - 1,
125
+ });
126
+ }, 500);
127
+ };
128
+ exports.scrollToNewRow = scrollToNewRow;
129
+ function addNewRow({ newRow, indexField, tableAutoHeight, apiRef, setDataGridRows, }) {
130
+ apiRef.current.updateRows([newRow]);
131
+ let fieldToFocus = indexField;
132
+ if (!fieldToFocus) {
133
+ const visibleColumns = apiRef.current.getAllColumns();
134
+ const firstEditableCol = visibleColumns.find((col) => col.editable && col.field !== 'actions');
135
+ fieldToFocus = firstEditableCol === null || firstEditableCol === void 0 ? void 0 : firstEditableCol.field;
136
+ }
137
+ apiRef.current.startRowEditMode({ id: newRow.id, fieldToFocus });
138
+ (0, exports.scrollToNewRow)(apiRef, tableAutoHeight);
139
+ setDataGridRows((currentRows) => tableAutoHeight ? [...currentRows, newRow] : [newRow, ...currentRows]);
140
+ }
141
+ function updateRow({ newRow, setDataGridRows, originalId, apiRef, }) {
142
+ const ids = getAllRowIds(apiRef);
143
+ const exists = ids.includes(newRow.id);
144
+ apiRef.current.updateRows([newRow]);
145
+ const idToRemove = originalId && originalId !== newRow.id && ids.includes(originalId) ? originalId : undefined;
146
+ if (exists) {
147
+ if (idToRemove) {
148
+ // Remove idToRemove and replace existing newRow.id with newRow:
149
+ apiRef.current.updateRows([{ id: idToRemove, _action: 'delete' }]);
150
+ setDataGridRows((currentRows) => currentRows
151
+ .filter(({ id }) => id !== idToRemove)
152
+ .map((currentRow) => (currentRow.id === newRow.id ? newRow : currentRow)));
153
+ }
154
+ else {
155
+ // Only replace existing newRow.id with newRow:
156
+ setDataGridRows((currentRows) => currentRows.map((currentRow) => (currentRow.id === newRow.id ? newRow : currentRow)));
157
+ }
158
+ return;
159
+ }
160
+ // Add new row in the exact same index where there was the idToRemove:
161
+ if (idToRemove) {
162
+ setDataGridRows((currentRows) => currentRows.map((currentRow) => (currentRow.id === idToRemove ? newRow : currentRow)));
163
+ return;
164
+ }
165
+ // Add absolutely new row:
166
+ setDataGridRows((currentRows) => [...currentRows, newRow]);
167
+ }
168
+ function deleteRow({ id, apiRef, setDataGridRows, onProcessRow, }) {
169
+ apiRef.current.updateRows([{ id, _action: 'delete' }]);
170
+ setDataGridRows((currentRows) => currentRows.filter((item) => item.id !== id));
171
+ if (onProcessRow) {
172
+ onProcessRow();
173
+ }
174
+ }
175
+ function getAllRowIds(apiRef) {
176
+ if (!apiRef.current.getRowModels) {
177
+ return [];
178
+ }
179
+ const rowModels = apiRef.current.getRowModels();
180
+ return Array.from(rowModels.keys());
181
+ }
@@ -0,0 +1,64 @@
1
+ import React, { ReactElement } from 'react';
2
+ import { GridRowId, GridRenderCellParams, GridColumnVisibilityModel } from '@mui/x-data-grid';
3
+ import { SxProps, Theme } from '@mui/material/styles';
4
+ import { Item, SchemaType, Id, GridEnrichedBySchemaColDef, PaginationModel, OnSelectActions, OptionsAC, CustomAction, LinkComponentType, MobileListRenderItemType, ExtraValidators, CustomFormFieldLayouts, FieldKey, CustomColumnOperations, PartialItem, RowAction, NonEditableRowAction, TField, WatchEditingRowValues } from '../@types';
5
+ import { OnEditModelType } from '../context/APIWrapperContext';
6
+ interface DataGridBySchemaEditableProps<T extends TField = void> {
7
+ schema: SchemaType<T>;
8
+ data: Item<T>[];
9
+ rowCount?: number;
10
+ columns: GridEnrichedBySchemaColDef<T>[];
11
+ columnVisibilityModel?: GridColumnVisibilityModel;
12
+ model: string;
13
+ fieldKey?: FieldKey<T>;
14
+ labelKey?: FieldKey<T>;
15
+ index?: number;
16
+ name?: string;
17
+ indexField?: FieldKey<T>;
18
+ addExistingModel?: string;
19
+ indexFieldMinWidth?: number;
20
+ indexFieldBasePath?: string;
21
+ indexFieldViewBasePath?: string;
22
+ stateToLink?: object;
23
+ minWidth?: number;
24
+ loading?: boolean;
25
+ modelParentId?: Id;
26
+ modelParent?: string;
27
+ customColumnOperations?: CustomColumnOperations<T>;
28
+ customFieldFormLayouts?: CustomFormFieldLayouts<T>;
29
+ customLinkDestination?: (p: GridRenderCellParams) => string;
30
+ LinkComponent?: LinkComponentType;
31
+ onProcessRow?: (p?: Item<T>) => void;
32
+ onDataChange?: (p: Item<T>[]) => void;
33
+ watchEditingRowValues?: WatchEditingRowValues;
34
+ onEditModel: <U extends TField = void>(p: OnEditModelType<U>) => void;
35
+ isEditable?: boolean;
36
+ nonEditableActions?: NonEditableRowAction<T>[];
37
+ hasBulkSelect?: boolean;
38
+ cardsViewOnly?: boolean;
39
+ onSelectActions?: OnSelectActions[];
40
+ sx?: SxProps<Theme>;
41
+ isAutoHeight?: boolean;
42
+ defaultValues?: PartialItem<T>;
43
+ hideFooterPagination?: boolean;
44
+ setVisibleRows?: (p: GridRowId[]) => void;
45
+ paginationModel?: PaginationModel;
46
+ setPaginationModel?: (x: PaginationModel) => void;
47
+ hideFooterComponent?: boolean;
48
+ hideToolbarComponent?: boolean;
49
+ tableAutoHeight?: boolean;
50
+ actions?: RowAction<T>[];
51
+ customActions?: CustomAction[];
52
+ hideColumnsButton?: boolean;
53
+ hideFilterButton?: boolean;
54
+ hideDensityButton?: boolean;
55
+ hideExportButton?: boolean;
56
+ hideQuickFilterBar?: boolean;
57
+ optionsAC?: OptionsAC<T>;
58
+ extraValidators?: ExtraValidators<T>;
59
+ MobileListRenderItem?: MobileListRenderItemType;
60
+ MobileRenderNoResults?: () => ReactElement | null;
61
+ }
62
+ declare function DataGridBySchemaEditable<T extends TField = void>({ schema, data, rowCount, columns, columnVisibilityModel, model, name, indexField, addExistingModel, indexFieldMinWidth, indexFieldBasePath, indexFieldViewBasePath, stateToLink, minWidth, loading, modelParent, modelParentId, customColumnOperations, customFieldFormLayouts, customLinkDestination, LinkComponent, onProcessRow, onDataChange, watchEditingRowValues, onEditModel, isEditable, nonEditableActions, hasBulkSelect, cardsViewOnly, onSelectActions, isAutoHeight, defaultValues, hideFooterPagination, setVisibleRows, paginationModel, setPaginationModel, hideFooterComponent, hideToolbarComponent, tableAutoHeight, actions, customActions, hideColumnsButton, hideFilterButton, hideDensityButton, hideExportButton, hideQuickFilterBar, optionsAC, extraValidators, MobileListRenderItem, MobileRenderNoResults, }: DataGridBySchemaEditableProps<T>): React.JSX.Element;
63
+ export default DataGridBySchemaEditable;
64
+ //# sourceMappingURL=DataGridBySchemaEditable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DataGridBySchemaEditable.d.ts","sourceRoot":"","sources":["../../src/components/DataGridBySchemaEditable.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAA+B,YAAY,EAAE,MAAM,OAAO,CAAC;AACzE,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eAAe,EACf,OAAkC,EAClC,aAAa,EACb,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,EAClB,SAAS,EACT,eAAe,EACf,oBAAoB,EACpB,qBAAqB,GACtB,EAAE,6BAA6B,CAAC,CAAC,CAAC,qBAoNlC;AAED,eAAe,wBAAwB,CAAC"}
@@ -0,0 +1,172 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
36
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
37
+ return new (P || (P = Promise))(function (resolve, reject) {
38
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
39
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
40
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
41
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
42
+ });
43
+ };
44
+ var __importDefault = (this && this.__importDefault) || function (mod) {
45
+ return (mod && mod.__esModule) ? mod : { "default": mod };
46
+ };
47
+ Object.defineProperty(exports, "__esModule", { value: true });
48
+ const react_1 = __importStar(require("react"));
49
+ const x_data_grid_1 = require("@mui/x-data-grid");
50
+ const Box_1 = __importDefault(require("@mui/material/Box"));
51
+ const Snackbar_1 = __importDefault(require("@mui/material/Snackbar"));
52
+ const Alert_1 = __importDefault(require("@mui/material/Alert"));
53
+ const utils_1 = require("../utils");
54
+ const APIWrapperContext_1 = require("../context/APIWrapperContext");
55
+ const ConfirmDialog_1 = require("./DataGridBySchemaEditable/ConfirmDialog");
56
+ const DataGridDesktop_1 = __importDefault(require("./DataGridBySchemaEditable/DataGridDesktop"));
57
+ const DataGridMobile_1 = __importDefault(require("./DataGridBySchemaEditable/DataGridMobile"));
58
+ const utils_2 = require("./DataGridBySchemaEditable/utils");
59
+ function DataGridBySchemaEditable({ schema, data, rowCount = 0, columns, columnVisibilityModel, model, name = Math.floor(Math.random() * 1000000).toString(), indexField = 'nome', addExistingModel, indexFieldMinWidth = 350, indexFieldBasePath = '', indexFieldViewBasePath, stateToLink = {}, minWidth = 80, loading, modelParent, modelParentId, customColumnOperations, customFieldFormLayouts, customLinkDestination, LinkComponent, onProcessRow, onDataChange, watchEditingRowValues, onEditModel, isEditable = false, nonEditableActions, hasBulkSelect = false, cardsViewOnly, onSelectActions, isAutoHeight = false, defaultValues, hideFooterPagination = false, setVisibleRows, paginationModel = undefined, setPaginationModel = undefined, hideFooterComponent, hideToolbarComponent, tableAutoHeight, actions = ['editInline', 'remove'], customActions, hideColumnsButton, hideFilterButton, hideDensityButton, hideExportButton, hideQuickFilterBar, optionsAC, extraValidators, MobileListRenderItem, MobileRenderNoResults, }) {
60
+ const wrapperRef = (0, react_1.useRef)(null);
61
+ const { isMobile, onDeleteModel, onDeleteRelatedModel } = (0, APIWrapperContext_1.useAPIWrapper)();
62
+ const initialSnackBar = {
63
+ open: false,
64
+ msg: '',
65
+ severity: 'info',
66
+ };
67
+ const [snackBar, setSnackBar] = (0, react_1.useState)(initialSnackBar);
68
+ const apiRef = (0, x_data_grid_1.useGridApiRef)();
69
+ const [dataGridRows, setDataGridRows] = (0, react_1.useState)([]);
70
+ const [confirmDialogOpen, setConfirmDialogOpen] = (0, react_1.useState)(false);
71
+ const [emptyItem, setEmptyItem] = (0, react_1.useState)({});
72
+ const yupValidationSchema = (0, react_1.useRef)(null);
73
+ const idToRemove = (0, react_1.useRef)(null);
74
+ const handleConfirmDialogClose = () => {
75
+ setConfirmDialogOpen(false);
76
+ };
77
+ const handleDeleteRelatedSave = () => __awaiter(this, void 0, void 0, function* () {
78
+ if (idToRemove.current === null) {
79
+ setConfirmDialogOpen(false);
80
+ return;
81
+ }
82
+ if (modelParent && modelParentId) {
83
+ yield onDeleteRelatedModel({
84
+ model: modelParent,
85
+ id: modelParentId,
86
+ relatedModel: model,
87
+ relatedModelId: idToRemove.current,
88
+ });
89
+ (0, utils_2.deleteRow)({ id: idToRemove.current, apiRef, setDataGridRows });
90
+ }
91
+ idToRemove.current = null;
92
+ setConfirmDialogOpen(false);
93
+ });
94
+ const handleDeleteClick = (id) => {
95
+ if (!modelParent || !modelParentId) {
96
+ onDeleteModel(model, id, () => {
97
+ (0, utils_2.deleteRow)({ id, apiRef, setDataGridRows, onProcessRow });
98
+ });
99
+ return;
100
+ }
101
+ idToRemove.current = id;
102
+ setConfirmDialogOpen(true);
103
+ };
104
+ (0, react_1.useEffect)(() => {
105
+ if (!columns) {
106
+ setDataGridRows([]);
107
+ return;
108
+ }
109
+ const newEmptyItem = {};
110
+ if (isEditable) {
111
+ for (const col of columns) {
112
+ const fieldKey = col.field;
113
+ const fieldSchema = schema[col.field];
114
+ if (fieldSchema === null || fieldSchema === void 0 ? void 0 : fieldSchema.model_default) {
115
+ newEmptyItem[fieldKey] = fieldSchema.model_default;
116
+ continue;
117
+ }
118
+ if (defaultValues && fieldKey in defaultValues) {
119
+ newEmptyItem[fieldKey] = defaultValues[fieldKey];
120
+ continue;
121
+ }
122
+ newEmptyItem[fieldKey] = fieldSchema ? (0, utils_1.emptyByType)(fieldSchema) : null;
123
+ }
124
+ setEmptyItem(newEmptyItem);
125
+ }
126
+ const skipFields = [];
127
+ if (indexField && addExistingModel) {
128
+ skipFields.push(indexField);
129
+ }
130
+ yupValidationSchema.current = (0, utils_1.buildGenericYupValidationSchema)({
131
+ data: newEmptyItem,
132
+ schema: schema,
133
+ skipFields,
134
+ extraValidators: extraValidators,
135
+ uiFields: columns.map(({ field }) => field),
136
+ });
137
+ setDataGridRows(data);
138
+ // eslint-disable-next-line react-hooks/exhaustive-deps
139
+ }, [data]);
140
+ // Accessibility requirement for DataGrid access with screenreader:
141
+ // useEffect(() => {
142
+ // const applyAria = () => {
143
+ // const scroller = wrapperRef.current?.querySelector('.MuiDataGrid-virtualScroller');
144
+ // if (scroller && scroller.getAttribute('role') !== 'region') {
145
+ // scroller.setAttribute('role', 'rowgroup');
146
+ // scroller.setAttribute('aria-label', 'Conteúdo rolável da tabela');
147
+ // scroller.setAttribute('tabindex', '0');
148
+ // }
149
+ // };
150
+ // applyAria();
151
+ // const observer = new MutationObserver(applyAria);
152
+ // if (wrapperRef.current) {
153
+ // observer.observe(wrapperRef.current, { childList: true, subtree: true });
154
+ // }
155
+ // return () => observer.disconnect();
156
+ // }, []);
157
+ // Reflect changes to the outside, for example for doing global calculations over multiple rows:
158
+ (0, react_1.useEffect)(() => {
159
+ const hasTmpIds = (0, utils_2.getAllRowIds)(apiRef).find((currentId) => (0, utils_1.isTmpId)(currentId));
160
+ if (onDataChange && !hasTmpIds) {
161
+ onDataChange(dataGridRows);
162
+ }
163
+ }, [dataGridRows, apiRef, onDataChange]);
164
+ return (react_1.default.createElement(Box_1.default, { sx: { height: '100%', width: '100%', maxWidth: '100%' }, ref: !(isMobile || cardsViewOnly) || !MobileListRenderItem ? wrapperRef : undefined },
165
+ (isMobile || cardsViewOnly) && MobileListRenderItem ? (react_1.default.createElement(DataGridMobile_1.default, { name: name, data: data, schema: schema, columns: columns, customColumnOperations: customColumnOperations, MobileListRenderItem: MobileListRenderItem, MobileRenderNoResults: MobileRenderNoResults, hideQuickFilterBar: hideQuickFilterBar, paginationModel: paginationModel, setPaginationModel: setPaginationModel, rowCount: rowCount })) : (react_1.default.createElement(DataGridDesktop_1.default, { schema: schema, apiRef: apiRef, dataGridRows: dataGridRows, setDataGridRows: setDataGridRows, rowCount: rowCount, columns: columns, columnVisibilityModel: columnVisibilityModel, model: model, name: name, indexField: indexField, addExistingModel: addExistingModel, indexFieldMinWidth: indexFieldMinWidth, indexFieldBasePath: indexFieldBasePath, indexFieldViewBasePath: indexFieldViewBasePath, stateToLink: stateToLink, minWidth: minWidth, loading: loading, modelParentId: modelParentId, modelParent: modelParent, customColumnOperations: customColumnOperations, customFieldFormLayouts: customFieldFormLayouts, customLinkDestination: customLinkDestination, LinkComponent: LinkComponent, onProcessRow: onProcessRow, watchEditingRowValues: watchEditingRowValues, onEditModel: onEditModel, isEditable: isEditable, hasBulkSelect: hasBulkSelect, onSelectActions: onSelectActions, isAutoHeight: isAutoHeight, defaultValues: defaultValues, hideFooterPagination: hideFooterPagination, setVisibleRows: setVisibleRows, paginationModel: paginationModel, setPaginationModel: setPaginationModel, hideFooterComponent: hideFooterComponent, hideToolbarComponent: hideToolbarComponent, tableAutoHeight: tableAutoHeight, actions: actions, nonEditableActions: nonEditableActions, customActions: customActions, hideColumnsButton: hideColumnsButton, hideFilterButton: hideFilterButton, hideDensityButton: hideDensityButton, hideExportButton: hideExportButton, hideQuickFilterBar: hideQuickFilterBar, optionsAC: optionsAC, extraValidators: extraValidators, emptyItem: emptyItem, handleDeleteClick: handleDeleteClick, setSnackBar: setSnackBar, yupValidationSchema: yupValidationSchema.current })),
166
+ react_1.default.createElement(ConfirmDialog_1.ConfirmDialog, { open: confirmDialogOpen, onClose: handleConfirmDialogClose, onConfirm: handleDeleteRelatedSave }),
167
+ react_1.default.createElement(Snackbar_1.default, { open: snackBar.open, autoHideDuration: 5000, onClose: () => {
168
+ setSnackBar(Object.assign(Object.assign({}, initialSnackBar), { open: false }));
169
+ }, anchorOrigin: { vertical: 'top', horizontal: 'center' } },
170
+ react_1.default.createElement(Alert_1.default, { severity: snackBar.severity }, snackBar.msg))));
171
+ }
172
+ exports.default = DataGridBySchemaEditable;
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ import { GridRowId } from '@mui/x-data-grid';
3
+ import { Item, SchemaType, SumRowsType } from '../@types';
4
+ interface DataTotalsProps {
5
+ schema?: SchemaType;
6
+ data?: Item[];
7
+ sumRows?: SumRowsType;
8
+ visibleRows?: GridRowId[];
9
+ }
10
+ declare const DataTotals: ({ schema, data, sumRows, visibleRows }: DataTotalsProps) => React.JSX.Element | null;
11
+ export default DataTotals;
12
+ //# sourceMappingURL=DataTotals.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DataTotals.d.ts","sourceRoot":"","sources":["../../src/components/DataTotals.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAE1D,UAAU,eAAe;IACvB,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC;IACd,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,WAAW,CAAC,EAAE,SAAS,EAAE,CAAC;CAC3B;AAED,QAAA,MAAM,UAAU,GAAI,wCAAwC,eAAe,6BA2C1E,CAAC;AAEF,eAAe,UAAU,CAAC"}
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const react_1 = __importDefault(require("react"));
7
+ const Alert_1 = __importDefault(require("@mui/material/Alert"));
8
+ const List_1 = __importDefault(require("@mui/material/List"));
9
+ const ListItem_1 = __importDefault(require("@mui/material/ListItem"));
10
+ const react_number_format_1 = require("react-number-format");
11
+ const DataTotals = ({ schema, data, sumRows, visibleRows }) => {
12
+ if (!schema || !data || !(sumRows === null || sumRows === void 0 ? void 0 : sumRows.rows)) {
13
+ return null;
14
+ }
15
+ return (react_1.default.createElement(react_1.default.Fragment, null, data && sumRows && sumRows.rows.length > 0 && (react_1.default.createElement(Alert_1.default, { severity: sumRows.severity || 'info' },
16
+ react_1.default.createElement(List_1.default, { dense: true }, sumRows.rows.map((row) => {
17
+ var _a;
18
+ return (react_1.default.createElement(ListItem_1.default, { key: `sumRows_${row.field}` },
19
+ react_1.default.createElement(react_number_format_1.NumericFormat, { value: [...data].reduce((total, item) => {
20
+ if (parseFloat(item[row.field]) &&
21
+ (!visibleRows || visibleRows.includes(`${item.id}`))) {
22
+ return total + parseFloat(item[row.field]);
23
+ }
24
+ return total;
25
+ }, 0), thousandSeparator: ".", decimalSeparator: ",", displayType: 'text', decimalScale: row.isCount ? 0 : 2, fixedDecimalScale: true, prefix: row.prefix
26
+ ? `${row.prefix} `
27
+ : schema && ((_a = schema[row.field]) === null || _a === void 0 ? void 0 : _a.label)
28
+ ? `${schema[row.field].label}: `
29
+ : undefined, suffix: row.suffix ? ` ${row.suffix}` : undefined })));
30
+ }))))));
31
+ };
32
+ exports.default = DataTotals;
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import { SchemaType, SumRowsType } from '../@types';
3
+ interface DataTotalsServerProps {
4
+ sumRows?: SumRowsType;
5
+ totals?: null | Record<string, number>;
6
+ schema?: SchemaType;
7
+ }
8
+ declare const DataTotalsServer: ({ schema, sumRows, totals, }: DataTotalsServerProps) => React.JSX.Element;
9
+ export default DataTotalsServer;
10
+ //# sourceMappingURL=DataTotalsServer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DataTotalsServer.d.ts","sourceRoot":"","sources":["../../src/components/DataTotalsServer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAEpD,UAAU,qBAAqB;IAC7B,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,MAAM,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACvC,MAAM,CAAC,EAAE,UAAU,CAAC;CACrB;AAED,QAAA,MAAM,gBAAgB,GAAI,8BAIvB,qBAAqB,sBA6BvB,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const react_1 = __importDefault(require("react"));
7
+ const Alert_1 = __importDefault(require("@mui/material/Alert"));
8
+ const List_1 = __importDefault(require("@mui/material/List"));
9
+ const ListItem_1 = __importDefault(require("@mui/material/ListItem"));
10
+ const react_number_format_1 = require("react-number-format");
11
+ const DataTotalsServer = ({ schema, sumRows, totals, }) => (react_1.default.createElement(react_1.default.Fragment, null, sumRows && sumRows.rows.length > 0 && (react_1.default.createElement(Alert_1.default, { severity: sumRows.severity || 'info' },
12
+ react_1.default.createElement(List_1.default, { dense: true }, sumRows.rows.map((row) => (react_1.default.createElement(ListItem_1.default, { key: `sumRows_${row.field}` },
13
+ react_1.default.createElement(react_number_format_1.NumericFormat, { value: totals && totals[`${row.field}_total`] ? totals[`${row.field}_total`] : 0, thousandSeparator: ".", decimalSeparator: ",", displayType: 'text', decimalScale: row.isCount ? 0 : 2, fixedDecimalScale: true, prefix: row.prefix
14
+ ? `${row.prefix} `
15
+ : schema && schema[row.field].label
16
+ ? `${schema[row.field].label}: `
17
+ : undefined, suffix: row.suffix ? ` ${row.suffix}` : undefined })))))))));
18
+ exports.default = DataTotalsServer;
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import { DialogType } from '../context/APIWrapperContext';
3
+ interface DialogActionsProps {
4
+ setDialog: (x: Partial<DialogType>) => void;
5
+ handleSave?: React.MouseEventHandler<HTMLButtonElement>;
6
+ btnCancel?: string;
7
+ btnConfirm?: string;
8
+ }
9
+ export default function DialogActions({ setDialog, handleSave, btnCancel, btnConfirm, }: DialogActionsProps): React.JSX.Element;
10
+ export {};
11
+ //# sourceMappingURL=DialogActions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DialogActions.d.ts","sourceRoot":"","sources":["../../src/components/DialogActions.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAG1D,UAAU,kBAAkB;IAC1B,SAAS,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,KAAK,IAAI,CAAC;IAC5C,UAAU,CAAC,EAAE,KAAK,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,CAAC;IACxD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AACD,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,EACpC,SAAS,EACT,UAAU,EACV,SAAS,EACT,UAAU,GACX,EAAE,kBAAkB,qBAepB"}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.default = DialogActions;
7
+ const react_1 = __importDefault(require("react"));
8
+ const Button_1 = __importDefault(require("@mui/material/Button"));
9
+ const styles_1 = require("@mui/material/styles");
10
+ const texts_1 = require("../styles/texts");
11
+ function DialogActions({ setDialog, handleSave, btnCancel, btnConfirm, }) {
12
+ const formTexts = (0, texts_1.getThemeTexts)((0, styles_1.useTheme)()).forms;
13
+ const cancelLabel = btnCancel !== null && btnCancel !== void 0 ? btnCancel : formTexts.dialogCancel;
14
+ const confirmLabel = btnConfirm !== null && btnConfirm !== void 0 ? btnConfirm : formTexts.dialogSave;
15
+ return (react_1.default.createElement(react_1.default.Fragment, null,
16
+ react_1.default.createElement(Button_1.default, { onClick: () => {
17
+ setDialog({ open: false });
18
+ } }, cancelLabel),
19
+ handleSave && react_1.default.createElement(Button_1.default, { onClick: handleSave }, confirmLabel)));
20
+ }
@@ -0,0 +1,18 @@
1
+ import React from 'react';
2
+ import SvgIcon from '@mui/material/SvgIcon';
3
+ /**
4
+ * File extension → icon, reused anywhere a stored file is shown (detail page,
5
+ * grid cells, mobile lists, ...). Kept here until a central constants module
6
+ * groups it with the other shared constants (as done with the types).
7
+ */
8
+ export declare const FILE_TYPE_ICONS: Record<string, typeof SvgIcon>;
9
+ export declare const DEFAULT_FILE_ICON: import("@mui/material/OverridableComponent").OverridableComponent<import("@mui/material/SvgIcon").SvgIconTypeMap<{}, "svg">> & {
10
+ muiName: string;
11
+ };
12
+ export interface FileTypeIconProps {
13
+ /** File name (or URL) whose extension selects the icon. */
14
+ name?: string;
15
+ }
16
+ /** Renders the small icon matching a stored file's extension. */
17
+ export default function FileTypeIcon({ name }: FileTypeIconProps): React.JSX.Element;
18
+ //# sourceMappingURL=FileTypeIcon.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FileTypeIcon.d.ts","sourceRoot":"","sources":["../../src/components/FileTypeIcon.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,OAAO,MAAM,uBAAuB,CAAC;AAQ5C;;;;GAIG;AACH,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,OAAO,CAoB1D,CAAC;AAEF,eAAO,MAAM,iBAAiB;;CAAsB,CAAC;AAErD,MAAM,WAAW,iBAAiB;IAChC,2DAA2D;IAC3D,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,iEAAiE;AACjE,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,EAAE,IAAI,EAAE,EAAE,iBAAiB,qBAI/D"}