@form-engine-ts/mui 2.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +13 -0
- package/dist/index.cjs +335 -0
- package/dist/index.d.cts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +333 -0
- package/package.json +70 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 nitta-a
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# @form-engine-ts/mui
|
|
2
|
+
|
|
3
|
+
Official Material UI v6/v7 adapters for `@form-engine-ts/react`.
|
|
4
|
+
|
|
5
|
+
```tsx
|
|
6
|
+
import { FormBuilder } from "@form-engine-ts/react";
|
|
7
|
+
import { muiBuilderComponents } from "@form-engine-ts/mui";
|
|
8
|
+
|
|
9
|
+
<FormBuilder schema={schema} onChange={setSchema} components={muiBuilderComponents} />;
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
The package keeps MUI and Emotion as peer dependencies and exposes `createMuiBuilderComponents` for targeted component
|
|
13
|
+
or icon overrides. Install `@mui/material`, `@mui/icons-material`, and Emotion alongside this package.
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.tsx
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
createMuiBuilderComponents: () => createMuiBuilderComponents,
|
|
24
|
+
muiBuilderComponents: () => muiBuilderComponents,
|
|
25
|
+
muiDefaultIconResolver: () => muiDefaultIconResolver
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(index_exports);
|
|
28
|
+
var import_icons_material = require("@mui/icons-material");
|
|
29
|
+
var import_material = require("@mui/material");
|
|
30
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
31
|
+
function MuiButtonAdapter({
|
|
32
|
+
id,
|
|
33
|
+
className,
|
|
34
|
+
disabled,
|
|
35
|
+
"aria-label": ariaLabel,
|
|
36
|
+
onClick,
|
|
37
|
+
children,
|
|
38
|
+
title,
|
|
39
|
+
variant = "secondary",
|
|
40
|
+
action,
|
|
41
|
+
targetId
|
|
42
|
+
}) {
|
|
43
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
44
|
+
import_material.Button,
|
|
45
|
+
{
|
|
46
|
+
id,
|
|
47
|
+
className,
|
|
48
|
+
type: "button",
|
|
49
|
+
disabled,
|
|
50
|
+
"aria-label": ariaLabel,
|
|
51
|
+
title,
|
|
52
|
+
"data-builder-action": action,
|
|
53
|
+
"data-target-id": targetId,
|
|
54
|
+
onClick,
|
|
55
|
+
color: variant === "danger" ? "error" : "primary",
|
|
56
|
+
variant: variant === "primary" ? "contained" : "outlined",
|
|
57
|
+
children
|
|
58
|
+
}
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
function MuiIconButtonAdapter({
|
|
62
|
+
id,
|
|
63
|
+
className,
|
|
64
|
+
disabled,
|
|
65
|
+
readOnly,
|
|
66
|
+
"aria-label": ariaLabel,
|
|
67
|
+
"aria-describedby": ariaDescribedBy,
|
|
68
|
+
"aria-labelledby": ariaLabelledBy,
|
|
69
|
+
onClick,
|
|
70
|
+
icon,
|
|
71
|
+
title
|
|
72
|
+
}) {
|
|
73
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
74
|
+
import_material.IconButton,
|
|
75
|
+
{
|
|
76
|
+
id,
|
|
77
|
+
className,
|
|
78
|
+
component: "button",
|
|
79
|
+
type: "button",
|
|
80
|
+
disabled: disabled || readOnly,
|
|
81
|
+
"aria-label": ariaLabel ?? title,
|
|
82
|
+
"aria-describedby": ariaDescribedBy,
|
|
83
|
+
"aria-labelledby": ariaLabelledBy,
|
|
84
|
+
title,
|
|
85
|
+
onClick,
|
|
86
|
+
sx: { minWidth: 0, padding: 0.5 },
|
|
87
|
+
children: icon
|
|
88
|
+
}
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
function MuiTextInputAdapter({
|
|
92
|
+
id,
|
|
93
|
+
className,
|
|
94
|
+
disabled,
|
|
95
|
+
readOnly,
|
|
96
|
+
"aria-label": ariaLabel,
|
|
97
|
+
"aria-describedby": ariaDescribedBy,
|
|
98
|
+
"aria-labelledby": ariaLabelledBy,
|
|
99
|
+
name,
|
|
100
|
+
label,
|
|
101
|
+
required,
|
|
102
|
+
error,
|
|
103
|
+
helperText,
|
|
104
|
+
value,
|
|
105
|
+
onChange,
|
|
106
|
+
placeholder,
|
|
107
|
+
maxLength,
|
|
108
|
+
inputMode,
|
|
109
|
+
type = "text",
|
|
110
|
+
min,
|
|
111
|
+
max,
|
|
112
|
+
step
|
|
113
|
+
}) {
|
|
114
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
115
|
+
import_material.TextField,
|
|
116
|
+
{
|
|
117
|
+
id,
|
|
118
|
+
className,
|
|
119
|
+
name,
|
|
120
|
+
label,
|
|
121
|
+
required,
|
|
122
|
+
error,
|
|
123
|
+
helperText,
|
|
124
|
+
value,
|
|
125
|
+
disabled,
|
|
126
|
+
slotProps: {
|
|
127
|
+
htmlInput: { maxLength, min, max, step, inputMode },
|
|
128
|
+
input: { readOnly },
|
|
129
|
+
formHelperText: { id: ariaDescribedBy }
|
|
130
|
+
},
|
|
131
|
+
type,
|
|
132
|
+
placeholder,
|
|
133
|
+
"aria-label": ariaLabel,
|
|
134
|
+
"aria-describedby": ariaDescribedBy,
|
|
135
|
+
"aria-labelledby": ariaLabelledBy,
|
|
136
|
+
fullWidth: true,
|
|
137
|
+
variant: "outlined",
|
|
138
|
+
onChange: (event) => onChange(event.currentTarget.value)
|
|
139
|
+
}
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
function MuiTextAreaAdapter({
|
|
143
|
+
id,
|
|
144
|
+
className,
|
|
145
|
+
disabled,
|
|
146
|
+
readOnly,
|
|
147
|
+
"aria-label": ariaLabel,
|
|
148
|
+
"aria-describedby": ariaDescribedBy,
|
|
149
|
+
"aria-labelledby": ariaLabelledBy,
|
|
150
|
+
name,
|
|
151
|
+
label,
|
|
152
|
+
required,
|
|
153
|
+
error,
|
|
154
|
+
helperText,
|
|
155
|
+
value,
|
|
156
|
+
onChange,
|
|
157
|
+
placeholder,
|
|
158
|
+
maxLength,
|
|
159
|
+
rows
|
|
160
|
+
}) {
|
|
161
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
162
|
+
import_material.TextField,
|
|
163
|
+
{
|
|
164
|
+
id,
|
|
165
|
+
className,
|
|
166
|
+
name,
|
|
167
|
+
label,
|
|
168
|
+
required,
|
|
169
|
+
error,
|
|
170
|
+
helperText,
|
|
171
|
+
value,
|
|
172
|
+
disabled,
|
|
173
|
+
slotProps: {
|
|
174
|
+
htmlInput: { maxLength },
|
|
175
|
+
input: { readOnly },
|
|
176
|
+
formHelperText: { id: ariaDescribedBy }
|
|
177
|
+
},
|
|
178
|
+
multiline: true,
|
|
179
|
+
rows,
|
|
180
|
+
placeholder,
|
|
181
|
+
"aria-label": ariaLabel,
|
|
182
|
+
"aria-describedby": ariaDescribedBy,
|
|
183
|
+
"aria-labelledby": ariaLabelledBy,
|
|
184
|
+
fullWidth: true,
|
|
185
|
+
variant: "outlined",
|
|
186
|
+
onChange: (event) => onChange(event.currentTarget.value)
|
|
187
|
+
}
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
function MuiSelectAdapter({
|
|
191
|
+
id,
|
|
192
|
+
className,
|
|
193
|
+
disabled,
|
|
194
|
+
readOnly,
|
|
195
|
+
"aria-label": ariaLabel,
|
|
196
|
+
"aria-describedby": ariaDescribedBy,
|
|
197
|
+
"aria-labelledby": ariaLabelledBy,
|
|
198
|
+
name,
|
|
199
|
+
label,
|
|
200
|
+
required,
|
|
201
|
+
error,
|
|
202
|
+
helperText,
|
|
203
|
+
value,
|
|
204
|
+
onChange,
|
|
205
|
+
options
|
|
206
|
+
}) {
|
|
207
|
+
const labelId = id === void 0 ? void 0 : `${id}-label`;
|
|
208
|
+
const handleChange = (event) => onChange(event.target.value);
|
|
209
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_material.FormControl, { className, fullWidth: true, error, required, disabled, children: [
|
|
210
|
+
label === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.InputLabel, { id: labelId, children: label }),
|
|
211
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
212
|
+
import_material.Select,
|
|
213
|
+
{
|
|
214
|
+
id,
|
|
215
|
+
labelId,
|
|
216
|
+
name,
|
|
217
|
+
label,
|
|
218
|
+
value,
|
|
219
|
+
onChange: handleChange,
|
|
220
|
+
readOnly,
|
|
221
|
+
"aria-label": ariaLabel,
|
|
222
|
+
"aria-describedby": ariaDescribedBy,
|
|
223
|
+
"aria-labelledby": ariaLabelledBy,
|
|
224
|
+
variant: "outlined",
|
|
225
|
+
children: options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.MenuItem, { value: option.value, disabled: option.disabled, children: option.label }, option.value))
|
|
226
|
+
}
|
|
227
|
+
),
|
|
228
|
+
helperText === void 0 || helperText.length === 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.FormHelperText, { id: ariaDescribedBy, children: helperText })
|
|
229
|
+
] });
|
|
230
|
+
}
|
|
231
|
+
function MuiCheckboxAdapter({
|
|
232
|
+
id,
|
|
233
|
+
className,
|
|
234
|
+
disabled,
|
|
235
|
+
readOnly,
|
|
236
|
+
"aria-label": ariaLabel,
|
|
237
|
+
checked,
|
|
238
|
+
onChange,
|
|
239
|
+
label
|
|
240
|
+
}) {
|
|
241
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
242
|
+
import_material.FormControlLabel,
|
|
243
|
+
{
|
|
244
|
+
className,
|
|
245
|
+
label,
|
|
246
|
+
control: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
247
|
+
import_material.Checkbox,
|
|
248
|
+
{
|
|
249
|
+
id,
|
|
250
|
+
checked,
|
|
251
|
+
disabled: disabled || readOnly,
|
|
252
|
+
inputProps: { "aria-label": ariaLabel },
|
|
253
|
+
onChange: (event) => onChange(event.target.checked)
|
|
254
|
+
}
|
|
255
|
+
)
|
|
256
|
+
}
|
|
257
|
+
);
|
|
258
|
+
}
|
|
259
|
+
function MuiSectionAdapter({
|
|
260
|
+
id,
|
|
261
|
+
className,
|
|
262
|
+
title,
|
|
263
|
+
description,
|
|
264
|
+
headingId,
|
|
265
|
+
"aria-label": ariaLabel,
|
|
266
|
+
children
|
|
267
|
+
}) {
|
|
268
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
269
|
+
import_material.Paper,
|
|
270
|
+
{
|
|
271
|
+
id,
|
|
272
|
+
className,
|
|
273
|
+
"aria-label": ariaLabel,
|
|
274
|
+
"aria-labelledby": title === void 0 ? void 0 : headingId,
|
|
275
|
+
sx: { p: 2, mb: 2 },
|
|
276
|
+
children: [
|
|
277
|
+
title === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.Typography, { id: headingId, variant: "h6", children: title }),
|
|
278
|
+
description === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.Typography, { variant: "body2", children: description }),
|
|
279
|
+
children
|
|
280
|
+
]
|
|
281
|
+
}
|
|
282
|
+
);
|
|
283
|
+
}
|
|
284
|
+
function MuiFieldsetAdapter({ className, legend, disabled, children }) {
|
|
285
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_material.Box, { component: "fieldset", className, disabled, sx: { border: 0, m: 0, p: 0 }, children: [
|
|
286
|
+
legend === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.Typography, { component: "legend", variant: "subtitle1", children: legend }),
|
|
287
|
+
children
|
|
288
|
+
] });
|
|
289
|
+
}
|
|
290
|
+
function MuiErrorMessageAdapter({ className, message }) {
|
|
291
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.Alert, { className, severity: "error", children: message });
|
|
292
|
+
}
|
|
293
|
+
function muiDefaultIconResolver(actionType) {
|
|
294
|
+
switch (actionType) {
|
|
295
|
+
case "moveUp":
|
|
296
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons_material.ArrowUpward, { fontSize: "small" });
|
|
297
|
+
case "moveDown":
|
|
298
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons_material.ArrowDownward, { fontSize: "small" });
|
|
299
|
+
case "delete":
|
|
300
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons_material.Delete, { fontSize: "small" });
|
|
301
|
+
case "add":
|
|
302
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons_material.Add, { fontSize: "small" });
|
|
303
|
+
case "edit":
|
|
304
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons_material.Edit, { fontSize: "small" });
|
|
305
|
+
case "settings":
|
|
306
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons_material.Settings, { fontSize: "small" });
|
|
307
|
+
case "translate":
|
|
308
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons_material.Translate, { fontSize: "small" });
|
|
309
|
+
case "close":
|
|
310
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons_material.Close, { fontSize: "small" });
|
|
311
|
+
case "dragHandle":
|
|
312
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons_material.DragHandle, { fontSize: "small" });
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
var muiBuilderComponents = {
|
|
316
|
+
Button: MuiButtonAdapter,
|
|
317
|
+
IconButton: MuiIconButtonAdapter,
|
|
318
|
+
TextInput: MuiTextInputAdapter,
|
|
319
|
+
TextArea: MuiTextAreaAdapter,
|
|
320
|
+
Select: MuiSelectAdapter,
|
|
321
|
+
Checkbox: MuiCheckboxAdapter,
|
|
322
|
+
Section: MuiSectionAdapter,
|
|
323
|
+
Fieldset: MuiFieldsetAdapter,
|
|
324
|
+
ErrorMessage: MuiErrorMessageAdapter,
|
|
325
|
+
renderIcon: muiDefaultIconResolver
|
|
326
|
+
};
|
|
327
|
+
function createMuiBuilderComponents(customOverrides = {}) {
|
|
328
|
+
return { ...muiBuilderComponents, ...customOverrides };
|
|
329
|
+
}
|
|
330
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
331
|
+
0 && (module.exports = {
|
|
332
|
+
createMuiBuilderComponents,
|
|
333
|
+
muiBuilderComponents,
|
|
334
|
+
muiDefaultIconResolver
|
|
335
|
+
});
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { FormBuilderComponents, BuilderActionIconType } from '@form-engine-ts/react';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
declare function muiDefaultIconResolver(actionType: BuilderActionIconType): ReactNode;
|
|
5
|
+
declare const muiBuilderComponents: FormBuilderComponents;
|
|
6
|
+
declare function createMuiBuilderComponents(customOverrides?: Partial<FormBuilderComponents>): FormBuilderComponents;
|
|
7
|
+
|
|
8
|
+
export { createMuiBuilderComponents, muiBuilderComponents, muiDefaultIconResolver };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { FormBuilderComponents, BuilderActionIconType } from '@form-engine-ts/react';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
declare function muiDefaultIconResolver(actionType: BuilderActionIconType): ReactNode;
|
|
5
|
+
declare const muiBuilderComponents: FormBuilderComponents;
|
|
6
|
+
declare function createMuiBuilderComponents(customOverrides?: Partial<FormBuilderComponents>): FormBuilderComponents;
|
|
7
|
+
|
|
8
|
+
export { createMuiBuilderComponents, muiBuilderComponents, muiDefaultIconResolver };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
// src/index.tsx
|
|
2
|
+
import {
|
|
3
|
+
Add,
|
|
4
|
+
ArrowDownward,
|
|
5
|
+
ArrowUpward,
|
|
6
|
+
Close,
|
|
7
|
+
Delete,
|
|
8
|
+
DragHandle,
|
|
9
|
+
Edit,
|
|
10
|
+
Settings,
|
|
11
|
+
Translate
|
|
12
|
+
} from "@mui/icons-material";
|
|
13
|
+
import {
|
|
14
|
+
Alert,
|
|
15
|
+
Box,
|
|
16
|
+
Button,
|
|
17
|
+
Checkbox,
|
|
18
|
+
FormControl,
|
|
19
|
+
FormControlLabel,
|
|
20
|
+
FormHelperText,
|
|
21
|
+
IconButton,
|
|
22
|
+
InputLabel,
|
|
23
|
+
MenuItem,
|
|
24
|
+
Paper,
|
|
25
|
+
Select,
|
|
26
|
+
TextField,
|
|
27
|
+
Typography
|
|
28
|
+
} from "@mui/material";
|
|
29
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
30
|
+
function MuiButtonAdapter({
|
|
31
|
+
id,
|
|
32
|
+
className,
|
|
33
|
+
disabled,
|
|
34
|
+
"aria-label": ariaLabel,
|
|
35
|
+
onClick,
|
|
36
|
+
children,
|
|
37
|
+
title,
|
|
38
|
+
variant = "secondary",
|
|
39
|
+
action,
|
|
40
|
+
targetId
|
|
41
|
+
}) {
|
|
42
|
+
return /* @__PURE__ */ jsx(
|
|
43
|
+
Button,
|
|
44
|
+
{
|
|
45
|
+
id,
|
|
46
|
+
className,
|
|
47
|
+
type: "button",
|
|
48
|
+
disabled,
|
|
49
|
+
"aria-label": ariaLabel,
|
|
50
|
+
title,
|
|
51
|
+
"data-builder-action": action,
|
|
52
|
+
"data-target-id": targetId,
|
|
53
|
+
onClick,
|
|
54
|
+
color: variant === "danger" ? "error" : "primary",
|
|
55
|
+
variant: variant === "primary" ? "contained" : "outlined",
|
|
56
|
+
children
|
|
57
|
+
}
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
function MuiIconButtonAdapter({
|
|
61
|
+
id,
|
|
62
|
+
className,
|
|
63
|
+
disabled,
|
|
64
|
+
readOnly,
|
|
65
|
+
"aria-label": ariaLabel,
|
|
66
|
+
"aria-describedby": ariaDescribedBy,
|
|
67
|
+
"aria-labelledby": ariaLabelledBy,
|
|
68
|
+
onClick,
|
|
69
|
+
icon,
|
|
70
|
+
title
|
|
71
|
+
}) {
|
|
72
|
+
return /* @__PURE__ */ jsx(
|
|
73
|
+
IconButton,
|
|
74
|
+
{
|
|
75
|
+
id,
|
|
76
|
+
className,
|
|
77
|
+
component: "button",
|
|
78
|
+
type: "button",
|
|
79
|
+
disabled: disabled || readOnly,
|
|
80
|
+
"aria-label": ariaLabel ?? title,
|
|
81
|
+
"aria-describedby": ariaDescribedBy,
|
|
82
|
+
"aria-labelledby": ariaLabelledBy,
|
|
83
|
+
title,
|
|
84
|
+
onClick,
|
|
85
|
+
sx: { minWidth: 0, padding: 0.5 },
|
|
86
|
+
children: icon
|
|
87
|
+
}
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
function MuiTextInputAdapter({
|
|
91
|
+
id,
|
|
92
|
+
className,
|
|
93
|
+
disabled,
|
|
94
|
+
readOnly,
|
|
95
|
+
"aria-label": ariaLabel,
|
|
96
|
+
"aria-describedby": ariaDescribedBy,
|
|
97
|
+
"aria-labelledby": ariaLabelledBy,
|
|
98
|
+
name,
|
|
99
|
+
label,
|
|
100
|
+
required,
|
|
101
|
+
error,
|
|
102
|
+
helperText,
|
|
103
|
+
value,
|
|
104
|
+
onChange,
|
|
105
|
+
placeholder,
|
|
106
|
+
maxLength,
|
|
107
|
+
inputMode,
|
|
108
|
+
type = "text",
|
|
109
|
+
min,
|
|
110
|
+
max,
|
|
111
|
+
step
|
|
112
|
+
}) {
|
|
113
|
+
return /* @__PURE__ */ jsx(
|
|
114
|
+
TextField,
|
|
115
|
+
{
|
|
116
|
+
id,
|
|
117
|
+
className,
|
|
118
|
+
name,
|
|
119
|
+
label,
|
|
120
|
+
required,
|
|
121
|
+
error,
|
|
122
|
+
helperText,
|
|
123
|
+
value,
|
|
124
|
+
disabled,
|
|
125
|
+
slotProps: {
|
|
126
|
+
htmlInput: { maxLength, min, max, step, inputMode },
|
|
127
|
+
input: { readOnly },
|
|
128
|
+
formHelperText: { id: ariaDescribedBy }
|
|
129
|
+
},
|
|
130
|
+
type,
|
|
131
|
+
placeholder,
|
|
132
|
+
"aria-label": ariaLabel,
|
|
133
|
+
"aria-describedby": ariaDescribedBy,
|
|
134
|
+
"aria-labelledby": ariaLabelledBy,
|
|
135
|
+
fullWidth: true,
|
|
136
|
+
variant: "outlined",
|
|
137
|
+
onChange: (event) => onChange(event.currentTarget.value)
|
|
138
|
+
}
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
function MuiTextAreaAdapter({
|
|
142
|
+
id,
|
|
143
|
+
className,
|
|
144
|
+
disabled,
|
|
145
|
+
readOnly,
|
|
146
|
+
"aria-label": ariaLabel,
|
|
147
|
+
"aria-describedby": ariaDescribedBy,
|
|
148
|
+
"aria-labelledby": ariaLabelledBy,
|
|
149
|
+
name,
|
|
150
|
+
label,
|
|
151
|
+
required,
|
|
152
|
+
error,
|
|
153
|
+
helperText,
|
|
154
|
+
value,
|
|
155
|
+
onChange,
|
|
156
|
+
placeholder,
|
|
157
|
+
maxLength,
|
|
158
|
+
rows
|
|
159
|
+
}) {
|
|
160
|
+
return /* @__PURE__ */ jsx(
|
|
161
|
+
TextField,
|
|
162
|
+
{
|
|
163
|
+
id,
|
|
164
|
+
className,
|
|
165
|
+
name,
|
|
166
|
+
label,
|
|
167
|
+
required,
|
|
168
|
+
error,
|
|
169
|
+
helperText,
|
|
170
|
+
value,
|
|
171
|
+
disabled,
|
|
172
|
+
slotProps: {
|
|
173
|
+
htmlInput: { maxLength },
|
|
174
|
+
input: { readOnly },
|
|
175
|
+
formHelperText: { id: ariaDescribedBy }
|
|
176
|
+
},
|
|
177
|
+
multiline: true,
|
|
178
|
+
rows,
|
|
179
|
+
placeholder,
|
|
180
|
+
"aria-label": ariaLabel,
|
|
181
|
+
"aria-describedby": ariaDescribedBy,
|
|
182
|
+
"aria-labelledby": ariaLabelledBy,
|
|
183
|
+
fullWidth: true,
|
|
184
|
+
variant: "outlined",
|
|
185
|
+
onChange: (event) => onChange(event.currentTarget.value)
|
|
186
|
+
}
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
function MuiSelectAdapter({
|
|
190
|
+
id,
|
|
191
|
+
className,
|
|
192
|
+
disabled,
|
|
193
|
+
readOnly,
|
|
194
|
+
"aria-label": ariaLabel,
|
|
195
|
+
"aria-describedby": ariaDescribedBy,
|
|
196
|
+
"aria-labelledby": ariaLabelledBy,
|
|
197
|
+
name,
|
|
198
|
+
label,
|
|
199
|
+
required,
|
|
200
|
+
error,
|
|
201
|
+
helperText,
|
|
202
|
+
value,
|
|
203
|
+
onChange,
|
|
204
|
+
options
|
|
205
|
+
}) {
|
|
206
|
+
const labelId = id === void 0 ? void 0 : `${id}-label`;
|
|
207
|
+
const handleChange = (event) => onChange(event.target.value);
|
|
208
|
+
return /* @__PURE__ */ jsxs(FormControl, { className, fullWidth: true, error, required, disabled, children: [
|
|
209
|
+
label === void 0 ? null : /* @__PURE__ */ jsx(InputLabel, { id: labelId, children: label }),
|
|
210
|
+
/* @__PURE__ */ jsx(
|
|
211
|
+
Select,
|
|
212
|
+
{
|
|
213
|
+
id,
|
|
214
|
+
labelId,
|
|
215
|
+
name,
|
|
216
|
+
label,
|
|
217
|
+
value,
|
|
218
|
+
onChange: handleChange,
|
|
219
|
+
readOnly,
|
|
220
|
+
"aria-label": ariaLabel,
|
|
221
|
+
"aria-describedby": ariaDescribedBy,
|
|
222
|
+
"aria-labelledby": ariaLabelledBy,
|
|
223
|
+
variant: "outlined",
|
|
224
|
+
children: options.map((option) => /* @__PURE__ */ jsx(MenuItem, { value: option.value, disabled: option.disabled, children: option.label }, option.value))
|
|
225
|
+
}
|
|
226
|
+
),
|
|
227
|
+
helperText === void 0 || helperText.length === 0 ? null : /* @__PURE__ */ jsx(FormHelperText, { id: ariaDescribedBy, children: helperText })
|
|
228
|
+
] });
|
|
229
|
+
}
|
|
230
|
+
function MuiCheckboxAdapter({
|
|
231
|
+
id,
|
|
232
|
+
className,
|
|
233
|
+
disabled,
|
|
234
|
+
readOnly,
|
|
235
|
+
"aria-label": ariaLabel,
|
|
236
|
+
checked,
|
|
237
|
+
onChange,
|
|
238
|
+
label
|
|
239
|
+
}) {
|
|
240
|
+
return /* @__PURE__ */ jsx(
|
|
241
|
+
FormControlLabel,
|
|
242
|
+
{
|
|
243
|
+
className,
|
|
244
|
+
label,
|
|
245
|
+
control: /* @__PURE__ */ jsx(
|
|
246
|
+
Checkbox,
|
|
247
|
+
{
|
|
248
|
+
id,
|
|
249
|
+
checked,
|
|
250
|
+
disabled: disabled || readOnly,
|
|
251
|
+
inputProps: { "aria-label": ariaLabel },
|
|
252
|
+
onChange: (event) => onChange(event.target.checked)
|
|
253
|
+
}
|
|
254
|
+
)
|
|
255
|
+
}
|
|
256
|
+
);
|
|
257
|
+
}
|
|
258
|
+
function MuiSectionAdapter({
|
|
259
|
+
id,
|
|
260
|
+
className,
|
|
261
|
+
title,
|
|
262
|
+
description,
|
|
263
|
+
headingId,
|
|
264
|
+
"aria-label": ariaLabel,
|
|
265
|
+
children
|
|
266
|
+
}) {
|
|
267
|
+
return /* @__PURE__ */ jsxs(
|
|
268
|
+
Paper,
|
|
269
|
+
{
|
|
270
|
+
id,
|
|
271
|
+
className,
|
|
272
|
+
"aria-label": ariaLabel,
|
|
273
|
+
"aria-labelledby": title === void 0 ? void 0 : headingId,
|
|
274
|
+
sx: { p: 2, mb: 2 },
|
|
275
|
+
children: [
|
|
276
|
+
title === void 0 ? null : /* @__PURE__ */ jsx(Typography, { id: headingId, variant: "h6", children: title }),
|
|
277
|
+
description === void 0 ? null : /* @__PURE__ */ jsx(Typography, { variant: "body2", children: description }),
|
|
278
|
+
children
|
|
279
|
+
]
|
|
280
|
+
}
|
|
281
|
+
);
|
|
282
|
+
}
|
|
283
|
+
function MuiFieldsetAdapter({ className, legend, disabled, children }) {
|
|
284
|
+
return /* @__PURE__ */ jsxs(Box, { component: "fieldset", className, disabled, sx: { border: 0, m: 0, p: 0 }, children: [
|
|
285
|
+
legend === void 0 ? null : /* @__PURE__ */ jsx(Typography, { component: "legend", variant: "subtitle1", children: legend }),
|
|
286
|
+
children
|
|
287
|
+
] });
|
|
288
|
+
}
|
|
289
|
+
function MuiErrorMessageAdapter({ className, message }) {
|
|
290
|
+
return /* @__PURE__ */ jsx(Alert, { className, severity: "error", children: message });
|
|
291
|
+
}
|
|
292
|
+
function muiDefaultIconResolver(actionType) {
|
|
293
|
+
switch (actionType) {
|
|
294
|
+
case "moveUp":
|
|
295
|
+
return /* @__PURE__ */ jsx(ArrowUpward, { fontSize: "small" });
|
|
296
|
+
case "moveDown":
|
|
297
|
+
return /* @__PURE__ */ jsx(ArrowDownward, { fontSize: "small" });
|
|
298
|
+
case "delete":
|
|
299
|
+
return /* @__PURE__ */ jsx(Delete, { fontSize: "small" });
|
|
300
|
+
case "add":
|
|
301
|
+
return /* @__PURE__ */ jsx(Add, { fontSize: "small" });
|
|
302
|
+
case "edit":
|
|
303
|
+
return /* @__PURE__ */ jsx(Edit, { fontSize: "small" });
|
|
304
|
+
case "settings":
|
|
305
|
+
return /* @__PURE__ */ jsx(Settings, { fontSize: "small" });
|
|
306
|
+
case "translate":
|
|
307
|
+
return /* @__PURE__ */ jsx(Translate, { fontSize: "small" });
|
|
308
|
+
case "close":
|
|
309
|
+
return /* @__PURE__ */ jsx(Close, { fontSize: "small" });
|
|
310
|
+
case "dragHandle":
|
|
311
|
+
return /* @__PURE__ */ jsx(DragHandle, { fontSize: "small" });
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
var muiBuilderComponents = {
|
|
315
|
+
Button: MuiButtonAdapter,
|
|
316
|
+
IconButton: MuiIconButtonAdapter,
|
|
317
|
+
TextInput: MuiTextInputAdapter,
|
|
318
|
+
TextArea: MuiTextAreaAdapter,
|
|
319
|
+
Select: MuiSelectAdapter,
|
|
320
|
+
Checkbox: MuiCheckboxAdapter,
|
|
321
|
+
Section: MuiSectionAdapter,
|
|
322
|
+
Fieldset: MuiFieldsetAdapter,
|
|
323
|
+
ErrorMessage: MuiErrorMessageAdapter,
|
|
324
|
+
renderIcon: muiDefaultIconResolver
|
|
325
|
+
};
|
|
326
|
+
function createMuiBuilderComponents(customOverrides = {}) {
|
|
327
|
+
return { ...muiBuilderComponents, ...customOverrides };
|
|
328
|
+
}
|
|
329
|
+
export {
|
|
330
|
+
createMuiBuilderComponents,
|
|
331
|
+
muiBuilderComponents,
|
|
332
|
+
muiDefaultIconResolver
|
|
333
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@form-engine-ts/mui",
|
|
3
|
+
"version": "2.9.2",
|
|
4
|
+
"publishConfig": {
|
|
5
|
+
"access": "public"
|
|
6
|
+
},
|
|
7
|
+
"type": "module",
|
|
8
|
+
"sideEffects": false,
|
|
9
|
+
"files": [
|
|
10
|
+
"dist",
|
|
11
|
+
"README.md",
|
|
12
|
+
"LICENSE"
|
|
13
|
+
],
|
|
14
|
+
"main": "./dist/index.cjs",
|
|
15
|
+
"module": "./dist/index.js",
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"import": "./dist/index.js",
|
|
21
|
+
"require": "./dist/index.cjs"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "git+https://github.com/nitta-a/form-engine-ts.git",
|
|
28
|
+
"directory": "packages/mui"
|
|
29
|
+
},
|
|
30
|
+
"bugs": {
|
|
31
|
+
"url": "https://github.com/nitta-a/form-engine-ts/issues"
|
|
32
|
+
},
|
|
33
|
+
"homepage": "https://github.com/nitta-a/form-engine-ts#readme",
|
|
34
|
+
"keywords": [
|
|
35
|
+
"form",
|
|
36
|
+
"react",
|
|
37
|
+
"mui",
|
|
38
|
+
"material-ui",
|
|
39
|
+
"form-builder",
|
|
40
|
+
"typescript"
|
|
41
|
+
],
|
|
42
|
+
"peerDependencies": {
|
|
43
|
+
"@emotion/react": "^11.0.0",
|
|
44
|
+
"@emotion/styled": "^11.0.0",
|
|
45
|
+
"@mui/icons-material": "^6.0.0 || ^7.0.0",
|
|
46
|
+
"@mui/material": "^6.0.0 || ^7.0.0",
|
|
47
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
48
|
+
"react-dom": "^18.0.0 || ^19.0.0",
|
|
49
|
+
"@form-engine-ts/core": "2.9.2",
|
|
50
|
+
"@form-engine-ts/react": "2.9.2"
|
|
51
|
+
},
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"@emotion/react": "^11.14.0",
|
|
54
|
+
"@emotion/styled": "^11.14.0",
|
|
55
|
+
"@mui/icons-material": "^7.3.2",
|
|
56
|
+
"@mui/material": "^7.3.2",
|
|
57
|
+
"@types/react": "^19.2.18",
|
|
58
|
+
"@types/react-dom": "^19.2.4",
|
|
59
|
+
"react": "^19.2.8",
|
|
60
|
+
"react-dom": "^19.2.8",
|
|
61
|
+
"@form-engine-ts/core": "2.9.2",
|
|
62
|
+
"@form-engine-ts/react": "2.9.2"
|
|
63
|
+
},
|
|
64
|
+
"scripts": {
|
|
65
|
+
"build": "tsup src/index.tsx --format esm,cjs --dts --clean --external @emotion/react --external @emotion/styled --external @form-engine-ts/core --external @form-engine-ts/react --external @mui/icons-material --external @mui/material --external react --external react-dom",
|
|
66
|
+
"check": "biome check . && tsc --noEmit",
|
|
67
|
+
"test": "vitest run --globals",
|
|
68
|
+
"typecheck": "tsc --noEmit"
|
|
69
|
+
}
|
|
70
|
+
}
|