@etsoo/materialui 1.5.18 → 1.5.19

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.
@@ -31,6 +31,7 @@ export type ViewPageGridItemProps = GridProps & {
31
31
  data: React.ReactNode;
32
32
  label?: React.ReactNode;
33
33
  singleRow?: ViewPageRowType;
34
+ horizontal?: boolean;
34
35
  };
35
36
  /**
36
37
  * View page grid item
@@ -58,6 +59,10 @@ export interface ViewPageField<T extends object> extends GridProps {
58
59
  * Display as single row
59
60
  */
60
61
  singleRow?: ViewPageRowType;
62
+ /**
63
+ * Render as horizontal or not
64
+ */
65
+ horizontal?: boolean;
61
66
  /**
62
67
  * Render props
63
68
  */
@@ -42,7 +42,7 @@ function getResp(singleRow) {
42
42
  }
43
43
  function getItemField(app, field, data) {
44
44
  // Item data and label
45
- let itemData, itemLabel, gridProps = {}, size;
45
+ let itemData, itemLabel, gridProps = {}, size, isHorizontal;
46
46
  if (Array.isArray(field)) {
47
47
  const [fieldData, fieldType, renderProps, singleRow = "small"] = field;
48
48
  itemData = (0, GridDataFormat_1.GridDataFormat)(data[fieldData], fieldType, renderProps);
@@ -52,7 +52,9 @@ function getItemField(app, field, data) {
52
52
  }
53
53
  else if (typeof field === "object") {
54
54
  // Destruct
55
- const { data: fieldData, dataType, label: fieldLabel, renderProps, singleRow = "default", ...rest } = field;
55
+ const { data: fieldData, dataType, label: fieldLabel, renderProps, singleRow = "default", horizontal, ...rest } = field;
56
+ // Horizontal or not
57
+ isHorizontal = horizontal;
56
58
  // Size
57
59
  size = getResp(singleRow);
58
60
  gridProps = {
@@ -85,7 +87,7 @@ function getItemField(app, field, data) {
85
87
  size = ViewPageSize.small;
86
88
  gridProps = { size };
87
89
  }
88
- return [itemData, itemLabel, gridProps, size];
90
+ return [itemData, itemLabel, gridProps, size, isHorizontal];
89
91
  }
90
92
  function getItemSize(bp, size) {
91
93
  const v = size[bp];
@@ -149,7 +151,7 @@ var ViewPageSize;
149
151
  */
150
152
  function ViewPageGridItem(props) {
151
153
  // Destruct
152
- const { data, label, singleRow, ...gridProps } = props;
154
+ const { data, label, singleRow, horizontal = false, ...gridProps } = props;
153
155
  // Default options
154
156
  let options = {};
155
157
  if (gridProps.size == null) {
@@ -159,7 +161,7 @@ function ViewPageGridItem(props) {
159
161
  options = getResp(singleRow ?? "small");
160
162
  }
161
163
  // Layout
162
- return ((0, jsx_runtime_1.jsxs)(Grid_1.default, { ...gridProps, ...options, children: [label != null && ((0, jsx_runtime_1.jsxs)(Typography_1.default, { variant: "caption", component: "div", children: [label, ":"] })), typeof data === "object" ? (data) : ((0, jsx_runtime_1.jsx)(Typography_1.default, { variant: "subtitle2", children: data }))] }));
164
+ return ((0, jsx_runtime_1.jsxs)(Grid_1.default, { ...gridProps, ...options, children: [label != null && ((0, jsx_runtime_1.jsxs)(Typography_1.default, { variant: "caption", component: horizontal ? "span" : "div", children: [label, ":"] })), typeof data === "object" ? (data) : horizontal ? ((0, jsx_runtime_1.jsx)(Typography_1.default, { variant: "subtitle2", component: "span", marginLeft: 0.5, children: data })) : ((0, jsx_runtime_1.jsx)(Typography_1.default, { variant: "subtitle2", children: data }))] }));
163
165
  }
164
166
  function ViewContainer(props) {
165
167
  // Global app
@@ -196,12 +198,12 @@ function ViewContainer(props) {
196
198
  }
197
199
  }
198
200
  else {
199
- const [itemData, itemLabel, gridProps, size] = getItemField(app, field, data);
201
+ const [itemData, itemLabel, gridProps, size, horizontal] = getItemField(app, field, data);
200
202
  // Some callback function may return '' instead of undefined
201
203
  if (itemData == null || itemData === "")
202
204
  continue;
203
205
  oneSize = size;
204
- oneItem = ((0, react_1.createElement)(ViewPageGridItem, { ...gridProps, key: i, data: itemData, label: itemLabel }));
206
+ oneItem = ((0, react_1.createElement)(ViewPageGridItem, { ...gridProps, key: i, data: itemData, label: itemLabel, horizontal: horizontal }));
205
207
  }
206
208
  // Max lines
207
209
  if (maxItems > 0) {
@@ -31,6 +31,7 @@ export type ViewPageGridItemProps = GridProps & {
31
31
  data: React.ReactNode;
32
32
  label?: React.ReactNode;
33
33
  singleRow?: ViewPageRowType;
34
+ horizontal?: boolean;
34
35
  };
35
36
  /**
36
37
  * View page grid item
@@ -58,6 +59,10 @@ export interface ViewPageField<T extends object> extends GridProps {
58
59
  * Display as single row
59
60
  */
60
61
  singleRow?: ViewPageRowType;
62
+ /**
63
+ * Render as horizontal or not
64
+ */
65
+ horizontal?: boolean;
61
66
  /**
62
67
  * Render props
63
68
  */
@@ -34,7 +34,7 @@ function getResp(singleRow) {
34
34
  }
35
35
  function getItemField(app, field, data) {
36
36
  // Item data and label
37
- let itemData, itemLabel, gridProps = {}, size;
37
+ let itemData, itemLabel, gridProps = {}, size, isHorizontal;
38
38
  if (Array.isArray(field)) {
39
39
  const [fieldData, fieldType, renderProps, singleRow = "small"] = field;
40
40
  itemData = GridDataFormat(data[fieldData], fieldType, renderProps);
@@ -44,7 +44,9 @@ function getItemField(app, field, data) {
44
44
  }
45
45
  else if (typeof field === "object") {
46
46
  // Destruct
47
- const { data: fieldData, dataType, label: fieldLabel, renderProps, singleRow = "default", ...rest } = field;
47
+ const { data: fieldData, dataType, label: fieldLabel, renderProps, singleRow = "default", horizontal, ...rest } = field;
48
+ // Horizontal or not
49
+ isHorizontal = horizontal;
48
50
  // Size
49
51
  size = getResp(singleRow);
50
52
  gridProps = {
@@ -77,7 +79,7 @@ function getItemField(app, field, data) {
77
79
  size = ViewPageSize.small;
78
80
  gridProps = { size };
79
81
  }
80
- return [itemData, itemLabel, gridProps, size];
82
+ return [itemData, itemLabel, gridProps, size, isHorizontal];
81
83
  }
82
84
  function getItemSize(bp, size) {
83
85
  const v = size[bp];
@@ -141,7 +143,7 @@ export var ViewPageSize;
141
143
  */
142
144
  export function ViewPageGridItem(props) {
143
145
  // Destruct
144
- const { data, label, singleRow, ...gridProps } = props;
146
+ const { data, label, singleRow, horizontal = false, ...gridProps } = props;
145
147
  // Default options
146
148
  let options = {};
147
149
  if (gridProps.size == null) {
@@ -151,7 +153,7 @@ export function ViewPageGridItem(props) {
151
153
  options = getResp(singleRow ?? "small");
152
154
  }
153
155
  // Layout
154
- return (_jsxs(Grid, { ...gridProps, ...options, children: [label != null && (_jsxs(Typography, { variant: "caption", component: "div", children: [label, ":"] })), typeof data === "object" ? (data) : (_jsx(Typography, { variant: "subtitle2", children: data }))] }));
156
+ return (_jsxs(Grid, { ...gridProps, ...options, children: [label != null && (_jsxs(Typography, { variant: "caption", component: horizontal ? "span" : "div", children: [label, ":"] })), typeof data === "object" ? (data) : horizontal ? (_jsx(Typography, { variant: "subtitle2", component: "span", marginLeft: 0.5, children: data })) : (_jsx(Typography, { variant: "subtitle2", children: data }))] }));
155
157
  }
156
158
  export function ViewContainer(props) {
157
159
  // Global app
@@ -188,12 +190,12 @@ export function ViewContainer(props) {
188
190
  }
189
191
  }
190
192
  else {
191
- const [itemData, itemLabel, gridProps, size] = getItemField(app, field, data);
193
+ const [itemData, itemLabel, gridProps, size, horizontal] = getItemField(app, field, data);
192
194
  // Some callback function may return '' instead of undefined
193
195
  if (itemData == null || itemData === "")
194
196
  continue;
195
197
  oneSize = size;
196
- oneItem = (_createElement(ViewPageGridItem, { ...gridProps, key: i, data: itemData, label: itemLabel }));
198
+ oneItem = (_createElement(ViewPageGridItem, { ...gridProps, key: i, data: itemData, label: itemLabel, horizontal: horizontal }));
197
199
  }
198
200
  // Max lines
199
201
  if (maxItems > 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/materialui",
3
- "version": "1.5.18",
3
+ "version": "1.5.19",
4
4
  "description": "TypeScript Material-UI Implementation",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -40,12 +40,13 @@ function getItemField<T extends object>(
40
40
  app: ReactAppType,
41
41
  field: ViewPageFieldTypeNarrow<T>,
42
42
  data: T
43
- ): [React.ReactNode, React.ReactNode, GridProps, ViewPageItemSize] {
43
+ ): [React.ReactNode, React.ReactNode, GridProps, ViewPageItemSize, boolean?] {
44
44
  // Item data and label
45
45
  let itemData: React.ReactNode,
46
46
  itemLabel: React.ReactNode,
47
47
  gridProps: GridProps = {},
48
- size: ViewPageItemSize;
48
+ size: ViewPageItemSize,
49
+ isHorizontal: boolean | undefined;
49
50
 
50
51
  if (Array.isArray(field)) {
51
52
  const [fieldData, fieldType, renderProps, singleRow = "small"] = field;
@@ -61,9 +62,13 @@ function getItemField<T extends object>(
61
62
  label: fieldLabel,
62
63
  renderProps,
63
64
  singleRow = "default",
65
+ horizontal,
64
66
  ...rest
65
67
  } = field;
66
68
 
69
+ // Horizontal or not
70
+ isHorizontal = horizontal;
71
+
67
72
  // Size
68
73
  size = getResp(singleRow);
69
74
 
@@ -96,7 +101,7 @@ function getItemField<T extends object>(
96
101
  gridProps = { size };
97
102
  }
98
103
 
99
- return [itemData, itemLabel, gridProps, size];
104
+ return [itemData, itemLabel, gridProps, size, isHorizontal];
100
105
  }
101
106
 
102
107
  function getItemSize(bp: Breakpoint, size: ViewPageItemSize) {
@@ -180,6 +185,7 @@ export type ViewPageGridItemProps = GridProps & {
180
185
  data: React.ReactNode;
181
186
  label?: React.ReactNode;
182
187
  singleRow?: ViewPageRowType;
188
+ horizontal?: boolean;
183
189
  };
184
190
 
185
191
  /**
@@ -189,7 +195,7 @@ export type ViewPageGridItemProps = GridProps & {
189
195
  */
190
196
  export function ViewPageGridItem(props: ViewPageGridItemProps) {
191
197
  // Destruct
192
- const { data, label, singleRow, ...gridProps } = props;
198
+ const { data, label, singleRow, horizontal = false, ...gridProps } = props;
193
199
 
194
200
  // Default options
195
201
  let options = {};
@@ -203,12 +209,16 @@ export function ViewPageGridItem(props: ViewPageGridItemProps) {
203
209
  return (
204
210
  <Grid {...gridProps} {...options}>
205
211
  {label != null && (
206
- <Typography variant="caption" component="div">
212
+ <Typography variant="caption" component={horizontal ? "span" : "div"}>
207
213
  {label}:
208
214
  </Typography>
209
215
  )}
210
216
  {typeof data === "object" ? (
211
217
  data
218
+ ) : horizontal ? (
219
+ <Typography variant="subtitle2" component="span" marginLeft={0.5}>
220
+ {data}
221
+ </Typography>
212
222
  ) : (
213
223
  <Typography variant="subtitle2">{data}</Typography>
214
224
  )}
@@ -240,6 +250,11 @@ export interface ViewPageField<T extends object> extends GridProps {
240
250
  */
241
251
  singleRow?: ViewPageRowType;
242
252
 
253
+ /**
254
+ * Render as horizontal or not
255
+ */
256
+ horizontal?: boolean;
257
+
243
258
  /**
244
259
  * Render props
245
260
  */
@@ -352,11 +367,8 @@ export function ViewContainer<T extends DataTypes.StringRecord>(
352
367
  oneItem = createdResult;
353
368
  }
354
369
  } else {
355
- const [itemData, itemLabel, gridProps, size] = getItemField(
356
- app,
357
- field,
358
- data
359
- );
370
+ const [itemData, itemLabel, gridProps, size, horizontal] =
371
+ getItemField(app, field, data);
360
372
 
361
373
  // Some callback function may return '' instead of undefined
362
374
  if (itemData == null || itemData === "") continue;
@@ -368,6 +380,7 @@ export function ViewContainer<T extends DataTypes.StringRecord>(
368
380
  key={i}
369
381
  data={itemData}
370
382
  label={itemLabel}
383
+ horizontal={horizontal}
371
384
  />
372
385
  );
373
386
  }