@jsonforms/material-renderers 3.1.0-alpha.1 → 3.1.0-alpha.2

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.
Files changed (123) hide show
  1. package/README.md +16 -17
  2. package/lib/additional/ListWithDetailMasterItem.d.ts +2 -0
  3. package/lib/additional/MaterialListWithDetailRenderer.d.ts +1 -1
  4. package/lib/additional/index.d.ts +2 -2
  5. package/lib/additional/unwrapped.d.ts +5 -0
  6. package/lib/cells/index.d.ts +1 -1
  7. package/lib/complex/CombinatorProperties.d.ts +1 -2
  8. package/lib/complex/DeleteDialog.d.ts +5 -1
  9. package/lib/complex/MaterialAllOfRenderer.d.ts +1 -1
  10. package/lib/complex/MaterialAnyOfRenderer.d.ts +1 -1
  11. package/lib/complex/MaterialArrayControlRenderer.d.ts +2 -1
  12. package/lib/complex/MaterialEnumArrayRenderer.d.ts +1 -1
  13. package/lib/complex/MaterialObjectRenderer.d.ts +1 -1
  14. package/lib/complex/MaterialOneOfRenderer.d.ts +1 -1
  15. package/lib/complex/MaterialTableControl.d.ts +4 -2
  16. package/lib/complex/NoBorderTableCell.d.ts +2 -2
  17. package/lib/complex/TableToolbar.d.ts +3 -2
  18. package/lib/complex/index.d.ts +11 -16
  19. package/lib/complex/unwrapped.d.ts +9 -0
  20. package/lib/controls/MaterialBooleanControl.d.ts +1 -1
  21. package/lib/controls/MaterialBooleanToggleControl.d.ts +1 -1
  22. package/lib/controls/index.d.ts +8 -26
  23. package/lib/controls/unwrapped.d.ts +19 -0
  24. package/lib/index.d.ts +34 -1
  25. package/lib/jsonforms-react-material.cjs.js +690 -599
  26. package/lib/jsonforms-react-material.cjs.js.map +1 -1
  27. package/lib/jsonforms-react-material.esm.js +620 -557
  28. package/lib/jsonforms-react-material.esm.js.map +1 -1
  29. package/lib/layouts/ArrayToolbar.d.ts +3 -1
  30. package/lib/layouts/ExpandPanelRenderer.d.ts +3 -1
  31. package/lib/layouts/MaterialGroupLayout.d.ts +1 -1
  32. package/lib/layouts/MaterialHorizontalLayout.d.ts +1 -1
  33. package/lib/layouts/MaterialVerticalLayout.d.ts +1 -1
  34. package/lib/layouts/index.d.ts +3 -1
  35. package/lib/layouts/unwrapped.d.ts +10 -0
  36. package/lib/mui-controls/MuiCheckbox.d.ts +1 -1
  37. package/lib/mui-controls/MuiInputInteger.d.ts +1 -1
  38. package/lib/mui-controls/MuiInputNumber.d.ts +1 -1
  39. package/lib/mui-controls/MuiInputNumberFormat.d.ts +1 -1
  40. package/lib/mui-controls/MuiInputText.d.ts +1 -1
  41. package/lib/mui-controls/MuiInputTime.d.ts +1 -1
  42. package/lib/mui-controls/MuiSelect.d.ts +1 -1
  43. package/lib/mui-controls/MuiToggle.d.ts +1 -1
  44. package/lib/mui-controls/index.d.ts +3 -1
  45. package/lib/util/layout.d.ts +2 -3
  46. package/package.json +16 -9
  47. package/src/additional/ListWithDetailMasterItem.tsx +31 -23
  48. package/src/additional/MaterialLabelRenderer.tsx +8 -15
  49. package/src/additional/MaterialListWithDetailRenderer.tsx +8 -5
  50. package/src/additional/index.ts +12 -4
  51. package/src/additional/unwrapped.ts +32 -0
  52. package/src/cells/MaterialBooleanCell.tsx +1 -1
  53. package/src/cells/MaterialBooleanToggleCell.tsx +2 -2
  54. package/src/cells/MaterialDateCell.tsx +4 -12
  55. package/src/cells/MaterialEnumCell.tsx +13 -6
  56. package/src/cells/MaterialIntegerCell.tsx +1 -1
  57. package/src/cells/MaterialNumberCell.tsx +1 -1
  58. package/src/cells/MaterialNumberFormatCell.tsx +1 -1
  59. package/src/cells/MaterialOneOfEnumCell.tsx +17 -7
  60. package/src/cells/MaterialTextCell.tsx +1 -1
  61. package/src/cells/MaterialTimeCell.tsx +1 -1
  62. package/src/cells/index.ts +7 -7
  63. package/src/complex/CombinatorProperties.tsx +20 -9
  64. package/src/complex/DeleteDialog.tsx +48 -37
  65. package/src/complex/MaterialAllOfRenderer.tsx +2 -2
  66. package/src/complex/MaterialAnyOfRenderer.tsx +3 -3
  67. package/src/complex/MaterialArrayControlRenderer.tsx +27 -11
  68. package/src/complex/MaterialEnumArrayRenderer.tsx +6 -8
  69. package/src/complex/MaterialObjectRenderer.tsx +6 -3
  70. package/src/complex/MaterialOneOfRenderer.tsx +105 -88
  71. package/src/complex/MaterialTableControl.tsx +145 -97
  72. package/src/complex/NoBorderTableCell.tsx +3 -5
  73. package/src/complex/TableToolbar.tsx +24 -25
  74. package/src/complex/ValidationIcon.tsx +10 -18
  75. package/src/complex/index.ts +35 -32
  76. package/src/complex/unwrapped.ts +39 -0
  77. package/src/controls/MaterialAnyOfStringOrEnumControl.tsx +19 -11
  78. package/src/controls/MaterialBooleanControl.tsx +22 -16
  79. package/src/controls/MaterialBooleanToggleControl.tsx +22 -16
  80. package/src/controls/MaterialDateControl.tsx +16 -19
  81. package/src/controls/MaterialDateTimeControl.tsx +24 -23
  82. package/src/controls/MaterialEnumControl.tsx +21 -15
  83. package/src/controls/MaterialInputControl.tsx +7 -8
  84. package/src/controls/MaterialIntegerControl.tsx +1 -1
  85. package/src/controls/MaterialNativeControl.tsx +12 -9
  86. package/src/controls/MaterialNumberControl.tsx +1 -1
  87. package/src/controls/MaterialOneOfEnumControl.tsx +21 -15
  88. package/src/controls/MaterialOneOfRadioGroupControl.tsx +5 -3
  89. package/src/controls/MaterialRadioGroup.tsx +11 -17
  90. package/src/controls/MaterialRadioGroupControl.tsx +8 -3
  91. package/src/controls/MaterialSliderControl.tsx +17 -16
  92. package/src/controls/MaterialTextControl.tsx +1 -1
  93. package/src/controls/MaterialTimeControl.tsx +19 -22
  94. package/src/controls/index.ts +36 -72
  95. package/src/controls/unwrapped.ts +57 -0
  96. package/src/index.ts +41 -22
  97. package/src/layouts/ArrayToolbar.tsx +38 -42
  98. package/src/layouts/ExpandPanelRenderer.tsx +96 -67
  99. package/src/layouts/MaterialArrayLayout.tsx +21 -16
  100. package/src/layouts/MaterialArrayLayoutRenderer.tsx +6 -9
  101. package/src/layouts/MaterialCategorizationLayout.tsx +52 -21
  102. package/src/layouts/MaterialCategorizationStepperLayout.tsx +60 -44
  103. package/src/layouts/MaterialGroupLayout.tsx +25 -6
  104. package/src/layouts/MaterialHorizontalLayout.tsx +18 -4
  105. package/src/layouts/MaterialVerticalLayout.tsx +18 -4
  106. package/src/layouts/index.ts +18 -7
  107. package/src/layouts/unwrapped.ts +41 -0
  108. package/src/mui-controls/MuiAutocomplete.tsx +51 -35
  109. package/src/mui-controls/MuiCheckbox.tsx +5 -3
  110. package/src/mui-controls/MuiInputInteger.tsx +31 -32
  111. package/src/mui-controls/MuiInputNumber.tsx +16 -16
  112. package/src/mui-controls/MuiInputNumberFormat.tsx +51 -42
  113. package/src/mui-controls/MuiInputText.tsx +30 -19
  114. package/src/mui-controls/MuiInputTime.tsx +11 -12
  115. package/src/mui-controls/MuiSelect.tsx +15 -6
  116. package/src/mui-controls/MuiToggle.tsx +5 -3
  117. package/src/mui-controls/index.ts +3 -1
  118. package/src/util/datejs.tsx +41 -20
  119. package/src/util/debounce.ts +26 -11
  120. package/src/util/focus.ts +7 -7
  121. package/src/util/i18nDefaults.ts +2 -2
  122. package/src/util/layout.tsx +47 -42
  123. package/src/util/theme.ts +2 -2
@@ -27,7 +27,7 @@ import union from 'lodash/union';
27
27
  import {
28
28
  DispatchCell,
29
29
  JsonFormsStateContext,
30
- useJsonForms
30
+ useJsonForms,
31
31
  } from '@jsonforms/react';
32
32
  import startCase from 'lodash/startCase';
33
33
  import range from 'lodash/range';
@@ -42,7 +42,7 @@ import {
42
42
  TableCell,
43
43
  TableHead,
44
44
  TableRow,
45
- Typography
45
+ Typography,
46
46
  } from '@mui/material';
47
47
  import {
48
48
  ArrayLayoutProps,
@@ -54,7 +54,8 @@ import {
54
54
  Resolve,
55
55
  JsonFormsRendererRegistryEntry,
56
56
  JsonFormsCellRendererRegistryEntry,
57
- encode
57
+ encode,
58
+ ArrayTranslations,
58
59
  } from '@jsonforms/core';
59
60
  import DeleteIcon from '@mui/icons-material/Delete';
60
61
  import ArrowDownward from '@mui/icons-material/ArrowDownward';
@@ -73,15 +74,15 @@ const styles = {
73
74
  height: '50px',
74
75
  paddingLeft: 0,
75
76
  paddingRight: 0,
76
- textAlign: 'center'
77
+ textAlign: 'center',
77
78
  },
78
79
  fixedCellSmall: {
79
80
  width: '50px',
80
81
  height: '50px',
81
82
  paddingLeft: 0,
82
83
  paddingRight: 0,
83
- textAlign: 'center'
84
- }
84
+ textAlign: 'center',
85
+ },
85
86
  };
86
87
 
87
88
  const generateCells = (
@@ -92,7 +93,7 @@ const generateCells = (
92
93
  cells?: JsonFormsCellRendererRegistryEntry[]
93
94
  ) => {
94
95
  if (schema.type === 'object') {
95
- return getValidColumnProps(schema).map(prop => {
96
+ return getValidColumnProps(schema).map((prop) => {
96
97
  const cellPath = Paths.compose(rowPath, prop);
97
98
  const props = {
98
99
  propName: prop,
@@ -101,7 +102,7 @@ const generateCells = (
101
102
  rowPath,
102
103
  cellPath,
103
104
  enabled,
104
- cells
105
+ cells,
105
106
  };
106
107
  return <Cell key={cellPath} {...props} />;
107
108
  });
@@ -111,16 +112,19 @@ const generateCells = (
111
112
  schema,
112
113
  rowPath,
113
114
  cellPath: rowPath,
114
- enabled
115
+ enabled,
115
116
  };
116
117
  return <Cell key={rowPath} {...props} />;
117
118
  }
118
119
  };
119
120
 
120
121
  const getValidColumnProps = (scopedSchema: JsonSchema) => {
121
- if (scopedSchema.type === 'object' && typeof scopedSchema.properties === 'object') {
122
+ if (
123
+ scopedSchema.type === 'object' &&
124
+ typeof scopedSchema.properties === 'object'
125
+ ) {
122
126
  return Object.keys(scopedSchema.properties).filter(
123
- prop => scopedSchema.properties[prop].type !== 'array'
127
+ (prop) => scopedSchema.properties[prop].type !== 'array'
124
128
  );
125
129
  }
126
130
  // primitives
@@ -129,12 +133,13 @@ const getValidColumnProps = (scopedSchema: JsonSchema) => {
129
133
 
130
134
  export interface EmptyTableProps {
131
135
  numColumns: number;
136
+ translations: ArrayTranslations;
132
137
  }
133
138
 
134
- const EmptyTable = ({ numColumns }: EmptyTableProps) => (
139
+ const EmptyTable = ({ numColumns, translations }: EmptyTableProps) => (
135
140
  <TableRow>
136
141
  <NoBorderTableCell colSpan={numColumns}>
137
- <Typography align='center'>No data</Typography>
142
+ <Typography align='center'>{translations.noDataMessage}</Typography>
138
143
  </NoBorderTableCell>
139
144
  </TableRow>
140
145
  );
@@ -143,9 +148,11 @@ interface TableHeaderCellProps {
143
148
  title: string;
144
149
  }
145
150
 
146
- const TableHeaderCell = React.memo(({ title }: TableHeaderCellProps) => (
147
- <TableCell>{title}</TableCell>
148
- ));
151
+ const TableHeaderCell = React.memo(function TableHeaderCell({
152
+ title,
153
+ }: TableHeaderCellProps) {
154
+ return <TableCell>{title}</TableCell>;
155
+ });
149
156
 
150
157
  interface NonEmptyCellProps extends OwnPropsOfNonEmptyCell {
151
158
  rootSchema: JsonSchema;
@@ -173,7 +180,7 @@ const ctxToNonEmptyCellProps = (
173
180
  errorsAt(
174
181
  path,
175
182
  ownProps.schema,
176
- p => p === path
183
+ (p) => p === path
177
184
  )(ctx.core.errors).map((error: ErrorObject) => error.message)
178
185
  )
179
186
  );
@@ -186,28 +193,38 @@ const ctxToNonEmptyCellProps = (
186
193
  path,
187
194
  enabled: ownProps.enabled,
188
195
  cells: ownProps.cells || ctx.cells,
189
- renderers: ownProps.renderers || ctx.renderers
196
+ renderers: ownProps.renderers || ctx.renderers,
190
197
  };
191
198
  };
192
199
 
193
200
  const controlWithoutLabel = (scope: string): ControlElement => ({
194
201
  type: 'Control',
195
202
  scope: scope,
196
- label: false
203
+ label: false,
197
204
  });
198
205
 
199
206
  interface NonEmptyCellComponentProps {
200
- path: string,
201
- propName?: string,
202
- schema: JsonSchema,
203
- rootSchema: JsonSchema,
204
- errors: string,
205
- enabled: boolean,
206
- renderers?: JsonFormsRendererRegistryEntry[],
207
- cells?: JsonFormsCellRendererRegistryEntry[],
208
- isValid: boolean
207
+ path: string;
208
+ propName?: string;
209
+ schema: JsonSchema;
210
+ rootSchema: JsonSchema;
211
+ errors: string;
212
+ enabled: boolean;
213
+ renderers?: JsonFormsRendererRegistryEntry[];
214
+ cells?: JsonFormsCellRendererRegistryEntry[];
215
+ isValid: boolean;
209
216
  }
210
- const NonEmptyCellComponent = React.memo(({path, propName, schema, rootSchema, errors, enabled, renderers, cells, isValid}:NonEmptyCellComponentProps) => {
217
+ const NonEmptyCellComponent = React.memo(function NonEmptyCellComponent({
218
+ path,
219
+ propName,
220
+ schema,
221
+ rootSchema,
222
+ errors,
223
+ enabled,
224
+ renderers,
225
+ cells,
226
+ isValid,
227
+ }: NonEmptyCellComponentProps) {
211
228
  return (
212
229
  <NoBorderTableCell>
213
230
  {schema.properties ? (
@@ -243,85 +260,99 @@ const NonEmptyCell = (ownProps: OwnPropsOfNonEmptyCell) => {
243
260
  const emptyCellProps = ctxToNonEmptyCellProps(ctx, ownProps);
244
261
 
245
262
  const isValid = isEmpty(emptyCellProps.errors);
246
- return <NonEmptyCellComponent {...emptyCellProps} isValid={isValid}/>
263
+ return <NonEmptyCellComponent {...emptyCellProps} isValid={isValid} />;
247
264
  };
248
265
 
249
266
  interface NonEmptyRowProps {
250
267
  childPath: string;
251
268
  schema: JsonSchema;
252
269
  rowIndex: number;
253
- moveUpCreator: (path:string, position: number)=> ()=> void;
254
- moveDownCreator: (path:string, position: number)=> ()=> void;
270
+ moveUpCreator: (path: string, position: number) => () => void;
271
+ moveDownCreator: (path: string, position: number) => () => void;
255
272
  enableUp: boolean;
256
273
  enableDown: boolean;
257
274
  showSortButtons: boolean;
258
275
  enabled: boolean;
259
276
  cells?: JsonFormsCellRendererRegistryEntry[];
260
277
  path: string;
278
+ translations: ArrayTranslations;
261
279
  }
262
280
 
263
- const NonEmptyRowComponent =
264
- ({
265
- childPath,
266
- schema,
267
- rowIndex,
268
- openDeleteDialog,
269
- moveUpCreator,
270
- moveDownCreator,
271
- enableUp,
272
- enableDown,
273
- showSortButtons,
274
- enabled,
275
- cells,
276
- path
277
- }: NonEmptyRowProps & WithDeleteDialogSupport) => {
278
- const moveUp = useMemo(() => moveUpCreator(path, rowIndex),[moveUpCreator, path, rowIndex]);
279
- const moveDown = useMemo(() => moveDownCreator(path, rowIndex),[moveDownCreator, path, rowIndex]);
280
- return (
281
- <TableRow key={childPath} hover>
282
- {generateCells(NonEmptyCell, schema, childPath, enabled, cells)}
283
- {enabled ? (
284
- <NoBorderTableCell
285
- style={showSortButtons ? styles.fixedCell : styles.fixedCellSmall}
281
+ const NonEmptyRowComponent = ({
282
+ childPath,
283
+ schema,
284
+ rowIndex,
285
+ openDeleteDialog,
286
+ moveUpCreator,
287
+ moveDownCreator,
288
+ enableUp,
289
+ enableDown,
290
+ showSortButtons,
291
+ enabled,
292
+ cells,
293
+ path,
294
+ translations,
295
+ }: NonEmptyRowProps & WithDeleteDialogSupport) => {
296
+ const moveUp = useMemo(
297
+ () => moveUpCreator(path, rowIndex),
298
+ [moveUpCreator, path, rowIndex]
299
+ );
300
+ const moveDown = useMemo(
301
+ () => moveDownCreator(path, rowIndex),
302
+ [moveDownCreator, path, rowIndex]
303
+ );
304
+ return (
305
+ <TableRow key={childPath} hover>
306
+ {generateCells(NonEmptyCell, schema, childPath, enabled, cells)}
307
+ {enabled ? (
308
+ <NoBorderTableCell
309
+ style={showSortButtons ? styles.fixedCell : styles.fixedCellSmall}
310
+ >
311
+ <Grid
312
+ container
313
+ direction='row'
314
+ justifyContent='flex-end'
315
+ alignItems='center'
286
316
  >
287
- <Grid
288
- container
289
- direction='row'
290
- justifyContent='flex-end'
291
- alignItems='center'
292
- >
293
- {showSortButtons ? (
294
- <Fragment>
295
- <Grid item>
296
- <IconButton aria-label={`Move up`} onClick={moveUp} disabled={!enableUp} size='large'>
297
- <ArrowUpward />
298
- </IconButton>
299
- </Grid>
300
- <Grid item>
301
- <IconButton
302
- aria-label={`Move down`}
303
- onClick={moveDown}
304
- disabled={!enableDown}
305
- size='large'>
306
- <ArrowDownward />
307
- </IconButton>
308
- </Grid>
309
- </Fragment>
310
- ) : null}
311
- <Grid item>
312
- <IconButton
313
- aria-label={`Delete`}
314
- onClick={() => openDeleteDialog(childPath, rowIndex)}
315
- size='large'>
316
- <DeleteIcon />
317
- </IconButton>
318
- </Grid>
317
+ {showSortButtons ? (
318
+ <Fragment>
319
+ <Grid item>
320
+ <IconButton
321
+ aria-label={translations.upAriaLabel}
322
+ onClick={moveUp}
323
+ disabled={!enableUp}
324
+ size='large'
325
+ >
326
+ <ArrowUpward />
327
+ </IconButton>
328
+ </Grid>
329
+ <Grid item>
330
+ <IconButton
331
+ aria-label={translations.downAriaLabel}
332
+ onClick={moveDown}
333
+ disabled={!enableDown}
334
+ size='large'
335
+ >
336
+ <ArrowDownward />
337
+ </IconButton>
338
+ </Grid>
339
+ </Fragment>
340
+ ) : null}
341
+ <Grid item>
342
+ <IconButton
343
+ aria-label={translations.removeAriaLabel}
344
+ onClick={() => openDeleteDialog(childPath, rowIndex)}
345
+ size='large'
346
+ >
347
+ <DeleteIcon />
348
+ </IconButton>
319
349
  </Grid>
320
- </NoBorderTableCell>
321
- ) : null}
322
- </TableRow>
323
- );
324
- };
350
+ </Grid>
351
+ </NoBorderTableCell>
352
+ ) : null}
353
+ </TableRow>
354
+ );
355
+ };
325
356
  export const NonEmptyRow = React.memo(NonEmptyRowComponent);
326
357
  interface TableRowsProp {
327
358
  data: number;
@@ -333,6 +364,7 @@ interface TableRowsProp {
333
364
  cells?: JsonFormsCellRendererRegistryEntry[];
334
365
  moveUp?(path: string, toMove: number): () => void;
335
366
  moveDown?(path: string, toMove: number): () => void;
367
+ translations: ArrayTranslations;
336
368
  }
337
369
  const TableRows = ({
338
370
  data,
@@ -344,12 +376,18 @@ const TableRows = ({
344
376
  uischema,
345
377
  config,
346
378
  enabled,
347
- cells
379
+ cells,
380
+ translations,
348
381
  }: TableRowsProp & WithDeleteDialogSupport) => {
349
382
  const isEmptyTable = data === 0;
350
383
 
351
384
  if (isEmptyTable) {
352
- return <EmptyTable numColumns={getValidColumnProps(schema).length + 1} />;
385
+ return (
386
+ <EmptyTable
387
+ numColumns={getValidColumnProps(schema).length + 1}
388
+ translations={translations}
389
+ />
390
+ );
353
391
  }
354
392
 
355
393
  const appliedUiSchemaOptions = merge({}, config, uischema.options);
@@ -370,10 +408,14 @@ const TableRows = ({
370
408
  moveDownCreator={moveDown}
371
409
  enableUp={index !== 0}
372
410
  enableDown={index !== data - 1}
373
- showSortButtons={appliedUiSchemaOptions.showSortButtons || appliedUiSchemaOptions.showArrayTableSortButtons}
411
+ showSortButtons={
412
+ appliedUiSchemaOptions.showSortButtons ||
413
+ appliedUiSchemaOptions.showArrayTableSortButtons
414
+ }
374
415
  enabled={enabled}
375
416
  cells={cells}
376
417
  path={path}
418
+ translations={translations}
377
419
  />
378
420
  );
379
421
  })}
@@ -397,7 +439,8 @@ export class MaterialTableControl extends React.Component<
397
439
  openDeleteDialog,
398
440
  visible,
399
441
  enabled,
400
- cells
442
+ cells,
443
+ translations,
401
444
  } = this.props;
402
445
 
403
446
  const controlElement = uischema as ControlElement;
@@ -420,6 +463,7 @@ export class MaterialTableControl extends React.Component<
420
463
  schema={schema}
421
464
  rootSchema={rootSchema}
422
465
  enabled={enabled}
466
+ translations={translations}
423
467
  />
424
468
  {isObjectSchema && (
425
469
  <TableRow>
@@ -429,7 +473,11 @@ export class MaterialTableControl extends React.Component<
429
473
  )}
430
474
  </TableHead>
431
475
  <TableBody>
432
- <TableRows openDeleteDialog={openDeleteDialog} {...this.props} />
476
+ <TableRows
477
+ openDeleteDialog={openDeleteDialog}
478
+ translations={translations}
479
+ {...this.props}
480
+ />
433
481
  </TableBody>
434
482
  </Table>
435
483
  </Hidden>
@@ -27,13 +27,11 @@ import { TableCell } from '@mui/material';
27
27
  import React from 'react';
28
28
 
29
29
  const StyledTableCell = styled(TableCell)({
30
- borderBottom: 'none'
30
+ borderBottom: 'none',
31
31
  });
32
32
 
33
33
  const NoBorderTableCell = ({ children, ...otherProps }: any) => (
34
- <StyledTableCell {...otherProps}>
35
- {children}
36
- </StyledTableCell>
34
+ <StyledTableCell {...otherProps}>{children}</StyledTableCell>
37
35
  );
38
36
 
39
- export default (NoBorderTableCell);
37
+ export default NoBorderTableCell;
@@ -27,13 +27,9 @@ import {
27
27
  ControlElement,
28
28
  createDefaultValue,
29
29
  JsonSchema,
30
+ ArrayTranslations,
30
31
  } from '@jsonforms/core';
31
- import {
32
- IconButton,
33
- TableRow,
34
- Tooltip
35
- } from '@mui/material';
36
- import { Grid, Typography } from '@mui/material';
32
+ import { IconButton, TableRow, Tooltip, Grid, Typography } from '@mui/material';
37
33
  import AddIcon from '@mui/icons-material/Add';
38
34
  import ValidationIcon from './ValidationIcon';
39
35
  import NoBorderTableCell from './NoBorderTableCell';
@@ -47,24 +43,26 @@ export interface MaterialTableToolbarProps {
47
43
  schema: JsonSchema;
48
44
  rootSchema: JsonSchema;
49
45
  enabled: boolean;
46
+ translations: ArrayTranslations;
50
47
  addItem(path: string, value: any): () => void;
51
48
  }
52
49
 
53
50
  const fixedCellSmall = {
54
51
  paddingLeft: 0,
55
52
  paddingRight: 0,
56
- }
53
+ };
57
54
 
58
- const TableToolbar = React.memo(
59
- ({
60
- numColumns,
61
- errors,
62
- label,
63
- path,
64
- addItem,
65
- schema,
66
- enabled
67
- }: MaterialTableToolbarProps) => (
55
+ const TableToolbar = React.memo(function TableToolbar({
56
+ numColumns,
57
+ errors,
58
+ label,
59
+ path,
60
+ addItem,
61
+ schema,
62
+ enabled,
63
+ translations,
64
+ }: MaterialTableToolbarProps) {
65
+ return (
68
66
  <TableRow>
69
67
  <NoBorderTableCell colSpan={numColumns}>
70
68
  <Grid
@@ -77,35 +75,36 @@ const TableToolbar = React.memo(
77
75
  <Typography variant={'h6'}>{label}</Typography>
78
76
  </Grid>
79
77
  <Grid item>
80
- {errors.length !== 0 &&
78
+ {errors.length !== 0 && (
81
79
  <Grid item>
82
80
  <ValidationIcon
83
81
  id='tooltip-validation'
84
82
  errorMessages={errors}
85
83
  />
86
84
  </Grid>
87
- }
85
+ )}
88
86
  </Grid>
89
87
  </Grid>
90
88
  </NoBorderTableCell>
91
89
  {enabled ? (
92
- <NoBorderTableCell align='right' style={ fixedCellSmall }>
90
+ <NoBorderTableCell align='right' style={fixedCellSmall}>
93
91
  <Tooltip
94
92
  id='tooltip-add'
95
- title={`Add to ${label}`}
93
+ title={translations.addTooltip}
96
94
  placement='bottom'
97
95
  >
98
96
  <IconButton
99
- aria-label={`Add to ${label}`}
97
+ aria-label={translations.addAriaLabel}
100
98
  onClick={addItem(path, createDefaultValue(schema))}
101
- size='large'>
99
+ size='large'
100
+ >
102
101
  <AddIcon />
103
102
  </IconButton>
104
103
  </Tooltip>
105
104
  </NoBorderTableCell>
106
105
  ) : null}
107
106
  </TableRow>
108
- )
109
- );
107
+ );
108
+ });
110
109
 
111
110
  export default TableToolbar;
@@ -25,14 +25,10 @@
25
25
  import React from 'react';
26
26
 
27
27
  import ErrorOutlineIcon from '@mui/icons-material/ErrorOutline';
28
- import {
29
- Badge,
30
- Tooltip,
31
- styled
32
- } from '@mui/material';
28
+ import { Badge, Tooltip, styled } from '@mui/material';
33
29
 
34
30
  const StyledBadge = styled(Badge)(({ theme }: any) => ({
35
- color: theme.palette.error.main
31
+ color: theme.palette.error.main,
36
32
  }));
37
33
 
38
34
  export interface ValidationProps {
@@ -40,18 +36,14 @@ export interface ValidationProps {
40
36
  id: string;
41
37
  }
42
38
 
43
- const ValidationIcon: React.FC<ValidationProps> =
44
- ({ errorMessages, id }) => {
45
- return (
46
- <Tooltip
47
- id={id}
48
- title={errorMessages}
49
- >
50
- <StyledBadge badgeContent={errorMessages.split('\n').length}>
51
- <ErrorOutlineIcon color='inherit'/>
52
- </StyledBadge>
53
- </Tooltip>
54
- );
39
+ const ValidationIcon: React.FC<ValidationProps> = ({ errorMessages, id }) => {
40
+ return (
41
+ <Tooltip id={id} title={errorMessages}>
42
+ <StyledBadge badgeContent={errorMessages.split('\n').length}>
43
+ <ErrorOutlineIcon color='inherit' />
44
+ </StyledBadge>
45
+ </Tooltip>
46
+ );
55
47
  };
56
48
 
57
49
  export default ValidationIcon;
@@ -22,42 +22,45 @@
22
22
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
23
  THE SOFTWARE.
24
24
  */
25
- import {
26
- isObjectArrayControl,
27
- isPrimitiveArrayControl,
28
- or,
29
- RankedTester,
30
- rankWith
31
- } from '@jsonforms/core';
32
- import MaterialArrayControlRenderer from './MaterialArrayControlRenderer';
33
- import MaterialObjectRenderer, {
34
- materialObjectControlTester
35
- } from './MaterialObjectRenderer';
36
25
  import MaterialAllOfRenderer, {
37
- materialAllOfControlTester
26
+ materialAllOfControlTester,
38
27
  } from './MaterialAllOfRenderer';
39
28
  import MaterialAnyOfRenderer, {
40
- materialAnyOfControlTester
29
+ materialAnyOfControlTester,
41
30
  } from './MaterialAnyOfRenderer';
42
- import MaterialOneOfRenderer, {
43
- materialOneOfControlTester
44
- } from './MaterialOneOfRenderer';
31
+ import MaterialArrayControlRenderer, {
32
+ materialArrayControlTester,
33
+ } from './MaterialArrayControlRenderer';
45
34
  import MaterialEnumArrayRenderer, {
46
- materialEnumArrayRendererTester
35
+ materialEnumArrayRendererTester,
47
36
  } from './MaterialEnumArrayRenderer';
37
+ import MaterialObjectRenderer, {
38
+ materialObjectControlTester,
39
+ } from './MaterialObjectRenderer';
40
+ import MaterialOneOfRenderer, {
41
+ materialOneOfControlTester,
42
+ } from './MaterialOneOfRenderer';
43
+
44
+ export {
45
+ materialAllOfControlTester,
46
+ MaterialAllOfRenderer,
47
+ materialAnyOfControlTester,
48
+ MaterialAnyOfRenderer,
49
+ materialArrayControlTester,
50
+ MaterialArrayControlRenderer,
51
+ materialEnumArrayRendererTester,
52
+ MaterialEnumArrayRenderer,
53
+ materialObjectControlTester,
54
+ MaterialObjectRenderer,
55
+ materialOneOfControlTester,
56
+ MaterialOneOfRenderer,
57
+ };
58
+
59
+ export * from './CombinatorProperties';
60
+ export * from './DeleteDialog';
61
+ export * from './MaterialTableControl';
62
+ export * from './TableToolbar';
63
+ export * from './ValidationIcon';
48
64
 
49
- export const materialArrayControlTester: RankedTester = rankWith(
50
- 3,
51
- or(isObjectArrayControl, isPrimitiveArrayControl)
52
- );
53
- export { MaterialArrayControlRenderer };
54
- export { MaterialObjectRenderer };
55
- export { MaterialAllOfRenderer };
56
- export { MaterialAnyOfRenderer };
57
- export { MaterialOneOfRenderer };
58
- export { MaterialEnumArrayRenderer };
59
- export { materialObjectControlTester };
60
- export { materialAllOfControlTester };
61
- export { materialAnyOfControlTester };
62
- export { materialOneOfControlTester };
63
- export { materialEnumArrayRendererTester };
65
+ import NoBorderTableCell from './NoBorderTableCell';
66
+ export { NoBorderTableCell };