formik-form-components 0.2.26 → 0.2.28

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.js CHANGED
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var formik = require('formik');
4
- var react = require('react');
4
+ var React4 = require('react');
5
5
  var material = require('@mui/material');
6
6
  var DatePicker = require('@mui/x-date-pickers/DatePicker');
7
7
  var LocalizationProvider = require('@mui/x-date-pickers/LocalizationProvider');
@@ -12,11 +12,10 @@ var jsxRuntime = require('react/jsx-runtime');
12
12
  var DateTimePicker = require('@mui/x-date-pickers/DateTimePicker');
13
13
  var Autocomplete3 = require('@mui/material/Autocomplete');
14
14
  var Typography9 = require('@mui/material/Typography');
15
- var react$1 = require('@iconify/react');
16
- var Select = require('@mui/material/Select');
15
+ var react = require('@iconify/react');
17
16
  var PhoneInput = require('react-phone-number-input');
18
17
  require('react-phone-number-input/style.css');
19
- var react$2 = require('@tiptap/react');
18
+ var react$1 = require('@tiptap/react');
20
19
  var StarterKit = require('@tiptap/starter-kit');
21
20
  var Link = require('@tiptap/extension-link');
22
21
  var TextAlign = require('@tiptap/extension-text-align');
@@ -42,11 +41,11 @@ var reactI18next = require('react-i18next');
42
41
 
43
42
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
44
43
 
44
+ var React4__default = /*#__PURE__*/_interopDefault(React4);
45
45
  var CalendarMonthIcon__default = /*#__PURE__*/_interopDefault(CalendarMonthIcon);
46
46
  var _19__default = /*#__PURE__*/_interopDefault(_19);
47
47
  var Autocomplete3__default = /*#__PURE__*/_interopDefault(Autocomplete3);
48
48
  var Typography9__default = /*#__PURE__*/_interopDefault(Typography9);
49
- var Select__default = /*#__PURE__*/_interopDefault(Select);
50
49
  var PhoneInput__default = /*#__PURE__*/_interopDefault(PhoneInput);
51
50
  var StarterKit__default = /*#__PURE__*/_interopDefault(StarterKit);
52
51
  var Link__default = /*#__PURE__*/_interopDefault(Link);
@@ -67,7 +66,7 @@ var CloudUploadIcon__default = /*#__PURE__*/_interopDefault(CloudUploadIcon);
67
66
  var CloseIcon__default = /*#__PURE__*/_interopDefault(CloseIcon);
68
67
 
69
68
  // src/Form/index.tsx
70
- var AppDatePicker = react.forwardRef(
69
+ var AppDatePicker = React4.forwardRef(
71
70
  ({
72
71
  name,
73
72
  label,
@@ -111,7 +110,7 @@ var AppDatePicker = react.forwardRef(
111
110
  );
112
111
  AppDatePicker.displayName = "AppDatePicker";
113
112
  var AppDatePicker_default = AppDatePicker;
114
- var AppDateAndTimePicker = react.forwardRef((props, ref) => {
113
+ var AppDateAndTimePicker = React4.forwardRef((props, ref) => {
115
114
  const {
116
115
  name,
117
116
  label,
@@ -368,7 +367,7 @@ function AppFormErrorMessage({
368
367
  return null;
369
368
  }
370
369
  var AppFormErrorMessage_default = AppFormErrorMessage;
371
- var AppTextArea = react.forwardRef(({
370
+ var AppTextArea = React4.forwardRef(({
372
371
  name,
373
372
  label,
374
373
  placeholder = "Enter text...",
@@ -574,7 +573,7 @@ function AppTagsCreator({
574
573
  flexWrap: "wrap",
575
574
  gap: 0.5,
576
575
  ...chipContainerSx
577
- }, children: value == null ? void 0 : value.map((option, index) => /* @__PURE__ */ react.createElement(
576
+ }, children: value == null ? void 0 : value.map((option, index) => /* @__PURE__ */ React4.createElement(
578
577
  material.Chip,
579
578
  {
580
579
  variant: "outlined",
@@ -679,25 +678,30 @@ function AppSwitchInput({
679
678
  material.Box,
680
679
  {
681
680
  className,
682
- sx: [{
683
- display: "flex",
684
- flexDirection: labelPlacement === "start" || labelPlacement === "end" ? "row" : "column",
685
- alignItems: labelPlacement === "start" || labelPlacement === "end" ? "center" : "flex-start",
686
- justifyContent: labelPlacement === "start" || labelPlacement === "end" ? "space-between" : "center",
687
- gap: 1,
688
- my: 1,
689
- ...containerSx
690
- }, sx],
681
+ sx: [
682
+ {
683
+ display: "flex",
684
+ flexDirection: labelPlacement === "start" || labelPlacement === "end" ? "row" : "column",
685
+ alignItems: labelPlacement === "start" || labelPlacement === "end" ? "center" : "flex-start",
686
+ justifyContent: labelPlacement === "start" || labelPlacement === "end" ? "space-between" : "center",
687
+ gap: 1,
688
+ my: 1,
689
+ ...containerSx
690
+ },
691
+ sx
692
+ ],
691
693
  children: [
692
694
  label && /* @__PURE__ */ jsxRuntime.jsx(
693
695
  material.Typography,
694
696
  {
695
697
  variant: "body2",
696
- sx: [{
697
- color: "text.primary",
698
- order: labelPlacement === "start" ? 0 : 1,
699
- ...labelSx
700
- }],
698
+ sx: [
699
+ {
700
+ color: "text.primary",
701
+ order: labelPlacement === "start" ? 0 : 1,
702
+ ...labelSx
703
+ }
704
+ ],
701
705
  children: label
702
706
  }
703
707
  ),
@@ -710,25 +714,27 @@ function AppSwitchInput({
710
714
  onChange: () => {
711
715
  setFieldValue(name, !values[name], true);
712
716
  },
713
- sx: [{
714
- "& .MuiSwitch-switchBase": {
715
- color: "text.secondary",
716
- "&.Mui-checked": {
717
- color: "primary.main",
718
- "& + .MuiSwitch-track": {
719
- backgroundColor: "primary.main",
720
- opacity: 0.5
717
+ sx: [
718
+ {
719
+ "& .MuiSwitch-switchBase": {
720
+ color: "text.secondary",
721
+ "&.Mui-checked": {
722
+ color: "primary.main",
723
+ "& + .MuiSwitch-track": {
724
+ backgroundColor: "primary.main",
725
+ opacity: 0.5
726
+ }
727
+ },
728
+ "&.Mui-disabled": {
729
+ color: "action.disabled",
730
+ "& + .MuiSwitch-track": {
731
+ backgroundColor: "action.disabledBackground"
732
+ }
721
733
  }
722
734
  },
723
- "&.Mui-disabled": {
724
- color: "action.disabled",
725
- "& + .MuiSwitch-track": {
726
- backgroundColor: "action.disabledBackground"
727
- }
728
- }
729
- },
730
- ...switchSx
731
- }],
735
+ ...switchSx
736
+ }
737
+ ],
732
738
  ...otherProps
733
739
  }
734
740
  ),
@@ -736,12 +742,14 @@ function AppSwitchInput({
736
742
  material.Typography,
737
743
  {
738
744
  variant: "caption",
739
- sx: [{
740
- color: "error.main",
741
- display: "block",
742
- mt: 0.5,
743
- ...errorSx
744
- }],
745
+ sx: [
746
+ {
747
+ color: "error.main",
748
+ display: "block",
749
+ mt: 0.5,
750
+ ...errorSx
751
+ }
752
+ ],
745
753
  gutterBottom: true,
746
754
  children: fieldError
747
755
  }
@@ -773,21 +781,26 @@ function AppSwitch({
773
781
  alignItems: labelPlacement === "start" || labelPlacement === "end" ? "center" : "flex-start",
774
782
  justifyContent: labelPlacement === "start" || labelPlacement === "end" ? "space-between" : "center",
775
783
  spacing: 1,
776
- sx: [{
777
- width: "100%",
778
- ...labelPlacement === "top" || labelPlacement === "bottom" ? { alignItems: "flex-start" } : {},
779
- ...containerSx
780
- }, sx],
784
+ sx: [
785
+ {
786
+ width: "100%",
787
+ ...labelPlacement === "top" || labelPlacement === "bottom" ? { alignItems: "flex-start" } : {},
788
+ ...containerSx
789
+ },
790
+ sx
791
+ ],
781
792
  children: [
782
793
  /* @__PURE__ */ jsxRuntime.jsx(
783
794
  material.Typography,
784
795
  {
785
796
  variant: "body2",
786
- sx: [{
787
- color: "text.primary",
788
- order: labelPlacement === "start" ? 0 : 1,
789
- ...labelSx
790
- }],
797
+ sx: [
798
+ {
799
+ color: "text.primary",
800
+ order: labelPlacement === "start" ? 0 : 1,
801
+ ...labelSx
802
+ }
803
+ ],
791
804
  children: label
792
805
  }
793
806
  ),
@@ -799,25 +812,27 @@ function AppSwitch({
799
812
  onChange: () => {
800
813
  setFieldValue(name, !fieldValue, true);
801
814
  },
802
- sx: [{
803
- "& .MuiSwitch-switchBase": {
804
- color: "text.secondary",
805
- "&.Mui-checked": {
806
- color: "primary.main",
807
- "& + .MuiSwitch-track": {
808
- backgroundColor: "primary.main",
809
- opacity: 0.5
815
+ sx: [
816
+ {
817
+ "& .MuiSwitch-switchBase": {
818
+ color: "text.secondary",
819
+ "&.Mui-checked": {
820
+ color: "primary.main",
821
+ "& + .MuiSwitch-track": {
822
+ backgroundColor: "primary.main",
823
+ opacity: 0.5
824
+ }
825
+ },
826
+ "&.Mui-disabled": {
827
+ color: "action.disabled",
828
+ "& + .MuiSwitch-track": {
829
+ backgroundColor: "action.disabledBackground"
830
+ }
810
831
  }
811
832
  },
812
- "&.Mui-disabled": {
813
- color: "action.disabled",
814
- "& + .MuiSwitch-track": {
815
- backgroundColor: "action.disabledBackground"
816
- }
817
- }
818
- },
819
- ...switchSx
820
- }],
833
+ ...switchSx
834
+ }
835
+ ],
821
836
  ...otherProps
822
837
  }
823
838
  ),
@@ -825,12 +840,14 @@ function AppSwitch({
825
840
  material.Typography,
826
841
  {
827
842
  variant: "caption",
828
- sx: [{
829
- color: "error.main",
830
- display: "block",
831
- mt: 0.5,
832
- ...errorSx
833
- }],
843
+ sx: [
844
+ {
845
+ color: "error.main",
846
+ display: "block",
847
+ mt: 0.5,
848
+ ...errorSx
849
+ }
850
+ ],
834
851
  gutterBottom: true,
835
852
  children: fieldError
836
853
  }
@@ -875,7 +892,7 @@ function AppAutoComplete({
875
892
  id: "tags-filled",
876
893
  options,
877
894
  freeSolo: true,
878
- renderTags: (value, getTagProps) => value.map((option, index) => /* @__PURE__ */ react.createElement(
895
+ renderTags: (value, getTagProps) => value.map((option, index) => /* @__PURE__ */ React4.createElement(
879
896
  material.Chip,
880
897
  {
881
898
  variant: "outlined",
@@ -953,7 +970,7 @@ function AppAutoCompleter({
953
970
  onChange: (_20, newValue) => {
954
971
  setFieldValue(name, newValue ? newValue.value : null);
955
972
  },
956
- renderOption: (props, option) => /* @__PURE__ */ react.createElement(material.Box, { component: "li", ...props, key: option.value, sx: listboxSx }, option.label),
973
+ renderOption: (props, option) => /* @__PURE__ */ React4.createElement(material.Box, { component: "li", ...props, key: option.value, sx: listboxSx }, option.label),
957
974
  renderInput: (params) => /* @__PURE__ */ jsxRuntime.jsx(
958
975
  material.TextField,
959
976
  {
@@ -1143,11 +1160,11 @@ var AppCheckBox = ({
1143
1160
  );
1144
1161
  };
1145
1162
  var AppCheckBox_default = AppCheckBox;
1146
- var Iconify = react.forwardRef(({ icon, width = 20, color, sx, ...other }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1163
+ var Iconify = React4.forwardRef(({ icon, width = 20, color, sx, ...other }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1147
1164
  material.Box,
1148
1165
  {
1149
1166
  ref,
1150
- component: react$1.Icon,
1167
+ component: react.Icon,
1151
1168
  icon,
1152
1169
  sx: { width, height: width, flexShrink: 0, color: color || "text.secondary", ...sx || {} },
1153
1170
  ...other
@@ -1167,7 +1184,7 @@ function AppInputField({
1167
1184
  const { errors, getFieldProps, touched } = formik.useFormikContext();
1168
1185
  const fieldError = _19__default.default.get(errors, name);
1169
1186
  const isTouched = _19__default.default.get(touched, name);
1170
- const [showPassword, setShowPassword] = react.useState(false);
1187
+ const [showPassword, setShowPassword] = React4.useState(false);
1171
1188
  const handleShowPassword = () => {
1172
1189
  setShowPassword(!showPassword);
1173
1190
  };
@@ -1225,282 +1242,323 @@ function AppInputField({
1225
1242
  }
1226
1243
  );
1227
1244
  }
1228
- var AppMultiSelector = react.forwardRef(
1245
+ var AppMultiSelector = React4.forwardRef(
1229
1246
  ({
1230
- multiple = true,
1231
1247
  name,
1232
1248
  label,
1249
+ mode = "autocomplete",
1233
1250
  options = [],
1234
1251
  required = false,
1235
- variant = "outlined",
1236
1252
  disabled = false,
1237
1253
  maxSelections,
1238
1254
  showSelectedCount = true,
1239
- showHelperText = false,
1240
1255
  helperText,
1256
+ variant = "outlined",
1257
+ placeholder = "Select options...",
1258
+ onSearchChange,
1259
+ onChange: externalOnChange,
1260
+ onMaxSelectionsReached,
1241
1261
  sx,
1242
1262
  formControlSx,
1243
- selectSx,
1244
1263
  labelSx,
1245
1264
  chipSx,
1246
1265
  checkboxSx,
1247
- menuItemSx,
1248
- errorSx,
1249
- helperTextSx,
1250
- iconSx,
1251
- onChange: externalOnChange,
1252
- onOpen,
1253
- onClose,
1254
- renderValue: externalRenderValue,
1255
- renderMenuItem,
1256
- ...otherProps
1266
+ searchDebounce = 300,
1267
+ clearable = true
1257
1268
  }, ref) => {
1258
1269
  const theme = material.useTheme();
1259
- const { errors, touched, values, setFieldValue, setFieldTouched } = formik.useFormikContext();
1270
+ const { values, setFieldValue, errors, touched, setFieldTouched } = formik.useFormikContext();
1260
1271
  const fieldError = _19__default.default.get(errors, name);
1261
- const isTouched = _19__default.default.get(touched, name);
1262
- const val = _19__default.default.get(values, name);
1263
- const selectedValues = Array.isArray(val) ? val : [];
1264
- const handleChange = (event, child) => {
1265
- const newValue = event.target.value;
1266
- if (maxSelections && newValue.length > maxSelections) {
1272
+ const isTouched = Boolean(_19__default.default.get(touched, name));
1273
+ const hasError = Boolean(fieldError) && isTouched;
1274
+ const currentValue = _19__default.default.get(values, name);
1275
+ const selectedValues = Array.isArray(currentValue) ? currentValue : [];
1276
+ const selectedCount = selectedValues.length;
1277
+ const isMaxReached = maxSelections ? selectedCount >= maxSelections : false;
1278
+ const handleValueChange = (newValues) => {
1279
+ if (maxSelections && newValues.length > maxSelections) {
1280
+ if (onMaxSelectionsReached) {
1281
+ onMaxSelectionsReached(maxSelections);
1282
+ }
1267
1283
  return;
1268
1284
  }
1269
- setFieldValue(name, newValue, true);
1285
+ setFieldValue(name, newValues, true);
1270
1286
  if (externalOnChange) {
1271
- externalOnChange(event, child);
1287
+ externalOnChange(newValues);
1272
1288
  }
1273
1289
  };
1274
1290
  const handleBlur = () => {
1275
1291
  setFieldTouched(name, true, true);
1276
1292
  };
1277
- const defaultRenderValue = (selected) => /* @__PURE__ */ jsxRuntime.jsx(
1278
- material.Box,
1279
- {
1280
- sx: { display: "flex", flexWrap: "wrap", gap: 0.5, minHeight: "24px" },
1281
- children: selected.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx(material.Typography, { variant: "body2", color: "text.secondary", children: "Select options..." }) : selected.map((value) => {
1282
- const option = options.find((obj) => obj.value === value);
1283
- return option ? /* @__PURE__ */ jsxRuntime.jsx(
1284
- material.Chip,
1285
- {
1286
- label: option.label,
1287
- size: "small",
1288
- sx: [
1289
- {
1290
- height: "24px",
1291
- borderRadius: "4px",
1292
- backgroundColor: "action.selected",
1293
- "& .MuiChip-label": {
1294
- px: 1
1295
- },
1296
- ...option.disabled && {
1297
- opacity: 0.6
1298
- }
1299
- },
1300
- chipSx
1301
- ]
1302
- },
1303
- value
1304
- ) : null;
1305
- })
1306
- }
1307
- );
1308
- const defaultRenderMenuItem = (option, isSelected) => /* @__PURE__ */ jsxRuntime.jsxs(
1309
- material.MenuItem,
1310
- {
1311
- value: option.value,
1312
- disabled: option.disabled,
1313
- sx: [
1314
- {
1315
- "&.Mui-selected": {
1316
- backgroundColor: "action.selected",
1317
- "&:hover": {
1318
- backgroundColor: "action.hover"
1319
- }
1320
- },
1321
- "&.Mui-disabled": {
1322
- opacity: 0.5
1323
- },
1324
- ...option.sx
1325
- },
1326
- menuItemSx
1327
- ],
1328
- children: [
1329
- /* @__PURE__ */ jsxRuntime.jsx(
1330
- material.Checkbox,
1331
- {
1332
- checked: isSelected,
1333
- disabled: option.disabled,
1334
- sx: [
1335
- {
1336
- color: "text.secondary",
1337
- "&.Mui-checked": {
1338
- color: "primary.main"
1339
- },
1340
- ...option.disabled && {
1341
- color: "action.disabled"
1342
- }
1293
+ const getSelectedOptions = () => {
1294
+ return options.filter((opt) => selectedValues.includes(opt.value));
1295
+ };
1296
+ if (mode === "autocomplete") {
1297
+ const debouncedSearch = React4__default.default.useRef();
1298
+ const handleSearchChange = (query) => {
1299
+ if (debouncedSearch.current) {
1300
+ clearTimeout(debouncedSearch.current);
1301
+ }
1302
+ debouncedSearch.current = setTimeout(() => {
1303
+ if (onSearchChange) {
1304
+ onSearchChange(query);
1305
+ }
1306
+ }, searchDebounce);
1307
+ };
1308
+ const filterOptions = (options2, { inputValue }) => {
1309
+ if (!inputValue)
1310
+ return options2;
1311
+ const inputValueLower = inputValue.toLowerCase();
1312
+ return options2.filter(
1313
+ (option) => {
1314
+ var _a, _b, _c;
1315
+ return option.label.toLowerCase().includes(inputValueLower) || String(option.value).toLowerCase().includes(inputValueLower) || ((_a = option.searchAbleValue1) == null ? void 0 : _a.toLowerCase().includes(inputValueLower)) || ((_b = option.searchAbleValue2) == null ? void 0 : _b.toLowerCase().includes(inputValueLower)) || ((_c = option.searchAbleValue3) == null ? void 0 : _c.toLowerCase().includes(inputValueLower));
1316
+ }
1317
+ );
1318
+ };
1319
+ const selectedOptions = getSelectedOptions();
1320
+ return /* @__PURE__ */ jsxRuntime.jsx(material.Box, { ref, sx, children: /* @__PURE__ */ jsxRuntime.jsxs(
1321
+ material.FormControl,
1322
+ {
1323
+ fullWidth: true,
1324
+ error: hasError,
1325
+ disabled,
1326
+ sx: formControlSx,
1327
+ children: [
1328
+ /* @__PURE__ */ jsxRuntime.jsx(
1329
+ material.Autocomplete,
1330
+ {
1331
+ multiple: true,
1332
+ options,
1333
+ value: selectedOptions,
1334
+ onChange: (event, newValues) => {
1335
+ const values2 = newValues.map((opt) => opt.value);
1336
+ handleValueChange(values2);
1343
1337
  },
1344
- checkboxSx
1345
- ]
1346
- }
1347
- ),
1348
- /* @__PURE__ */ jsxRuntime.jsx(
1349
- material.Typography,
1350
- {
1351
- variant: "body2",
1352
- sx: [
1353
- {
1354
- color: option.disabled ? "text.disabled" : "text.primary",
1355
- ...option.textSx
1356
- }
1357
- ],
1358
- children: option.label || String(option.value)
1359
- }
1360
- )
1361
- ]
1362
- },
1363
- option.value
1364
- );
1365
- const displayLabel = showSelectedCount && selectedValues.length > 0 ? `${label} (${selectedValues.length} selected)` : label;
1366
- return /* @__PURE__ */ jsxRuntime.jsx(material.Box, { sx, ref, children: /* @__PURE__ */ jsxRuntime.jsxs(
1367
- material.FormControl,
1368
- {
1369
- fullWidth: true,
1370
- variant,
1371
- error: isTouched && Boolean(fieldError),
1372
- disabled,
1373
- sx: [
1374
- {
1375
- "& .MuiInputLabel-root": {
1376
- "&.Mui-focused": {
1377
- color: "primary.main"
1378
- },
1379
- "&.Mui-error": {
1380
- color: "error.main"
1381
- },
1382
- "&.Mui-disabled": {
1383
- color: "text.disabled"
1384
- }
1385
- }
1386
- },
1387
- formControlSx
1388
- ],
1389
- children: [
1390
- label && /* @__PURE__ */ jsxRuntime.jsxs(
1391
- material.InputLabel,
1392
- {
1393
- id: `select-${name}`,
1394
- sx: [
1395
- {
1396
- color: "text.secondary",
1397
- "&.Mui-focused": {
1398
- color: "primary.main"
1399
- },
1400
- "&.Mui-disabled": {
1401
- color: "text.disabled"
1338
+ onInputChange: (event, value, reason) => {
1339
+ if (reason === "input" && onSearchChange) {
1340
+ handleSearchChange(value);
1402
1341
  }
1403
1342
  },
1404
- labelSx
1405
- ],
1406
- children: [
1407
- displayLabel,
1408
- required && /* @__PURE__ */ jsxRuntime.jsx(
1409
- material.Typography,
1343
+ filterOptions,
1344
+ onBlur: handleBlur,
1345
+ disabled: disabled || isMaxReached,
1346
+ disableCloseOnSelect: true,
1347
+ clearOnBlur: false,
1348
+ clearOnEscape: true,
1349
+ disableClearable: !clearable,
1350
+ getOptionLabel: (option) => option.label,
1351
+ isOptionEqualToValue: (option, value) => option.value === value.value,
1352
+ getOptionDisabled: (option) => !!option.disabled,
1353
+ renderInput: (params) => /* @__PURE__ */ jsxRuntime.jsx(
1354
+ material.TextField,
1410
1355
  {
1411
- component: "span",
1412
- sx: {
1413
- color: "error.main",
1414
- ml: 0.5
1415
- },
1416
- children: "*"
1417
- }
1418
- )
1419
- ]
1420
- }
1421
- ),
1422
- /* @__PURE__ */ jsxRuntime.jsx(
1423
- Select__default.default,
1424
- {
1425
- multiple,
1426
- variant: "outlined",
1427
- labelId: label ? `select-${name}` : void 0,
1428
- label: label || void 0,
1429
- value: selectedValues,
1430
- onChange: handleChange,
1431
- onBlur: handleBlur,
1432
- onOpen,
1433
- onClose,
1434
- renderValue: externalRenderValue || defaultRenderValue,
1435
- MenuProps: {
1436
- PaperProps: {
1437
- sx: {
1438
- mt: 1,
1439
- boxShadow: theme.shadows[3],
1440
- "& .MuiMenuItem-root": {
1441
- px: 2,
1442
- py: 1
1356
+ ...params,
1357
+ label: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1358
+ label,
1359
+ required && /* @__PURE__ */ jsxRuntime.jsx(
1360
+ material.Typography,
1361
+ {
1362
+ sx: { color: "error.main" },
1363
+ component: "span",
1364
+ children: " *"
1365
+ }
1366
+ )
1367
+ ] }),
1368
+ variant,
1369
+ placeholder,
1370
+ error: hasError,
1371
+ helperText: hasError ? fieldError : helperText,
1372
+ FormHelperTextProps: {
1373
+ sx: { mx: 0, mt: 0.5 }
1443
1374
  }
1444
1375
  }
1445
- }
1446
- },
1447
- sx: [
1448
- {
1449
- backgroundColor: "background.paper",
1450
- color: "text.primary",
1451
- "& .MuiSvgIcon-root": {
1452
- color: "text.secondary",
1453
- ...iconSx
1454
- },
1455
- "& .MuiSelect-icon": {
1456
- color: "text.secondary"
1457
- },
1458
- "& .MuiOutlinedInput-notchedOutline": {
1459
- borderColor: "divider"
1460
- },
1461
- "&:hover .MuiOutlinedInput-notchedOutline": {
1462
- borderColor: "primary.main"
1463
- },
1464
- "&.Mui-focused .MuiOutlinedInput-notchedOutline": {
1465
- borderColor: "primary.main"
1466
- },
1467
- "&.Mui-error .MuiOutlinedInput-notchedOutline": {
1468
- borderColor: "error.main"
1469
- },
1470
- "&.Mui-disabled": {
1471
- backgroundColor: "action.disabledBackground",
1472
- "& .MuiOutlinedInput-notchedOutline": {
1473
- borderColor: "action.disabled"
1376
+ ),
1377
+ renderOption: (props, option, { selected }) => /* @__PURE__ */ jsxRuntime.jsxs("li", { ...props, children: [
1378
+ /* @__PURE__ */ jsxRuntime.jsx(
1379
+ material.Checkbox,
1380
+ {
1381
+ checked: selected,
1382
+ disabled: option.disabled || isMaxReached && !selected,
1383
+ sx: checkboxSx
1474
1384
  }
1475
- },
1476
- ...selectSx
1477
- }
1478
- ],
1479
- error: Boolean(fieldError) && isTouched,
1480
- ...otherProps,
1481
- children: options.map((option) => {
1482
- const isSelected = selectedValues.includes(option.value);
1483
- return renderMenuItem ? renderMenuItem(option, isSelected) : defaultRenderMenuItem(option, isSelected);
1484
- })
1485
- }
1486
- ),
1487
- (showHelperText || isTouched && fieldError) && /* @__PURE__ */ jsxRuntime.jsx(
1488
- material.FormHelperText,
1489
- {
1490
- sx: [
1491
- {
1492
- mx: 0,
1385
+ ),
1386
+ option.icon,
1387
+ /* @__PURE__ */ jsxRuntime.jsx(
1388
+ material.Typography,
1389
+ {
1390
+ variant: "body2",
1391
+ sx: {
1392
+ color: option.disabled ? "text.disabled" : "text.primary",
1393
+ ...option.textSx
1394
+ },
1395
+ children: option.label
1396
+ }
1397
+ )
1398
+ ] }),
1399
+ renderTags: (value, getTagProps) => /* @__PURE__ */ jsxRuntime.jsx(
1400
+ material.Box,
1401
+ {
1402
+ sx: { display: "flex", flexWrap: "wrap", gap: 0.5, mt: 0.5 },
1403
+ children: value.map((option, index) => /* @__PURE__ */ React4.createElement(
1404
+ material.Chip,
1405
+ {
1406
+ ...getTagProps({ index }),
1407
+ key: option.value,
1408
+ label: option.label,
1409
+ disabled: disabled || option.disabled,
1410
+ sx: chipSx,
1411
+ onDelete: !disabled && !option.disabled ? () => {
1412
+ const newValues = selectedValues.filter(
1413
+ (v) => v !== option.value
1414
+ );
1415
+ handleValueChange(newValues);
1416
+ } : void 0
1417
+ }
1418
+ ))
1419
+ }
1420
+ )
1421
+ }
1422
+ ),
1423
+ showSelectedCount && /* @__PURE__ */ jsxRuntime.jsxs(
1424
+ material.Typography,
1425
+ {
1426
+ variant: "caption",
1427
+ sx: {
1493
1428
  mt: 0.5,
1494
- color: isTouched && fieldError ? "error.main" : "text.secondary",
1495
- ...isTouched && fieldError ? errorSx : helperTextSx
1496
- }
1497
- ],
1498
- children: isTouched && fieldError ? fieldError : helperText
1499
- }
1500
- )
1501
- ]
1502
- }
1503
- ) });
1429
+ color: isMaxReached ? "error.main" : "text.secondary"
1430
+ },
1431
+ children: [
1432
+ selectedCount,
1433
+ " selected",
1434
+ maxSelections ? ` (max ${maxSelections})` : ""
1435
+ ]
1436
+ }
1437
+ )
1438
+ ]
1439
+ }
1440
+ ) });
1441
+ }
1442
+ if (mode === "dropdown") {
1443
+ const handleSelectChange = (event) => {
1444
+ const {
1445
+ target: { value }
1446
+ } = event;
1447
+ const newValues = typeof value === "string" ? value.split(",") : value;
1448
+ handleValueChange(newValues);
1449
+ };
1450
+ return /* @__PURE__ */ jsxRuntime.jsx(material.Box, { ref, sx, children: /* @__PURE__ */ jsxRuntime.jsxs(
1451
+ material.FormControl,
1452
+ {
1453
+ fullWidth: true,
1454
+ variant,
1455
+ error: hasError,
1456
+ disabled,
1457
+ sx: formControlSx,
1458
+ children: [
1459
+ label && /* @__PURE__ */ jsxRuntime.jsxs(
1460
+ material.Typography,
1461
+ {
1462
+ variant: "body2",
1463
+ sx: {
1464
+ mb: 1,
1465
+ color: hasError ? "error.main" : "text.secondary",
1466
+ ...labelSx
1467
+ },
1468
+ children: [
1469
+ label,
1470
+ required && /* @__PURE__ */ jsxRuntime.jsx(material.Typography, { sx: { color: "error.main" }, component: "span", children: " *" })
1471
+ ]
1472
+ }
1473
+ ),
1474
+ /* @__PURE__ */ jsxRuntime.jsx(
1475
+ material.Select,
1476
+ {
1477
+ multiple: true,
1478
+ value: selectedValues,
1479
+ onChange: handleSelectChange,
1480
+ onBlur: handleBlur,
1481
+ displayEmpty: true,
1482
+ renderValue: (selected) => {
1483
+ if (selected.length === 0) {
1484
+ return /* @__PURE__ */ jsxRuntime.jsx("em", { children: placeholder });
1485
+ }
1486
+ return /* @__PURE__ */ jsxRuntime.jsx(material.Box, { sx: { display: "flex", flexWrap: "wrap", gap: 0.5 }, children: selected.map((value) => {
1487
+ const option = options.find((opt) => opt.value === value);
1488
+ return option ? /* @__PURE__ */ jsxRuntime.jsx(
1489
+ material.Chip,
1490
+ {
1491
+ label: option.label,
1492
+ size: "small",
1493
+ sx: chipSx
1494
+ },
1495
+ value
1496
+ ) : null;
1497
+ }) });
1498
+ },
1499
+ MenuProps: {
1500
+ PaperProps: {
1501
+ sx: {
1502
+ mt: 1,
1503
+ boxShadow: theme.shadows[3],
1504
+ maxHeight: 300
1505
+ }
1506
+ }
1507
+ },
1508
+ children: options.map((option) => /* @__PURE__ */ jsxRuntime.jsxs(
1509
+ material.MenuItem,
1510
+ {
1511
+ value: option.value,
1512
+ disabled: option.disabled || isMaxReached && !selectedValues.includes(option.value),
1513
+ sx: option.sx,
1514
+ children: [
1515
+ /* @__PURE__ */ jsxRuntime.jsx(
1516
+ material.Checkbox,
1517
+ {
1518
+ checked: selectedValues.includes(option.value),
1519
+ disabled: option.disabled,
1520
+ sx: checkboxSx
1521
+ }
1522
+ ),
1523
+ option.icon,
1524
+ /* @__PURE__ */ jsxRuntime.jsx(
1525
+ material.Typography,
1526
+ {
1527
+ variant: "body2",
1528
+ sx: {
1529
+ color: option.disabled ? "text.disabled" : "text.primary",
1530
+ ...option.textSx
1531
+ },
1532
+ children: option.label
1533
+ }
1534
+ )
1535
+ ]
1536
+ },
1537
+ option.value
1538
+ ))
1539
+ }
1540
+ ),
1541
+ (helperText || hasError) && /* @__PURE__ */ jsxRuntime.jsx(material.FormHelperText, { error: hasError, sx: { mx: 0, mt: 0.5 }, children: hasError ? fieldError : helperText }),
1542
+ showSelectedCount && /* @__PURE__ */ jsxRuntime.jsxs(
1543
+ material.Typography,
1544
+ {
1545
+ variant: "caption",
1546
+ sx: {
1547
+ mt: 0.5,
1548
+ color: isMaxReached ? "error.main" : "text.secondary"
1549
+ },
1550
+ children: [
1551
+ selectedCount,
1552
+ " selected",
1553
+ maxSelections ? ` (max ${maxSelections})` : ""
1554
+ ]
1555
+ }
1556
+ )
1557
+ ]
1558
+ }
1559
+ ) });
1560
+ }
1561
+ return null;
1504
1562
  }
1505
1563
  );
1506
1564
  AppMultiSelector.displayName = "AppMultiSelector";
@@ -1520,8 +1578,8 @@ var AppPhoneNoInput = ({
1520
1578
  withCountryCallingCode = true
1521
1579
  }) => {
1522
1580
  const { values, errors, touched, setFieldValue, setFieldTouched } = formik.useFormikContext();
1523
- const fieldError = react.useMemo(() => _19__default.default.get(errors, name), [errors, name]);
1524
- const isTouched = react.useMemo(() => _19__default.default.get(touched, name), [touched, name]);
1581
+ const fieldError = React4.useMemo(() => _19__default.default.get(errors, name), [errors, name]);
1582
+ const isTouched = React4.useMemo(() => _19__default.default.get(touched, name), [touched, name]);
1525
1583
  return /* @__PURE__ */ jsxRuntime.jsxs(
1526
1584
  material.Box,
1527
1585
  {
@@ -1612,7 +1670,7 @@ var AppPhoneNoInput = ({
1612
1670
  );
1613
1671
  };
1614
1672
  var AppPhoneNoInput_default = AppPhoneNoInput;
1615
- var AppRadioGroup = react.forwardRef(({
1673
+ var AppRadioGroup = React4.forwardRef(({
1616
1674
  name,
1617
1675
  options = [],
1618
1676
  label,
@@ -1772,7 +1830,7 @@ var AppRadioGroup = react.forwardRef(({
1772
1830
  });
1773
1831
  AppRadioGroup.displayName = "AppRadioGroup";
1774
1832
  var AppRadioGroup_default = AppRadioGroup;
1775
- var AppRating = react.forwardRef(
1833
+ var AppRating = React4.forwardRef(
1776
1834
  ({
1777
1835
  name,
1778
1836
  label,
@@ -2159,7 +2217,7 @@ function findDiffEnd(a, b, posA, posB) {
2159
2217
  posB -= size;
2160
2218
  }
2161
2219
  }
2162
- var Fragment2 = class {
2220
+ var Fragment3 = class {
2163
2221
  /**
2164
2222
  @internal
2165
2223
  */
@@ -2227,7 +2285,7 @@ var Fragment2 = class {
2227
2285
  }
2228
2286
  for (; i < other.content.length; i++)
2229
2287
  content.push(other.content[i]);
2230
- return new Fragment2(content, this.size + other.size);
2288
+ return new Fragment3(content, this.size + other.size);
2231
2289
  }
2232
2290
  /**
2233
2291
  Cut out the sub-fragment between the two given positions.
@@ -2251,17 +2309,17 @@ var Fragment2 = class {
2251
2309
  }
2252
2310
  pos = end;
2253
2311
  }
2254
- return new Fragment2(result, size);
2312
+ return new Fragment3(result, size);
2255
2313
  }
2256
2314
  /**
2257
2315
  @internal
2258
2316
  */
2259
2317
  cutByIndex(from, to) {
2260
2318
  if (from == to)
2261
- return Fragment2.empty;
2319
+ return Fragment3.empty;
2262
2320
  if (from == 0 && to == this.content.length)
2263
2321
  return this;
2264
- return new Fragment2(this.content.slice(from, to));
2322
+ return new Fragment3(this.content.slice(from, to));
2265
2323
  }
2266
2324
  /**
2267
2325
  Create a new fragment in which the node at the given index is
@@ -2274,21 +2332,21 @@ var Fragment2 = class {
2274
2332
  let copy2 = this.content.slice();
2275
2333
  let size = this.size + node.nodeSize - current.nodeSize;
2276
2334
  copy2[index] = node;
2277
- return new Fragment2(copy2, size);
2335
+ return new Fragment3(copy2, size);
2278
2336
  }
2279
2337
  /**
2280
2338
  Create a new fragment by prepending the given node to this
2281
2339
  fragment.
2282
2340
  */
2283
2341
  addToStart(node) {
2284
- return new Fragment2([node].concat(this.content), this.size + node.nodeSize);
2342
+ return new Fragment3([node].concat(this.content), this.size + node.nodeSize);
2285
2343
  }
2286
2344
  /**
2287
2345
  Create a new fragment by appending the given node to this
2288
2346
  fragment.
2289
2347
  */
2290
2348
  addToEnd(node) {
2291
- return new Fragment2(this.content.concat(node), this.size + node.nodeSize);
2349
+ return new Fragment3(this.content.concat(node), this.size + node.nodeSize);
2292
2350
  }
2293
2351
  /**
2294
2352
  Compare this fragment to another one.
@@ -2407,10 +2465,10 @@ var Fragment2 = class {
2407
2465
  */
2408
2466
  static fromJSON(schema, value) {
2409
2467
  if (!value)
2410
- return Fragment2.empty;
2468
+ return Fragment3.empty;
2411
2469
  if (!Array.isArray(value))
2412
2470
  throw new RangeError("Invalid input for Fragment.fromJSON");
2413
- return new Fragment2(value.map(schema.nodeFromJSON));
2471
+ return new Fragment3(value.map(schema.nodeFromJSON));
2414
2472
  }
2415
2473
  /**
2416
2474
  Build a fragment from an array of nodes. Ensures that adjacent
@@ -2418,7 +2476,7 @@ var Fragment2 = class {
2418
2476
  */
2419
2477
  static fromArray(array) {
2420
2478
  if (!array.length)
2421
- return Fragment2.empty;
2479
+ return Fragment3.empty;
2422
2480
  let joined, size = 0;
2423
2481
  for (let i = 0; i < array.length; i++) {
2424
2482
  let node = array[i];
@@ -2431,7 +2489,7 @@ var Fragment2 = class {
2431
2489
  joined.push(node);
2432
2490
  }
2433
2491
  }
2434
- return new Fragment2(joined || array, size);
2492
+ return new Fragment3(joined || array, size);
2435
2493
  }
2436
2494
  /**
2437
2495
  Create a fragment from something that can be interpreted as a
@@ -2441,17 +2499,17 @@ var Fragment2 = class {
2441
2499
  */
2442
2500
  static from(nodes) {
2443
2501
  if (!nodes)
2444
- return Fragment2.empty;
2445
- if (nodes instanceof Fragment2)
2502
+ return Fragment3.empty;
2503
+ if (nodes instanceof Fragment3)
2446
2504
  return nodes;
2447
2505
  if (Array.isArray(nodes))
2448
2506
  return this.fromArray(nodes);
2449
2507
  if (nodes.attrs)
2450
- return new Fragment2([nodes], nodes.nodeSize);
2508
+ return new Fragment3([nodes], nodes.nodeSize);
2451
2509
  throw new RangeError("Can not convert " + nodes + " to a Fragment" + (nodes.nodesBetween ? " (looks like multiple versions of prosemirror-model were loaded)" : ""));
2452
2510
  }
2453
2511
  };
2454
- Fragment2.empty = new Fragment2([], 0);
2512
+ Fragment3.empty = new Fragment3([], 0);
2455
2513
  var found = { index: 0, offset: 0 };
2456
2514
  function retIndex(index, offset) {
2457
2515
  found.index = index;
@@ -2676,7 +2734,7 @@ var Slice = class {
2676
2734
  let openStart = json.openStart || 0, openEnd = json.openEnd || 0;
2677
2735
  if (typeof openStart != "number" || typeof openEnd != "number")
2678
2736
  throw new RangeError("Invalid input for Slice.fromJSON");
2679
- return new Slice(Fragment2.fromJSON(schema, json.content), openStart, openEnd);
2737
+ return new Slice(Fragment3.fromJSON(schema, json.content), openStart, openEnd);
2680
2738
  }
2681
2739
  /**
2682
2740
  Create a slice from a fragment by taking the maximum possible
@@ -2691,7 +2749,7 @@ var Slice = class {
2691
2749
  return new Slice(fragment, openStart, openEnd);
2692
2750
  }
2693
2751
  };
2694
- Slice.empty = new Slice(Fragment2.empty, 0, 0);
2752
+ Slice.empty = new Slice(Fragment3.empty, 0, 0);
2695
2753
  function removeRange(content, from, to) {
2696
2754
  let { index, offset } = content.findIndex(from), child = content.maybeChild(index);
2697
2755
  let { index: indexTo, offset: offsetTo } = content.findIndex(to);
@@ -2789,7 +2847,7 @@ function replaceThreeWay($from, $start, $end, $to, depth) {
2789
2847
  addNode(close(openEnd, replaceTwoWay($end, $to, depth + 1)), content);
2790
2848
  }
2791
2849
  addRange($to, null, depth, content);
2792
- return new Fragment2(content);
2850
+ return new Fragment3(content);
2793
2851
  }
2794
2852
  function replaceTwoWay($from, $to, depth) {
2795
2853
  let content = [];
@@ -2799,13 +2857,13 @@ function replaceTwoWay($from, $to, depth) {
2799
2857
  addNode(close(type, replaceTwoWay($from, $to, depth + 1)), content);
2800
2858
  }
2801
2859
  addRange($to, null, depth, content);
2802
- return new Fragment2(content);
2860
+ return new Fragment3(content);
2803
2861
  }
2804
2862
  function prepareSliceForReplace(slice, $along) {
2805
2863
  let extra = $along.depth - slice.openStart, parent = $along.node(extra);
2806
2864
  let node = parent.copy(slice.content);
2807
2865
  for (let i = extra - 1; i >= 0; i--)
2808
- node = $along.node(i).copy(Fragment2.from(node));
2866
+ node = $along.node(i).copy(Fragment3.from(node));
2809
2867
  return {
2810
2868
  start: node.resolveNoCache(slice.openStart + extra),
2811
2869
  end: node.resolveNoCache(node.content.size - slice.openEnd - extra)
@@ -3144,7 +3202,7 @@ var Node = class {
3144
3202
  this.type = type;
3145
3203
  this.attrs = attrs;
3146
3204
  this.marks = marks;
3147
- this.content = content || Fragment2.empty;
3205
+ this.content = content || Fragment3.empty;
3148
3206
  }
3149
3207
  /**
3150
3208
  The array of this node's child nodes.
@@ -3449,7 +3507,7 @@ var Node = class {
3449
3507
  can optionally pass `start` and `end` indices into the
3450
3508
  replacement fragment.
3451
3509
  */
3452
- canReplace(from, to, replacement = Fragment2.empty, start = 0, end = replacement.childCount) {
3510
+ canReplace(from, to, replacement = Fragment3.empty, start = 0, end = replacement.childCount) {
3453
3511
  let one = this.contentMatchAt(from).matchFragment(replacement, start, end);
3454
3512
  let two = one && one.matchFragment(this.content, to);
3455
3513
  if (!two || !two.validEnd)
@@ -3531,7 +3589,7 @@ var Node = class {
3531
3589
  throw new RangeError("Invalid text node in JSON");
3532
3590
  return schema.text(json.text, marks);
3533
3591
  }
3534
- let content = Fragment2.fromJSON(schema, json.content);
3592
+ let content = Fragment3.fromJSON(schema, json.content);
3535
3593
  let node = schema.nodeType(json.type).create(json.attrs, content, marks);
3536
3594
  node.type.checkAttrs(node.attrs);
3537
3595
  return node;
@@ -3673,7 +3731,7 @@ var ContentMatch = class {
3673
3731
  function search(match, types) {
3674
3732
  let finished = match.matchFragment(after, startIndex);
3675
3733
  if (finished && (!toEnd || finished.validEnd))
3676
- return Fragment2.from(types.map((tp) => tp.createAndFill()));
3734
+ return Fragment3.from(types.map((tp) => tp.createAndFill()));
3677
3735
  for (let i = 0; i < match.next.length; i++) {
3678
3736
  let { type, next } = match.next[i];
3679
3737
  if (!(type.isText || type.hasRequiredAttrs()) && seen.indexOf(next) == -1) {
@@ -4125,7 +4183,7 @@ var NodeType = class {
4125
4183
  create(attrs = null, content, marks) {
4126
4184
  if (this.isText)
4127
4185
  throw new Error("NodeType.create can't construct text nodes");
4128
- return new Node(this, this.computeAttrs(attrs), Fragment2.from(content), Mark.setFrom(marks));
4186
+ return new Node(this, this.computeAttrs(attrs), Fragment3.from(content), Mark.setFrom(marks));
4129
4187
  }
4130
4188
  /**
4131
4189
  Like [`create`](https://prosemirror.net/docs/ref/#model.NodeType.create), but check the given content
@@ -4133,7 +4191,7 @@ var NodeType = class {
4133
4191
  if it doesn't match.
4134
4192
  */
4135
4193
  createChecked(attrs = null, content, marks) {
4136
- content = Fragment2.from(content);
4194
+ content = Fragment3.from(content);
4137
4195
  this.checkContent(content);
4138
4196
  return new Node(this, this.computeAttrs(attrs), content, Mark.setFrom(marks));
4139
4197
  }
@@ -4147,7 +4205,7 @@ var NodeType = class {
4147
4205
  */
4148
4206
  createAndFill(attrs = null, content, marks) {
4149
4207
  attrs = this.computeAttrs(attrs);
4150
- content = Fragment2.from(content);
4208
+ content = Fragment3.from(content);
4151
4209
  if (content.size) {
4152
4210
  let before = this.contentMatch.fillBefore(content);
4153
4211
  if (!before)
@@ -4155,7 +4213,7 @@ var NodeType = class {
4155
4213
  content = before.append(content);
4156
4214
  }
4157
4215
  let matched = this.contentMatch.matchFragment(content);
4158
- let after = matched && matched.fillBefore(Fragment2.empty, true);
4216
+ let after = matched && matched.fillBefore(Fragment3.empty, true);
4159
4217
  if (!after)
4160
4218
  return null;
4161
4219
  return new Node(this, attrs, content.append(after), Mark.setFrom(marks));
@@ -4619,7 +4677,7 @@ var NodeContext = class {
4619
4677
  if (!this.match) {
4620
4678
  if (!this.type)
4621
4679
  return [];
4622
- let fill = this.type.contentMatch.fillBefore(Fragment2.from(node));
4680
+ let fill = this.type.contentMatch.fillBefore(Fragment3.from(node));
4623
4681
  if (fill) {
4624
4682
  this.match = this.type.contentMatch.matchFragment(fill);
4625
4683
  } else {
@@ -4645,9 +4703,9 @@ var NodeContext = class {
4645
4703
  this.content[this.content.length - 1] = text.withText(text.text.slice(0, text.text.length - m2[0].length));
4646
4704
  }
4647
4705
  }
4648
- let content = Fragment2.from(this.content);
4706
+ let content = Fragment3.from(this.content);
4649
4707
  if (!openEnd && this.match)
4650
- content = content.append(this.match.fillBefore(Fragment2.empty, true));
4708
+ content = content.append(this.match.fillBefore(Fragment3.empty, true));
4651
4709
  return this.type ? this.type.create(this.attrs, content, this.marks) : content;
4652
4710
  }
4653
4711
  inlineContext(node) {
@@ -5464,7 +5522,7 @@ function mapFragment(fragment, f, parent) {
5464
5522
  child = f(child, parent, i);
5465
5523
  mapped.push(child);
5466
5524
  }
5467
- return Fragment2.fromArray(mapped);
5525
+ return Fragment3.fromArray(mapped);
5468
5526
  }
5469
5527
  var AddMarkStep = class extends Step {
5470
5528
  /**
@@ -5581,7 +5639,7 @@ var AddNodeMarkStep = class extends Step {
5581
5639
  if (!node)
5582
5640
  return StepResult.fail("No node at mark step's position");
5583
5641
  let updated = node.type.create(node.attrs, null, this.mark.addToSet(node.marks));
5584
- return StepResult.fromReplace(doc2, this.pos, this.pos + 1, new Slice(Fragment2.from(updated), 0, node.isLeaf ? 0 : 1));
5642
+ return StepResult.fromReplace(doc2, this.pos, this.pos + 1, new Slice(Fragment3.from(updated), 0, node.isLeaf ? 0 : 1));
5585
5643
  }
5586
5644
  invert(doc2) {
5587
5645
  let node = doc2.nodeAt(this.pos);
@@ -5627,7 +5685,7 @@ var RemoveNodeMarkStep = class extends Step {
5627
5685
  if (!node)
5628
5686
  return StepResult.fail("No node at mark step's position");
5629
5687
  let updated = node.type.create(node.attrs, null, this.mark.removeFromSet(node.marks));
5630
- return StepResult.fromReplace(doc2, this.pos, this.pos + 1, new Slice(Fragment2.from(updated), 0, node.isLeaf ? 0 : 1));
5688
+ return StepResult.fromReplace(doc2, this.pos, this.pos + 1, new Slice(Fragment3.from(updated), 0, node.isLeaf ? 0 : 1));
5631
5689
  }
5632
5690
  invert(doc2) {
5633
5691
  let node = doc2.nodeAt(this.pos);
@@ -5892,7 +5950,7 @@ function clearIncompatible(tr, pos, parentType, match = parentType.contentMatch,
5892
5950
  let m2, newline = /\r?\n|\r/g, slice;
5893
5951
  while (m2 = newline.exec(child.text)) {
5894
5952
  if (!slice)
5895
- slice = new Slice(Fragment2.from(parentType.schema.text(" ", parentType.allowedMarks(child.marks))), 0, 0);
5953
+ slice = new Slice(Fragment3.from(parentType.schema.text(" ", parentType.allowedMarks(child.marks))), 0, 0);
5896
5954
  replSteps.push(new ReplaceStep(cur + m2.index, cur + m2.index + m2[0].length, slice));
5897
5955
  }
5898
5956
  }
@@ -5900,7 +5958,7 @@ function clearIncompatible(tr, pos, parentType, match = parentType.contentMatch,
5900
5958
  cur = end;
5901
5959
  }
5902
5960
  if (!match.validEnd) {
5903
- let fill = match.fillBefore(Fragment2.empty, true);
5961
+ let fill = match.fillBefore(Fragment3.empty, true);
5904
5962
  tr.replace(cur, cur, new Slice(fill, 0, 0));
5905
5963
  }
5906
5964
  for (let i = replSteps.length - 1; i >= 0; i--)
@@ -5930,20 +5988,20 @@ function lift(tr, range, target) {
5930
5988
  let { $from, $to, depth } = range;
5931
5989
  let gapStart = $from.before(depth + 1), gapEnd = $to.after(depth + 1);
5932
5990
  let start = gapStart, end = gapEnd;
5933
- let before = Fragment2.empty, openStart = 0;
5991
+ let before = Fragment3.empty, openStart = 0;
5934
5992
  for (let d = depth, splitting = false; d > target; d--)
5935
5993
  if (splitting || $from.index(d) > 0) {
5936
5994
  splitting = true;
5937
- before = Fragment2.from($from.node(d).copy(before));
5995
+ before = Fragment3.from($from.node(d).copy(before));
5938
5996
  openStart++;
5939
5997
  } else {
5940
5998
  start--;
5941
5999
  }
5942
- let after = Fragment2.empty, openEnd = 0;
6000
+ let after = Fragment3.empty, openEnd = 0;
5943
6001
  for (let d = depth, splitting = false; d > target; d--)
5944
6002
  if (splitting || $to.after(d + 1) < $to.end(d)) {
5945
6003
  splitting = true;
5946
- after = Fragment2.from($to.node(d).copy(after));
6004
+ after = Fragment3.from($to.node(d).copy(after));
5947
6005
  openEnd++;
5948
6006
  } else {
5949
6007
  end++;
@@ -5983,14 +6041,14 @@ function findWrappingInside(range, type) {
5983
6041
  return inside;
5984
6042
  }
5985
6043
  function wrap(tr, range, wrappers) {
5986
- let content = Fragment2.empty;
6044
+ let content = Fragment3.empty;
5987
6045
  for (let i = wrappers.length - 1; i >= 0; i--) {
5988
6046
  if (content.size) {
5989
6047
  let match = wrappers[i].type.contentMatch.matchFragment(content);
5990
6048
  if (!match || !match.validEnd)
5991
6049
  throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper");
5992
6050
  }
5993
- content = Fragment2.from(wrappers[i].type.create(wrappers[i].attrs, content));
6051
+ content = Fragment3.from(wrappers[i].type.create(wrappers[i].attrs, content));
5994
6052
  }
5995
6053
  let start = range.start, end = range.end;
5996
6054
  tr.step(new ReplaceAroundStep(start, end, start, end, new Slice(content, 0, 0), wrappers.length, true));
@@ -6015,7 +6073,7 @@ function setBlockType(tr, from, to, type, attrs) {
6015
6073
  clearIncompatible(tr, tr.mapping.slice(mapFrom).map(pos, 1), type, void 0, convertNewlines === null);
6016
6074
  let mapping = tr.mapping.slice(mapFrom);
6017
6075
  let startM = mapping.map(pos, 1), endM = mapping.map(pos + node.nodeSize, 1);
6018
- tr.step(new ReplaceAroundStep(startM, endM, startM + 1, endM - 1, new Slice(Fragment2.from(type.create(attrsHere, null, node.marks)), 0, 0), 1, true));
6076
+ tr.step(new ReplaceAroundStep(startM, endM, startM + 1, endM - 1, new Slice(Fragment3.from(type.create(attrsHere, null, node.marks)), 0, 0), 1, true));
6019
6077
  if (convertNewlines === true)
6020
6078
  replaceNewlines(tr, node, pos, mapFrom);
6021
6079
  return false;
@@ -6056,7 +6114,7 @@ function setNodeMarkup(tr, pos, type, attrs, marks) {
6056
6114
  return tr.replaceWith(pos, pos + node.nodeSize, newNode);
6057
6115
  if (!type.validContent(node.content))
6058
6116
  throw new RangeError("Invalid content for node type " + type.name);
6059
- tr.step(new ReplaceAroundStep(pos, pos + node.nodeSize, pos + 1, pos + node.nodeSize - 1, new Slice(Fragment2.from(newNode), 0, 0), 1, true));
6117
+ tr.step(new ReplaceAroundStep(pos, pos + node.nodeSize, pos + 1, pos + node.nodeSize - 1, new Slice(Fragment3.from(newNode), 0, 0), 1, true));
6060
6118
  }
6061
6119
  function canSplit(doc2, pos, depth = 1, typesAfter) {
6062
6120
  let $pos = doc2.resolve(pos), base2 = $pos.depth - depth;
@@ -6080,11 +6138,11 @@ function canSplit(doc2, pos, depth = 1, typesAfter) {
6080
6138
  return $pos.node(base2).canReplaceWith(index, index, baseType ? baseType.type : $pos.node(base2 + 1).type);
6081
6139
  }
6082
6140
  function split(tr, pos, depth = 1, typesAfter) {
6083
- let $pos = tr.doc.resolve(pos), before = Fragment2.empty, after = Fragment2.empty;
6141
+ let $pos = tr.doc.resolve(pos), before = Fragment3.empty, after = Fragment3.empty;
6084
6142
  for (let d = $pos.depth, e = $pos.depth - depth, i = depth - 1; d > e; d--, i--) {
6085
- before = Fragment2.from($pos.node(d).copy(before));
6143
+ before = Fragment3.from($pos.node(d).copy(before));
6086
6144
  let typeAfter = typesAfter && typesAfter[i];
6087
- after = Fragment2.from(typeAfter ? typeAfter.type.create(typeAfter.attrs, after) : $pos.node(d).copy(after));
6145
+ after = Fragment3.from(typeAfter ? typeAfter.type.create(typeAfter.attrs, after) : $pos.node(d).copy(after));
6088
6146
  }
6089
6147
  tr.step(new ReplaceStep(pos, pos, new Slice(before.append(after), depth, depth), true));
6090
6148
  }
@@ -6199,7 +6257,7 @@ var Fitter = class {
6199
6257
  this.$to = $to;
6200
6258
  this.unplaced = unplaced;
6201
6259
  this.frontier = [];
6202
- this.placed = Fragment2.empty;
6260
+ this.placed = Fragment3.empty;
6203
6261
  for (let i = 0; i <= $from.depth; i++) {
6204
6262
  let node = $from.node(i);
6205
6263
  this.frontier.push({
@@ -6208,7 +6266,7 @@ var Fitter = class {
6208
6266
  });
6209
6267
  }
6210
6268
  for (let i = $from.depth; i > 0; i--)
6211
- this.placed = Fragment2.from($from.node(i).copy(this.placed));
6269
+ this.placed = Fragment3.from($from.node(i).copy(this.placed));
6212
6270
  }
6213
6271
  get depth() {
6214
6272
  return this.frontier.length - 1;
@@ -6265,7 +6323,7 @@ var Fitter = class {
6265
6323
  let first2 = fragment.firstChild;
6266
6324
  for (let frontierDepth = this.depth; frontierDepth >= 0; frontierDepth--) {
6267
6325
  let { type, match } = this.frontier[frontierDepth], wrap2, inject = null;
6268
- if (pass == 1 && (first2 ? match.matchType(first2.type) || (inject = match.fillBefore(Fragment2.from(first2), false)) : parent && type.compatibleContent(parent.type)))
6326
+ if (pass == 1 && (first2 ? match.matchType(first2.type) || (inject = match.fillBefore(Fragment3.from(first2), false)) : parent && type.compatibleContent(parent.type)))
6269
6327
  return { sliceDepth, frontierDepth, parent, inject };
6270
6328
  else if (pass == 2 && first2 && (wrap2 = match.findWrapping(first2.type)))
6271
6329
  return { sliceDepth, frontierDepth, parent, wrap: wrap2 };
@@ -6325,7 +6383,7 @@ var Fitter = class {
6325
6383
  let toEnd = taken == fragment.childCount;
6326
6384
  if (!toEnd)
6327
6385
  openEndCount = -1;
6328
- this.placed = addToFragment(this.placed, frontierDepth, Fragment2.from(add));
6386
+ this.placed = addToFragment(this.placed, frontierDepth, Fragment3.from(add));
6329
6387
  this.frontier[frontierDepth].match = match;
6330
6388
  if (toEnd && openEndCount < 0 && parent && parent.type == this.frontier[this.depth].type && this.frontier.length > 1)
6331
6389
  this.closeFrontierNode();
@@ -6382,12 +6440,12 @@ var Fitter = class {
6382
6440
  openFrontierNode(type, attrs = null, content) {
6383
6441
  let top = this.frontier[this.depth];
6384
6442
  top.match = top.match.matchType(type);
6385
- this.placed = addToFragment(this.placed, this.depth, Fragment2.from(type.create(attrs, content)));
6443
+ this.placed = addToFragment(this.placed, this.depth, Fragment3.from(type.create(attrs, content)));
6386
6444
  this.frontier.push({ type, match: type.contentMatch });
6387
6445
  }
6388
6446
  closeFrontierNode() {
6389
6447
  let open = this.frontier.pop();
6390
- let add = open.match.fillBefore(Fragment2.empty, true);
6448
+ let add = open.match.fillBefore(Fragment3.empty, true);
6391
6449
  if (add.childCount)
6392
6450
  this.placed = addToFragment(this.placed, this.frontier.length, add);
6393
6451
  }
@@ -6416,7 +6474,7 @@ function closeNodeStart(node, openStart, openEnd) {
6416
6474
  if (openStart > 0) {
6417
6475
  frag = node.type.contentMatch.fillBefore(frag).append(frag);
6418
6476
  if (openEnd <= 0)
6419
- frag = frag.append(node.type.contentMatch.matchFragment(frag).fillBefore(Fragment2.empty, true));
6477
+ frag = frag.append(node.type.contentMatch.matchFragment(frag).fillBefore(Fragment3.empty, true));
6420
6478
  }
6421
6479
  return node.copy(frag);
6422
6480
  }
@@ -6508,7 +6566,7 @@ function closeFragment(fragment, depth, oldOpen, newOpen, parent) {
6508
6566
  if (depth > newOpen) {
6509
6567
  let match = parent.contentMatchAt(0);
6510
6568
  let start = match.fillBefore(fragment).append(fragment);
6511
- fragment = start.append(match.matchFragment(start).fillBefore(Fragment2.empty, true));
6569
+ fragment = start.append(match.matchFragment(start).fillBefore(Fragment3.empty, true));
6512
6570
  }
6513
6571
  return fragment;
6514
6572
  }
@@ -6518,7 +6576,7 @@ function replaceRangeWith(tr, from, to, node) {
6518
6576
  if (point != null)
6519
6577
  from = to = point;
6520
6578
  }
6521
- tr.replaceRange(from, to, new Slice(Fragment2.from(node), 0, 0));
6579
+ tr.replaceRange(from, to, new Slice(Fragment3.from(node), 0, 0));
6522
6580
  }
6523
6581
  function deleteRange(tr, from, to) {
6524
6582
  let $from = tr.doc.resolve(from), $to = tr.doc.resolve(to);
@@ -6566,7 +6624,7 @@ var AttrStep = class extends Step {
6566
6624
  attrs[name] = node.attrs[name];
6567
6625
  attrs[this.attr] = this.value;
6568
6626
  let updated = node.type.create(attrs, null, node.marks);
6569
- return StepResult.fromReplace(doc2, this.pos, this.pos + 1, new Slice(Fragment2.from(updated), 0, node.isLeaf ? 0 : 1));
6627
+ return StepResult.fromReplace(doc2, this.pos, this.pos + 1, new Slice(Fragment3.from(updated), 0, node.isLeaf ? 0 : 1));
6570
6628
  }
6571
6629
  getMap() {
6572
6630
  return StepMap.empty;
@@ -6701,7 +6759,7 @@ var Transform = class {
6701
6759
  fragment, node, or array of nodes.
6702
6760
  */
6703
6761
  replaceWith(from, to, content) {
6704
- return this.replace(from, to, new Slice(Fragment2.from(content), 0, 0));
6762
+ return this.replace(from, to, new Slice(Fragment3.from(content), 0, 0));
6705
6763
  }
6706
6764
  /**
6707
6765
  Delete the content between the given positions.
@@ -7203,7 +7261,7 @@ var NodeSelection = class extends Selection {
7203
7261
  return new NodeSelection($pos);
7204
7262
  }
7205
7263
  content() {
7206
- return new Slice(Fragment2.from(this.node), 0, 0);
7264
+ return new Slice(Fragment3.from(this.node), 0, 0);
7207
7265
  }
7208
7266
  eq(other) {
7209
7267
  return other instanceof NodeSelection && other.anchor == this.anchor;
@@ -7761,10 +7819,10 @@ function deleteBarrier(state, $cut, dispatch, dir) {
7761
7819
  let canDelAfter = !isolated && $cut.parent.canReplace($cut.index(), $cut.index() + 1);
7762
7820
  if (canDelAfter && (conn = (match = before.contentMatchAt(before.childCount)).findWrapping(after.type)) && match.matchType(conn[0] || after.type).validEnd) {
7763
7821
  if (dispatch) {
7764
- let end = $cut.pos + after.nodeSize, wrap2 = Fragment2.empty;
7822
+ let end = $cut.pos + after.nodeSize, wrap2 = Fragment3.empty;
7765
7823
  for (let i = conn.length - 1; i >= 0; i--)
7766
- wrap2 = Fragment2.from(conn[i].create(null, wrap2));
7767
- wrap2 = Fragment2.from(before.copy(wrap2));
7824
+ wrap2 = Fragment3.from(conn[i].create(null, wrap2));
7825
+ wrap2 = Fragment3.from(before.copy(wrap2));
7768
7826
  let tr = state.tr.step(new ReplaceAroundStep($cut.pos - 1, end, $cut.pos, end, new Slice(wrap2, 1, 0), conn.length, true));
7769
7827
  let $joinAt = tr.doc.resolve(end + 2 * conn.length);
7770
7828
  if ($joinAt.nodeAfter && $joinAt.nodeAfter.type == before.type && canJoin(tr.doc, $joinAt.pos))
@@ -7793,9 +7851,9 @@ function deleteBarrier(state, $cut, dispatch, dir) {
7793
7851
  afterDepth++;
7794
7852
  if (at.canReplace(at.childCount, at.childCount, afterText.content)) {
7795
7853
  if (dispatch) {
7796
- let end = Fragment2.empty;
7854
+ let end = Fragment3.empty;
7797
7855
  for (let i = wrap2.length - 1; i >= 0; i--)
7798
- end = Fragment2.from(wrap2[i].copy(end));
7856
+ end = Fragment3.from(wrap2[i].copy(end));
7799
7857
  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));
7800
7858
  dispatch(tr.scrollIntoView());
7801
7859
  }
@@ -7900,9 +7958,9 @@ function wrapRangeInList(tr, range, listType, attrs = null) {
7900
7958
  return true;
7901
7959
  }
7902
7960
  function doWrapInList(tr, range, wrappers, joinBefore, listType) {
7903
- let content = Fragment2.empty;
7961
+ let content = Fragment3.empty;
7904
7962
  for (let i = wrappers.length - 1; i >= 0; i--)
7905
- content = Fragment2.from(wrappers[i].type.create(wrappers[i].attrs, content));
7963
+ content = Fragment3.from(wrappers[i].type.create(wrappers[i].attrs, content));
7906
7964
  tr.step(new ReplaceAroundStep(range.start - (joinBefore ? 2 : 0), range.end, range.start, range.end, new Slice(content, 0, 0), wrappers.length, true));
7907
7965
  let found2 = 0;
7908
7966
  for (let i = 0; i < wrappers.length; i++)
@@ -7936,7 +7994,7 @@ function liftListItem(itemType) {
7936
7994
  function liftToOuterList(state, dispatch, itemType, range) {
7937
7995
  let tr = state.tr, end = range.end, endOfList = range.$to.end(range.depth);
7938
7996
  if (end < endOfList) {
7939
- tr.step(new ReplaceAroundStep(end - 1, endOfList, end, endOfList, new Slice(Fragment2.from(itemType.create(null, range.parent.copy())), 1, 0), 1, true));
7997
+ tr.step(new ReplaceAroundStep(end - 1, endOfList, end, endOfList, new Slice(Fragment3.from(itemType.create(null, range.parent.copy())), 1, 0), 1, true));
7940
7998
  range = new NodeRange(tr.doc.resolve(range.$from.pos), tr.doc.resolve(endOfList), range.depth);
7941
7999
  }
7942
8000
  const target = liftTarget(range);
@@ -7960,10 +8018,10 @@ function liftOutOfList(state, dispatch, range) {
7960
8018
  return false;
7961
8019
  let atStart = range.startIndex == 0, atEnd = range.endIndex == list.childCount;
7962
8020
  let parent = $start.node(-1), indexBefore = $start.index(-1);
7963
- if (!parent.canReplace(indexBefore + (atStart ? 0 : 1), indexBefore + 1, item.content.append(atEnd ? Fragment2.empty : Fragment2.from(list))))
8021
+ if (!parent.canReplace(indexBefore + (atStart ? 0 : 1), indexBefore + 1, item.content.append(atEnd ? Fragment3.empty : Fragment3.from(list))))
7964
8022
  return false;
7965
8023
  let start = $start.pos, end = start + item.nodeSize;
7966
- 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));
8024
+ 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));
7967
8025
  dispatch(tr.scrollIntoView());
7968
8026
  return true;
7969
8027
  }
@@ -7981,8 +8039,8 @@ function sinkListItem(itemType) {
7981
8039
  return false;
7982
8040
  if (dispatch) {
7983
8041
  let nestedBefore = nodeBefore.lastChild && nodeBefore.lastChild.type == parent.type;
7984
- let inner = Fragment2.from(nestedBefore ? itemType.create() : null);
7985
- let slice = new Slice(Fragment2.from(itemType.create(null, Fragment2.from(parent.type.create(null, inner)))), nestedBefore ? 3 : 1, 0);
8042
+ let inner = Fragment3.from(nestedBefore ? itemType.create() : null);
8043
+ let slice = new Slice(Fragment3.from(itemType.create(null, Fragment3.from(parent.type.create(null, inner)))), nestedBefore ? 3 : 1, 0);
7986
8044
  let before = range.start, after = range.end;
7987
8045
  dispatch(state.tr.step(new ReplaceAroundStep(before - (nestedBefore ? 3 : 1), after, before, after, slice, 1, true)).scrollIntoView());
7988
8046
  }
@@ -8601,7 +8659,7 @@ function elementFromString(value) {
8601
8659
  return removeWhitespaces(html);
8602
8660
  }
8603
8661
  function createNodeFromContent(content, schema, options) {
8604
- if (content instanceof Node || content instanceof Fragment2) {
8662
+ if (content instanceof Node || content instanceof Fragment3) {
8605
8663
  return content;
8606
8664
  }
8607
8665
  options = {
@@ -8615,7 +8673,7 @@ function createNodeFromContent(content, schema, options) {
8615
8673
  try {
8616
8674
  const isArrayContent = Array.isArray(content) && content.length > 0;
8617
8675
  if (isArrayContent) {
8618
- return Fragment2.fromArray(content.map((item) => schema.nodeFromJSON(item)));
8676
+ return Fragment3.fromArray(content.map((item) => schema.nodeFromJSON(item)));
8619
8677
  }
8620
8678
  const node = schema.nodeFromJSON(content);
8621
8679
  if (options.errorOnInvalidContent) {
@@ -8762,7 +8820,7 @@ var insertContentAt = (position, value, options) => ({ tr, dispatch, editor }) =
8762
8820
  if (isOnlyTextContent) {
8763
8821
  if (Array.isArray(value)) {
8764
8822
  newContent = value.map((v) => v.text || "").join("");
8765
- } else if (value instanceof Fragment2) {
8823
+ } else if (value instanceof Fragment3) {
8766
8824
  let text = "";
8767
8825
  value.forEach((node) => {
8768
8826
  if (node.text) {
@@ -9633,10 +9691,10 @@ var splitListItem = (typeOrName, overrideAttrs = {}) => ({ tr, state, dispatch,
9633
9691
  return false;
9634
9692
  }
9635
9693
  if (dispatch) {
9636
- let wrap2 = Fragment2.empty;
9694
+ let wrap2 = Fragment3.empty;
9637
9695
  const depthBefore = $from.index(-1) ? 1 : $from.index(-2) ? 2 : 3;
9638
9696
  for (let d = $from.depth - depthBefore; d >= $from.depth - 3; d -= 1) {
9639
- wrap2 = Fragment2.from($from.node(d).copy(wrap2));
9697
+ wrap2 = Fragment3.from($from.node(d).copy(wrap2));
9640
9698
  }
9641
9699
  const depthAfter = (
9642
9700
  // eslint-disable-next-line no-nested-ternary
@@ -9647,7 +9705,7 @@ var splitListItem = (typeOrName, overrideAttrs = {}) => ({ tr, state, dispatch,
9647
9705
  ...overrideAttrs
9648
9706
  };
9649
9707
  const nextType2 = ((_a = type.contentMatch.defaultType) == null ? void 0 : _a.createAndFill(newNextTypeAttributes2)) || void 0;
9650
- wrap2 = wrap2.append(Fragment2.from(type.createAndFill(null, nextType2) || void 0));
9708
+ wrap2 = wrap2.append(Fragment3.from(type.createAndFill(null, nextType2) || void 0));
9651
9709
  const start = $from.before($from.depth - (depthBefore - 1));
9652
9710
  tr.replace(start, $from.after(-depthAfter), new Slice(wrap2, 4 - depthBefore, 0));
9653
9711
  let sel = -1;
@@ -11087,9 +11145,9 @@ var AppRichTextEditor = ({
11087
11145
  }) => {
11088
11146
  material.useTheme();
11089
11147
  const { values, setFieldValue } = formik.useFormikContext();
11090
- const [linkDialogOpen, setLinkDialogOpen] = react.useState(false);
11091
- const [linkUrl, setLinkUrl] = react.useState("");
11092
- const editor = react$2.useEditor({
11148
+ const [linkDialogOpen, setLinkDialogOpen] = React4.useState(false);
11149
+ const [linkUrl, setLinkUrl] = React4.useState("");
11150
+ const editor = react$1.useEditor({
11093
11151
  extensions: [
11094
11152
  StarterKit__default.default,
11095
11153
  index_default,
@@ -11101,7 +11159,7 @@ var AppRichTextEditor = ({
11101
11159
  setFieldValue(name, editor2.getHTML());
11102
11160
  }
11103
11161
  });
11104
- react.useEffect(() => {
11162
+ React4.useEffect(() => {
11105
11163
  if (editor && values[name] !== editor.getHTML()) {
11106
11164
  editor.commands.setContent(values[name] || "");
11107
11165
  }
@@ -11359,7 +11417,7 @@ var AppRichTextEditor = ({
11359
11417
  ...editorSx
11360
11418
  },
11361
11419
  children: /* @__PURE__ */ jsxRuntime.jsx(
11362
- react$2.EditorContent,
11420
+ react$1.EditorContent,
11363
11421
  {
11364
11422
  editor,
11365
11423
  placeholder: placeholder || "Start typing..."
@@ -11433,7 +11491,7 @@ var AppRichTextEditor = ({
11433
11491
  ] });
11434
11492
  };
11435
11493
  var AppRichTextEditor_default = AppRichTextEditor;
11436
- var AppSearchableMultiSelector = react.forwardRef(
11494
+ var AppSearchableMultiSelector = React4.forwardRef(
11437
11495
  ({
11438
11496
  name,
11439
11497
  label,
@@ -11613,7 +11671,7 @@ var AppSearchableMultiSelector = react.forwardRef(
11613
11671
  ...textFieldProps
11614
11672
  }
11615
11673
  );
11616
- const defaultRenderOption = (props, option, { selected }) => /* @__PURE__ */ react.createElement(
11674
+ const defaultRenderOption = (props, option, { selected }) => /* @__PURE__ */ React4.createElement(
11617
11675
  "li",
11618
11676
  {
11619
11677
  ...props,
@@ -11662,7 +11720,7 @@ var AppSearchableMultiSelector = react.forwardRef(
11662
11720
  );
11663
11721
  const defaultRenderTags = (value, getTagProps) => /* @__PURE__ */ jsxRuntime.jsx(material.Box, { sx: { display: "flex", flexWrap: "wrap", gap: 0.5, mt: 0.5 }, children: value.map((option, index) => {
11664
11722
  const { key, ...tagProps } = getTagProps({ index });
11665
- return /* @__PURE__ */ react.createElement(
11723
+ return /* @__PURE__ */ React4.createElement(
11666
11724
  material.Chip,
11667
11725
  {
11668
11726
  ...tagProps,
@@ -11868,743 +11926,324 @@ var AppSearchableMultiSelector = react.forwardRef(
11868
11926
  );
11869
11927
  AppSearchableMultiSelector.displayName = "AppSearchableMultiSelector";
11870
11928
  var AppSearchableMultiSelector_default = AppSearchableMultiSelector;
11871
- var AppSearchableMultiSelector2 = react.forwardRef((props, ref) => {
11872
- const {
11929
+ function AppSearchableSelectInput({
11930
+ name,
11931
+ label,
11932
+ options = [],
11933
+ required = false,
11934
+ variant = "outlined",
11935
+ placeholder,
11936
+ setSearchQuery,
11937
+ isResetRequired,
11938
+ ...otherProps
11939
+ }) {
11940
+ const { errors, touched, setFieldValue, values } = formik.useFormikContext();
11941
+ const fieldError = _19__default.default.get(errors, name);
11942
+ const isTouched = _19__default.default.get(touched, name);
11943
+ const val = _19__default.default.get(values, name);
11944
+ const selectedOption = options.find((option) => option.value === val) || null;
11945
+ const handleChange = (event, newValue) => {
11946
+ setFieldValue(name, newValue ? newValue.value : "");
11947
+ };
11948
+ const handleSearchChange = (event) => {
11949
+ const { value } = event.target;
11950
+ if (setSearchQuery) {
11951
+ setSearchQuery(value);
11952
+ }
11953
+ };
11954
+ return /* @__PURE__ */ jsxRuntime.jsx(
11955
+ material.FormControl,
11956
+ {
11957
+ fullWidth: true,
11958
+ variant,
11959
+ error: isTouched && Boolean(fieldError),
11960
+ sx: {
11961
+ padding: "0px !important",
11962
+ ".MuiAutocomplete-endAdornment": { right: "0 !important" },
11963
+ ".MuiInputBase-root": {
11964
+ padding: "0px !important",
11965
+ pr: "39px !important",
11966
+ pl: "10px !important"
11967
+ },
11968
+ ".MuiOutlinedInput-root": {
11969
+ backgroundColor: (theme) => `${theme.palette.common.white} !important`
11970
+ }
11971
+ },
11972
+ children: /* @__PURE__ */ jsxRuntime.jsx(
11973
+ material.Autocomplete,
11974
+ {
11975
+ options,
11976
+ getOptionLabel: (option) => option.label || String(option.value),
11977
+ isOptionEqualToValue: (option, value) => option.value === value.value,
11978
+ value: selectedOption,
11979
+ onChange: handleChange,
11980
+ filterOptions: (options2, { inputValue }) => {
11981
+ return options2.filter(
11982
+ (option) => {
11983
+ var _a, _b, _c, _d;
11984
+ 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()));
11985
+ }
11986
+ );
11987
+ },
11988
+ renderInput: (params) => /* @__PURE__ */ jsxRuntime.jsx(
11989
+ material.TextField,
11990
+ {
11991
+ ...params,
11992
+ onChange: handleSearchChange,
11993
+ label: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
11994
+ label,
11995
+ required && /* @__PURE__ */ jsxRuntime.jsx(material.Typography, { sx: { color: "red" }, component: "span", children: " *" })
11996
+ ] }),
11997
+ variant,
11998
+ placeholder,
11999
+ error: Boolean(fieldError) && isTouched,
12000
+ helperText: isTouched && fieldError ? fieldError : "",
12001
+ FormHelperTextProps: {
12002
+ sx: { color: "#FF5630" }
12003
+ },
12004
+ sx: {
12005
+ "& .MuiInputLabel-root": {
12006
+ color: "text.primary"
12007
+ },
12008
+ "& .MuiInputLabel-root.Mui-focused": {
12009
+ color: "text.primary"
12010
+ },
12011
+ "& .MuiOutlinedInput-input": {
12012
+ color: "common.black"
12013
+ },
12014
+ "& .MuiOutlinedInput-root.Mui-focused .MuiOutlinedInput-notchedOutline": {
12015
+ borderColor: "common.white"
12016
+ },
12017
+ "& .MuiSvgIcon-root": {
12018
+ color: "common.black"
12019
+ }
12020
+ }
12021
+ }
12022
+ ),
12023
+ ...otherProps
12024
+ }
12025
+ )
12026
+ }
12027
+ );
12028
+ }
12029
+ var AppSelectInput = React4.forwardRef(
12030
+ ({
11873
12031
  name,
11874
12032
  label,
11875
- multiple = true,
12033
+ mode = "autocomplete",
11876
12034
  options = [],
11877
- setSearchQuery,
11878
12035
  required = false,
11879
- variant = "outlined",
11880
12036
  disabled = false,
11881
- readOnly = false,
11882
- showHelperText = false,
12037
+ showNoneOption = false,
12038
+ noneOptionText = "None",
11883
12039
  helperText,
11884
- maxSelections,
11885
- showSelectedCount = false,
12040
+ variant = "outlined",
12041
+ placeholder,
12042
+ onSearchChange,
12043
+ onChange: externalOnChange,
11886
12044
  sx,
11887
12045
  formControlSx,
11888
12046
  labelSx,
11889
- inputSx,
11890
- textFieldSx,
11891
- autocompleteSx,
11892
- listboxSx,
11893
- optionSx,
11894
- chipSx,
11895
- errorSx,
11896
- helperTextSx,
11897
- selectedCountSx,
11898
- renderInput: externalRenderInput,
11899
- renderOption: externalRenderOption,
11900
- renderTags: externalRenderTags,
11901
- renderGroup: externalRenderGroup,
11902
- labelComponent: LabelComponent = material.InputLabel,
11903
- inputComponent: InputComponent = "input",
11904
- errorComponent: ErrorComponent = material.Typography,
11905
- helperTextComponent: HelperTextComponent = material.FormHelperText,
11906
- labelProps = {},
11907
- inputProps = {},
11908
- textFieldProps = {},
11909
- autocompleteProps = {},
11910
- checkboxProps = {},
11911
- chipProps = {},
11912
- errorProps = {},
11913
- helperTextProps = {},
11914
- className = "",
11915
- formControlClassName = "",
11916
- labelClassName = "",
11917
- inputClassName = "",
11918
- textFieldClassName = "",
11919
- autocompleteClassName = "",
11920
- listboxClassName = "",
11921
- optionClassName = "",
11922
- chipClassName = "",
11923
- errorClassName = "",
11924
- helperTextClassName = "",
11925
- onInputChange: externalOnInputChange,
11926
- onChange: externalOnChange,
11927
- onOpen,
11928
- onClose,
11929
- onBlur: externalOnBlur,
11930
- onFocus: externalOnFocus,
11931
- onClear,
11932
- onMaxSelectionsReached,
11933
- onRemove,
11934
- onAdd,
11935
- ...otherProps
11936
- } = props;
11937
- material.useTheme();
11938
- const { values, setFieldValue, errors, touched, setFieldTouched } = formik.useFormikContext();
11939
- const fieldError = _19__default.default.get(errors, name);
11940
- const isTouched = Boolean(_19__default.default.get(touched, name));
11941
- const hasError = Boolean(fieldError) && isTouched;
11942
- const val = _19__default.default.get(values, name);
11943
- const selectedValues = Array.isArray(val) ? val : [];
11944
- const selectedCount = selectedValues.length;
11945
- const handleChange = react.useCallback(
11946
- (event, value, reason, details) => {
11947
- const normalizedValue = (() => {
11948
- if (value === null)
11949
- return [];
11950
- const arr = Array.isArray(value) ? value : [value];
11951
- return arr.map(
11952
- (item) => typeof item === "string" ? { value: item, label: item } : item
11953
- );
11954
- })();
11955
- if (maxSelections && normalizedValue.length > maxSelections) {
11956
- onMaxSelectionsReached == null ? void 0 : onMaxSelectionsReached(maxSelections);
11957
- return;
11958
- }
11959
- if (reason === "selectOption" || reason === "removeOption") {
11960
- const added = normalizedValue.filter(
11961
- (item) => !selectedValues.some((v) => v.value === item.value)
11962
- );
11963
- const removed = selectedValues.filter(
11964
- (item) => !normalizedValue.some((v) => v.value === item.value)
11965
- );
11966
- added.forEach((item) => onAdd == null ? void 0 : onAdd(item));
11967
- removed.forEach((item) => onRemove == null ? void 0 : onRemove(item));
12047
+ searchDebounce = 300,
12048
+ clearable = true
12049
+ }, ref) => {
12050
+ const theme = material.useTheme();
12051
+ const { values, setFieldValue, errors, touched, setFieldTouched } = formik.useFormikContext();
12052
+ const fieldError = _19__default.default.get(errors, name);
12053
+ const isTouched = Boolean(_19__default.default.get(touched, name));
12054
+ const hasError = Boolean(fieldError) && isTouched;
12055
+ const currentValue = _19__default.default.get(values, name);
12056
+ const handleValueChange = (newValue) => {
12057
+ setFieldValue(name, newValue, true);
12058
+ if (externalOnChange) {
12059
+ externalOnChange(newValue);
11968
12060
  }
11969
- setFieldValue(name, normalizedValue, true);
11970
- externalOnChange == null ? void 0 : externalOnChange(event, normalizedValue, reason);
11971
- },
11972
- [
11973
- maxSelections,
11974
- selectedValues,
11975
- setFieldValue,
11976
- name,
11977
- onMaxSelectionsReached,
11978
- onAdd,
11979
- onRemove,
11980
- externalOnChange
11981
- ]
11982
- );
11983
- const handleInputChange = react.useCallback(
11984
- (event, value, reason) => {
11985
- setSearchQuery == null ? void 0 : setSearchQuery(value);
11986
- externalOnInputChange == null ? void 0 : externalOnInputChange(event, value, reason);
11987
- },
11988
- [setSearchQuery, externalOnInputChange]
11989
- );
11990
- const handleBlur = react.useCallback(
11991
- (event) => {
12061
+ };
12062
+ const handleBlur = () => {
11992
12063
  setFieldTouched(name, true, true);
11993
- externalOnBlur == null ? void 0 : externalOnBlur(event);
11994
- },
11995
- [name, setFieldTouched, externalOnBlur]
11996
- );
11997
- const handleFocus = react.useCallback(
11998
- (event) => {
11999
- externalOnFocus == null ? void 0 : externalOnFocus(event);
12000
- },
12001
- [externalOnFocus]
12002
- );
12003
- const filterOptions = react.useCallback(
12004
- (options2, { inputValue }) => {
12005
- if (!inputValue)
12006
- return options2;
12007
- const inputValueLower = inputValue.toLowerCase();
12008
- return options2.filter(
12009
- (option) => {
12010
- var _a, _b, _c, _d;
12011
- 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));
12064
+ };
12065
+ const selectedOption = options.find((opt) => opt.value === currentValue) || null;
12066
+ if (mode === "autocomplete") {
12067
+ const debouncedSearch = React4__default.default.useRef();
12068
+ const handleSearchChange = (query) => {
12069
+ if (debouncedSearch.current) {
12070
+ clearTimeout(debouncedSearch.current);
12012
12071
  }
12013
- );
12014
- },
12015
- []
12016
- );
12017
- const defaultRenderInput = react.useCallback(
12018
- (params) => /* @__PURE__ */ jsxRuntime.jsx(
12019
- material.TextField,
12020
- {
12021
- ...params,
12022
- variant,
12023
- error: hasError,
12024
- helperText: "",
12025
- placeholder: "",
12026
- inputRef: inputProps.ref,
12027
- inputProps: {
12028
- ...params.inputProps,
12029
- ...inputProps,
12030
- className: `${params.inputProps.className || ""} ${inputClassName}`.trim()
12031
- },
12032
- InputProps: {
12033
- ...params.InputProps,
12034
- ...textFieldProps.InputProps,
12035
- className: `${params.InputProps.className || ""} ${textFieldClassName}`.trim()
12036
- },
12037
- sx: [
12038
- {
12039
- "& .MuiOutlinedInput-root": {
12040
- borderRadius: "8px",
12041
- "& fieldset": {
12042
- borderColor: hasError ? "error.main" : "divider"
12043
- },
12044
- "&:hover fieldset": {
12045
- borderColor: hasError ? "error.main" : "text.primary"
12046
- },
12047
- "&.Mui-focused fieldset": {
12048
- borderColor: hasError ? "error.main" : "primary.main"
12049
- }
12050
- }
12051
- },
12052
- ...Array.isArray(textFieldSx) ? textFieldSx : textFieldSx ? [textFieldSx] : []
12053
- ],
12054
- ...textFieldProps
12055
- }
12056
- ),
12057
- [
12058
- variant,
12059
- hasError,
12060
- inputProps,
12061
- inputClassName,
12062
- textFieldProps,
12063
- textFieldClassName,
12064
- textFieldSx
12065
- ]
12066
- );
12067
- const defaultRenderOption = react.useCallback(
12068
- (props2, option, { selected }) => /* @__PURE__ */ react.createElement(
12069
- "li",
12070
- {
12071
- ...props2,
12072
- key: option.value,
12073
- className: `${props2.className || ""} ${optionClassName}`.trim(),
12074
- style: {
12075
- ...props2.style,
12076
- opacity: option.disabled ? 0.5 : 1,
12077
- pointerEvents: option.disabled ? "none" : "auto"
12078
- }
12079
- },
12080
- /* @__PURE__ */ jsxRuntime.jsx(
12081
- material.Checkbox,
12082
- {
12083
- checked: selected,
12084
- disabled: option.disabled,
12085
- sx: {
12086
- color: "text.secondary",
12087
- "&.Mui-checked": {
12088
- color: "primary.main"
12089
- },
12090
- "&.Mui-disabled": {
12091
- color: "text.disabled"
12092
- },
12093
- mr: 1,
12094
- ...checkboxProps.sx
12095
- },
12096
- ...checkboxProps
12097
- }
12098
- ),
12099
- option.icon && /* @__PURE__ */ jsxRuntime.jsx(material.Box, { component: "span", sx: { mr: 1 }, children: option.icon }),
12100
- /* @__PURE__ */ jsxRuntime.jsx(
12101
- material.Typography,
12102
- {
12103
- variant: "body2",
12104
- sx: [
12105
- {
12106
- color: option.disabled ? "text.disabled" : "text.primary",
12107
- ...option.textSx
12108
- },
12109
- ...Array.isArray(optionSx) ? optionSx : [optionSx]
12110
- ],
12111
- children: option.label
12112
- }
12113
- )
12114
- ),
12115
- [optionClassName, checkboxProps, optionSx]
12116
- );
12117
- const defaultRenderTags = react.useCallback(
12118
- (value, getTagProps) => /* @__PURE__ */ jsxRuntime.jsx(material.Box, { sx: { display: "flex", flexWrap: "wrap", gap: 0.5, mt: 0.5 }, children: value.map((option, index) => {
12119
- const { key, ...tagProps } = getTagProps({ index });
12120
- return /* @__PURE__ */ react.createElement(
12121
- material.Chip,
12072
+ debouncedSearch.current = setTimeout(() => {
12073
+ if (onSearchChange) {
12074
+ onSearchChange(query);
12075
+ }
12076
+ }, searchDebounce);
12077
+ };
12078
+ const filterOptions = (options2, { inputValue }) => {
12079
+ if (!inputValue)
12080
+ return options2;
12081
+ const inputValueLower = inputValue.toLowerCase();
12082
+ return options2.filter(
12083
+ (option) => {
12084
+ var _a, _b, _c;
12085
+ return option.label.toLowerCase().includes(inputValueLower) || String(option.value).toLowerCase().includes(inputValueLower) || ((_a = option.searchAbleValue1) == null ? void 0 : _a.toLowerCase().includes(inputValueLower)) || ((_b = option.searchAbleValue2) == null ? void 0 : _b.toLowerCase().includes(inputValueLower)) || ((_c = option.searchAbleValue3) == null ? void 0 : _c.toLowerCase().includes(inputValueLower));
12086
+ }
12087
+ );
12088
+ };
12089
+ return /* @__PURE__ */ jsxRuntime.jsx(material.Box, { ref, sx, children: /* @__PURE__ */ jsxRuntime.jsx(
12090
+ material.FormControl,
12122
12091
  {
12123
- ...tagProps,
12124
- key: option.value,
12125
- label: option.label,
12126
- disabled: disabled || option.disabled,
12127
- sx: [
12092
+ fullWidth: true,
12093
+ error: hasError,
12094
+ disabled,
12095
+ sx: formControlSx,
12096
+ children: /* @__PURE__ */ jsxRuntime.jsx(
12097
+ material.Autocomplete,
12128
12098
  {
12129
- height: "24px",
12130
- borderRadius: "4px",
12131
- "& .MuiChip-deleteIcon": {
12132
- color: "text.secondary",
12133
- "&:hover": {
12134
- color: "text.primary"
12099
+ options,
12100
+ value: selectedOption,
12101
+ onChange: (event, newValue) => {
12102
+ handleValueChange((newValue == null ? void 0 : newValue.value) || "");
12103
+ },
12104
+ onInputChange: (event, value, reason) => {
12105
+ if (reason === "input" && onSearchChange) {
12106
+ handleSearchChange(value);
12135
12107
  }
12136
- }
12137
- },
12138
- ...Array.isArray(chipSx) ? chipSx : [chipSx]
12139
- ],
12140
- className: `${chipClassName} ${option.disabled ? "Mui-disabled" : ""}`.trim(),
12141
- ...chipProps
12108
+ },
12109
+ filterOptions,
12110
+ onBlur: handleBlur,
12111
+ disabled,
12112
+ clearOnBlur: false,
12113
+ clearOnEscape: true,
12114
+ disableClearable: !clearable,
12115
+ getOptionLabel: (option) => option.label,
12116
+ isOptionEqualToValue: (option, value) => option.value === value.value,
12117
+ getOptionDisabled: (option) => !!option.disabled,
12118
+ renderInput: (params) => /* @__PURE__ */ jsxRuntime.jsx(
12119
+ material.TextField,
12120
+ {
12121
+ ...params,
12122
+ label: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
12123
+ label,
12124
+ required && /* @__PURE__ */ jsxRuntime.jsx(
12125
+ material.Typography,
12126
+ {
12127
+ sx: { color: "error.main" },
12128
+ component: "span",
12129
+ children: " *"
12130
+ }
12131
+ )
12132
+ ] }),
12133
+ variant,
12134
+ placeholder,
12135
+ error: hasError,
12136
+ helperText: hasError ? fieldError : helperText,
12137
+ FormHelperTextProps: {
12138
+ sx: { mx: 0, mt: 0.5 }
12139
+ }
12140
+ }
12141
+ ),
12142
+ renderOption: (props, option) => /* @__PURE__ */ jsxRuntime.jsxs("li", { ...props, children: [
12143
+ option.icon,
12144
+ /* @__PURE__ */ jsxRuntime.jsx(
12145
+ material.Typography,
12146
+ {
12147
+ variant: "body2",
12148
+ sx: {
12149
+ color: option.disabled ? "text.disabled" : "text.primary",
12150
+ ...option.textSx
12151
+ },
12152
+ children: option.label
12153
+ }
12154
+ )
12155
+ ] })
12156
+ }
12157
+ )
12142
12158
  }
12143
- );
12144
- }) }),
12145
- [disabled, chipSx, chipClassName, chipProps]
12146
- );
12147
- const renderSelectedCount = react.useCallback(() => {
12148
- if (!showSelectedCount || !multiple)
12149
- return null;
12150
- return /* @__PURE__ */ jsxRuntime.jsxs(
12151
- material.Typography,
12152
- {
12153
- variant: "caption",
12154
- sx: [
12155
- {
12156
- mt: 0.5,
12157
- color: "text.secondary"
12158
- },
12159
- ...Array.isArray(selectedCountSx) ? selectedCountSx : [selectedCountSx]
12160
- ],
12161
- children: [
12162
- `${selectedCount} selected`,
12163
- maxSelections ? ` (max ${maxSelections})` : ""
12164
- ]
12165
- }
12166
- );
12167
- }, [
12168
- showSelectedCount,
12169
- multiple,
12170
- selectedCount,
12171
- maxSelections,
12172
- selectedCountSx
12173
- ]);
12174
- return /* @__PURE__ */ jsxRuntime.jsx(
12175
- material.Box,
12176
- {
12177
- ref,
12178
- className: `app-searchable-multi-selector ${className}`.trim(),
12179
- sx: [{ width: "100%" }, ...Array.isArray(sx) ? sx : sx ? [sx] : []],
12180
- children: /* @__PURE__ */ jsxRuntime.jsxs(
12159
+ ) });
12160
+ }
12161
+ if (mode === "dropdown") {
12162
+ const handleSelectChange = (event) => {
12163
+ const newValue = event.target.value;
12164
+ handleValueChange(newValue);
12165
+ };
12166
+ return /* @__PURE__ */ jsxRuntime.jsx(material.Box, { ref, sx, children: /* @__PURE__ */ jsxRuntime.jsxs(
12181
12167
  material.FormControl,
12182
12168
  {
12183
12169
  fullWidth: true,
12170
+ variant,
12184
12171
  error: hasError,
12185
12172
  disabled,
12186
- className: `app-searchable-multi-selector-form-control ${formControlClassName}`.trim(),
12187
- sx: [
12188
- {
12189
- "& .MuiAutocomplete-root": {
12190
- "& .MuiOutlinedInput-root": {
12191
- padding: "4px"
12192
- },
12193
- "& .MuiAutocomplete-input": {
12194
- padding: "8.5px 4px"
12195
- }
12196
- }
12197
- },
12198
- ...Array.isArray(formControlSx) ? formControlSx : formControlSx ? [formControlSx] : []
12199
- ],
12173
+ sx: formControlSx,
12200
12174
  children: [
12201
12175
  label && /* @__PURE__ */ jsxRuntime.jsxs(
12202
- LabelComponent,
12176
+ material.Typography,
12203
12177
  {
12204
- shrink: true,
12205
- htmlFor: `autocomplete-${name}`,
12206
- className: `app-searchable-multi-selector-label ${labelClassName}`.trim(),
12207
- sx: [
12208
- {
12209
- mb: 1,
12210
- color: hasError ? "error.main" : "text.primary",
12211
- "&.Mui-focused": {
12212
- color: hasError ? "error.main" : "primary.main"
12213
- }
12214
- },
12215
- ...Array.isArray(labelSx) ? labelSx : [labelSx]
12216
- ],
12217
- ...labelProps,
12178
+ variant: "body2",
12179
+ sx: {
12180
+ mb: 1,
12181
+ color: hasError ? "error.main" : "text.secondary",
12182
+ ...labelSx
12183
+ },
12218
12184
  children: [
12219
12185
  label,
12220
- required && /* @__PURE__ */ jsxRuntime.jsx(material.Box, { component: "span", sx: { color: "error.main", ml: 0.5 }, children: "*" })
12186
+ required && /* @__PURE__ */ jsxRuntime.jsx(material.Typography, { sx: { color: "error.main" }, component: "span", children: " *" })
12221
12187
  ]
12222
12188
  }
12223
12189
  ),
12224
- /* @__PURE__ */ jsxRuntime.jsx(
12225
- material.Autocomplete,
12190
+ /* @__PURE__ */ jsxRuntime.jsxs(
12191
+ material.Select,
12226
12192
  {
12227
- multiple,
12228
- id: `autocomplete-${name}`,
12229
- options,
12230
- value: selectedValues,
12231
- filterOptions,
12232
- onInputChange: handleInputChange,
12233
- onChange: handleChange,
12234
- onOpen,
12235
- onClose,
12193
+ value: currentValue != null ? currentValue : "",
12194
+ onChange: handleSelectChange,
12236
12195
  onBlur: handleBlur,
12237
- onFocus: handleFocus,
12238
- disableCloseOnSelect: multiple,
12239
- readOnly,
12240
- disabled,
12241
- isOptionEqualToValue: (option, value) => option.value === value.value,
12242
- getOptionLabel: (option) => typeof option === "string" ? option : option.label,
12243
- getOptionDisabled: (option) => !!option.disabled,
12244
- renderInput: externalRenderInput || defaultRenderInput,
12245
- renderOption: externalRenderOption || defaultRenderOption,
12246
- renderTags: externalRenderTags || defaultRenderTags,
12247
- renderGroup: externalRenderGroup,
12248
- ListboxProps: {
12249
- className: `app-searchable-multi-selector-listbox ${listboxClassName}`.trim(),
12250
- sx: [
12251
- {
12252
- "& .MuiAutocomplete-option": {
12253
- px: 2,
12254
- py: 1,
12255
- '&[aria-selected="true"]': {
12256
- backgroundColor: "action.selected",
12257
- "&.Mui-focused": {
12258
- backgroundColor: "action.hover"
12259
- }
12260
- },
12261
- "&.Mui-focused": {
12262
- backgroundColor: "action.hover"
12263
- }
12264
- }
12265
- },
12266
- ...Array.isArray(optionSx) ? optionSx : optionSx ? [optionSx] : [],
12267
- ...Array.isArray(listboxSx) ? listboxSx : listboxSx ? [listboxSx] : []
12268
- ]
12196
+ displayEmpty: true,
12197
+ renderValue: (selected) => {
12198
+ if (selected === "") {
12199
+ return /* @__PURE__ */ jsxRuntime.jsx("em", { children: placeholder || noneOptionText });
12200
+ }
12201
+ const option = options.find((opt) => opt.value === selected);
12202
+ return (option == null ? void 0 : option.label) || String(selected);
12269
12203
  },
12270
- className: `app-searchable-multi-selector-autocomplete ${autocompleteClassName}`.trim(),
12271
- sx: [
12272
- {
12273
- "& .MuiAutocomplete-tag": {
12274
- margin: 0,
12275
- height: "auto"
12276
- },
12277
- "& .MuiAutocomplete-endAdornment": {
12278
- right: 8
12204
+ MenuProps: {
12205
+ PaperProps: {
12206
+ sx: {
12207
+ mt: 1,
12208
+ boxShadow: theme.shadows[3],
12209
+ maxHeight: 300
12279
12210
  }
12280
- },
12281
- ...Array.isArray(autocompleteSx) ? autocompleteSx : autocompleteSx ? [autocompleteSx] : []
12282
- ],
12283
- ...autocompleteProps,
12284
- ...otherProps
12285
- }
12286
- ),
12287
- (showHelperText || hasError) && /* @__PURE__ */ jsxRuntime.jsx(
12288
- HelperTextComponent,
12289
- {
12290
- error: hasError,
12291
- sx: [
12292
- {
12293
- mx: 0,
12294
- mt: 0.5,
12295
- ...hasError ? { color: "error.main", ...errorSx } : { color: "text.secondary", ...helperTextSx }
12296
12211
  }
12297
- ],
12298
- className: `app-searchable-multi-selector-helper-text ${helperTextClassName} ${hasError ? "Mui-error" : ""}`.trim(),
12299
- ...helperTextProps,
12300
- children: hasError ? fieldError : helperText
12212
+ },
12213
+ children: [
12214
+ showNoneOption && /* @__PURE__ */ jsxRuntime.jsx(material.MenuItem, { value: "", children: /* @__PURE__ */ jsxRuntime.jsx("em", { children: noneOptionText }) }),
12215
+ options.map((option) => /* @__PURE__ */ jsxRuntime.jsxs(
12216
+ material.MenuItem,
12217
+ {
12218
+ value: option.value,
12219
+ disabled: option.disabled,
12220
+ sx: option.sx,
12221
+ children: [
12222
+ option.icon,
12223
+ /* @__PURE__ */ jsxRuntime.jsx(
12224
+ material.Typography,
12225
+ {
12226
+ variant: "body2",
12227
+ sx: {
12228
+ color: option.disabled ? "text.disabled" : "text.primary",
12229
+ ...option.textSx
12230
+ },
12231
+ children: option.label
12232
+ }
12233
+ )
12234
+ ]
12235
+ },
12236
+ option.value
12237
+ ))
12238
+ ]
12301
12239
  }
12302
12240
  ),
12303
- renderSelectedCount()
12241
+ (helperText || hasError) && /* @__PURE__ */ jsxRuntime.jsx(material.FormHelperText, { error: hasError, sx: { mx: 0, mt: 0.5 }, children: hasError ? fieldError : helperText })
12304
12242
  ]
12305
12243
  }
12306
- )
12244
+ ) });
12307
12245
  }
12308
- );
12309
- });
12310
- AppSearchableMultiSelector2.displayName = "AppSearchableMultiSelector";
12311
- var AppSearchableSelect_default = AppSearchableMultiSelector2;
12312
- var AppSelectInput = react.forwardRef(
12313
- ({
12314
- name,
12315
- variant = "outlined",
12316
- label,
12317
- fullWidth = true,
12318
- required = false,
12319
- disabled = false,
12320
- readOnly = false,
12321
- options = [],
12322
- showNoneOption = false,
12323
- noneOptionText = "None",
12324
- showHelperText = false,
12325
- helperText,
12326
- sx,
12327
- formControlSx,
12328
- selectSx,
12329
- inputSx,
12330
- labelSx,
12331
- menuPaperSx,
12332
- menuItemSx,
12333
- selectedMenuItemSx,
12334
- errorSx,
12335
- helperTextSx,
12336
- iconSx,
12337
- labelComponent: LabelComponent = material.InputLabel,
12338
- errorComponent: ErrorComponent = material.Typography,
12339
- helperTextComponent: HelperTextComponent = material.FormHelperText,
12340
- onChange: externalOnChange,
12341
- onOpen,
12342
- onClose,
12343
- onBlur: externalOnBlur,
12344
- renderValue,
12345
- renderMenuItem,
12346
- MenuProps,
12347
- inputProps,
12348
- ...otherProps
12349
- }, ref) => {
12350
- const theme = material.useTheme();
12351
- const { errors, touched, values, setFieldValue, setFieldTouched } = formik.useFormikContext();
12352
- const fieldError = _19__default.default.get(errors, name);
12353
- const isTouched = _19__default.default.get(touched, name);
12354
- const hasError = Boolean(fieldError) && isTouched;
12355
- const value = _19__default.default.get(values, name);
12356
- const handleChange = (event, child) => {
12357
- setFieldValue(name, event.target.value, true);
12358
- if (externalOnChange) {
12359
- externalOnChange(event, child);
12360
- }
12361
- };
12362
- const handleBlur = (event) => {
12363
- setFieldTouched(name, true, true);
12364
- if (externalOnBlur) {
12365
- externalOnBlur(event);
12366
- }
12367
- };
12368
- const renderDefaultMenuItem = (option, index) => {
12369
- const MenuItemComponent = option.component || material.MenuItem;
12370
- const menuItemProps = option.component ? option.componentProps : {};
12371
- return /* @__PURE__ */ jsxRuntime.jsxs(
12372
- MenuItemComponent,
12373
- {
12374
- value: option.value,
12375
- disabled: option.disabled,
12376
- ...menuItemProps,
12377
- sx: [
12378
- {
12379
- color: "text.primary",
12380
- "&.Mui-selected": {
12381
- backgroundColor: "action.selected",
12382
- "&:hover": {
12383
- backgroundColor: "action.hover"
12384
- },
12385
- ...selectedMenuItemSx
12386
- },
12387
- "&.Mui-disabled": {
12388
- opacity: 0.5,
12389
- pointerEvents: "none"
12390
- },
12391
- ...option.sx
12392
- },
12393
- ...Array.isArray(menuItemSx) ? menuItemSx : [menuItemSx]
12394
- ],
12395
- children: [
12396
- option.icon && /* @__PURE__ */ jsxRuntime.jsx(material.Box, { component: "span", sx: { mr: 1 }, children: option.icon }),
12397
- /* @__PURE__ */ jsxRuntime.jsx(
12398
- material.Typography,
12399
- {
12400
- variant: "body2",
12401
- sx: [
12402
- {
12403
- color: option.disabled ? "text.disabled" : "text.primary",
12404
- ...option.textSx
12405
- }
12406
- ],
12407
- children: option.label
12408
- }
12409
- )
12410
- ]
12411
- },
12412
- `${option.value}-${index}`
12413
- );
12414
- };
12415
- return /* @__PURE__ */ jsxRuntime.jsx(
12416
- material.Box,
12417
- {
12418
- ref,
12419
- className: "app-select-input",
12420
- sx: [
12421
- {
12422
- width: fullWidth ? "100%" : "auto"
12423
- },
12424
- ...Array.isArray(sx) ? sx : [sx].filter(Boolean)
12425
- ],
12426
- children: /* @__PURE__ */ jsxRuntime.jsxs(
12427
- material.FormControl,
12428
- {
12429
- fullWidth,
12430
- variant,
12431
- error: hasError,
12432
- disabled,
12433
- className: "app-select-form-control",
12434
- sx: [
12435
- {
12436
- position: "relative",
12437
- "& .MuiOutlinedInput-notchedOutline": {
12438
- borderWidth: "1px"
12439
- },
12440
- "& .MuiInputLabel-root": {
12441
- position: "relative",
12442
- transform: "none",
12443
- fontSize: "0.875rem",
12444
- mb: 1,
12445
- "&.Mui-focused": {
12446
- color: hasError ? "error.main" : "primary.main"
12447
- },
12448
- "&.Mui-disabled": {
12449
- color: "text.disabled"
12450
- }
12451
- },
12452
- "& .MuiInputLabel-shrink": {
12453
- transform: "none"
12454
- }
12455
- },
12456
- ...Array.isArray(formControlSx) ? formControlSx : formControlSx ? [formControlSx] : []
12457
- ],
12458
- children: [
12459
- label && /* @__PURE__ */ jsxRuntime.jsxs(
12460
- LabelComponent,
12461
- {
12462
- id: `select-${name}-label`,
12463
- htmlFor: `select-${name}`,
12464
- className: "app-select-label",
12465
- shrink: false,
12466
- sx: [
12467
- {
12468
- position: "relative",
12469
- transform: "none",
12470
- fontSize: "0.875rem",
12471
- fontWeight: 500,
12472
- color: hasError ? "error.main" : "text.secondary",
12473
- mb: 1,
12474
- "&.Mui-focused": {
12475
- color: hasError ? "error.main" : "primary.main"
12476
- },
12477
- "&.Mui-disabled": {
12478
- color: "text.disabled"
12479
- }
12480
- },
12481
- ...Array.isArray(labelSx) ? labelSx : [labelSx].filter(Boolean)
12482
- ],
12483
- children: [
12484
- label,
12485
- required && /* @__PURE__ */ jsxRuntime.jsx(
12486
- material.Box,
12487
- {
12488
- component: "span",
12489
- sx: {
12490
- color: "error.main",
12491
- ml: 0.5
12492
- },
12493
- children: "*"
12494
- }
12495
- )
12496
- ]
12497
- }
12498
- ),
12499
- /* @__PURE__ */ jsxRuntime.jsxs(
12500
- Select__default.default,
12501
- {
12502
- variant: "outlined",
12503
- labelId: label ? `select-${name}-label` : void 0,
12504
- id: `select-${name}`,
12505
- name,
12506
- value: value != null ? value : "",
12507
- onChange: handleChange,
12508
- onBlur: handleBlur,
12509
- onOpen,
12510
- onClose,
12511
- renderValue,
12512
- label: void 0,
12513
- displayEmpty: true,
12514
- inputProps: {
12515
- readOnly,
12516
- ...inputProps
12517
- },
12518
- MenuProps: {
12519
- PaperProps: {
12520
- sx: [
12521
- {
12522
- mt: 1,
12523
- boxShadow: theme.shadows[3],
12524
- maxHeight: 300,
12525
- "& .MuiMenuItem-root": {
12526
- px: 2,
12527
- py: 1,
12528
- "&.Mui-selected": {
12529
- backgroundColor: "action.selected",
12530
- "&:hover": {
12531
- backgroundColor: "action.hover"
12532
- }
12533
- }
12534
- },
12535
- ...Array.isArray(menuPaperSx) ? menuPaperSx : [menuPaperSx]
12536
- }
12537
- ]
12538
- },
12539
- ...MenuProps
12540
- },
12541
- sx: [
12542
- {
12543
- "& .MuiSelect-select": {
12544
- minHeight: "1.4375em",
12545
- padding: "16.5px 14px",
12546
- "&.MuiInputBase-input": {
12547
- padding: "16.5px 14px"
12548
- }
12549
- },
12550
- "&.MuiOutlinedInput-root": {
12551
- "& fieldset": {
12552
- borderWidth: "1px"
12553
- },
12554
- "&:hover fieldset": {
12555
- borderWidth: "1px"
12556
- },
12557
- "&.Mui-focused fieldset": {
12558
- borderWidth: "2px"
12559
- }
12560
- },
12561
- "&.Mui-disabled": {
12562
- backgroundColor: "action.disabledBackground",
12563
- "& .MuiOutlinedInput-notchedOutline": {
12564
- borderColor: "action.disabled"
12565
- },
12566
- "& .MuiSelect-icon": {
12567
- color: "action.disabled"
12568
- }
12569
- }
12570
- },
12571
- ...Array.isArray(selectSx) ? selectSx : selectSx ? [selectSx] : []
12572
- ],
12573
- ...otherProps,
12574
- children: [
12575
- showNoneOption && /* @__PURE__ */ jsxRuntime.jsx(material.MenuItem, { value: "", children: /* @__PURE__ */ jsxRuntime.jsx("em", { children: noneOptionText }) }),
12576
- options.map(
12577
- (option, index) => renderMenuItem ? renderMenuItem(option, index) : renderDefaultMenuItem(option, index)
12578
- )
12579
- ]
12580
- }
12581
- ),
12582
- (showHelperText || hasError) && /* @__PURE__ */ jsxRuntime.jsx(
12583
- HelperTextComponent,
12584
- {
12585
- error: hasError,
12586
- sx: [
12587
- {
12588
- mx: 0,
12589
- mt: 0.5,
12590
- fontSize: "0.75rem",
12591
- ...hasError ? {
12592
- color: "error.main",
12593
- ...errorSx
12594
- } : {
12595
- color: "text.secondary",
12596
- ...helperTextSx
12597
- }
12598
- }
12599
- ],
12600
- children: hasError ? fieldError : helperText
12601
- }
12602
- )
12603
- ]
12604
- }
12605
- )
12606
- }
12607
- );
12246
+ return null;
12608
12247
  }
12609
12248
  );
12610
12249
  AppSelectInput.displayName = "AppSelectInput";
@@ -13022,7 +12661,7 @@ function getRatio(ratio = "1/1") {
13022
12661
  }[ratio];
13023
12662
  }
13024
12663
  var TRANSPARENT_PNG = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8Xw8AApIBgX6cJqkAAAAASUVORK5CYII=";
13025
- var Image = react.forwardRef(
12664
+ var Image = React4.forwardRef(
13026
12665
  ({
13027
12666
  ratio,
13028
12667
  disabledEffect = false,
@@ -13200,8 +12839,8 @@ function MultiFilePreview({
13200
12839
  if ((files == null ? void 0 : files.length) == null) {
13201
12840
  return null;
13202
12841
  }
13203
- const [anchorEl, setAnchorEl] = react.useState(null);
13204
- const [selectedFile, setSelectedFile] = react.useState(null);
12842
+ const [anchorEl, setAnchorEl] = React4.useState(null);
12843
+ const [selectedFile, setSelectedFile] = React4.useState(null);
13205
12844
  const canViewPrivate = true;
13206
12845
  return /* @__PURE__ */ jsxRuntime.jsx(framerMotion.AnimatePresence, { initial: false, children: files.map((file) => {
13207
12846
  const typedFile = file;
@@ -13482,7 +13121,7 @@ function BackgroundIllustration() {
13482
13121
  )
13483
13122
  ] });
13484
13123
  }
13485
- var BackgroundIllustration_default = react.memo(BackgroundIllustration);
13124
+ var BackgroundIllustration_default = React4.memo(BackgroundIllustration);
13486
13125
  function UploadIllustration({ ...other }) {
13487
13126
  const theme = styles.useTheme();
13488
13127
  const PRIMARY_MAIN = theme.palette.primary.main;
@@ -14036,7 +13675,7 @@ function UploadIllustration({ ...other }) {
14036
13675
  )
14037
13676
  ] }) });
14038
13677
  }
14039
- var UploadIllustration_default = react.memo(UploadIllustration);
13678
+ var UploadIllustration_default = React4.memo(UploadIllustration);
14040
13679
  var StyledDropZone = styles.styled("div")(({ theme }) => ({
14041
13680
  outline: "none",
14042
13681
  cursor: "pointer",
@@ -14314,7 +13953,7 @@ var SubmitButton = ({
14314
13953
  ...rest
14315
13954
  }) => {
14316
13955
  const { submitForm, isSubmitting } = formik.useFormikContext();
14317
- const [isLoading, setIsLoading] = react.useState(false);
13956
+ const [isLoading, setIsLoading] = React4.useState(false);
14318
13957
  const handleClick = async () => {
14319
13958
  try {
14320
13959
  setIsLoading(true);
@@ -14382,7 +14021,7 @@ exports.AppRadioGroup = AppRadioGroup_default;
14382
14021
  exports.AppRating = AppRating_default;
14383
14022
  exports.AppRichTextEditor = AppRichTextEditor_default;
14384
14023
  exports.AppSearchableMultiSelector = AppSearchableMultiSelector_default;
14385
- exports.AppSearchableSelectInput = AppSearchableSelect_default;
14024
+ exports.AppSearchableSelectInput = AppSearchableSelectInput;
14386
14025
  exports.AppSelectInput = AppSelectInput_default;
14387
14026
  exports.AppSimpleUploadFile = AppSimpleUploadFile_default;
14388
14027
  exports.AppSwitch = AppSwitch;