drf-react-by-schema 0.19.5 → 0.19.6

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/README.md CHANGED
@@ -42,7 +42,7 @@ The _DRF and React By Schema_ Suite is available for React at https://www.npmjs.
42
42
 
43
43
  3. Install all peer-dependencies of drf-react-by-schema:
44
44
  ```
45
- yarn add @emotion/react@^11.11.0 @emotion/styled@^11.11.0 @hookform/resolvers@^2.9.10 @mui/icons-material@^5.11.0 @mui/lab@^5.0.0-alpha.112 @mui/material@^5.13.7 @mui/x-data-grid@^5.17.26 @mui/x-date-pickers@^6.18.1 axios@^0.27.2 date-fns@^4.1.0 dayjs@^1.11.10 react@^18.2.0 react-dom@^18.2.0 react-hook-form@^7.41.3 react-number-format@^5.3.2 string-mask@^0.3.0 yup@^0.32.11
45
+ yarn add @emotion/react@^11.11.0 @emotion/styled@^11.11.0 @hookform/resolvers@^2.9.10 @mui/icons-material@^5.11.0 @mui/lab@^5.0.0-alpha.112 @mui/material@^5.13.7 @mui/x-data-grid@^5.17.26 @mui/x-date-pickers@^6.18.1 axios@^0.27.2 dayjs@^1.11.10 react@^18.2.0 react-dom@^18.2.0 react-hook-form@^7.41.3 react-number-format@^5.3.2 string-mask@^0.3.0 yup@^0.32.11
46
46
  ```
47
47
 
48
48
  4. Install drf-react-by-schema:
package/dist/api.js CHANGED
@@ -14,7 +14,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.getAllModels = exports.getGenericModel = exports.getGenericModelList = exports.signUp = exports.getSignUpOptions = exports.isLoggedIn = exports.setAuthToken = exports.hasJWT = exports.clearJWT = exports.loginByPayload = exports.getAutoComplete = exports.addExistingRelatedModel = exports.updateDataBySchema = exports.createOrUpdateData = exports.deleteData = exports.createData = exports.partialUpdateData = exports.updateData = exports.getRawData = void 0;
16
16
  const axios_1 = __importDefault(require("axios"));
17
- const format_1 = require("date-fns/format");
17
+ const dayjs_1 = __importDefault(require("dayjs"));
18
18
  const utils_1 = require("./utils");
19
19
  const expiredTokenMessage = 'Token expired! System must login again';
20
20
  const noServerEndPointMessage = 'There is not API definition (serverEndPoint)!';
@@ -449,12 +449,12 @@ const prepareDataBySchema = ({ data, schema }) => {
449
449
  }
450
450
  // Date:
451
451
  if (field.type === 'date') {
452
- dbData[key] = (0, format_1.format)(new Date(data[key]), 'yyyy-MM-dd');
452
+ dbData[key] = (0, dayjs_1.default)(data[key]).format('YYYY-MM-DD');
453
453
  continue;
454
454
  }
455
455
  // DateTime:
456
456
  if (field.type === 'datetime') {
457
- dbData[key] = (0, format_1.format)(new Date(data[key]), "yyyy-MM-dd'T'HH:mm");
457
+ dbData[key] = (0, dayjs_1.default)(data[key]).format("YYYY-MM-DD'T'HH:mm");
458
458
  continue;
459
459
  }
460
460
  // Default:
@@ -46,7 +46,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
46
46
  };
47
47
  Object.defineProperty(exports, "__esModule", { value: true });
48
48
  const react_1 = __importStar(require("react"));
49
- const date_fns_1 = require("date-fns");
49
+ const dayjs_1 = __importDefault(require("dayjs"));
50
50
  const x_data_grid_1 = require("@mui/x-data-grid");
51
51
  const Box_1 = __importDefault(require("@mui/material/Box"));
52
52
  const CircularProgress_1 = __importDefault(require("@mui/material/CircularProgress"));
@@ -250,7 +250,7 @@ const DataGridBySchemaEditable = (0, react_1.forwardRef)(({ schema, data, rowCou
250
250
  case 'date':
251
251
  column.type = 'date';
252
252
  const dateFormat = (0, utils_1.buildDateFormatBySchema)(schema[col.field].date_views);
253
- column.valueFormatter = (params) => params.value ? (0, date_fns_1.format)(new Date(params.value), dateFormat) : '';
253
+ column.valueFormatter = (params) => params.value ? (0, dayjs_1.default)(params.value).format(dateFormat) : '';
254
254
  column.filterOperators = (0, utils_2.quantityOnlyOperators)({
255
255
  type: 'date',
256
256
  });
@@ -262,7 +262,7 @@ const DataGridBySchemaEditable = (0, react_1.forwardRef)(({ schema, data, rowCou
262
262
  case 'datetime':
263
263
  column.type = 'dateTime';
264
264
  column.minWidth = 180;
265
- column.valueFormatter = (params) => params.value ? (0, date_fns_1.format)(new Date(params.value), 'dd/MM/yyyy HH:mm') : '';
265
+ column.valueFormatter = (params) => params.value ? (0, dayjs_1.default)(params.value).format('dd/MM/yyyy HH:mm') : '';
266
266
  column.filterOperators = (0, utils_2.quantityOnlyOperators)({
267
267
  type: 'date',
268
268
  });
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.default = DetailFieldBySchema;
7
7
  const react_1 = __importDefault(require("react"));
8
- const date_fns_1 = require("date-fns");
8
+ const dayjs_1 = __importDefault(require("dayjs"));
9
9
  const Typography_1 = __importDefault(require("@mui/material/Typography"));
10
10
  const Box_1 = __importDefault(require("@mui/material/Box"));
11
11
  const List_1 = __importDefault(require("@mui/material/List"));
@@ -21,11 +21,11 @@ function DetailFieldBySchema({ name, value, schema, labelKey = 'label', optionId
21
21
  case 'date':
22
22
  return (react_1.default.createElement(Box_1.default, { sx: sxField },
23
23
  react_1.default.createElement(Typography_1.default, { variant: "h5", sx: sxLabel }, schema[name].label),
24
- react_1.default.createElement(Typography_1.default, { variant: "body2", sx: sxValue }, (0, date_fns_1.format)(new Date(value), 'dd/MM/yyyy'))));
24
+ react_1.default.createElement(Typography_1.default, { variant: "body2", sx: sxValue }, (0, dayjs_1.default)(value).format('DD/MM/YYYY'))));
25
25
  case 'datetime':
26
26
  return (react_1.default.createElement(Box_1.default, { sx: sxField },
27
27
  react_1.default.createElement(Typography_1.default, { variant: "h5", sx: sxLabel }, schema[name].label),
28
- react_1.default.createElement(Typography_1.default, { variant: "body2", sx: sxValue }, (0, date_fns_1.format)(new Date(value), 'dd/MM/yyyy HH:mm'))));
28
+ react_1.default.createElement(Typography_1.default, { variant: "body2", sx: sxValue }, (0, dayjs_1.default)(value).format('DD/MM/YYYY HH:mm'))));
29
29
  case 'nested object':
30
30
  case 'field':
31
31
  const multiple = schema[name].many || false;
package/dist/utils.d.ts CHANGED
@@ -26,7 +26,7 @@ export declare const getTmpId: () => string;
26
26
  export declare const isTmpId: (id: string | number | undefined | null) => boolean;
27
27
  export declare function reducer<T>(state: T | null, newState: Partial<T> | null): T | null;
28
28
  export declare const getPatternFormat: (type: string) => string;
29
- export declare function buildDateFormatBySchema(dateViews: string[] | null | undefined): "dd/MM/yyyy" | "MM/yyyy" | "yyyy" | "MM" | "dd";
29
+ export declare function buildDateFormatBySchema(dateViews: string[] | null | undefined): "DD/MM/YYYY" | "MM/YYYY" | "YYYY" | "MM" | "DD";
30
30
  export declare const slugToCamelCase: (str: string, includeFirst?: boolean) => string;
31
31
  export declare const slugify: (text: string | null) => string;
32
32
  export declare function mergeFilterItems(defaultFilter: GridFilterModel | undefined, filter: GridFilterModel | undefined): any;
package/dist/utils.js CHANGED
@@ -291,7 +291,7 @@ const getPatternFormat = (type) => {
291
291
  };
292
292
  exports.getPatternFormat = getPatternFormat;
293
293
  function buildDateFormatBySchema(dateViews) {
294
- const defaultFormat = 'dd/MM/yyyy';
294
+ const defaultFormat = 'DD/MM/YYYY';
295
295
  if (!dateViews) {
296
296
  return defaultFormat;
297
297
  }
@@ -302,16 +302,16 @@ function buildDateFormatBySchema(dateViews) {
302
302
  return defaultFormat;
303
303
  }
304
304
  if (!hasDay && hasMonth && hasYear) {
305
- return 'MM/yyyy';
305
+ return 'MM/YYYY';
306
306
  }
307
307
  if (!hasDay && !hasMonth && hasYear) {
308
- return 'yyyy';
308
+ return 'YYYY';
309
309
  }
310
310
  if (!hasDay && hasMonth && !hasYear) {
311
311
  return 'MM';
312
312
  }
313
313
  if (hasDay && !hasMonth && !hasYear) {
314
- return 'dd';
314
+ return 'DD';
315
315
  }
316
316
  return defaultFormat;
317
317
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drf-react-by-schema",
3
- "version": "0.19.5",
3
+ "version": "0.19.6",
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",
@@ -67,7 +67,6 @@
67
67
  "@mui/x-data-grid": "^5.17.26",
68
68
  "@mui/x-date-pickers": "^6.18.1",
69
69
  "axios": "^0.27.2",
70
- "date-fns": "^4.1.0",
71
70
  "dayjs": "^1.11.10",
72
71
  "react": "^18.2.0",
73
72
  "react-dom": "^18.2.0",