formik-form-components 0.2.28 → 0.2.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ var DatePicker = require('@mui/x-date-pickers/DatePicker');
7
7
  var LocalizationProvider = require('@mui/x-date-pickers/LocalizationProvider');
8
8
  var AdapterDayjs = require('@mui/x-date-pickers/AdapterDayjs');
9
9
  var CalendarMonthIcon = require('@mui/icons-material/CalendarMonth');
10
- var _19 = require('lodash');
10
+ var _17 = require('lodash');
11
11
  var jsxRuntime = require('react/jsx-runtime');
12
12
  var DateTimePicker = require('@mui/x-date-pickers/DateTimePicker');
13
13
  var Autocomplete3 = require('@mui/material/Autocomplete');
@@ -43,7 +43,7 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
43
43
 
44
44
  var React4__default = /*#__PURE__*/_interopDefault(React4);
45
45
  var CalendarMonthIcon__default = /*#__PURE__*/_interopDefault(CalendarMonthIcon);
46
- var _19__default = /*#__PURE__*/_interopDefault(_19);
46
+ var _17__default = /*#__PURE__*/_interopDefault(_17);
47
47
  var Autocomplete3__default = /*#__PURE__*/_interopDefault(Autocomplete3);
48
48
  var Typography9__default = /*#__PURE__*/_interopDefault(Typography9);
49
49
  var PhoneInput__default = /*#__PURE__*/_interopDefault(PhoneInput);
@@ -77,9 +77,9 @@ var AppDatePicker = React4.forwardRef(
77
77
  ...otherProps
78
78
  }, ref) => {
79
79
  const { values, setFieldValue, touched, errors, setFieldTouched } = formik.useFormikContext();
80
- const fieldValue = _19__default.default.get(values, name);
81
- const fieldError = _19__default.default.get(errors, name);
82
- const isTouched = _19__default.default.get(touched, name);
80
+ const fieldValue = _17__default.default.get(values, name);
81
+ const fieldError = _17__default.default.get(errors, name);
82
+ const isTouched = _17__default.default.get(touched, name);
83
83
  const handleChange = (newValue) => {
84
84
  setFieldValue(name, newValue);
85
85
  };
@@ -135,9 +135,9 @@ var AppDateAndTimePicker = React4.forwardRef((props, ref) => {
135
135
  } = props;
136
136
  const theme = material.useTheme();
137
137
  const { errors, touched, values, setFieldValue, setFieldTouched } = formik.useFormikContext();
138
- const fieldError = _19.get(errors, name);
139
- const isTouched = _19.get(touched, name);
140
- const val = _19.get(values, name);
138
+ const fieldError = _17.get(errors, name);
139
+ const isTouched = _17.get(touched, name);
140
+ const val = _17.get(values, name);
141
141
  const handleChange = (value) => {
142
142
  setFieldValue(name, value);
143
143
  if (externalOnChange) {
@@ -313,8 +313,8 @@ function AppFormErrorMessage({
313
313
  textSx
314
314
  }) {
315
315
  const { errors, touched } = formik.useFormikContext();
316
- const fieldError = _19__default.default.get(errors, name);
317
- const isTouched = _19__default.default.get(touched, name);
316
+ const fieldError = _17__default.default.get(errors, name);
317
+ const isTouched = _17__default.default.get(touched, name);
318
318
  const showError = fieldError && typeof fieldError === "string";
319
319
  if (alwaysShow) {
320
320
  return showError ? /* @__PURE__ */ jsxRuntime.jsx(
@@ -391,9 +391,9 @@ var AppTextArea = React4.forwardRef(({
391
391
  }, ref) => {
392
392
  var _a, _b, _c, _d;
393
393
  const { errors, getFieldProps, touched, setFieldValue } = formik.useFormikContext();
394
- const fieldError = _19__default.default.get(errors, name);
395
- const isTouched = _19__default.default.get(touched, name);
396
- const value = _19__default.default.get(getFieldProps(name), "value", "");
394
+ const fieldError = _17__default.default.get(errors, name);
395
+ const isTouched = _17__default.default.get(touched, name);
396
+ const value = _17__default.default.get(getFieldProps(name), "value", "");
397
397
  const handleChange = (e) => {
398
398
  const newValue = e.target.value;
399
399
  if (maxLength && newValue.length > maxLength)
@@ -547,9 +547,9 @@ function AppTagsCreator({
547
547
  inputSx
548
548
  }) {
549
549
  const { errors, touched, getFieldProps, values, setFieldValue, setTouched } = formik.useFormikContext();
550
- const fieldError = _19__default.default.get(errors, name);
551
- const isTouched = _19__default.default.get(touched, name);
552
- const val = _19__default.default.get(values, name);
550
+ const fieldError = _17__default.default.get(errors, name);
551
+ const isTouched = _17__default.default.get(touched, name);
552
+ const val = _17__default.default.get(values, name);
553
553
  return /* @__PURE__ */ jsxRuntime.jsxs(
554
554
  material.FormControl,
555
555
  {
@@ -672,8 +672,8 @@ function AppSwitchInput({
672
672
  ...otherProps
673
673
  }) {
674
674
  const { errors, touched, setFieldValue, values } = formik.useFormikContext();
675
- const fieldError = _19__default.default.get(errors, name);
676
- const isTouched = _19__default.default.get(touched, name);
675
+ const fieldError = _17__default.default.get(errors, name);
676
+ const isTouched = _17__default.default.get(touched, name);
677
677
  return /* @__PURE__ */ jsxRuntime.jsxs(
678
678
  material.Box,
679
679
  {
@@ -771,9 +771,9 @@ function AppSwitch({
771
771
  ...otherProps
772
772
  }) {
773
773
  const { errors, touched, setFieldValue, values } = formik.useFormikContext();
774
- const fieldValue = _19__default.default.get(values, name);
775
- const fieldError = _19__default.default.get(errors, name);
776
- const isTouched = _19__default.default.get(touched, name);
774
+ const fieldValue = _17__default.default.get(values, name);
775
+ const fieldError = _17__default.default.get(errors, name);
776
+ const isTouched = _17__default.default.get(touched, name);
777
777
  return /* @__PURE__ */ jsxRuntime.jsxs(
778
778
  material.Stack,
779
779
  {
@@ -879,9 +879,9 @@ function AppAutoComplete({
879
879
  errorSx
880
880
  }) {
881
881
  const { errors, touched, getFieldProps, values, setFieldValue } = formik.useFormikContext();
882
- const fieldError = _19__default.default.get(errors, name);
883
- const isTouched = _19__default.default.get(touched, name);
884
- const formikValue = _19__default.default.get(values, name);
882
+ const fieldError = _17__default.default.get(errors, name);
883
+ const isTouched = _17__default.default.get(touched, name);
884
+ const formikValue = _17__default.default.get(values, name);
885
885
  const val = propValue !== void 0 ? propValue : formikValue || [];
886
886
  return /* @__PURE__ */ jsxRuntime.jsxs(material.FormControl, { fullWidth: true, variant: "filled", sx: formControlSx, children: [
887
887
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -953,9 +953,9 @@ function AppAutoCompleter({
953
953
  errorSx
954
954
  }) {
955
955
  const { errors, touched, values, setFieldValue } = formik.useFormikContext();
956
- const fieldError = _19__default.default.get(errors, name);
957
- const isTouched = _19__default.default.get(touched, name);
958
- const value = _19__default.default.get(values, name);
956
+ const fieldError = _17__default.default.get(errors, name);
957
+ const isTouched = _17__default.default.get(touched, name);
958
+ const value = _17__default.default.get(values, name);
959
959
  const selectedOption = options.find((opt) => opt.value === value) || null;
960
960
  return /* @__PURE__ */ jsxRuntime.jsxs(material.FormControl, { fullWidth: true, variant: "filled", sx: formControlSx, children: [
961
961
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -967,7 +967,7 @@ function AppAutoCompleter({
967
967
  getOptionLabel: (option) => (option == null ? void 0 : option.label) || "",
968
968
  isOptionEqualToValue: (option, value2) => option.value === value2.value,
969
969
  autoHighlight: true,
970
- onChange: (_20, newValue) => {
970
+ onChange: (_18, newValue) => {
971
971
  setFieldValue(name, newValue ? newValue.value : null);
972
972
  },
973
973
  renderOption: (props, option) => /* @__PURE__ */ React4.createElement(material.Box, { component: "li", ...props, key: option.value, sx: listboxSx }, option.label),
@@ -1018,8 +1018,8 @@ var AppCheckBox = ({
1018
1018
  ...rest
1019
1019
  }) => {
1020
1020
  const { getFieldProps, setFieldValue, touched, errors } = formik.useFormikContext();
1021
- const fieldError = _19__default.default.get(errors, name);
1022
- const isTouched = _19__default.default.get(touched, name);
1021
+ const fieldError = _17__default.default.get(errors, name);
1022
+ const isTouched = _17__default.default.get(touched, name);
1023
1023
  material.useTheme();
1024
1024
  const value = getFieldProps(name).value;
1025
1025
  const checkedValues = (() => {
@@ -1182,8 +1182,8 @@ function AppInputField({
1182
1182
  ...otherProps
1183
1183
  }) {
1184
1184
  const { errors, getFieldProps, touched } = formik.useFormikContext();
1185
- const fieldError = _19__default.default.get(errors, name);
1186
- const isTouched = _19__default.default.get(touched, name);
1185
+ const fieldError = _17__default.default.get(errors, name);
1186
+ const isTouched = _17__default.default.get(touched, name);
1187
1187
  const [showPassword, setShowPassword] = React4.useState(false);
1188
1188
  const handleShowPassword = () => {
1189
1189
  setShowPassword(!showPassword);
@@ -1268,10 +1268,10 @@ var AppMultiSelector = React4.forwardRef(
1268
1268
  }, ref) => {
1269
1269
  const theme = material.useTheme();
1270
1270
  const { values, setFieldValue, errors, touched, setFieldTouched } = formik.useFormikContext();
1271
- const fieldError = _19__default.default.get(errors, name);
1272
- const isTouched = Boolean(_19__default.default.get(touched, name));
1271
+ const fieldError = _17__default.default.get(errors, name);
1272
+ const isTouched = Boolean(_17__default.default.get(touched, name));
1273
1273
  const hasError = Boolean(fieldError) && isTouched;
1274
- const currentValue = _19__default.default.get(values, name);
1274
+ const currentValue = _17__default.default.get(values, name);
1275
1275
  const selectedValues = Array.isArray(currentValue) ? currentValue : [];
1276
1276
  const selectedCount = selectedValues.length;
1277
1277
  const isMaxReached = maxSelections ? selectedCount >= maxSelections : false;
@@ -1310,10 +1310,7 @@ var AppMultiSelector = React4.forwardRef(
1310
1310
  return options2;
1311
1311
  const inputValueLower = inputValue.toLowerCase();
1312
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
- }
1313
+ (option) => option.label.toLowerCase().includes(inputValueLower) || String(option.value).toLowerCase().includes(inputValueLower)
1317
1314
  );
1318
1315
  };
1319
1316
  const selectedOptions = getSelectedOptions();
@@ -1374,28 +1371,31 @@ var AppMultiSelector = React4.forwardRef(
1374
1371
  }
1375
1372
  }
1376
1373
  ),
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
1384
- }
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
- ] }),
1374
+ renderOption: (props, option, { selected }) => {
1375
+ const { key, ...restProps } = props;
1376
+ return /* @__PURE__ */ jsxRuntime.jsxs("li", { ...restProps, children: [
1377
+ /* @__PURE__ */ jsxRuntime.jsx(
1378
+ material.Checkbox,
1379
+ {
1380
+ checked: selected,
1381
+ disabled: option.disabled || isMaxReached && !selected,
1382
+ sx: checkboxSx
1383
+ }
1384
+ ),
1385
+ option.icon,
1386
+ /* @__PURE__ */ jsxRuntime.jsx(
1387
+ material.Typography,
1388
+ {
1389
+ variant: "body2",
1390
+ sx: {
1391
+ color: option.disabled ? "text.disabled" : "text.primary",
1392
+ ...option.textSx
1393
+ },
1394
+ children: option.label
1395
+ }
1396
+ )
1397
+ ] }, key);
1398
+ },
1399
1399
  renderTags: (value, getTagProps) => /* @__PURE__ */ jsxRuntime.jsx(
1400
1400
  material.Box,
1401
1401
  {
@@ -1578,8 +1578,8 @@ var AppPhoneNoInput = ({
1578
1578
  withCountryCallingCode = true
1579
1579
  }) => {
1580
1580
  const { values, errors, touched, setFieldValue, setFieldTouched } = formik.useFormikContext();
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]);
1581
+ const fieldError = React4.useMemo(() => _17__default.default.get(errors, name), [errors, name]);
1582
+ const isTouched = React4.useMemo(() => _17__default.default.get(touched, name), [touched, name]);
1583
1583
  return /* @__PURE__ */ jsxRuntime.jsxs(
1584
1584
  material.Box,
1585
1585
  {
@@ -1689,9 +1689,9 @@ var AppRadioGroup = React4.forwardRef(({
1689
1689
  ...rest
1690
1690
  }, ref) => {
1691
1691
  const { errors, touched, getFieldProps, setFieldValue } = formik.useFormikContext();
1692
- const fieldError = _19__default.default.get(errors, name);
1693
- const isTouched = _19__default.default.get(touched, name);
1694
- const value = _19__default.default.get(getFieldProps(name), "value");
1692
+ const fieldError = _17__default.default.get(errors, name);
1693
+ const isTouched = _17__default.default.get(touched, name);
1694
+ const value = _17__default.default.get(getFieldProps(name), "value");
1695
1695
  const handleChange = (event) => {
1696
1696
  const newValue = event.target.value;
1697
1697
  setFieldValue(name, newValue);
@@ -1870,9 +1870,9 @@ var AppRating = React4.forwardRef(
1870
1870
  }, ref) => {
1871
1871
  material.useTheme();
1872
1872
  const { errors, touched, setFieldValue, values, setFieldTouched } = formik.useFormikContext();
1873
- const val = _19__default.default.get(values, name);
1874
- const fieldError = _19__default.default.get(errors, name);
1875
- const isTouched = _19__default.default.get(touched, name);
1873
+ const val = _17__default.default.get(values, name);
1874
+ const fieldError = _17__default.default.get(errors, name);
1875
+ const isTouched = _17__default.default.get(touched, name);
1876
1876
  const hasError = Boolean(fieldError) && isTouched;
1877
1877
  const handleChange = (event, newValue) => {
1878
1878
  setFieldValue(name, newValue);
@@ -2614,7 +2614,7 @@ var Mark = class {
2614
2614
  */
2615
2615
  toJSON() {
2616
2616
  let obj = { type: this.type.name };
2617
- for (let _20 in this.attrs) {
2617
+ for (let _18 in this.attrs) {
2618
2618
  obj.attrs = this.attrs;
2619
2619
  break;
2620
2620
  }
@@ -3562,7 +3562,7 @@ var Node = class {
3562
3562
  */
3563
3563
  toJSON() {
3564
3564
  let obj = { type: this.type.name };
3565
- for (let _20 in this.attrs) {
3565
+ for (let _18 in this.attrs) {
3566
3566
  obj.attrs = this.attrs;
3567
3567
  break;
3568
3568
  }
@@ -4291,7 +4291,7 @@ var NodeType = class {
4291
4291
  throw new RangeError("Schema is missing its top node type ('" + topType + "')");
4292
4292
  if (!result.text)
4293
4293
  throw new RangeError("Every schema needs a 'text' type");
4294
- for (let _20 in result.text.attrs)
4294
+ for (let _18 in result.text.attrs)
4295
4295
  throw new RangeError("The text node type should not have attributes");
4296
4296
  return result;
4297
4297
  }
@@ -9300,7 +9300,7 @@ function removeDuplicates(array, by = JSON.stringify) {
9300
9300
  function simplifyChangedRanges(changes) {
9301
9301
  const uniqueChanges = removeDuplicates(changes);
9302
9302
  return uniqueChanges.length === 1 ? uniqueChanges : uniqueChanges.filter((change, index) => {
9303
- const rest = uniqueChanges.filter((_20, i) => i !== index);
9303
+ const rest = uniqueChanges.filter((_18, i) => i !== index);
9304
9304
  return !rest.some((otherChange) => {
9305
9305
  return change.oldRange.from >= otherChange.oldRange.from && change.oldRange.to <= otherChange.oldRange.to && change.newRange.from >= otherChange.newRange.from && change.newRange.to <= otherChange.newRange.to;
9306
9306
  });
@@ -10325,7 +10325,7 @@ var Drop = Extension.create({
10325
10325
  new Plugin({
10326
10326
  key: new PluginKey("tiptapDrop"),
10327
10327
  props: {
10328
- handleDrop: (_20, e, slice, moved) => {
10328
+ handleDrop: (_18, e, slice, moved) => {
10329
10329
  this.editor.emit("drop", {
10330
10330
  editor: this.editor,
10331
10331
  event: e,
@@ -11491,541 +11491,6 @@ var AppRichTextEditor = ({
11491
11491
  ] });
11492
11492
  };
11493
11493
  var AppRichTextEditor_default = AppRichTextEditor;
11494
- var AppSearchableMultiSelector = React4.forwardRef(
11495
- ({
11496
- name,
11497
- label,
11498
- multiple = true,
11499
- options = [],
11500
- setSearchQuery,
11501
- required = false,
11502
- variant = "outlined",
11503
- disabled = false,
11504
- readOnly = false,
11505
- showHelperText = false,
11506
- helperText,
11507
- maxSelections,
11508
- showSelectedCount = false,
11509
- sx,
11510
- formControlSx,
11511
- labelSx,
11512
- inputSx,
11513
- textFieldSx,
11514
- autocompleteSx,
11515
- listboxSx,
11516
- optionSx,
11517
- chipSx,
11518
- errorSx,
11519
- helperTextSx,
11520
- selectedCountSx,
11521
- renderInput: externalRenderInput,
11522
- renderOption: externalRenderOption,
11523
- renderTags: externalRenderTags,
11524
- renderGroup: externalRenderGroup,
11525
- labelComponent: LabelComponent = material.InputLabel,
11526
- inputComponent: InputComponent = "input",
11527
- errorComponent: ErrorComponent = material.Typography,
11528
- helperTextComponent: HelperTextComponent = material.FormHelperText,
11529
- labelProps = {},
11530
- inputProps = {},
11531
- textFieldProps = {},
11532
- autocompleteProps = {},
11533
- checkboxProps = {},
11534
- chipProps = {},
11535
- errorProps = {},
11536
- helperTextProps = {},
11537
- className = "",
11538
- formControlClassName = "",
11539
- labelClassName = "",
11540
- inputClassName = "",
11541
- textFieldClassName = "",
11542
- autocompleteClassName = "",
11543
- listboxClassName = "",
11544
- optionClassName = "",
11545
- chipClassName = "",
11546
- errorClassName = "",
11547
- helperTextClassName = "",
11548
- onInputChange: externalOnInputChange,
11549
- onChange: externalOnChange,
11550
- onOpen,
11551
- onClose,
11552
- onBlur: externalOnBlur,
11553
- onFocus: externalOnFocus,
11554
- onClear,
11555
- onMaxSelectionsReached,
11556
- onRemove,
11557
- onAdd,
11558
- ...otherProps
11559
- }, ref) => {
11560
- material.useTheme();
11561
- const { values, setFieldValue, errors, touched, setFieldTouched } = formik.useFormikContext();
11562
- const fieldError = _19__default.default.get(errors, name);
11563
- const isTouched = Boolean(_19__default.default.get(touched, name));
11564
- const hasError = Boolean(fieldError) && isTouched;
11565
- const val = _19__default.default.get(values, name);
11566
- const selectedValues = Array.isArray(val) ? val : [];
11567
- const selectedCount = selectedValues.length;
11568
- const handleChange = (event, value, reason, details) => {
11569
- const normalizedValue = (() => {
11570
- if (value === null)
11571
- return [];
11572
- const arr = Array.isArray(value) ? value : [value];
11573
- return arr.map(
11574
- (item) => typeof item === "string" ? { value: item, label: item } : item
11575
- );
11576
- })();
11577
- if (maxSelections && normalizedValue.length > maxSelections) {
11578
- if (onMaxSelectionsReached) {
11579
- onMaxSelectionsReached(maxSelections);
11580
- }
11581
- return;
11582
- }
11583
- if (reason === "selectOption" || reason === "removeOption") {
11584
- const added = normalizedValue.filter(
11585
- (item) => !selectedValues.some((v) => v.value === item.value)
11586
- );
11587
- const removed = selectedValues.filter(
11588
- (item) => !normalizedValue.some((v) => v.value === item.value)
11589
- );
11590
- if (added.length > 0 && onAdd) {
11591
- added.forEach((item) => onAdd(item));
11592
- }
11593
- if (removed.length > 0 && onRemove) {
11594
- removed.forEach((item) => onRemove(item));
11595
- }
11596
- }
11597
- setFieldValue(name, normalizedValue, true);
11598
- if (externalOnChange) {
11599
- externalOnChange(event, normalizedValue, reason);
11600
- }
11601
- };
11602
- const handleInputChange = (event, value, reason) => {
11603
- if (setSearchQuery) {
11604
- setSearchQuery(value);
11605
- }
11606
- if (externalOnInputChange) {
11607
- externalOnInputChange(event, value, reason);
11608
- }
11609
- };
11610
- const handleBlur = (event) => {
11611
- setFieldTouched(name, true, true);
11612
- if (externalOnBlur) {
11613
- externalOnBlur(event);
11614
- }
11615
- };
11616
- const handleFocus = (event) => {
11617
- if (externalOnFocus) {
11618
- externalOnFocus(event);
11619
- }
11620
- };
11621
- const filterOptions = (options2, { inputValue }) => {
11622
- if (!inputValue)
11623
- return options2;
11624
- const inputValueLower = inputValue.toLowerCase();
11625
- return options2.filter(
11626
- (option) => {
11627
- var _a, _b, _c, _d;
11628
- 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));
11629
- }
11630
- );
11631
- };
11632
- const defaultRenderInput = (params) => /* @__PURE__ */ jsxRuntime.jsx(
11633
- material.TextField,
11634
- {
11635
- ...params,
11636
- variant,
11637
- error: hasError,
11638
- helperText: "",
11639
- placeholder: "",
11640
- inputRef: inputProps.ref,
11641
- inputProps: {
11642
- ...params.inputProps,
11643
- ...inputProps,
11644
- className: `${params.inputProps.className || ""} ${inputClassName}`.trim()
11645
- },
11646
- InputProps: {
11647
- ...params.InputProps,
11648
- ...textFieldProps.InputProps,
11649
- className: `${params.InputProps.className || ""} ${textFieldClassName}`.trim()
11650
- },
11651
- sx: [
11652
- {
11653
- "& .MuiOutlinedInput-root": {
11654
- borderRadius: "8px",
11655
- "& fieldset": {
11656
- borderColor: hasError ? "error.main" : "divider"
11657
- },
11658
- "&:hover fieldset": {
11659
- borderColor: hasError ? "error.main" : "text.primary"
11660
- },
11661
- "&.Mui-focused fieldset": {
11662
- borderColor: hasError ? "error.main" : "primary.main"
11663
- },
11664
- "& .MuiInputLabel-root": {
11665
- // Your label styles here
11666
- }
11667
- }
11668
- },
11669
- ...Array.isArray(sx) ? sx : sx ? [sx] : []
11670
- ],
11671
- ...textFieldProps
11672
- }
11673
- );
11674
- const defaultRenderOption = (props, option, { selected }) => /* @__PURE__ */ React4.createElement(
11675
- "li",
11676
- {
11677
- ...props,
11678
- key: option.value,
11679
- className: `${props.className || ""} ${optionClassName}`.trim(),
11680
- style: {
11681
- ...props.style,
11682
- opacity: option.disabled ? 0.5 : 1,
11683
- pointerEvents: option.disabled ? "none" : "auto"
11684
- }
11685
- },
11686
- /* @__PURE__ */ jsxRuntime.jsx(
11687
- material.Checkbox,
11688
- {
11689
- checked: selected,
11690
- disabled: option.disabled,
11691
- sx: {
11692
- color: "text.secondary",
11693
- "&.Mui-checked": {
11694
- color: "primary.main"
11695
- },
11696
- "&.Mui-disabled": {
11697
- color: "text.disabled"
11698
- },
11699
- mr: 1,
11700
- ...checkboxProps.sx
11701
- },
11702
- ...checkboxProps
11703
- }
11704
- ),
11705
- option.icon && /* @__PURE__ */ jsxRuntime.jsx(material.Box, { component: "span", sx: { mr: 1 }, children: option.icon }),
11706
- /* @__PURE__ */ jsxRuntime.jsx(
11707
- material.Typography,
11708
- {
11709
- variant: "body2",
11710
- sx: [
11711
- {
11712
- color: option.disabled ? "text.disabled" : "text.primary",
11713
- ...option.textSx
11714
- },
11715
- ...Array.isArray(optionSx) ? optionSx : [optionSx]
11716
- ],
11717
- children: option.label
11718
- }
11719
- )
11720
- );
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) => {
11722
- const { key, ...tagProps } = getTagProps({ index });
11723
- return /* @__PURE__ */ React4.createElement(
11724
- material.Chip,
11725
- {
11726
- ...tagProps,
11727
- key: option.value,
11728
- label: option.label,
11729
- disabled: disabled || option.disabled,
11730
- sx: [
11731
- {
11732
- height: "24px",
11733
- borderRadius: "4px",
11734
- "& .MuiChip-deleteIcon": {
11735
- color: "text.secondary",
11736
- "&:hover": {
11737
- color: "text.primary"
11738
- }
11739
- },
11740
- ...chipSx
11741
- },
11742
- ...Array.isArray(chipSx) ? chipSx : [chipSx]
11743
- ],
11744
- className: `${chipClassName} ${option.disabled ? "Mui-disabled" : ""}`.trim(),
11745
- ...chipProps
11746
- }
11747
- );
11748
- }) });
11749
- const renderSelectedCount = () => {
11750
- if (!showSelectedCount || !multiple)
11751
- return null;
11752
- return /* @__PURE__ */ jsxRuntime.jsxs(
11753
- material.Typography,
11754
- {
11755
- variant: "caption",
11756
- sx: [
11757
- {
11758
- mt: 0.5,
11759
- color: "text.secondary",
11760
- ...selectedCountSx
11761
- },
11762
- ...Array.isArray(selectedCountSx) ? selectedCountSx : [selectedCountSx]
11763
- ],
11764
- children: [
11765
- `${selectedCount} selected`,
11766
- maxSelections ? ` (max ${maxSelections})` : ""
11767
- ]
11768
- }
11769
- );
11770
- };
11771
- return /* @__PURE__ */ jsxRuntime.jsx(
11772
- material.Box,
11773
- {
11774
- ref,
11775
- className: `app-searchable-multi-selector ${className}`.trim(),
11776
- sx: [
11777
- {
11778
- width: "100%"
11779
- },
11780
- ...Array.isArray(sx) ? sx : sx ? [sx] : []
11781
- ],
11782
- children: /* @__PURE__ */ jsxRuntime.jsxs(
11783
- material.FormControl,
11784
- {
11785
- fullWidth: true,
11786
- error: hasError,
11787
- disabled,
11788
- className: `app-searchable-multi-selector-form-control ${formControlClassName}`.trim(),
11789
- sx: [
11790
- {
11791
- "& .MuiAutocomplete-root": {
11792
- "& .MuiOutlinedInput-root": {
11793
- padding: "4px"
11794
- },
11795
- "& .MuiAutocomplete-input": {
11796
- padding: "8.5px 4px"
11797
- }
11798
- }
11799
- },
11800
- ...Array.isArray(formControlSx) ? formControlSx : formControlSx ? [formControlSx] : []
11801
- ],
11802
- children: [
11803
- label && /* @__PURE__ */ jsxRuntime.jsxs(
11804
- LabelComponent,
11805
- {
11806
- shrink: true,
11807
- htmlFor: `autocomplete-${name}`,
11808
- className: `app-searchable-multi-selector-label ${labelClassName}`.trim(),
11809
- sx: [
11810
- {
11811
- mb: 1,
11812
- color: hasError ? "error.main" : "text.primary",
11813
- "&.Mui-focused": {
11814
- color: hasError ? "error.main" : "primary.main"
11815
- },
11816
- ...Array.isArray(labelSx) ? labelSx : [labelSx]
11817
- }
11818
- ],
11819
- ...labelProps,
11820
- children: [
11821
- label,
11822
- required && /* @__PURE__ */ jsxRuntime.jsx(
11823
- material.Box,
11824
- {
11825
- component: "span",
11826
- sx: {
11827
- color: "error.main",
11828
- ml: 0.5
11829
- },
11830
- children: "*"
11831
- }
11832
- )
11833
- ]
11834
- }
11835
- ),
11836
- /* @__PURE__ */ jsxRuntime.jsx(
11837
- material.Autocomplete,
11838
- {
11839
- multiple,
11840
- id: `autocomplete-${name}`,
11841
- options,
11842
- value: selectedValues,
11843
- filterOptions,
11844
- onInputChange: handleInputChange,
11845
- onChange: handleChange,
11846
- onOpen,
11847
- onClose,
11848
- onBlur: handleBlur,
11849
- onFocus: handleFocus,
11850
- disableCloseOnSelect: multiple,
11851
- readOnly,
11852
- disabled,
11853
- isOptionEqualToValue: (option, value) => option.value === value.value,
11854
- getOptionLabel: (option) => typeof option === "string" ? option : option.label,
11855
- getOptionDisabled: (option) => !!option.disabled,
11856
- renderInput: externalRenderInput || defaultRenderInput,
11857
- renderOption: externalRenderOption || defaultRenderOption,
11858
- renderTags: externalRenderTags || defaultRenderTags,
11859
- renderGroup: externalRenderGroup,
11860
- ListboxProps: {
11861
- className: `app-searchable-multi-selector-listbox ${listboxClassName}`.trim(),
11862
- sx: {
11863
- "& .MuiAutocomplete-option": {
11864
- px: 2,
11865
- py: 1,
11866
- '&[aria-selected="true"]': {
11867
- backgroundColor: "action.selected",
11868
- "&.Mui-focused": {
11869
- backgroundColor: "action.hover"
11870
- }
11871
- },
11872
- "&.Mui-focused": {
11873
- backgroundColor: "action.hover"
11874
- }
11875
- },
11876
- ...Array.isArray(optionSx) ? optionSx : optionSx ? [optionSx] : [],
11877
- ...Array.isArray(listboxSx) ? listboxSx : listboxSx ? [listboxSx] : []
11878
- }
11879
- },
11880
- className: `app-searchable-multi-selector-autocomplete ${autocompleteClassName}`.trim(),
11881
- sx: [
11882
- {
11883
- "& .MuiAutocomplete-tag": {
11884
- margin: 0,
11885
- height: "auto"
11886
- },
11887
- "& .MuiAutocomplete-endAdornment": {
11888
- right: 8
11889
- }
11890
- },
11891
- ...Array.isArray(autocompleteSx) ? autocompleteSx : autocompleteSx ? [autocompleteSx] : []
11892
- ],
11893
- ...autocompleteProps,
11894
- ...otherProps
11895
- }
11896
- ),
11897
- (showHelperText || hasError) && /* @__PURE__ */ jsxRuntime.jsx(
11898
- HelperTextComponent,
11899
- {
11900
- error: hasError,
11901
- sx: [
11902
- {
11903
- mx: 0,
11904
- mt: 0.5,
11905
- ...hasError ? {
11906
- color: "error.main",
11907
- ...errorSx
11908
- } : {
11909
- color: "text.secondary",
11910
- ...helperTextSx
11911
- }
11912
- }
11913
- ],
11914
- className: `app-searchable-multi-selector-helper-text ${helperTextClassName} ${hasError ? "Mui-error" : ""}`.trim(),
11915
- ...helperTextProps,
11916
- children: hasError ? fieldError : helperText
11917
- }
11918
- ),
11919
- renderSelectedCount()
11920
- ]
11921
- }
11922
- )
11923
- }
11924
- );
11925
- }
11926
- );
11927
- AppSearchableMultiSelector.displayName = "AppSearchableMultiSelector";
11928
- var AppSearchableMultiSelector_default = AppSearchableMultiSelector;
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
11494
  var AppSelectInput = React4.forwardRef(
12030
11495
  ({
12031
11496
  name,
@@ -12049,10 +11514,10 @@ var AppSelectInput = React4.forwardRef(
12049
11514
  }, ref) => {
12050
11515
  const theme = material.useTheme();
12051
11516
  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));
11517
+ const fieldError = _17__default.default.get(errors, name);
11518
+ const isTouched = Boolean(_17__default.default.get(touched, name));
12054
11519
  const hasError = Boolean(fieldError) && isTouched;
12055
- const currentValue = _19__default.default.get(values, name);
11520
+ const currentValue = _17__default.default.get(values, name);
12056
11521
  const handleValueChange = (newValue) => {
12057
11522
  setFieldValue(name, newValue, true);
12058
11523
  if (externalOnChange) {
@@ -12080,10 +11545,7 @@ var AppSelectInput = React4.forwardRef(
12080
11545
  return options2;
12081
11546
  const inputValueLower = inputValue.toLowerCase();
12082
11547
  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
- }
11548
+ (option) => option.label.toLowerCase().includes(inputValueLower) || String(option.value).toLowerCase().includes(inputValueLower)
12087
11549
  );
12088
11550
  };
12089
11551
  return /* @__PURE__ */ jsxRuntime.jsx(material.Box, { ref, sx, children: /* @__PURE__ */ jsxRuntime.jsx(
@@ -12139,20 +11601,23 @@ var AppSelectInput = React4.forwardRef(
12139
11601
  }
12140
11602
  }
12141
11603
  ),
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
- ] })
11604
+ renderOption: (props, option) => {
11605
+ const { key, ...restProps } = props;
11606
+ return /* @__PURE__ */ jsxRuntime.jsxs("li", { ...restProps, children: [
11607
+ option.icon,
11608
+ /* @__PURE__ */ jsxRuntime.jsx(
11609
+ material.Typography,
11610
+ {
11611
+ variant: "body2",
11612
+ sx: {
11613
+ color: option.disabled ? "text.disabled" : "text.primary",
11614
+ ...option.textSx
11615
+ },
11616
+ children: option.label
11617
+ }
11618
+ )
11619
+ ] }, key);
11620
+ }
12156
11621
  }
12157
11622
  )
12158
11623
  }
@@ -12266,8 +11731,8 @@ var AppSimpleUploadFile = ({
12266
11731
  onError
12267
11732
  }) => {
12268
11733
  const { setFieldValue, values, errors, touched } = formik.useFormikContext();
12269
- const fieldValue = _19__default.default.get(values, name);
12270
- const fieldError = _19__default.default.get(touched, name) ? _19__default.default.get(errors, name) : void 0;
11734
+ const fieldValue = _17__default.default.get(values, name);
11735
+ const fieldError = _17__default.default.get(touched, name) ? _17__default.default.get(errors, name) : void 0;
12271
11736
  const handleChange = (event) => {
12272
11737
  const files = event.target.files;
12273
11738
  if (!files || files.length === 0)
@@ -12294,7 +11759,7 @@ var AppSimpleUploadFile = ({
12294
11759
  if (!fieldValue || index < 0 || index >= fieldValue.length)
12295
11760
  return;
12296
11761
  const fileToRemove = fieldValue[index];
12297
- const newFiles = fieldValue.filter((_20, i) => i !== index);
11762
+ const newFiles = fieldValue.filter((_18, i) => i !== index);
12298
11763
  setFieldValue(name, newFiles);
12299
11764
  onRemove == null ? void 0 : onRemove(fileToRemove);
12300
11765
  if (fileToRemove.preview) {
@@ -13846,12 +13311,12 @@ function Placeholder({ sx, ...other }) {
13846
13311
  var AppUploadFile = ({ name, ...rest }) => {
13847
13312
  var _a, _b, _c;
13848
13313
  const { errors, touched, setFieldValue, values } = formik.useFormikContext();
13849
- const fieldError = _19__default.default.get(errors, name);
13850
- const isTouched = _19__default.default.get(touched, name);
13851
- let val = _19__default.default.get(values, name);
13314
+ const fieldError = _17__default.default.get(errors, name);
13315
+ const isTouched = _17__default.default.get(touched, name);
13316
+ let val = _17__default.default.get(values, name);
13852
13317
  if (((_a = rest.multiple) != null ? _a : false) && typeof val === "string") {
13853
13318
  val = val ? [val] : [];
13854
- } else if (!((_b = rest.multiple) != null ? _b : false) && _19__default.default.isArray(val)) {
13319
+ } else if (!((_b = rest.multiple) != null ? _b : false) && _17__default.default.isArray(val)) {
13855
13320
  val = val[0];
13856
13321
  }
13857
13322
  ((_c = rest.multiple) != null ? _c : false) ? (val != null ? val : []).map((__) => (__ == null ? void 0 : __.file) ? __ == null ? void 0 : __.file : __) : val;
@@ -14020,8 +13485,6 @@ exports.AppPhoneNoInput = AppPhoneNoInput_default;
14020
13485
  exports.AppRadioGroup = AppRadioGroup_default;
14021
13486
  exports.AppRating = AppRating_default;
14022
13487
  exports.AppRichTextEditor = AppRichTextEditor_default;
14023
- exports.AppSearchableMultiSelector = AppSearchableMultiSelector_default;
14024
- exports.AppSearchableSelectInput = AppSearchableSelectInput;
14025
13488
  exports.AppSelectInput = AppSelectInput_default;
14026
13489
  exports.AppSimpleUploadFile = AppSimpleUploadFile_default;
14027
13490
  exports.AppSwitch = AppSwitch;