drf-react-by-schema 0.22.4 → 0.23.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/@types/index.d.ts +25 -14
- package/dist/@types/index.d.ts.map +1 -1
- package/dist/api.d.ts +7 -11
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +50 -28
- package/dist/components/DataGridBySchemaEditable/BooleanInputCell.d.ts +4 -21
- package/dist/components/DataGridBySchemaEditable/BooleanInputCell.d.ts.map +1 -1
- package/dist/components/DataGridBySchemaEditable/BooleanInputCell.js +64 -19
- package/dist/components/DataGridBySchemaEditable/CustomToolbar.d.ts.map +1 -1
- package/dist/components/DataGridBySchemaEditable/CustomToolbar.js +6 -4
- package/dist/components/DataGridBySchemaEditable/DataGridDesktop.d.ts +8 -8
- package/dist/components/DataGridBySchemaEditable/DataGridDesktop.d.ts.map +1 -1
- package/dist/components/DataGridBySchemaEditable/DataGridDesktop.js +234 -737
- package/dist/components/DataGridBySchemaEditable/DataGridMobile.js +1 -1
- package/dist/components/DataGridBySchemaEditable/FileInputCell.d.ts +4 -21
- package/dist/components/DataGridBySchemaEditable/FileInputCell.d.ts.map +1 -1
- package/dist/components/DataGridBySchemaEditable/FileInputCell.js +62 -21
- package/dist/components/DataGridBySchemaEditable/FooterToolbar.d.ts +5 -1
- package/dist/components/DataGridBySchemaEditable/FooterToolbar.d.ts.map +1 -1
- package/dist/components/DataGridBySchemaEditable/FooterToolbar.js +18 -2
- package/dist/components/DataGridBySchemaEditable/GridDateInput.d.ts +4 -9
- package/dist/components/DataGridBySchemaEditable/GridDateInput.d.ts.map +1 -1
- package/dist/components/DataGridBySchemaEditable/GridDateInput.js +125 -5
- package/dist/components/DataGridBySchemaEditable/GridDecimalInput.d.ts +4 -9
- package/dist/components/DataGridBySchemaEditable/GridDecimalInput.d.ts.map +1 -1
- package/dist/components/DataGridBySchemaEditable/GridDecimalInput.js +51 -7
- package/dist/components/DataGridBySchemaEditable/GridGenericInput.d.ts +8 -0
- package/dist/components/DataGridBySchemaEditable/GridGenericInput.d.ts.map +1 -0
- package/dist/components/DataGridBySchemaEditable/GridGenericInput.js +30 -0
- package/dist/components/DataGridBySchemaEditable/GridPatternInput.d.ts +4 -7
- package/dist/components/DataGridBySchemaEditable/GridPatternInput.d.ts.map +1 -1
- package/dist/components/DataGridBySchemaEditable/GridPatternInput.js +59 -5
- package/dist/components/DataGridBySchemaEditable/InputInterval.d.ts +2 -2
- package/dist/components/DataGridBySchemaEditable/InputInterval.d.ts.map +1 -1
- package/dist/components/DataGridBySchemaEditable/InputInterval.js +23 -4
- package/dist/components/DataGridBySchemaEditable/SelectEditInputCell.d.ts +4 -1
- package/dist/components/DataGridBySchemaEditable/SelectEditInputCell.d.ts.map +1 -1
- package/dist/components/DataGridBySchemaEditable/SelectEditInputCell.js +72 -25
- package/dist/components/DataGridBySchemaEditable/hooks/useDataGridActions.d.ts +34 -0
- package/dist/components/DataGridBySchemaEditable/hooks/useDataGridActions.d.ts.map +1 -0
- package/dist/components/DataGridBySchemaEditable/hooks/useDataGridActions.js +170 -0
- package/dist/components/DataGridBySchemaEditable/hooks/useOptionsAC.d.ts +14 -0
- package/dist/components/DataGridBySchemaEditable/hooks/useOptionsAC.d.ts.map +1 -0
- package/dist/components/DataGridBySchemaEditable/hooks/useOptionsAC.js +67 -0
- package/dist/components/DataGridBySchemaEditable/hooks/usePreparedColumns.d.ts +9 -0
- package/dist/components/DataGridBySchemaEditable/hooks/usePreparedColumns.d.ts.map +1 -0
- package/dist/components/DataGridBySchemaEditable/hooks/usePreparedColumns.js +68 -0
- package/dist/components/DataGridBySchemaEditable/hooks/useProcessRowUpdate.d.ts +33 -0
- package/dist/components/DataGridBySchemaEditable/hooks/useProcessRowUpdate.d.ts.map +1 -0
- package/dist/components/DataGridBySchemaEditable/hooks/useProcessRowUpdate.js +219 -0
- package/dist/components/DataGridBySchemaEditable/hooks/useRowMode.d.ts +18 -0
- package/dist/components/DataGridBySchemaEditable/hooks/useRowMode.d.ts.map +1 -0
- package/dist/components/DataGridBySchemaEditable/hooks/useRowMode.js +43 -0
- package/dist/components/DataGridBySchemaEditable/utils/columnFactory.d.ts +30 -0
- package/dist/components/DataGridBySchemaEditable/utils/columnFactory.d.ts.map +1 -0
- package/dist/components/DataGridBySchemaEditable/utils/columnFactory.js +180 -0
- package/dist/components/DataGridBySchemaEditable.d.ts +2 -1
- package/dist/components/DataGridBySchemaEditable.d.ts.map +1 -1
- package/dist/components/DataGridBySchemaEditable.js +5 -4
- package/dist/components/GenericModelList.d.ts.map +1 -1
- package/dist/components/GenericModelList.js +13 -8
- package/dist/components/GenericRelatedModelList.d.ts.map +1 -1
- package/dist/components/GenericRelatedModelList.js +13 -8
- package/dist/components/GenericRelatedModelListTable.d.ts +3 -2
- package/dist/components/GenericRelatedModelListTable.d.ts.map +1 -1
- package/dist/components/GenericRelatedModelListTable.js +3 -3
- package/dist/components/details/DetailBySchema.js +2 -2
- package/dist/components/details/DetailFieldBySchema.d.ts.map +1 -1
- package/dist/components/details/DetailFieldBySchema.js +3 -0
- package/dist/components/forms/DialogFormBySchema.d.ts +4 -3
- package/dist/components/forms/DialogFormBySchema.d.ts.map +1 -1
- package/dist/components/forms/FieldBySchema.d.ts.map +1 -1
- package/dist/components/forms/Form.d.ts +4 -3
- package/dist/components/forms/Form.d.ts.map +1 -1
- package/dist/components/forms/Form.js +3 -2
- package/dist/components/forms/FormBySchema.d.ts +3 -2
- package/dist/components/forms/FormBySchema.d.ts.map +1 -1
- package/dist/components/forms/FormBySchema.js +3 -2
- package/dist/context/APIWrapper.d.ts.map +1 -1
- package/dist/context/APIWrapper.js +35 -29
- package/dist/context/APIWrapperContext.d.ts +17 -14
- package/dist/context/APIWrapperContext.d.ts.map +1 -1
- package/dist/context/APIWrapperContext.js +12 -10
- package/dist/context/DRFReactBySchemaProvider.d.ts.map +1 -1
- package/dist/context/DRFReactBySchemaProvider.js +5 -1
- package/dist/styles/grid.d.ts +3 -0
- package/dist/styles/grid.d.ts.map +1 -0
- package/dist/styles/grid.js +38 -0
- package/dist/styles/theme.d.ts.map +1 -1
- package/dist/styles/theme.js +46 -12
- package/dist/utils.d.ts +2 -2
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +24 -28
- package/package.json +9 -8
package/dist/utils.js
CHANGED
|
@@ -388,13 +388,13 @@ function mergeFilterItems(defaultFilter, filter) {
|
|
|
388
388
|
const items = filter.items;
|
|
389
389
|
const defaultItems = defaultFilter.items;
|
|
390
390
|
const mergedItems = defaultItems.map((defaultItem) => {
|
|
391
|
-
const itemFound = items.find((item) => item.
|
|
391
|
+
const itemFound = items.find((item) => item.field === defaultItem.field);
|
|
392
392
|
if (itemFound) {
|
|
393
393
|
return itemFound;
|
|
394
394
|
}
|
|
395
395
|
return defaultItem;
|
|
396
396
|
});
|
|
397
|
-
const unMergedItems = items.filter((item) => !defaultItems.map((defaultItem) => defaultItem.
|
|
397
|
+
const unMergedItems = items.filter((item) => !defaultItems.map((defaultItem) => defaultItem.field).includes(item.field));
|
|
398
398
|
return Object.assign(Object.assign({}, filter), { items: [...mergedItems, ...unMergedItems] });
|
|
399
399
|
}
|
|
400
400
|
return undefined;
|
|
@@ -416,49 +416,47 @@ function initViewColumns(_a) {
|
|
|
416
416
|
case 'date':
|
|
417
417
|
column.type = 'date';
|
|
418
418
|
const dateFormat = buildDateFormatBySchema(fieldSchema.date_views);
|
|
419
|
-
column.valueFormatter = (
|
|
419
|
+
column.valueFormatter = (value) => (value ? (0, dayjs_1.default)(value).format(dateFormat) : '');
|
|
420
420
|
break;
|
|
421
421
|
case 'datetime':
|
|
422
422
|
column.type = 'dateTime';
|
|
423
|
-
column.valueFormatter = (
|
|
423
|
+
column.valueFormatter = (value) => (value ? (0, dayjs_1.default)(value).format('DD/MM/YYYY HH:mm') : '');
|
|
424
424
|
break;
|
|
425
425
|
case 'nested object':
|
|
426
|
-
column.valueFormatter = (
|
|
427
|
-
return !
|
|
426
|
+
column.valueFormatter = (value) => {
|
|
427
|
+
return !value ? '' : value.label;
|
|
428
428
|
};
|
|
429
429
|
break;
|
|
430
430
|
case 'field':
|
|
431
|
-
column.valueFormatter = (
|
|
432
|
-
return !
|
|
433
|
-
? ''
|
|
434
|
-
: params.value.map((val) => val.label).join(', ');
|
|
431
|
+
column.valueFormatter = (value) => {
|
|
432
|
+
return !value || !Array.isArray(value) ? '' : value.map((val) => val.label).join(', ');
|
|
435
433
|
};
|
|
436
434
|
break;
|
|
437
435
|
case 'choice':
|
|
438
|
-
column.valueFormatter = (
|
|
439
|
-
return !
|
|
436
|
+
column.valueFormatter = (value) => {
|
|
437
|
+
return !value ? '' : value.display_name;
|
|
440
438
|
};
|
|
441
439
|
break;
|
|
442
440
|
case 'list':
|
|
443
|
-
column.valueFormatter = (
|
|
444
|
-
return !
|
|
441
|
+
column.valueFormatter = (value) => {
|
|
442
|
+
return !value || !Array.isArray(value)
|
|
445
443
|
? ''
|
|
446
|
-
:
|
|
444
|
+
: value.map((val) => val.display_name).join(', ');
|
|
447
445
|
};
|
|
448
446
|
break;
|
|
449
447
|
case 'boolean':
|
|
450
|
-
column.valueFormatter = (
|
|
451
|
-
return
|
|
448
|
+
column.valueFormatter = (value) => {
|
|
449
|
+
return value ? 'Sim' : 'Não';
|
|
452
450
|
};
|
|
453
451
|
break;
|
|
454
452
|
case 'decimal':
|
|
455
453
|
case 'float':
|
|
456
454
|
const decimalScale = fieldSchema.decimal_places || 2;
|
|
457
455
|
column.type = 'number';
|
|
458
|
-
column.valueFormatter = (
|
|
459
|
-
return !
|
|
456
|
+
column.valueFormatter = (value) => {
|
|
457
|
+
return !value
|
|
460
458
|
? ''
|
|
461
|
-
: parseFloat(
|
|
459
|
+
: parseFloat(value).toLocaleString('pt-BR', {
|
|
462
460
|
minimumFractionDigits: decimalScale,
|
|
463
461
|
maximumFractionDigits: decimalScale,
|
|
464
462
|
});
|
|
@@ -473,10 +471,8 @@ function initViewColumns(_a) {
|
|
|
473
471
|
break;
|
|
474
472
|
case 'file upload':
|
|
475
473
|
case 'image upload':
|
|
476
|
-
column.valueFormatter = (
|
|
477
|
-
return !
|
|
478
|
-
? ''
|
|
479
|
-
: `${params.value.name.split('/').pop()} (${formatFileSize(params.value.size)})`;
|
|
474
|
+
column.valueFormatter = (value) => {
|
|
475
|
+
return !value ? '' : `${value.name.split('/').pop()} (${formatFileSize(value.size)})`;
|
|
480
476
|
};
|
|
481
477
|
default:
|
|
482
478
|
if (fieldSchema.pattern_format) {
|
|
@@ -485,11 +481,11 @@ function initViewColumns(_a) {
|
|
|
485
481
|
}
|
|
486
482
|
// format numbers:
|
|
487
483
|
if (column.patternFormat) {
|
|
488
|
-
column.valueFormatter = (
|
|
489
|
-
if (!
|
|
490
|
-
return
|
|
484
|
+
column.valueFormatter = (value) => {
|
|
485
|
+
if (!value || typeof value !== 'string') {
|
|
486
|
+
return value;
|
|
491
487
|
}
|
|
492
|
-
const formattedValue = new string_mask_1.default(column.patternFormat, {}).apply(
|
|
488
|
+
const formattedValue = new string_mask_1.default(column.patternFormat, {}).apply(value);
|
|
493
489
|
return formattedValue;
|
|
494
490
|
};
|
|
495
491
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "drf-react-by-schema",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.23.1",
|
|
4
4
|
"description": "Components and Tools for building a React App having Django Rest Framework (DRF) as server",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
"test": "echo \"There are (still) no tests in this package\"",
|
|
9
9
|
"build": "tsc",
|
|
10
10
|
"install-peers": "yarn add --peer --ignore-workspace-root-check --no-lockfile $(node -pe \"Object.keys(require('./package.json').peerDependencies).map(pkg => pkg+'@'+require('./package.json').peerDependencies[pkg]).join(' ')\")",
|
|
11
|
+
"install-peers-for-dev": "yarn add --dev $(node -pe \"Object.keys(require('./package.json').peerDependencies).map(pkg => pkg+'@'+require('./package.json').peerDependencies[pkg]).join(' ')\")",
|
|
12
|
+
"reinstall-all": "rm -rf node_modules && yarn install && yarn install-peers-for-dev",
|
|
11
13
|
"release:major": "tsc || true && yarn version --version $(semver $npm_package_version -i major) && yarn publish --tag latest",
|
|
12
14
|
"release:minor": "tsc || true && yarn version --new-version $(semver $npm_package_version -i minor) && yarn publish --tag latest",
|
|
13
15
|
"release:patch": "tsc || true && yarn version --new-version $(semver $npm_package_version -i patch) && yarn publish --tag latest"
|
|
@@ -58,14 +60,13 @@
|
|
|
58
60
|
"webpack": "^5.75.0"
|
|
59
61
|
},
|
|
60
62
|
"peerDependencies": {
|
|
61
|
-
"@emotion/react": "
|
|
62
|
-
"@emotion/styled": "
|
|
63
|
+
"@emotion/react": "11.14.0",
|
|
64
|
+
"@emotion/styled": "11.14.0",
|
|
63
65
|
"@hookform/resolvers": "^2.9.10",
|
|
64
|
-
"@mui/icons-material": "
|
|
65
|
-
"@mui/
|
|
66
|
-
"@mui/
|
|
67
|
-
"@mui/x-
|
|
68
|
-
"@mui/x-date-pickers": "^6.18.1",
|
|
66
|
+
"@mui/icons-material": "6.5.0",
|
|
67
|
+
"@mui/material": "6.5.0",
|
|
68
|
+
"@mui/x-data-grid": "7.29.12",
|
|
69
|
+
"@mui/x-date-pickers": "7.29.4",
|
|
69
70
|
"axios": "^0.27.2",
|
|
70
71
|
"dayjs": "^1.11.10",
|
|
71
72
|
"react": "^18.2.0",
|