@jsonforms/material-renderers 2.5.2-alpha.0 → 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 (311) hide show
  1. package/README.md +1 -1
  2. package/docs/assets/js/search.json +1 -1
  3. package/docs/classes/combinatorproperties.html +2 -5
  4. package/docs/classes/materialanyofstringorenumcontrol.html +6 -9
  5. package/docs/classes/materialtablecontrol.html +4 -7
  6. package/docs/globals.html +986 -274
  7. package/docs/index.html +78 -51
  8. package/docs/interfaces/ajvprops.html +1 -4
  9. package/docs/interfaces/arraylayouttoolbarprops.html +0 -3
  10. package/docs/interfaces/categorizationstate.html +0 -3
  11. package/docs/interfaces/categorizationstepperstate.html +0 -3
  12. package/docs/interfaces/combinatorpropertiesprops.html +0 -3
  13. package/docs/interfaces/deletedialogprops.html +0 -3
  14. package/docs/interfaces/dispatchpropsofexpandpanel.html +3 -6
  15. package/docs/interfaces/emptytableprops.html +0 -3
  16. package/docs/interfaces/expandpanelprops.html +19 -22
  17. package/docs/interfaces/jsonformstheme.html +0 -3
  18. package/docs/interfaces/materialcategorizationlayoutrendererprops.html +7 -10
  19. package/docs/interfaces/materialcategorizationstepperlayoutrendererprops.html +7 -10
  20. package/docs/interfaces/materiallayoutrendererprops.html +0 -3
  21. package/docs/interfaces/materialtabletoolbarprops.html +10 -13
  22. package/docs/interfaces/muitextinputprops.html +2 -5
  23. package/docs/interfaces/nonemptycellcomponentprops.html +266 -0
  24. package/docs/interfaces/nonemptycellprops.html +0 -3
  25. package/docs/interfaces/nonemptyrowprops.html +80 -27
  26. package/docs/interfaces/ownoneofprops.html +0 -3
  27. package/docs/interfaces/ownpropsofexpandpanel.html +14 -17
  28. package/docs/interfaces/ownpropsofnonemptycell.html +0 -3
  29. package/docs/interfaces/statepropsofexpandpanel.html +16 -19
  30. package/docs/interfaces/tableheadercellprops.html +0 -3
  31. package/docs/interfaces/tablerowsprop.html +9 -12
  32. package/docs/interfaces/validationprops.html +0 -3
  33. package/docs/interfaces/withdeletedialogsupport.html +0 -3
  34. package/docs/interfaces/withinput.html +1 -4
  35. package/docs/interfaces/withoptionlabel.html +3 -6
  36. package/lib/additional/ListWithDetailMasterItem.d.ts +1 -1
  37. package/lib/additional/ListWithDetailMasterItem.js.map +1 -1
  38. package/lib/additional/MaterialLabelRenderer.d.ts +1 -1
  39. package/lib/additional/MaterialLabelRenderer.js +3 -1
  40. package/lib/additional/MaterialLabelRenderer.js.map +1 -1
  41. package/lib/additional/MaterialListWithDetailRenderer.d.ts +1 -1
  42. package/lib/additional/MaterialListWithDetailRenderer.js +5 -3
  43. package/lib/additional/MaterialListWithDetailRenderer.js.map +1 -1
  44. package/lib/additional/index.js +3 -2
  45. package/lib/additional/index.js.map +1 -1
  46. package/lib/cells/CustomizableCells.d.ts +1 -0
  47. package/lib/cells/CustomizableCells.js +11 -8
  48. package/lib/cells/CustomizableCells.js.map +1 -1
  49. package/lib/cells/MaterialBooleanCell.d.ts +1 -1
  50. package/lib/cells/MaterialBooleanCell.js +3 -1
  51. package/lib/cells/MaterialBooleanCell.js.map +1 -1
  52. package/lib/cells/MaterialBooleanToggleCell.d.ts +1 -1
  53. package/lib/cells/MaterialBooleanToggleCell.js +3 -1
  54. package/lib/cells/MaterialBooleanToggleCell.js.map +1 -1
  55. package/lib/cells/MaterialDateCell.d.ts +1 -1
  56. package/lib/cells/MaterialDateCell.js +3 -1
  57. package/lib/cells/MaterialDateCell.js.map +1 -1
  58. package/lib/cells/MaterialEnumCell.d.ts +1 -1
  59. package/lib/cells/MaterialEnumCell.js +3 -1
  60. package/lib/cells/MaterialEnumCell.js.map +1 -1
  61. package/lib/cells/MaterialIntegerCell.d.ts +1 -1
  62. package/lib/cells/MaterialIntegerCell.js +3 -1
  63. package/lib/cells/MaterialIntegerCell.js.map +1 -1
  64. package/lib/cells/MaterialNumberCell.d.ts +1 -1
  65. package/lib/cells/MaterialNumberCell.js +3 -1
  66. package/lib/cells/MaterialNumberCell.js.map +1 -1
  67. package/lib/cells/MaterialNumberFormatCell.d.ts +1 -1
  68. package/lib/cells/MaterialNumberFormatCell.js +3 -1
  69. package/lib/cells/MaterialNumberFormatCell.js.map +1 -1
  70. package/lib/cells/MaterialOneOfEnumCell.d.ts +10 -0
  71. package/lib/cells/MaterialOneOfEnumCell.js +41 -0
  72. package/lib/cells/MaterialOneOfEnumCell.js.map +1 -0
  73. package/lib/cells/MaterialTextCell.d.ts +1 -1
  74. package/lib/cells/MaterialTextCell.js +3 -1
  75. package/lib/cells/MaterialTextCell.js.map +1 -1
  76. package/lib/cells/MaterialTimeCell.d.ts +1 -1
  77. package/lib/cells/MaterialTimeCell.js +3 -1
  78. package/lib/cells/MaterialTimeCell.js.map +1 -1
  79. package/lib/cells/index.d.ts +2 -1
  80. package/lib/cells/index.js +13 -9
  81. package/lib/cells/index.js.map +1 -1
  82. package/lib/complex/CombinatorProperties.js +4 -2
  83. package/lib/complex/CombinatorProperties.js.map +1 -1
  84. package/lib/complex/DeleteDialog.js +1 -0
  85. package/lib/complex/DeleteDialog.js.map +1 -1
  86. package/lib/complex/MaterialAllOfRenderer.d.ts +3 -2
  87. package/lib/complex/MaterialAllOfRenderer.js +5 -3
  88. package/lib/complex/MaterialAllOfRenderer.js.map +1 -1
  89. package/lib/complex/MaterialAnyOfRenderer.d.ts +3 -2
  90. package/lib/complex/MaterialAnyOfRenderer.js +4 -2
  91. package/lib/complex/MaterialAnyOfRenderer.js.map +1 -1
  92. package/lib/complex/MaterialArrayControlRenderer.d.ts +1 -1
  93. package/lib/complex/MaterialArrayControlRenderer.js +3 -1
  94. package/lib/complex/MaterialArrayControlRenderer.js.map +1 -1
  95. package/lib/complex/MaterialEnumArrayRenderer.d.ts +2 -2
  96. package/lib/complex/MaterialEnumArrayRenderer.js +6 -3
  97. package/lib/complex/MaterialEnumArrayRenderer.js.map +1 -1
  98. package/lib/complex/MaterialObjectRenderer.d.ts +3 -2
  99. package/lib/complex/MaterialObjectRenderer.js +5 -3
  100. package/lib/complex/MaterialObjectRenderer.js.map +1 -1
  101. package/lib/complex/MaterialOneOfRenderer.d.ts +2 -1
  102. package/lib/complex/MaterialOneOfRenderer.js +6 -5
  103. package/lib/complex/MaterialOneOfRenderer.js.map +1 -1
  104. package/lib/complex/MaterialTableControl.d.ts +16 -1
  105. package/lib/complex/MaterialTableControl.js +16 -8
  106. package/lib/complex/MaterialTableControl.js.map +1 -1
  107. package/lib/complex/NoBorderTableCell.js.map +1 -1
  108. package/lib/complex/TableToolbar.d.ts +2 -2
  109. package/lib/complex/TableToolbar.js.map +1 -1
  110. package/lib/complex/ValidationIcon.d.ts +5 -3
  111. package/lib/complex/ValidationIcon.js.map +1 -1
  112. package/lib/complex/index.js +6 -5
  113. package/lib/complex/index.js.map +1 -1
  114. package/lib/controls/MaterialAnyOfStringOrEnumControl.d.ts +1 -1
  115. package/lib/controls/MaterialAnyOfStringOrEnumControl.js +17 -12
  116. package/lib/controls/MaterialAnyOfStringOrEnumControl.js.map +1 -1
  117. package/lib/controls/MaterialBooleanControl.d.ts +1 -1
  118. package/lib/controls/MaterialBooleanControl.js +3 -1
  119. package/lib/controls/MaterialBooleanControl.js.map +1 -1
  120. package/lib/controls/MaterialBooleanToggleControl.d.ts +1 -1
  121. package/lib/controls/MaterialBooleanToggleControl.js +3 -1
  122. package/lib/controls/MaterialBooleanToggleControl.js.map +1 -1
  123. package/lib/controls/MaterialDateControl.d.ts +3 -15
  124. package/lib/controls/MaterialDateControl.js +27 -45
  125. package/lib/controls/MaterialDateControl.js.map +1 -1
  126. package/lib/controls/MaterialDateTimeControl.d.ts +3 -6
  127. package/lib/controls/MaterialDateTimeControl.js +27 -24
  128. package/lib/controls/MaterialDateTimeControl.js.map +1 -1
  129. package/lib/controls/MaterialEnumControl.d.ts +1 -1
  130. package/lib/controls/MaterialEnumControl.js +3 -1
  131. package/lib/controls/MaterialEnumControl.js.map +1 -1
  132. package/lib/controls/MaterialInputControl.d.ts +2 -5
  133. package/lib/controls/MaterialInputControl.js +23 -28
  134. package/lib/controls/MaterialInputControl.js.map +1 -1
  135. package/lib/controls/MaterialIntegerControl.d.ts +1 -1
  136. package/lib/controls/MaterialIntegerControl.js +3 -1
  137. package/lib/controls/MaterialIntegerControl.js.map +1 -1
  138. package/lib/controls/MaterialNativeControl.d.ts +3 -6
  139. package/lib/controls/MaterialNativeControl.js +15 -18
  140. package/lib/controls/MaterialNativeControl.js.map +1 -1
  141. package/lib/controls/MaterialNumberControl.d.ts +1 -1
  142. package/lib/controls/MaterialNumberControl.js +3 -1
  143. package/lib/controls/MaterialNumberControl.js.map +1 -1
  144. package/lib/controls/MaterialOneOfEnumControl.d.ts +1 -1
  145. package/lib/controls/MaterialOneOfEnumControl.js +3 -1
  146. package/lib/controls/MaterialOneOfEnumControl.js.map +1 -1
  147. package/lib/controls/MaterialOneOfRadioGroupControl.d.ts +1 -1
  148. package/lib/controls/MaterialOneOfRadioGroupControl.js +3 -1
  149. package/lib/controls/MaterialOneOfRadioGroupControl.js.map +1 -1
  150. package/lib/controls/MaterialRadioGroup.d.ts +2 -5
  151. package/lib/controls/MaterialRadioGroup.js +15 -20
  152. package/lib/controls/MaterialRadioGroup.js.map +1 -1
  153. package/lib/controls/MaterialRadioGroupControl.d.ts +1 -1
  154. package/lib/controls/MaterialRadioGroupControl.js +3 -1
  155. package/lib/controls/MaterialRadioGroupControl.js.map +1 -1
  156. package/lib/controls/MaterialSliderControl.d.ts +3 -6
  157. package/lib/controls/MaterialSliderControl.js +35 -39
  158. package/lib/controls/MaterialSliderControl.js.map +1 -1
  159. package/lib/controls/MaterialTextControl.d.ts +1 -1
  160. package/lib/controls/MaterialTextControl.js +3 -1
  161. package/lib/controls/MaterialTextControl.js.map +1 -1
  162. package/lib/controls/MaterialTimeControl.d.ts +6 -0
  163. package/lib/controls/MaterialTimeControl.js +62 -0
  164. package/lib/controls/MaterialTimeControl.js.map +1 -0
  165. package/lib/controls/index.d.ts +11 -9
  166. package/lib/controls/index.js +19 -14
  167. package/lib/controls/index.js.map +1 -1
  168. package/lib/extended/MaterialAutocompleteEnumControl.d.ts +1 -1
  169. package/lib/extended/MaterialAutocompleteEnumControl.js +3 -1
  170. package/lib/extended/MaterialAutocompleteEnumControl.js.map +1 -1
  171. package/lib/extended/MaterialAutocompleteOneOfEnumControl.d.ts +1 -1
  172. package/lib/extended/MaterialAutocompleteOneOfEnumControl.js +3 -1
  173. package/lib/extended/MaterialAutocompleteOneOfEnumControl.js.map +1 -1
  174. package/lib/extended/MuiAutocomplete.d.ts +2 -2
  175. package/lib/extended/MuiAutocomplete.js +4 -3
  176. package/lib/extended/MuiAutocomplete.js.map +1 -1
  177. package/lib/extended/index.d.ts +2 -2
  178. package/lib/extended/index.js +2 -1
  179. package/lib/extended/index.js.map +1 -1
  180. package/lib/index.js +3 -0
  181. package/lib/index.js.map +1 -1
  182. package/lib/jsonforms-material.js +9 -281
  183. package/lib/jsonforms-material.js.map +1 -1
  184. package/lib/layouts/ArrayToolbar.js +1 -0
  185. package/lib/layouts/ArrayToolbar.js.map +1 -1
  186. package/lib/layouts/ExpandPanelRenderer.d.ts +2 -3
  187. package/lib/layouts/ExpandPanelRenderer.js +29 -22
  188. package/lib/layouts/ExpandPanelRenderer.js.map +1 -1
  189. package/lib/layouts/MaterialArrayLayout.d.ts +1 -11
  190. package/lib/layouts/MaterialArrayLayout.js +19 -31
  191. package/lib/layouts/MaterialArrayLayout.js.map +1 -1
  192. package/lib/layouts/MaterialArrayLayoutRenderer.d.ts +1 -1
  193. package/lib/layouts/MaterialArrayLayoutRenderer.js +3 -1
  194. package/lib/layouts/MaterialArrayLayoutRenderer.js.map +1 -1
  195. package/lib/layouts/MaterialCategorizationLayout.d.ts +2 -10
  196. package/lib/layouts/MaterialCategorizationLayout.js +31 -47
  197. package/lib/layouts/MaterialCategorizationLayout.js.map +1 -1
  198. package/lib/layouts/MaterialCategorizationStepperLayout.d.ts +2 -9
  199. package/lib/layouts/MaterialCategorizationStepperLayout.js +42 -53
  200. package/lib/layouts/MaterialCategorizationStepperLayout.js.map +1 -1
  201. package/lib/layouts/MaterialGroupLayout.d.ts +1 -1
  202. package/lib/layouts/MaterialGroupLayout.js +3 -1
  203. package/lib/layouts/MaterialGroupLayout.js.map +1 -1
  204. package/lib/layouts/MaterialHorizontalLayout.d.ts +1 -1
  205. package/lib/layouts/MaterialHorizontalLayout.js +3 -1
  206. package/lib/layouts/MaterialHorizontalLayout.js.map +1 -1
  207. package/lib/layouts/MaterialVerticalLayout.d.ts +1 -1
  208. package/lib/layouts/MaterialVerticalLayout.js +3 -1
  209. package/lib/layouts/MaterialVerticalLayout.js.map +1 -1
  210. package/lib/layouts/index.js +6 -5
  211. package/lib/layouts/index.js.map +1 -1
  212. package/lib/mui-controls/MuiCheckbox.js +2 -2
  213. package/lib/mui-controls/MuiCheckbox.js.map +1 -1
  214. package/lib/mui-controls/MuiInputInteger.js +9 -6
  215. package/lib/mui-controls/MuiInputInteger.js.map +1 -1
  216. package/lib/mui-controls/MuiInputNumber.js +9 -6
  217. package/lib/mui-controls/MuiInputNumber.js.map +1 -1
  218. package/lib/mui-controls/MuiInputNumberFormat.js +7 -8
  219. package/lib/mui-controls/MuiInputNumberFormat.js.map +1 -1
  220. package/lib/mui-controls/MuiInputText.js +11 -7
  221. package/lib/mui-controls/MuiInputText.js.map +1 -1
  222. package/lib/mui-controls/MuiInputTime.js +5 -3
  223. package/lib/mui-controls/MuiInputTime.js.map +1 -1
  224. package/lib/mui-controls/MuiSelect.js +3 -3
  225. package/lib/mui-controls/MuiSelect.js.map +1 -1
  226. package/lib/mui-controls/MuiToggle.js +2 -2
  227. package/lib/mui-controls/MuiToggle.js.map +1 -1
  228. package/lib/util/datejs.d.ts +3 -0
  229. package/lib/util/datejs.js +29 -0
  230. package/lib/util/datejs.js.map +1 -0
  231. package/lib/util/debounce.d.ts +1 -0
  232. package/lib/util/debounce.js +48 -0
  233. package/lib/util/debounce.js.map +1 -0
  234. package/lib/util/focus.d.ts +1 -0
  235. package/lib/util/focus.js +36 -0
  236. package/lib/util/focus.js.map +1 -0
  237. package/lib/util/index.d.ts +3 -0
  238. package/lib/util/index.js +4 -0
  239. package/lib/util/index.js.map +1 -1
  240. package/lib/util/layout.d.ts +2 -1
  241. package/lib/util/layout.js +9 -5
  242. package/lib/util/layout.js.map +1 -1
  243. package/package.json +12 -13
  244. package/src/additional/MaterialListWithDetailRenderer.tsx +3 -4
  245. package/src/cells/CustomizableCells.ts +1 -0
  246. package/src/cells/MaterialOneOfEnumCell.tsx +46 -0
  247. package/src/cells/MaterialTimeCell.tsx +1 -0
  248. package/src/cells/index.ts +5 -0
  249. package/src/complex/CombinatorProperties.tsx +2 -2
  250. package/src/complex/MaterialAllOfRenderer.tsx +5 -4
  251. package/src/complex/MaterialAnyOfRenderer.tsx +4 -3
  252. package/src/complex/MaterialEnumArrayRenderer.tsx +1 -0
  253. package/src/complex/MaterialObjectRenderer.tsx +5 -5
  254. package/src/complex/MaterialOneOfRenderer.tsx +8 -8
  255. package/src/complex/MaterialTableControl.tsx +36 -24
  256. package/src/complex/TableToolbar.tsx +1 -2
  257. package/src/controls/MaterialAnyOfStringOrEnumControl.tsx +16 -12
  258. package/src/controls/MaterialDateControl.tsx +82 -113
  259. package/src/controls/MaterialDateTimeControl.tsx +88 -70
  260. package/src/controls/MaterialInputControl.tsx +62 -70
  261. package/src/controls/MaterialNativeControl.tsx +54 -58
  262. package/src/controls/MaterialRadioGroup.tsx +67 -70
  263. package/src/controls/MaterialSliderControl.tsx +92 -88
  264. package/src/controls/MaterialTimeControl.tsx +128 -0
  265. package/src/controls/index.ts +7 -0
  266. package/src/extended/MuiAutocomplete.tsx +2 -3
  267. package/src/index.ts +6 -0
  268. package/src/layouts/ExpandPanelRenderer.tsx +32 -32
  269. package/src/layouts/MaterialArrayLayout.tsx +73 -83
  270. package/src/layouts/MaterialCategorizationLayout.tsx +49 -65
  271. package/src/layouts/MaterialCategorizationStepperLayout.tsx +79 -87
  272. package/src/mui-controls/MuiCheckbox.tsx +1 -2
  273. package/src/mui-controls/MuiInputInteger.tsx +12 -9
  274. package/src/mui-controls/MuiInputNumber.tsx +9 -6
  275. package/src/mui-controls/MuiInputNumberFormat.tsx +8 -11
  276. package/src/mui-controls/MuiInputText.tsx +17 -15
  277. package/src/mui-controls/MuiInputTime.tsx +6 -4
  278. package/src/mui-controls/MuiSelect.tsx +2 -3
  279. package/src/mui-controls/MuiToggle.tsx +1 -2
  280. package/src/util/datejs.ts +32 -0
  281. package/src/util/debounce.ts +43 -0
  282. package/src/util/focus.ts +32 -0
  283. package/src/util/index.ts +3 -0
  284. package/src/util/layout.tsx +6 -7
  285. package/test/renderers/MaterialAnyOfRenderer.test.tsx +14 -8
  286. package/test/renderers/MaterialArrayLayout.test.tsx +8 -8
  287. package/test/renderers/MaterialBooleanToggleControl.test.tsx +0 -1
  288. package/test/renderers/MaterialCategorizationLayout.test.tsx +73 -0
  289. package/test/renderers/MaterialCategorizationStepperLayout.test.tsx +73 -0
  290. package/test/renderers/MaterialDateControl.test.tsx +42 -0
  291. package/test/renderers/MaterialDateTimeControl.test.tsx +54 -11
  292. package/test/renderers/MaterialInputControl.test.tsx +3 -3
  293. package/test/renderers/MaterialIntegerCell.test.tsx +41 -20
  294. package/test/renderers/MaterialNumberCell.test.tsx +45 -24
  295. package/test/renderers/MaterialOneOfEnumCell.test.tsx +93 -0
  296. package/test/renderers/MaterialOneOfRenderer.test.tsx +10 -7
  297. package/test/renderers/MaterialTextCell.test.tsx +41 -20
  298. package/test/renderers/MaterialTimeCell.test.tsx +41 -20
  299. package/test/renderers/MaterialTimeControl.test.tsx +378 -0
  300. package/docs/classes/materialarraylayout.html +0 -777
  301. package/docs/classes/materialcategorizationlayoutrenderer.html +0 -786
  302. package/docs/classes/materialcategorizationstepperlayoutrenderer.html +0 -762
  303. package/docs/classes/materialdatecontrol.html +0 -825
  304. package/docs/classes/materialdatetimecontrol.html +0 -825
  305. package/docs/classes/materialinputcontrol.html +0 -825
  306. package/docs/classes/materialnativecontrol.html +0 -825
  307. package/docs/classes/materialradiogroup.html +0 -825
  308. package/docs/classes/materialslidercontrol.html +0 -825
  309. package/docs/interfaces/datecontrol.html +0 -157
  310. package/docs/interfaces/materialarraylayoutstate.html +0 -157
  311. package/docs/interfaces/statepropsofdatecontrol.html +0 -468
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  The MIT License
3
3
 
4
- Copyright (c) 2017-2019 EclipseSource Munich
4
+ Copyright (c) 2017-2021 EclipseSource Munich
5
5
  https://github.com/eclipsesource/jsonforms
6
6
 
7
7
  Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -24,88 +24,80 @@
24
24
  */
25
25
  import React from 'react';
26
26
  import {
27
- computeLabel,
27
+ showAsRequired,
28
28
  ControlProps,
29
- ControlState,
30
29
  isDescriptionHidden,
31
- isPlainLabel
32
30
  } from '@jsonforms/core';
33
- import { Control } from '@jsonforms/react';
34
31
 
35
32
  import { Hidden, InputLabel } from '@material-ui/core';
36
33
  import { FormControl, FormHelperText } from '@material-ui/core';
37
34
  import merge from 'lodash/merge';
35
+ import { useFocus } from '../util';
38
36
 
39
37
  export interface WithInput {
40
38
  input: any;
41
39
  }
42
40
 
43
- export abstract class MaterialInputControl extends Control<
44
- ControlProps & WithInput,
45
- ControlState
46
- > {
47
- render() {
48
- const {
49
- id,
50
- description,
51
- errors,
52
- label,
53
- uischema,
54
- visible,
55
- required,
56
- config,
57
- input
58
- } = this.props;
59
- const isValid = errors.length === 0;
60
- const appliedUiSchemaOptions = merge({}, config, uischema.options);
41
+ export const MaterialInputControl = (props: ControlProps & WithInput) => {
42
+ const [focused, onFocus, onBlur] = useFocus();
43
+ const {
44
+ id,
45
+ description,
46
+ errors,
47
+ label,
48
+ uischema,
49
+ visible,
50
+ required,
51
+ config,
52
+ input
53
+ } = props;
54
+ const isValid = errors.length === 0;
55
+ const appliedUiSchemaOptions = merge({}, config, uischema.options);
61
56
 
62
- const showDescription = !isDescriptionHidden(
63
- visible,
64
- description,
65
- this.state.isFocused,
66
- appliedUiSchemaOptions.showUnfocusedDescription
67
- );
57
+ const showDescription = !isDescriptionHidden(
58
+ visible,
59
+ description,
60
+ focused,
61
+ appliedUiSchemaOptions.showUnfocusedDescription
62
+ );
68
63
 
69
- const firstFormHelperText = showDescription
70
- ? description
71
- : !isValid
72
- ? errors
73
- : null;
74
- const secondFormHelperText = showDescription && !isValid ? errors : null;
75
- const InnerComponent = input;
64
+ const firstFormHelperText = showDescription
65
+ ? description
66
+ : !isValid
67
+ ? errors
68
+ : null;
69
+ const secondFormHelperText = showDescription && !isValid ? errors : null;
70
+ const InnerComponent = input;
76
71
 
77
- return (
78
- <Hidden xsUp={!visible}>
79
- <FormControl
80
- fullWidth={!appliedUiSchemaOptions.trim}
81
- onFocus={this.onFocus}
82
- onBlur={this.onBlur}
83
- id={id}
72
+ return (
73
+ <Hidden xsUp={!visible}>
74
+ <FormControl
75
+ fullWidth={!appliedUiSchemaOptions.trim}
76
+ onFocus={onFocus}
77
+ onBlur={onBlur}
78
+ id={id}
79
+ >
80
+ <InputLabel
81
+ htmlFor={id + '-input'}
82
+ error={!isValid}
83
+ required={showAsRequired(required,
84
+ appliedUiSchemaOptions.hideRequiredAsterisk)}
84
85
  >
85
- <InputLabel
86
- htmlFor={id + '-input'}
87
- error={!isValid}
88
- >
89
- {computeLabel(
90
- isPlainLabel(label) ? label : label.default,
91
- required,
92
- appliedUiSchemaOptions.hideRequiredAsterisk
93
- )}
94
- </InputLabel>
95
- <InnerComponent
96
- {...this.props}
97
- id={id + '-input'}
98
- isValid={isValid}
99
- visible={visible}
100
- />
101
- <FormHelperText error={!isValid && !showDescription}>
102
- {firstFormHelperText}
103
- </FormHelperText>
104
- <FormHelperText error={!isValid}>
105
- {secondFormHelperText}
106
- </FormHelperText>
107
- </FormControl>
108
- </Hidden>
109
- );
110
- }
111
- }
86
+ {label}
87
+ </InputLabel>
88
+ <InnerComponent
89
+ {...props}
90
+ id={id + '-input'}
91
+ isValid={isValid}
92
+ visible={visible}
93
+ />
94
+ <FormHelperText error={!isValid && !showDescription}>
95
+ {firstFormHelperText}
96
+ </FormHelperText>
97
+ <FormHelperText error={!isValid}>
98
+ {secondFormHelperText}
99
+ </FormHelperText>
100
+ </FormControl>
101
+ </Hidden>
102
+ );
103
+ };
@@ -24,77 +24,73 @@
24
24
  */
25
25
  import React from 'react';
26
26
  import {
27
- computeLabel,
28
27
  ControlProps,
29
- ControlState,
28
+ showAsRequired,
30
29
  isDateControl,
31
30
  isDescriptionHidden,
32
- isPlainLabel,
33
31
  isTimeControl,
34
32
  or,
35
33
  RankedTester,
36
34
  rankWith
37
35
  } from '@jsonforms/core';
38
36
  import { Hidden } from '@material-ui/core';
39
- import { Control, withJsonFormsControlProps } from '@jsonforms/react';
37
+ import { withJsonFormsControlProps } from '@jsonforms/react';
40
38
  import TextField from '@material-ui/core/TextField';
41
39
  import merge from 'lodash/merge';
40
+ import { useDebouncedChange, useFocus } from '../util';
42
41
 
43
- export class MaterialNativeControl extends Control<ControlProps, ControlState> {
44
- render() {
45
- const {
46
- id,
47
- errors,
48
- label,
49
- schema,
50
- description,
51
- enabled,
52
- visible,
53
- required,
54
- path,
55
- handleChange,
56
- data,
57
- config
58
- } = this.props;
59
- const isValid = errors.length === 0;
60
- const appliedUiSchemaOptions = merge(
61
- {},
62
- config,
63
- this.props.uischema.options
64
- );
65
- const onChange = (ev: any) => handleChange(path, ev.target.value);
66
- const fieldType = schema.format;
67
- const showDescription = !isDescriptionHidden(
68
- visible,
69
- description,
70
- this.state.isFocused,
71
- appliedUiSchemaOptions.showUnfocusedDescription
72
- );
42
+ export const MaterialNativeControl = (props: ControlProps) => {
43
+ const [focused, onFocus, onBlur] = useFocus();
44
+ const {
45
+ id,
46
+ errors,
47
+ label,
48
+ schema,
49
+ description,
50
+ enabled,
51
+ visible,
52
+ required,
53
+ path,
54
+ handleChange,
55
+ data,
56
+ config
57
+ } = props;
58
+ const isValid = errors.length === 0;
59
+ const appliedUiSchemaOptions = merge(
60
+ {},
61
+ config,
62
+ props.uischema.options
63
+ );
64
+ const [inputValue, onChange] = useDebouncedChange(handleChange, '', data, path);
65
+ const fieldType = appliedUiSchemaOptions.format ?? schema.format;
66
+ const showDescription = !isDescriptionHidden(
67
+ visible,
68
+ description,
69
+ focused,
70
+ appliedUiSchemaOptions.showUnfocusedDescription
71
+ );
73
72
 
74
- return (
75
- <Hidden xsUp={!visible}>
76
- <TextField
77
- id={id + '-input'}
78
- label={computeLabel(
79
- isPlainLabel(label) ? label : label.default,
80
- required,
81
- appliedUiSchemaOptions.hideRequiredAsterisk
82
- )}
83
- type={fieldType}
84
- error={!isValid}
85
- disabled={!enabled}
86
- fullWidth={!appliedUiSchemaOptions.trim}
87
- onFocus={this.onFocus}
88
- onBlur={this.onBlur}
89
- helperText={!isValid ? errors : showDescription ? description : null}
90
- InputLabelProps={{ shrink: true }}
91
- value={data}
92
- onChange={onChange}
93
- />
94
- </Hidden>
95
- );
96
- }
97
- }
73
+ return (
74
+ <Hidden xsUp={!visible}>
75
+ <TextField
76
+ required={showAsRequired(required,
77
+ appliedUiSchemaOptions.hideRequiredAsterisk)}
78
+ id={id + '-input'}
79
+ label={label}
80
+ type={fieldType}
81
+ error={!isValid}
82
+ disabled={!enabled}
83
+ fullWidth={!appliedUiSchemaOptions.trim}
84
+ onFocus={onFocus}
85
+ onBlur={onBlur}
86
+ helperText={!isValid ? errors : showDescription ? description : null}
87
+ InputLabelProps={{ shrink: true }}
88
+ value={inputValue}
89
+ onChange={onChange}
90
+ />
91
+ </Hidden>
92
+ );
93
+ };
98
94
 
99
95
  export const materialNativeControlTester: RankedTester = rankWith(
100
96
  2,
@@ -25,14 +25,11 @@
25
25
  import merge from 'lodash/merge';
26
26
  import React from 'react';
27
27
  import {
28
- computeLabel,
29
28
  ControlProps,
30
- ControlState,
29
+ showAsRequired,
31
30
  isDescriptionHidden,
32
- isPlainLabel,
33
31
  OwnPropsOfEnum
34
32
  } from '@jsonforms/core';
35
- import { Control } from '@jsonforms/react';
36
33
  import Radio from '@material-ui/core/Radio';
37
34
  import RadioGroup from '@material-ui/core/RadioGroup';
38
35
  import {
@@ -42,73 +39,73 @@ import {
42
39
  FormLabel,
43
40
  Hidden
44
41
  } from '@material-ui/core';
42
+ import { useFocus } from '../util';
45
43
 
46
- export class MaterialRadioGroup extends Control<
47
- ControlProps & OwnPropsOfEnum,
48
- ControlState
49
- > {
50
- render() {
51
- const {
52
- config,
53
- id,
54
- label,
55
- required,
56
- description,
57
- errors,
58
- data,
59
- visible,
60
- options
61
- } = this.props;
62
- const isValid = errors.length === 0;
63
- const appliedUiSchemaOptions = merge(
64
- {},
65
- config,
66
- this.props.uischema.options
67
- );
68
- const showDescription = !isDescriptionHidden(
69
- visible,
70
- description,
71
- this.state.isFocused,
72
- appliedUiSchemaOptions.showUnfocusedDescription
73
- );
44
+ export const MaterialRadioGroup = (props: ControlProps & OwnPropsOfEnum) => {
45
+ const [focused, onFocus, onBlur] = useFocus();
46
+ const {
47
+ config,
48
+ id,
49
+ label,
50
+ required,
51
+ description,
52
+ errors,
53
+ data,
54
+ visible,
55
+ options,
56
+ handleChange,
57
+ path
58
+ } = props;
59
+ const isValid = errors.length === 0;
60
+ const appliedUiSchemaOptions = merge(
61
+ {},
62
+ config,
63
+ props.uischema.options
64
+ );
65
+ const showDescription = !isDescriptionHidden(
66
+ visible,
67
+ description,
68
+ focused,
69
+ appliedUiSchemaOptions.showUnfocusedDescription
70
+ );
71
+ const onChange = (_ev:any, value:any) => handleChange(path, value);
74
72
 
75
- return (
76
- <Hidden xsUp={!visible}>
77
- <FormControl
78
- component={'fieldset' as 'div'}
79
- fullWidth={!appliedUiSchemaOptions.trim}
73
+ return (
74
+ <Hidden xsUp={!visible}>
75
+ <FormControl
76
+ component={'fieldset' as 'div'}
77
+ fullWidth={!appliedUiSchemaOptions.trim}
78
+ onFocus={onFocus}
79
+ onBlur={onBlur}
80
+ >
81
+ <FormLabel
82
+ htmlFor={id}
83
+ error={!isValid}
84
+ component={'legend' as 'label'}
85
+ required={showAsRequired(required,
86
+ appliedUiSchemaOptions.hideRequiredAsterisk)}
80
87
  >
81
- <FormLabel
82
- htmlFor={id}
83
- error={!isValid}
84
- component={'legend' as 'label'}
85
- >
86
- {computeLabel(
87
- isPlainLabel(label) ? label : label.default,
88
- required,
89
- appliedUiSchemaOptions.hideRequiredAsterisk
90
- )}
91
- </FormLabel>
88
+ {label}
89
+ </FormLabel>
92
90
 
93
- <RadioGroup
94
- value={this.state.value}
95
- onChange={(_ev, value) => this.handleChange(value)}
96
- row={true}
97
- >
98
- {options.map(option => (
99
- <FormControlLabel
100
- value={option.value}
101
- key={option.label}
102
- control={<Radio checked={data === option.value} />}
103
- label={option.label}
104
- />
105
- ))}
106
- </RadioGroup>
107
- <FormHelperText error={!isValid}>
108
- {!isValid ? errors : showDescription ? description : null}
109
- </FormHelperText>
110
- </FormControl>
111
- </Hidden>
112
- );
113
- }
114
- }
91
+ <RadioGroup
92
+ value={props.data}
93
+ onChange={onChange}
94
+ row={true}
95
+ >
96
+ {options.map(option => (
97
+ <FormControlLabel
98
+ value={option.value}
99
+ key={option.label}
100
+ control={<Radio checked={data === option.value} />}
101
+ label={option.label}
102
+ />
103
+ ))}
104
+ </RadioGroup>
105
+ <FormHelperText error={!isValid}>
106
+ {!isValid ? errors : showDescription ? description : null}
107
+ </FormHelperText>
108
+ </FormControl>
109
+ </Hidden>
110
+ );
111
+ };
@@ -22,115 +22,119 @@
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 {
27
- computeLabel,
28
27
  ControlProps,
29
- ControlState,
28
+ showAsRequired,
30
29
  isDescriptionHidden,
31
- isPlainLabel,
32
30
  isRangeControl,
33
31
  RankedTester,
34
32
  rankWith
35
33
  } from '@jsonforms/core';
36
- import { Control, withJsonFormsControlProps } from '@jsonforms/react';
34
+ import { withJsonFormsControlProps } from '@jsonforms/react';
37
35
 
38
36
  import {
39
37
  FormControl,
40
38
  FormHelperText,
39
+ FormLabel,
41
40
  Hidden,
42
41
  Slider,
43
42
  Typography
44
43
  } from '@material-ui/core';
45
44
  import merge from 'lodash/merge';
45
+ import { useFocus } from '../util';
46
46
 
47
- export class MaterialSliderControl extends Control<ControlProps, ControlState> {
48
- render() {
49
- const {
50
- id,
51
- data,
52
- description,
53
- enabled,
54
- errors,
55
- label,
56
- schema,
57
- handleChange,
58
- visible,
59
- path,
60
- required,
61
- config
62
- } = this.props;
63
- const isValid = errors.length === 0;
64
- const appliedUiSchemaOptions = merge(
65
- {},
66
- config,
67
- this.props.uischema.options
68
- );
69
- const labelStyle: { [x: string]: any } = {
70
- whiteSpace: 'nowrap',
71
- overflow: 'hidden',
72
- textOverflow: 'ellipsis',
73
- width: '100%'
74
- };
75
- const rangeContainerStyle: { [x: string]: any } = {
76
- display: 'flex'
77
- };
78
- const rangeItemStyle: { [x: string]: any } = {
79
- flexGrow: '1'
80
- };
81
- const sliderStyle: { [x: string]: any } = {
82
- marginTop: '7px'
83
- };
47
+ export const MaterialSliderControl = (props: ControlProps) => {
48
+ const [focused, onFocus, onBlur] = useFocus();
49
+ const {
50
+ id,
51
+ data,
52
+ description,
53
+ enabled,
54
+ errors,
55
+ label,
56
+ schema,
57
+ handleChange,
58
+ visible,
59
+ path,
60
+ required,
61
+ config
62
+ } = props;
63
+ const isValid = errors.length === 0;
64
+ const appliedUiSchemaOptions = merge(
65
+ {},
66
+ config,
67
+ props.uischema.options
68
+ );
69
+ const labelStyle: { [x: string]: any } = {
70
+ whiteSpace: 'nowrap',
71
+ overflow: 'hidden',
72
+ textOverflow: 'ellipsis',
73
+ width: '100%'
74
+ };
75
+ const rangeContainerStyle: { [x: string]: any } = {
76
+ display: 'flex'
77
+ };
78
+ const rangeItemStyle: { [x: string]: any } = {
79
+ flexGrow: '1'
80
+ };
81
+ const sliderStyle: { [x: string]: any } = {
82
+ marginTop: '7px'
83
+ };
84
84
 
85
- const showDescription = !isDescriptionHidden(
86
- visible,
87
- description,
88
- this.state.isFocused,
89
- appliedUiSchemaOptions.showUnfocusedDescription
90
- );
91
- return (
92
- <Hidden xsUp={!visible}>
93
- <FormControl
94
- fullWidth={!appliedUiSchemaOptions.trim}
95
- onFocus={this.onFocus}
96
- onBlur={this.onBlur}
97
- id={id}
85
+ const showDescription = !isDescriptionHidden(
86
+ visible,
87
+ description,
88
+ focused,
89
+ appliedUiSchemaOptions.showUnfocusedDescription
90
+ );
91
+
92
+ const onChange = useCallback((_ev: any, value: any) => handleChange(path, Number(value)), [path, handleChange]);
93
+
94
+ return (
95
+ <Hidden xsUp={!visible}>
96
+ <FormControl
97
+ fullWidth={!appliedUiSchemaOptions.trim}
98
+ onFocus={onFocus}
99
+ onBlur={onBlur}
100
+ id={id}
101
+ >
102
+ <FormLabel
103
+ htmlFor={id}
104
+ error={!isValid}
105
+ component={'legend' as 'label'}
106
+ required={showAsRequired(required,
107
+ appliedUiSchemaOptions.hideRequiredAsterisk)}
98
108
  >
99
109
  <Typography id={id + '-typo'} style={labelStyle} variant='caption'>
100
- {computeLabel(
101
- isPlainLabel(label) ? label : label.default,
102
- required,
103
- appliedUiSchemaOptions.hideRequiredAsterisk
104
- )}
110
+ {label}
111
+ </Typography>
112
+ </FormLabel>
113
+ <div style={rangeContainerStyle}>
114
+ <Typography style={rangeItemStyle} variant='caption' align='left'>
115
+ {schema.minimum}
116
+ </Typography>
117
+ <Typography style={rangeItemStyle} variant='caption' align='right'>
118
+ {schema.maximum}
105
119
  </Typography>
106
- <div style={rangeContainerStyle}>
107
- <Typography style={rangeItemStyle} variant='caption' align='left'>
108
- {schema.minimum}
109
- </Typography>
110
- <Typography style={rangeItemStyle} variant='caption' align='right'>
111
- {schema.maximum}
112
- </Typography>
113
- </div>
114
- <Slider
115
- style={sliderStyle}
116
- min={schema.minimum}
117
- max={schema.maximum}
118
- value={Number(data || schema.default)}
119
- onChange={(_ev: any, value: any) => {
120
- handleChange(path, Number(value));
121
- }}
122
- id={id + '-input'}
123
- disabled={!enabled}
124
- step={schema.multipleOf || 1}
125
- />
126
- <FormHelperText error={!isValid}>
127
- {!isValid ? errors : showDescription ? description : null}
128
- </FormHelperText>
129
- </FormControl>
130
- </Hidden>
131
- );
132
- }
133
- }
120
+ </div>
121
+ <Slider
122
+ style={sliderStyle}
123
+ min={schema.minimum}
124
+ max={schema.maximum}
125
+ value={Number(data || schema.default)}
126
+ onChange={onChange}
127
+ id={id + '-input'}
128
+ disabled={!enabled}
129
+ step={schema.multipleOf || 1}
130
+ />
131
+ <FormHelperText error={!isValid}>
132
+ {!isValid ? errors : showDescription ? description : null}
133
+ </FormHelperText>
134
+ </FormControl>
135
+ </Hidden>
136
+ );
137
+ };
134
138
  export const materialSliderControlTester: RankedTester = rankWith(
135
139
  4,
136
140
  isRangeControl