drf-react-by-schema 0.2.2 → 0.3.1
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.
- package/dist/api.d.ts +84 -0
- package/dist/api.js +613 -0
- package/dist/components/DataGridBySchemaEditable/ConfirmDialog.d.ts +8 -0
- package/dist/components/DataGridBySchemaEditable/ConfirmDialog.js +21 -0
- package/dist/components/DataGridBySchemaEditable/CustomToolbar.d.ts +16 -0
- package/dist/components/DataGridBySchemaEditable/CustomToolbar.js +77 -0
- package/dist/components/DataGridBySchemaEditable/FooterToolbar.d.ts +16 -0
- package/dist/components/DataGridBySchemaEditable/FooterToolbar.js +41 -0
- package/dist/components/DataGridBySchemaEditable/GridDecimalInput.d.ts +8 -0
- package/dist/components/DataGridBySchemaEditable/GridDecimalInput.js +32 -0
- package/dist/components/DataGridBySchemaEditable/GridPatternInput.d.ts +8 -0
- package/dist/components/DataGridBySchemaEditable/GridPatternInput.js +30 -0
- package/dist/components/DataGridBySchemaEditable/InputInterval.d.ts +3 -0
- package/dist/components/DataGridBySchemaEditable/InputInterval.js +105 -0
- package/dist/components/DataGridBySchemaEditable/SelectEditInputCell.d.ts +33 -0
- package/dist/components/DataGridBySchemaEditable/SelectEditInputCell.js +140 -0
- package/dist/components/DataGridBySchemaEditable/utils.d.ts +15 -0
- package/{src/components/DataGridBySchemaEditable/utils.ts → dist/components/DataGridBySchemaEditable/utils.js} +32 -50
- package/dist/components/DataGridBySchemaEditable.d.ts +34 -0
- package/dist/components/DataGridBySchemaEditable.js +549 -0
- package/dist/components/DataTotals.d.ts +14 -0
- package/dist/components/DataTotals.js +23 -0
- package/dist/components/DialogActions.d.ts +10 -0
- package/dist/components/DialogActions.js +17 -0
- package/dist/components/DialogJSONSchemaForm.d.ts +12 -0
- package/dist/components/DialogJSONSchemaForm.js +20 -0
- package/dist/components/FormButtons.d.ts +14 -0
- package/dist/components/FormButtons.js +39 -0
- package/dist/components/GenericModelList.d.ts +19 -0
- package/dist/components/GenericModelList.js +113 -0
- package/dist/components/GenericRelatedModelList.d.ts +25 -0
- package/dist/components/GenericRelatedModelList.js +111 -0
- package/dist/components/TextFieldBySchema.js +39 -0
- package/dist/context/APIWrapper.d.ts +12 -0
- package/dist/context/APIWrapper.js +341 -0
- package/dist/context/APIWrapperContext.d.ts +75 -0
- package/dist/context/APIWrapperContext.js +15 -0
- package/dist/context/DRFReactBySchemaContext.d.ts +20 -0
- package/dist/context/DRFReactBySchemaContext.js +19 -0
- package/dist/context/DRFReactBySchemaProvider.d.ts +13 -0
- package/dist/context/DRFReactBySchemaProvider.js +53 -0
- package/dist/context/Form.d.ts +11 -0
- package/dist/context/Form.js +82 -0
- package/dist/context/Overlays.d.ts +4 -0
- package/dist/context/Overlays.js +87 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +14 -27
- package/{src/styles/index.ts → dist/styles/index.d.ts} +0 -1
- package/dist/styles/index.js +28 -0
- package/dist/styles/layout.d.ts +107 -0
- package/dist/styles/layout.js +56 -0
- package/dist/styles/theme.d.ts +21 -0
- package/dist/styles/theme.js +139 -0
- package/dist/utils.d.ts +75 -0
- package/dist/utils.js +268 -0
- package/package.json +15 -2
- package/.eslintrc.js +0 -14
- package/.gitlab-ci.yml +0 -14
- package/src/api.ts +0 -733
- package/src/components/DataGridBySchemaEditable/ConfirmDialog.tsx +0 -41
- package/src/components/DataGridBySchemaEditable/CustomToolbar.tsx +0 -93
- package/src/components/DataGridBySchemaEditable/FooterToolbar.tsx +0 -77
- package/src/components/DataGridBySchemaEditable/GridDecimalInput.tsx +0 -41
- package/src/components/DataGridBySchemaEditable/GridPatternInput.tsx +0 -37
- package/src/components/DataGridBySchemaEditable/InputInterval.tsx +0 -194
- package/src/components/DataGridBySchemaEditable/SelectEditInputCell.tsx +0 -153
- package/src/components/DataGridBySchemaEditable.md +0 -50
- package/src/components/DataGridBySchemaEditable.tsx +0 -747
- package/src/components/DataTotals.tsx +0 -56
- package/src/components/GenericModelList.tsx +0 -155
- package/src/context/DRFReactBySchemaProvider.md +0 -50
- package/src/context/DRFReactBySchemaProvider.tsx +0 -78
- package/src/index.ts +0 -64
- package/src/styles/layout.ts +0 -104
- package/src/styles/theme.ts +0 -190
- package/src/utils.ts +0 -321
- package/styleguide.config.js +0 -13
- package/tsconfig.json +0 -104
- package/webpack.config.js +0 -24
|
@@ -1,24 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
} from "@mui/x-data-grid";
|
|
7
|
-
import { GridEnrichedBySchemaColDef } from "../../utils";
|
|
8
|
-
import {
|
|
9
|
-
InputNumberInterval,
|
|
10
|
-
InputDateInterval,
|
|
11
|
-
InputFloatInterval
|
|
12
|
-
} from "./InputInterval";
|
|
13
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.quantityOnlyOperators = exports.resizeColumns = void 0;
|
|
4
|
+
const x_data_grid_1 = require("@mui/x-data-grid");
|
|
5
|
+
const InputInterval_1 = require("./InputInterval");
|
|
14
6
|
/**
|
|
15
7
|
* Get the largest width in a column, looking at all rows
|
|
16
8
|
* @param colIndex the column index
|
|
17
9
|
* @returns width of the biggest row inside a column
|
|
18
10
|
*/
|
|
19
|
-
function maxOfCol
|
|
11
|
+
function maxOfCol(colIndex) {
|
|
20
12
|
const invisibleContainer = document.createElement('div');
|
|
21
|
-
|
|
22
13
|
invisibleContainer.style.visibility = 'hidden';
|
|
23
14
|
invisibleContainer.style.zIndex = '-9999999999';
|
|
24
15
|
invisibleContainer.style.position = 'absolute';
|
|
@@ -26,10 +17,8 @@ function maxOfCol (colIndex: number): number {
|
|
|
26
17
|
invisibleContainer.style.top = '0';
|
|
27
18
|
invisibleContainer.style.left = '0';
|
|
28
19
|
document.body.append(invisibleContainer);
|
|
29
|
-
const widths
|
|
30
|
-
document.querySelectorAll(
|
|
31
|
-
`[aria-colindex='${colIndex}']`
|
|
32
|
-
).forEach(cell => {
|
|
20
|
+
const widths = [];
|
|
21
|
+
document.querySelectorAll(`[aria-colindex='${colIndex}']`).forEach(cell => {
|
|
33
22
|
const invisibleCell = document.createElement('div');
|
|
34
23
|
invisibleCell.innerHTML = cell.innerHTML;
|
|
35
24
|
invisibleCell.style.width = 'max-content';
|
|
@@ -45,74 +34,67 @@ function maxOfCol (colIndex: number): number {
|
|
|
45
34
|
invisibleContainer.remove();
|
|
46
35
|
return max;
|
|
47
36
|
}
|
|
48
|
-
|
|
49
|
-
export type ResizeType = 'condense' | 'maxContent' | 'fitScreen';
|
|
50
|
-
|
|
51
37
|
/**
|
|
52
|
-
*
|
|
53
|
-
* @param columns
|
|
54
|
-
* @param resizeType
|
|
55
|
-
* @param apiRef
|
|
38
|
+
*
|
|
39
|
+
* @param columns
|
|
40
|
+
* @param resizeType
|
|
41
|
+
* @param apiRef
|
|
56
42
|
* @returns columns resized to the chosen resizeType
|
|
57
43
|
*/
|
|
58
|
-
|
|
59
|
-
columns: GridEnrichedBySchemaColDef[],
|
|
60
|
-
resizeType: ResizeType,
|
|
61
|
-
apiRef: React.MutableRefObject<GridApi>
|
|
62
|
-
): GridEnrichedBySchemaColDef[] {
|
|
44
|
+
function resizeColumns(columns, resizeType, apiRef) {
|
|
63
45
|
const cols = [...columns];
|
|
64
|
-
cols.forEach((col, index
|
|
46
|
+
cols.forEach((col, index) => {
|
|
65
47
|
if (resizeType === 'fitScreen') {
|
|
66
48
|
delete col.width;
|
|
67
49
|
col.minWidth = 80;
|
|
68
50
|
if (col.isIndexField) {
|
|
69
51
|
col.flex = 1;
|
|
70
52
|
}
|
|
71
|
-
}
|
|
53
|
+
}
|
|
54
|
+
else if (resizeType === 'maxContent') {
|
|
72
55
|
const maxColWidth = maxOfCol(index);
|
|
73
56
|
delete col.flex;
|
|
74
57
|
delete col.minWidth;
|
|
75
58
|
col.width = maxColWidth + 22;
|
|
76
|
-
}
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
77
61
|
col.width = 0;
|
|
78
62
|
}
|
|
79
63
|
});
|
|
80
64
|
return cols;
|
|
81
65
|
}
|
|
82
|
-
|
|
83
|
-
|
|
66
|
+
exports.resizeColumns = resizeColumns;
|
|
67
|
+
const quantityOnlyOperators = ({ type }) => {
|
|
84
68
|
const builtInFilters = (type === 'date')
|
|
85
|
-
? getGridDateOperators()
|
|
86
|
-
: getGridNumericOperators();
|
|
87
|
-
let InputComponent = InputNumberInterval;
|
|
69
|
+
? (0, x_data_grid_1.getGridDateOperators)()
|
|
70
|
+
: (0, x_data_grid_1.getGridNumericOperators)();
|
|
71
|
+
let InputComponent = InputInterval_1.InputNumberInterval;
|
|
88
72
|
if (type === 'date') {
|
|
89
|
-
InputComponent = InputDateInterval;
|
|
73
|
+
InputComponent = InputInterval_1.InputDateInterval;
|
|
90
74
|
}
|
|
91
75
|
if (type === 'float') {
|
|
92
|
-
InputComponent = InputFloatInterval;
|
|
76
|
+
InputComponent = InputInterval_1.InputFloatInterval;
|
|
93
77
|
}
|
|
94
78
|
return [
|
|
95
79
|
...builtInFilters,
|
|
96
80
|
{
|
|
97
81
|
label: 'entre',
|
|
98
82
|
value: 'entre',
|
|
99
|
-
getApplyFilterFn: (filterItem
|
|
83
|
+
getApplyFilterFn: (filterItem) => {
|
|
100
84
|
if (!Array.isArray(filterItem.value) || filterItem.value.length !== 2) {
|
|
101
85
|
return null;
|
|
102
86
|
}
|
|
103
87
|
if (filterItem.value[0] === null || filterItem.value[1] === null) {
|
|
104
88
|
return null;
|
|
105
89
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
return (
|
|
109
|
-
value !== null &&
|
|
90
|
+
return ({ value }) => {
|
|
91
|
+
return (value !== null &&
|
|
110
92
|
filterItem.value[0] <= value &&
|
|
111
|
-
value <= filterItem.value[1]
|
|
112
|
-
);
|
|
93
|
+
value <= filterItem.value[1]);
|
|
113
94
|
};
|
|
114
95
|
},
|
|
115
96
|
InputComponent
|
|
116
97
|
}
|
|
117
|
-
]
|
|
118
|
-
};
|
|
98
|
+
];
|
|
99
|
+
};
|
|
100
|
+
exports.quantityOnlyOperators = quantityOnlyOperators;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Item, SchemaType, Id, GridEnrichedBySchemaColDef } from '../utils';
|
|
3
|
+
import { SxProps } from '@mui/material';
|
|
4
|
+
interface DataGridBySchemaEditableProps {
|
|
5
|
+
schema: SchemaType;
|
|
6
|
+
data: Item[];
|
|
7
|
+
columns: GridEnrichedBySchemaColDef[];
|
|
8
|
+
model: string;
|
|
9
|
+
fieldKey?: string;
|
|
10
|
+
labelKey?: string;
|
|
11
|
+
index?: number;
|
|
12
|
+
name?: string;
|
|
13
|
+
indexField?: string;
|
|
14
|
+
addExistingModel?: string;
|
|
15
|
+
indexFieldMinWidth?: number;
|
|
16
|
+
indexFieldBasePath?: string;
|
|
17
|
+
stateToLink?: object;
|
|
18
|
+
minWidth?: number;
|
|
19
|
+
modelParentId?: Id;
|
|
20
|
+
modelParent?: string;
|
|
21
|
+
customColumnOperations?: (p: any) => GridEnrichedBySchemaColDef;
|
|
22
|
+
customLinkDestination?: (p: any) => string;
|
|
23
|
+
LinkComponent?: any;
|
|
24
|
+
onProcessRow?: (p: any) => void;
|
|
25
|
+
onDataChange?: (p: any) => void;
|
|
26
|
+
isEditable?: boolean;
|
|
27
|
+
sx?: SxProps;
|
|
28
|
+
isAutoHeight?: boolean;
|
|
29
|
+
defaultValues?: Item;
|
|
30
|
+
hideFooterPagination?: boolean;
|
|
31
|
+
setVisibleRows?: (p: any) => void;
|
|
32
|
+
}
|
|
33
|
+
declare const DataGridBySchemaEditable: React.ForwardRefExoticComponent<DataGridBySchemaEditableProps & React.RefAttributes<unknown>>;
|
|
34
|
+
export default DataGridBySchemaEditable;
|