formik-form-components 0.2.27 → 0.2.29

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.mjs CHANGED
@@ -1,17 +1,16 @@
1
1
  import { useFormikContext, Formik, Form as Form$1, ErrorMessage } from 'formik';
2
- import { forwardRef, memo, createElement, useState, useMemo, useEffect } from 'react';
3
- import { Box, useTheme, FormControl, Typography, FormHelperText, TextField, InputLabel, FormLabel, RadioGroup, FormControlLabel, Radio, Stack, Rating, Autocomplete, MenuItem, Chip, Switch, InputAdornment, IconButton, Checkbox, Tooltip, Dialog, DialogTitle, DialogContent, DialogActions, Button, CircularProgress, Paper, Menu } from '@mui/material';
2
+ import React4, { forwardRef, createElement, memo, useState, useMemo, useEffect } from 'react';
3
+ import { Box, useTheme, FormControl, Typography, FormHelperText, TextField, Autocomplete, Checkbox, Chip, Select, MenuItem, FormLabel, RadioGroup, FormControlLabel, Radio, Stack, Rating, Switch, InputAdornment, IconButton, Tooltip, Dialog, DialogTitle, DialogContent, DialogActions, Button, CircularProgress, Paper, Menu } from '@mui/material';
4
4
  import { DatePicker } from '@mui/x-date-pickers/DatePicker';
5
5
  import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
6
6
  import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs';
7
7
  import CalendarMonthIcon from '@mui/icons-material/CalendarMonth';
8
- import _19, { get } from 'lodash';
8
+ import _17, { get } from 'lodash';
9
9
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
10
10
  import { DateTimePicker } from '@mui/x-date-pickers/DateTimePicker';
11
11
  import Autocomplete3 from '@mui/material/Autocomplete';
12
12
  import Typography9 from '@mui/material/Typography';
13
13
  import { Icon } from '@iconify/react';
14
- import Select from '@mui/material/Select';
15
14
  import PhoneInput from 'react-phone-number-input';
16
15
  import 'react-phone-number-input/style.css';
17
16
  import { useEditor, EditorContent } from '@tiptap/react';
@@ -50,9 +49,9 @@ var AppDatePicker = forwardRef(
50
49
  ...otherProps
51
50
  }, ref) => {
52
51
  const { values, setFieldValue, touched, errors, setFieldTouched } = useFormikContext();
53
- const fieldValue = _19.get(values, name);
54
- const fieldError = _19.get(errors, name);
55
- const isTouched = _19.get(touched, name);
52
+ const fieldValue = _17.get(values, name);
53
+ const fieldError = _17.get(errors, name);
54
+ const isTouched = _17.get(touched, name);
56
55
  const handleChange = (newValue) => {
57
56
  setFieldValue(name, newValue);
58
57
  };
@@ -286,8 +285,8 @@ function AppFormErrorMessage({
286
285
  textSx
287
286
  }) {
288
287
  const { errors, touched } = useFormikContext();
289
- const fieldError = _19.get(errors, name);
290
- const isTouched = _19.get(touched, name);
288
+ const fieldError = _17.get(errors, name);
289
+ const isTouched = _17.get(touched, name);
291
290
  const showError = fieldError && typeof fieldError === "string";
292
291
  if (alwaysShow) {
293
292
  return showError ? /* @__PURE__ */ jsx(
@@ -364,9 +363,9 @@ var AppTextArea = forwardRef(({
364
363
  }, ref) => {
365
364
  var _a, _b, _c, _d;
366
365
  const { errors, getFieldProps, touched, setFieldValue } = useFormikContext();
367
- const fieldError = _19.get(errors, name);
368
- const isTouched = _19.get(touched, name);
369
- const value = _19.get(getFieldProps(name), "value", "");
366
+ const fieldError = _17.get(errors, name);
367
+ const isTouched = _17.get(touched, name);
368
+ const value = _17.get(getFieldProps(name), "value", "");
370
369
  const handleChange = (e) => {
371
370
  const newValue = e.target.value;
372
371
  if (maxLength && newValue.length > maxLength)
@@ -520,9 +519,9 @@ function AppTagsCreator({
520
519
  inputSx
521
520
  }) {
522
521
  const { errors, touched, getFieldProps, values, setFieldValue, setTouched } = useFormikContext();
523
- const fieldError = _19.get(errors, name);
524
- const isTouched = _19.get(touched, name);
525
- const val = _19.get(values, name);
522
+ const fieldError = _17.get(errors, name);
523
+ const isTouched = _17.get(touched, name);
524
+ const val = _17.get(values, name);
526
525
  return /* @__PURE__ */ jsxs(
527
526
  FormControl,
528
527
  {
@@ -645,8 +644,8 @@ function AppSwitchInput({
645
644
  ...otherProps
646
645
  }) {
647
646
  const { errors, touched, setFieldValue, values } = useFormikContext();
648
- const fieldError = _19.get(errors, name);
649
- const isTouched = _19.get(touched, name);
647
+ const fieldError = _17.get(errors, name);
648
+ const isTouched = _17.get(touched, name);
650
649
  return /* @__PURE__ */ jsxs(
651
650
  Box,
652
651
  {
@@ -744,9 +743,9 @@ function AppSwitch({
744
743
  ...otherProps
745
744
  }) {
746
745
  const { errors, touched, setFieldValue, values } = useFormikContext();
747
- const fieldValue = _19.get(values, name);
748
- const fieldError = _19.get(errors, name);
749
- const isTouched = _19.get(touched, name);
746
+ const fieldValue = _17.get(values, name);
747
+ const fieldError = _17.get(errors, name);
748
+ const isTouched = _17.get(touched, name);
750
749
  return /* @__PURE__ */ jsxs(
751
750
  Stack,
752
751
  {
@@ -852,9 +851,9 @@ function AppAutoComplete({
852
851
  errorSx
853
852
  }) {
854
853
  const { errors, touched, getFieldProps, values, setFieldValue } = useFormikContext();
855
- const fieldError = _19.get(errors, name);
856
- const isTouched = _19.get(touched, name);
857
- const formikValue = _19.get(values, name);
854
+ const fieldError = _17.get(errors, name);
855
+ const isTouched = _17.get(touched, name);
856
+ const formikValue = _17.get(values, name);
858
857
  const val = propValue !== void 0 ? propValue : formikValue || [];
859
858
  return /* @__PURE__ */ jsxs(FormControl, { fullWidth: true, variant: "filled", sx: formControlSx, children: [
860
859
  /* @__PURE__ */ jsx(
@@ -926,9 +925,9 @@ function AppAutoCompleter({
926
925
  errorSx
927
926
  }) {
928
927
  const { errors, touched, values, setFieldValue } = useFormikContext();
929
- const fieldError = _19.get(errors, name);
930
- const isTouched = _19.get(touched, name);
931
- const value = _19.get(values, name);
928
+ const fieldError = _17.get(errors, name);
929
+ const isTouched = _17.get(touched, name);
930
+ const value = _17.get(values, name);
932
931
  const selectedOption = options.find((opt) => opt.value === value) || null;
933
932
  return /* @__PURE__ */ jsxs(FormControl, { fullWidth: true, variant: "filled", sx: formControlSx, children: [
934
933
  /* @__PURE__ */ jsx(
@@ -940,7 +939,7 @@ function AppAutoCompleter({
940
939
  getOptionLabel: (option) => (option == null ? void 0 : option.label) || "",
941
940
  isOptionEqualToValue: (option, value2) => option.value === value2.value,
942
941
  autoHighlight: true,
943
- onChange: (_20, newValue) => {
942
+ onChange: (_18, newValue) => {
944
943
  setFieldValue(name, newValue ? newValue.value : null);
945
944
  },
946
945
  renderOption: (props, option) => /* @__PURE__ */ createElement(Box, { component: "li", ...props, key: option.value, sx: listboxSx }, option.label),
@@ -991,8 +990,8 @@ var AppCheckBox = ({
991
990
  ...rest
992
991
  }) => {
993
992
  const { getFieldProps, setFieldValue, touched, errors } = useFormikContext();
994
- const fieldError = _19.get(errors, name);
995
- const isTouched = _19.get(touched, name);
993
+ const fieldError = _17.get(errors, name);
994
+ const isTouched = _17.get(touched, name);
996
995
  useTheme();
997
996
  const value = getFieldProps(name).value;
998
997
  const checkedValues = (() => {
@@ -1155,8 +1154,8 @@ function AppInputField({
1155
1154
  ...otherProps
1156
1155
  }) {
1157
1156
  const { errors, getFieldProps, touched } = useFormikContext();
1158
- const fieldError = _19.get(errors, name);
1159
- const isTouched = _19.get(touched, name);
1157
+ const fieldError = _17.get(errors, name);
1158
+ const isTouched = _17.get(touched, name);
1160
1159
  const [showPassword, setShowPassword] = useState(false);
1161
1160
  const handleShowPassword = () => {
1162
1161
  setShowPassword(!showPassword);
@@ -1217,280 +1216,321 @@ function AppInputField({
1217
1216
  }
1218
1217
  var AppMultiSelector = forwardRef(
1219
1218
  ({
1220
- multiple = true,
1221
1219
  name,
1222
1220
  label,
1221
+ mode = "autocomplete",
1223
1222
  options = [],
1224
1223
  required = false,
1225
- variant = "outlined",
1226
1224
  disabled = false,
1227
1225
  maxSelections,
1228
1226
  showSelectedCount = true,
1229
- showHelperText = false,
1230
1227
  helperText,
1228
+ variant = "outlined",
1229
+ placeholder = "Select options...",
1230
+ onSearchChange,
1231
+ onChange: externalOnChange,
1232
+ onMaxSelectionsReached,
1231
1233
  sx,
1232
1234
  formControlSx,
1233
- selectSx,
1234
1235
  labelSx,
1235
1236
  chipSx,
1236
1237
  checkboxSx,
1237
- menuItemSx,
1238
- errorSx,
1239
- helperTextSx,
1240
- iconSx,
1241
- onChange: externalOnChange,
1242
- onOpen,
1243
- onClose,
1244
- renderValue: externalRenderValue,
1245
- renderMenuItem,
1246
- ...otherProps
1238
+ searchDebounce = 300,
1239
+ clearable = true
1247
1240
  }, ref) => {
1248
1241
  const theme = useTheme();
1249
- const { errors, touched, values, setFieldValue, setFieldTouched } = useFormikContext();
1250
- const fieldError = _19.get(errors, name);
1251
- const isTouched = _19.get(touched, name);
1252
- const val = _19.get(values, name);
1253
- const selectedValues = Array.isArray(val) ? val : [];
1254
- const handleChange = (event, child) => {
1255
- const newValue = event.target.value;
1256
- if (maxSelections && newValue.length > maxSelections) {
1242
+ const { values, setFieldValue, errors, touched, setFieldTouched } = useFormikContext();
1243
+ const fieldError = _17.get(errors, name);
1244
+ const isTouched = Boolean(_17.get(touched, name));
1245
+ const hasError = Boolean(fieldError) && isTouched;
1246
+ const currentValue = _17.get(values, name);
1247
+ const selectedValues = Array.isArray(currentValue) ? currentValue : [];
1248
+ const selectedCount = selectedValues.length;
1249
+ const isMaxReached = maxSelections ? selectedCount >= maxSelections : false;
1250
+ const handleValueChange = (newValues) => {
1251
+ if (maxSelections && newValues.length > maxSelections) {
1252
+ if (onMaxSelectionsReached) {
1253
+ onMaxSelectionsReached(maxSelections);
1254
+ }
1257
1255
  return;
1258
1256
  }
1259
- setFieldValue(name, newValue, true);
1257
+ setFieldValue(name, newValues, true);
1260
1258
  if (externalOnChange) {
1261
- externalOnChange(event, child);
1259
+ externalOnChange(newValues);
1262
1260
  }
1263
1261
  };
1264
1262
  const handleBlur = () => {
1265
1263
  setFieldTouched(name, true, true);
1266
1264
  };
1267
- const defaultRenderValue = (selected) => /* @__PURE__ */ jsx(
1268
- Box,
1269
- {
1270
- sx: { display: "flex", flexWrap: "wrap", gap: 0.5, minHeight: "24px" },
1271
- children: selected.length === 0 ? /* @__PURE__ */ jsx(Typography, { variant: "body2", color: "text.secondary", children: "Select options..." }) : selected.map((value) => {
1272
- const option = options.find((obj) => obj.value === value);
1273
- return option ? /* @__PURE__ */ jsx(
1274
- Chip,
1275
- {
1276
- label: option.label,
1277
- size: "small",
1278
- sx: [
1279
- {
1280
- height: "24px",
1281
- borderRadius: "4px",
1282
- backgroundColor: "action.selected",
1283
- "& .MuiChip-label": {
1284
- px: 1
1285
- },
1286
- ...option.disabled && {
1287
- opacity: 0.6
1288
- }
1265
+ const getSelectedOptions = () => {
1266
+ return options.filter((opt) => selectedValues.includes(opt.value));
1267
+ };
1268
+ if (mode === "autocomplete") {
1269
+ const debouncedSearch = React4.useRef();
1270
+ const handleSearchChange = (query) => {
1271
+ if (debouncedSearch.current) {
1272
+ clearTimeout(debouncedSearch.current);
1273
+ }
1274
+ debouncedSearch.current = setTimeout(() => {
1275
+ if (onSearchChange) {
1276
+ onSearchChange(query);
1277
+ }
1278
+ }, searchDebounce);
1279
+ };
1280
+ const filterOptions = (options2, { inputValue }) => {
1281
+ if (!inputValue)
1282
+ return options2;
1283
+ const inputValueLower = inputValue.toLowerCase();
1284
+ return options2.filter(
1285
+ (option) => option.label.toLowerCase().includes(inputValueLower) || String(option.value).toLowerCase().includes(inputValueLower)
1286
+ );
1287
+ };
1288
+ const selectedOptions = getSelectedOptions();
1289
+ return /* @__PURE__ */ jsx(Box, { ref, sx, children: /* @__PURE__ */ jsxs(
1290
+ FormControl,
1291
+ {
1292
+ fullWidth: true,
1293
+ error: hasError,
1294
+ disabled,
1295
+ sx: formControlSx,
1296
+ children: [
1297
+ /* @__PURE__ */ jsx(
1298
+ Autocomplete,
1299
+ {
1300
+ multiple: true,
1301
+ options,
1302
+ value: selectedOptions,
1303
+ onChange: (event, newValues) => {
1304
+ const values2 = newValues.map((opt) => opt.value);
1305
+ handleValueChange(values2);
1289
1306
  },
1290
- chipSx
1291
- ]
1292
- },
1293
- value
1294
- ) : null;
1295
- })
1296
- }
1297
- );
1298
- const defaultRenderMenuItem = (option, isSelected) => /* @__PURE__ */ jsxs(
1299
- MenuItem,
1300
- {
1301
- value: option.value,
1302
- disabled: option.disabled,
1303
- sx: [
1304
- {
1305
- "&.Mui-selected": {
1306
- backgroundColor: "action.selected",
1307
- "&:hover": {
1308
- backgroundColor: "action.hover"
1309
- }
1310
- },
1311
- "&.Mui-disabled": {
1312
- opacity: 0.5
1313
- },
1314
- ...option.sx
1315
- },
1316
- menuItemSx
1317
- ],
1318
- children: [
1319
- /* @__PURE__ */ jsx(
1320
- Checkbox,
1321
- {
1322
- checked: isSelected,
1323
- disabled: option.disabled,
1324
- sx: [
1325
- {
1326
- color: "text.secondary",
1327
- "&.Mui-checked": {
1328
- color: "primary.main"
1329
- },
1330
- ...option.disabled && {
1331
- color: "action.disabled"
1307
+ onInputChange: (event, value, reason) => {
1308
+ if (reason === "input" && onSearchChange) {
1309
+ handleSearchChange(value);
1332
1310
  }
1333
1311
  },
1334
- checkboxSx
1335
- ]
1336
- }
1337
- ),
1338
- /* @__PURE__ */ jsx(
1339
- Typography,
1340
- {
1341
- variant: "body2",
1342
- sx: [
1343
- {
1344
- color: option.disabled ? "text.disabled" : "text.primary",
1345
- ...option.textSx
1346
- }
1347
- ],
1348
- children: option.label || String(option.value)
1349
- }
1350
- )
1351
- ]
1352
- },
1353
- option.value
1354
- );
1355
- const displayLabel = showSelectedCount && selectedValues.length > 0 ? `${label} (${selectedValues.length} selected)` : label;
1356
- return /* @__PURE__ */ jsx(Box, { sx, ref, children: /* @__PURE__ */ jsxs(
1357
- FormControl,
1358
- {
1359
- fullWidth: true,
1360
- variant,
1361
- error: isTouched && Boolean(fieldError),
1362
- disabled,
1363
- sx: [
1364
- {
1365
- "& .MuiInputLabel-root": {
1366
- "&.Mui-focused": {
1367
- color: "primary.main"
1368
- },
1369
- "&.Mui-error": {
1370
- color: "error.main"
1371
- },
1372
- "&.Mui-disabled": {
1373
- color: "text.disabled"
1374
- }
1375
- }
1376
- },
1377
- formControlSx
1378
- ],
1379
- children: [
1380
- label && /* @__PURE__ */ jsxs(
1381
- InputLabel,
1382
- {
1383
- id: `select-${name}`,
1384
- sx: [
1385
- {
1386
- color: "text.secondary",
1387
- "&.Mui-focused": {
1388
- color: "primary.main"
1389
- },
1390
- "&.Mui-disabled": {
1391
- color: "text.disabled"
1312
+ filterOptions,
1313
+ onBlur: handleBlur,
1314
+ disabled: disabled || isMaxReached,
1315
+ disableCloseOnSelect: true,
1316
+ clearOnBlur: false,
1317
+ clearOnEscape: true,
1318
+ disableClearable: !clearable,
1319
+ getOptionLabel: (option) => option.label,
1320
+ isOptionEqualToValue: (option, value) => option.value === value.value,
1321
+ getOptionDisabled: (option) => !!option.disabled,
1322
+ renderInput: (params) => /* @__PURE__ */ jsx(
1323
+ TextField,
1324
+ {
1325
+ ...params,
1326
+ label: /* @__PURE__ */ jsxs(Fragment, { children: [
1327
+ label,
1328
+ required && /* @__PURE__ */ jsx(
1329
+ Typography,
1330
+ {
1331
+ sx: { color: "error.main" },
1332
+ component: "span",
1333
+ children: " *"
1334
+ }
1335
+ )
1336
+ ] }),
1337
+ variant,
1338
+ placeholder,
1339
+ error: hasError,
1340
+ helperText: hasError ? fieldError : helperText,
1341
+ FormHelperTextProps: {
1342
+ sx: { mx: 0, mt: 0.5 }
1343
+ }
1392
1344
  }
1345
+ ),
1346
+ renderOption: (props, option, { selected }) => {
1347
+ const { key, ...restProps } = props;
1348
+ return /* @__PURE__ */ jsxs("li", { ...restProps, children: [
1349
+ /* @__PURE__ */ jsx(
1350
+ Checkbox,
1351
+ {
1352
+ checked: selected,
1353
+ disabled: option.disabled || isMaxReached && !selected,
1354
+ sx: checkboxSx
1355
+ }
1356
+ ),
1357
+ option.icon,
1358
+ /* @__PURE__ */ jsx(
1359
+ Typography,
1360
+ {
1361
+ variant: "body2",
1362
+ sx: {
1363
+ color: option.disabled ? "text.disabled" : "text.primary",
1364
+ ...option.textSx
1365
+ },
1366
+ children: option.label
1367
+ }
1368
+ )
1369
+ ] }, key);
1393
1370
  },
1394
- labelSx
1395
- ],
1396
- children: [
1397
- displayLabel,
1398
- required && /* @__PURE__ */ jsx(
1399
- Typography,
1371
+ renderTags: (value, getTagProps) => /* @__PURE__ */ jsx(
1372
+ Box,
1400
1373
  {
1401
- component: "span",
1402
- sx: {
1403
- color: "error.main",
1404
- ml: 0.5
1405
- },
1406
- children: "*"
1374
+ sx: { display: "flex", flexWrap: "wrap", gap: 0.5, mt: 0.5 },
1375
+ children: value.map((option, index) => /* @__PURE__ */ createElement(
1376
+ Chip,
1377
+ {
1378
+ ...getTagProps({ index }),
1379
+ key: option.value,
1380
+ label: option.label,
1381
+ disabled: disabled || option.disabled,
1382
+ sx: chipSx,
1383
+ onDelete: !disabled && !option.disabled ? () => {
1384
+ const newValues = selectedValues.filter(
1385
+ (v) => v !== option.value
1386
+ );
1387
+ handleValueChange(newValues);
1388
+ } : void 0
1389
+ }
1390
+ ))
1407
1391
  }
1408
1392
  )
1409
- ]
1410
- }
1411
- ),
1412
- /* @__PURE__ */ jsx(
1413
- Select,
1414
- {
1415
- multiple,
1416
- variant: "outlined",
1417
- labelId: label ? `select-${name}` : void 0,
1418
- label: label || void 0,
1419
- value: selectedValues,
1420
- onChange: handleChange,
1421
- onBlur: handleBlur,
1422
- onOpen,
1423
- onClose,
1424
- renderValue: externalRenderValue || defaultRenderValue,
1425
- MenuProps: {
1426
- PaperProps: {
1427
- sx: {
1428
- mt: 1,
1429
- boxShadow: theme.shadows[3],
1430
- "& .MuiMenuItem-root": {
1431
- px: 2,
1432
- py: 1
1433
- }
1393
+ }
1394
+ ),
1395
+ showSelectedCount && /* @__PURE__ */ jsxs(
1396
+ Typography,
1397
+ {
1398
+ variant: "caption",
1399
+ sx: {
1400
+ mt: 0.5,
1401
+ color: isMaxReached ? "error.main" : "text.secondary"
1402
+ },
1403
+ children: [
1404
+ selectedCount,
1405
+ " selected",
1406
+ maxSelections ? ` (max ${maxSelections})` : ""
1407
+ ]
1408
+ }
1409
+ )
1410
+ ]
1411
+ }
1412
+ ) });
1413
+ }
1414
+ if (mode === "dropdown") {
1415
+ const handleSelectChange = (event) => {
1416
+ const {
1417
+ target: { value }
1418
+ } = event;
1419
+ const newValues = typeof value === "string" ? value.split(",") : value;
1420
+ handleValueChange(newValues);
1421
+ };
1422
+ return /* @__PURE__ */ jsx(Box, { ref, sx, children: /* @__PURE__ */ jsxs(
1423
+ FormControl,
1424
+ {
1425
+ fullWidth: true,
1426
+ variant,
1427
+ error: hasError,
1428
+ disabled,
1429
+ sx: formControlSx,
1430
+ children: [
1431
+ label && /* @__PURE__ */ jsxs(
1432
+ Typography,
1433
+ {
1434
+ variant: "body2",
1435
+ sx: {
1436
+ mb: 1,
1437
+ color: hasError ? "error.main" : "text.secondary",
1438
+ ...labelSx
1439
+ },
1440
+ children: [
1441
+ label,
1442
+ required && /* @__PURE__ */ jsx(Typography, { sx: { color: "error.main" }, component: "span", children: " *" })
1443
+ ]
1444
+ }
1445
+ ),
1446
+ /* @__PURE__ */ jsx(
1447
+ Select,
1448
+ {
1449
+ multiple: true,
1450
+ value: selectedValues,
1451
+ onChange: handleSelectChange,
1452
+ onBlur: handleBlur,
1453
+ displayEmpty: true,
1454
+ renderValue: (selected) => {
1455
+ if (selected.length === 0) {
1456
+ return /* @__PURE__ */ jsx("em", { children: placeholder });
1434
1457
  }
1435
- }
1436
- },
1437
- sx: [
1438
- {
1439
- backgroundColor: "background.paper",
1440
- color: "text.primary",
1441
- "& .MuiSvgIcon-root": {
1442
- color: "text.secondary",
1443
- ...iconSx
1444
- },
1445
- "& .MuiSelect-icon": {
1446
- color: "text.secondary"
1447
- },
1448
- "& .MuiOutlinedInput-notchedOutline": {
1449
- borderColor: "divider"
1450
- },
1451
- "&:hover .MuiOutlinedInput-notchedOutline": {
1452
- borderColor: "primary.main"
1453
- },
1454
- "&.Mui-focused .MuiOutlinedInput-notchedOutline": {
1455
- borderColor: "primary.main"
1456
- },
1457
- "&.Mui-error .MuiOutlinedInput-notchedOutline": {
1458
- borderColor: "error.main"
1459
- },
1460
- "&.Mui-disabled": {
1461
- backgroundColor: "action.disabledBackground",
1462
- "& .MuiOutlinedInput-notchedOutline": {
1463
- borderColor: "action.disabled"
1458
+ return /* @__PURE__ */ jsx(Box, { sx: { display: "flex", flexWrap: "wrap", gap: 0.5 }, children: selected.map((value) => {
1459
+ const option = options.find((opt) => opt.value === value);
1460
+ return option ? /* @__PURE__ */ jsx(
1461
+ Chip,
1462
+ {
1463
+ label: option.label,
1464
+ size: "small",
1465
+ sx: chipSx
1466
+ },
1467
+ value
1468
+ ) : null;
1469
+ }) });
1470
+ },
1471
+ MenuProps: {
1472
+ PaperProps: {
1473
+ sx: {
1474
+ mt: 1,
1475
+ boxShadow: theme.shadows[3],
1476
+ maxHeight: 300
1464
1477
  }
1478
+ }
1479
+ },
1480
+ children: options.map((option) => /* @__PURE__ */ jsxs(
1481
+ MenuItem,
1482
+ {
1483
+ value: option.value,
1484
+ disabled: option.disabled || isMaxReached && !selectedValues.includes(option.value),
1485
+ sx: option.sx,
1486
+ children: [
1487
+ /* @__PURE__ */ jsx(
1488
+ Checkbox,
1489
+ {
1490
+ checked: selectedValues.includes(option.value),
1491
+ disabled: option.disabled,
1492
+ sx: checkboxSx
1493
+ }
1494
+ ),
1495
+ option.icon,
1496
+ /* @__PURE__ */ jsx(
1497
+ Typography,
1498
+ {
1499
+ variant: "body2",
1500
+ sx: {
1501
+ color: option.disabled ? "text.disabled" : "text.primary",
1502
+ ...option.textSx
1503
+ },
1504
+ children: option.label
1505
+ }
1506
+ )
1507
+ ]
1465
1508
  },
1466
- ...selectSx
1467
- }
1468
- ],
1469
- error: Boolean(fieldError) && isTouched,
1470
- ...otherProps,
1471
- children: options.map((option) => {
1472
- const isSelected = selectedValues.includes(option.value);
1473
- return renderMenuItem ? renderMenuItem(option, isSelected) : defaultRenderMenuItem(option, isSelected);
1474
- })
1475
- }
1476
- ),
1477
- (showHelperText || isTouched && fieldError) && /* @__PURE__ */ jsx(
1478
- FormHelperText,
1479
- {
1480
- sx: [
1481
- {
1482
- mx: 0,
1509
+ option.value
1510
+ ))
1511
+ }
1512
+ ),
1513
+ (helperText || hasError) && /* @__PURE__ */ jsx(FormHelperText, { error: hasError, sx: { mx: 0, mt: 0.5 }, children: hasError ? fieldError : helperText }),
1514
+ showSelectedCount && /* @__PURE__ */ jsxs(
1515
+ Typography,
1516
+ {
1517
+ variant: "caption",
1518
+ sx: {
1483
1519
  mt: 0.5,
1484
- color: isTouched && fieldError ? "error.main" : "text.secondary",
1485
- ...isTouched && fieldError ? errorSx : helperTextSx
1486
- }
1487
- ],
1488
- children: isTouched && fieldError ? fieldError : helperText
1489
- }
1490
- )
1491
- ]
1492
- }
1493
- ) });
1520
+ color: isMaxReached ? "error.main" : "text.secondary"
1521
+ },
1522
+ children: [
1523
+ selectedCount,
1524
+ " selected",
1525
+ maxSelections ? ` (max ${maxSelections})` : ""
1526
+ ]
1527
+ }
1528
+ )
1529
+ ]
1530
+ }
1531
+ ) });
1532
+ }
1533
+ return null;
1494
1534
  }
1495
1535
  );
1496
1536
  AppMultiSelector.displayName = "AppMultiSelector";
@@ -1510,8 +1550,8 @@ var AppPhoneNoInput = ({
1510
1550
  withCountryCallingCode = true
1511
1551
  }) => {
1512
1552
  const { values, errors, touched, setFieldValue, setFieldTouched } = useFormikContext();
1513
- const fieldError = useMemo(() => _19.get(errors, name), [errors, name]);
1514
- const isTouched = useMemo(() => _19.get(touched, name), [touched, name]);
1553
+ const fieldError = useMemo(() => _17.get(errors, name), [errors, name]);
1554
+ const isTouched = useMemo(() => _17.get(touched, name), [touched, name]);
1515
1555
  return /* @__PURE__ */ jsxs(
1516
1556
  Box,
1517
1557
  {
@@ -1621,9 +1661,9 @@ var AppRadioGroup = forwardRef(({
1621
1661
  ...rest
1622
1662
  }, ref) => {
1623
1663
  const { errors, touched, getFieldProps, setFieldValue } = useFormikContext();
1624
- const fieldError = _19.get(errors, name);
1625
- const isTouched = _19.get(touched, name);
1626
- const value = _19.get(getFieldProps(name), "value");
1664
+ const fieldError = _17.get(errors, name);
1665
+ const isTouched = _17.get(touched, name);
1666
+ const value = _17.get(getFieldProps(name), "value");
1627
1667
  const handleChange = (event) => {
1628
1668
  const newValue = event.target.value;
1629
1669
  setFieldValue(name, newValue);
@@ -1802,9 +1842,9 @@ var AppRating = forwardRef(
1802
1842
  }, ref) => {
1803
1843
  useTheme();
1804
1844
  const { errors, touched, setFieldValue, values, setFieldTouched } = useFormikContext();
1805
- const val = _19.get(values, name);
1806
- const fieldError = _19.get(errors, name);
1807
- const isTouched = _19.get(touched, name);
1845
+ const val = _17.get(values, name);
1846
+ const fieldError = _17.get(errors, name);
1847
+ const isTouched = _17.get(touched, name);
1808
1848
  const hasError = Boolean(fieldError) && isTouched;
1809
1849
  const handleChange = (event, newValue) => {
1810
1850
  setFieldValue(name, newValue);
@@ -2149,7 +2189,7 @@ function findDiffEnd(a, b, posA, posB) {
2149
2189
  posB -= size;
2150
2190
  }
2151
2191
  }
2152
- var Fragment2 = class {
2192
+ var Fragment3 = class {
2153
2193
  /**
2154
2194
  @internal
2155
2195
  */
@@ -2217,7 +2257,7 @@ var Fragment2 = class {
2217
2257
  }
2218
2258
  for (; i < other.content.length; i++)
2219
2259
  content.push(other.content[i]);
2220
- return new Fragment2(content, this.size + other.size);
2260
+ return new Fragment3(content, this.size + other.size);
2221
2261
  }
2222
2262
  /**
2223
2263
  Cut out the sub-fragment between the two given positions.
@@ -2241,17 +2281,17 @@ var Fragment2 = class {
2241
2281
  }
2242
2282
  pos = end;
2243
2283
  }
2244
- return new Fragment2(result, size);
2284
+ return new Fragment3(result, size);
2245
2285
  }
2246
2286
  /**
2247
2287
  @internal
2248
2288
  */
2249
2289
  cutByIndex(from, to) {
2250
2290
  if (from == to)
2251
- return Fragment2.empty;
2291
+ return Fragment3.empty;
2252
2292
  if (from == 0 && to == this.content.length)
2253
2293
  return this;
2254
- return new Fragment2(this.content.slice(from, to));
2294
+ return new Fragment3(this.content.slice(from, to));
2255
2295
  }
2256
2296
  /**
2257
2297
  Create a new fragment in which the node at the given index is
@@ -2264,21 +2304,21 @@ var Fragment2 = class {
2264
2304
  let copy2 = this.content.slice();
2265
2305
  let size = this.size + node.nodeSize - current.nodeSize;
2266
2306
  copy2[index] = node;
2267
- return new Fragment2(copy2, size);
2307
+ return new Fragment3(copy2, size);
2268
2308
  }
2269
2309
  /**
2270
2310
  Create a new fragment by prepending the given node to this
2271
2311
  fragment.
2272
2312
  */
2273
2313
  addToStart(node) {
2274
- return new Fragment2([node].concat(this.content), this.size + node.nodeSize);
2314
+ return new Fragment3([node].concat(this.content), this.size + node.nodeSize);
2275
2315
  }
2276
2316
  /**
2277
2317
  Create a new fragment by appending the given node to this
2278
2318
  fragment.
2279
2319
  */
2280
2320
  addToEnd(node) {
2281
- return new Fragment2(this.content.concat(node), this.size + node.nodeSize);
2321
+ return new Fragment3(this.content.concat(node), this.size + node.nodeSize);
2282
2322
  }
2283
2323
  /**
2284
2324
  Compare this fragment to another one.
@@ -2397,10 +2437,10 @@ var Fragment2 = class {
2397
2437
  */
2398
2438
  static fromJSON(schema, value) {
2399
2439
  if (!value)
2400
- return Fragment2.empty;
2440
+ return Fragment3.empty;
2401
2441
  if (!Array.isArray(value))
2402
2442
  throw new RangeError("Invalid input for Fragment.fromJSON");
2403
- return new Fragment2(value.map(schema.nodeFromJSON));
2443
+ return new Fragment3(value.map(schema.nodeFromJSON));
2404
2444
  }
2405
2445
  /**
2406
2446
  Build a fragment from an array of nodes. Ensures that adjacent
@@ -2408,7 +2448,7 @@ var Fragment2 = class {
2408
2448
  */
2409
2449
  static fromArray(array) {
2410
2450
  if (!array.length)
2411
- return Fragment2.empty;
2451
+ return Fragment3.empty;
2412
2452
  let joined, size = 0;
2413
2453
  for (let i = 0; i < array.length; i++) {
2414
2454
  let node = array[i];
@@ -2421,7 +2461,7 @@ var Fragment2 = class {
2421
2461
  joined.push(node);
2422
2462
  }
2423
2463
  }
2424
- return new Fragment2(joined || array, size);
2464
+ return new Fragment3(joined || array, size);
2425
2465
  }
2426
2466
  /**
2427
2467
  Create a fragment from something that can be interpreted as a
@@ -2431,17 +2471,17 @@ var Fragment2 = class {
2431
2471
  */
2432
2472
  static from(nodes) {
2433
2473
  if (!nodes)
2434
- return Fragment2.empty;
2435
- if (nodes instanceof Fragment2)
2474
+ return Fragment3.empty;
2475
+ if (nodes instanceof Fragment3)
2436
2476
  return nodes;
2437
2477
  if (Array.isArray(nodes))
2438
2478
  return this.fromArray(nodes);
2439
2479
  if (nodes.attrs)
2440
- return new Fragment2([nodes], nodes.nodeSize);
2480
+ return new Fragment3([nodes], nodes.nodeSize);
2441
2481
  throw new RangeError("Can not convert " + nodes + " to a Fragment" + (nodes.nodesBetween ? " (looks like multiple versions of prosemirror-model were loaded)" : ""));
2442
2482
  }
2443
2483
  };
2444
- Fragment2.empty = new Fragment2([], 0);
2484
+ Fragment3.empty = new Fragment3([], 0);
2445
2485
  var found = { index: 0, offset: 0 };
2446
2486
  function retIndex(index, offset) {
2447
2487
  found.index = index;
@@ -2546,7 +2586,7 @@ var Mark = class {
2546
2586
  */
2547
2587
  toJSON() {
2548
2588
  let obj = { type: this.type.name };
2549
- for (let _20 in this.attrs) {
2589
+ for (let _18 in this.attrs) {
2550
2590
  obj.attrs = this.attrs;
2551
2591
  break;
2552
2592
  }
@@ -2666,7 +2706,7 @@ var Slice = class {
2666
2706
  let openStart = json.openStart || 0, openEnd = json.openEnd || 0;
2667
2707
  if (typeof openStart != "number" || typeof openEnd != "number")
2668
2708
  throw new RangeError("Invalid input for Slice.fromJSON");
2669
- return new Slice(Fragment2.fromJSON(schema, json.content), openStart, openEnd);
2709
+ return new Slice(Fragment3.fromJSON(schema, json.content), openStart, openEnd);
2670
2710
  }
2671
2711
  /**
2672
2712
  Create a slice from a fragment by taking the maximum possible
@@ -2681,7 +2721,7 @@ var Slice = class {
2681
2721
  return new Slice(fragment, openStart, openEnd);
2682
2722
  }
2683
2723
  };
2684
- Slice.empty = new Slice(Fragment2.empty, 0, 0);
2724
+ Slice.empty = new Slice(Fragment3.empty, 0, 0);
2685
2725
  function removeRange(content, from, to) {
2686
2726
  let { index, offset } = content.findIndex(from), child = content.maybeChild(index);
2687
2727
  let { index: indexTo, offset: offsetTo } = content.findIndex(to);
@@ -2779,7 +2819,7 @@ function replaceThreeWay($from, $start, $end, $to, depth) {
2779
2819
  addNode(close(openEnd, replaceTwoWay($end, $to, depth + 1)), content);
2780
2820
  }
2781
2821
  addRange($to, null, depth, content);
2782
- return new Fragment2(content);
2822
+ return new Fragment3(content);
2783
2823
  }
2784
2824
  function replaceTwoWay($from, $to, depth) {
2785
2825
  let content = [];
@@ -2789,13 +2829,13 @@ function replaceTwoWay($from, $to, depth) {
2789
2829
  addNode(close(type, replaceTwoWay($from, $to, depth + 1)), content);
2790
2830
  }
2791
2831
  addRange($to, null, depth, content);
2792
- return new Fragment2(content);
2832
+ return new Fragment3(content);
2793
2833
  }
2794
2834
  function prepareSliceForReplace(slice, $along) {
2795
2835
  let extra = $along.depth - slice.openStart, parent = $along.node(extra);
2796
2836
  let node = parent.copy(slice.content);
2797
2837
  for (let i = extra - 1; i >= 0; i--)
2798
- node = $along.node(i).copy(Fragment2.from(node));
2838
+ node = $along.node(i).copy(Fragment3.from(node));
2799
2839
  return {
2800
2840
  start: node.resolveNoCache(slice.openStart + extra),
2801
2841
  end: node.resolveNoCache(node.content.size - slice.openEnd - extra)
@@ -3134,7 +3174,7 @@ var Node = class {
3134
3174
  this.type = type;
3135
3175
  this.attrs = attrs;
3136
3176
  this.marks = marks;
3137
- this.content = content || Fragment2.empty;
3177
+ this.content = content || Fragment3.empty;
3138
3178
  }
3139
3179
  /**
3140
3180
  The array of this node's child nodes.
@@ -3439,7 +3479,7 @@ var Node = class {
3439
3479
  can optionally pass `start` and `end` indices into the
3440
3480
  replacement fragment.
3441
3481
  */
3442
- canReplace(from, to, replacement = Fragment2.empty, start = 0, end = replacement.childCount) {
3482
+ canReplace(from, to, replacement = Fragment3.empty, start = 0, end = replacement.childCount) {
3443
3483
  let one = this.contentMatchAt(from).matchFragment(replacement, start, end);
3444
3484
  let two = one && one.matchFragment(this.content, to);
3445
3485
  if (!two || !two.validEnd)
@@ -3494,7 +3534,7 @@ var Node = class {
3494
3534
  */
3495
3535
  toJSON() {
3496
3536
  let obj = { type: this.type.name };
3497
- for (let _20 in this.attrs) {
3537
+ for (let _18 in this.attrs) {
3498
3538
  obj.attrs = this.attrs;
3499
3539
  break;
3500
3540
  }
@@ -3521,7 +3561,7 @@ var Node = class {
3521
3561
  throw new RangeError("Invalid text node in JSON");
3522
3562
  return schema.text(json.text, marks);
3523
3563
  }
3524
- let content = Fragment2.fromJSON(schema, json.content);
3564
+ let content = Fragment3.fromJSON(schema, json.content);
3525
3565
  let node = schema.nodeType(json.type).create(json.attrs, content, marks);
3526
3566
  node.type.checkAttrs(node.attrs);
3527
3567
  return node;
@@ -3663,7 +3703,7 @@ var ContentMatch = class {
3663
3703
  function search(match, types) {
3664
3704
  let finished = match.matchFragment(after, startIndex);
3665
3705
  if (finished && (!toEnd || finished.validEnd))
3666
- return Fragment2.from(types.map((tp) => tp.createAndFill()));
3706
+ return Fragment3.from(types.map((tp) => tp.createAndFill()));
3667
3707
  for (let i = 0; i < match.next.length; i++) {
3668
3708
  let { type, next } = match.next[i];
3669
3709
  if (!(type.isText || type.hasRequiredAttrs()) && seen.indexOf(next) == -1) {
@@ -4115,7 +4155,7 @@ var NodeType = class {
4115
4155
  create(attrs = null, content, marks) {
4116
4156
  if (this.isText)
4117
4157
  throw new Error("NodeType.create can't construct text nodes");
4118
- return new Node(this, this.computeAttrs(attrs), Fragment2.from(content), Mark.setFrom(marks));
4158
+ return new Node(this, this.computeAttrs(attrs), Fragment3.from(content), Mark.setFrom(marks));
4119
4159
  }
4120
4160
  /**
4121
4161
  Like [`create`](https://prosemirror.net/docs/ref/#model.NodeType.create), but check the given content
@@ -4123,7 +4163,7 @@ var NodeType = class {
4123
4163
  if it doesn't match.
4124
4164
  */
4125
4165
  createChecked(attrs = null, content, marks) {
4126
- content = Fragment2.from(content);
4166
+ content = Fragment3.from(content);
4127
4167
  this.checkContent(content);
4128
4168
  return new Node(this, this.computeAttrs(attrs), content, Mark.setFrom(marks));
4129
4169
  }
@@ -4137,7 +4177,7 @@ var NodeType = class {
4137
4177
  */
4138
4178
  createAndFill(attrs = null, content, marks) {
4139
4179
  attrs = this.computeAttrs(attrs);
4140
- content = Fragment2.from(content);
4180
+ content = Fragment3.from(content);
4141
4181
  if (content.size) {
4142
4182
  let before = this.contentMatch.fillBefore(content);
4143
4183
  if (!before)
@@ -4145,7 +4185,7 @@ var NodeType = class {
4145
4185
  content = before.append(content);
4146
4186
  }
4147
4187
  let matched = this.contentMatch.matchFragment(content);
4148
- let after = matched && matched.fillBefore(Fragment2.empty, true);
4188
+ let after = matched && matched.fillBefore(Fragment3.empty, true);
4149
4189
  if (!after)
4150
4190
  return null;
4151
4191
  return new Node(this, attrs, content.append(after), Mark.setFrom(marks));
@@ -4223,7 +4263,7 @@ var NodeType = class {
4223
4263
  throw new RangeError("Schema is missing its top node type ('" + topType + "')");
4224
4264
  if (!result.text)
4225
4265
  throw new RangeError("Every schema needs a 'text' type");
4226
- for (let _20 in result.text.attrs)
4266
+ for (let _18 in result.text.attrs)
4227
4267
  throw new RangeError("The text node type should not have attributes");
4228
4268
  return result;
4229
4269
  }
@@ -4609,7 +4649,7 @@ var NodeContext = class {
4609
4649
  if (!this.match) {
4610
4650
  if (!this.type)
4611
4651
  return [];
4612
- let fill = this.type.contentMatch.fillBefore(Fragment2.from(node));
4652
+ let fill = this.type.contentMatch.fillBefore(Fragment3.from(node));
4613
4653
  if (fill) {
4614
4654
  this.match = this.type.contentMatch.matchFragment(fill);
4615
4655
  } else {
@@ -4635,9 +4675,9 @@ var NodeContext = class {
4635
4675
  this.content[this.content.length - 1] = text.withText(text.text.slice(0, text.text.length - m2[0].length));
4636
4676
  }
4637
4677
  }
4638
- let content = Fragment2.from(this.content);
4678
+ let content = Fragment3.from(this.content);
4639
4679
  if (!openEnd && this.match)
4640
- content = content.append(this.match.fillBefore(Fragment2.empty, true));
4680
+ content = content.append(this.match.fillBefore(Fragment3.empty, true));
4641
4681
  return this.type ? this.type.create(this.attrs, content, this.marks) : content;
4642
4682
  }
4643
4683
  inlineContext(node) {
@@ -5454,7 +5494,7 @@ function mapFragment(fragment, f, parent) {
5454
5494
  child = f(child, parent, i);
5455
5495
  mapped.push(child);
5456
5496
  }
5457
- return Fragment2.fromArray(mapped);
5497
+ return Fragment3.fromArray(mapped);
5458
5498
  }
5459
5499
  var AddMarkStep = class extends Step {
5460
5500
  /**
@@ -5571,7 +5611,7 @@ var AddNodeMarkStep = class extends Step {
5571
5611
  if (!node)
5572
5612
  return StepResult.fail("No node at mark step's position");
5573
5613
  let updated = node.type.create(node.attrs, null, this.mark.addToSet(node.marks));
5574
- return StepResult.fromReplace(doc2, this.pos, this.pos + 1, new Slice(Fragment2.from(updated), 0, node.isLeaf ? 0 : 1));
5614
+ return StepResult.fromReplace(doc2, this.pos, this.pos + 1, new Slice(Fragment3.from(updated), 0, node.isLeaf ? 0 : 1));
5575
5615
  }
5576
5616
  invert(doc2) {
5577
5617
  let node = doc2.nodeAt(this.pos);
@@ -5617,7 +5657,7 @@ var RemoveNodeMarkStep = class extends Step {
5617
5657
  if (!node)
5618
5658
  return StepResult.fail("No node at mark step's position");
5619
5659
  let updated = node.type.create(node.attrs, null, this.mark.removeFromSet(node.marks));
5620
- return StepResult.fromReplace(doc2, this.pos, this.pos + 1, new Slice(Fragment2.from(updated), 0, node.isLeaf ? 0 : 1));
5660
+ return StepResult.fromReplace(doc2, this.pos, this.pos + 1, new Slice(Fragment3.from(updated), 0, node.isLeaf ? 0 : 1));
5621
5661
  }
5622
5662
  invert(doc2) {
5623
5663
  let node = doc2.nodeAt(this.pos);
@@ -5882,7 +5922,7 @@ function clearIncompatible(tr, pos, parentType, match = parentType.contentMatch,
5882
5922
  let m2, newline = /\r?\n|\r/g, slice;
5883
5923
  while (m2 = newline.exec(child.text)) {
5884
5924
  if (!slice)
5885
- slice = new Slice(Fragment2.from(parentType.schema.text(" ", parentType.allowedMarks(child.marks))), 0, 0);
5925
+ slice = new Slice(Fragment3.from(parentType.schema.text(" ", parentType.allowedMarks(child.marks))), 0, 0);
5886
5926
  replSteps.push(new ReplaceStep(cur + m2.index, cur + m2.index + m2[0].length, slice));
5887
5927
  }
5888
5928
  }
@@ -5890,7 +5930,7 @@ function clearIncompatible(tr, pos, parentType, match = parentType.contentMatch,
5890
5930
  cur = end;
5891
5931
  }
5892
5932
  if (!match.validEnd) {
5893
- let fill = match.fillBefore(Fragment2.empty, true);
5933
+ let fill = match.fillBefore(Fragment3.empty, true);
5894
5934
  tr.replace(cur, cur, new Slice(fill, 0, 0));
5895
5935
  }
5896
5936
  for (let i = replSteps.length - 1; i >= 0; i--)
@@ -5920,20 +5960,20 @@ function lift(tr, range, target) {
5920
5960
  let { $from, $to, depth } = range;
5921
5961
  let gapStart = $from.before(depth + 1), gapEnd = $to.after(depth + 1);
5922
5962
  let start = gapStart, end = gapEnd;
5923
- let before = Fragment2.empty, openStart = 0;
5963
+ let before = Fragment3.empty, openStart = 0;
5924
5964
  for (let d = depth, splitting = false; d > target; d--)
5925
5965
  if (splitting || $from.index(d) > 0) {
5926
5966
  splitting = true;
5927
- before = Fragment2.from($from.node(d).copy(before));
5967
+ before = Fragment3.from($from.node(d).copy(before));
5928
5968
  openStart++;
5929
5969
  } else {
5930
5970
  start--;
5931
5971
  }
5932
- let after = Fragment2.empty, openEnd = 0;
5972
+ let after = Fragment3.empty, openEnd = 0;
5933
5973
  for (let d = depth, splitting = false; d > target; d--)
5934
5974
  if (splitting || $to.after(d + 1) < $to.end(d)) {
5935
5975
  splitting = true;
5936
- after = Fragment2.from($to.node(d).copy(after));
5976
+ after = Fragment3.from($to.node(d).copy(after));
5937
5977
  openEnd++;
5938
5978
  } else {
5939
5979
  end++;
@@ -5973,14 +6013,14 @@ function findWrappingInside(range, type) {
5973
6013
  return inside;
5974
6014
  }
5975
6015
  function wrap(tr, range, wrappers) {
5976
- let content = Fragment2.empty;
6016
+ let content = Fragment3.empty;
5977
6017
  for (let i = wrappers.length - 1; i >= 0; i--) {
5978
6018
  if (content.size) {
5979
6019
  let match = wrappers[i].type.contentMatch.matchFragment(content);
5980
6020
  if (!match || !match.validEnd)
5981
6021
  throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper");
5982
6022
  }
5983
- content = Fragment2.from(wrappers[i].type.create(wrappers[i].attrs, content));
6023
+ content = Fragment3.from(wrappers[i].type.create(wrappers[i].attrs, content));
5984
6024
  }
5985
6025
  let start = range.start, end = range.end;
5986
6026
  tr.step(new ReplaceAroundStep(start, end, start, end, new Slice(content, 0, 0), wrappers.length, true));
@@ -6005,7 +6045,7 @@ function setBlockType(tr, from, to, type, attrs) {
6005
6045
  clearIncompatible(tr, tr.mapping.slice(mapFrom).map(pos, 1), type, void 0, convertNewlines === null);
6006
6046
  let mapping = tr.mapping.slice(mapFrom);
6007
6047
  let startM = mapping.map(pos, 1), endM = mapping.map(pos + node.nodeSize, 1);
6008
- tr.step(new ReplaceAroundStep(startM, endM, startM + 1, endM - 1, new Slice(Fragment2.from(type.create(attrsHere, null, node.marks)), 0, 0), 1, true));
6048
+ tr.step(new ReplaceAroundStep(startM, endM, startM + 1, endM - 1, new Slice(Fragment3.from(type.create(attrsHere, null, node.marks)), 0, 0), 1, true));
6009
6049
  if (convertNewlines === true)
6010
6050
  replaceNewlines(tr, node, pos, mapFrom);
6011
6051
  return false;
@@ -6046,7 +6086,7 @@ function setNodeMarkup(tr, pos, type, attrs, marks) {
6046
6086
  return tr.replaceWith(pos, pos + node.nodeSize, newNode);
6047
6087
  if (!type.validContent(node.content))
6048
6088
  throw new RangeError("Invalid content for node type " + type.name);
6049
- tr.step(new ReplaceAroundStep(pos, pos + node.nodeSize, pos + 1, pos + node.nodeSize - 1, new Slice(Fragment2.from(newNode), 0, 0), 1, true));
6089
+ tr.step(new ReplaceAroundStep(pos, pos + node.nodeSize, pos + 1, pos + node.nodeSize - 1, new Slice(Fragment3.from(newNode), 0, 0), 1, true));
6050
6090
  }
6051
6091
  function canSplit(doc2, pos, depth = 1, typesAfter) {
6052
6092
  let $pos = doc2.resolve(pos), base2 = $pos.depth - depth;
@@ -6070,11 +6110,11 @@ function canSplit(doc2, pos, depth = 1, typesAfter) {
6070
6110
  return $pos.node(base2).canReplaceWith(index, index, baseType ? baseType.type : $pos.node(base2 + 1).type);
6071
6111
  }
6072
6112
  function split(tr, pos, depth = 1, typesAfter) {
6073
- let $pos = tr.doc.resolve(pos), before = Fragment2.empty, after = Fragment2.empty;
6113
+ let $pos = tr.doc.resolve(pos), before = Fragment3.empty, after = Fragment3.empty;
6074
6114
  for (let d = $pos.depth, e = $pos.depth - depth, i = depth - 1; d > e; d--, i--) {
6075
- before = Fragment2.from($pos.node(d).copy(before));
6115
+ before = Fragment3.from($pos.node(d).copy(before));
6076
6116
  let typeAfter = typesAfter && typesAfter[i];
6077
- after = Fragment2.from(typeAfter ? typeAfter.type.create(typeAfter.attrs, after) : $pos.node(d).copy(after));
6117
+ after = Fragment3.from(typeAfter ? typeAfter.type.create(typeAfter.attrs, after) : $pos.node(d).copy(after));
6078
6118
  }
6079
6119
  tr.step(new ReplaceStep(pos, pos, new Slice(before.append(after), depth, depth), true));
6080
6120
  }
@@ -6189,7 +6229,7 @@ var Fitter = class {
6189
6229
  this.$to = $to;
6190
6230
  this.unplaced = unplaced;
6191
6231
  this.frontier = [];
6192
- this.placed = Fragment2.empty;
6232
+ this.placed = Fragment3.empty;
6193
6233
  for (let i = 0; i <= $from.depth; i++) {
6194
6234
  let node = $from.node(i);
6195
6235
  this.frontier.push({
@@ -6198,7 +6238,7 @@ var Fitter = class {
6198
6238
  });
6199
6239
  }
6200
6240
  for (let i = $from.depth; i > 0; i--)
6201
- this.placed = Fragment2.from($from.node(i).copy(this.placed));
6241
+ this.placed = Fragment3.from($from.node(i).copy(this.placed));
6202
6242
  }
6203
6243
  get depth() {
6204
6244
  return this.frontier.length - 1;
@@ -6255,7 +6295,7 @@ var Fitter = class {
6255
6295
  let first2 = fragment.firstChild;
6256
6296
  for (let frontierDepth = this.depth; frontierDepth >= 0; frontierDepth--) {
6257
6297
  let { type, match } = this.frontier[frontierDepth], wrap2, inject = null;
6258
- if (pass == 1 && (first2 ? match.matchType(first2.type) || (inject = match.fillBefore(Fragment2.from(first2), false)) : parent && type.compatibleContent(parent.type)))
6298
+ if (pass == 1 && (first2 ? match.matchType(first2.type) || (inject = match.fillBefore(Fragment3.from(first2), false)) : parent && type.compatibleContent(parent.type)))
6259
6299
  return { sliceDepth, frontierDepth, parent, inject };
6260
6300
  else if (pass == 2 && first2 && (wrap2 = match.findWrapping(first2.type)))
6261
6301
  return { sliceDepth, frontierDepth, parent, wrap: wrap2 };
@@ -6315,7 +6355,7 @@ var Fitter = class {
6315
6355
  let toEnd = taken == fragment.childCount;
6316
6356
  if (!toEnd)
6317
6357
  openEndCount = -1;
6318
- this.placed = addToFragment(this.placed, frontierDepth, Fragment2.from(add));
6358
+ this.placed = addToFragment(this.placed, frontierDepth, Fragment3.from(add));
6319
6359
  this.frontier[frontierDepth].match = match;
6320
6360
  if (toEnd && openEndCount < 0 && parent && parent.type == this.frontier[this.depth].type && this.frontier.length > 1)
6321
6361
  this.closeFrontierNode();
@@ -6372,12 +6412,12 @@ var Fitter = class {
6372
6412
  openFrontierNode(type, attrs = null, content) {
6373
6413
  let top = this.frontier[this.depth];
6374
6414
  top.match = top.match.matchType(type);
6375
- this.placed = addToFragment(this.placed, this.depth, Fragment2.from(type.create(attrs, content)));
6415
+ this.placed = addToFragment(this.placed, this.depth, Fragment3.from(type.create(attrs, content)));
6376
6416
  this.frontier.push({ type, match: type.contentMatch });
6377
6417
  }
6378
6418
  closeFrontierNode() {
6379
6419
  let open = this.frontier.pop();
6380
- let add = open.match.fillBefore(Fragment2.empty, true);
6420
+ let add = open.match.fillBefore(Fragment3.empty, true);
6381
6421
  if (add.childCount)
6382
6422
  this.placed = addToFragment(this.placed, this.frontier.length, add);
6383
6423
  }
@@ -6406,7 +6446,7 @@ function closeNodeStart(node, openStart, openEnd) {
6406
6446
  if (openStart > 0) {
6407
6447
  frag = node.type.contentMatch.fillBefore(frag).append(frag);
6408
6448
  if (openEnd <= 0)
6409
- frag = frag.append(node.type.contentMatch.matchFragment(frag).fillBefore(Fragment2.empty, true));
6449
+ frag = frag.append(node.type.contentMatch.matchFragment(frag).fillBefore(Fragment3.empty, true));
6410
6450
  }
6411
6451
  return node.copy(frag);
6412
6452
  }
@@ -6498,7 +6538,7 @@ function closeFragment(fragment, depth, oldOpen, newOpen, parent) {
6498
6538
  if (depth > newOpen) {
6499
6539
  let match = parent.contentMatchAt(0);
6500
6540
  let start = match.fillBefore(fragment).append(fragment);
6501
- fragment = start.append(match.matchFragment(start).fillBefore(Fragment2.empty, true));
6541
+ fragment = start.append(match.matchFragment(start).fillBefore(Fragment3.empty, true));
6502
6542
  }
6503
6543
  return fragment;
6504
6544
  }
@@ -6508,7 +6548,7 @@ function replaceRangeWith(tr, from, to, node) {
6508
6548
  if (point != null)
6509
6549
  from = to = point;
6510
6550
  }
6511
- tr.replaceRange(from, to, new Slice(Fragment2.from(node), 0, 0));
6551
+ tr.replaceRange(from, to, new Slice(Fragment3.from(node), 0, 0));
6512
6552
  }
6513
6553
  function deleteRange(tr, from, to) {
6514
6554
  let $from = tr.doc.resolve(from), $to = tr.doc.resolve(to);
@@ -6556,7 +6596,7 @@ var AttrStep = class extends Step {
6556
6596
  attrs[name] = node.attrs[name];
6557
6597
  attrs[this.attr] = this.value;
6558
6598
  let updated = node.type.create(attrs, null, node.marks);
6559
- return StepResult.fromReplace(doc2, this.pos, this.pos + 1, new Slice(Fragment2.from(updated), 0, node.isLeaf ? 0 : 1));
6599
+ return StepResult.fromReplace(doc2, this.pos, this.pos + 1, new Slice(Fragment3.from(updated), 0, node.isLeaf ? 0 : 1));
6560
6600
  }
6561
6601
  getMap() {
6562
6602
  return StepMap.empty;
@@ -6691,7 +6731,7 @@ var Transform = class {
6691
6731
  fragment, node, or array of nodes.
6692
6732
  */
6693
6733
  replaceWith(from, to, content) {
6694
- return this.replace(from, to, new Slice(Fragment2.from(content), 0, 0));
6734
+ return this.replace(from, to, new Slice(Fragment3.from(content), 0, 0));
6695
6735
  }
6696
6736
  /**
6697
6737
  Delete the content between the given positions.
@@ -7193,7 +7233,7 @@ var NodeSelection = class extends Selection {
7193
7233
  return new NodeSelection($pos);
7194
7234
  }
7195
7235
  content() {
7196
- return new Slice(Fragment2.from(this.node), 0, 0);
7236
+ return new Slice(Fragment3.from(this.node), 0, 0);
7197
7237
  }
7198
7238
  eq(other) {
7199
7239
  return other instanceof NodeSelection && other.anchor == this.anchor;
@@ -7751,10 +7791,10 @@ function deleteBarrier(state, $cut, dispatch, dir) {
7751
7791
  let canDelAfter = !isolated && $cut.parent.canReplace($cut.index(), $cut.index() + 1);
7752
7792
  if (canDelAfter && (conn = (match = before.contentMatchAt(before.childCount)).findWrapping(after.type)) && match.matchType(conn[0] || after.type).validEnd) {
7753
7793
  if (dispatch) {
7754
- let end = $cut.pos + after.nodeSize, wrap2 = Fragment2.empty;
7794
+ let end = $cut.pos + after.nodeSize, wrap2 = Fragment3.empty;
7755
7795
  for (let i = conn.length - 1; i >= 0; i--)
7756
- wrap2 = Fragment2.from(conn[i].create(null, wrap2));
7757
- wrap2 = Fragment2.from(before.copy(wrap2));
7796
+ wrap2 = Fragment3.from(conn[i].create(null, wrap2));
7797
+ wrap2 = Fragment3.from(before.copy(wrap2));
7758
7798
  let tr = state.tr.step(new ReplaceAroundStep($cut.pos - 1, end, $cut.pos, end, new Slice(wrap2, 1, 0), conn.length, true));
7759
7799
  let $joinAt = tr.doc.resolve(end + 2 * conn.length);
7760
7800
  if ($joinAt.nodeAfter && $joinAt.nodeAfter.type == before.type && canJoin(tr.doc, $joinAt.pos))
@@ -7783,9 +7823,9 @@ function deleteBarrier(state, $cut, dispatch, dir) {
7783
7823
  afterDepth++;
7784
7824
  if (at.canReplace(at.childCount, at.childCount, afterText.content)) {
7785
7825
  if (dispatch) {
7786
- let end = Fragment2.empty;
7826
+ let end = Fragment3.empty;
7787
7827
  for (let i = wrap2.length - 1; i >= 0; i--)
7788
- end = Fragment2.from(wrap2[i].copy(end));
7828
+ end = Fragment3.from(wrap2[i].copy(end));
7789
7829
  let tr = state.tr.step(new ReplaceAroundStep($cut.pos - wrap2.length, $cut.pos + after.nodeSize, $cut.pos + afterDepth, $cut.pos + after.nodeSize - afterDepth, new Slice(end, wrap2.length, 0), 0, true));
7790
7830
  dispatch(tr.scrollIntoView());
7791
7831
  }
@@ -7890,9 +7930,9 @@ function wrapRangeInList(tr, range, listType, attrs = null) {
7890
7930
  return true;
7891
7931
  }
7892
7932
  function doWrapInList(tr, range, wrappers, joinBefore, listType) {
7893
- let content = Fragment2.empty;
7933
+ let content = Fragment3.empty;
7894
7934
  for (let i = wrappers.length - 1; i >= 0; i--)
7895
- content = Fragment2.from(wrappers[i].type.create(wrappers[i].attrs, content));
7935
+ content = Fragment3.from(wrappers[i].type.create(wrappers[i].attrs, content));
7896
7936
  tr.step(new ReplaceAroundStep(range.start - (joinBefore ? 2 : 0), range.end, range.start, range.end, new Slice(content, 0, 0), wrappers.length, true));
7897
7937
  let found2 = 0;
7898
7938
  for (let i = 0; i < wrappers.length; i++)
@@ -7926,7 +7966,7 @@ function liftListItem(itemType) {
7926
7966
  function liftToOuterList(state, dispatch, itemType, range) {
7927
7967
  let tr = state.tr, end = range.end, endOfList = range.$to.end(range.depth);
7928
7968
  if (end < endOfList) {
7929
- tr.step(new ReplaceAroundStep(end - 1, endOfList, end, endOfList, new Slice(Fragment2.from(itemType.create(null, range.parent.copy())), 1, 0), 1, true));
7969
+ tr.step(new ReplaceAroundStep(end - 1, endOfList, end, endOfList, new Slice(Fragment3.from(itemType.create(null, range.parent.copy())), 1, 0), 1, true));
7930
7970
  range = new NodeRange(tr.doc.resolve(range.$from.pos), tr.doc.resolve(endOfList), range.depth);
7931
7971
  }
7932
7972
  const target = liftTarget(range);
@@ -7950,10 +7990,10 @@ function liftOutOfList(state, dispatch, range) {
7950
7990
  return false;
7951
7991
  let atStart = range.startIndex == 0, atEnd = range.endIndex == list.childCount;
7952
7992
  let parent = $start.node(-1), indexBefore = $start.index(-1);
7953
- if (!parent.canReplace(indexBefore + (atStart ? 0 : 1), indexBefore + 1, item.content.append(atEnd ? Fragment2.empty : Fragment2.from(list))))
7993
+ if (!parent.canReplace(indexBefore + (atStart ? 0 : 1), indexBefore + 1, item.content.append(atEnd ? Fragment3.empty : Fragment3.from(list))))
7954
7994
  return false;
7955
7995
  let start = $start.pos, end = start + item.nodeSize;
7956
- tr.step(new ReplaceAroundStep(start - (atStart ? 1 : 0), end + (atEnd ? 1 : 0), start + 1, end - 1, new Slice((atStart ? Fragment2.empty : Fragment2.from(list.copy(Fragment2.empty))).append(atEnd ? Fragment2.empty : Fragment2.from(list.copy(Fragment2.empty))), atStart ? 0 : 1, atEnd ? 0 : 1), atStart ? 0 : 1));
7996
+ tr.step(new ReplaceAroundStep(start - (atStart ? 1 : 0), end + (atEnd ? 1 : 0), start + 1, end - 1, new Slice((atStart ? Fragment3.empty : Fragment3.from(list.copy(Fragment3.empty))).append(atEnd ? Fragment3.empty : Fragment3.from(list.copy(Fragment3.empty))), atStart ? 0 : 1, atEnd ? 0 : 1), atStart ? 0 : 1));
7957
7997
  dispatch(tr.scrollIntoView());
7958
7998
  return true;
7959
7999
  }
@@ -7971,8 +8011,8 @@ function sinkListItem(itemType) {
7971
8011
  return false;
7972
8012
  if (dispatch) {
7973
8013
  let nestedBefore = nodeBefore.lastChild && nodeBefore.lastChild.type == parent.type;
7974
- let inner = Fragment2.from(nestedBefore ? itemType.create() : null);
7975
- let slice = new Slice(Fragment2.from(itemType.create(null, Fragment2.from(parent.type.create(null, inner)))), nestedBefore ? 3 : 1, 0);
8014
+ let inner = Fragment3.from(nestedBefore ? itemType.create() : null);
8015
+ let slice = new Slice(Fragment3.from(itemType.create(null, Fragment3.from(parent.type.create(null, inner)))), nestedBefore ? 3 : 1, 0);
7976
8016
  let before = range.start, after = range.end;
7977
8017
  dispatch(state.tr.step(new ReplaceAroundStep(before - (nestedBefore ? 3 : 1), after, before, after, slice, 1, true)).scrollIntoView());
7978
8018
  }
@@ -8591,7 +8631,7 @@ function elementFromString(value) {
8591
8631
  return removeWhitespaces(html);
8592
8632
  }
8593
8633
  function createNodeFromContent(content, schema, options) {
8594
- if (content instanceof Node || content instanceof Fragment2) {
8634
+ if (content instanceof Node || content instanceof Fragment3) {
8595
8635
  return content;
8596
8636
  }
8597
8637
  options = {
@@ -8605,7 +8645,7 @@ function createNodeFromContent(content, schema, options) {
8605
8645
  try {
8606
8646
  const isArrayContent = Array.isArray(content) && content.length > 0;
8607
8647
  if (isArrayContent) {
8608
- return Fragment2.fromArray(content.map((item) => schema.nodeFromJSON(item)));
8648
+ return Fragment3.fromArray(content.map((item) => schema.nodeFromJSON(item)));
8609
8649
  }
8610
8650
  const node = schema.nodeFromJSON(content);
8611
8651
  if (options.errorOnInvalidContent) {
@@ -8752,7 +8792,7 @@ var insertContentAt = (position, value, options) => ({ tr, dispatch, editor }) =
8752
8792
  if (isOnlyTextContent) {
8753
8793
  if (Array.isArray(value)) {
8754
8794
  newContent = value.map((v) => v.text || "").join("");
8755
- } else if (value instanceof Fragment2) {
8795
+ } else if (value instanceof Fragment3) {
8756
8796
  let text = "";
8757
8797
  value.forEach((node) => {
8758
8798
  if (node.text) {
@@ -9232,7 +9272,7 @@ function removeDuplicates(array, by = JSON.stringify) {
9232
9272
  function simplifyChangedRanges(changes) {
9233
9273
  const uniqueChanges = removeDuplicates(changes);
9234
9274
  return uniqueChanges.length === 1 ? uniqueChanges : uniqueChanges.filter((change, index) => {
9235
- const rest = uniqueChanges.filter((_20, i) => i !== index);
9275
+ const rest = uniqueChanges.filter((_18, i) => i !== index);
9236
9276
  return !rest.some((otherChange) => {
9237
9277
  return change.oldRange.from >= otherChange.oldRange.from && change.oldRange.to <= otherChange.oldRange.to && change.newRange.from >= otherChange.newRange.from && change.newRange.to <= otherChange.newRange.to;
9238
9278
  });
@@ -9623,10 +9663,10 @@ var splitListItem = (typeOrName, overrideAttrs = {}) => ({ tr, state, dispatch,
9623
9663
  return false;
9624
9664
  }
9625
9665
  if (dispatch) {
9626
- let wrap2 = Fragment2.empty;
9666
+ let wrap2 = Fragment3.empty;
9627
9667
  const depthBefore = $from.index(-1) ? 1 : $from.index(-2) ? 2 : 3;
9628
9668
  for (let d = $from.depth - depthBefore; d >= $from.depth - 3; d -= 1) {
9629
- wrap2 = Fragment2.from($from.node(d).copy(wrap2));
9669
+ wrap2 = Fragment3.from($from.node(d).copy(wrap2));
9630
9670
  }
9631
9671
  const depthAfter = (
9632
9672
  // eslint-disable-next-line no-nested-ternary
@@ -9637,7 +9677,7 @@ var splitListItem = (typeOrName, overrideAttrs = {}) => ({ tr, state, dispatch,
9637
9677
  ...overrideAttrs
9638
9678
  };
9639
9679
  const nextType2 = ((_a = type.contentMatch.defaultType) == null ? void 0 : _a.createAndFill(newNextTypeAttributes2)) || void 0;
9640
- wrap2 = wrap2.append(Fragment2.from(type.createAndFill(null, nextType2) || void 0));
9680
+ wrap2 = wrap2.append(Fragment3.from(type.createAndFill(null, nextType2) || void 0));
9641
9681
  const start = $from.before($from.depth - (depthBefore - 1));
9642
9682
  tr.replace(start, $from.after(-depthAfter), new Slice(wrap2, 4 - depthBefore, 0));
9643
9683
  let sel = -1;
@@ -10257,7 +10297,7 @@ var Drop = Extension.create({
10257
10297
  new Plugin({
10258
10298
  key: new PluginKey("tiptapDrop"),
10259
10299
  props: {
10260
- handleDrop: (_20, e, slice, moved) => {
10300
+ handleDrop: (_18, e, slice, moved) => {
10261
10301
  this.editor.emit("drop", {
10262
10302
  editor: this.editor,
10263
10303
  event: e,
@@ -11423,804 +11463,224 @@ var AppRichTextEditor = ({
11423
11463
  ] });
11424
11464
  };
11425
11465
  var AppRichTextEditor_default = AppRichTextEditor;
11426
- var AppSearchableMultiSelector = forwardRef(
11466
+ var AppSelectInput = forwardRef(
11427
11467
  ({
11428
11468
  name,
11429
11469
  label,
11430
- multiple = true,
11470
+ mode = "autocomplete",
11431
11471
  options = [],
11432
- setSearchQuery,
11433
11472
  required = false,
11434
- variant = "outlined",
11435
11473
  disabled = false,
11436
- readOnly = false,
11437
- showHelperText = false,
11474
+ showNoneOption = false,
11475
+ noneOptionText = "None",
11438
11476
  helperText,
11439
- maxSelections,
11440
- showSelectedCount = false,
11477
+ variant = "outlined",
11478
+ placeholder,
11479
+ onSearchChange,
11480
+ onChange: externalOnChange,
11441
11481
  sx,
11442
11482
  formControlSx,
11443
11483
  labelSx,
11444
- inputSx,
11445
- textFieldSx,
11446
- autocompleteSx,
11447
- listboxSx,
11448
- optionSx,
11449
- chipSx,
11450
- errorSx,
11451
- helperTextSx,
11452
- selectedCountSx,
11453
- renderInput: externalRenderInput,
11454
- renderOption: externalRenderOption,
11455
- renderTags: externalRenderTags,
11456
- renderGroup: externalRenderGroup,
11457
- labelComponent: LabelComponent = InputLabel,
11458
- inputComponent: InputComponent = "input",
11459
- errorComponent: ErrorComponent = Typography,
11460
- helperTextComponent: HelperTextComponent = FormHelperText,
11461
- labelProps = {},
11462
- inputProps = {},
11463
- textFieldProps = {},
11464
- autocompleteProps = {},
11465
- checkboxProps = {},
11466
- chipProps = {},
11467
- errorProps = {},
11468
- helperTextProps = {},
11469
- className = "",
11470
- formControlClassName = "",
11471
- labelClassName = "",
11472
- inputClassName = "",
11473
- textFieldClassName = "",
11474
- autocompleteClassName = "",
11475
- listboxClassName = "",
11476
- optionClassName = "",
11477
- chipClassName = "",
11478
- errorClassName = "",
11479
- helperTextClassName = "",
11480
- onInputChange: externalOnInputChange,
11481
- onChange: externalOnChange,
11482
- onOpen,
11483
- onClose,
11484
- onBlur: externalOnBlur,
11485
- onFocus: externalOnFocus,
11486
- onClear,
11487
- onMaxSelectionsReached,
11488
- onRemove,
11489
- onAdd,
11490
- ...otherProps
11484
+ searchDebounce = 300,
11485
+ clearable = true
11491
11486
  }, ref) => {
11492
- useTheme();
11487
+ const theme = useTheme();
11493
11488
  const { values, setFieldValue, errors, touched, setFieldTouched } = useFormikContext();
11494
- const fieldError = _19.get(errors, name);
11495
- const isTouched = Boolean(_19.get(touched, name));
11489
+ const fieldError = _17.get(errors, name);
11490
+ const isTouched = Boolean(_17.get(touched, name));
11496
11491
  const hasError = Boolean(fieldError) && isTouched;
11497
- const val = _19.get(values, name);
11498
- const selectedValues = Array.isArray(val) ? val : [];
11499
- const selectedCount = selectedValues.length;
11500
- const handleChange = (event, value, reason, details) => {
11501
- const normalizedValue = (() => {
11502
- if (value === null)
11503
- return [];
11504
- const arr = Array.isArray(value) ? value : [value];
11505
- return arr.map(
11506
- (item) => typeof item === "string" ? { value: item, label: item } : item
11507
- );
11508
- })();
11509
- if (maxSelections && normalizedValue.length > maxSelections) {
11510
- if (onMaxSelectionsReached) {
11511
- onMaxSelectionsReached(maxSelections);
11512
- }
11513
- return;
11514
- }
11515
- if (reason === "selectOption" || reason === "removeOption") {
11516
- const added = normalizedValue.filter(
11517
- (item) => !selectedValues.some((v) => v.value === item.value)
11518
- );
11519
- const removed = selectedValues.filter(
11520
- (item) => !normalizedValue.some((v) => v.value === item.value)
11521
- );
11522
- if (added.length > 0 && onAdd) {
11523
- added.forEach((item) => onAdd(item));
11524
- }
11525
- if (removed.length > 0 && onRemove) {
11526
- removed.forEach((item) => onRemove(item));
11527
- }
11528
- }
11529
- setFieldValue(name, normalizedValue, true);
11492
+ const currentValue = _17.get(values, name);
11493
+ const handleValueChange = (newValue) => {
11494
+ setFieldValue(name, newValue, true);
11530
11495
  if (externalOnChange) {
11531
- externalOnChange(event, normalizedValue, reason);
11496
+ externalOnChange(newValue);
11532
11497
  }
11533
11498
  };
11534
- const handleInputChange = (event, value, reason) => {
11535
- if (setSearchQuery) {
11536
- setSearchQuery(value);
11537
- }
11538
- if (externalOnInputChange) {
11539
- externalOnInputChange(event, value, reason);
11540
- }
11541
- };
11542
- const handleBlur = (event) => {
11499
+ const handleBlur = () => {
11543
11500
  setFieldTouched(name, true, true);
11544
- if (externalOnBlur) {
11545
- externalOnBlur(event);
11546
- }
11547
- };
11548
- const handleFocus = (event) => {
11549
- if (externalOnFocus) {
11550
- externalOnFocus(event);
11551
- }
11552
11501
  };
11553
- const filterOptions = (options2, { inputValue }) => {
11554
- if (!inputValue)
11555
- return options2;
11556
- const inputValueLower = inputValue.toLowerCase();
11557
- return options2.filter(
11558
- (option) => {
11559
- var _a, _b, _c, _d;
11560
- return ((_a = option == null ? void 0 : option.label) == null ? void 0 : _a.toLowerCase().includes(inputValueLower)) || String(option.value).toLowerCase().includes(inputValueLower) || ((_b = option == null ? void 0 : option.searchAbleValue1) == null ? void 0 : _b.toLowerCase().includes(inputValueLower)) || ((_c = option == null ? void 0 : option.searchAbleValue2) == null ? void 0 : _c.toLowerCase().includes(inputValueLower)) || ((_d = option == null ? void 0 : option.searchAbleValue3) == null ? void 0 : _d.toLowerCase().includes(inputValueLower));
11561
- }
11562
- );
11563
- };
11564
- const defaultRenderInput = (params) => /* @__PURE__ */ jsx(
11565
- TextField,
11566
- {
11567
- ...params,
11568
- variant,
11569
- error: hasError,
11570
- helperText: "",
11571
- placeholder: "",
11572
- inputRef: inputProps.ref,
11573
- inputProps: {
11574
- ...params.inputProps,
11575
- ...inputProps,
11576
- className: `${params.inputProps.className || ""} ${inputClassName}`.trim()
11577
- },
11578
- InputProps: {
11579
- ...params.InputProps,
11580
- ...textFieldProps.InputProps,
11581
- className: `${params.InputProps.className || ""} ${textFieldClassName}`.trim()
11582
- },
11583
- sx: [
11584
- {
11585
- "& .MuiOutlinedInput-root": {
11586
- borderRadius: "8px",
11587
- "& fieldset": {
11588
- borderColor: hasError ? "error.main" : "divider"
11589
- },
11590
- "&:hover fieldset": {
11591
- borderColor: hasError ? "error.main" : "text.primary"
11592
- },
11593
- "&.Mui-focused fieldset": {
11594
- borderColor: hasError ? "error.main" : "primary.main"
11595
- },
11596
- "& .MuiInputLabel-root": {
11597
- // Your label styles here
11598
- }
11599
- }
11600
- },
11601
- ...Array.isArray(sx) ? sx : sx ? [sx] : []
11602
- ],
11603
- ...textFieldProps
11604
- }
11605
- );
11606
- const defaultRenderOption = (props, option, { selected }) => /* @__PURE__ */ createElement(
11607
- "li",
11608
- {
11609
- ...props,
11610
- key: option.value,
11611
- className: `${props.className || ""} ${optionClassName}`.trim(),
11612
- style: {
11613
- ...props.style,
11614
- opacity: option.disabled ? 0.5 : 1,
11615
- pointerEvents: option.disabled ? "none" : "auto"
11616
- }
11617
- },
11618
- /* @__PURE__ */ jsx(
11619
- Checkbox,
11620
- {
11621
- checked: selected,
11622
- disabled: option.disabled,
11623
- sx: {
11624
- color: "text.secondary",
11625
- "&.Mui-checked": {
11626
- color: "primary.main"
11627
- },
11628
- "&.Mui-disabled": {
11629
- color: "text.disabled"
11630
- },
11631
- mr: 1,
11632
- ...checkboxProps.sx
11633
- },
11634
- ...checkboxProps
11635
- }
11636
- ),
11637
- option.icon && /* @__PURE__ */ jsx(Box, { component: "span", sx: { mr: 1 }, children: option.icon }),
11638
- /* @__PURE__ */ jsx(
11639
- Typography,
11640
- {
11641
- variant: "body2",
11642
- sx: [
11643
- {
11644
- color: option.disabled ? "text.disabled" : "text.primary",
11645
- ...option.textSx
11646
- },
11647
- ...Array.isArray(optionSx) ? optionSx : [optionSx]
11648
- ],
11649
- children: option.label
11502
+ const selectedOption = options.find((opt) => opt.value === currentValue) || null;
11503
+ if (mode === "autocomplete") {
11504
+ const debouncedSearch = React4.useRef();
11505
+ const handleSearchChange = (query) => {
11506
+ if (debouncedSearch.current) {
11507
+ clearTimeout(debouncedSearch.current);
11650
11508
  }
11651
- )
11652
- );
11653
- const defaultRenderTags = (value, getTagProps) => /* @__PURE__ */ jsx(Box, { sx: { display: "flex", flexWrap: "wrap", gap: 0.5, mt: 0.5 }, children: value.map((option, index) => {
11654
- const { key, ...tagProps } = getTagProps({ index });
11655
- return /* @__PURE__ */ createElement(
11656
- Chip,
11509
+ debouncedSearch.current = setTimeout(() => {
11510
+ if (onSearchChange) {
11511
+ onSearchChange(query);
11512
+ }
11513
+ }, searchDebounce);
11514
+ };
11515
+ const filterOptions = (options2, { inputValue }) => {
11516
+ if (!inputValue)
11517
+ return options2;
11518
+ const inputValueLower = inputValue.toLowerCase();
11519
+ return options2.filter(
11520
+ (option) => option.label.toLowerCase().includes(inputValueLower) || String(option.value).toLowerCase().includes(inputValueLower)
11521
+ );
11522
+ };
11523
+ return /* @__PURE__ */ jsx(Box, { ref, sx, children: /* @__PURE__ */ jsx(
11524
+ FormControl,
11657
11525
  {
11658
- ...tagProps,
11659
- key: option.value,
11660
- label: option.label,
11661
- disabled: disabled || option.disabled,
11662
- sx: [
11526
+ fullWidth: true,
11527
+ error: hasError,
11528
+ disabled,
11529
+ sx: formControlSx,
11530
+ children: /* @__PURE__ */ jsx(
11531
+ Autocomplete,
11663
11532
  {
11664
- height: "24px",
11665
- borderRadius: "4px",
11666
- "& .MuiChip-deleteIcon": {
11667
- color: "text.secondary",
11668
- "&:hover": {
11669
- color: "text.primary"
11670
- }
11533
+ options,
11534
+ value: selectedOption,
11535
+ onChange: (event, newValue) => {
11536
+ handleValueChange((newValue == null ? void 0 : newValue.value) || "");
11671
11537
  },
11672
- ...chipSx
11673
- },
11674
- ...Array.isArray(chipSx) ? chipSx : [chipSx]
11675
- ],
11676
- className: `${chipClassName} ${option.disabled ? "Mui-disabled" : ""}`.trim(),
11677
- ...chipProps
11678
- }
11679
- );
11680
- }) });
11681
- const renderSelectedCount = () => {
11682
- if (!showSelectedCount || !multiple)
11683
- return null;
11684
- return /* @__PURE__ */ jsxs(
11685
- Typography,
11686
- {
11687
- variant: "caption",
11688
- sx: [
11689
- {
11690
- mt: 0.5,
11691
- color: "text.secondary",
11692
- ...selectedCountSx
11693
- },
11694
- ...Array.isArray(selectedCountSx) ? selectedCountSx : [selectedCountSx]
11695
- ],
11696
- children: [
11697
- `${selectedCount} selected`,
11698
- maxSelections ? ` (max ${maxSelections})` : ""
11699
- ]
11700
- }
11701
- );
11702
- };
11703
- return /* @__PURE__ */ jsx(
11704
- Box,
11705
- {
11706
- ref,
11707
- className: `app-searchable-multi-selector ${className}`.trim(),
11708
- sx: [
11709
- {
11710
- width: "100%"
11711
- },
11712
- ...Array.isArray(sx) ? sx : sx ? [sx] : []
11713
- ],
11714
- children: /* @__PURE__ */ jsxs(
11715
- FormControl,
11716
- {
11717
- fullWidth: true,
11718
- error: hasError,
11719
- disabled,
11720
- className: `app-searchable-multi-selector-form-control ${formControlClassName}`.trim(),
11721
- sx: [
11722
- {
11723
- "& .MuiAutocomplete-root": {
11724
- "& .MuiOutlinedInput-root": {
11725
- padding: "4px"
11726
- },
11727
- "& .MuiAutocomplete-input": {
11728
- padding: "8.5px 4px"
11729
- }
11538
+ onInputChange: (event, value, reason) => {
11539
+ if (reason === "input" && onSearchChange) {
11540
+ handleSearchChange(value);
11730
11541
  }
11731
11542
  },
11732
- ...Array.isArray(formControlSx) ? formControlSx : formControlSx ? [formControlSx] : []
11733
- ],
11734
- children: [
11735
- label && /* @__PURE__ */ jsxs(
11736
- LabelComponent,
11543
+ filterOptions,
11544
+ onBlur: handleBlur,
11545
+ disabled,
11546
+ clearOnBlur: false,
11547
+ clearOnEscape: true,
11548
+ disableClearable: !clearable,
11549
+ getOptionLabel: (option) => option.label,
11550
+ isOptionEqualToValue: (option, value) => option.value === value.value,
11551
+ getOptionDisabled: (option) => !!option.disabled,
11552
+ renderInput: (params) => /* @__PURE__ */ jsx(
11553
+ TextField,
11737
11554
  {
11738
- shrink: true,
11739
- htmlFor: `autocomplete-${name}`,
11740
- className: `app-searchable-multi-selector-label ${labelClassName}`.trim(),
11741
- sx: [
11742
- {
11743
- mb: 1,
11744
- color: hasError ? "error.main" : "text.primary",
11745
- "&.Mui-focused": {
11746
- color: hasError ? "error.main" : "primary.main"
11747
- },
11748
- ...Array.isArray(labelSx) ? labelSx : [labelSx]
11749
- }
11750
- ],
11751
- ...labelProps,
11752
- children: [
11555
+ ...params,
11556
+ label: /* @__PURE__ */ jsxs(Fragment, { children: [
11753
11557
  label,
11754
11558
  required && /* @__PURE__ */ jsx(
11755
- Box,
11559
+ Typography,
11756
11560
  {
11561
+ sx: { color: "error.main" },
11757
11562
  component: "span",
11758
- sx: {
11759
- color: "error.main",
11760
- ml: 0.5
11761
- },
11762
- children: "*"
11563
+ children: " *"
11763
11564
  }
11764
11565
  )
11765
- ]
11566
+ ] }),
11567
+ variant,
11568
+ placeholder,
11569
+ error: hasError,
11570
+ helperText: hasError ? fieldError : helperText,
11571
+ FormHelperTextProps: {
11572
+ sx: { mx: 0, mt: 0.5 }
11573
+ }
11766
11574
  }
11767
11575
  ),
11768
- /* @__PURE__ */ jsx(
11769
- Autocomplete,
11770
- {
11771
- multiple,
11772
- id: `autocomplete-${name}`,
11773
- options,
11774
- value: selectedValues,
11775
- filterOptions,
11776
- onInputChange: handleInputChange,
11777
- onChange: handleChange,
11778
- onOpen,
11779
- onClose,
11780
- onBlur: handleBlur,
11781
- onFocus: handleFocus,
11782
- disableCloseOnSelect: multiple,
11783
- readOnly,
11784
- disabled,
11785
- isOptionEqualToValue: (option, value) => option.value === value.value,
11786
- getOptionLabel: (option) => typeof option === "string" ? option : option.label,
11787
- getOptionDisabled: (option) => !!option.disabled,
11788
- renderInput: externalRenderInput || defaultRenderInput,
11789
- renderOption: externalRenderOption || defaultRenderOption,
11790
- renderTags: externalRenderTags || defaultRenderTags,
11791
- renderGroup: externalRenderGroup,
11792
- ListboxProps: {
11793
- className: `app-searchable-multi-selector-listbox ${listboxClassName}`.trim(),
11794
- sx: {
11795
- "& .MuiAutocomplete-option": {
11796
- px: 2,
11797
- py: 1,
11798
- '&[aria-selected="true"]': {
11799
- backgroundColor: "action.selected",
11800
- "&.Mui-focused": {
11801
- backgroundColor: "action.hover"
11802
- }
11803
- },
11804
- "&.Mui-focused": {
11805
- backgroundColor: "action.hover"
11806
- }
11807
- },
11808
- ...Array.isArray(optionSx) ? optionSx : optionSx ? [optionSx] : [],
11809
- ...Array.isArray(listboxSx) ? listboxSx : listboxSx ? [listboxSx] : []
11810
- }
11811
- },
11812
- className: `app-searchable-multi-selector-autocomplete ${autocompleteClassName}`.trim(),
11813
- sx: [
11576
+ renderOption: (props, option) => {
11577
+ const { key, ...restProps } = props;
11578
+ return /* @__PURE__ */ jsxs("li", { ...restProps, children: [
11579
+ option.icon,
11580
+ /* @__PURE__ */ jsx(
11581
+ Typography,
11814
11582
  {
11815
- "& .MuiAutocomplete-tag": {
11816
- margin: 0,
11817
- height: "auto"
11583
+ variant: "body2",
11584
+ sx: {
11585
+ color: option.disabled ? "text.disabled" : "text.primary",
11586
+ ...option.textSx
11818
11587
  },
11819
- "& .MuiAutocomplete-endAdornment": {
11820
- right: 8
11821
- }
11822
- },
11823
- ...Array.isArray(autocompleteSx) ? autocompleteSx : autocompleteSx ? [autocompleteSx] : []
11824
- ],
11825
- ...autocompleteProps,
11826
- ...otherProps
11827
- }
11828
- ),
11829
- (showHelperText || hasError) && /* @__PURE__ */ jsx(
11830
- HelperTextComponent,
11831
- {
11832
- error: hasError,
11833
- sx: [
11834
- {
11835
- mx: 0,
11836
- mt: 0.5,
11837
- ...hasError ? {
11838
- color: "error.main",
11839
- ...errorSx
11840
- } : {
11841
- color: "text.secondary",
11842
- ...helperTextSx
11843
- }
11588
+ children: option.label
11844
11589
  }
11845
- ],
11846
- className: `app-searchable-multi-selector-helper-text ${helperTextClassName} ${hasError ? "Mui-error" : ""}`.trim(),
11847
- ...helperTextProps,
11848
- children: hasError ? fieldError : helperText
11849
- }
11850
- ),
11851
- renderSelectedCount()
11852
- ]
11853
- }
11854
- )
11855
- }
11856
- );
11857
- }
11858
- );
11859
- AppSearchableMultiSelector.displayName = "AppSearchableMultiSelector";
11860
- var AppSearchableMultiSelector_default = AppSearchableMultiSelector;
11861
- function AppSearchableSelectInput({
11862
- name,
11863
- label,
11864
- options = [],
11865
- required = false,
11866
- variant = "outlined",
11867
- placeholder,
11868
- setSearchQuery,
11869
- isResetRequired,
11870
- ...otherProps
11871
- }) {
11872
- const { errors, touched, setFieldValue, values } = useFormikContext();
11873
- const fieldError = _19.get(errors, name);
11874
- const isTouched = _19.get(touched, name);
11875
- const val = _19.get(values, name);
11876
- const selectedOption = options.find((option) => option.value === val) || null;
11877
- const handleChange = (event, newValue) => {
11878
- setFieldValue(name, newValue ? newValue.value : "");
11879
- };
11880
- const handleSearchChange = (event) => {
11881
- const { value } = event.target;
11882
- if (setSearchQuery) {
11883
- setSearchQuery(value);
11884
- }
11885
- };
11886
- return /* @__PURE__ */ jsx(
11887
- FormControl,
11888
- {
11889
- fullWidth: true,
11890
- variant,
11891
- error: isTouched && Boolean(fieldError),
11892
- sx: {
11893
- padding: "0px !important",
11894
- ".MuiAutocomplete-endAdornment": { right: "0 !important" },
11895
- ".MuiInputBase-root": {
11896
- padding: "0px !important",
11897
- pr: "39px !important",
11898
- pl: "10px !important"
11899
- },
11900
- ".MuiOutlinedInput-root": {
11901
- backgroundColor: (theme) => `${theme.palette.common.white} !important`
11902
- }
11903
- },
11904
- children: /* @__PURE__ */ jsx(
11905
- Autocomplete,
11906
- {
11907
- options,
11908
- getOptionLabel: (option) => option.label || String(option.value),
11909
- isOptionEqualToValue: (option, value) => option.value === value.value,
11910
- value: selectedOption,
11911
- onChange: handleChange,
11912
- filterOptions: (options2, { inputValue }) => {
11913
- return options2.filter(
11914
- (option) => {
11915
- var _a, _b, _c, _d;
11916
- return ((_a = option == null ? void 0 : option.label) == null ? void 0 : _a.toLowerCase().includes(inputValue.toLowerCase())) || String(option.value).toLowerCase().includes(inputValue.toLowerCase()) || ((_b = option == null ? void 0 : option.searchAbleValue1) == null ? void 0 : _b.toLowerCase().includes(inputValue.toLowerCase())) || ((_c = option == null ? void 0 : option.searchAbleValue2) == null ? void 0 : _c.toLowerCase().includes(inputValue.toLowerCase())) || ((_d = option == null ? void 0 : option.searchAbleValue3) == null ? void 0 : _d.toLowerCase().includes(inputValue.toLowerCase()));
11917
- }
11918
- );
11919
- },
11920
- renderInput: (params) => /* @__PURE__ */ jsx(
11921
- TextField,
11922
- {
11923
- ...params,
11924
- onChange: handleSearchChange,
11925
- label: /* @__PURE__ */ jsxs(Fragment, { children: [
11926
- label,
11927
- required && /* @__PURE__ */ jsx(Typography, { sx: { color: "red" }, component: "span", children: " *" })
11928
- ] }),
11929
- variant,
11930
- placeholder,
11931
- error: Boolean(fieldError) && isTouched,
11932
- helperText: isTouched && fieldError ? fieldError : "",
11933
- FormHelperTextProps: {
11934
- sx: { color: "#FF5630" }
11935
- },
11936
- sx: {
11937
- "& .MuiInputLabel-root": {
11938
- color: "text.primary"
11939
- },
11940
- "& .MuiInputLabel-root.Mui-focused": {
11941
- color: "text.primary"
11942
- },
11943
- "& .MuiOutlinedInput-input": {
11944
- color: "common.black"
11945
- },
11946
- "& .MuiOutlinedInput-root.Mui-focused .MuiOutlinedInput-notchedOutline": {
11947
- borderColor: "common.white"
11948
- },
11949
- "& .MuiSvgIcon-root": {
11950
- color: "common.black"
11951
- }
11590
+ )
11591
+ ] }, key);
11952
11592
  }
11953
11593
  }
11954
- ),
11955
- ...otherProps
11594
+ )
11956
11595
  }
11957
- )
11596
+ ) });
11958
11597
  }
11959
- );
11960
- }
11961
- var AppSelectInput = forwardRef(
11962
- ({
11963
- name,
11964
- variant = "outlined",
11965
- label,
11966
- fullWidth = true,
11967
- required = false,
11968
- disabled = false,
11969
- readOnly = false,
11970
- options = [],
11971
- showNoneOption = false,
11972
- noneOptionText = "None",
11973
- showHelperText = false,
11974
- helperText,
11975
- sx,
11976
- formControlSx,
11977
- selectSx,
11978
- inputSx,
11979
- labelSx,
11980
- menuPaperSx,
11981
- menuItemSx,
11982
- selectedMenuItemSx,
11983
- errorSx,
11984
- helperTextSx,
11985
- iconSx,
11986
- labelComponent: LabelComponent = InputLabel,
11987
- errorComponent: ErrorComponent = Typography,
11988
- helperTextComponent: HelperTextComponent = FormHelperText,
11989
- onChange: externalOnChange,
11990
- onOpen,
11991
- onClose,
11992
- onBlur: externalOnBlur,
11993
- renderValue,
11994
- renderMenuItem,
11995
- MenuProps,
11996
- inputProps,
11997
- ...otherProps
11998
- }, ref) => {
11999
- const theme = useTheme();
12000
- const { errors, touched, values, setFieldValue, setFieldTouched } = useFormikContext();
12001
- const fieldError = _19.get(errors, name);
12002
- const isTouched = _19.get(touched, name);
12003
- const hasError = Boolean(fieldError) && isTouched;
12004
- const value = _19.get(values, name);
12005
- const handleChange = (event, child) => {
12006
- setFieldValue(name, event.target.value, true);
12007
- if (externalOnChange) {
12008
- externalOnChange(event, child);
12009
- }
12010
- };
12011
- const handleBlur = (event) => {
12012
- setFieldTouched(name, true, true);
12013
- if (externalOnBlur) {
12014
- externalOnBlur(event);
12015
- }
12016
- };
12017
- const renderDefaultMenuItem = (option, index) => {
12018
- const MenuItemComponent = option.component || MenuItem;
12019
- const menuItemProps = option.component ? option.componentProps : {};
12020
- return /* @__PURE__ */ jsxs(
12021
- MenuItemComponent,
11598
+ if (mode === "dropdown") {
11599
+ const handleSelectChange = (event) => {
11600
+ const newValue = event.target.value;
11601
+ handleValueChange(newValue);
11602
+ };
11603
+ return /* @__PURE__ */ jsx(Box, { ref, sx, children: /* @__PURE__ */ jsxs(
11604
+ FormControl,
12022
11605
  {
12023
- value: option.value,
12024
- disabled: option.disabled,
12025
- ...menuItemProps,
12026
- sx: [
12027
- {
12028
- color: "text.primary",
12029
- "&.Mui-selected": {
12030
- backgroundColor: "action.selected",
12031
- "&:hover": {
12032
- backgroundColor: "action.hover"
12033
- },
12034
- ...selectedMenuItemSx
12035
- },
12036
- "&.Mui-disabled": {
12037
- opacity: 0.5,
12038
- pointerEvents: "none"
12039
- },
12040
- ...option.sx
12041
- },
12042
- ...Array.isArray(menuItemSx) ? menuItemSx : [menuItemSx]
12043
- ],
11606
+ fullWidth: true,
11607
+ variant,
11608
+ error: hasError,
11609
+ disabled,
11610
+ sx: formControlSx,
12044
11611
  children: [
12045
- option.icon && /* @__PURE__ */ jsx(Box, { component: "span", sx: { mr: 1 }, children: option.icon }),
12046
- /* @__PURE__ */ jsx(
11612
+ label && /* @__PURE__ */ jsxs(
12047
11613
  Typography,
12048
11614
  {
12049
11615
  variant: "body2",
12050
- sx: [
12051
- {
12052
- color: option.disabled ? "text.disabled" : "text.primary",
12053
- ...option.textSx
12054
- }
12055
- ],
12056
- children: option.label
12057
- }
12058
- )
12059
- ]
12060
- },
12061
- `${option.value}-${index}`
12062
- );
12063
- };
12064
- return /* @__PURE__ */ jsx(
12065
- Box,
12066
- {
12067
- ref,
12068
- className: "app-select-input",
12069
- sx: [
12070
- {
12071
- "& .MuiInputLabel-root": {
12072
- "&.Mui-focused": {
12073
- color: hasError ? "error.main" : "primary.main"
12074
- },
12075
- "&.Mui-disabled": {
12076
- color: "text.disabled"
11616
+ sx: {
11617
+ mb: 1,
11618
+ color: hasError ? "error.main" : "text.secondary",
11619
+ ...labelSx
11620
+ },
11621
+ children: [
11622
+ label,
11623
+ required && /* @__PURE__ */ jsx(Typography, { sx: { color: "error.main" }, component: "span", children: " *" })
11624
+ ]
12077
11625
  }
12078
- }
12079
- },
12080
- ...Array.isArray(formControlSx) ? formControlSx : [formControlSx].filter(Boolean)
12081
- ],
12082
- children: /* @__PURE__ */ jsxs(
12083
- FormControl,
12084
- {
12085
- fullWidth,
12086
- variant,
12087
- error: hasError,
12088
- disabled,
12089
- className: "app-select-form-control",
12090
- sx: [
11626
+ ),
11627
+ /* @__PURE__ */ jsxs(
11628
+ Select,
12091
11629
  {
12092
- "& .MuiInputLabel-root": {
12093
- "&.Mui-focused": {
12094
- color: hasError ? "error.main" : "primary.main"
12095
- },
12096
- "&.Mui-disabled": {
12097
- color: "text.disabled"
11630
+ value: currentValue != null ? currentValue : "",
11631
+ onChange: handleSelectChange,
11632
+ onBlur: handleBlur,
11633
+ displayEmpty: true,
11634
+ renderValue: (selected) => {
11635
+ if (selected === "") {
11636
+ return /* @__PURE__ */ jsx("em", { children: placeholder || noneOptionText });
12098
11637
  }
12099
- }
12100
- },
12101
- ...Array.isArray(formControlSx) ? formControlSx : formControlSx ? [formControlSx] : []
12102
- ],
12103
- children: [
12104
- label && /* @__PURE__ */ jsxs(
12105
- LabelComponent,
12106
- {
12107
- id: `select-${name}-label`,
12108
- htmlFor: `select-${name}`,
12109
- className: "app-select-label",
12110
- sx: [
12111
- {
12112
- color: hasError ? "error.main" : "text.secondary",
12113
- "&.Mui-focused": {
12114
- color: hasError ? "error.main" : "primary.main"
12115
- },
12116
- mb: 1,
12117
- ...Array.isArray(labelSx) ? labelSx : [labelSx]
11638
+ const option = options.find((opt) => opt.value === selected);
11639
+ return (option == null ? void 0 : option.label) || String(selected);
11640
+ },
11641
+ MenuProps: {
11642
+ PaperProps: {
11643
+ sx: {
11644
+ mt: 1,
11645
+ boxShadow: theme.shadows[3],
11646
+ maxHeight: 300
12118
11647
  }
12119
- ],
12120
- children: [
12121
- label,
12122
- required && /* @__PURE__ */ jsx(
12123
- Box,
12124
- {
12125
- component: "span",
12126
- sx: {
12127
- color: "error.main",
12128
- ml: 0.5
12129
- },
12130
- children: "*"
12131
- }
12132
- )
12133
- ]
12134
- }
12135
- ),
12136
- /* @__PURE__ */ jsxs(
12137
- Select,
12138
- {
12139
- variant: "outlined",
12140
- labelId: label ? `select-${name}-label` : void 0,
12141
- id: `select-${name}`,
12142
- name,
12143
- value: value != null ? value : "",
12144
- onChange: handleChange,
12145
- onBlur: handleBlur,
12146
- onOpen,
12147
- onClose,
12148
- renderValue,
12149
- inputProps: {
12150
- readOnly,
12151
- ...inputProps
12152
- },
12153
- MenuProps: {
12154
- PaperProps: {
12155
- sx: [
12156
- {
12157
- mt: 1,
12158
- boxShadow: theme.shadows[3],
12159
- "& .MuiMenuItem-root": {
12160
- px: 2,
12161
- py: 1,
12162
- "&.Mui-selected": {
12163
- backgroundColor: "action.selected",
12164
- "&:hover": {
12165
- backgroundColor: "action.hover"
12166
- }
12167
- }
12168
- },
12169
- ...Array.isArray(menuPaperSx) ? menuPaperSx : [menuPaperSx]
12170
- }
12171
- ]
12172
- },
12173
- ...MenuProps
12174
- },
12175
- sx: [
11648
+ }
11649
+ },
11650
+ children: [
11651
+ showNoneOption && /* @__PURE__ */ jsx(MenuItem, { value: "", children: /* @__PURE__ */ jsx("em", { children: noneOptionText }) }),
11652
+ options.map((option) => /* @__PURE__ */ jsxs(
11653
+ MenuItem,
12176
11654
  {
12177
- // Your base styles here
12178
- "&.Mui-disabled": {
12179
- backgroundColor: "action.disabledBackground",
12180
- "& .MuiOutlinedInput-notchedOutline": {
12181
- borderColor: "action.disabled"
12182
- },
12183
- "& .MuiSelect-icon": {
12184
- color: "action.disabled"
12185
- }
12186
- }
11655
+ value: option.value,
11656
+ disabled: option.disabled,
11657
+ sx: option.sx,
11658
+ children: [
11659
+ option.icon,
11660
+ /* @__PURE__ */ jsx(
11661
+ Typography,
11662
+ {
11663
+ variant: "body2",
11664
+ sx: {
11665
+ color: option.disabled ? "text.disabled" : "text.primary",
11666
+ ...option.textSx
11667
+ },
11668
+ children: option.label
11669
+ }
11670
+ )
11671
+ ]
12187
11672
  },
12188
- ...Array.isArray(selectSx) ? selectSx : selectSx ? [selectSx] : []
12189
- ],
12190
- ...otherProps,
12191
- children: [
12192
- showNoneOption && /* @__PURE__ */ jsx(MenuItem, { value: "", children: /* @__PURE__ */ jsx("em", { children: noneOptionText }) }),
12193
- options.map(
12194
- (option, index) => renderMenuItem ? renderMenuItem(option, index) : renderDefaultMenuItem(option, index)
12195
- )
12196
- ]
12197
- }
12198
- ),
12199
- (showHelperText || hasError) && /* @__PURE__ */ jsx(
12200
- HelperTextComponent,
12201
- {
12202
- error: hasError,
12203
- sx: [
12204
- {
12205
- mx: 0,
12206
- mt: 0.5,
12207
- ...hasError ? {
12208
- color: "error.main",
12209
- ...errorSx
12210
- } : {
12211
- color: "text.secondary",
12212
- ...helperTextSx
12213
- }
12214
- }
12215
- ],
12216
- children: hasError ? fieldError : helperText
12217
- }
12218
- )
12219
- ]
12220
- }
12221
- )
12222
- }
12223
- );
11673
+ option.value
11674
+ ))
11675
+ ]
11676
+ }
11677
+ ),
11678
+ (helperText || hasError) && /* @__PURE__ */ jsx(FormHelperText, { error: hasError, sx: { mx: 0, mt: 0.5 }, children: hasError ? fieldError : helperText })
11679
+ ]
11680
+ }
11681
+ ) });
11682
+ }
11683
+ return null;
12224
11684
  }
12225
11685
  );
12226
11686
  AppSelectInput.displayName = "AppSelectInput";
@@ -12243,8 +11703,8 @@ var AppSimpleUploadFile = ({
12243
11703
  onError
12244
11704
  }) => {
12245
11705
  const { setFieldValue, values, errors, touched } = useFormikContext();
12246
- const fieldValue = _19.get(values, name);
12247
- const fieldError = _19.get(touched, name) ? _19.get(errors, name) : void 0;
11706
+ const fieldValue = _17.get(values, name);
11707
+ const fieldError = _17.get(touched, name) ? _17.get(errors, name) : void 0;
12248
11708
  const handleChange = (event) => {
12249
11709
  const files = event.target.files;
12250
11710
  if (!files || files.length === 0)
@@ -12271,7 +11731,7 @@ var AppSimpleUploadFile = ({
12271
11731
  if (!fieldValue || index < 0 || index >= fieldValue.length)
12272
11732
  return;
12273
11733
  const fileToRemove = fieldValue[index];
12274
- const newFiles = fieldValue.filter((_20, i) => i !== index);
11734
+ const newFiles = fieldValue.filter((_18, i) => i !== index);
12275
11735
  setFieldValue(name, newFiles);
12276
11736
  onRemove == null ? void 0 : onRemove(fileToRemove);
12277
11737
  if (fileToRemove.preview) {
@@ -13823,12 +13283,12 @@ function Placeholder({ sx, ...other }) {
13823
13283
  var AppUploadFile = ({ name, ...rest }) => {
13824
13284
  var _a, _b, _c;
13825
13285
  const { errors, touched, setFieldValue, values } = useFormikContext();
13826
- const fieldError = _19.get(errors, name);
13827
- const isTouched = _19.get(touched, name);
13828
- let val = _19.get(values, name);
13286
+ const fieldError = _17.get(errors, name);
13287
+ const isTouched = _17.get(touched, name);
13288
+ let val = _17.get(values, name);
13829
13289
  if (((_a = rest.multiple) != null ? _a : false) && typeof val === "string") {
13830
13290
  val = val ? [val] : [];
13831
- } else if (!((_b = rest.multiple) != null ? _b : false) && _19.isArray(val)) {
13291
+ } else if (!((_b = rest.multiple) != null ? _b : false) && _17.isArray(val)) {
13832
13292
  val = val[0];
13833
13293
  }
13834
13294
  ((_c = rest.multiple) != null ? _c : false) ? (val != null ? val : []).map((__) => (__ == null ? void 0 : __.file) ? __ == null ? void 0 : __.file : __) : val;
@@ -13985,6 +13445,6 @@ var SubmitButton = ({
13985
13445
  };
13986
13446
  var SubmitButton_default = SubmitButton;
13987
13447
 
13988
- export { AppAutoComplete, AppAutoCompleter, AppCheckBox_default as AppCheckBox, AppDateAndTimePicker_default as AppDateAndTimePicker, AppDatePicker_default as AppDatePicker, AppFormErrorMessage_default as AppFormErrorMessage, AppInputField, AppMultiSelector_default as AppMultiSelector, AppPhoneNoInput_default as AppPhoneNoInput, AppRadioGroup_default as AppRadioGroup, AppRating_default as AppRating, AppRichTextEditor_default as AppRichTextEditor, AppSearchableMultiSelector_default as AppSearchableMultiSelector, AppSearchableSelectInput, AppSelectInput_default as AppSelectInput, AppSimpleUploadFile_default as AppSimpleUploadFile, AppSwitch, AppSwitchInput, AppTagsCreator, AppTextArea_default as AppTextArea, AppUploadFile_default as AppUploadFile, Form_default as Form, Iconify_default as Iconify, SubmitButton_default as SubmitButton };
13448
+ export { AppAutoComplete, AppAutoCompleter, AppCheckBox_default as AppCheckBox, AppDateAndTimePicker_default as AppDateAndTimePicker, AppDatePicker_default as AppDatePicker, AppFormErrorMessage_default as AppFormErrorMessage, AppInputField, AppMultiSelector_default as AppMultiSelector, AppPhoneNoInput_default as AppPhoneNoInput, AppRadioGroup_default as AppRadioGroup, AppRating_default as AppRating, AppRichTextEditor_default as AppRichTextEditor, AppSelectInput_default as AppSelectInput, AppSimpleUploadFile_default as AppSimpleUploadFile, AppSwitch, AppSwitchInput, AppTagsCreator, AppTextArea_default as AppTextArea, AppUploadFile_default as AppUploadFile, Form_default as Form, Iconify_default as Iconify, SubmitButton_default as SubmitButton };
13989
13449
  //# sourceMappingURL=out.js.map
13990
13450
  //# sourceMappingURL=index.mjs.map