@aatulwork/customform-renderer 1.10.0 → 1.11.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.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Controller, useWatch } from 'react-hook-form';
2
- import { FormControl, FormLabel, TextField as TextField$1, FormControlLabel, Checkbox, RadioGroup, Radio, Box, Typography, Switch, Input, useTheme, FormHelperText, alpha, useMediaQuery, CircularProgress, Tooltip, IconButton, InputLabel, Select, ListSubheader, MenuItem, Chip, InputAdornment, OutlinedInput } from '@mui/material';
2
+ import { FormControl, FormLabel, TextField as TextField$1, FormControlLabel, Checkbox, RadioGroup, Radio, Box, Typography, Switch, useTheme, FormHelperText, alpha, useMediaQuery, CircularProgress, Tooltip, IconButton, Select, ListSubheader, MenuItem, Chip, InputAdornment, OutlinedInput } from '@mui/material';
3
3
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
4
4
  import { useMemo, useRef, useEffect, useCallback, useState } from 'react';
5
5
  import RefreshIcon from '@mui/icons-material/Refresh';
@@ -156,10 +156,6 @@ var SimpleSelect = ({
156
156
  const [filterText, setFilterText] = useState("");
157
157
  const handleChange = (event) => {
158
158
  const val = event.target.value;
159
- if (val === "__refresh__") {
160
- onRefresh?.();
161
- return;
162
- }
163
159
  onChange(val);
164
160
  };
165
161
  const filteredOptions = filterable && filterText ? options.filter(
@@ -172,14 +168,14 @@ var SimpleSelect = ({
172
168
  setFilterText("");
173
169
  };
174
170
  return /* @__PURE__ */ jsxs(FormControl, { fullWidth, size, required, error, disabled, children: [
175
- /* @__PURE__ */ jsx(InputLabel, { children: label }),
171
+ /* @__PURE__ */ jsx(FormLabel, { required, error, sx: { mb: 0.5, display: "block" }, children: label }),
176
172
  /* @__PURE__ */ jsxs(
177
173
  Select,
178
174
  {
179
175
  value: value ?? (multiple ? [] : ""),
180
176
  onChange: handleChange,
181
177
  onClose: handleClose,
182
- input: /* @__PURE__ */ jsx(OutlinedInput, { label }),
178
+ input: /* @__PURE__ */ jsx(OutlinedInput, {}),
183
179
  MenuProps: {
184
180
  autoFocus: false
185
181
  },
@@ -381,40 +377,47 @@ var ColorField = ({ field, control, defaultValue, rules, errors }) => {
381
377
  control,
382
378
  defaultValue,
383
379
  rules,
384
- render: ({ field: formField }) => /* @__PURE__ */ jsxs(Box, { sx: { display: "flex", alignItems: "center", gap: 2, width: "100%" }, children: [
385
- /* @__PURE__ */ jsx(
386
- FormLabel,
387
- {
388
- required: field.required,
389
- error: !!errors[field.name],
390
- children: field.label
391
- }
392
- ),
393
- /* @__PURE__ */ jsxs(Box, { sx: { display: "flex", flexDirection: "column", flex: 1, maxWidth: 200 }, children: [
380
+ render: ({ field: formField }) => {
381
+ const inputId = `color-field-${field.name}`;
382
+ return /* @__PURE__ */ jsxs(Box, { sx: { display: "flex", alignItems: "center", gap: 2, width: "100%" }, children: [
394
383
  /* @__PURE__ */ jsx(
395
- Input,
384
+ FormLabel,
396
385
  {
397
- ...formField,
398
- type: "color",
399
- sx: {
400
- width: "20%",
401
- height: "40px",
402
- cursor: "pointer",
403
- border: errors[field.name] ? "1px solid red" : "1px solid rgba(0, 0, 0, 0.23)",
404
- borderRadius: "4px",
405
- padding: "1px"
406
- },
407
- inputProps: {
408
- style: {
409
- height: "100%",
410
- cursor: "pointer"
411
- }
412
- }
386
+ component: "label",
387
+ htmlFor: inputId,
388
+ required: field.required,
389
+ error: !!errors[field.name],
390
+ children: field.label
413
391
  }
414
392
  ),
415
- errors[field.name] && /* @__PURE__ */ jsx(Typography, { variant: "caption", color: "error", sx: { mt: 0.5 }, children: errors[field.name]?.message })
416
- ] })
417
- ] })
393
+ /* @__PURE__ */ jsxs(Box, { sx: { display: "flex", flexDirection: "column", flex: 1, maxWidth: 200 }, children: [
394
+ /* @__PURE__ */ jsx(
395
+ Box,
396
+ {
397
+ component: "input",
398
+ type: "color",
399
+ id: inputId,
400
+ ref: formField.ref,
401
+ name: formField.name,
402
+ value: formField.value ?? "#000000",
403
+ onChange: formField.onChange,
404
+ onBlur: formField.onBlur,
405
+ sx: {
406
+ width: 40,
407
+ height: 40,
408
+ padding: 0,
409
+ cursor: "pointer",
410
+ backgroundColor: "transparent",
411
+ "&::-webkit-color-swatch-wrapper": { padding: 0 },
412
+ "&::-webkit-color-swatch": { border: "none", borderRadius: "4px" },
413
+ "&::-moz-color-swatch": { border: "none", borderRadius: "4px" }
414
+ }
415
+ }
416
+ ),
417
+ errors[field.name] && /* @__PURE__ */ jsx(Typography, { variant: "caption", color: "error", sx: { mt: 0.5 }, children: errors[field.name]?.message })
418
+ ] })
419
+ ] });
420
+ }
418
421
  },
419
422
  field.name
420
423
  );