@form-engine-ts/mui 3.2.0 → 4.0.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.
- package/README.md +3 -2
- package/dist/index.cjs +82 -17
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +83 -17
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -76,8 +76,9 @@ default.
|
|
|
76
76
|
`layoutOptions`, `localizationOptions`, and `muiSlotProps` are also accepted in `muiOptions` for low-level factories such
|
|
77
77
|
as `createMuiBuilderSlots`; the dedicated `MuiFormBuilder` props take precedence.
|
|
78
78
|
|
|
79
|
-
Select options in the MUI adapter support icons, descriptions,
|
|
80
|
-
callbacks. Without a custom renderer, icons appear beside labels in the menu and
|
|
79
|
+
Select options in the MUI adapter support icons, descriptions, groups (`group`/`groupLabel` or `kind`), custom metadata,
|
|
80
|
+
and custom `renderOption`/`renderValue` callbacks. Without a custom renderer, icons appear beside labels in the menu and
|
|
81
|
+
in the selected value. The standard
|
|
81
82
|
MUI field editor supplies icons for every field type and accepts `slots.fieldTypeSelect` and `slots.fieldEditorHeader`
|
|
82
83
|
for focused customization. `muiSlotProps` also supports `textField`, `select`, `selectMenu`, `checkbox`, `button`, and
|
|
83
84
|
`iconButton` MUI props in addition to the layout props.
|
package/dist/index.cjs
CHANGED
|
@@ -417,6 +417,40 @@ var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
|
417
417
|
function normalizeOptions(options) {
|
|
418
418
|
return options.map((option) => typeof option === "string" ? { value: option, label: option } : option);
|
|
419
419
|
}
|
|
420
|
+
function SelectGroupHeader({ children }) {
|
|
421
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_material7.ListSubheader, { role: "presentation", children });
|
|
422
|
+
}
|
|
423
|
+
function groupSelectOptions(options) {
|
|
424
|
+
const groups = [];
|
|
425
|
+
const groupIndexes = /* @__PURE__ */ new Map();
|
|
426
|
+
for (const option of options) {
|
|
427
|
+
const groupKey = option.group ?? option.kind;
|
|
428
|
+
const groupLabel = option.groupLabel ?? groupKey;
|
|
429
|
+
if (groupKey === void 0 && groupLabel === void 0) {
|
|
430
|
+
groups.push({ items: [option] });
|
|
431
|
+
continue;
|
|
432
|
+
}
|
|
433
|
+
const key = groupKey ?? groupLabel;
|
|
434
|
+
if (key === void 0) {
|
|
435
|
+
groups.push({ items: [option] });
|
|
436
|
+
continue;
|
|
437
|
+
}
|
|
438
|
+
const existingIndex = groupIndexes.get(key);
|
|
439
|
+
if (existingIndex === void 0) {
|
|
440
|
+
groupIndexes.set(key, groups.length);
|
|
441
|
+
groups.push({
|
|
442
|
+
groupKey: key,
|
|
443
|
+
...groupLabel === void 0 ? {} : { groupLabel },
|
|
444
|
+
items: [option]
|
|
445
|
+
});
|
|
446
|
+
continue;
|
|
447
|
+
}
|
|
448
|
+
const existing = groups[existingIndex];
|
|
449
|
+
if (existing === void 0) continue;
|
|
450
|
+
groups[existingIndex] = { ...existing, items: [...existing.items, option] };
|
|
451
|
+
}
|
|
452
|
+
return groups;
|
|
453
|
+
}
|
|
420
454
|
function createMuiSelectAdapter(options) {
|
|
421
455
|
return function MuiSelect({
|
|
422
456
|
id,
|
|
@@ -440,13 +474,14 @@ function createMuiSelectAdapter(options) {
|
|
|
440
474
|
}) {
|
|
441
475
|
const resolved = useResolvedMuiAdapterOptions(options);
|
|
442
476
|
const normalizedOptions = normalizeOptions(selectOptions);
|
|
477
|
+
const groupedOptions = groupSelectOptions(normalizedOptions);
|
|
443
478
|
const selectSlotProps = resolved.muiSlotProps?.select;
|
|
444
479
|
const menuProps = { ...selectSlotProps?.MenuProps, ...resolved.muiSlotProps?.selectMenu };
|
|
445
480
|
const slotInputProps = selectSlotProps?.inputProps;
|
|
446
481
|
const labelId = id === void 0 || label === void 0 ? void 0 : `${id}-label`;
|
|
447
482
|
const helperId = id === void 0 ? void 0 : ariaDescribedBy?.split(/\s+/u)[0] ?? `${id}-helper-text`;
|
|
448
483
|
const describedBy = ariaDescribedBy ?? (helperText === void 0 || helperText.length === 0 ? void 0 : helperId);
|
|
449
|
-
const handleChange = (event) => onChange(
|
|
484
|
+
const handleChange = (event) => onChange(event.target.value);
|
|
450
485
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
451
486
|
import_material7.FormControl,
|
|
452
487
|
{
|
|
@@ -491,10 +526,22 @@ function createMuiSelectAdapter(options) {
|
|
|
491
526
|
...describedBy === void 0 ? {} : { "aria-describedby": describedBy },
|
|
492
527
|
...ariaLabelledBy === void 0 ? {} : { "aria-labelledby": ariaLabelledBy }
|
|
493
528
|
},
|
|
494
|
-
children:
|
|
495
|
-
|
|
496
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
497
|
-
|
|
529
|
+
children: groupedOptions.flatMap((group) => [
|
|
530
|
+
group.groupLabel === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(SelectGroupHeader, { children: group.groupLabel }, `header-${group.groupKey ?? group.groupLabel}`),
|
|
531
|
+
...group.items.map((option) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
532
|
+
import_material7.MenuItem,
|
|
533
|
+
{
|
|
534
|
+
value: option.value,
|
|
535
|
+
disabled: option.disabled,
|
|
536
|
+
...option.group === void 0 && option.groupLabel === void 0 && option.kind === void 0 ? {} : { "aria-label": option.label },
|
|
537
|
+
children: renderOption === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
|
|
538
|
+
option.icon === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_material7.ListItemIcon, { sx: { minWidth: 32 }, children: option.icon }),
|
|
539
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_material7.ListItemText, { primary: option.label, secondary: option.description })
|
|
540
|
+
] }) : renderOption(option)
|
|
541
|
+
},
|
|
542
|
+
option.value
|
|
543
|
+
))
|
|
544
|
+
])
|
|
498
545
|
}
|
|
499
546
|
),
|
|
500
547
|
helperText === void 0 || helperText.length === 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_material7.FormHelperText, { id: helperId, children: helperText })
|
|
@@ -503,7 +550,10 @@ function createMuiSelectAdapter(options) {
|
|
|
503
550
|
);
|
|
504
551
|
};
|
|
505
552
|
}
|
|
506
|
-
|
|
553
|
+
function MuiSelectAdapter(props) {
|
|
554
|
+
const Adapter = createMuiSelectAdapter();
|
|
555
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Adapter, { ...props });
|
|
556
|
+
}
|
|
507
557
|
|
|
508
558
|
// src/adapters/TextArea.tsx
|
|
509
559
|
var import_material8 = require("@mui/material");
|
|
@@ -923,6 +973,24 @@ function createMuiFieldEditorSlot(options) {
|
|
|
923
973
|
const titleErrorId = field.title.trim().length === 0 ? `mui-field-${field.id}-title-error` : void 0;
|
|
924
974
|
const FieldTypeSelect = slots?.fieldTypeSelect;
|
|
925
975
|
const FieldEditorHeader = slots?.fieldEditorHeader;
|
|
976
|
+
const fieldTypeSelectId = `mui-field-${field.id}-type`;
|
|
977
|
+
const fieldTypeSelectLabel = translate("builder.type");
|
|
978
|
+
const fieldTypeOptions = FIELD_TYPES.filter(
|
|
979
|
+
(type) => allowedTypes.includes(type)
|
|
980
|
+
).map((type) => {
|
|
981
|
+
const definition = import_core.DEFAULT_FIELD_TYPE_DEFINITIONS.find((candidate) => candidate.type === type);
|
|
982
|
+
const group = definition?.category;
|
|
983
|
+
return {
|
|
984
|
+
value: type,
|
|
985
|
+
label: translate(definition?.labelKey ?? `builder.fieldType.${type}`),
|
|
986
|
+
description: translate(`builder.fieldTypeDescription.${type}`),
|
|
987
|
+
icon: components.renderFieldTypeIcon(type),
|
|
988
|
+
...group === void 0 ? {} : {
|
|
989
|
+
group,
|
|
990
|
+
groupLabel: translate(`builder.fieldCategory.${group}`)
|
|
991
|
+
}
|
|
992
|
+
};
|
|
993
|
+
});
|
|
926
994
|
const changeFieldType = (nextType) => {
|
|
927
995
|
if (allowedTypes.includes(nextType)) actions.changeFieldType(field.id, nextType);
|
|
928
996
|
};
|
|
@@ -975,19 +1043,11 @@ function createMuiFieldEditorSlot(options) {
|
|
|
975
1043
|
FieldTypeSelect === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
976
1044
|
Select2,
|
|
977
1045
|
{
|
|
978
|
-
id:
|
|
1046
|
+
id: fieldTypeSelectId,
|
|
979
1047
|
name: `fields.${field.id}.type`,
|
|
980
|
-
label:
|
|
1048
|
+
label: fieldTypeSelectLabel,
|
|
981
1049
|
value: allowedTypes.includes(field.type) ? field.type : "",
|
|
982
|
-
options:
|
|
983
|
-
const definition = import_core.DEFAULT_FIELD_TYPE_DEFINITIONS.find((candidate) => candidate.type === type);
|
|
984
|
-
return {
|
|
985
|
-
value: type,
|
|
986
|
-
label: translate(definition?.labelKey ?? `builder.fieldType.${type}`),
|
|
987
|
-
icon: components.renderFieldTypeIcon(type),
|
|
988
|
-
...definition?.category === void 0 ? {} : { kind: definition.category }
|
|
989
|
-
};
|
|
990
|
-
}),
|
|
1050
|
+
options: fieldTypeOptions,
|
|
991
1051
|
disabled: readOnly,
|
|
992
1052
|
onChange: (value) => {
|
|
993
1053
|
if (isFieldType(value)) changeFieldType(value);
|
|
@@ -996,11 +1056,16 @@ function createMuiFieldEditorSlot(options) {
|
|
|
996
1056
|
) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
997
1057
|
FieldTypeSelect,
|
|
998
1058
|
{
|
|
1059
|
+
id: fieldTypeSelectId,
|
|
1060
|
+
name: `fields.${field.id}.type`,
|
|
1061
|
+
label: fieldTypeSelectLabel,
|
|
999
1062
|
currentType: field.type,
|
|
1000
1063
|
allowedTypes,
|
|
1064
|
+
options: fieldTypeOptions,
|
|
1001
1065
|
onChangeType: changeFieldType,
|
|
1002
1066
|
disabled: readOnly,
|
|
1003
1067
|
readOnly,
|
|
1068
|
+
"aria-labelledby": `${fieldTypeSelectId}-label`,
|
|
1004
1069
|
renderIcon: components.renderFieldTypeIcon
|
|
1005
1070
|
}
|
|
1006
1071
|
)
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BuilderActionIconType, LocalizationSummaryContext, BuilderButtonProps, BuilderCheckboxProps, BuilderErrorMessageProps, BuilderFieldsetProps, BuilderIconButtonProps, BuilderSectionProps, BuilderSelectProps, BuilderTextAreaProps, BuilderTextInputProps, FormBuilderComponents, FormBuilderSlots, FormBuilderProps, QuestionType, BuilderFieldEditorSlotProps, BuilderLocalizationSlotProps, BuilderOptionEditorSlotProps, BuilderToolbarSlotProps } from '@form-engine-ts/react';
|
|
2
2
|
import * as react from 'react';
|
|
3
|
-
import { ReactNode, ComponentType } from 'react';
|
|
3
|
+
import { ReactNode, ComponentType, ReactElement } from 'react';
|
|
4
4
|
import { CardProps, PaperProps, AccordionProps, StackProps, TextFieldProps, SelectProps, MenuProps, CheckboxProps, ButtonProps, IconButtonProps } from '@mui/material';
|
|
5
5
|
|
|
6
6
|
type BuilderSectionName = "basicSettings" | "completionMessage" | "questions" | "addQuestion" | "localization";
|
|
@@ -117,8 +117,8 @@ declare const MuiIconButtonAdapter: ComponentType<BuilderIconButtonProps>;
|
|
|
117
117
|
declare function createMuiSectionAdapter(options?: MuiAdapterOptions): ComponentType<BuilderSectionProps>;
|
|
118
118
|
declare const MuiSectionAdapter: ComponentType<BuilderSectionProps>;
|
|
119
119
|
|
|
120
|
-
declare function createMuiSelectAdapter(options?: MuiAdapterOptions): ComponentType<BuilderSelectProps
|
|
121
|
-
declare
|
|
120
|
+
declare function createMuiSelectAdapter<T extends string = string>(options?: MuiAdapterOptions): ComponentType<BuilderSelectProps<T>>;
|
|
121
|
+
declare function MuiSelectAdapter<T extends string = string>(props: BuilderSelectProps<T>): ReactElement;
|
|
122
122
|
|
|
123
123
|
declare function createMuiTextAreaAdapter(options?: MuiAdapterOptions): ComponentType<BuilderTextAreaProps>;
|
|
124
124
|
declare const MuiTextAreaAdapter: ComponentType<BuilderTextAreaProps>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BuilderActionIconType, LocalizationSummaryContext, BuilderButtonProps, BuilderCheckboxProps, BuilderErrorMessageProps, BuilderFieldsetProps, BuilderIconButtonProps, BuilderSectionProps, BuilderSelectProps, BuilderTextAreaProps, BuilderTextInputProps, FormBuilderComponents, FormBuilderSlots, FormBuilderProps, QuestionType, BuilderFieldEditorSlotProps, BuilderLocalizationSlotProps, BuilderOptionEditorSlotProps, BuilderToolbarSlotProps } from '@form-engine-ts/react';
|
|
2
2
|
import * as react from 'react';
|
|
3
|
-
import { ReactNode, ComponentType } from 'react';
|
|
3
|
+
import { ReactNode, ComponentType, ReactElement } from 'react';
|
|
4
4
|
import { CardProps, PaperProps, AccordionProps, StackProps, TextFieldProps, SelectProps, MenuProps, CheckboxProps, ButtonProps, IconButtonProps } from '@mui/material';
|
|
5
5
|
|
|
6
6
|
type BuilderSectionName = "basicSettings" | "completionMessage" | "questions" | "addQuestion" | "localization";
|
|
@@ -117,8 +117,8 @@ declare const MuiIconButtonAdapter: ComponentType<BuilderIconButtonProps>;
|
|
|
117
117
|
declare function createMuiSectionAdapter(options?: MuiAdapterOptions): ComponentType<BuilderSectionProps>;
|
|
118
118
|
declare const MuiSectionAdapter: ComponentType<BuilderSectionProps>;
|
|
119
119
|
|
|
120
|
-
declare function createMuiSelectAdapter(options?: MuiAdapterOptions): ComponentType<BuilderSelectProps
|
|
121
|
-
declare
|
|
120
|
+
declare function createMuiSelectAdapter<T extends string = string>(options?: MuiAdapterOptions): ComponentType<BuilderSelectProps<T>>;
|
|
121
|
+
declare function MuiSelectAdapter<T extends string = string>(props: BuilderSelectProps<T>): ReactElement;
|
|
122
122
|
|
|
123
123
|
declare function createMuiTextAreaAdapter(options?: MuiAdapterOptions): ComponentType<BuilderTextAreaProps>;
|
|
124
124
|
declare const MuiTextAreaAdapter: ComponentType<BuilderTextAreaProps>;
|
package/dist/index.js
CHANGED
|
@@ -354,6 +354,7 @@ import {
|
|
|
354
354
|
InputLabel,
|
|
355
355
|
ListItemIcon,
|
|
356
356
|
ListItemText,
|
|
357
|
+
ListSubheader,
|
|
357
358
|
MenuItem,
|
|
358
359
|
Select
|
|
359
360
|
} from "@mui/material";
|
|
@@ -361,6 +362,40 @@ import { Fragment, jsx as jsx7, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
|
361
362
|
function normalizeOptions(options) {
|
|
362
363
|
return options.map((option) => typeof option === "string" ? { value: option, label: option } : option);
|
|
363
364
|
}
|
|
365
|
+
function SelectGroupHeader({ children }) {
|
|
366
|
+
return /* @__PURE__ */ jsx7(ListSubheader, { role: "presentation", children });
|
|
367
|
+
}
|
|
368
|
+
function groupSelectOptions(options) {
|
|
369
|
+
const groups = [];
|
|
370
|
+
const groupIndexes = /* @__PURE__ */ new Map();
|
|
371
|
+
for (const option of options) {
|
|
372
|
+
const groupKey = option.group ?? option.kind;
|
|
373
|
+
const groupLabel = option.groupLabel ?? groupKey;
|
|
374
|
+
if (groupKey === void 0 && groupLabel === void 0) {
|
|
375
|
+
groups.push({ items: [option] });
|
|
376
|
+
continue;
|
|
377
|
+
}
|
|
378
|
+
const key = groupKey ?? groupLabel;
|
|
379
|
+
if (key === void 0) {
|
|
380
|
+
groups.push({ items: [option] });
|
|
381
|
+
continue;
|
|
382
|
+
}
|
|
383
|
+
const existingIndex = groupIndexes.get(key);
|
|
384
|
+
if (existingIndex === void 0) {
|
|
385
|
+
groupIndexes.set(key, groups.length);
|
|
386
|
+
groups.push({
|
|
387
|
+
groupKey: key,
|
|
388
|
+
...groupLabel === void 0 ? {} : { groupLabel },
|
|
389
|
+
items: [option]
|
|
390
|
+
});
|
|
391
|
+
continue;
|
|
392
|
+
}
|
|
393
|
+
const existing = groups[existingIndex];
|
|
394
|
+
if (existing === void 0) continue;
|
|
395
|
+
groups[existingIndex] = { ...existing, items: [...existing.items, option] };
|
|
396
|
+
}
|
|
397
|
+
return groups;
|
|
398
|
+
}
|
|
364
399
|
function createMuiSelectAdapter(options) {
|
|
365
400
|
return function MuiSelect({
|
|
366
401
|
id,
|
|
@@ -384,13 +419,14 @@ function createMuiSelectAdapter(options) {
|
|
|
384
419
|
}) {
|
|
385
420
|
const resolved = useResolvedMuiAdapterOptions(options);
|
|
386
421
|
const normalizedOptions = normalizeOptions(selectOptions);
|
|
422
|
+
const groupedOptions = groupSelectOptions(normalizedOptions);
|
|
387
423
|
const selectSlotProps = resolved.muiSlotProps?.select;
|
|
388
424
|
const menuProps = { ...selectSlotProps?.MenuProps, ...resolved.muiSlotProps?.selectMenu };
|
|
389
425
|
const slotInputProps = selectSlotProps?.inputProps;
|
|
390
426
|
const labelId = id === void 0 || label === void 0 ? void 0 : `${id}-label`;
|
|
391
427
|
const helperId = id === void 0 ? void 0 : ariaDescribedBy?.split(/\s+/u)[0] ?? `${id}-helper-text`;
|
|
392
428
|
const describedBy = ariaDescribedBy ?? (helperText === void 0 || helperText.length === 0 ? void 0 : helperId);
|
|
393
|
-
const handleChange = (event) => onChange(
|
|
429
|
+
const handleChange = (event) => onChange(event.target.value);
|
|
394
430
|
return /* @__PURE__ */ jsxs4(
|
|
395
431
|
FormControl2,
|
|
396
432
|
{
|
|
@@ -435,10 +471,22 @@ function createMuiSelectAdapter(options) {
|
|
|
435
471
|
...describedBy === void 0 ? {} : { "aria-describedby": describedBy },
|
|
436
472
|
...ariaLabelledBy === void 0 ? {} : { "aria-labelledby": ariaLabelledBy }
|
|
437
473
|
},
|
|
438
|
-
children:
|
|
439
|
-
|
|
440
|
-
/* @__PURE__ */ jsx7(
|
|
441
|
-
|
|
474
|
+
children: groupedOptions.flatMap((group) => [
|
|
475
|
+
group.groupLabel === void 0 ? null : /* @__PURE__ */ jsx7(SelectGroupHeader, { children: group.groupLabel }, `header-${group.groupKey ?? group.groupLabel}`),
|
|
476
|
+
...group.items.map((option) => /* @__PURE__ */ jsx7(
|
|
477
|
+
MenuItem,
|
|
478
|
+
{
|
|
479
|
+
value: option.value,
|
|
480
|
+
disabled: option.disabled,
|
|
481
|
+
...option.group === void 0 && option.groupLabel === void 0 && option.kind === void 0 ? {} : { "aria-label": option.label },
|
|
482
|
+
children: renderOption === void 0 ? /* @__PURE__ */ jsxs4(Fragment, { children: [
|
|
483
|
+
option.icon === void 0 ? null : /* @__PURE__ */ jsx7(ListItemIcon, { sx: { minWidth: 32 }, children: option.icon }),
|
|
484
|
+
/* @__PURE__ */ jsx7(ListItemText, { primary: option.label, secondary: option.description })
|
|
485
|
+
] }) : renderOption(option)
|
|
486
|
+
},
|
|
487
|
+
option.value
|
|
488
|
+
))
|
|
489
|
+
])
|
|
442
490
|
}
|
|
443
491
|
),
|
|
444
492
|
helperText === void 0 || helperText.length === 0 ? null : /* @__PURE__ */ jsx7(FormHelperText2, { id: helperId, children: helperText })
|
|
@@ -447,7 +495,10 @@ function createMuiSelectAdapter(options) {
|
|
|
447
495
|
);
|
|
448
496
|
};
|
|
449
497
|
}
|
|
450
|
-
|
|
498
|
+
function MuiSelectAdapter(props) {
|
|
499
|
+
const Adapter = createMuiSelectAdapter();
|
|
500
|
+
return /* @__PURE__ */ jsx7(Adapter, { ...props });
|
|
501
|
+
}
|
|
451
502
|
|
|
452
503
|
// src/adapters/TextArea.tsx
|
|
453
504
|
import { TextField } from "@mui/material";
|
|
@@ -884,6 +935,24 @@ function createMuiFieldEditorSlot(options) {
|
|
|
884
935
|
const titleErrorId = field.title.trim().length === 0 ? `mui-field-${field.id}-title-error` : void 0;
|
|
885
936
|
const FieldTypeSelect = slots?.fieldTypeSelect;
|
|
886
937
|
const FieldEditorHeader = slots?.fieldEditorHeader;
|
|
938
|
+
const fieldTypeSelectId = `mui-field-${field.id}-type`;
|
|
939
|
+
const fieldTypeSelectLabel = translate("builder.type");
|
|
940
|
+
const fieldTypeOptions = FIELD_TYPES.filter(
|
|
941
|
+
(type) => allowedTypes.includes(type)
|
|
942
|
+
).map((type) => {
|
|
943
|
+
const definition = DEFAULT_FIELD_TYPE_DEFINITIONS.find((candidate) => candidate.type === type);
|
|
944
|
+
const group = definition?.category;
|
|
945
|
+
return {
|
|
946
|
+
value: type,
|
|
947
|
+
label: translate(definition?.labelKey ?? `builder.fieldType.${type}`),
|
|
948
|
+
description: translate(`builder.fieldTypeDescription.${type}`),
|
|
949
|
+
icon: components.renderFieldTypeIcon(type),
|
|
950
|
+
...group === void 0 ? {} : {
|
|
951
|
+
group,
|
|
952
|
+
groupLabel: translate(`builder.fieldCategory.${group}`)
|
|
953
|
+
}
|
|
954
|
+
};
|
|
955
|
+
});
|
|
887
956
|
const changeFieldType = (nextType) => {
|
|
888
957
|
if (allowedTypes.includes(nextType)) actions.changeFieldType(field.id, nextType);
|
|
889
958
|
};
|
|
@@ -936,19 +1005,11 @@ function createMuiFieldEditorSlot(options) {
|
|
|
936
1005
|
FieldTypeSelect === void 0 ? /* @__PURE__ */ jsx13(
|
|
937
1006
|
Select2,
|
|
938
1007
|
{
|
|
939
|
-
id:
|
|
1008
|
+
id: fieldTypeSelectId,
|
|
940
1009
|
name: `fields.${field.id}.type`,
|
|
941
|
-
label:
|
|
1010
|
+
label: fieldTypeSelectLabel,
|
|
942
1011
|
value: allowedTypes.includes(field.type) ? field.type : "",
|
|
943
|
-
options:
|
|
944
|
-
const definition = DEFAULT_FIELD_TYPE_DEFINITIONS.find((candidate) => candidate.type === type);
|
|
945
|
-
return {
|
|
946
|
-
value: type,
|
|
947
|
-
label: translate(definition?.labelKey ?? `builder.fieldType.${type}`),
|
|
948
|
-
icon: components.renderFieldTypeIcon(type),
|
|
949
|
-
...definition?.category === void 0 ? {} : { kind: definition.category }
|
|
950
|
-
};
|
|
951
|
-
}),
|
|
1012
|
+
options: fieldTypeOptions,
|
|
952
1013
|
disabled: readOnly,
|
|
953
1014
|
onChange: (value) => {
|
|
954
1015
|
if (isFieldType(value)) changeFieldType(value);
|
|
@@ -957,11 +1018,16 @@ function createMuiFieldEditorSlot(options) {
|
|
|
957
1018
|
) : /* @__PURE__ */ jsx13(
|
|
958
1019
|
FieldTypeSelect,
|
|
959
1020
|
{
|
|
1021
|
+
id: fieldTypeSelectId,
|
|
1022
|
+
name: `fields.${field.id}.type`,
|
|
1023
|
+
label: fieldTypeSelectLabel,
|
|
960
1024
|
currentType: field.type,
|
|
961
1025
|
allowedTypes,
|
|
1026
|
+
options: fieldTypeOptions,
|
|
962
1027
|
onChangeType: changeFieldType,
|
|
963
1028
|
disabled: readOnly,
|
|
964
1029
|
readOnly,
|
|
1030
|
+
"aria-labelledby": `${fieldTypeSelectId}-label`,
|
|
965
1031
|
renderIcon: components.renderFieldTypeIcon
|
|
966
1032
|
}
|
|
967
1033
|
)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@form-engine-ts/mui",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
"@mui/material": "^6.0.0 || ^7.0.0",
|
|
47
47
|
"react": "^18.0.0 || ^19.0.0",
|
|
48
48
|
"react-dom": "^18.0.0 || ^19.0.0",
|
|
49
|
-
"@form-engine-ts/core": "
|
|
50
|
-
"@form-engine-ts/react": "
|
|
49
|
+
"@form-engine-ts/core": "4.0.0",
|
|
50
|
+
"@form-engine-ts/react": "4.0.0"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@emotion/react": "^11.14.0",
|
|
@@ -58,8 +58,8 @@
|
|
|
58
58
|
"@types/react-dom": "^19.2.4",
|
|
59
59
|
"react": "^19.2.8",
|
|
60
60
|
"react-dom": "^19.2.8",
|
|
61
|
-
"@form-engine-ts/
|
|
62
|
-
"@form-engine-ts/
|
|
61
|
+
"@form-engine-ts/react": "4.0.0",
|
|
62
|
+
"@form-engine-ts/core": "4.0.0"
|
|
63
63
|
},
|
|
64
64
|
"scripts": {
|
|
65
65
|
"build": "tsup src/index.ts --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",
|