@etsoo/materialui 1.0.12 → 1.0.13

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.
@@ -3,6 +3,7 @@ import { DataTypes } from '@etsoo/shared';
3
3
  import { GridProps } from '@mui/material';
4
4
  import React from 'react';
5
5
  import { CommonPageProps } from './CommonPageProps';
6
+ declare type RowType = boolean | 'default' | 'small';
6
7
  /**
7
8
  * View page display field
8
9
  */
@@ -22,13 +23,13 @@ export interface ViewPageField<T extends object> extends GridProps {
22
23
  /**
23
24
  * Display as single row
24
25
  */
25
- singleRow?: boolean | 'default' | 'small';
26
+ singleRow?: RowType;
26
27
  /**
27
28
  * Render props
28
29
  */
29
30
  renderProps?: GridColumnRenderProps;
30
31
  }
31
- declare type ViewPageFieldType<T extends object> = (string & keyof T) | [string & keyof T, GridDataType, GridColumnRenderProps?] | ViewPageField<T>;
32
+ declare type ViewPageFieldType<T extends object> = (string & keyof T) | [string & keyof T, GridDataType, GridColumnRenderProps?, RowType?] | ViewPageField<T>;
32
33
  /**
33
34
  * View page props
34
35
  */
@@ -16,32 +16,35 @@ function formatItemData(fieldData) {
16
16
  return globalApp.formatDate(fieldData, 'd');
17
17
  return `${fieldData}`;
18
18
  }
19
+ function getResp(singleRow) {
20
+ return singleRow === 'default'
21
+ ? { xs: 12, sm: 12, md: 12, lg: 6, xl: 6 }
22
+ : singleRow === true
23
+ ? { xs: 12, sm: 12, md: 12, lg: 12, xl: 12 }
24
+ : {
25
+ xs: singleRow === false ? 12 : 6,
26
+ sm: 6,
27
+ md: 6,
28
+ lg: 4,
29
+ xl: 3
30
+ };
31
+ }
19
32
  function getItemField(field, data) {
20
33
  var _a, _b, _c;
21
34
  // Item data and label
22
35
  let itemData, itemLabel, gridProps = {};
23
36
  if (Array.isArray(field)) {
24
- const [fieldData, fieldType, renderProps] = field;
37
+ const [fieldData, fieldType, renderProps, singleRow = 'small'] = field;
25
38
  itemData = GridDataFormat(data[fieldData], fieldType, renderProps);
26
39
  itemLabel = (_a = globalApp.get(fieldData)) !== null && _a !== void 0 ? _a : fieldData;
40
+ gridProps = { ...getResp(singleRow) };
27
41
  }
28
42
  else if (typeof field === 'object') {
29
43
  // Destruct
30
44
  const { data: fieldData, dataType, label: fieldLabel, renderProps, singleRow = 'default', ...rest } = field;
31
- const res = singleRow === 'default'
32
- ? { xs: 12, sm: 12, md: 6, lg: 6, xl: 4 }
33
- : singleRow === true
34
- ? { xs: 12, sm: 12, md: 12, lg: 12, xl: 12 }
35
- : {
36
- xs: singleRow === false ? 12 : 6,
37
- sm: 6,
38
- md: 6,
39
- lg: 4,
40
- xl: 3
41
- };
42
45
  gridProps = {
43
46
  ...rest,
44
- ...res
47
+ ...getResp(singleRow)
45
48
  };
46
49
  // Field data
47
50
  if (typeof fieldData === 'function')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/materialui",
3
- "version": "1.0.12",
3
+ "version": "1.0.13",
4
4
  "description": "TypeScript Material-UI Implementation",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -16,6 +16,8 @@ import { PullToRefreshUI } from '../PullToRefreshUI';
16
16
  import { CommonPage } from './CommonPage';
17
17
  import { CommonPageProps } from './CommonPageProps';
18
18
 
19
+ type RowType = boolean | 'default' | 'small';
20
+
19
21
  /**
20
22
  * View page display field
21
23
  */
@@ -38,7 +40,7 @@ export interface ViewPageField<T extends object> extends GridProps {
38
40
  /**
39
41
  * Display as single row
40
42
  */
41
- singleRow?: boolean | 'default' | 'small';
43
+ singleRow?: RowType;
42
44
 
43
45
  /**
44
46
  * Render props
@@ -48,7 +50,7 @@ export interface ViewPageField<T extends object> extends GridProps {
48
50
 
49
51
  type ViewPageFieldType<T extends object> =
50
52
  | (string & keyof T)
51
- | [string & keyof T, GridDataType, GridColumnRenderProps?]
53
+ | [string & keyof T, GridDataType, GridColumnRenderProps?, RowType?]
52
54
  | ViewPageField<T>;
53
55
 
54
56
  /**
@@ -98,6 +100,20 @@ function formatItemData(fieldData: unknown): string | undefined {
98
100
  return `${fieldData}`;
99
101
  }
100
102
 
103
+ function getResp(singleRow: RowType) {
104
+ return singleRow === 'default'
105
+ ? { xs: 12, sm: 12, md: 12, lg: 6, xl: 6 }
106
+ : singleRow === true
107
+ ? { xs: 12, sm: 12, md: 12, lg: 12, xl: 12 }
108
+ : {
109
+ xs: singleRow === false ? 12 : 6,
110
+ sm: 6,
111
+ md: 6,
112
+ lg: 4,
113
+ xl: 3
114
+ };
115
+ }
116
+
101
117
  function getItemField<T extends object>(
102
118
  field: ViewPageFieldType<T>,
103
119
  data: T
@@ -108,9 +124,10 @@ function getItemField<T extends object>(
108
124
  gridProps: GridProps = {};
109
125
 
110
126
  if (Array.isArray(field)) {
111
- const [fieldData, fieldType, renderProps] = field;
127
+ const [fieldData, fieldType, renderProps, singleRow = 'small'] = field;
112
128
  itemData = GridDataFormat(data[fieldData], fieldType, renderProps);
113
129
  itemLabel = globalApp.get<string>(fieldData) ?? fieldData;
130
+ gridProps = { ...getResp(singleRow) };
114
131
  } else if (typeof field === 'object') {
115
132
  // Destruct
116
133
  const {
@@ -122,22 +139,9 @@ function getItemField<T extends object>(
122
139
  ...rest
123
140
  } = field;
124
141
 
125
- const res =
126
- singleRow === 'default'
127
- ? { xs: 12, sm: 12, md: 6, lg: 6, xl: 4 }
128
- : singleRow === true
129
- ? { xs: 12, sm: 12, md: 12, lg: 12, xl: 12 }
130
- : {
131
- xs: singleRow === false ? 12 : 6,
132
- sm: 6,
133
- md: 6,
134
- lg: 4,
135
- xl: 3
136
- };
137
-
138
142
  gridProps = {
139
143
  ...rest,
140
- ...res
144
+ ...getResp(singleRow)
141
145
  };
142
146
 
143
147
  // Field data