drf-react-by-schema 0.28.5 → 0.28.7

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 (227) hide show
  1. package/README.md +11 -0
  2. package/package.json +8 -21
  3. package/dist/@types/index.d.ts +0 -408
  4. package/dist/@types/index.d.ts.map +0 -1
  5. package/dist/@types/index.js +0 -9
  6. package/dist/@types/string-mask.d.ts +0 -10
  7. package/dist/@types/string-mask.d.ts.map +0 -1
  8. package/dist/@types/string-mask.js +0 -1
  9. package/dist/api.d.ts +0 -78
  10. package/dist/api.d.ts.map +0 -1
  11. package/dist/api.js +0 -1058
  12. package/dist/components/DataGridBySchemaEditable/BooleanInputCell.d.ts +0 -8
  13. package/dist/components/DataGridBySchemaEditable/BooleanInputCell.d.ts.map +0 -1
  14. package/dist/components/DataGridBySchemaEditable/BooleanInputCell.js +0 -86
  15. package/dist/components/DataGridBySchemaEditable/ConditionalEditWrapper.d.ts +0 -12
  16. package/dist/components/DataGridBySchemaEditable/ConditionalEditWrapper.d.ts.map +0 -1
  17. package/dist/components/DataGridBySchemaEditable/ConditionalEditWrapper.js +0 -71
  18. package/dist/components/DataGridBySchemaEditable/ConfirmDialog.d.ts +0 -9
  19. package/dist/components/DataGridBySchemaEditable/ConfirmDialog.d.ts.map +0 -1
  20. package/dist/components/DataGridBySchemaEditable/ConfirmDialog.js +0 -21
  21. package/dist/components/DataGridBySchemaEditable/CustomToolbar.d.ts +0 -26
  22. package/dist/components/DataGridBySchemaEditable/CustomToolbar.d.ts.map +0 -1
  23. package/dist/components/DataGridBySchemaEditable/CustomToolbar.js +0 -146
  24. package/dist/components/DataGridBySchemaEditable/DataGridDesktop.d.ts +0 -72
  25. package/dist/components/DataGridBySchemaEditable/DataGridDesktop.d.ts.map +0 -1
  26. package/dist/components/DataGridBySchemaEditable/DataGridDesktop.js +0 -416
  27. package/dist/components/DataGridBySchemaEditable/DataGridMobile.d.ts +0 -18
  28. package/dist/components/DataGridBySchemaEditable/DataGridMobile.d.ts.map +0 -1
  29. package/dist/components/DataGridBySchemaEditable/DataGridMobile.js +0 -105
  30. package/dist/components/DataGridBySchemaEditable/FileInputCell.d.ts +0 -11
  31. package/dist/components/DataGridBySchemaEditable/FileInputCell.d.ts.map +0 -1
  32. package/dist/components/DataGridBySchemaEditable/FileInputCell.js +0 -155
  33. package/dist/components/DataGridBySchemaEditable/FooterToolbar.d.ts +0 -12
  34. package/dist/components/DataGridBySchemaEditable/FooterToolbar.d.ts.map +0 -1
  35. package/dist/components/DataGridBySchemaEditable/FooterToolbar.js +0 -36
  36. package/dist/components/DataGridBySchemaEditable/GeoEditCell.d.ts +0 -10
  37. package/dist/components/DataGridBySchemaEditable/GeoEditCell.d.ts.map +0 -1
  38. package/dist/components/DataGridBySchemaEditable/GeoEditCell.js +0 -85
  39. package/dist/components/DataGridBySchemaEditable/GeoThumbCell.d.ts +0 -11
  40. package/dist/components/DataGridBySchemaEditable/GeoThumbCell.d.ts.map +0 -1
  41. package/dist/components/DataGridBySchemaEditable/GeoThumbCell.js +0 -87
  42. package/dist/components/DataGridBySchemaEditable/GridActionsCellItemLink.d.ts +0 -18
  43. package/dist/components/DataGridBySchemaEditable/GridActionsCellItemLink.d.ts.map +0 -1
  44. package/dist/components/DataGridBySchemaEditable/GridActionsCellItemLink.js +0 -24
  45. package/dist/components/DataGridBySchemaEditable/GridDateInput.d.ts +0 -8
  46. package/dist/components/DataGridBySchemaEditable/GridDateInput.d.ts.map +0 -1
  47. package/dist/components/DataGridBySchemaEditable/GridDateInput.js +0 -166
  48. package/dist/components/DataGridBySchemaEditable/GridDateTimeInput.d.ts +0 -6
  49. package/dist/components/DataGridBySchemaEditable/GridDateTimeInput.d.ts.map +0 -1
  50. package/dist/components/DataGridBySchemaEditable/GridDateTimeInput.js +0 -154
  51. package/dist/components/DataGridBySchemaEditable/GridDecimalInput.d.ts +0 -10
  52. package/dist/components/DataGridBySchemaEditable/GridDecimalInput.d.ts.map +0 -1
  53. package/dist/components/DataGridBySchemaEditable/GridDecimalInput.js +0 -78
  54. package/dist/components/DataGridBySchemaEditable/GridGenericInput.d.ts +0 -8
  55. package/dist/components/DataGridBySchemaEditable/GridGenericInput.d.ts.map +0 -1
  56. package/dist/components/DataGridBySchemaEditable/GridGenericInput.js +0 -30
  57. package/dist/components/DataGridBySchemaEditable/GridPatternInput.d.ts +0 -7
  58. package/dist/components/DataGridBySchemaEditable/GridPatternInput.d.ts.map +0 -1
  59. package/dist/components/DataGridBySchemaEditable/GridPatternInput.js +0 -74
  60. package/dist/components/DataGridBySchemaEditable/InputInterval.d.ts +0 -21
  61. package/dist/components/DataGridBySchemaEditable/InputInterval.d.ts.map +0 -1
  62. package/dist/components/DataGridBySchemaEditable/InputInterval.js +0 -131
  63. package/dist/components/DataGridBySchemaEditable/MobileSearchBar.d.ts +0 -9
  64. package/dist/components/DataGridBySchemaEditable/MobileSearchBar.d.ts.map +0 -1
  65. package/dist/components/DataGridBySchemaEditable/MobileSearchBar.js +0 -70
  66. package/dist/components/DataGridBySchemaEditable/RowEditingWatcher.d.ts +0 -7
  67. package/dist/components/DataGridBySchemaEditable/RowEditingWatcher.d.ts.map +0 -1
  68. package/dist/components/DataGridBySchemaEditable/RowEditingWatcher.js +0 -41
  69. package/dist/components/DataGridBySchemaEditable/SelectEditInputCell.d.ts +0 -24
  70. package/dist/components/DataGridBySchemaEditable/SelectEditInputCell.d.ts.map +0 -1
  71. package/dist/components/DataGridBySchemaEditable/SelectEditInputCell.js +0 -259
  72. package/dist/components/DataGridBySchemaEditable/geoConstants.d.ts +0 -5
  73. package/dist/components/DataGridBySchemaEditable/geoConstants.d.ts.map +0 -1
  74. package/dist/components/DataGridBySchemaEditable/geoConstants.js +0 -6
  75. package/dist/components/DataGridBySchemaEditable/hooks/useDataGridActions.d.ts +0 -33
  76. package/dist/components/DataGridBySchemaEditable/hooks/useDataGridActions.d.ts.map +0 -1
  77. package/dist/components/DataGridBySchemaEditable/hooks/useDataGridActions.js +0 -161
  78. package/dist/components/DataGridBySchemaEditable/hooks/useOptionsAC.d.ts +0 -14
  79. package/dist/components/DataGridBySchemaEditable/hooks/useOptionsAC.d.ts.map +0 -1
  80. package/dist/components/DataGridBySchemaEditable/hooks/useOptionsAC.js +0 -69
  81. package/dist/components/DataGridBySchemaEditable/hooks/usePreparedColumns.d.ts +0 -9
  82. package/dist/components/DataGridBySchemaEditable/hooks/usePreparedColumns.d.ts.map +0 -1
  83. package/dist/components/DataGridBySchemaEditable/hooks/usePreparedColumns.js +0 -73
  84. package/dist/components/DataGridBySchemaEditable/hooks/useProcessRowUpdate.d.ts +0 -30
  85. package/dist/components/DataGridBySchemaEditable/hooks/useProcessRowUpdate.d.ts.map +0 -1
  86. package/dist/components/DataGridBySchemaEditable/hooks/useProcessRowUpdate.js +0 -199
  87. package/dist/components/DataGridBySchemaEditable/utils/columnFactory.d.ts +0 -33
  88. package/dist/components/DataGridBySchemaEditable/utils/columnFactory.d.ts.map +0 -1
  89. package/dist/components/DataGridBySchemaEditable/utils/columnFactory.js +0 -270
  90. package/dist/components/DataGridBySchemaEditable/utils.d.ts +0 -40
  91. package/dist/components/DataGridBySchemaEditable/utils.d.ts.map +0 -1
  92. package/dist/components/DataGridBySchemaEditable/utils.js +0 -181
  93. package/dist/components/DataGridBySchemaEditable.d.ts +0 -63
  94. package/dist/components/DataGridBySchemaEditable.d.ts.map +0 -1
  95. package/dist/components/DataGridBySchemaEditable.js +0 -172
  96. package/dist/components/DataTotals.d.ts +0 -12
  97. package/dist/components/DataTotals.d.ts.map +0 -1
  98. package/dist/components/DataTotals.js +0 -32
  99. package/dist/components/DataTotalsServer.d.ts +0 -10
  100. package/dist/components/DataTotalsServer.d.ts.map +0 -1
  101. package/dist/components/DataTotalsServer.js +0 -18
  102. package/dist/components/DialogActions.d.ts +0 -11
  103. package/dist/components/DialogActions.d.ts.map +0 -1
  104. package/dist/components/DialogActions.js +0 -20
  105. package/dist/components/FileTypeIcon.d.ts +0 -18
  106. package/dist/components/FileTypeIcon.d.ts.map +0 -1
  107. package/dist/components/FileTypeIcon.js +0 -48
  108. package/dist/components/GenericModelList.d.ts +0 -52
  109. package/dist/components/GenericModelList.d.ts.map +0 -1
  110. package/dist/components/GenericModelList.js +0 -194
  111. package/dist/components/GenericRelatedModelList.d.ts +0 -54
  112. package/dist/components/GenericRelatedModelList.d.ts.map +0 -1
  113. package/dist/components/GenericRelatedModelList.js +0 -181
  114. package/dist/components/GenericRelatedModelListTable.d.ts +0 -55
  115. package/dist/components/GenericRelatedModelListTable.d.ts.map +0 -1
  116. package/dist/components/GenericRelatedModelListTable.js +0 -31
  117. package/dist/components/Image.d.ts +0 -10
  118. package/dist/components/Image.d.ts.map +0 -1
  119. package/dist/components/Image.js +0 -111
  120. package/dist/components/details/DetailBySchema.d.ts +0 -4
  121. package/dist/components/details/DetailBySchema.d.ts.map +0 -1
  122. package/dist/components/details/DetailBySchema.js +0 -175
  123. package/dist/components/details/DetailFieldBySchema.d.ts +0 -4
  124. package/dist/components/details/DetailFieldBySchema.d.ts.map +0 -1
  125. package/dist/components/details/DetailFieldBySchema.js +0 -88
  126. package/dist/components/forms/DialogFormBySchema.d.ts +0 -22
  127. package/dist/components/forms/DialogFormBySchema.d.ts.map +0 -1
  128. package/dist/components/forms/DialogFormBySchema.js +0 -97
  129. package/dist/components/forms/FieldBySchema.d.ts +0 -4
  130. package/dist/components/forms/FieldBySchema.d.ts.map +0 -1
  131. package/dist/components/forms/FieldBySchema.js +0 -80
  132. package/dist/components/forms/Form.d.ts +0 -61
  133. package/dist/components/forms/Form.d.ts.map +0 -1
  134. package/dist/components/forms/Form.js +0 -264
  135. package/dist/components/forms/FormActions.d.ts +0 -20
  136. package/dist/components/forms/FormActions.d.ts.map +0 -1
  137. package/dist/components/forms/FormActions.js +0 -55
  138. package/dist/components/forms/FormBySchema.d.ts +0 -21
  139. package/dist/components/forms/FormBySchema.d.ts.map +0 -1
  140. package/dist/components/forms/FormBySchema.js +0 -280
  141. package/dist/components/forms/FormWatcher.d.ts +0 -10
  142. package/dist/components/forms/FormWatcher.d.ts.map +0 -1
  143. package/dist/components/forms/FormWatcher.js +0 -25
  144. package/dist/components/forms/inputs/AutocompleteFieldBySchema.d.ts +0 -13
  145. package/dist/components/forms/inputs/AutocompleteFieldBySchema.d.ts.map +0 -1
  146. package/dist/components/forms/inputs/AutocompleteFieldBySchema.js +0 -133
  147. package/dist/components/forms/inputs/BooleanFieldBySchema.d.ts +0 -4
  148. package/dist/components/forms/inputs/BooleanFieldBySchema.d.ts.map +0 -1
  149. package/dist/components/forms/inputs/BooleanFieldBySchema.js +0 -39
  150. package/dist/components/forms/inputs/DesktopDatePickerBySchema.d.ts +0 -5
  151. package/dist/components/forms/inputs/DesktopDatePickerBySchema.d.ts.map +0 -1
  152. package/dist/components/forms/inputs/DesktopDatePickerBySchema.js +0 -54
  153. package/dist/components/forms/inputs/DesktopDateTimePickerBySchema.d.ts +0 -5
  154. package/dist/components/forms/inputs/DesktopDateTimePickerBySchema.d.ts.map +0 -1
  155. package/dist/components/forms/inputs/DesktopDateTimePickerBySchema.js +0 -47
  156. package/dist/components/forms/inputs/EditableAutocompleteFieldBySchema.d.ts +0 -14
  157. package/dist/components/forms/inputs/EditableAutocompleteFieldBySchema.d.ts.map +0 -1
  158. package/dist/components/forms/inputs/EditableAutocompleteFieldBySchema.js +0 -272
  159. package/dist/components/forms/inputs/FileFieldBySchema.d.ts +0 -4
  160. package/dist/components/forms/inputs/FileFieldBySchema.d.ts.map +0 -1
  161. package/dist/components/forms/inputs/FileFieldBySchema.js +0 -144
  162. package/dist/components/forms/inputs/FloatFieldBySchema.d.ts +0 -4
  163. package/dist/components/forms/inputs/FloatFieldBySchema.d.ts.map +0 -1
  164. package/dist/components/forms/inputs/FloatFieldBySchema.js +0 -64
  165. package/dist/components/forms/inputs/GeometryFieldBySchema.d.ts +0 -8
  166. package/dist/components/forms/inputs/GeometryFieldBySchema.d.ts.map +0 -1
  167. package/dist/components/forms/inputs/GeometryFieldBySchema.js +0 -57
  168. package/dist/components/forms/inputs/MapGeometryPicker.d.ts +0 -19
  169. package/dist/components/forms/inputs/MapGeometryPicker.d.ts.map +0 -1
  170. package/dist/components/forms/inputs/MapGeometryPicker.js +0 -322
  171. package/dist/components/forms/inputs/PatternFieldBySchema.d.ts +0 -4
  172. package/dist/components/forms/inputs/PatternFieldBySchema.d.ts.map +0 -1
  173. package/dist/components/forms/inputs/PatternFieldBySchema.js +0 -56
  174. package/dist/components/forms/inputs/TextFieldBySchema.d.ts +0 -4
  175. package/dist/components/forms/inputs/TextFieldBySchema.d.ts.map +0 -1
  176. package/dist/components/forms/inputs/TextFieldBySchema.js +0 -56
  177. package/dist/components/forms/inputs/leafletMarker.d.ts +0 -12
  178. package/dist/components/forms/inputs/leafletMarker.d.ts.map +0 -1
  179. package/dist/components/forms/inputs/leafletMarker.js +0 -52
  180. package/dist/context/APIWrapper.d.ts +0 -18
  181. package/dist/context/APIWrapper.d.ts.map +0 -1
  182. package/dist/context/APIWrapper.js +0 -584
  183. package/dist/context/APIWrapperContext.d.ts +0 -129
  184. package/dist/context/APIWrapperContext.d.ts.map +0 -1
  185. package/dist/context/APIWrapperContext.js +0 -60
  186. package/dist/context/DRFReactBySchemaContext.d.ts +0 -28
  187. package/dist/context/DRFReactBySchemaContext.d.ts.map +0 -1
  188. package/dist/context/DRFReactBySchemaContext.js +0 -20
  189. package/dist/context/DRFReactBySchemaProvider.d.ts +0 -5
  190. package/dist/context/DRFReactBySchemaProvider.d.ts.map +0 -1
  191. package/dist/context/DRFReactBySchemaProvider.js +0 -93
  192. package/dist/context/Overlays.d.ts +0 -5
  193. package/dist/context/Overlays.d.ts.map +0 -1
  194. package/dist/context/Overlays.js +0 -114
  195. package/dist/context/PrivateContext.d.ts +0 -10
  196. package/dist/context/PrivateContext.d.ts.map +0 -1
  197. package/dist/context/PrivateContext.js +0 -16
  198. package/dist/hooks/useDeepMemo.d.ts +0 -2
  199. package/dist/hooks/useDeepMemo.d.ts.map +0 -1
  200. package/dist/hooks/useDeepMemo.js +0 -13
  201. package/dist/hooks/useWhyDidYouUpdate.d.ts +0 -4
  202. package/dist/hooks/useWhyDidYouUpdate.d.ts.map +0 -1
  203. package/dist/hooks/useWhyDidYouUpdate.js +0 -26
  204. package/dist/index.d.ts +0 -35
  205. package/dist/index.d.ts.map +0 -1
  206. package/dist/index.js +0 -104
  207. package/dist/styles/grid.d.ts +0 -3
  208. package/dist/styles/grid.d.ts.map +0 -1
  209. package/dist/styles/grid.js +0 -38
  210. package/dist/styles/index.d.ts +0 -3
  211. package/dist/styles/index.d.ts.map +0 -1
  212. package/dist/styles/index.js +0 -38
  213. package/dist/styles/layout.d.ts +0 -23
  214. package/dist/styles/layout.d.ts.map +0 -1
  215. package/dist/styles/layout.js +0 -71
  216. package/dist/styles/texts.d.ts +0 -48
  217. package/dist/styles/texts.d.ts.map +0 -1
  218. package/dist/styles/texts.js +0 -55
  219. package/dist/styles/theme.d.ts +0 -29
  220. package/dist/styles/theme.d.ts.map +0 -1
  221. package/dist/styles/theme.js +0 -226
  222. package/dist/utils/index.d.ts +0 -2
  223. package/dist/utils/index.d.ts.map +0 -1
  224. package/dist/utils/index.js +0 -17
  225. package/dist/utils/utils.d.ts +0 -107
  226. package/dist/utils/utils.d.ts.map +0 -1
  227. package/dist/utils/utils.js +0 -957
@@ -1,280 +0,0 @@
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
- exports.default = FormBySchema;
49
- const react_1 = __importStar(require("react"));
50
- const axios_1 = __importDefault(require("axios"));
51
- const Box_1 = __importDefault(require("@mui/material/Box"));
52
- const Card_1 = __importDefault(require("@mui/material/Card"));
53
- const CardHeader_1 = __importDefault(require("@mui/material/CardHeader"));
54
- const CardContent_1 = __importDefault(require("@mui/material/CardContent"));
55
- const CircularProgress_1 = __importDefault(require("@mui/material/CircularProgress"));
56
- const styles_1 = require("../../styles");
57
- const APIWrapperContext_1 = require("../../context/APIWrapperContext");
58
- const utils_1 = require("../../utils");
59
- const FieldBySchema_1 = __importDefault(require("./FieldBySchema"));
60
- const api_1 = require("../../api");
61
- function FormBySchema({ schema, control, errors, register, multiline, setValue, getValues, fieldKey, labelKey = 'nome', index, optionsAC, setOptionsAC, optionsModel, getOptionLabel, renderOption, onEditModel: customOnEditModel, options, isSemaphoric, label, decimalScale = 2, fieldsLayout: fieldsLayoutInitial, customFieldFormLayouts, conditionalVisible, watchedValues, fieldsProps, hiddenFields, isolatedGetAutoComplete, relatedEditable, autoFocusField, elevation,
62
- // sx,
63
- // sxField,
64
- // sxLabel,
65
- sxRow, sxRowMultiple, sxSection, sxSectionTitle,
66
- // sxValue,
67
- // sxValueList,
68
- // sxValueListItem,
69
- // sxValueListItemText,
70
- }) {
71
- var _a;
72
- const { getAutoComplete: defaulGetAutoComplete, onEditModel: defaultOnEditModel, isMobile, } = (0, APIWrapperContext_1.useAPIWrapper)();
73
- const getAutoComplete = (0, react_1.useMemo)(() => isolatedGetAutoComplete || defaulGetAutoComplete, [defaulGetAutoComplete, isolatedGetAutoComplete]);
74
- const onEditModel = (0, react_1.useMemo)(() => (relatedEditable === false ? undefined : customOnEditModel || defaultOnEditModel), [customOnEditModel, defaultOnEditModel, relatedEditable]);
75
- const [localOptionsAC, setLocalOptionsAC] = (0, react_1.useState)();
76
- const defaultSx = { mr: 0 };
77
- const { fieldsLayout, optionsACModels } = (0, react_1.useMemo)(() => {
78
- if (!schema) {
79
- return { fieldsLayout: undefined, optionsACModels: [] };
80
- }
81
- const newOptionsACModels = [];
82
- if (fieldsLayoutInitial && fieldsLayoutInitial.length > 0) {
83
- const mobileFieldsLayout = [];
84
- for (const section of fieldsLayoutInitial) {
85
- if (!section.rows) {
86
- continue;
87
- }
88
- const mobileSection = {
89
- title: section.title,
90
- rows: [],
91
- };
92
- for (const row of section.rows) {
93
- if (typeof row === 'string') {
94
- const field = row;
95
- const fieldSchema = schema[field];
96
- if (!fieldSchema) {
97
- console.log(`there is no schema for field ${field}!`);
98
- continue;
99
- }
100
- if (['field', 'nested object'].includes(fieldSchema.type) &&
101
- !newOptionsACModels.includes(field)) {
102
- newOptionsACModels.push(field);
103
- }
104
- if (isMobile) {
105
- mobileSection.rows.push(field);
106
- }
107
- continue;
108
- }
109
- if (Array.isArray(row)) {
110
- for (const field of row) {
111
- if (typeof field === 'string' && !(field in schema)) {
112
- console.log(`there is no schema for field ${field}!`);
113
- continue;
114
- }
115
- if (typeof field === 'string' &&
116
- ['field', 'nested object'].includes(schema[field].type) &&
117
- !newOptionsACModels.includes(field)) {
118
- newOptionsACModels.push(field);
119
- }
120
- if (isMobile && typeof field === 'string') {
121
- mobileSection.rows.push(field);
122
- }
123
- }
124
- continue;
125
- }
126
- if (newOptionsACModels.includes(row.key)) {
127
- newOptionsACModels.push(row.key);
128
- }
129
- if (isMobile) {
130
- mobileSection.rows.push(row.key);
131
- }
132
- }
133
- if (isMobile) {
134
- mobileFieldsLayout.push(mobileSection);
135
- }
136
- }
137
- return {
138
- fieldsLayout: isMobile ? mobileFieldsLayout : fieldsLayoutInitial,
139
- optionsACModels: newOptionsACModels,
140
- };
141
- }
142
- const rows = [];
143
- for (const [key, field] of Object.entries(schema)) {
144
- if (field && ['field', 'nested object'].includes(field.type)) {
145
- rows.push(key);
146
- if (!newOptionsACModels.includes(key)) {
147
- newOptionsACModels.push(key);
148
- }
149
- continue;
150
- }
151
- if (!(field === null || field === void 0 ? void 0 : field.read_only)) {
152
- rows.push(key);
153
- }
154
- }
155
- return { fieldsLayout: [{ rows }], optionsACModels: newOptionsACModels };
156
- }, [schema, fieldsLayoutInitial, isMobile]);
157
- (0, react_1.useEffect)(() => {
158
- const populateOptionsACAsync = () => __awaiter(this, void 0, void 0, function* () {
159
- const promises = [];
160
- const fieldsToLoad = [];
161
- optionsACModels.map((field) => {
162
- if (!optionsAC || !(field in optionsAC)) {
163
- fieldsToLoad.push(field);
164
- promises.push(getAutoComplete(field));
165
- }
166
- });
167
- const newOptionsAC = {};
168
- const results = yield Promise.all(promises);
169
- results.map((result, index) => {
170
- if (!axios_1.default.isAxiosError(result)) {
171
- newOptionsAC[fieldsToLoad[index]] = result;
172
- }
173
- });
174
- if (setOptionsAC) {
175
- setOptionsAC(newOptionsAC);
176
- return;
177
- }
178
- setLocalOptionsAC(newOptionsAC);
179
- });
180
- populateOptionsACAsync();
181
- }, [optionsACModels, setOptionsAC]);
182
- const preparedHiddenFields = (0, react_1.useMemo)(() => {
183
- const values = {};
184
- if (!getValues || !hiddenFields) {
185
- return values;
186
- }
187
- for (const [key, value] of Object.entries(getValues())) {
188
- if (hiddenFields.includes(key)) {
189
- values[key] = value;
190
- }
191
- }
192
- return (0, api_1.prepareDataBySchema)({ data: values, schema }).data;
193
- }, [getValues, hiddenFields, schema]);
194
- if (!fieldsLayout ||
195
- fieldsLayout.length === 0 ||
196
- (setOptionsAC && !optionsAC) ||
197
- (!setOptionsAC && !localOptionsAC)) {
198
- return (react_1.default.createElement(Card_1.default, { sx: sxSection ? Object.assign(Object.assign({}, styles_1.Layout.formCard), sxSection) : styles_1.Layout.formCard, elevation: elevation },
199
- react_1.default.createElement(CardContent_1.default, null,
200
- react_1.default.createElement(Box_1.default, { sx: styles_1.Layout.loadingBoxWhite },
201
- react_1.default.createElement(CircularProgress_1.default, null)))));
202
- }
203
- return (react_1.default.createElement(react_1.default.Fragment, null,
204
- register &&
205
- ((_a = Object.entries(preparedHiddenFields)) === null || _a === void 0 ? void 0 : _a.map(([hiddenField, preparedValue]) => {
206
- return (react_1.default.createElement("input", Object.assign({ hidden: true }, register(hiddenField), { value: preparedValue, key: hiddenField })));
207
- })),
208
- fieldsLayout.map((section, sectionIndex) => {
209
- return (react_1.default.createElement(Card_1.default, { sx: sxSection ? Object.assign(Object.assign({}, styles_1.Layout.formCard), sxSection) : styles_1.Layout.formCard, key: `section_${sectionIndex}`, elevation: elevation },
210
- section.title && react_1.default.createElement(CardHeader_1.default, { title: section.title, sx: sxSectionTitle }),
211
- react_1.default.createElement(CardContent_1.default, null,
212
- section.CustomElement && react_1.default.createElement(react_1.default.Fragment, null, section.CustomElement),
213
- section.rows && (react_1.default.createElement(react_1.default.Fragment, null, section.rows.map((row, rowIndex) => {
214
- if (typeof row === 'string') {
215
- if (hiddenFields === null || hiddenFields === void 0 ? void 0 : hiddenFields.includes(row)) {
216
- return null;
217
- }
218
- const field = row;
219
- const fieldProps = fieldsProps && field in fieldsProps
220
- ? fieldsProps[field]
221
- : {};
222
- if (fieldProps) {
223
- fieldProps.sx = 'sx' in fieldProps ? fieldProps.sx : defaultSx;
224
- }
225
- const isVisible = (0, utils_1.showConditionalVisibleField)(field, conditionalVisible, watchedValues);
226
- if (!isVisible) {
227
- return react_1.default.createElement(Box_1.default, { key: field, sx: sxRow });
228
- }
229
- return (react_1.default.createElement(Box_1.default, { key: field, sx: sxRow },
230
- react_1.default.createElement(FieldBySchema_1.default, Object.assign({ name: field, schema: schema, control: control, errors: errors, multiline: multiline, setValue: setValue, getValues: getValues, fieldKey: fieldKey, labelKey: labelKey, index: index,
231
- // optionsAC={setOptionsAC ? optionsAC : localOptionsAC}
232
- optionsAC: optionsAC && field in optionsAC
233
- ? optionsAC
234
- : localOptionsAC,
235
- // optionsAC: BaseOptionsAC | Partial<Record<FieldKey<T>, FieldOptionsAC>>
236
- // optionsAC: BaseOptionsAC | Partial<Record<FieldKey<T>, FieldOptionsAC>> | undefined
237
- optionsModel: optionsModel, getOptionLabel: getOptionLabel, renderOption: renderOption, onEditModel: onEditModel, fieldsLayout: customFieldFormLayouts && field in customFieldFormLayouts
238
- ? customFieldFormLayouts[field]
239
- : undefined, options: options, isSemaphoric: isSemaphoric, label: label, decimalScale: decimalScale, autoFocus: autoFocusField === field || (sectionIndex === 0 && rowIndex === 0) }, fieldProps))));
240
- }
241
- if (Array.isArray(row)) {
242
- return (react_1.default.createElement(Box_1.default, { sx: sxRowMultiple
243
- ? Object.assign(Object.assign({}, styles_1.Layout.inLineForm), { sxRowMultiple })
244
- : styles_1.Layout.inLineForm, key: `row_${rowIndex}` },
245
- react_1.default.createElement(react_1.default.Fragment, null, row.map((field, i, j) => {
246
- if (typeof field === 'string' && (hiddenFields === null || hiddenFields === void 0 ? void 0 : hiddenFields.includes(field))) {
247
- return null;
248
- }
249
- const mr = i + 1 === j.length ? 0 : 2;
250
- const key = typeof field === 'string' ? field : field.key;
251
- const fieldProps = fieldsProps && key in fieldsProps
252
- ? fieldsProps[key]
253
- : {};
254
- if (fieldProps) {
255
- fieldProps.sx =
256
- 'sx' in fieldProps
257
- ? Object.assign(Object.assign({}, fieldProps.sx), { mr }) : {
258
- mr,
259
- };
260
- }
261
- const isVisible = (0, utils_1.showConditionalVisibleField)(key, conditionalVisible, watchedValues);
262
- if (!isVisible) {
263
- return (react_1.default.createElement(react_1.default.Fragment, { key: `field_${rowIndex}_${i}` }));
264
- }
265
- return (react_1.default.createElement(react_1.default.Fragment, { key: `field_${rowIndex}_${i}` }, typeof field === 'string' ? (react_1.default.createElement(FieldBySchema_1.default, Object.assign({ name: field, schema: schema, control: control, errors: errors, multiline: multiline, setValue: setValue, getValues: getValues, fieldKey: fieldKey, labelKey: labelKey, index: index, optionsAC: optionsAC && field in optionsAC
266
- ? optionsAC
267
- : localOptionsAC, optionsModel: optionsModel, getOptionLabel: getOptionLabel, renderOption: renderOption, onEditModel: onEditModel, options: options, isSemaphoric: isSemaphoric, label: label, decimalScale: decimalScale, autoFocus: autoFocusField === field ||
268
- (sectionIndex === 0 && rowIndex === 0 && i === 0) }, fieldProps))) : (react_1.default.createElement(field.CustomElement, Object.assign({}, fieldProps)))));
269
- }))));
270
- }
271
- const fieldProps = fieldsProps && row.key in fieldsProps
272
- ? fieldsProps[row.key]
273
- : {};
274
- if (fieldProps) {
275
- fieldProps.sx = 'sx' in fieldProps ? fieldProps.sx : defaultSx;
276
- }
277
- return (react_1.default.createElement(row.CustomElement, Object.assign({ key: `customElement_row_${rowIndex}` }, fieldProps)));
278
- }))))));
279
- })));
280
- }
@@ -1,10 +0,0 @@
1
- import { Control } from 'react-hook-form';
2
- import { FieldList, FormWatchObject, GenericValue, TField } from '../../@types';
3
- export interface FormWatcherProps<T extends TField = void> {
4
- control: Control<GenericValue>;
5
- watch: FieldList<T>;
6
- onChange: (values: FormWatchObject<T>) => void;
7
- }
8
- declare function FormWatcher<T extends TField = void>({ control, watch, onChange }: FormWatcherProps<T>): null;
9
- export default FormWatcher;
10
- //# sourceMappingURL=FormWatcher.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FormWatcher.d.ts","sourceRoot":"","sources":["../../../src/components/forms/FormWatcher.tsx"],"names":[],"mappings":"AACA,OAAO,EAAY,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAEpD,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,YAAY,EAAQ,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtF,MAAM,WAAW,gBAAgB,CAAC,CAAC,SAAS,MAAM,GAAG,IAAI;IACvD,OAAO,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC;IAC/B,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;IACpB,QAAQ,EAAE,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;CAChD;AAGD,iBAAS,WAAW,CAAC,CAAC,SAAS,MAAM,GAAG,IAAI,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,gBAAgB,CAAC,CAAC,CAAC,QAqB9F;AAED,eAAe,WAAW,CAAC"}
@@ -1,25 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const react_1 = require("react");
4
- const react_hook_form_1 = require("react-hook-form");
5
- const utils_1 = require("../../utils");
6
- // Ensure K is constrained to the same type as the prop
7
- function FormWatcher({ control, watch, onChange }) {
8
- const values = (0, react_hook_form_1.useWatch)({
9
- control,
10
- name: watch,
11
- });
12
- const previousValues = (0, react_1.useRef)(null);
13
- (0, react_1.useEffect)(() => {
14
- if (!(0, utils_1.deepEqual)(values, previousValues.current)) {
15
- previousValues.current = values;
16
- const valuesObject = watch.reduce((acc, key, index) => {
17
- acc[key] = values[index];
18
- return acc;
19
- }, {});
20
- onChange(valuesObject);
21
- }
22
- }, [values, watch, onChange]);
23
- return null;
24
- }
25
- exports.default = FormWatcher;
@@ -1,13 +0,0 @@
1
- import React from 'react';
2
- import { FieldBySchemaProps } from '../../../@types';
3
- /**
4
- * Choice/list picker built on MUI Autocomplete.
5
- *
6
- * `options` must be objects, and the current form `value` must match them: a
7
- * single option object, or (when `multiple`) an array of option objects. The
8
- * option shape is defined by `optionIdKey`/`optionLabelKey` (defaults
9
- * `'id'`/`'label'`); it is NOT raw values/strings. Seed forms with
10
- * populateValues() so values are already objects in the same format as options.
11
- */
12
- export default function AutocompleteFieldBySchema({ fieldKey, index, name, schema, control, errors, optionIdKey, optionLabelKey, options: optionsByProps, isSemaphoric, sx, onValueChange, autoFocus, disabled, autoComplete: _, multiple, ...other }: FieldBySchemaProps): React.JSX.Element | undefined;
13
- //# sourceMappingURL=AutocompleteFieldBySchema.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AutocompleteFieldBySchema.d.ts","sourceRoot":"","sources":["../../../../src/components/forms/inputs/AutocompleteFieldBySchema.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkB,MAAM,OAAO,CAAC;AAMvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AA8DrD;;;;;;;;GAQG;AACH,MAAM,CAAC,OAAO,UAAU,yBAAyB,CAAC,EAChD,QAAQ,EACR,KAAK,EACL,IAAI,EACJ,MAAM,EACN,OAAO,EACP,MAAM,EACN,WAAkB,EAClB,cAAwB,EACxB,OAAO,EAAE,cAAc,EACvB,YAAoB,EACpB,EAAc,EACd,aAAa,EACb,SAAS,EACT,QAAQ,EACR,YAAY,EAAE,CAAC,EACf,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,kBAAkB,iCA+DpB"}
@@ -1,133 +0,0 @@
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 __rest = (this && this.__rest) || function (s, e) {
36
- var t = {};
37
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
38
- t[p] = s[p];
39
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
40
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
41
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
42
- t[p[i]] = s[p[i]];
43
- }
44
- return t;
45
- };
46
- var __importDefault = (this && this.__importDefault) || function (mod) {
47
- return (mod && mod.__esModule) ? mod : { "default": mod };
48
- };
49
- Object.defineProperty(exports, "__esModule", { value: true });
50
- exports.default = AutocompleteFieldBySchema;
51
- const react_1 = __importStar(require("react"));
52
- const react_hook_form_1 = require("react-hook-form");
53
- const Autocomplete_1 = __importDefault(require("@mui/material/Autocomplete"));
54
- const TextField_1 = __importDefault(require("@mui/material/TextField"));
55
- const utils_1 = require("../../../utils");
56
- const DRFReactBySchemaContext_1 = require("../../../context/DRFReactBySchemaContext");
57
- const renderInput = (_a) => {
58
- var { control: _, options, optionLabelKey, schema, name, errors, fieldKey, index, isSemaphoric, label, theme } = _a, params = __rest(_a, ["control", "options", "optionLabelKey", "schema", "name", "errors", "fieldKey", "index", "isSemaphoric", "label", "theme"]);
59
- const fieldSchema = schema[name];
60
- const { error, helperText } = fieldKey && index && index >= 0
61
- ? (0, utils_1.errorProps)({
62
- fieldKey,
63
- index,
64
- fieldKeyProp: name,
65
- errors,
66
- })
67
- : {
68
- error: errors && Boolean(errors[name]),
69
- helperText: errors && errors[name] ? errors[name].message : fieldSchema.help_text || '',
70
- };
71
- let sx = undefined;
72
- if (isSemaphoric && options && optionLabelKey) {
73
- let tipo;
74
- switch (params.inputProps.value) {
75
- case options[0][optionLabelKey]:
76
- tipo = 'success';
77
- break;
78
- case options[1][optionLabelKey]:
79
- tipo = 'warning';
80
- break;
81
- case options[2][optionLabelKey]:
82
- tipo = 'error';
83
- break;
84
- }
85
- if (tipo) {
86
- sx = { backgroundColor: theme.palette[tipo].semaphoric };
87
- }
88
- }
89
- return (react_1.default.createElement(TextField_1.default, Object.assign({}, params, { label: label || fieldSchema.label, required: (0, utils_1.isFieldRequired)(fieldSchema), margin: "normal", error: error, helperText: helperText, sx: sx })));
90
- };
91
- /**
92
- * Choice/list picker built on MUI Autocomplete.
93
- *
94
- * `options` must be objects, and the current form `value` must match them: a
95
- * single option object, or (when `multiple`) an array of option objects. The
96
- * option shape is defined by `optionIdKey`/`optionLabelKey` (defaults
97
- * `'id'`/`'label'`); it is NOT raw values/strings. Seed forms with
98
- * populateValues() so values are already objects in the same format as options.
99
- */
100
- function AutocompleteFieldBySchema(_a) {
101
- var { fieldKey, index, name, schema, control, errors, optionIdKey = 'id', optionLabelKey = 'label', options: optionsByProps, isSemaphoric = false, sx = { mr: 2 }, onValueChange, autoFocus, disabled, autoComplete: _, multiple } = _a, other = __rest(_a, ["fieldKey", "index", "name", "schema", "control", "errors", "optionIdKey", "optionLabelKey", "options", "isSemaphoric", "sx", "onValueChange", "autoFocus", "disabled", "autoComplete", "multiple"]);
102
- const { theme } = (0, DRFReactBySchemaContext_1.useDRFReactBySchema)();
103
- const fieldSchema = schema[name];
104
- const options = (0, react_1.useMemo)(() => optionsByProps || fieldSchema.choices, [optionsByProps, fieldSchema]);
105
- if (!(name in schema)) {
106
- console.error(`AutocompleteFieldBySchema: could not find schema for ${name}! Not rendering`);
107
- return;
108
- }
109
- if (fieldKey && index && index >= 0) {
110
- name = `${fieldKey}.${index}.${name}`;
111
- }
112
- return (react_1.default.createElement(react_hook_form_1.Controller, { name: name, control: control, render: ({ field }) => (react_1.default.createElement(Autocomplete_1.default, Object.assign({}, field, { key: name, id: name, options: options || [], disabled: fieldSchema.disabled === true || disabled === true, selectOnFocus: true, autoHighlight: true, autoFocus: autoFocus, multiple: multiple, isOptionEqualToValue: (option, value) => {
113
- return option[optionIdKey] === value[optionIdKey];
114
- }, getOptionLabel: (option) => {
115
- return option[optionLabelKey];
116
- }, onChange: (e, value) => {
117
- field.onChange(value);
118
- if (onValueChange) {
119
- onValueChange(e);
120
- }
121
- }, fullWidth: true, renderInput: (params) => {
122
- return renderInput(Object.assign(Object.assign({}, params), { control,
123
- isSemaphoric,
124
- options,
125
- optionLabelKey,
126
- schema,
127
- name,
128
- errors,
129
- fieldKey,
130
- index,
131
- theme }));
132
- }, sx: sx }, other))) }));
133
- }
@@ -1,4 +0,0 @@
1
- import React from 'react';
2
- import { FieldBySchemaProps } from '../../../@types';
3
- export default function BooleanFieldBySchema({ name, schema, control, fieldKey, index, sx, onValueChange, autoFocus, disabled, ...other }: FieldBySchemaProps): React.JSX.Element | undefined;
4
- //# sourceMappingURL=BooleanFieldBySchema.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BooleanFieldBySchema.d.ts","sourceRoot":"","sources":["../../../../src/components/forms/inputs/BooleanFieldBySchema.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAGrD,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAAC,EAC3C,IAAI,EACJ,MAAM,EACN,OAAO,EACP,QAAQ,EACR,KAAK,EACL,EAAc,EACd,aAAa,EACb,SAAS,EACT,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,kBAAkB,iCAwCpB"}
@@ -1,39 +0,0 @@
1
- "use strict";
2
- var __rest = (this && this.__rest) || function (s, e) {
3
- var t = {};
4
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
- t[p] = s[p];
6
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
- t[p[i]] = s[p[i]];
10
- }
11
- return t;
12
- };
13
- var __importDefault = (this && this.__importDefault) || function (mod) {
14
- return (mod && mod.__esModule) ? mod : { "default": mod };
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.default = BooleanFieldBySchema;
18
- const react_1 = __importDefault(require("react"));
19
- const react_hook_form_1 = require("react-hook-form");
20
- const Checkbox_1 = __importDefault(require("@mui/material/Checkbox"));
21
- const FormControlLabel_1 = __importDefault(require("@mui/material/FormControlLabel"));
22
- const utils_1 = require("../../../utils");
23
- function BooleanFieldBySchema(_a) {
24
- var { name, schema, control, fieldKey, index, sx = { mr: 2 }, onValueChange, autoFocus, disabled } = _a, other = __rest(_a, ["name", "schema", "control", "fieldKey", "index", "sx", "onValueChange", "autoFocus", "disabled"]);
25
- if (!(name in schema)) {
26
- console.error(`BooleanFieldBySchema: could not find schema for ${name}! Not rendering`);
27
- return;
28
- }
29
- const fieldSchema = schema[name];
30
- if (fieldKey && index && index >= 0) {
31
- name = `${fieldKey}.${index}.${name}`;
32
- }
33
- return (react_1.default.createElement(react_hook_form_1.Controller, { name: name, control: control, render: ({ field }) => (react_1.default.createElement(FormControlLabel_1.default, { control: react_1.default.createElement(Checkbox_1.default, Object.assign({}, field, other, { value: field.value || false, checked: field.value || false, disabled: fieldSchema.disabled === true || disabled === true, inputProps: { 'aria-label': 'controlled' }, onChange: (e) => {
34
- if (onValueChange) {
35
- onValueChange(e);
36
- }
37
- field.onChange(e);
38
- }, autoFocus: autoFocus })), label: fieldSchema.label, required: (0, utils_1.isFieldRequired)(fieldSchema), sx: Object.assign({ width: '100%' }, sx) })) }));
39
- }
@@ -1,5 +0,0 @@
1
- import React from 'react';
2
- import 'dayjs/locale/pt-br';
3
- import { FieldBySchemaProps } from '../../../@types';
4
- export default function DesktopDatePickerBySchema({ name, schema, control, errors, fieldKey, index, sx, autoFocus, disabled, }: FieldBySchemaProps): React.JSX.Element | undefined;
5
- //# sourceMappingURL=DesktopDatePickerBySchema.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DesktopDatePickerBySchema.d.ts","sourceRoot":"","sources":["../../../../src/components/forms/inputs/DesktopDatePickerBySchema.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,OAAO,oBAAoB,CAAC;AAE5B,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAGrD,MAAM,CAAC,OAAO,UAAU,yBAAyB,CAAC,EAChD,IAAI,EACJ,MAAM,EACN,OAAO,EACP,MAAM,EACN,QAAQ,EACR,KAAK,EACL,EAAqB,EACrB,SAAS,EACT,QAAQ,GACT,EAAE,kBAAkB,iCA2DpB"}
@@ -1,54 +0,0 @@
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 = DesktopDatePickerBySchema;
7
- const react_1 = __importDefault(require("react"));
8
- const react_hook_form_1 = require("react-hook-form");
9
- const DesktopDatePicker_1 = require("@mui/x-date-pickers/DesktopDatePicker");
10
- const LocalizationProvider_1 = require("@mui/x-date-pickers/LocalizationProvider");
11
- const AdapterDayjs_1 = require("@mui/x-date-pickers/AdapterDayjs");
12
- const dayjs_1 = __importDefault(require("dayjs"));
13
- require("dayjs/locale/pt-br");
14
- const utils_1 = require("../../../utils");
15
- function DesktopDatePickerBySchema({ name, schema, control, errors, fieldKey, index, sx = { mr: 2, mt: 2 }, autoFocus, disabled, }) {
16
- var _a;
17
- if (!(name in schema)) {
18
- console.error(`DesktopDatePickerBySchema: could not find schema for ${name}! Not rendering`);
19
- return;
20
- }
21
- const fieldSchema = schema[name];
22
- if (!sx) {
23
- sx = { minWidth: 200 };
24
- }
25
- if (!('width' in sx)) {
26
- sx = Object.assign(Object.assign({}, sx), { width: '100%' });
27
- }
28
- if (fieldKey && index && index >= 0) {
29
- name = `${fieldKey}.${index}.${name}`;
30
- }
31
- const inputFormat = (0, utils_1.buildDateFormatBySchema)(fieldSchema.date_views);
32
- const { error, helperText } = fieldKey && index && index >= 0
33
- ? (0, utils_1.errorProps)({
34
- fieldKey,
35
- index,
36
- fieldKeyProp: name,
37
- errors,
38
- })
39
- : {
40
- error: errors && Boolean(errors[name]),
41
- helperText: errors && errors[name] ? (_a = errors[name]) === null || _a === void 0 ? void 0 : _a.message : fieldSchema.help_text || '',
42
- };
43
- return (react_1.default.createElement(react_hook_form_1.Controller, { name: name, control: control, render: ({ field }) => (react_1.default.createElement(LocalizationProvider_1.LocalizationProvider, { dateAdapter: AdapterDayjs_1.AdapterDayjs, adapterLocale: "pt-br" },
44
- react_1.default.createElement(DesktopDatePicker_1.DesktopDatePicker, Object.assign({}, field, { value: (0, dayjs_1.default)(field.value), label: fieldSchema.label, disabled: fieldSchema.disabled === true || disabled === true, views: fieldSchema.date_views, format: inputFormat, sx: Object.assign({ mt: 2, mb: 1 }, sx), slotProps: {
45
- textField: {
46
- error,
47
- helperText,
48
- sx,
49
- margin: 'normal',
50
- autoFocus,
51
- required: (0, utils_1.isFieldRequired)(fieldSchema),
52
- },
53
- } })))) }));
54
- }
@@ -1,5 +0,0 @@
1
- import React from 'react';
2
- import 'dayjs/locale/pt-br';
3
- import { FieldBySchemaProps } from '../../../@types';
4
- export default function DesktopDateTimePickerBySchema({ name, schema, control, errors, fieldKey, index, sx, autoFocus, disabled, }: FieldBySchemaProps): React.JSX.Element | undefined;
5
- //# sourceMappingURL=DesktopDateTimePickerBySchema.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DesktopDateTimePickerBySchema.d.ts","sourceRoot":"","sources":["../../../../src/components/forms/inputs/DesktopDateTimePickerBySchema.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,OAAO,oBAAoB,CAAC;AAE5B,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAGrD,MAAM,CAAC,OAAO,UAAU,6BAA6B,CAAC,EACpD,IAAI,EACJ,MAAM,EACN,OAAO,EACP,MAAM,EACN,QAAQ,EACR,KAAK,EACL,EAAqB,EACrB,SAAS,EACT,QAAQ,GACT,EAAE,kBAAkB,iCAqDpB"}
@@ -1,47 +0,0 @@
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 = DesktopDateTimePickerBySchema;
7
- const react_1 = __importDefault(require("react"));
8
- const react_hook_form_1 = require("react-hook-form");
9
- const DesktopDateTimePicker_1 = require("@mui/x-date-pickers/DesktopDateTimePicker");
10
- const LocalizationProvider_1 = require("@mui/x-date-pickers/LocalizationProvider");
11
- const AdapterDayjs_1 = require("@mui/x-date-pickers/AdapterDayjs");
12
- const dayjs_1 = __importDefault(require("dayjs"));
13
- require("dayjs/locale/pt-br");
14
- const utils_1 = require("../../../utils");
15
- function DesktopDateTimePickerBySchema({ name, schema, control, errors, fieldKey, index, sx = { mr: 2, mt: 2 }, autoFocus, disabled, }) {
16
- var _a;
17
- if (!(name in schema)) {
18
- console.error(`DesktopDateTimePickerBySchema: could not find schema for ${name}! Not rendering`);
19
- return;
20
- }
21
- const fieldSchema = schema[name];
22
- if (fieldKey && index && index >= 0) {
23
- name = `${fieldKey}.${index}.${name}`;
24
- }
25
- const { error, helperText } = fieldKey && index && index >= 0
26
- ? (0, utils_1.errorProps)({
27
- fieldKey,
28
- index,
29
- fieldKeyProp: name,
30
- errors,
31
- })
32
- : {
33
- error: errors && Boolean(errors[name]),
34
- helperText: errors && errors[name] ? (_a = errors[name]) === null || _a === void 0 ? void 0 : _a.message : fieldSchema.help_text || '',
35
- };
36
- return (react_1.default.createElement(react_hook_form_1.Controller, { name: name, control: control, render: ({ field }) => (react_1.default.createElement(LocalizationProvider_1.LocalizationProvider, { dateAdapter: AdapterDayjs_1.AdapterDayjs, adapterLocale: "pt-br" },
37
- react_1.default.createElement(DesktopDateTimePicker_1.DesktopDateTimePicker, Object.assign({}, field, { value: (0, dayjs_1.default)(field.value), label: fieldSchema.label, disabled: fieldSchema.disabled === true || disabled === true, format: "DD/MM/YYYY HH:mm", sx: Object.assign({ mt: 2, mb: 1 }, sx), slotProps: {
38
- textField: {
39
- error,
40
- helperText,
41
- sx,
42
- margin: 'normal',
43
- autoFocus,
44
- required: (0, utils_1.isFieldRequired)(fieldSchema),
45
- },
46
- } })))) }));
47
- }