@rjsf/mui 5.11.1 → 5.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (211) hide show
  1. package/dist/index.js +1003 -5
  2. package/dist/index.js.map +7 -0
  3. package/dist/mui.esm.js +650 -824
  4. package/dist/mui.esm.js.map +7 -1
  5. package/dist/mui.umd.js +852 -0
  6. package/lib/AddButton/AddButton.d.ts +5 -0
  7. package/lib/AddButton/AddButton.js +13 -0
  8. package/lib/AddButton/AddButton.js.map +1 -0
  9. package/lib/AddButton/index.d.ts +2 -0
  10. package/lib/AddButton/index.js +3 -0
  11. package/lib/AddButton/index.js.map +1 -0
  12. package/lib/ArrayFieldItemTemplate/ArrayFieldItemTemplate.d.ts +7 -0
  13. package/lib/ArrayFieldItemTemplate/ArrayFieldItemTemplate.js +21 -0
  14. package/lib/ArrayFieldItemTemplate/ArrayFieldItemTemplate.js.map +1 -0
  15. package/lib/ArrayFieldItemTemplate/index.d.ts +2 -0
  16. package/lib/ArrayFieldItemTemplate/index.js +3 -0
  17. package/lib/ArrayFieldItemTemplate/index.js.map +1 -0
  18. package/lib/ArrayFieldTemplate/ArrayFieldTemplate.d.ts +7 -0
  19. package/lib/ArrayFieldTemplate/ArrayFieldTemplate.js +25 -0
  20. package/lib/ArrayFieldTemplate/ArrayFieldTemplate.js.map +1 -0
  21. package/lib/ArrayFieldTemplate/index.d.ts +2 -0
  22. package/lib/ArrayFieldTemplate/index.js +3 -0
  23. package/lib/ArrayFieldTemplate/index.js.map +1 -0
  24. package/lib/BaseInputTemplate/BaseInputTemplate.d.ts +9 -0
  25. package/lib/BaseInputTemplate/BaseInputTemplate.js +32 -0
  26. package/lib/BaseInputTemplate/BaseInputTemplate.js.map +1 -0
  27. package/lib/BaseInputTemplate/index.d.ts +2 -0
  28. package/lib/BaseInputTemplate/index.js +3 -0
  29. package/lib/BaseInputTemplate/index.js.map +1 -0
  30. package/lib/CheckboxWidget/CheckboxWidget.d.ts +8 -0
  31. package/lib/CheckboxWidget/CheckboxWidget.js +24 -0
  32. package/lib/CheckboxWidget/CheckboxWidget.js.map +1 -0
  33. package/lib/CheckboxWidget/index.d.ts +2 -0
  34. package/lib/CheckboxWidget/index.js +3 -0
  35. package/lib/CheckboxWidget/index.js.map +1 -0
  36. package/lib/CheckboxesWidget/CheckboxesWidget.d.ts +8 -0
  37. package/lib/CheckboxesWidget/CheckboxesWidget.js +33 -0
  38. package/lib/CheckboxesWidget/CheckboxesWidget.js.map +1 -0
  39. package/lib/CheckboxesWidget/index.d.ts +2 -0
  40. package/lib/CheckboxesWidget/index.js +3 -0
  41. package/lib/CheckboxesWidget/index.js.map +1 -0
  42. package/lib/DescriptionField/DescriptionField.d.ts +7 -0
  43. package/lib/DescriptionField/DescriptionField.js +14 -0
  44. package/lib/DescriptionField/DescriptionField.js.map +1 -0
  45. package/lib/DescriptionField/index.d.ts +2 -0
  46. package/lib/DescriptionField/index.js +3 -0
  47. package/lib/DescriptionField/index.js.map +1 -0
  48. package/lib/ErrorList/ErrorList.d.ts +7 -0
  49. package/lib/ErrorList/ErrorList.js +21 -0
  50. package/lib/ErrorList/ErrorList.js.map +1 -0
  51. package/lib/ErrorList/index.d.ts +2 -0
  52. package/lib/ErrorList/index.js +3 -0
  53. package/lib/ErrorList/index.js.map +1 -0
  54. package/lib/FieldErrorTemplate/FieldErrorTemplate.d.ts +7 -0
  55. package/lib/FieldErrorTemplate/FieldErrorTemplate.js +20 -0
  56. package/lib/FieldErrorTemplate/FieldErrorTemplate.js.map +1 -0
  57. package/lib/FieldErrorTemplate/index.d.ts +2 -0
  58. package/lib/FieldErrorTemplate/index.js +3 -0
  59. package/lib/FieldErrorTemplate/index.js.map +1 -0
  60. package/lib/FieldHelpTemplate/FieldHelpTemplate.d.ts +7 -0
  61. package/lib/FieldHelpTemplate/FieldHelpTemplate.js +16 -0
  62. package/lib/FieldHelpTemplate/FieldHelpTemplate.js.map +1 -0
  63. package/lib/FieldHelpTemplate/index.d.ts +2 -0
  64. package/lib/FieldHelpTemplate/index.js +3 -0
  65. package/lib/FieldHelpTemplate/index.js.map +1 -0
  66. package/lib/FieldTemplate/FieldTemplate.d.ts +8 -0
  67. package/lib/FieldTemplate/FieldTemplate.js +19 -0
  68. package/lib/FieldTemplate/FieldTemplate.js.map +1 -0
  69. package/lib/FieldTemplate/index.d.ts +2 -0
  70. package/lib/FieldTemplate/index.js +3 -0
  71. package/lib/FieldTemplate/index.js.map +1 -0
  72. package/lib/IconButton/IconButton.d.ts +7 -0
  73. package/lib/IconButton/IconButton.js +30 -0
  74. package/lib/IconButton/IconButton.js.map +1 -0
  75. package/lib/IconButton/index.d.ts +2 -0
  76. package/lib/IconButton/index.js +3 -0
  77. package/lib/IconButton/index.js.map +1 -0
  78. package/lib/MuiForm/MuiForm.d.ts +6 -0
  79. package/lib/MuiForm/MuiForm.js +7 -0
  80. package/lib/MuiForm/MuiForm.js.map +1 -0
  81. package/lib/MuiForm/index.d.ts +2 -0
  82. package/lib/MuiForm/index.js +3 -0
  83. package/lib/MuiForm/index.js.map +1 -0
  84. package/lib/ObjectFieldTemplate/ObjectFieldTemplate.d.ts +9 -0
  85. package/lib/ObjectFieldTemplate/ObjectFieldTemplate.js +22 -0
  86. package/lib/ObjectFieldTemplate/ObjectFieldTemplate.js.map +1 -0
  87. package/lib/ObjectFieldTemplate/index.d.ts +2 -0
  88. package/lib/ObjectFieldTemplate/index.js +3 -0
  89. package/lib/ObjectFieldTemplate/index.js.map +1 -0
  90. package/lib/RadioWidget/RadioWidget.d.ts +8 -0
  91. package/lib/RadioWidget/RadioWidget.js +27 -0
  92. package/lib/RadioWidget/RadioWidget.js.map +1 -0
  93. package/lib/RadioWidget/index.d.ts +2 -0
  94. package/lib/RadioWidget/index.js +3 -0
  95. package/lib/RadioWidget/index.js.map +1 -0
  96. package/lib/RangeWidget/RangeWidget.d.ts +8 -0
  97. package/lib/RangeWidget/RangeWidget.js +20 -0
  98. package/lib/RangeWidget/RangeWidget.js.map +1 -0
  99. package/lib/RangeWidget/index.d.ts +2 -0
  100. package/lib/RangeWidget/index.js +3 -0
  101. package/lib/RangeWidget/index.js.map +1 -0
  102. package/lib/SelectWidget/SelectWidget.d.ts +9 -0
  103. package/lib/SelectWidget/SelectWidget.js +29 -0
  104. package/lib/SelectWidget/SelectWidget.js.map +1 -0
  105. package/lib/SelectWidget/index.d.ts +2 -0
  106. package/lib/SelectWidget/index.js +3 -0
  107. package/lib/SelectWidget/index.js.map +1 -0
  108. package/lib/SubmitButton/SubmitButton.d.ts +5 -0
  109. package/lib/SubmitButton/SubmitButton.js +14 -0
  110. package/lib/SubmitButton/SubmitButton.js.map +1 -0
  111. package/lib/SubmitButton/index.d.ts +2 -0
  112. package/lib/SubmitButton/index.js +3 -0
  113. package/lib/SubmitButton/index.js.map +1 -0
  114. package/lib/Templates/Templates.d.ts +4 -0
  115. package/lib/Templates/Templates.js +39 -0
  116. package/lib/Templates/Templates.js.map +1 -0
  117. package/lib/Templates/index.d.ts +2 -0
  118. package/lib/Templates/index.js +3 -0
  119. package/lib/Templates/index.js.map +1 -0
  120. package/lib/TextareaWidget/TextareaWidget.d.ts +7 -0
  121. package/lib/TextareaWidget/TextareaWidget.js +16 -0
  122. package/lib/TextareaWidget/TextareaWidget.js.map +1 -0
  123. package/lib/TextareaWidget/index.d.ts +2 -0
  124. package/lib/TextareaWidget/index.js +3 -0
  125. package/lib/TextareaWidget/index.js.map +1 -0
  126. package/lib/Theme/Theme.d.ts +5 -0
  127. package/lib/Theme/Theme.js +10 -0
  128. package/lib/Theme/Theme.js.map +1 -0
  129. package/lib/Theme/index.d.ts +2 -0
  130. package/lib/Theme/index.js +3 -0
  131. package/lib/Theme/index.js.map +1 -0
  132. package/lib/TitleField/TitleField.d.ts +7 -0
  133. package/lib/TitleField/TitleField.js +12 -0
  134. package/lib/TitleField/TitleField.js.map +1 -0
  135. package/lib/TitleField/index.d.ts +2 -0
  136. package/lib/TitleField/index.js +3 -0
  137. package/lib/TitleField/index.js.map +1 -0
  138. package/lib/Widgets/Widgets.d.ts +4 -0
  139. package/lib/Widgets/Widgets.js +18 -0
  140. package/lib/Widgets/Widgets.js.map +1 -0
  141. package/lib/Widgets/index.d.ts +2 -0
  142. package/lib/Widgets/index.js +3 -0
  143. package/lib/Widgets/index.js.map +1 -0
  144. package/lib/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.d.ts +8 -0
  145. package/lib/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.js +29 -0
  146. package/lib/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.js.map +1 -0
  147. package/lib/WrapIfAdditionalTemplate/index.d.ts +2 -0
  148. package/lib/WrapIfAdditionalTemplate/index.js +3 -0
  149. package/lib/WrapIfAdditionalTemplate/index.js.map +1 -0
  150. package/lib/index.d.ts +6 -0
  151. package/lib/index.js +7 -0
  152. package/lib/index.js.map +1 -0
  153. package/package.json +24 -16
  154. package/src/AddButton/AddButton.tsx +18 -0
  155. package/src/AddButton/index.ts +2 -0
  156. package/src/ArrayFieldItemTemplate/ArrayFieldItemTemplate.tsx +91 -0
  157. package/src/ArrayFieldItemTemplate/index.ts +2 -0
  158. package/src/ArrayFieldTemplate/ArrayFieldTemplate.tsx +87 -0
  159. package/src/ArrayFieldTemplate/index.ts +2 -0
  160. package/src/BaseInputTemplate/BaseInputTemplate.tsx +106 -0
  161. package/src/BaseInputTemplate/index.ts +2 -0
  162. package/src/CheckboxWidget/CheckboxWidget.tsx +87 -0
  163. package/src/CheckboxWidget/index.ts +2 -0
  164. package/src/CheckboxesWidget/CheckboxesWidget.tsx +92 -0
  165. package/src/CheckboxesWidget/index.ts +2 -0
  166. package/src/DescriptionField/DescriptionField.tsx +23 -0
  167. package/src/DescriptionField/index.ts +2 -0
  168. package/src/ErrorList/ErrorList.tsx +39 -0
  169. package/src/ErrorList/index.ts +2 -0
  170. package/src/FieldErrorTemplate/FieldErrorTemplate.tsx +32 -0
  171. package/src/FieldErrorTemplate/index.ts +2 -0
  172. package/src/FieldHelpTemplate/FieldHelpTemplate.tsx +19 -0
  173. package/src/FieldHelpTemplate/index.ts +2 -0
  174. package/src/FieldTemplate/FieldTemplate.tsx +81 -0
  175. package/src/FieldTemplate/index.ts +2 -0
  176. package/src/IconButton/IconButton.tsx +81 -0
  177. package/src/IconButton/index.ts +2 -0
  178. package/src/MuiForm/MuiForm.tsx +15 -0
  179. package/src/MuiForm/index.ts +2 -0
  180. package/src/ObjectFieldTemplate/ObjectFieldTemplate.tsx +99 -0
  181. package/src/ObjectFieldTemplate/index.ts +2 -0
  182. package/src/RadioWidget/RadioWidget.tsx +83 -0
  183. package/src/RadioWidget/index.ts +2 -0
  184. package/src/RangeWidget/RangeWidget.tsx +51 -0
  185. package/src/RangeWidget/index.ts +2 -0
  186. package/src/SelectWidget/SelectWidget.tsx +100 -0
  187. package/src/SelectWidget/index.ts +2 -0
  188. package/src/SubmitButton/SubmitButton.tsx +23 -0
  189. package/src/SubmitButton/index.ts +2 -0
  190. package/src/Templates/Templates.ts +46 -0
  191. package/src/Templates/index.ts +2 -0
  192. package/src/TextareaWidget/TextareaWidget.tsx +21 -0
  193. package/src/TextareaWidget/index.ts +2 -0
  194. package/src/Theme/Theme.tsx +18 -0
  195. package/src/Theme/index.ts +2 -0
  196. package/src/TitleField/TitleField.tsx +20 -0
  197. package/src/TitleField/index.ts +2 -0
  198. package/src/Widgets/Widgets.ts +25 -0
  199. package/src/Widgets/index.ts +2 -0
  200. package/src/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.tsx +90 -0
  201. package/src/WrapIfAdditionalTemplate/index.ts +2 -0
  202. package/src/index.ts +8 -0
  203. package/dist/index.d.ts +0 -17
  204. package/dist/mui.cjs.development.js +0 -1239
  205. package/dist/mui.cjs.development.js.map +0 -1
  206. package/dist/mui.cjs.production.min.js +0 -2
  207. package/dist/mui.cjs.production.min.js.map +0 -1
  208. package/dist/mui.umd.development.js +0 -1213
  209. package/dist/mui.umd.development.js.map +0 -1
  210. package/dist/mui.umd.production.min.js +0 -2
  211. package/dist/mui.umd.production.min.js.map +0 -1
@@ -1,1213 +0,0 @@
1
- (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@rjsf/core'), require('react/jsx-runtime'), require('@mui/icons-material/Add'), require('@mui/material/IconButton'), require('@rjsf/utils'), require('@mui/material/Box'), require('@mui/material/Grid'), require('@mui/material/Paper'), require('@mui/material/TextField'), require('@mui/material/Typography'), require('@mui/icons-material/Error'), require('@mui/material/List'), require('@mui/material/ListItem'), require('@mui/material/ListItemIcon'), require('@mui/material/ListItemText'), require('@mui/icons-material/ArrowDownward'), require('@mui/icons-material/ArrowUpward'), require('@mui/icons-material/ContentCopy'), require('@mui/icons-material/Remove'), require('@mui/material/FormHelperText'), require('@mui/material/FormControl'), require('@mui/material/Button'), require('@mui/material/Divider'), require('@mui/material/Checkbox'), require('@mui/material/FormControlLabel'), require('@mui/material/FormGroup'), require('@mui/material/FormLabel'), require('@mui/material/Radio'), require('@mui/material/RadioGroup'), require('@mui/material/Slider'), require('@mui/material/MenuItem')) :
3
- typeof define === 'function' && define.amd ? define(['exports', '@rjsf/core', 'react/jsx-runtime', '@mui/icons-material/Add', '@mui/material/IconButton', '@rjsf/utils', '@mui/material/Box', '@mui/material/Grid', '@mui/material/Paper', '@mui/material/TextField', '@mui/material/Typography', '@mui/icons-material/Error', '@mui/material/List', '@mui/material/ListItem', '@mui/material/ListItemIcon', '@mui/material/ListItemText', '@mui/icons-material/ArrowDownward', '@mui/icons-material/ArrowUpward', '@mui/icons-material/ContentCopy', '@mui/icons-material/Remove', '@mui/material/FormHelperText', '@mui/material/FormControl', '@mui/material/Button', '@mui/material/Divider', '@mui/material/Checkbox', '@mui/material/FormControlLabel', '@mui/material/FormGroup', '@mui/material/FormLabel', '@mui/material/Radio', '@mui/material/RadioGroup', '@mui/material/Slider', '@mui/material/MenuItem'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@rjsf/mui"] = {}, global.core, global.jsxRuntime, global.AddIcon, global.IconButton, global.utils, global.Box, global.Grid, global.Paper, global.TextField, global.Typography, global.ErrorIcon, global.List, global.ListItem, global.ListItemIcon, global.ListItemText, global.ArrowDownwardIcon, global.ArrowUpwardIcon, global.CopyIcon, global.RemoveIcon, global.FormHelperText, global.FormControl, global.Button, global.Divider, global.Checkbox, global.FormControlLabel, global.FormGroup, global.FormLabel, global.Radio, global.RadioGroup, global.Slider, global.MenuItem));
5
- })(this, (function (exports, core, jsxRuntime, AddIcon, IconButton, utils, Box, Grid, Paper, TextField, Typography, ErrorIcon, List, ListItem, ListItemIcon, ListItemText, ArrowDownwardIcon, ArrowUpwardIcon, CopyIcon, RemoveIcon, FormHelperText, FormControl, Button, Divider, Checkbox, FormControlLabel, FormGroup, FormLabel, Radio, RadioGroup, Slider, MenuItem) { 'use strict';
6
-
7
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
-
9
- var AddIcon__default = /*#__PURE__*/_interopDefaultLegacy(AddIcon);
10
- var IconButton__default = /*#__PURE__*/_interopDefaultLegacy(IconButton);
11
- var Box__default = /*#__PURE__*/_interopDefaultLegacy(Box);
12
- var Grid__default = /*#__PURE__*/_interopDefaultLegacy(Grid);
13
- var Paper__default = /*#__PURE__*/_interopDefaultLegacy(Paper);
14
- var TextField__default = /*#__PURE__*/_interopDefaultLegacy(TextField);
15
- var Typography__default = /*#__PURE__*/_interopDefaultLegacy(Typography);
16
- var ErrorIcon__default = /*#__PURE__*/_interopDefaultLegacy(ErrorIcon);
17
- var List__default = /*#__PURE__*/_interopDefaultLegacy(List);
18
- var ListItem__default = /*#__PURE__*/_interopDefaultLegacy(ListItem);
19
- var ListItemIcon__default = /*#__PURE__*/_interopDefaultLegacy(ListItemIcon);
20
- var ListItemText__default = /*#__PURE__*/_interopDefaultLegacy(ListItemText);
21
- var ArrowDownwardIcon__default = /*#__PURE__*/_interopDefaultLegacy(ArrowDownwardIcon);
22
- var ArrowUpwardIcon__default = /*#__PURE__*/_interopDefaultLegacy(ArrowUpwardIcon);
23
- var CopyIcon__default = /*#__PURE__*/_interopDefaultLegacy(CopyIcon);
24
- var RemoveIcon__default = /*#__PURE__*/_interopDefaultLegacy(RemoveIcon);
25
- var FormHelperText__default = /*#__PURE__*/_interopDefaultLegacy(FormHelperText);
26
- var FormControl__default = /*#__PURE__*/_interopDefaultLegacy(FormControl);
27
- var Button__default = /*#__PURE__*/_interopDefaultLegacy(Button);
28
- var Divider__default = /*#__PURE__*/_interopDefaultLegacy(Divider);
29
- var Checkbox__default = /*#__PURE__*/_interopDefaultLegacy(Checkbox);
30
- var FormControlLabel__default = /*#__PURE__*/_interopDefaultLegacy(FormControlLabel);
31
- var FormGroup__default = /*#__PURE__*/_interopDefaultLegacy(FormGroup);
32
- var FormLabel__default = /*#__PURE__*/_interopDefaultLegacy(FormLabel);
33
- var Radio__default = /*#__PURE__*/_interopDefaultLegacy(Radio);
34
- var RadioGroup__default = /*#__PURE__*/_interopDefaultLegacy(RadioGroup);
35
- var Slider__default = /*#__PURE__*/_interopDefaultLegacy(Slider);
36
- var MenuItem__default = /*#__PURE__*/_interopDefaultLegacy(MenuItem);
37
-
38
- /** The `AddButton` renders a button that represent the `Add` action on a form
39
- */
40
- function AddButton({
41
- uiSchema,
42
- registry,
43
- ...props
44
- }) {
45
- const {
46
- translateString
47
- } = registry;
48
- return jsxRuntime.jsx(IconButton__default["default"], {
49
- title: translateString(utils.TranslatableString.AddItemButton),
50
- ...props,
51
- color: 'primary',
52
- children: jsxRuntime.jsx(AddIcon__default["default"], {})
53
- });
54
- }
55
-
56
- /** The `ArrayFieldItemTemplate` component is the template used to render an items of an array.
57
- *
58
- * @param props - The `ArrayFieldTemplateItemType` props for the component
59
- */
60
- function ArrayFieldItemTemplate(props) {
61
- const {
62
- children,
63
- disabled,
64
- hasToolbar,
65
- hasCopy,
66
- hasMoveDown,
67
- hasMoveUp,
68
- hasRemove,
69
- index,
70
- onCopyIndexClick,
71
- onDropIndexClick,
72
- onReorderClick,
73
- readonly,
74
- uiSchema,
75
- registry
76
- } = props;
77
- const {
78
- CopyButton,
79
- MoveDownButton,
80
- MoveUpButton,
81
- RemoveButton
82
- } = registry.templates.ButtonTemplates;
83
- const btnStyle = {
84
- flex: 1,
85
- paddingLeft: 6,
86
- paddingRight: 6,
87
- fontWeight: 'bold',
88
- minWidth: 0
89
- };
90
- return jsxRuntime.jsxs(Grid__default["default"], {
91
- container: true,
92
- alignItems: 'center',
93
- children: [jsxRuntime.jsx(Grid__default["default"], {
94
- item: true,
95
- xs: true,
96
- style: {
97
- overflow: 'auto'
98
- },
99
- children: jsxRuntime.jsx(Box__default["default"], {
100
- mb: 2,
101
- children: jsxRuntime.jsx(Paper__default["default"], {
102
- elevation: 2,
103
- children: jsxRuntime.jsx(Box__default["default"], {
104
- p: 2,
105
- children: children
106
- })
107
- })
108
- })
109
- }), hasToolbar && jsxRuntime.jsxs(Grid__default["default"], {
110
- item: true,
111
- children: [(hasMoveUp || hasMoveDown) && jsxRuntime.jsx(MoveUpButton, {
112
- style: btnStyle,
113
- disabled: disabled || readonly || !hasMoveUp,
114
- onClick: onReorderClick(index, index - 1),
115
- uiSchema: uiSchema,
116
- registry: registry
117
- }), (hasMoveUp || hasMoveDown) && jsxRuntime.jsx(MoveDownButton, {
118
- style: btnStyle,
119
- disabled: disabled || readonly || !hasMoveDown,
120
- onClick: onReorderClick(index, index + 1),
121
- uiSchema: uiSchema,
122
- registry: registry
123
- }), hasCopy && jsxRuntime.jsx(CopyButton, {
124
- style: btnStyle,
125
- disabled: disabled || readonly,
126
- onClick: onCopyIndexClick(index),
127
- uiSchema: uiSchema,
128
- registry: registry
129
- }), hasRemove && jsxRuntime.jsx(RemoveButton, {
130
- style: btnStyle,
131
- disabled: disabled || readonly,
132
- onClick: onDropIndexClick(index),
133
- uiSchema: uiSchema,
134
- registry: registry
135
- })]
136
- })]
137
- });
138
- }
139
-
140
- /** The `ArrayFieldTemplate` component is the template used to render all items in an array.
141
- *
142
- * @param props - The `ArrayFieldTemplateItemType` props for the component
143
- */
144
- function ArrayFieldTemplate(props) {
145
- const {
146
- canAdd,
147
- disabled,
148
- idSchema,
149
- uiSchema,
150
- items,
151
- onAddClick,
152
- readonly,
153
- registry,
154
- required,
155
- schema,
156
- title
157
- } = props;
158
- const uiOptions = utils.getUiOptions(uiSchema);
159
- const ArrayFieldDescriptionTemplate = utils.getTemplate('ArrayFieldDescriptionTemplate', registry, uiOptions);
160
- const ArrayFieldItemTemplate = utils.getTemplate('ArrayFieldItemTemplate', registry, uiOptions);
161
- const ArrayFieldTitleTemplate = utils.getTemplate('ArrayFieldTitleTemplate', registry, uiOptions);
162
- // Button templates are not overridden in the uiSchema
163
- const {
164
- ButtonTemplates: {
165
- AddButton
166
- }
167
- } = registry.templates;
168
- return jsxRuntime.jsx(Paper__default["default"], {
169
- elevation: 2,
170
- children: jsxRuntime.jsxs(Box__default["default"], {
171
- p: 2,
172
- children: [jsxRuntime.jsx(ArrayFieldTitleTemplate, {
173
- idSchema: idSchema,
174
- title: uiOptions.title || title,
175
- schema: schema,
176
- uiSchema: uiSchema,
177
- required: required,
178
- registry: registry
179
- }), jsxRuntime.jsx(ArrayFieldDescriptionTemplate, {
180
- idSchema: idSchema,
181
- description: uiOptions.description || schema.description,
182
- schema: schema,
183
- uiSchema: uiSchema,
184
- registry: registry
185
- }), jsxRuntime.jsxs(Grid__default["default"], {
186
- container: true,
187
- children: [items && items.map(({
188
- key,
189
- ...itemProps
190
- }) => jsxRuntime.jsx(ArrayFieldItemTemplate, {
191
- ...itemProps
192
- }, key)), canAdd && jsxRuntime.jsx(Grid__default["default"], {
193
- container: true,
194
- justifyContent: 'flex-end',
195
- children: jsxRuntime.jsx(Grid__default["default"], {
196
- item: true,
197
- children: jsxRuntime.jsx(Box__default["default"], {
198
- mt: 2,
199
- children: jsxRuntime.jsx(AddButton, {
200
- className: 'array-item-add',
201
- onClick: onAddClick,
202
- disabled: disabled || readonly,
203
- uiSchema: uiSchema,
204
- registry: registry
205
- })
206
- })
207
- })
208
- })]
209
- }, `array-item-list-${idSchema.$id}`)]
210
- })
211
- });
212
- }
213
-
214
- const TYPES_THAT_SHRINK_LABEL = ['date', 'datetime-local', 'file', 'time'];
215
- /** The `BaseInputTemplate` is the template to use to render the basic `<input>` component for the `core` theme.
216
- * It is used as the template for rendering many of the <input> based widgets that differ by `type` and callbacks only.
217
- * It can be customized/overridden for other themes or individual implementations as needed.
218
- *
219
- * @param props - The `WidgetProps` for this template
220
- */
221
- function BaseInputTemplate(props) {
222
- const {
223
- id,
224
- name,
225
- // remove this from textFieldProps
226
- placeholder,
227
- required,
228
- readonly,
229
- disabled,
230
- type,
231
- label,
232
- hideLabel,
233
- value,
234
- onChange,
235
- onChangeOverride,
236
- onBlur,
237
- onFocus,
238
- autofocus,
239
- options,
240
- schema,
241
- uiSchema,
242
- rawErrors = [],
243
- formContext,
244
- registry,
245
- InputLabelProps,
246
- ...textFieldProps
247
- } = props;
248
- const inputProps = utils.getInputProps(schema, type, options);
249
- // Now we need to pull out the step, min, max into an inner `inputProps` for material-ui
250
- const {
251
- step,
252
- min,
253
- max,
254
- ...rest
255
- } = inputProps;
256
- const otherProps = {
257
- inputProps: {
258
- step,
259
- min,
260
- max,
261
- ...(schema.examples ? {
262
- list: utils.examplesId(id)
263
- } : undefined)
264
- },
265
- ...rest
266
- };
267
- const _onChange = ({
268
- target: {
269
- value
270
- }
271
- }) => onChange(value === '' ? options.emptyValue : value);
272
- const _onBlur = ({
273
- target: {
274
- value
275
- }
276
- }) => onBlur(id, value);
277
- const _onFocus = ({
278
- target: {
279
- value
280
- }
281
- }) => onFocus(id, value);
282
- const DisplayInputLabelProps = TYPES_THAT_SHRINK_LABEL.includes(type) ? {
283
- ...InputLabelProps,
284
- shrink: true
285
- } : InputLabelProps;
286
- return jsxRuntime.jsxs(jsxRuntime.Fragment, {
287
- children: [jsxRuntime.jsx(TextField__default["default"], {
288
- id: id,
289
- name: id,
290
- placeholder: placeholder,
291
- label: utils.labelValue(label || undefined, hideLabel, false),
292
- autoFocus: autofocus,
293
- required: required,
294
- disabled: disabled || readonly,
295
- ...otherProps,
296
- value: value || value === 0 ? value : '',
297
- error: rawErrors.length > 0,
298
- onChange: onChangeOverride || _onChange,
299
- onBlur: _onBlur,
300
- onFocus: _onFocus,
301
- InputLabelProps: DisplayInputLabelProps,
302
- ...textFieldProps,
303
- "aria-describedby": utils.ariaDescribedByIds(id, !!schema.examples)
304
- }), Array.isArray(schema.examples) && jsxRuntime.jsx("datalist", {
305
- id: utils.examplesId(id),
306
- children: schema.examples.concat(schema.default && !schema.examples.includes(schema.default) ? [schema.default] : []).map(example => {
307
- return jsxRuntime.jsx("option", {
308
- value: example
309
- }, example);
310
- })
311
- })]
312
- });
313
- }
314
-
315
- /** The `DescriptionField` is the template to use to render the description of a field
316
- *
317
- * @param props - The `DescriptionFieldProps` for this component
318
- */
319
- function DescriptionField(props) {
320
- const {
321
- id,
322
- description
323
- } = props;
324
- if (description) {
325
- return jsxRuntime.jsx(Typography__default["default"], {
326
- id: id,
327
- variant: 'subtitle2',
328
- style: {
329
- marginTop: '5px'
330
- },
331
- children: description
332
- });
333
- }
334
- return null;
335
- }
336
-
337
- /** The `ErrorList` component is the template that renders the all the errors associated with the fields in the `Form`
338
- *
339
- * @param props - The `ErrorListProps` for this component
340
- */
341
- function ErrorList({
342
- errors,
343
- registry
344
- }) {
345
- const {
346
- translateString
347
- } = registry;
348
- return jsxRuntime.jsx(Paper__default["default"], {
349
- elevation: 2,
350
- children: jsxRuntime.jsxs(Box__default["default"], {
351
- mb: 2,
352
- p: 2,
353
- children: [jsxRuntime.jsx(Typography__default["default"], {
354
- variant: 'h6',
355
- children: translateString(utils.TranslatableString.ErrorsLabel)
356
- }), jsxRuntime.jsx(List__default["default"], {
357
- dense: true,
358
- children: errors.map((error, i) => {
359
- return jsxRuntime.jsxs(ListItem__default["default"], {
360
- children: [jsxRuntime.jsx(ListItemIcon__default["default"], {
361
- children: jsxRuntime.jsx(ErrorIcon__default["default"], {
362
- color: 'error'
363
- })
364
- }), jsxRuntime.jsx(ListItemText__default["default"], {
365
- primary: error.stack
366
- })]
367
- }, i);
368
- })
369
- })]
370
- })
371
- });
372
- }
373
-
374
- function MuiIconButton(props) {
375
- const {
376
- icon,
377
- color,
378
- uiSchema,
379
- registry,
380
- ...otherProps
381
- } = props;
382
- return jsxRuntime.jsx(IconButton__default["default"], {
383
- ...otherProps,
384
- size: 'small',
385
- color: color,
386
- children: icon
387
- });
388
- }
389
- function CopyButton(props) {
390
- const {
391
- registry: {
392
- translateString
393
- }
394
- } = props;
395
- return jsxRuntime.jsx(MuiIconButton, {
396
- title: translateString(utils.TranslatableString.CopyButton),
397
- ...props,
398
- icon: jsxRuntime.jsx(CopyIcon__default["default"], {
399
- fontSize: 'small'
400
- })
401
- });
402
- }
403
- function MoveDownButton(props) {
404
- const {
405
- registry: {
406
- translateString
407
- }
408
- } = props;
409
- return jsxRuntime.jsx(MuiIconButton, {
410
- title: translateString(utils.TranslatableString.MoveDownButton),
411
- ...props,
412
- icon: jsxRuntime.jsx(ArrowDownwardIcon__default["default"], {
413
- fontSize: 'small'
414
- })
415
- });
416
- }
417
- function MoveUpButton(props) {
418
- const {
419
- registry: {
420
- translateString
421
- }
422
- } = props;
423
- return jsxRuntime.jsx(MuiIconButton, {
424
- title: translateString(utils.TranslatableString.MoveUpButton),
425
- ...props,
426
- icon: jsxRuntime.jsx(ArrowUpwardIcon__default["default"], {
427
- fontSize: 'small'
428
- })
429
- });
430
- }
431
- function RemoveButton(props) {
432
- const {
433
- iconType,
434
- ...otherProps
435
- } = props;
436
- const {
437
- registry: {
438
- translateString
439
- }
440
- } = otherProps;
441
- return jsxRuntime.jsx(MuiIconButton, {
442
- title: translateString(utils.TranslatableString.RemoveButton),
443
- ...otherProps,
444
- color: 'error',
445
- icon: jsxRuntime.jsx(RemoveIcon__default["default"], {
446
- fontSize: iconType === 'default' ? undefined : 'small'
447
- })
448
- });
449
- }
450
-
451
- /** The `FieldErrorTemplate` component renders the errors local to the particular field
452
- *
453
- * @param props - The `FieldErrorProps` for the errors being rendered
454
- */
455
- function FieldErrorTemplate(props) {
456
- const {
457
- errors = [],
458
- idSchema
459
- } = props;
460
- if (errors.length === 0) {
461
- return null;
462
- }
463
- const id = utils.errorId(idSchema);
464
- return jsxRuntime.jsx(List__default["default"], {
465
- dense: true,
466
- disablePadding: true,
467
- children: errors.map((error, i) => {
468
- return jsxRuntime.jsx(ListItem__default["default"], {
469
- disableGutters: true,
470
- children: jsxRuntime.jsx(FormHelperText__default["default"], {
471
- id: id,
472
- children: error
473
- })
474
- }, i);
475
- })
476
- });
477
- }
478
-
479
- /** The `FieldHelpTemplate` component renders any help desired for a field
480
- *
481
- * @param props - The `FieldHelpProps` to be rendered
482
- */
483
- function FieldHelpTemplate(props) {
484
- const {
485
- idSchema,
486
- help
487
- } = props;
488
- if (!help) {
489
- return null;
490
- }
491
- const id = utils.helpId(idSchema);
492
- return jsxRuntime.jsx(FormHelperText__default["default"], {
493
- id: id,
494
- children: help
495
- });
496
- }
497
-
498
- /** The `FieldTemplate` component is the template used by `SchemaField` to render any field. It renders the field
499
- * content, (label, description, children, errors and help) inside of a `WrapIfAdditional` component.
500
- *
501
- * @param props - The `FieldTemplateProps` for this component
502
- */
503
- function FieldTemplate(props) {
504
- const {
505
- id,
506
- children,
507
- classNames,
508
- style,
509
- disabled,
510
- displayLabel,
511
- hidden,
512
- label,
513
- onDropPropertyClick,
514
- onKeyChange,
515
- readonly,
516
- required,
517
- rawErrors = [],
518
- errors,
519
- help,
520
- description,
521
- rawDescription,
522
- schema,
523
- uiSchema,
524
- registry
525
- } = props;
526
- const uiOptions = utils.getUiOptions(uiSchema);
527
- const WrapIfAdditionalTemplate = utils.getTemplate('WrapIfAdditionalTemplate', registry, uiOptions);
528
- if (hidden) {
529
- return jsxRuntime.jsx("div", {
530
- style: {
531
- display: 'none'
532
- },
533
- children: children
534
- });
535
- }
536
- return jsxRuntime.jsx(WrapIfAdditionalTemplate, {
537
- classNames: classNames,
538
- style: style,
539
- disabled: disabled,
540
- id: id,
541
- label: label,
542
- onDropPropertyClick: onDropPropertyClick,
543
- onKeyChange: onKeyChange,
544
- readonly: readonly,
545
- required: required,
546
- schema: schema,
547
- uiSchema: uiSchema,
548
- registry: registry,
549
- children: jsxRuntime.jsxs(FormControl__default["default"], {
550
- fullWidth: true,
551
- error: rawErrors.length ? true : false,
552
- required: required,
553
- children: [children, displayLabel && rawDescription ? jsxRuntime.jsx(Typography__default["default"], {
554
- variant: 'caption',
555
- color: 'textSecondary',
556
- children: description
557
- }) : null, errors, help]
558
- })
559
- });
560
- }
561
-
562
- /** The `ObjectFieldTemplate` is the template to use to render all the inner properties of an object along with the
563
- * title and description if available. If the object is expandable, then an `AddButton` is also rendered after all
564
- * the properties.
565
- *
566
- * @param props - The `ObjectFieldTemplateProps` for this component
567
- */
568
- function ObjectFieldTemplate(props) {
569
- const {
570
- description,
571
- title,
572
- properties,
573
- required,
574
- disabled,
575
- readonly,
576
- uiSchema,
577
- idSchema,
578
- schema,
579
- formData,
580
- onAddClick,
581
- registry
582
- } = props;
583
- const uiOptions = utils.getUiOptions(uiSchema);
584
- const TitleFieldTemplate = utils.getTemplate('TitleFieldTemplate', registry, uiOptions);
585
- const DescriptionFieldTemplate = utils.getTemplate('DescriptionFieldTemplate', registry, uiOptions);
586
- // Button templates are not overridden in the uiSchema
587
- const {
588
- ButtonTemplates: {
589
- AddButton
590
- }
591
- } = registry.templates;
592
- return jsxRuntime.jsxs(jsxRuntime.Fragment, {
593
- children: [title && jsxRuntime.jsx(TitleFieldTemplate, {
594
- id: utils.titleId(idSchema),
595
- title: title,
596
- required: required,
597
- schema: schema,
598
- uiSchema: uiSchema,
599
- registry: registry
600
- }), description && jsxRuntime.jsx(DescriptionFieldTemplate, {
601
- id: utils.descriptionId(idSchema),
602
- description: description,
603
- schema: schema,
604
- uiSchema: uiSchema,
605
- registry: registry
606
- }), jsxRuntime.jsxs(Grid__default["default"], {
607
- container: true,
608
- spacing: 2,
609
- style: {
610
- marginTop: '10px'
611
- },
612
- children: [properties.map((element, index) =>
613
- // Remove the <Grid> if the inner element is hidden as the <Grid>
614
- // itself would otherwise still take up space.
615
- element.hidden ? element.content : jsxRuntime.jsx(Grid__default["default"], {
616
- item: true,
617
- xs: 12,
618
- style: {
619
- marginBottom: '10px'
620
- },
621
- children: element.content
622
- }, index)), utils.canExpand(schema, uiSchema, formData) && jsxRuntime.jsx(Grid__default["default"], {
623
- container: true,
624
- justifyContent: 'flex-end',
625
- children: jsxRuntime.jsx(Grid__default["default"], {
626
- item: true,
627
- children: jsxRuntime.jsx(AddButton, {
628
- className: 'object-property-expand',
629
- onClick: onAddClick(schema),
630
- disabled: disabled || readonly,
631
- uiSchema: uiSchema,
632
- registry: registry
633
- })
634
- })
635
- })]
636
- })]
637
- });
638
- }
639
-
640
- /** The `SubmitButton` renders a button that represent the `Submit` action on a form
641
- */
642
- function SubmitButton({
643
- uiSchema
644
- }) {
645
- const {
646
- submitText,
647
- norender,
648
- props: submitButtonProps = {}
649
- } = utils.getSubmitButtonOptions(uiSchema);
650
- if (norender) {
651
- return null;
652
- }
653
- return jsxRuntime.jsx(Box__default["default"], {
654
- marginTop: 3,
655
- children: jsxRuntime.jsx(Button__default["default"], {
656
- type: 'submit',
657
- variant: 'contained',
658
- color: 'primary',
659
- ...submitButtonProps,
660
- children: submitText
661
- })
662
- });
663
- }
664
-
665
- /** The `TitleField` is the template to use to render the title of a field
666
- *
667
- * @param props - The `TitleFieldProps` for this component
668
- */
669
- function TitleField({
670
- id,
671
- title
672
- }) {
673
- return jsxRuntime.jsxs(Box__default["default"], {
674
- id: id,
675
- mb: 1,
676
- mt: 1,
677
- children: [jsxRuntime.jsx(Typography__default["default"], {
678
- variant: 'h5',
679
- children: title
680
- }), jsxRuntime.jsx(Divider__default["default"], {})]
681
- });
682
- }
683
-
684
- /** The `WrapIfAdditional` component is used by the `FieldTemplate` to rename, or remove properties that are
685
- * part of an `additionalProperties` part of a schema.
686
- *
687
- * @param props - The `WrapIfAdditionalProps` for this component
688
- */
689
- function WrapIfAdditionalTemplate(props) {
690
- const {
691
- children,
692
- classNames,
693
- style,
694
- disabled,
695
- id,
696
- label,
697
- onDropPropertyClick,
698
- onKeyChange,
699
- readonly,
700
- required,
701
- schema,
702
- uiSchema,
703
- registry
704
- } = props;
705
- const {
706
- templates,
707
- translateString
708
- } = registry;
709
- // Button templates are not overridden in the uiSchema
710
- const {
711
- RemoveButton
712
- } = templates.ButtonTemplates;
713
- const keyLabel = translateString(utils.TranslatableString.KeyLabel, [label]);
714
- const additional = (utils.ADDITIONAL_PROPERTY_FLAG in schema);
715
- const btnStyle = {
716
- flex: 1,
717
- paddingLeft: 6,
718
- paddingRight: 6,
719
- fontWeight: 'bold'
720
- };
721
- if (!additional) {
722
- return jsxRuntime.jsx("div", {
723
- className: classNames,
724
- style: style,
725
- children: children
726
- });
727
- }
728
- const handleBlur = ({
729
- target
730
- }) => onKeyChange(target.value);
731
- return jsxRuntime.jsxs(Grid__default["default"], {
732
- container: true,
733
- alignItems: 'center',
734
- spacing: 2,
735
- className: classNames,
736
- style: style,
737
- children: [jsxRuntime.jsx(Grid__default["default"], {
738
- item: true,
739
- xs: true,
740
- children: jsxRuntime.jsx(TextField__default["default"], {
741
- fullWidth: true,
742
- required: required,
743
- label: keyLabel,
744
- defaultValue: label,
745
- disabled: disabled || readonly,
746
- id: `${id}-key`,
747
- name: `${id}-key`,
748
- onBlur: !readonly ? handleBlur : undefined,
749
- type: 'text'
750
- })
751
- }), jsxRuntime.jsx(Grid__default["default"], {
752
- item: true,
753
- xs: true,
754
- children: children
755
- }), jsxRuntime.jsx(Grid__default["default"], {
756
- item: true,
757
- children: jsxRuntime.jsx(RemoveButton, {
758
- iconType: 'default',
759
- style: btnStyle,
760
- disabled: disabled || readonly,
761
- onClick: onDropPropertyClick(label),
762
- uiSchema: uiSchema,
763
- registry: registry
764
- })
765
- })]
766
- }, `${id}-key`);
767
- }
768
-
769
- function generateTemplates() {
770
- return {
771
- ArrayFieldItemTemplate,
772
- ArrayFieldTemplate,
773
- BaseInputTemplate,
774
- ButtonTemplates: {
775
- AddButton,
776
- CopyButton,
777
- MoveDownButton,
778
- MoveUpButton,
779
- RemoveButton,
780
- SubmitButton
781
- },
782
- DescriptionFieldTemplate: DescriptionField,
783
- ErrorListTemplate: ErrorList,
784
- FieldErrorTemplate,
785
- FieldHelpTemplate,
786
- FieldTemplate,
787
- ObjectFieldTemplate,
788
- TitleFieldTemplate: TitleField,
789
- WrapIfAdditionalTemplate
790
- };
791
- }
792
- var Templates = /*#__PURE__*/generateTemplates();
793
-
794
- /** The `CheckBoxWidget` is a widget for rendering boolean properties.
795
- * It is typically used to represent a boolean.
796
- *
797
- * @param props - The `WidgetProps` for this component
798
- */
799
- function CheckboxWidget(props) {
800
- const {
801
- schema,
802
- id,
803
- value,
804
- disabled,
805
- readonly,
806
- label = '',
807
- hideLabel,
808
- autofocus,
809
- onChange,
810
- onBlur,
811
- onFocus,
812
- registry,
813
- options,
814
- uiSchema
815
- } = props;
816
- const DescriptionFieldTemplate = utils.getTemplate('DescriptionFieldTemplate', registry, options);
817
- // Because an unchecked checkbox will cause html5 validation to fail, only add
818
- // the "required" attribute if the field value must be "true", due to the
819
- // "const" or "enum" keywords
820
- const required = utils.schemaRequiresTrueValue(schema);
821
- const _onChange = (_, checked) => onChange(checked);
822
- const _onBlur = ({
823
- target: {
824
- value
825
- }
826
- }) => onBlur(id, value);
827
- const _onFocus = ({
828
- target: {
829
- value
830
- }
831
- }) => onFocus(id, value);
832
- const description = options.description ?? schema.description;
833
- return jsxRuntime.jsxs(jsxRuntime.Fragment, {
834
- children: [!hideLabel && !!description && jsxRuntime.jsx(DescriptionFieldTemplate, {
835
- id: utils.descriptionId(id),
836
- description: description,
837
- schema: schema,
838
- uiSchema: uiSchema,
839
- registry: registry
840
- }), jsxRuntime.jsx(FormControlLabel__default["default"], {
841
- control: jsxRuntime.jsx(Checkbox__default["default"], {
842
- id: id,
843
- name: id,
844
- checked: typeof value === 'undefined' ? false : Boolean(value),
845
- required: required,
846
- disabled: disabled || readonly,
847
- autoFocus: autofocus,
848
- onChange: _onChange,
849
- onBlur: _onBlur,
850
- onFocus: _onFocus,
851
- "aria-describedby": utils.ariaDescribedByIds(id)
852
- }),
853
- label: utils.labelValue(label, hideLabel, false)
854
- })]
855
- });
856
- }
857
-
858
- /** The `CheckboxesWidget` is a widget for rendering checkbox groups.
859
- * It is typically used to represent an array of enums.
860
- *
861
- * @param props - The `WidgetProps` for this component
862
- */
863
- function CheckboxesWidget({
864
- label,
865
- hideLabel,
866
- id,
867
- disabled,
868
- options,
869
- value,
870
- autofocus,
871
- readonly,
872
- required,
873
- onChange,
874
- onBlur,
875
- onFocus
876
- }) {
877
- const {
878
- enumOptions,
879
- enumDisabled,
880
- inline,
881
- emptyValue
882
- } = options;
883
- const checkboxesValues = Array.isArray(value) ? value : [value];
884
- const _onChange = index => ({
885
- target: {
886
- checked
887
- }
888
- }) => {
889
- if (checked) {
890
- onChange(utils.enumOptionsSelectValue(index, checkboxesValues, enumOptions));
891
- } else {
892
- onChange(utils.enumOptionsDeselectValue(index, checkboxesValues, enumOptions));
893
- }
894
- };
895
- const _onBlur = ({
896
- target: {
897
- value
898
- }
899
- }) => onBlur(id, utils.enumOptionsValueForIndex(value, enumOptions, emptyValue));
900
- const _onFocus = ({
901
- target: {
902
- value
903
- }
904
- }) => onFocus(id, utils.enumOptionsValueForIndex(value, enumOptions, emptyValue));
905
- return jsxRuntime.jsxs(jsxRuntime.Fragment, {
906
- children: [utils.labelValue(jsxRuntime.jsx(FormLabel__default["default"], {
907
- required: required,
908
- htmlFor: id,
909
- children: label || undefined
910
- }), hideLabel), jsxRuntime.jsx(FormGroup__default["default"], {
911
- id: id,
912
- row: !!inline,
913
- children: Array.isArray(enumOptions) && enumOptions.map((option, index) => {
914
- const checked = utils.enumOptionsIsSelected(option.value, checkboxesValues);
915
- const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
916
- const checkbox = jsxRuntime.jsx(Checkbox__default["default"], {
917
- id: utils.optionId(id, index),
918
- name: id,
919
- checked: checked,
920
- disabled: disabled || itemDisabled || readonly,
921
- autoFocus: autofocus && index === 0,
922
- onChange: _onChange(index),
923
- onBlur: _onBlur,
924
- onFocus: _onFocus,
925
- "aria-describedby": utils.ariaDescribedByIds(id)
926
- });
927
- return jsxRuntime.jsx(FormControlLabel__default["default"], {
928
- control: checkbox,
929
- label: option.label
930
- }, index);
931
- })
932
- })]
933
- });
934
- }
935
-
936
- /** The `RadioWidget` is a widget for rendering a radio group.
937
- * It is typically used with a string property constrained with enum options.
938
- *
939
- * @param props - The `WidgetProps` for this component
940
- */
941
- function RadioWidget({
942
- id,
943
- options,
944
- value,
945
- required,
946
- disabled,
947
- readonly,
948
- label,
949
- hideLabel,
950
- onChange,
951
- onBlur,
952
- onFocus
953
- }) {
954
- const {
955
- enumOptions,
956
- enumDisabled,
957
- emptyValue
958
- } = options;
959
- const _onChange = (_, value) => onChange(utils.enumOptionsValueForIndex(value, enumOptions, emptyValue));
960
- const _onBlur = ({
961
- target: {
962
- value
963
- }
964
- }) => onBlur(id, utils.enumOptionsValueForIndex(value, enumOptions, emptyValue));
965
- const _onFocus = ({
966
- target: {
967
- value
968
- }
969
- }) => onFocus(id, utils.enumOptionsValueForIndex(value, enumOptions, emptyValue));
970
- const row = options ? options.inline : false;
971
- const selectedIndex = utils.enumOptionsIndexForValue(value, enumOptions) ?? null;
972
- return jsxRuntime.jsxs(jsxRuntime.Fragment, {
973
- children: [utils.labelValue(jsxRuntime.jsx(FormLabel__default["default"], {
974
- required: required,
975
- htmlFor: id,
976
- children: label || undefined
977
- }), hideLabel), jsxRuntime.jsx(RadioGroup__default["default"], {
978
- id: id,
979
- name: id,
980
- value: selectedIndex,
981
- row: row,
982
- onChange: _onChange,
983
- onBlur: _onBlur,
984
- onFocus: _onFocus,
985
- "aria-describedby": utils.ariaDescribedByIds(id),
986
- children: Array.isArray(enumOptions) && enumOptions.map((option, index) => {
987
- const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
988
- const radio = jsxRuntime.jsx(FormControlLabel__default["default"], {
989
- control: jsxRuntime.jsx(Radio__default["default"], {
990
- name: id,
991
- id: utils.optionId(id, index),
992
- color: 'primary'
993
- }),
994
- label: option.label,
995
- value: String(index),
996
- disabled: disabled || itemDisabled || readonly
997
- }, index);
998
- return radio;
999
- })
1000
- })]
1001
- });
1002
- }
1003
-
1004
- /** The `RangeWidget` component uses the `BaseInputTemplate` changing the type to `range` and wrapping the result
1005
- * in a div, with the value along side it.
1006
- *
1007
- * @param props - The `WidgetProps` for this component
1008
- */
1009
- function RangeWidget(props) {
1010
- const {
1011
- value,
1012
- readonly,
1013
- disabled,
1014
- onBlur,
1015
- onFocus,
1016
- options,
1017
- schema,
1018
- onChange,
1019
- required,
1020
- label,
1021
- hideLabel,
1022
- id
1023
- } = props;
1024
- const sliderProps = {
1025
- value,
1026
- label,
1027
- id,
1028
- name: id,
1029
- ...utils.rangeSpec(schema)
1030
- };
1031
- const _onChange = (_, value) => {
1032
- onChange(value ?? options.emptyValue);
1033
- };
1034
- const _onBlur = ({
1035
- target: {
1036
- value
1037
- }
1038
- }) => onBlur(id, value);
1039
- const _onFocus = ({
1040
- target: {
1041
- value
1042
- }
1043
- }) => onFocus(id, value);
1044
- return jsxRuntime.jsxs(jsxRuntime.Fragment, {
1045
- children: [utils.labelValue(jsxRuntime.jsx(FormLabel__default["default"], {
1046
- required: required,
1047
- htmlFor: id,
1048
- children: label || undefined
1049
- }), hideLabel), jsxRuntime.jsx(Slider__default["default"], {
1050
- disabled: disabled || readonly,
1051
- onChange: _onChange,
1052
- onBlur: _onBlur,
1053
- onFocus: _onFocus,
1054
- valueLabelDisplay: 'auto',
1055
- ...sliderProps,
1056
- "aria-describedby": utils.ariaDescribedByIds(id)
1057
- })]
1058
- });
1059
- }
1060
-
1061
- /** The `SelectWidget` is a widget for rendering dropdowns.
1062
- * It is typically used with string properties constrained with enum options.
1063
- *
1064
- * @param props - The `WidgetProps` for this component
1065
- */
1066
- function SelectWidget({
1067
- schema,
1068
- id,
1069
- name,
1070
- // remove this from textFieldProps
1071
- options,
1072
- label,
1073
- hideLabel,
1074
- required,
1075
- disabled,
1076
- placeholder,
1077
- readonly,
1078
- value,
1079
- multiple,
1080
- autofocus,
1081
- onChange,
1082
- onBlur,
1083
- onFocus,
1084
- rawErrors = [],
1085
- registry,
1086
- uiSchema,
1087
- hideError,
1088
- formContext,
1089
- ...textFieldProps
1090
- }) {
1091
- const {
1092
- enumOptions,
1093
- enumDisabled,
1094
- emptyValue: optEmptyVal
1095
- } = options;
1096
- multiple = typeof multiple === 'undefined' ? false : !!multiple;
1097
- const emptyValue = multiple ? [] : '';
1098
- const isEmpty = typeof value === 'undefined' || multiple && value.length < 1 || !multiple && value === emptyValue;
1099
- const _onChange = ({
1100
- target: {
1101
- value
1102
- }
1103
- }) => onChange(utils.enumOptionsValueForIndex(value, enumOptions, optEmptyVal));
1104
- const _onBlur = ({
1105
- target: {
1106
- value
1107
- }
1108
- }) => onBlur(id, utils.enumOptionsValueForIndex(value, enumOptions, optEmptyVal));
1109
- const _onFocus = ({
1110
- target: {
1111
- value
1112
- }
1113
- }) => onFocus(id, utils.enumOptionsValueForIndex(value, enumOptions, optEmptyVal));
1114
- const selectedIndexes = utils.enumOptionsIndexForValue(value, enumOptions, multiple);
1115
- return jsxRuntime.jsx(TextField__default["default"], {
1116
- id: id,
1117
- name: id,
1118
- label: utils.labelValue(label || undefined, hideLabel, false),
1119
- value: isEmpty ? emptyValue : selectedIndexes,
1120
- required: required,
1121
- disabled: disabled || readonly,
1122
- autoFocus: autofocus,
1123
- placeholder: placeholder,
1124
- error: rawErrors.length > 0,
1125
- onChange: _onChange,
1126
- onBlur: _onBlur,
1127
- onFocus: _onFocus,
1128
- ...textFieldProps,
1129
- select // Apply this and the following props after the potential overrides defined in textFieldProps
1130
- : true,
1131
- InputLabelProps: {
1132
- ...textFieldProps.InputLabelProps,
1133
- shrink: !isEmpty
1134
- },
1135
- SelectProps: {
1136
- ...textFieldProps.SelectProps,
1137
- multiple
1138
- },
1139
- "aria-describedby": utils.ariaDescribedByIds(id),
1140
- children: Array.isArray(enumOptions) && enumOptions.map(({
1141
- value,
1142
- label
1143
- }, i) => {
1144
- const disabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(value) !== -1;
1145
- return jsxRuntime.jsx(MenuItem__default["default"], {
1146
- value: String(i),
1147
- disabled: disabled,
1148
- children: label
1149
- }, i);
1150
- })
1151
- });
1152
- }
1153
-
1154
- /** The `TextareaWidget` is a widget for rendering input fields as textarea.
1155
- *
1156
- * @param props - The `WidgetProps` for this component
1157
- */
1158
- function TextareaWidget(props) {
1159
- const {
1160
- options,
1161
- registry
1162
- } = props;
1163
- const BaseInputTemplate = utils.getTemplate('BaseInputTemplate', registry, options);
1164
- let rows = 5;
1165
- if (typeof options.rows === 'string' || typeof options.rows === 'number') {
1166
- rows = options.rows;
1167
- }
1168
- return jsxRuntime.jsx(BaseInputTemplate, {
1169
- ...props,
1170
- multiline: true,
1171
- rows: rows
1172
- });
1173
- }
1174
-
1175
- function generateWidgets() {
1176
- return {
1177
- CheckboxWidget,
1178
- CheckboxesWidget,
1179
- RadioWidget,
1180
- RangeWidget,
1181
- SelectWidget,
1182
- TextareaWidget
1183
- };
1184
- }
1185
- var Widgets = /*#__PURE__*/generateWidgets();
1186
-
1187
- function generateTheme() {
1188
- return {
1189
- templates: generateTemplates(),
1190
- widgets: generateWidgets()
1191
- };
1192
- }
1193
- var Theme = /*#__PURE__*/generateTheme();
1194
-
1195
- function generateForm() {
1196
- return core.withTheme(generateTheme());
1197
- }
1198
- var MuiForm = /*#__PURE__*/generateForm();
1199
-
1200
- exports.Form = MuiForm;
1201
- exports.Templates = Templates;
1202
- exports.Theme = Theme;
1203
- exports.Widgets = Widgets;
1204
- exports["default"] = MuiForm;
1205
- exports.generateForm = generateForm;
1206
- exports.generateTemplates = generateTemplates;
1207
- exports.generateTheme = generateTheme;
1208
- exports.generateWidgets = generateWidgets;
1209
-
1210
- Object.defineProperty(exports, '__esModule', { value: true });
1211
-
1212
- }));
1213
- //# sourceMappingURL=mui.umd.development.js.map