@jsonforms/material-renderers 3.3.0 → 3.4.0-alpha.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.
@@ -9,5 +9,6 @@ export interface ArrayLayoutToolbarProps {
9
9
  addItem(path: string, data: any): () => void;
10
10
  createDefault(): any;
11
11
  translations: ArrayTranslations;
12
+ disableAdd?: boolean;
12
13
  }
13
14
  export declare const ArrayLayoutToolbar: React.NamedExoticComponent<ArrayLayoutToolbarProps>;
@@ -18,6 +18,7 @@ interface OwnPropsOfExpandPanel {
18
18
  childLabelProp?: string;
19
19
  handleExpansion(panel: string): (event: any, expanded: boolean) => void;
20
20
  translations: ArrayTranslations;
21
+ disableRemove?: boolean;
21
22
  }
22
23
  interface StatePropsOfExpandPanel extends OwnPropsOfExpandPanel {
23
24
  childLabel: string;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
2
  import { EnumCellProps, WithClassname } from '@jsonforms/core';
3
3
  import { TranslateProps } from '@jsonforms/react';
4
- import { WithInputProps } from '../util';
5
- export declare const MuiSelect: React.NamedExoticComponent<EnumCellProps & WithClassname & TranslateProps & WithInputProps>;
4
+ import { WithInputProps, WithSelectProps } from '../util';
5
+ export declare const MuiSelect: React.NamedExoticComponent<EnumCellProps & WithClassname & TranslateProps & WithInputProps & WithSelectProps>;
@@ -12,6 +12,9 @@ export interface JsonFormsTheme extends Theme {
12
12
  export interface WithInputProps {
13
13
  label?: string;
14
14
  }
15
+ export interface WithSelectProps {
16
+ multiple?: boolean;
17
+ }
15
18
  export declare const defaultInputVariant: TextFieldProps['variant'];
16
19
  export declare function useInputVariant(): TextFieldProps['variant'];
17
20
  export declare function useInputComponent(): React.JSXElementConstructor<InputBaseProps & WithInputProps>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsonforms/material-renderers",
3
- "version": "3.3.0",
3
+ "version": "3.4.0-alpha.1",
4
4
  "description": "Material Renderer Set for JSON Forms",
5
5
  "repository": "https://github.com/eclipsesource/jsonforms",
6
6
  "bugs": "https://github.com/eclipsesource/jsonforms/issues",
@@ -73,11 +73,11 @@
73
73
  "peerDependencies": {
74
74
  "@emotion/react": "^11.4.1",
75
75
  "@emotion/styled": "^11.3.0",
76
- "@jsonforms/core": "3.3.0",
77
- "@jsonforms/react": "3.3.0",
76
+ "@jsonforms/core": "3.4.0-alpha.1",
77
+ "@jsonforms/react": "3.4.0-alpha.1",
78
78
  "@mui/icons-material": "^5.11.16",
79
79
  "@mui/material": "^5.13.0",
80
- "@mui/x-date-pickers": "^6.0.0",
80
+ "@mui/x-date-pickers": "^6.0.0 || ^7.0.0",
81
81
  "react": "^16.12.0 || ^17.0.0 || ^18.0.0"
82
82
  },
83
83
  "devDependencies": {
@@ -85,7 +85,7 @@
85
85
  "@emotion/styled": "^11.3.0",
86
86
  "@mui/icons-material": "^5.11.16",
87
87
  "@mui/material": "~5.13.0",
88
- "@mui/x-date-pickers": "^6.5.0",
88
+ "@mui/x-date-pickers": "^7.7.1",
89
89
  "@rollup/plugin-commonjs": "^23.0.3",
90
90
  "@rollup/plugin-json": "^5.0.2",
91
91
  "@rollup/plugin-node-resolve": "^15.0.1",
@@ -126,8 +126,8 @@
126
126
  "webpack": "^5.78.0",
127
127
  "webpack-cli": "^5.1.4",
128
128
  "webpack-dev-server": "^4.15.1",
129
- "@jsonforms/core": "3.3.0",
130
- "@jsonforms/react": "3.3.0"
129
+ "@jsonforms/react": "3.4.0-alpha.1",
130
+ "@jsonforms/core": "3.4.0-alpha.1"
131
131
  },
132
132
  "scripts": {
133
133
  "build": "rollup -c rollup.config.js",
@@ -33,7 +33,7 @@ import {
33
33
  ListItemText,
34
34
  Tooltip,
35
35
  } from '@mui/material';
36
- import { Delete as DeleteIcon } from '@mui/icons-material';
36
+ import DeleteIcon from '@mui/icons-material/Delete';
37
37
  import React from 'react';
38
38
 
39
39
  export const ListWithDetailMasterItem = ({
@@ -45,6 +45,7 @@ export const ListWithDetailMasterItem = ({
45
45
  removeItem,
46
46
  path,
47
47
  translations,
48
+ disableRemove,
48
49
  }: StatePropsOfMasterItem) => {
49
50
  return (
50
51
  <ListItem button selected={selected} onClick={handleSelect(index)}>
@@ -52,7 +53,7 @@ export const ListWithDetailMasterItem = ({
52
53
  <Avatar aria-label='Index'>{index + 1}</Avatar>
53
54
  </ListItemAvatar>
54
55
  <ListItemText primary={childLabel} />
55
- {enabled && (
56
+ {enabled && !disableRemove && (
56
57
  <ListItemSecondaryAction>
57
58
  <Tooltip
58
59
  id='tooltip-remove'
@@ -65,6 +65,8 @@ export const MaterialListWithDetailRenderer = ({
65
65
  rootSchema,
66
66
  translations,
67
67
  description,
68
+ disableAdd,
69
+ disableRemove,
68
70
  }: ArrayLayoutProps) => {
69
71
  const [selectedIndex, setSelectedIndex] = useState(undefined);
70
72
  const handleRemoveItem = useCallback(
@@ -100,6 +102,8 @@ export const MaterialListWithDetailRenderer = ({
100
102
  [uischemas, schema, uischema.scope, path, uischema, rootSchema]
101
103
  );
102
104
  const appliedUiSchemaOptions = merge({}, config, uischema.options);
105
+ const doDisableAdd = disableAdd || appliedUiSchemaOptions.disableAdd;
106
+ const doDisableRemove = disableRemove || appliedUiSchemaOptions.disableRemove;
103
107
 
104
108
  React.useEffect(() => {
105
109
  setSelectedIndex(undefined);
@@ -124,6 +128,7 @@ export const MaterialListWithDetailRenderer = ({
124
128
  enabled={enabled}
125
129
  addItem={addItem}
126
130
  createDefault={handleCreateDefaultValue}
131
+ disableAdd={doDisableAdd}
127
132
  />
128
133
  <Grid container direction='row' spacing={2}>
129
134
  <Grid item xs={3}>
@@ -142,6 +147,7 @@ export const MaterialListWithDetailRenderer = ({
142
147
  uischema={foundUISchema}
143
148
  childLabelProp={appliedUiSchemaOptions.elementLabelProp}
144
149
  translations={translations}
150
+ disableRemove={doDisableRemove}
145
151
  />
146
152
  ))
147
153
  ) : (
@@ -57,11 +57,9 @@ import {
57
57
  encode,
58
58
  ArrayTranslations,
59
59
  } from '@jsonforms/core';
60
- import {
61
- Delete as DeleteIcon,
62
- ArrowDownward,
63
- ArrowUpward,
64
- } from '@mui/icons-material';
60
+ import DeleteIcon from '@mui/icons-material/Delete';
61
+ import ArrowDownward from '@mui/icons-material/ArrowDownward';
62
+ import ArrowUpward from '@mui/icons-material/ArrowUpward';
65
63
 
66
64
  import { WithDeleteDialogSupport } from './DeleteDialog';
67
65
  import NoBorderTableCell from './NoBorderTableCell';
@@ -278,6 +276,7 @@ interface NonEmptyRowProps {
278
276
  cells?: JsonFormsCellRendererRegistryEntry[];
279
277
  path: string;
280
278
  translations: ArrayTranslations;
279
+ disableRemove?: boolean;
281
280
  }
282
281
 
283
282
  const NonEmptyRowComponent = ({
@@ -294,6 +293,7 @@ const NonEmptyRowComponent = ({
294
293
  cells,
295
294
  path,
296
295
  translations,
296
+ disableRemove,
297
297
  }: NonEmptyRowProps & WithDeleteDialogSupport) => {
298
298
  const moveUp = useMemo(
299
299
  () => moveUpCreator(path, rowIndex),
@@ -354,21 +354,23 @@ const NonEmptyRowComponent = ({
354
354
  </Grid>
355
355
  </Fragment>
356
356
  ) : null}
357
- <Grid item>
358
- <Tooltip
359
- id='tooltip-remove'
360
- title={translations.removeTooltip}
361
- placement='bottom'
362
- >
363
- <IconButton
364
- aria-label={translations.removeAriaLabel}
365
- onClick={() => openDeleteDialog(childPath, rowIndex)}
366
- size='large'
357
+ {!disableRemove ? (
358
+ <Grid item>
359
+ <Tooltip
360
+ id='tooltip-remove'
361
+ title={translations.removeTooltip}
362
+ placement='bottom'
367
363
  >
368
- <DeleteIcon />
369
- </IconButton>
370
- </Tooltip>
371
- </Grid>
364
+ <IconButton
365
+ aria-label={translations.removeAriaLabel}
366
+ onClick={() => openDeleteDialog(childPath, rowIndex)}
367
+ size='large'
368
+ >
369
+ <DeleteIcon />
370
+ </IconButton>
371
+ </Tooltip>
372
+ </Grid>
373
+ ) : null}
372
374
  </Grid>
373
375
  </NoBorderTableCell>
374
376
  ) : null}
@@ -387,6 +389,7 @@ interface TableRowsProp {
387
389
  moveUp?(path: string, toMove: number): () => void;
388
390
  moveDown?(path: string, toMove: number): () => void;
389
391
  translations: ArrayTranslations;
392
+ disableRemove?: boolean;
390
393
  }
391
394
  const TableRows = ({
392
395
  data,
@@ -400,6 +403,7 @@ const TableRows = ({
400
403
  enabled,
401
404
  cells,
402
405
  translations,
406
+ disableRemove,
403
407
  }: TableRowsProp & WithDeleteDialogSupport) => {
404
408
  const isEmptyTable = data === 0;
405
409
 
@@ -438,6 +442,7 @@ const TableRows = ({
438
442
  cells={cells}
439
443
  path={path}
440
444
  translations={translations}
445
+ disableRemove={disableRemove}
441
446
  />
442
447
  );
443
448
  })}
@@ -464,8 +469,16 @@ export class MaterialTableControl extends React.Component<
464
469
  enabled,
465
470
  cells,
466
471
  translations,
472
+ disableAdd,
473
+ disableRemove,
474
+ config,
467
475
  } = this.props;
468
476
 
477
+ const appliedUiSchemaOptions = merge({}, config, uischema.options);
478
+ const doDisableAdd = disableAdd || appliedUiSchemaOptions.disableAdd;
479
+ const doDisableRemove =
480
+ disableRemove || appliedUiSchemaOptions.disableRemove;
481
+
469
482
  const controlElement = uischema as ControlElement;
470
483
  const isObjectSchema = schema.type === 'object';
471
484
  const headerCells: any = isObjectSchema
@@ -491,6 +504,7 @@ export class MaterialTableControl extends React.Component<
491
504
  rootSchema={rootSchema}
492
505
  enabled={enabled}
493
506
  translations={translations}
507
+ disableAdd={doDisableAdd}
494
508
  />
495
509
  {isObjectSchema && (
496
510
  <TableRow>
@@ -504,6 +518,7 @@ export class MaterialTableControl extends React.Component<
504
518
  openDeleteDialog={openDeleteDialog}
505
519
  translations={translations}
506
520
  {...this.props}
521
+ disableRemove={doDisableRemove}
507
522
  />
508
523
  </TableBody>
509
524
  </Table>
@@ -38,7 +38,7 @@ import {
38
38
  FormHelperText,
39
39
  Stack,
40
40
  } from '@mui/material';
41
- import { Add as AddIcon } from '@mui/icons-material';
41
+ import AddIcon from '@mui/icons-material/Add';
42
42
  import ValidationIcon from './ValidationIcon';
43
43
  import NoBorderTableCell from './NoBorderTableCell';
44
44
 
@@ -54,6 +54,7 @@ export interface MaterialTableToolbarProps {
54
54
  enabled: boolean;
55
55
  translations: ArrayTranslations;
56
56
  addItem(path: string, value: any): () => void;
57
+ disableAdd?: boolean;
57
58
  }
58
59
 
59
60
  const fixedCellSmall = {
@@ -72,6 +73,7 @@ const TableToolbar = React.memo(function TableToolbar({
72
73
  enabled,
73
74
  translations,
74
75
  rootSchema,
76
+ disableAdd,
75
77
  }: MaterialTableToolbarProps) {
76
78
  return (
77
79
  <TableRow>
@@ -100,7 +102,7 @@ const TableToolbar = React.memo(function TableToolbar({
100
102
  {description && <FormHelperText>{description}</FormHelperText>}
101
103
  </Stack>
102
104
  </NoBorderTableCell>
103
- {enabled ? (
105
+ {enabled && !disableAdd ? (
104
106
  <NoBorderTableCell align='right' style={fixedCellSmall}>
105
107
  <Tooltip
106
108
  id='tooltip-add'
@@ -24,7 +24,7 @@
24
24
  */
25
25
  import React from 'react';
26
26
 
27
- import { ErrorOutline as ErrorOutlineIcon } from '@mui/icons-material';
27
+ import ErrorOutlineIcon from '@mui/icons-material/ErrorOutline';
28
28
  import { Badge, Tooltip, styled } from '@mui/material';
29
29
 
30
30
  const StyledBadge = styled(Badge)(({ theme }: any) => ({
@@ -20,6 +20,7 @@ export interface ArrayLayoutToolbarProps {
20
20
  addItem(path: string, data: any): () => void;
21
21
  createDefault(): any;
22
22
  translations: ArrayTranslations;
23
+ disableAdd?: boolean;
23
24
  }
24
25
  export const ArrayLayoutToolbar = React.memo(function ArrayLayoutToolbar({
25
26
  label,
@@ -30,6 +31,7 @@ export const ArrayLayoutToolbar = React.memo(function ArrayLayoutToolbar({
30
31
  enabled,
31
32
  createDefault,
32
33
  translations,
34
+ disableAdd,
33
35
  }: ArrayLayoutToolbarProps) {
34
36
  return (
35
37
  <Toolbar disableGutters={true}>
@@ -57,7 +59,7 @@ export const ArrayLayoutToolbar = React.memo(function ArrayLayoutToolbar({
57
59
  </Grid>
58
60
  </Grid>
59
61
  </Grid>
60
- {enabled && (
62
+ {enabled && !disableAdd && (
61
63
  <Grid item>
62
64
  <Grid container>
63
65
  <Grid item>
@@ -29,6 +29,7 @@ import {
29
29
  removeId,
30
30
  ArrayTranslations,
31
31
  computeChildLabel,
32
+ UpdateArrayContext,
32
33
  } from '@jsonforms/core';
33
34
  import {
34
35
  Accordion,
@@ -39,12 +40,10 @@ import {
39
40
  IconButton,
40
41
  Tooltip,
41
42
  } from '@mui/material';
42
- import {
43
- ExpandMore as ExpandMoreIcon,
44
- Delete as DeleteIcon,
45
- ArrowUpward,
46
- ArrowDownward,
47
- } from '@mui/icons-material';
43
+ import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
44
+ import ArrowUpward from '@mui/icons-material/ArrowUpward';
45
+ import ArrowDownward from '@mui/icons-material/ArrowDownward';
46
+ import DeleteIcon from '@mui/icons-material/Delete';
48
47
 
49
48
  const iconStyle: any = { float: 'right' };
50
49
 
@@ -65,6 +64,7 @@ interface OwnPropsOfExpandPanel {
65
64
  childLabelProp?: string;
66
65
  handleExpansion(panel: string): (event: any, expanded: boolean) => void;
67
66
  translations: ArrayTranslations;
67
+ disableRemove?: boolean;
68
68
  }
69
69
 
70
70
  interface StatePropsOfExpandPanel extends OwnPropsOfExpandPanel {
@@ -117,6 +117,7 @@ const ExpandPanelRendererComponent = (props: ExpandPanelProps) => {
117
117
  cells,
118
118
  config,
119
119
  translations,
120
+ disableRemove,
120
121
  } = props;
121
122
 
122
123
  const foundUISchema = useMemo(
@@ -207,7 +208,7 @@ const ExpandPanelRendererComponent = (props: ExpandPanelProps) => {
207
208
  ) : (
208
209
  ''
209
210
  )}
210
- {enabled && (
211
+ {enabled && !disableRemove && (
211
212
  <Grid item>
212
213
  <Tooltip
213
214
  id='tooltip-remove'
@@ -262,13 +263,17 @@ export const ctxDispatchToExpandPanelProps: (
262
263
  (event: any): void => {
263
264
  event.stopPropagation();
264
265
  dispatch(
265
- update(path, (array) => {
266
- toDelete
267
- .sort()
268
- .reverse()
269
- .forEach((s) => array.splice(s, 1));
270
- return array;
271
- })
266
+ update(
267
+ path,
268
+ (array) => {
269
+ toDelete
270
+ .sort()
271
+ .reverse()
272
+ .forEach((s) => array.splice(s, 1));
273
+ return array;
274
+ },
275
+ { type: 'REMOVE', indices: toDelete } as UpdateArrayContext
276
+ )
272
277
  );
273
278
  },
274
279
  [dispatch]
@@ -278,10 +283,17 @@ export const ctxDispatchToExpandPanelProps: (
278
283
  (event: any): void => {
279
284
  event.stopPropagation();
280
285
  dispatch(
281
- update(path, (array) => {
282
- moveUp(array, toMove);
283
- return array;
284
- })
286
+ update(
287
+ path,
288
+ (array) => {
289
+ moveUp(array, toMove);
290
+ return array;
291
+ },
292
+ {
293
+ type: 'MOVE',
294
+ moves: [{ from: toMove, to: toMove - 1 }],
295
+ } as UpdateArrayContext
296
+ )
285
297
  );
286
298
  },
287
299
  [dispatch]
@@ -291,10 +303,17 @@ export const ctxDispatchToExpandPanelProps: (
291
303
  (event: any): void => {
292
304
  event.stopPropagation();
293
305
  dispatch(
294
- update(path, (array) => {
295
- moveDown(array, toMove);
296
- return array;
297
- })
306
+ update(
307
+ path,
308
+ (array) => {
309
+ moveDown(array, toMove);
310
+ return array;
311
+ },
312
+ {
313
+ type: 'MOVE',
314
+ moves: [{ from: toMove, to: toMove + 1 }],
315
+ } as UpdateArrayContext
316
+ )
298
317
  );
299
318
  },
300
319
  [dispatch]
@@ -67,8 +67,12 @@ const MaterialArrayLayoutComponent = (props: ArrayLayoutProps) => {
67
67
  uischemas,
68
68
  translations,
69
69
  description,
70
+ disableAdd,
71
+ disableRemove,
70
72
  } = props;
71
73
  const appliedUiSchemaOptions = merge({}, config, props.uischema.options);
74
+ const doDisableAdd = disableAdd || appliedUiSchemaOptions.disableAdd;
75
+ const doDisableRemove = disableRemove || appliedUiSchemaOptions.disableRemove;
72
76
 
73
77
  return (
74
78
  <div>
@@ -85,6 +89,7 @@ const MaterialArrayLayoutComponent = (props: ArrayLayoutProps) => {
85
89
  enabled={enabled}
86
90
  addItem={addItem}
87
91
  createDefault={innerCreateDefaultValue}
92
+ disableAdd={doDisableAdd}
88
93
  />
89
94
  <div>
90
95
  {data > 0 ? (
@@ -108,6 +113,7 @@ const MaterialArrayLayoutComponent = (props: ArrayLayoutProps) => {
108
113
  childLabelProp={appliedUiSchemaOptions.elementLabelProp}
109
114
  uischemas={uischemas}
110
115
  translations={translations}
116
+ disableRemove={doDisableRemove}
111
117
  />
112
118
  );
113
119
  })
@@ -32,7 +32,7 @@ import {
32
32
  useTheme,
33
33
  } from '@mui/material';
34
34
  import merge from 'lodash/merge';
35
- import { Close } from '@mui/icons-material';
35
+ import Close from '@mui/icons-material/Close';
36
36
  import {
37
37
  JsonFormsTheme,
38
38
  WithInputProps,
@@ -28,10 +28,14 @@ import { EnumCellProps, WithClassname } from '@jsonforms/core';
28
28
  import { MenuItem, Select } from '@mui/material';
29
29
  import merge from 'lodash/merge';
30
30
  import { TranslateProps } from '@jsonforms/react';
31
- import { i18nDefaults, WithInputProps } from '../util';
31
+ import { i18nDefaults, WithInputProps, WithSelectProps } from '../util';
32
32
 
33
33
  export const MuiSelect = React.memo(function MuiSelect(
34
- props: EnumCellProps & WithClassname & TranslateProps & WithInputProps
34
+ props: EnumCellProps &
35
+ WithClassname &
36
+ TranslateProps &
37
+ WithInputProps &
38
+ WithSelectProps
35
39
  ) {
36
40
  const {
37
41
  data,
@@ -46,6 +50,7 @@ export const MuiSelect = React.memo(function MuiSelect(
46
50
  config,
47
51
  label,
48
52
  t,
53
+ multiple,
49
54
  } = props;
50
55
  const appliedUiSchemaOptions = merge({}, config, uischema.options);
51
56
  const noneOptionLabel = useMemo(
@@ -63,6 +68,7 @@ export const MuiSelect = React.memo(function MuiSelect(
63
68
  value={data !== undefined ? data : ''}
64
69
  onChange={(ev) => handleChange(path, ev.target.value || undefined)}
65
70
  fullWidth={true}
71
+ multiple={multiple || false}
66
72
  >
67
73
  {[
68
74
  <MenuItem value={''} key='jsonforms.enum.none'>
package/src/util/theme.ts CHANGED
@@ -46,6 +46,10 @@ export interface WithInputProps {
46
46
  label?: string;
47
47
  }
48
48
 
49
+ export interface WithSelectProps {
50
+ multiple?: boolean;
51
+ }
52
+
49
53
  const variantToInput = {
50
54
  standard: Input,
51
55
  filled: FilledInput,