@aatulwork/customform-renderer 1.10.0 → 1.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/fields.js +52 -36
- package/dist/fields.js.map +1 -1
- package/dist/fields.mjs +54 -38
- package/dist/fields.mjs.map +1 -1
- package/dist/index.js +54 -38
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +56 -40
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { useState, useMemo, useEffect, useRef, useCallback } from 'react';
|
|
1
|
+
import { useState, useId, useMemo, useEffect, useRef, useCallback } from 'react';
|
|
2
2
|
import { Controller, useWatch, useForm } from 'react-hook-form';
|
|
3
|
-
import { FormControl, FormLabel, TextField as TextField$1,
|
|
3
|
+
import { FormControl, FormLabel, TextField as TextField$1, Select, ListSubheader, MenuItem, Box, Chip, CircularProgress, InputAdornment, IconButton, OutlinedInput, FormHelperText, FormControlLabel, Checkbox, RadioGroup, Radio, Typography, Switch, useTheme, alpha, useMediaQuery, Tooltip, Accordion, AccordionSummary, AccordionDetails, Alert, Stepper, Step, StepLabel, Button, Stack } from '@mui/material';
|
|
4
4
|
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
|
|
5
5
|
import DoubleArrowOutlinedIcon from '@mui/icons-material/DoubleArrowOutlined';
|
|
6
6
|
import ArrowForwardIcon from '@mui/icons-material/ArrowForward';
|
|
@@ -279,12 +279,9 @@ var SimpleSelect = ({
|
|
|
279
279
|
onRefresh
|
|
280
280
|
}) => {
|
|
281
281
|
const [filterText, setFilterText] = useState("");
|
|
282
|
+
const selectId = useId();
|
|
282
283
|
const handleChange = (event) => {
|
|
283
284
|
const val = event.target.value;
|
|
284
|
-
if (val === "__refresh__") {
|
|
285
|
-
onRefresh?.();
|
|
286
|
-
return;
|
|
287
|
-
}
|
|
288
285
|
onChange(val);
|
|
289
286
|
};
|
|
290
287
|
const filteredOptions = filterable && filterText ? options.filter(
|
|
@@ -297,14 +294,25 @@ var SimpleSelect = ({
|
|
|
297
294
|
setFilterText("");
|
|
298
295
|
};
|
|
299
296
|
return /* @__PURE__ */ jsxs(FormControl, { fullWidth, size, required, error, disabled, children: [
|
|
300
|
-
/* @__PURE__ */ jsx(
|
|
297
|
+
/* @__PURE__ */ jsx(
|
|
298
|
+
FormLabel,
|
|
299
|
+
{
|
|
300
|
+
component: "label",
|
|
301
|
+
htmlFor: selectId,
|
|
302
|
+
required,
|
|
303
|
+
error,
|
|
304
|
+
sx: { mb: 0.5, display: "block" },
|
|
305
|
+
children: label
|
|
306
|
+
}
|
|
307
|
+
),
|
|
301
308
|
/* @__PURE__ */ jsxs(
|
|
302
309
|
Select,
|
|
303
310
|
{
|
|
311
|
+
id: selectId,
|
|
304
312
|
value: value ?? (multiple ? [] : ""),
|
|
305
313
|
onChange: handleChange,
|
|
306
314
|
onClose: handleClose,
|
|
307
|
-
input: /* @__PURE__ */ jsx(OutlinedInput, {
|
|
315
|
+
input: /* @__PURE__ */ jsx(OutlinedInput, {}),
|
|
308
316
|
MenuProps: {
|
|
309
317
|
autoFocus: false
|
|
310
318
|
},
|
|
@@ -506,40 +514,48 @@ var ColorField = ({ field, control, defaultValue, rules, errors }) => {
|
|
|
506
514
|
control,
|
|
507
515
|
defaultValue,
|
|
508
516
|
rules,
|
|
509
|
-
render: ({ field: formField }) =>
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
{
|
|
513
|
-
required: field.required,
|
|
514
|
-
error: !!errors[field.name],
|
|
515
|
-
children: field.label
|
|
516
|
-
}
|
|
517
|
-
),
|
|
518
|
-
/* @__PURE__ */ jsxs(Box, { sx: { display: "flex", flexDirection: "column", flex: 1, maxWidth: 200 }, children: [
|
|
517
|
+
render: ({ field: formField }) => {
|
|
518
|
+
const inputId = `color-field-${field.name}`;
|
|
519
|
+
return /* @__PURE__ */ jsxs(Box, { sx: { display: "flex", alignItems: "center", gap: 2, width: "100%" }, children: [
|
|
519
520
|
/* @__PURE__ */ jsx(
|
|
520
|
-
|
|
521
|
+
FormLabel,
|
|
521
522
|
{
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
cursor: "pointer",
|
|
528
|
-
border: errors[field.name] ? "1px solid red" : "1px solid rgba(0, 0, 0, 0.23)",
|
|
529
|
-
borderRadius: "4px",
|
|
530
|
-
padding: "1px"
|
|
531
|
-
},
|
|
532
|
-
inputProps: {
|
|
533
|
-
style: {
|
|
534
|
-
height: "100%",
|
|
535
|
-
cursor: "pointer"
|
|
536
|
-
}
|
|
537
|
-
}
|
|
523
|
+
component: "label",
|
|
524
|
+
htmlFor: inputId,
|
|
525
|
+
required: field.required,
|
|
526
|
+
error: !!errors[field.name],
|
|
527
|
+
children: field.label
|
|
538
528
|
}
|
|
539
529
|
),
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
530
|
+
/* @__PURE__ */ jsxs(Box, { sx: { display: "flex", flexDirection: "column", flex: 1, maxWidth: 200 }, children: [
|
|
531
|
+
/* @__PURE__ */ jsx(
|
|
532
|
+
Box,
|
|
533
|
+
{
|
|
534
|
+
component: "input",
|
|
535
|
+
type: "color",
|
|
536
|
+
id: inputId,
|
|
537
|
+
ref: formField.ref,
|
|
538
|
+
name: formField.name,
|
|
539
|
+
value: formField.value ?? "#000000",
|
|
540
|
+
onChange: formField.onChange,
|
|
541
|
+
onBlur: formField.onBlur,
|
|
542
|
+
sx: {
|
|
543
|
+
width: 30,
|
|
544
|
+
height: 30,
|
|
545
|
+
padding: 0,
|
|
546
|
+
cursor: "pointer",
|
|
547
|
+
backgroundColor: "transparent",
|
|
548
|
+
border: "none",
|
|
549
|
+
"&::-webkit-color-swatch-wrapper": { padding: 0 },
|
|
550
|
+
"&::-webkit-color-swatch": { border: "none", borderRadius: "4px" },
|
|
551
|
+
"&::-moz-color-swatch": { border: "none", borderRadius: "4px" }
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
),
|
|
555
|
+
errors[field.name] && /* @__PURE__ */ jsx(Typography, { variant: "caption", color: "error", sx: { mt: 0.5 }, children: errors[field.name]?.message })
|
|
556
|
+
] })
|
|
557
|
+
] });
|
|
558
|
+
}
|
|
543
559
|
},
|
|
544
560
|
field.name
|
|
545
561
|
);
|
|
@@ -1757,7 +1773,7 @@ var FormRenderer = ({
|
|
|
1757
1773
|
);
|
|
1758
1774
|
if (sectionDisplayMode === "stepper") {
|
|
1759
1775
|
return /* @__PURE__ */ jsxs(Box, { sx: { border: "1px solid", borderColor: formColors.divider, p: 5, backgroundColor: formColors.backgroundPaper }, children: [
|
|
1760
|
-
/* @__PURE__ */ jsx(Stepper, { activeStep, orientation: "horizontal", children: formSchema.sections.map((section) => /* @__PURE__ */ jsx(Step, { children: /* @__PURE__ */ jsx(StepLabel, { children: /* @__PURE__ */ jsx(Typography, { variant: "subtitle1",
|
|
1776
|
+
/* @__PURE__ */ jsx(Stepper, { activeStep, orientation: "horizontal", children: formSchema.sections.map((section) => /* @__PURE__ */ jsx(Step, { children: /* @__PURE__ */ jsx(StepLabel, { children: /* @__PURE__ */ jsx(Typography, { variant: "subtitle1", children: section.title }) }) }, section.id)) }),
|
|
1761
1777
|
/* @__PURE__ */ jsx(Box, { sx: { mt: 5 }, children: formSchema.sections.map((section, sectionIndex) => {
|
|
1762
1778
|
const sectionsLength = formSchema.sections?.length || 0;
|
|
1763
1779
|
return /* @__PURE__ */ jsxs(
|
|
@@ -1813,7 +1829,7 @@ var FormRenderer = ({
|
|
|
1813
1829
|
id: `panel-${section.id}-header`,
|
|
1814
1830
|
children: /* @__PURE__ */ jsxs(Box, { sx: { display: "flex", alignItems: "center", gap: 1 }, children: [
|
|
1815
1831
|
/* @__PURE__ */ jsx(DoubleArrowOutlinedIcon, { fontSize: "small", sx: { color: formColors.primary } }),
|
|
1816
|
-
/* @__PURE__ */ jsx(Typography, { variant: "subtitle1", sx: {
|
|
1832
|
+
/* @__PURE__ */ jsx(Typography, { variant: "subtitle1", sx: { color: formColors.primary }, children: section.title })
|
|
1817
1833
|
] })
|
|
1818
1834
|
}
|
|
1819
1835
|
),
|