@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
@@ -31,7 +31,7 @@ import {
31
31
  } from '@jsonforms/react';
32
32
  import startCase from 'lodash/startCase';
33
33
  import range from 'lodash/range';
34
- import React, { Fragment } from 'react';
34
+ import React, { Fragment, useMemo } from 'react';
35
35
  import {
36
36
  FormHelperText,
37
37
  Grid,
@@ -195,20 +195,19 @@ const controlWithoutLabel = (scope: string): ControlElement => ({
195
195
  label: false
196
196
  });
197
197
 
198
- const NonEmptyCell = (ownProps: OwnPropsOfNonEmptyCell) => {
199
- const ctx = useJsonForms();
200
- const {
201
- path,
202
- propName,
203
- schema,
204
- rootSchema,
205
- errors,
206
- enabled,
207
- renderers,
208
- cells
209
- } = ctxToNonEmptyCellProps(ctx, ownProps);
198
+ interface NonEmptyCellComponentProps {
199
+ path: string,
200
+ propName?: string,
201
+ schema: JsonSchema,
202
+ rootSchema: JsonSchema,
203
+ errors: string,
204
+ enabled: boolean,
205
+ renderers?: JsonFormsRendererRegistryEntry[],
206
+ cells?: JsonFormsCellRendererRegistryEntry[],
207
+ isValid: boolean
208
+ }
209
+ const NonEmptyCellComponent = React.memo(({path, propName, schema,rootSchema, errors, enabled, renderers, cells, isValid}:NonEmptyCellComponentProps) => {
210
210
 
211
- const isValid = isEmpty(errors);
212
211
  return (
213
212
  <NoBorderTableCell>
214
213
  {schema.properties ? (
@@ -237,35 +236,47 @@ const NonEmptyCell = (ownProps: OwnPropsOfNonEmptyCell) => {
237
236
  <FormHelperText error={!isValid}>{!isValid && errors}</FormHelperText>
238
237
  </NoBorderTableCell>
239
238
  );
239
+ });
240
+
241
+ const NonEmptyCell = (ownProps: OwnPropsOfNonEmptyCell) => {
242
+ const ctx = useJsonForms();
243
+ const emptyCellProps = ctxToNonEmptyCellProps(ctx, ownProps);
244
+
245
+ const isValid = isEmpty(emptyCellProps.errors);
246
+ return <NonEmptyCellComponent {...emptyCellProps} isValid={isValid}/>
240
247
  };
241
248
 
242
249
  interface NonEmptyRowProps {
243
250
  childPath: string;
244
251
  schema: JsonSchema;
245
252
  rowIndex: number;
246
- moveUp: () => void;
247
- moveDown: () => void;
253
+ moveUpCreator: (path:string, position: number)=> ()=> void;
254
+ moveDownCreator: (path:string, position: number)=> ()=> void;
248
255
  enableUp: boolean;
249
256
  enableDown: boolean;
250
257
  showSortButtons: boolean;
251
258
  enabled: boolean;
252
259
  cells?: JsonFormsCellRendererRegistryEntry[];
260
+ path: string;
253
261
  }
254
262
 
255
- const NonEmptyRow = React.memo(
263
+ const NonEmptyRowComponent =
256
264
  ({
257
265
  childPath,
258
266
  schema,
259
267
  rowIndex,
260
268
  openDeleteDialog,
261
- moveUp,
262
- moveDown,
269
+ moveUpCreator,
270
+ moveDownCreator,
263
271
  enableUp,
264
272
  enableDown,
265
273
  showSortButtons,
266
274
  enabled,
267
- cells
275
+ cells,
276
+ path
268
277
  }: NonEmptyRowProps & WithDeleteDialogSupport) => {
278
+ const moveUp = useMemo(() => moveUpCreator(path, rowIndex),[moveUpCreator, path, rowIndex]);
279
+ const moveDown = useMemo(() => moveDownCreator(path, rowIndex),[moveDownCreator, path, rowIndex]);
269
280
  return (
270
281
  <TableRow key={childPath} hover>
271
282
  {generateCells(NonEmptyCell, schema, childPath, enabled, cells)}
@@ -314,8 +325,8 @@ const NonEmptyRow = React.memo(
314
325
  ) : null}
315
326
  </TableRow>
316
327
  );
317
- }
318
- );
328
+ };
329
+ export const NonEmptyRow = React.memo(NonEmptyRowComponent);
319
330
  interface TableRowsProp {
320
331
  data: number;
321
332
  path: string;
@@ -359,13 +370,14 @@ const TableRows = ({
359
370
  rowIndex={index}
360
371
  schema={schema}
361
372
  openDeleteDialog={openDeleteDialog}
362
- moveUp={moveUp(path, index)}
363
- moveDown={moveDown(path, index)}
373
+ moveUpCreator={moveUp}
374
+ moveDownCreator={moveDown}
364
375
  enableUp={index !== 0}
365
376
  enableDown={index !== data - 1}
366
377
  showSortButtons={appliedUiSchemaOptions.showSortButtons}
367
378
  enabled={enabled}
368
379
  cells={cells}
380
+ path={path}
369
381
  />
370
382
  );
371
383
  })}
@@ -27,7 +27,6 @@ import {
27
27
  ControlElement,
28
28
  createDefaultValue,
29
29
  JsonSchema,
30
- Labels
31
30
  } from '@jsonforms/core';
32
31
  import IconButton from '@material-ui/core/IconButton';
33
32
  import { Grid, Hidden, Typography } from '@material-ui/core';
@@ -40,7 +39,7 @@ import NoBorderTableCell from './NoBorderTableCell';
40
39
  export interface MaterialTableToolbarProps {
41
40
  numColumns: number;
42
41
  errors: string;
43
- label: string | Labels;
42
+ label: string;
44
43
  path: string;
45
44
  uischema: ControlElement;
46
45
  schema: JsonSchema;
@@ -38,7 +38,8 @@ import { Control, withJsonFormsControlProps } from '@jsonforms/react';
38
38
  import { Input } from '@material-ui/core';
39
39
  import { InputBaseComponentProps } from '@material-ui/core/InputBase';
40
40
  import merge from 'lodash/merge';
41
- import React from 'react';
41
+ import React, { useMemo } from 'react';
42
+ import { useDebouncedChange } from '../util';
42
43
  import { MaterialInputControl } from './MaterialInputControl';
43
44
 
44
45
  const findEnumSchema = (schemas: JsonSchema[]) =>
@@ -64,17 +65,20 @@ const MuiAutocompleteInputText = (props: EnumCellProps & WithClassname) => {
64
65
  const enumSchema = findEnumSchema(schema.anyOf);
65
66
  const stringSchema = findTextSchema(schema.anyOf);
66
67
  const maxLength = stringSchema.maxLength;
67
- const appliedUiSchemaOptions = merge({}, config, uischema.options);
68
- let inputProps: InputBaseComponentProps = {};
69
- if (appliedUiSchemaOptions.restrict) {
70
- inputProps = { maxLength: maxLength };
71
- }
72
- if (appliedUiSchemaOptions.trim && maxLength !== undefined) {
73
- inputProps.size = maxLength;
74
- }
75
- const onChange = (ev: any) => handleChange(path, ev.target.value);
68
+ const appliedUiSchemaOptions = useMemo(() => merge({}, config, uischema.options),[config, uischema.options]);
69
+ const inputProps: InputBaseComponentProps = useMemo(() => {
70
+ let propMemo: InputBaseComponentProps = {};
71
+ if (appliedUiSchemaOptions.restrict) {
72
+ propMemo = { maxLength: maxLength };
73
+ }
74
+ if (appliedUiSchemaOptions.trim && maxLength !== undefined) {
75
+ propMemo.size = maxLength;
76
+ }
77
+ propMemo.list = props.id + 'datalist';
78
+ return propMemo;
79
+ },[appliedUiSchemaOptions,props.id]);
80
+ const [inputText, onChange] = useDebouncedChange(handleChange, '', data, path);
76
81
 
77
- inputProps.list = props.id + 'datalist';
78
82
  const dataList = (
79
83
  <datalist id={props.id + 'datalist'}>
80
84
  {enumSchema.enum.map(optionValue => (
@@ -85,7 +89,7 @@ const MuiAutocompleteInputText = (props: EnumCellProps & WithClassname) => {
85
89
  return (
86
90
  <Input
87
91
  type='text'
88
- value={data || ''}
92
+ value={inputText}
89
93
  onChange={onChange}
90
94
  className={className}
91
95
  id={id}
@@ -22,137 +22,106 @@
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 startsWith from 'lodash/startsWith';
26
25
  import merge from 'lodash/merge';
27
- import React from 'react';
26
+ import React, { useMemo } from 'react';
28
27
  import {
29
- computeLabel,
30
- ControlState,
31
- DispatchPropsOfControl,
28
+ ControlProps,
32
29
  isDateControl,
33
30
  isDescriptionHidden,
34
- isPlainLabel,
35
31
  RankedTester,
36
32
  rankWith,
37
- StatePropsOfControl
38
33
  } from '@jsonforms/core';
39
- import { Control, withJsonFormsControlProps } from '@jsonforms/react';
40
- import { Hidden } from '@material-ui/core';
34
+ import { withJsonFormsControlProps } from '@jsonforms/react';
35
+ import { FormHelperText, Hidden } from '@material-ui/core';
41
36
  import KeyboardArrowLeftIcon from '@material-ui/icons/KeyboardArrowLeft';
42
37
  import KeyboardArrowRightIcon from '@material-ui/icons/KeyboardArrowRight';
43
38
  import EventIcon from '@material-ui/icons/Event';
44
- import moment from 'moment';
45
- import { Moment } from 'moment';
46
39
  import {
47
40
  KeyboardDatePicker,
48
41
  MuiPickersUtilsProvider
49
42
  } from '@material-ui/pickers';
50
- import MomentUtils from '@date-io/moment';
43
+ import DayJsUtils from '@date-io/dayjs';
44
+ import { createOnChangeHandler, getData, useFocus } from '../util';
51
45
 
52
- export interface DateControl {
53
- momentLocale?: Moment;
54
- }
46
+ export const MaterialDateControl = (props: ControlProps)=> {
47
+ const [focused, onFocus, onBlur] = useFocus();
48
+ const {
49
+ description,
50
+ id,
51
+ errors,
52
+ label,
53
+ uischema,
54
+ visible,
55
+ enabled,
56
+ required,
57
+ path,
58
+ handleChange,
59
+ data,
60
+ config
61
+ } = props;
62
+ const isValid = errors.length === 0;
63
+ const appliedUiSchemaOptions = merge({}, config, uischema.options);
64
+ const showDescription = !isDescriptionHidden(
65
+ visible,
66
+ description,
67
+ focused,
68
+ appliedUiSchemaOptions.showUnfocusedDescription
69
+ );
55
70
 
56
- // Workaround typing problems in @material-ui/pickers@3.2.3
57
- const AnyPropsKeyboardDatePicker: React.FunctionComponent<
58
- any
59
- > = KeyboardDatePicker;
71
+ const format = appliedUiSchemaOptions.dateFormat ?? 'YYYY-MM-DD';
72
+ const saveFormat = appliedUiSchemaOptions.dateSaveFormat ?? 'YYYY-MM-DD';
60
73
 
61
- export class MaterialDateControl extends Control<
62
- StatePropsOfDateControl & DispatchPropsOfControl & DateControl,
63
- ControlState
64
- > {
65
- render() {
66
- const {
67
- description,
68
- id,
69
- errors,
70
- label,
71
- uischema,
72
- visible,
73
- enabled,
74
- required,
75
- path,
76
- handleChange,
77
- data,
78
- momentLocale,
79
- config
80
- } = this.props;
81
- const defaultLabel = label as string;
82
- const cancelLabel = '%cancel';
83
- const clearLabel = '%clear';
84
- const isValid = errors.length === 0;
85
- const appliedUiSchemaOptions = merge({}, config, uischema.options);
86
- const showDescription = !isDescriptionHidden(
87
- visible,
88
- description,
89
- this.state.isFocused,
90
- appliedUiSchemaOptions.showUnfocusedDescription
91
- );
92
- const inputProps = {};
93
- const localeDateTimeFormat = momentLocale
94
- ? `${momentLocale.localeData().longDateFormat('L')}`
95
- : 'YYYY-MM-DD';
74
+ const firstFormHelperText = showDescription
75
+ ? description
76
+ : !isValid
77
+ ? errors
78
+ : null;
79
+ const secondFormHelperText = showDescription && !isValid ? errors : null;
80
+ const onChange = useMemo(() => createOnChangeHandler(
81
+ path,
82
+ handleChange,
83
+ saveFormat
84
+ ),[path, handleChange, saveFormat]);
96
85
 
97
- let labelText;
98
- let labelCancel;
99
- let labelClear;
100
-
101
- if (isPlainLabel(label)) {
102
- labelText = label;
103
- labelCancel = 'Cancel';
104
- labelClear = 'Clear';
105
- } else {
106
- labelText = defaultLabel;
107
- labelCancel = startsWith(cancelLabel, '%') ? 'Cancel' : cancelLabel;
108
- labelClear = startsWith(clearLabel, '%') ? 'Clear' : clearLabel;
109
- }
110
-
111
- return (
112
- <Hidden xsUp={!visible}>
113
- <MuiPickersUtilsProvider utils={MomentUtils}>
114
- <AnyPropsKeyboardDatePicker
115
- id={id + '-input'}
116
- label={computeLabel(
117
- labelText,
118
- required,
119
- appliedUiSchemaOptions.hideRequiredAsterisk
120
- )}
121
- error={!isValid}
122
- fullWidth={!appliedUiSchemaOptions.trim}
123
- helperText={!isValid ? errors : showDescription ? description : ' '}
124
- InputLabelProps={{ shrink: true }}
125
- value={data || null}
126
- onChange={(datetime: any) =>
127
- handleChange(
128
- path,
129
- datetime ? moment(datetime).format('YYYY-MM-DD') : ''
130
- )
131
- }
132
- format={localeDateTimeFormat}
133
- clearable={true}
134
- disabled={!enabled}
135
- autoFocus={appliedUiSchemaOptions.focus}
136
- onFocus={this.onFocus}
137
- onBlur={this.onBlur}
138
- cancelLabel={labelCancel}
139
- clearLabel={labelClear}
140
- leftArrowIcon={<KeyboardArrowLeftIcon />}
141
- rightArrowIcon={<KeyboardArrowRightIcon />}
142
- keyboardIcon={<EventIcon />}
143
- InputProps={inputProps}
144
- />
145
- </MuiPickersUtilsProvider>
146
- </Hidden>
147
- );
148
- }
149
- }
150
-
151
- export interface StatePropsOfDateControl extends StatePropsOfControl {
152
- defaultLabel: string;
153
- cancelLabel: string;
154
- clearLabel: string;
155
- }
86
+ return (
87
+ <Hidden xsUp={!visible}>
88
+ <MuiPickersUtilsProvider utils={DayJsUtils}>
89
+ <KeyboardDatePicker
90
+ id={id + '-input'}
91
+ required={required && !appliedUiSchemaOptions.hideRequiredAsterisk}
92
+ label={label}
93
+ error={!isValid}
94
+ fullWidth={!appliedUiSchemaOptions.trim}
95
+ InputLabelProps={data ? { shrink: true } : undefined}
96
+ value={getData(data, saveFormat)}
97
+ clearable
98
+ onChange={onChange}
99
+ format={format}
100
+ views={appliedUiSchemaOptions.views}
101
+ disabled={!enabled}
102
+ autoFocus={appliedUiSchemaOptions.focus}
103
+ onFocus={onFocus}
104
+ onBlur={onBlur}
105
+ cancelLabel={appliedUiSchemaOptions.cancelLabel}
106
+ clearLabel={appliedUiSchemaOptions.clearLabel}
107
+ okLabel={appliedUiSchemaOptions.okLabel}
108
+ leftArrowIcon={<KeyboardArrowLeftIcon />}
109
+ rightArrowIcon={<KeyboardArrowRightIcon />}
110
+ keyboardIcon={<EventIcon />}
111
+ invalidDateMessage={null}
112
+ maxDateMessage={null}
113
+ minDateMessage={null}
114
+ />
115
+ <FormHelperText error={!isValid && !showDescription}>
116
+ {firstFormHelperText}
117
+ </FormHelperText>
118
+ <FormHelperText error={!isValid}>
119
+ {secondFormHelperText}
120
+ </FormHelperText>
121
+ </MuiPickersUtilsProvider>
122
+ </Hidden>
123
+ );
124
+ };
156
125
 
157
126
  export const materialDateControlTester: RankedTester = rankWith(
158
127
  4,
@@ -22,20 +22,17 @@
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, { useMemo } from 'react';
26
26
  import merge from 'lodash/merge';
27
27
  import {
28
- computeLabel,
29
28
  ControlProps,
30
- ControlState,
31
29
  isDateTimeControl,
32
- isPlainLabel,
30
+ isDescriptionHidden,
33
31
  RankedTester,
34
32
  rankWith
35
33
  } from '@jsonforms/core';
36
- import { Control, withJsonFormsControlProps } from '@jsonforms/react';
37
- import moment from 'moment';
38
- import { Hidden } from '@material-ui/core';
34
+ import { withJsonFormsControlProps } from '@jsonforms/react';
35
+ import { FormHelperText, Hidden } from '@material-ui/core';
39
36
  import KeyboardArrowLeftIcon from '@material-ui/icons/KeyboardArrowLeft';
40
37
  import KeyboardArrowRightIcon from '@material-ui/icons/KeyboardArrowRight';
41
38
  import DateRangeIcon from '@material-ui/icons/DateRange';
@@ -45,72 +42,93 @@ import {
45
42
  KeyboardDateTimePicker,
46
43
  MuiPickersUtilsProvider
47
44
  } from '@material-ui/pickers';
48
- import MomentUtils from '@date-io/moment';
45
+ import DayjsUtils from '@date-io/dayjs';
46
+ import { createOnChangeHandler, getData, useFocus } from '../util';
49
47
 
50
- // Workaround typing problems in @material-ui/pickers@3.2.3
51
- const AnyPropsKeyboardDateTimepicker: React.FunctionComponent<
52
- any
53
- > = KeyboardDateTimePicker;
48
+ export const MaterialDateTimeControl = (props: ControlProps) => {
49
+ const [focused, onFocus, onBlur] = useFocus();
50
+ const {
51
+ id,
52
+ description,
53
+ errors,
54
+ label,
55
+ uischema,
56
+ visible,
57
+ enabled,
58
+ required,
59
+ path,
60
+ handleChange,
61
+ data,
62
+ config
63
+ } = props;
64
+ const appliedUiSchemaOptions = merge({}, config, uischema.options);
65
+ const isValid = errors.length === 0;
54
66
 
55
- export class MaterialDateTimeControl extends Control<
56
- ControlProps,
57
- ControlState
58
- > {
59
- render() {
60
- const {
61
- id,
62
- description,
63
- errors,
64
- label,
65
- uischema,
66
- visible,
67
- enabled,
68
- required,
69
- path,
70
- handleChange,
71
- data,
72
- config
73
- } = this.props;
74
- const appliedUiSchemaOptions = merge({}, config, uischema.options);
75
- const isValid = errors.length === 0;
76
- const inputProps = {};
67
+ const showDescription = !isDescriptionHidden(
68
+ visible,
69
+ description,
70
+ focused,
71
+ appliedUiSchemaOptions.showUnfocusedDescription
72
+ );
73
+
74
+ const format = appliedUiSchemaOptions.dateTimeFormat ?? 'YYYY-MM-DD HH:mm';
75
+ const saveFormat = appliedUiSchemaOptions.dateTimeSaveFormat ?? undefined;
76
+
77
+ const firstFormHelperText = showDescription
78
+ ? description
79
+ : !isValid
80
+ ? errors
81
+ : null;
82
+ const secondFormHelperText = showDescription && !isValid ? errors : null;
83
+
84
+ const onChange = useMemo(() => createOnChangeHandler(
85
+ path,
86
+ handleChange,
87
+ saveFormat
88
+ ),[path, handleChange, saveFormat]);
77
89
 
78
- return (
79
- <Hidden xsUp={!visible}>
80
- <MuiPickersUtilsProvider utils={MomentUtils}>
81
- <AnyPropsKeyboardDateTimepicker
82
- id={id + '-input'}
83
- label={computeLabel(
84
- isPlainLabel(label) ? label : label.default,
85
- required,
86
- appliedUiSchemaOptions.hideRequiredAsterisk
87
- )}
88
- error={!isValid}
89
- fullWidth={!appliedUiSchemaOptions.trim}
90
- onFocus={this.onFocus}
91
- onBlur={this.onBlur}
92
- helperText={!isValid ? errors : description}
93
- InputLabelProps={{ shrink: true }}
94
- value={data || null}
95
- onChange={(datetime: any) =>
96
- handleChange(path, datetime ? moment(datetime).format() : '')
97
- }
98
- format='MM/DD/YYYY h:mm a'
99
- clearable={true}
100
- disabled={!enabled}
101
- autoFocus={appliedUiSchemaOptions.focus}
102
- leftArrowIcon={<KeyboardArrowLeftIcon />}
103
- rightArrowIcon={<KeyboardArrowRightIcon />}
104
- dateRangeIcon={<DateRangeIcon />}
105
- keyboardIcon={<EventIcon />}
106
- timeIcon={<AccessTimeIcon />}
107
- InputProps={inputProps}
108
- />
109
- </MuiPickersUtilsProvider>
110
- </Hidden>
111
- );
112
- }
113
- }
90
+ return (
91
+ <Hidden xsUp={!visible}>
92
+ <MuiPickersUtilsProvider utils={DayjsUtils}>
93
+ <KeyboardDateTimePicker
94
+ id={id + '-input'}
95
+ required={required && !appliedUiSchemaOptions.hideRequiredAsterisk}
96
+ label={label}
97
+ error={!isValid}
98
+ fullWidth={!appliedUiSchemaOptions.trim}
99
+ onFocus={onFocus}
100
+ onBlur={onBlur}
101
+ InputLabelProps={data ? { shrink: true } : undefined}
102
+ value={getData(data, saveFormat)}
103
+ clearable
104
+ onChange={onChange}
105
+ format={format}
106
+ ampm={!!appliedUiSchemaOptions.ampm}
107
+ views={appliedUiSchemaOptions.views}
108
+ disabled={!enabled}
109
+ autoFocus={appliedUiSchemaOptions.focus}
110
+ cancelLabel={appliedUiSchemaOptions.cancelLabel}
111
+ clearLabel={appliedUiSchemaOptions.clearLabel}
112
+ okLabel={appliedUiSchemaOptions.okLabel}
113
+ leftArrowIcon={<KeyboardArrowLeftIcon />}
114
+ rightArrowIcon={<KeyboardArrowRightIcon />}
115
+ dateRangeIcon={<DateRangeIcon />}
116
+ keyboardIcon={<EventIcon />}
117
+ timeIcon={<AccessTimeIcon />}
118
+ invalidDateMessage={null}
119
+ maxDateMessage={null}
120
+ minDateMessage={null}
121
+ />
122
+ <FormHelperText error={!isValid && !showDescription}>
123
+ {firstFormHelperText}
124
+ </FormHelperText>
125
+ <FormHelperText error={!isValid}>
126
+ {secondFormHelperText}
127
+ </FormHelperText>
128
+ </MuiPickersUtilsProvider>
129
+ </Hidden>
130
+ );
131
+ };
114
132
 
115
133
  export const materialDateTimeControlTester: RankedTester = rankWith(
116
134
  2,