@jsonforms/material-renderers 3.1.0 → 3.2.0-alpha.0

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 (84) hide show
  1. package/lib/additional/ListWithDetailMasterItem.d.ts +1 -1
  2. package/lib/additional/MaterialLabelRenderer.d.ts +1 -1
  3. package/lib/additional/MaterialListWithDetailRenderer.d.ts +1 -1
  4. package/lib/additional/unwrapped.d.ts +2 -2
  5. package/lib/cells/MaterialBooleanCell.d.ts +1 -1
  6. package/lib/cells/MaterialBooleanToggleCell.d.ts +1 -1
  7. package/lib/cells/MaterialDateCell.d.ts +2 -1
  8. package/lib/cells/MaterialEnumCell.d.ts +1 -1
  9. package/lib/cells/MaterialIntegerCell.d.ts +1 -1
  10. package/lib/cells/MaterialNumberCell.d.ts +1 -1
  11. package/lib/cells/MaterialNumberFormatCell.d.ts +1 -1
  12. package/lib/cells/MaterialOneOfEnumCell.d.ts +1 -1
  13. package/lib/cells/MaterialTextCell.d.ts +1 -1
  14. package/lib/cells/MaterialTimeCell.d.ts +1 -1
  15. package/lib/complex/CombinatorProperties.d.ts +1 -1
  16. package/lib/complex/MaterialAllOfRenderer.d.ts +1 -1
  17. package/lib/complex/MaterialAnyOfRenderer.d.ts +2 -2
  18. package/lib/complex/MaterialArrayControlRenderer.d.ts +1 -1
  19. package/lib/complex/MaterialEnumArrayRenderer.d.ts +1 -1
  20. package/lib/complex/MaterialObjectRenderer.d.ts +1 -1
  21. package/lib/complex/MaterialOneOfRenderer.d.ts +1 -1
  22. package/lib/complex/MaterialTableControl.d.ts +2 -2
  23. package/lib/complex/NoBorderTableCell.d.ts +2 -2
  24. package/lib/complex/TabSwitchConfirmDialog.d.ts +9 -0
  25. package/lib/complex/unwrapped.d.ts +6 -6
  26. package/lib/controls/MaterialAnyOfStringOrEnumControl.d.ts +1 -1
  27. package/lib/controls/MaterialBooleanControl.d.ts +1 -1
  28. package/lib/controls/MaterialBooleanToggleControl.d.ts +1 -1
  29. package/lib/controls/MaterialDateControl.d.ts +1 -1
  30. package/lib/controls/MaterialDateTimeControl.d.ts +1 -1
  31. package/lib/controls/MaterialEnumControl.d.ts +1 -1
  32. package/lib/controls/MaterialInputControl.d.ts +2 -2
  33. package/lib/controls/MaterialIntegerControl.d.ts +1 -1
  34. package/lib/controls/MaterialNativeControl.d.ts +1 -1
  35. package/lib/controls/MaterialNumberControl.d.ts +1 -1
  36. package/lib/controls/MaterialOneOfEnumControl.d.ts +1 -1
  37. package/lib/controls/MaterialOneOfRadioGroupControl.d.ts +1 -1
  38. package/lib/controls/MaterialRadioGroup.d.ts +2 -2
  39. package/lib/controls/MaterialRadioGroupControl.d.ts +1 -1
  40. package/lib/controls/MaterialSliderControl.d.ts +1 -1
  41. package/lib/controls/MaterialTextControl.d.ts +1 -1
  42. package/lib/controls/MaterialTimeControl.d.ts +1 -1
  43. package/lib/controls/unwrapped.d.ts +14 -14
  44. package/lib/index.d.ts +28 -28
  45. package/lib/jsonforms-react-material.cjs.js +102 -43
  46. package/lib/jsonforms-react-material.cjs.js.map +1 -1
  47. package/lib/jsonforms-react-material.esm.js +90 -42
  48. package/lib/jsonforms-react-material.esm.js.map +1 -1
  49. package/lib/layouts/ExpandPanelRenderer.d.ts +1 -1
  50. package/lib/layouts/MaterialArrayLayout.d.ts +1 -1
  51. package/lib/layouts/MaterialArrayLayoutRenderer.d.ts +1 -1
  52. package/lib/layouts/MaterialCategorizationLayout.d.ts +3 -3
  53. package/lib/layouts/MaterialCategorizationStepperLayout.d.ts +3 -3
  54. package/lib/layouts/MaterialGroupLayout.d.ts +1 -1
  55. package/lib/layouts/MaterialHorizontalLayout.d.ts +1 -1
  56. package/lib/layouts/MaterialVerticalLayout.d.ts +1 -1
  57. package/lib/layouts/unwrapped.d.ts +6 -6
  58. package/lib/mui-controls/MuiAutocomplete.d.ts +1 -1
  59. package/lib/mui-controls/MuiInputInteger.d.ts +2 -1
  60. package/lib/mui-controls/MuiInputNumber.d.ts +2 -1
  61. package/lib/mui-controls/MuiInputNumberFormat.d.ts +2 -1
  62. package/lib/mui-controls/MuiInputText.d.ts +2 -1
  63. package/lib/mui-controls/MuiInputTime.d.ts +2 -1
  64. package/lib/mui-controls/MuiSelect.d.ts +2 -1
  65. package/lib/util/layout.d.ts +3 -3
  66. package/lib/util/theme.d.ts +8 -1
  67. package/package.json +26 -17
  68. package/src/cells/MaterialDateCell.tsx +21 -6
  69. package/src/complex/MaterialAnyOfRenderer.tsx +49 -6
  70. package/src/complex/MaterialOneOfRenderer.tsx +21 -45
  71. package/src/complex/TabSwitchConfirmDialog.tsx +56 -0
  72. package/src/controls/MaterialAnyOfStringOrEnumControl.tsx +9 -4
  73. package/src/controls/MaterialDateControl.tsx +0 -1
  74. package/src/controls/MaterialDateTimeControl.tsx +0 -1
  75. package/src/controls/MaterialInputControl.tsx +3 -2
  76. package/src/controls/MaterialTimeControl.tsx +0 -1
  77. package/src/mui-controls/MuiAutocomplete.tsx +0 -1
  78. package/src/mui-controls/MuiInputInteger.tsx +16 -6
  79. package/src/mui-controls/MuiInputNumber.tsx +20 -10
  80. package/src/mui-controls/MuiInputNumberFormat.tsx +6 -4
  81. package/src/mui-controls/MuiInputText.tsx +11 -4
  82. package/src/mui-controls/MuiInputTime.tsx +20 -10
  83. package/src/mui-controls/MuiSelect.tsx +4 -3
  84. package/src/util/theme.ts +40 -5
@@ -34,7 +34,7 @@ export interface DispatchPropsOfExpandPanel {
34
34
  }
35
35
  export interface ExpandPanelProps extends StatePropsOfExpandPanel, DispatchPropsOfExpandPanel {
36
36
  }
37
- export declare const ExpandPanelRenderer: React.MemoExoticComponent<(props: ExpandPanelProps) => JSX.Element>;
37
+ export declare const ExpandPanelRenderer: React.MemoExoticComponent<(props: ExpandPanelProps) => React.JSX.Element>;
38
38
  /**
39
39
  * Maps state to dispatch properties of an expand pandel control.
40
40
  *
@@ -1,3 +1,3 @@
1
1
  import React from 'react';
2
2
  import { ArrayLayoutProps } from '@jsonforms/core';
3
- export declare const MaterialArrayLayout: React.MemoExoticComponent<(props: ArrayLayoutProps) => JSX.Element>;
3
+ export declare const MaterialArrayLayout: React.MemoExoticComponent<(props: ArrayLayoutProps) => React.JSX.Element>;
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { ArrayLayoutProps, RankedTester } from '@jsonforms/core';
3
- export declare const MaterialArrayLayoutRenderer: ({ visible, addItem, ...props }: ArrayLayoutProps) => JSX.Element;
3
+ export declare const MaterialArrayLayoutRenderer: ({ visible, addItem, ...props }: ArrayLayoutProps) => React.JSX.Element;
4
4
  export declare const materialArrayLayoutTester: RankedTester;
5
5
  declare const _default: React.ComponentType<import("@jsonforms/core").OwnPropsOfControl>;
6
6
  export default _default;
@@ -1,4 +1,4 @@
1
- /// <reference types="react" />
1
+ import React from 'react';
2
2
  import { RankedTester, StatePropsOfLayout, Tester } from '@jsonforms/core';
3
3
  import { TranslateProps } from '@jsonforms/react';
4
4
  import { AjvProps } from '../util/layout';
@@ -13,6 +13,6 @@ export interface MaterialCategorizationLayoutRendererProps extends StatePropsOfL
13
13
  data?: any;
14
14
  onChange?(selected: number, prevSelected: number): void;
15
15
  }
16
- export declare const MaterialCategorizationLayoutRenderer: (props: MaterialCategorizationLayoutRendererProps) => JSX.Element;
17
- declare const _default: (props: MaterialCategorizationLayoutRendererProps & import("@jsonforms/core").OwnPropsOfLayout) => JSX.Element;
16
+ export declare const MaterialCategorizationLayoutRenderer: (props: MaterialCategorizationLayoutRendererProps) => React.JSX.Element;
17
+ declare const _default: (props: MaterialCategorizationLayoutRendererProps & import("@jsonforms/core").OwnPropsOfLayout) => React.JSX.Element;
18
18
  export default _default;
@@ -1,4 +1,4 @@
1
- /// <reference types="react" />
1
+ import React from 'react';
2
2
  import { RankedTester, StatePropsOfLayout } from '@jsonforms/core';
3
3
  import { TranslateProps } from '@jsonforms/react';
4
4
  import { AjvProps } from '../util/layout';
@@ -9,6 +9,6 @@ export interface CategorizationStepperState {
9
9
  export interface MaterialCategorizationStepperLayoutRendererProps extends StatePropsOfLayout, AjvProps, TranslateProps {
10
10
  data: any;
11
11
  }
12
- export declare const MaterialCategorizationStepperLayoutRenderer: (props: MaterialCategorizationStepperLayoutRendererProps) => JSX.Element;
13
- declare const _default: (props: MaterialCategorizationStepperLayoutRendererProps & import("@jsonforms/core").OwnPropsOfLayout) => JSX.Element;
12
+ export declare const MaterialCategorizationStepperLayoutRenderer: (props: MaterialCategorizationStepperLayoutRendererProps) => React.JSX.Element;
13
+ declare const _default: (props: MaterialCategorizationStepperLayoutRendererProps & import("@jsonforms/core").OwnPropsOfLayout) => React.JSX.Element;
14
14
  export default _default;
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { LayoutProps, RankedTester } from '@jsonforms/core';
3
3
  export declare const groupTester: RankedTester;
4
- export declare const MaterializedGroupLayoutRenderer: ({ uischema, schema, path, visible, enabled, renderers, cells, direction, label, }: LayoutProps) => JSX.Element;
4
+ export declare const MaterializedGroupLayoutRenderer: ({ uischema, schema, path, visible, enabled, renderers, cells, direction, label, }: LayoutProps) => React.JSX.Element;
5
5
  declare const _default: React.ComponentType<LayoutProps & import("@jsonforms/core").OwnPropsOfLayout>;
6
6
  export default _default;
7
7
  export declare const materialGroupTester: RankedTester;
@@ -5,6 +5,6 @@ import { LayoutProps, RankedTester } from '@jsonforms/core';
5
5
  * @type {RankedTester}
6
6
  */
7
7
  export declare const materialHorizontalLayoutTester: RankedTester;
8
- export declare const MaterialHorizontalLayoutRenderer: ({ uischema, renderers, cells, schema, path, enabled, visible, }: LayoutProps) => JSX.Element;
8
+ export declare const MaterialHorizontalLayoutRenderer: ({ uischema, renderers, cells, schema, path, enabled, visible, }: LayoutProps) => React.JSX.Element;
9
9
  declare const _default: React.ComponentType<LayoutProps & import("@jsonforms/core").OwnPropsOfLayout>;
10
10
  export default _default;
@@ -5,6 +5,6 @@ import { LayoutProps, RankedTester } from '@jsonforms/core';
5
5
  * @type {RankedTester}
6
6
  */
7
7
  export declare const materialVerticalLayoutTester: RankedTester;
8
- export declare const MaterialVerticalLayoutRenderer: ({ uischema, schema, path, enabled, visible, renderers, cells, }: LayoutProps) => JSX.Element;
8
+ export declare const MaterialVerticalLayoutRenderer: ({ uischema, schema, path, enabled, visible, renderers, cells, }: LayoutProps) => React.JSX.Element;
9
9
  declare const _default: React.ComponentType<LayoutProps & import("@jsonforms/core").OwnPropsOfLayout>;
10
10
  export default _default;
@@ -1,10 +1,10 @@
1
1
  /// <reference types="react" />
2
2
  export declare const UnwrappedLayouts: {
3
- ExpandPanelRenderer: import("react").MemoExoticComponent<(props: import("./ExpandPanelRenderer").ExpandPanelProps) => JSX.Element>;
4
- MaterialArrayLayout: ({ visible, addItem, ...props }: import("@jsonforms/core").ArrayLayoutProps) => JSX.Element;
5
- MaterialCategorizationLayout: (props: import("./MaterialCategorizationLayout").MaterialCategorizationLayoutRendererProps) => JSX.Element;
6
- MaterialGroupLayout: ({ uischema, schema, path, visible, enabled, renderers, cells, direction, label, }: import("@jsonforms/core").LayoutProps) => JSX.Element;
7
- MaterialHorizontalLayout: ({ uischema, renderers, cells, schema, path, enabled, visible, }: import("@jsonforms/core").LayoutProps) => JSX.Element;
8
- MaterialVerticalLayout: ({ uischema, schema, path, enabled, visible, renderers, cells, }: import("@jsonforms/core").LayoutProps) => JSX.Element;
3
+ ExpandPanelRenderer: import("react").MemoExoticComponent<(props: import("./ExpandPanelRenderer").ExpandPanelProps) => import("react").JSX.Element>;
4
+ MaterialArrayLayout: ({ visible, addItem, ...props }: import("@jsonforms/core").ArrayLayoutProps) => import("react").JSX.Element;
5
+ MaterialCategorizationLayout: (props: import("./MaterialCategorizationLayout").MaterialCategorizationLayoutRendererProps) => import("react").JSX.Element;
6
+ MaterialGroupLayout: ({ uischema, schema, path, visible, enabled, renderers, cells, direction, label, }: import("@jsonforms/core").LayoutProps) => import("react").JSX.Element;
7
+ MaterialHorizontalLayout: ({ uischema, renderers, cells, schema, path, enabled, visible, }: import("@jsonforms/core").LayoutProps) => import("react").JSX.Element;
8
+ MaterialVerticalLayout: ({ uischema, schema, path, enabled, visible, renderers, cells, }: import("@jsonforms/core").LayoutProps) => import("react").JSX.Element;
9
9
  };
10
10
  export * from './ArrayToolbar';
@@ -6,4 +6,4 @@ export interface WithOptionLabel {
6
6
  renderOption?(props: React.HTMLAttributes<HTMLLIElement>, option: EnumOption, state: AutocompleteRenderOptionState): ReactNode;
7
7
  filterOptions?(options: EnumOption[], state: FilterOptionsState<EnumOption>): EnumOption[];
8
8
  }
9
- export declare const MuiAutocomplete: (props: ControlProps & EnumCellProps & WithClassname & WithOptionLabel) => JSX.Element;
9
+ export declare const MuiAutocomplete: (props: ControlProps & EnumCellProps & WithClassname & WithOptionLabel) => React.JSX.Element;
@@ -1,3 +1,4 @@
1
1
  import React from 'react';
2
2
  import { CellProps, WithClassname } from '@jsonforms/core';
3
- export declare const MuiInputInteger: React.NamedExoticComponent<CellProps & WithClassname>;
3
+ import { WithInputProps } from '../util';
4
+ export declare const MuiInputInteger: React.NamedExoticComponent<CellProps & WithClassname & WithInputProps>;
@@ -1,3 +1,4 @@
1
1
  import React from 'react';
2
2
  import { CellProps, WithClassname } from '@jsonforms/core';
3
- export declare const MuiInputNumber: React.NamedExoticComponent<CellProps & WithClassname>;
3
+ import { WithInputProps } from '../util';
4
+ export declare const MuiInputNumber: React.NamedExoticComponent<CellProps & WithClassname & WithInputProps>;
@@ -1,3 +1,4 @@
1
1
  import React from 'react';
2
2
  import { CellProps, Formatted, WithClassname } from '@jsonforms/core';
3
- export declare const MuiInputNumberFormat: React.NamedExoticComponent<CellProps & WithClassname & Formatted<number>>;
3
+ import { WithInputProps } from '../util';
4
+ export declare const MuiInputNumberFormat: React.NamedExoticComponent<CellProps & WithClassname & Formatted<number> & WithInputProps>;
@@ -1,9 +1,10 @@
1
1
  import React from 'react';
2
2
  import { CellProps, WithClassname } from '@jsonforms/core';
3
3
  import { InputProps } from '@mui/material';
4
+ import { WithInputProps } from '../util';
4
5
  interface MuiTextInputProps {
5
6
  muiInputProps?: InputProps['inputProps'];
6
7
  inputComponent?: InputProps['inputComponent'];
7
8
  }
8
- export declare const MuiInputText: React.NamedExoticComponent<CellProps & WithClassname & MuiTextInputProps>;
9
+ export declare const MuiInputText: React.NamedExoticComponent<CellProps & WithClassname & MuiTextInputProps & WithInputProps>;
9
10
  export {};
@@ -1,3 +1,4 @@
1
1
  import React from 'react';
2
2
  import { CellProps, WithClassname } from '@jsonforms/core';
3
- export declare const MuiInputTime: React.NamedExoticComponent<CellProps & WithClassname>;
3
+ import { WithInputProps } from '../util';
4
+ export declare const MuiInputTime: React.NamedExoticComponent<CellProps & WithClassname & WithInputProps>;
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
2
  import { EnumCellProps, WithClassname } from '@jsonforms/core';
3
3
  import { TranslateProps } from '@jsonforms/react';
4
- export declare const MuiSelect: React.NamedExoticComponent<EnumCellProps & WithClassname & TranslateProps>;
4
+ import { WithInputProps } from '../util';
5
+ export declare const MuiSelect: React.NamedExoticComponent<EnumCellProps & WithClassname & TranslateProps & WithInputProps>;
@@ -2,16 +2,16 @@ import React, { ComponentType } from 'react';
2
2
  import Ajv from 'ajv';
3
3
  import type { UISchemaElement } from '@jsonforms/core';
4
4
  import { JsonFormsCellRendererRegistryEntry, JsonFormsRendererRegistryEntry, JsonSchema, OwnPropsOfRenderer } from '@jsonforms/core';
5
- export declare const renderLayoutElements: (elements: UISchemaElement[], schema: JsonSchema, path: string, enabled: boolean, renderers?: JsonFormsRendererRegistryEntry[], cells?: JsonFormsCellRendererRegistryEntry[]) => JSX.Element[];
5
+ export declare const renderLayoutElements: (elements: UISchemaElement[], schema: JsonSchema, path: string, enabled: boolean, renderers?: JsonFormsRendererRegistryEntry[], cells?: JsonFormsCellRendererRegistryEntry[]) => React.JSX.Element[];
6
6
  export interface MaterialLayoutRendererProps extends OwnPropsOfRenderer {
7
7
  elements: UISchemaElement[];
8
8
  direction: 'row' | 'column';
9
9
  }
10
- export declare const MaterialLayoutRenderer: React.MemoExoticComponent<({ visible, elements, schema, path, enabled, direction, renderers, cells, }: MaterialLayoutRendererProps) => JSX.Element>;
10
+ export declare const MaterialLayoutRenderer: React.MemoExoticComponent<({ visible, elements, schema, path, enabled, direction, renderers, cells, }: MaterialLayoutRendererProps) => React.JSX.Element>;
11
11
  export interface AjvProps {
12
12
  ajv: Ajv;
13
13
  }
14
- export declare const withAjvProps: <P extends {}>(Component: React.ComponentType<AjvProps & P>) => (props: P) => JSX.Element;
14
+ export declare const withAjvProps: <P extends {}>(Component: React.ComponentType<AjvProps & P>) => (props: P) => React.JSX.Element;
15
15
  export interface MaterialLabelableLayoutRendererProps extends MaterialLayoutRendererProps {
16
16
  label?: string;
17
17
  }
@@ -1,4 +1,5 @@
1
- import { Theme } from '@mui/material';
1
+ /// <reference types="react" />
2
+ import { Theme, TextFieldProps, InputBaseProps } from '@mui/material';
2
3
  export interface JsonFormsTheme extends Theme {
3
4
  jsonforms?: {
4
5
  input?: {
@@ -8,3 +9,9 @@ export interface JsonFormsTheme extends Theme {
8
9
  };
9
10
  };
10
11
  }
12
+ export interface WithInputProps {
13
+ label?: string;
14
+ }
15
+ export declare const defaultInputVariant: TextFieldProps['variant'];
16
+ export declare function useInputVariant(): TextFieldProps['variant'];
17
+ 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.1.0",
3
+ "version": "3.2.0-alpha.0",
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",
@@ -45,7 +45,8 @@
45
45
  "test": "jest --no-cache",
46
46
  "test-cov": "jest --no-cache --coverage",
47
47
  "report": "nyc report --reporter=html",
48
- "doc": "typedoc --name 'JSON Forms React Material Renderers' --mode file --excludeExternals --theme ../../typedoc-jsonforms --out docs src"
48
+ "doc": "typedoc --name 'JSON Forms React Material Renderers' --excludeExternals --theme ../../typedoc-jsonforms --out docs src",
49
+ "tsc": "tsc --build tsconfig.json"
49
50
  },
50
51
  "jest": {
51
52
  "moduleFileExtensions": [
@@ -56,6 +57,7 @@
56
57
  "transform": {
57
58
  "^.+\\.(ts|tsx)$": "ts-jest"
58
59
  },
60
+ "testEnvironment": "jsdom",
59
61
  "testMatch": [
60
62
  "**/test/**/*.test.tsx"
61
63
  ],
@@ -77,22 +79,24 @@
77
79
  },
78
80
  "dependencies": {
79
81
  "@date-io/dayjs": "1.3.13",
80
- "dayjs": "1.10.6"
82
+ "dayjs": "1.10.6",
83
+ "lodash": "^4.17.21"
81
84
  },
82
85
  "peerDependencies": {
83
86
  "@emotion/react": "^11.4.1",
84
87
  "@emotion/styled": "^11.3.0",
85
- "@jsonforms/core": "3.1.0",
86
- "@jsonforms/react": "3.1.0",
87
- "@mui/icons-material": "~5.11.16",
88
+ "@jsonforms/core": "3.1.1-alpha.1",
89
+ "@jsonforms/react": "3.1.1-alpha.1",
90
+ "@mui/icons-material": "^5.11.16",
88
91
  "@mui/material": "~5.13.0",
89
- "@mui/x-date-pickers": "^6.0.0"
92
+ "@mui/x-date-pickers": "^6.0.0",
93
+ "react": "^16.12.0 || ^17.0.0 || ^18.0.0"
90
94
  },
91
95
  "devDependencies": {
92
96
  "@emotion/react": "^11.5.0",
93
97
  "@emotion/styled": "^11.3.0",
94
- "@jsonforms/core": "^3.1.0",
95
- "@jsonforms/react": "^3.1.0",
98
+ "@jsonforms/core": "3.2.0-alpha.0",
99
+ "@jsonforms/react": "3.2.0-alpha.0",
96
100
  "@mui/icons-material": "~5.11.16",
97
101
  "@mui/material": "~5.13.0",
98
102
  "@mui/x-date-pickers": "^6.5.0",
@@ -101,36 +105,41 @@
101
105
  "@rollup/plugin-node-resolve": "^15.0.1",
102
106
  "@rollup/plugin-replace": "^5.0.1",
103
107
  "@types/enzyme": "^3.10.3",
108
+ "@types/react": "^17.0.24",
104
109
  "@types/react-dom": "^17.0.9",
105
110
  "@typescript-eslint/eslint-plugin": "^5.54.1",
106
111
  "@typescript-eslint/parser": "^5.54.1",
107
- "@wojtekmaj/enzyme-adapter-react-17": "^0.6.3",
112
+ "@wojtekmaj/enzyme-adapter-react-17": "^0.6.7",
108
113
  "copy-webpack-plugin": "^5.0.5",
109
- "enzyme": "^3.10.0",
114
+ "enzyme": "^3.11.0",
110
115
  "eslint": "^7.32.0",
111
116
  "eslint-config-prettier": "^8.7.0",
112
117
  "eslint-plugin-import": "^2.27.5",
113
118
  "eslint-plugin-prettier": "^4.2.1",
114
119
  "eslint-plugin-react": "^7.32.2",
115
- "jest": "^26.6.3",
120
+ "jest": "^27.5.1",
121
+ "jsdom": "^22.0.0",
122
+ "jsdom-global": "^3.0.2",
116
123
  "nyc": "^15.1.0",
117
124
  "prettier": "^2.8.4",
125
+ "react": "^17.0.2",
118
126
  "react-dom": "^17.0.2",
119
127
  "rimraf": "^3.0.2",
120
128
  "rollup": "^2.78.0",
121
129
  "rollup-plugin-cleanup": "^3.2.1",
122
130
  "rollup-plugin-copy": "^3.4.0",
123
- "rollup-plugin-import-css": "^3.1.0",
124
- "rollup-plugin-typescript2": "^0.31.1",
131
+ "rollup-plugin-import-css": "^3.3.1",
132
+ "rollup-plugin-typescript2": "^0.34.1",
125
133
  "rollup-plugin-visualizer": "^5.4.1",
126
134
  "source-map-loader": "^0.2.4",
127
- "ts-jest": "^26.4.4",
135
+ "ts-jest": "^27.1.4",
128
136
  "ts-loader": "^6.2.1",
129
- "typedoc": "^0.19.2",
137
+ "tslib": "^2.5.0",
138
+ "typedoc": "~0.21.9",
130
139
  "typescript": "4.2.3",
131
140
  "webpack": "^4.41.2",
132
141
  "webpack-cli": "^3.2.1",
133
142
  "webpack-dev-server": "^3.9.0"
134
143
  },
135
- "gitHead": "7e0115feeced7711b0768d325566aaa6b054c32b"
144
+ "gitHead": "9146b0fdf5913d2251fadd5435d2c7e813db6f71"
136
145
  }
@@ -31,22 +31,37 @@ import {
31
31
  WithClassname,
32
32
  } from '@jsonforms/core';
33
33
  import { withJsonFormsCellProps } from '@jsonforms/react';
34
- import Input from '@mui/material/Input';
35
34
  import merge from 'lodash/merge';
35
+ import { useInputComponent, WithInputProps } from '../util';
36
36
 
37
- export const MaterialDateCell = (props: CellProps & WithClassname) => {
38
- const { data, className, id, enabled, uischema, path, handleChange, config } =
39
- props;
37
+ export const MaterialDateCell = (
38
+ props: CellProps & WithClassname & WithInputProps
39
+ ) => {
40
+ const {
41
+ data,
42
+ className,
43
+ id,
44
+ enabled,
45
+ uischema,
46
+ path,
47
+ handleChange,
48
+ config,
49
+ label,
50
+ } = props;
40
51
 
52
+ const InputComponent = useInputComponent();
41
53
  const appliedUiSchemaOptions = merge({}, config, uischema.options);
42
54
 
43
55
  return (
44
- <Input
56
+ <InputComponent
45
57
  type='date'
46
58
  value={data || ''}
47
- onChange={(ev) => handleChange(path, ev.target.value)}
59
+ onChange={(ev: React.ChangeEvent<HTMLInputElement>) =>
60
+ handleChange(path, ev.target.value)
61
+ }
48
62
  className={className}
49
63
  id={id}
64
+ label={label}
50
65
  disabled={!enabled}
51
66
  autoFocus={appliedUiSchemaOptions.focus}
52
67
  fullWidth={true}
@@ -25,18 +25,22 @@
25
25
  import React, { useCallback, useState } from 'react';
26
26
 
27
27
  import {
28
+ CombinatorRendererProps,
28
29
  createCombinatorRenderInfos,
30
+ createDefaultValue,
29
31
  isAnyOfControl,
30
32
  JsonSchema,
31
33
  RankedTester,
32
34
  rankWith,
33
- StatePropsOfCombinator,
34
35
  } from '@jsonforms/core';
35
36
  import { JsonFormsDispatch, withJsonFormsAnyOfProps } from '@jsonforms/react';
36
37
  import { Hidden, Tab, Tabs } from '@mui/material';
37
38
  import CombinatorProperties from './CombinatorProperties';
39
+ import isEmpty from 'lodash/isEmpty';
40
+ import { TabSwitchConfirmDialog } from './TabSwitchConfirmDialog';
38
41
 
39
42
  export const MaterialAnyOfRenderer = ({
43
+ handleChange,
40
44
  schema,
41
45
  rootSchema,
42
46
  indexOfFittingSchema,
@@ -46,12 +50,44 @@ export const MaterialAnyOfRenderer = ({
46
50
  cells,
47
51
  uischema,
48
52
  uischemas,
49
- }: StatePropsOfCombinator) => {
53
+ id,
54
+ data,
55
+ }: CombinatorRendererProps) => {
50
56
  const [selectedAnyOf, setSelectedAnyOf] = useState(indexOfFittingSchema || 0);
51
- const handleChange = useCallback(
52
- (_ev: any, value: number) => setSelectedAnyOf(value),
53
- [setSelectedAnyOf]
57
+ const [confirmDialogOpen, setConfirmDialogOpen] = useState(false);
58
+ const [newSelectedIndex, setNewSelectedIndex] = useState(0);
59
+
60
+ const handleClose = useCallback(
61
+ () => setConfirmDialogOpen(false),
62
+ [setConfirmDialogOpen]
63
+ );
64
+
65
+ const handleTabChange = useCallback(
66
+ (_event: any, newIndex: number) => {
67
+ if (
68
+ isEmpty(data) ||
69
+ typeof data ===
70
+ typeof createDefaultValue(anyOfRenderInfos[newIndex].schema)
71
+ ) {
72
+ setSelectedAnyOf(newIndex);
73
+ } else {
74
+ setNewSelectedIndex(newIndex);
75
+ setConfirmDialogOpen(true);
76
+ }
77
+ },
78
+ [setConfirmDialogOpen, setSelectedAnyOf, data]
54
79
  );
80
+
81
+ const openNewTab = (newIndex: number) => {
82
+ handleChange(path, createDefaultValue(anyOfRenderInfos[newIndex].schema));
83
+ setSelectedAnyOf(newIndex);
84
+ };
85
+
86
+ const confirm = useCallback(() => {
87
+ openNewTab(newSelectedIndex);
88
+ setConfirmDialogOpen(false);
89
+ }, [handleChange, createDefaultValue, newSelectedIndex]);
90
+
55
91
  const anyOf = 'anyOf';
56
92
  const anyOfRenderInfos = createCombinatorRenderInfos(
57
93
  (schema as JsonSchema).anyOf,
@@ -69,7 +105,7 @@ export const MaterialAnyOfRenderer = ({
69
105
  combinatorKeyword={anyOf}
70
106
  path={path}
71
107
  />
72
- <Tabs value={selectedAnyOf} onChange={handleChange}>
108
+ <Tabs value={selectedAnyOf} onChange={handleTabChange}>
73
109
  {anyOfRenderInfos.map((anyOfRenderInfo) => (
74
110
  <Tab key={anyOfRenderInfo.label} label={anyOfRenderInfo.label} />
75
111
  ))}
@@ -87,6 +123,13 @@ export const MaterialAnyOfRenderer = ({
87
123
  />
88
124
  )
89
125
  )}
126
+ <TabSwitchConfirmDialog
127
+ cancel={handleClose}
128
+ confirm={confirm}
129
+ id={'anyOf-' + id}
130
+ open={confirmDialogOpen}
131
+ handleClose={handleClose}
132
+ />
90
133
  </Hidden>
91
134
  );
92
135
  };
@@ -25,6 +25,8 @@
25
25
  import React, { useCallback, useState } from 'react';
26
26
  import isEmpty from 'lodash/isEmpty';
27
27
 
28
+ import { TabSwitchConfirmDialog } from './TabSwitchConfirmDialog';
29
+
28
30
  import {
29
31
  CombinatorRendererProps,
30
32
  createCombinatorRenderInfos,
@@ -35,17 +37,7 @@ import {
35
37
  RankedTester,
36
38
  rankWith,
37
39
  } from '@jsonforms/core';
38
- import {
39
- Button,
40
- Dialog,
41
- DialogActions,
42
- DialogContent,
43
- DialogContentText,
44
- DialogTitle,
45
- Hidden,
46
- Tab,
47
- Tabs,
48
- } from '@mui/material';
40
+ import { Hidden, Tab, Tabs } from '@mui/material';
49
41
  import { JsonFormsDispatch, withJsonFormsOneOfProps } from '@jsonforms/react';
50
42
  import CombinatorProperties from './CombinatorProperties';
51
43
 
@@ -67,13 +59,16 @@ export const MaterialOneOfRenderer = ({
67
59
  uischemas,
68
60
  data,
69
61
  }: CombinatorRendererProps) => {
70
- const [open, setOpen] = useState(false);
62
+ const [confirmDialogOpen, setConfirmDialogOpen] = useState(false);
71
63
  const [selectedIndex, setSelectedIndex] = useState(indexOfFittingSchema || 0);
72
64
  const [newSelectedIndex, setNewSelectedIndex] = useState(0);
73
- const handleClose = useCallback(() => setOpen(false), [setOpen]);
65
+ const handleClose = useCallback(
66
+ () => setConfirmDialogOpen(false),
67
+ [setConfirmDialogOpen]
68
+ );
74
69
  const cancel = useCallback(() => {
75
- setOpen(false);
76
- }, [setOpen]);
70
+ setConfirmDialogOpen(false);
71
+ }, [setConfirmDialogOpen]);
77
72
  const oneOfRenderInfos = createCombinatorRenderInfos(
78
73
  (schema as JsonSchema).oneOf,
79
74
  rootSchema,
@@ -90,18 +85,19 @@ export const MaterialOneOfRenderer = ({
90
85
 
91
86
  const confirm = useCallback(() => {
92
87
  openNewTab(newSelectedIndex);
93
- setOpen(false);
88
+ setConfirmDialogOpen(false);
94
89
  }, [handleChange, createDefaultValue, newSelectedIndex]);
90
+
95
91
  const handleTabChange = useCallback(
96
92
  (_event: any, newOneOfIndex: number) => {
97
93
  setNewSelectedIndex(newOneOfIndex);
98
94
  if (isEmpty(data)) {
99
95
  openNewTab(newOneOfIndex);
100
96
  } else {
101
- setOpen(true);
97
+ setConfirmDialogOpen(true);
102
98
  }
103
99
  },
104
- [setOpen, setSelectedIndex, data]
100
+ [setConfirmDialogOpen, setSelectedIndex, data]
105
101
  );
106
102
 
107
103
  return (
@@ -129,33 +125,13 @@ export const MaterialOneOfRenderer = ({
129
125
  />
130
126
  )
131
127
  )}
132
- <Dialog
133
- open={open}
134
- onClose={handleClose}
135
- aria-labelledby='alert-dialog-title'
136
- aria-describedby='alert-dialog-description'
137
- >
138
- <DialogTitle id='alert-dialog-title'>{'Clear form?'}</DialogTitle>
139
- <DialogContent>
140
- <DialogContentText id='alert-dialog-description'>
141
- Your data will be cleared if you navigate away from this tab. Do you
142
- want to proceed?
143
- </DialogContentText>
144
- </DialogContent>
145
- <DialogActions>
146
- <Button onClick={cancel} color='primary'>
147
- No
148
- </Button>
149
- <Button
150
- onClick={confirm}
151
- color='primary'
152
- autoFocus
153
- id={`oneOf-${id}-confirm-yes`}
154
- >
155
- Yes
156
- </Button>
157
- </DialogActions>
158
- </Dialog>
128
+ <TabSwitchConfirmDialog
129
+ cancel={cancel}
130
+ confirm={confirm}
131
+ id={'oneOf-' + id}
132
+ open={confirmDialogOpen}
133
+ handleClose={handleClose}
134
+ />
159
135
  </Hidden>
160
136
  );
161
137
  };
@@ -0,0 +1,56 @@
1
+ import React from 'react';
2
+
3
+ import {
4
+ Button,
5
+ Dialog,
6
+ DialogActions,
7
+ DialogContent,
8
+ DialogContentText,
9
+ DialogTitle,
10
+ } from '@mui/material';
11
+
12
+ export interface TabSwitchConfirmDialogProps {
13
+ open: boolean;
14
+ handleClose: () => void;
15
+ confirm: () => void;
16
+ cancel: () => void;
17
+ id: string;
18
+ }
19
+
20
+ export const TabSwitchConfirmDialog = ({
21
+ open,
22
+ handleClose,
23
+ confirm,
24
+ cancel,
25
+ id,
26
+ }: TabSwitchConfirmDialogProps) => {
27
+ return (
28
+ <Dialog
29
+ open={open}
30
+ onClose={handleClose}
31
+ aria-labelledby='alert-dialog-title'
32
+ aria-describedby='alert-dialog-description'
33
+ >
34
+ <DialogTitle id='alert-dialog-title'>{'Clear form?'}</DialogTitle>
35
+ <DialogContent>
36
+ <DialogContentText id='alert-dialog-description'>
37
+ Your data will be cleared if you navigate away from this tab. Do you
38
+ want to proceed?
39
+ </DialogContentText>
40
+ </DialogContent>
41
+ <DialogActions>
42
+ <Button onClick={cancel} color='primary'>
43
+ No
44
+ </Button>
45
+ <Button
46
+ onClick={confirm}
47
+ color='primary'
48
+ autoFocus
49
+ id={`${id}-confirm-yes`}
50
+ >
51
+ Yes
52
+ </Button>
53
+ </DialogActions>
54
+ </Dialog>
55
+ );
56
+ };