@rjsf/mui 5.11.2 → 5.12.1
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.
- package/dist/index.js +1003 -5
- package/dist/index.js.map +7 -0
- package/dist/mui.esm.js +650 -824
- package/dist/mui.esm.js.map +7 -1
- package/dist/mui.umd.js +852 -0
- package/lib/AddButton/AddButton.d.ts +5 -0
- package/lib/AddButton/AddButton.js +13 -0
- package/lib/AddButton/AddButton.js.map +1 -0
- package/lib/AddButton/index.d.ts +2 -0
- package/lib/AddButton/index.js +3 -0
- package/lib/AddButton/index.js.map +1 -0
- package/lib/ArrayFieldItemTemplate/ArrayFieldItemTemplate.d.ts +7 -0
- package/lib/ArrayFieldItemTemplate/ArrayFieldItemTemplate.js +21 -0
- package/lib/ArrayFieldItemTemplate/ArrayFieldItemTemplate.js.map +1 -0
- package/lib/ArrayFieldItemTemplate/index.d.ts +2 -0
- package/lib/ArrayFieldItemTemplate/index.js +3 -0
- package/lib/ArrayFieldItemTemplate/index.js.map +1 -0
- package/lib/ArrayFieldTemplate/ArrayFieldTemplate.d.ts +7 -0
- package/lib/ArrayFieldTemplate/ArrayFieldTemplate.js +25 -0
- package/lib/ArrayFieldTemplate/ArrayFieldTemplate.js.map +1 -0
- package/lib/ArrayFieldTemplate/index.d.ts +2 -0
- package/lib/ArrayFieldTemplate/index.js +3 -0
- package/lib/ArrayFieldTemplate/index.js.map +1 -0
- package/lib/BaseInputTemplate/BaseInputTemplate.d.ts +9 -0
- package/lib/BaseInputTemplate/BaseInputTemplate.js +32 -0
- package/lib/BaseInputTemplate/BaseInputTemplate.js.map +1 -0
- package/lib/BaseInputTemplate/index.d.ts +2 -0
- package/lib/BaseInputTemplate/index.js +3 -0
- package/lib/BaseInputTemplate/index.js.map +1 -0
- package/lib/CheckboxWidget/CheckboxWidget.d.ts +8 -0
- package/lib/CheckboxWidget/CheckboxWidget.js +24 -0
- package/lib/CheckboxWidget/CheckboxWidget.js.map +1 -0
- package/lib/CheckboxWidget/index.d.ts +2 -0
- package/lib/CheckboxWidget/index.js +3 -0
- package/lib/CheckboxWidget/index.js.map +1 -0
- package/lib/CheckboxesWidget/CheckboxesWidget.d.ts +8 -0
- package/lib/CheckboxesWidget/CheckboxesWidget.js +33 -0
- package/lib/CheckboxesWidget/CheckboxesWidget.js.map +1 -0
- package/lib/CheckboxesWidget/index.d.ts +2 -0
- package/lib/CheckboxesWidget/index.js +3 -0
- package/lib/CheckboxesWidget/index.js.map +1 -0
- package/lib/DescriptionField/DescriptionField.d.ts +7 -0
- package/lib/DescriptionField/DescriptionField.js +14 -0
- package/lib/DescriptionField/DescriptionField.js.map +1 -0
- package/lib/DescriptionField/index.d.ts +2 -0
- package/lib/DescriptionField/index.js +3 -0
- package/lib/DescriptionField/index.js.map +1 -0
- package/lib/ErrorList/ErrorList.d.ts +7 -0
- package/lib/ErrorList/ErrorList.js +21 -0
- package/lib/ErrorList/ErrorList.js.map +1 -0
- package/lib/ErrorList/index.d.ts +2 -0
- package/lib/ErrorList/index.js +3 -0
- package/lib/ErrorList/index.js.map +1 -0
- package/lib/FieldErrorTemplate/FieldErrorTemplate.d.ts +7 -0
- package/lib/FieldErrorTemplate/FieldErrorTemplate.js +20 -0
- package/lib/FieldErrorTemplate/FieldErrorTemplate.js.map +1 -0
- package/lib/FieldErrorTemplate/index.d.ts +2 -0
- package/lib/FieldErrorTemplate/index.js +3 -0
- package/lib/FieldErrorTemplate/index.js.map +1 -0
- package/lib/FieldHelpTemplate/FieldHelpTemplate.d.ts +7 -0
- package/lib/FieldHelpTemplate/FieldHelpTemplate.js +16 -0
- package/lib/FieldHelpTemplate/FieldHelpTemplate.js.map +1 -0
- package/lib/FieldHelpTemplate/index.d.ts +2 -0
- package/lib/FieldHelpTemplate/index.js +3 -0
- package/lib/FieldHelpTemplate/index.js.map +1 -0
- package/lib/FieldTemplate/FieldTemplate.d.ts +8 -0
- package/lib/FieldTemplate/FieldTemplate.js +19 -0
- package/lib/FieldTemplate/FieldTemplate.js.map +1 -0
- package/lib/FieldTemplate/index.d.ts +2 -0
- package/lib/FieldTemplate/index.js +3 -0
- package/lib/FieldTemplate/index.js.map +1 -0
- package/lib/IconButton/IconButton.d.ts +7 -0
- package/lib/IconButton/IconButton.js +30 -0
- package/lib/IconButton/IconButton.js.map +1 -0
- package/lib/IconButton/index.d.ts +2 -0
- package/lib/IconButton/index.js +3 -0
- package/lib/IconButton/index.js.map +1 -0
- package/lib/MuiForm/MuiForm.d.ts +6 -0
- package/lib/MuiForm/MuiForm.js +7 -0
- package/lib/MuiForm/MuiForm.js.map +1 -0
- package/lib/MuiForm/index.d.ts +2 -0
- package/lib/MuiForm/index.js +3 -0
- package/lib/MuiForm/index.js.map +1 -0
- package/lib/ObjectFieldTemplate/ObjectFieldTemplate.d.ts +9 -0
- package/lib/ObjectFieldTemplate/ObjectFieldTemplate.js +22 -0
- package/lib/ObjectFieldTemplate/ObjectFieldTemplate.js.map +1 -0
- package/lib/ObjectFieldTemplate/index.d.ts +2 -0
- package/lib/ObjectFieldTemplate/index.js +3 -0
- package/lib/ObjectFieldTemplate/index.js.map +1 -0
- package/lib/RadioWidget/RadioWidget.d.ts +8 -0
- package/lib/RadioWidget/RadioWidget.js +27 -0
- package/lib/RadioWidget/RadioWidget.js.map +1 -0
- package/lib/RadioWidget/index.d.ts +2 -0
- package/lib/RadioWidget/index.js +3 -0
- package/lib/RadioWidget/index.js.map +1 -0
- package/lib/RangeWidget/RangeWidget.d.ts +8 -0
- package/lib/RangeWidget/RangeWidget.js +20 -0
- package/lib/RangeWidget/RangeWidget.js.map +1 -0
- package/lib/RangeWidget/index.d.ts +2 -0
- package/lib/RangeWidget/index.js +3 -0
- package/lib/RangeWidget/index.js.map +1 -0
- package/lib/SelectWidget/SelectWidget.d.ts +9 -0
- package/lib/SelectWidget/SelectWidget.js +29 -0
- package/lib/SelectWidget/SelectWidget.js.map +1 -0
- package/lib/SelectWidget/index.d.ts +2 -0
- package/lib/SelectWidget/index.js +3 -0
- package/lib/SelectWidget/index.js.map +1 -0
- package/lib/SubmitButton/SubmitButton.d.ts +5 -0
- package/lib/SubmitButton/SubmitButton.js +14 -0
- package/lib/SubmitButton/SubmitButton.js.map +1 -0
- package/lib/SubmitButton/index.d.ts +2 -0
- package/lib/SubmitButton/index.js +3 -0
- package/lib/SubmitButton/index.js.map +1 -0
- package/lib/Templates/Templates.d.ts +4 -0
- package/lib/Templates/Templates.js +39 -0
- package/lib/Templates/Templates.js.map +1 -0
- package/lib/Templates/index.d.ts +2 -0
- package/lib/Templates/index.js +3 -0
- package/lib/Templates/index.js.map +1 -0
- package/lib/TextareaWidget/TextareaWidget.d.ts +7 -0
- package/lib/TextareaWidget/TextareaWidget.js +16 -0
- package/lib/TextareaWidget/TextareaWidget.js.map +1 -0
- package/lib/TextareaWidget/index.d.ts +2 -0
- package/lib/TextareaWidget/index.js +3 -0
- package/lib/TextareaWidget/index.js.map +1 -0
- package/lib/Theme/Theme.d.ts +5 -0
- package/lib/Theme/Theme.js +10 -0
- package/lib/Theme/Theme.js.map +1 -0
- package/lib/Theme/index.d.ts +2 -0
- package/lib/Theme/index.js +3 -0
- package/lib/Theme/index.js.map +1 -0
- package/lib/TitleField/TitleField.d.ts +7 -0
- package/lib/TitleField/TitleField.js +12 -0
- package/lib/TitleField/TitleField.js.map +1 -0
- package/lib/TitleField/index.d.ts +2 -0
- package/lib/TitleField/index.js +3 -0
- package/lib/TitleField/index.js.map +1 -0
- package/lib/Widgets/Widgets.d.ts +4 -0
- package/lib/Widgets/Widgets.js +18 -0
- package/lib/Widgets/Widgets.js.map +1 -0
- package/lib/Widgets/index.d.ts +2 -0
- package/lib/Widgets/index.js +3 -0
- package/lib/Widgets/index.js.map +1 -0
- package/lib/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.d.ts +8 -0
- package/lib/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.js +29 -0
- package/lib/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.js.map +1 -0
- package/lib/WrapIfAdditionalTemplate/index.d.ts +2 -0
- package/lib/WrapIfAdditionalTemplate/index.js +3 -0
- package/lib/WrapIfAdditionalTemplate/index.js.map +1 -0
- package/lib/index.d.ts +6 -0
- package/lib/index.js +7 -0
- package/lib/index.js.map +1 -0
- package/package.json +24 -16
- package/src/AddButton/AddButton.tsx +18 -0
- package/src/AddButton/index.ts +2 -0
- package/src/ArrayFieldItemTemplate/ArrayFieldItemTemplate.tsx +91 -0
- package/src/ArrayFieldItemTemplate/index.ts +2 -0
- package/src/ArrayFieldTemplate/ArrayFieldTemplate.tsx +87 -0
- package/src/ArrayFieldTemplate/index.ts +2 -0
- package/src/BaseInputTemplate/BaseInputTemplate.tsx +106 -0
- package/src/BaseInputTemplate/index.ts +2 -0
- package/src/CheckboxWidget/CheckboxWidget.tsx +87 -0
- package/src/CheckboxWidget/index.ts +2 -0
- package/src/CheckboxesWidget/CheckboxesWidget.tsx +92 -0
- package/src/CheckboxesWidget/index.ts +2 -0
- package/src/DescriptionField/DescriptionField.tsx +23 -0
- package/src/DescriptionField/index.ts +2 -0
- package/src/ErrorList/ErrorList.tsx +39 -0
- package/src/ErrorList/index.ts +2 -0
- package/src/FieldErrorTemplate/FieldErrorTemplate.tsx +32 -0
- package/src/FieldErrorTemplate/index.ts +2 -0
- package/src/FieldHelpTemplate/FieldHelpTemplate.tsx +19 -0
- package/src/FieldHelpTemplate/index.ts +2 -0
- package/src/FieldTemplate/FieldTemplate.tsx +81 -0
- package/src/FieldTemplate/index.ts +2 -0
- package/src/IconButton/IconButton.tsx +81 -0
- package/src/IconButton/index.ts +2 -0
- package/src/MuiForm/MuiForm.tsx +15 -0
- package/src/MuiForm/index.ts +2 -0
- package/src/ObjectFieldTemplate/ObjectFieldTemplate.tsx +99 -0
- package/src/ObjectFieldTemplate/index.ts +2 -0
- package/src/RadioWidget/RadioWidget.tsx +83 -0
- package/src/RadioWidget/index.ts +2 -0
- package/src/RangeWidget/RangeWidget.tsx +51 -0
- package/src/RangeWidget/index.ts +2 -0
- package/src/SelectWidget/SelectWidget.tsx +100 -0
- package/src/SelectWidget/index.ts +2 -0
- package/src/SubmitButton/SubmitButton.tsx +23 -0
- package/src/SubmitButton/index.ts +2 -0
- package/src/Templates/Templates.ts +46 -0
- package/src/Templates/index.ts +2 -0
- package/src/TextareaWidget/TextareaWidget.tsx +21 -0
- package/src/TextareaWidget/index.ts +2 -0
- package/src/Theme/Theme.tsx +18 -0
- package/src/Theme/index.ts +2 -0
- package/src/TitleField/TitleField.tsx +20 -0
- package/src/TitleField/index.ts +2 -0
- package/src/Widgets/Widgets.ts +25 -0
- package/src/Widgets/index.ts +2 -0
- package/src/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.tsx +90 -0
- package/src/WrapIfAdditionalTemplate/index.ts +2 -0
- package/src/index.ts +8 -0
- package/dist/index.d.ts +0 -17
- package/dist/mui.cjs.development.js +0 -1239
- package/dist/mui.cjs.development.js.map +0 -1
- package/dist/mui.cjs.production.min.js +0 -2
- package/dist/mui.cjs.production.min.js.map +0 -1
- package/dist/mui.umd.development.js +0 -1213
- package/dist/mui.umd.development.js.map +0 -1
- package/dist/mui.umd.production.min.js +0 -2
- package/dist/mui.umd.production.min.js.map +0 -1
package/dist/mui.umd.js
ADDED
|
@@ -0,0 +1,852 @@
|
|
|
1
|
+
(function (global, factory) {
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@rjsf/core'), require('@mui/icons-material/Add'), require('@mui/material/IconButton'), require('@rjsf/utils'), require('react/jsx-runtime'), 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', '@mui/icons-material/Add', '@mui/material/IconButton', '@rjsf/utils', 'react/jsx-runtime', '@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.AddIcon, global.IconButton, global.utils, global.jsxRuntime, global.Box, global.Grid3, 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, AddIcon, IconButton, utils, jsxRuntime, Box, Grid3, 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
|
+
// src/MuiForm/MuiForm.tsx
|
|
8
|
+
function AddButton({
|
|
9
|
+
uiSchema,
|
|
10
|
+
registry,
|
|
11
|
+
...props
|
|
12
|
+
}) {
|
|
13
|
+
const { translateString } = registry;
|
|
14
|
+
return /* @__PURE__ */ jsxRuntime.jsx(IconButton, { title: translateString(utils.TranslatableString.AddItemButton), ...props, color: "primary", children: /* @__PURE__ */ jsxRuntime.jsx(AddIcon, {}) });
|
|
15
|
+
}
|
|
16
|
+
function ArrayFieldItemTemplate(props) {
|
|
17
|
+
const {
|
|
18
|
+
children,
|
|
19
|
+
disabled,
|
|
20
|
+
hasToolbar,
|
|
21
|
+
hasCopy,
|
|
22
|
+
hasMoveDown,
|
|
23
|
+
hasMoveUp,
|
|
24
|
+
hasRemove,
|
|
25
|
+
index,
|
|
26
|
+
onCopyIndexClick,
|
|
27
|
+
onDropIndexClick,
|
|
28
|
+
onReorderClick,
|
|
29
|
+
readonly,
|
|
30
|
+
uiSchema,
|
|
31
|
+
registry
|
|
32
|
+
} = props;
|
|
33
|
+
const { CopyButton: CopyButton2, MoveDownButton: MoveDownButton2, MoveUpButton: MoveUpButton2, RemoveButton: RemoveButton2 } = registry.templates.ButtonTemplates;
|
|
34
|
+
const btnStyle = {
|
|
35
|
+
flex: 1,
|
|
36
|
+
paddingLeft: 6,
|
|
37
|
+
paddingRight: 6,
|
|
38
|
+
fontWeight: "bold",
|
|
39
|
+
minWidth: 0
|
|
40
|
+
};
|
|
41
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Grid3, { container: true, alignItems: "center", children: [
|
|
42
|
+
/* @__PURE__ */ jsxRuntime.jsx(Grid3, { item: true, xs: true, style: { overflow: "auto" }, children: /* @__PURE__ */ jsxRuntime.jsx(Box, { mb: 2, children: /* @__PURE__ */ jsxRuntime.jsx(Paper, { elevation: 2, children: /* @__PURE__ */ jsxRuntime.jsx(Box, { p: 2, children }) }) }) }),
|
|
43
|
+
hasToolbar && /* @__PURE__ */ jsxRuntime.jsxs(Grid3, { item: true, children: [
|
|
44
|
+
(hasMoveUp || hasMoveDown) && /* @__PURE__ */ jsxRuntime.jsx(
|
|
45
|
+
MoveUpButton2,
|
|
46
|
+
{
|
|
47
|
+
style: btnStyle,
|
|
48
|
+
disabled: disabled || readonly || !hasMoveUp,
|
|
49
|
+
onClick: onReorderClick(index, index - 1),
|
|
50
|
+
uiSchema,
|
|
51
|
+
registry
|
|
52
|
+
}
|
|
53
|
+
),
|
|
54
|
+
(hasMoveUp || hasMoveDown) && /* @__PURE__ */ jsxRuntime.jsx(
|
|
55
|
+
MoveDownButton2,
|
|
56
|
+
{
|
|
57
|
+
style: btnStyle,
|
|
58
|
+
disabled: disabled || readonly || !hasMoveDown,
|
|
59
|
+
onClick: onReorderClick(index, index + 1),
|
|
60
|
+
uiSchema,
|
|
61
|
+
registry
|
|
62
|
+
}
|
|
63
|
+
),
|
|
64
|
+
hasCopy && /* @__PURE__ */ jsxRuntime.jsx(
|
|
65
|
+
CopyButton2,
|
|
66
|
+
{
|
|
67
|
+
style: btnStyle,
|
|
68
|
+
disabled: disabled || readonly,
|
|
69
|
+
onClick: onCopyIndexClick(index),
|
|
70
|
+
uiSchema,
|
|
71
|
+
registry
|
|
72
|
+
}
|
|
73
|
+
),
|
|
74
|
+
hasRemove && /* @__PURE__ */ jsxRuntime.jsx(
|
|
75
|
+
RemoveButton2,
|
|
76
|
+
{
|
|
77
|
+
style: btnStyle,
|
|
78
|
+
disabled: disabled || readonly,
|
|
79
|
+
onClick: onDropIndexClick(index),
|
|
80
|
+
uiSchema,
|
|
81
|
+
registry
|
|
82
|
+
}
|
|
83
|
+
)
|
|
84
|
+
] })
|
|
85
|
+
] });
|
|
86
|
+
}
|
|
87
|
+
function ArrayFieldTemplate(props) {
|
|
88
|
+
const { canAdd, disabled, idSchema, uiSchema, items, onAddClick, readonly, registry, required, schema, title } = props;
|
|
89
|
+
const uiOptions = utils.getUiOptions(uiSchema);
|
|
90
|
+
const ArrayFieldDescriptionTemplate = utils.getTemplate(
|
|
91
|
+
"ArrayFieldDescriptionTemplate",
|
|
92
|
+
registry,
|
|
93
|
+
uiOptions
|
|
94
|
+
);
|
|
95
|
+
const ArrayFieldItemTemplate2 = utils.getTemplate(
|
|
96
|
+
"ArrayFieldItemTemplate",
|
|
97
|
+
registry,
|
|
98
|
+
uiOptions
|
|
99
|
+
);
|
|
100
|
+
const ArrayFieldTitleTemplate = utils.getTemplate(
|
|
101
|
+
"ArrayFieldTitleTemplate",
|
|
102
|
+
registry,
|
|
103
|
+
uiOptions
|
|
104
|
+
);
|
|
105
|
+
const {
|
|
106
|
+
ButtonTemplates: { AddButton: AddButton2 }
|
|
107
|
+
} = registry.templates;
|
|
108
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Paper, { elevation: 2, children: /* @__PURE__ */ jsxRuntime.jsxs(Box, { p: 2, children: [
|
|
109
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
110
|
+
ArrayFieldTitleTemplate,
|
|
111
|
+
{
|
|
112
|
+
idSchema,
|
|
113
|
+
title: uiOptions.title || title,
|
|
114
|
+
schema,
|
|
115
|
+
uiSchema,
|
|
116
|
+
required,
|
|
117
|
+
registry
|
|
118
|
+
}
|
|
119
|
+
),
|
|
120
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
121
|
+
ArrayFieldDescriptionTemplate,
|
|
122
|
+
{
|
|
123
|
+
idSchema,
|
|
124
|
+
description: uiOptions.description || schema.description,
|
|
125
|
+
schema,
|
|
126
|
+
uiSchema,
|
|
127
|
+
registry
|
|
128
|
+
}
|
|
129
|
+
),
|
|
130
|
+
/* @__PURE__ */ jsxRuntime.jsxs(Grid3, { container: true, children: [
|
|
131
|
+
items && items.map(({ key, ...itemProps }) => /* @__PURE__ */ jsxRuntime.jsx(ArrayFieldItemTemplate2, { ...itemProps }, key)),
|
|
132
|
+
canAdd && /* @__PURE__ */ jsxRuntime.jsx(Grid3, { container: true, justifyContent: "flex-end", children: /* @__PURE__ */ jsxRuntime.jsx(Grid3, { item: true, children: /* @__PURE__ */ jsxRuntime.jsx(Box, { mt: 2, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
133
|
+
AddButton2,
|
|
134
|
+
{
|
|
135
|
+
className: "array-item-add",
|
|
136
|
+
onClick: onAddClick,
|
|
137
|
+
disabled: disabled || readonly,
|
|
138
|
+
uiSchema,
|
|
139
|
+
registry
|
|
140
|
+
}
|
|
141
|
+
) }) }) })
|
|
142
|
+
] }, `array-item-list-${idSchema.$id}`)
|
|
143
|
+
] }) });
|
|
144
|
+
}
|
|
145
|
+
var TYPES_THAT_SHRINK_LABEL = ["date", "datetime-local", "file", "time"];
|
|
146
|
+
function BaseInputTemplate(props) {
|
|
147
|
+
const {
|
|
148
|
+
id,
|
|
149
|
+
name,
|
|
150
|
+
// remove this from textFieldProps
|
|
151
|
+
placeholder,
|
|
152
|
+
required,
|
|
153
|
+
readonly,
|
|
154
|
+
disabled,
|
|
155
|
+
type,
|
|
156
|
+
label,
|
|
157
|
+
hideLabel,
|
|
158
|
+
value,
|
|
159
|
+
onChange,
|
|
160
|
+
onChangeOverride,
|
|
161
|
+
onBlur,
|
|
162
|
+
onFocus,
|
|
163
|
+
autofocus,
|
|
164
|
+
options,
|
|
165
|
+
schema,
|
|
166
|
+
uiSchema,
|
|
167
|
+
rawErrors = [],
|
|
168
|
+
formContext,
|
|
169
|
+
registry,
|
|
170
|
+
InputLabelProps,
|
|
171
|
+
...textFieldProps
|
|
172
|
+
} = props;
|
|
173
|
+
const inputProps = utils.getInputProps(schema, type, options);
|
|
174
|
+
const { step, min, max, ...rest } = inputProps;
|
|
175
|
+
const otherProps = {
|
|
176
|
+
inputProps: {
|
|
177
|
+
step,
|
|
178
|
+
min,
|
|
179
|
+
max,
|
|
180
|
+
...schema.examples ? { list: utils.examplesId(id) } : void 0
|
|
181
|
+
},
|
|
182
|
+
...rest
|
|
183
|
+
};
|
|
184
|
+
const _onChange = ({ target: { value: value2 } }) => onChange(value2 === "" ? options.emptyValue : value2);
|
|
185
|
+
const _onBlur = ({ target: { value: value2 } }) => onBlur(id, value2);
|
|
186
|
+
const _onFocus = ({ target: { value: value2 } }) => onFocus(id, value2);
|
|
187
|
+
const DisplayInputLabelProps = TYPES_THAT_SHRINK_LABEL.includes(type) ? {
|
|
188
|
+
...InputLabelProps,
|
|
189
|
+
shrink: true
|
|
190
|
+
} : InputLabelProps;
|
|
191
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
192
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
193
|
+
TextField,
|
|
194
|
+
{
|
|
195
|
+
id,
|
|
196
|
+
name: id,
|
|
197
|
+
placeholder,
|
|
198
|
+
label: utils.labelValue(label || void 0, hideLabel, false),
|
|
199
|
+
autoFocus: autofocus,
|
|
200
|
+
required,
|
|
201
|
+
disabled: disabled || readonly,
|
|
202
|
+
...otherProps,
|
|
203
|
+
value: value || value === 0 ? value : "",
|
|
204
|
+
error: rawErrors.length > 0,
|
|
205
|
+
onChange: onChangeOverride || _onChange,
|
|
206
|
+
onBlur: _onBlur,
|
|
207
|
+
onFocus: _onFocus,
|
|
208
|
+
InputLabelProps: DisplayInputLabelProps,
|
|
209
|
+
...textFieldProps,
|
|
210
|
+
"aria-describedby": utils.ariaDescribedByIds(id, !!schema.examples)
|
|
211
|
+
}
|
|
212
|
+
),
|
|
213
|
+
Array.isArray(schema.examples) && /* @__PURE__ */ jsxRuntime.jsx("datalist", { id: utils.examplesId(id), children: schema.examples.concat(schema.default && !schema.examples.includes(schema.default) ? [schema.default] : []).map((example) => {
|
|
214
|
+
return /* @__PURE__ */ jsxRuntime.jsx("option", { value: example }, example);
|
|
215
|
+
}) })
|
|
216
|
+
] });
|
|
217
|
+
}
|
|
218
|
+
function DescriptionField(props) {
|
|
219
|
+
const { id, description } = props;
|
|
220
|
+
if (description) {
|
|
221
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Typography, { id, variant: "subtitle2", style: { marginTop: "5px" }, children: description });
|
|
222
|
+
}
|
|
223
|
+
return null;
|
|
224
|
+
}
|
|
225
|
+
function ErrorList({
|
|
226
|
+
errors,
|
|
227
|
+
registry
|
|
228
|
+
}) {
|
|
229
|
+
const { translateString } = registry;
|
|
230
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Paper, { elevation: 2, children: /* @__PURE__ */ jsxRuntime.jsxs(Box, { mb: 2, p: 2, children: [
|
|
231
|
+
/* @__PURE__ */ jsxRuntime.jsx(Typography, { variant: "h6", children: translateString(utils.TranslatableString.ErrorsLabel) }),
|
|
232
|
+
/* @__PURE__ */ jsxRuntime.jsx(List, { dense: true, children: errors.map((error, i) => {
|
|
233
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(ListItem, { children: [
|
|
234
|
+
/* @__PURE__ */ jsxRuntime.jsx(ListItemIcon, { children: /* @__PURE__ */ jsxRuntime.jsx(ErrorIcon, { color: "error" }) }),
|
|
235
|
+
/* @__PURE__ */ jsxRuntime.jsx(ListItemText, { primary: error.stack })
|
|
236
|
+
] }, i);
|
|
237
|
+
}) })
|
|
238
|
+
] }) });
|
|
239
|
+
}
|
|
240
|
+
function MuiIconButton(props) {
|
|
241
|
+
const { icon, color, uiSchema, registry, ...otherProps } = props;
|
|
242
|
+
return /* @__PURE__ */ jsxRuntime.jsx(IconButton, { ...otherProps, size: "small", color, children: icon });
|
|
243
|
+
}
|
|
244
|
+
function CopyButton(props) {
|
|
245
|
+
const {
|
|
246
|
+
registry: { translateString }
|
|
247
|
+
} = props;
|
|
248
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
249
|
+
MuiIconButton,
|
|
250
|
+
{
|
|
251
|
+
title: translateString(utils.TranslatableString.CopyButton),
|
|
252
|
+
...props,
|
|
253
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(CopyIcon, { fontSize: "small" })
|
|
254
|
+
}
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
function MoveDownButton(props) {
|
|
258
|
+
const {
|
|
259
|
+
registry: { translateString }
|
|
260
|
+
} = props;
|
|
261
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
262
|
+
MuiIconButton,
|
|
263
|
+
{
|
|
264
|
+
title: translateString(utils.TranslatableString.MoveDownButton),
|
|
265
|
+
...props,
|
|
266
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(ArrowDownwardIcon, { fontSize: "small" })
|
|
267
|
+
}
|
|
268
|
+
);
|
|
269
|
+
}
|
|
270
|
+
function MoveUpButton(props) {
|
|
271
|
+
const {
|
|
272
|
+
registry: { translateString }
|
|
273
|
+
} = props;
|
|
274
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
275
|
+
MuiIconButton,
|
|
276
|
+
{
|
|
277
|
+
title: translateString(utils.TranslatableString.MoveUpButton),
|
|
278
|
+
...props,
|
|
279
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(ArrowUpwardIcon, { fontSize: "small" })
|
|
280
|
+
}
|
|
281
|
+
);
|
|
282
|
+
}
|
|
283
|
+
function RemoveButton(props) {
|
|
284
|
+
const { iconType, ...otherProps } = props;
|
|
285
|
+
const {
|
|
286
|
+
registry: { translateString }
|
|
287
|
+
} = otherProps;
|
|
288
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
289
|
+
MuiIconButton,
|
|
290
|
+
{
|
|
291
|
+
title: translateString(utils.TranslatableString.RemoveButton),
|
|
292
|
+
...otherProps,
|
|
293
|
+
color: "error",
|
|
294
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(RemoveIcon, { fontSize: iconType === "default" ? void 0 : "small" })
|
|
295
|
+
}
|
|
296
|
+
);
|
|
297
|
+
}
|
|
298
|
+
function FieldErrorTemplate(props) {
|
|
299
|
+
const { errors = [], idSchema } = props;
|
|
300
|
+
if (errors.length === 0) {
|
|
301
|
+
return null;
|
|
302
|
+
}
|
|
303
|
+
const id = utils.errorId(idSchema);
|
|
304
|
+
return /* @__PURE__ */ jsxRuntime.jsx(List, { dense: true, disablePadding: true, children: errors.map((error, i) => {
|
|
305
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ListItem, { disableGutters: true, children: /* @__PURE__ */ jsxRuntime.jsx(FormHelperText, { id, children: error }) }, i);
|
|
306
|
+
}) });
|
|
307
|
+
}
|
|
308
|
+
function FieldHelpTemplate(props) {
|
|
309
|
+
const { idSchema, help } = props;
|
|
310
|
+
if (!help) {
|
|
311
|
+
return null;
|
|
312
|
+
}
|
|
313
|
+
const id = utils.helpId(idSchema);
|
|
314
|
+
return /* @__PURE__ */ jsxRuntime.jsx(FormHelperText, { id, children: help });
|
|
315
|
+
}
|
|
316
|
+
function FieldTemplate(props) {
|
|
317
|
+
const {
|
|
318
|
+
id,
|
|
319
|
+
children,
|
|
320
|
+
classNames,
|
|
321
|
+
style,
|
|
322
|
+
disabled,
|
|
323
|
+
displayLabel,
|
|
324
|
+
hidden,
|
|
325
|
+
label,
|
|
326
|
+
onDropPropertyClick,
|
|
327
|
+
onKeyChange,
|
|
328
|
+
readonly,
|
|
329
|
+
required,
|
|
330
|
+
rawErrors = [],
|
|
331
|
+
errors,
|
|
332
|
+
help,
|
|
333
|
+
description,
|
|
334
|
+
rawDescription,
|
|
335
|
+
schema,
|
|
336
|
+
uiSchema,
|
|
337
|
+
registry
|
|
338
|
+
} = props;
|
|
339
|
+
const uiOptions = utils.getUiOptions(uiSchema);
|
|
340
|
+
const WrapIfAdditionalTemplate2 = utils.getTemplate(
|
|
341
|
+
"WrapIfAdditionalTemplate",
|
|
342
|
+
registry,
|
|
343
|
+
uiOptions
|
|
344
|
+
);
|
|
345
|
+
if (hidden) {
|
|
346
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { style: { display: "none" }, children });
|
|
347
|
+
}
|
|
348
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
349
|
+
WrapIfAdditionalTemplate2,
|
|
350
|
+
{
|
|
351
|
+
classNames,
|
|
352
|
+
style,
|
|
353
|
+
disabled,
|
|
354
|
+
id,
|
|
355
|
+
label,
|
|
356
|
+
onDropPropertyClick,
|
|
357
|
+
onKeyChange,
|
|
358
|
+
readonly,
|
|
359
|
+
required,
|
|
360
|
+
schema,
|
|
361
|
+
uiSchema,
|
|
362
|
+
registry,
|
|
363
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(FormControl, { fullWidth: true, error: rawErrors.length ? true : false, required, children: [
|
|
364
|
+
children,
|
|
365
|
+
displayLabel && rawDescription ? /* @__PURE__ */ jsxRuntime.jsx(Typography, { variant: "caption", color: "textSecondary", children: description }) : null,
|
|
366
|
+
errors,
|
|
367
|
+
help
|
|
368
|
+
] })
|
|
369
|
+
}
|
|
370
|
+
);
|
|
371
|
+
}
|
|
372
|
+
function ObjectFieldTemplate(props) {
|
|
373
|
+
const {
|
|
374
|
+
description,
|
|
375
|
+
title,
|
|
376
|
+
properties,
|
|
377
|
+
required,
|
|
378
|
+
disabled,
|
|
379
|
+
readonly,
|
|
380
|
+
uiSchema,
|
|
381
|
+
idSchema,
|
|
382
|
+
schema,
|
|
383
|
+
formData,
|
|
384
|
+
onAddClick,
|
|
385
|
+
registry
|
|
386
|
+
} = props;
|
|
387
|
+
const uiOptions = utils.getUiOptions(uiSchema);
|
|
388
|
+
const TitleFieldTemplate = utils.getTemplate("TitleFieldTemplate", registry, uiOptions);
|
|
389
|
+
const DescriptionFieldTemplate = utils.getTemplate(
|
|
390
|
+
"DescriptionFieldTemplate",
|
|
391
|
+
registry,
|
|
392
|
+
uiOptions
|
|
393
|
+
);
|
|
394
|
+
const {
|
|
395
|
+
ButtonTemplates: { AddButton: AddButton2 }
|
|
396
|
+
} = registry.templates;
|
|
397
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
398
|
+
title && /* @__PURE__ */ jsxRuntime.jsx(
|
|
399
|
+
TitleFieldTemplate,
|
|
400
|
+
{
|
|
401
|
+
id: utils.titleId(idSchema),
|
|
402
|
+
title,
|
|
403
|
+
required,
|
|
404
|
+
schema,
|
|
405
|
+
uiSchema,
|
|
406
|
+
registry
|
|
407
|
+
}
|
|
408
|
+
),
|
|
409
|
+
description && /* @__PURE__ */ jsxRuntime.jsx(
|
|
410
|
+
DescriptionFieldTemplate,
|
|
411
|
+
{
|
|
412
|
+
id: utils.descriptionId(idSchema),
|
|
413
|
+
description,
|
|
414
|
+
schema,
|
|
415
|
+
uiSchema,
|
|
416
|
+
registry
|
|
417
|
+
}
|
|
418
|
+
),
|
|
419
|
+
/* @__PURE__ */ jsxRuntime.jsxs(Grid3, { container: true, spacing: 2, style: { marginTop: "10px" }, children: [
|
|
420
|
+
properties.map(
|
|
421
|
+
(element, index) => (
|
|
422
|
+
// Remove the <Grid> if the inner element is hidden as the <Grid>
|
|
423
|
+
// itself would otherwise still take up space.
|
|
424
|
+
element.hidden ? element.content : /* @__PURE__ */ jsxRuntime.jsx(Grid3, { item: true, xs: 12, style: { marginBottom: "10px" }, children: element.content }, index)
|
|
425
|
+
)
|
|
426
|
+
),
|
|
427
|
+
utils.canExpand(schema, uiSchema, formData) && /* @__PURE__ */ jsxRuntime.jsx(Grid3, { container: true, justifyContent: "flex-end", children: /* @__PURE__ */ jsxRuntime.jsx(Grid3, { item: true, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
428
|
+
AddButton2,
|
|
429
|
+
{
|
|
430
|
+
className: "object-property-expand",
|
|
431
|
+
onClick: onAddClick(schema),
|
|
432
|
+
disabled: disabled || readonly,
|
|
433
|
+
uiSchema,
|
|
434
|
+
registry
|
|
435
|
+
}
|
|
436
|
+
) }) })
|
|
437
|
+
] })
|
|
438
|
+
] });
|
|
439
|
+
}
|
|
440
|
+
function SubmitButton({ uiSchema }) {
|
|
441
|
+
const { submitText, norender, props: submitButtonProps = {} } = utils.getSubmitButtonOptions(uiSchema);
|
|
442
|
+
if (norender) {
|
|
443
|
+
return null;
|
|
444
|
+
}
|
|
445
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Box, { marginTop: 3, children: /* @__PURE__ */ jsxRuntime.jsx(Button, { type: "submit", variant: "contained", color: "primary", ...submitButtonProps, children: submitText }) });
|
|
446
|
+
}
|
|
447
|
+
function TitleField({
|
|
448
|
+
id,
|
|
449
|
+
title
|
|
450
|
+
}) {
|
|
451
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Box, { id, mb: 1, mt: 1, children: [
|
|
452
|
+
/* @__PURE__ */ jsxRuntime.jsx(Typography, { variant: "h5", children: title }),
|
|
453
|
+
/* @__PURE__ */ jsxRuntime.jsx(Divider, {})
|
|
454
|
+
] });
|
|
455
|
+
}
|
|
456
|
+
function WrapIfAdditionalTemplate(props) {
|
|
457
|
+
const {
|
|
458
|
+
children,
|
|
459
|
+
classNames,
|
|
460
|
+
style,
|
|
461
|
+
disabled,
|
|
462
|
+
id,
|
|
463
|
+
label,
|
|
464
|
+
onDropPropertyClick,
|
|
465
|
+
onKeyChange,
|
|
466
|
+
readonly,
|
|
467
|
+
required,
|
|
468
|
+
schema,
|
|
469
|
+
uiSchema,
|
|
470
|
+
registry
|
|
471
|
+
} = props;
|
|
472
|
+
const { templates, translateString } = registry;
|
|
473
|
+
const { RemoveButton: RemoveButton2 } = templates.ButtonTemplates;
|
|
474
|
+
const keyLabel = translateString(utils.TranslatableString.KeyLabel, [label]);
|
|
475
|
+
const additional = utils.ADDITIONAL_PROPERTY_FLAG in schema;
|
|
476
|
+
const btnStyle = {
|
|
477
|
+
flex: 1,
|
|
478
|
+
paddingLeft: 6,
|
|
479
|
+
paddingRight: 6,
|
|
480
|
+
fontWeight: "bold"
|
|
481
|
+
};
|
|
482
|
+
if (!additional) {
|
|
483
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: classNames, style, children });
|
|
484
|
+
}
|
|
485
|
+
const handleBlur = ({ target }) => onKeyChange(target.value);
|
|
486
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Grid3, { container: true, alignItems: "center", spacing: 2, className: classNames, style, children: [
|
|
487
|
+
/* @__PURE__ */ jsxRuntime.jsx(Grid3, { item: true, xs: true, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
488
|
+
TextField,
|
|
489
|
+
{
|
|
490
|
+
fullWidth: true,
|
|
491
|
+
required,
|
|
492
|
+
label: keyLabel,
|
|
493
|
+
defaultValue: label,
|
|
494
|
+
disabled: disabled || readonly,
|
|
495
|
+
id: `${id}-key`,
|
|
496
|
+
name: `${id}-key`,
|
|
497
|
+
onBlur: !readonly ? handleBlur : void 0,
|
|
498
|
+
type: "text"
|
|
499
|
+
}
|
|
500
|
+
) }),
|
|
501
|
+
/* @__PURE__ */ jsxRuntime.jsx(Grid3, { item: true, xs: true, children }),
|
|
502
|
+
/* @__PURE__ */ jsxRuntime.jsx(Grid3, { item: true, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
503
|
+
RemoveButton2,
|
|
504
|
+
{
|
|
505
|
+
iconType: "default",
|
|
506
|
+
style: btnStyle,
|
|
507
|
+
disabled: disabled || readonly,
|
|
508
|
+
onClick: onDropPropertyClick(label),
|
|
509
|
+
uiSchema,
|
|
510
|
+
registry
|
|
511
|
+
}
|
|
512
|
+
) })
|
|
513
|
+
] }, `${id}-key`);
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
// src/Templates/Templates.ts
|
|
517
|
+
function generateTemplates() {
|
|
518
|
+
return {
|
|
519
|
+
ArrayFieldItemTemplate,
|
|
520
|
+
ArrayFieldTemplate,
|
|
521
|
+
BaseInputTemplate,
|
|
522
|
+
ButtonTemplates: {
|
|
523
|
+
AddButton,
|
|
524
|
+
CopyButton,
|
|
525
|
+
MoveDownButton,
|
|
526
|
+
MoveUpButton,
|
|
527
|
+
RemoveButton,
|
|
528
|
+
SubmitButton
|
|
529
|
+
},
|
|
530
|
+
DescriptionFieldTemplate: DescriptionField,
|
|
531
|
+
ErrorListTemplate: ErrorList,
|
|
532
|
+
FieldErrorTemplate,
|
|
533
|
+
FieldHelpTemplate,
|
|
534
|
+
FieldTemplate,
|
|
535
|
+
ObjectFieldTemplate,
|
|
536
|
+
TitleFieldTemplate: TitleField,
|
|
537
|
+
WrapIfAdditionalTemplate
|
|
538
|
+
};
|
|
539
|
+
}
|
|
540
|
+
var Templates_default = generateTemplates();
|
|
541
|
+
function CheckboxWidget(props) {
|
|
542
|
+
const {
|
|
543
|
+
schema,
|
|
544
|
+
id,
|
|
545
|
+
value,
|
|
546
|
+
disabled,
|
|
547
|
+
readonly,
|
|
548
|
+
label = "",
|
|
549
|
+
hideLabel,
|
|
550
|
+
autofocus,
|
|
551
|
+
onChange,
|
|
552
|
+
onBlur,
|
|
553
|
+
onFocus,
|
|
554
|
+
registry,
|
|
555
|
+
options,
|
|
556
|
+
uiSchema
|
|
557
|
+
} = props;
|
|
558
|
+
const DescriptionFieldTemplate = utils.getTemplate(
|
|
559
|
+
"DescriptionFieldTemplate",
|
|
560
|
+
registry,
|
|
561
|
+
options
|
|
562
|
+
);
|
|
563
|
+
const required = utils.schemaRequiresTrueValue(schema);
|
|
564
|
+
const _onChange = (_, checked) => onChange(checked);
|
|
565
|
+
const _onBlur = ({ target: { value: value2 } }) => onBlur(id, value2);
|
|
566
|
+
const _onFocus = ({ target: { value: value2 } }) => onFocus(id, value2);
|
|
567
|
+
const description = options.description ?? schema.description;
|
|
568
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
569
|
+
!hideLabel && !!description && /* @__PURE__ */ jsxRuntime.jsx(
|
|
570
|
+
DescriptionFieldTemplate,
|
|
571
|
+
{
|
|
572
|
+
id: utils.descriptionId(id),
|
|
573
|
+
description,
|
|
574
|
+
schema,
|
|
575
|
+
uiSchema,
|
|
576
|
+
registry
|
|
577
|
+
}
|
|
578
|
+
),
|
|
579
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
580
|
+
FormControlLabel,
|
|
581
|
+
{
|
|
582
|
+
control: /* @__PURE__ */ jsxRuntime.jsx(
|
|
583
|
+
Checkbox,
|
|
584
|
+
{
|
|
585
|
+
id,
|
|
586
|
+
name: id,
|
|
587
|
+
checked: typeof value === "undefined" ? false : Boolean(value),
|
|
588
|
+
required,
|
|
589
|
+
disabled: disabled || readonly,
|
|
590
|
+
autoFocus: autofocus,
|
|
591
|
+
onChange: _onChange,
|
|
592
|
+
onBlur: _onBlur,
|
|
593
|
+
onFocus: _onFocus,
|
|
594
|
+
"aria-describedby": utils.ariaDescribedByIds(id)
|
|
595
|
+
}
|
|
596
|
+
),
|
|
597
|
+
label: utils.labelValue(label, hideLabel, false)
|
|
598
|
+
}
|
|
599
|
+
)
|
|
600
|
+
] });
|
|
601
|
+
}
|
|
602
|
+
function CheckboxesWidget({
|
|
603
|
+
label,
|
|
604
|
+
hideLabel,
|
|
605
|
+
id,
|
|
606
|
+
disabled,
|
|
607
|
+
options,
|
|
608
|
+
value,
|
|
609
|
+
autofocus,
|
|
610
|
+
readonly,
|
|
611
|
+
required,
|
|
612
|
+
onChange,
|
|
613
|
+
onBlur,
|
|
614
|
+
onFocus
|
|
615
|
+
}) {
|
|
616
|
+
const { enumOptions, enumDisabled, inline, emptyValue } = options;
|
|
617
|
+
const checkboxesValues = Array.isArray(value) ? value : [value];
|
|
618
|
+
const _onChange = (index) => ({ target: { checked } }) => {
|
|
619
|
+
if (checked) {
|
|
620
|
+
onChange(utils.enumOptionsSelectValue(index, checkboxesValues, enumOptions));
|
|
621
|
+
} else {
|
|
622
|
+
onChange(utils.enumOptionsDeselectValue(index, checkboxesValues, enumOptions));
|
|
623
|
+
}
|
|
624
|
+
};
|
|
625
|
+
const _onBlur = ({ target: { value: value2 } }) => onBlur(id, utils.enumOptionsValueForIndex(value2, enumOptions, emptyValue));
|
|
626
|
+
const _onFocus = ({ target: { value: value2 } }) => onFocus(id, utils.enumOptionsValueForIndex(value2, enumOptions, emptyValue));
|
|
627
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
628
|
+
utils.labelValue(
|
|
629
|
+
/* @__PURE__ */ jsxRuntime.jsx(FormLabel, { required, htmlFor: id, children: label || void 0 }),
|
|
630
|
+
hideLabel
|
|
631
|
+
),
|
|
632
|
+
/* @__PURE__ */ jsxRuntime.jsx(FormGroup, { id, row: !!inline, children: Array.isArray(enumOptions) && enumOptions.map((option, index) => {
|
|
633
|
+
const checked = utils.enumOptionsIsSelected(option.value, checkboxesValues);
|
|
634
|
+
const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
|
|
635
|
+
const checkbox = /* @__PURE__ */ jsxRuntime.jsx(
|
|
636
|
+
Checkbox,
|
|
637
|
+
{
|
|
638
|
+
id: utils.optionId(id, index),
|
|
639
|
+
name: id,
|
|
640
|
+
checked,
|
|
641
|
+
disabled: disabled || itemDisabled || readonly,
|
|
642
|
+
autoFocus: autofocus && index === 0,
|
|
643
|
+
onChange: _onChange(index),
|
|
644
|
+
onBlur: _onBlur,
|
|
645
|
+
onFocus: _onFocus,
|
|
646
|
+
"aria-describedby": utils.ariaDescribedByIds(id)
|
|
647
|
+
}
|
|
648
|
+
);
|
|
649
|
+
return /* @__PURE__ */ jsxRuntime.jsx(FormControlLabel, { control: checkbox, label: option.label }, index);
|
|
650
|
+
}) })
|
|
651
|
+
] });
|
|
652
|
+
}
|
|
653
|
+
function RadioWidget({
|
|
654
|
+
id,
|
|
655
|
+
options,
|
|
656
|
+
value,
|
|
657
|
+
required,
|
|
658
|
+
disabled,
|
|
659
|
+
readonly,
|
|
660
|
+
label,
|
|
661
|
+
hideLabel,
|
|
662
|
+
onChange,
|
|
663
|
+
onBlur,
|
|
664
|
+
onFocus
|
|
665
|
+
}) {
|
|
666
|
+
const { enumOptions, enumDisabled, emptyValue } = options;
|
|
667
|
+
const _onChange = (_, value2) => onChange(utils.enumOptionsValueForIndex(value2, enumOptions, emptyValue));
|
|
668
|
+
const _onBlur = ({ target: { value: value2 } }) => onBlur(id, utils.enumOptionsValueForIndex(value2, enumOptions, emptyValue));
|
|
669
|
+
const _onFocus = ({ target: { value: value2 } }) => onFocus(id, utils.enumOptionsValueForIndex(value2, enumOptions, emptyValue));
|
|
670
|
+
const row = options ? options.inline : false;
|
|
671
|
+
const selectedIndex = utils.enumOptionsIndexForValue(value, enumOptions) ?? null;
|
|
672
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
673
|
+
utils.labelValue(
|
|
674
|
+
/* @__PURE__ */ jsxRuntime.jsx(FormLabel, { required, htmlFor: id, children: label || void 0 }),
|
|
675
|
+
hideLabel
|
|
676
|
+
),
|
|
677
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
678
|
+
RadioGroup,
|
|
679
|
+
{
|
|
680
|
+
id,
|
|
681
|
+
name: id,
|
|
682
|
+
value: selectedIndex,
|
|
683
|
+
row,
|
|
684
|
+
onChange: _onChange,
|
|
685
|
+
onBlur: _onBlur,
|
|
686
|
+
onFocus: _onFocus,
|
|
687
|
+
"aria-describedby": utils.ariaDescribedByIds(id),
|
|
688
|
+
children: Array.isArray(enumOptions) && enumOptions.map((option, index) => {
|
|
689
|
+
const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
|
|
690
|
+
const radio = /* @__PURE__ */ jsxRuntime.jsx(
|
|
691
|
+
FormControlLabel,
|
|
692
|
+
{
|
|
693
|
+
control: /* @__PURE__ */ jsxRuntime.jsx(Radio, { name: id, id: utils.optionId(id, index), color: "primary" }),
|
|
694
|
+
label: option.label,
|
|
695
|
+
value: String(index),
|
|
696
|
+
disabled: disabled || itemDisabled || readonly
|
|
697
|
+
},
|
|
698
|
+
index
|
|
699
|
+
);
|
|
700
|
+
return radio;
|
|
701
|
+
})
|
|
702
|
+
}
|
|
703
|
+
)
|
|
704
|
+
] });
|
|
705
|
+
}
|
|
706
|
+
function RangeWidget(props) {
|
|
707
|
+
const { value, readonly, disabled, onBlur, onFocus, options, schema, onChange, required, label, hideLabel, id } = props;
|
|
708
|
+
const sliderProps = { value, label, id, name: id, ...utils.rangeSpec(schema) };
|
|
709
|
+
const _onChange = (_, value2) => {
|
|
710
|
+
onChange(value2 ?? options.emptyValue);
|
|
711
|
+
};
|
|
712
|
+
const _onBlur = ({ target: { value: value2 } }) => onBlur(id, value2);
|
|
713
|
+
const _onFocus = ({ target: { value: value2 } }) => onFocus(id, value2);
|
|
714
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
715
|
+
utils.labelValue(
|
|
716
|
+
/* @__PURE__ */ jsxRuntime.jsx(FormLabel, { required, htmlFor: id, children: label || void 0 }),
|
|
717
|
+
hideLabel
|
|
718
|
+
),
|
|
719
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
720
|
+
Slider,
|
|
721
|
+
{
|
|
722
|
+
disabled: disabled || readonly,
|
|
723
|
+
onChange: _onChange,
|
|
724
|
+
onBlur: _onBlur,
|
|
725
|
+
onFocus: _onFocus,
|
|
726
|
+
valueLabelDisplay: "auto",
|
|
727
|
+
...sliderProps,
|
|
728
|
+
"aria-describedby": utils.ariaDescribedByIds(id)
|
|
729
|
+
}
|
|
730
|
+
)
|
|
731
|
+
] });
|
|
732
|
+
}
|
|
733
|
+
function SelectWidget({
|
|
734
|
+
schema,
|
|
735
|
+
id,
|
|
736
|
+
name,
|
|
737
|
+
// remove this from textFieldProps
|
|
738
|
+
options,
|
|
739
|
+
label,
|
|
740
|
+
hideLabel,
|
|
741
|
+
required,
|
|
742
|
+
disabled,
|
|
743
|
+
placeholder,
|
|
744
|
+
readonly,
|
|
745
|
+
value,
|
|
746
|
+
multiple,
|
|
747
|
+
autofocus,
|
|
748
|
+
onChange,
|
|
749
|
+
onBlur,
|
|
750
|
+
onFocus,
|
|
751
|
+
rawErrors = [],
|
|
752
|
+
registry,
|
|
753
|
+
uiSchema,
|
|
754
|
+
hideError,
|
|
755
|
+
formContext,
|
|
756
|
+
...textFieldProps
|
|
757
|
+
}) {
|
|
758
|
+
const { enumOptions, enumDisabled, emptyValue: optEmptyVal } = options;
|
|
759
|
+
multiple = typeof multiple === "undefined" ? false : !!multiple;
|
|
760
|
+
const emptyValue = multiple ? [] : "";
|
|
761
|
+
const isEmpty = typeof value === "undefined" || multiple && value.length < 1 || !multiple && value === emptyValue;
|
|
762
|
+
const _onChange = ({ target: { value: value2 } }) => onChange(utils.enumOptionsValueForIndex(value2, enumOptions, optEmptyVal));
|
|
763
|
+
const _onBlur = ({ target: { value: value2 } }) => onBlur(id, utils.enumOptionsValueForIndex(value2, enumOptions, optEmptyVal));
|
|
764
|
+
const _onFocus = ({ target: { value: value2 } }) => onFocus(id, utils.enumOptionsValueForIndex(value2, enumOptions, optEmptyVal));
|
|
765
|
+
const selectedIndexes = utils.enumOptionsIndexForValue(value, enumOptions, multiple);
|
|
766
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
767
|
+
TextField,
|
|
768
|
+
{
|
|
769
|
+
id,
|
|
770
|
+
name: id,
|
|
771
|
+
label: utils.labelValue(label || void 0, hideLabel, false),
|
|
772
|
+
value: isEmpty ? emptyValue : selectedIndexes,
|
|
773
|
+
required,
|
|
774
|
+
disabled: disabled || readonly,
|
|
775
|
+
autoFocus: autofocus,
|
|
776
|
+
placeholder,
|
|
777
|
+
error: rawErrors.length > 0,
|
|
778
|
+
onChange: _onChange,
|
|
779
|
+
onBlur: _onBlur,
|
|
780
|
+
onFocus: _onFocus,
|
|
781
|
+
...textFieldProps,
|
|
782
|
+
select: true,
|
|
783
|
+
InputLabelProps: {
|
|
784
|
+
...textFieldProps.InputLabelProps,
|
|
785
|
+
shrink: !isEmpty
|
|
786
|
+
},
|
|
787
|
+
SelectProps: {
|
|
788
|
+
...textFieldProps.SelectProps,
|
|
789
|
+
multiple
|
|
790
|
+
},
|
|
791
|
+
"aria-describedby": utils.ariaDescribedByIds(id),
|
|
792
|
+
children: Array.isArray(enumOptions) && enumOptions.map(({ value: value2, label: label2 }, i) => {
|
|
793
|
+
const disabled2 = Array.isArray(enumDisabled) && enumDisabled.indexOf(value2) !== -1;
|
|
794
|
+
return /* @__PURE__ */ jsxRuntime.jsx(MenuItem, { value: String(i), disabled: disabled2, children: label2 }, i);
|
|
795
|
+
})
|
|
796
|
+
}
|
|
797
|
+
);
|
|
798
|
+
}
|
|
799
|
+
function TextareaWidget(props) {
|
|
800
|
+
const { options, registry } = props;
|
|
801
|
+
const BaseInputTemplate2 = utils.getTemplate("BaseInputTemplate", registry, options);
|
|
802
|
+
let rows = 5;
|
|
803
|
+
if (typeof options.rows === "string" || typeof options.rows === "number") {
|
|
804
|
+
rows = options.rows;
|
|
805
|
+
}
|
|
806
|
+
return /* @__PURE__ */ jsxRuntime.jsx(BaseInputTemplate2, { ...props, multiline: true, rows });
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
// src/Widgets/Widgets.ts
|
|
810
|
+
function generateWidgets() {
|
|
811
|
+
return {
|
|
812
|
+
CheckboxWidget,
|
|
813
|
+
CheckboxesWidget,
|
|
814
|
+
RadioWidget,
|
|
815
|
+
RangeWidget,
|
|
816
|
+
SelectWidget,
|
|
817
|
+
TextareaWidget
|
|
818
|
+
};
|
|
819
|
+
}
|
|
820
|
+
var Widgets_default = generateWidgets();
|
|
821
|
+
|
|
822
|
+
// src/Theme/Theme.tsx
|
|
823
|
+
function generateTheme() {
|
|
824
|
+
return {
|
|
825
|
+
templates: generateTemplates(),
|
|
826
|
+
widgets: generateWidgets()
|
|
827
|
+
};
|
|
828
|
+
}
|
|
829
|
+
var Theme_default = generateTheme();
|
|
830
|
+
|
|
831
|
+
// src/MuiForm/MuiForm.tsx
|
|
832
|
+
function generateForm() {
|
|
833
|
+
return core.withTheme(generateTheme());
|
|
834
|
+
}
|
|
835
|
+
var MuiForm_default = generateForm();
|
|
836
|
+
|
|
837
|
+
// src/index.ts
|
|
838
|
+
var src_default = MuiForm_default;
|
|
839
|
+
|
|
840
|
+
exports.Form = MuiForm_default;
|
|
841
|
+
exports.Templates = Templates_default;
|
|
842
|
+
exports.Theme = Theme_default;
|
|
843
|
+
exports.Widgets = Widgets_default;
|
|
844
|
+
exports.default = src_default;
|
|
845
|
+
exports.generateForm = generateForm;
|
|
846
|
+
exports.generateTemplates = generateTemplates;
|
|
847
|
+
exports.generateTheme = generateTheme;
|
|
848
|
+
exports.generateWidgets = generateWidgets;
|
|
849
|
+
|
|
850
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
851
|
+
|
|
852
|
+
}));
|