@jsonforms/material-renderers 3.0.0-alpha.1 → 3.0.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 (293) hide show
  1. package/docs/assets/js/search.json +1 -1
  2. package/docs/classes/combinatorproperties.html +2 -5
  3. package/docs/classes/materialanyofstringorenumcontrol.html +6 -9
  4. package/docs/classes/materialtablecontrol.html +4 -7
  5. package/docs/globals.html +803 -213
  6. package/docs/index.html +63 -42
  7. package/docs/interfaces/ajvprops.html +1 -4
  8. package/docs/interfaces/arraylayouttoolbarprops.html +0 -3
  9. package/docs/interfaces/categorizationstate.html +0 -3
  10. package/docs/interfaces/categorizationstepperstate.html +0 -3
  11. package/docs/interfaces/combinatorpropertiesprops.html +0 -3
  12. package/docs/interfaces/deletedialogprops.html +0 -3
  13. package/docs/interfaces/dispatchpropsofexpandpanel.html +3 -6
  14. package/docs/interfaces/emptytableprops.html +0 -3
  15. package/docs/interfaces/expandpanelprops.html +19 -22
  16. package/docs/interfaces/jsonformstheme.html +0 -3
  17. package/docs/interfaces/materialcategorizationlayoutrendererprops.html +1 -4
  18. package/docs/interfaces/materialcategorizationstepperlayoutrendererprops.html +1 -4
  19. package/docs/interfaces/materiallayoutrendererprops.html +0 -3
  20. package/docs/interfaces/materialtabletoolbarprops.html +0 -3
  21. package/docs/interfaces/muitextinputprops.html +2 -5
  22. package/docs/interfaces/nonemptycellcomponentprops.html +266 -0
  23. package/docs/interfaces/nonemptycellprops.html +0 -3
  24. package/docs/interfaces/nonemptyrowprops.html +80 -27
  25. package/docs/interfaces/ownoneofprops.html +0 -3
  26. package/docs/interfaces/ownpropsofexpandpanel.html +14 -17
  27. package/docs/interfaces/ownpropsofnonemptycell.html +0 -3
  28. package/docs/interfaces/statepropsofexpandpanel.html +16 -19
  29. package/docs/interfaces/tableheadercellprops.html +0 -3
  30. package/docs/interfaces/tablerowsprop.html +9 -12
  31. package/docs/interfaces/validationprops.html +0 -3
  32. package/docs/interfaces/withdeletedialogsupport.html +0 -3
  33. package/docs/interfaces/withinput.html +1 -4
  34. package/docs/interfaces/withoptionlabel.html +3 -6
  35. package/lib/additional/ListWithDetailMasterItem.d.ts +1 -1
  36. package/lib/additional/ListWithDetailMasterItem.js.map +1 -1
  37. package/lib/additional/MaterialLabelRenderer.d.ts +1 -1
  38. package/lib/additional/MaterialLabelRenderer.js +3 -1
  39. package/lib/additional/MaterialLabelRenderer.js.map +1 -1
  40. package/lib/additional/MaterialListWithDetailRenderer.d.ts +1 -1
  41. package/lib/additional/MaterialListWithDetailRenderer.js +3 -1
  42. package/lib/additional/MaterialListWithDetailRenderer.js.map +1 -1
  43. package/lib/additional/index.js +3 -2
  44. package/lib/additional/index.js.map +1 -1
  45. package/lib/cells/CustomizableCells.js +10 -9
  46. package/lib/cells/CustomizableCells.js.map +1 -1
  47. package/lib/cells/MaterialBooleanCell.d.ts +1 -1
  48. package/lib/cells/MaterialBooleanCell.js +3 -1
  49. package/lib/cells/MaterialBooleanCell.js.map +1 -1
  50. package/lib/cells/MaterialBooleanToggleCell.d.ts +1 -1
  51. package/lib/cells/MaterialBooleanToggleCell.js +3 -1
  52. package/lib/cells/MaterialBooleanToggleCell.js.map +1 -1
  53. package/lib/cells/MaterialDateCell.d.ts +1 -1
  54. package/lib/cells/MaterialDateCell.js +3 -1
  55. package/lib/cells/MaterialDateCell.js.map +1 -1
  56. package/lib/cells/MaterialEnumCell.d.ts +1 -1
  57. package/lib/cells/MaterialEnumCell.js +3 -1
  58. package/lib/cells/MaterialEnumCell.js.map +1 -1
  59. package/lib/cells/MaterialIntegerCell.d.ts +1 -1
  60. package/lib/cells/MaterialIntegerCell.js +3 -1
  61. package/lib/cells/MaterialIntegerCell.js.map +1 -1
  62. package/lib/cells/MaterialNumberCell.d.ts +1 -1
  63. package/lib/cells/MaterialNumberCell.js +3 -1
  64. package/lib/cells/MaterialNumberCell.js.map +1 -1
  65. package/lib/cells/MaterialNumberFormatCell.d.ts +1 -1
  66. package/lib/cells/MaterialNumberFormatCell.js +3 -1
  67. package/lib/cells/MaterialNumberFormatCell.js.map +1 -1
  68. package/lib/cells/MaterialOneOfEnumCell.d.ts +1 -1
  69. package/lib/cells/MaterialOneOfEnumCell.js +3 -1
  70. package/lib/cells/MaterialOneOfEnumCell.js.map +1 -1
  71. package/lib/cells/MaterialTextCell.d.ts +1 -1
  72. package/lib/cells/MaterialTextCell.js +3 -1
  73. package/lib/cells/MaterialTextCell.js.map +1 -1
  74. package/lib/cells/MaterialTimeCell.d.ts +1 -1
  75. package/lib/cells/MaterialTimeCell.js +3 -1
  76. package/lib/cells/MaterialTimeCell.js.map +1 -1
  77. package/lib/cells/index.js +11 -10
  78. package/lib/cells/index.js.map +1 -1
  79. package/lib/complex/CombinatorProperties.js +3 -1
  80. package/lib/complex/CombinatorProperties.js.map +1 -1
  81. package/lib/complex/DeleteDialog.js +1 -0
  82. package/lib/complex/DeleteDialog.js.map +1 -1
  83. package/lib/complex/MaterialAllOfRenderer.d.ts +3 -2
  84. package/lib/complex/MaterialAllOfRenderer.js +3 -1
  85. package/lib/complex/MaterialAllOfRenderer.js.map +1 -1
  86. package/lib/complex/MaterialAnyOfRenderer.d.ts +3 -2
  87. package/lib/complex/MaterialAnyOfRenderer.js +3 -1
  88. package/lib/complex/MaterialAnyOfRenderer.js.map +1 -1
  89. package/lib/complex/MaterialArrayControlRenderer.d.ts +1 -1
  90. package/lib/complex/MaterialArrayControlRenderer.js +3 -1
  91. package/lib/complex/MaterialArrayControlRenderer.js.map +1 -1
  92. package/lib/complex/MaterialEnumArrayRenderer.d.ts +2 -2
  93. package/lib/complex/MaterialEnumArrayRenderer.js +6 -3
  94. package/lib/complex/MaterialEnumArrayRenderer.js.map +1 -1
  95. package/lib/complex/MaterialObjectRenderer.d.ts +3 -2
  96. package/lib/complex/MaterialObjectRenderer.js +3 -1
  97. package/lib/complex/MaterialObjectRenderer.js.map +1 -1
  98. package/lib/complex/MaterialOneOfRenderer.d.ts +2 -1
  99. package/lib/complex/MaterialOneOfRenderer.js +5 -4
  100. package/lib/complex/MaterialOneOfRenderer.js.map +1 -1
  101. package/lib/complex/MaterialTableControl.d.ts +16 -1
  102. package/lib/complex/MaterialTableControl.js +16 -8
  103. package/lib/complex/MaterialTableControl.js.map +1 -1
  104. package/lib/complex/NoBorderTableCell.js.map +1 -1
  105. package/lib/complex/TableToolbar.js.map +1 -1
  106. package/lib/complex/ValidationIcon.d.ts +5 -3
  107. package/lib/complex/ValidationIcon.js.map +1 -1
  108. package/lib/complex/index.js +6 -5
  109. package/lib/complex/index.js.map +1 -1
  110. package/lib/controls/MaterialAnyOfStringOrEnumControl.d.ts +1 -1
  111. package/lib/controls/MaterialAnyOfStringOrEnumControl.js +17 -12
  112. package/lib/controls/MaterialAnyOfStringOrEnumControl.js.map +1 -1
  113. package/lib/controls/MaterialBooleanControl.d.ts +1 -1
  114. package/lib/controls/MaterialBooleanControl.js +3 -1
  115. package/lib/controls/MaterialBooleanControl.js.map +1 -1
  116. package/lib/controls/MaterialBooleanToggleControl.d.ts +1 -1
  117. package/lib/controls/MaterialBooleanToggleControl.js +3 -1
  118. package/lib/controls/MaterialBooleanToggleControl.js.map +1 -1
  119. package/lib/controls/MaterialDateControl.d.ts +3 -6
  120. package/lib/controls/MaterialDateControl.js +25 -29
  121. package/lib/controls/MaterialDateControl.js.map +1 -1
  122. package/lib/controls/MaterialDateTimeControl.d.ts +3 -6
  123. package/lib/controls/MaterialDateTimeControl.js +25 -29
  124. package/lib/controls/MaterialDateTimeControl.js.map +1 -1
  125. package/lib/controls/MaterialEnumControl.d.ts +1 -1
  126. package/lib/controls/MaterialEnumControl.js +3 -1
  127. package/lib/controls/MaterialEnumControl.js.map +1 -1
  128. package/lib/controls/MaterialInputControl.d.ts +2 -5
  129. package/lib/controls/MaterialInputControl.js +23 -28
  130. package/lib/controls/MaterialInputControl.js.map +1 -1
  131. package/lib/controls/MaterialIntegerControl.d.ts +1 -1
  132. package/lib/controls/MaterialIntegerControl.js +3 -1
  133. package/lib/controls/MaterialIntegerControl.js.map +1 -1
  134. package/lib/controls/MaterialNativeControl.d.ts +3 -6
  135. package/lib/controls/MaterialNativeControl.js +15 -19
  136. package/lib/controls/MaterialNativeControl.js.map +1 -1
  137. package/lib/controls/MaterialNumberControl.d.ts +1 -1
  138. package/lib/controls/MaterialNumberControl.js +3 -1
  139. package/lib/controls/MaterialNumberControl.js.map +1 -1
  140. package/lib/controls/MaterialOneOfEnumControl.d.ts +1 -1
  141. package/lib/controls/MaterialOneOfEnumControl.js +3 -1
  142. package/lib/controls/MaterialOneOfEnumControl.js.map +1 -1
  143. package/lib/controls/MaterialOneOfRadioGroupControl.d.ts +1 -1
  144. package/lib/controls/MaterialOneOfRadioGroupControl.js +3 -1
  145. package/lib/controls/MaterialOneOfRadioGroupControl.js.map +1 -1
  146. package/lib/controls/MaterialRadioGroup.d.ts +2 -5
  147. package/lib/controls/MaterialRadioGroup.js +15 -20
  148. package/lib/controls/MaterialRadioGroup.js.map +1 -1
  149. package/lib/controls/MaterialRadioGroupControl.d.ts +1 -1
  150. package/lib/controls/MaterialRadioGroupControl.js +3 -1
  151. package/lib/controls/MaterialRadioGroupControl.js.map +1 -1
  152. package/lib/controls/MaterialSliderControl.d.ts +3 -6
  153. package/lib/controls/MaterialSliderControl.js +35 -39
  154. package/lib/controls/MaterialSliderControl.js.map +1 -1
  155. package/lib/controls/MaterialTextControl.d.ts +1 -1
  156. package/lib/controls/MaterialTextControl.js +3 -1
  157. package/lib/controls/MaterialTextControl.js.map +1 -1
  158. package/lib/controls/MaterialTimeControl.d.ts +3 -6
  159. package/lib/controls/MaterialTimeControl.js +25 -29
  160. package/lib/controls/MaterialTimeControl.js.map +1 -1
  161. package/lib/controls/index.d.ts +10 -10
  162. package/lib/controls/index.js +16 -15
  163. package/lib/controls/index.js.map +1 -1
  164. package/lib/extended/MaterialAutocompleteEnumControl.d.ts +1 -1
  165. package/lib/extended/MaterialAutocompleteEnumControl.js +3 -1
  166. package/lib/extended/MaterialAutocompleteEnumControl.js.map +1 -1
  167. package/lib/extended/MaterialAutocompleteOneOfEnumControl.d.ts +1 -1
  168. package/lib/extended/MaterialAutocompleteOneOfEnumControl.js +3 -1
  169. package/lib/extended/MaterialAutocompleteOneOfEnumControl.js.map +1 -1
  170. package/lib/extended/MuiAutocomplete.d.ts +2 -2
  171. package/lib/extended/MuiAutocomplete.js +4 -3
  172. package/lib/extended/MuiAutocomplete.js.map +1 -1
  173. package/lib/extended/index.d.ts +2 -2
  174. package/lib/extended/index.js +2 -1
  175. package/lib/extended/index.js.map +1 -1
  176. package/lib/index.js +1 -0
  177. package/lib/index.js.map +1 -1
  178. package/lib/jsonforms-material.js +8 -8
  179. package/lib/jsonforms-material.js.map +1 -1
  180. package/lib/layouts/ArrayToolbar.js +1 -0
  181. package/lib/layouts/ArrayToolbar.js.map +1 -1
  182. package/lib/layouts/ExpandPanelRenderer.d.ts +3 -3
  183. package/lib/layouts/ExpandPanelRenderer.js +16 -13
  184. package/lib/layouts/ExpandPanelRenderer.js.map +1 -1
  185. package/lib/layouts/MaterialArrayLayout.d.ts +1 -11
  186. package/lib/layouts/MaterialArrayLayout.js +19 -31
  187. package/lib/layouts/MaterialArrayLayout.js.map +1 -1
  188. package/lib/layouts/MaterialArrayLayoutRenderer.d.ts +1 -1
  189. package/lib/layouts/MaterialArrayLayoutRenderer.js +3 -1
  190. package/lib/layouts/MaterialArrayLayoutRenderer.js.map +1 -1
  191. package/lib/layouts/MaterialCategorizationLayout.d.ts +2 -10
  192. package/lib/layouts/MaterialCategorizationLayout.js +31 -47
  193. package/lib/layouts/MaterialCategorizationLayout.js.map +1 -1
  194. package/lib/layouts/MaterialCategorizationStepperLayout.d.ts +2 -9
  195. package/lib/layouts/MaterialCategorizationStepperLayout.js +42 -53
  196. package/lib/layouts/MaterialCategorizationStepperLayout.js.map +1 -1
  197. package/lib/layouts/MaterialGroupLayout.d.ts +1 -1
  198. package/lib/layouts/MaterialGroupLayout.js +3 -1
  199. package/lib/layouts/MaterialGroupLayout.js.map +1 -1
  200. package/lib/layouts/MaterialHorizontalLayout.d.ts +1 -1
  201. package/lib/layouts/MaterialHorizontalLayout.js +3 -1
  202. package/lib/layouts/MaterialHorizontalLayout.js.map +1 -1
  203. package/lib/layouts/MaterialVerticalLayout.d.ts +1 -1
  204. package/lib/layouts/MaterialVerticalLayout.js +3 -1
  205. package/lib/layouts/MaterialVerticalLayout.js.map +1 -1
  206. package/lib/layouts/index.js +6 -5
  207. package/lib/layouts/index.js.map +1 -1
  208. package/lib/mui-controls/MuiCheckbox.js +2 -2
  209. package/lib/mui-controls/MuiCheckbox.js.map +1 -1
  210. package/lib/mui-controls/MuiInputInteger.js +9 -6
  211. package/lib/mui-controls/MuiInputInteger.js.map +1 -1
  212. package/lib/mui-controls/MuiInputNumber.js +9 -6
  213. package/lib/mui-controls/MuiInputNumber.js.map +1 -1
  214. package/lib/mui-controls/MuiInputNumberFormat.js +7 -8
  215. package/lib/mui-controls/MuiInputNumberFormat.js.map +1 -1
  216. package/lib/mui-controls/MuiInputText.js +11 -7
  217. package/lib/mui-controls/MuiInputText.js.map +1 -1
  218. package/lib/mui-controls/MuiInputTime.js +5 -3
  219. package/lib/mui-controls/MuiInputTime.js.map +1 -1
  220. package/lib/mui-controls/MuiSelect.js +3 -3
  221. package/lib/mui-controls/MuiSelect.js.map +1 -1
  222. package/lib/mui-controls/MuiToggle.js +2 -2
  223. package/lib/mui-controls/MuiToggle.js.map +1 -1
  224. package/lib/util/datejs.d.ts +2 -2
  225. package/lib/util/datejs.js +5 -2
  226. package/lib/util/datejs.js.map +1 -1
  227. package/lib/util/debounce.d.ts +1 -0
  228. package/lib/util/debounce.js +48 -0
  229. package/lib/util/debounce.js.map +1 -0
  230. package/lib/util/focus.d.ts +1 -0
  231. package/lib/util/focus.js +36 -0
  232. package/lib/util/focus.js.map +1 -0
  233. package/lib/util/index.d.ts +2 -0
  234. package/lib/util/index.js +3 -0
  235. package/lib/util/index.js.map +1 -1
  236. package/lib/util/layout.d.ts +2 -1
  237. package/lib/util/layout.js +8 -4
  238. package/lib/util/layout.js.map +1 -1
  239. package/package.json +5 -5
  240. package/src/cells/MaterialTimeCell.tsx +1 -0
  241. package/src/complex/MaterialAllOfRenderer.tsx +2 -1
  242. package/src/complex/MaterialAnyOfRenderer.tsx +2 -1
  243. package/src/complex/MaterialEnumArrayRenderer.tsx +1 -0
  244. package/src/complex/MaterialObjectRenderer.tsx +2 -1
  245. package/src/complex/MaterialOneOfRenderer.tsx +6 -6
  246. package/src/complex/MaterialTableControl.tsx +36 -24
  247. package/src/controls/MaterialAnyOfStringOrEnumControl.tsx +16 -12
  248. package/src/controls/MaterialDateControl.tsx +80 -85
  249. package/src/controls/MaterialDateTimeControl.tsx +83 -86
  250. package/src/controls/MaterialInputControl.tsx +62 -69
  251. package/src/controls/MaterialNativeControl.tsx +54 -57
  252. package/src/controls/MaterialRadioGroup.tsx +67 -69
  253. package/src/controls/MaterialSliderControl.tsx +92 -87
  254. package/src/controls/MaterialTimeControl.tsx +77 -80
  255. package/src/extended/MuiAutocomplete.tsx +2 -3
  256. package/src/layouts/ExpandPanelRenderer.tsx +11 -17
  257. package/src/layouts/MaterialArrayLayout.tsx +73 -82
  258. package/src/layouts/MaterialCategorizationLayout.tsx +49 -65
  259. package/src/layouts/MaterialCategorizationStepperLayout.tsx +79 -87
  260. package/src/mui-controls/MuiCheckbox.tsx +1 -2
  261. package/src/mui-controls/MuiInputInteger.tsx +12 -9
  262. package/src/mui-controls/MuiInputNumber.tsx +9 -6
  263. package/src/mui-controls/MuiInputNumberFormat.tsx +8 -11
  264. package/src/mui-controls/MuiInputText.tsx +17 -15
  265. package/src/mui-controls/MuiInputTime.tsx +6 -4
  266. package/src/mui-controls/MuiSelect.tsx +2 -3
  267. package/src/mui-controls/MuiToggle.tsx +1 -2
  268. package/src/util/debounce.ts +43 -0
  269. package/src/util/focus.ts +32 -0
  270. package/src/util/index.ts +2 -0
  271. package/src/util/layout.tsx +5 -6
  272. package/test/renderers/MaterialAnyOfRenderer.test.tsx +14 -8
  273. package/test/renderers/MaterialArrayLayout.test.tsx +6 -6
  274. package/test/renderers/MaterialCategorizationLayout.test.tsx +73 -0
  275. package/test/renderers/MaterialCategorizationStepperLayout.test.tsx +73 -0
  276. package/test/renderers/MaterialInputControl.test.tsx +3 -3
  277. package/test/renderers/MaterialIntegerCell.test.tsx +41 -20
  278. package/test/renderers/MaterialNumberCell.test.tsx +45 -24
  279. package/test/renderers/MaterialOneOfRenderer.test.tsx +7 -4
  280. package/test/renderers/MaterialTextCell.test.tsx +41 -20
  281. package/test/renderers/MaterialTimeCell.test.tsx +41 -20
  282. package/test/renderers/MaterialTimeControl.test.tsx +3 -3
  283. package/docs/classes/materialarraylayout.html +0 -777
  284. package/docs/classes/materialcategorizationlayoutrenderer.html +0 -786
  285. package/docs/classes/materialcategorizationstepperlayoutrenderer.html +0 -762
  286. package/docs/classes/materialdatecontrol.html +0 -825
  287. package/docs/classes/materialdatetimecontrol.html +0 -825
  288. package/docs/classes/materialinputcontrol.html +0 -825
  289. package/docs/classes/materialnativecontrol.html +0 -825
  290. package/docs/classes/materialradiogroup.html +0 -825
  291. package/docs/classes/materialslidercontrol.html +0 -825
  292. package/docs/classes/materialtimecontrol.html +0 -825
  293. package/docs/interfaces/materialarraylayoutstate.html +0 -157
@@ -22,7 +22,7 @@
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 React from 'react';
25
+ import React, {useState} from 'react';
26
26
  import { Hidden, Tab, Tabs } from '@material-ui/core';
27
27
  import AppBar from '@material-ui/core/AppBar';
28
28
  import {
@@ -37,7 +37,7 @@ import {
37
37
  UISchemaElement,
38
38
  uiTypeIs
39
39
  } from '@jsonforms/core';
40
- import { RendererComponent, withJsonFormsLayoutProps } from '@jsonforms/react';
40
+ import { withJsonFormsLayoutProps } from '@jsonforms/react';
41
41
  import {
42
42
  AjvProps,
43
43
  MaterialLayoutRenderer,
@@ -76,71 +76,55 @@ export interface MaterialCategorizationLayoutRendererProps
76
76
  onChange?(selected: number, prevSelected: number): void;
77
77
  }
78
78
 
79
- export class MaterialCategorizationLayoutRenderer extends RendererComponent<
80
- MaterialCategorizationLayoutRendererProps,
81
- CategorizationState
82
- > {
83
- state = {
84
- activeCategory: 0
79
+ export const MaterialCategorizationLayoutRenderer = (props: MaterialCategorizationLayoutRendererProps) => {
80
+ const {
81
+ data,
82
+ path,
83
+ renderers,
84
+ cells,
85
+ schema,
86
+ uischema,
87
+ visible,
88
+ enabled,
89
+ selected,
90
+ onChange,
91
+ ajv
92
+ } = props;
93
+ const categorization = uischema as Categorization;
94
+ const [activeCategory, setActiveCategory]= useState<number|undefined>(selected??0);
95
+ const categories = categorization.elements.filter((category: Category) =>
96
+ isVisible(category, data, undefined, ajv)
97
+ );
98
+ const childProps: MaterialLayoutRendererProps = {
99
+ elements: categories[activeCategory].elements,
100
+ schema,
101
+ path,
102
+ direction: 'column',
103
+ enabled,
104
+ visible,
105
+ renderers,
106
+ cells
85
107
  };
86
-
87
- render() {
88
- const {
89
- data,
90
- path,
91
- renderers,
92
- cells,
93
- schema,
94
- uischema,
95
- visible,
96
- enabled,
97
- selected,
98
- ajv
99
- } = this.props;
100
- const categorization = uischema as Categorization;
101
- const value = this.hasOwnState() ? this.state.activeCategory : selected;
102
- const childProps: MaterialLayoutRendererProps = {
103
- elements: categorization.elements[value].elements,
104
- schema,
105
- path,
106
- direction: 'column',
107
- enabled,
108
- visible,
109
- renderers,
110
- cells
111
- };
112
- const categories = categorization.elements.filter((category: Category) =>
113
- isVisible(category, data, undefined, ajv)
114
- );
115
- return (
116
- <Hidden xsUp={!visible}>
117
- <AppBar position='static'>
118
- <Tabs value={value} onChange={this.handleChange} variant='scrollable'>
119
- {categories.map((e: Category, idx: number) => (
120
- <Tab key={idx} label={e.label} />
121
- ))}
122
- </Tabs>
123
- </AppBar>
124
- <div style={{ marginTop: '0.5em' }}>
125
- <MaterialLayoutRenderer {...childProps} />
126
- </div>
127
- </Hidden>
128
- );
129
- }
130
-
131
- hasOwnState = () => {
132
- return this.props.ownState !== undefined ? this.props.ownState : true;
133
- };
134
-
135
- private handleChange = (_event: any, value: any) => {
136
- if (this.props.onChange) {
137
- this.props.onChange(value, this.state.activeCategory);
138
- }
139
- const hasOwnState = this.hasOwnState();
140
- if (hasOwnState) {
141
- this.setState({ activeCategory: value });
108
+ const onTabChange = (_event: any, value: any) => {
109
+ if (onChange) {
110
+ onChange(value, activeCategory);
142
111
  }
112
+ setActiveCategory(value);
143
113
  };
144
- }
114
+ return (
115
+ <Hidden xsUp={!visible}>
116
+ <AppBar position='static'>
117
+ <Tabs value={activeCategory} onChange={onTabChange} variant='scrollable'>
118
+ {categories.map((e: Category, idx: number) => (
119
+ <Tab key={idx} label={e.label} />
120
+ ))}
121
+ </Tabs>
122
+ </AppBar>
123
+ <div style={{ marginTop: '0.5em' }}>
124
+ <MaterialLayoutRenderer {...childProps} />
125
+ </div>
126
+ </Hidden>
127
+ );
128
+ };
145
129
 
146
130
  export default withJsonFormsLayoutProps(withAjvProps(MaterialCategorizationLayoutRenderer));
@@ -22,7 +22,7 @@
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 React from 'react';
25
+ import React, {useState} from 'react';
26
26
  import merge from 'lodash/merge';
27
27
  import { Button, Hidden, Step, StepButton, Stepper } from '@material-ui/core';
28
28
  import {
@@ -37,7 +37,7 @@ import {
37
37
  StatePropsOfLayout,
38
38
  uiTypeIs
39
39
  } from '@jsonforms/core';
40
- import { RendererComponent, withJsonFormsLayoutProps } from '@jsonforms/react';
40
+ import { withJsonFormsLayoutProps } from '@jsonforms/react';
41
41
  import {
42
42
  AjvProps,
43
43
  MaterialLayoutRenderer,
@@ -63,94 +63,86 @@ export interface MaterialCategorizationStepperLayoutRendererProps
63
63
  data: any;
64
64
  }
65
65
 
66
- export class MaterialCategorizationStepperLayoutRenderer extends RendererComponent<
67
- MaterialCategorizationStepperLayoutRendererProps,
68
- CategorizationStepperState
69
- > {
70
- state = {
71
- activeCategory: 0
72
- };
66
+ export const MaterialCategorizationStepperLayoutRenderer = (props: MaterialCategorizationStepperLayoutRendererProps)=> {
67
+ const [activeCategory, setActiveCategory] = useState<number>(0);
73
68
 
74
- handleStep = (step: number) => {
75
- this.setState({ activeCategory: step });
69
+ const handleStep = (step: number) => {
70
+ setActiveCategory( step);
76
71
  };
77
72
 
78
- render() {
79
- const {
80
- data,
81
- path,
82
- renderers,
83
- schema,
84
- uischema,
85
- visible,
86
- cells,
87
- config,
88
- ajv
89
- } = this.props;
90
- const categorization = uischema as Categorization;
91
- const activeCategory = this.state.activeCategory;
92
- const appliedUiSchemaOptions = merge({}, config, uischema.options);
93
- const buttonWrapperStyle = {
94
- textAlign: 'right' as 'right',
95
- width: '100%',
96
- margin: '1em auto'
97
- };
98
- const buttonNextStyle = {
99
- float: 'right' as 'right'
100
- };
101
- const buttonStyle = {
102
- marginRight: '1em'
103
- };
104
- const childProps: MaterialLayoutRendererProps = {
105
- elements: categorization.elements[activeCategory].elements,
106
- schema,
107
- path,
108
- direction: 'column',
109
- visible,
110
- renderers,
111
- cells
112
- };
113
- const categories = categorization.elements.filter((category: Category) =>
114
- isVisible(category, data, undefined, ajv)
115
- );
116
- return (
117
- <Hidden xsUp={!visible}>
118
- <Stepper activeStep={activeCategory} nonLinear>
119
- {categories.map((e: Category, idx: number) => (
120
- <Step key={e.label}>
121
- <StepButton onClick={() => this.handleStep(idx)}>
122
- {e.label}
123
- </StepButton>
124
- </Step>
125
- ))}
126
- </Stepper>
127
- <div>
128
- <MaterialLayoutRenderer {...childProps} />
129
- </div>
130
- { !!appliedUiSchemaOptions.showNavButtons ? (<div style={buttonWrapperStyle}>
131
- <Button
132
- style={buttonNextStyle}
133
- variant="contained"
134
- color="primary"
135
- disabled={activeCategory >= categories.length - 1}
136
- onClick={() => this.handleStep(activeCategory + 1)}
137
- >
138
- Next
139
- </Button>
140
- <Button
141
- style={buttonStyle}
142
- color="secondary"
143
- variant="contained"
144
- disabled={activeCategory <= 0}
145
- onClick={() => this.handleStep(activeCategory - 1)}
146
- >
147
- Previous
148
- </Button>
149
- </div>) : (<></>)}
150
- </Hidden>
151
- );
152
- }
153
- }
73
+ const {
74
+ data,
75
+ path,
76
+ renderers,
77
+ schema,
78
+ uischema,
79
+ visible,
80
+ cells,
81
+ config,
82
+ ajv
83
+ } = props;
84
+ const categorization = uischema as Categorization;
85
+ const appliedUiSchemaOptions = merge({}, config, uischema.options);
86
+ const buttonWrapperStyle = {
87
+ textAlign: 'right' as 'right',
88
+ width: '100%',
89
+ margin: '1em auto'
90
+ };
91
+ const buttonNextStyle = {
92
+ float: 'right' as 'right'
93
+ };
94
+ const buttonStyle = {
95
+ marginRight: '1em'
96
+ };
97
+ const categories = categorization.elements.filter((category: Category) =>
98
+ isVisible(category, data, undefined, ajv)
99
+ );
100
+ const childProps: MaterialLayoutRendererProps = {
101
+ elements: categories[activeCategory].elements,
102
+ schema,
103
+ path,
104
+ direction: 'column',
105
+ visible,
106
+ renderers,
107
+ cells
108
+ };
109
+ return (
110
+ <Hidden xsUp={!visible}>
111
+ <Stepper activeStep={activeCategory} nonLinear>
112
+ {categories.map((e: Category, idx: number) => (
113
+ <Step key={e.label}>
114
+ <StepButton onClick={() => handleStep(idx)}>
115
+ {e.label}
116
+ </StepButton>
117
+ </Step>
118
+ ))}
119
+ </Stepper>
120
+ <div>
121
+ <MaterialLayoutRenderer {...childProps} />
122
+ </div>
123
+ { !!appliedUiSchemaOptions.showNavButtons ? (<div style={buttonWrapperStyle}>
124
+ <Button
125
+ style={buttonNextStyle}
126
+ variant="contained"
127
+ color="primary"
128
+ disabled={activeCategory >= categories.length - 1}
129
+ onClick={() => handleStep(activeCategory + 1)}
130
+ >
131
+ Next
132
+ </Button>
133
+ <Button
134
+ style={buttonStyle}
135
+ color="secondary"
136
+ variant="contained"
137
+ disabled={activeCategory <= 0}
138
+ onClick={() => handleStep(activeCategory - 1)}
139
+ >
140
+ Previous
141
+ </Button>
142
+ </div>) : (<></>)}
143
+ </Hidden>
144
+ );
145
+ };
154
146
 
155
147
  export default withJsonFormsLayoutProps(withAjvProps(
156
148
  MaterialCategorizationStepperLayoutRenderer
@@ -25,7 +25,6 @@
25
25
  import React from 'react';
26
26
  import { CellProps, WithClassname } from '@jsonforms/core';
27
27
  import Checkbox from '@material-ui/core/Checkbox';
28
- import { areEqual } from '@jsonforms/react';
29
28
  import merge from 'lodash/merge';
30
29
 
31
30
  export const MuiCheckbox = React.memo((props: CellProps & WithClassname) => {
@@ -54,4 +53,4 @@ export const MuiCheckbox = React.memo((props: CellProps & WithClassname) => {
54
53
  inputProps={inputProps}
55
54
  />
56
55
  );
57
- }, areEqual);
56
+ });
@@ -25,10 +25,14 @@
25
25
  import React from 'react';
26
26
  import { CellProps, WithClassname } from '@jsonforms/core';
27
27
  import Input from '@material-ui/core/Input';
28
- import { areEqual } from '@jsonforms/react';
29
28
  import merge from 'lodash/merge';
29
+ import { useDebouncedChange } from '../util';
30
30
 
31
- export const MuiInputInteger = React.memo(
31
+ const toNumber = (value: string) =>
32
+ value === '' ? undefined : parseInt(value, 10);
33
+ const eventToValue = (ev:any) => toNumber(ev.target.value);
34
+
35
+ export const MuiInputInteger = React.memo(
32
36
  (props: CellProps & WithClassname) => {
33
37
  const {
34
38
  data,
@@ -41,15 +45,16 @@ export const MuiInputInteger = React.memo(
41
45
  config
42
46
  } = props;
43
47
  const inputProps = { step: '1' };
44
- const toNumber = (value: string) =>
45
- value === '' ? undefined : parseInt(value, 10);
48
+
46
49
  const appliedUiSchemaOptions = merge({}, config, uischema.options);
47
50
 
51
+ const [inputValue, onChange] = useDebouncedChange(handleChange, '', data, path, eventToValue);
52
+
48
53
  return (
49
54
  <Input
50
55
  type='number'
51
- value={data !== undefined && data !== null ? data : ''}
52
- onChange={ev => handleChange(path, toNumber(ev.target.value))}
56
+ value={inputValue}
57
+ onChange={onChange}
53
58
  className={className}
54
59
  id={id}
55
60
  disabled={!enabled}
@@ -58,6 +63,4 @@ export const MuiInputInteger = React.memo(
58
63
  fullWidth={true}
59
64
  />
60
65
  );
61
- },
62
- areEqual
63
- );
66
+ });
@@ -25,9 +25,12 @@
25
25
  import React from 'react';
26
26
  import { CellProps, WithClassname } from '@jsonforms/core';
27
27
  import Input from '@material-ui/core/Input';
28
- import { areEqual } from '@jsonforms/react';
29
28
  import merge from 'lodash/merge';
29
+ import {useDebouncedChange} from '../util';
30
30
 
31
+ const toNumber = (value: string) =>
32
+ value === '' ? undefined : parseFloat(value);
33
+ const eventToValue = (ev:any) => toNumber(ev.target.value);
31
34
  export const MuiInputNumber = React.memo((props: CellProps & WithClassname) => {
32
35
  const {
33
36
  data,
@@ -40,15 +43,15 @@ export const MuiInputNumber = React.memo((props: CellProps & WithClassname) => {
40
43
  config
41
44
  } = props;
42
45
  const inputProps = { step: '0.1' };
43
- const toNumber = (value: string) =>
44
- value === '' ? undefined : parseFloat(value);
46
+
45
47
  const appliedUiSchemaOptions = merge({}, config, uischema.options);
48
+ const [inputValue, onChange] = useDebouncedChange(handleChange, '', data, path, eventToValue);
46
49
 
47
50
  return (
48
51
  <Input
49
52
  type='number'
50
- value={data === undefined || data === null ? '' : data}
51
- onChange={ev => handleChange(path, toNumber(ev.target.value))}
53
+ value={inputValue}
54
+ onChange={onChange}
52
55
  className={className}
53
56
  id={id}
54
57
  disabled={!enabled}
@@ -57,4 +60,4 @@ export const MuiInputNumber = React.memo((props: CellProps & WithClassname) => {
57
60
  fullWidth={true}
58
61
  />
59
62
  );
60
- }, areEqual);
63
+ });
@@ -22,13 +22,13 @@
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 React from 'react';
25
+ import React, {useCallback} from 'react';
26
26
  import { CellProps, Formatted, WithClassname } from '@jsonforms/core';
27
27
  import Input from '@material-ui/core/Input';
28
- import { areEqual } from '@jsonforms/react';
29
28
  import merge from 'lodash/merge';
29
+ import { useDebouncedChange } from '../util';
30
30
 
31
- export const MuiInputNumberFormat = React.memo(
31
+ export const MuiInputNumberFormat = React.memo(
32
32
  (props: CellProps & WithClassname & Formatted<number>) => {
33
33
  const {
34
34
  className,
@@ -51,15 +51,14 @@ export const MuiInputNumberFormat = React.memo(
51
51
  }
52
52
  const formattedNumber = props.toFormatted(props.data);
53
53
 
54
- const onChange = (ev: any) => {
55
- const validStringNumber = props.fromFormatted(ev.currentTarget.value);
56
- handleChange(path, validStringNumber);
57
- };
54
+ const validStringNumber = useCallback((ev:any) => props.fromFormatted(ev.currentTarget.value),[props.fromFormatted]);
55
+ const [inputValue, onChange] = useDebouncedChange(handleChange, '', formattedNumber, path, validStringNumber);
56
+
58
57
 
59
58
  return (
60
59
  <Input
61
60
  type='text'
62
- value={formattedNumber}
61
+ value={inputValue}
63
62
  onChange={onChange}
64
63
  className={className}
65
64
  id={id}
@@ -71,6 +70,4 @@ export const MuiInputNumberFormat = React.memo(
71
70
  error={!isValid}
72
71
  />
73
72
  );
74
- },
75
- areEqual
76
- );
73
+ });
@@ -24,22 +24,20 @@
24
24
  */
25
25
  import React, { useState } from 'react';
26
26
  import { CellProps, WithClassname } from '@jsonforms/core';
27
- import { areEqual } from '@jsonforms/react';
28
27
  import Input, { InputProps } from '@material-ui/core/Input';
29
28
  import merge from 'lodash/merge';
30
29
  import IconButton from '@material-ui/core/IconButton';
31
30
  import InputAdornment from '@material-ui/core/InputAdornment';
32
31
  import Close from '@material-ui/icons/Close';
33
32
  import { useTheme } from '@material-ui/core/styles';
34
- import { JsonFormsTheme } from '../util';
33
+ import { JsonFormsTheme, useDebouncedChange } from '../util';
35
34
  import { InputBaseComponentProps } from '@material-ui/core';
36
35
 
37
36
  interface MuiTextInputProps {
38
37
  muiInputProps?: InputProps['inputProps'];
39
38
  inputComponent?: InputProps['inputComponent'];
40
39
  }
41
-
42
- export const MuiInputText = React.memo((props: CellProps & WithClassname & MuiTextInputProps) => {
40
+ export const MuiInputText = React.memo((props: CellProps & WithClassname & MuiTextInputProps) => {
43
41
  const [showAdornment, setShowAdornment] = useState(false);
44
42
  const {
45
43
  data,
@@ -63,23 +61,27 @@ export const MuiInputText = React.memo((props: CellProps & WithClassname & MuiTe
63
61
  } else {
64
62
  inputProps = {};
65
63
  }
66
-
64
+
67
65
  inputProps = merge(inputProps, muiInputProps);
68
-
66
+
69
67
  if (appliedUiSchemaOptions.trim && maxLength !== undefined) {
70
68
  inputProps.size = maxLength;
71
- }
72
- const onChange = (ev: any) => handleChange(path, ev.target.value);
69
+ };
70
+
71
+ const [inputText, onChange, onClear] = useDebouncedChange(handleChange, '', data, path);
72
+ const onPointerEnter = () => setShowAdornment(true);
73
+ const onPointerLeave = () => setShowAdornment(false);
73
74
 
74
75
  const theme: JsonFormsTheme = useTheme();
75
- const inputDeleteBackgroundColor = theme.jsonforms?.input?.delete?.background || theme.palette.background.default;
76
+
77
+ const closeStyle = {background: theme.jsonforms?.input?.delete?.background || theme.palette.background.default, borderRadius: '50%'};
76
78
 
77
79
  return (
78
80
  <Input
79
81
  type={
80
82
  appliedUiSchemaOptions.format === 'password' ? 'password' : 'text'
81
83
  }
82
- value={data || ''}
84
+ value={inputText}
83
85
  onChange={onChange}
84
86
  className={className}
85
87
  id={id}
@@ -89,8 +91,8 @@ export const MuiInputText = React.memo((props: CellProps & WithClassname & MuiTe
89
91
  fullWidth={!appliedUiSchemaOptions.trim || maxLength === undefined}
90
92
  inputProps={inputProps}
91
93
  error={!isValid}
92
- onPointerEnter={() => setShowAdornment(true) }
93
- onPointerLeave={() => setShowAdornment(false) }
94
+ onPointerEnter={onPointerEnter}
95
+ onPointerLeave={onPointerLeave}
94
96
  endAdornment={
95
97
  <InputAdornment
96
98
  position='end'
@@ -103,13 +105,13 @@ export const MuiInputText = React.memo((props: CellProps & WithClassname & MuiTe
103
105
  >
104
106
  <IconButton
105
107
  aria-label='Clear input field'
106
- onClick={() => handleChange(path, undefined)}
108
+ onClick={onClear}
107
109
  >
108
- <Close style={{background: inputDeleteBackgroundColor, borderRadius: '50%'}}/>
110
+ <Close style={closeStyle}/>
109
111
  </IconButton>
110
112
  </InputAdornment>
111
113
  }
112
114
  inputComponent={inputComponent}
113
115
  />
114
116
  );
115
- }, areEqual);
117
+ });
@@ -25,8 +25,8 @@
25
25
  import React from 'react';
26
26
  import { CellProps, WithClassname } from '@jsonforms/core';
27
27
  import Input from '@material-ui/core/Input';
28
- import { areEqual } from '@jsonforms/react';
29
28
  import merge from 'lodash/merge';
29
+ import { useDebouncedChange } from '../util';
30
30
 
31
31
  export const MuiInputTime = React.memo((props: CellProps & WithClassname) => {
32
32
  const {
@@ -40,11 +40,13 @@ export const MuiInputTime = React.memo((props: CellProps & WithClassname) => {
40
40
  config
41
41
  } = props;
42
42
  const appliedUiSchemaOptions = merge({}, config, uischema.options);
43
+ const [inputValue, onChange] = useDebouncedChange(handleChange, '', data, path);
44
+
43
45
  return (
44
46
  <Input
45
47
  type='time'
46
- value={data || ''}
47
- onChange={ev => handleChange(path, ev.target.value)}
48
+ value={inputValue}
49
+ onChange={onChange}
48
50
  className={className}
49
51
  id={id}
50
52
  disabled={!enabled}
@@ -52,4 +54,4 @@ export const MuiInputTime = React.memo((props: CellProps & WithClassname) => {
52
54
  fullWidth={true}
53
55
  />
54
56
  );
55
- }, areEqual);
57
+ });
@@ -27,7 +27,6 @@ import { EnumCellProps, WithClassname } from '@jsonforms/core';
27
27
 
28
28
  import Select from '@material-ui/core/Select';
29
29
  import { MenuItem } from '@material-ui/core';
30
- import { areEqual } from '@jsonforms/react';
31
30
  import merge from 'lodash/merge';
32
31
 
33
32
  export const MuiSelect = React.memo((props: EnumCellProps & WithClassname) => {
@@ -50,7 +49,7 @@ export const MuiSelect = React.memo((props: EnumCellProps & WithClassname) => {
50
49
  id={id}
51
50
  disabled={!enabled}
52
51
  autoFocus={appliedUiSchemaOptions.focus}
53
- value={data || ''}
52
+ value={data !== undefined ? data : ''}
54
53
  onChange={ev => handleChange(path, ev.target.value)}
55
54
  fullWidth={true}
56
55
  >
@@ -63,4 +62,4 @@ export const MuiSelect = React.memo((props: EnumCellProps & WithClassname) => {
63
62
  )}
64
63
  </Select>
65
64
  );
66
- }, areEqual);
65
+ });
@@ -25,7 +25,6 @@
25
25
  import React from 'react';
26
26
  import { CellProps, WithClassname } from '@jsonforms/core';
27
27
  import Switch from '@material-ui/core/Switch';
28
- import { areEqual } from '@jsonforms/react';
29
28
  import merge from 'lodash/merge';
30
29
 
31
30
  export const MuiToggle = React.memo((props: CellProps & WithClassname) => {
@@ -53,4 +52,4 @@ export const MuiToggle = React.memo((props: CellProps & WithClassname) => {
53
52
  inputProps={inputProps}
54
53
  />
55
54
  );
56
- }, areEqual);
55
+ });
@@ -0,0 +1,43 @@
1
+ /*
2
+ The MIT License
3
+
4
+ Copyright (c) 2021 EclipseSource Munich
5
+ https://github.com/eclipsesource/jsonforms
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ of this software and associated documentation files (the "Software"), to deal
9
+ in the Software without restriction, including without limitation the rights
10
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ copies of the Software, and to permit persons to whom the Software is
12
+ furnished to do so, subject to the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be included in
15
+ all copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
+ THE SOFTWARE.
24
+ */
25
+ import { debounce } from 'lodash';
26
+ import { useState, useCallback, useEffect } from 'react'
27
+
28
+
29
+ const eventToValue = (ev: any) => ev.target.value;
30
+ export const useDebouncedChange = (handleChange: (path: string, value: any) => void, defaultValue: any, data: any, path: string, eventToValueFunction: (ev: any) => any = eventToValue, timeout = 300): [any, React.ChangeEventHandler, () => void] => {
31
+ const [input, setInput] = useState(data ?? defaultValue);
32
+ useEffect(() => {
33
+ setInput(data ?? defaultValue);
34
+ }, [data]);
35
+ const debouncedUpdate = useCallback(debounce((newValue: string) => handleChange(path, newValue), timeout), [handleChange, path, timeout]);
36
+ const onChange = useCallback((ev: any) => {
37
+ const newValue = eventToValueFunction(ev);
38
+ setInput(newValue ?? defaultValue);
39
+ debouncedUpdate(newValue);
40
+ }, [debouncedUpdate, eventToValueFunction]);
41
+ const onClear = useCallback(() => { setInput(defaultValue); handleChange(path, undefined) }, [defaultValue, handleChange, path]);
42
+ return [input, onChange, onClear];
43
+ };